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

Method getCommonAttributesAtRange

src/trix/models/document.js:530–550  ·  view source on GitHub ↗
(range)

Source from the content-addressed store, hash-verified

528 }
529
530 getCommonAttributesAtRange(range) {
531 range = normalizeRange(range)
532 const [ startPosition ] = range
533 if (rangeIsCollapsed(range)) {
534 return this.getCommonAttributesAtPosition(startPosition)
535 } else {
536 const textAttributes = []
537 const blockAttributes = []
538
539 this.eachBlockAtRange(range, function(block, textRange) {
540 if (textRange[0] !== textRange[1]) {
541 textAttributes.push(block.text.getCommonAttributesAtRange(textRange))
542 return blockAttributes.push(attributesForBlock(block))
543 }
544 })
545
546 return Hash.fromCommonAttributesOfObjects(textAttributes)
547 .merge(Hash.fromCommonAttributesOfObjects(blockAttributes))
548 .toObject()
549 }
550 }
551
552 getCommonAttributesAtPosition(position) {
553 let key, value

Callers

nothing calls this directly

Calls 8

eachBlockAtRangeMethod · 0.95
normalizeRangeFunction · 0.90
rangeIsCollapsedFunction · 0.90
attributesForBlockFunction · 0.85
toObjectMethod · 0.45
mergeMethod · 0.45

Tested by

no test coverage detected