Skip to content

handleClickOn (and associated handlers) don’t fire for node views #99

Description

@steobrien

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions