@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.
Files changed (71) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/LICENSE +9 -0
  3. package/README.md +3 -0
  4. package/dist/cjs/index.development.js +11252 -0
  5. package/dist/cjs/index.development.js.map +1 -0
  6. package/dist/cjs/index.js +11252 -0
  7. package/dist/cjs/index.js.map +1 -0
  8. package/dist/cjs/index.production.js +11252 -0
  9. package/dist/cjs/index.production.js.map +1 -0
  10. package/dist/designer/clipboard.d.ts +12 -0
  11. package/dist/designer/component-meta/component-meta-manager.d.ts +21 -0
  12. package/dist/designer/component-meta/component-meta.d.ts +30 -0
  13. package/dist/designer/component-meta/index.d.ts +3 -0
  14. package/dist/designer/component-meta/meta.d.ts +264 -0
  15. package/dist/designer/designer.d.ts +86 -0
  16. package/dist/designer/detecting.d.ts +23 -0
  17. package/dist/designer/dragon.d.ts +103 -0
  18. package/dist/designer/index.d.ts +10 -0
  19. package/dist/designer/location.d.ts +94 -0
  20. package/dist/designer/offset-observer.d.ts +41 -0
  21. package/dist/designer/selection.d.ts +27 -0
  22. package/dist/designer/sensor.d.ts +30 -0
  23. package/dist/designer/setting/index.d.ts +5 -0
  24. package/dist/designer/setting/setting-entry.d.ts +42 -0
  25. package/dist/designer/setting/setting-field.d.ts +49 -0
  26. package/dist/designer/setting/setting-manager.d.ts +16 -0
  27. package/dist/designer/setting/setting-prop-entry.d.ts +89 -0
  28. package/dist/designer/setting/setting-top-entry.d.ts +83 -0
  29. package/dist/document/document.d.ts +89 -0
  30. package/dist/document/history.d.ts +76 -0
  31. package/dist/document/index.d.ts +6 -0
  32. package/dist/document/node/node-children.d.ts +51 -0
  33. package/dist/document/node/node.d.ts +233 -0
  34. package/dist/document/prop/prop.d.ts +185 -0
  35. package/dist/document/prop/props.d.ts +57 -0
  36. package/dist/document/prop/value-to-source.d.ts +8 -0
  37. package/dist/editor.d.ts +94 -0
  38. package/dist/esm/index.development.js +11145 -0
  39. package/dist/esm/index.development.js.map +1 -0
  40. package/dist/esm/index.js +11145 -0
  41. package/dist/esm/index.js.map +1 -0
  42. package/dist/esm/index.production.js +11145 -0
  43. package/dist/esm/index.production.js.map +1 -0
  44. package/dist/index.d.ts +10 -0
  45. package/dist/index.js +11144 -0
  46. package/dist/plugin/index.d.ts +3 -0
  47. package/dist/plugin/plugin-context.d.ts +20 -0
  48. package/dist/plugin/plugin-extend.d.ts +32 -0
  49. package/dist/plugin/plugin-manager.d.ts +78 -0
  50. package/dist/plugin/plugin-runtime.d.ts +28 -0
  51. package/dist/plugin/sequencify.d.ts +19 -0
  52. package/dist/project/index.d.ts +1 -0
  53. package/dist/project/project.d.ts +68 -0
  54. package/dist/setter-manager/index.d.ts +1 -0
  55. package/dist/setter-manager/setter-manager.d.ts +29 -0
  56. package/dist/simulator/index.d.ts +3 -0
  57. package/dist/simulator/simulator-renderer.d.ts +41 -0
  58. package/dist/simulator/simulator.d.ts +106 -0
  59. package/dist/simulator/viewport.d.ts +29 -0
  60. package/dist/types/common.d.ts +11 -0
  61. package/dist/types/event.d.ts +12 -0
  62. package/dist/types/index.d.ts +3 -0
  63. package/dist/types/schema.d.ts +64 -0
  64. package/dist/utils/common.d.ts +1 -0
  65. package/dist/utils/event-bus.d.ts +45 -0
  66. package/dist/utils/hotkey.d.ts +87 -0
  67. package/dist/utils/index.d.ts +6 -0
  68. package/dist/utils/is.d.ts +2 -0
  69. package/dist/utils/logger.d.ts +18 -0
  70. package/dist/utils/unique-id.d.ts +5 -0
  71. package/package.json +67 -0
