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

Method locationFromPosition

src/trix/models/document.js:696–704  ·  view source on GitHub ↗
(position)

Source from the content-addressed store, hash-verified

694 }
695
696 locationFromPosition(position) {
697 const location = this.blockList.findIndexAndOffsetAtPosition(Math.max(0, position))
698 if (location.index != null) {
699 return location
700 } else {
701 const blocks = this.getBlocks()
702 return { index: blocks.length - 1, offset: blocks[blocks.length - 1].getLength() }
703 }
704 }
705
706 positionFromLocation(location) {
707 return this.blockList.findPositionAtIndexAndOffset(location.index, location.offset)

Callers 15

insertDocumentAtRangeMethod · 0.95
mergeDocumentAtRangeMethod · 0.95
insertTextAtRangeMethod · 0.95
getBlockAtPositionMethod · 0.95
getTextAtPositionMethod · 0.95
getPieceAtPositionMethod · 0.95
eachBlockAtRangeMethod · 0.95

Calls 3

getBlocksMethod · 0.95
getLengthMethod · 0.45

Tested by

no test coverage detected