MCPcopy
hub / github.com/yjs/yjs / insertAttributes

Function insertAttributes

src/ytype.js:262–280  ·  view source on GitHub ↗
(transaction, parent, currPos, attributes)

Source from the content-addressed store, hash-verified

260 * @function
261 **/
262const insertAttributes = (transaction, parent, currPos, attributes) => {
263 const doc = transaction.doc
264 const ownClientId = doc.clientID
265 const negatedAttributes = new Map()
266 // insert format-start items
267 for (const key in attributes) {
268 const val = attributes[key]
269 const currentVal = currPos.currentAttributes.get(key) ?? null
270 if (!equalAttrs(currentVal, val)) {
271 // save negated attribute (set null if currentVal undefined)
272 negatedAttributes.set(key, currentVal)
273 const { left, right } = currPos
274 currPos.right = new Item(createID(ownClientId, getState(doc.store, ownClientId)), left, left && left.lastId, right, right && right.id, parent, null, new ContentFormat(key, val))
275 currPos.right.integrate(transaction, 0)
276 currPos.forward()
277 }
278 }
279 return negatedAttributes
280}
281
282/**
283 * @param {Transaction} transaction

Callers 2

formatTextMethod · 0.85
insertContentFunction · 0.85

Calls 6

createIDFunction · 0.90
getStateFunction · 0.90
equalAttrsFunction · 0.85
forwardMethod · 0.80
getMethod · 0.45
integrateMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…