MCPcopy
hub / github.com/basecamp/trix / applyBlockAttributeAtRange

Method applyBlockAttributeAtRange

src/trix/models/document.js:306–326  ·  view source on GitHub ↗
(attributeName, value, range)

Source from the content-addressed store, hash-verified

304 }
305
306 applyBlockAttributeAtRange(attributeName, value, range) {
307 const expanded = this.expandRangeToLineBreaksAndSplitBlocks(range)
308 let document = expanded.document
309 range = expanded.range
310 const blockConfig = getBlockConfig(attributeName)
311
312 if (blockConfig.listAttribute) {
313 document = document.removeLastListAttributeAtRange(range, { exceptAttributeName: attributeName })
314 const converted = document.convertLineBreaksToBlockBreaksInRange(range)
315 document = converted.document
316 range = converted.range
317 } else if (blockConfig.exclusive) {
318 document = document.removeBlockAttributesAtRange(range)
319 } else if (blockConfig.terminal) {
320 document = document.removeLastTerminalAttributeAtRange(range)
321 } else {
322 document = document.consolidateBlocksAtRange(range)
323 }
324
325 return document.addAttributeAtRange(attributeName, value, range)
326 }
327
328 removeLastListAttributeAtRange(range, options = {}) {
329 let { blockList } = this

Callers 4

applyBlockAttributeMethod · 0.80
setBlockAttributeMethod · 0.80
trix.jsFile · 0.80
applyBlockAttributeMethod · 0.80

Tested by

no test coverage detected