From 882774311a8245769de92d68d3d43b523e85e571 Mon Sep 17 00:00:00 2001 From: roymondchen Date: Thu, 11 Aug 2022 17:11:52 +0800 Subject: [PATCH] =?UTF-8?q?fix(editor):=20=E6=B0=B4=E5=B9=B3=E5=B1=85?= =?UTF-8?q?=E4=B8=AD=E6=B7=BB=E5=8A=A0=E4=BA=86=E4=B8=A4=E4=B8=AA=E5=8E=86?= =?UTF-8?q?=E5=8F=B2=E5=A0=86=E6=A0=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/editor/src/services/editor.ts | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/packages/editor/src/services/editor.ts b/packages/editor/src/services/editor.ts index 4ac8d8b7..6d1da4de 100644 --- a/packages/editor/src/services/editor.ts +++ b/packages/editor/src/services/editor.ts @@ -523,15 +523,15 @@ class Editor extends BaseService { * @param config 组件节点配置 * @returns 当前组件节点配置 */ - public async alignCenter(config: MNode): Promise { + public async alignCenter(config: MNode): Promise { const parent = this.get('parent'); - const node = this.get('node'); - const layout = await this.getLayout(toRaw(parent), toRaw(node)); + const node = cloneDeep(toRaw(config)); + const layout = await this.getLayout(toRaw(parent), node); if (layout === Layout.RELATIVE) { - return; + return config; } - if (!node.style) return; + if (!node.style) return config; const stage = this.get('stage'); const doc = stage?.renderer.contentWindow?.document; @@ -546,15 +546,14 @@ class Editor extends BaseService { node.style.left = (parent.style.width - node.style.width) / 2; } - await this.update(node); + const newNode = await this.update(node); + this.get('stage')?.update({ - config: cloneDeep(toRaw(node)), + config: cloneDeep(toRaw(newNode)), root: cloneDeep(this.get('root')), }); - this.addModifiedNodeId(config.id); - this.pushHistoryState(); - return config; + return newNode; } /**