-
When adding this to the editor:
And injecting things inside the editor based on what is in that paste function, it doesn't seem to trigger the embed functionality. I can trigger it by pasting the same code in the toolbar's version of an embed item, but it doesn't trigger if it gets placed in there manually when handling it in the DOM paste function above. I'm unsure if this is a bug or I'm doing it wrong. If you can point me in the right direction, happy to help fix it if it's a bug ... or would be really grateful if you can point out what I'm doing wrong. The paste handler has some of this code, to give you better context: const onPaste = (view: any, event: Event) => {
// ... do stuff here where we transform certain values and wrap them
// so we can pull them out later
const transaction = pasteView.state.tr
.insertText(
linkValue, // <-- !! the specially formatted thing, this won't trigger the embed once it's added to the editor
pasteView.state.selection.from,
pasteView.state.selection.to
);
// this works fine
if (value === PasteType.dismiss) {
transaction.addMark(
pasteView.state.selection.from,
pasteView.state.selection.to + pasteValue?.length || 0,
pasteView.state.schema.marks.link.create({ href: linkValue })
);
}
pasteView.dispatch(transaction);
// ... do other things...
}; I see here where the embed code is called, but unsure how to programmatically call this if necessary. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
I think it would help if you describe exactly what you're trying to achieve with your handler. By providing your own |
Beta Was this translation helpful? Give feedback.
I think it would help if you describe exactly what you're trying to achieve with your handler. By providing your own
onPaste
handler you're not going through the inbuilt paste handler for embeds…