@tmagic/editor 1.1.0-beta.3 → 1.1.0-beta.6
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 +1 -1
- package/dist/{tmagic-editor.es.js → tmagic-editor.mjs} +1342 -1130
- package/dist/tmagic-editor.mjs.map +1 -0
- package/dist/tmagic-editor.umd.js +1357 -1145
- package/dist/tmagic-editor.umd.js.map +1 -1
- package/package.json +21 -19
- package/src/Editor.vue +14 -12
- package/src/components/ContentMenu.vue +87 -99
- package/src/components/ScrollViewer.vue +2 -2
- package/src/components/ToolButton.vue +150 -167
- package/src/fields/UISelect.vue +50 -70
- package/src/index.ts +1 -0
- package/src/layouts/AddPageBox.vue +2 -2
- package/src/layouts/Framework.vue +1 -1
- package/src/layouts/NavMenu.vue +2 -2
- package/src/layouts/PropsPanel.vue +1 -1
- package/src/layouts/Resizer.vue +1 -1
- package/src/layouts/sidebar/ComponentListPanel.vue +2 -2
- package/src/layouts/sidebar/LayerMenu.vue +2 -2
- package/src/layouts/sidebar/LayerPanel.vue +13 -4
- package/src/layouts/sidebar/Sidebar.vue +1 -1
- package/src/layouts/sidebar/TabPane.vue +2 -2
- package/src/layouts/workspace/PageBar.vue +53 -64
- package/src/layouts/workspace/Stage.vue +195 -220
- package/src/layouts/workspace/ViewerMenu.vue +142 -146
- package/src/layouts/workspace/Workspace.vue +11 -11
- package/src/services/BaseService.ts +1 -1
- package/src/services/componentList.ts +3 -3
- package/src/services/editor.ts +118 -135
- package/src/services/events.ts +1 -1
- package/src/services/history.ts +1 -1
- package/src/services/props.ts +63 -11
- package/src/services/storage.ts +133 -0
- package/src/services/ui.ts +10 -4
- package/src/theme/framework.scss +1 -1
- package/src/theme/stage.scss +2 -2
- package/src/type.ts +23 -6
- package/src/utils/config.ts +1 -1
- package/src/utils/editor.ts +1 -1
- package/src/utils/operator.ts +210 -0
- package/src/utils/props.ts +2 -24
- package/src/utils/scroll-viewer.ts +1 -1
- package/tsconfig.build.json +13 -0
- package/{dist/types/src → types}/Editor.vue.d.ts +7 -8
- package/types/components/ContentMenu.vue.d.ts +116 -0
- package/types/components/Icon.vue.d.ts +13 -0
- package/types/components/ScrollViewer.vue.d.ts +22 -0
- package/types/components/ToolButton.vue.d.ts +109 -0
- package/types/fields/Code.vue.d.ts +23 -0
- package/{dist/types/src → types}/fields/CodeLink.vue.d.ts +4 -6
- package/types/fields/UISelect.vue.d.ts +87 -0
- package/{dist/types/src → types}/index.d.ts +4 -1
- package/types/layouts/AddPageBox.vue.d.ts +4 -0
- package/{dist/types/src → types}/layouts/CodeEditor.vue.d.ts +11 -13
- package/types/layouts/Framework.vue.d.ts +22 -0
- package/types/layouts/NavMenu.vue.d.ts +25 -0
- package/types/layouts/PropsPanel.vue.d.ts +245 -0
- package/types/layouts/Resizer.vue.d.ts +12 -0
- package/types/layouts/sidebar/ComponentListPanel.vue.d.ts +14 -0
- package/types/layouts/sidebar/LayerMenu.vue.d.ts +100 -0
- package/types/layouts/sidebar/LayerPanel.vue.d.ts +1099 -0
- package/{dist/types/src → types}/layouts/sidebar/Sidebar.vue.d.ts +3 -5
- package/types/layouts/sidebar/TabPane.vue.d.ts +14 -0
- package/types/layouts/workspace/PageBar.vue.d.ts +54 -0
- package/types/layouts/workspace/Stage.vue.d.ts +46 -0
- package/types/layouts/workspace/ViewerMenu.vue.d.ts +88 -0
- package/types/layouts/workspace/Workspace.vue.d.ts +6 -0
- package/{dist/types/src → types}/services/BaseService.d.ts +0 -0
- package/types/services/componentList.d.ts +14 -0
- package/{dist/types/src → types}/services/editor.d.ts +26 -11
- package/{dist/types/src → types}/services/events.d.ts +0 -0
- package/{dist/types/src → types}/services/history.d.ts +0 -0
- package/{dist/types/src → types}/services/props.d.ts +26 -2
- package/types/services/storage.d.ts +56 -0
- package/{dist/types/src → types}/services/ui.d.ts +1 -1
- package/{dist/types/src → types}/type.d.ts +16 -0
- package/{dist/types/src → types}/utils/compose.d.ts +1 -1
- package/{dist/types/src → types}/utils/config.d.ts +0 -0
- package/{dist/types/src → types}/utils/editor.d.ts +2 -2
- package/{dist/types/src → types}/utils/index.d.ts +0 -0
- package/{dist/types/src → types}/utils/logger.d.ts +0 -0
- package/types/utils/operator.d.ts +44 -0
- package/{dist/types/src → types}/utils/polyfills.d.ts +0 -0
- package/{dist/types/src → types}/utils/props.d.ts +2 -22
- package/{dist/types/src → types}/utils/scroll-viewer.d.ts +0 -0
- package/{dist/types/src → types}/utils/undo-redo.d.ts +0 -0
- package/dist/tmagic-editor.es.js.map +0 -1
- package/dist/types/src/components/Icon.vue.d.ts +0 -14
- package/dist/types/src/components/ScrollViewer.vue.d.ts +0 -24
- package/dist/types/src/fields/Code.vue.d.ts +0 -25
- package/dist/types/src/layouts/AddPageBox.vue.d.ts +0 -5
- package/dist/types/src/layouts/Framework.vue.d.ts +0 -24
- package/dist/types/src/layouts/NavMenu.vue.d.ts +0 -27
- package/dist/types/src/layouts/PropsPanel.vue.d.ts +0 -13
- package/dist/types/src/layouts/Resizer.vue.d.ts +0 -14
- package/dist/types/src/layouts/sidebar/ComponentListPanel.vue.d.ts +0 -16
- package/dist/types/src/layouts/sidebar/TabPane.vue.d.ts +0 -16
- package/dist/types/src/layouts/workspace/Workspace.vue.d.ts +0 -8
- package/dist/types/src/shims-vue.d.ts +0 -6
- package/dist/types/src/vite-env.d.ts +0 -1
- package/src/vite-env.d.ts +0 -1
package/src/fields/UISelect.vue
CHANGED
|
@@ -12,89 +12,69 @@
|
|
|
12
12
|
</div>
|
|
13
13
|
</template>
|
|
14
14
|
|
|
15
|
-
<script lang="ts">
|
|
16
|
-
import { computed,
|
|
17
|
-
import { Close, Delete
|
|
15
|
+
<script lang="ts" setup>
|
|
16
|
+
import { computed, inject, ref } from 'vue';
|
|
17
|
+
import { Close, Delete } from '@element-plus/icons-vue';
|
|
18
18
|
|
|
19
19
|
import { FormState } from '@tmagic/form';
|
|
20
20
|
|
|
21
|
-
import { Services } from '
|
|
21
|
+
import { Services } from '../type';
|
|
22
22
|
|
|
23
|
-
|
|
24
|
-
|
|
23
|
+
const props = defineProps<{
|
|
24
|
+
labelWidth: string;
|
|
25
|
+
config: any;
|
|
26
|
+
model: any;
|
|
27
|
+
prop: string;
|
|
28
|
+
name: string;
|
|
29
|
+
}>();
|
|
25
30
|
|
|
26
|
-
|
|
27
|
-
labelWidth: String,
|
|
28
|
-
config: Object,
|
|
29
|
-
model: Object,
|
|
30
|
-
prop: {
|
|
31
|
-
type: String,
|
|
32
|
-
default() {
|
|
33
|
-
return '';
|
|
34
|
-
},
|
|
35
|
-
},
|
|
36
|
-
name: String,
|
|
37
|
-
},
|
|
31
|
+
const emit = defineEmits(['change']);
|
|
38
32
|
|
|
39
|
-
|
|
33
|
+
const services = inject<Services>('services');
|
|
34
|
+
const mForm = inject<FormState>('mForm');
|
|
35
|
+
const val = computed(() => props.model[props.name]);
|
|
36
|
+
const uiSelectMode = ref(false);
|
|
40
37
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
38
|
+
const cancelHandler = () => {
|
|
39
|
+
if (!services?.uiService) return;
|
|
40
|
+
services.uiService.set<boolean>('uiSelectMode', false);
|
|
41
|
+
uiSelectMode.value = false;
|
|
42
|
+
globalThis.document.removeEventListener('ui-select', clickHandler as EventListener);
|
|
43
|
+
};
|
|
46
44
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
const clickHandler = ({ detail }: Event & { detail: any }) => {
|
|
55
|
-
if (detail.id) {
|
|
56
|
-
props.model[props.name] = detail.id;
|
|
57
|
-
emit('change', detail.id);
|
|
58
|
-
mForm?.$emit('field-change', props.prop, detail.id);
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
if (cancelHandler) {
|
|
62
|
-
cancelHandler();
|
|
63
|
-
}
|
|
64
|
-
};
|
|
65
|
-
|
|
66
|
-
return {
|
|
67
|
-
Delete: markRaw(Delete),
|
|
68
|
-
Pointer: markRaw(Pointer),
|
|
69
|
-
Close: markRaw(Close),
|
|
45
|
+
const clickHandler = ({ detail }: Event & { detail: any }) => {
|
|
46
|
+
if (detail.id) {
|
|
47
|
+
props.model[props.name] = detail.id;
|
|
48
|
+
emit('change', detail.id);
|
|
49
|
+
mForm?.$emit('field-change', props.prop, detail.id);
|
|
50
|
+
}
|
|
70
51
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
return config?.name || '';
|
|
76
|
-
}),
|
|
52
|
+
if (cancelHandler) {
|
|
53
|
+
cancelHandler();
|
|
54
|
+
}
|
|
55
|
+
};
|
|
77
56
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
globalThis.document.addEventListener('ui-select', clickHandler as EventListener);
|
|
83
|
-
},
|
|
57
|
+
const toName = computed(() => {
|
|
58
|
+
const config = services?.editorService.getNodeById(val.value);
|
|
59
|
+
return config?.name || '';
|
|
60
|
+
});
|
|
84
61
|
|
|
85
|
-
|
|
62
|
+
const startSelect = () => {
|
|
63
|
+
if (!services?.uiService) return;
|
|
64
|
+
services.uiService.set<boolean>('uiSelectMode', true);
|
|
65
|
+
uiSelectMode.value = true;
|
|
66
|
+
globalThis.document.addEventListener('ui-select', clickHandler as EventListener);
|
|
67
|
+
};
|
|
86
68
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
};
|
|
95
|
-
},
|
|
96
|
-
});
|
|
69
|
+
const deleteHandler = () => {
|
|
70
|
+
if (props.model) {
|
|
71
|
+
props.model[props.name] = '';
|
|
72
|
+
emit('change', '');
|
|
73
|
+
mForm?.$emit('field-change', props.prop, '');
|
|
74
|
+
}
|
|
75
|
+
};
|
|
97
76
|
</script>
|
|
77
|
+
|
|
98
78
|
<style lang="scss">
|
|
99
79
|
.m-fields-ui-select {
|
|
100
80
|
cursor: pointer;
|
package/src/index.ts
CHANGED
|
@@ -37,6 +37,7 @@ export { default as TMagicCodeEditor } from './layouts/CodeEditor.vue';
|
|
|
37
37
|
export { default as editorService } from './services/editor';
|
|
38
38
|
export { default as propsService } from './services/props';
|
|
39
39
|
export { default as historyService } from './services/history';
|
|
40
|
+
export { default as storageService } from './services/storage';
|
|
40
41
|
export { default as eventsService } from './services/events';
|
|
41
42
|
export { default as uiService } from './services/ui';
|
|
42
43
|
export { default as ComponentListPanel } from './layouts/sidebar/ComponentListPanel.vue';
|
|
@@ -17,8 +17,8 @@ import { Plus } from '@element-plus/icons-vue';
|
|
|
17
17
|
|
|
18
18
|
import { NodeType } from '@tmagic/schema';
|
|
19
19
|
|
|
20
|
-
import type { Services } from '
|
|
21
|
-
import { generatePageNameByApp } from '
|
|
20
|
+
import type { Services } from '../type';
|
|
21
|
+
import { generatePageNameByApp } from '../utils';
|
|
22
22
|
|
|
23
23
|
export default defineComponent({
|
|
24
24
|
components: { Plus },
|
|
@@ -43,7 +43,7 @@ import { computed, defineComponent, inject } from 'vue';
|
|
|
43
43
|
|
|
44
44
|
import type { MApp } from '@tmagic/schema';
|
|
45
45
|
|
|
46
|
-
import { GetColumnWidth, Services } from '
|
|
46
|
+
import { GetColumnWidth, Services } from '../type';
|
|
47
47
|
|
|
48
48
|
import AddPageBox from './AddPageBox.vue';
|
|
49
49
|
import Resizer from './Resizer.vue';
|
package/src/layouts/NavMenu.vue
CHANGED
|
@@ -9,8 +9,8 @@
|
|
|
9
9
|
<script lang="ts">
|
|
10
10
|
import { computed, defineComponent, inject, PropType } from 'vue';
|
|
11
11
|
|
|
12
|
-
import ToolButton from '
|
|
13
|
-
import { GetColumnWidth, MenuBarData, Services } from '
|
|
12
|
+
import ToolButton from '../components/ToolButton.vue';
|
|
13
|
+
import { GetColumnWidth, MenuBarData, Services } from '../type';
|
|
14
14
|
|
|
15
15
|
export default defineComponent({
|
|
16
16
|
name: 'nav-menu',
|
|
@@ -20,7 +20,7 @@ import { ElMessage } from 'element-plus';
|
|
|
20
20
|
import type { FormValue, MForm } from '@tmagic/form';
|
|
21
21
|
import type { MNode } from '@tmagic/schema';
|
|
22
22
|
|
|
23
|
-
import type { Services } from '
|
|
23
|
+
import type { Services } from '../type';
|
|
24
24
|
|
|
25
25
|
export default defineComponent({
|
|
26
26
|
name: 'm-editor-props-panel',
|
package/src/layouts/Resizer.vue
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
import { defineComponent, inject, onMounted, onUnmounted, ref, toRaw } from 'vue';
|
|
9
9
|
import Gesto from 'gesto';
|
|
10
10
|
|
|
11
|
-
import { Services } from '
|
|
11
|
+
import { Services } from '../type';
|
|
12
12
|
|
|
13
13
|
export default defineComponent({
|
|
14
14
|
name: 'm-editor-resize',
|
|
@@ -43,8 +43,8 @@ import serialize from 'serialize-javascript';
|
|
|
43
43
|
import type StageCore from '@tmagic/stage';
|
|
44
44
|
import { removeClassNameByClassName } from '@tmagic/utils';
|
|
45
45
|
|
|
46
|
-
import MIcon from '
|
|
47
|
-
import type { ComponentGroup, ComponentItem, Services, StageOptions } from '
|
|
46
|
+
import MIcon from '../../components/Icon.vue';
|
|
47
|
+
import type { ComponentGroup, ComponentItem, Services, StageOptions } from '../../type';
|
|
48
48
|
|
|
49
49
|
export default defineComponent({
|
|
50
50
|
name: 'ui-component-panel',
|
|
@@ -8,8 +8,8 @@ import { Delete, DocumentCopy, Files, Plus } from '@element-plus/icons-vue';
|
|
|
8
8
|
|
|
9
9
|
import { NodeType } from '@tmagic/schema';
|
|
10
10
|
|
|
11
|
-
import ContentMenu from '
|
|
12
|
-
import type { ComponentGroup, MenuButton, MenuItem, Services } from '
|
|
11
|
+
import ContentMenu from '../../components/ContentMenu.vue';
|
|
12
|
+
import type { ComponentGroup, MenuButton, MenuItem, Services } from '../../type';
|
|
13
13
|
|
|
14
14
|
export default defineComponent({
|
|
15
15
|
components: { ContentMenu },
|
|
@@ -61,11 +61,12 @@ import type { ElTree } from 'element-plus';
|
|
|
61
61
|
import { throttle } from 'lodash-es';
|
|
62
62
|
|
|
63
63
|
import type { MNode, MPage } from '@tmagic/schema';
|
|
64
|
-
import { NodeType } from '@tmagic/schema';
|
|
64
|
+
import { MContainer, NodeType } from '@tmagic/schema';
|
|
65
65
|
import StageCore from '@tmagic/stage';
|
|
66
66
|
|
|
67
|
-
import type { EditorService } from '
|
|
68
|
-
import type { Services } from '
|
|
67
|
+
import type { EditorService } from '../../services/editor';
|
|
68
|
+
import type { Services } from '../../type';
|
|
69
|
+
import { Layout } from '../../type';
|
|
69
70
|
|
|
70
71
|
import LayerMenu from './LayerMenu.vue';
|
|
71
72
|
|
|
@@ -104,8 +105,16 @@ const useDrop = (tree: Ref<InstanceType<typeof ElTree> | undefined>, editorServi
|
|
|
104
105
|
return false;
|
|
105
106
|
},
|
|
106
107
|
|
|
107
|
-
handleDragEnd() {
|
|
108
|
+
async handleDragEnd(e: any) {
|
|
108
109
|
if (!tree.value) return;
|
|
110
|
+
const { data: node } = e;
|
|
111
|
+
const parent = editorService?.getParentById(node.id, false) as MContainer;
|
|
112
|
+
const layout = await editorService?.getLayout(parent);
|
|
113
|
+
node.style.position = layout;
|
|
114
|
+
if (layout === Layout.RELATIVE) {
|
|
115
|
+
node.style.top = 0;
|
|
116
|
+
node.style.left = 0;
|
|
117
|
+
}
|
|
109
118
|
const { data } = tree.value;
|
|
110
119
|
const [page] = data as [MPage];
|
|
111
120
|
editorService?.update(page);
|
|
@@ -29,8 +29,8 @@
|
|
|
29
29
|
import { computed, defineComponent, PropType } from 'vue';
|
|
30
30
|
import { Coin, Files } from '@element-plus/icons-vue';
|
|
31
31
|
|
|
32
|
-
import MIcon from '
|
|
33
|
-
import { SideComponent, SideItem } from '
|
|
32
|
+
import MIcon from '../../components/Icon.vue';
|
|
33
|
+
import { SideComponent, SideItem } from '../../type';
|
|
34
34
|
|
|
35
35
|
import ComponentListPanel from './ComponentListPanel.vue';
|
|
36
36
|
import LayerPanel from './LayerPanel.vue';
|
|
@@ -3,10 +3,19 @@
|
|
|
3
3
|
<div id="m-editor-page-bar-add-icon" class="m-editor-page-bar-item m-editor-page-bar-item-icon" @click="addPage">
|
|
4
4
|
<el-icon><plus></plus></el-icon>
|
|
5
5
|
</div>
|
|
6
|
-
<div
|
|
6
|
+
<div
|
|
7
|
+
v-if="scrollState.canScroll"
|
|
8
|
+
class="m-editor-page-bar-item m-editor-page-bar-item-icon"
|
|
9
|
+
@click="scrollState.scroll('left')"
|
|
10
|
+
>
|
|
7
11
|
<el-icon><arrow-left-bold></arrow-left-bold></el-icon>
|
|
8
12
|
</div>
|
|
9
|
-
<div
|
|
13
|
+
<div
|
|
14
|
+
v-if="root"
|
|
15
|
+
class="m-editor-page-bar-items"
|
|
16
|
+
ref="itemsContainer"
|
|
17
|
+
:style="`width: ${scrollState.itemsContainerWidth}px`"
|
|
18
|
+
>
|
|
10
19
|
<div
|
|
11
20
|
v-for="item in root.items"
|
|
12
21
|
:key="item.key"
|
|
@@ -51,33 +60,26 @@
|
|
|
51
60
|
</el-popover>
|
|
52
61
|
</div>
|
|
53
62
|
</div>
|
|
54
|
-
<div
|
|
63
|
+
<div
|
|
64
|
+
v-if="scrollState.canScroll"
|
|
65
|
+
class="m-editor-page-bar-item m-editor-page-bar-item-icon"
|
|
66
|
+
@click="scrollState.scroll('right')"
|
|
67
|
+
>
|
|
55
68
|
<el-icon><arrow-right-bold></arrow-right-bold></el-icon>
|
|
56
69
|
</div>
|
|
57
70
|
</div>
|
|
58
71
|
</template>
|
|
59
72
|
|
|
60
|
-
<script lang="ts">
|
|
61
|
-
import {
|
|
62
|
-
computed,
|
|
63
|
-
ComputedRef,
|
|
64
|
-
defineComponent,
|
|
65
|
-
inject,
|
|
66
|
-
markRaw,
|
|
67
|
-
onMounted,
|
|
68
|
-
onUnmounted,
|
|
69
|
-
ref,
|
|
70
|
-
toRaw,
|
|
71
|
-
watch,
|
|
72
|
-
} from 'vue';
|
|
73
|
+
<script lang="ts" setup>
|
|
74
|
+
import { computed, ComputedRef, inject, onMounted, onUnmounted, ref, toRaw, watch } from 'vue';
|
|
73
75
|
import { ArrowLeftBold, ArrowRightBold, CaretBottom, Delete, DocumentCopy, Plus } from '@element-plus/icons-vue';
|
|
74
76
|
|
|
75
77
|
import type { MApp, MPage } from '@tmagic/schema';
|
|
76
78
|
import { NodeType } from '@tmagic/schema';
|
|
77
79
|
|
|
78
|
-
import ToolButton from '
|
|
79
|
-
import type { Services } from '
|
|
80
|
-
import { generatePageNameByApp } from '
|
|
80
|
+
import ToolButton from '../../components/ToolButton.vue';
|
|
81
|
+
import type { Services } from '../../type';
|
|
82
|
+
import { generatePageNameByApp } from '../../utils/editor';
|
|
81
83
|
|
|
82
84
|
const useScroll = (root: ComputedRef<MApp | undefined>) => {
|
|
83
85
|
const pageBar = ref<HTMLDivElement>();
|
|
@@ -163,49 +165,36 @@ const useScroll = (root: ComputedRef<MApp | undefined>) => {
|
|
|
163
165
|
};
|
|
164
166
|
};
|
|
165
167
|
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
node && editorService?.copy(node);
|
|
199
|
-
editorService?.paste({
|
|
200
|
-
left: 0,
|
|
201
|
-
top: 0,
|
|
202
|
-
});
|
|
203
|
-
},
|
|
204
|
-
|
|
205
|
-
remove(node: MPage) {
|
|
206
|
-
editorService?.remove(node);
|
|
207
|
-
},
|
|
208
|
-
};
|
|
209
|
-
},
|
|
210
|
-
});
|
|
168
|
+
const services = inject<Services>('services');
|
|
169
|
+
const editorService = services?.editorService;
|
|
170
|
+
|
|
171
|
+
const root = computed(() => editorService?.get<MApp>('root'));
|
|
172
|
+
|
|
173
|
+
const scrollState = useScroll(root);
|
|
174
|
+
const page = computed(() => editorService?.get('page'));
|
|
175
|
+
|
|
176
|
+
const switchPage = (page: MPage) => {
|
|
177
|
+
editorService?.select(page);
|
|
178
|
+
};
|
|
179
|
+
|
|
180
|
+
const addPage = () => {
|
|
181
|
+
if (!editorService) return;
|
|
182
|
+
const pageConfig = {
|
|
183
|
+
type: NodeType.PAGE,
|
|
184
|
+
name: generatePageNameByApp(toRaw(editorService.get('root'))),
|
|
185
|
+
};
|
|
186
|
+
editorService.add(pageConfig);
|
|
187
|
+
};
|
|
188
|
+
|
|
189
|
+
const copy = (node: MPage) => {
|
|
190
|
+
node && editorService?.copy(node);
|
|
191
|
+
editorService?.paste({
|
|
192
|
+
left: 0,
|
|
193
|
+
top: 0,
|
|
194
|
+
});
|
|
195
|
+
};
|
|
196
|
+
|
|
197
|
+
const remove = (node: MPage) => {
|
|
198
|
+
editorService?.remove(node);
|
|
199
|
+
};
|
|
211
200
|
</script>
|