@tmagic/editor 1.2.0-beta.18 → 1.2.0-beta.19
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/tmagic-editor.mjs +21 -12
- package/dist/tmagic-editor.mjs.map +1 -1
- package/dist/tmagic-editor.umd.js +20 -11
- package/dist/tmagic-editor.umd.js.map +1 -1
- package/package.json +10 -10
- package/src/Editor.vue +22 -13
- package/src/layouts/workspace/Stage.vue +10 -1
- package/src/layouts/workspace/Workspace.vue +1 -1
- package/src/services/editor.ts +4 -6
- package/src/services/history.ts +4 -14
- package/src/services/props.ts +1 -1
- package/src/type.ts +39 -12
- package/src/utils/stage.ts +2 -2
- package/types/Editor.vue.d.ts +40 -27
- package/types/layouts/workspace/Stage.vue.d.ts +2 -1
- package/types/services/editor.d.ts +3 -6
- package/types/services/history.d.ts +4 -14
- package/types/services/props.d.ts +1 -1
- package/types/type.d.ts +31 -13
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "1.2.0-beta.
|
|
2
|
+
"version": "1.2.0-beta.19",
|
|
3
3
|
"name": "@tmagic/editor",
|
|
4
4
|
"sideEffects": [
|
|
5
5
|
"dist/*",
|
|
@@ -45,12 +45,12 @@
|
|
|
45
45
|
"dependencies": {
|
|
46
46
|
"@babel/core": "^7.18.0",
|
|
47
47
|
"@element-plus/icons-vue": "^2.0.9",
|
|
48
|
-
"@tmagic/core": "1.2.0-beta.
|
|
49
|
-
"@tmagic/design": "1.2.0-beta.
|
|
50
|
-
"@tmagic/form": "1.2.0-beta.
|
|
51
|
-
"@tmagic/schema": "1.2.0-beta.
|
|
52
|
-
"@tmagic/stage": "1.2.0-beta.
|
|
53
|
-
"@tmagic/utils": "1.2.0-beta.
|
|
48
|
+
"@tmagic/core": "1.2.0-beta.19",
|
|
49
|
+
"@tmagic/design": "1.2.0-beta.19",
|
|
50
|
+
"@tmagic/form": "1.2.0-beta.19",
|
|
51
|
+
"@tmagic/schema": "1.2.0-beta.19",
|
|
52
|
+
"@tmagic/stage": "1.2.0-beta.19",
|
|
53
|
+
"@tmagic/utils": "1.2.0-beta.19",
|
|
54
54
|
"buffer": "^6.0.3",
|
|
55
55
|
"color": "^3.1.3",
|
|
56
56
|
"events": "^3.3.0",
|
|
@@ -62,8 +62,8 @@
|
|
|
62
62
|
"vue": "^3.2.37"
|
|
63
63
|
},
|
|
64
64
|
"peerDependencies": {
|
|
65
|
-
"@tmagic/design": "1.2.0-beta.
|
|
66
|
-
"@tmagic/form": "1.2.0-beta.
|
|
65
|
+
"@tmagic/design": "1.2.0-beta.19",
|
|
66
|
+
"@tmagic/form": "1.2.0-beta.19",
|
|
67
67
|
"monaco-editor": "^0.34.0",
|
|
68
68
|
"vue": "^3.2.37"
|
|
69
69
|
},
|
|
@@ -80,6 +80,6 @@
|
|
|
80
80
|
"typescript": "^4.7.4",
|
|
81
81
|
"vite": "^3.1.3",
|
|
82
82
|
"vite-plugin-vue-setup-extend": "^0.4.0",
|
|
83
|
-
"vue-tsc": "^1.0.
|
|
83
|
+
"vue-tsc": "^1.0.10"
|
|
84
84
|
}
|
|
85
85
|
}
|
package/src/Editor.vue
CHANGED
|
@@ -69,8 +69,13 @@ import { defineComponent, onUnmounted, PropType, provide, reactive, toRaw, watch
|
|
|
69
69
|
import { EventOption } from '@tmagic/core';
|
|
70
70
|
import type { FormConfig } from '@tmagic/form';
|
|
71
71
|
import type { MApp, MNode } from '@tmagic/schema';
|
|
72
|
-
import
|
|
73
|
-
|
|
72
|
+
import StageCore, {
|
|
73
|
+
CONTAINER_HIGHLIGHT_CLASS_NAME,
|
|
74
|
+
ContainerHighlightType,
|
|
75
|
+
CustomizeMoveableOptionsCallbackConfig,
|
|
76
|
+
MoveableOptions,
|
|
77
|
+
UpdateDragEl,
|
|
78
|
+
} from '@tmagic/stage';
|
|
74
79
|
|
|
75
80
|
import Framework from './layouts/Framework.vue';
|
|
76
81
|
import NavMenu from './layouts/NavMenu.vue';
|
|
@@ -117,25 +122,27 @@ export default defineComponent({
|
|
|
117
122
|
type: Object as PropType<SideBarData>,
|
|
118
123
|
},
|
|
119
124
|
|
|
125
|
+
/** 顶部工具栏配置 */
|
|
126
|
+
menu: {
|
|
127
|
+
type: Object as PropType<MenuBarData>,
|
|
128
|
+
default: () => ({ left: [], right: [] }),
|
|
129
|
+
},
|
|
130
|
+
|
|
131
|
+
/** 组件树右键菜单 */
|
|
120
132
|
layerContentMenu: {
|
|
121
133
|
type: Array as PropType<(MenuButton | MenuComponent)[]>,
|
|
122
134
|
default: () => [],
|
|
123
135
|
},
|
|
124
136
|
|
|
137
|
+
/** 画布右键菜单 */
|
|
125
138
|
stageContentMenu: {
|
|
126
139
|
type: Array as PropType<(MenuButton | MenuComponent)[]>,
|
|
127
140
|
default: () => [],
|
|
128
141
|
},
|
|
129
142
|
|
|
130
|
-
/** 顶部工具栏配置 */
|
|
131
|
-
menu: {
|
|
132
|
-
type: Object as PropType<MenuBarData>,
|
|
133
|
-
default: () => ({ left: [], right: [] }),
|
|
134
|
-
},
|
|
135
|
-
|
|
136
143
|
/** 中间工作区域中画布渲染的内容 */
|
|
137
144
|
render: {
|
|
138
|
-
type: Function as PropType<() => HTMLDivElement
|
|
145
|
+
type: Function as PropType<(stage: StageCore) => HTMLDivElement | Promise<HTMLDivElement>>,
|
|
139
146
|
},
|
|
140
147
|
|
|
141
148
|
/** 中间工作区域中画布通过iframe渲染时的页面url */
|
|
@@ -158,13 +165,15 @@ export default defineComponent({
|
|
|
158
165
|
|
|
159
166
|
/** 组件联动事件选项列表 */
|
|
160
167
|
eventMethodList: {
|
|
161
|
-
type: Object,
|
|
168
|
+
type: Object as PropType<Record<string, { events: EventOption[]; methods: EventOption[] }>>,
|
|
162
169
|
default: () => ({}),
|
|
163
170
|
},
|
|
164
171
|
|
|
165
172
|
/** 画布中组件选中框的移动范围 */
|
|
166
173
|
moveableOptions: {
|
|
167
|
-
type: [Object, Function] as PropType<
|
|
174
|
+
type: [Object, Function] as PropType<
|
|
175
|
+
MoveableOptions | ((config?: CustomizeMoveableOptionsCallbackConfig) => MoveableOptions)
|
|
176
|
+
>,
|
|
168
177
|
},
|
|
169
178
|
|
|
170
179
|
/** 编辑器初始化时默认选中的组件ID */
|
|
@@ -184,7 +193,7 @@ export default defineComponent({
|
|
|
184
193
|
|
|
185
194
|
containerHighlightClassName: {
|
|
186
195
|
type: String,
|
|
187
|
-
default:
|
|
196
|
+
default: CONTAINER_HIGHLIGHT_CLASS_NAME,
|
|
188
197
|
},
|
|
189
198
|
|
|
190
199
|
containerHighlightDuration: {
|
|
@@ -207,7 +216,7 @@ export default defineComponent({
|
|
|
207
216
|
},
|
|
208
217
|
|
|
209
218
|
updateDragEl: {
|
|
210
|
-
type: Function as PropType<
|
|
219
|
+
type: Function as PropType<UpdateDragEl>,
|
|
211
220
|
},
|
|
212
221
|
},
|
|
213
222
|
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
</template>
|
|
28
28
|
|
|
29
29
|
<script lang="ts" setup name="MEditorStage">
|
|
30
|
-
import { computed, inject, markRaw, onMounted, onUnmounted, ref, toRaw, watch, watchEffect } from 'vue';
|
|
30
|
+
import { computed, inject, markRaw, nextTick, onMounted, onUnmounted, ref, toRaw, watch, watchEffect } from 'vue';
|
|
31
31
|
import { cloneDeep } from 'lodash-es';
|
|
32
32
|
|
|
33
33
|
import type { MApp, MContainer, MNode, MPage } from '@tmagic/schema';
|
|
@@ -96,6 +96,15 @@ watch(root, (root) => {
|
|
|
96
96
|
}
|
|
97
97
|
});
|
|
98
98
|
|
|
99
|
+
watch(page, (page) => {
|
|
100
|
+
if (runtime && page) {
|
|
101
|
+
runtime.updatePageId?.(page.id);
|
|
102
|
+
nextTick(() => {
|
|
103
|
+
stage?.select(page.id);
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
});
|
|
107
|
+
|
|
99
108
|
const resizeObserver = new ResizeObserver((entries) => {
|
|
100
109
|
for (const { contentRect } of entries) {
|
|
101
110
|
services?.uiService.set('stageContainerRect', {
|
package/src/services/editor.ts
CHANGED
|
@@ -25,9 +25,9 @@ import StageCore from '@tmagic/stage';
|
|
|
25
25
|
import { getNodePath, isNumber, isPage, isPop } from '@tmagic/utils';
|
|
26
26
|
|
|
27
27
|
import codeBlockService from '../services/codeBlock';
|
|
28
|
-
import historyService
|
|
28
|
+
import historyService from '../services/history';
|
|
29
29
|
import storageService, { Protocol } from '../services/storage';
|
|
30
|
-
import type { AddMNode, EditorNodeInfo, PastePosition, StoreState } from '../type';
|
|
30
|
+
import type { AddMNode, EditorNodeInfo, PastePosition, StepValue, StoreState } from '../type';
|
|
31
31
|
import { LayerOffset, Layout } from '../type';
|
|
32
32
|
import {
|
|
33
33
|
change2Fixed,
|
|
@@ -91,9 +91,8 @@ class Editor extends BaseService {
|
|
|
91
91
|
|
|
92
92
|
/**
|
|
93
93
|
* 设置当前指点节点配置
|
|
94
|
-
* @param name 'root' | 'page' | 'parent' | 'node' | 'highlightNode' | 'nodes'
|
|
94
|
+
* @param name 'root' | 'page' | 'parent' | 'node' | 'highlightNode' | 'nodes' | 'stage' | 'modifiedNodeIds' | 'pageLength'
|
|
95
95
|
* @param value MNode
|
|
96
|
-
* @returns MNode
|
|
97
96
|
*/
|
|
98
97
|
public set<T = MNode>(name: keyof StoreState, value: T) {
|
|
99
98
|
this.state[name] = value as any;
|
|
@@ -109,7 +108,7 @@ class Editor extends BaseService {
|
|
|
109
108
|
|
|
110
109
|
/**
|
|
111
110
|
* 获取当前指点节点配置
|
|
112
|
-
* @param name 'root' | 'page' | 'parent' | 'node' | 'highlightNode' | 'nodes'
|
|
111
|
+
* @param name 'root' | 'page' | 'parent' | 'node' | 'highlightNode' | 'nodes' | 'stage' | 'modifiedNodeIds' | 'pageLength'
|
|
113
112
|
* @returns MNode
|
|
114
113
|
*/
|
|
115
114
|
public get<T = MNode>(name: keyof StoreState): T {
|
|
@@ -432,7 +431,6 @@ class Editor extends BaseService {
|
|
|
432
431
|
/**
|
|
433
432
|
* 删除组件
|
|
434
433
|
* @param {Object} node
|
|
435
|
-
* @return {Object} 删除的组件配置
|
|
436
434
|
*/
|
|
437
435
|
public async remove(nodeOrNodeList: MNode | MNode[]): Promise<void> {
|
|
438
436
|
const nodes = Array.isArray(nodeOrNodeList) ? nodeOrNodeList : [nodeOrNodeList];
|
package/src/services/history.ts
CHANGED
|
@@ -18,25 +18,13 @@
|
|
|
18
18
|
|
|
19
19
|
import { reactive } from 'vue';
|
|
20
20
|
|
|
21
|
-
import type {
|
|
21
|
+
import type { MPage } from '@tmagic/schema';
|
|
22
22
|
|
|
23
|
+
import { HistoryState, StepValue } from '../type';
|
|
23
24
|
import { UndoRedo } from '../utils/undo-redo';
|
|
24
25
|
|
|
25
26
|
import BaseService from './BaseService';
|
|
26
27
|
|
|
27
|
-
export interface StepValue {
|
|
28
|
-
data: MPage;
|
|
29
|
-
modifiedNodeIds: Map<Id, Id>;
|
|
30
|
-
nodeId: Id;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
export interface HistoryState {
|
|
34
|
-
pageId?: Id;
|
|
35
|
-
pageSteps: Record<Id, UndoRedo<StepValue>>;
|
|
36
|
-
canRedo: boolean;
|
|
37
|
-
canUndo: boolean;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
28
|
class History extends BaseService {
|
|
41
29
|
public state = reactive<HistoryState>({
|
|
42
30
|
pageSteps: {},
|
|
@@ -76,6 +64,8 @@ class History extends BaseService {
|
|
|
76
64
|
}
|
|
77
65
|
|
|
78
66
|
this.setCanUndoRedo();
|
|
67
|
+
|
|
68
|
+
this.emit('page-change', this.state.pageSteps[this.state.pageId]);
|
|
79
69
|
}
|
|
80
70
|
|
|
81
71
|
public empty(): void {
|
package/src/services/props.ts
CHANGED
package/src/type.ts
CHANGED
|
@@ -21,7 +21,12 @@ import type { Component } from 'vue';
|
|
|
21
21
|
import type { FormConfig } from '@tmagic/form';
|
|
22
22
|
import type { CodeBlockContent, CodeBlockDSL, Id, MApp, MContainer, MNode, MPage } from '@tmagic/schema';
|
|
23
23
|
import type StageCore from '@tmagic/stage';
|
|
24
|
-
import type {
|
|
24
|
+
import type {
|
|
25
|
+
ContainerHighlightType,
|
|
26
|
+
CustomizeMoveableOptionsCallbackConfig,
|
|
27
|
+
MoveableOptions,
|
|
28
|
+
UpdateDragEl,
|
|
29
|
+
} from '@tmagic/stage';
|
|
25
30
|
|
|
26
31
|
import type { CodeBlockService } from './services/codeBlock';
|
|
27
32
|
import type { ComponentListService } from './services/componentList';
|
|
@@ -31,6 +36,7 @@ import type { HistoryService } from './services/history';
|
|
|
31
36
|
import type { PropsService } from './services/props';
|
|
32
37
|
import type { StorageService } from './services/storage';
|
|
33
38
|
import type { UiService } from './services/ui';
|
|
39
|
+
import type { UndoRedo } from './utils/undo-redo';
|
|
34
40
|
|
|
35
41
|
export type BeforeAdd = (config: MNode, parent: MContainer) => Promise<MNode> | MNode;
|
|
36
42
|
export type GetConfig = (config: FormConfig) => Promise<FormConfig> | FormConfig;
|
|
@@ -56,11 +62,11 @@ export interface StageOptions {
|
|
|
56
62
|
containerHighlightClassName: string;
|
|
57
63
|
containerHighlightDuration: number;
|
|
58
64
|
containerHighlightType: ContainerHighlightType;
|
|
59
|
-
render: () => HTMLDivElement
|
|
60
|
-
moveableOptions: MoveableOptions | ((
|
|
65
|
+
render: (stage: StageCore) => HTMLDivElement | Promise<HTMLDivElement>;
|
|
66
|
+
moveableOptions: MoveableOptions | ((config?: CustomizeMoveableOptionsCallbackConfig) => MoveableOptions);
|
|
61
67
|
canSelect: (el: HTMLElement) => boolean | Promise<boolean>;
|
|
62
68
|
isContainer: (el: HTMLElement) => boolean | Promise<boolean>;
|
|
63
|
-
updateDragEl:
|
|
69
|
+
updateDragEl: UpdateDragEl;
|
|
64
70
|
}
|
|
65
71
|
|
|
66
72
|
export interface StoreState {
|
|
@@ -164,18 +170,17 @@ export interface MenuButton {
|
|
|
164
170
|
* 按钮类型
|
|
165
171
|
* button: 只有文字不带边框的按钮
|
|
166
172
|
* text: 纯文本
|
|
173
|
+
* divider: 分割线
|
|
167
174
|
* dropdown: 下拉菜单
|
|
168
|
-
* divider: 分隔线
|
|
169
|
-
* zoom: 放大缩小
|
|
170
175
|
*/
|
|
171
|
-
type: 'button' | '
|
|
176
|
+
type: 'button' | 'text' | 'divider' | 'dropdown';
|
|
172
177
|
/** 当type为divider时有效,分割线方向, 默认vertical */
|
|
173
178
|
direction?: 'horizontal' | 'vertical';
|
|
174
179
|
/** 展示的文案 */
|
|
175
180
|
text?: string;
|
|
176
181
|
/** 鼠标悬浮是显示的气泡中的文案 */
|
|
177
182
|
tooltip?: string;
|
|
178
|
-
/**
|
|
183
|
+
/** Vue组件或url */
|
|
179
184
|
icon?: string | Component<{}, {}, any>;
|
|
180
185
|
/** 是否置灰,默认为false */
|
|
181
186
|
disabled?: boolean | ((data?: Services) => boolean);
|
|
@@ -183,8 +188,8 @@ export interface MenuButton {
|
|
|
183
188
|
display?: boolean | ((data?: Services) => boolean);
|
|
184
189
|
/** type为button/dropdown时点击运行的方法 */
|
|
185
190
|
handler?: (data: Services, event: MouseEvent) => Promise<any> | any;
|
|
186
|
-
/** type为dropdown时,下拉的菜单列表, 或者有子菜单时 */
|
|
187
191
|
className?: string;
|
|
192
|
+
/** type为dropdown时,下拉的菜单列表, 或者有子菜单时 */
|
|
188
193
|
items?: MenuButton[];
|
|
189
194
|
}
|
|
190
195
|
|
|
@@ -208,8 +213,13 @@ export interface MenuComponent {
|
|
|
208
213
|
* 'delete': 删除按钮
|
|
209
214
|
* 'undo': 撤销按钮
|
|
210
215
|
* 'redo': 恢复按钮
|
|
216
|
+
* 'zoom': 'zoom-in', 'zoom-out', 'scale-to-original', 'scale-to-fit' 的集合
|
|
211
217
|
* 'zoom-in': 放大按钮
|
|
212
218
|
* 'zoom-out': 缩小按钮
|
|
219
|
+
* 'guides': 显示隐藏参考线
|
|
220
|
+
* 'rule': 显示隐藏标尺
|
|
221
|
+
* 'scale-to-original': 缩放到实际大小
|
|
222
|
+
* 'scale-to-fit': 缩放以适应
|
|
213
223
|
*/
|
|
214
224
|
export type MenuItem =
|
|
215
225
|
| '/'
|
|
@@ -221,6 +231,8 @@ export type MenuItem =
|
|
|
221
231
|
| 'zoom-out'
|
|
222
232
|
| 'guides'
|
|
223
233
|
| 'rule'
|
|
234
|
+
| 'scale-to-original'
|
|
235
|
+
| 'scale-to-fit'
|
|
224
236
|
| MenuButton
|
|
225
237
|
| MenuComponent
|
|
226
238
|
| string;
|
|
@@ -238,13 +250,14 @@ export interface MenuBarData {
|
|
|
238
250
|
export interface SideComponent extends MenuComponent {
|
|
239
251
|
/** 显示文案 */
|
|
240
252
|
text: string;
|
|
241
|
-
/**
|
|
253
|
+
/** vue组件或url */
|
|
242
254
|
icon: Component<{}, {}, any>;
|
|
243
255
|
}
|
|
244
256
|
|
|
245
257
|
/**
|
|
246
258
|
* component-list: 组件列表
|
|
247
259
|
* layer: 已选组件树
|
|
260
|
+
* code-block: 代码块
|
|
248
261
|
*/
|
|
249
262
|
export type SideItem = 'component-list' | 'layer' | 'code-block' | SideComponent;
|
|
250
263
|
|
|
@@ -263,8 +276,9 @@ export interface ComponentItem {
|
|
|
263
276
|
text: string;
|
|
264
277
|
/** 组件类型 */
|
|
265
278
|
type: string;
|
|
266
|
-
/**
|
|
267
|
-
icon?: string | Component
|
|
279
|
+
/** Vue组件或url */
|
|
280
|
+
icon?: string | Component<{}, {}, any>;
|
|
281
|
+
/** 新增组件时需要透传到组价节点上的数据 */
|
|
268
282
|
data?: {
|
|
269
283
|
[key: string]: any;
|
|
270
284
|
};
|
|
@@ -390,3 +404,16 @@ export interface CodeParamStatement {
|
|
|
390
404
|
/** 参数类型 */
|
|
391
405
|
type?: string;
|
|
392
406
|
}
|
|
407
|
+
|
|
408
|
+
export interface StepValue {
|
|
409
|
+
data: MPage;
|
|
410
|
+
modifiedNodeIds: Map<Id, Id>;
|
|
411
|
+
nodeId: Id;
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
export interface HistoryState {
|
|
415
|
+
pageId?: Id;
|
|
416
|
+
pageSteps: Record<Id, UndoRedo<StepValue>>;
|
|
417
|
+
canRedo: boolean;
|
|
418
|
+
canUndo: boolean;
|
|
419
|
+
}
|
package/src/utils/stage.ts
CHANGED
|
@@ -54,7 +54,7 @@ export const useStage = (stageOptions: StageOptions) => {
|
|
|
54
54
|
editorService.highlight(el.id);
|
|
55
55
|
});
|
|
56
56
|
|
|
57
|
-
stage.on('
|
|
57
|
+
stage.on('multi-select', (els: HTMLElement[]) => {
|
|
58
58
|
editorService.multiSelect(els.map((el) => el.id));
|
|
59
59
|
});
|
|
60
60
|
|
|
@@ -79,7 +79,7 @@ export const useStage = (stageOptions: StageOptions) => {
|
|
|
79
79
|
editorService.get<StageCore>('stage').select(parent.id);
|
|
80
80
|
});
|
|
81
81
|
|
|
82
|
-
stage.on('
|
|
82
|
+
stage.on('change-guides', (e) => {
|
|
83
83
|
uiService.set('showGuides', true);
|
|
84
84
|
|
|
85
85
|
if (!root.value || !page.value) return;
|
package/types/Editor.vue.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { PropType } from 'vue';
|
|
2
|
+
import { EventOption } from '@tmagic/core';
|
|
2
3
|
import type { FormConfig } from '@tmagic/form';
|
|
3
4
|
import type { MApp, MNode } from '@tmagic/schema';
|
|
4
|
-
import
|
|
5
|
-
import { ContainerHighlightType, MoveableOptions } from '@tmagic/stage';
|
|
5
|
+
import StageCore, { ContainerHighlightType, CustomizeMoveableOptionsCallbackConfig, MoveableOptions, UpdateDragEl } from '@tmagic/stage';
|
|
6
6
|
import type { ComponentGroup, MenuBarData, MenuButton, MenuComponent, Services, SideBarData, StageRect } from './type';
|
|
7
7
|
declare const _default: import("vue").DefineComponent<{
|
|
8
8
|
/** 页面初始值 */
|
|
@@ -20,14 +20,6 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
20
20
|
sidebar: {
|
|
21
21
|
type: PropType<SideBarData>;
|
|
22
22
|
};
|
|
23
|
-
layerContentMenu: {
|
|
24
|
-
type: PropType<(MenuButton | MenuComponent)[]>;
|
|
25
|
-
default: () => never[];
|
|
26
|
-
};
|
|
27
|
-
stageContentMenu: {
|
|
28
|
-
type: PropType<(MenuButton | MenuComponent)[]>;
|
|
29
|
-
default: () => never[];
|
|
30
|
-
};
|
|
31
23
|
/** 顶部工具栏配置 */
|
|
32
24
|
menu: {
|
|
33
25
|
type: PropType<MenuBarData>;
|
|
@@ -36,9 +28,19 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
36
28
|
right: never[];
|
|
37
29
|
};
|
|
38
30
|
};
|
|
31
|
+
/** 组件树右键菜单 */
|
|
32
|
+
layerContentMenu: {
|
|
33
|
+
type: PropType<(MenuButton | MenuComponent)[]>;
|
|
34
|
+
default: () => never[];
|
|
35
|
+
};
|
|
36
|
+
/** 画布右键菜单 */
|
|
37
|
+
stageContentMenu: {
|
|
38
|
+
type: PropType<(MenuButton | MenuComponent)[]>;
|
|
39
|
+
default: () => never[];
|
|
40
|
+
};
|
|
39
41
|
/** 中间工作区域中画布渲染的内容 */
|
|
40
42
|
render: {
|
|
41
|
-
type: PropType<() => HTMLDivElement
|
|
43
|
+
type: PropType<(stage: StageCore) => HTMLDivElement | Promise<HTMLDivElement>>;
|
|
42
44
|
};
|
|
43
45
|
/** 中间工作区域中画布通过iframe渲染时的页面url */
|
|
44
46
|
runtimeUrl: StringConstructor;
|
|
@@ -56,12 +58,15 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
56
58
|
};
|
|
57
59
|
/** 组件联动事件选项列表 */
|
|
58
60
|
eventMethodList: {
|
|
59
|
-
type:
|
|
61
|
+
type: PropType<Record<string, {
|
|
62
|
+
events: EventOption[];
|
|
63
|
+
methods: EventOption[];
|
|
64
|
+
}>>;
|
|
60
65
|
default: () => {};
|
|
61
66
|
};
|
|
62
67
|
/** 画布中组件选中框的移动范围 */
|
|
63
68
|
moveableOptions: {
|
|
64
|
-
type: PropType<MoveableOptions | ((
|
|
69
|
+
type: PropType<MoveableOptions | ((config?: CustomizeMoveableOptionsCallbackConfig) => MoveableOptions)>;
|
|
65
70
|
};
|
|
66
71
|
/** 编辑器初始化时默认选中的组件ID */
|
|
67
72
|
defaultSelected: {
|
|
@@ -95,7 +100,7 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
95
100
|
default: () => {};
|
|
96
101
|
};
|
|
97
102
|
updateDragEl: {
|
|
98
|
-
type: PropType<
|
|
103
|
+
type: PropType<UpdateDragEl>;
|
|
99
104
|
};
|
|
100
105
|
}, Services, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("update:modelValue" | "props-panel-mounted")[], "update:modelValue" | "props-panel-mounted", import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
|
|
101
106
|
/** 页面初始值 */
|
|
@@ -113,14 +118,6 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
113
118
|
sidebar: {
|
|
114
119
|
type: PropType<SideBarData>;
|
|
115
120
|
};
|
|
116
|
-
layerContentMenu: {
|
|
117
|
-
type: PropType<(MenuButton | MenuComponent)[]>;
|
|
118
|
-
default: () => never[];
|
|
119
|
-
};
|
|
120
|
-
stageContentMenu: {
|
|
121
|
-
type: PropType<(MenuButton | MenuComponent)[]>;
|
|
122
|
-
default: () => never[];
|
|
123
|
-
};
|
|
124
121
|
/** 顶部工具栏配置 */
|
|
125
122
|
menu: {
|
|
126
123
|
type: PropType<MenuBarData>;
|
|
@@ -129,9 +126,19 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
129
126
|
right: never[];
|
|
130
127
|
};
|
|
131
128
|
};
|
|
129
|
+
/** 组件树右键菜单 */
|
|
130
|
+
layerContentMenu: {
|
|
131
|
+
type: PropType<(MenuButton | MenuComponent)[]>;
|
|
132
|
+
default: () => never[];
|
|
133
|
+
};
|
|
134
|
+
/** 画布右键菜单 */
|
|
135
|
+
stageContentMenu: {
|
|
136
|
+
type: PropType<(MenuButton | MenuComponent)[]>;
|
|
137
|
+
default: () => never[];
|
|
138
|
+
};
|
|
132
139
|
/** 中间工作区域中画布渲染的内容 */
|
|
133
140
|
render: {
|
|
134
|
-
type: PropType<() => HTMLDivElement
|
|
141
|
+
type: PropType<(stage: StageCore) => HTMLDivElement | Promise<HTMLDivElement>>;
|
|
135
142
|
};
|
|
136
143
|
/** 中间工作区域中画布通过iframe渲染时的页面url */
|
|
137
144
|
runtimeUrl: StringConstructor;
|
|
@@ -149,12 +156,15 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
149
156
|
};
|
|
150
157
|
/** 组件联动事件选项列表 */
|
|
151
158
|
eventMethodList: {
|
|
152
|
-
type:
|
|
159
|
+
type: PropType<Record<string, {
|
|
160
|
+
events: EventOption[];
|
|
161
|
+
methods: EventOption[];
|
|
162
|
+
}>>;
|
|
153
163
|
default: () => {};
|
|
154
164
|
};
|
|
155
165
|
/** 画布中组件选中框的移动范围 */
|
|
156
166
|
moveableOptions: {
|
|
157
|
-
type: PropType<MoveableOptions | ((
|
|
167
|
+
type: PropType<MoveableOptions | ((config?: CustomizeMoveableOptionsCallbackConfig) => MoveableOptions)>;
|
|
158
168
|
};
|
|
159
169
|
/** 编辑器初始化时默认选中的组件ID */
|
|
160
170
|
defaultSelected: {
|
|
@@ -188,7 +198,7 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
188
198
|
default: () => {};
|
|
189
199
|
};
|
|
190
200
|
updateDragEl: {
|
|
191
|
-
type: PropType<
|
|
201
|
+
type: PropType<UpdateDragEl>;
|
|
192
202
|
};
|
|
193
203
|
}>> & {
|
|
194
204
|
"onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
|
|
@@ -203,7 +213,10 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
203
213
|
autoScrollIntoView: boolean;
|
|
204
214
|
propsConfigs: Record<string, FormConfig>;
|
|
205
215
|
propsValues: Record<string, MNode>;
|
|
206
|
-
eventMethodList: Record<string,
|
|
216
|
+
eventMethodList: Record<string, {
|
|
217
|
+
events: EventOption[];
|
|
218
|
+
methods: EventOption[];
|
|
219
|
+
}>;
|
|
207
220
|
canSelect: (el: HTMLElement) => boolean | Promise<boolean>;
|
|
208
221
|
isContainer: (el: HTMLElement) => boolean | Promise<boolean>;
|
|
209
222
|
containerHighlightClassName: string;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { nextTick } from 'vue';
|
|
1
2
|
import { MenuButton, MenuComponent } from '../../type';
|
|
2
3
|
declare const _default: {
|
|
3
4
|
new (...args: any[]): {
|
|
@@ -39,7 +40,7 @@ declare const _default: {
|
|
|
39
40
|
errorCaptured?: (((err: unknown, instance: import("vue").ComponentPublicInstance<{}, {}, {}, {}, {}, {}, {}, {}, false, import("vue").ComponentOptionsBase<any, any, any, any, any, any, any, any, any, {}>> | null, info: string) => boolean | void) | ((err: unknown, instance: import("vue").ComponentPublicInstance<{}, {}, {}, {}, {}, {}, {}, {}, false, import("vue").ComponentOptionsBase<any, any, any, any, any, any, any, any, any, {}>> | null, info: string) => boolean | void)[]) | undefined;
|
|
40
41
|
};
|
|
41
42
|
$forceUpdate: () => void;
|
|
42
|
-
$nextTick: typeof
|
|
43
|
+
$nextTick: typeof nextTick;
|
|
43
44
|
$watch(source: string | Function, cb: Function, options?: import("vue").WatchOptions<boolean> | undefined): import("vue").WatchStopHandle;
|
|
44
45
|
} & Readonly<import("vue").ExtractPropTypes<__VLS_TypePropsToRuntimeProps<{
|
|
45
46
|
stageContentMenu: (MenuButton | MenuComponent)[];
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import type { CodeBlockDSL, Id, MContainer, MNode } from '@tmagic/schema';
|
|
2
|
-
import { StepValue } from '../
|
|
3
|
-
import type { AddMNode, EditorNodeInfo, PastePosition, StoreState } from '../type';
|
|
2
|
+
import type { AddMNode, EditorNodeInfo, PastePosition, StepValue, StoreState } from '../type';
|
|
4
3
|
import { LayerOffset, Layout } from '../type';
|
|
5
4
|
import BaseService from './BaseService';
|
|
6
5
|
declare class Editor extends BaseService {
|
|
@@ -9,14 +8,13 @@ declare class Editor extends BaseService {
|
|
|
9
8
|
constructor();
|
|
10
9
|
/**
|
|
11
10
|
* 设置当前指点节点配置
|
|
12
|
-
* @param name 'root' | 'page' | 'parent' | 'node' | 'highlightNode' | 'nodes'
|
|
11
|
+
* @param name 'root' | 'page' | 'parent' | 'node' | 'highlightNode' | 'nodes' | 'stage' | 'modifiedNodeIds' | 'pageLength'
|
|
13
12
|
* @param value MNode
|
|
14
|
-
* @returns MNode
|
|
15
13
|
*/
|
|
16
14
|
set<T = MNode>(name: keyof StoreState, value: T): void;
|
|
17
15
|
/**
|
|
18
16
|
* 获取当前指点节点配置
|
|
19
|
-
* @param name 'root' | 'page' | 'parent' | 'node' | 'highlightNode' | 'nodes'
|
|
17
|
+
* @param name 'root' | 'page' | 'parent' | 'node' | 'highlightNode' | 'nodes' | 'stage' | 'modifiedNodeIds' | 'pageLength'
|
|
20
18
|
* @returns MNode
|
|
21
19
|
*/
|
|
22
20
|
get<T = MNode>(name: keyof StoreState): T;
|
|
@@ -77,7 +75,6 @@ declare class Editor extends BaseService {
|
|
|
77
75
|
/**
|
|
78
76
|
* 删除组件
|
|
79
77
|
* @param {Object} node
|
|
80
|
-
* @return {Object} 删除的组件配置
|
|
81
78
|
*/
|
|
82
79
|
remove(nodeOrNodeList: MNode | MNode[]): Promise<void>;
|
|
83
80
|
doUpdate(config: MNode): Promise<MNode>;
|
|
@@ -1,21 +1,11 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { MPage } from '@tmagic/schema';
|
|
2
|
+
import { StepValue } from '../type';
|
|
2
3
|
import { UndoRedo } from '../utils/undo-redo';
|
|
3
4
|
import BaseService from './BaseService';
|
|
4
|
-
export interface StepValue {
|
|
5
|
-
data: MPage;
|
|
6
|
-
modifiedNodeIds: Map<Id, Id>;
|
|
7
|
-
nodeId: Id;
|
|
8
|
-
}
|
|
9
|
-
export interface HistoryState {
|
|
10
|
-
pageId?: Id;
|
|
11
|
-
pageSteps: Record<Id, UndoRedo<StepValue>>;
|
|
12
|
-
canRedo: boolean;
|
|
13
|
-
canUndo: boolean;
|
|
14
|
-
}
|
|
15
5
|
declare class History extends BaseService {
|
|
16
6
|
state: {
|
|
17
|
-
pageId?: Id | undefined;
|
|
18
|
-
pageSteps: Record<Id, UndoRedo<StepValue>>;
|
|
7
|
+
pageId?: import("@tmagic/schema").Id | undefined;
|
|
8
|
+
pageSteps: Record<import("@tmagic/schema").Id, UndoRedo<StepValue>>;
|
|
19
9
|
canRedo: boolean;
|
|
20
10
|
canUndo: boolean;
|
|
21
11
|
};
|