-
Notifications
You must be signed in to change notification settings - Fork 81
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Getting Rich Text from various blocks #167
Conversation
This needs to be merged, otherwise, there is no way to obtain text from a block. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi! Sorry for the delayed response Т__Т.
Please, check out suggestion below
block.go
Outdated
@@ -218,6 +218,7 @@ type Block interface { | |||
GetHasChildren() bool | |||
GetArchived() bool | |||
GetParent() *Parent | |||
GetRichText() string |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's rename GetRichText
to GetRichTextString
, because this function returns string
instead of notionapi.RichText
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Its okay. Sure, I'm updating the PR and merging again.
I've done the renamings and calling them properly. It's ready to go 👌 The first commit failed because I forgot to call the proper function, I fixed it immediately. If you dont want this in your commit history, I can create a new PR with a better commit history. It's up to you. |
block.go
Outdated
@@ -296,6 +297,98 @@ func (b BasicBlock) GetParent() *Parent { | |||
return b.Parent | |||
} | |||
|
|||
func ConcatenateRichTextString(richtext []RichText) string { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this func should be private
concatenateRichTextString(..)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
The commit history has been so tangled up. I'm creating a new PR with a clean history. The last commit failed anyways. I kinda rush all the time with these PRs hence the errors. Fixing and opening it back again. :D |
@wulfharth7 don't worry about the history, I'll squash before merge anyway |
@jomei yeah sure, I didn't know that you could do that. I opened a new PR for you to review. |
As the issue #165 has mentioned, getting rich text is really messy from different blocks. He has suggested creating a new interface but I dont think it was necessary, while we can use the "Block" interface already.
(used the library to test)
(result)
Basically, you can get the rich texts immediately with just one function now instead of calling lots of switch cases. It still has room to be improved, im open for reviews and so on.
I tried to grasp as much as I can from the codebase as knowledge, but I may probably have missed some parts, so we can work on them if there are loopholes after you review my code.
I've destroyed the secret token so the screenshot is safe. fyi.
Waiting for an answer, thanks.