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

Method constructor

src/trix/models/line_break_insertion.js:2–16  ·  view source on GitHub ↗
(composition)

Source from the content-addressed store, hash-verified

1export default class LineBreakInsertion {
2 constructor(composition) {
3 this.composition = composition
4 this.document = this.composition.document
5 const selectedRange = this.composition.getSelectedRange()
6 this.startPosition = selectedRange[0]
7 this.endPosition = selectedRange[1]
8
9 this.startLocation = this.document.locationFromPosition(this.startPosition)
10 this.endLocation = this.document.locationFromPosition(this.endPosition)
11
12 this.block = this.document.getBlockAtIndex(this.endLocation.index)
13 this.breaksOnReturn = this.block.breaksOnReturn()
14 this.previousCharacter = this.block.text.getStringAtPosition(this.endLocation.offset - 1)
15 this.nextCharacter = this.block.text.getStringAtPosition(this.endLocation.offset)
16 }
17
18 shouldInsertBlockBreak() {
19 if (this.block.hasAttributes() && this.block.isListItem() && !this.block.isEmpty()) {

Callers

nothing calls this directly

Calls 5

locationFromPositionMethod · 0.80
getBlockAtIndexMethod · 0.80
getStringAtPositionMethod · 0.80
getSelectedRangeMethod · 0.45
breaksOnReturnMethod · 0.45

Tested by

no test coverage detected