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

Method insertTextAtRange

src/trix/models/document.js:126–137  ·  view source on GitHub ↗
(text, range)

Source from the content-addressed store, hash-verified

124 }
125
126 insertTextAtRange(text, range) {
127 range = normalizeRange(range)
128 const [ startPosition ] = range
129 const { index, offset } = this.locationFromPosition(startPosition)
130
131 const document = this.removeTextAtRange(range)
132 return new this.constructor(
133 document.blockList.editObjectAtIndex(index, (block) =>
134 block.copyWithText(block.text.insertTextAtPosition(text, offset))
135 )
136 )
137 }
138
139 removeTextAtRange(range) {
140 let blocks

Callers 4

mergeDocumentAtRangeMethod · 0.95
insertTextMethod · 0.80
trix.jsFile · 0.80

Calls 6

locationFromPositionMethod · 0.95
removeTextAtRangeMethod · 0.95
normalizeRangeFunction · 0.90
editObjectAtIndexMethod · 0.80
insertTextAtPositionMethod · 0.80
copyWithTextMethod · 0.45

Tested by

no test coverage detected