(editor: HTMLElement, visitor: (el: Node) => 'stop' | undefined)
| 479 | } |
| 480 | |
| 481 | function visit(editor: HTMLElement, visitor: (el: Node) => 'stop' | undefined) { |
| 482 | const queue: Node[] = [] |
| 483 | if (editor.firstChild) queue.push(editor.firstChild) |
| 484 | let el = queue.pop() |
| 485 | while (el) { |
| 486 | if (visitor(el) === 'stop') break |
| 487 | if (el.nextSibling) queue.push(el.nextSibling) |
| 488 | if (el.firstChild) queue.push(el.firstChild) |
| 489 | el = queue.pop() |
| 490 | } |
| 491 | } |
| 492 | |
| 493 | function isCtrl(event: KeyboardEvent) { |
| 494 | return event.metaKey || event.ctrlKey |