Override "Ctrl/Cmd+A" to enable input-like behaviour

I built a node view that resembles a form. The elements of the form are node views with contenteditable="false" and the actual input are the contentDOM of these node views with contenteditable="true".

I am trying to replicate the behaviour of Ctrl/Cmd+A, ie selecting the entire written content of the input element or the inline* content of contentDOM.

I tried binding the command in the keymap like so:

if ((type = schema.nodes.custom_node)) {
    bind("Mod-a", (state, dispatch, view) => {
      const { $from } = state.selection;
      const node = $from.node();

      if (node.type === type) {
            TextSelection.create(state.doc, $from.start(), $from.start() + node.nodeSize)
        return true;

This does not work though. What irritates me is that after the second time of hitting Cmd+A, the $from object is not updated anymore, no matter where I set the caret.

Interestingly, creating a NodeSelection works but only once after reload.

Thank you for your help.

That kind of structure is not supported by ProseMirror – creating non-editable wrappers around editable nodes will cause those nodes to become their own focusable element, which means that the editor won’t treat them as part of its content.

That’s really good to know. Thank you for ending my odyssey. If I turn it off, Mod-A works as expected.