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

Function getStoredPositionsAbsolute

packages/yjs-transform/src/position.ts:90–108  ·  view source on GitHub ↗
(sharedRoot: Y.XmlText)

Source from the content-addressed store, hash-verified

88}
89
90function getStoredPositionsAbsolute(sharedRoot: Y.XmlText) {
91 assertDocumentAttachment(sharedRoot)
92
93 return Object.fromEntries(
94 Object.entries(sharedRoot.getAttributes())
95 .filter(([key]) => key.startsWith(STORED_POSITION_PREFIX))
96 .map(
97 ([key, position]) =>
98 [
99 key.slice(STORED_POSITION_PREFIX.length),
100 Y.createAbsolutePositionFromRelativePosition(
101 Y.decodeRelativePosition(position),
102 sharedRoot.doc,
103 ),
104 ] as const,
105 )
106 .filter(([, position]) => position),
107 ) as Record<string, Y.AbsolutePosition>
108}
109
110export function removeStoredPosition(sharedRoot: Y.XmlText, key: string) {
111 sharedRoot.removeAttribute(STORED_POSITION_PREFIX + key)

Callers 1

Calls 1

assertDocumentAttachmentFunction · 0.90

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…