Skip to content

fix: node conversion#800

Merged
matthewlipski merged 8 commits intoTypeCellOS:mainfrom
jkcs:fix/block-conver
Jun 6, 2024
Merged

fix: node conversion#800
matthewlipski merged 8 commits intoTypeCellOS:mainfrom
jkcs:fix/block-conver

Conversation

@jkcs
Copy link
Contributor

@jkcs jkcs commented Jun 4, 2024

close #742
/claim #742

@vercel
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

@vercel
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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cannot have \n in custom block content.

3 participants