From 0d6420215c87f85fbf87bcd80d8ee295075fc1d9 Mon Sep 17 00:00:00 2001 From: roymondchen Date: Wed, 4 Dec 2024 16:26:48 +0800 Subject: [PATCH] =?UTF-8?q?fix(editor):=20=E4=BF=AE=E6=94=B9=E6=9C=AA?= =?UTF-8?q?=E5=8C=85=E5=90=AB=E6=95=B0=E6=8D=AE=E6=BA=90=E7=9A=84=E9=85=8D?= =?UTF-8?q?=E7=BD=AE=EF=BC=8C=E7=94=BB=E5=B8=83=E4=B8=AD=E6=B2=A1=E6=9C=89?= =?UTF-8?q?=E5=AE=9E=E6=97=B6=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/editor/src/initService.ts | 7 ++++--- packages/editor/src/utils/editor.ts | 18 +----------------- packages/utils/src/index.ts | 16 ++++++++++++++++ 3 files changed, 21 insertions(+), 20 deletions(-) diff --git a/packages/editor/src/initService.ts b/packages/editor/src/initService.ts index 588482fc..070b19c7 100644 --- a/packages/editor/src/initService.ts +++ b/packages/editor/src/initService.ts @@ -21,10 +21,10 @@ import { Target, } from '@tmagic/core'; import { ChangeRecord } from '@tmagic/form'; -import { getNodes, isPage, traverseNode } from '@tmagic/utils'; +import { getNodes, isPage, isValueIncludeDataSource, traverseNode } from '@tmagic/utils'; import PropsPanel from './layouts/PropsPanel.vue'; -import { isIncludeDataSource, isValueIncludeDataSource } from './utils/editor'; +import { isIncludeDataSource } from './utils/editor'; import { EditorProps } from './editorProps'; import { Services } from './type'; @@ -418,7 +418,8 @@ export const initServiceEvents = ( isValueIncludeDataSource(record.value) ) { needRecollectNodes.push(newNode); - break; + } else { + normalNodes.push(newNode); } } } else if (isIncludeDataSource(newNode, oldNode)) { diff --git a/packages/editor/src/utils/editor.ts b/packages/editor/src/utils/editor.ts index 2a439c80..c204d51a 100644 --- a/packages/editor/src/utils/editor.ts +++ b/packages/editor/src/utils/editor.ts @@ -25,13 +25,13 @@ import { NODE_CONDS_KEY, NodeType } from '@tmagic/core'; import type StageCore from '@tmagic/stage'; import { calcValueByFontsize, - DATA_SOURCE_FIELDS_SELECT_VALUE_PREFIX, getElById, getNodePath, isNumber, isPage, isPageFragment, isPop, + isValueIncludeDataSource, } from '@tmagic/utils'; import { Layout } from '@editor/type'; @@ -302,22 +302,6 @@ export const moveItemsInContainer = (sourceIndices: number[], parent: MContainer } }; -export const isValueIncludeDataSource = (value: any) => { - if (typeof value === 'string' && /\$\{([\s\S]+?)\}/.test(value)) { - return true; - } - if (Array.isArray(value) && `${value[0]}`.startsWith(DATA_SOURCE_FIELDS_SELECT_VALUE_PREFIX)) { - return true; - } - if (value?.isBindDataSource && value.dataSourceId) { - return true; - } - if (value?.isBindDataSourceField && value.dataSourceId) { - return true; - } - return false; -}; - const isIncludeDataSourceByDiffAddResult = (diffResult: any) => { for (const value of Object.values(diffResult)) { const result = isValueIncludeDataSource(value); diff --git a/packages/utils/src/index.ts b/packages/utils/src/index.ts index 6e545de8..890c08e5 100644 --- a/packages/utils/src/index.ts +++ b/packages/utils/src/index.ts @@ -509,3 +509,19 @@ export const traverseNode = ( }); } }; + +export const isValueIncludeDataSource = (value: any) => { + if (typeof value === 'string' && /\$\{([\s\S]+?)\}/.test(value)) { + return true; + } + if (Array.isArray(value) && `${value[0]}`.startsWith(DATA_SOURCE_FIELDS_SELECT_VALUE_PREFIX)) { + return true; + } + if (value?.isBindDataSource && value.dataSourceId) { + return true; + } + if (value?.isBindDataSourceField && value.dataSourceId) { + return true; + } + return false; +};