I noticed this difference in behavior between a regular prosemirror NodeView, and one created by useNodeViews:
- For a vanilla
NodeView, an editor-attached handleClickOn fires, for a click within the NodeView, or elsewhere in the editor, as documented/expected
- For a
useNodeViews NodeView, a click within the NodeView does not fire, but other editor clicks do
This is also the case for handleDoubleClickOn and handleTripleClickOn.
I think this behavior should be consistent?
Vanilla implementation
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
>
useNodeViews implementation
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
I noticed this difference in behavior between a regular prosemirror
NodeView, and one created byuseNodeViews:NodeView, an editor-attachedhandleClickOnfires, for a click within theNodeView, or elsewhere in the editor, as documented/expecteduseNodeViewsNodeView, a click within theNodeViewdoes not fire, but other editor clicks doThis is also the case for
handleDoubleClickOnandhandleTripleClickOn.I think this behavior should be consistent?
Vanilla implementation
useNodeViewsimplementation