Skip to content

Conversation

@milaiwi
Copy link
Collaborator

@milaiwi milaiwi commented Apr 27, 2025

Fixed a bug on pasting non-media content. Originally, would not paste content but now it does.

Copy link

@greptile-apps greptile-apps bot left a 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 BlockNoteEditor parameter to createMarkdownExtension in /src/lib/blocknote/core/BlockNoteExtensions.ts for proper node creation
  • Implemented markdown-to-blocks conversion in /src/lib/blocknote/core/extensions/Markdown/MarkdownExtension.ts for 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

Comment on lines 70 to +71
// @ts-ignore
createMarkdownExtension(),
createMarkdownExtension(opts.editor),
Copy link

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

Comment on lines +118 to +126
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)
})
Copy link

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

Comment on lines +122 to +123
// @ts-ignore
organizedBlocks,
Copy link

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

@milaiwi milaiwi merged commit 9b47fca into reorproject:main May 13, 2025
4 checks passed
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.

1 participant