mirror of
https://github.com/alibaba/lowcode-engine.git
synced 2026-03-07 10:57:19 +00:00
refactor: .experimental -> .configure.advanced
This commit is contained in:
parent
befc669f99
commit
11078f4c18
@ -78,7 +78,7 @@ export class BorderDetecting extends Component<{ host: BuiltinSimulatorHost }> {
|
|||||||
const { current } = this;
|
const { current } = this;
|
||||||
|
|
||||||
|
|
||||||
const canHoverHook = current?.componentMeta.getMetadata()?.advanced?.callbacks?.onHoverHook;
|
const canHoverHook = current?.componentMeta.getMetadata()?.configure.advanced?.callbacks?.onHoverHook;
|
||||||
const canHover = (canHoverHook && typeof canHoverHook === 'function') ? canHoverHook(current.internalToShellNode()) : true;
|
const canHover = (canHoverHook && typeof canHoverHook === 'function') ? canHoverHook(current.internalToShellNode()) : true;
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -137,38 +137,38 @@ export class BoxResizingInstance extends Component<{
|
|||||||
const resize = (e: MouseEvent, direction: string, node: any, moveX: number, moveY: number) => {
|
const resize = (e: MouseEvent, direction: string, node: any, moveX: number, moveY: number) => {
|
||||||
const metadata = node.componentMeta.getMetadata();
|
const metadata = node.componentMeta.getMetadata();
|
||||||
if (
|
if (
|
||||||
metadata?.advanced?.callbacks &&
|
metadata.configure?.advanced?.callbacks &&
|
||||||
typeof metadata.advanced.callbacks.onResize === 'function'
|
typeof metadata.configure.advanced.callbacks.onResize === 'function'
|
||||||
) {
|
) {
|
||||||
(e as any).trigger = direction;
|
(e as any).trigger = direction;
|
||||||
(e as any).deltaX = moveX;
|
(e as any).deltaX = moveX;
|
||||||
(e as any).deltaY = moveY;
|
(e as any).deltaY = moveY;
|
||||||
const cbNode = node?.isNode ? node.internalToShellNode() : node;
|
const cbNode = node?.isNode ? node.internalToShellNode() : node;
|
||||||
metadata.advanced.callbacks.onResize(e, cbNode);
|
metadata.configure.advanced.callbacks.onResize(e, cbNode);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const resizeStart = (e: MouseEvent, direction: string, node: any) => {
|
const resizeStart = (e: MouseEvent, direction: string, node: any) => {
|
||||||
const metadata = node.componentMeta.getMetadata();
|
const metadata = node.componentMeta.getMetadata();
|
||||||
if (
|
if (
|
||||||
metadata?.advanced?.callbacks &&
|
metadata.configure?.advanced?.callbacks &&
|
||||||
typeof metadata.advanced.callbacks.onResizeStart === 'function'
|
typeof metadata.configure.advanced.callbacks.onResizeStart === 'function'
|
||||||
) {
|
) {
|
||||||
(e as any).trigger = direction;
|
(e as any).trigger = direction;
|
||||||
const cbNode = node?.isNode ? node.internalToShellNode() : node;
|
const cbNode = node?.isNode ? node.internalToShellNode() : node;
|
||||||
metadata.advanced.callbacks.onResizeStart(e, cbNode);
|
metadata.configure.advanced.callbacks.onResizeStart(e, cbNode);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const resizeEnd = (e: MouseEvent, direction: string, node: any) => {
|
const resizeEnd = (e: MouseEvent, direction: string, node: any) => {
|
||||||
const metadata = node.componentMeta.getMetadata();
|
const metadata = node.componentMeta.getMetadata();
|
||||||
if (
|
if (
|
||||||
metadata?.advanced?.callbacks &&
|
metadata.configure?.advanced?.callbacks &&
|
||||||
typeof metadata.advanced.callbacks.onResizeEnd === 'function'
|
typeof metadata.configure.advanced.callbacks.onResizeEnd === 'function'
|
||||||
) {
|
) {
|
||||||
(e as any).trigger = direction;
|
(e as any).trigger = direction;
|
||||||
const cbNode = node?.isNode ? node.internalToShellNode() : node;
|
const cbNode = node?.isNode ? node.internalToShellNode() : node;
|
||||||
metadata.advanced.callbacks.onResizeEnd(e, cbNode);
|
metadata.configure.advanced.callbacks.onResizeEnd(e, cbNode);
|
||||||
}
|
}
|
||||||
|
|
||||||
const editor = globalContext.get(Editor);
|
const editor = globalContext.get(Editor);
|
||||||
@ -241,8 +241,8 @@ export class BoxResizingInstance extends Component<{
|
|||||||
const { node, offsetWidth, offsetHeight, offsetTop, offsetLeft } = observed;
|
const { node, offsetWidth, offsetHeight, offsetTop, offsetLeft } = observed;
|
||||||
let triggerVisible: any = [];
|
let triggerVisible: any = [];
|
||||||
const metadata = node.componentMeta.getMetadata();
|
const metadata = node.componentMeta.getMetadata();
|
||||||
if (metadata?.advanced?.getResizingHandlers) {
|
if (metadata.configure?.advanced?.getResizingHandlers) {
|
||||||
triggerVisible = metadata.advanced.getResizingHandlers(node);
|
triggerVisible = metadata.configure.advanced.getResizingHandlers(node);
|
||||||
}
|
}
|
||||||
|
|
||||||
const baseSideClass = 'lc-borders lc-resize-side';
|
const baseSideClass = 'lc-borders lc-resize-side';
|
||||||
|
|||||||
@ -46,7 +46,7 @@ export class BorderSelectingInstance extends Component<{
|
|||||||
dragging,
|
dragging,
|
||||||
});
|
});
|
||||||
|
|
||||||
const hideSelectTools = observed.node.componentMeta.getMetadata().advanced?.hideSelectTools;
|
const hideSelectTools = observed.node.componentMeta.getMetadata().configure.advanced?.hideSelectTools;
|
||||||
|
|
||||||
if (hideSelectTools) {
|
if (hideSelectTools) {
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
@ -123,7 +123,7 @@ export class InsertionView extends Component<{ host: BuiltinSimulatorHost }> {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
// 如果是个绝对定位容器,不需要渲染插入标记
|
// 如果是个绝对定位容器,不需要渲染插入标记
|
||||||
if (loc.target.componentMeta.getMetadata().advanced?.isAbsoluteLayoutContainer) {
|
if (loc.target.componentMeta.getMetadata().configure.advanced?.isAbsoluteLayoutContainer) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1139,7 +1139,7 @@ export class BuiltinSimulatorHost implements ISimulatorHost<BuiltinSimulatorProp
|
|||||||
const { nodes } = dragObject as DragNodeObject;
|
const { nodes } = dragObject as DragNodeObject;
|
||||||
|
|
||||||
const operationalNodes = nodes?.filter((node) => {
|
const operationalNodes = nodes?.filter((node) => {
|
||||||
const onMoveHook = node.componentMeta?.getMetadata()?.advanced?.callbacks?.onMoveHook;
|
const onMoveHook = node.componentMeta?.getMetadata()?.configure.advanced?.callbacks?.onMoveHook;
|
||||||
const canMove = onMoveHook && typeof onMoveHook === 'function' ? onMoveHook(node.internalToShellNode()) : true;
|
const canMove = onMoveHook && typeof onMoveHook === 'function' ? onMoveHook(node.internalToShellNode()) : true;
|
||||||
|
|
||||||
return canMove;
|
return canMove;
|
||||||
|
|||||||
@ -13,6 +13,7 @@ import {
|
|||||||
LiveTextEditingConfig,
|
LiveTextEditingConfig,
|
||||||
FieldConfig,
|
FieldConfig,
|
||||||
} from '@ali/lowcode-types';
|
} from '@ali/lowcode-types';
|
||||||
|
import { deprecate } from '@ali/lowcode-utils';
|
||||||
import { computed, engineConfig } from '@ali/lowcode-editor-core';
|
import { computed, engineConfig } from '@ali/lowcode-editor-core';
|
||||||
import EventEmitter from 'events';
|
import EventEmitter from 'events';
|
||||||
|
|
||||||
@ -199,7 +200,7 @@ export class ComponentMeta {
|
|||||||
: title;
|
: title;
|
||||||
}
|
}
|
||||||
|
|
||||||
const liveTextEditing = this._transformedMetadata.advanced?.liveTextEditing || [];
|
const liveTextEditing = this._transformedMetadata.configure.advanced?.liveTextEditing || [];
|
||||||
|
|
||||||
function collectLiveTextEditing(items: FieldConfig[]) {
|
function collectLiveTextEditing(items: FieldConfig[]) {
|
||||||
items.forEach((config) => {
|
items.forEach((config) => {
|
||||||
@ -219,7 +220,7 @@ export class ComponentMeta {
|
|||||||
collectLiveTextEditing(this.configure);
|
collectLiveTextEditing(this.configure);
|
||||||
this._liveTextEditing = liveTextEditing.length > 0 ? liveTextEditing : undefined;
|
this._liveTextEditing = liveTextEditing.length > 0 ? liveTextEditing : undefined;
|
||||||
|
|
||||||
const isTopFiexd = this._transformedMetadata.advanced?.isTopFixed;
|
const isTopFiexd = this._transformedMetadata.configure.advanced?.isTopFixed;
|
||||||
|
|
||||||
if (isTopFiexd) {
|
if (isTopFiexd) {
|
||||||
this._isTopFixed = isTopFiexd;
|
this._isTopFixed = isTopFiexd;
|
||||||
@ -259,8 +260,9 @@ export class ComponentMeta {
|
|||||||
if (!result.configure) {
|
if (!result.configure) {
|
||||||
result.configure = {};
|
result.configure = {};
|
||||||
}
|
}
|
||||||
if (result.experimental && !result.advanced) {
|
if (result.experimental && !result.configure.advanced) {
|
||||||
result.advanced = result.experimental;
|
deprecate(result.experimental, '.experimental', '.configure.advanced');
|
||||||
|
result.configure.advanced = result.experimental;
|
||||||
}
|
}
|
||||||
return result as any;
|
return result as any;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -524,7 +524,7 @@ export class Designer {
|
|||||||
if (metaData.devMode === 'lowcode') {
|
if (metaData.devMode === 'lowcode') {
|
||||||
maps[key] = metaData.schema;
|
maps[key] = metaData.schema;
|
||||||
} else {
|
} else {
|
||||||
const view = metaData.advanced?.view;
|
const view = metaData.configure.advanced?.view;
|
||||||
if (view) {
|
if (view) {
|
||||||
maps[key] = view;
|
maps[key] = view;
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@ -38,7 +38,7 @@ export default class DragGhost extends Component<{ designer: Designer }> {
|
|||||||
this.y = e.globalY;
|
this.y = e.globalY;
|
||||||
if (isSimulatorHost(e.sensor)) {
|
if (isSimulatorHost(e.sensor)) {
|
||||||
const container = e.sensor.getDropContainer(e);
|
const container = e.sensor.getDropContainer(e);
|
||||||
if (container?.container.componentMeta.getMetadata().advanced?.isAbsoluteLayoutContainer) {
|
if (container?.container.componentMeta.getMetadata().configure.advanced?.isAbsoluteLayoutContainer) {
|
||||||
this.isAbsoluteLayoutContainer = true;
|
this.isAbsoluteLayoutContainer = true;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -416,7 +416,7 @@ export class NodeChildren {
|
|||||||
if (node.isRoot()) {
|
if (node.isRoot()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const callbacks = owner.componentMeta.getMetadata().advanced?.callbacks;
|
const callbacks = owner.componentMeta.getMetadata().configure.advanced?.callbacks;
|
||||||
if (callbacks?.onSubtreeModified) {
|
if (callbacks?.onSubtreeModified) {
|
||||||
try {
|
try {
|
||||||
callbacks?.onSubtreeModified.call(
|
callbacks?.onSubtreeModified.call(
|
||||||
|
|||||||
@ -223,7 +223,7 @@ export class Node<Schema extends NodeSchema = NodeSchema> {
|
|||||||
private autoruns?: Array<() => void>;
|
private autoruns?: Array<() => void>;
|
||||||
|
|
||||||
private setupAutoruns() {
|
private setupAutoruns() {
|
||||||
const autoruns = this.componentMeta.getMetadata().advanced?.autoruns;
|
const autoruns = this.componentMeta.getMetadata().configure.advanced?.autoruns;
|
||||||
if (!autoruns || autoruns.length < 1) {
|
if (!autoruns || autoruns.length < 1) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -237,7 +237,7 @@ export class Node<Schema extends NodeSchema = NodeSchema> {
|
|||||||
private initialChildren(children: any): NodeData[] {
|
private initialChildren(children: any): NodeData[] {
|
||||||
// FIXME! this is dirty code
|
// FIXME! this is dirty code
|
||||||
if (children == null) {
|
if (children == null) {
|
||||||
const initialChildren = this.componentMeta.getMetadata().advanced?.initialChildren;
|
const initialChildren = this.componentMeta.getMetadata().configure.advanced?.initialChildren;
|
||||||
if (initialChildren) {
|
if (initialChildren) {
|
||||||
if (typeof initialChildren === 'function') {
|
if (typeof initialChildren === 'function') {
|
||||||
return initialChildren(this as any) || [];
|
return initialChildren(this as any) || [];
|
||||||
@ -302,7 +302,7 @@ export class Node<Schema extends NodeSchema = NodeSchema> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private didDropIn(dragment: Node) {
|
private didDropIn(dragment: Node) {
|
||||||
const callbacks = this.componentMeta.getMetadata().advanced?.callbacks;
|
const callbacks = this.componentMeta.getMetadata().configure.advanced?.callbacks;
|
||||||
if (callbacks?.onNodeAdd) {
|
if (callbacks?.onNodeAdd) {
|
||||||
const cbThis = this.internalToShellNode();
|
const cbThis = this.internalToShellNode();
|
||||||
callbacks?.onNodeAdd.call(cbThis, dragment.internalToShellNode(), cbThis);
|
callbacks?.onNodeAdd.call(cbThis, dragment.internalToShellNode(), cbThis);
|
||||||
@ -313,7 +313,7 @@ export class Node<Schema extends NodeSchema = NodeSchema> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private didDropOut(dragment: Node) {
|
private didDropOut(dragment: Node) {
|
||||||
const callbacks = this.componentMeta.getMetadata().advanced?.callbacks;
|
const callbacks = this.componentMeta.getMetadata().configure.advanced?.callbacks;
|
||||||
if (callbacks?.onNodeRemove) {
|
if (callbacks?.onNodeRemove) {
|
||||||
const cbThis = this.internalToShellNode();
|
const cbThis = this.internalToShellNode();
|
||||||
callbacks?.onNodeRemove.call(cbThis, dragment.internalToShellNode(), cbThis);
|
callbacks?.onNodeRemove.call(cbThis, dragment.internalToShellNode(), cbThis);
|
||||||
|
|||||||
@ -146,7 +146,7 @@ export class OutlineMain implements ISensor, ITreeBoard, IScrollable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const operationalNodes = nodes?.filter((node: any) => {
|
const operationalNodes = nodes?.filter((node: any) => {
|
||||||
const onMoveHook = node.componentMeta?.getMetadata()?.advanced?.callbacks?.onMoveHook;
|
const onMoveHook = node.componentMeta?.getMetadata().configure?.advanced?.callbacks?.onMoveHook;
|
||||||
const canMove = onMoveHook && typeof onMoveHook === 'function' ? onMoveHook(node) : true;
|
const canMove = onMoveHook && typeof onMoveHook === 'function' ? onMoveHook(node) : true;
|
||||||
|
|
||||||
return canMove;
|
return canMove;
|
||||||
|
|||||||
@ -285,6 +285,10 @@ export interface Configure {
|
|||||||
* 通用扩展面板支持性配置
|
* 通用扩展面板支持性配置
|
||||||
*/
|
*/
|
||||||
supports?: ConfigureSupport;
|
supports?: ConfigureSupport;
|
||||||
|
/**
|
||||||
|
* 高级特性配置
|
||||||
|
*/
|
||||||
|
advanced?: Advanced;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -388,10 +392,6 @@ export interface ComponentMetadata {
|
|||||||
* 编辑体验增强
|
* 编辑体验增强
|
||||||
*/
|
*/
|
||||||
configure?: FieldConfig[] | Configure;
|
configure?: FieldConfig[] | Configure;
|
||||||
/**
|
|
||||||
* 高级特性配置
|
|
||||||
*/
|
|
||||||
advanced?: Advanced;
|
|
||||||
/**
|
/**
|
||||||
* @deprecated, use advanced instead
|
* @deprecated, use advanced instead
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -66,7 +66,7 @@ export function arrShallowEquals(arr1: any[], arr2: any[]): boolean {
|
|||||||
* @param meta
|
* @param meta
|
||||||
*/
|
*/
|
||||||
export function isFromVC(meta: ComponentMeta) {
|
export function isFromVC(meta: ComponentMeta) {
|
||||||
return !!meta?.getMetadata()?.advanced;
|
return !!meta?.getMetadata().configure?.advanced;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function executePendingFn(fn: () => void, timeout: number = 2000) {
|
export function executePendingFn(fn: () => void, timeout: number = 2000) {
|
||||||
@ -93,3 +93,15 @@ export function compatStage(stage: TransformStage | number): TransformStage {
|
|||||||
}
|
}
|
||||||
return stage as TransformStage;
|
return stage as TransformStage;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function invariant(check: any, message: string, thing?: any) {
|
||||||
|
if (!check) {
|
||||||
|
throw new Error(`Invariant failed: ${ message }${thing ? ` in '${thing}'` : ''}`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export function deprecate(fail: any, message: string, alterative?: string) {
|
||||||
|
if (fail) {
|
||||||
|
console.warn(`Deprecation: ${message}` + alterative ? `, use ${alterative} instead.'` : '');
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -20,7 +20,7 @@ export const getClosestNode = (node: Node, until: (node: Node) => boolean): Node
|
|||||||
* @returns {boolean} 是否可点击,true表示可点击
|
* @returns {boolean} 是否可点击,true表示可点击
|
||||||
*/
|
*/
|
||||||
export const canClickNode = (node: Node, e: unknown): boolean => {
|
export const canClickNode = (node: Node, e: unknown): boolean => {
|
||||||
const onClickHook = node.componentMeta?.getMetadata()?.advanced?.callbacks?.onClickHook;
|
const onClickHook = node.componentMeta?.getMetadata().configure?.advanced?.callbacks?.onClickHook;
|
||||||
const canClick = typeof onClickHook === 'function' ? onClickHook(e as MouseEvent, node) : true;
|
const canClick = typeof onClickHook === 'function' ? onClickHook(e as MouseEvent, node) : true;
|
||||||
return canClick;
|
return canClick;
|
||||||
};
|
};
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user