diff --git a/packages/demo/CHANGELOG.md b/packages/demo/CHANGELOG.md index 791cd28cc..07452c012 100644 --- a/packages/demo/CHANGELOG.md +++ b/packages/demo/CHANGELOG.md @@ -493,10 +493,5 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline ### Features -<<<<<<< HEAD * complet preview ([56c16ff](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/56c16ff)) * double outline & ZH_EN support ([b379bd7](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/b379bd7)) -======= -* complet preview ([56c16ff](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/56c16ffa5c39c2d01abd9cfa90fea49a4539da1d)) -* double outline & ZH_EN support ([b379bd7](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/b379bd7c0c488ef24f825760750a13d3fa083c96)) ->>>>>>> df955e1db90ff104cd11160def80113cfd6faccc diff --git a/packages/demo/public/index.html b/packages/demo/public/index.html index 35d745971..e10b9be7f 100644 --- a/packages/demo/public/index.html +++ b/packages/demo/public/index.html @@ -70,5 +70,9 @@
+ diff --git a/packages/demo/public/raxAssets.json b/packages/demo/public/raxAssets.json index d7c438ead..ec93fa281 100644 --- a/packages/demo/public/raxAssets.json +++ b/packages/demo/public/raxAssets.json @@ -149,25 +149,25 @@ "prototypeViewsUrl": null, "prototypeUrls": { "default": [ - "https://g.alicdn.com/legao-comp/web_bundle_0724/@ali/vc-deep-mobile/2.0.1-beta.5/proto.bb4ec38.css", - "https://g.alicdn.com/legao-comp/web_bundle_0724/@ali/vc-deep-mobile/2.0.1-beta.5/proto.ed31eab.js" + "https://g.alicdn.com/legao-comp/web_bundle_0724/@ali/vc-deep-mobile/2.0.1-beta.25/proto.2f23cdf.css", + "https://g.alicdn.com/legao-comp/web_bundle_0724/@ali/vc-deep-mobile/2.0.1-beta.25/proto.9a739a7.js" ] }, "prototypeConfigsUrl": [ - "https://g.alicdn.com/legao-comp/web_bundle_0724/@ali/vc-deep-mobile/2.0.1-beta.5/proto.bb4ec38.css", - "https://g.alicdn.com/legao-comp/web_bundle_0724/@ali/vc-deep-mobile/2.0.1-beta.5/proto.ed31eab.js" + "https://g.alicdn.com/legao-comp/web_bundle_0724/@ali/vc-deep-mobile/2.0.1-beta.25/proto.2f23cdf.css", + "https://g.alicdn.com/legao-comp/web_bundle_0724/@ali/vc-deep-mobile/2.0.1-beta.25/proto.9a739a7.js" ], "alias": "", "urls": [ - "https://g.alicdn.com/legao-comp/web_bundle_0724/@ali/vc-deep-mobile/2.0.1-beta.5/view.f2b6dde.css", - "https://g.alicdn.com/legao-comp/web_bundle_0724/@ali/vc-deep-mobile/2.0.1-beta.5/view.46f546f.js", - "https://g.alicdn.com/legao-comp/web_bundle_0724/@ali/vc-deep-mobile/2.0.1-beta.5/view.mobile.f2b6dde.css", - "https://g.alicdn.com/legao-comp/web_bundle_0724/@ali/vc-deep-mobile/2.0.1-beta.5/view.mobile.6b901e9.js" + "https://g.alicdn.com/legao-comp/web_bundle_0724/@ali/vc-deep-mobile/2.0.1-beta.25/view.d6d0d1f.css", + "https://g.alicdn.com/legao-comp/web_bundle_0724/@ali/vc-deep-mobile/2.0.1-beta.25/view.14bb8e8.js", + "https://g.alicdn.com/legao-comp/web_bundle_0724/@ali/vc-deep-mobile/2.0.1-beta.25/view.mobile. d6d0d1f.css", + "https://g.alicdn.com/legao-comp/web_bundle_0724/@ali/vc-deep-mobile/2.0.1-beta.25/view.mobile.fe36565.js" ], "library": "AliVcDeepMobile", "components": null, "packageName": "@ali/vc-deep-mobile", - "version": "2.0.1-beta.5" + "version": "2.0.1-beta.25" }, { "prototypeViewsUrl": null, diff --git a/packages/demo/src/index.ts b/packages/demo/src/index.ts index eae3b122e..d4c178537 100644 --- a/packages/demo/src/index.ts +++ b/packages/demo/src/index.ts @@ -1 +1,2 @@ +// import './vision'; import './editor'; diff --git a/packages/designer/CHANGELOG.md b/packages/designer/CHANGELOG.md index 048d204c6..775ca6ba4 100644 --- a/packages/designer/CHANGELOG.md +++ b/packages/designer/CHANGELOG.md @@ -3,6 +3,7 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +<<<<<<< HEAD # [1.0.0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-designer@0.14.0...@ali/lowcode-designer@1.0.0) (2020-08-17) @@ -45,11 +46,86 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline # [0.10.0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-designer@0.9.37...@ali/lowcode-designer@0.10.0) (2020-08-14) +======= + +## [0.9.43](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-designer@0.9.42...@ali/lowcode-designer@0.9.43) (2020-08-14) ### Bug Fixes +* 修改移动端设备宽度 ([cd7b1e6](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/cd7b1e6)) + + + + + +## [0.9.42](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-designer@0.9.41...@ali/lowcode-designer@0.9.42) (2020-08-14) + + +### Bug Fixes + +* createComponent 支持所有 schema ([7f946f5](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/7f946f5)) +* 不对外暴露 Node ([05957ce](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/05957ce)) +* 卡片内容不可用拖动 ([6a85c43](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/6a85c43)) +* 处理选区的 toolkit 位置不对的 bug ([bfc63db](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/bfc63db)) +* 快捷键增加判断 ([0f64829](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/0f64829)) +* 快捷键增加判断 ([e18a231](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/e18a231)) +* 组件缺失占位 ([aff2f34](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/aff2f34)) + + +### Features + +* 导出的schema增加componentsMap ([dbc958c](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/dbc958c)) + + + + + +## [0.9.41](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-designer@0.9.40...@ali/lowcode-designer@0.9.41) (2020-08-07) + + +### Bug Fixes + +* canDropIn 为 boolean 时失效 ([7508fb6](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/7508fb6)) + + + + + +## [0.9.40](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-designer@0.9.39...@ali/lowcode-designer@0.9.40) (2020-08-06) + + +### Bug Fixes + +* fieldId 重复问题 ([e761b1a](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/e761b1a)) + + + + + +## [0.9.39](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-designer@0.9.38...@ali/lowcode-designer@0.9.39) (2020-08-06) + + +### Bug Fixes + +* 增加兼容 API ([2960446](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/2960446)) +* 复制之后 fieldId 重复 ([36621ea](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/36621ea)) + + + + + +## [0.9.38](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-designer@0.9.37...@ali/lowcode-designer@0.9.38) (2020-08-06) +>>>>>>> master + + +### Bug Fixes + +<<<<<<< HEAD * 兼容modal模式 ([1092ee9](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/1092ee9)) +======= +* 修复 preset-vision 版本 lifeCycles 丢失以及 slot 初始化问题 ([7cf6d24](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/7cf6d24)) +>>>>>>> master diff --git a/packages/designer/src/builtin-simulator/bem-tools/border-selecting.tsx b/packages/designer/src/builtin-simulator/bem-tools/border-selecting.tsx index 4562c9ffd..7341fc056 100644 --- a/packages/designer/src/builtin-simulator/bem-tools/border-selecting.tsx +++ b/packages/designer/src/builtin-simulator/bem-tools/border-selecting.tsx @@ -66,7 +66,9 @@ class Toolbar extends Component<{ observed: OffsetObserver }> { const MARGIN = 1; const BORDER = 2; const SPACE_HEIGHT = BAR_HEIGHT + MARGIN + BORDER; + const SPACE_MINIMUM_WIDTH = 140; // magic number let style: any; + // 计算 toolbar 的上/下位置 if (observed.top > SPACE_HEIGHT) { style = { top: -SPACE_HEIGHT, @@ -83,10 +85,12 @@ class Toolbar extends Component<{ observed: OffsetObserver }> { top: Math.max(MARGIN, MARGIN - observed.top), }; } - if (observed.width < 140) { + // 计算 toolbar 的左/右位置 + if (SPACE_MINIMUM_WIDTH > observed.left + observed.width) { style.left = Math.max(-BORDER, observed.left - width - BORDER); } else { style.right = Math.max(-BORDER, observed.right - width - BORDER); + style.justifyContent = 'flex-start'; } const { node } = observed; const actions: ReactNodeArray = []; diff --git a/packages/designer/src/builtin-simulator/host.less b/packages/designer/src/builtin-simulator/host.less index d183408f2..c51cd5d67 100644 --- a/packages/designer/src/builtin-simulator/host.less +++ b/packages/designer/src/builtin-simulator/host.less @@ -24,7 +24,7 @@ &-device-mobile { left: 50%; - width: 460px; + width: 378px; transform: translateX(-50%); box-shadow: 0 2px 10px 0 rgba(31,56,88,.15); } diff --git a/packages/designer/src/builtin-simulator/host.ts b/packages/designer/src/builtin-simulator/host.ts index 4cd34d8ca..e9a68e3fa 100644 --- a/packages/designer/src/builtin-simulator/host.ts +++ b/packages/designer/src/builtin-simulator/host.ts @@ -31,7 +31,7 @@ import { CanvasPoint, } from '../designer'; import { parseMetadata } from './utils/parse-metadata'; -import { ComponentMetadata, ComponentSchema } from '@ali/lowcode-types'; +import { ComponentMetadata, NodeSchema } from '@ali/lowcode-types'; import { BuiltinSimulatorRenderer } from './renderer'; import clipboard from '../designer/clipboard'; import { LiveEditing } from './live-editing/live-editing'; @@ -302,6 +302,11 @@ export class BuiltinSimulatorHost implements ISimulatorHost { @@ -538,7 +543,7 @@ export class BuiltinSimulatorHost implements ISimulatorHost { + const onMoveHook = node.componentMeta?.getMetadata()?.experimental?.callbacks?.onMoveHook; + const canMove = onMoveHook && typeof onMoveHook === 'function' ? onMoveHook() : true; + + return canMove; + }); + + if (!operationalNodes || operationalNodes.length === 0) { + return; + } this.sensing = true; this.scroller.scrolling(e); const dropContainer = this.getDropContainer(e); + const canDropIn = dropContainer?.container?.componentMeta?.prototype?.options?.canDropIn; + if ( !dropContainer || + canDropIn === false || // too dirty - (typeof dropContainer.container?.componentMeta?.prototype?.options?.canDropIn === 'function' && - !dropContainer.container?.componentMeta?.prototype?.options?.canDropIn(e.dragObject.nodes[0])) + (typeof canDropIn === 'function' && !canDropIn(operationalNodes[0])) ) { return null; } diff --git a/packages/designer/src/builtin-simulator/renderer.ts b/packages/designer/src/builtin-simulator/renderer.ts index 3994d67c4..cf814ba48 100644 --- a/packages/designer/src/builtin-simulator/renderer.ts +++ b/packages/designer/src/builtin-simulator/renderer.ts @@ -1,9 +1,9 @@ import { ComponentInstance, NodeInstance, Component } from '../simulator'; -import { ComponentSchema } from '@ali/lowcode-types'; +import { NodeSchema } from '@ali/lowcode-types'; export interface BuiltinSimulatorRenderer { readonly isSimulatorRenderer: true; - createComponent(schema: ComponentSchema): Component | null; + createComponent(schema: NodeSchema): Component | null; getComponent(componentName: string): Component; getComponentInstances(id: string): ComponentInstance[] | null; getClosestNodeInstance(from: ComponentInstance, nodeId?: string): NodeInstance | null; diff --git a/packages/designer/src/component-meta.ts b/packages/designer/src/component-meta.ts index 44f2ca64f..f34b98238 100644 --- a/packages/designer/src/component-meta.ts +++ b/packages/designer/src/component-meta.ts @@ -137,13 +137,13 @@ export class ComponentMeta { } } - private parseMetadata(metadta: ComponentMetadata) { - const { componentName, npm } = metadta; + private parseMetadata(metadata: ComponentMetadata) { + const { componentName, npm } = metadata; this._npm = npm; this._componentName = componentName; // 额外转换逻辑 - this._transformedMetadata = this.transformMetadata(metadta); + this._transformedMetadata = this.transformMetadata(metadata); const title = this._transformedMetadata.title; if (title) { @@ -381,7 +381,10 @@ const builtinComponentActions: ComponentAction[] = [ action(node: Node) { // node.remove(); const { document: doc, parent, index } = node; - parent && doc.insertNode(parent, node, index, true); + if (parent) { + const newNode = doc.insertNode(parent, node, index + 1, true); + newNode.select(); + } }, }, important: true, diff --git a/packages/designer/src/designer/builtin-hotkey.ts b/packages/designer/src/designer/builtin-hotkey.ts index a30ee0ad4..13bea87f4 100644 --- a/packages/designer/src/designer/builtin-hotkey.ts +++ b/packages/designer/src/designer/builtin-hotkey.ts @@ -77,7 +77,9 @@ hotkey.bind(['backspace', 'del'], (e: KeyboardEvent) => { const topItems = sel.getTopNodes(); // TODO: check can remove topItems.forEach((node) => { - doc.removeNode(node); + if (node.canPerformAction('remove')) { + doc.removeNode(node); + } }); sel.clear(); }); @@ -102,8 +104,13 @@ hotkey.bind(['command+c', 'ctrl+c', 'command+x', 'ctrl+x'], (e, action) => { } e.preventDefault(); - const selected = doc.selection.getTopNodes(true); - if (!selected || selected.length < 1) return; + let selected = doc.selection.getTopNodes(true); + selected = selected.filter((node) => { + return node.canPerformAction('copy'); + }) + if (!selected || selected.length < 1) { + return; + } const componentsMap = {}; const componentsTree = selected.map((item) => item.export(TransformStage.Clone)); diff --git a/packages/designer/src/document/document-model.ts b/packages/designer/src/document/document-model.ts index 903312e29..6a5eade7e 100644 --- a/packages/designer/src/document/document-model.ts +++ b/packages/designer/src/document/document-model.ts @@ -20,6 +20,15 @@ export type GetDataType = T extends undefined : any : T; + export interface ComponentMap { + componentName: string; + package: string; + version?: string; + destructuring?: boolean; + exportName?: string; + subName?: string; + } + export class DocumentModel { /** * 根节点 类型有:Page/Component/Block @@ -301,8 +310,11 @@ export class DocumentModel { } import(schema: RootSchema, checkId = false) { + // TODO: do purge + this.nodes.forEach(node => { + this.destroyNode(node); + }); this.rootNode.import(schema as any, checkId); - // todo: purge something // todo: select added and active track added } @@ -493,9 +505,13 @@ export class DocumentModel { } // add toData - toData() { + toData(extraComps?: string[]) { const node = this.project?.currentDocument?.export(TransformStage.Save); - return { componentsTree: [node] }; + const data = { + componentsMap: this.getComponentsMap(extraComps), + componentsTree: [node], + }; + return data; } getHistory(): History { @@ -564,6 +580,37 @@ export class DocumentModel { return this.rootNodeVisitorMap[name]; } + getComponentsMap(extraComps?: string[]) { + const componentsMap: ComponentMap[] = []; + // 组件去重 + const map: any = {}; + for (let node of this.nodesMap.values()) { + const { componentName } = node || {}; + if (!map[componentName] && node?.componentMeta?.npm?.package) { + map[componentName] = true; + componentsMap.push({ + componentName, + package: node?.componentMeta?.npm?.package, + }); + } + } + // 合并外界传入的自定义渲染的组件 + if (Array.isArray(extraComps)) { + extraComps.forEach(c => { + if (c && !map[c]) { + const m = this.getComponentMeta(c); + if (m && m.npm?.package) { + componentsMap.push({ + componentName: c, + package: m.npm?.package, + }); + } + } + }); + } + return componentsMap; + } + onNodeCreate(func: (node: Node) => void) { this.emitter.on('nodecreate', func); return () => { @@ -584,6 +631,13 @@ export class DocumentModel { refresh() { console.warn('refresh method is deprecated'); } + + /** + * @deprecated + */ + onRefresh(func: () => void) { + console.warn('onRefresh method is deprecated'); + } } export function isDocumentModel(obj: any): obj is DocumentModel { diff --git a/packages/designer/src/document/history.ts b/packages/designer/src/document/history.ts index 44c9010c6..3cfb6b4cf 100644 --- a/packages/designer/src/document/history.ts +++ b/packages/designer/src/document/history.ts @@ -36,8 +36,6 @@ export class History { this.obx = autorun(() => { const data = logger(); - // TODO: remove this line - console.info('log'); if (this.justWokeup) { this.justWokeup = false; return; diff --git a/packages/designer/src/document/node/node-children.ts b/packages/designer/src/document/node/node-children.ts index 80f91b430..f89e55008 100644 --- a/packages/designer/src/document/node/node-children.ts +++ b/packages/designer/src/document/node/node-children.ts @@ -87,7 +87,7 @@ export class NodeChildren { return this.size > 0; } - @computed length() { + @computed get length(): number { return this.children.length; } diff --git a/packages/designer/src/document/node/node.ts b/packages/designer/src/document/node/node.ts index f34426092..f0273c6b0 100644 --- a/packages/designer/src/document/node/node.ts +++ b/packages/designer/src/document/node/node.ts @@ -653,6 +653,16 @@ export class Node { slotNode.internalSetParent(this as ParentalNode, true); this._slots.push(slotNode); } + /** + * 当前node对应组件是否已注册可用 + */ + isValidComponent() { + const allComponents = this.document?.designer?.componentsMap; + if (allComponents && allComponents[this.componentName]) { + return true; + } + return false; + } /** * 删除一个节点 @@ -692,6 +702,14 @@ export class Node { this.document.destroyNode(this); } + /** + * 是否可执行某action + */ + canPerformAction(action: string): boolean { + const availableActions = this.componentMeta?.availableActions?.map((action) => action.name) || []; + return availableActions.indexOf(action) >= 0; + } + // ======= compatible apis ==== isEmpty(): boolean { return this.children ? this.children.isEmpty() : true; @@ -702,6 +720,7 @@ export class Node { getComponentName() { return this.componentName; } + insertBefore(node: Node, ref?: Node, useMutator = true) { this.children?.insert(node, ref ? ref.index : null, useMutator); } @@ -855,10 +874,20 @@ export class Node { return this.document.simulator?.computeRect(this) || null; } + /** + * @deprecated + */ getPrototype() { return this.componentMeta.prototype; } + /** + * @deprecated + */ + setPrototype(proto: any) { + this.componentMeta.prototype = proto; + } + getIcon() { return this.icon; } diff --git a/packages/designer/src/document/node/props/prop.ts b/packages/designer/src/document/node/props/prop.ts index 40e8a502b..3ba60b5f3 100644 --- a/packages/designer/src/document/node/props/prop.ts +++ b/packages/designer/src/document/node/props/prop.ts @@ -71,6 +71,10 @@ export class Prop implements IPropParent { } if (type === 'literal' || type === 'expression') { + // TODO 后端改造之后删除此逻辑 + if (this._value === null && stage === TransformStage.Save) { + return ''; + } return this._value; } @@ -181,7 +185,7 @@ export class Prop implements IPropParent { this._code = null; const t = typeof val; if (val == null) { - this._value = undefined; + // this._value = undefined; this._type = 'literal'; } else if (t === 'string' || t === 'number' || t === 'boolean') { this._type = 'literal'; diff --git a/packages/designer/src/simulator.ts b/packages/designer/src/simulator.ts index f051bc1f8..665f64a50 100644 --- a/packages/designer/src/simulator.ts +++ b/packages/designer/src/simulator.ts @@ -1,5 +1,5 @@ import { Component as ReactComponent, ComponentType } from 'react'; -import { ComponentMetadata, ComponentSchema } from '@ali/lowcode-types'; +import { ComponentMetadata, NodeSchema } from '@ali/lowcode-types'; import { ISensor, Point, ScrollTarget, IScrollable } from './designer'; import { Node } from './document'; @@ -127,9 +127,9 @@ export interface ISimulatorHost

extends ISensor { */ getComponentInstances(node: Node): ComponentInstance[] | null; /** - * 根据低代码组件 schema 创建组件类 + * 根据 schema 创建组件类 */ - createComponent(schema: ComponentSchema): Component | null; + createComponent(schema: NodeSchema): Component | null; /** * 根据节点获取节点的组件运行上下文 */ diff --git a/packages/editor-preset-general/CHANGELOG.md b/packages/editor-preset-general/CHANGELOG.md index d3df05e9b..c01ca8874 100644 --- a/packages/editor-preset-general/CHANGELOG.md +++ b/packages/editor-preset-general/CHANGELOG.md @@ -3,48 +3,88 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +<<<<<<< HEAD # [1.0.0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-preset-general-beta@0.14.0...@ali/lowcode-editor-preset-general-beta@1.0.0) (2020-08-17) +======= + +## [0.9.28](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-preset-general@0.9.27...@ali/lowcode-editor-preset-general@0.9.28) (2020-08-14) +>>>>>>> master +<<<<<<< HEAD **Note:** Version bump only for package @ali/lowcode-editor-preset-general-beta # [0.14.0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-preset-general-beta@0.13.0...@ali/lowcode-editor-preset-general-beta@0.14.0) (2020-08-17) +======= +**Note:** Version bump only for package @ali/lowcode-editor-preset-general + + +## [0.9.27](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-preset-general@0.9.26...@ali/lowcode-editor-preset-general@0.9.27) (2020-08-14) +>>>>>>> master +<<<<<<< HEAD **Note:** Version bump only for package @ali/lowcode-editor-preset-general-beta # [0.13.0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-preset-general-beta@0.11.0...@ali/lowcode-editor-preset-general-beta@0.13.0) (2020-08-17) +======= +**Note:** Version bump only for package @ali/lowcode-editor-preset-general + + +## [0.9.26](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-preset-general@0.9.25...@ali/lowcode-editor-preset-general@0.9.26) (2020-08-07) +>>>>>>> master +<<<<<<< HEAD **Note:** Version bump only for package @ali/lowcode-editor-preset-general-beta # [0.12.0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-preset-general-beta@0.11.0...@ali/lowcode-editor-preset-general-beta@0.12.0) (2020-08-17) +======= +**Note:** Version bump only for package @ali/lowcode-editor-preset-general + + +## [0.9.25](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-preset-general@0.9.24...@ali/lowcode-editor-preset-general@0.9.25) (2020-08-06) +>>>>>>> master +<<<<<<< HEAD **Note:** Version bump only for package @ali/lowcode-editor-preset-general-beta # 0.11.0 (2020-08-16) +======= +**Note:** Version bump only for package @ali/lowcode-editor-preset-general + + +## [0.9.24](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-preset-general@0.9.23...@ali/lowcode-editor-preset-general@0.9.24) (2020-08-06) +>>>>>>> master +<<<<<<< HEAD **Note:** Version bump only for package @ali/lowcode-editor-preset-general-beta # [0.10.0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-preset-general@0.9.22...@ali/lowcode-editor-preset-general@0.10.0) (2020-08-14) +======= +**Note:** Version bump only for package @ali/lowcode-editor-preset-general + + +## [0.9.23](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-preset-general@0.9.22...@ali/lowcode-editor-preset-general@0.9.23) (2020-08-06) +>>>>>>> master diff --git a/packages/editor-preset-vision/CHANGELOG.md b/packages/editor-preset-vision/CHANGELOG.md index cce2db9a4..7add6bb0e 100644 --- a/packages/editor-preset-vision/CHANGELOG.md +++ b/packages/editor-preset-vision/CHANGELOG.md @@ -3,6 +3,7 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +<<<<<<< HEAD # [1.0.0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-preset-vision@0.13.0...@ali/lowcode-editor-preset-vision@1.0.0) (2020-08-17) @@ -13,12 +14,28 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline # [0.13.0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-preset-vision@0.12.0...@ali/lowcode-editor-preset-vision@0.13.0) (2020-08-17) +======= + +## [0.8.45](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-preset-vision@0.8.44...@ali/lowcode-editor-preset-vision@0.8.45) (2020-08-14) + + +### Bug Fixes + +* 兼容 rpx ([5050af7](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/5050af7)) + + + + + +## [0.8.44](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-preset-vision@0.8.43...@ali/lowcode-editor-preset-vision@0.8.44) (2020-08-14) +>>>>>>> master **Note:** Version bump only for package @ali/lowcode-editor-preset-vision +<<<<<<< HEAD # [0.12.0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-preset-vision@0.10.0...@ali/lowcode-editor-preset-vision@0.12.0) (2020-08-17) @@ -37,10 +54,35 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline # [0.10.0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-preset-vision@0.9.0...@ali/lowcode-editor-preset-vision@0.10.0) (2020-08-16) +======= + +## [0.8.43](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-preset-vision@0.8.42...@ali/lowcode-editor-preset-vision@0.8.43) (2020-08-14) + + +### Bug Fixes + +* createComponent 支持所有 schema ([7f946f5](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/7f946f5)) +* upgradePropsReducer ([e68977f](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/e68977f)) +* vision 大包 window 指向问题 ([aa1b526](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/aa1b526)) +* 不对外暴露 Node ([05957ce](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/05957ce)) +* 支持 AC 组件 ([c287bad](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/c287bad)) + +## [0.8.42](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-preset-vision@0.8.41...@ali/lowcode-editor-preset-vision@0.8.42) (2020-08-07) + + +### Bug Fixes + +* vision API 兼容 DockPane.getDocks() ([f72fb66](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/f72fb66)) +>>>>>>> master + + + + +<<<<<<< HEAD **Note:** Version bump only for package @ali/lowcode-editor-preset-vision @@ -50,6 +92,42 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline **Note:** Version bump only for package @ali/lowcode-editor-preset-vision +======= + +## [0.8.41](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-preset-vision@0.8.40...@ali/lowcode-editor-preset-vision@0.8.41) (2020-08-06) + + +### Bug Fixes + +* fieldId 重复问题 ([e761b1a](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/e761b1a)) + + + + + +## [0.8.40](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-preset-vision@0.8.39...@ali/lowcode-editor-preset-vision@0.8.40) (2020-08-06) + + +### Bug Fixes + +* 保存区块按钮渲染异常 ([33a7227](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/33a7227)) +* 增加兼容 API ([2960446](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/2960446)) + + + + + +## [0.8.39](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-preset-vision@0.8.38...@ali/lowcode-editor-preset-vision@0.8.39) (2020-08-06) + + +### Bug Fixes + +* 修复 preset-vision 版本 lifeCycles 丢失以及 slot 初始化问题 ([7cf6d24](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/7cf6d24)) +* 框架样式调整 ([58790c5](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/58790c5)) + + + +>>>>>>> master ## [0.8.38](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-preset-vision@0.8.37...@ali/lowcode-editor-preset-vision@0.8.38) (2020-08-04) diff --git a/packages/editor-preset-vision/src/bundle/bundle.ts b/packages/editor-preset-vision/src/bundle/bundle.ts index c913b7e84..8b0ce27d5 100644 --- a/packages/editor-preset-vision/src/bundle/bundle.ts +++ b/packages/editor-preset-vision/src/bundle/bundle.ts @@ -2,6 +2,7 @@ import lg from '@ali/vu-logger'; import { ComponentClass, ComponentType } from 'react'; import Prototype, { isPrototype } from './prototype'; import { designer } from '../editor'; +import trunk from './trunk'; function basename(name: string) { return name ? (/[^\/]+$/.exec(name) || [''])[0] : ''; @@ -65,6 +66,22 @@ export default class Bundle { this.recursivelyRegisterPrototypes(prototype, item); } }); + + // invoke prototype mocker while the prototype does not exist + Object.keys(this.viewsMap).forEach((viewName) => { + const test = this; + // console.log(test, viewName); + if (!this.prototypeList.find((proto) => proto.getComponentName() === viewName)) { + const mockedPrototype = trunk.mockComponentPrototype(this.viewsMap[viewName]); + if (mockedPrototype) { + mockedPrototype.setView(this.viewsMap[viewName]); + this.registerPrototype(mockedPrototype); + if (!mockedPrototype.getPackageName()) { + mockedPrototype.setPackageName((this.viewsMap[viewName] as any)._packageName_); + } + } + } + }); } getFromMeta(componentName: string): Prototype { @@ -148,7 +165,7 @@ export default class Bundle { } if (isPrototype(proto)) { const componentName = proto.getComponentName()!; - if (!proto.getView() && this.viewsMap[componentName]) { + if (this.viewsMap[componentName]) { proto.setView(this.viewsMap[componentName]); } if (cp.name && !proto.getPackageName()) { diff --git a/packages/editor-preset-vision/src/bundle/prototype.ts b/packages/editor-preset-vision/src/bundle/prototype.ts index b1406c987..7499f899e 100644 --- a/packages/editor-preset-vision/src/bundle/prototype.ts +++ b/packages/editor-preset-vision/src/bundle/prototype.ts @@ -213,8 +213,8 @@ class Prototype { static addGlobalExtraActions = addGlobalExtraActions; static removeGlobalPropsConfigure = removeGlobalPropsConfigure; static overridePropsConfigure = overridePropsConfigure; - static create(config: OldPrototypeConfig | ComponentMetadata | ComponentMeta, lookup: boolean = false) { - return new Prototype(config, lookup); + static create(config: OldPrototypeConfig | ComponentMetadata | ComponentMeta, extraConfigs: any = null, lookup: boolean = false) { + return new Prototype(config, extraConfigs, lookup); } readonly isPrototype = true; @@ -224,7 +224,7 @@ class Prototype { return this.meta.npm?.package; } - constructor(input: OldPrototypeConfig | ComponentMetadata | ComponentMeta, lookup: boolean = false) { + constructor(input: OldPrototypeConfig | ComponentMetadata | ComponentMeta, extraConfigs: any = null, lookup: boolean = false) { if (lookup) { this.meta = designer.getComponentMeta(input.componentName); this.options = this.meta.getMetadata(); @@ -279,15 +279,15 @@ class Prototype { private category?: string; getCategory() { - if (this.category != null) { - return this.category; + if (this.options.category != null) { + return this.options.category; } return this.meta.getMetadata().tags?.[0] || '*'; } setCategory(category: string) { - this.category = category; + this.options.category = category; } getIcon() { diff --git a/packages/editor-preset-vision/src/bundle/trunk.ts b/packages/editor-preset-vision/src/bundle/trunk.ts index b8e0f19d6..4ae5ed640 100644 --- a/packages/editor-preset-vision/src/bundle/trunk.ts +++ b/packages/editor-preset-vision/src/bundle/trunk.ts @@ -3,11 +3,13 @@ import { EventEmitter } from 'events'; import { registerSetter, RegisteredSetter, getSetter } from '@ali/lowcode-editor-core'; import Bundle from './bundle'; import { CustomView } from '@ali/lowcode-types'; +import Prototype from './prototype'; export class Trunk { private trunk: any[] = []; private emitter: EventEmitter = new EventEmitter(); private metaBundle = new Bundle(); + private componentPrototypeMocker: any; isReady() { return this.getList().length > 0; @@ -25,7 +27,13 @@ export class Trunk { getList(): any[] { const list = this.trunk.reduceRight((prev, cur) => prev.concat(cur.getList()), []); - return Array.from(new Set(list)); + const result: Prototype[] = []; + list.forEach((item: Prototype) => { + if (!result.find(r => r.options.componentName === item.options.componentName)) { + result.push(item); + } + }); + return result; } getPrototype(name: string) { @@ -98,8 +106,16 @@ export class Trunk { console.warn('Trunk.afterLoadBundle is deprecated'); } - registerComponentPrototypeMocker() { - console.warn('Trunk.registerComponentPrototypeMocker is deprecated'); + registerComponentPrototypeMocker(mocker: any) { + this.componentPrototypeMocker = mocker; + } + + mockComponentPrototype(bundle: any) { + if (!this.componentPrototypeMocker) { + lg.error('ERROR: no component prototypeMocker is set'); + } + return this.componentPrototypeMocker + && this.componentPrototypeMocker.mockPrototype(bundle); } setPackages() { @@ -113,6 +129,10 @@ export class Trunk { } return setter; } + + getRecents(limit: number) { + return this.getList().filter((prototype) => prototype.getCategory()).slice(0, limit); + } } export default new Trunk(); diff --git a/packages/editor-preset-vision/src/bundle/upgrade-metadata.ts b/packages/editor-preset-vision/src/bundle/upgrade-metadata.ts index 4af320f41..c03b7f82e 100644 --- a/packages/editor-preset-vision/src/bundle/upgrade-metadata.ts +++ b/packages/editor-preset-vision/src/bundle/upgrade-metadata.ts @@ -564,7 +564,7 @@ export function upgradeActions(actions?: Array | ReactElement if (typeof content === 'function') { const fn = content as () => ReactElement; content = (({ node }: any) => { - fn.call(node); + return fn.call(node); }) as any; } return { diff --git a/packages/editor-preset-vision/src/editor.ts b/packages/editor-preset-vision/src/editor.ts index aecaa7410..70fc3860a 100644 --- a/packages/editor-preset-vision/src/editor.ts +++ b/packages/editor-preset-vision/src/editor.ts @@ -1,7 +1,7 @@ import { isJSBlock, isJSExpression, isJSSlot, isI18nData } from '@ali/lowcode-types'; import { isPlainObject, hasOwnProperty } from '@ali/lowcode-utils'; import { globalContext, Editor } from '@ali/lowcode-editor-core'; -import { Designer, LiveEditing, TransformStage, Node } from '@ali/lowcode-designer'; +import { Designer, LiveEditing, TransformStage, Node, getConvertedExtraKey } from '@ali/lowcode-designer'; import Outline, { OutlineBackupPane, getTreeMaster } from '@ali/lowcode-plugin-outline-pane'; import { toCss } from '@ali/vu-css-style'; import logger from '@ali/vu-logger'; @@ -25,10 +25,17 @@ export const designer = new Designer({ editor: editor }); editor.set(Designer, designer); editor.set('designer', designer); +const nodeCache: any = {}; designer.project.onCurrentDocumentChange((doc) => { doc.onRendererReady(() => { bus.emit(VE_EVENTS.VE_PAGE_PAGE_READY); }); + doc.onNodeCreate((node) => { + nodeCache[node.id] = node; + }); + doc.onNodeDestroy((node) => { + delete nodeCache[node.id]; + }); }); interface Variable { @@ -42,49 +49,61 @@ function isVariable(obj: any): obj is Variable { } function upgradePropsReducer(props: any) { - if (!isPlainObject(props)) { + if (!props || !isPlainObject(props)) { return props; } + if (isJSBlock(props)) { + if (props.value.componentName === 'Slot') { + return { + type: 'JSSlot', + title: (props.value.props as any)?.slotTitle, + name: (props.value.props as any)?.slotName, + value: props.value.children, + }; + } else { + return props.value; + } + } + if (isVariable(props)) { + return { + type: 'JSExpression', + value: props.variable, + mock: props.value, + }; + } const newProps: any = {}; - Object.entries(props).forEach(([key, val]) => { - if (/^__slot__/.test(key) && val === true) { + Object.keys(props).forEach(key => { + if (/^__slot__/.test(key) && props[key] === true) { return; } - if (isJSBlock(val)) { - if (val.value.componentName === 'Slot') { - val = { - type: 'JSSlot', - title: (val.value.props as any)?.slotTitle, - name: (val.value.props as any)?.slotName, - value: val.value.children, - }; - } else { - val = val.value; - } - } - // todo: deep find - if (isVariable(val)) { - val = { - type: 'JSExpression', - value: val.variable, - mock: val.value, - }; - } - newProps[key] = val; + newProps[key] = upgradePropsReducer(props[key]); }); return newProps; } + // 升级 Props designer.addPropsReducer(upgradePropsReducer, TransformStage.Upgrade); // 节点 props 初始化 designer.addPropsReducer((props, node) => { // run initials + const newProps: any = { + ...props, + }; + if (newProps.fieldId) { + const fieldIds: any = []; + Object.keys(nodeCache).forEach(nodeId => { + const fieldId = nodeCache[nodeId].getPropValue('fieldId'); + if (fieldId) { + fieldIds.push(fieldId); + } + }); + if (fieldIds.indexOf(props.fieldId) >= 0) { + newProps.fieldId = undefined; + } + } const initials = node.componentMeta.getMetadata().experimental?.initials; if (initials) { - const newProps: any = { - ...props, - }; const getRealValue = (propValue: any) => { if (isVariable(propValue)) { return propValue.value; @@ -98,22 +117,10 @@ designer.addPropsReducer((props, node) => { // FIXME! this implements SettingTarget try { // FIXME! item.name could be 'xxx.xxx' - const ov = props[item.name]; + const ov = newProps[item.name]; const v = item.initial(node as any, getRealValue(ov)); - if (!ov && v !== undefined) { - if (isVariable(ov)) { - newProps[item.name] = { - ...ov, - value: v, - }; - } else if (isJSExpression(ov)) { - newProps[item.name] = { - ...ov, - mock: v, - }; - } else { - newProps[item.name] = v; - } + if (ov === undefined && v !== undefined) { + newProps[item.name] = v; } } catch (e) { if (hasOwnProperty(props, item.name)) { @@ -124,11 +131,19 @@ designer.addPropsReducer((props, node) => { node.props.add(newProps[item.name], item.name); } }); + } + return newProps; +}, TransformStage.Init); - return newProps; +designer.addPropsReducer((props: any, node: Node) => { + if (node.isRoot() && props && props.lifeCycles) { + return { + ...props, + lifeCycles: {}, + } } return props; -}, TransformStage.Init); +}, TransformStage.Render); function filterReducer(props: any, node: Node): any { const filters = node.componentMeta.getMetadata().experimental?.filters; @@ -188,6 +203,20 @@ function compatiableReducer(props: any) { } // FIXME: Dirty fix, will remove this reducer designer.addPropsReducer(compatiableReducer, TransformStage.Save); +// 兼容历史版本的 Page 组件 +designer.addPropsReducer((props: any, node: Node) => { + const lifeCycleNames = ['didMount', 'willUnmount']; + if (node.isRoot()) { + lifeCycleNames.forEach(key => { + if (props[key]) { + const lifeCycles = node.props.getPropValue(getConvertedExtraKey('lifeCycles')) || {}; + lifeCycles[key] = props[key]; + node.props.setPropValue(getConvertedExtraKey('lifeCycles'), lifeCycles); + } + }); + } + return props; +}, TransformStage.Save); // 设计器组件样式处理 function stylePropsReducer(props: any, node: any) { @@ -231,7 +260,9 @@ function appendStyleNode(props: any, styleProp: any, cssClass: string, cssId: st s.setAttribute('id', cssId); doc.getElementsByTagName('head')[0].appendChild(s); - s.appendChild(doc.createTextNode(styleProp.replace(/:root/g, '.' + cssClass))); + s.appendChild(doc.createTextNode(styleProp.replace(/(\d+)rpx/g, (a, b) => { + return `${b / 2}px`; + }).replace(/:root/g, '.' + cssClass))); } } designer.addPropsReducer(stylePropsReducer, TransformStage.Render); diff --git a/packages/editor-preset-vision/src/index.ts b/packages/editor-preset-vision/src/index.ts index 9df95fbc6..c619514e0 100644 --- a/packages/editor-preset-vision/src/index.ts +++ b/packages/editor-preset-vision/src/index.ts @@ -163,7 +163,7 @@ export { Symbols, }; -const version = '6.0.0(LowcodeEngine 0.9.0-beta)'; +const version = '6.0.0(LowcodeEngine 0.9.3)'; console.log( `%c VisionEngine %c v${version} `, diff --git a/packages/editor-preset-vision/src/pages.ts b/packages/editor-preset-vision/src/pages.ts index 4e9cd2c35..e11dddd89 100644 --- a/packages/editor-preset-vision/src/pages.ts +++ b/packages/editor-preset-vision/src/pages.ts @@ -42,7 +42,6 @@ const pages = Object.assign(project, { componentsTree[0].componentName = componentsTree[0].componentName || 'Page'; // FIXME if (componentsTree[0].componentName === 'Page' || componentsTree[0].componentName === 'Component') { - componentsTree[0].lifeCycles = {}; componentsTree[0].methods = {}; } } @@ -56,6 +55,11 @@ const pages = Object.assign(project, { }, true, ); + + // FIXME: 根本原因应该是 propStash 导致的,这样可以避免页面加载之后就被标记为 isModified + setTimeout(() => { + project.currentDocument?.history.savePoint(); + }, 0); }, addPage(data: OldPageData | RootSchema) { if (isPageDataV1(data)) { diff --git a/packages/editor-preset-vision/src/panes.ts b/packages/editor-preset-vision/src/panes.ts index 5f4b9fdce..5d4e063cd 100644 --- a/packages/editor-preset-vision/src/panes.ts +++ b/packages/editor-preset-vision/src/panes.ts @@ -161,6 +161,9 @@ const actionPane = Object.assign(skeleton.topArea, { setActions() { // empty }, + get actions() { + return skeleton.topArea.container.items; + }, }); const dockPane = Object.assign(skeleton.leftArea, { /** @@ -210,6 +213,9 @@ const dockPane = Object.assign(skeleton.leftArea, { setFixed(flag: boolean) { // todo: }, + getDocks() { + return skeleton.leftFloatArea?.container.items; + }, }); const tabPane = Object.assign(skeleton.rightArea, { setFloat(flag: boolean) { diff --git a/packages/editor-preset-vision/src/vision.less b/packages/editor-preset-vision/src/vision.less index df469d567..ffaff2b83 100644 --- a/packages/editor-preset-vision/src/vision.less +++ b/packages/editor-preset-vision/src/vision.less @@ -49,7 +49,7 @@ html.engine-blur #engine { .engine-main { width: 100%; height: 100%; - position: relative; + position: fixed; .ve-icon-button { > .ve-icon-contents { @@ -121,4 +121,4 @@ html.engine-preview-mode { align-items: center; line-height: 22px; } -} \ No newline at end of file +} diff --git a/packages/editor-skeleton/CHANGELOG.md b/packages/editor-skeleton/CHANGELOG.md index 6b9657db0..46f0f1dcb 100644 --- a/packages/editor-skeleton/CHANGELOG.md +++ b/packages/editor-skeleton/CHANGELOG.md @@ -3,14 +3,20 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +<<<<<<< HEAD # [1.0.0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-skeleton@0.13.0...@ali/lowcode-editor-skeleton@1.0.0) (2020-08-17) +======= + +## [0.8.49](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-skeleton@0.8.48...@ali/lowcode-editor-skeleton@0.8.49) (2020-08-14) +>>>>>>> master **Note:** Version bump only for package @ali/lowcode-editor-skeleton +<<<<<<< HEAD # [0.13.0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-skeleton@0.12.0...@ali/lowcode-editor-skeleton@0.13.0) (2020-08-17) @@ -21,28 +27,51 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline # [0.12.0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-skeleton@0.10.0...@ali/lowcode-editor-skeleton@0.12.0) (2020-08-17) +======= + +## [0.8.48](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-skeleton@0.8.47...@ali/lowcode-editor-skeleton@0.8.48) (2020-08-14) + + +### Bug Fixes + +* remove console ([6889123](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/6889123)) +* setter 报错不影响页面渲染 ([c0a6022](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/c0a6022)) +* vision 大包 window 指向问题 ([aa1b526](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/aa1b526)) +* 钉住行为调整 ([91a390e](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/91a390e)) +>>>>>>> master +<<<<<<< HEAD **Note:** Version bump only for package @ali/lowcode-editor-skeleton # [0.11.0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-skeleton@0.10.0...@ali/lowcode-editor-skeleton@0.11.0) (2020-08-17) +======= + +## [0.8.47](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-skeleton@0.8.46...@ali/lowcode-editor-skeleton@0.8.47) (2020-08-07) +>>>>>>> master **Note:** Version bump only for package @ali/lowcode-editor-skeleton +<<<<<<< HEAD # [0.10.0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-skeleton@0.9.0...@ali/lowcode-editor-skeleton@0.10.0) (2020-08-16) +======= + +## [0.8.46](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-skeleton@0.8.45...@ali/lowcode-editor-skeleton@0.8.46) (2020-08-06) +>>>>>>> master **Note:** Version bump only for package @ali/lowcode-editor-skeleton +<<<<<<< HEAD # [0.9.0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-skeleton@0.8.43...@ali/lowcode-editor-skeleton@0.9.0) (2020-08-14) @@ -61,6 +90,23 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline +======= + +## [0.8.45](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-skeleton@0.8.44...@ali/lowcode-editor-skeleton@0.8.45) (2020-08-06) + + + + +**Note:** Version bump only for package @ali/lowcode-editor-skeleton + + +## [0.8.44](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-skeleton@0.8.43...@ali/lowcode-editor-skeleton@0.8.44) (2020-08-06) + + + + +**Note:** Version bump only for package @ali/lowcode-editor-skeleton +>>>>>>> master ## [0.8.43](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-skeleton@0.8.42...@ali/lowcode-editor-skeleton@0.8.43) (2020-08-04) diff --git a/packages/editor-skeleton/src/components/field/fields.tsx b/packages/editor-skeleton/src/components/field/fields.tsx index 6d0c3bd9f..5b3508d64 100644 --- a/packages/editor-skeleton/src/components/field/fields.tsx +++ b/packages/editor-skeleton/src/components/field/fields.tsx @@ -25,6 +25,7 @@ export class Field extends Component { state = { collapsed: this.props.collapsed, display: this.props.defaultDisplay || 'inline', + hasError: false, }; constructor(props: any) { @@ -88,6 +89,10 @@ export class Field extends Component { } } + static getDerivedStateFromError() { + return { hasError: true }; + } + getTipContent(propName: string, tip?: any): any { let tipContent = (

@@ -114,6 +119,11 @@ export class Field extends Component { } render() { + const { hasError } = this.state; + if (hasError) { + return null; + } + const { className, children, meta, title, valueState, onClear, name: propName, tip } = this.props; const { display, collapsed } = this.state; const isAccordion = display === 'accordion'; diff --git a/packages/editor-skeleton/src/layouts/left-float-pane.tsx b/packages/editor-skeleton/src/layouts/left-float-pane.tsx index 6d184c5ac..493490cd7 100644 --- a/packages/editor-skeleton/src/layouts/left-float-pane.tsx +++ b/packages/editor-skeleton/src/layouts/left-float-pane.tsx @@ -63,6 +63,13 @@ export default class LeftFloatPane extends Component<{ area: Area }> const { area } = this.props; if (area.visible) { this.focusing?.active(); + // 关闭当前fixed区域的面板 + // TODO: 看看有没有更合适的地方 + const fixedContainer = area?.skeleton?.leftFixedArea?.container; + const currentFixed = fixedContainer?.current; + if (currentFixed) { + fixedContainer.unactive(currentFixed); + } } else { this.focusing?.suspense(); } diff --git a/packages/editor-skeleton/src/layouts/workbench.less b/packages/editor-skeleton/src/layouts/workbench.less index 0ceaea4cc..6de8cbe09 100644 --- a/packages/editor-skeleton/src/layouts/workbench.less +++ b/packages/editor-skeleton/src/layouts/workbench.less @@ -239,7 +239,7 @@ body { top: 0; bottom: 0; width: var(--dock-pane-width); - min-width: var(--dock-fixed-pane-width); + // min-width: var(--dock-fixed-pane-width); left: calc(var(--left-area-width) + 1px); background-color: var(--color-pane-background); box-shadow: 4px 6px 6px 0 rgba(31,50,88,0.08); diff --git a/packages/plugin-components-pane/CHANGELOG.md b/packages/plugin-components-pane/CHANGELOG.md index 901fd515a..111338b69 100644 --- a/packages/plugin-components-pane/CHANGELOG.md +++ b/packages/plugin-components-pane/CHANGELOG.md @@ -3,48 +3,78 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +<<<<<<< HEAD # [1.0.0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-plugin-components-pane@0.13.0...@ali/lowcode-plugin-components-pane@1.0.0) (2020-08-17) +======= + +## [0.8.45](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-plugin-components-pane@0.8.44...@ali/lowcode-plugin-components-pane@0.8.45) (2020-08-14) +>>>>>>> master **Note:** Version bump only for package @ali/lowcode-plugin-components-pane +<<<<<<< HEAD # [0.13.0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-plugin-components-pane@0.12.0...@ali/lowcode-plugin-components-pane@0.13.0) (2020-08-17) +======= + +## [0.8.44](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-plugin-components-pane@0.8.43...@ali/lowcode-plugin-components-pane@0.8.44) (2020-08-14) +>>>>>>> master **Note:** Version bump only for package @ali/lowcode-plugin-components-pane +<<<<<<< HEAD # [0.12.0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-plugin-components-pane@0.10.0...@ali/lowcode-plugin-components-pane@0.12.0) (2020-08-17) +======= + +## [0.8.43](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-plugin-components-pane@0.8.42...@ali/lowcode-plugin-components-pane@0.8.43) (2020-08-07) +>>>>>>> master **Note:** Version bump only for package @ali/lowcode-plugin-components-pane +<<<<<<< HEAD # [0.11.0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-plugin-components-pane@0.10.0...@ali/lowcode-plugin-components-pane@0.11.0) (2020-08-17) +======= + +## [0.8.42](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-plugin-components-pane@0.8.41...@ali/lowcode-plugin-components-pane@0.8.42) (2020-08-06) +>>>>>>> master **Note:** Version bump only for package @ali/lowcode-plugin-components-pane +<<<<<<< HEAD # [0.10.0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-plugin-components-pane@0.9.0...@ali/lowcode-plugin-components-pane@0.10.0) (2020-08-16) +======= + +## [0.8.41](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-plugin-components-pane@0.8.40...@ali/lowcode-plugin-components-pane@0.8.41) (2020-08-06) +>>>>>>> master **Note:** Version bump only for package @ali/lowcode-plugin-components-pane +<<<<<<< HEAD # [0.9.0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-plugin-components-pane@0.8.39...@ali/lowcode-plugin-components-pane@0.9.0) (2020-08-14) +======= + +## [0.8.40](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-plugin-components-pane@0.8.39...@ali/lowcode-plugin-components-pane@0.8.40) (2020-08-06) +>>>>>>> master diff --git a/packages/plugin-designer/CHANGELOG.md b/packages/plugin-designer/CHANGELOG.md index d6670f278..82ee63763 100644 --- a/packages/plugin-designer/CHANGELOG.md +++ b/packages/plugin-designer/CHANGELOG.md @@ -3,48 +3,78 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +<<<<<<< HEAD # [1.0.0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-plugin-designer@0.14.0...@ali/lowcode-plugin-designer@1.0.0) (2020-08-17) +======= + +## [0.9.43](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-plugin-designer@0.9.42...@ali/lowcode-plugin-designer@0.9.43) (2020-08-14) +>>>>>>> master **Note:** Version bump only for package @ali/lowcode-plugin-designer +<<<<<<< HEAD # [0.14.0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-plugin-designer@0.13.0...@ali/lowcode-plugin-designer@0.14.0) (2020-08-17) +======= + +## [0.9.42](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-plugin-designer@0.9.41...@ali/lowcode-plugin-designer@0.9.42) (2020-08-14) +>>>>>>> master **Note:** Version bump only for package @ali/lowcode-plugin-designer +<<<<<<< HEAD # [0.13.0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-plugin-designer@0.11.0...@ali/lowcode-plugin-designer@0.13.0) (2020-08-17) +======= + +## [0.9.41](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-plugin-designer@0.9.40...@ali/lowcode-plugin-designer@0.9.41) (2020-08-07) +>>>>>>> master **Note:** Version bump only for package @ali/lowcode-plugin-designer +<<<<<<< HEAD # [0.12.0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-plugin-designer@0.11.0...@ali/lowcode-plugin-designer@0.12.0) (2020-08-17) +======= + +## [0.9.40](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-plugin-designer@0.9.39...@ali/lowcode-plugin-designer@0.9.40) (2020-08-06) +>>>>>>> master **Note:** Version bump only for package @ali/lowcode-plugin-designer +<<<<<<< HEAD # [0.11.0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-plugin-designer@0.10.0...@ali/lowcode-plugin-designer@0.11.0) (2020-08-16) +======= + +## [0.9.39](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-plugin-designer@0.9.38...@ali/lowcode-plugin-designer@0.9.39) (2020-08-06) +>>>>>>> master **Note:** Version bump only for package @ali/lowcode-plugin-designer +<<<<<<< HEAD # [0.10.0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-plugin-designer@0.9.37...@ali/lowcode-plugin-designer@0.10.0) (2020-08-14) +======= + +## [0.9.38](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-plugin-designer@0.9.37...@ali/lowcode-plugin-designer@0.9.38) (2020-08-06) +>>>>>>> master diff --git a/packages/plugin-outline-pane/CHANGELOG.md b/packages/plugin-outline-pane/CHANGELOG.md index 6e04a8ad9..bebbd110b 100644 --- a/packages/plugin-outline-pane/CHANGELOG.md +++ b/packages/plugin-outline-pane/CHANGELOG.md @@ -3,14 +3,20 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +<<<<<<< HEAD # [1.0.0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-plugin-outline-pane@0.13.0...@ali/lowcode-plugin-outline-pane@1.0.0) (2020-08-17) +======= + +## [0.8.49](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-plugin-outline-pane@0.8.48...@ali/lowcode-plugin-outline-pane@0.8.49) (2020-08-14) +>>>>>>> master **Note:** Version bump only for package @ali/lowcode-plugin-outline-pane +<<<<<<< HEAD # [0.13.0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-plugin-outline-pane@0.12.0...@ali/lowcode-plugin-outline-pane@0.13.0) (2020-08-17) @@ -21,28 +27,54 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline # [0.12.0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-plugin-outline-pane@0.10.0...@ali/lowcode-plugin-outline-pane@0.12.0) (2020-08-17) +======= + +## [0.8.48](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-plugin-outline-pane@0.8.47...@ali/lowcode-plugin-outline-pane@0.8.48) (2020-08-14) + + +### Bug Fixes + +* 卡片内容不可用拖动 ([6a85c43](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/6a85c43)) + + + + + +## [0.8.47](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-plugin-outline-pane@0.8.46...@ali/lowcode-plugin-outline-pane@0.8.47) (2020-08-07) +>>>>>>> master **Note:** Version bump only for package @ali/lowcode-plugin-outline-pane +<<<<<<< HEAD # [0.11.0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-plugin-outline-pane@0.10.0...@ali/lowcode-plugin-outline-pane@0.11.0) (2020-08-17) +======= + +## [0.8.46](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-plugin-outline-pane@0.8.45...@ali/lowcode-plugin-outline-pane@0.8.46) (2020-08-06) +>>>>>>> master **Note:** Version bump only for package @ali/lowcode-plugin-outline-pane +<<<<<<< HEAD # [0.10.0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-plugin-outline-pane@0.9.0...@ali/lowcode-plugin-outline-pane@0.10.0) (2020-08-16) +======= + +## [0.8.45](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-plugin-outline-pane@0.8.44...@ali/lowcode-plugin-outline-pane@0.8.45) (2020-08-06) +>>>>>>> master **Note:** Version bump only for package @ali/lowcode-plugin-outline-pane +<<<<<<< HEAD # [0.9.0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-plugin-outline-pane@0.8.43...@ali/lowcode-plugin-outline-pane@0.9.0) (2020-08-14) @@ -53,6 +85,15 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline +======= + +## [0.8.44](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-plugin-outline-pane@0.8.43...@ali/lowcode-plugin-outline-pane@0.8.44) (2020-08-06) + + + + +**Note:** Version bump only for package @ali/lowcode-plugin-outline-pane +>>>>>>> master ## [0.8.43](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-plugin-outline-pane@0.8.42...@ali/lowcode-plugin-outline-pane@0.8.43) (2020-08-04) diff --git a/packages/plugin-outline-pane/src/main.ts b/packages/plugin-outline-pane/src/main.ts index c221f02ec..1be1ac192 100644 --- a/packages/plugin-outline-pane/src/main.ts +++ b/packages/plugin-outline-pane/src/main.ts @@ -122,15 +122,27 @@ export class OutlineMain implements ISensor, ITreeBoard, IScrollable { locate(e: LocateEvent): DropLocation | undefined | null { this.sensing = true; this.scroller?.scrolling(e); + const { globalY, dragObject } = e; + const { nodes } = dragObject; const tree = this._master?.currentTree; if (!tree || !this._shell) { return null; } + const operationalNodes = nodes?.filter((node: any) => { + const onMoveHook = node.componentMeta?.getMetadata()?.experimental?.callbacks?.onMoveHook; + const canMove = onMoveHook && typeof onMoveHook === 'function' ? onMoveHook() : true; + + return canMove; + }); + + if (!operationalNodes || operationalNodes.length === 0) { + return; + } + const document = tree.document; const designer = document.designer; - const { globalY, dragObject } = e; const pos = getPosFromEvent(e, this._shell); const irect = this.getInsertionRect(); const originLoc = document.dropLocation; @@ -196,7 +208,7 @@ export class OutlineMain implements ISensor, ITreeBoard, IScrollable { let focusSlots = pos.focusSlots; let { node } = treeNode; if (isDragNodeObject(dragObject)) { - const nodes = dragObject.nodes; + const nodes = operationalNodes; let i = nodes.length; let p: any = node; while (i-- > 0) { diff --git a/packages/plugin-sample-preview/CHANGELOG.md b/packages/plugin-sample-preview/CHANGELOG.md index 993cc298c..9f4ac3add 100644 --- a/packages/plugin-sample-preview/CHANGELOG.md +++ b/packages/plugin-sample-preview/CHANGELOG.md @@ -3,38 +3,59 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +<<<<<<< HEAD # [1.0.0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-plugin-sample-preview@0.15.0...@ali/lowcode-plugin-sample-preview@1.0.0) (2020-08-17) +======= + +## [0.8.47](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-plugin-sample-preview@0.8.46...@ali/lowcode-plugin-sample-preview@0.8.47) (2020-08-14) +>>>>>>> master **Note:** Version bump only for package @ali/lowcode-plugin-sample-preview +<<<<<<< HEAD # [0.15.0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-plugin-sample-preview@0.14.0...@ali/lowcode-plugin-sample-preview@0.15.0) (2020-08-17) +======= + +## [0.8.46](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-plugin-sample-preview@0.8.45...@ali/lowcode-plugin-sample-preview@0.8.46) (2020-08-14) +>>>>>>> master **Note:** Version bump only for package @ali/lowcode-plugin-sample-preview +<<<<<<< HEAD # [0.14.0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-plugin-sample-preview@0.12.0...@ali/lowcode-plugin-sample-preview@0.14.0) (2020-08-17) +======= + +## [0.8.45](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-plugin-sample-preview@0.8.44...@ali/lowcode-plugin-sample-preview@0.8.45) (2020-08-07) +>>>>>>> master **Note:** Version bump only for package @ali/lowcode-plugin-sample-preview +<<<<<<< HEAD # [0.13.0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-plugin-sample-preview@0.12.0...@ali/lowcode-plugin-sample-preview@0.13.0) (2020-08-17) +======= + +## [0.8.44](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-plugin-sample-preview@0.8.43...@ali/lowcode-plugin-sample-preview@0.8.44) (2020-08-06) +>>>>>>> master **Note:** Version bump only for package @ali/lowcode-plugin-sample-preview +<<<<<<< HEAD # [0.12.0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-plugin-sample-preview@0.11.0...@ali/lowcode-plugin-sample-preview@0.12.0) (2020-08-16) @@ -48,20 +69,30 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline # [0.11.0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-plugin-sample-preview@0.10.0...@ali/lowcode-plugin-sample-preview@0.11.0) (2020-08-14) +======= + +## [0.8.43](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-plugin-sample-preview@0.8.42...@ali/lowcode-plugin-sample-preview@0.8.43) (2020-08-06) +>>>>>>> master **Note:** Version bump only for package @ali/lowcode-plugin-sample-preview +<<<<<<< HEAD # [0.10.0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-plugin-sample-preview@0.9.0...@ali/lowcode-plugin-sample-preview@0.10.0) (2020-08-14) +======= + +## [0.8.42](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-plugin-sample-preview@0.8.41...@ali/lowcode-plugin-sample-preview@0.8.42) (2020-08-06) +>>>>>>> master **Note:** Version bump only for package @ali/lowcode-plugin-sample-preview +<<<<<<< HEAD # [0.9.0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-plugin-sample-preview@0.8.41...@ali/lowcode-plugin-sample-preview@0.9.0) (2020-08-14) @@ -79,6 +110,8 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline +======= +>>>>>>> master ## [0.8.41](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-plugin-sample-preview@0.8.40...@ali/lowcode-plugin-sample-preview@0.8.41) (2020-08-04) diff --git a/packages/plugin-undo-redo/CHANGELOG.md b/packages/plugin-undo-redo/CHANGELOG.md index 6ac5f2180..080ecb9aa 100644 --- a/packages/plugin-undo-redo/CHANGELOG.md +++ b/packages/plugin-undo-redo/CHANGELOG.md @@ -3,46 +3,72 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +<<<<<<< HEAD # [1.0.0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-plugin-undo-redo@0.13.0...@ali/lowcode-plugin-undo-redo@1.0.0) (2020-08-17) +======= + +## [0.8.47](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-plugin-undo-redo@0.8.46...@ali/lowcode-plugin-undo-redo@0.8.47) (2020-08-14) +>>>>>>> master **Note:** Version bump only for package @ali/lowcode-plugin-undo-redo +<<<<<<< HEAD # [0.13.0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-plugin-undo-redo@0.12.0...@ali/lowcode-plugin-undo-redo@0.13.0) (2020-08-17) +======= + +## [0.8.46](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-plugin-undo-redo@0.8.45...@ali/lowcode-plugin-undo-redo@0.8.46) (2020-08-14) +>>>>>>> master **Note:** Version bump only for package @ali/lowcode-plugin-undo-redo +<<<<<<< HEAD # [0.12.0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-plugin-undo-redo@0.10.0...@ali/lowcode-plugin-undo-redo@0.12.0) (2020-08-17) +======= + +## [0.8.45](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-plugin-undo-redo@0.8.44...@ali/lowcode-plugin-undo-redo@0.8.45) (2020-08-07) +>>>>>>> master **Note:** Version bump only for package @ali/lowcode-plugin-undo-redo +<<<<<<< HEAD # [0.11.0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-plugin-undo-redo@0.10.0...@ali/lowcode-plugin-undo-redo@0.11.0) (2020-08-17) +======= + +## [0.8.44](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-plugin-undo-redo@0.8.43...@ali/lowcode-plugin-undo-redo@0.8.44) (2020-08-06) +>>>>>>> master **Note:** Version bump only for package @ali/lowcode-plugin-undo-redo +<<<<<<< HEAD # [0.10.0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-plugin-undo-redo@0.9.0...@ali/lowcode-plugin-undo-redo@0.10.0) (2020-08-16) +======= + +## [0.8.43](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-plugin-undo-redo@0.8.42...@ali/lowcode-plugin-undo-redo@0.8.43) (2020-08-06) +>>>>>>> master **Note:** Version bump only for package @ali/lowcode-plugin-undo-redo +<<<<<<< HEAD # [0.9.0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-plugin-undo-redo@0.8.41...@ali/lowcode-plugin-undo-redo@0.9.0) (2020-08-14) @@ -53,6 +79,15 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline +======= + +## [0.8.42](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-plugin-undo-redo@0.8.41...@ali/lowcode-plugin-undo-redo@0.8.42) (2020-08-06) + + + + +**Note:** Version bump only for package @ali/lowcode-plugin-undo-redo +>>>>>>> master ## [0.8.41](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-plugin-undo-redo@0.8.40...@ali/lowcode-plugin-undo-redo@0.8.41) (2020-08-04) diff --git a/packages/rax-render/CHANGELOG.md b/packages/rax-render/CHANGELOG.md index d784bc7c5..d42e70d16 100644 --- a/packages/rax-render/CHANGELOG.md +++ b/packages/rax-render/CHANGELOG.md @@ -3,6 +3,7 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +<<<<<<< HEAD # [1.0.0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-rax-renderer@0.5.0...@ali/lowcode-rax-renderer@1.0.0) (2020-08-17) @@ -44,6 +45,20 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline **Note:** Version bump only for package @ali/lowcode-rax-renderer +======= + +## [0.1.7](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-rax-renderer@0.1.6...@ali/lowcode-rax-renderer@0.1.7) (2020-08-14) + + +### Bug Fixes + +* **rax-render:** hidden无效 ([08a3e36](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/08a3e36)) + + + + + +>>>>>>> master ## [0.1.6](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-rax-renderer@0.1.5...@ali/lowcode-rax-renderer@0.1.6) (2020-07-22) @@ -112,7 +127,11 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline ### Features * init rax-render ([7167767](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/7167767)) +<<<<<<< HEAD +======= + +>>>>>>> master && && || diff --git a/packages/rax-render/src/engine/base.jsx b/packages/rax-render/src/engine/base.jsx index 92f86505d..850804129 100644 --- a/packages/rax-render/src/engine/base.jsx +++ b/packages/rax-render/src/engine/base.jsx @@ -241,6 +241,10 @@ export default class BaseEngine extends Component { if (!isSchema(schema)) return null; let Comp = components[schema.componentName] || engine.getNotFoundComponent(); + if (schema.hidden) { + return null; + } + if (schema.loop !== undefined) { return this.__createLoopVirtualDom( { diff --git a/packages/rax-simulator-renderer/CHANGELOG.md b/packages/rax-simulator-renderer/CHANGELOG.md index bff58610b..4c0c4370a 100644 --- a/packages/rax-simulator-renderer/CHANGELOG.md +++ b/packages/rax-simulator-renderer/CHANGELOG.md @@ -3,14 +3,20 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +<<<<<<< HEAD # [1.0.0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-rax-simulator-renderer@0.15.0...@ali/lowcode-rax-simulator-renderer@1.0.0) (2020-08-17) +======= + +## [0.8.47](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-rax-simulator-renderer@0.8.46...@ali/lowcode-rax-simulator-renderer@0.8.47) (2020-08-14) +>>>>>>> master **Note:** Version bump only for package @ali/lowcode-rax-simulator-renderer +<<<<<<< HEAD # [0.15.0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-rax-simulator-renderer@0.14.0...@ali/lowcode-rax-simulator-renderer@0.15.0) (2020-08-17) @@ -29,36 +35,67 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline # [0.13.0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-rax-simulator-renderer@0.12.0...@ali/lowcode-rax-simulator-renderer@0.13.0) (2020-08-17) +======= + +## [0.8.46](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-rax-simulator-renderer@0.8.45...@ali/lowcode-rax-simulator-renderer@0.8.46) (2020-08-14) + + +### Bug Fixes + +* update package.json ([f1ec59c](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/f1ec59c)) + + + + + +## [0.8.45](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-rax-simulator-renderer@0.8.44...@ali/lowcode-rax-simulator-renderer@0.8.45) (2020-08-14) +>>>>>>> master **Note:** Version bump only for package @ali/lowcode-rax-simulator-renderer +<<<<<<< HEAD # [0.12.0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-rax-simulator-renderer@0.11.0...@ali/lowcode-rax-simulator-renderer@0.12.0) (2020-08-16) +======= + +## [0.8.44](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-rax-simulator-renderer@0.8.43...@ali/lowcode-rax-simulator-renderer@0.8.44) (2020-08-07) +>>>>>>> master **Note:** Version bump only for package @ali/lowcode-rax-simulator-renderer +<<<<<<< HEAD # [0.11.0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-rax-simulator-renderer@0.10.0...@ali/lowcode-rax-simulator-renderer@0.11.0) (2020-08-14) +======= + +## [0.8.43](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-rax-simulator-renderer@0.8.42...@ali/lowcode-rax-simulator-renderer@0.8.43) (2020-08-06) +>>>>>>> master **Note:** Version bump only for package @ali/lowcode-rax-simulator-renderer +<<<<<<< HEAD # [0.10.0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-rax-simulator-renderer@0.9.0...@ali/lowcode-rax-simulator-renderer@0.10.0) (2020-08-14) +======= + +## [0.8.42](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-rax-simulator-renderer@0.8.41...@ali/lowcode-rax-simulator-renderer@0.8.42) (2020-08-06) +>>>>>>> master **Note:** Version bump only for package @ali/lowcode-rax-simulator-renderer +<<<<<<< HEAD # [0.9.0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-rax-simulator-renderer@0.8.40...@ali/lowcode-rax-simulator-renderer@0.9.0) (2020-08-14) @@ -66,6 +103,18 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline **Note:** Version bump only for package @ali/lowcode-rax-simulator-renderer +======= + +## [0.8.41](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-rax-simulator-renderer@0.8.40...@ali/lowcode-rax-simulator-renderer@0.8.41) (2020-08-06) + + +### Bug Fixes + +* 修复 preset-vision 版本 lifeCycles 丢失以及 slot 初始化问题 ([7cf6d24](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/7cf6d24)) + + + +>>>>>>> master ## [0.8.40](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-rax-simulator-renderer@0.8.39...@ali/lowcode-rax-simulator-renderer@0.8.40) (2020-08-04) diff --git a/packages/react-renderer/CHANGELOG.md b/packages/react-renderer/CHANGELOG.md index 1f95d419a..5c962449c 100644 --- a/packages/react-renderer/CHANGELOG.md +++ b/packages/react-renderer/CHANGELOG.md @@ -3,6 +3,7 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +<<<<<<< HEAD # [1.0.0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-react-renderer@0.15.0...@ali/lowcode-react-renderer@1.0.0) (2020-08-17) @@ -61,10 +62,15 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline # [0.9.0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-react-renderer@0.8.17...@ali/lowcode-react-renderer@0.9.0) (2020-08-14) +======= + +## [0.8.18](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-react-renderer@0.8.17...@ali/lowcode-react-renderer@0.8.18) (2020-08-14) +>>>>>>> master ### Bug Fixes +<<<<<<< HEAD * dropdown and menu schema ([ae1d125](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/ae1d125)) * parse custom methods function ([87d8b86](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/87d8b86)) @@ -72,6 +78,11 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline ### Features * 🎸 add demo-server ([df35c6a](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/df35c6a)) +======= +* remove debugger ([a835dc6](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/a835dc6)) +* render error样式 ([d601d5e](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/d601d5e)) +* 组件缺失占位 ([aff2f34](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/aff2f34)) +>>>>>>> master diff --git a/packages/react-renderer/src/engine/index.jsx b/packages/react-renderer/src/engine/index.jsx index 7afef11c6..27ab9254d 100644 --- a/packages/react-renderer/src/engine/index.jsx +++ b/packages/react-renderer/src/engine/index.jsx @@ -30,14 +30,33 @@ class FaultComponent extends PureComponent { render() { // FIXME: errorlog console.error('render error', this.props); - return
RenderError
; + const { _componentName: componentName } = this.props; + return
组件 {componentName} 渲染错误,请打开控制台排查
;; } } class NotFoundComponent extends PureComponent { render() { - console.error('component not found', this.props); - return
; + console.error('component not found:', this.props); + const { _componentName: componentName } = this.props; + return
组件 {componentName} 无视图,请打开控制台排查
; } } diff --git a/packages/react-simulator-renderer/CHANGELOG.md b/packages/react-simulator-renderer/CHANGELOG.md index 979f690b2..859c26418 100644 --- a/packages/react-simulator-renderer/CHANGELOG.md +++ b/packages/react-simulator-renderer/CHANGELOG.md @@ -3,6 +3,7 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +<<<<<<< HEAD # [1.0.0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-react-simulator-renderer@0.15.0...@ali/lowcode-react-simulator-renderer@1.0.0) (2020-08-17) @@ -29,10 +30,39 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline # [0.13.0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-react-simulator-renderer@0.12.0...@ali/lowcode-react-simulator-renderer@0.13.0) (2020-08-17) +======= + +## [0.8.49](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-react-simulator-renderer@0.8.48...@ali/lowcode-react-simulator-renderer@0.8.49) (2020-08-14) + + +### Bug Fixes + +* 支持低代码组件样式 ([6e64be1](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/6e64be1)) + +## [0.8.48](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-react-simulator-renderer@0.8.47...@ali/lowcode-react-simulator-renderer@0.8.48) (2020-08-14) + + + + +**Note:** Version bump only for package @ali/lowcode-react-simulator-renderer + + +## [0.8.47](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-react-simulator-renderer@0.8.46...@ali/lowcode-react-simulator-renderer@0.8.47) (2020-08-14) + + +### Bug Fixes + +* createComponent 支持所有 schema ([7f946f5](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/7f946f5)) +>>>>>>> master + + + + +<<<<<<< HEAD **Note:** Version bump only for package @ali/lowcode-react-simulator-renderer @@ -45,22 +75,47 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline # [0.11.0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-react-simulator-renderer@0.10.0...@ali/lowcode-react-simulator-renderer@0.11.0) (2020-08-14) +======= + +## [0.8.46](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-react-simulator-renderer@0.8.45...@ali/lowcode-react-simulator-renderer@0.8.46) (2020-08-07) + + +### Bug Fixes + +* 部分低代码组件渲染报错 ([093015c](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/093015c)) + + + + + +## [0.8.45](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-react-simulator-renderer@0.8.44...@ali/lowcode-react-simulator-renderer@0.8.45) (2020-08-06) +>>>>>>> master **Note:** Version bump only for package @ali/lowcode-react-simulator-renderer +<<<<<<< HEAD # [0.10.0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-react-simulator-renderer@0.9.0...@ali/lowcode-react-simulator-renderer@0.10.0) (2020-08-14) +======= + +## [0.8.44](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-react-simulator-renderer@0.8.43...@ali/lowcode-react-simulator-renderer@0.8.44) (2020-08-06) +>>>>>>> master **Note:** Version bump only for package @ali/lowcode-react-simulator-renderer +<<<<<<< HEAD # [0.9.0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-react-simulator-renderer@0.8.42...@ali/lowcode-react-simulator-renderer@0.9.0) (2020-08-14) +======= + +## [0.8.43](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-react-simulator-renderer@0.8.42...@ali/lowcode-react-simulator-renderer@0.8.43) (2020-08-06) +>>>>>>> master diff --git a/packages/react-simulator-renderer/src/renderer.ts b/packages/react-simulator-renderer/src/renderer.ts index 836aa5e29..0170ebca6 100644 --- a/packages/react-simulator-renderer/src/renderer.ts +++ b/packages/react-simulator-renderer/src/renderer.ts @@ -6,8 +6,15 @@ import { computed, obx } from '@recore/obx'; import { Asset } from '@ali/lowcode-utils'; import { getClientRects } from './utils/get-client-rects'; import { reactFindDOMNodes, FIBER_KEY } from './utils/react-find-dom-nodes'; -import { isElement, cursor, setNativeSelection, buildComponents, getSubComponent, AssetLoader } from '@ali/lowcode-utils'; -import { RootSchema, ComponentSchema, TransformStage } from '@ali/lowcode-types'; +import { + isElement, + cursor, + setNativeSelection, + buildComponents, + getSubComponent, + AssetLoader, +} from '@ali/lowcode-utils'; +import { RootSchema, ComponentSchema, TransformStage, NodeSchema } from '@ali/lowcode-types'; // just use types import { BuiltinSimulatorRenderer, NodeInstance, Component } from '@ali/lowcode-designer'; import Slot from './builtin-components/slot'; @@ -216,13 +223,22 @@ export class SimulatorRenderer implements BuiltinSimulatorRenderer { return this.instancesMap.get(id) || null; } - createComponent(schema: ComponentSchema): Component | null { + createComponent(schema: NodeSchema): Component | null { let _schema: any = { ...schema, }; _schema.methods = {}; _schema.lifeCycles = {}; + if (schema.componentName === 'Component' && (schema as ComponentSchema).css) { + const doc = window.document; + const s = doc.createElement('style'); + s.setAttribute('type', 'text/css'); + s.setAttribute('id', `Component-${schema.id || ''}`); + s.appendChild(doc.createTextNode((schema as ComponentSchema).css || '')); + doc.getElementsByTagName('head')[0].appendChild(s); + } + const node = host.document.createNode(_schema); _schema = node.export(TransformStage.Render); @@ -234,14 +250,14 @@ export class SimulatorRenderer implements BuiltinSimulatorRenderer { const result = { ...propsSchema }; const reg = /^(?:this\.props|props)\.(\S+)$/; Object.keys(result).map((key: string) => { - if (result[key].type === 'JSExpression') { + if (result[key]?.type === 'JSExpression') { const { value } = result[key]; const matched = reg.exec(value); if (matched) { const propName = matched[1]; result[key] = propsMap[propName]; } - } else if (result[key].type === 'JSSlot') { + } else if (result[key]?.type === 'JSSlot') { const schema = result[key].value; result[key] = createElement(Ele, { schema, propsMap: {} }); } @@ -271,6 +287,9 @@ export class SimulatorRenderer implements BuiltinSimulatorRenderer { } const { schema, propsMap } = this.props; const Com = componentsMap[schema.componentName]; + if (!Com) { + return null; + } let children = null; if (schema.children && schema.children.length > 0) { children = schema.children.map((item: any) => createElement(Ele, { schema: item, propsMap })); @@ -283,13 +302,23 @@ export class SimulatorRenderer implements BuiltinSimulatorRenderer { } class Com extends React.Component { + // TODO: 暂时解决性能问题 + shouldComponentUpdate() { + return false; + } + render() { - let children = []; - const propsMap = this.props; - if (_schema.children && Array.isArray(_schema.children)) { - children = _schema.children.map((item: any) => createElement(Ele, { schema: item, propsMap })); + const componentName = _schema.componentName; + if (componentName === 'Component') { + let children = []; + const propsMap = this.props || {}; + if (_schema.children && Array.isArray(_schema.children)) { + children = _schema.children.map((item: any) => createElement(Ele, { schema: item, propsMap })); + } + return createElement('div', {}, children); + } else { + return createElement(Ele, { schema: _schema, propsMap: {} }); } - return createElement(React.Fragment, {}, children); } }