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

Function findLineEdgePoint

packages/editor/src/plugin/editable.ts:742–766  ·  view source on GitHub ↗
(
    editor: Editor,
    { at, edge = 'start' }: { at?: Range; edge?: 'start' | 'end' } = {},
  )

Source from the content-addressed store, hash-verified

740 },
741
742 findLineEdgePoint(
743 editor: Editor,
744 { at, edge = 'start' }: { at?: Range; edge?: 'start' | 'end' } = {},
745 ): Point | null {
746 const { selection } = editor
747 if (!at && selection) at = selection
748 if (!at) return null
749 const isStart = edge === 'start'
750 const point = isStart ? Range.start(at) : Range.end(at)
751 const range = Editable.toDOMRange(editor, {
752 anchor: point,
753 focus: point,
754 })
755 range.collapse(isStart)
756 const rects = range.getClientRects()
757 const rect = rects[rects.length - 1]
758 const bottom = rect.top + rect.height / 2
759 const block = Editor.above(editor, {
760 at: point,
761 match: n => Editor.isBlock(editor, n),
762 })
763 if (!block) return null
764 const domBlock = Editable.toDOMNode(editor, block[0])
765 return Editable.findClosestPoint(editor, domBlock, isStart ? -99999 : 99999, bottom)
766 },
767
768 findNextLinePoint(editor: Editor, at?: Range): Point | null {
769 const { selection } = editor

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…