MCPcopy Index your code
hub / github.com/basecamp/trix / decreaseListLevel

Method decreaseListLevel

src/trix/models/composition.js:440–458  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

438 }
439
440 decreaseListLevel() {
441 let [ startPosition ] = Array.from(this.getSelectedRange())
442 const { index } = this.document.locationFromPosition(startPosition)
443 let endIndex = index
444 const attributeLevel = this.getBlock().getAttributeLevel()
445
446 let block = this.document.getBlockAtIndex(endIndex + 1)
447 while (block) {
448 if (!block.isListItem() || block.getAttributeLevel() <= attributeLevel) {
449 break
450 }
451 endIndex++
452 block = this.document.getBlockAtIndex(endIndex + 1)
453 }
454
455 startPosition = this.document.positionFromLocation({ index, offset: 0 })
456 const endPosition = this.document.positionFromLocation({ index: endIndex, offset: 0 })
457 return this.setDocument(this.document.removeLastListAttributeAtRange([ startPosition, endPosition ]))
458 }
459
460 updateCurrentAttributes() {
461 const selectedRange = this.getSelectedRange({ ignoreLock: true })

Callers 4

insertLineBreakMethod · 0.95
deleteInDirectionMethod · 0.95
trix.jsFile · 0.80
ifFunction · 0.80

Calls 9

getSelectedRangeMethod · 0.95
getBlockMethod · 0.95
setDocumentMethod · 0.95
locationFromPositionMethod · 0.80
getBlockAtIndexMethod · 0.80
positionFromLocationMethod · 0.80
getAttributeLevelMethod · 0.45
isListItemMethod · 0.45

Tested by

no test coverage detected