Make right click on a cellselection area work as expect

Reproduce step

  1. create a table
  2. add the right click listener
  3. make a cell selection(like press the mouse from first cell to second cell to select the first and the second cell)
  4. right click on the first cell

result: the cell selection is disappeared, and a text selection is be set in the first cell, just like left click in there.

EXPECT: the cell selection is not disappeared.

Yes, I think this is a feature by design, becase i guess that when mouseup event trigger from the second cell, the window selection is be set to the second cell, the cell selection just a "look like be selected’. But is there a solution to make the cell selection work as EXPECT? here is the gif below: cell-selection

I added a mouseDownHandler to the handleDOMEvents.

const onMouseDownHandler = (view: EditorView, event: MouseEvent) => {
    // If the mousedown event is a right click
    if (event.button === 2) {
        const { target } = event;
        if (target instanceof Node) {
           const $targetPos = view.state.doc.resolve(view.posAtDOM(target, 0));
           if (!view.state.selection.empty && isPositionWithinSelectionRange(view, $targetPos)) {
               return true;
    return false;