产品-公式编辑器封装
This commit is contained in:
parent
159eadc164
commit
11e1cc89a9
|
|
@ -133,7 +133,9 @@ class ExcelEditor extends Component {
|
|||
handleFuncSelect = str => {
|
||||
const cursor = this.editorRef.getCursor();
|
||||
this.editorRef.replaceRange(`${str}()`, cursor);
|
||||
this.editorRef.goColumnLeft();
|
||||
console.log(this.editorRef);
|
||||
console.log(this.editorRef.doc);
|
||||
this.editorRef.doc.goColumnLeft();
|
||||
};
|
||||
handleEditorRedo = () => {
|
||||
const { ch, line } = this.editorRef.getCursor();
|
||||
|
|
@ -154,12 +156,10 @@ class ExcelEditor extends Component {
|
|||
const delStr = this.editorRef.getRange({ line, ch: ch - 1 }, { line, ch });
|
||||
const codeValue = this.editorRef.getValue();
|
||||
if (delStr === "}") {
|
||||
console.log(ch);
|
||||
console.log(codeValue.slice(0, ch).lastIndexOf("{"));
|
||||
if (codeValue.slice(0, ch).lastIndexOf("{") === -1) {
|
||||
this.editorRef.replaceRange("", { line, ch: ch - 1 }, { line, ch });
|
||||
} else {
|
||||
this.editorRef.replaceRange("", { line, ch: codeValue.slice(0, ch).lastIndexOf("{") }, { line, ch });
|
||||
this.editorRef.replaceRange("", { line, ch: codeValue.slice(0, ch).lastIndexOf("{") + 1 }, { line, ch });
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
@ -200,7 +200,8 @@ class ExcelEditor extends Component {
|
|||
lint: false,
|
||||
indentUnit: 2,
|
||||
cursorHeight: 0.85,
|
||||
placeholder: ""
|
||||
placeholder: "",
|
||||
showCursorWhenSelecting: true
|
||||
}}
|
||||
onKeyDown={(_, { keyCode }) => keyCode === 8 && this.handleBackSpaceRedo()}
|
||||
/>
|
||||
|
|
@ -226,8 +227,7 @@ class ExcelEditor extends Component {
|
|||
</div>
|
||||
<div className="excel-codeBox-keyboard-operate-clear">
|
||||
<Button title="←" size="small" className="excel-codeBox-keyboard-del"
|
||||
// this.handleEditorRedo
|
||||
onClick={() => this.editorRef.delCharBefore()}>←</Button>
|
||||
onClick={this.handleEditorRedo}>←</Button>
|
||||
<Button title="C" size="small" className="excel-codeBox-keyboard-clear"
|
||||
onClick={() => this.setState({ value: "", widgets: [] })}>C</Button>
|
||||
</div>
|
||||
|
|
|
|||
Loading…
Reference in New Issue