From 05666af7d60f389cb38a3a5563df02afb3c84e12 Mon Sep 17 00:00:00 2001 From: "zude.hzd" Date: Mon, 26 Oct 2020 22:14:17 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E7=BC=96=E8=BE=91?= =?UTF-8?q?=E5=99=A8=E8=BD=AC=E5=8C=96bug,=E5=A2=9E=E5=8A=A0=E7=AA=97?= =?UTF-8?q?=E5=8F=A3=E6=9C=80=E5=A4=A7=E6=9C=80=E5=B0=8F=E5=8C=96=E5=8A=9F?= =?UTF-8?q?=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/demo/public/assets.json | 7 --- .../src/expression-setter/index.tsx | 16 +++--- packages/plugin-source-editor/src/index.tsx | 55 +++++++++++-------- .../plugin-source-editor/src/transform.ts | 2 +- 4 files changed, 40 insertions(+), 40 deletions(-) diff --git a/packages/demo/public/assets.json b/packages/demo/public/assets.json index c5fd05dda..ef8650e05 100644 --- a/packages/demo/public/assets.json +++ b/packages/demo/public/assets.json @@ -26,13 +26,6 @@ "version": "1.0.0", "urls": ["https://unpkg.alibaba-inc.com/mc-breadcrumb@1.0.0/dist/MCBreadcrumb.js", "https://unpkg.alibaba-inc.com/mc-breadcrumb@1.0.0/dist/MCBreadcrumb.css"], "library": "MCBreadcrumb" - }, - { - "title": "krumpDemo", - "package": "krumpDemo", - "version": "1.0.0", - "urls": ["http://30.37.82.74:8000/lc-engine.js"], - "library": "krump-test-module" } ], "components": [ diff --git a/packages/editor-setters/src/expression-setter/index.tsx b/packages/editor-setters/src/expression-setter/index.tsx index a4195a7a1..040c6f5b1 100644 --- a/packages/editor-setters/src/expression-setter/index.tsx +++ b/packages/editor-setters/src/expression-setter/index.tsx @@ -89,17 +89,17 @@ export default class ExpressionView extends PureComponent { return null; } - onChange(value: string, actionType: string) { - let realInputValue = value; + onChange(value: string) { + const realInputValue = value; const realDataSource = null; let nextCursorIndex: number; // 更新值 - if (actionType === 'itemClick' || actionType === 'enter') { - const curValue = this.state.value; - if (curValue) { - realInputValue = curValue + realInputValue; - } - } + // if (actionType === 'itemClick' || actionType === 'enter') { + // // const curValue = this.state.value; + // // if (curValue) { + // // realInputValue = curValue + realInputValue; + // // } + // } // 更新数据源 const newState = { value: realInputValue, diff --git a/packages/plugin-source-editor/src/index.tsx b/packages/plugin-source-editor/src/index.tsx index fb8551d6b..50e1228a3 100644 --- a/packages/plugin-source-editor/src/index.tsx +++ b/packages/plugin-source-editor/src/index.tsx @@ -58,12 +58,12 @@ export default class SourceEditor extends Component<{ private originSize: { width: '', height: '' - } + }; state = { isShowSaveBtn: true, visiable: false, - fullScreenStatus:false + fullScreenStatus: false, }; // eslint-disable-next-line react/no-deprecated @@ -103,7 +103,7 @@ export default class SourceEditor extends Component<{ componentDidMount() { - this.editorNode = this.editorJsRef.current; // 记录当前dom节点; + // this.editorNode = this.editorJsRef.current; // 记录当前dom节点; } /** @@ -152,6 +152,7 @@ export default class SourceEditor extends Component<{ css, selectTab: TAB_KEY.JS_TAB, visiable: true, + fullScreenStatus: false, }); }; @@ -204,9 +205,14 @@ export default class SourceEditor extends Component<{ if (this.editorCmd) { this.callEditorEvent(this.editorCmd.eventName, this.editorCmd.params); } + + setTimeout(() => { + this.editorNode = this.editorJsRef.current; // 记录当前dom节点; + }, 0); }; fullScreen = () => { + console.log(this.editorNode); document.body.appendChild(this.editorNode); // this.originSize = { // width: this.editorNode.clientWidth, @@ -224,33 +230,34 @@ export default class SourceEditor extends Component<{ this.monocoEditor.layout({ height: document.body.clientHeight, - width: document.body.clientWidth - }) + width: document.body.clientWidth, + }); this.monocoEditor.updateOptions(fullScreenOption); this.setState({ - fullScreenStatus:true - }) + fullScreenStatus: true, + }); }; minScreen = () => { - - // document.body.removeChild(this.editorNode); - let node=document.getElementById("editor-context-container").lastChild; - document.getElementById('editor-context-container')?.insertBefore(node,this.editorNode); + const listNode = document.getElementById('editor-context-container'); + listNode.insertBefore(this.editorNode, listNode.childNodes[0]); const minScreenOption = { - ...defaultEditorOption + ...defaultEditorOption, + minimap: { + enabled: false, + }, }; this.monocoEditor.updateOptions(minScreenOption); this.setState({ - fullScreenStatus:false - }) + fullScreenStatus: false, + }); - } + }; onTabChange = (key) => { const { editor } = this.props; @@ -312,7 +319,7 @@ export default class SourceEditor extends Component<{ }; render() { - const { selectTab, jsCode, css, isShowSaveBtn, visiable,fullScreenStatus } = this.state; + const { selectTab, jsCode, css, isShowSaveBtn, visiable, fullScreenStatus } = this.state; const tabs = [ { tab: 'index.js', key: TAB_KEY.JS_TAB }, { tab: 'style.css', key: TAB_KEY.CSS_TAB }, @@ -331,7 +338,7 @@ export default class SourceEditor extends Component<{ { visiable &&
- + { - !fullScreenStatus? -
- -
: -
- -
+ !fullScreenStatus ? +
+ +
: +
+ +
}
diff --git a/packages/plugin-source-editor/src/transform.ts b/packages/plugin-source-editor/src/transform.ts index cbb4a2a0c..99e486925 100644 --- a/packages/plugin-source-editor/src/transform.ts +++ b/packages/plugin-source-editor/src/transform.ts @@ -84,7 +84,7 @@ const transfrom = { // eslint-disable-next-line no-useless-escape const reg = /\w+\s?\((\w|\,|\s|\{|\}|\=|\'|\")*\)\s?\{/; const result = codeStr.match(reg); - + if (result && result[0]) { const functionNameStr = result[0];