Found strange block wrapping behavior when using dispatch
and onmousedown
.
My task is to implement a “Hook” to wrap block elements and use the standard drag mechanics.
The main logic is to add a widget in the form of a button using the plugin in decorations
. When creating a button, I hang onmousedown
on it
drag_action_button.onmousedown = () => {
view.dispatch(view.state.tr.setSelection(NodeSelection.create(state.doc, pos)));
};
The logic itself works correctly, except for one case: If you try to drag the first line, it does not react
If you remove dispatch
and use a pre-allocated block for transfer, everything works correctly.
As an alternative, I wanted to use onmousemove
. In this case, the transfer works as it should, but visually, at the moment of transferring the same first line, it looks like it transfers the entire editor, although in the end everything transfers correctly
What is the reason for this and how can it be corrected?