()
| 219 | export * from 'slate' |
| 220 | |
| 221 | export const createEditor = () => { |
| 222 | const baseEditor = createSlateEditor() |
| 223 | |
| 224 | const { apply, onChange } = baseEditor |
| 225 | |
| 226 | baseEditor.apply = (op: Operation) => { |
| 227 | EDITOR_ACTIVE_MARKS.delete(baseEditor) |
| 228 | EDITOR_ACTIVE_ELEMENTS.delete(baseEditor) |
| 229 | |
| 230 | apply(op) |
| 231 | } |
| 232 | |
| 233 | baseEditor.onChange = () => { |
| 234 | EDITOR_ACTIVE_MARKS.delete(baseEditor) |
| 235 | EDITOR_ACTIVE_ELEMENTS.delete(baseEditor) |
| 236 | |
| 237 | onChange() |
| 238 | } |
| 239 | |
| 240 | baseEditor.isSolidVoid = (value: Element) => true |
| 241 | |
| 242 | baseEditor.isGrid = (value: any): value is Grid => false |
| 243 | |
| 244 | baseEditor.isGridRow = (value: any): value is GridRow => false |
| 245 | |
| 246 | baseEditor.isGridCell = (value: any): value is GridCell => false |
| 247 | |
| 248 | baseEditor.isList = (value: any): value is List => false |
| 249 | |
| 250 | baseEditor.normalizeSelection = (fn, at) => { |
| 251 | const selection = at ? Editor.range(baseEditor, at) : baseEditor.selection |
| 252 | if (!selection) return fn(selection) |
| 253 | const grid = Grid.above(baseEditor, selection) |
| 254 | if (grid) { |
| 255 | const sel = Grid.getSelection(baseEditor, grid) |
| 256 | if (sel) { |
| 257 | let { start, end } = sel |
| 258 | const [startRow, startCol] = start |
| 259 | const [endRow, endCol] = end |
| 260 | |
| 261 | const rowCount = endRow - startRow |
| 262 | const colCount = endCol - startCol |
| 263 | |
| 264 | if (rowCount > 0 || colCount > 0) { |
| 265 | const [, path] = grid |
| 266 | const edgesSelection = Grid.edges(baseEditor, grid, sel) |
| 267 | const { start: edgeStart, end: edgeEnd } = edgesSelection |
| 268 | const cells = Grid.cells(baseEditor, grid, { |
| 269 | startRow: edgeStart[0], |
| 270 | startCol: edgeStart[1], |
| 271 | endRow: edgeEnd[0], |
| 272 | endCol: edgeEnd[1], |
| 273 | }) |
| 274 | const rangeRef = Editor.rangeRef(baseEditor, selection) |
| 275 | for (const [cell, row, col] of cells) { |
| 276 | if (!cell) break |
| 277 | if (!cell.span) { |
| 278 | const range = Editor.range(baseEditor, path.concat([row, col])) |
no test coverage detected