(editor: Editor, at: Location | null = editor.selection)
| 10 | } |
| 11 | |
| 12 | export const findGridOfEdges = (editor: Editor, at: Location | null = editor.selection) => { |
| 13 | const value: OperationGridValue = {} |
| 14 | if (Range.isRange(at) && Range.isExpanded(at)) { |
| 15 | const [anchor, focus] = Range.edges(at) |
| 16 | const [startCell] = Editor.nodes<GridCell>(editor, { |
| 17 | at: anchor.path, |
| 18 | match: n => editor.isGridCell(n), |
| 19 | }) |
| 20 | value.start = startCell |
| 21 | const [endCell] = Editor.nodes<GridCell>(editor, { |
| 22 | at: focus.path, |
| 23 | match: n => editor.isGridCell(n), |
| 24 | }) |
| 25 | value.end = endCell |
| 26 | if (startCell && endCell) { |
| 27 | if (Path.equals(startCell[1], endCell[1])) { |
| 28 | value.start = undefined |
| 29 | value.end = undefined |
| 30 | return value |
| 31 | } |
| 32 | const [, startPath] = startCell |
| 33 | const [, endPath] = endCell |
| 34 | const gridPath = Path.common(startPath, endPath) |
| 35 | const grid = Grid.above(editor, gridPath) |
| 36 | value.grid = grid |
| 37 | } |
| 38 | } |
| 39 | return value |
| 40 | } |
| 41 | |
| 42 | export const handleInserInGrid = (editor: Editor, at: Location | null = editor.selection) => { |
| 43 | const { grid, start, end } = findGridOfEdges(editor, at) |
no outgoing calls
no test coverage detected
searching dependent graphs…