@@ -0,0 +1,233 @@
1
+ import type { NodeSchema } from '../../types';
2
+ import type { Document } from '../document';
3
+ import type { PropValue, PropsMap } from '../prop/prop';
4
+ import { type SettingTopEntry } from '../..';
5
+ import { TRANSFORM_STAGE } from '../../types';
6
+ import { Props } from '../prop/props';
7
+ import { NodeChildren } from './node-children';
8
+ export declare enum NODE_EVENT {
9
+ ADD = "node:add",
10
+ REMOVE = "node:remove",
11
+ VISIBLE_CHANGE = "node:visible.change",
12
+ LOCK_CHANGE = "node:lock.change",
13
+ PROP_CHANGE = "node:prop.change"
14
+ }
15
+ export declare class Node<Schema extends NodeSchema = NodeSchema> {
16
+ readonly document: Document;
17
+ protected emitter: import("../..").EventBus;
18
+ readonly isNode = true;
19
+ readonly id: string;
20
+ readonly componentName: string;
21
+ protected _children: NodeChildren | null;
22
+ private accessor _parent;
23
+ get parent(): Node<NodeSchema> | null;
24
+ get children(): NodeChildren | null;
25
+ get childrenNodes(): Node<NodeSchema>[];
26
+ /**
27
+ * if the node is the root node or not linked, return -1
28
+ */
29
+ get index(): number;
30
+ /**
31
+ * z-index level of this node
32
+ */
33
+ get zLevel(): number;
34
+ get title(): string;
35
+ get icon(): string | undefined;
36
+ private purged;
37
+ /**
38
+ * 是否已销毁
39
+ */
40
+ get isPurged(): boolean;
41
+ props: Props;
42
+ _settingEntry: SettingTopEntry;
43
+ get settingEntry(): SettingTopEntry;
44
+ constructor(document: Document, Schema: Schema);
45
+ import(data: Schema, checkId?: boolean): void;
46
+ export<T = NodeSchema>(stage?: TRANSFORM_STAGE): T;
47
+ purge(): void;
48
+ toData(): NodeSchema;
49
+ /**
50
+ * get node schema
51
+ */
52
+ get schema(): Schema;
53
+ set schema(data: Schema);
54
+ initBuiltinProps(): void;
55
+ private initProps;
56
+ private upgradeProps;
57
+ /**
58
+ * relate to componentMeta.advanced.initialChildren
59
+ */
60
+ private initialChildren;
61
+ /**
62
+ * link to componentMeta.advanced.callbacks.onNodeAdd
63
+ */
64
+ didDropIn(dragNode: Node): void;
65
+ /**
66
+ * link to componentMeta.advanced.callbacks.onNodeRemove
67
+ */
68
+ didDropOut(dragNode: Node): void;
69
+ /**
70
+ * link to componentMeta.advanced.callbacks.onSelectHook
71
+ */
72
+ canSelect(): boolean;
73
+ /**
74
+ * link to componentMeta.advanced.callbacks.onClickHook
75
+ */
76
+ canClick(e: MouseEvent): any;
77
+ select(): void;
78
+ hover(flag?: boolean): void;
79
+ getChildren(): NodeChildren | null;
80
+ getComponentName(): string;
81
+ getParent(): Node<NodeSchema> | null;
82
+ getId(): string;
83
+ getIndex(): number;
84
+ getNode(): this;
85
+ getRoot(): Node<NodeSchema> | null;
86
+ getProps(): Props;
87
+ get isContainer(): boolean;
88
+ get isRoot(): boolean;
89
+ /**
90
+ * whether child nodes are included
91
+ */
92
+ get isParental(): boolean;
93
+ /**
94
+ * whether this node is a leaf node
95
+ */
96
+ get isLeaf(): boolean;
97
+ toString(): string;
98
+ hide(flag?: boolean): void;
99
+ get hidden(): boolean;
100
+ get isHidden(): boolean;
101
+ lock(flag?: boolean): void;
102
+ get locked(): boolean;
103
+ get isLocked(): boolean;
104
+ hasCondition(): boolean;
105
+ /**
106
+ * has loop when 1. loop is validArray with length > 1 ; OR 2. loop is variable object
107
+ * @return boolean, has loop config or not
108
+ */
109
+ hasLoop(): boolean;
110
+ getProp(path: string, createIfNone?: boolean): import("..").Prop | null;
111
+ getExtraProp(key: string, createIfNone?: boolean): import("..").Prop | null;
112
+ setExtraProp(key: string, value: PropValue): void;
113
+ getPropValue(path: string): unknown;
114
+ setPropValue(path: string, value: PropValue): void;
115
+ getExtraPropValue(key: string): unknown;
116
+ setExtraPropValue(key: string, value: PropValue): void;
117
+ clearPropValue(path: string): void;
118
+ mergeProps(props: PropsMap): void;
119
+ setProps(props?: PropsMap | Props | null): void;
120
+ internalSetParent(parent: Node | null, useMutator?: boolean): void;
121
+ internalUnlinkParent(): void;
122
+ /**
123
+ * unlink this node from its parent and document
124
+ */
125
+ unlink(): void;
126
+ /**
127
+ * migrate this node to a new parent
128
+ */
129
+ migrate(newParent: Node): void;
130
+ /**
131
+ * if the node is linked in the document tree
132
+ */
133
+ get isLinked(): boolean;
134
+ /**
135
+ * insert a node at a specific position or a reference node
136
+ */
137
+ insert(node: Node, ref?: Node | number, useMutator?: boolean): void;
138
+ /**
139
+ * insert a node before a reference node(in current node's children)
140
+ */
141
+ insertBefore(node: Node, ref?: Node, useMutator?: boolean): void;
142
+ /**
143
+ * insert a node after a reference node(in current node's children)
144
+ */
145
+ insertAfter(node: Node, ref?: Node, useMutator?: boolean): void;
146
+ remove(purge?: boolean, useMutator?: boolean): void;
147
+ removeChild(node: Node): void;
148
+ isValidComponent(): boolean;
149
+ get componentMeta(): import("../..").ComponentMeta;
150
+ get propsData(): PropsMap | null;
151
+ getRect(): DOMRect | null;
152
+ getDOMNode(): any;
153
+ /**
154
+ * use schema to update this node
155
+ */
156
+ wrapWith(schema: Schema): Node<NodeSchema> | null | undefined;
157
+ /**
158
+ * replace this node with a new node
159
+ */
160
+ replaceWith(schema: Schema, migrate?: boolean): Node<NodeSchema> | null | undefined;
161
+ /**
162
+ * replace a child node with a new node
163
+ */
164
+ replaceChild(node: Node, data: Schema): Node | null;
165
+ /**
166
+ * check if this node contains another node
167
+ */
168
+ contains(node: Node): boolean;
169
+ /**
170
+ * get the parent node at a specific depth
171
+ */
172
+ getZLevelTop(zLevel: number): Node<NodeSchema> | null;
173
+ /**
174
+ * compare the position of this node and another node
175
+ *
176
+ * - 16 thisNode contains otherNode
177
+ * - 8 thisNode contained_by otherNode
178
+ * - 2 thisNode before or after otherNode
179
+ * - 0 thisNode same as otherNode
180
+ */
181
+ comparePosition(otherNode: Node): PositionNO;
182
+ /**
183
+ * get next sibling node
184
+ */
185
+ get nextSibling(): Node | null | undefined;
186
+ /**
187
+ * get previous sibling node
188
+ */
189
+ get prevSibling(): Node | null | undefined;
190
+ mergeChildren(remover: (node: Node, idx: number) => any, adder: (children: Node[]) => Schema[] | null, sorter: (firstNode: Node, secondNode: Node) => any): void;
191
+ onVisibleChange(listener: (flag: boolean) => void): () => void;
192
+ onLockChange(listener: (flag: boolean) => void): () => void;
193
+ onChildrenChange(listener: (info?: {
194
+ type: string;
195
+ node: Node;
196
+ }) => void): (() => void) | undefined;
197
+ emitPropChange(prop: any): void;
198
+ onPropChange(listener: (info: any) => void): () => void;
199
+ }
200
+ export declare const isNode: (node: any) => node is Node;
201
+ export declare const isNodeSchema: (data: any) => data is NodeSchema;
202
+ /**
203
+ * get the top node of the same zLevel
204
+ */
205
+ export declare const getZLevelTop: (child: Node, zLevel: number) => Node | null;
206
+ /**
207
+ * check if node1 contains node2
208
+ */
209
+ export declare const contains: (node1: Node, node2: Node) => boolean;
210
+ export declare enum PositionNO {
211
+ Contains = 16,
212
+ ContainedBy = 8,
213
+ BeforeOrAfter = 2,
214
+ TheSame = 0
215
+ }
216
+ /**
217
+ * compare the position of two nodes
218
+ */
219
+ export declare const comparePosition: (node1: Node, node2: Node) => PositionNO;
220
+ export declare const insertChild: (container: Node, thing: Node | NodeSchema, at?: number | null, copy?: boolean) => Node | null;
221
+ export declare const insertChildren: (container: Node, nodes: Node[] | NodeSchema[], at?: number | null, copy?: boolean) => Node[];
222
+ /**
223
+ * get the closest node that satisfies the condition
224
+ */
225
+ export declare const getClosestNode: (node: Node | null, until: (n: Node) => boolean) => Node | undefined;
226
+ /**
227
+ * get the closest clickable node
228
+ */
229
+ export declare const getClosestClickableNode: (currentNode: Node | undefined | null, event: MouseEvent) => Node<NodeSchema> | null | undefined;
230
+ /**
231
+ * ensure the node is a Node instance
232
+ */
233
+ export declare const ensureNode: (node: any, document: Document) => Node;
@@ -0,0 +1,185 @@
1
+ import type { NodeSchema } from '../../types';
2
+ import type { Node } from '../node/node';
3
+ import type { Props } from './props';
4
+ import { TRANSFORM_STAGE } from '../../types';
5
+ export declare const UNSET: unique symbol;
6
+ export type UNSET = typeof UNSET;
7
+ export type ValueTypes = 'unset' | 'literal' | 'list' | 'map' | 'expression';
8
+ /**
9
+ * a common interface for Prop and Props
10
+ */
11
+ export interface PropParent {
12
+ readonly props: Props;
13
+ readonly owner: Node;
14
+ get path(): string[];
15
+ delete(prop: Prop): void;
16
+ }
17
+ export type PropKey = string | number;
18
+ export type PropValue = CompositeValue;
19
+ export type PropsMap = CompositeObject<NodeSchema | NodeSchema[]>;
20
+ export type CompositeValue = JSONValue | CompositeArray | CompositeObject | JSExpression | JSFunction;
21
+ export type CompositeArray = CompositeValue[];
22
+ export interface CompositeObject<T = CompositeValue> {
23
+ [key: PropKey]: CompositeValue | T;
24
+ }
25
+ export type JSONValue = boolean | string | number | null | undefined | JSONArray | JSONObject;
26
+ export type JSONArray = JSONValue[];
27
+ export interface JSONObject {
28
+ [key: PropKey]: JSONValue;
29
+ }
30
+ export interface JSExpression {
31
+ type: 'JSExpression';
32
+ /**
33
+ * 表达式字符串
34
+ */
35
+ value: string;
36
+ /**
37
+ * 模拟值
38
+ */
39
+ mock?: any;
40
+ /**
41
+ * 源码
42
+ */
43
+ compiled?: string;
44
+ }
45
+ export interface JSFunction {
46
+ type: 'JSFunction';
47
+ /**
48
+ * 函数定义,或直接函数表达式
49
+ */
50
+ value: string;
51
+ /**
52
+ * 源码
53
+ */
54
+ compiled?: string;
55
+ /**
56
+ * 模拟值
57
+ */
58
+ mock?: any;
59
+ /**
60
+ * 额外扩展属性,如 extType、events
61
+ */
62
+ [key: string]: any;
63
+ }
64
+ export declare const isJSExpression: (data: any) => data is JSExpression;
65
+ export declare function isJSFunction(data: any): data is JSFunction;
66
+ export declare class Prop {
67
+ readonly parent: PropParent;
68
+ readonly isProp = true;
69
+ readonly id: string;
70
+ accessor key: PropKey;
71
+ readonly owner: Node;
72
+ getNode(): Node<NodeSchema>;
73
+ readonly props: Props;
74
+ getProps(): Props;
75
+ private accessor _value;
76
+ get value(): unknown | UNSET;
77
+ private _code;
78
+ /**
79
+ * 获得表达式值
80
+ */
81
+ get code(): string;
82
+ /**
83
+ * 设置表达式值
84
+ */
85
+ set code(code: string);
86
+ private accessor _type;
87
+ get type(): ValueTypes;
88
+ /** use for list or map type */
89
+ private accessor _items;
90
+ /**
91
+ * 作为一层缓存机制,主要是复用部分已存在的 Prop,保持响应式关系,比如:
92
+ * 当前 Prop#_value 值为 { a: 1 },当调用 setValue({ a: 2 }) 时,所有原来的子 Prop 均被销毁,
93
+ * 导致假如外部有 mobx reaction(常见于 observer),此时响应式链路会被打断,
94
+ * 因为 reaction 监听的是原 Prop(a) 的 _value,而不是新 Prop(a) 的 _value。
95
+ */
96
+ private accessor _maps;
97
+ /**
98
+ * Construct the items and maps for the prop value
99
+ */
100
+ private get items();
101
+ private get maps();
102
+ /**
103
+ * return a path of prop
104
+ */
105
+ get path(): string[];
106
+ /**
107
+ * item length
108
+ */
109
+ get size(): number;
110
+ constructor(parent: PropParent, key: PropKey, value?: PropValue | UNSET);
111
+ /**
112
+ * This is to trigger the execution of the items getter function,
113
+ * which will construct the items and maps for the prop value
114
+ */
115
+ initItems(): void;
116
+ export(stage?: TRANSFORM_STAGE): PropValue;
117
+ /**
118
+ * whether the prop has been destroyed
119
+ */
120
+ private accessor purged;
121
+ /**
122
+ * clear internal data
123
+ */
124
+ purge(): void;
125
+ remove(): void;
126
+ /**
127
+ * dispose internal data, use for changing value,
128
+ * this will not trigger reactive
129
+ */
130
+ private dispose;
131
+ unset(): void;
132
+ isUnset(): boolean;
133
+ /**
134
+ * @returns 0: the same 1: maybe & like 2: not the same
135
+ */
136
+ compare(other: Prop | null): number;
137
+ /**
138
+ * set value, val should be JSON Object
139
+ */
140
+ setValue(val: PropValue): void;
141
+ getValue(): unknown;
142
+ getAsString(): string;
143
+ get(path: PropKey, createIfNone?: boolean): Prop | null;
144
+ set(key: PropKey, value: PropValue | Prop, force?: boolean): Prop | null;
145
+ delete(prop: Prop): void;
146
+ add(key: PropKey, value?: PropValue | UNSET, force?: boolean): Prop | null;
147
+ /**
148
+ * check if the prop has the key, only for map and list type
149
+ */
150
+ has(key: PropKey): boolean;
151
+ deleteKey(key: PropKey): void;
152
+ /**
153
+ * @see SettingTarget
154
+ */
155
+ getPropValue(key: PropKey): any;
156
+ /**
157
+ * @see SettingTarget
158
+ */
159
+ setPropValue(key: PropKey, value: any): void;
160
+ /**
161
+ * @see SettingTarget
162
+ */
163
+ clearPropValue(key: PropKey): void;
164
+ forEach(fn: (item: Prop, key: PropKey | number) => void): void;
165
+ map<T>(fn: (item: Prop, key: PropKey | number) => T): T[] | null;
166
+ [Symbol.iterator](): {
167
+ next(): {
168
+ value: Prop;
169
+ };
170
+ };
171
+ }
172
+ export declare const isProp: (obj: any) => obj is Prop;
173
+ /**
174
+ * split path to entry and nest
175
+ * - entry: a or 0
176
+ * - nest: .b or [1].b
177
+ */
178
+ export declare const splitPath: (path: PropKey) => {
179
+ entry: PropKey;
180
+ nest: string;
181
+ };
182
+ /**
183
+ * check if the key is a valid array index
184
+ */
185
+ export declare function isValidArrayIndex(key: any, limit?: number): key is number;
@@ -0,0 +1,57 @@
1
+ import type { Node } from '../node/node';
2
+ import type { PropKey, PropValue, PropsMap } from './prop';
3
+ import { TRANSFORM_STAGE } from '../../types';
4
+ import { Prop, UNSET } from './prop';
5
+ /**
6
+ * prop key convert to extra key
7
+ */
8
+ export declare const getConvertedExtraKey: (key: string) => string;
9
+ /**
10
+ * extra key convert to prop key
11
+ */
12
+ export declare const getOriginalExtraKey: (key: string) => string;
13
+ export declare const isExtraKey: (key: string) => boolean;
14
+ export declare class Props {
15
+ readonly id: string;
16
+ readonly path: never[];
17
+ readonly owner: Node;
18
+ getNode(): Node<import("../..").NodeSchema>;
19
+ get props(): this;
20
+ getProps(): this;
21
+ accessor type: string;
22
+ accessor items: Prop[];
23
+ private get maps();
24
+ get size(): number;
25
+ constructor(owner: Node, props?: PropsMap, extras?: PropsMap);
26
+ import(props?: PropsMap | null, extras?: PropsMap): void;
27
+ export(stage?: TRANSFORM_STAGE): {
28
+ props?: undefined;
29
+ extras?: undefined;
30
+ } | {
31
+ props: PropsMap;
32
+ extras: PropsMap;
33
+ };
34
+ merge(value: PropsMap, extras?: PropsMap): void;
35
+ private purged;
36
+ purge(): void;
37
+ /**
38
+ * get a prop, if not found, create a prop when createIfNone is true
39
+ */
40
+ get(path: PropKey, createIfNone?: boolean): Prop | null;
41
+ query(path: PropKey, createIfNone?: boolean): Prop | null;
42
+ getProp(path: PropKey, createIfNone?: boolean): Prop | null;
43
+ getPropValue(path: PropKey): unknown;
44
+ setPropValue(path: PropKey, value: any): void;
45
+ delete(prop: Prop): void;
46
+ deleteKey(key: PropKey): void;
47
+ add(key: PropKey, value?: PropValue | UNSET): Prop;
48
+ has(key: PropKey): boolean;
49
+ forEach(fn: (item: Prop, key: PropKey) => void): void;
50
+ map<E>(fn: (item: Prop, key: PropKey) => E): E[] | null;
51
+ filter(fn: (item: Prop, key: PropKey) => boolean): Prop[];
52
+ [Symbol.iterator](): {
53
+ next(): {
54
+ value: Prop;
55
+ };
56
+ };
57
+ }
@@ -0,0 +1,8 @@
1
+ /**
2
+ * 将 JavaScript 值转换为字符串格式
3
+ * @param value
4
+ * @param param1
5
+ * @returns
6
+ */
7
+ export declare const valueToSource: (value: any, { circularReferenceToken, doubleQuote, includeFunctions, includeUndefinedProperties, indentLevel, indentString, lineEnding, visitedObjects, }?: any) => any;
8
+ export declare const getSource: (value: any) => string;
@@ -0,0 +1,94 @@
1
+ import type { Component, ComponentMetadata } from './designer';
2
+ import type { Plugin } from './plugin';
3
+ import type { Setter } from './setter-manager';
4
+ import type { ProjectSchema } from './types';
5
+ import { type DesignerProps } from './designer';
6
+ import { PluginManager } from './plugin';
7
+ import { type HotkeyConfig } from './utils';
8
+ export type EditorValueKey = string | symbol;
9
+ export type EditorGetResult<T, ClsType> = T extends undefined ? ClsType extends {
10
+ prototype: infer R;
11
+ } ? R : any : T;
12
+ export interface EditorConfig {
13
+ /**
14
+ * 插件 Plugin
15
+ */
16
+ plugins?: Plugin[];
17
+ /**
18
+ * 设置器 Setter
19
+ */
20
+ setters?: Record<string, Setter>;
21
+ /**
22
+ * 组件 Component
23
+ */
24
+ components?: Record<string, Component>;
25
+ /**
26
+ * 组件元数据 ComponentMetadata
27
+ */
28
+ componentMetas?: Record<string, ComponentMetadata>;
29
+ /**
30
+ * 生命周期
31
+ */
32
+ lifeCycles?: LifeCyclesConfig;
33
+ /**
34
+ * designer props
35
+ */
36
+ designer?: Pick<DesignerProps, 'onDragstart' | 'onDrag' | 'onDragend'>;
37
+ /**
38
+ * 默认项目 Schema
39
+ */
40
+ defaultSchema?: ProjectSchema;
41
+ /**
42
+ * 快捷键
43
+ */
44
+ hotkeys?: HotkeyConfig[];
45
+ }
46
+ export interface LifeCyclesConfig {
47
+ init?: (editor: Editor) => any;
48
+ destroy?: (editor: Editor) => any;
49
+ extend?: (editor: Editor) => any;
50
+ }
51
+ export declare enum EDITOR_EVENT {
52
+ BEFORE_INIT = "editor:beforeInit",
53
+ AFTER_INIT = "editor:afterInit",
54
+ DESTROY = "editor:destroy",
55
+ BEFORE_EXTEND = "editor:beforeExtend",
56
+ AFTER_EXTEND = "editor:afterExtend"
57
+ }
58
+ export declare class Editor {
59
+ private accessor context;
60
+ config?: EditorConfig;
61
+ eventBus: import("./utils").EventBus;
62
+ private waits;
63
+ constructor(config?: EditorConfig);
64
+ get<T = undefined, KeyOrType extends EditorValueKey = any>(keyOrType: KeyOrType): EditorGetResult<T, KeyOrType> | undefined;
65
+ has(keyOrType: EditorValueKey): boolean;
66
+ set(key: EditorValueKey, data: any): void | Promise<void>;
67
+ /**
68
+ * get value until value is set
69
+ */
70
+ onceGot<T = undefined, KeyOrType extends EditorValueKey = any>(keyOrType: KeyOrType): Promise<EditorGetResult<T, KeyOrType>>;
71
+ /**
72
+ * listen value when value is set
73
+ */
74
+ onGot<T = undefined, KeyOrType extends EditorValueKey = any>(keyOrType: KeyOrType, fn: (data: EditorGetResult<T, KeyOrType>) => void): () => void;
75
+ /**
76
+ * listen value when value is changed
77
+ */
78
+ onChange<T = undefined, KeyOrType extends EditorValueKey = any>(keyOrType: KeyOrType, fn: (data: EditorGetResult<T, KeyOrType>) => void): () => void;
79
+ init(config?: EditorConfig): Promise<void>;
80
+ destroy(): void;
81
+ extend(pluginManager: PluginManager): Promise<void>;
82
+ /**
83
+ * notify all listeners when value is got
84
+ */
85
+ private notifyGot;
86
+ private setWait;
87
+ private delWait;
88
+ onBeforeInit(listener: (editor: Editor) => void): () => void;
89
+ onAfterInit(listener: (editor: Editor) => void): () => void;
90
+ onDestroy(listener: (editor: Editor) => void): () => void;
91
+ onBeforeExtend(listener: (editor: Editor) => void): () => void;
92
+ onAfterExtend(listener: (editor: Editor) => void): () => void;
93
+ }
94
+ export declare const createEasyEditor: (config?: EditorConfig) => Editor;