MCPcopy Create free account
hub / github.com/SplootCode/splootcode / onSelected

Method onSelected

packages/editor/src/components/insert_box.tsx:556–576  ·  view source on GitHub ↗
(suggestion: RenderedSuggestion, leftoverText = '')

Source from the content-addressed store, hash-verified

554 }
555
556 onSelected(suggestion: RenderedSuggestion, leftoverText = '') {
557 const { selection } = this.props
558 const node = suggestion.node.clone()
559 if (suggestion.hasOverrideLocation()) {
560 if (suggestion.wrapChildSetId) {
561 selection.wrapNode(
562 suggestion.overrideLocationChildSet,
563 suggestion.overrideLocationIndex,
564 node,
565 suggestion.wrapChildSetId
566 )
567 } else {
568 selection.insertNodeByChildSet(suggestion.overrideLocationChildSet, suggestion.overrideLocationIndex, node)
569 }
570 } else if (suggestion.wrapChildSetId) {
571 selection.wrapNode(suggestion.childSet, suggestion.index - 1, node, suggestion.wrapChildSetId)
572 } else {
573 selection.insertNodeByChildSet(suggestion.childSet, suggestion.index, node)
574 }
575 this.setState({ userInput: leftoverText })
576 }
577
578 // Event fired when the user clicks on a suggestion
579 onClickSuggestion = (suggestion: RenderedSuggestion) => {

Callers 2

InsertBoxClass · 0.95
handleEarlyInsertMethod · 0.95

Calls 4

hasOverrideLocationMethod · 0.80
wrapNodeMethod · 0.80
insertNodeByChildSetMethod · 0.80
cloneMethod · 0.45

Tested by

no test coverage detected