(options)
| 51 | } |
| 52 | |
| 53 | export const expandSelection = async (options) => { |
| 54 | await nextFrame() |
| 55 | |
| 56 | let direction, times |
| 57 | if (typeof options === "string") { |
| 58 | direction = options |
| 59 | } else { |
| 60 | ({ direction } = options) |
| 61 | times = options.times |
| 62 | } |
| 63 | |
| 64 | if (!times) times = 1 |
| 65 | |
| 66 | const expand = async () => { |
| 67 | await nextFrame() |
| 68 | |
| 69 | if (triggerEvent(document.activeElement, "keydown", { keyCode: keyCodes[direction], key: keys[direction], shiftKey: true })) { |
| 70 | getComposition().expandSelectionInDirection(direction === "left" ? "backward" : "forward") |
| 71 | } |
| 72 | |
| 73 | if (--times === 0) { |
| 74 | await nextFrame() |
| 75 | } else { |
| 76 | return await expand() |
| 77 | } |
| 78 | } |
| 79 | |
| 80 | return await expand() |
| 81 | } |
| 82 | |
| 83 | export const collapseSelection = async (direction) => { |
| 84 | const selection = rangy.getSelection() |
no test coverage detected
searching dependent graphs…