Open steobrien opened 9 months ago
I noticed this difference in behavior between a regular prosemirror NodeView, and one created by useNodeViews:
NodeView
useNodeViews
handleClickOn
This is also the case for handleDoubleClickOn and handleTripleClickOn.
handleDoubleClickOn
handleTripleClickOn
I think this behavior should be consistent?
class Pill { constructor(node) { this.dom = document.createElement("div"); this.dom.innerText = node.attrs.text; } } // in component <ProseMirror nodeViews={{ pill(node) { return new Pill(node); }, }} // other editor props >
function Pill({ node }) { return ( <span>{node.attrs.text}</span> ); } const reactNodeViews = { pill: () => { const dom = document.createElement("div"); dom.style.display = "contents"; return { component: Pill, dom, }; }, }; // passed to <ProseMirror> with `useNodeViews` as per README example
Interestingly, if I replace <span>{node.attrs.text}</span> with an unwrapped <>{node.attrs.text}</>, the event does propagate as expected.
<span>{node.attrs.text}</span>
<>{node.attrs.text}</>
I noticed this difference in behavior between a regular prosemirror
NodeView
, and one created byuseNodeViews
:NodeView
, an editor-attachedhandleClickOn
fires, for a click within theNodeView
, or elsewhere in the editor, as documented/expecteduseNodeViews
NodeView
, a click within theNodeView
does not fire, but other editor clicks doThis is also the case for
handleDoubleClickOn
andhandleTripleClickOn
.I think this behavior should be consistent?
Vanilla implementation
useNodeViews
implementation