| 35 | |
| 36 | @observer |
| 37 | export class Editor extends React.Component<EditorProps, EditorState> { |
| 38 | private editorSvgRef: React.RefObject<SVGSVGElement> |
| 39 | private editorColumnRef: React.RefObject<HTMLDivElement> |
| 40 | |
| 41 | state = { |
| 42 | visibleView: 'tray' as EditorSideMenuView, |
| 43 | } |
| 44 | |
| 45 | constructor(props: EditorProps) { |
| 46 | super(props) |
| 47 | this.editorSvgRef = React.createRef() |
| 48 | this.editorColumnRef = React.createRef() |
| 49 | } |
| 50 | |
| 51 | render() { |
| 52 | const { block, selection, banner } = this.props |
| 53 | let fileBody = null |
| 54 | |
| 55 | fileBody = block.renderedChildSets['body'] |
| 56 | |
| 57 | const height = block.rowHeight + block.indentedBlockHeight |
| 58 | let insertBox = null |
| 59 | let editBox = null |
| 60 | if (selection.isCursor() && selection.insertBox !== null) { |
| 61 | insertBox = ( |
| 62 | <InsertBox |
| 63 | hidden={selection.isHidden} |
| 64 | editorX={0} |
| 65 | editorY={0} |
| 66 | selection={selection} |
| 67 | cursorPosition={selection.cursor} |
| 68 | insertBoxData={selection.insertBox} |
| 69 | /> |
| 70 | ) |
| 71 | } else if (selection.isEditingSingleNode()) { |
| 72 | editBox = <EditBox editorX={1} editorY={1} selection={selection} editBoxData={selection.editBox} /> |
| 73 | } |
| 74 | return ( |
| 75 | <React.Fragment> |
| 76 | <div className="editor-column"> |
| 77 | {banner} |
| 78 | <div |
| 79 | className="editor-box" |
| 80 | ref={this.editorColumnRef} |
| 81 | onBlur={this.onBlurHandler} |
| 82 | onFocus={this.onFocusHandler} |
| 83 | > |
| 84 | <svg |
| 85 | className="editor-svg" |
| 86 | xmlns="http://www.w3.org/2000/svg" |
| 87 | height={height} |
| 88 | preserveAspectRatio="none" |
| 89 | onClick={this.onClickHandler} |
| 90 | ref={this.editorSvgRef} |
| 91 | > |
| 92 | <ExpandedListBlockView block={fileBody} isSelected={false} /> |
| 93 | <ActiveCursor selection={selection} /> |
| 94 | </svg> |
nothing calls this directly
no test coverage detected