From cb72e4ce9204c4c4744e0cbd0953ee25ab64a804 Mon Sep 17 00:00:00 2001 From: "zude.hzd" Date: Tue, 8 Sep 2020 12:45:59 +0800 Subject: [PATCH] =?UTF-8?q?fix:js=E9=9D=A2=E6=9D=BF=E6=AF=8F=E6=AC=A1?= =?UTF-8?q?=E6=89=93=E5=BC=80=E7=9A=84=E6=97=B6=E5=80=99=E9=87=8D=E6=96=B0?= =?UTF-8?q?=E8=8E=B7=E5=8F=96=E6=9C=80=E6=96=B0schema?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/plugin-source-editor/src/index.tsx | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/packages/plugin-source-editor/src/index.tsx b/packages/plugin-source-editor/src/index.tsx index b746179d8..ab5116ad9 100644 --- a/packages/plugin-source-editor/src/index.tsx +++ b/packages/plugin-source-editor/src/index.tsx @@ -71,6 +71,8 @@ export default class SourceEditor extends Component<{ this.callEditorEvent('sourceEditor.focusByFunction', params); }); + + // 插件面板关闭事件,监听规则同上 editor.on('skeleton.panel-dock.unactive',(pluginName,dock)=>{ @@ -79,8 +81,14 @@ export default class SourceEditor extends Component<{ } }) - let schema = editor.get('designer').project.getSchema(); - this.initCode(schema); + // 插件面板打开事件,监听规则同上 + editor.on('skeleton.panel-dock.active',(pluginName,dock)=>{ + if (pluginName == 'sourceEditor'){ + this.initCode(); + } + }) + + this.initCode(); } @@ -121,7 +129,9 @@ export default class SourceEditor extends Component<{ } }; - initCode = (schema) => { + initCode = () => { + const {editor} = this.props; + let schema = editor.get('designer').project.getSchema(); let jsCode = js_beautify(transfrom.schema2Code(schema), { indent_size: 2, indent_empty_lines: true }); let css;