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