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

Method render

packages/editor/src/components/insert_box.tsx:233–325  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

231 }
232
233 render() {
234 const { userInput, autoWidth, filteredSuggestions, activeSuggestion } = this.state
235 const { selection, insertBoxData } = this.props
236 const isInserting = selection.state === SelectionState.Inserting && !this.props.hidden
237
238 let suggestionsListComponent: JSX.Element
239 if (selection.state === SelectionState.Inserting) {
240 if (filteredSuggestions.length) {
241 suggestionsListComponent = (
242 <ul className="autocomplete-suggestions" ref={this.suggestionsRef}>
243 {filteredSuggestions.map((suggestion, index) => {
244 let className = ''
245
246 // Flag the active suggestion with a class
247 if (index === activeSuggestion) {
248 className = 'autocomplete-suggestion-active'
249 }
250
251 if (!suggestion.valid) {
252 className += ' invalid'
253 }
254
255 return (
256 <li
257 className={className}
258 key={suggestion.key}
259 onClick={this.onClickSuggestion(suggestion)}
260 tabIndex={-1}
261 >
262 <svg
263 className="autocomplete-inline-svg"
264 height={suggestion.nodeBlock.rowHeight}
265 width={suggestion.nodeBlock.rowWidth + 2}
266 >
267 <g
268 transform={
269 suggestion.nodeBlock.marginTop !== 0
270 ? `translate(0 ${-suggestion.nodeBlock.marginTop + suggestion.nodeBlock.beforeStackHeight})`
271 : ''
272 }
273 >
274 <EditorNodeBlock block={suggestion.nodeBlock} selectionState={NodeSelectionState.UNSELECTED} />
275 </g>
276 </svg>
277 <span className="autocomplete-description">{suggestion.description}</span>
278 </li>
279 )
280 })}
281 </ul>
282 )
283 } else {
284 suggestionsListComponent = null
285 }
286 }
287
288 const { editorX, editorY } = this.props
289 const { x, y } = insertBoxData
290 let positionStyles: React.CSSProperties

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected