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

fix: node conversion #800

Merged
merged 8 commits into from
Jun 6, 2024
Merged

Conversation

jkcs
Copy link
Contributor

@jkcs jkcs commented Jun 4, 2024

close #742
/claim #742

Copy link

vercel bot commented Jun 4, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
blocknote ✅ Ready (Inspect) Visit Preview Jun 6, 2024 8:40pm
blocknote-website ✅ Ready (Inspect) Visit Preview Jun 6, 2024 8:40pm

Copy link

vercel bot commented Jun 4, 2024

@jkcs is attempting to deploy a commit to the TypeCell Team on Vercel.

A member of the Team first needs to authorize it.

@jkcs
Copy link
Contributor Author

jkcs commented Jun 4, 2024

if (typeof block.content === "string") {
// Adds a single text node with no marks to the content.
content = [state.schema.text(block.content)];
} else if (Array.isArray(block.content)) {

It seems like there is the same issue here?

@YousefED
Copy link
Collaborator

YousefED commented Jun 4, 2024

Thanks @jkcs. Your solution looks great, I think you've found the right place to fix it.

if (typeof block.content === "string") {
// Adds a single text node with no marks to the content.
content = [state.schema.text(block.content)];
} else if (Array.isArray(block.content)) {

It seems like there is the same issue here?

Great find! I think you're right. Could you fix this as well and create unit tests for both of them? I can double the bounty for that

@jkcs
Copy link
Contributor Author

jkcs commented Jun 4, 2024

@YousefED Currently there seems to be no unit test for BNUpdateBlock. How can I add it?

@YousefED
Copy link
Collaborator

YousefED commented Jun 5, 2024

@jkcs the updateBlock function in https://github.com/TypeCellOS/BlockNote/blob/4a197733e46cf2d53b888e0de5db5a82792ae796/packages/core/src/api/blockManipulation/blockManipulation.test.ts indirectly call BNUpdateBlock. You can add the test there!

Can you also confirm that the test wasn't working before your fix, but now is? (to make sure the tests really work)?

@jkcs
Copy link
Contributor Author

jkcs commented Jun 5, 2024

@YousefED Thank you for providing more information. I just tried adding tests in blockManipulation.test.ts and found that the update tests for BlockContainer.ts are not effective. The output of typeof block.content === "string" consistently shows the editor.document. I believe this test does not verify this point correctly. In the view, it should be converted to <br>.

@jkcs
Copy link
Contributor Author

jkcs commented Jun 5, 2024

Can you also confirm that the test wasn't working before your fix, but now is? (to make sure the tests really work)?

I confirmed through snapshots that it was invalid before the fix and okay after the fix.

@YousefED
Copy link
Collaborator

YousefED commented Jun 5, 2024

@YousefED Thank you for providing more information. I just tried adding tests in blockManipulation.test.ts and found that the update tests for BlockContainer.ts are not effective. The output of typeof block.content === "string" consistently shows the editor.document. I believe this test does not verify this point correctly. In the view, it should be converted to <br>.

I don't understand what you mean with typeof block.content === "string" consistently shows the editor.document, can you explain?

@jkcs
Copy link
Contributor Author

jkcs commented Jun 6, 2024

@YousefED Tests have been added and are ready for review

@YousefED YousefED requested a review from matthewlipski June 6, 2024 07:45
@YousefED
Copy link
Collaborator

YousefED commented Jun 6, 2024

Great!

After that, @matthewlipski can you do a final review and merge if ok?

@jkcs
Copy link
Contributor Author

jkcs commented Jun 6, 2024

done

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

Successfully merging this pull request may close these issues.

Cannot have \n in custom block content.
3 participants