Greetings! I am using ProseMirror to build an editor. In the process, I am creating a custom node to support social embeds. Seek some advise from correct approach Here is the minimal code.
{
attrs: {
url: {
default: ""
}
},
content: "inline*",
group: "block",
atom: true,
selectable: false,
parseDOM: [
{
tag: this.name,
getAttrs: dom => {
return {
url: dom.getAttribute("url")
};
}
}
],
toDOM: node => ["embed", node.attrs, 0]
}
I added NodeView for node using VueJs and passed node
, getPos
, view
as props.
<template><div><div v-html="node.textContent"></div></div></template>
I made editor instance using following json
{
type: 'doc',
content: [
{
type: 'paragraph',
content: [{
type: 'text'
text: 'Test backspace'
}]
}
{
type: 'embed',
attrs: {
url: 'https://example.com",
},
content: [ {
type: 'text'
text: 'some html'
}]
} ,
]
}
Now when I try to delete embed node using backspace, editor loses focus. Thanks in Advance.