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