MCPcopy Create free account
hub / github.com/editablejs/editable / findGridOfEdges

Function findGridOfEdges

packages/models/src/transforms/utils.ts:12–40  ·  view source on GitHub ↗
(editor: Editor, at: Location | null = editor.selection)

Source from the content-addressed store, hash-verified

10}
11
12export 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
42export const handleInserInGrid = (editor: Editor, at: Location | null = editor.selection) => {
43 const { grid, start, end } = findGridOfEdges(editor, at)

Callers 2

_deleteFunction · 0.90
handleInserInGridFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…