@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,12 @@
|
|
|
1
|
+
declare class Clipboard {
|
|
2
|
+
private copyPasters;
|
|
3
|
+
private waitFn?;
|
|
4
|
+
isCopyPasteEvent(e: Event): void;
|
|
5
|
+
private isCopyPaster;
|
|
6
|
+
initCopyPaster(el: HTMLTextAreaElement): () => void;
|
|
7
|
+
injectCopyPaster(document: Document): (() => void) | undefined;
|
|
8
|
+
setData(data: any): Promise<void>;
|
|
9
|
+
waitPasteData(keyboardEvent: KeyboardEvent, cb: (data: any, e: ClipboardEvent) => void): void;
|
|
10
|
+
}
|
|
11
|
+
export declare const clipboard: Clipboard;
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { Editor } from '../../editor';
|
|
2
|
+
import type { Designer } from '../designer';
|
|
3
|
+
import type { Component, ComponentMetadata } from './meta';
|
|
4
|
+
import { ComponentMeta } from './component-meta';
|
|
5
|
+
export declare class ComponentMetaManager {
|
|
6
|
+
readonly editor: Editor;
|
|
7
|
+
private accessor _componentMetasMap;
|
|
8
|
+
private _lostComponentMetasMap;
|
|
9
|
+
get designer(): Designer;
|
|
10
|
+
constructor(editor: Editor);
|
|
11
|
+
buildComponentMetasMap: (metas: Record<string, ComponentMetadata>) => void;
|
|
12
|
+
createComponentMeta(data: ComponentMetadata): ComponentMeta | null;
|
|
13
|
+
getComponentMeta(componentName: string, generateMetadata?: () => ComponentMetadata | null): ComponentMeta;
|
|
14
|
+
getComponentSnippets(): import("./meta").Snippet[];
|
|
15
|
+
get componentMetasMap(): Record<string, ComponentMetadata>;
|
|
16
|
+
get componentsMap(): {
|
|
17
|
+
[key: string]: Component;
|
|
18
|
+
};
|
|
19
|
+
getComponentMetasMap(): Map<string, ComponentMeta>;
|
|
20
|
+
isComponentMeta(obj: any): obj is ComponentMeta;
|
|
21
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { Designer } from '../designer';
|
|
2
|
+
import type { ComponentMetadata } from './meta';
|
|
3
|
+
export declare enum COMPONENT_META_EVENT {
|
|
4
|
+
CHANGE = "componentMeta:metadata.change"
|
|
5
|
+
}
|
|
6
|
+
export declare class ComponentMeta {
|
|
7
|
+
readonly designer: Designer;
|
|
8
|
+
readonly isComponentMeta = true;
|
|
9
|
+
private emitter;
|
|
10
|
+
private _componentName?;
|
|
11
|
+
get componentName(): string;
|
|
12
|
+
private _isContainer?;
|
|
13
|
+
get isContainer(): boolean;
|
|
14
|
+
private _descriptor?;
|
|
15
|
+
get descriptor(): string | undefined;
|
|
16
|
+
private _metadata?;
|
|
17
|
+
get configure(): import("./meta").FieldConfig[];
|
|
18
|
+
private _title?;
|
|
19
|
+
get title(): string;
|
|
20
|
+
get icon(): string | undefined;
|
|
21
|
+
get advanced(): import("./meta").Advanced;
|
|
22
|
+
get snippets(): import("./meta").Snippet[];
|
|
23
|
+
constructor(designer: Designer, metadata: ComponentMetadata);
|
|
24
|
+
private parseMetadata;
|
|
25
|
+
refreshMetadata(): void;
|
|
26
|
+
setMetadata(metadata: ComponentMetadata): void;
|
|
27
|
+
getMetadata(): ComponentMetadata;
|
|
28
|
+
onMetadataChange(fn: (args: any) => void): () => void;
|
|
29
|
+
}
|
|
30
|
+
export declare function isComponentMeta(obj: any): obj is ComponentMeta;
|
|
@@ -0,0 +1,264 @@
|
|
|
1
|
+
import type { Node, PropKey } from '../../document';
|
|
2
|
+
import type { NodeSchema } from '../../types';
|
|
3
|
+
import type { SettingField, SettingPropEntry } from '../setting';
|
|
4
|
+
export interface ComponentMetadata {
|
|
5
|
+
componentName: string;
|
|
6
|
+
title?: string;
|
|
7
|
+
icon?: string;
|
|
8
|
+
tags?: string[];
|
|
9
|
+
description?: string;
|
|
10
|
+
/**
|
|
11
|
+
* component screenshot, for left panel to display component screenshot
|
|
12
|
+
*/
|
|
13
|
+
screenshot?: string;
|
|
14
|
+
/**
|
|
15
|
+
* component dev mode
|
|
16
|
+
*/
|
|
17
|
+
devMode?: 'proCode' | 'lowCode';
|
|
18
|
+
/**
|
|
19
|
+
* component configure, for right panel to use setter to config component
|
|
20
|
+
*/
|
|
21
|
+
configure?: Configure;
|
|
22
|
+
/**
|
|
23
|
+
* available snippets, one snippet is a schema(a component)
|
|
24
|
+
*/
|
|
25
|
+
snippets?: Snippet[];
|
|
26
|
+
/**
|
|
27
|
+
* first level group
|
|
28
|
+
*/
|
|
29
|
+
group?: string;
|
|
30
|
+
/**
|
|
31
|
+
* second level group
|
|
32
|
+
*/
|
|
33
|
+
category?: string;
|
|
34
|
+
/**
|
|
35
|
+
* component priority for sorting
|
|
36
|
+
*/
|
|
37
|
+
priority?: number;
|
|
38
|
+
[key: string]: any;
|
|
39
|
+
}
|
|
40
|
+
export interface Snippet {
|
|
41
|
+
/**
|
|
42
|
+
* same as component title
|
|
43
|
+
*/
|
|
44
|
+
title?: string;
|
|
45
|
+
/**
|
|
46
|
+
* same as component screenshot
|
|
47
|
+
*/
|
|
48
|
+
screenshot?: string;
|
|
49
|
+
/**
|
|
50
|
+
* schema to be inserted
|
|
51
|
+
*/
|
|
52
|
+
schema?: NodeSchema;
|
|
53
|
+
}
|
|
54
|
+
export interface Configure {
|
|
55
|
+
/**
|
|
56
|
+
* configure component props
|
|
57
|
+
*/
|
|
58
|
+
props?: FieldConfig[];
|
|
59
|
+
/**
|
|
60
|
+
* component behavior configure
|
|
61
|
+
*/
|
|
62
|
+
component?: ComponentConfigure;
|
|
63
|
+
/**
|
|
64
|
+
* 通用扩展面板支持性配置
|
|
65
|
+
*/
|
|
66
|
+
supports?: ConfigureSupport;
|
|
67
|
+
/**
|
|
68
|
+
* 高级特性配置
|
|
69
|
+
*/
|
|
70
|
+
advanced?: Advanced;
|
|
71
|
+
}
|
|
72
|
+
export interface FieldConfig {
|
|
73
|
+
/**
|
|
74
|
+
* default is field, if is group, the items will be used
|
|
75
|
+
*/
|
|
76
|
+
type?: 'field' | 'group';
|
|
77
|
+
/**
|
|
78
|
+
* the setting items which group body contains when .type = 'group'
|
|
79
|
+
*/
|
|
80
|
+
items?: FieldConfig[];
|
|
81
|
+
/**
|
|
82
|
+
* the name of this setting field, the name can refer to the props of the component, such as `title` or `obj.a` ...
|
|
83
|
+
*/
|
|
84
|
+
name?: PropKey;
|
|
85
|
+
/**
|
|
86
|
+
* the field title, for configure tooltip
|
|
87
|
+
*/
|
|
88
|
+
title?: string;
|
|
89
|
+
/**
|
|
90
|
+
* the field body contains when .type = 'field'
|
|
91
|
+
*/
|
|
92
|
+
setter?: SetterType | DynamicSetter;
|
|
93
|
+
/**
|
|
94
|
+
* extra props for field
|
|
95
|
+
*/
|
|
96
|
+
extraProps?: FieldExtraProps;
|
|
97
|
+
}
|
|
98
|
+
export interface FieldExtraProps {
|
|
99
|
+
/**
|
|
100
|
+
* is required
|
|
101
|
+
*/
|
|
102
|
+
isRequired?: boolean;
|
|
103
|
+
/**
|
|
104
|
+
* default value of target prop for setter use
|
|
105
|
+
*/
|
|
106
|
+
defaultValue?: any;
|
|
107
|
+
/**
|
|
108
|
+
* default collapsed
|
|
109
|
+
*/
|
|
110
|
+
defaultCollapsed?: boolean;
|
|
111
|
+
/**
|
|
112
|
+
* get value for field
|
|
113
|
+
*/
|
|
114
|
+
getValue?: (target: SettingField, fieldValue: any) => any;
|
|
115
|
+
/**
|
|
116
|
+
* set value for field
|
|
117
|
+
*/
|
|
118
|
+
setValue?: (target: SettingField, value: any) => void;
|
|
119
|
+
/**
|
|
120
|
+
* the field conditional show, is not set always true
|
|
121
|
+
*/
|
|
122
|
+
condition?: (target: SettingField) => boolean;
|
|
123
|
+
/**
|
|
124
|
+
* autorun when something change
|
|
125
|
+
*/
|
|
126
|
+
autorun?: (target: SettingField) => void;
|
|
127
|
+
/**
|
|
128
|
+
* support variable
|
|
129
|
+
*/
|
|
130
|
+
supportVariable?: boolean;
|
|
131
|
+
onChange?: (target: SettingField, value: any) => void;
|
|
132
|
+
}
|
|
133
|
+
export interface ComponentConfigure {
|
|
134
|
+
isContainer?: boolean;
|
|
135
|
+
descriptor?: string;
|
|
136
|
+
/**
|
|
137
|
+
* disable some behaviors, such as `'copy'`, `'move'`, `'remove'` or array of them
|
|
138
|
+
*/
|
|
139
|
+
disableBehaviors?: string[] | string;
|
|
140
|
+
}
|
|
141
|
+
export interface ConfigureSupport {
|
|
142
|
+
/**
|
|
143
|
+
* supported events
|
|
144
|
+
*/
|
|
145
|
+
events?: string[];
|
|
146
|
+
/**
|
|
147
|
+
* supported className
|
|
148
|
+
*/
|
|
149
|
+
className?: boolean;
|
|
150
|
+
/**
|
|
151
|
+
* supported style
|
|
152
|
+
*/
|
|
153
|
+
style?: boolean;
|
|
154
|
+
/**
|
|
155
|
+
* supported lifecycle
|
|
156
|
+
*/
|
|
157
|
+
lifecycles?: any[];
|
|
158
|
+
/**
|
|
159
|
+
* supported loop component
|
|
160
|
+
*/
|
|
161
|
+
loop?: boolean;
|
|
162
|
+
/**
|
|
163
|
+
* supported condition render
|
|
164
|
+
*/
|
|
165
|
+
condition?: boolean;
|
|
166
|
+
}
|
|
167
|
+
export interface Advanced {
|
|
168
|
+
/**
|
|
169
|
+
* callbacks/hooks which can be used to do things on some special cations like onNodeAdd or onResize
|
|
170
|
+
*/
|
|
171
|
+
callbacks?: Callbacks;
|
|
172
|
+
/**
|
|
173
|
+
* auto add children when drag into container
|
|
174
|
+
*/
|
|
175
|
+
initialChildren?: NodeSchema[] | ((target: Node) => NodeSchema[]);
|
|
176
|
+
/**
|
|
177
|
+
* TODO: 补充文档
|
|
178
|
+
* @experimental not in spec yet
|
|
179
|
+
*/
|
|
180
|
+
view?: ComponentType<any>;
|
|
181
|
+
}
|
|
182
|
+
export interface Callbacks {
|
|
183
|
+
onMouseDownHook?: (e: MouseEvent, currentNode: Node | null) => any;
|
|
184
|
+
onDblClickHook?: (e: MouseEvent, currentNode: Node | null) => any;
|
|
185
|
+
onClickHook?: (e: MouseEvent, currentNode: Node | null) => any;
|
|
186
|
+
onMoveHook?: (currentNode: Node) => boolean;
|
|
187
|
+
onHoverHook?: (currentNode: Node) => boolean;
|
|
188
|
+
/** 选中 hook,如果返回值是 false,可以控制组件不可被选中 */
|
|
189
|
+
onSelectHook?: (currentNode: Node) => boolean;
|
|
190
|
+
onChildMoveHook?: (childNode: Node, currentNode: Node) => boolean;
|
|
191
|
+
onNodeRemove?: (removedNode: Node | null, currentNode: Node | null) => void;
|
|
192
|
+
onNodeAdd?: (addedNode: Node | null, currentNode: Node | null) => void;
|
|
193
|
+
onSubtreeModified?: (currentNode: Node, options: any) => void;
|
|
194
|
+
onResize?: (e: MouseEvent & {
|
|
195
|
+
trigger: string;
|
|
196
|
+
deltaX?: number;
|
|
197
|
+
deltaY?: number;
|
|
198
|
+
}, currentNode: any) => void;
|
|
199
|
+
onResizeStart?: (e: MouseEvent & {
|
|
200
|
+
trigger: string;
|
|
201
|
+
deltaX?: number;
|
|
202
|
+
deltaY?: number;
|
|
203
|
+
}, currentNode: any) => void;
|
|
204
|
+
onResizeEnd?: (e: MouseEvent & {
|
|
205
|
+
trigger: string;
|
|
206
|
+
deltaX?: number;
|
|
207
|
+
deltaY?: number;
|
|
208
|
+
}, currentNode: Node) => void;
|
|
209
|
+
}
|
|
210
|
+
export type SetterType = SetterConfig | string;
|
|
211
|
+
export type DynamicSetterProps = (target: SettingField) => Record<string, unknown>;
|
|
212
|
+
export interface SetterConfig {
|
|
213
|
+
/**
|
|
214
|
+
* the name of the setter
|
|
215
|
+
*/
|
|
216
|
+
componentName: string;
|
|
217
|
+
/**
|
|
218
|
+
* the props pass to Setter Component
|
|
219
|
+
*/
|
|
220
|
+
props?: Record<string, unknown> | DynamicSetterProps;
|
|
221
|
+
/**
|
|
222
|
+
* is required
|
|
223
|
+
*/
|
|
224
|
+
isRequired?: boolean;
|
|
225
|
+
/**
|
|
226
|
+
* Setter initial value
|
|
227
|
+
*/
|
|
228
|
+
/**
|
|
229
|
+
* Setter default value
|
|
230
|
+
*/
|
|
231
|
+
defaultValue?: any;
|
|
232
|
+
}
|
|
233
|
+
export declare const isSetterConfig: (obj: any) => obj is SetterConfig;
|
|
234
|
+
export type DynamicSetter = (target: SettingPropEntry) => string | SetterConfig | Component;
|
|
235
|
+
export type ComponentInstance = any;
|
|
236
|
+
export type ComponentType<T> = any;
|
|
237
|
+
/**
|
|
238
|
+
* component type
|
|
239
|
+
*/
|
|
240
|
+
export type Component = ComponentType<any> | object;
|
|
241
|
+
export interface LowCodeComponent {
|
|
242
|
+
/**
|
|
243
|
+
* 研发模式
|
|
244
|
+
*/
|
|
245
|
+
devMode: 'lowCode';
|
|
246
|
+
/**
|
|
247
|
+
* 组件名称
|
|
248
|
+
*/
|
|
249
|
+
componentName: string;
|
|
250
|
+
}
|
|
251
|
+
export interface ProCodeComponent {
|
|
252
|
+
/**
|
|
253
|
+
* 研发模式
|
|
254
|
+
*/
|
|
255
|
+
devMode: 'proCode';
|
|
256
|
+
/**
|
|
257
|
+
* 组件名称
|
|
258
|
+
*/
|
|
259
|
+
componentName: string;
|
|
260
|
+
}
|
|
261
|
+
export type ComponentMap = ProCodeComponent | LowCodeComponent;
|
|
262
|
+
export type ComponentsMap = ComponentMap[];
|
|
263
|
+
export declare function isProCodeComponentType(desc: ComponentMap): desc is ProCodeComponent;
|
|
264
|
+
export declare function isLowCodeComponentType(desc: ComponentMap): desc is LowCodeComponent;
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import type { Node, PropsMap } from '../document';
|
|
2
|
+
import type { Editor } from '../editor';
|
|
3
|
+
import type { ProjectSchema, TRANSFORM_STAGE } from '../types';
|
|
4
|
+
import type { ComponentMetaManager } from './component-meta';
|
|
5
|
+
import type { DragObject } from './dragon';
|
|
6
|
+
import type { LocateEvent, LocationData } from './location';
|
|
7
|
+
import { Project } from '../project';
|
|
8
|
+
import { Detecting } from './detecting';
|
|
9
|
+
import { Dragon } from './dragon';
|
|
10
|
+
import { DropLocation } from './location';
|
|
11
|
+
import { type NodeSelector, type OffsetObserver } from './offset-observer';
|
|
12
|
+
import { Selection } from './selection';
|
|
13
|
+
import { SettingsManager } from './setting';
|
|
14
|
+
import { SettingTopEntry } from './setting/setting-top-entry';
|
|
15
|
+
export type PropsTransducer = (props: PropsMap, node: Node, ctx?: {
|
|
16
|
+
stage: TRANSFORM_STAGE;
|
|
17
|
+
}) => PropsMap;
|
|
18
|
+
export interface DesignerProps {
|
|
19
|
+
editor: Editor;
|
|
20
|
+
defaultSchema?: ProjectSchema;
|
|
21
|
+
onDragstart?: (e: LocateEvent) => void;
|
|
22
|
+
onDrag?: (e: LocateEvent) => void;
|
|
23
|
+
onDragend?: (e: {
|
|
24
|
+
dragObject: DragObject;
|
|
25
|
+
copy: boolean;
|
|
26
|
+
}, loc?: DropLocation) => void;
|
|
27
|
+
[key: string]: any;
|
|
28
|
+
}
|
|
29
|
+
export declare enum DESIGNER_EVENT {
|
|
30
|
+
INIT = "designer:init",
|
|
31
|
+
DRAG_START = "designer:dragstart",
|
|
32
|
+
DRAG = "designer:drag",
|
|
33
|
+
DRAG_END = "designer:dragend",
|
|
34
|
+
CURRENT_DOCUMENT_CHANGE = "designer:current-document.change",
|
|
35
|
+
CURRENT_HISTORY_CHANGE = "designer:current-history.change",
|
|
36
|
+
DROP_LOCATION_CHANGE = "designer:dropLocation.change",
|
|
37
|
+
DOCUMENT_DROP_LOCATION_CHANGE = "designer:document.dropLocation.change",
|
|
38
|
+
INSERT_NODE_BEFORE = "designer:node.insert.before",
|
|
39
|
+
INSERT_NODE_AFTER = "designer:node.insert.after",
|
|
40
|
+
NODE_VISIBLE_CHANGE = "designer:node.visible.change",
|
|
41
|
+
NODE_LOCK_CHANGE = "designer:node.lock.change",
|
|
42
|
+
NODE_CHILDREN_CHANGE = "designer:node.children.change",
|
|
43
|
+
NODE_PROPS_CHANGE = "designer:node.props.change",
|
|
44
|
+
NODE_REMOVE = "designer:node.remove",
|
|
45
|
+
NODE_RENDER = "designer:node.render",
|
|
46
|
+
SETTING_TOP_ENTRY_VALUE_CHANGE = "designer:setting.top-entry.value.change",
|
|
47
|
+
SELECTION_CHANGE = "designer:selection.change",
|
|
48
|
+
SIMULATOR_SELECT = "designer:simulator.select",
|
|
49
|
+
VIEWPORT_MOUNT = "simulator:viewport.mount"
|
|
50
|
+
}
|
|
51
|
+
export declare class Designer {
|
|
52
|
+
private emitter;
|
|
53
|
+
readonly editor: Editor;
|
|
54
|
+
readonly dragon: Dragon;
|
|
55
|
+
readonly detecting: Detecting;
|
|
56
|
+
readonly project: Project;
|
|
57
|
+
readonly selection: Selection;
|
|
58
|
+
readonly settingsManager: SettingsManager;
|
|
59
|
+
private _dropLocation?;
|
|
60
|
+
get componentMetaManager(): ComponentMetaManager;
|
|
61
|
+
private props?;
|
|
62
|
+
private propsReducers;
|
|
63
|
+
private oobxList;
|
|
64
|
+
get currentDocument(): import("..").Document | undefined;
|
|
65
|
+
get currentHistory(): import("..").History<import("..").RootSchema> | undefined;
|
|
66
|
+
constructor(props: DesignerProps);
|
|
67
|
+
/**
|
|
68
|
+
* 该函数用于 Designer constructor 的插件扩展,因为 Object.defineProperty 无法修改 constructor
|
|
69
|
+
*/
|
|
70
|
+
init(): void;
|
|
71
|
+
setProps(nextProps: DesignerProps): void;
|
|
72
|
+
get(key: string): any;
|
|
73
|
+
postEvent(event: string, ...args: any[]): void;
|
|
74
|
+
onEvent(event: string, listener: (...args: any[]) => void): () => void;
|
|
75
|
+
createLocation(locationData: LocationData<Node>): DropLocation;
|
|
76
|
+
clearLocation(): void;
|
|
77
|
+
createOffsetObserver(nodeInstance: NodeSelector): OffsetObserver | null;
|
|
78
|
+
private clearOobxList;
|
|
79
|
+
touchOffsetObserver(): void;
|
|
80
|
+
onInit(listener: (designer: Designer) => void): void;
|
|
81
|
+
get schema(): ProjectSchema<import("..").RootSchema>;
|
|
82
|
+
setSchema(schema: ProjectSchema): void;
|
|
83
|
+
transformProps(props: PropsMap, node: Node, stage: TRANSFORM_STAGE): PropsMap;
|
|
84
|
+
addPropsReducer(reducer: PropsTransducer, stage: TRANSFORM_STAGE): void;
|
|
85
|
+
createSettingEntry(nodes: Node[]): SettingTopEntry;
|
|
86
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { Designer } from '..';
|
|
2
|
+
import type { Document, Node } from '../document';
|
|
3
|
+
export declare enum DETECTING_EVENT {
|
|
4
|
+
CHANGE = "detecting:change"
|
|
5
|
+
}
|
|
6
|
+
export declare class Detecting {
|
|
7
|
+
readonly designer: Designer;
|
|
8
|
+
private emitter;
|
|
9
|
+
private accessor _enable;
|
|
10
|
+
/**
|
|
11
|
+
* control whether to show the hover effect when the outline tree is hovered
|
|
12
|
+
* TODO: extract this logic from the designer
|
|
13
|
+
*/
|
|
14
|
+
get enable(): boolean;
|
|
15
|
+
set enable(flag: boolean);
|
|
16
|
+
private accessor _current;
|
|
17
|
+
get current(): Node<import("..").NodeSchema> | null;
|
|
18
|
+
constructor(designer: Designer);
|
|
19
|
+
capture(node: Node | null): void;
|
|
20
|
+
release(node: Node | null): void;
|
|
21
|
+
leave(document: Document | undefined): void;
|
|
22
|
+
onDetectingChange(fn: (node: Node) => void): () => void;
|
|
23
|
+
}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import type { Designer } from '.';
|
|
2
|
+
import type { Node } from '../document';
|
|
3
|
+
import type { Simulator } from '../simulator';
|
|
4
|
+
import type { NodeSchema } from '../types';
|
|
5
|
+
import type { ComponentInstance } from './component-meta';
|
|
6
|
+
import type { LocateEvent } from './location';
|
|
7
|
+
import type { Sensor } from './sensor';
|
|
8
|
+
export declare enum DRAGON_EVENT {
|
|
9
|
+
DRAGSTART = "dragstart",
|
|
10
|
+
DRAG = "drag",
|
|
11
|
+
DRAGEND = "dragend"
|
|
12
|
+
}
|
|
13
|
+
export declare enum DragObjectType {
|
|
14
|
+
Node = "node",
|
|
15
|
+
NodeData = "nodedata"
|
|
16
|
+
}
|
|
17
|
+
export declare class DragObject {
|
|
18
|
+
type: DragObjectType;
|
|
19
|
+
data?: NodeSchema | NodeSchema[] | undefined;
|
|
20
|
+
nodes?: (Node | null)[] | undefined;
|
|
21
|
+
}
|
|
22
|
+
export interface DragAnyObject {
|
|
23
|
+
type: string;
|
|
24
|
+
[key: string]: any;
|
|
25
|
+
}
|
|
26
|
+
export interface DragNodeObject<T = Node> {
|
|
27
|
+
type: DragObjectType.Node;
|
|
28
|
+
nodes: T[];
|
|
29
|
+
}
|
|
30
|
+
export interface DragNodeDataObject {
|
|
31
|
+
type: DragObjectType.NodeData;
|
|
32
|
+
data: NodeSchema | NodeSchema[];
|
|
33
|
+
thumbnail?: string;
|
|
34
|
+
description?: string;
|
|
35
|
+
[extra: string]: any;
|
|
36
|
+
}
|
|
37
|
+
export interface NodeInstance<T = ComponentInstance, N = Node> {
|
|
38
|
+
docId: string;
|
|
39
|
+
nodeId: string;
|
|
40
|
+
instance: T;
|
|
41
|
+
node?: N | null;
|
|
42
|
+
}
|
|
43
|
+
export declare function isDragAnyObject(obj: any): obj is DragAnyObject;
|
|
44
|
+
export declare const isDragNodeObject: (obj: any) => obj is DragNodeObject;
|
|
45
|
+
export declare const isDragNodeDataObject: (obj: any) => obj is DragNodeDataObject;
|
|
46
|
+
export declare const isLocateEvent: (e: any) => e is LocateEvent;
|
|
47
|
+
export declare const isDragEvent: (e: any) => e is DragEvent;
|
|
48
|
+
export declare const isInvalidPoint: (e: any, last: any) => boolean;
|
|
49
|
+
export declare const isSameAs: (e1: MouseEvent | DragEvent, e2: MouseEvent | DragEvent) => boolean;
|
|
50
|
+
/**
|
|
51
|
+
* mouse shake check
|
|
52
|
+
*/
|
|
53
|
+
export declare const isShaken: (e1: MouseEvent | DragEvent, e2: MouseEvent | DragEvent) => boolean;
|
|
54
|
+
export declare const setShaken: (e: any) => void;
|
|
55
|
+
export declare const getSourceSensor: (dragObject: DragObject) => Simulator | null;
|
|
56
|
+
export declare class Dragon {
|
|
57
|
+
readonly designer: Designer;
|
|
58
|
+
emitter: import("..").EventBus;
|
|
59
|
+
private sensors;
|
|
60
|
+
/** current active sensor */
|
|
61
|
+
private accessor _activeSensor;
|
|
62
|
+
get activeSensor(): Sensor<Node<NodeSchema>> | undefined;
|
|
63
|
+
private accessor _dragging;
|
|
64
|
+
get dragging(): boolean;
|
|
65
|
+
constructor(designer: Designer);
|
|
66
|
+
/**
|
|
67
|
+
* Quick listen a shell(container element) drag behavior
|
|
68
|
+
* @param shell container element
|
|
69
|
+
* @param boost boost got a drag object
|
|
70
|
+
* @param eventType choose a event to trigger the dnd
|
|
71
|
+
*/
|
|
72
|
+
from(shell: HTMLElement, boost: (e: MouseEvent | DragEvent) => DragObject | null, eventType?: 'mouse' | 'drag'): () => void;
|
|
73
|
+
/**
|
|
74
|
+
* boost your dragObject for dragging(flying)
|
|
75
|
+
* @param dragObject drag object
|
|
76
|
+
* @param boostEvent drag start event
|
|
77
|
+
*/
|
|
78
|
+
boost(dragObject: DragObject, boostEvent: MouseEvent | DragEvent): void;
|
|
79
|
+
/**
|
|
80
|
+
* get master sensors(opened documents)
|
|
81
|
+
*/
|
|
82
|
+
private getMasterSensors;
|
|
83
|
+
/**
|
|
84
|
+
* get all simulators
|
|
85
|
+
*/
|
|
86
|
+
private getSimulators;
|
|
87
|
+
/**
|
|
88
|
+
* 添加投放感应区
|
|
89
|
+
*/
|
|
90
|
+
addSensor(sensor: Sensor): void;
|
|
91
|
+
/**
|
|
92
|
+
* 移除投放感应
|
|
93
|
+
*/
|
|
94
|
+
removeSensor(sensor: Sensor): void;
|
|
95
|
+
onDragstart(func: (e: LocateEvent) => void): () => void;
|
|
96
|
+
onDrag(func: (e: LocateEvent) => void): () => void;
|
|
97
|
+
onDragend(func: (e: {
|
|
98
|
+
dragObject: DragObject;
|
|
99
|
+
copy?: boolean;
|
|
100
|
+
esc?: boolean;
|
|
101
|
+
}) => void): () => void;
|
|
102
|
+
}
|
|
103
|
+
export declare const makeEventsHandler: (boostEvent: MouseEvent | DragEvent, sensors: Simulator[]) => (handle: (sdoc: globalThis.Document) => void) => void;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export * from './clipboard';
|
|
2
|
+
export * from './component-meta';
|
|
3
|
+
export * from './designer';
|
|
4
|
+
export * from './detecting';
|
|
5
|
+
export * from './dragon';
|
|
6
|
+
export * from './location';
|
|
7
|
+
export * from './offset-observer';
|
|
8
|
+
export * from './selection';
|
|
9
|
+
export * from './sensor';
|
|
10
|
+
export * from './setting';
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import type { Document as IDocument, Node as INode } from '../document';
|
|
2
|
+
import type { DragObject } from './dragon';
|
|
3
|
+
import type { Sensor } from './sensor';
|
|
4
|
+
export interface Point {
|
|
5
|
+
clientX: number;
|
|
6
|
+
clientY: number;
|
|
7
|
+
}
|
|
8
|
+
export interface CanvasPoint {
|
|
9
|
+
canvasX: number;
|
|
10
|
+
canvasY: number;
|
|
11
|
+
}
|
|
12
|
+
export type Rect = DOMRect & {
|
|
13
|
+
elements?: Array<Element | Text>;
|
|
14
|
+
computed?: boolean;
|
|
15
|
+
};
|
|
16
|
+
export type Rects = DOMRect[] & {
|
|
17
|
+
elements: Array<Element | Text>;
|
|
18
|
+
};
|
|
19
|
+
export declare enum LocationDetailType {
|
|
20
|
+
Children = "Children",
|
|
21
|
+
Prop = "Prop"
|
|
22
|
+
}
|
|
23
|
+
export interface LocationChildrenDetail {
|
|
24
|
+
type: LocationDetailType.Children;
|
|
25
|
+
index?: number | null;
|
|
26
|
+
/** is valid location */
|
|
27
|
+
valid?: boolean;
|
|
28
|
+
edge?: DOMRect;
|
|
29
|
+
near?: {
|
|
30
|
+
node: INode;
|
|
31
|
+
pos: 'before' | 'after' | 'replace';
|
|
32
|
+
rect?: Rect;
|
|
33
|
+
align?: 'V' | 'H';
|
|
34
|
+
};
|
|
35
|
+
focus?: {
|
|
36
|
+
type: 'node';
|
|
37
|
+
node: INode;
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
export interface LocationPropDetail {
|
|
41
|
+
type: LocationDetailType.Prop;
|
|
42
|
+
name: string;
|
|
43
|
+
domNode?: HTMLElement;
|
|
44
|
+
}
|
|
45
|
+
export type LocationDetail = LocationChildrenDetail | LocationPropDetail | {
|
|
46
|
+
[key: string]: any;
|
|
47
|
+
type: string;
|
|
48
|
+
};
|
|
49
|
+
export interface LocationData<Node = INode> {
|
|
50
|
+
target: Node;
|
|
51
|
+
detail: LocationDetail;
|
|
52
|
+
source: string;
|
|
53
|
+
event: LocateEvent;
|
|
54
|
+
}
|
|
55
|
+
export interface LocateEvent {
|
|
56
|
+
get type(): string;
|
|
57
|
+
/**
|
|
58
|
+
* browser window coordinate system
|
|
59
|
+
*/
|
|
60
|
+
readonly globalX: number;
|
|
61
|
+
readonly globalY: number;
|
|
62
|
+
readonly originalEvent: MouseEvent | DragEvent;
|
|
63
|
+
/**
|
|
64
|
+
* browser event response target
|
|
65
|
+
*/
|
|
66
|
+
target?: Element | null;
|
|
67
|
+
/**
|
|
68
|
+
* event correction identifier, initially constructed from the initiating end, missing canvasX,canvasY, needs to be corrected
|
|
69
|
+
*/
|
|
70
|
+
fixed?: true;
|
|
71
|
+
canvasX?: number;
|
|
72
|
+
canvasY?: number;
|
|
73
|
+
/**
|
|
74
|
+
* active or target document
|
|
75
|
+
*/
|
|
76
|
+
document?: Document | null;
|
|
77
|
+
get dragObject(): DragObject | null;
|
|
78
|
+
sensor?: Sensor;
|
|
79
|
+
}
|
|
80
|
+
export declare const isLocationData: (obj: any) => obj is LocationData;
|
|
81
|
+
export declare const isLocationChildrenDetail: (obj: any) => obj is LocationChildrenDetail;
|
|
82
|
+
export declare const isText: (elem: any) => elem is Text;
|
|
83
|
+
export declare const isElement: (node: any) => node is Element;
|
|
84
|
+
export declare const isDocumentElem: (elem: any) => elem is Document;
|
|
85
|
+
export declare const getWindow: (elem: Element | Document) => Window;
|
|
86
|
+
export declare class DropLocation {
|
|
87
|
+
readonly target: INode;
|
|
88
|
+
readonly detail: LocationDetail;
|
|
89
|
+
readonly event: LocateEvent;
|
|
90
|
+
readonly source: string;
|
|
91
|
+
get document(): IDocument | null;
|
|
92
|
+
constructor({ target, detail, source, event }: LocationData);
|
|
93
|
+
clone(event: LocateEvent): DropLocation;
|
|
94
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { ComponentInstance, Node, Viewport } from '..';
|
|
2
|
+
export interface NodeSelector {
|
|
3
|
+
node: Node;
|
|
4
|
+
instance?: ComponentInstance;
|
|
5
|
+
}
|
|
6
|
+
export declare class OffsetObserver {
|
|
7
|
+
readonly nodeInstance: NodeSelector;
|
|
8
|
+
readonly id: string;
|
|
9
|
+
private lastOffsetLeft?;
|
|
10
|
+
private lastOffsetTop?;
|
|
11
|
+
private lastOffsetHeight?;
|
|
12
|
+
private lastOffsetWidth?;
|
|
13
|
+
private accessor _height;
|
|
14
|
+
private accessor _width;
|
|
15
|
+
private accessor _left;
|
|
16
|
+
private accessor _top;
|
|
17
|
+
private accessor _right;
|
|
18
|
+
private accessor _bottom;
|
|
19
|
+
get height(): number;
|
|
20
|
+
get width(): number;
|
|
21
|
+
get top(): number;
|
|
22
|
+
get left(): number;
|
|
23
|
+
get bottom(): number;
|
|
24
|
+
get right(): number;
|
|
25
|
+
accessor hasOffset: boolean;
|
|
26
|
+
get offsetLeft(): number;
|
|
27
|
+
get offsetTop(): number;
|
|
28
|
+
get offsetHeight(): number;
|
|
29
|
+
get offsetWidth(): number;
|
|
30
|
+
get scale(): number;
|
|
31
|
+
private pid;
|
|
32
|
+
readonly viewport: Viewport;
|
|
33
|
+
private isRoot;
|
|
34
|
+
readonly node: Node;
|
|
35
|
+
readonly compute: () => void;
|
|
36
|
+
constructor(nodeInstance: NodeSelector);
|
|
37
|
+
computeRect(): DOMRect | undefined;
|
|
38
|
+
purge(): void;
|
|
39
|
+
isPurged(): boolean;
|
|
40
|
+
}
|
|
41
|
+
export declare function createOffsetObserver(nodeInstance: NodeSelector): OffsetObserver | null;
|