MCPcopy
hub / github.com/basecamp/trix / expandSelection

Function expandSelection

src/test/test_helpers/selection_helpers.js:53–81  ·  view source on GitHub ↗
(options)

Source from the content-addressed store, hash-verified

51}
52
53export 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
83export const collapseSelection = async (direction) => {
84 const selection = rangy.getSelection()

Callers 6

undo_test.jsFile · 0.90
pasting_test.jsFile · 0.90

Calls 2

nextFrameFunction · 0.90
expandFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…