-
Notifications
You must be signed in to change notification settings - Fork 516
Fix pasting #517
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 pasting #517
Conversation
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.
PR Summary
This PR fixes a critical paste functionality bug by implementing proper handling of non-media content through the Markdown extension, ensuring text content is correctly converted into editor blocks.
- Added
BlockNoteEditorparameter tocreateMarkdownExtensionin/src/lib/blocknote/core/BlockNoteExtensions.tsfor proper node creation - Implemented markdown-to-blocks conversion in
/src/lib/blocknote/core/extensions/Markdown/MarkdownExtension.tsfor non-video content - Added security check in paste handler to prevent code block injection when pasting into code blocks
- Fixed potential XSS vulnerability by properly sanitizing pasted HTML content before processing lists
2 file(s) reviewed, 3 comment(s)
Edit PR Review Bot Settings | Greptile
| // @ts-ignore | ||
| createMarkdownExtension(), | ||
| createMarkdownExtension(opts.editor), |
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.
style: Remove @ts-ignore by properly typing the createMarkdownExtension function parameters
| bnEditor.markdownToBlocks(pastedText).then((organizedBlocks: any) => { | ||
| const blockInfo = getBlockInfoFromPos(state.doc, selection.from) | ||
| bnEditor.replaceBlocks( | ||
| [blockInfo.node.attrs.id], | ||
| // @ts-ignore | ||
| organizedBlocks, | ||
| ) | ||
| BlockUtils.setGroupTypes(bnEditor._tiptapEditor, organizedBlocks) | ||
| }) |
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.
logic: Potential race condition - state.doc and selection might change before the async markdownToBlocks promise resolves
| // @ts-ignore | ||
| organizedBlocks, |
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.
style: Type safety issue with @ts-ignore - organizedBlocks should be properly typed
Fixed a bug on pasting non-media content. Originally, would not paste content but now it does.