Skip to content
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

Closed
wants to merge 4 commits into from

Conversation

wulfharth7
Copy link
Contributor

@wulfharth7 wulfharth7 commented Nov 5, 2023

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.

image (used the library to test)
image (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.

@Mr-Destructive
Copy link

This needs to be merged, otherwise, there is no way to obtain text from a block.

Copy link
Owner

@jomei jomei left a 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
Copy link
Owner

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

Copy link
Contributor Author

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.

@wulfharth7
Copy link
Contributor Author

wulfharth7 commented Feb 14, 2024

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 {
Copy link
Owner

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(..)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@wulfharth7 wulfharth7 closed this Feb 14, 2024
@wulfharth7
Copy link
Contributor Author

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

@jomei
Copy link
Owner

jomei commented Feb 14, 2024

@wulfharth7 don't worry about the history, I'll squash before merge anyway

@wulfharth7
Copy link
Contributor Author

@jomei yeah sure, I didn't know that you could do that. I opened a new PR for you to review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants