| 260 | * @function |
| 261 | **/ |
| 262 | const 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 |