@easy-editor/core 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +7 -0
- package/LICENSE +9 -0
- package/README.md +3 -0
- package/dist/cjs/index.development.js +11252 -0
- package/dist/cjs/index.development.js.map +1 -0
- package/dist/cjs/index.js +11252 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/index.production.js +11252 -0
- package/dist/cjs/index.production.js.map +1 -0
- package/dist/designer/clipboard.d.ts +12 -0
- package/dist/designer/component-meta/component-meta-manager.d.ts +21 -0
- package/dist/designer/component-meta/component-meta.d.ts +30 -0
- package/dist/designer/component-meta/index.d.ts +3 -0
- package/dist/designer/component-meta/meta.d.ts +264 -0
- package/dist/designer/designer.d.ts +86 -0
- package/dist/designer/detecting.d.ts +23 -0
- package/dist/designer/dragon.d.ts +103 -0
- package/dist/designer/index.d.ts +10 -0
- package/dist/designer/location.d.ts +94 -0
- package/dist/designer/offset-observer.d.ts +41 -0
- package/dist/designer/selection.d.ts +27 -0
- package/dist/designer/sensor.d.ts +30 -0
- package/dist/designer/setting/index.d.ts +5 -0
- package/dist/designer/setting/setting-entry.d.ts +42 -0
- package/dist/designer/setting/setting-field.d.ts +49 -0
- package/dist/designer/setting/setting-manager.d.ts +16 -0
- package/dist/designer/setting/setting-prop-entry.d.ts +89 -0
- package/dist/designer/setting/setting-top-entry.d.ts +83 -0
- package/dist/document/document.d.ts +89 -0
- package/dist/document/history.d.ts +76 -0
- package/dist/document/index.d.ts +6 -0
- package/dist/document/node/node-children.d.ts +51 -0
- package/dist/document/node/node.d.ts +233 -0
- package/dist/document/prop/prop.d.ts +185 -0
- package/dist/document/prop/props.d.ts +57 -0
- package/dist/document/prop/value-to-source.d.ts +8 -0
- package/dist/editor.d.ts +94 -0
- package/dist/esm/index.development.js +11145 -0
- package/dist/esm/index.development.js.map +1 -0
- package/dist/esm/index.js +11145 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/index.production.js +11145 -0
- package/dist/esm/index.production.js.map +1 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.js +11144 -0
- package/dist/plugin/index.d.ts +3 -0
- package/dist/plugin/plugin-context.d.ts +20 -0
- package/dist/plugin/plugin-extend.d.ts +32 -0
- package/dist/plugin/plugin-manager.d.ts +78 -0
- package/dist/plugin/plugin-runtime.d.ts +28 -0
- package/dist/plugin/sequencify.d.ts +19 -0
- package/dist/project/index.d.ts +1 -0
- package/dist/project/project.d.ts +68 -0
- package/dist/setter-manager/index.d.ts +1 -0
- package/dist/setter-manager/setter-manager.d.ts +29 -0
- package/dist/simulator/index.d.ts +3 -0
- package/dist/simulator/simulator-renderer.d.ts +41 -0
- package/dist/simulator/simulator.d.ts +106 -0
- package/dist/simulator/viewport.d.ts +29 -0
- package/dist/types/common.d.ts +11 -0
- package/dist/types/event.d.ts +12 -0
- package/dist/types/index.d.ts +3 -0
- package/dist/types/schema.d.ts +64 -0
- package/dist/utils/common.d.ts +1 -0
- package/dist/utils/event-bus.d.ts +45 -0
- package/dist/utils/hotkey.d.ts +87 -0
- package/dist/utils/index.d.ts +6 -0
- package/dist/utils/is.d.ts +2 -0
- package/dist/utils/logger.d.ts +18 -0
- package/dist/utils/unique-id.d.ts +5 -0
- package/package.json +67 -0
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { Node } from '../document';
|
|
2
|
+
import type { Designer } from './designer';
|
|
3
|
+
export declare enum SELECTION_EVENT {
|
|
4
|
+
CHANGE = "selection:change"
|
|
5
|
+
}
|
|
6
|
+
export declare class Selection {
|
|
7
|
+
readonly designer: Designer;
|
|
8
|
+
private emitter;
|
|
9
|
+
private accessor _selected;
|
|
10
|
+
get currentDocument(): import("..").Document;
|
|
11
|
+
constructor(designer: Designer);
|
|
12
|
+
get selected(): string[];
|
|
13
|
+
select(id: string): void;
|
|
14
|
+
selectAll(ids: string[]): void;
|
|
15
|
+
clear(): void;
|
|
16
|
+
/**
|
|
17
|
+
* tidy selected ids(remove invalid ids)
|
|
18
|
+
*/
|
|
19
|
+
tidy(): void;
|
|
20
|
+
add(id: string): void;
|
|
21
|
+
has(id: string): boolean;
|
|
22
|
+
remove(id: string): void;
|
|
23
|
+
containsNode(node: Node, excludeRoot?: boolean): boolean;
|
|
24
|
+
getNodes(): Node[];
|
|
25
|
+
getTopNodes(includeRoot?: boolean): Node<import("..").NodeSchema>[];
|
|
26
|
+
onSelectionChange(listener: (ids: string[]) => void): () => void;
|
|
27
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { Node } from '../document';
|
|
2
|
+
import type { ComponentInstance } from './component-meta';
|
|
3
|
+
import type { NodeInstance } from './dragon';
|
|
4
|
+
import type { DropLocation, LocateEvent } from './location';
|
|
5
|
+
export interface Sensor<T = Node> {
|
|
6
|
+
/**
|
|
7
|
+
* whether the sensor is available
|
|
8
|
+
*/
|
|
9
|
+
readonly sensorAvailable: boolean;
|
|
10
|
+
/**
|
|
11
|
+
* fix location event, add canvasX,canvasY
|
|
12
|
+
*/
|
|
13
|
+
fixEvent(e: LocateEvent): LocateEvent;
|
|
14
|
+
/**
|
|
15
|
+
* locate and activate
|
|
16
|
+
*/
|
|
17
|
+
locate(e: LocateEvent): DropLocation | undefined | null;
|
|
18
|
+
/**
|
|
19
|
+
* whether enter the sensitive area
|
|
20
|
+
*/
|
|
21
|
+
isEnter(e: LocateEvent): boolean;
|
|
22
|
+
/**
|
|
23
|
+
* deactivate
|
|
24
|
+
*/
|
|
25
|
+
deactiveSensor(): void;
|
|
26
|
+
/**
|
|
27
|
+
* get node instance from element
|
|
28
|
+
*/
|
|
29
|
+
getNodeInstanceFromElement?: (e: Element | null) => NodeInstance<ComponentInstance, T> | null;
|
|
30
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import type { Editor, Node, SetterManager } from '../..';
|
|
2
|
+
import type { Designer } from '../designer';
|
|
3
|
+
import type { SettingField } from './setting-field';
|
|
4
|
+
export interface SettingEntry {
|
|
5
|
+
readonly designer: Designer | undefined;
|
|
6
|
+
readonly id: string;
|
|
7
|
+
/**
|
|
8
|
+
* 同样类型的节点
|
|
9
|
+
*/
|
|
10
|
+
readonly isSameComponent: boolean;
|
|
11
|
+
/**
|
|
12
|
+
* 一个
|
|
13
|
+
*/
|
|
14
|
+
readonly isSingle: boolean;
|
|
15
|
+
/**
|
|
16
|
+
* 多个
|
|
17
|
+
*/
|
|
18
|
+
readonly isMultiple: boolean;
|
|
19
|
+
/**
|
|
20
|
+
* 编辑器引用
|
|
21
|
+
*/
|
|
22
|
+
readonly editor: Editor;
|
|
23
|
+
readonly setters: SetterManager;
|
|
24
|
+
/**
|
|
25
|
+
* 取得子项
|
|
26
|
+
*/
|
|
27
|
+
get: (propName: string | number) => SettingField | null;
|
|
28
|
+
readonly nodes: Node[];
|
|
29
|
+
/**
|
|
30
|
+
* 获取 node 中的第一项
|
|
31
|
+
*/
|
|
32
|
+
getNode: () => any;
|
|
33
|
+
}
|
|
34
|
+
export interface SettingTarget {
|
|
35
|
+
readonly nodes: Node[];
|
|
36
|
+
readonly props: object;
|
|
37
|
+
setPropValue(propName: string, value: any): void;
|
|
38
|
+
getPropValue(propName: string): any;
|
|
39
|
+
setProps(data: object): void;
|
|
40
|
+
mergeProps(data: object): void;
|
|
41
|
+
onPropsChange(fn: () => void): () => void;
|
|
42
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import type { DynamicSetter, FieldConfig, FieldExtraProps, SetterType } from '../component-meta';
|
|
2
|
+
import type { SettingTopEntry } from './setting-top-entry';
|
|
3
|
+
import { SettingPropEntry } from './setting-prop-entry';
|
|
4
|
+
export interface SetValueOptions {
|
|
5
|
+
disableMutator?: boolean;
|
|
6
|
+
type?: PropValueChangedType;
|
|
7
|
+
fromSetHotValue?: boolean;
|
|
8
|
+
}
|
|
9
|
+
export declare enum PropValueChangedType {
|
|
10
|
+
/**
|
|
11
|
+
* normal set value
|
|
12
|
+
*/
|
|
13
|
+
SET_VALUE = "SET_VALUE",
|
|
14
|
+
/**
|
|
15
|
+
* value changed caused by sub-prop value change
|
|
16
|
+
*/
|
|
17
|
+
SUB_VALUE_CHANGE = "SUB_VALUE_CHANGE"
|
|
18
|
+
}
|
|
19
|
+
export declare class SettingField extends SettingPropEntry {
|
|
20
|
+
private settingFieldCollector?;
|
|
21
|
+
readonly isSettingField = true;
|
|
22
|
+
readonly isRequired: boolean;
|
|
23
|
+
private _config;
|
|
24
|
+
private hotValue;
|
|
25
|
+
parent: SettingTopEntry | SettingField;
|
|
26
|
+
extraProps: FieldExtraProps;
|
|
27
|
+
private _title?;
|
|
28
|
+
get title(): import("../..").PropKey | undefined;
|
|
29
|
+
private _setter?;
|
|
30
|
+
private accessor _expanded;
|
|
31
|
+
private _items;
|
|
32
|
+
constructor(parent: SettingTopEntry | SettingField, config: FieldConfig, settingFieldCollector?: ((name: string, field: SettingField) => void) | undefined);
|
|
33
|
+
get setter(): SetterType | null;
|
|
34
|
+
get expanded(): boolean;
|
|
35
|
+
setExpanded(value: boolean): void;
|
|
36
|
+
get items(): SettingField[];
|
|
37
|
+
get config(): FieldConfig;
|
|
38
|
+
private initItems;
|
|
39
|
+
private disposeItems;
|
|
40
|
+
createField(config: FieldConfig): SettingField;
|
|
41
|
+
purge(): void;
|
|
42
|
+
getConfig<K extends keyof FieldConfig>(configName?: K): FieldConfig[K] | FieldConfig;
|
|
43
|
+
getItems(filter?: (item: SettingField) => boolean): SettingField[];
|
|
44
|
+
setValue(val: any, isHotValue?: boolean, extraOptions?: SetValueOptions): void;
|
|
45
|
+
getHotValue(): any;
|
|
46
|
+
setHotValue(data: any, options?: SetValueOptions): void;
|
|
47
|
+
}
|
|
48
|
+
export declare const isSettingField: (obj: any) => obj is SettingField;
|
|
49
|
+
export declare const isDynamicSetter: (obj: any) => obj is DynamicSetter;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { SettingTopEntry } from './setting-top-entry';
|
|
2
|
+
import { type Editor } from '../..';
|
|
3
|
+
export declare class SettingsManager {
|
|
4
|
+
readonly editor: Editor;
|
|
5
|
+
private _sessionId;
|
|
6
|
+
private accessor _settings;
|
|
7
|
+
get length(): number | undefined;
|
|
8
|
+
get componentMeta(): import("..").ComponentMeta | null | undefined;
|
|
9
|
+
get settings(): SettingTopEntry | undefined;
|
|
10
|
+
private disposeListener;
|
|
11
|
+
private designer?;
|
|
12
|
+
constructor(editor: Editor);
|
|
13
|
+
private init;
|
|
14
|
+
private setup;
|
|
15
|
+
purge(): void;
|
|
16
|
+
}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import type { ComponentMeta, Designer, FieldExtraProps, Node, PropKey } from '../..';
|
|
2
|
+
import type { Editor } from '../../editor';
|
|
3
|
+
import type { SetterManager } from '../../setter-manager';
|
|
4
|
+
import type { SettingEntry } from './setting-entry';
|
|
5
|
+
import type { SetValueOptions, SettingField } from './setting-field';
|
|
6
|
+
import type { SettingTopEntry } from './setting-top-entry';
|
|
7
|
+
export declare class SettingPropEntry implements SettingEntry {
|
|
8
|
+
readonly parent: SettingTopEntry | SettingField;
|
|
9
|
+
readonly editor: Editor;
|
|
10
|
+
readonly isSameComponent: boolean;
|
|
11
|
+
readonly isMultiple: boolean;
|
|
12
|
+
readonly isSingle: boolean;
|
|
13
|
+
readonly setters: SetterManager;
|
|
14
|
+
readonly nodes: Node[];
|
|
15
|
+
readonly componentMeta: ComponentMeta | null;
|
|
16
|
+
readonly designer: Designer | undefined;
|
|
17
|
+
readonly top: SettingTopEntry;
|
|
18
|
+
readonly isGroup: boolean;
|
|
19
|
+
readonly type: 'field' | 'group';
|
|
20
|
+
readonly id: string;
|
|
21
|
+
readonly emitter: import("../..").EventBus;
|
|
22
|
+
private accessor _name;
|
|
23
|
+
get name(): PropKey | undefined;
|
|
24
|
+
get path(): PropKey[];
|
|
25
|
+
extraProps: FieldExtraProps;
|
|
26
|
+
constructor(parent: SettingTopEntry | SettingField, name: PropKey | undefined, type?: 'field' | 'group');
|
|
27
|
+
getId(): string;
|
|
28
|
+
setKey(key: PropKey): void;
|
|
29
|
+
getKey(): PropKey | undefined;
|
|
30
|
+
remove(): void;
|
|
31
|
+
/**
|
|
32
|
+
* 判断当前属性值是否一致
|
|
33
|
+
* -1 多种值
|
|
34
|
+
* 0 无值
|
|
35
|
+
* 1 类似值,比如数组长度一样
|
|
36
|
+
* 2 单一植
|
|
37
|
+
*/
|
|
38
|
+
get valueState(): number;
|
|
39
|
+
/**
|
|
40
|
+
* 获取当前属性值
|
|
41
|
+
*/
|
|
42
|
+
getValue(): any;
|
|
43
|
+
/**
|
|
44
|
+
* 设置当前属性值
|
|
45
|
+
*/
|
|
46
|
+
setValue(val: any, isHotValue?: boolean, extraOptions?: SetValueOptions): void;
|
|
47
|
+
/**
|
|
48
|
+
* 清除已设置的值
|
|
49
|
+
*/
|
|
50
|
+
clearValue(): void;
|
|
51
|
+
/**
|
|
52
|
+
* 获取子项
|
|
53
|
+
*/
|
|
54
|
+
get(propName: PropKey): SettingField | null;
|
|
55
|
+
/**
|
|
56
|
+
* 设置子级属性值
|
|
57
|
+
*/
|
|
58
|
+
setPropValue(propName: PropKey, value: any): void;
|
|
59
|
+
/**
|
|
60
|
+
* 清除已设置值
|
|
61
|
+
*/
|
|
62
|
+
clearPropValue(propName: PropKey): void;
|
|
63
|
+
/**
|
|
64
|
+
* 获取子级属性值
|
|
65
|
+
*/
|
|
66
|
+
getPropValue(propName: PropKey): any;
|
|
67
|
+
/**
|
|
68
|
+
* 获取顶层附属属性值
|
|
69
|
+
*/
|
|
70
|
+
getExtraPropValue(propName: string): unknown;
|
|
71
|
+
/**
|
|
72
|
+
* 设置顶层附属属性值
|
|
73
|
+
*/
|
|
74
|
+
setExtraPropValue(propName: string, value: any): void;
|
|
75
|
+
getNode(): Node<import("../..").NodeSchema>;
|
|
76
|
+
getName(): string;
|
|
77
|
+
getProps(): SettingTopEntry;
|
|
78
|
+
get props(): SettingTopEntry;
|
|
79
|
+
onValueChange(func: () => any): () => void;
|
|
80
|
+
notifyValueChange(oldValue: any, newValue: any): void;
|
|
81
|
+
getDefaultValue(): any;
|
|
82
|
+
isIgnore(): boolean;
|
|
83
|
+
getVariableValue(): string;
|
|
84
|
+
setVariableValue(value: string): void;
|
|
85
|
+
setUseVariable(flag: boolean): void;
|
|
86
|
+
isUseVariable(): boolean;
|
|
87
|
+
get useVariable(): boolean;
|
|
88
|
+
getMockOrValue(): any;
|
|
89
|
+
}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import type { ComponentMeta, Designer, Editor, Node, PropKey, SetterManager } from '../..';
|
|
2
|
+
import type { SettingEntry } from './setting-entry';
|
|
3
|
+
import { SettingField } from './setting-field';
|
|
4
|
+
export declare const generateSessionId: (nodes: Node[]) => string;
|
|
5
|
+
export declare class SettingTopEntry implements SettingEntry {
|
|
6
|
+
readonly editor: Editor;
|
|
7
|
+
readonly nodes: Node[];
|
|
8
|
+
private emitter;
|
|
9
|
+
private _items;
|
|
10
|
+
private _componentMeta;
|
|
11
|
+
private _isSame;
|
|
12
|
+
private _settingFieldMap;
|
|
13
|
+
readonly path: never[];
|
|
14
|
+
readonly top: this;
|
|
15
|
+
readonly parent: this;
|
|
16
|
+
get componentMeta(): ComponentMeta | null;
|
|
17
|
+
get items(): SettingField[];
|
|
18
|
+
/**
|
|
19
|
+
* 同样的
|
|
20
|
+
*/
|
|
21
|
+
get isSameComponent(): boolean;
|
|
22
|
+
/**
|
|
23
|
+
* 一个
|
|
24
|
+
*/
|
|
25
|
+
get isSingle(): boolean;
|
|
26
|
+
get isLocked(): boolean;
|
|
27
|
+
/**
|
|
28
|
+
* 多个
|
|
29
|
+
*/
|
|
30
|
+
get isMultiple(): boolean;
|
|
31
|
+
readonly id: string;
|
|
32
|
+
readonly first: Node;
|
|
33
|
+
readonly designer: Designer | undefined;
|
|
34
|
+
readonly setters: SetterManager;
|
|
35
|
+
disposeFunctions: any[];
|
|
36
|
+
constructor(editor: Editor, nodes: Node[]);
|
|
37
|
+
private setupComponentMeta;
|
|
38
|
+
private setupItems;
|
|
39
|
+
private setupEvents;
|
|
40
|
+
/**
|
|
41
|
+
* 获取当前属性值
|
|
42
|
+
*/
|
|
43
|
+
getValue(): import("../..").PropsMap | null;
|
|
44
|
+
/**
|
|
45
|
+
* 设置当前属性值
|
|
46
|
+
*/
|
|
47
|
+
setValue(val: any): void;
|
|
48
|
+
/**
|
|
49
|
+
* 获取子项
|
|
50
|
+
*/
|
|
51
|
+
get(propName: PropKey): SettingField | null;
|
|
52
|
+
/**
|
|
53
|
+
* 设置子级属性值
|
|
54
|
+
*/
|
|
55
|
+
setPropValue(propName: PropKey, value: any): void;
|
|
56
|
+
/**
|
|
57
|
+
* 清除已设置值
|
|
58
|
+
*/
|
|
59
|
+
clearPropValue(propName: PropKey): void;
|
|
60
|
+
/**
|
|
61
|
+
* 获取子级属性值
|
|
62
|
+
*/
|
|
63
|
+
getPropValue(propName: PropKey): any;
|
|
64
|
+
/**
|
|
65
|
+
* 获取顶层附属属性值
|
|
66
|
+
*/
|
|
67
|
+
getExtraPropValue(propName: string): unknown;
|
|
68
|
+
/**
|
|
69
|
+
* 设置顶层附属属性值
|
|
70
|
+
*/
|
|
71
|
+
setExtraPropValue(propName: string, value: any): void;
|
|
72
|
+
setProps(data: object): void;
|
|
73
|
+
mergeProps(data: object): void;
|
|
74
|
+
private disposeItems;
|
|
75
|
+
purge(): void;
|
|
76
|
+
getProp(propName: PropKey): SettingField | null;
|
|
77
|
+
getNode(): Node<import("../..").NodeSchema>;
|
|
78
|
+
}
|
|
79
|
+
interface Purgeable {
|
|
80
|
+
purge(): void;
|
|
81
|
+
}
|
|
82
|
+
export declare const isPurgeable: (obj: any) => obj is Purgeable;
|
|
83
|
+
export {};
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import type { ComponentsMap, Designer, DropLocation } from '../designer';
|
|
2
|
+
import type { Project } from '../project';
|
|
3
|
+
import type { Simulator } from '../simulator';
|
|
4
|
+
import type { NodeSchema, RootSchema } from '../types';
|
|
5
|
+
import { TRANSFORM_STAGE } from '../types';
|
|
6
|
+
import { History } from './history';
|
|
7
|
+
import { Node } from './node/node';
|
|
8
|
+
export declare enum DOCUMENT_EVENT {
|
|
9
|
+
ADD = "document:add",
|
|
10
|
+
REMOVE = "document:remove",
|
|
11
|
+
OPEN_CHANGE = "document:open.change",
|
|
12
|
+
OPEN = "document:open"
|
|
13
|
+
}
|
|
14
|
+
export declare class Document {
|
|
15
|
+
readonly isDocument = true;
|
|
16
|
+
private emitter;
|
|
17
|
+
id: string;
|
|
18
|
+
/** document is open or not */
|
|
19
|
+
accessor _opened: boolean;
|
|
20
|
+
/** document is blank or not */
|
|
21
|
+
private _blank;
|
|
22
|
+
/** document root node */
|
|
23
|
+
rootNode: Node | null;
|
|
24
|
+
get root(): Node<NodeSchema> | null;
|
|
25
|
+
getRoot(): Node<NodeSchema> | null;
|
|
26
|
+
private _nodesMap;
|
|
27
|
+
get nodesMap(): Map<string, Node<NodeSchema>>;
|
|
28
|
+
get simulator(): Simulator | null;
|
|
29
|
+
/** 对应 document 的 path */
|
|
30
|
+
get fileName(): string;
|
|
31
|
+
set fileName(fileName: string);
|
|
32
|
+
private accessor nodes;
|
|
33
|
+
get opened(): boolean;
|
|
34
|
+
isBlank(): boolean;
|
|
35
|
+
readonly history: History;
|
|
36
|
+
getHistory(): History<RootSchema>;
|
|
37
|
+
readonly project: Project;
|
|
38
|
+
readonly designer: Designer;
|
|
39
|
+
private accessor _dropLocation;
|
|
40
|
+
set dropLocation(loc: DropLocation | null);
|
|
41
|
+
get dropLocation(): DropLocation | null;
|
|
42
|
+
get schema(): RootSchema;
|
|
43
|
+
constructor(project: Project, schema?: RootSchema);
|
|
44
|
+
import(schema?: RootSchema, checkId?: boolean): void;
|
|
45
|
+
export(stage?: TRANSFORM_STAGE): RootSchema;
|
|
46
|
+
remove(): void;
|
|
47
|
+
purge(): void;
|
|
48
|
+
createNode(schema: NodeSchema, checkId?: boolean): Node<NodeSchema>;
|
|
49
|
+
getNode(id: string): Node<NodeSchema> | null;
|
|
50
|
+
getNodeCount(): number;
|
|
51
|
+
hasNode(id: string): boolean;
|
|
52
|
+
removeNode(idOrNode: string | Node): void;
|
|
53
|
+
private internalRemoveNode;
|
|
54
|
+
unlinkNode(node: Node): void;
|
|
55
|
+
migrateNode(node: Node, newParent: Node): void;
|
|
56
|
+
batchRemoveNode(idOrNodeList: (string | Node)[]): void;
|
|
57
|
+
insertNode(parent: Node, thing: Node | NodeSchema, at?: number, copy?: boolean): Node<NodeSchema> | null;
|
|
58
|
+
/**
|
|
59
|
+
* insert multiple nodes
|
|
60
|
+
*/
|
|
61
|
+
insertNodes(parent: Node, nodes: Node[] | NodeSchema[], at?: number, copy?: boolean): Node<NodeSchema>[];
|
|
62
|
+
open(): this;
|
|
63
|
+
close(): void;
|
|
64
|
+
/**
|
|
65
|
+
* use open a document and suspense other documents
|
|
66
|
+
*/
|
|
67
|
+
private setOpened;
|
|
68
|
+
suspense(): void;
|
|
69
|
+
activate(): void;
|
|
70
|
+
/**
|
|
71
|
+
* check if there is unsaved change for document
|
|
72
|
+
*/
|
|
73
|
+
isModified(): boolean;
|
|
74
|
+
/**
|
|
75
|
+
* get components map of all the nodes in this document
|
|
76
|
+
* @param extraComps - extra components that will be added to the components map, use for custom components
|
|
77
|
+
*/
|
|
78
|
+
getComponentsMap(extraComps?: string[]): ComponentsMap;
|
|
79
|
+
getComponent(componentName: string): any;
|
|
80
|
+
getComponentMeta(componentName: string): import("..").ComponentMeta;
|
|
81
|
+
toData(extraComps?: string[]): {
|
|
82
|
+
componentsMap: ComponentsMap;
|
|
83
|
+
componentsTree: RootSchema[];
|
|
84
|
+
};
|
|
85
|
+
onReady(listener: () => void): () => void;
|
|
86
|
+
onNodeAdd(listener: (node: Node) => void): () => void;
|
|
87
|
+
onNodeRemove(listener: (id: string) => void): () => void;
|
|
88
|
+
}
|
|
89
|
+
export declare function isDocument(obj: any): obj is Document;
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import type { RootSchema } from '../types';
|
|
2
|
+
import type { Document } from './document';
|
|
3
|
+
export interface Serialization<K = RootSchema, T = string> {
|
|
4
|
+
serialize(data: K): T;
|
|
5
|
+
unserialize(data: T): K;
|
|
6
|
+
}
|
|
7
|
+
export declare enum HISTORY_EVENT {
|
|
8
|
+
STATE_CHANGE = "history:state.change",
|
|
9
|
+
CURSOR_CHANGE = "history:cursor.change"
|
|
10
|
+
}
|
|
11
|
+
export declare class History<T = RootSchema> {
|
|
12
|
+
private redoer;
|
|
13
|
+
readonly document?: Document | undefined;
|
|
14
|
+
emitter: import("..").EventBus;
|
|
15
|
+
/** current record */
|
|
16
|
+
private session;
|
|
17
|
+
/** all records */
|
|
18
|
+
private records;
|
|
19
|
+
/** as a cursor of records to go back and forward */
|
|
20
|
+
private point;
|
|
21
|
+
private asleep;
|
|
22
|
+
/** current recorded data */
|
|
23
|
+
get hotData(): string;
|
|
24
|
+
private timeGap;
|
|
25
|
+
private serialization;
|
|
26
|
+
setSerialization(serialization: Serialization<T, string>): void;
|
|
27
|
+
constructor(dataFn: () => T | null, redoer: (data: T) => void, document?: Document | undefined);
|
|
28
|
+
/**
|
|
29
|
+
* check if there is unsaved change for history
|
|
30
|
+
*/
|
|
31
|
+
isSavePoint(): boolean;
|
|
32
|
+
private sleep;
|
|
33
|
+
private wakeup;
|
|
34
|
+
go(originalCursor: number): void;
|
|
35
|
+
back(): void;
|
|
36
|
+
forward(): void;
|
|
37
|
+
savePoint(): void;
|
|
38
|
+
destroy(): void;
|
|
39
|
+
/**
|
|
40
|
+
* | 1 | 1 | 1 |
|
|
41
|
+
* | -------- | -------- | -------- |
|
|
42
|
+
* | modified | redoable | undoable |
|
|
43
|
+
* eg.
|
|
44
|
+
* 7 means : modified && redoable && undoable
|
|
45
|
+
* 5 means : modified && undoable
|
|
46
|
+
* ...
|
|
47
|
+
*/
|
|
48
|
+
getState(): number;
|
|
49
|
+
isModified(): boolean;
|
|
50
|
+
isRedoable(): boolean;
|
|
51
|
+
isUndoable(): boolean;
|
|
52
|
+
onStateChange(listener: () => void): () => void;
|
|
53
|
+
onCursorChange(func: () => void): () => void;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Session is a record of History
|
|
57
|
+
*/
|
|
58
|
+
export declare class Session<T = string> {
|
|
59
|
+
readonly cursor: number;
|
|
60
|
+
private timeGap;
|
|
61
|
+
private _data;
|
|
62
|
+
private activeTimer;
|
|
63
|
+
get data(): T;
|
|
64
|
+
constructor(cursor: number, data: T, timeGap?: number);
|
|
65
|
+
/**
|
|
66
|
+
* log data
|
|
67
|
+
* log may be executed multiple times, and it has a timeGap period, during this period,
|
|
68
|
+
* the changes will only be recorded in this Session, until the timeGap period will be reset
|
|
69
|
+
* you can see it in the reaction function of History
|
|
70
|
+
*/
|
|
71
|
+
log(data: T): void;
|
|
72
|
+
isActive(): boolean;
|
|
73
|
+
end(): void;
|
|
74
|
+
private setTimer;
|
|
75
|
+
private clearTimer;
|
|
76
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import type { NodeSchema } from '../../types';
|
|
2
|
+
import type { Node } from './node';
|
|
3
|
+
import { TRANSFORM_STAGE } from '../../types';
|
|
4
|
+
export declare enum NODE_CHILDREN_EVENT {
|
|
5
|
+
CHANGE = "nodeChildren:change",
|
|
6
|
+
INSERT = "nodeChildren:insert"
|
|
7
|
+
}
|
|
8
|
+
export declare class NodeChildren {
|
|
9
|
+
private emitter;
|
|
10
|
+
readonly owner: Node;
|
|
11
|
+
getNode(): Node<NodeSchema>;
|
|
12
|
+
accessor children: Node[];
|
|
13
|
+
get size(): number;
|
|
14
|
+
get isEmptyNode(): boolean;
|
|
15
|
+
isEmpty(): boolean;
|
|
16
|
+
constructor(owner: Node, data?: NodeSchema[]);
|
|
17
|
+
export(stage?: TRANSFORM_STAGE): NodeSchema[];
|
|
18
|
+
import(data?: NodeSchema | NodeSchema[], checkId?: boolean): void;
|
|
19
|
+
remove(purge?: boolean, useMutator?: boolean): void;
|
|
20
|
+
private purged;
|
|
21
|
+
purge(): void;
|
|
22
|
+
internalInitParent(): void;
|
|
23
|
+
internalUnlinkChild(node: Node): boolean;
|
|
24
|
+
unlinkChild(node: Node): void;
|
|
25
|
+
delete(node: Node): boolean;
|
|
26
|
+
internalDelete(node: Node, purge?: boolean, useMutator?: boolean): boolean;
|
|
27
|
+
get(index: number): Node<NodeSchema> | null;
|
|
28
|
+
has(node: Node): boolean;
|
|
29
|
+
insert(node: Node, at?: number | null): void;
|
|
30
|
+
/**
|
|
31
|
+
* insert a node into the children
|
|
32
|
+
* @param node
|
|
33
|
+
* @param at if at is null or -1, insert the node to the end of the children
|
|
34
|
+
*/
|
|
35
|
+
internalInsert(node: Node, at?: number | null, useMutator?: boolean): void;
|
|
36
|
+
mergeChildren(remover: (node: Node, idx: number) => boolean, adder: (children: Node[]) => NodeSchema[] | null, sorter: (firstNode: Node, secondNode: Node) => number): any;
|
|
37
|
+
indexOf(node: Node): number;
|
|
38
|
+
find(f: (value: Node, index: number, obj: Node[]) => unknown): Node<NodeSchema> | undefined;
|
|
39
|
+
forEach(fn: (node: Node, index: number) => void): void;
|
|
40
|
+
reverse(): Node[];
|
|
41
|
+
map(fn: (node: Node, index: number) => Node): Node[];
|
|
42
|
+
every(fn: (node: Node, index: number) => boolean): boolean;
|
|
43
|
+
some(fn: (node: Node, index: number) => boolean): boolean;
|
|
44
|
+
filter(fn: (node: Node, index: number) => boolean): Node[];
|
|
45
|
+
reduce(fn: (acc: any, cur: Node) => any, initialValue: any): any;
|
|
46
|
+
onChange(listener: (info?: {
|
|
47
|
+
type: string;
|
|
48
|
+
node: Node;
|
|
49
|
+
}) => void): () => void;
|
|
50
|
+
onInsert(listener: (node: Node) => void): () => void;
|
|
51
|
+
}
|