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

Function getAbsolutePositionsInYText

packages/yjs-transform/src/position.ts:144–168  ·  view source on GitHub ↗
(
  absolutePositions: Record<string, Y.AbsolutePosition>,
  yText: Y.XmlText,
  parentPath = '',
)

Source from the content-addressed store, hash-verified

142}
143
144function getAbsolutePositionsInYText(
145 absolutePositions: Record<string, Y.AbsolutePosition>,
146 yText: Y.XmlText,
147 parentPath = '',
148): Record<string, Record<string, Y.AbsolutePosition>> {
149 const positions = {
150 [parentPath]: getAbsolutePositionsInTextRange(absolutePositions, yText),
151 }
152
153 const insertDelta = yTextToInsertDelta(yText)
154 insertDelta.forEach(({ insert }, i) => {
155 if (insert instanceof Y.XmlText) {
156 Object.assign(
157 positions,
158 getAbsolutePositionsInYText(
159 absolutePositions,
160 insert,
161 parentPath ? `${parentPath}.${i}` : i.toString(),
162 ),
163 )
164 }
165 })
166
167 return positions
168}
169
170export function getStoredPositionsInDeltaAbsolute(
171 sharedRoot: Y.XmlText,

Callers 1

Calls 2

yTextToInsertDeltaFunction · 0.90

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…