diff --git a/packages/designer/src/builtin-simulator/bem-tools/border-detecting.tsx b/packages/designer/src/builtin-simulator/bem-tools/border-detecting.tsx index 565078a66..1f1735801 100644 --- a/packages/designer/src/builtin-simulator/bem-tools/border-detecting.tsx +++ b/packages/designer/src/builtin-simulator/bem-tools/border-detecting.tsx @@ -58,13 +58,12 @@ export class BorderDetecting extends Component<{ host: BuiltinSimulatorHost }> { @computed get current() { const { host } = this.props; const doc = host.currentDocument; - console.info(doc); if (!doc) { return null; } const { selection } = doc; - const { current } = host.designer.detecting; - + const { current } = host.designer.detecting; + if (!current || current.document !== doc || selection.has(current.id)) { return null; } diff --git a/packages/designer/src/builtin-simulator/host.ts b/packages/designer/src/builtin-simulator/host.ts index 50daf3d3d..d61a4bed0 100644 --- a/packages/designer/src/builtin-simulator/host.ts +++ b/packages/designer/src/builtin-simulator/host.ts @@ -327,10 +327,10 @@ export class BuiltinSimulatorHost implements ISimulatorHost { doc.removeEventListener('mouseup', checkSelect, true); diff --git a/packages/editor-preset-vision/src/editor.ts b/packages/editor-preset-vision/src/editor.ts index f63a8fc0e..1ed7b3757 100644 --- a/packages/editor-preset-vision/src/editor.ts +++ b/packages/editor-preset-vision/src/editor.ts @@ -1,5 +1,5 @@ -import { isJSBlock, isJSExpression, isJSSlot, isI18nData } from '@ali/lowcode-types'; -import { isPlainObject, hasOwnProperty, cloneDeep } from '@ali/lowcode-utils'; +import { isJSBlock, isJSExpression, isJSSlot } from '@ali/lowcode-types'; +import { isPlainObject, hasOwnProperty, cloneDeep, isI18NObject, isUseI18NSetter, convertToI18NObject } from '@ali/lowcode-utils'; import { globalContext, Editor } from '@ali/lowcode-editor-core'; import { Designer, LiveEditing, TransformStage, Node, getConvertedExtraKey } from '@ali/lowcode-designer'; import Outline, { OutlineBackupPane, getTreeMaster } from '@ali/lowcode-plugin-outline-pane'; @@ -123,6 +123,10 @@ designer.addPropsReducer((props, node) => { if (ov === undefined && v !== undefined) { newProps[item.name] = v; } + // 兼容 props 中的属性为 i18n 类型,但是仅提供了一个值 + if (isUseI18NSetter(node.componentMeta.prototype, item.name) && !isI18NObject(ov)) { + newProps[item.name] = v; + } } catch (e) { if (hasOwnProperty(props, item.name)) { newProps[item.name] = props[item.name]; diff --git a/packages/utils/src/index.ts b/packages/utils/src/index.ts index 0f9fcad2a..e5dd40da3 100644 --- a/packages/utils/src/index.ts +++ b/packages/utils/src/index.ts @@ -20,3 +20,4 @@ export * from './svg-icon'; export * from './unique-id'; export * from './build-components'; export * from './appHelper'; +export * from './misc'; \ No newline at end of file diff --git a/packages/utils/src/misc.ts b/packages/utils/src/misc.ts new file mode 100644 index 000000000..574def94a --- /dev/null +++ b/packages/utils/src/misc.ts @@ -0,0 +1,15 @@ + + +export function isUseI18NSetter(prototype: any, propName: string) { + const configure = prototype?.options?.configure; + if (Array.isArray(configure)) { + return configure.some(c => { + return c.name === propName && c?.setter?.type?.displayName === 'I18nSetter'; + }); + } + return false; +} + +export function convertToI18NObject(v: string, locale: string = 'zh_CN') { + return { type: 'i18n', use: locale, [locale]: v }; +}