MCPcopy
hub / github.com/yjs/yjs / insertNegatedAttributes

Function insertNegatedAttributes

src/ytype.js:188–213  ·  view source on GitHub ↗
(transaction, parent, currPos, negatedAttributes)

Source from the content-addressed store, hash-verified

186 * @function
187 */
188const insertNegatedAttributes = (transaction, parent, currPos, negatedAttributes) => {
189 // check if we really need to remove attributes
190 while (
191 currPos.right !== null && (
192 (currPos.right.deleted && (currPos.am === noAttributionsManager || currPos.am.contentLength(currPos.right) === 0)) || (
193 currPos.right.content.constructor === ContentFormat &&
194 equalAttrs(negatedAttributes.get(/** @type {ContentFormat} */ (currPos.right.content).key), /** @type {ContentFormat} */ (currPos.right.content).value)
195 )
196 )
197 ) {
198 if (!currPos.right.deleted) {
199 negatedAttributes.delete(/** @type {ContentFormat} */ (currPos.right.content).key)
200 }
201 currPos.forward()
202 }
203 const doc = transaction.doc
204 const ownClientId = doc.clientID
205 negatedAttributes.forEach((val, key) => {
206 const left = currPos.left
207 const right = currPos.right
208 const nextFormat = new Item(createID(ownClientId, getState(doc.store, ownClientId)), left, left && left.lastId, right, right && right.id, parent, null, new ContentFormat(key, val))
209 nextFormat.integrate(transaction, 0)
210 currPos.right = nextFormat
211 currPos.forward()
212 })
213}
214
215/**
216 * @param {Map<string,any>} currentAttributes

Callers 2

formatTextMethod · 0.85
insertContentFunction · 0.85

Calls 9

integrateMethod · 0.95
createIDFunction · 0.90
getStateFunction · 0.90
equalAttrsFunction · 0.85
forwardMethod · 0.80
contentLengthMethod · 0.45
getMethod · 0.45
deleteMethod · 0.45
forEachMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…