@tmagic/editor 1.0.0-rc.7 → 1.0.0-rc.8
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 +3 -0
- package/dist/tmagic-editor.es.js +77 -90
- package/dist/tmagic-editor.es.js.map +1 -1
- package/dist/tmagic-editor.umd.js +76 -91
- package/dist/tmagic-editor.umd.js.map +1 -1
- package/dist/types/src/Editor.vue.d.ts +17 -1
- package/dist/types/src/layouts/workspace/Workspace.vue.d.ts +3 -31
- package/dist/types/src/services/props.d.ts +8 -2
- package/dist/types/src/type.d.ts +9 -0
- package/dist/types/src/utils/editor.d.ts +0 -6
- package/dist/types/src/utils/props.d.ts +8 -1
- package/package.json +7 -7
- package/src/Editor.vue +21 -8
- package/src/layouts/workspace/Stage.vue +11 -31
- package/src/layouts/workspace/Workspace.vue +2 -28
- package/src/theme/workspace.scss +4 -0
- package/src/type.ts +10 -0
- package/src/utils/props.ts +15 -6
|
@@ -62,6 +62,9 @@ declare const _default: DefineComponent<{
|
|
|
62
62
|
/** 画布中组件选中框的移动范围 */
|
|
63
63
|
moveableOptions: {
|
|
64
64
|
type: PropType<MoveableOptions | ((core?: StageCore | undefined) => MoveableOptions)>;
|
|
65
|
+
default: () => (core?: StageCore | undefined) => {
|
|
66
|
+
container: HTMLElement | null | undefined;
|
|
67
|
+
};
|
|
65
68
|
};
|
|
66
69
|
/** 编辑器初始化时默认选中的组件ID */
|
|
67
70
|
defaultSelected: {
|
|
@@ -69,6 +72,7 @@ declare const _default: DefineComponent<{
|
|
|
69
72
|
};
|
|
70
73
|
canSelect: {
|
|
71
74
|
type: PropType<(el: HTMLElement) => boolean | Promise<boolean>>;
|
|
75
|
+
default: (el: HTMLElement) => boolean;
|
|
72
76
|
};
|
|
73
77
|
stageRect: {
|
|
74
78
|
type: PropType<StageRect>;
|
|
@@ -77,6 +81,9 @@ declare const _default: DefineComponent<{
|
|
|
77
81
|
type: ObjectConstructor;
|
|
78
82
|
default: () => {};
|
|
79
83
|
};
|
|
84
|
+
updateDragEl: {
|
|
85
|
+
type: PropType<(el: HTMLDivElement, target: HTMLElement) => void>;
|
|
86
|
+
};
|
|
80
87
|
}, Services, unknown, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, ("props-panel-mounted" | "update:modelValue")[], "props-panel-mounted" | "update:modelValue", VNodeProps & AllowedComponentProps & ComponentCustomProps, Readonly<ExtractPropTypes<{
|
|
81
88
|
/** 页面初始值 */
|
|
82
89
|
modelValue: {
|
|
@@ -135,6 +142,9 @@ declare const _default: DefineComponent<{
|
|
|
135
142
|
/** 画布中组件选中框的移动范围 */
|
|
136
143
|
moveableOptions: {
|
|
137
144
|
type: PropType<MoveableOptions | ((core?: StageCore | undefined) => MoveableOptions)>;
|
|
145
|
+
default: () => (core?: StageCore | undefined) => {
|
|
146
|
+
container: HTMLElement | null | undefined;
|
|
147
|
+
};
|
|
138
148
|
};
|
|
139
149
|
/** 编辑器初始化时默认选中的组件ID */
|
|
140
150
|
defaultSelected: {
|
|
@@ -142,6 +152,7 @@ declare const _default: DefineComponent<{
|
|
|
142
152
|
};
|
|
143
153
|
canSelect: {
|
|
144
154
|
type: PropType<(el: HTMLElement) => boolean | Promise<boolean>>;
|
|
155
|
+
default: (el: HTMLElement) => boolean;
|
|
145
156
|
};
|
|
146
157
|
stageRect: {
|
|
147
158
|
type: PropType<StageRect>;
|
|
@@ -150,6 +161,9 @@ declare const _default: DefineComponent<{
|
|
|
150
161
|
type: ObjectConstructor;
|
|
151
162
|
default: () => {};
|
|
152
163
|
};
|
|
164
|
+
updateDragEl: {
|
|
165
|
+
type: PropType<(el: HTMLDivElement, target: HTMLElement) => void>;
|
|
166
|
+
};
|
|
153
167
|
}>> & {
|
|
154
168
|
"onProps-panel-mounted"?: ((...args: any[]) => any) | undefined;
|
|
155
169
|
"onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
|
|
@@ -157,12 +171,14 @@ declare const _default: DefineComponent<{
|
|
|
157
171
|
menu: MenuBarData;
|
|
158
172
|
layerContentMenu: MenuItem[];
|
|
159
173
|
stageContentMenu: MenuItem[];
|
|
160
|
-
autoScrollIntoView: boolean;
|
|
161
174
|
codeOptions: Record<string, any>;
|
|
162
175
|
modelValue: MApp;
|
|
163
176
|
componentGroupList: ComponentGroup[];
|
|
177
|
+
autoScrollIntoView: boolean;
|
|
164
178
|
propsConfigs: Record<string, FormConfig>;
|
|
165
179
|
propsValues: Record<string, MNode>;
|
|
166
180
|
eventMethodList: Record<string, any>;
|
|
181
|
+
moveableOptions: MoveableOptions | ((core?: StageCore | undefined) => MoveableOptions);
|
|
182
|
+
canSelect: (el: HTMLElement) => boolean | Promise<boolean>;
|
|
167
183
|
}>;
|
|
168
184
|
export default _default;
|
|
@@ -1,35 +1,7 @@
|
|
|
1
|
-
import type { DefineComponent, Ref, ComputedRef, ComponentOptionsMixin, VNodeProps, AllowedComponentProps, ComponentCustomProps, ExtractPropTypes
|
|
1
|
+
import type { DefineComponent, Ref, ComputedRef, ComponentOptionsMixin, EmitsOptions, VNodeProps, AllowedComponentProps, ComponentCustomProps, ExtractPropTypes } from 'vue';
|
|
2
2
|
import type { MPage } from '@tmagic/schema';
|
|
3
|
-
|
|
4
|
-
import StageCore from '@tmagic/stage';
|
|
5
|
-
declare const _default: DefineComponent<{
|
|
6
|
-
runtimeUrl: StringConstructor;
|
|
7
|
-
autoScrollIntoView: BooleanConstructor;
|
|
8
|
-
render: {
|
|
9
|
-
type: PropType<() => HTMLDivElement>;
|
|
10
|
-
};
|
|
11
|
-
moveableOptions: {
|
|
12
|
-
type: PropType<MoveableOptions | ((core?: StageCore | undefined) => MoveableOptions)>;
|
|
13
|
-
};
|
|
14
|
-
canSelect: {
|
|
15
|
-
type: PropType<(el: HTMLElement) => boolean | Promise<boolean>>;
|
|
16
|
-
};
|
|
17
|
-
}, {
|
|
3
|
+
declare const _default: DefineComponent<{}, {
|
|
18
4
|
workspace: Ref<HTMLDivElement | undefined>;
|
|
19
5
|
page: ComputedRef<MPage | undefined>;
|
|
20
|
-
},
|
|
21
|
-
runtimeUrl: StringConstructor;
|
|
22
|
-
autoScrollIntoView: BooleanConstructor;
|
|
23
|
-
render: {
|
|
24
|
-
type: PropType<() => HTMLDivElement>;
|
|
25
|
-
};
|
|
26
|
-
moveableOptions: {
|
|
27
|
-
type: PropType<MoveableOptions | ((core?: StageCore | undefined) => MoveableOptions)>;
|
|
28
|
-
};
|
|
29
|
-
canSelect: {
|
|
30
|
-
type: PropType<(el: HTMLElement) => boolean | Promise<boolean>>;
|
|
31
|
-
};
|
|
32
|
-
}>>, {
|
|
33
|
-
autoScrollIntoView: boolean;
|
|
34
|
-
}>;
|
|
6
|
+
}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, EmitsOptions, string, VNodeProps & AllowedComponentProps & ComponentCustomProps, Readonly<ExtractPropTypes<{}>>, {}>;
|
|
35
7
|
export default _default;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { FormConfig } from '@tmagic/form';
|
|
2
|
-
import type { MNode } from '@tmagic/schema';
|
|
2
|
+
import type { MNode, MPage } from '@tmagic/schema';
|
|
3
3
|
import BaseService from './BaseService';
|
|
4
4
|
declare class Props extends BaseService {
|
|
5
5
|
private state;
|
|
@@ -29,7 +29,13 @@ declare class Props extends BaseService {
|
|
|
29
29
|
* @param type 组件类型
|
|
30
30
|
* @returns 组件初始值
|
|
31
31
|
*/
|
|
32
|
-
getPropsValue(type: string, defaultValue?:
|
|
32
|
+
getPropsValue(type: string, defaultValue?: Record<string, any>): Promise<any>;
|
|
33
|
+
createId(type: string | number): Promise<string>;
|
|
34
|
+
/**
|
|
35
|
+
* 将组件与组件的子元素配置中的id都设置成一个新的ID
|
|
36
|
+
* @param {Object} config 组件配置
|
|
37
|
+
*/
|
|
38
|
+
setNewItemId(config: MNode, parent?: MPage): Promise<void>;
|
|
33
39
|
}
|
|
34
40
|
export declare type PropsService = Props;
|
|
35
41
|
declare const _default: Props;
|
package/dist/types/src/type.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ import type { Component } from 'vue';
|
|
|
2
2
|
import type { FormConfig } from '@tmagic/form';
|
|
3
3
|
import type { Id, MApp, MContainer, MNode, MPage } from '@tmagic/schema';
|
|
4
4
|
import type StageCore from '@tmagic/stage';
|
|
5
|
+
import type { MoveableOptions } from '@tmagic/stage';
|
|
5
6
|
import type { ComponentListService } from './services/componentList';
|
|
6
7
|
import type { EditorService } from './services/editor';
|
|
7
8
|
import type { EventsService } from './services/events';
|
|
@@ -21,6 +22,14 @@ export interface Services {
|
|
|
21
22
|
componentListService: ComponentListService;
|
|
22
23
|
uiService: UiService;
|
|
23
24
|
}
|
|
25
|
+
export interface StageOptions {
|
|
26
|
+
runtimeUrl: string;
|
|
27
|
+
autoScrollIntoView: boolean;
|
|
28
|
+
render: () => HTMLDivElement;
|
|
29
|
+
moveableOptions: MoveableOptions | ((core?: StageCore) => MoveableOptions);
|
|
30
|
+
canSelect: (el: HTMLElement) => boolean | Promise<boolean>;
|
|
31
|
+
updateDragEl: (el: HTMLDivElement) => void;
|
|
32
|
+
}
|
|
24
33
|
export interface StoreState {
|
|
25
34
|
root: MApp | null;
|
|
26
35
|
page: MPage | null;
|
|
@@ -2,7 +2,6 @@ import type { MApp, MContainer, MNode, MPage } from '@tmagic/schema';
|
|
|
2
2
|
import type StageCore from '@tmagic/stage';
|
|
3
3
|
import { Layout } from '../type';
|
|
4
4
|
export declare const COPY_STORAGE_KEY = "$MagicEditorCopyData";
|
|
5
|
-
export declare const generateId: (type: string | number) => string;
|
|
6
5
|
/**
|
|
7
6
|
* 获取所有页面配置
|
|
8
7
|
* @param app DSL跟节点
|
|
@@ -27,11 +26,6 @@ export declare const generatePageName: (pageNameList: string[]) => string;
|
|
|
27
26
|
* @returns {string}
|
|
28
27
|
*/
|
|
29
28
|
export declare const generatePageNameByApp: (app: MApp) => string;
|
|
30
|
-
/**
|
|
31
|
-
* 将组件与组件的子元素配置中的id都设置成一个新的ID
|
|
32
|
-
* @param {Object} config 组件配置
|
|
33
|
-
*/
|
|
34
|
-
export declare const setNewItemId: (config: MNode, parent?: MPage | undefined) => void;
|
|
35
29
|
/**
|
|
36
30
|
* @param {Object} node
|
|
37
31
|
* @returns {boolean}
|
|
@@ -41,9 +41,16 @@ export declare const DEFAULT_CONFIG: FormConfig;
|
|
|
41
41
|
* @param type 组件类型
|
|
42
42
|
* @returns Object
|
|
43
43
|
*/
|
|
44
|
-
export declare const getDefaultPropsValue: (type: string) => {
|
|
44
|
+
export declare const getDefaultPropsValue: (type: string, id: string) => {
|
|
45
45
|
type: string;
|
|
46
46
|
id: string;
|
|
47
47
|
style: {};
|
|
48
48
|
name: string;
|
|
49
|
+
items: never[];
|
|
50
|
+
} | {
|
|
51
|
+
type: string;
|
|
52
|
+
id: string;
|
|
53
|
+
style: {};
|
|
54
|
+
name: string;
|
|
55
|
+
items?: undefined;
|
|
49
56
|
};
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "1.0.0-rc.
|
|
2
|
+
"version": "1.0.0-rc.8",
|
|
3
3
|
"name": "@tmagic/editor",
|
|
4
4
|
"sideEffects": [
|
|
5
5
|
"dist/*",
|
|
@@ -43,11 +43,11 @@
|
|
|
43
43
|
"dependencies": {
|
|
44
44
|
"@babel/core": "^7.18.0",
|
|
45
45
|
"@element-plus/icons": "0.0.11",
|
|
46
|
-
"@tmagic/core": "1.0.0-rc.
|
|
47
|
-
"@tmagic/form": "1.0.0-rc.
|
|
48
|
-
"@tmagic/schema": "1.0.0-rc.
|
|
49
|
-
"@tmagic/stage": "1.0.0-rc.
|
|
50
|
-
"@tmagic/utils": "1.0.0-rc.
|
|
46
|
+
"@tmagic/core": "1.0.0-rc.8",
|
|
47
|
+
"@tmagic/form": "1.0.0-rc.8",
|
|
48
|
+
"@tmagic/schema": "1.0.0-rc.8",
|
|
49
|
+
"@tmagic/stage": "1.0.0-rc.8",
|
|
50
|
+
"@tmagic/utils": "1.0.0-rc.8",
|
|
51
51
|
"buffer": "^6.0.3",
|
|
52
52
|
"color": "^3.1.3",
|
|
53
53
|
"element-plus": "^2.2.0",
|
|
@@ -60,7 +60,7 @@
|
|
|
60
60
|
"vue": "^3.2.0"
|
|
61
61
|
},
|
|
62
62
|
"peerDependencies": {
|
|
63
|
-
"@tmagic/form": "1.0.0-rc.
|
|
63
|
+
"@tmagic/form": "1.0.0-rc.8",
|
|
64
64
|
"element-plus": "^2.2.0",
|
|
65
65
|
"monaco-editor": "^0.32.1",
|
|
66
66
|
"vue": "^3.2.0"
|
package/src/Editor.vue
CHANGED
|
@@ -12,13 +12,7 @@
|
|
|
12
12
|
|
|
13
13
|
<template #workspace :editorService="editorService">
|
|
14
14
|
<slot name="workspace">
|
|
15
|
-
<workspace
|
|
16
|
-
:runtime-url="runtimeUrl"
|
|
17
|
-
:auto-scroll-into-view="autoScrollIntoView"
|
|
18
|
-
:render="render"
|
|
19
|
-
:moveable-options="moveableOptions"
|
|
20
|
-
:can-select="canSelect"
|
|
21
|
-
>
|
|
15
|
+
<workspace>
|
|
22
16
|
<template #workspace-content><slot name="workspace-content" :editorService="editorService"></slot></template>
|
|
23
17
|
<template #page-bar-title="{ page }"><slot name="page-bar-title" :page="page"></slot></template>
|
|
24
18
|
<template #page-bar-popover="{ page }"><slot name="page-bar-popover" :page="page"></slot></template>
|
|
@@ -37,7 +31,7 @@
|
|
|
37
31
|
</template>
|
|
38
32
|
|
|
39
33
|
<script lang="ts">
|
|
40
|
-
import { defineComponent, onUnmounted, PropType, provide, toRaw, watch } from 'vue';
|
|
34
|
+
import { defineComponent, onUnmounted, PropType, provide, reactive, toRaw, watch } from 'vue';
|
|
41
35
|
|
|
42
36
|
import { EventOption } from '@tmagic/core';
|
|
43
37
|
import type { FormConfig } from '@tmagic/form';
|
|
@@ -136,6 +130,9 @@ export default defineComponent({
|
|
|
136
130
|
/** 画布中组件选中框的移动范围 */
|
|
137
131
|
moveableOptions: {
|
|
138
132
|
type: [Object, Function] as PropType<MoveableOptions | ((core?: StageCore) => MoveableOptions)>,
|
|
133
|
+
default: () => (core?: StageCore) => ({
|
|
134
|
+
container: core?.renderer?.contentWindow?.document.getElementById('app'),
|
|
135
|
+
}),
|
|
139
136
|
},
|
|
140
137
|
|
|
141
138
|
/** 编辑器初始化时默认选中的组件ID */
|
|
@@ -145,6 +142,7 @@ export default defineComponent({
|
|
|
145
142
|
|
|
146
143
|
canSelect: {
|
|
147
144
|
type: Function as PropType<(el: HTMLElement) => boolean | Promise<boolean>>,
|
|
145
|
+
default: (el: HTMLElement) => Boolean(el.id),
|
|
148
146
|
},
|
|
149
147
|
|
|
150
148
|
stageRect: {
|
|
@@ -155,6 +153,10 @@ export default defineComponent({
|
|
|
155
153
|
type: Object,
|
|
156
154
|
default: () => ({}),
|
|
157
155
|
},
|
|
156
|
+
|
|
157
|
+
updateDragEl: {
|
|
158
|
+
type: Function as PropType<(el: HTMLDivElement, target: HTMLElement) => void>,
|
|
159
|
+
},
|
|
158
160
|
},
|
|
159
161
|
|
|
160
162
|
emits: ['props-panel-mounted', 'update:modelValue'],
|
|
@@ -249,6 +251,17 @@ export default defineComponent({
|
|
|
249
251
|
|
|
250
252
|
provide('layerContentMenu', props.layerContentMenu);
|
|
251
253
|
provide('stageContentMenu', props.stageContentMenu);
|
|
254
|
+
provide(
|
|
255
|
+
'stageOptions',
|
|
256
|
+
reactive({
|
|
257
|
+
runtimeUrl: props.runtimeUrl,
|
|
258
|
+
autoScrollIntoView: props.autoScrollIntoView,
|
|
259
|
+
render: props.render,
|
|
260
|
+
moveableOptions: props.moveableOptions,
|
|
261
|
+
canSelect: props.canSelect,
|
|
262
|
+
updateDragEl: props.updateDragEl,
|
|
263
|
+
}),
|
|
264
|
+
);
|
|
252
265
|
|
|
253
266
|
return services;
|
|
254
267
|
},
|
|
@@ -28,7 +28,6 @@ import {
|
|
|
28
28
|
markRaw,
|
|
29
29
|
onMounted,
|
|
30
30
|
onUnmounted,
|
|
31
|
-
PropType,
|
|
32
31
|
ref,
|
|
33
32
|
toRaw,
|
|
34
33
|
watch,
|
|
@@ -37,11 +36,11 @@ import {
|
|
|
37
36
|
import { cloneDeep } from 'lodash-es';
|
|
38
37
|
|
|
39
38
|
import type { MApp, MNode, MPage } from '@tmagic/schema';
|
|
40
|
-
import type {
|
|
39
|
+
import type { Runtime, SortEventData, UpdateEventData } from '@tmagic/stage';
|
|
41
40
|
import StageCore from '@tmagic/stage';
|
|
42
41
|
|
|
43
42
|
import ScrollViewer from '@editor/components/ScrollViewer.vue';
|
|
44
|
-
import { Layout, Services, StageRect } from '@editor/type';
|
|
43
|
+
import { Layout, Services, StageOptions, StageRect } from '@editor/type';
|
|
45
44
|
|
|
46
45
|
import ViewerMenu from './ViewerMenu.vue';
|
|
47
46
|
|
|
@@ -53,29 +52,9 @@ export default defineComponent({
|
|
|
53
52
|
ScrollViewer,
|
|
54
53
|
},
|
|
55
54
|
|
|
56
|
-
|
|
57
|
-
render: {
|
|
58
|
-
type: Function as PropType<() => HTMLDivElement>,
|
|
59
|
-
},
|
|
60
|
-
|
|
61
|
-
runtimeUrl: String,
|
|
62
|
-
autoScrollIntoView: Boolean,
|
|
63
|
-
|
|
64
|
-
canSelect: {
|
|
65
|
-
type: Function as PropType<(el: HTMLElement) => boolean | Promise<boolean>>,
|
|
66
|
-
default: (el: HTMLElement) => Boolean(el.id),
|
|
67
|
-
},
|
|
68
|
-
|
|
69
|
-
moveableOptions: {
|
|
70
|
-
type: [Object, Function] as PropType<MoveableOptions | ((core?: StageCore) => MoveableOptions)>,
|
|
71
|
-
default: () => (core?: StageCore) => ({
|
|
72
|
-
container: core?.renderer?.contentWindow?.document.getElementById('app'),
|
|
73
|
-
}),
|
|
74
|
-
},
|
|
75
|
-
},
|
|
76
|
-
|
|
77
|
-
setup(props) {
|
|
55
|
+
setup() {
|
|
78
56
|
const services = inject<Services>('services');
|
|
57
|
+
const stageOptions = inject<StageOptions>('stageOptions');
|
|
79
58
|
|
|
80
59
|
const stageWrap = ref<InstanceType<typeof ScrollViewer>>();
|
|
81
60
|
const stageContainer = ref<HTMLDivElement>();
|
|
@@ -95,15 +74,15 @@ export default defineComponent({
|
|
|
95
74
|
if (stage) return;
|
|
96
75
|
|
|
97
76
|
if (!stageContainer.value) return;
|
|
98
|
-
if (!(
|
|
77
|
+
if (!(stageOptions?.runtimeUrl || stageOptions?.render) || !root.value) return;
|
|
99
78
|
|
|
100
79
|
stage = new StageCore({
|
|
101
|
-
render:
|
|
102
|
-
runtimeUrl:
|
|
80
|
+
render: stageOptions.render,
|
|
81
|
+
runtimeUrl: stageOptions.runtimeUrl,
|
|
103
82
|
zoom: zoom.value,
|
|
104
|
-
autoScrollIntoView:
|
|
83
|
+
autoScrollIntoView: stageOptions.autoScrollIntoView,
|
|
105
84
|
canSelect: (el, event, stop) => {
|
|
106
|
-
const elCanSelect =
|
|
85
|
+
const elCanSelect = stageOptions.canSelect(el);
|
|
107
86
|
// 在组件联动过程中不能再往下选择,返回并触发 ui-select
|
|
108
87
|
if (uiSelectMode.value && elCanSelect && event.type === 'mousedown') {
|
|
109
88
|
document.dispatchEvent(new CustomEvent('ui-select', { detail: el }));
|
|
@@ -112,7 +91,8 @@ export default defineComponent({
|
|
|
112
91
|
|
|
113
92
|
return elCanSelect;
|
|
114
93
|
},
|
|
115
|
-
moveableOptions:
|
|
94
|
+
moveableOptions: stageOptions.moveableOptions,
|
|
95
|
+
updateDragEl: stageOptions.updateDragEl,
|
|
116
96
|
});
|
|
117
97
|
|
|
118
98
|
services?.editorService.set('stage', markRaw(stage));
|
|
@@ -1,13 +1,6 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<div class="m-editor-workspace" tabindex="1" ref="workspace">
|
|
3
|
-
<magic-stage
|
|
4
|
-
:key="page?.id"
|
|
5
|
-
:runtime-url="runtimeUrl"
|
|
6
|
-
:auto-scroll-into-view="autoScrollIntoView"
|
|
7
|
-
:render="render"
|
|
8
|
-
:moveable-options="moveableOptions"
|
|
9
|
-
:can-select="canSelect"
|
|
10
|
-
></magic-stage>
|
|
3
|
+
<magic-stage :key="page?.id"></magic-stage>
|
|
11
4
|
|
|
12
5
|
<slot name="workspace-content"></slot>
|
|
13
6
|
|
|
@@ -19,12 +12,10 @@
|
|
|
19
12
|
</template>
|
|
20
13
|
|
|
21
14
|
<script lang="ts">
|
|
22
|
-
import { computed, defineComponent, inject, onMounted, onUnmounted,
|
|
15
|
+
import { computed, defineComponent, inject, onMounted, onUnmounted, ref } from 'vue';
|
|
23
16
|
import KeyController from 'keycon';
|
|
24
17
|
|
|
25
18
|
import type { MNode, MPage } from '@tmagic/schema';
|
|
26
|
-
import type { MoveableOptions } from '@tmagic/stage';
|
|
27
|
-
import StageCore from '@tmagic/stage';
|
|
28
19
|
import { isPage } from '@tmagic/utils';
|
|
29
20
|
|
|
30
21
|
import type { Services } from '@editor/type';
|
|
@@ -40,23 +31,6 @@ export default defineComponent({
|
|
|
40
31
|
MagicStage,
|
|
41
32
|
},
|
|
42
33
|
|
|
43
|
-
props: {
|
|
44
|
-
runtimeUrl: String,
|
|
45
|
-
autoScrollIntoView: Boolean,
|
|
46
|
-
|
|
47
|
-
render: {
|
|
48
|
-
type: Function as PropType<() => HTMLDivElement>,
|
|
49
|
-
},
|
|
50
|
-
|
|
51
|
-
moveableOptions: {
|
|
52
|
-
type: [Object, Function] as PropType<MoveableOptions | ((core?: StageCore) => MoveableOptions)>,
|
|
53
|
-
},
|
|
54
|
-
|
|
55
|
-
canSelect: {
|
|
56
|
-
type: Function as PropType<(el: HTMLElement) => boolean | Promise<boolean>>,
|
|
57
|
-
},
|
|
58
|
-
},
|
|
59
|
-
|
|
60
34
|
setup() {
|
|
61
35
|
const services = inject<Services>('services');
|
|
62
36
|
const workspace = ref<HTMLDivElement>();
|
package/src/theme/workspace.scss
CHANGED
package/src/type.ts
CHANGED
|
@@ -21,6 +21,7 @@ import type { Component } from 'vue';
|
|
|
21
21
|
import type { FormConfig } from '@tmagic/form';
|
|
22
22
|
import type { Id, MApp, MContainer, MNode, MPage } from '@tmagic/schema';
|
|
23
23
|
import type StageCore from '@tmagic/stage';
|
|
24
|
+
import type { MoveableOptions } from '@tmagic/stage';
|
|
24
25
|
|
|
25
26
|
import type { ComponentListService } from '@editor/services/componentList';
|
|
26
27
|
import type { EditorService } from '@editor/services/editor';
|
|
@@ -45,6 +46,15 @@ export interface Services {
|
|
|
45
46
|
uiService: UiService;
|
|
46
47
|
}
|
|
47
48
|
|
|
49
|
+
export interface StageOptions {
|
|
50
|
+
runtimeUrl: string;
|
|
51
|
+
autoScrollIntoView: boolean;
|
|
52
|
+
render: () => HTMLDivElement;
|
|
53
|
+
moveableOptions: MoveableOptions | ((core?: StageCore) => MoveableOptions);
|
|
54
|
+
canSelect: (el: HTMLElement) => boolean | Promise<boolean>;
|
|
55
|
+
updateDragEl: (el: HTMLDivElement) => void;
|
|
56
|
+
}
|
|
57
|
+
|
|
48
58
|
export interface StoreState {
|
|
49
59
|
root: MApp | null;
|
|
50
60
|
page: MPage | null;
|
package/src/utils/props.ts
CHANGED
|
@@ -243,9 +243,18 @@ export const DEFAULT_CONFIG: FormConfig = fillConfig([]);
|
|
|
243
243
|
* @param type 组件类型
|
|
244
244
|
* @returns Object
|
|
245
245
|
*/
|
|
246
|
-
export const getDefaultPropsValue = (type: string, id: string) =>
|
|
247
|
-
type
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
}
|
|
246
|
+
export const getDefaultPropsValue = (type: string, id: string) =>
|
|
247
|
+
['page', 'container'].includes(type)
|
|
248
|
+
? {
|
|
249
|
+
type,
|
|
250
|
+
id,
|
|
251
|
+
style: {},
|
|
252
|
+
name: type,
|
|
253
|
+
items: [],
|
|
254
|
+
}
|
|
255
|
+
: {
|
|
256
|
+
type,
|
|
257
|
+
id,
|
|
258
|
+
style: {},
|
|
259
|
+
name: type,
|
|
260
|
+
};
|