MCPcopy Create free account
hub / github.com/editablejs/editable / findLineKey

Function findLineKey

packages/editor/src/utils/selection.ts:42–57  ·  view source on GitHub ↗
(rect: DOMRect)

Source from the content-addressed store, hash-verified

40 * @param rect
41 */
42 const findLineKey = (rect: DOMRect) => {
43 for (const lineKey of lineKeys) {
44 const { right } = lineKey
45 const previousRects = lines.get(lineKey)
46 const lastRect = previousRects
47 ? previousRects
48 .concat()
49 .reverse()
50 .find(p => p.width > 0) ?? previousRects[previousRects.length - 1]
51 : null
52 if (isRectInLine(rect, lineKey) && rect.left <= (lastRect ? lastRect.right : right) + 1) {
53 return lineKey
54 }
55 }
56 return null
57 }
58
59 // Loop through each rectangle and find its line
60 for (let r = 0; r < rects.length; r++) {

Callers 1

splitRectsIntoLinesFunction · 0.85

Calls 2

isRectInLineFunction · 0.85
getMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…