mirror of
https://github.com/alibaba/lowcode-engine.git
synced 2025-12-26 05:20:21 +00:00
fix: fix lint issues in shell
This commit is contained in:
parent
c1299e3143
commit
8537eff893
@ -77,7 +77,7 @@ hover 节点变化事件
|
||||
* set callback which will be called when hovering object changed.
|
||||
* @since v1.1.0
|
||||
*/
|
||||
onDetectingChange(fn: (node: IPublicModelNode) => void): IPublicTypeDisposable;
|
||||
onDetectingChange(fn: (node: IPublicModelNode | null) => void): IPublicTypeDisposable;
|
||||
```
|
||||
|
||||
相关类型:
|
||||
|
||||
@ -6,7 +6,7 @@ import {
|
||||
} from '@alilc/lowcode-types';
|
||||
import { isNode } from '@alilc/lowcode-utils';
|
||||
|
||||
export interface IActiveTracker extends IPublicModelActiveTracker {
|
||||
export interface IActiveTracker extends Omit< IPublicModelActiveTracker, 'track' > {
|
||||
track(originalTarget: IPublicTypeActiveTarget | INode): void;
|
||||
}
|
||||
|
||||
|
||||
@ -17,17 +17,16 @@ import {
|
||||
IPublicTypeLocationData,
|
||||
IPublicEnumTransformStage,
|
||||
IPublicModelDragon,
|
||||
IPublicModelActiveTracker,
|
||||
IPublicModelDropLocation,
|
||||
} from '@alilc/lowcode-types';
|
||||
import { megreAssets, IPublicTypeAssetsJson, isNodeSchema, isDragNodeObject, isDragNodeDataObject, isLocationChildrenDetail, Logger } from '@alilc/lowcode-utils';
|
||||
import { Project } from '../project';
|
||||
import { Node, DocumentModel, insertChildren, INode } from '../document';
|
||||
import { ComponentMeta } from '../component-meta';
|
||||
import { ComponentMeta, IComponentMeta } from '../component-meta';
|
||||
import { INodeSelector, Component } from '../simulator';
|
||||
import { Scroller } from './scroller';
|
||||
import { Dragon, ILocateEvent } from './dragon';
|
||||
import { ActiveTracker } from './active-tracker';
|
||||
import { Dragon, IDragon, ILocateEvent } from './dragon';
|
||||
import { ActiveTracker, IActiveTracker } from './active-tracker';
|
||||
import { Detecting } from './detecting';
|
||||
import { DropLocation } from './location';
|
||||
import { OffsetObserver, createOffsetObserver } from './offset-observer';
|
||||
@ -56,24 +55,49 @@ export interface DesignerProps {
|
||||
onMount?: (designer: Designer) => void;
|
||||
onDragstart?: (e: ILocateEvent) => void;
|
||||
onDrag?: (e: ILocateEvent) => void;
|
||||
onDragend?: (e: { dragObject: IPublicModelDragObject; copy: boolean }, loc?: DropLocation) => void;
|
||||
onDragend?: (
|
||||
e: { dragObject: IPublicModelDragObject; copy: boolean },
|
||||
loc?: DropLocation,
|
||||
) => void;
|
||||
}
|
||||
|
||||
export interface IDesigner {
|
||||
|
||||
get dragon(): IPublicModelDragon;
|
||||
get activeTracker(): IPublicModelActiveTracker;
|
||||
|
||||
get activeTracker(): IActiveTracker;
|
||||
|
||||
get componentActions(): ComponentActions;
|
||||
|
||||
get editor(): IPublicModelEditor;
|
||||
|
||||
createScroller(scrollable: IPublicModelScrollable): IPublicModelScroller;
|
||||
|
||||
/**
|
||||
* 创建插入位置,考虑放到 dragon 中
|
||||
*/
|
||||
createLocation(locationData: IPublicTypeLocationData): IPublicModelDropLocation;
|
||||
|
||||
get componentsMap(): { [key: string]: IPublicTypeNpmInfo | Component };
|
||||
|
||||
loadIncrementalAssets(incrementalAssets: IPublicTypeAssetsJson): Promise<void>;
|
||||
|
||||
getComponentMeta(
|
||||
componentName: string,
|
||||
generateMetadata?: () => IPublicTypeComponentMetadata | null,
|
||||
): IComponentMeta;
|
||||
|
||||
createComponentMeta(data: IPublicTypeComponentMetadata): IComponentMeta | null;
|
||||
|
||||
getComponentMetasMap(): Map<string, IComponentMeta>;
|
||||
|
||||
addPropsReducer(reducer: IPublicTypePropsTransducer, stage: IPublicEnumTransformStage): void;
|
||||
}
|
||||
|
||||
export class Designer implements IDesigner {
|
||||
public dragon: Dragon;
|
||||
dragon: IDragon;
|
||||
|
||||
public viewName: string | undefined;
|
||||
viewName: string | undefined;
|
||||
|
||||
readonly componentActions = new ComponentActions();
|
||||
|
||||
@ -99,7 +123,7 @@ export class Designer implements IDesigner {
|
||||
|
||||
private oobxList: OffsetObserver[] = [];
|
||||
|
||||
@obx.ref private _componentMetasMap = new Map<string, ComponentMeta>();
|
||||
@obx.ref private _componentMetasMap = new Map<string, IComponentMeta>();
|
||||
|
||||
@obx.ref private _simulatorComponent?: ComponentType<any>;
|
||||
|
||||
@ -483,7 +507,7 @@ export class Designer implements IDesigner {
|
||||
metas.forEach((data) => this.createComponentMeta(data));
|
||||
}
|
||||
|
||||
createComponentMeta(data: IPublicTypeComponentMetadata): ComponentMeta | null {
|
||||
createComponentMeta(data: IPublicTypeComponentMetadata): IComponentMeta | null {
|
||||
const key = data.componentName;
|
||||
if (!key) {
|
||||
return null;
|
||||
@ -515,7 +539,7 @@ export class Designer implements IDesigner {
|
||||
getComponentMeta(
|
||||
componentName: string,
|
||||
generateMetadata?: () => IPublicTypeComponentMetadata | null,
|
||||
) {
|
||||
): IComponentMeta {
|
||||
if (this._componentMetasMap.has(componentName)) {
|
||||
return this._componentMetasMap.get(componentName)!;
|
||||
}
|
||||
|
||||
@ -1,14 +1,18 @@
|
||||
import { makeObservable, obx, IEventBus, createModuleEventBus } from '@alilc/lowcode-editor-core';
|
||||
import { IPublicModelDetecting, IPublicModelNode, IPublicModelDocumentModel } from '@alilc/lowcode-types';
|
||||
import { IPublicModelDetecting } from '@alilc/lowcode-types';
|
||||
import { IDocumentModel } from '../document/document-model';
|
||||
import { INode } from '../document/node/node';
|
||||
|
||||
const DETECTING_CHANGE_EVENT = 'detectingChange';
|
||||
export interface IDetecting extends Omit< IPublicModelDetecting, 'capture' | 'release' | 'leave' > {
|
||||
|
||||
capture(node: IPublicModelNode | null): void;
|
||||
capture(node: INode | null): void;
|
||||
|
||||
release(node: IPublicModelNode | null): void;
|
||||
release(node: INode | null): void;
|
||||
|
||||
leave(document: IPublicModelDocumentModel | undefined): void;
|
||||
leave(document: IDocumentModel | undefined): void;
|
||||
|
||||
get current(): INode | null;
|
||||
}
|
||||
|
||||
export class Detecting implements IDetecting {
|
||||
@ -31,7 +35,7 @@ export class Detecting implements IDetecting {
|
||||
|
||||
@obx.ref xRayMode = false;
|
||||
|
||||
@obx.ref private _current: IPublicModelNode | null = null;
|
||||
@obx.ref private _current: INode | null = null;
|
||||
|
||||
private emitter: IEventBus = createModuleEventBus('Detecting');
|
||||
|
||||
@ -43,27 +47,27 @@ export class Detecting implements IDetecting {
|
||||
return this._current;
|
||||
}
|
||||
|
||||
capture(node: IPublicModelNode | null) {
|
||||
capture(node: INode | null) {
|
||||
if (this._current !== node) {
|
||||
this._current = node;
|
||||
this.emitter.emit(DETECTING_CHANGE_EVENT, this.current);
|
||||
}
|
||||
}
|
||||
|
||||
release(node: IPublicModelNode | null) {
|
||||
release(node: INode | null) {
|
||||
if (this._current === node) {
|
||||
this._current = null;
|
||||
this.emitter.emit(DETECTING_CHANGE_EVENT, this.current);
|
||||
}
|
||||
}
|
||||
|
||||
leave(document: IPublicModelDocumentModel | undefined) {
|
||||
leave(document: IDocumentModel | undefined) {
|
||||
if (this.current && this.current.document === document) {
|
||||
this._current = null;
|
||||
}
|
||||
}
|
||||
|
||||
onDetectingChange(fn: (node: IPublicModelNode) => void) {
|
||||
onDetectingChange(fn: (node: INode) => void) {
|
||||
this.emitter.on(DETECTING_CHANGE_EVENT, fn);
|
||||
return () => {
|
||||
this.emitter.off(DETECTING_CHANGE_EVENT, fn);
|
||||
|
||||
@ -9,21 +9,18 @@ import {
|
||||
IPublicTypeDragNodeDataObject,
|
||||
IPublicModelDocumentModel,
|
||||
IPublicModelHistory,
|
||||
IPublicModelModalNodesManager,
|
||||
IPublicModelNode,
|
||||
IPublicApiProject,
|
||||
IPublicModelDropLocation,
|
||||
IPublicEnumTransformStage,
|
||||
IPublicTypeOnChangeOptions,
|
||||
} from '@alilc/lowcode-types';
|
||||
import { Project } from '../project';
|
||||
import { IProject, Project } from '../project';
|
||||
import { ISimulatorHost } from '../simulator';
|
||||
import { ComponentMeta } from '../component-meta';
|
||||
import { IDropLocation, Designer } from '../designer';
|
||||
import { IDropLocation, Designer, IHistory } from '../designer';
|
||||
import { Node, insertChildren, insertChild, isNode, RootNode, INode } from './node/node';
|
||||
import { Selection, ISelection } from './selection';
|
||||
import { History } from './history';
|
||||
import { ModalNodesManager } from './node';
|
||||
import { IModalNodesManager, ModalNodesManager } from './node';
|
||||
import { uniqueId, isPlainObject, compatStage, isJSExpression, isDOMText, isNodeSchema, isDragNodeObject, isDragNodeDataObject } from '@alilc/lowcode-utils';
|
||||
import { EDITOR_EVENT } from '../types';
|
||||
|
||||
@ -44,17 +41,31 @@ export interface IDocumentModel extends Omit< IPublicModelDocumentModel, 'select
|
||||
*/
|
||||
readonly selection: ISelection;
|
||||
|
||||
readonly project: IProject;
|
||||
|
||||
/**
|
||||
* 模态节点管理
|
||||
*/
|
||||
readonly modalNodesManager: IModalNodesManager;
|
||||
|
||||
/**
|
||||
* 根据 id 获取节点
|
||||
*/
|
||||
getNode(id: string): INode | null;
|
||||
|
||||
getHistory(): IHistory;
|
||||
|
||||
get focusNode(): INode | null;
|
||||
|
||||
get rootNode(): INode | null;
|
||||
|
||||
}
|
||||
|
||||
export class DocumentModel implements IDocumentModel {
|
||||
/**
|
||||
* 根节点 类型有:Page/Component/Block
|
||||
*/
|
||||
rootNode: RootNode | null;
|
||||
rootNode: INode | null;
|
||||
|
||||
/**
|
||||
* 文档编号
|
||||
@ -74,11 +85,11 @@ export class DocumentModel implements IDocumentModel {
|
||||
/**
|
||||
* 模态节点管理
|
||||
*/
|
||||
readonly modalNodesManager: IPublicModelModalNodesManager;
|
||||
readonly modalNodesManager: IModalNodesManager;
|
||||
|
||||
private _nodesMap = new Map<string, IPublicModelNode>();
|
||||
|
||||
readonly project: IPublicApiProject;
|
||||
readonly project: IProject;
|
||||
|
||||
readonly designer: Designer;
|
||||
|
||||
@ -114,7 +125,7 @@ export class DocumentModel implements IDocumentModel {
|
||||
this.rootNode?.getExtraProp('fileName', true)?.setValue(fileName);
|
||||
}
|
||||
|
||||
get focusNode() {
|
||||
get focusNode(): INode {
|
||||
if (this._drillDownNode) {
|
||||
return this._drillDownNode;
|
||||
}
|
||||
@ -147,7 +158,7 @@ export class DocumentModel implements IDocumentModel {
|
||||
|
||||
@obx.ref private _dropLocation: IDropLocation | null = null;
|
||||
|
||||
set dropLocation(loc: IPublicModelDropLocation | null) {
|
||||
set dropLocation(loc: IDropLocation | null) {
|
||||
this._dropLocation = loc;
|
||||
// pub event
|
||||
this.designer.editor.eventBus.emit(
|
||||
@ -626,7 +637,7 @@ export class DocumentModel implements IDocumentModel {
|
||||
return data;
|
||||
}
|
||||
|
||||
getHistory(): History {
|
||||
getHistory(): IHistory {
|
||||
return this.history;
|
||||
}
|
||||
|
||||
|
||||
@ -193,7 +193,7 @@ export class History<T = IPublicTypeNodeSchema> implements IHistory {
|
||||
return this.onStateChange(func);
|
||||
}
|
||||
|
||||
onStateChange(func: () => any) {
|
||||
onStateChange(func: () => any): () => void {
|
||||
this.emitter.on('statechange', func);
|
||||
return () => {
|
||||
this.emitter.removeListener('statechange', func);
|
||||
@ -208,7 +208,8 @@ export class History<T = IPublicTypeNodeSchema> implements IHistory {
|
||||
onChangeCursor(func: () => any): () => void {
|
||||
return this.onCursor(func);
|
||||
}
|
||||
onCursor(func: () => any) {
|
||||
|
||||
onCursor(func: () => any): () => void {
|
||||
this.emitter.on('cursor', func);
|
||||
return () => {
|
||||
this.emitter.removeListener('cursor', func);
|
||||
|
||||
@ -11,7 +11,10 @@ export interface IOnChangeOptions {
|
||||
}
|
||||
|
||||
export interface INodeChildren extends Omit<IPublicModelNodeChildren, 'forEach' | 'map' | 'every' | 'some' | 'filter' | 'find' | 'reduce' | 'mergeChildren' > {
|
||||
get owner(): INode;
|
||||
|
||||
unlinkChild(node: INode): void;
|
||||
|
||||
/**
|
||||
* 删除一个节点
|
||||
*/
|
||||
@ -57,6 +60,11 @@ export interface INodeChildren extends Omit<IPublicModelNodeChildren, 'forEach'
|
||||
sorter: (firstNode: INode, secondNode: INode) => number,
|
||||
): any;
|
||||
|
||||
/**
|
||||
* 根据索引获得节点
|
||||
*/
|
||||
get(index: number): INode | null;
|
||||
|
||||
/** overriding methods end */
|
||||
}
|
||||
export class NodeChildren implements INodeChildren {
|
||||
@ -64,6 +72,31 @@ export class NodeChildren implements INodeChildren {
|
||||
|
||||
private emitter: IEventBus = createModuleEventBus('NodeChildren');
|
||||
|
||||
/**
|
||||
* 元素个数
|
||||
*/
|
||||
@computed get size(): number {
|
||||
return this.children.length;
|
||||
}
|
||||
|
||||
get isEmptyNode(): boolean {
|
||||
return this.size < 1;
|
||||
}
|
||||
get notEmptyNode(): boolean {
|
||||
return this.size > 0;
|
||||
}
|
||||
|
||||
@computed get length(): number {
|
||||
return this.children.length;
|
||||
}
|
||||
|
||||
private purged = false;
|
||||
|
||||
get [Symbol.toStringTag]() {
|
||||
// 保证向前兼容性
|
||||
return 'Array';
|
||||
}
|
||||
|
||||
constructor(
|
||||
readonly owner: INode,
|
||||
data: IPublicTypeNodeData | IPublicTypeNodeData[],
|
||||
@ -130,13 +163,6 @@ export class NodeChildren implements INodeChildren {
|
||||
return this.children.concat(nodes);
|
||||
}
|
||||
|
||||
/**
|
||||
* 元素个数
|
||||
*/
|
||||
@computed get size(): number {
|
||||
return this.children.length;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@ -144,24 +170,10 @@ export class NodeChildren implements INodeChildren {
|
||||
return this.isEmptyNode;
|
||||
}
|
||||
|
||||
get isEmptyNode(): boolean {
|
||||
return this.size < 1;
|
||||
}
|
||||
|
||||
notEmpty() {
|
||||
return this.notEmptyNode;
|
||||
}
|
||||
|
||||
get notEmptyNode(): boolean {
|
||||
return this.size > 0;
|
||||
}
|
||||
|
||||
@computed get length(): number {
|
||||
return this.children.length;
|
||||
}
|
||||
|
||||
private purged = false;
|
||||
|
||||
/**
|
||||
* 回收销毁
|
||||
*/
|
||||
@ -483,11 +495,6 @@ export class NodeChildren implements INodeChildren {
|
||||
};
|
||||
}
|
||||
|
||||
get [Symbol.toStringTag]() {
|
||||
// 保证向前兼容性
|
||||
return 'Array';
|
||||
}
|
||||
|
||||
private reportModified(node: INode, owner: INode, options = {}) {
|
||||
if (!node) {
|
||||
return;
|
||||
|
||||
@ -18,11 +18,11 @@ import {
|
||||
} from '@alilc/lowcode-types';
|
||||
import { compatStage, isDOMText, isJSExpression } from '@alilc/lowcode-utils';
|
||||
import { SettingTopEntry } from '@alilc/lowcode-designer';
|
||||
import { Props, getConvertedExtraKey } from './props/props';
|
||||
import { Props, getConvertedExtraKey, IProps } from './props/props';
|
||||
import { DocumentModel, IDocumentModel } from '../document-model';
|
||||
import { NodeChildren, INodeChildren } from './node-children';
|
||||
import { Prop } from './props/prop';
|
||||
import { ComponentMeta } from '../../component-meta';
|
||||
import { IProp, Prop } from './props/prop';
|
||||
import { ComponentMeta, IComponentMeta } from '../../component-meta';
|
||||
import { ExclusiveGroup, isExclusiveGroup } from './exclusive-group';
|
||||
import { includeSlot, removeSlot } from '../../utils/slot';
|
||||
import { foreachReverse } from '../../utils/tree';
|
||||
@ -41,6 +41,34 @@ export interface INode extends IPublicModelNode {
|
||||
*/
|
||||
get children(): INodeChildren | null;
|
||||
|
||||
/**
|
||||
* 获取上一个兄弟节点
|
||||
*/
|
||||
get prevSibling(): INode | null;
|
||||
|
||||
/**
|
||||
* 获取下一个兄弟节点
|
||||
*/
|
||||
get nextSibling(): INode | null;
|
||||
|
||||
/**
|
||||
* 父级节点
|
||||
*/
|
||||
get parent(): INode | null;
|
||||
|
||||
get slots(): INode[];
|
||||
|
||||
/**
|
||||
* 关联属性
|
||||
*/
|
||||
get slotFor(): IProp | null;
|
||||
|
||||
get props(): IProps;
|
||||
|
||||
get componentMeta(): IComponentMeta;
|
||||
|
||||
get document(): IDocumentModel;
|
||||
|
||||
setVisible(flag: boolean): void;
|
||||
|
||||
getVisible(): boolean;
|
||||
@ -66,8 +94,6 @@ export interface INode extends IPublicModelNode {
|
||||
*/
|
||||
export(stage: IPublicEnumTransformStage, options?: any): IPublicTypeNodeSchema;
|
||||
|
||||
get document(): IDocumentModel;
|
||||
|
||||
emitPropChange(val: IPublicTypePropChangeOptions): void;
|
||||
|
||||
import(data: IPublicTypeNodeSchema, checkId?: boolean): void;
|
||||
@ -76,9 +102,13 @@ export interface INode extends IPublicModelNode {
|
||||
|
||||
addSlot(slotNode: INode): void;
|
||||
|
||||
get componentMeta(): ComponentMeta;
|
||||
|
||||
onVisibleChange(func: (flag: boolean) => any): () => void;
|
||||
|
||||
getProp(path: string, createIfNone?: boolean): IProp | null;
|
||||
|
||||
getExtraProp(key: string, createIfNone?: boolean): IProp | null;
|
||||
|
||||
replaceChild(node: INode, data: any): INode;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -157,7 +187,7 @@ export class Node<Schema extends IPublicTypeNodeSchema = IPublicTypeNodeSchema>
|
||||
/**
|
||||
* 属性抽象
|
||||
*/
|
||||
props: Props;
|
||||
props: IProps;
|
||||
|
||||
protected _children?: INodeChildren;
|
||||
|
||||
@ -241,11 +271,11 @@ export class Node<Schema extends IPublicTypeNodeSchema = IPublicTypeNodeSchema>
|
||||
return !!this._isRGLContainer;
|
||||
}
|
||||
|
||||
private _slotFor?: Prop | null = null;
|
||||
private _slotFor?: IProp | null = null;
|
||||
|
||||
@obx.shallow _slots: INode[] = [];
|
||||
|
||||
get slots() {
|
||||
get slots(): INode[] {
|
||||
return this._slots;
|
||||
}
|
||||
|
||||
@ -509,7 +539,7 @@ export class Node<Schema extends IPublicTypeNodeSchema = IPublicTypeNodeSchema>
|
||||
/**
|
||||
* 关联属性
|
||||
*/
|
||||
get slotFor() {
|
||||
get slotFor(): IProp | null {
|
||||
return this._slotFor;
|
||||
}
|
||||
|
||||
@ -665,10 +695,10 @@ export class Node<Schema extends IPublicTypeNodeSchema = IPublicTypeNodeSchema>
|
||||
/**
|
||||
* 替换子节点
|
||||
*
|
||||
* @param {Node} node
|
||||
* @param {INode} node
|
||||
* @param {object} data
|
||||
*/
|
||||
replaceChild(node: Node, data: any): Node {
|
||||
replaceChild(node: INode, data: any): INode {
|
||||
if (this.children?.has(node)) {
|
||||
const selected = this.document.selection.has(node.id);
|
||||
|
||||
@ -703,11 +733,11 @@ export class Node<Schema extends IPublicTypeNodeSchema = IPublicTypeNodeSchema>
|
||||
};
|
||||
}
|
||||
|
||||
getProp(path: string, createIfNone = true): Prop | null {
|
||||
getProp(path: string, createIfNone = true): IProp | null {
|
||||
return this.props.query(path, createIfNone) || null;
|
||||
}
|
||||
|
||||
getExtraProp(key: string, createIfNone = true): Prop | null {
|
||||
getExtraProp(key: string, createIfNone = true): IProp | null {
|
||||
return this.props.get(getConvertedExtraKey(key), createIfNone) || null;
|
||||
}
|
||||
|
||||
@ -767,7 +797,7 @@ export class Node<Schema extends IPublicTypeNodeSchema = IPublicTypeNodeSchema>
|
||||
/**
|
||||
* 获取下一个兄弟节点
|
||||
*/
|
||||
get nextSibling(): Node | null {
|
||||
get nextSibling(): INode | null {
|
||||
if (!this.parent) {
|
||||
return null;
|
||||
}
|
||||
@ -781,7 +811,7 @@ export class Node<Schema extends IPublicTypeNodeSchema = IPublicTypeNodeSchema>
|
||||
/**
|
||||
* 获取上一个兄弟节点
|
||||
*/
|
||||
get prevSibling(): Node | null {
|
||||
get prevSibling(): INode | null {
|
||||
if (!this.parent) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import { obx, computed, makeObservable, action, IEventBus, createModuleEventBus } from '@alilc/lowcode-editor-core';
|
||||
import { Designer } from '../designer';
|
||||
import { DocumentModel, isDocumentModel } from '../document';
|
||||
import { IDesigner } from '../designer';
|
||||
import { DocumentModel, IDocumentModel, isDocumentModel } from '../document';
|
||||
import {
|
||||
IPublicTypeProjectSchema,
|
||||
IPublicTypeRootSchema,
|
||||
@ -12,14 +12,60 @@ import {
|
||||
import { isLowCodeComponentType, isProCodeComponentType } from '@alilc/lowcode-utils';
|
||||
import { ISimulatorHost } from '../simulator';
|
||||
|
||||
export interface IProject extends IPublicApiProject {
|
||||
export interface IProject extends Omit< IPublicApiProject, 'simulatorHost' | 'importSchema' | 'exportSchema' | 'openDocument' | 'getDocumentById' | 'getCurrentDocument' | 'addPropsTransducer' | 'onRemoveDocument' | 'onChangeDocument' | 'onSimulatorHostReady' | 'onSimulatorRendererReady' | 'setI18n' > {
|
||||
|
||||
get designer(): IDesigner;
|
||||
|
||||
get simulator(): ISimulatorHost | null;
|
||||
|
||||
get currentDocument(): IDocumentModel | null;
|
||||
|
||||
get documents(): IDocumentModel[];
|
||||
|
||||
open(doc?: string | IDocumentModel | IPublicTypeRootSchema): IDocumentModel | null;
|
||||
|
||||
getDocumentByFileName(fileName: string): IDocumentModel | null;
|
||||
|
||||
createDocument(data?: IPublicTypeRootSchema): IDocumentModel;
|
||||
|
||||
load(schema?: IPublicTypeProjectSchema, autoOpen?: boolean | string): void;
|
||||
|
||||
getSchema(
|
||||
stage: IPublicEnumTransformStage,
|
||||
): IPublicTypeProjectSchema;
|
||||
|
||||
getDocument(id: string): IDocumentModel | null;
|
||||
|
||||
onCurrentDocumentChange(fn: (doc: IDocumentModel) => void): () => void;
|
||||
|
||||
onSimulatorReady(fn: (args: any) => void): () => void;
|
||||
|
||||
onRendererReady(fn: () => void): () => void;
|
||||
|
||||
/**
|
||||
* 分字段设置储存数据,不记录操作记录
|
||||
*/
|
||||
set(
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
key:
|
||||
| 'version'
|
||||
| 'componentsTree'
|
||||
| 'componentsMap'
|
||||
| 'utils'
|
||||
| 'constants'
|
||||
| 'i18n'
|
||||
| 'css'
|
||||
| 'dataSource'
|
||||
| string,
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
value: any,
|
||||
): void;
|
||||
}
|
||||
|
||||
export class Project implements IProject {
|
||||
private emitter: IEventBus = createModuleEventBus('Project');
|
||||
|
||||
@obx.shallow readonly documents: IPublicModelDocumentModel[] = [];
|
||||
@obx.shallow readonly documents: IDocumentModel[] = [];
|
||||
|
||||
private data: IPublicTypeProjectSchema = {
|
||||
version: '1.0.0',
|
||||
@ -41,14 +87,7 @@ export class Project implements IProject {
|
||||
|
||||
key = Math.random();
|
||||
|
||||
// TODO: 考虑项目级别 History
|
||||
|
||||
constructor(readonly designer: Designer, schema?: IPublicTypeProjectSchema, readonly viewName = 'global') {
|
||||
makeObservable(this);
|
||||
this.load(schema);
|
||||
}
|
||||
|
||||
@computed get currentDocument() {
|
||||
@computed get currentDocument(): IDocumentModel | null {
|
||||
return this.documents.find((doc) => doc.active);
|
||||
}
|
||||
|
||||
@ -69,6 +108,13 @@ export class Project implements IProject {
|
||||
this._i18n = value || {};
|
||||
}
|
||||
|
||||
private documentsMap = new Map<string, DocumentModel>();
|
||||
|
||||
constructor(readonly designer: IDesigner, schema?: IPublicTypeProjectSchema, readonly viewName = 'global') {
|
||||
makeObservable(this);
|
||||
this.load(schema);
|
||||
}
|
||||
|
||||
private getComponentsMap(): IPublicTypeComponentsMap {
|
||||
return this.documents.reduce((
|
||||
compomentsMap: IPublicTypeComponentsMap,
|
||||
@ -104,7 +150,9 @@ export class Project implements IProject {
|
||||
/**
|
||||
* 获取项目整体 schema
|
||||
*/
|
||||
getSchema(stage: IPublicEnumTransformStage = IPublicEnumTransformStage.Save): IPublicTypeProjectSchema {
|
||||
getSchema(
|
||||
stage: IPublicEnumTransformStage = IPublicEnumTransformStage.Save,
|
||||
): IPublicTypeProjectSchema {
|
||||
return {
|
||||
...this.data,
|
||||
componentsMap: this.getComponentsMap(),
|
||||
@ -240,26 +288,24 @@ export class Project implements IProject {
|
||||
return Reflect.get(this.data, key);
|
||||
}
|
||||
|
||||
private documentsMap = new Map<string, DocumentModel>();
|
||||
|
||||
getDocument(id: string): DocumentModel | null {
|
||||
getDocument(id: string): IDocumentModel | null {
|
||||
// 此处不能使用 this.documentsMap.get(id),因为在乐高 rollback 场景,document.id 会被改成其他值
|
||||
return this.documents.find((doc) => doc.id === id) || null;
|
||||
}
|
||||
|
||||
getDocumentByFileName(fileName: string): DocumentModel | null {
|
||||
getDocumentByFileName(fileName: string): IDocumentModel | null {
|
||||
return this.documents.find((doc) => doc.fileName === fileName) || null;
|
||||
}
|
||||
|
||||
@action
|
||||
createDocument(data?: IPublicTypeRootSchema): DocumentModel {
|
||||
createDocument(data?: IPublicTypeRootSchema): IDocumentModel {
|
||||
const doc = new DocumentModel(this, data || this?.data?.componentsTree?.[0]);
|
||||
this.documents.push(doc);
|
||||
this.documentsMap.set(doc.id, doc);
|
||||
return doc;
|
||||
}
|
||||
|
||||
open(doc?: string | DocumentModel | IPublicTypeRootSchema): DocumentModel | null {
|
||||
open(doc?: string | IDocumentModel | IPublicTypeRootSchema): IDocumentModel | null {
|
||||
if (!doc) {
|
||||
const got = this.documents.find((item) => item.isBlank());
|
||||
if (got) {
|
||||
@ -341,7 +387,7 @@ export class Project implements IProject {
|
||||
};
|
||||
}
|
||||
|
||||
onCurrentDocumentChange(fn: (doc: DocumentModel) => void): () => void {
|
||||
onCurrentDocumentChange(fn: (doc: IDocumentModel) => void): () => void {
|
||||
this.emitter.on('current-document.change', fn);
|
||||
return () => {
|
||||
this.emitter.removeListener('current-document.change', fn);
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import { isEqual } from 'lodash';
|
||||
import { globalContext } from './di';
|
||||
import { IPublicTypeHotkeyCallback, IPublicApiHotkey } from '@alilc/lowcode-types';
|
||||
import { IPublicTypeHotkeyCallback, IPublicTypeHotkeyCallbackConfig, IPublicTypeHotkeyCallbacks, IPublicApiHotkey } from '@alilc/lowcode-types';
|
||||
|
||||
interface KeyMap {
|
||||
[key: number]: string;
|
||||
@ -14,23 +14,10 @@ interface ActionEvent {
|
||||
type: string;
|
||||
}
|
||||
|
||||
interface IPublicTypeHotkeyCallbacks {
|
||||
[key: string]: IPublicTypeHotkeyCallbackCfg[];
|
||||
}
|
||||
|
||||
interface HotkeyDirectMap {
|
||||
[key: string]: IPublicTypeHotkeyCallback;
|
||||
}
|
||||
|
||||
interface IPublicTypeHotkeyCallbackCfg {
|
||||
callback: IPublicTypeHotkeyCallback;
|
||||
modifiers: string[];
|
||||
action: string;
|
||||
seq?: string;
|
||||
level?: number;
|
||||
combo?: string;
|
||||
}
|
||||
|
||||
interface KeyInfo {
|
||||
key: string;
|
||||
modifiers: string[];
|
||||
@ -444,10 +431,10 @@ export class Hotkey implements IHotKey {
|
||||
sequenceName?: string,
|
||||
combination?: string,
|
||||
level?: number,
|
||||
): IPublicTypeHotkeyCallbackCfg[] {
|
||||
): IPublicTypeHotkeyCallbackConfig[] {
|
||||
let i: number;
|
||||
let callback: IPublicTypeHotkeyCallbackCfg;
|
||||
const matches: IPublicTypeHotkeyCallbackCfg[] = [];
|
||||
let callback: IPublicTypeHotkeyCallbackConfig;
|
||||
const matches: IPublicTypeHotkeyCallbackConfig[] = [];
|
||||
const action: string = e.type;
|
||||
|
||||
// if there are no events related to this keycode
|
||||
@ -498,7 +485,7 @@ export class Hotkey implements IHotKey {
|
||||
}
|
||||
|
||||
private handleKey(character: string, modifiers: string[], e: KeyboardEvent): void {
|
||||
const callbacks: IPublicTypeHotkeyCallbackCfg[] = this.getMatches(character, modifiers, e);
|
||||
const callbacks: IPublicTypeHotkeyCallbackConfig[] = this.getMatches(character, modifiers, e);
|
||||
let i: number;
|
||||
const doNotReset: SequenceLevels = {};
|
||||
let maxLevel = 0;
|
||||
|
||||
@ -14,9 +14,11 @@ import {
|
||||
IDesigner,
|
||||
} from '@alilc/lowcode-designer';
|
||||
import { editorSymbol, designerSymbol, nodeSymbol } from '../symbols';
|
||||
import { Dragon } from '../model';
|
||||
import { DropLocation } from '../model/drop-location';
|
||||
import { ActiveTracker } from '../model/active-tracker';
|
||||
import {
|
||||
Dragon as ShellDragon,
|
||||
DropLocation as ShellDropLocation,
|
||||
ActiveTracker as ShellActiveTracker,
|
||||
} from '../model';
|
||||
|
||||
export class Canvas implements IPublicApiCanvas {
|
||||
private readonly [editorSymbol]: IPublicModelEditor;
|
||||
@ -25,6 +27,15 @@ export class Canvas implements IPublicApiCanvas {
|
||||
return this[editorSymbol].get('designer') as IDesigner;
|
||||
}
|
||||
|
||||
get dragon(): IPublicModelDragon | null {
|
||||
return ShellDragon.create(this[designerSymbol].dragon, this.workspaceMode);
|
||||
}
|
||||
|
||||
get activeTracker(): IPublicModelActiveTracker | null {
|
||||
const activeTracker = new ShellActiveTracker(this[designerSymbol].activeTracker);
|
||||
return activeTracker;
|
||||
}
|
||||
|
||||
constructor(editor: IPublicModelEditor, readonly workspaceMode: boolean = false) {
|
||||
this[editorSymbol] = editor;
|
||||
}
|
||||
@ -47,19 +58,10 @@ export class Canvas implements IPublicApiCanvas {
|
||||
});
|
||||
}
|
||||
|
||||
get dragon(): IPublicModelDragon | null {
|
||||
return Dragon.create(this[designerSymbol].dragon, this.workspaceMode);
|
||||
}
|
||||
|
||||
get activeTracker(): IPublicModelActiveTracker | null {
|
||||
const activeTracker = new ActiveTracker(this[designerSymbol].activeTracker);
|
||||
return activeTracker;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
*/
|
||||
get dropLocation() {
|
||||
return DropLocation.create((this[designerSymbol] as any).dropLocation || null);
|
||||
return ShellDropLocation.create((this[designerSymbol] as any).dropLocation || null);
|
||||
}
|
||||
}
|
||||
@ -58,7 +58,7 @@ import {
|
||||
computed as innerComputed,
|
||||
observer as innerObserver,
|
||||
} from '@alilc/lowcode-editor-core';
|
||||
import { Dragon } from '../model';
|
||||
import { Dragon as ShellDragon } from '../model';
|
||||
import { ReactNode, Component } from 'react';
|
||||
|
||||
class DesignerCabin implements IPublicApiCommonDesignerCabin {
|
||||
@ -149,7 +149,7 @@ class DesignerCabin implements IPublicApiCommonDesignerCabin {
|
||||
* @deprecated please use canvas.dragon
|
||||
*/
|
||||
get dragon(): IPublicModelDragon | null {
|
||||
return Dragon.create(this[designerSymbol].dragon);
|
||||
return ShellDragon.create(this[designerSymbol].dragon, false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -14,12 +14,6 @@ export class Event implements IPublicApiEvent {
|
||||
private readonly [eventBusSymbol]: EventBus;
|
||||
private readonly options: EventOptions;
|
||||
|
||||
// TODO:
|
||||
/**
|
||||
* 内核触发的事件名
|
||||
*/
|
||||
readonly names = [];
|
||||
|
||||
constructor(eventBus: EventBus, options: EventOptions, public workspaceMode = false) {
|
||||
this[eventBusSymbol] = eventBus;
|
||||
this.options = options;
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import { globalContext, Hotkey as InnerHotkey } from '@alilc/lowcode-editor-core';
|
||||
import { hotkeySymbol } from '../symbols';
|
||||
import { IPublicTypeDisposable, IPublicTypeHotkeyCallback, IPublicApiHotkey } from '@alilc/lowcode-types';
|
||||
import { IPublicTypeDisposable, IPublicTypeHotkeyCallback, IPublicTypeHotkeyCallbacks, IPublicApiHotkey } from '@alilc/lowcode-types';
|
||||
|
||||
const innerHotkeySymbol = Symbol('innerHotkey');
|
||||
|
||||
@ -22,15 +22,17 @@ export class Hotkey implements IPublicApiHotkey {
|
||||
this[innerHotkeySymbol] = hotkey;
|
||||
}
|
||||
|
||||
get callbacks(): any {
|
||||
get callbacks(): IPublicTypeHotkeyCallbacks {
|
||||
return this[hotkeySymbol].callBacks;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
*/
|
||||
get callBacks() {
|
||||
return this.callbacks;
|
||||
}
|
||||
|
||||
/**
|
||||
* 绑定快捷键
|
||||
* @param combos 快捷键,格式如:['command + s'] 、['ctrl + shift + s'] 等
|
||||
@ -38,7 +40,11 @@ export class Hotkey implements IPublicApiHotkey {
|
||||
* @param action
|
||||
* @returns
|
||||
*/
|
||||
bind(combos: string[] | string, callback: IPublicTypeHotkeyCallback, action?: string): IPublicTypeDisposable {
|
||||
bind(
|
||||
combos: string[] | string,
|
||||
callback: IPublicTypeHotkeyCallback,
|
||||
action?: string,
|
||||
): IPublicTypeDisposable {
|
||||
this[hotkeySymbol].bind(combos, callback, action);
|
||||
return () => {
|
||||
this[hotkeySymbol].unbind(combos, callback, action);
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import { Editor, globalContext } from '@alilc/lowcode-editor-core';
|
||||
import { globalContext } from '@alilc/lowcode-editor-core';
|
||||
import {
|
||||
Designer,
|
||||
IDesigner,
|
||||
isComponentMeta,
|
||||
} from '@alilc/lowcode-designer';
|
||||
import { IPublicTypeAssetsJson } from '@alilc/lowcode-utils';
|
||||
@ -11,21 +11,22 @@ import {
|
||||
IPublicTypeMetadataTransducer,
|
||||
IPublicModelComponentMeta,
|
||||
IPublicTypeNpmInfo,
|
||||
IPublicModelEditor,
|
||||
} from '@alilc/lowcode-types';
|
||||
import { Workspace } from '@alilc/lowcode-workspace';
|
||||
import { Workspace as InnerWorkspace } from '@alilc/lowcode-workspace';
|
||||
import { editorSymbol, designerSymbol } from '../symbols';
|
||||
import { ComponentMeta } from '../model/component-meta';
|
||||
import { ComponentMeta as ShellComponentMeta } from '../model';
|
||||
import { ComponentType } from 'react';
|
||||
|
||||
const innerEditorSymbol = Symbol('editor');
|
||||
export class Material implements IPublicApiMaterial {
|
||||
private readonly [innerEditorSymbol]: Editor;
|
||||
private readonly [innerEditorSymbol]: IPublicModelEditor;
|
||||
|
||||
get [editorSymbol](): Editor {
|
||||
get [editorSymbol](): IPublicModelEditor {
|
||||
if (this.workspaceMode) {
|
||||
return this[innerEditorSymbol];
|
||||
}
|
||||
const workspace: Workspace = globalContext.get('workspace');
|
||||
const workspace: InnerWorkspace = globalContext.get('workspace');
|
||||
if (workspace.isActive) {
|
||||
return workspace.window.editor;
|
||||
}
|
||||
@ -33,11 +34,11 @@ export class Material implements IPublicApiMaterial {
|
||||
return this[innerEditorSymbol];
|
||||
}
|
||||
|
||||
get [designerSymbol](): Designer {
|
||||
get [designerSymbol](): IDesigner {
|
||||
return this[editorSymbol].get('designer')!;
|
||||
}
|
||||
|
||||
constructor(editor: Editor, readonly workspaceMode: boolean = false) {
|
||||
constructor(editor: IPublicModelEditor, readonly workspaceMode: boolean = false) {
|
||||
this[innerEditorSymbol] = editor;
|
||||
}
|
||||
|
||||
@ -103,7 +104,7 @@ export class Material implements IPublicApiMaterial {
|
||||
*/
|
||||
getComponentMeta(componentName: string): IPublicModelComponentMeta | null {
|
||||
const innerMeta = this[designerSymbol].getComponentMeta(componentName);
|
||||
return ComponentMeta.create(innerMeta);
|
||||
return ShellComponentMeta.create(innerMeta);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -112,7 +113,7 @@ export class Material implements IPublicApiMaterial {
|
||||
* @returns
|
||||
*/
|
||||
createComponentMeta(metadata: IPublicTypeComponentMetadata) {
|
||||
return ComponentMeta.create(this[designerSymbol].createComponentMeta(metadata));
|
||||
return ShellComponentMeta.create(this[designerSymbol].createComponentMeta(metadata));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -158,7 +159,10 @@ export class Material implements IPublicApiMaterial {
|
||||
* @param actionName
|
||||
* @param handle
|
||||
*/
|
||||
modifyBuiltinComponentAction(actionName: string, handle: (action: IPublicTypeComponentAction) => void) {
|
||||
modifyBuiltinComponentAction(
|
||||
actionName: string,
|
||||
handle: (action: IPublicTypeComponentAction) => void,
|
||||
) {
|
||||
this[designerSymbol].componentActions.modifyBuiltinComponentAction(actionName, handle);
|
||||
}
|
||||
|
||||
|
||||
@ -9,7 +9,7 @@ import {
|
||||
IPublicTypePluginRegisterOptions,
|
||||
IPublicTypePreferenceValueType,
|
||||
} from '@alilc/lowcode-types';
|
||||
import { PluginInstance } from '../model/plugin-instance';
|
||||
import { PluginInstance as ShellPluginInstance } from '../model';
|
||||
import { pluginsSymbol } from '../symbols';
|
||||
|
||||
const innerPluginsSymbol = Symbol('plugin');
|
||||
@ -43,21 +43,23 @@ export class Plugins implements IPublicApiPlugins {
|
||||
await this[pluginsSymbol].init(registerOptions);
|
||||
}
|
||||
|
||||
getPluginPreference(pluginName: string): Record<string, IPublicTypePreferenceValueType> | null | undefined {
|
||||
getPluginPreference(
|
||||
pluginName: string,
|
||||
): Record<string, IPublicTypePreferenceValueType> | null | undefined {
|
||||
return this[pluginsSymbol].getPluginPreference(pluginName);
|
||||
}
|
||||
|
||||
get(pluginName: string): IPublicModelPluginInstance | null {
|
||||
const instance = this[pluginsSymbol].get(pluginName);
|
||||
if (instance) {
|
||||
return new PluginInstance(instance);
|
||||
return new ShellPluginInstance(instance);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
getAll() {
|
||||
return this[pluginsSymbol].getAll()?.map(d => new PluginInstance(d));
|
||||
return this[pluginsSymbol].getAll()?.map((d) => new ShellPluginInstance(d));
|
||||
}
|
||||
|
||||
has(pluginName: string) {
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import {
|
||||
BuiltinSimulatorHost,
|
||||
Project as InnerProject,
|
||||
IProject as InnerProject,
|
||||
} from '@alilc/lowcode-designer';
|
||||
import { globalContext } from '@alilc/lowcode-editor-core';
|
||||
import {
|
||||
@ -14,9 +14,7 @@ import {
|
||||
IPublicEnumTransformStage,
|
||||
IPublicTypeDisposable,
|
||||
} from '@alilc/lowcode-types';
|
||||
|
||||
|
||||
import { DocumentModel } from '../model/document-model';
|
||||
import { DocumentModel as ShellDocumentModel } from '../model';
|
||||
import { SimulatorHost } from './simulator-host';
|
||||
import { editorSymbol, projectSymbol, simulatorHostSymbol, documentSymbol } from '../symbols';
|
||||
|
||||
@ -61,7 +59,7 @@ export class Project implements IPublicApiProject {
|
||||
* @returns
|
||||
*/
|
||||
get documents(): IPublicModelDocumentModel[] {
|
||||
return this[projectSymbol].documents.map((doc) => DocumentModel.create(doc)!);
|
||||
return this[projectSymbol].documents.map((doc) => ShellDocumentModel.create(doc)!);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -85,8 +83,10 @@ export class Project implements IPublicApiProject {
|
||||
*/
|
||||
openDocument(doc?: string | IPublicTypeRootSchema | undefined) {
|
||||
const documentModel = this[projectSymbol].open(doc);
|
||||
if (!documentModel) return null;
|
||||
return DocumentModel.create(documentModel);
|
||||
if (!documentModel) {
|
||||
return null;
|
||||
}
|
||||
return ShellDocumentModel.create(documentModel);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -96,7 +96,7 @@ export class Project implements IPublicApiProject {
|
||||
*/
|
||||
createDocument(data?: IPublicTypeRootSchema): IPublicModelDocumentModel | null {
|
||||
const doc = this[projectSymbol].createDocument(data);
|
||||
return DocumentModel.create(doc);
|
||||
return ShellDocumentModel.create(doc);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -113,7 +113,8 @@ export class Project implements IPublicApiProject {
|
||||
* @returns
|
||||
*/
|
||||
getDocumentByFileName(fileName: string): IPublicModelDocumentModel | null {
|
||||
return DocumentModel.create(this[projectSymbol].getDocumentByFileName(fileName));
|
||||
const innerDocumentModel = this[projectSymbol].getDocumentByFileName(fileName);
|
||||
return ShellDocumentModel.create(innerDocumentModel);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -122,7 +123,7 @@ export class Project implements IPublicApiProject {
|
||||
* @returns
|
||||
*/
|
||||
getDocumentById(id: string): IPublicModelDocumentModel | null {
|
||||
return DocumentModel.create(this[projectSymbol].getDocument(id));
|
||||
return ShellDocumentModel.create(this[projectSymbol].getDocument(id));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -146,7 +147,7 @@ export class Project implements IPublicApiProject {
|
||||
* @returns
|
||||
*/
|
||||
getCurrentDocument(): IPublicModelDocumentModel | null {
|
||||
return DocumentModel.create(this[projectSymbol].currentDocument);
|
||||
return ShellDocumentModel.create(this[projectSymbol].currentDocument);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -154,7 +155,10 @@ export class Project implements IPublicApiProject {
|
||||
* @param transducer
|
||||
* @param stage
|
||||
*/
|
||||
addPropsTransducer(transducer: IPublicTypePropsTransducer, stage: IPublicEnumTransformStage): void {
|
||||
addPropsTransducer(
|
||||
transducer: IPublicTypePropsTransducer,
|
||||
stage: IPublicEnumTransformStage,
|
||||
): void {
|
||||
this[projectSymbol].designer.addPropsReducer(transducer, stage);
|
||||
}
|
||||
|
||||
@ -175,10 +179,10 @@ export class Project implements IPublicApiProject {
|
||||
*/
|
||||
onChangeDocument(fn: (doc: IPublicModelDocumentModel) => void): IPublicTypeDisposable {
|
||||
const offFn = this[projectSymbol].onCurrentDocumentChange((originalDoc) => {
|
||||
fn(DocumentModel.create(originalDoc)!);
|
||||
fn(ShellDocumentModel.create(originalDoc)!);
|
||||
});
|
||||
if (this[projectSymbol].currentDocument) {
|
||||
fn(DocumentModel.create(this[projectSymbol].currentDocument)!);
|
||||
fn(ShellDocumentModel.create(this[projectSymbol].currentDocument)!);
|
||||
}
|
||||
return offFn;
|
||||
}
|
||||
|
||||
@ -23,7 +23,11 @@ export class Skeleton implements IPublicApiSkeleton {
|
||||
return this[innerSkeletonSymbol];
|
||||
}
|
||||
|
||||
constructor(skeleton: InnerSkeleton, pluginName: string, readonly workspaceMode: boolean = false) {
|
||||
constructor(
|
||||
skeleton: InnerSkeleton,
|
||||
pluginName: string,
|
||||
readonly workspaceMode: boolean = false,
|
||||
) {
|
||||
this[innerSkeletonSymbol] = skeleton;
|
||||
this.pluginName = pluginName;
|
||||
}
|
||||
|
||||
@ -1,9 +1,8 @@
|
||||
import { IPublicApiWorkspace, IPublicResourceList, IPublicTypeResourceType } from '@alilc/lowcode-types';
|
||||
import { Workspace as InnerWorkSpace } from '@alilc/lowcode-workspace';
|
||||
import { Plugins } from '@alilc/lowcode-shell';
|
||||
import { Window } from '../model/window';
|
||||
import { workspaceSymbol } from '../symbols';
|
||||
import { Resource } from '../model';
|
||||
import { Resource as ShellResource, Window as ShellWindow } from '../model';
|
||||
|
||||
export class Workspace implements IPublicApiWorkspace {
|
||||
readonly [workspaceSymbol]: InnerWorkSpace;
|
||||
@ -13,7 +12,7 @@ export class Workspace implements IPublicApiWorkspace {
|
||||
}
|
||||
|
||||
get resourceList() {
|
||||
return this[workspaceSymbol].getResourceList().map(d => new Resource(d));
|
||||
return this[workspaceSymbol].getResourceList().map((d) => new ShellResource(d));
|
||||
}
|
||||
|
||||
setResourceList(resourceList: IPublicResourceList) {
|
||||
@ -29,14 +28,14 @@ export class Workspace implements IPublicApiWorkspace {
|
||||
}
|
||||
|
||||
get window() {
|
||||
return new Window(this[workspaceSymbol].window);
|
||||
return new ShellWindow(this[workspaceSymbol].window);
|
||||
}
|
||||
|
||||
registerResourceType(resourceTypeModel: IPublicTypeResourceType): void {
|
||||
this[workspaceSymbol].registerResourceType(resourceTypeModel);
|
||||
}
|
||||
|
||||
openEditorWindow(resourceName: string, title: string, extra: Object, viewName?: string) {
|
||||
openEditorWindow(resourceName: string, title: string, extra: object, viewName?: string) {
|
||||
this[workspaceSymbol].openEditorWindow(resourceName, title, extra, viewName);
|
||||
}
|
||||
|
||||
@ -57,7 +56,7 @@ export class Workspace implements IPublicApiWorkspace {
|
||||
}
|
||||
|
||||
get windows() {
|
||||
return this[workspaceSymbol].windows.map(d => new Window(d));
|
||||
return this[workspaceSymbol].windows.map((d) => new ShellWindow(d));
|
||||
}
|
||||
|
||||
onChangeWindows(fn: () => void) {
|
||||
|
||||
@ -1,16 +1,14 @@
|
||||
import { IPublicModelActiveTracker, IPublicModelNode, IPublicTypeActiveTarget } from '@alilc/lowcode-types';
|
||||
import { IActiveTracker } from '@alilc/lowcode-designer';
|
||||
import { Node } from './node';
|
||||
import { IActiveTracker as InnerActiveTracker, INode as InnerNode } from '@alilc/lowcode-designer';
|
||||
import { Node as ShellNode } from './node';
|
||||
import { nodeSymbol } from '../symbols';
|
||||
|
||||
const activeTrackerSymbol = Symbol('activeTracker');
|
||||
|
||||
|
||||
export class ActiveTracker implements IPublicModelActiveTracker {
|
||||
private readonly [activeTrackerSymbol]: IActiveTracker;
|
||||
private readonly [activeTrackerSymbol]: InnerActiveTracker;
|
||||
|
||||
|
||||
constructor(innerTracker: IActiveTracker) {
|
||||
constructor(innerTracker: InnerActiveTracker) {
|
||||
this[activeTrackerSymbol] = innerTracker;
|
||||
}
|
||||
|
||||
@ -20,7 +18,7 @@ export class ActiveTracker implements IPublicModelActiveTracker {
|
||||
}
|
||||
return this[activeTrackerSymbol].onChange((t: IPublicTypeActiveTarget) => {
|
||||
const { node: innerNode, detail, instance } = t;
|
||||
const publicNode = Node.create(innerNode);
|
||||
const publicNode = ShellNode.create(innerNode as InnerNode);
|
||||
const publicActiveTarget = {
|
||||
node: publicNode!,
|
||||
detail,
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
import {
|
||||
ComponentMeta as InnerComponentMeta,
|
||||
IComponentMeta as InnerComponentMeta,
|
||||
INode,
|
||||
} from '@alilc/lowcode-designer';
|
||||
import { IPublicTypeNodeData, IPublicTypeNodeSchema, IPublicModelComponentMeta, IPublicTypeI18nData, IPublicTypeIconType, IPublicTypeNpmInfo, IPublicTypeTransformedComponentMetadata, IPublicModelNode } from '@alilc/lowcode-types';
|
||||
@ -9,6 +9,8 @@ import { ReactElement } from 'react';
|
||||
export class ComponentMeta implements IPublicModelComponentMeta {
|
||||
private readonly [componentMetaSymbol]: InnerComponentMeta;
|
||||
|
||||
isComponentMeta = true;
|
||||
|
||||
constructor(componentMeta: InnerComponentMeta) {
|
||||
this[componentMetaSymbol] = componentMeta;
|
||||
}
|
||||
@ -83,7 +85,7 @@ export class ComponentMeta implements IPublicModelComponentMeta {
|
||||
* @deprecated
|
||||
*/
|
||||
get prototype() {
|
||||
return this[componentMetaSymbol].prototype;
|
||||
return (this[componentMetaSymbol] as any).prototype;
|
||||
}
|
||||
|
||||
get availableActions(): any {
|
||||
@ -106,7 +108,6 @@ export class ComponentMeta implements IPublicModelComponentMeta {
|
||||
return this[componentMetaSymbol].getMetadata();
|
||||
}
|
||||
|
||||
isComponentMeta = true;
|
||||
/**
|
||||
* check if the current node could be placed in parent node
|
||||
* @param my
|
||||
@ -124,9 +125,15 @@ export class ComponentMeta implements IPublicModelComponentMeta {
|
||||
* @param parent
|
||||
* @returns
|
||||
*/
|
||||
checkNestingDown(my: IPublicModelNode | IPublicTypeNodeData, target: IPublicTypeNodeSchema | IPublicModelNode | IPublicTypeNodeSchema[]) {
|
||||
checkNestingDown(
|
||||
my: IPublicModelNode | IPublicTypeNodeData,
|
||||
target: IPublicTypeNodeSchema | IPublicModelNode | IPublicTypeNodeSchema[],
|
||||
) {
|
||||
const curNode = (my as any)?.isNode ? (my as any)[nodeSymbol] : my;
|
||||
return this[componentMetaSymbol].checkNestingDown(curNode as any, (target as any)[nodeSymbol] || target);
|
||||
return this[componentMetaSymbol].checkNestingDown(
|
||||
curNode as any,
|
||||
(target as any)[nodeSymbol] || target,
|
||||
);
|
||||
}
|
||||
|
||||
refreshMetadata(): void {
|
||||
|
||||
@ -2,6 +2,7 @@ import { Node as ShellNode } from './node';
|
||||
import {
|
||||
Detecting as InnerDetecting,
|
||||
IDocumentModel as InnerDocumentModel,
|
||||
INode as InnerNode,
|
||||
} from '@alilc/lowcode-designer';
|
||||
import { documentSymbol, detectingSymbol } from '../symbols';
|
||||
import { IPublicModelDetecting, IPublicModelNode, IPublicTypeDisposable } from '@alilc/lowcode-types';
|
||||
@ -52,7 +53,11 @@ export class Detecting implements IPublicModelDetecting {
|
||||
this[detectingSymbol].leave(this[documentSymbol]);
|
||||
}
|
||||
|
||||
onDetectingChange(fn: (node: IPublicModelNode) => void): IPublicTypeDisposable {
|
||||
return this[detectingSymbol].onDetectingChange(fn);
|
||||
onDetectingChange(fn: (node: IPublicModelNode | null) => void): IPublicTypeDisposable {
|
||||
const innerFn = (innerNode: InnerNode) => {
|
||||
const shellNode = ShellNode.create(innerNode);
|
||||
fn(shellNode);
|
||||
};
|
||||
return this[detectingSymbol].onDetectingChange(innerFn);
|
||||
}
|
||||
}
|
||||
@ -1,8 +1,6 @@
|
||||
import { Editor } from '@alilc/lowcode-editor-core';
|
||||
import {
|
||||
DocumentModel as InnerDocumentModel,
|
||||
Node as InnerNode,
|
||||
isDragNodeObject,
|
||||
IDocumentModel as InnerDocumentModel,
|
||||
INode as InnerNode,
|
||||
} from '@alilc/lowcode-designer';
|
||||
import {
|
||||
IPublicEnumTransformStage,
|
||||
@ -23,23 +21,24 @@ import {
|
||||
IPublicModelDropLocation,
|
||||
IPublicApiCanvas,
|
||||
IPublicTypeDisposable,
|
||||
IPublicModelEditor,
|
||||
} from '@alilc/lowcode-types';
|
||||
import { Node } from './node';
|
||||
import { Selection } from './selection';
|
||||
import { Detecting } from './detecting';
|
||||
import { History } from './history';
|
||||
import { DropLocation } from './drop-location';
|
||||
import { Project } from '../api/project';
|
||||
import { Prop } from './prop';
|
||||
import { isDragNodeObject } from '@alilc/lowcode-utils';
|
||||
import { Node as ShellNode } from './node';
|
||||
import { Selection as ShellSelection } from './selection';
|
||||
import { Detecting as ShellDetecting } from './detecting';
|
||||
import { History as ShellHistory } from './history';
|
||||
import { DropLocation as ShellDropLocation } from './drop-location';
|
||||
import { Project as ShellProject, Canvas as ShellCanvas } from '../api';
|
||||
import { Prop as ShellProp } from './prop';
|
||||
import { ModalNodesManager } from './modal-nodes-manager';
|
||||
import { documentSymbol, editorSymbol, nodeSymbol } from '../symbols';
|
||||
import { Canvas } from '../api';
|
||||
|
||||
const shellDocSymbol = Symbol('shellDocSymbol');
|
||||
|
||||
export class DocumentModel implements IPublicModelDocumentModel {
|
||||
private readonly [documentSymbol]: InnerDocumentModel;
|
||||
private readonly [editorSymbol]: Editor;
|
||||
private readonly [editorSymbol]: IPublicModelEditor;
|
||||
private _focusNode: IPublicModelNode | null;
|
||||
selection: IPublicModelSelection;
|
||||
detecting: IPublicModelDetecting;
|
||||
@ -52,13 +51,13 @@ export class DocumentModel implements IPublicModelDocumentModel {
|
||||
|
||||
constructor(document: InnerDocumentModel) {
|
||||
this[documentSymbol] = document;
|
||||
this[editorSymbol] = document.designer?.editor as Editor;
|
||||
this.selection = new Selection(document);
|
||||
this.detecting = new Detecting(document);
|
||||
this.history = new History(document);
|
||||
this.canvas = new Canvas(this[editorSymbol]);
|
||||
this[editorSymbol] = document.designer?.editor as IPublicModelEditor;
|
||||
this.selection = new ShellSelection(document);
|
||||
this.detecting = new ShellDetecting(document);
|
||||
this.history = new ShellHistory(document);
|
||||
this.canvas = new ShellCanvas(this[editorSymbol]);
|
||||
|
||||
this._focusNode = Node.create(this[documentSymbol].focusNode);
|
||||
this._focusNode = ShellNode.create(this[documentSymbol].focusNode);
|
||||
}
|
||||
|
||||
static create(document: InnerDocumentModel | undefined | null): IPublicModelDocumentModel | null {
|
||||
@ -91,7 +90,7 @@ export class DocumentModel implements IPublicModelDocumentModel {
|
||||
* @returns
|
||||
*/
|
||||
get project(): IPublicApiProject {
|
||||
return Project.create(this[documentSymbol].project);
|
||||
return ShellProject.create(this[documentSymbol].project);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -100,7 +99,7 @@ export class DocumentModel implements IPublicModelDocumentModel {
|
||||
* @returns
|
||||
*/
|
||||
get root(): IPublicModelNode | null {
|
||||
return Node.create(this[documentSymbol].getRoot());
|
||||
return ShellNode.create(this[documentSymbol].rootNode);
|
||||
}
|
||||
|
||||
get focusNode(): IPublicModelNode | null {
|
||||
@ -135,7 +134,7 @@ export class DocumentModel implements IPublicModelDocumentModel {
|
||||
}
|
||||
|
||||
get dropLocation(): IPublicModelDropLocation | null {
|
||||
return DropLocation.create(this[documentSymbol].dropLocation);
|
||||
return ShellDropLocation.create(this[documentSymbol].dropLocation);
|
||||
}
|
||||
|
||||
set dropLocation(loc: IPublicModelDropLocation | null) {
|
||||
@ -148,7 +147,7 @@ export class DocumentModel implements IPublicModelDocumentModel {
|
||||
* @param {string} nodeId
|
||||
*/
|
||||
getNodeById(nodeId: string): IPublicModelNode | null {
|
||||
return Node.create(this[documentSymbol].getNode(nodeId));
|
||||
return ShellNode.create(this[documentSymbol].getNode(nodeId));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -189,7 +188,7 @@ export class DocumentModel implements IPublicModelDocumentModel {
|
||||
at,
|
||||
copy,
|
||||
);
|
||||
return Node.create(node);
|
||||
return ShellNode.create(node);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -198,7 +197,7 @@ export class DocumentModel implements IPublicModelDocumentModel {
|
||||
* @returns
|
||||
*/
|
||||
createNode(data: any): IPublicModelNode | null {
|
||||
return Node.create(this[documentSymbol].createNode(data));
|
||||
return ShellNode.create(this[documentSymbol].createNode(data));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -243,7 +242,7 @@ export class DocumentModel implements IPublicModelDocumentModel {
|
||||
*/
|
||||
onAddNode(fn: (node: IPublicModelNode) => void): IPublicTypeDisposable {
|
||||
return this[documentSymbol].onNodeCreate((node: InnerNode) => {
|
||||
fn(Node.create(node)!);
|
||||
fn(ShellNode.create(node)!);
|
||||
});
|
||||
}
|
||||
|
||||
@ -262,7 +261,7 @@ export class DocumentModel implements IPublicModelDocumentModel {
|
||||
*/
|
||||
onRemoveNode(fn: (node: IPublicModelNode) => void): IPublicTypeDisposable {
|
||||
return this[documentSymbol].onNodeDestroy((node: InnerNode) => {
|
||||
fn(Node.create(node)!);
|
||||
fn(ShellNode.create(node)!);
|
||||
});
|
||||
}
|
||||
|
||||
@ -271,7 +270,7 @@ export class DocumentModel implements IPublicModelDocumentModel {
|
||||
*/
|
||||
onChangeDetecting(fn: (node: IPublicModelNode) => void): IPublicTypeDisposable {
|
||||
return this[documentSymbol].designer.detecting.onDetectingChange((node: InnerNode) => {
|
||||
fn(Node.create(node)!);
|
||||
fn(ShellNode.create(node)!);
|
||||
});
|
||||
}
|
||||
|
||||
@ -290,7 +289,7 @@ export class DocumentModel implements IPublicModelDocumentModel {
|
||||
*/
|
||||
onChangeNodeVisible(fn: (node: IPublicModelNode, visible: boolean) => void): void {
|
||||
this[documentSymbol].onChangeNodeVisible((node: IPublicModelNode, visible: boolean) => {
|
||||
fn(Node.create(node)!, visible);
|
||||
fn(ShellNode.create(node)!, visible);
|
||||
});
|
||||
}
|
||||
|
||||
@ -305,7 +304,7 @@ export class DocumentModel implements IPublicModelDocumentModel {
|
||||
}
|
||||
fn({
|
||||
type: info.type,
|
||||
node: Node.create(info.node)!,
|
||||
node: ShellNode.create(info.node)!,
|
||||
});
|
||||
});
|
||||
}
|
||||
@ -322,8 +321,8 @@ export class DocumentModel implements IPublicModelDocumentModel {
|
||||
key: info.key,
|
||||
oldValue: info.oldValue,
|
||||
newValue: info.newValue,
|
||||
prop: Prop.create(info.prop)!,
|
||||
node: Node.create(info.node as any)!,
|
||||
prop: ShellProp.create(info.prop)!,
|
||||
node: ShellNode.create(info.node as any)!,
|
||||
});
|
||||
},
|
||||
);
|
||||
|
||||
@ -9,7 +9,7 @@ export class DragObject implements IPublicModelDragObject {
|
||||
this[dragObjectSymbol] = dragObject;
|
||||
}
|
||||
|
||||
static create(dragObject: InnerDragObject): IPublicModelDragObject | null {
|
||||
static create(dragObject: InnerDragObject | null): IPublicModelDragObject | null {
|
||||
if (!dragObject) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -15,7 +15,6 @@ import {
|
||||
|
||||
export const innerDragonSymbol = Symbol('innerDragonSymbol');
|
||||
|
||||
|
||||
export class Dragon implements IPublicModelDragon {
|
||||
private readonly [innerDragonSymbol]: IPublicModelDragon;
|
||||
|
||||
@ -38,7 +37,10 @@ export class Dragon implements IPublicModelDragon {
|
||||
return designer.dragon;
|
||||
}
|
||||
|
||||
static create(dragon: IPublicModelDragon | null, workspaceMode: boolean): IPublicModelDragon | null {
|
||||
static create(
|
||||
dragon: IPublicModelDragon | null,
|
||||
workspaceMode: boolean,
|
||||
): IPublicModelDragon | null {
|
||||
if (!dragon) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
import {
|
||||
DropLocation as InnerDropLocation,
|
||||
IDropLocation as InnerDropLocation,
|
||||
} from '@alilc/lowcode-designer';
|
||||
import { dropLocationSymbol } from '../symbols';
|
||||
import { Node } from './node';
|
||||
|
||||
@ -1,11 +1,11 @@
|
||||
import { DocumentModel as InnerDocumentModel } from '@alilc/lowcode-designer';
|
||||
import { IDocumentModel as InnerDocumentModel, IHistory as InnerHistory } from '@alilc/lowcode-designer';
|
||||
import { historySymbol, documentSymbol } from '../symbols';
|
||||
import { IPublicModelHistory, IPublicTypeDisposable } from '@alilc/lowcode-types';
|
||||
|
||||
export class History implements IPublicModelHistory {
|
||||
private readonly [documentSymbol]: InnerDocumentModel;
|
||||
|
||||
private get [historySymbol]() {
|
||||
private get [historySymbol](): InnerHistory {
|
||||
return this[documentSymbol].getHistory();
|
||||
}
|
||||
|
||||
@ -64,7 +64,7 @@ export class History implements IPublicModelHistory {
|
||||
* @returns
|
||||
*/
|
||||
onChangeState(func: () => any): IPublicTypeDisposable {
|
||||
return this[historySymbol].onStateChange(func);
|
||||
return this[historySymbol].onChangeState(func);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -73,6 +73,6 @@ export class History implements IPublicModelHistory {
|
||||
* @returns
|
||||
*/
|
||||
onChangeCursor(func: () => any): IPublicTypeDisposable {
|
||||
return this[historySymbol].onCursor(func);
|
||||
return this[historySymbol].onChangeCursor(func);
|
||||
}
|
||||
}
|
||||
|
||||
@ -14,4 +14,7 @@ export * from './props';
|
||||
export * from './selection';
|
||||
export * from './setting-prop-entry';
|
||||
export * from './setting-top-entry';
|
||||
export * from './resource';
|
||||
export * from './resource';
|
||||
export * from './active-tracker';
|
||||
export * from './plugin-instance';
|
||||
export * from './window';
|
||||
@ -1,6 +1,6 @@
|
||||
import { INode as InnerNode, INodeChildren } from '@alilc/lowcode-designer';
|
||||
import { IPublicTypeNodeData, IPublicEnumTransformStage, IPublicModelNodeChildren, IPublicModelNode } from '@alilc/lowcode-types';
|
||||
import { Node } from './node';
|
||||
import { Node as ShellNode } from './node';
|
||||
import { nodeSymbol, nodeChildrenSymbol } from '../symbols';
|
||||
|
||||
export class NodeChildren implements IPublicModelNodeChildren {
|
||||
@ -21,7 +21,7 @@ export class NodeChildren implements IPublicModelNodeChildren {
|
||||
* 返回当前 children 实例所属的节点实例
|
||||
*/
|
||||
get owner(): IPublicModelNode | null {
|
||||
return Node.create(this[nodeChildrenSymbol].owner);
|
||||
return ShellNode.create(this[nodeChildrenSymbol].owner);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -107,7 +107,7 @@ export class NodeChildren implements IPublicModelNodeChildren {
|
||||
* @returns
|
||||
*/
|
||||
get(index: number): IPublicModelNode | null {
|
||||
return Node.create(this[nodeChildrenSymbol].get(index));
|
||||
return ShellNode.create(this[nodeChildrenSymbol].get(index));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -125,7 +125,7 @@ export class NodeChildren implements IPublicModelNodeChildren {
|
||||
*/
|
||||
forEach(fn: (node: IPublicModelNode, index: number) => void): void {
|
||||
this[nodeChildrenSymbol].forEach((item: InnerNode, index: number) => {
|
||||
fn(Node.create(item)!, index);
|
||||
fn(ShellNode.create(item)!, index);
|
||||
});
|
||||
}
|
||||
|
||||
@ -135,7 +135,7 @@ export class NodeChildren implements IPublicModelNodeChildren {
|
||||
*/
|
||||
map<T>(fn: (node: IPublicModelNode, index: number) => T[]): any[] | null {
|
||||
return this[nodeChildrenSymbol].map((item: InnerNode, index: number) => {
|
||||
return fn(Node.create(item)!, index);
|
||||
return fn(ShellNode.create(item)!, index);
|
||||
});
|
||||
}
|
||||
|
||||
@ -145,7 +145,7 @@ export class NodeChildren implements IPublicModelNodeChildren {
|
||||
*/
|
||||
every(fn: (node: IPublicModelNode, index: number) => boolean): boolean {
|
||||
return this[nodeChildrenSymbol].every((item: InnerNode, index: number) => {
|
||||
return fn(Node.create(item)!, index);
|
||||
return fn(ShellNode.create(item)!, index);
|
||||
});
|
||||
}
|
||||
|
||||
@ -155,7 +155,7 @@ export class NodeChildren implements IPublicModelNodeChildren {
|
||||
*/
|
||||
some(fn: (node: IPublicModelNode, index: number) => boolean): boolean {
|
||||
return this[nodeChildrenSymbol].some((item: InnerNode, index: number) => {
|
||||
return fn(Node.create(item)!, index);
|
||||
return fn(ShellNode.create(item)!, index);
|
||||
});
|
||||
}
|
||||
|
||||
@ -166,9 +166,9 @@ export class NodeChildren implements IPublicModelNodeChildren {
|
||||
filter(fn: (node: IPublicModelNode, index: number) => boolean): any {
|
||||
return this[nodeChildrenSymbol]
|
||||
.filter((item: InnerNode, index: number) => {
|
||||
return fn(Node.create(item)!, index);
|
||||
return fn(ShellNode.create(item)!, index);
|
||||
})
|
||||
.map((item: InnerNode) => Node.create(item)!);
|
||||
.map((item: InnerNode) => ShellNode.create(item)!);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -176,9 +176,9 @@ export class NodeChildren implements IPublicModelNodeChildren {
|
||||
* @param fn
|
||||
*/
|
||||
find(fn: (node: IPublicModelNode, index: number) => boolean): IPublicModelNode | null {
|
||||
return Node.create(
|
||||
return ShellNode.create(
|
||||
this[nodeChildrenSymbol].find((item: InnerNode, index: number) => {
|
||||
return fn(Node.create(item)!, index);
|
||||
return fn(ShellNode.create(item)!, index);
|
||||
}),
|
||||
);
|
||||
}
|
||||
@ -189,7 +189,7 @@ export class NodeChildren implements IPublicModelNodeChildren {
|
||||
*/
|
||||
reduce(fn: (acc: any, cur: IPublicModelNode) => any, initialValue: any): void {
|
||||
return this[nodeChildrenSymbol].reduce((acc: any, cur: InnerNode) => {
|
||||
return fn(acc, Node.create(cur)!);
|
||||
return fn(acc, ShellNode.create(cur)!);
|
||||
}, initialValue);
|
||||
}
|
||||
|
||||
@ -226,10 +226,11 @@ export class NodeChildren implements IPublicModelNodeChildren {
|
||||
sorter = () => 0;
|
||||
}
|
||||
this[nodeChildrenSymbol].mergeChildren(
|
||||
(node: InnerNode, idx: number) => remover(Node.create(node)!, idx),
|
||||
(children: InnerNode[]) => adder(children.map((node) => Node.create(node)!)),
|
||||
(firstNode: InnerNode, secondNode: InnerNode) =>
|
||||
sorter(Node.create(firstNode)!, Node.create(secondNode)!),
|
||||
(node: InnerNode, idx: number) => remover(ShellNode.create(node)!, idx),
|
||||
(children: InnerNode[]) => adder(children.map((node) => ShellNode.create(node)!)),
|
||||
(firstNode: InnerNode, secondNode: InnerNode) => {
|
||||
return sorter(ShellNode.create(firstNode)!, ShellNode.create(secondNode)!);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -283,7 +283,7 @@ export class Node implements IPublicModelNode {
|
||||
* 节点上挂载的插槽节点们
|
||||
*/
|
||||
get slots(): IPublicModelNode[] {
|
||||
return this[nodeSymbol].slots.map((node: IPublicModelNode) => Node.create(node)!);
|
||||
return this[nodeSymbol].slots.map((node: InnerNode) => Node.create(node)!);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -318,7 +318,7 @@ export class Node implements IPublicModelNode {
|
||||
return ShellSettingTopEntry.create(this[nodeSymbol].settingEntry as any);
|
||||
}
|
||||
|
||||
constructor(node: IPublicModelNode) {
|
||||
constructor(node: InnerNode) {
|
||||
this[nodeSymbol] = node;
|
||||
this[documentSymbol] = node.document;
|
||||
|
||||
@ -351,7 +351,7 @@ export class Node implements IPublicModelNode {
|
||||
* @deprecated
|
||||
*/
|
||||
getDOMNode() {
|
||||
return this[nodeSymbol].getDOMNode();
|
||||
return (this[nodeSymbol] as any).getDOMNode();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -512,7 +512,10 @@ export class Node implements IPublicModelNode {
|
||||
* @param options
|
||||
* @returns
|
||||
*/
|
||||
exportSchema(stage: IPublicEnumTransformStage = IPublicEnumTransformStage.Render, options?: any): IPublicTypeNodeSchema {
|
||||
exportSchema(
|
||||
stage: IPublicEnumTransformStage = IPublicEnumTransformStage.Render,
|
||||
options?: any,
|
||||
): IPublicTypeNodeSchema {
|
||||
return this[nodeSymbol].export(stage, options);
|
||||
}
|
||||
|
||||
|
||||
@ -1,7 +1,14 @@
|
||||
import { IPublicTypeDisposable, IPublicTypeHotkeyCallback } from '../type';
|
||||
import { IPublicTypeDisposable, IPublicTypeHotkeyCallback, IPublicTypeHotkeyCallbacks } from '../type';
|
||||
|
||||
export interface IPublicApiHotkey {
|
||||
get callbacks(): any;
|
||||
|
||||
/**
|
||||
* 获取当前快捷键配置
|
||||
*
|
||||
* @experimental
|
||||
* @since v1.1.0
|
||||
*/
|
||||
get callbacks(): IPublicTypeHotkeyCallbacks;
|
||||
|
||||
/**
|
||||
* 绑定快捷键
|
||||
@ -9,7 +16,6 @@ export interface IPublicApiHotkey {
|
||||
* @param combos 快捷键,格式如:['command + s'] 、['ctrl + shift + s'] 等
|
||||
* @param callback 回调函数
|
||||
* @param action
|
||||
* @returns
|
||||
*/
|
||||
bind(
|
||||
combos: string[] | string,
|
||||
|
||||
@ -3,8 +3,8 @@ import { IPublicEnumTransformStage } from '../enum';
|
||||
import { IPublicApiSimulatorHost } from './';
|
||||
import { IPublicModelDocumentModel } from '../model';
|
||||
|
||||
|
||||
export interface IPublicApiProject {
|
||||
|
||||
/**
|
||||
* 获取当前的 document
|
||||
* get current document
|
||||
@ -40,7 +40,6 @@ export interface IPublicApiProject {
|
||||
*/
|
||||
createDocument(data?: IPublicTypeRootSchema): IPublicModelDocumentModel | null;
|
||||
|
||||
|
||||
/**
|
||||
* 删除一个 document
|
||||
* remove a document
|
||||
|
||||
@ -3,6 +3,7 @@ import { ReactElement } from 'react';
|
||||
import { IPublicModelNode } from './node';
|
||||
|
||||
export interface IPublicModelComponentMeta {
|
||||
|
||||
/**
|
||||
* 组件名
|
||||
*/
|
||||
@ -79,6 +80,5 @@ export interface IPublicModelComponentMeta {
|
||||
target: IPublicTypeNodeSchema | IPublicModelNode | IPublicTypeNodeSchema[],
|
||||
): boolean;
|
||||
|
||||
|
||||
refreshMetadata(): void;
|
||||
}
|
||||
|
||||
@ -42,5 +42,5 @@ export interface IPublicModelDetecting {
|
||||
* set callback which will be called when hovering object changed.
|
||||
* @since v1.1.0
|
||||
*/
|
||||
onDetectingChange(fn: (node: IPublicModelNode) => void): IPublicTypeDisposable;
|
||||
onDetectingChange(fn: (node: IPublicModelNode | null) => void): IPublicTypeDisposable;
|
||||
}
|
||||
|
||||
@ -3,7 +3,7 @@ import { EventEmitter } from 'events';
|
||||
import StrictEventEmitter from 'strict-event-emitter-types';
|
||||
import * as GlobalEvent from '../../event';
|
||||
import { IPublicApiEvent } from '../api';
|
||||
import { IPublicTypeEditorValueKey, IPublicTypeEditorGetOptions, IPublicTypeEditorGetResult, IPublicTypeEditorRegisterOptions } from '../type';
|
||||
import { IPublicTypeEditorValueKey, IPublicTypeEditorGetOptions, IPublicTypeEditorGetResult, IPublicTypeEditorRegisterOptions, IPublicTypeAssetsJson } from '../type';
|
||||
|
||||
export interface IPublicModelEditor extends StrictEventEmitter<EventEmitter, GlobalEvent.EventConfig> {
|
||||
get: <T = undefined, KeyOrType = any>(
|
||||
@ -25,4 +25,6 @@ export interface IPublicModelEditor extends StrictEventEmitter<EventEmitter, Glo
|
||||
register: (data: any, key?: IPublicTypeEditorValueKey, options?: IPublicTypeEditorRegisterOptions) => void;
|
||||
|
||||
get eventBus(): IPublicApiEvent;
|
||||
|
||||
setAssets(assets: IPublicTypeAssetsJson): void;
|
||||
}
|
||||
|
||||
10
packages/types/src/shell/type/hotkey-callback-config.ts
Normal file
10
packages/types/src/shell/type/hotkey-callback-config.ts
Normal file
@ -0,0 +1,10 @@
|
||||
import { IPublicTypeHotkeyCallback } from './';
|
||||
|
||||
export interface IPublicTypeHotkeyCallbackConfig {
|
||||
callback: IPublicTypeHotkeyCallback;
|
||||
modifiers: string[];
|
||||
action: string;
|
||||
seq?: string;
|
||||
level?: number;
|
||||
combo?: string;
|
||||
}
|
||||
5
packages/types/src/shell/type/hotkey-callbacks.ts
Normal file
5
packages/types/src/shell/type/hotkey-callbacks.ts
Normal file
@ -0,0 +1,5 @@
|
||||
import { IPublicTypeHotkeyCallbackConfig } from './';
|
||||
|
||||
export interface IPublicTypeHotkeyCallbacks {
|
||||
[key: string]: IPublicTypeHotkeyCallbackConfig[];
|
||||
}
|
||||
@ -86,4 +86,6 @@ export * from './editor-register-options';
|
||||
export * from './editor-view';
|
||||
export * from './resource-type';
|
||||
export * from './resource-type-config';
|
||||
export * from './editor-view-config';
|
||||
export * from './editor-view-config';
|
||||
export * from './hotkey-callback-config';
|
||||
export * from './hotkey-callbacks';
|
||||
Loading…
x
Reference in New Issue
Block a user