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) {
dispatch(
state.tr.setSelection(
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.