@tmagic/editor 1.4.16 → 1.5.0-beta.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/dist/style.css +11 -7
- package/dist/tmagic-editor.js +434 -411
- package/dist/tmagic-editor.umd.cjs +441 -408
- package/package.json +11 -15
- package/src/components/CodeParams.vue +1 -1
- package/src/editorProps.ts +2 -1
- package/src/fields/DataSourceInput.vue +2 -2
- package/src/fields/UISelect.vue +20 -15
- package/src/hooks/index.ts +7 -0
- package/src/hooks/use-stage.ts +13 -7
- package/src/index.ts +2 -0
- package/src/initService.ts +50 -53
- package/src/layouts/sidebar/Sidebar.vue +18 -2
- package/src/layouts/sidebar/data-source/DataSourceListPanel.vue +12 -14
- package/src/layouts/workspace/viewer/NodeListMenu.vue +2 -1
- package/src/layouts/workspace/viewer/Stage.vue +4 -3
- package/src/services/editor.ts +2 -2
- package/src/services/stageOverlay.ts +3 -1
- package/src/theme/data-source.scss +8 -5
- package/src/theme/page-bar.scss +2 -2
- package/src/utils/data-source/index.ts +25 -23
- package/src/utils/editor.ts +4 -3
- package/src/utils/index.ts +4 -0
- package/src/utils/operator.ts +3 -2
- package/src/utils/props.ts +2 -1
- package/types/index.d.ts +6685 -49
- package/src/shims-vue.d.ts +0 -6
- package/types/Editor.vue.d.ts +0 -2313
- package/types/components/CodeBlockEditor.vue.d.ts +0 -33
- package/types/components/CodeParams.vue.d.ts +0 -28
- package/types/components/ContentMenu.vue.d.ts +0 -81
- package/types/components/FloatingBox.vue.d.ts +0 -70
- package/types/components/Icon.vue.d.ts +0 -15
- package/types/components/Resizer.vue.d.ts +0 -16
- package/types/components/ScrollBar.vue.d.ts +0 -25
- package/types/components/ScrollViewer.vue.d.ts +0 -81
- package/types/components/SearchInput.vue.d.ts +0 -6
- package/types/components/SplitView.vue.d.ts +0 -72
- package/types/components/ToolButton.vue.d.ts +0 -41
- package/types/components/Tree.vue.d.ts +0 -83
- package/types/components/TreeNode.vue.d.ts +0 -83
- package/types/editorProps.d.ts +0 -111
- package/types/fields/Code.vue.d.ts +0 -44
- package/types/fields/CodeLink.vue.d.ts +0 -24
- package/types/fields/CodeSelect.vue.d.ts +0 -28
- package/types/fields/CodeSelectCol.vue.d.ts +0 -31
- package/types/fields/CondOpSelect.vue.d.ts +0 -17
- package/types/fields/DataSourceFieldSelect/FieldSelect.vue.d.ts +0 -36
- package/types/fields/DataSourceFieldSelect/Index.vue.d.ts +0 -31
- package/types/fields/DataSourceFields.vue.d.ts +0 -44
- package/types/fields/DataSourceInput.vue.d.ts +0 -34
- package/types/fields/DataSourceMethodSelect.vue.d.ts +0 -31
- package/types/fields/DataSourceMethods.vue.d.ts +0 -34
- package/types/fields/DataSourceMocks.vue.d.ts +0 -41
- package/types/fields/DataSourceSelect.vue.d.ts +0 -31
- package/types/fields/DisplayConds.vue.d.ts +0 -37
- package/types/fields/EventSelect.vue.d.ts +0 -17
- package/types/fields/KeyValue.vue.d.ts +0 -36
- package/types/fields/PageFragmentSelect.vue.d.ts +0 -31
- package/types/fields/UISelect.vue.d.ts +0 -20
- package/types/hooks/index.d.ts +0 -6
- package/types/hooks/use-code-block-edit.d.ts +0 -189
- package/types/hooks/use-data-source-edit.d.ts +0 -176
- package/types/hooks/use-data-source-method.d.ts +0 -187
- package/types/hooks/use-editor-content-height.d.ts +0 -3
- package/types/hooks/use-filter.d.ts +0 -7
- package/types/hooks/use-float-box.d.ts +0 -17
- package/types/hooks/use-getso.d.ts +0 -5
- package/types/hooks/use-next-float-box-position.d.ts +0 -15
- package/types/hooks/use-node-status.d.ts +0 -16
- package/types/hooks/use-stage.d.ts +0 -3
- package/types/hooks/use-window-rect.d.ts +0 -6
- package/types/icons/AppManageIcon.vue.d.ts +0 -2
- package/types/icons/CenterIcon.vue.d.ts +0 -2
- package/types/icons/CodeIcon.vue.d.ts +0 -2
- package/types/icons/FolderMinusIcon.vue.d.ts +0 -2
- package/types/icons/PinIcon.vue.d.ts +0 -2
- package/types/icons/PinnedIcon.vue.d.ts +0 -2
- package/types/initService.d.ts +0 -9
- package/types/layouts/AddPageBox.vue.d.ts +0 -15
- package/types/layouts/CodeEditor.vue.d.ts +0 -80
- package/types/layouts/Framework.vue.d.ts +0 -25
- package/types/layouts/NavMenu.vue.d.ts +0 -35
- package/types/layouts/PropsPanel.vue.d.ts +0 -535
- package/types/layouts/page-bar/AddButton.vue.d.ts +0 -16
- package/types/layouts/page-bar/PageBar.vue.d.ts +0 -36
- package/types/layouts/page-bar/PageBarScrollContainer.vue.d.ts +0 -29
- package/types/layouts/page-bar/PageList.vue.d.ts +0 -27
- package/types/layouts/page-bar/SwitchTypeButton.vue.d.ts +0 -20
- package/types/layouts/sidebar/ComponentListPanel.vue.d.ts +0 -10
- package/types/layouts/sidebar/Sidebar.vue.d.ts +0 -51
- package/types/layouts/sidebar/code-block/CodeBlockList.vue.d.ts +0 -32
- package/types/layouts/sidebar/code-block/CodeBlockListPanel.vue.d.ts +0 -24
- package/types/layouts/sidebar/data-source/DataSourceConfigPanel.vue.d.ts +0 -31
- package/types/layouts/sidebar/data-source/DataSourceList.vue.d.ts +0 -18
- package/types/layouts/sidebar/data-source/DataSourceListPanel.vue.d.ts +0 -10
- package/types/layouts/sidebar/layer/LayerMenu.vue.d.ts +0 -41
- package/types/layouts/sidebar/layer/LayerNodeTool.vue.d.ts +0 -16
- package/types/layouts/sidebar/layer/LayerPanel.vue.d.ts +0 -25
- package/types/layouts/sidebar/layer/use-click.d.ts +0 -119
- package/types/layouts/sidebar/layer/use-drag.d.ts +0 -14
- package/types/layouts/sidebar/layer/use-keybinding.d.ts +0 -6
- package/types/layouts/sidebar/layer/use-node-status.d.ts +0 -16
- package/types/layouts/workspace/Breadcrumb.vue.d.ts +0 -2
- package/types/layouts/workspace/Workspace.vue.d.ts +0 -41
- package/types/layouts/workspace/viewer/NodeListMenu.vue.d.ts +0 -2
- package/types/layouts/workspace/viewer/Stage.vue.d.ts +0 -34
- package/types/layouts/workspace/viewer/StageOverlay.vue.d.ts +0 -2
- package/types/layouts/workspace/viewer/ViewerMenu.vue.d.ts +0 -42
- package/types/services/BaseService.d.ts +0 -65
- package/types/services/codeBlock.d.ts +0 -130
- package/types/services/componentList.d.ts +0 -16
- package/types/services/dataSource.d.ts +0 -68
- package/types/services/dep.d.ts +0 -33
- package/types/services/editor.d.ts +0 -180
- package/types/services/events.d.ts +0 -18
- package/types/services/history.d.ts +0 -26
- package/types/services/keybinding.d.ts +0 -40
- package/types/services/props.d.ts +0 -92
- package/types/services/stageOverlay.d.ts +0 -30
- package/types/services/storage.d.ts +0 -65
- package/types/services/ui.d.ts +0 -77
- package/types/type.d.ts +0 -657
- package/types/utils/compose.d.ts +0 -5
- package/types/utils/config.d.ts +0 -4
- package/types/utils/content-menu.d.ts +0 -7
- package/types/utils/data-source/formConfigs/base.d.ts +0 -2
- package/types/utils/data-source/formConfigs/http.d.ts +0 -3
- package/types/utils/data-source/index.d.ts +0 -10
- package/types/utils/editor.d.ts +0 -59
- package/types/utils/idle-task.d.ts +0 -13
- package/types/utils/index.d.ts +0 -6
- package/types/utils/keybinding-config.d.ts +0 -7
- package/types/utils/logger.d.ts +0 -5
- package/types/utils/monaco-editor.d.ts +0 -2
- package/types/utils/operator.d.ts +0 -21
- package/types/utils/props.d.ts +0 -23
- package/types/utils/scroll-viewer.d.ts +0 -37
- package/types/utils/tree.d.ts +0 -3
- package/types/utils/undo-redo.d.ts +0 -12
|
@@ -1,130 +0,0 @@
|
|
|
1
|
-
import type { Writable } from 'type-fest';
|
|
2
|
-
import { type TargetOptions } from '@tmagic/dep';
|
|
3
|
-
import type { ColumnConfig } from '@tmagic/form';
|
|
4
|
-
import type { CodeBlockContent, CodeBlockDSL, Id, MNode } from '@tmagic/schema';
|
|
5
|
-
import type { AsyncHookPlugin } from '../type';
|
|
6
|
-
import BaseService from './BaseService';
|
|
7
|
-
declare const canUsePluginMethods: {
|
|
8
|
-
async: readonly ["setCodeDslById", "setEditStatus", "setCombineIds", "setUndeleteableList", "deleteCodeDslByIds"];
|
|
9
|
-
sync: string[];
|
|
10
|
-
};
|
|
11
|
-
type AsyncMethodName = Writable<(typeof canUsePluginMethods)['async']>;
|
|
12
|
-
declare class CodeBlock extends BaseService {
|
|
13
|
-
private state;
|
|
14
|
-
constructor();
|
|
15
|
-
/**
|
|
16
|
-
* 设置活动的代码块dsl数据源
|
|
17
|
-
* @param {CodeBlockDSL} codeDsl 代码DSL
|
|
18
|
-
* @returns {void}
|
|
19
|
-
*/
|
|
20
|
-
setCodeDsl(codeDsl: CodeBlockDSL): Promise<void>;
|
|
21
|
-
/**
|
|
22
|
-
* 获取活动的代码块dsl数据源(默认从dsl中的codeBlocks字段读取)
|
|
23
|
-
* 方法要支持钩子添加扩展,会被重写为异步方法,因此这里显示写为异步以提醒调用者需以异步形式调用
|
|
24
|
-
* @param {boolean} forceRefresh 是否强制从活动dsl拉取刷新
|
|
25
|
-
* @returns {CodeBlockDSL | null}
|
|
26
|
-
*/
|
|
27
|
-
getCodeDsl(): CodeBlockDSL | null;
|
|
28
|
-
/**
|
|
29
|
-
* 根据代码块id获取代码块内容
|
|
30
|
-
* @param {Id} id 代码块id
|
|
31
|
-
* @returns {CodeBlockContent | null}
|
|
32
|
-
*/
|
|
33
|
-
getCodeContentById(id: Id): CodeBlockContent | null;
|
|
34
|
-
/**
|
|
35
|
-
* 设置代码块ID和代码内容到源dsl
|
|
36
|
-
* @param {Id} id 代码块id
|
|
37
|
-
* @param {CodeBlockContent} codeConfig 代码块内容配置信息
|
|
38
|
-
* @returns {void}
|
|
39
|
-
*/
|
|
40
|
-
setCodeDslById(id: Id, codeConfig: Partial<CodeBlockContent>): Promise<void>;
|
|
41
|
-
/**
|
|
42
|
-
* 为了兼容历史原因
|
|
43
|
-
* 设置代码块ID和代码内容到源dsl
|
|
44
|
-
* @param {Id} id 代码块id
|
|
45
|
-
* @param {CodeBlockContent} codeConfig 代码块内容配置信息
|
|
46
|
-
* @param {boolean} force 是否强制写入,默认true
|
|
47
|
-
* @returns {void}
|
|
48
|
-
*/
|
|
49
|
-
setCodeDslByIdSync(id: Id, codeConfig: Partial<CodeBlockContent>, force?: boolean): void;
|
|
50
|
-
/**
|
|
51
|
-
* 根据代码块id数组获取代码dsl
|
|
52
|
-
* @param {string[]} ids 代码块id数组
|
|
53
|
-
* @returns {CodeBlockDSL}
|
|
54
|
-
*/
|
|
55
|
-
getCodeDslByIds(ids: string[]): CodeBlockDSL;
|
|
56
|
-
/**
|
|
57
|
-
* 获取编辑状态
|
|
58
|
-
* @returns {boolean} 是否可编辑
|
|
59
|
-
*/
|
|
60
|
-
getEditStatus(): boolean;
|
|
61
|
-
/**
|
|
62
|
-
* 设置编辑状态
|
|
63
|
-
* @param {boolean} status 是否可编辑
|
|
64
|
-
* @returns {void}
|
|
65
|
-
*/
|
|
66
|
-
setEditStatus(status: boolean): Promise<void>;
|
|
67
|
-
/**
|
|
68
|
-
* 设置当前选中组件已关联绑定的代码块id数组
|
|
69
|
-
* @param {string[]} ids 代码块id数组
|
|
70
|
-
* @returns {void}
|
|
71
|
-
*/
|
|
72
|
-
setCombineIds(ids: string[]): Promise<void>;
|
|
73
|
-
/**
|
|
74
|
-
* 获取当前选中组件已关联绑定的代码块id数组
|
|
75
|
-
* @returns {string[]}
|
|
76
|
-
*/
|
|
77
|
-
getCombineIds(): string[];
|
|
78
|
-
/**
|
|
79
|
-
* 获取不可删除列表
|
|
80
|
-
* @returns {Id[]}
|
|
81
|
-
*/
|
|
82
|
-
getUndeletableList(): Id[];
|
|
83
|
-
/**
|
|
84
|
-
* 设置不可删除列表:为业务逻辑预留的不可删除的代码块列表,由业务逻辑维护(如代码块上线后不可删除)
|
|
85
|
-
* @param {Id[]} codeIds 代码块id数组
|
|
86
|
-
* @returns {void}
|
|
87
|
-
*/
|
|
88
|
-
setUndeleteableList(codeIds: Id[]): Promise<void>;
|
|
89
|
-
/**
|
|
90
|
-
* 设置代码草稿
|
|
91
|
-
*/
|
|
92
|
-
setCodeDraft(codeId: Id, content: string): void;
|
|
93
|
-
/**
|
|
94
|
-
* 获取代码草稿
|
|
95
|
-
*/
|
|
96
|
-
getCodeDraft(codeId: Id): string | null;
|
|
97
|
-
/**
|
|
98
|
-
* 删除代码草稿
|
|
99
|
-
*/
|
|
100
|
-
removeCodeDraft(codeId: Id): void;
|
|
101
|
-
/**
|
|
102
|
-
* 在dsl数据源中删除指定id的代码块
|
|
103
|
-
* @param {Id[]} codeIds 需要删除的代码块id数组
|
|
104
|
-
*/
|
|
105
|
-
deleteCodeDslByIds(codeIds: Id[]): Promise<void>;
|
|
106
|
-
setParamsColConfig(config: ColumnConfig): void;
|
|
107
|
-
getParamsColConfig(): ColumnConfig | undefined;
|
|
108
|
-
/**
|
|
109
|
-
* 生成代码块唯一id
|
|
110
|
-
* @returns {Id} 代码块唯一id
|
|
111
|
-
*/
|
|
112
|
-
getUniqueId(): Promise<string>;
|
|
113
|
-
/**
|
|
114
|
-
* 复制时会带上组件关联的代码块
|
|
115
|
-
* @param config 组件节点配置
|
|
116
|
-
* @returns
|
|
117
|
-
*/
|
|
118
|
-
copyWithRelated(config: MNode | MNode[], collectorOptions?: TargetOptions): void;
|
|
119
|
-
/**
|
|
120
|
-
* 粘贴代码块
|
|
121
|
-
* @returns
|
|
122
|
-
*/
|
|
123
|
-
paste(): void;
|
|
124
|
-
resetState(): void;
|
|
125
|
-
destroy(): void;
|
|
126
|
-
usePlugin(options: AsyncHookPlugin<AsyncMethodName, CodeBlock>): void;
|
|
127
|
-
}
|
|
128
|
-
export type CodeBlockService = CodeBlock;
|
|
129
|
-
declare const _default: CodeBlock;
|
|
130
|
-
export default _default;
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import type { ComponentGroup } from '../type';
|
|
2
|
-
import BaseService from './BaseService';
|
|
3
|
-
declare class ComponentList extends BaseService {
|
|
4
|
-
private state;
|
|
5
|
-
constructor();
|
|
6
|
-
/**
|
|
7
|
-
* @param componentGroupList 组件列表配置
|
|
8
|
-
*/
|
|
9
|
-
setList(componentGroupList: ComponentGroup[]): void;
|
|
10
|
-
getList(): ComponentGroup[];
|
|
11
|
-
resetState(): void;
|
|
12
|
-
destroy(): void;
|
|
13
|
-
}
|
|
14
|
-
export type ComponentListService = ComponentList;
|
|
15
|
-
declare const _default: ComponentList;
|
|
16
|
-
export default _default;
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
import { Writable } from 'type-fest';
|
|
2
|
-
import type { EventOption } from '@tmagic/core';
|
|
3
|
-
import { type TargetOptions } from '@tmagic/dep';
|
|
4
|
-
import type { FormConfig } from '@tmagic/form';
|
|
5
|
-
import type { DataSourceSchema, MNode } from '@tmagic/schema';
|
|
6
|
-
import type { DatasourceTypeOption, SyncHookPlugin } from '../type';
|
|
7
|
-
import BaseService from './BaseService';
|
|
8
|
-
interface State {
|
|
9
|
-
datasourceTypeList: DatasourceTypeOption[];
|
|
10
|
-
dataSources: DataSourceSchema[];
|
|
11
|
-
editable: boolean;
|
|
12
|
-
configs: Record<string, FormConfig>;
|
|
13
|
-
values: Record<string, Partial<DataSourceSchema>>;
|
|
14
|
-
events: Record<string, EventOption[]>;
|
|
15
|
-
methods: Record<string, EventOption[]>;
|
|
16
|
-
}
|
|
17
|
-
type StateKey = keyof State;
|
|
18
|
-
declare const canUsePluginMethods: {
|
|
19
|
-
async: never[];
|
|
20
|
-
sync: readonly ["getFormConfig", "setFormConfig", "getFormValue", "setFormValue", "getFormEvent", "setFormEvent", "getFormMethod", "setFormMethod", "add", "update", "remove", "createId"];
|
|
21
|
-
};
|
|
22
|
-
type SyncMethodName = Writable<(typeof canUsePluginMethods)['sync']>;
|
|
23
|
-
declare class DataSource extends BaseService {
|
|
24
|
-
private state;
|
|
25
|
-
constructor();
|
|
26
|
-
set<K extends StateKey, T extends State[K]>(name: K, value: T): void;
|
|
27
|
-
get<K extends StateKey>(name: K): State[K];
|
|
28
|
-
getFormConfig(type?: string): FormConfig;
|
|
29
|
-
setFormConfig(type: string, config: FormConfig): void;
|
|
30
|
-
getFormValue(type?: string): Partial<DataSourceSchema>;
|
|
31
|
-
setFormValue(type: string, value: Partial<DataSourceSchema>): void;
|
|
32
|
-
getFormEvent(type?: string): EventOption[];
|
|
33
|
-
setFormEvent(type: string, value?: EventOption[]): void;
|
|
34
|
-
getFormMethod(type?: string): EventOption[];
|
|
35
|
-
setFormMethod(type: string, value?: EventOption[]): void;
|
|
36
|
-
add(config: DataSourceSchema): {
|
|
37
|
-
id: string;
|
|
38
|
-
type: string;
|
|
39
|
-
title?: string;
|
|
40
|
-
description?: string;
|
|
41
|
-
fields: import("@tmagic/schema").DataSchema[];
|
|
42
|
-
methods: import("@tmagic/schema").CodeBlockContent[];
|
|
43
|
-
mocks?: import("@tmagic/schema").MockSchema[];
|
|
44
|
-
events: import("@tmagic/schema").EventConfig[];
|
|
45
|
-
disabledInitInJsEngine?: (import("@tmagic/schema").JsEngine | string)[];
|
|
46
|
-
};
|
|
47
|
-
update(config: DataSourceSchema): DataSourceSchema;
|
|
48
|
-
remove(id: string): void;
|
|
49
|
-
createId(): string;
|
|
50
|
-
getDataSourceById(id: string): DataSourceSchema | undefined;
|
|
51
|
-
resetState(): void;
|
|
52
|
-
destroy(): void;
|
|
53
|
-
usePlugin(options: SyncHookPlugin<SyncMethodName, DataSource>): void;
|
|
54
|
-
/**
|
|
55
|
-
* 复制时会带上组件关联的数据源
|
|
56
|
-
* @param config 组件节点配置
|
|
57
|
-
* @returns
|
|
58
|
-
*/
|
|
59
|
-
copyWithRelated(config: MNode | MNode[], collectorOptions?: TargetOptions): void;
|
|
60
|
-
/**
|
|
61
|
-
* 粘贴数据源
|
|
62
|
-
* @returns
|
|
63
|
-
*/
|
|
64
|
-
paste(): void;
|
|
65
|
-
}
|
|
66
|
-
export type DataSourceService = DataSource;
|
|
67
|
-
declare const _default: DataSource;
|
|
68
|
-
export default _default;
|
package/types/services/dep.d.ts
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { type DepExtendedData, DepTargetType, type Target } from '@tmagic/dep';
|
|
2
|
-
import type { Id, MNode } from '@tmagic/schema';
|
|
3
|
-
import BaseService from './BaseService';
|
|
4
|
-
export interface DepEvents {
|
|
5
|
-
'add-target': [target: Target];
|
|
6
|
-
'remove-target': [id: string | number];
|
|
7
|
-
collected: [nodes: MNode[], deep: boolean];
|
|
8
|
-
}
|
|
9
|
-
declare class Dep extends BaseService {
|
|
10
|
-
private watcher;
|
|
11
|
-
removeTargets(type?: string): void;
|
|
12
|
-
getTargets(type?: string): {
|
|
13
|
-
[targetId: string]: Target;
|
|
14
|
-
[targetId: number]: Target;
|
|
15
|
-
};
|
|
16
|
-
getTarget(id: Id, type?: string): Target;
|
|
17
|
-
addTarget(target: Target): void;
|
|
18
|
-
removeTarget(id: Id, type?: string): void;
|
|
19
|
-
clearTargets(): void;
|
|
20
|
-
collect(nodes: MNode[], depExtendedData?: DepExtendedData, deep?: boolean, type?: DepTargetType): void;
|
|
21
|
-
collectIdle(nodes: MNode[], depExtendedData?: DepExtendedData, deep?: boolean, type?: DepTargetType): void;
|
|
22
|
-
collectNode(node: MNode, target: Target, depExtendedData?: DepExtendedData, deep?: boolean): void;
|
|
23
|
-
clear(nodes?: MNode[]): void;
|
|
24
|
-
clearByType(type: DepTargetType, nodes?: MNode[]): void;
|
|
25
|
-
hasTarget(id: Id, type?: string): boolean;
|
|
26
|
-
hasSpecifiedTypeTarget(type?: string): boolean;
|
|
27
|
-
on<Name extends keyof DepEvents, Param extends DepEvents[Name]>(eventName: Name, listener: (...args: Param) => void | Promise<void>): this;
|
|
28
|
-
once<Name extends keyof DepEvents, Param extends DepEvents[Name]>(eventName: Name, listener: (...args: Param) => void | Promise<void>): this;
|
|
29
|
-
emit<Name extends keyof DepEvents, Param extends DepEvents[Name]>(eventName: Name, ...args: Param): boolean;
|
|
30
|
-
}
|
|
31
|
-
export type DepService = Dep;
|
|
32
|
-
declare const _default: Dep;
|
|
33
|
-
export default _default;
|
|
@@ -1,180 +0,0 @@
|
|
|
1
|
-
import { Writable } from 'type-fest';
|
|
2
|
-
import { type TargetOptions } from '@tmagic/dep';
|
|
3
|
-
import type { Id, MContainer, MNode, MPage, MPageFragment } from '@tmagic/schema';
|
|
4
|
-
import BaseService from '../services/BaseService';
|
|
5
|
-
import type { AddMNode, AsyncHookPlugin, EditorNodeInfo, PastePosition, StepValue, StoreState, StoreStateKey } from '../type';
|
|
6
|
-
import { LayerOffset, Layout } from '../type';
|
|
7
|
-
export interface EditorEvents {
|
|
8
|
-
'root-change': [value: StoreState['root'], preValue?: StoreState['root']];
|
|
9
|
-
select: [node: MNode | null];
|
|
10
|
-
add: [nodes: MNode[]];
|
|
11
|
-
remove: [nodes: MNode[]];
|
|
12
|
-
update: [nodes: MNode[]];
|
|
13
|
-
'move-layer': [offset: number | LayerOffset];
|
|
14
|
-
'drag-to': [data: {
|
|
15
|
-
targetIndex: number;
|
|
16
|
-
configs: MNode | MNode[];
|
|
17
|
-
targetParent: MContainer;
|
|
18
|
-
}];
|
|
19
|
-
'history-change': [data: MPage | MPageFragment];
|
|
20
|
-
}
|
|
21
|
-
declare const canUsePluginMethods: {
|
|
22
|
-
async: readonly ["getLayout", "highlight", "select", "multiSelect", "doAdd", "add", "doRemove", "remove", "doUpdate", "update", "sort", "copy", "paste", "doPaste", "doAlignCenter", "alignCenter", "moveLayer", "moveToContainer", "dragTo", "undo", "redo", "move"];
|
|
23
|
-
sync: never[];
|
|
24
|
-
};
|
|
25
|
-
type AsyncMethodName = Writable<(typeof canUsePluginMethods)['async']>;
|
|
26
|
-
declare class Editor extends BaseService {
|
|
27
|
-
state: StoreState;
|
|
28
|
-
private isHistoryStateChange;
|
|
29
|
-
constructor();
|
|
30
|
-
/**
|
|
31
|
-
* 设置当前指点节点配置
|
|
32
|
-
* @param name 'root' | 'page' | 'parent' | 'node' | 'highlightNode' | 'nodes' | 'stage' | 'modifiedNodeIds' | 'pageLength' | 'pageFragmentLength
|
|
33
|
-
* @param value MNode
|
|
34
|
-
*/
|
|
35
|
-
set<K extends StoreStateKey, T extends StoreState[K]>(name: K, value: T): void;
|
|
36
|
-
/**
|
|
37
|
-
* 获取当前指点节点配置
|
|
38
|
-
* @param name 'root' | 'page' | 'parent' | 'node' | 'highlightNode' | 'nodes' | 'stage' | 'modifiedNodeIds' | 'pageLength' | 'pageFragmentLength'
|
|
39
|
-
* @returns MNode
|
|
40
|
-
*/
|
|
41
|
-
get<K extends StoreStateKey>(name: K): StoreState[K];
|
|
42
|
-
/**
|
|
43
|
-
* 根据id获取组件、组件的父组件以及组件所属的页面节点
|
|
44
|
-
* @param {number | string} id 组件id
|
|
45
|
-
* @param {boolean} raw 是否使用toRaw
|
|
46
|
-
* @returns {EditorNodeInfo}
|
|
47
|
-
*/
|
|
48
|
-
getNodeInfo(id: Id, raw?: boolean): EditorNodeInfo;
|
|
49
|
-
/**
|
|
50
|
-
* 根据ID获取指点节点配置
|
|
51
|
-
* @param id 组件ID
|
|
52
|
-
* @param {boolean} raw 是否使用toRaw
|
|
53
|
-
* @returns 组件节点配置
|
|
54
|
-
*/
|
|
55
|
-
getNodeById(id: Id, raw?: boolean): MNode | null;
|
|
56
|
-
/**
|
|
57
|
-
* 根据ID获取指点节点的父节点配置
|
|
58
|
-
* @param id 组件ID
|
|
59
|
-
* @param {boolean} raw 是否使用toRaw
|
|
60
|
-
* @returns 指点组件的父节点配置
|
|
61
|
-
*/
|
|
62
|
-
getParentById(id: Id, raw?: boolean): MContainer | null;
|
|
63
|
-
/**
|
|
64
|
-
* 只有容器拥有布局
|
|
65
|
-
*/
|
|
66
|
-
getLayout(parent: MNode, node?: MNode | null): Promise<Layout>;
|
|
67
|
-
/**
|
|
68
|
-
* 选中指定节点(将指定节点设置成当前选中状态)
|
|
69
|
-
* @param config 指定节点配置或者ID
|
|
70
|
-
* @returns 当前选中的节点配置
|
|
71
|
-
*/
|
|
72
|
-
select(config: MNode | Id): Promise<MNode> | never;
|
|
73
|
-
selectNextNode(): Promise<MNode | null> | never;
|
|
74
|
-
selectNextPage(): Promise<MNode> | never;
|
|
75
|
-
/**
|
|
76
|
-
* 高亮指定节点
|
|
77
|
-
* @param config 指定节点配置或者ID
|
|
78
|
-
* @returns 当前高亮的节点配置
|
|
79
|
-
*/
|
|
80
|
-
highlight(config: MNode | Id): void;
|
|
81
|
-
/**
|
|
82
|
-
* 多选
|
|
83
|
-
* @param ids 指定节点ID
|
|
84
|
-
* @returns 加入多选的节点配置
|
|
85
|
-
*/
|
|
86
|
-
multiSelect(ids: Id[]): void;
|
|
87
|
-
selectRoot(): void;
|
|
88
|
-
doAdd(node: MNode, parent: MContainer): Promise<MNode>;
|
|
89
|
-
/**
|
|
90
|
-
* 向指点容器添加组件节点
|
|
91
|
-
* @param addConfig 将要添加的组件节点配置
|
|
92
|
-
* @param parent 要添加到的容器组件节点配置,如果不设置,默认为当前选中的组件的父节点
|
|
93
|
-
* @returns 添加后的节点
|
|
94
|
-
*/
|
|
95
|
-
add(addNode: AddMNode | MNode[], parent?: MContainer | null): Promise<MNode | MNode[]>;
|
|
96
|
-
doRemove(node: MNode): Promise<void>;
|
|
97
|
-
/**
|
|
98
|
-
* 删除组件
|
|
99
|
-
* @param {Object} node
|
|
100
|
-
*/
|
|
101
|
-
remove(nodeOrNodeList: MNode | MNode[]): Promise<void>;
|
|
102
|
-
doUpdate(config: MNode): Promise<MNode>;
|
|
103
|
-
/**
|
|
104
|
-
* 更新节点
|
|
105
|
-
* @param config 新的节点配置,配置中需要有id信息
|
|
106
|
-
* @returns 更新后的节点配置
|
|
107
|
-
*/
|
|
108
|
-
update(config: MNode | MNode[]): Promise<MNode | MNode[]>;
|
|
109
|
-
/**
|
|
110
|
-
* 将id为id1的组件移动到id为id2的组件位置上,例如:[1,2,3,4] -> sort(1,3) -> [2,1,3,4]
|
|
111
|
-
* @param id1 组件ID
|
|
112
|
-
* @param id2 组件ID
|
|
113
|
-
* @returns void
|
|
114
|
-
*/
|
|
115
|
-
sort(id1: Id, id2: Id): Promise<void>;
|
|
116
|
-
/**
|
|
117
|
-
* 将组件节点配置存储到localStorage中
|
|
118
|
-
* @param config 组件节点配置
|
|
119
|
-
* @returns
|
|
120
|
-
*/
|
|
121
|
-
copy(config: MNode | MNode[]): void;
|
|
122
|
-
/**
|
|
123
|
-
* 复制时会带上组件关联的依赖
|
|
124
|
-
* @param config 组件节点配置
|
|
125
|
-
* @returns
|
|
126
|
-
*/
|
|
127
|
-
copyWithRelated(config: MNode | MNode[], collectorOptions?: TargetOptions): void;
|
|
128
|
-
/**
|
|
129
|
-
* 从localStorage中获取节点,然后添加到当前容器中
|
|
130
|
-
* @param position 粘贴的坐标
|
|
131
|
-
* @returns 添加后的组件节点配置
|
|
132
|
-
*/
|
|
133
|
-
paste(position?: PastePosition, collectorOptions?: TargetOptions): Promise<MNode | MNode[] | void>;
|
|
134
|
-
doPaste(config: MNode[], position?: PastePosition): Promise<MNode[]>;
|
|
135
|
-
doAlignCenter(config: MNode): Promise<MNode>;
|
|
136
|
-
/**
|
|
137
|
-
* 将指点节点设置居中
|
|
138
|
-
* @param config 组件节点配置
|
|
139
|
-
* @returns 当前组件节点配置
|
|
140
|
-
*/
|
|
141
|
-
alignCenter(config: MNode | MNode[]): Promise<MNode | MNode[]>;
|
|
142
|
-
/**
|
|
143
|
-
* 移动当前选中节点位置
|
|
144
|
-
* @param offset 偏移量
|
|
145
|
-
*/
|
|
146
|
-
moveLayer(offset: number | LayerOffset): Promise<void>;
|
|
147
|
-
/**
|
|
148
|
-
* 移动到指定容器中
|
|
149
|
-
* @param config 需要移动的节点
|
|
150
|
-
* @param targetId 容器ID
|
|
151
|
-
*/
|
|
152
|
-
moveToContainer(config: MNode, targetId: Id): Promise<MNode | undefined>;
|
|
153
|
-
dragTo(config: MNode | MNode[], targetParent: MContainer, targetIndex: number): Promise<void>;
|
|
154
|
-
/**
|
|
155
|
-
* 撤销当前操作
|
|
156
|
-
* @returns 上一次数据
|
|
157
|
-
*/
|
|
158
|
-
undo(): Promise<StepValue | null>;
|
|
159
|
-
/**
|
|
160
|
-
* 恢复到下一步
|
|
161
|
-
* @returns 下一步数据
|
|
162
|
-
*/
|
|
163
|
-
redo(): Promise<StepValue | null>;
|
|
164
|
-
move(left: number, top: number): Promise<void>;
|
|
165
|
-
resetState(): void;
|
|
166
|
-
destroy(): void;
|
|
167
|
-
resetModifiedNodeId(): void;
|
|
168
|
-
usePlugin(options: AsyncHookPlugin<AsyncMethodName, Editor>): void;
|
|
169
|
-
on<Name extends keyof EditorEvents, Param extends EditorEvents[Name]>(eventName: Name, listener: (...args: Param) => void | Promise<void>): this;
|
|
170
|
-
once<Name extends keyof EditorEvents, Param extends EditorEvents[Name]>(eventName: Name, listener: (...args: Param) => void | Promise<void>): this;
|
|
171
|
-
emit<Name extends keyof EditorEvents, Param extends EditorEvents[Name]>(eventName: Name, ...args: Param): boolean;
|
|
172
|
-
private addModifiedNodeId;
|
|
173
|
-
private pushHistoryState;
|
|
174
|
-
private changeHistoryState;
|
|
175
|
-
private toggleFixedPosition;
|
|
176
|
-
private selectedConfigExceptionHandler;
|
|
177
|
-
}
|
|
178
|
-
export type EditorService = Editor;
|
|
179
|
-
declare const _default: Editor;
|
|
180
|
-
export default _default;
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { EventOption } from '@tmagic/core';
|
|
2
|
-
import type { ComponentGroup } from '../type';
|
|
3
|
-
import BaseService from './BaseService';
|
|
4
|
-
declare class Events extends BaseService {
|
|
5
|
-
constructor();
|
|
6
|
-
init(componentGroupList: ComponentGroup[]): void;
|
|
7
|
-
setEvents(events: Record<string, EventOption[]>): void;
|
|
8
|
-
setEvent(type: string, events: EventOption[]): void;
|
|
9
|
-
getEvent(type: string): EventOption[];
|
|
10
|
-
setMethods(methods: Record<string, EventOption[]>): void;
|
|
11
|
-
setMethod(type: string, method: EventOption[]): void;
|
|
12
|
-
getMethod(type: string): EventOption[];
|
|
13
|
-
resetState(): void;
|
|
14
|
-
destroy(): void;
|
|
15
|
-
}
|
|
16
|
-
export type EventsService = Events;
|
|
17
|
-
declare const _default: Events;
|
|
18
|
-
export default _default;
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import type { MPage, MPageFragment } from '@tmagic/schema';
|
|
2
|
-
import type { StepValue } from '../type';
|
|
3
|
-
import { UndoRedo } from '../utils/undo-redo';
|
|
4
|
-
import BaseService from './BaseService';
|
|
5
|
-
declare class History extends BaseService {
|
|
6
|
-
state: {
|
|
7
|
-
pageId?: import("@tmagic/schema").Id | undefined;
|
|
8
|
-
pageSteps: Record<import("@tmagic/schema").Id, UndoRedo<StepValue>>;
|
|
9
|
-
canRedo: boolean;
|
|
10
|
-
canUndo: boolean;
|
|
11
|
-
};
|
|
12
|
-
constructor();
|
|
13
|
-
reset(): void;
|
|
14
|
-
resetPage(): void;
|
|
15
|
-
changePage(page: MPage | MPageFragment): void;
|
|
16
|
-
resetState(): void;
|
|
17
|
-
push(state: StepValue): StepValue | null;
|
|
18
|
-
undo(): StepValue | null;
|
|
19
|
-
redo(): StepValue | null;
|
|
20
|
-
destroy(): void;
|
|
21
|
-
private getUndoRedo;
|
|
22
|
-
private setCanUndoRedo;
|
|
23
|
-
}
|
|
24
|
-
export type HistoryService = History;
|
|
25
|
-
declare const _default: History;
|
|
26
|
-
export default _default;
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import { KeyBindingItem } from '../type';
|
|
2
|
-
import BaseService from './BaseService';
|
|
3
|
-
declare class Keybinding extends BaseService {
|
|
4
|
-
ctrlKey: string;
|
|
5
|
-
private controllers;
|
|
6
|
-
private bindingList;
|
|
7
|
-
private commands;
|
|
8
|
-
registerCommand(command: string, handler: (e: KeyboardEvent) => void | Promise<void>): void;
|
|
9
|
-
/**
|
|
10
|
-
* @deprecated
|
|
11
|
-
*/
|
|
12
|
-
registeCommand(command: string, handler: (e: KeyboardEvent) => void | Promise<void>): void;
|
|
13
|
-
unregisterCommand(command: string): void;
|
|
14
|
-
/**
|
|
15
|
-
* @deprecated
|
|
16
|
-
*/
|
|
17
|
-
unregisteCommand(command: string): void;
|
|
18
|
-
registerEl(name: string, el?: HTMLElement): void;
|
|
19
|
-
/**
|
|
20
|
-
* @deprecated
|
|
21
|
-
*/
|
|
22
|
-
registeEl(name: string, el?: HTMLElement): void;
|
|
23
|
-
unregisterEl(name: string): void;
|
|
24
|
-
/**
|
|
25
|
-
* @deprecated
|
|
26
|
-
*/
|
|
27
|
-
unregisteEl(name: string): void;
|
|
28
|
-
register(maps: KeyBindingItem[]): void;
|
|
29
|
-
/**
|
|
30
|
-
* @deprecated
|
|
31
|
-
*/
|
|
32
|
-
registe(map: KeyBindingItem[]): void;
|
|
33
|
-
reset(): void;
|
|
34
|
-
destroy(): void;
|
|
35
|
-
private bind;
|
|
36
|
-
private getKeyconKeys;
|
|
37
|
-
}
|
|
38
|
-
export type KeybindingService = Keybinding;
|
|
39
|
-
declare const _default: Keybinding;
|
|
40
|
-
export default _default;
|
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
import { Writable } from 'type-fest';
|
|
2
|
-
import { type TargetOptions } from '@tmagic/dep';
|
|
3
|
-
import type { FormConfig } from '@tmagic/form';
|
|
4
|
-
import type { MNode } from '@tmagic/schema';
|
|
5
|
-
import type { AsyncHookPlugin, PropsFormConfigFunction, PropsFormValueFunction, SyncHookPlugin } from '../type';
|
|
6
|
-
import BaseService from './BaseService';
|
|
7
|
-
declare const canUsePluginMethods: {
|
|
8
|
-
async: readonly ["setPropsConfig", "getPropsConfig", "setPropsValue", "getPropsValue", "fillConfig", "getDefaultPropsValue"];
|
|
9
|
-
sync: readonly ["createId", "setNewItemId"];
|
|
10
|
-
};
|
|
11
|
-
type AsyncMethodName = Writable<(typeof canUsePluginMethods)['async']>;
|
|
12
|
-
type SyncMethodName = Writable<(typeof canUsePluginMethods)['sync']>;
|
|
13
|
-
declare class Props extends BaseService {
|
|
14
|
-
private state;
|
|
15
|
-
constructor();
|
|
16
|
-
setPropsConfigs(configs: Record<string, FormConfig | PropsFormConfigFunction>): void;
|
|
17
|
-
fillConfig(config: FormConfig, labelWidth?: string): Promise<FormConfig>;
|
|
18
|
-
setPropsConfig(type: string, config: FormConfig | PropsFormConfigFunction): Promise<void>;
|
|
19
|
-
/**
|
|
20
|
-
* 获取指点类型的组件属性表单配置
|
|
21
|
-
* @param type 组件类型
|
|
22
|
-
* @returns 组件属性表单配置
|
|
23
|
-
*/
|
|
24
|
-
getPropsConfig(type: string): Promise<FormConfig>;
|
|
25
|
-
setPropsValues(values: Record<string, Partial<MNode> | PropsFormValueFunction>): void;
|
|
26
|
-
/**
|
|
27
|
-
* 为指点类型组件设置组件初始值
|
|
28
|
-
* @param type 组件类型
|
|
29
|
-
* @param value 组件初始值
|
|
30
|
-
*/
|
|
31
|
-
setPropsValue(type: string, value: Partial<MNode> | PropsFormValueFunction): Promise<void>;
|
|
32
|
-
/**
|
|
33
|
-
* 获取指定类型的组件初始值
|
|
34
|
-
* @param type 组件类型
|
|
35
|
-
* @returns 组件初始值
|
|
36
|
-
*/
|
|
37
|
-
getPropsValue(componentType: string, { inputEvent, ...defaultValue }?: Record<string, any>): Promise<any>;
|
|
38
|
-
createId(type: string | number): string;
|
|
39
|
-
/**
|
|
40
|
-
* 将组件与组件的子元素配置中的id都设置成一个新的ID
|
|
41
|
-
* 如果没有相同ID并且force为false则保持不变
|
|
42
|
-
* @param {Object} config 组件配置
|
|
43
|
-
* @param {Boolean} force 是否强制设置新的ID
|
|
44
|
-
*/
|
|
45
|
-
setNewItemId(config: MNode, force?: boolean): MNode;
|
|
46
|
-
/**
|
|
47
|
-
* 获取默认属性配置
|
|
48
|
-
* @param type 组件类型
|
|
49
|
-
* @returns Object
|
|
50
|
-
*/
|
|
51
|
-
getDefaultPropsValue(type: string): {
|
|
52
|
-
type: string;
|
|
53
|
-
layout: string;
|
|
54
|
-
style: {};
|
|
55
|
-
name: string;
|
|
56
|
-
items: never[];
|
|
57
|
-
} | {
|
|
58
|
-
type: string;
|
|
59
|
-
style: {};
|
|
60
|
-
name: string;
|
|
61
|
-
layout?: undefined;
|
|
62
|
-
items?: undefined;
|
|
63
|
-
};
|
|
64
|
-
resetState(): void;
|
|
65
|
-
/**
|
|
66
|
-
* 替换关联ID
|
|
67
|
-
* @param originConfigs 原组件配置
|
|
68
|
-
* @param targetConfigs 待替换的组件配置
|
|
69
|
-
*/
|
|
70
|
-
replaceRelateId(originConfigs: MNode[], targetConfigs: MNode[], collectorOptions: TargetOptions): void;
|
|
71
|
-
/**
|
|
72
|
-
* 清除setNewItemId前后映射关系
|
|
73
|
-
*/
|
|
74
|
-
clearRelateId(): void;
|
|
75
|
-
destroy(): void;
|
|
76
|
-
usePlugin(options: AsyncHookPlugin<AsyncMethodName, Props> & SyncHookPlugin<SyncMethodName, Props>): void;
|
|
77
|
-
/**
|
|
78
|
-
* 获取setNewItemId前后映射关系
|
|
79
|
-
* @param oldId 原组件ID
|
|
80
|
-
* @returns 新旧ID映射
|
|
81
|
-
*/
|
|
82
|
-
private getRelateIdMap;
|
|
83
|
-
/**
|
|
84
|
-
* 记录setNewItemId前后映射关系
|
|
85
|
-
* @param oldId 原组件ID
|
|
86
|
-
* @param newId 分配的新ID
|
|
87
|
-
*/
|
|
88
|
-
private setRelateId;
|
|
89
|
-
}
|
|
90
|
-
export type PropsService = Props;
|
|
91
|
-
declare const _default: Props;
|
|
92
|
-
export default _default;
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import type { Writable } from 'type-fest';
|
|
2
|
-
import StageCore from '@tmagic/stage';
|
|
3
|
-
import BaseService from '../services/BaseService';
|
|
4
|
-
import type { StageOptions, StageOverlayState, SyncHookPlugin } from '../type';
|
|
5
|
-
declare const canUsePluginMethods: {
|
|
6
|
-
async: never[];
|
|
7
|
-
sync: readonly ["openOverlay", "closeOverlay", "updateOverlay", "createStage"];
|
|
8
|
-
};
|
|
9
|
-
type SyncMethodName = Writable<(typeof canUsePluginMethods)['sync']>;
|
|
10
|
-
declare class StageOverlay extends BaseService {
|
|
11
|
-
private state;
|
|
12
|
-
constructor();
|
|
13
|
-
get<K extends keyof StageOverlayState>(name: K): StageOverlayState[K];
|
|
14
|
-
set<K extends keyof StageOverlayState, T extends StageOverlayState[K]>(name: K, value: T): void;
|
|
15
|
-
openOverlay(el: HTMLElement | null): void;
|
|
16
|
-
closeOverlay(): void;
|
|
17
|
-
updateOverlay(): void;
|
|
18
|
-
createStage(stageOptions?: StageOptions): StageCore;
|
|
19
|
-
usePlugin(options: SyncHookPlugin<SyncMethodName, StageOverlay>): void;
|
|
20
|
-
private createContentEl;
|
|
21
|
-
private copyDocumentElement;
|
|
22
|
-
private render;
|
|
23
|
-
private updateHandler;
|
|
24
|
-
private addHandler;
|
|
25
|
-
private removeHandler;
|
|
26
|
-
private updateSelectStatus;
|
|
27
|
-
}
|
|
28
|
-
export type StageOverlayService = StageOverlay;
|
|
29
|
-
declare const _default: StageOverlay;
|
|
30
|
-
export default _default;
|