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

Method insertHTML

src/trix/models/composition.js:129–140  ·  view source on GitHub ↗
(html)

Source from the content-addressed store, hash-verified

127 }
128
129 insertHTML(html) {
130 const document = HTMLParser.parse(html, { purifyOptions: { SAFE_FOR_XML: true } }).getDocument()
131 const selectedRange = this.getSelectedRange()
132
133 this.setDocument(this.document.mergeDocumentAtRange(document, selectedRange))
134
135 const startPosition = selectedRange[0]
136 const endPosition = startPosition + document.getLength() - 1
137
138 this.setSelection(endPosition)
139 return this.notifyDelegateOfInsertionAtRange([ startPosition, endPosition ])
140 }
141
142 replaceHTML(html) {
143 const document = HTMLParser.parse(html).getDocument().copyUsingObjectsFromDocument(this.document)

Callers

nothing calls this directly

Calls 8

getSelectedRangeMethod · 0.95
setDocumentMethod · 0.95
setSelectionMethod · 0.95
mergeDocumentAtRangeMethod · 0.80
getDocumentMethod · 0.45
parseMethod · 0.45
getLengthMethod · 0.45

Tested by

no test coverage detected