y-prosemirror
y-prosemirror copied to clipboard
Feature: need absolutePositionToRelativePosition method support CellSelection of Prosemirror-tables
Is your feature request related to a problem? absolutePositionToRelativePosition and relativePositionToAbsolutePosition calculate anchor and head inaccurately when selection is CellSelection of prosemirror-tables
Describe the solution you'd like when editor current selection is instance of CellSelection of table, getRelativeSelection and restoreRelativeSelection can restore the cellSelection correctly.
Additional context
the problem not comes from the source code : textSelection.create(xxx), cus I have changed that by telling the type of last selection, the code is as blow:
I found that the anchor and head is not correct at all when selection is instance of CellSelection, seems absolutePositionToRelativePosition not get correct relativePosition.. however i do not have a clue how to modify the method of absolutePositionToRelativePosition..... : (
Hi @zlv-thisF Can you please give me steps to reproduce the problem?
E.g.
- set cursor location at x
- remote cursor is not rendering as expected (if that is the case)
Better yet, show me a broken demo application.
I need specific input and the expected outcome. "It is inaccurate" doesn't help me to find the problem.
@dmonad I have created a demo here: https://codesandbox.io/s/relaxed-herschel-el656?file=/src/App.js https://el656.csb.app/
The demo above , editor's table menu can create a table with 3 columns and 2 row, when user1 select all fist columns as CellSelection, any operation from user2 will break the user1's selection .
Here is another demo that modified the source code from "tr.setSelection(TextSelection.create)" to "CellSelection" in restorePosFromRelativeToAbsolute
https://codesandbox.io/s/sweet-northcutt-xvl51?file=/src/ySync.js:6913-6921 https://xvl51.csb.app/
This demo can reproduce the inaccurate restored head and anchor when origin selection is CellSelection.
I commented where i had modified with "// MODIFIED" in ySync.js