@easy-editor/core 0.0.16 → 1.0.0
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/README.md +26 -28
- package/dist/config.d.ts +131 -0
- package/dist/designer/active-tracker.d.ts +17 -0
- package/dist/designer/designer.d.ts +31 -13
- package/dist/designer/dragon.d.ts +4 -5
- package/dist/designer/index.d.ts +0 -1
- package/dist/designer/location.d.ts +0 -3
- package/dist/designer/scroller.d.ts +34 -0
- package/dist/designer/selection.d.ts +1 -1
- package/dist/designer/sensor.d.ts +1 -1
- package/dist/designer/setting/setting-entry.d.ts +2 -2
- package/dist/designer/setting/setting-field.d.ts +2 -2
- package/dist/designer/setting/setting-manager.d.ts +2 -2
- package/dist/designer/setting/setting-prop-entry.d.ts +4 -4
- package/dist/designer/setting/setting-top-entry.d.ts +2 -2
- package/dist/document/document.d.ts +2 -4
- package/dist/document/node/node-children.d.ts +2 -3
- package/dist/document/node/node.d.ts +2 -3
- package/dist/document/prop/prop.d.ts +2 -3
- package/dist/document/prop/props.d.ts +2 -3
- package/dist/engine/editor.d.ts +45 -0
- package/dist/engine/engine.d.ts +11 -0
- package/dist/engine/index.d.ts +5 -0
- package/dist/{cjs/index.development.js → index.cjs} +6112 -5364
- package/dist/index.d.ts +4 -4
- package/dist/index.js +6089 -5353
- package/dist/{designer/component-meta → materials}/component-meta.d.ts +4 -4
- package/dist/materials/index.d.ts +2 -0
- package/dist/{designer/component-meta/component-meta-manager.d.ts → materials/materials.d.ts} +9 -6
- package/dist/plugin/index.d.ts +1 -1
- package/dist/plugin/plugin-context.d.ts +10 -10
- package/dist/plugin/plugin-extend.d.ts +3 -3
- package/dist/plugin/plugin-runtime.d.ts +3 -2
- package/dist/plugin/{plugin-manager.d.ts → plugins.d.ts} +4 -2
- package/dist/plugin/sequencify.d.ts +3 -3
- package/dist/project/project.d.ts +3 -4
- package/dist/setters/index.d.ts +1 -0
- package/dist/{setter-manager/setter-manager.d.ts → setters/setters.d.ts} +10 -7
- package/dist/simulator/simulator-renderer.d.ts +7 -2
- package/dist/simulator/simulator.d.ts +15 -14
- package/dist/simulator/viewport.d.ts +13 -0
- package/dist/types/component.d.ts +28 -0
- package/dist/types/data-source.d.ts +7 -0
- package/dist/{editor.d.ts → types/editor.d.ts} +35 -54
- package/dist/types/index.d.ts +4 -0
- package/dist/{designer/component-meta → types}/meta.d.ts +6 -60
- package/dist/types/setter.d.ts +26 -0
- package/dist/utils/event-bus.d.ts +11 -13
- package/dist/utils/event.d.ts +39 -0
- package/dist/utils/hotkey.d.ts +1 -5
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/is.d.ts +16 -0
- package/dist/utils/logger.d.ts +37 -17
- package/package.json +17 -12
- package/dist/cjs/index.development.js.map +0 -1
- package/dist/cjs/index.js +0 -11262
- package/dist/cjs/index.js.map +0 -1
- package/dist/cjs/index.production.js +0 -11262
- package/dist/cjs/index.production.js.map +0 -1
- package/dist/designer/component-meta/index.d.ts +0 -3
- package/dist/esm/index.development.js +0 -11154
- package/dist/esm/index.development.js.map +0 -1
- package/dist/esm/index.js +0 -11154
- package/dist/esm/index.js.map +0 -1
- package/dist/esm/index.production.js +0 -11154
- package/dist/esm/index.production.js.map +0 -1
- package/dist/setter-manager/index.d.ts +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Designer } from '../designer';
|
|
2
|
-
import type { ComponentMetadata } from '
|
|
2
|
+
import type { ComponentMetadata } from '../types';
|
|
3
3
|
export declare enum COMPONENT_META_EVENT {
|
|
4
4
|
CHANGE = "componentMeta:metadata.change"
|
|
5
5
|
}
|
|
@@ -16,12 +16,12 @@ export declare class ComponentMeta {
|
|
|
16
16
|
private _descriptor?;
|
|
17
17
|
get descriptor(): string | undefined;
|
|
18
18
|
private _metadata?;
|
|
19
|
-
get configure(): import("
|
|
19
|
+
get configure(): import("..").FieldConfig[];
|
|
20
20
|
private _title?;
|
|
21
21
|
get title(): string;
|
|
22
22
|
get icon(): string | undefined;
|
|
23
|
-
get advanced(): import("
|
|
24
|
-
get snippets(): import("
|
|
23
|
+
get advanced(): import("..").Advanced;
|
|
24
|
+
get snippets(): import("..").Snippet[];
|
|
25
25
|
constructor(designer: Designer, metadata: ComponentMetadata);
|
|
26
26
|
private parseMetadata;
|
|
27
27
|
refreshMetadata(): void;
|
package/dist/{designer/component-meta/component-meta-manager.d.ts → materials/materials.d.ts}
RENAMED
|
@@ -1,21 +1,24 @@
|
|
|
1
|
-
import type { Editor } from '../../editor';
|
|
2
1
|
import type { Designer } from '../designer';
|
|
3
|
-
import type { Component, ComponentMetadata } from '
|
|
2
|
+
import type { Component, ComponentMetadata, Editor } from '../types';
|
|
4
3
|
import { ComponentMeta } from './component-meta';
|
|
5
|
-
export declare class
|
|
4
|
+
export declare class Materials {
|
|
6
5
|
readonly editor: Editor;
|
|
7
6
|
private accessor _componentMetasMap;
|
|
8
7
|
private _lostComponentMetasMap;
|
|
9
8
|
get designer(): Designer;
|
|
10
9
|
constructor(editor: Editor);
|
|
11
|
-
buildComponentMetasMap: (metas:
|
|
10
|
+
buildComponentMetasMap: (metas: ComponentMetadata[]) => void;
|
|
12
11
|
createComponentMeta(data: ComponentMetadata): ComponentMeta | null;
|
|
13
12
|
getComponentMeta(componentName: string, generateMetadata?: () => ComponentMetadata | null): ComponentMeta;
|
|
14
|
-
getComponentSnippets(): import("
|
|
13
|
+
getComponentSnippets(): import("..").Snippet[];
|
|
14
|
+
getComponentMetasMap(): Map<string, ComponentMeta>;
|
|
15
15
|
get componentMetasMap(): Record<string, ComponentMetadata>;
|
|
16
16
|
get componentsMap(): {
|
|
17
17
|
[key: string]: Component;
|
|
18
18
|
};
|
|
19
|
-
|
|
19
|
+
/**
|
|
20
|
+
* 刷新 componentMetasMap,可间接触发模拟器里的 buildComponents
|
|
21
|
+
*/
|
|
22
|
+
refreshComponentMetasMap(): void;
|
|
20
23
|
isComponentMeta(obj: any): obj is ComponentMeta;
|
|
21
24
|
}
|
package/dist/plugin/index.d.ts
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type {
|
|
3
|
-
import type
|
|
1
|
+
import type { Event, Materials, Project, Setters } from '..';
|
|
2
|
+
import type { Config } from '../config';
|
|
3
|
+
import { type EventBus, type Hotkey, type Logger } from '../utils';
|
|
4
|
+
import type { PluginContextApiAssembler, PluginMeta, Plugins } from './plugins';
|
|
4
5
|
export interface PluginContextOptions {
|
|
5
6
|
pluginName: string;
|
|
6
7
|
meta?: PluginMeta;
|
|
7
8
|
}
|
|
8
9
|
export declare class PluginContext {
|
|
9
|
-
editor: Editor;
|
|
10
|
-
simulator: Simulator;
|
|
11
|
-
designer: Designer;
|
|
12
10
|
project: Project;
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
event:
|
|
11
|
+
plugins: Plugins;
|
|
12
|
+
setters: Setters;
|
|
13
|
+
materials: Materials;
|
|
14
|
+
event: Event;
|
|
17
15
|
pluginEvent: EventBus;
|
|
18
16
|
hotkey: Hotkey;
|
|
17
|
+
config: Config;
|
|
18
|
+
logger: Logger;
|
|
19
19
|
constructor(options: PluginContextOptions, contextApiAssembler: PluginContextApiAssembler);
|
|
20
20
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ComponentMeta,
|
|
1
|
+
import type { ComponentMeta, Designer, Detecting, Document, Dragon, DropLocation, History, Materials, Node, NodeChildren, OffsetObserver, Project, Prop, Props, Selection, Setters, Simulator, Viewport } from '..';
|
|
2
2
|
export interface PluginExtend {
|
|
3
3
|
extendClass: PluginExtendClass;
|
|
4
4
|
extend: <T extends keyof PluginExtendClass>(extendClass: T, properties: Record<PropertyKey, () => any> | (PropertyDescriptorMap & ThisType<InstanceType<PluginExtendClass[T]>>)) => void;
|
|
@@ -19,8 +19,8 @@ export interface PluginExtendClass {
|
|
|
19
19
|
NodeChildren: typeof NodeChildren;
|
|
20
20
|
Props: typeof Props;
|
|
21
21
|
Prop: typeof Prop;
|
|
22
|
-
|
|
23
|
-
|
|
22
|
+
Materials: typeof Materials;
|
|
23
|
+
Setters: typeof Setters;
|
|
24
24
|
ComponentMeta: typeof ComponentMeta;
|
|
25
25
|
}
|
|
26
26
|
/**
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type Logger } from '../utils';
|
|
2
2
|
import type { PluginExtend } from './plugin-extend';
|
|
3
|
-
import type { Plugin,
|
|
3
|
+
import type { Plugin, PluginMeta, Plugins } from './plugins';
|
|
4
4
|
export declare class PluginRuntime {
|
|
5
5
|
config: Plugin;
|
|
6
6
|
logger: Logger;
|
|
@@ -14,7 +14,7 @@ export declare class PluginRuntime {
|
|
|
14
14
|
*/
|
|
15
15
|
private _disabled;
|
|
16
16
|
get ctx(): import("./plugin-context").PluginContext;
|
|
17
|
-
constructor(pluginName: string, manager:
|
|
17
|
+
constructor(pluginName: string, manager: Plugins, config: Plugin);
|
|
18
18
|
get name(): string;
|
|
19
19
|
get deps(): string[];
|
|
20
20
|
get disabled(): boolean;
|
|
@@ -25,4 +25,5 @@ export declare class PluginRuntime {
|
|
|
25
25
|
extend(pluginExtend: PluginExtend): Promise<void>;
|
|
26
26
|
setDisabled(flag?: boolean): void;
|
|
27
27
|
dispose(): Promise<void>;
|
|
28
|
+
toProxy(): this;
|
|
28
29
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { PluginContextOptions } from './plugin-context';
|
|
2
|
-
import { type PluginExtend } from './plugin-extend';
|
|
3
2
|
import { PluginContext } from './plugin-context';
|
|
3
|
+
import { type PluginExtend } from './plugin-extend';
|
|
4
4
|
import { PluginRuntime } from './plugin-runtime';
|
|
5
5
|
export interface Plugin {
|
|
6
6
|
name: string;
|
|
@@ -9,6 +9,7 @@ export interface Plugin {
|
|
|
9
9
|
init(ctx: PluginContext): Promise<void> | void;
|
|
10
10
|
destroy?(ctx: PluginContext): Promise<void> | void;
|
|
11
11
|
extend?(ctx: PluginExtend): void;
|
|
12
|
+
exports?(): Record<string, any>;
|
|
12
13
|
}
|
|
13
14
|
export interface PluginMeta {
|
|
14
15
|
/**
|
|
@@ -39,7 +40,7 @@ export interface PluginRegisterOptions {
|
|
|
39
40
|
export interface PluginContextApiAssembler {
|
|
40
41
|
assembleApis(context: PluginContext, pluginName: string, meta: PluginMeta): void;
|
|
41
42
|
}
|
|
42
|
-
export declare class
|
|
43
|
+
export declare class Plugins {
|
|
43
44
|
private plugins;
|
|
44
45
|
pluginsMap: Map<string, PluginRuntime>;
|
|
45
46
|
pluginContextMap: Map<string, PluginContext>;
|
|
@@ -74,5 +75,6 @@ export declare class PluginManager {
|
|
|
74
75
|
* reset plugin manager
|
|
75
76
|
*/
|
|
76
77
|
dispose(): Promise<void>;
|
|
78
|
+
toProxy(): this;
|
|
77
79
|
}
|
|
78
80
|
export declare const isRegisterOptions: (opts: any) => opts is PluginRegisterOptions;
|
|
@@ -2,7 +2,7 @@ type Tasks = Record<string, {
|
|
|
2
2
|
name: string;
|
|
3
3
|
deps: string[];
|
|
4
4
|
}>;
|
|
5
|
-
export declare
|
|
5
|
+
export declare const sequence: ({ tasks, names, results, missing, recursive, nest, parentName, }: {
|
|
6
6
|
tasks: Tasks;
|
|
7
7
|
names: string[];
|
|
8
8
|
results: string[];
|
|
@@ -10,8 +10,8 @@ export declare function sequence({ tasks, names, results, missing, recursive, ne
|
|
|
10
10
|
recursive: string[][];
|
|
11
11
|
nest: string[];
|
|
12
12
|
parentName: string;
|
|
13
|
-
})
|
|
14
|
-
export
|
|
13
|
+
}) => void;
|
|
14
|
+
export declare const sequencify: (tasks: Tasks, names: string[]) => {
|
|
15
15
|
sequence: string[];
|
|
16
16
|
missingTasks: string[];
|
|
17
17
|
recursiveDependencies: string[][];
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import type { Designer } from '../designer';
|
|
2
|
-
import type { Simulator } from '../simulator';
|
|
3
|
-
import type { ProjectSchema, RootSchema } from '../types';
|
|
4
2
|
import { Document } from '../document';
|
|
5
|
-
import {
|
|
3
|
+
import type { Simulator } from '../simulator';
|
|
4
|
+
import { type ProjectSchema, type RootSchema, TRANSFORM_STAGE } from '../types';
|
|
6
5
|
export declare enum PROJECT_EVENT {
|
|
7
6
|
RENDERER_READY = "renderer:ready",
|
|
8
7
|
SIMULATOR_READY = "simulator:ready"
|
|
@@ -31,7 +30,7 @@ export declare class Project {
|
|
|
31
30
|
load(schema?: ProjectSchema, autoOpen?: boolean | string): void;
|
|
32
31
|
unload(): void;
|
|
33
32
|
createDocument(schema?: RootSchema): Document;
|
|
34
|
-
removeDocument(idOrDoc: string | Document):
|
|
33
|
+
removeDocument(idOrDoc: string | Document): any;
|
|
35
34
|
getDocument(id: string): Document | undefined;
|
|
36
35
|
getDocumentByFileName(fileName: string): Document | undefined;
|
|
37
36
|
/**
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './setters';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { Node } from '..';
|
|
2
|
-
import type {
|
|
1
|
+
import type { Component, Node } from '..';
|
|
2
|
+
import type { SettingField } from '../designer';
|
|
3
3
|
/**
|
|
4
4
|
* for setter component props
|
|
5
5
|
*/
|
|
@@ -20,16 +20,19 @@ export interface Setter {
|
|
|
20
20
|
interface RegisterSetterOption {
|
|
21
21
|
overwrite?: boolean;
|
|
22
22
|
}
|
|
23
|
-
export declare class
|
|
24
|
-
|
|
25
|
-
get settersMap(): Map<string, Setter & {
|
|
23
|
+
export declare class Setters {
|
|
24
|
+
settersMap: Map<string, Setter & {
|
|
26
25
|
type: string;
|
|
27
26
|
}>;
|
|
28
27
|
getSetter(type: string): (Setter & {
|
|
29
28
|
type: string;
|
|
30
29
|
}) | undefined;
|
|
31
|
-
|
|
32
|
-
|
|
30
|
+
getSettersMap: () => Map<string, Setter & {
|
|
31
|
+
type: string;
|
|
32
|
+
}>;
|
|
33
|
+
registerSetter(typeOrMaps: string | {
|
|
34
|
+
[key: string]: Component | Setter;
|
|
35
|
+
}, setter?: Component | Setter, option?: RegisterSetterOption): void;
|
|
33
36
|
createSetterContent: (setter: any, props: Record<string, any>) => Component;
|
|
34
37
|
}
|
|
35
38
|
export {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { Node } from '..';
|
|
2
|
-
import type {
|
|
1
|
+
import type { Component, ComponentInstance, Node } from '..';
|
|
2
|
+
import type { NodeInstance } from '../designer';
|
|
3
3
|
export interface SimulatorRenderer {
|
|
4
4
|
readonly isSimulatorRenderer: true;
|
|
5
5
|
/**
|
|
@@ -22,6 +22,10 @@ export interface SimulatorRenderer {
|
|
|
22
22
|
* 获取最近的节点实例
|
|
23
23
|
*/
|
|
24
24
|
getClosestNodeInstance(from: ComponentInstance, nodeId?: string): NodeInstance<ComponentInstance, Node> | null;
|
|
25
|
+
/**
|
|
26
|
+
* 获取组件的 DOM 节点
|
|
27
|
+
*/
|
|
28
|
+
findDOMNodes(instance: ComponentInstance): Array<Element | Text> | null;
|
|
25
29
|
/**
|
|
26
30
|
* 获取元素的 Rect 信息
|
|
27
31
|
*/
|
|
@@ -39,3 +43,4 @@ export interface SimulatorRenderer {
|
|
|
39
43
|
*/
|
|
40
44
|
run(): void;
|
|
41
45
|
}
|
|
46
|
+
export declare const isSimulatorRenderer: (obj: any) => obj is SimulatorRenderer;
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import type { IReactionDisposer, IReactionOptions, IReactionPublic } from 'mobx';
|
|
2
|
-
import type {
|
|
3
|
-
import type {
|
|
2
|
+
import type { Designer, LocateEvent, NodeInstance } from '../designer';
|
|
3
|
+
import type { Scroller } from '../designer/scroller';
|
|
4
|
+
import { type Node } from '../document';
|
|
4
5
|
import type { Project } from '../project';
|
|
6
|
+
import type { ComponentInstance, DataSourceEngine, Snippet } from '../types';
|
|
5
7
|
import type { SimulatorRenderer } from './simulator-renderer';
|
|
6
8
|
import { Viewport } from './viewport';
|
|
7
9
|
export interface DropContainer {
|
|
@@ -14,7 +16,7 @@ export interface SimulatorProps {
|
|
|
14
16
|
designMode?: DesignMode;
|
|
15
17
|
device?: Device;
|
|
16
18
|
deviceClassName?: string;
|
|
17
|
-
|
|
19
|
+
dataSourceEngine?: DataSourceEngine;
|
|
18
20
|
[key: string]: any;
|
|
19
21
|
}
|
|
20
22
|
export interface DeviceStyleProps {
|
|
@@ -28,16 +30,20 @@ export declare class Simulator {
|
|
|
28
30
|
readonly project: Project;
|
|
29
31
|
readonly designer: Designer;
|
|
30
32
|
readonly viewport: Viewport;
|
|
33
|
+
readonly scroller: Scroller;
|
|
31
34
|
iframe?: HTMLElement;
|
|
32
35
|
autoRender: boolean;
|
|
33
36
|
get editor(): import("..").Editor;
|
|
37
|
+
get renderEnv(): string;
|
|
34
38
|
get device(): string;
|
|
35
|
-
get
|
|
39
|
+
get locale(): string;
|
|
40
|
+
get deviceClassName(): string | undefined;
|
|
41
|
+
get designMode(): DesignMode;
|
|
42
|
+
get dataSourceEngine(): DataSourceEngine | undefined;
|
|
36
43
|
get enableStrictNotFoundMode(): any;
|
|
37
44
|
get excuteLifeCycleInDesignMode(): any;
|
|
38
45
|
get notFoundComponent(): any;
|
|
39
46
|
get faultComponent(): any;
|
|
40
|
-
get designMode(): DesignMode;
|
|
41
47
|
get deviceStyle(): DeviceStyleProps | undefined;
|
|
42
48
|
get componentsMap(): {
|
|
43
49
|
[key: string]: any;
|
|
@@ -47,11 +53,7 @@ export declare class Simulator {
|
|
|
47
53
|
get contentWindow(): Window | undefined;
|
|
48
54
|
private accessor _contentDocument;
|
|
49
55
|
get contentDocument(): Document | undefined;
|
|
50
|
-
private accessor
|
|
51
|
-
/**
|
|
52
|
-
* material to component map
|
|
53
|
-
*/
|
|
54
|
-
get components(): Record<string, any>;
|
|
56
|
+
private accessor _appHelper;
|
|
55
57
|
private accessor instancesMap;
|
|
56
58
|
private _sensorAvailable;
|
|
57
59
|
get sensorAvailable(): boolean;
|
|
@@ -59,7 +61,7 @@ export declare class Simulator {
|
|
|
59
61
|
get renderer(): SimulatorRenderer | undefined;
|
|
60
62
|
private sensing;
|
|
61
63
|
get currentDocument(): import("..").Document | undefined;
|
|
62
|
-
constructor(designer: Designer);
|
|
64
|
+
constructor(project: Project, designer: Designer);
|
|
63
65
|
setProps(props: SimulatorProps): void;
|
|
64
66
|
set(key: string, value: any): void;
|
|
65
67
|
get(key: string): any;
|
|
@@ -72,22 +74,21 @@ export declare class Simulator {
|
|
|
72
74
|
*/
|
|
73
75
|
rerender(): void;
|
|
74
76
|
mountContentFrame(iframe: HTMLIFrameElement | HTMLElement | null): void;
|
|
75
|
-
getComponent(componentName: string): any;
|
|
76
77
|
postEvent(eventName: string, ...data: any[]): void;
|
|
77
78
|
linkSnippet(ref: HTMLElement, snippet: Snippet): () => void;
|
|
78
79
|
setSuspense(suspended: boolean): boolean;
|
|
79
80
|
setupEvents(): void;
|
|
80
81
|
setupDragAndClick(): void;
|
|
81
82
|
setupDetecting(): void;
|
|
82
|
-
buildComponentMap(components: Record<string, Component>): void;
|
|
83
|
-
addComponent(name: string, component: Component, override?: boolean): void;
|
|
84
83
|
setInstance(docId: string, id: string, instances: ComponentInstance[] | null): void;
|
|
85
84
|
getInstance(docId: string, id: string): any;
|
|
86
85
|
getComponentInstances(node: Node, context?: NodeInstance<ComponentInstance, Node>): ComponentInstance | null;
|
|
87
86
|
getClosestNodeInstance(from: ComponentInstance, specId?: string): NodeInstance<ComponentInstance> | null;
|
|
88
87
|
computeRect(node: Node): DOMRect | null | undefined;
|
|
89
88
|
computeComponentInstanceRect(instance: ComponentInstance, selector?: string): DOMRect | undefined;
|
|
89
|
+
findDOMNodes(instance: ComponentInstance, selector?: string): Array<Element | Text> | null;
|
|
90
90
|
getNodeInstanceFromElement(target: Element | null): NodeInstance<ComponentInstance, Node> | null;
|
|
91
|
+
scrollToNode(node: Node, detail?: any): void;
|
|
91
92
|
/**
|
|
92
93
|
* fix event's prop, canvasX、canvasY and target
|
|
93
94
|
*/
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { type Designer, type Point } from '../designer';
|
|
2
|
+
import { ScrollTarget } from '../designer/scroller';
|
|
2
3
|
export type AutoFit = '100%';
|
|
3
4
|
export declare const AutoFit: AutoFit;
|
|
4
5
|
export declare class Viewport {
|
|
@@ -24,6 +25,18 @@ export declare class Viewport {
|
|
|
24
25
|
set contentHeight(newContentHeight: number | AutoFit);
|
|
25
26
|
get contentWidth(): number | AutoFit;
|
|
26
27
|
set contentWidth(val: number | AutoFit);
|
|
28
|
+
private accessor _scrollX;
|
|
29
|
+
private accessor _scrollY;
|
|
30
|
+
get scrollX(): number;
|
|
31
|
+
get scrollY(): number;
|
|
32
|
+
private _scrollTarget?;
|
|
33
|
+
/**
|
|
34
|
+
* 滚动对象
|
|
35
|
+
*/
|
|
36
|
+
get scrollTarget(): ScrollTarget | undefined;
|
|
37
|
+
private accessor _scrolling;
|
|
38
|
+
get scrolling(): boolean;
|
|
39
|
+
setScrollTarget(target: Window): void;
|
|
27
40
|
toGlobalPoint(point: Point): Point;
|
|
28
41
|
toLocalPoint(point: Point): Point;
|
|
29
42
|
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export type ComponentInstance = any;
|
|
2
|
+
export type ComponentType<T = any> = any;
|
|
3
|
+
/**
|
|
4
|
+
* component type
|
|
5
|
+
*/
|
|
6
|
+
export type Component = ComponentType<any> | object;
|
|
7
|
+
export interface LowCodeComponent {
|
|
8
|
+
/**
|
|
9
|
+
* 研发模式
|
|
10
|
+
*/
|
|
11
|
+
devMode: 'lowCode';
|
|
12
|
+
/**
|
|
13
|
+
* 组件名称
|
|
14
|
+
*/
|
|
15
|
+
componentName: string;
|
|
16
|
+
}
|
|
17
|
+
export interface ProCodeComponent {
|
|
18
|
+
/**
|
|
19
|
+
* 研发模式
|
|
20
|
+
*/
|
|
21
|
+
devMode: 'proCode';
|
|
22
|
+
/**
|
|
23
|
+
* 组件名称
|
|
24
|
+
*/
|
|
25
|
+
componentName: string;
|
|
26
|
+
}
|
|
27
|
+
export type ComponentMap = ProCodeComponent | LowCodeComponent;
|
|
28
|
+
export type ComponentsMap = ComponentMap[];
|
|
@@ -18,3 +18,10 @@ export interface DataSource {
|
|
|
18
18
|
list?: DataSourceItem[];
|
|
19
19
|
dataHandler?: JSExpression;
|
|
20
20
|
}
|
|
21
|
+
export interface DataSourceEngine {
|
|
22
|
+
createDataSourceEngine: (dataSource: DataSource, engine: any) => {
|
|
23
|
+
dataSourceMap: Record<string, any>;
|
|
24
|
+
reloadDataSource: () => Promise<void>;
|
|
25
|
+
};
|
|
26
|
+
[key: string]: any;
|
|
27
|
+
}
|
|
@@ -1,48 +1,38 @@
|
|
|
1
|
-
import type
|
|
2
|
-
import type { Plugin } from '
|
|
3
|
-
import type {
|
|
4
|
-
import type {
|
|
5
|
-
import { type DesignerProps } from './designer';
|
|
6
|
-
import { PluginManager } from './plugin';
|
|
7
|
-
import { type HotkeyConfig } from './utils';
|
|
1
|
+
import type EventEmitter from 'events';
|
|
2
|
+
import type { Plugin, Plugins } from '../plugin';
|
|
3
|
+
import type { EventBus } from '../utils';
|
|
4
|
+
import type { Component } from './component';
|
|
8
5
|
export type EditorValueKey = string | symbol;
|
|
9
6
|
export type EditorGetResult<T, ClsType> = T extends undefined ? ClsType extends {
|
|
10
7
|
prototype: infer R;
|
|
11
8
|
} ? R : any : T;
|
|
12
9
|
export interface EditorConfig {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
* 设置器 Setter
|
|
19
|
-
*/
|
|
20
|
-
setters?: Record<string, Component | Setter>;
|
|
21
|
-
/**
|
|
22
|
-
* 组件 Component
|
|
23
|
-
*/
|
|
24
|
-
components?: Record<string, Component>;
|
|
25
|
-
/**
|
|
26
|
-
* 组件元数据 ComponentMetadata
|
|
27
|
-
*/
|
|
28
|
-
componentMetas?: Record<string, ComponentMetadata>;
|
|
29
|
-
/**
|
|
30
|
-
* 生命周期
|
|
31
|
-
*/
|
|
10
|
+
plugins?: PluginConfig;
|
|
11
|
+
hooks?: HooksConfig;
|
|
12
|
+
shortCuts?: ShortCutsConfig;
|
|
13
|
+
utils?: UtilsConfig;
|
|
14
|
+
constants?: ConstantsConfig;
|
|
32
15
|
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
16
|
}
|
|
17
|
+
export type PluginConfig = Plugin[];
|
|
18
|
+
export type HooksConfig = HookConfig[];
|
|
19
|
+
export interface HookConfig {
|
|
20
|
+
message: string;
|
|
21
|
+
type: 'on' | 'once';
|
|
22
|
+
handler: (this: Editor, editor: Editor, ...args: any[]) => void;
|
|
23
|
+
}
|
|
24
|
+
export type ShortCutsConfig = ShortCutConfig[];
|
|
25
|
+
export interface ShortCutConfig {
|
|
26
|
+
keyboard: string;
|
|
27
|
+
handler: (editor: Editor, ev: Event, keymaster: any) => void;
|
|
28
|
+
}
|
|
29
|
+
export type UtilsConfig = UtilConfig[];
|
|
30
|
+
export interface UtilConfig {
|
|
31
|
+
name: string;
|
|
32
|
+
type: 'function';
|
|
33
|
+
content: (...args: []) => any;
|
|
34
|
+
}
|
|
35
|
+
export type ConstantsConfig = Record<string, unknown>;
|
|
46
36
|
export interface LifeCyclesConfig {
|
|
47
37
|
init?: (editor: Editor) => any;
|
|
48
38
|
destroy?: (editor: Editor) => any;
|
|
@@ -55,12 +45,10 @@ export declare enum EDITOR_EVENT {
|
|
|
55
45
|
BEFORE_EXTEND = "editor:beforeExtend",
|
|
56
46
|
AFTER_EXTEND = "editor:afterExtend"
|
|
57
47
|
}
|
|
58
|
-
export
|
|
59
|
-
private accessor context;
|
|
48
|
+
export interface Editor extends EventEmitter {
|
|
60
49
|
config?: EditorConfig;
|
|
61
|
-
eventBus:
|
|
62
|
-
|
|
63
|
-
constructor(config?: EditorConfig);
|
|
50
|
+
eventBus: EventBus;
|
|
51
|
+
components?: Record<string, Component>;
|
|
64
52
|
get<T = undefined, KeyOrType extends EditorValueKey = any>(keyOrType: KeyOrType): EditorGetResult<T, KeyOrType> | undefined;
|
|
65
53
|
has(keyOrType: EditorValueKey): boolean;
|
|
66
54
|
set(key: EditorValueKey, data: any): void | Promise<void>;
|
|
@@ -76,19 +64,12 @@ export declare class Editor {
|
|
|
76
64
|
* listen value when value is changed
|
|
77
65
|
*/
|
|
78
66
|
onChange<T = undefined, KeyOrType extends EditorValueKey = any>(keyOrType: KeyOrType, fn: (data: EditorGetResult<T, KeyOrType>) => void): () => void;
|
|
79
|
-
|
|
67
|
+
extend(pluginManager: Plugins): Promise<void>;
|
|
68
|
+
init(config?: EditorConfig, components?: Editor['components']): Promise<void>;
|
|
80
69
|
destroy(): void;
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
* notify all listeners when value is got
|
|
84
|
-
*/
|
|
85
|
-
private notifyGot;
|
|
86
|
-
private setWait;
|
|
87
|
-
private delWait;
|
|
70
|
+
onBeforeExtend(listener: (editor: Editor) => void): () => void;
|
|
71
|
+
onAfterExtend(listener: (editor: Editor) => void): () => void;
|
|
88
72
|
onBeforeInit(listener: (editor: Editor) => void): () => void;
|
|
89
73
|
onAfterInit(listener: (editor: Editor) => void): () => void;
|
|
90
74
|
onDestroy(listener: (editor: Editor) => void): () => void;
|
|
91
|
-
onBeforeExtend(listener: (editor: Editor) => void): () => void;
|
|
92
|
-
onAfterExtend(listener: (editor: Editor) => void): () => void;
|
|
93
75
|
}
|
|
94
|
-
export declare const createEasyEditor: (config?: EditorConfig) => Editor;
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type {
|
|
3
|
-
import type {
|
|
1
|
+
import type { SettingField } from '../designer';
|
|
2
|
+
import type { Node, PropKey } from '../document';
|
|
3
|
+
import type { ComponentType } from './component';
|
|
4
|
+
import type { NodeSchema } from './schema';
|
|
5
|
+
import type { DynamicSetter, SetterType } from './setter';
|
|
4
6
|
export interface ComponentMetadata {
|
|
5
7
|
componentName: string;
|
|
6
8
|
title?: string;
|
|
@@ -189,8 +191,7 @@ export interface Advanced {
|
|
|
189
191
|
*/
|
|
190
192
|
initialChildren?: NodeSchema[] | ((target: Node) => NodeSchema[]);
|
|
191
193
|
/**
|
|
192
|
-
*
|
|
193
|
-
* @experimental not in spec yet
|
|
194
|
+
* 物料组件
|
|
194
195
|
*/
|
|
195
196
|
view?: ComponentType<any>;
|
|
196
197
|
}
|
|
@@ -222,58 +223,3 @@ export interface Callbacks {
|
|
|
222
223
|
deltaY?: number;
|
|
223
224
|
}, currentNode: Node) => void;
|
|
224
225
|
}
|
|
225
|
-
export type SetterType = SetterConfig | string;
|
|
226
|
-
export type DynamicSetterProps = (target: SettingField) => Record<string, unknown>;
|
|
227
|
-
export interface SetterConfig {
|
|
228
|
-
/**
|
|
229
|
-
* the name of the setter
|
|
230
|
-
*/
|
|
231
|
-
componentName: string;
|
|
232
|
-
/**
|
|
233
|
-
* the props pass to Setter Component
|
|
234
|
-
*/
|
|
235
|
-
props?: Record<string, unknown> | DynamicSetterProps;
|
|
236
|
-
/**
|
|
237
|
-
* is required
|
|
238
|
-
*/
|
|
239
|
-
isRequired?: boolean;
|
|
240
|
-
/**
|
|
241
|
-
* Setter initial value
|
|
242
|
-
*/
|
|
243
|
-
/**
|
|
244
|
-
* Setter default value
|
|
245
|
-
*/
|
|
246
|
-
defaultValue?: any;
|
|
247
|
-
}
|
|
248
|
-
export declare const isSetterConfig: (obj: any) => obj is SetterConfig;
|
|
249
|
-
export type DynamicSetter = (target: SettingPropEntry) => string | SetterConfig | Component;
|
|
250
|
-
export type ComponentInstance = any;
|
|
251
|
-
export type ComponentType<T> = any;
|
|
252
|
-
/**
|
|
253
|
-
* component type
|
|
254
|
-
*/
|
|
255
|
-
export type Component = ComponentType<any> | object;
|
|
256
|
-
export interface LowCodeComponent {
|
|
257
|
-
/**
|
|
258
|
-
* 研发模式
|
|
259
|
-
*/
|
|
260
|
-
devMode: 'lowCode';
|
|
261
|
-
/**
|
|
262
|
-
* 组件名称
|
|
263
|
-
*/
|
|
264
|
-
componentName: string;
|
|
265
|
-
}
|
|
266
|
-
export interface ProCodeComponent {
|
|
267
|
-
/**
|
|
268
|
-
* 研发模式
|
|
269
|
-
*/
|
|
270
|
-
devMode: 'proCode';
|
|
271
|
-
/**
|
|
272
|
-
* 组件名称
|
|
273
|
-
*/
|
|
274
|
-
componentName: string;
|
|
275
|
-
}
|
|
276
|
-
export type ComponentMap = ProCodeComponent | LowCodeComponent;
|
|
277
|
-
export type ComponentsMap = ComponentMap[];
|
|
278
|
-
export declare function isProCodeComponentType(desc: ComponentMap): desc is ProCodeComponent;
|
|
279
|
-
export declare function isLowCodeComponentType(desc: ComponentMap): desc is LowCodeComponent;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { SettingField, SettingPropEntry } from '../designer';
|
|
2
|
+
import type { Component } from './component';
|
|
3
|
+
export type SetterType = SetterConfig | string;
|
|
4
|
+
export type DynamicSetterProps = (target: SettingField) => Record<string, unknown>;
|
|
5
|
+
export interface SetterConfig {
|
|
6
|
+
/**
|
|
7
|
+
* the name of the setter
|
|
8
|
+
*/
|
|
9
|
+
componentName: string;
|
|
10
|
+
/**
|
|
11
|
+
* the props pass to Setter Component
|
|
12
|
+
*/
|
|
13
|
+
props?: Record<string, unknown> | DynamicSetterProps;
|
|
14
|
+
/**
|
|
15
|
+
* is required
|
|
16
|
+
*/
|
|
17
|
+
isRequired?: boolean;
|
|
18
|
+
/**
|
|
19
|
+
* Setter initial value
|
|
20
|
+
*/
|
|
21
|
+
/**
|
|
22
|
+
* Setter default value
|
|
23
|
+
*/
|
|
24
|
+
defaultValue?: any;
|
|
25
|
+
}
|
|
26
|
+
export type DynamicSetter = (target: SettingPropEntry) => string | SetterConfig | Component;
|