@tmagic/editor 1.1.6 → 1.2.0-beta.10
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 +191 -8
- package/dist/tmagic-editor.mjs +2104 -1027
- package/dist/tmagic-editor.mjs.map +1 -1
- package/dist/tmagic-editor.umd.js +2136 -1053
- package/dist/tmagic-editor.umd.js.map +1 -1
- package/package.json +11 -10
- package/src/Editor.vue +27 -12
- package/src/components/ContentMenu.vue +4 -4
- package/src/components/Icon.vue +7 -5
- package/src/{layouts → components}/Layout.vue +15 -5
- package/src/components/ScrollBar.vue +1 -1
- package/src/components/ScrollViewer.vue +10 -1
- package/src/components/ToolButton.vue +30 -15
- package/src/fields/Code.vue +5 -2
- package/src/fields/CodeLink.vue +20 -12
- package/src/fields/CodeSelect.vue +131 -0
- package/src/fields/UISelect.vue +9 -8
- package/src/index.ts +7 -2
- package/src/layouts/AddPageBox.vue +13 -20
- package/src/layouts/CodeEditor.vue +106 -120
- package/src/layouts/Framework.vue +62 -40
- package/src/layouts/NavMenu.vue +1 -1
- package/src/layouts/PropsPanel.vue +5 -10
- package/src/layouts/Resizer.vue +1 -1
- package/src/layouts/sidebar/ComponentListPanel.vue +15 -13
- package/src/layouts/sidebar/LayerMenu.vue +89 -92
- package/src/layouts/sidebar/LayerPanel.vue +273 -178
- package/src/layouts/sidebar/Sidebar.vue +129 -37
- package/src/layouts/sidebar/code-block/CodeBlockEditor.vue +169 -0
- package/src/layouts/sidebar/code-block/CodeBlockList.vue +267 -0
- package/src/layouts/workspace/Breadcrumb.vue +32 -0
- package/src/layouts/workspace/PageBar.vue +12 -11
- package/src/layouts/workspace/PageBarScrollContainer.vue +1 -1
- package/src/layouts/workspace/Stage.vue +15 -7
- package/src/layouts/workspace/ViewerMenu.vue +8 -7
- package/src/layouts/workspace/Workspace.vue +10 -3
- package/src/services/codeBlock.ts +415 -0
- package/src/services/editor.ts +35 -5
- package/src/theme/breadcrumb.scss +6 -0
- package/src/theme/code-block.scss +184 -0
- package/src/theme/component-list-panel.scss +3 -7
- package/src/theme/index.scss +1 -13
- package/src/theme/layer-panel.scss +7 -2
- package/src/theme/layout.scss +5 -0
- package/src/theme/theme.scss +16 -0
- package/src/type.ts +88 -1
- package/src/utils/props.ts +9 -3
- package/src/utils/scroll-viewer.ts +18 -2
- package/src/utils/stage.ts +7 -0
- package/types/Editor.vue.d.ts +2 -2
- package/types/components/ContentMenu.vue.d.ts +1 -3
- package/types/components/Icon.vue.d.ts +1 -3
- package/types/{layouts → components}/Layout.vue.d.ts +0 -0
- package/types/components/ScrollBar.vue.d.ts +1 -3
- package/types/components/ScrollViewer.vue.d.ts +45 -1
- package/types/components/ToolButton.vue.d.ts +1 -3
- package/types/fields/Code.vue.d.ts +9 -3
- package/types/fields/CodeLink.vue.d.ts +5 -3
- package/types/fields/CodeSelect.vue.d.ts +94 -0
- package/types/fields/UISelect.vue.d.ts +1 -3
- package/types/index.d.ts +4 -0
- package/types/layouts/AddPageBox.vue.d.ts +43 -3
- package/types/layouts/CodeEditor.vue.d.ts +158 -45
- package/types/layouts/NavMenu.vue.d.ts +1 -3
- package/types/layouts/sidebar/LayerMenu.vue.d.ts +31 -63
- package/types/layouts/sidebar/LayerPanel.vue.d.ts +38 -1074
- package/types/layouts/sidebar/Sidebar.vue.d.ts +119 -17
- package/types/layouts/sidebar/code-block/CodeBlockEditor.vue.d.ts +50 -0
- package/types/layouts/sidebar/code-block/CodeBlockList.vue.d.ts +73 -0
- package/types/layouts/workspace/Breadcrumb.vue.d.ts +44 -0
- package/types/layouts/workspace/Stage.vue.d.ts +23 -7
- package/types/layouts/workspace/ViewerMenu.vue.d.ts +6 -3
- package/types/layouts/workspace/Workspace.vue.d.ts +23 -5
- package/types/services/codeBlock.d.ts +155 -0
- package/types/services/editor.d.ts +12 -1
- package/types/services/props.d.ts +12 -0
- package/types/services/ui.d.ts +1 -1
- package/types/type.d.ts +78 -1
- package/types/utils/props.d.ts +12 -0
- package/types/utils/scroll-viewer.d.ts +5 -0
- package/src/layouts/sidebar/TabPane.vue +0 -99
- package/types/layouts/sidebar/TabPane.vue.d.ts +0 -14
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<
|
|
2
|
+
<ContentMenu :menu-data="menuData" ref="menu" style="overflow: initial"></ContentMenu>
|
|
3
3
|
</template>
|
|
4
4
|
|
|
5
|
-
<script lang="ts">
|
|
6
|
-
import { computed,
|
|
5
|
+
<script lang="ts" setup name="MEditorLayerMenu">
|
|
6
|
+
import { computed, inject, markRaw, ref } from 'vue';
|
|
7
7
|
import { Delete, DocumentCopy, Files, Plus } from '@element-plus/icons-vue';
|
|
8
8
|
|
|
9
9
|
import { NodeType } from '@tmagic/schema';
|
|
@@ -11,105 +11,102 @@ import { NodeType } from '@tmagic/schema';
|
|
|
11
11
|
import ContentMenu from '../../components/ContentMenu.vue';
|
|
12
12
|
import type { ComponentGroup, MenuButton, MenuComponent, Services } from '../../type';
|
|
13
13
|
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
const props = defineProps<{
|
|
15
|
+
layerContentMenu: (MenuButton | MenuComponent)[];
|
|
16
|
+
}>();
|
|
16
17
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
const componentList = computed(() => services?.componentListService.getList() || []);
|
|
18
|
+
const services = inject<Services>('services');
|
|
19
|
+
const menu = ref<InstanceType<typeof ContentMenu>>();
|
|
20
|
+
const node = computed(() => services?.editorService.get('node'));
|
|
21
|
+
const isRoot = computed(() => node.value?.type === NodeType.ROOT);
|
|
22
|
+
const isPage = computed(() => node.value?.type === NodeType.PAGE);
|
|
23
|
+
const componentList = computed(() => services?.componentListService.getList() || []);
|
|
24
24
|
|
|
25
|
-
|
|
25
|
+
const createMenuItems = (group: ComponentGroup): MenuButton[] =>
|
|
26
|
+
group.items.map((component) => ({
|
|
27
|
+
text: component.text,
|
|
28
|
+
type: 'button',
|
|
29
|
+
icon: component.icon,
|
|
30
|
+
handler: () => {
|
|
31
|
+
services?.editorService.add({
|
|
32
|
+
name: component.text,
|
|
33
|
+
type: component.type,
|
|
34
|
+
...(component.data || {}),
|
|
35
|
+
});
|
|
36
|
+
},
|
|
37
|
+
}));
|
|
26
38
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
39
|
+
const getSubMenuData = computed<MenuButton[]>(() => {
|
|
40
|
+
if (node.value?.type === 'tabs') {
|
|
41
|
+
return [
|
|
42
|
+
{
|
|
43
|
+
text: '标签页',
|
|
30
44
|
type: 'button',
|
|
31
|
-
icon:
|
|
45
|
+
icon: Files,
|
|
32
46
|
handler: () => {
|
|
33
47
|
services?.editorService.add({
|
|
34
|
-
|
|
35
|
-
type: component.type,
|
|
36
|
-
...(component.data || {}),
|
|
48
|
+
type: 'tab-pane',
|
|
37
49
|
});
|
|
38
50
|
},
|
|
39
|
-
}
|
|
51
|
+
},
|
|
52
|
+
];
|
|
53
|
+
}
|
|
54
|
+
if (node.value?.items) {
|
|
55
|
+
return (
|
|
56
|
+
componentList.value.reduce(
|
|
57
|
+
(subMenuData: MenuButton[], group: ComponentGroup, index) =>
|
|
58
|
+
subMenuData.concat(
|
|
59
|
+
createMenuItems(group),
|
|
60
|
+
index < componentList.value.length - 1
|
|
61
|
+
? [
|
|
62
|
+
{
|
|
63
|
+
type: 'divider',
|
|
64
|
+
direction: 'horizontal',
|
|
65
|
+
},
|
|
66
|
+
]
|
|
67
|
+
: [],
|
|
68
|
+
),
|
|
69
|
+
[],
|
|
70
|
+
) || []
|
|
71
|
+
);
|
|
72
|
+
}
|
|
73
|
+
return [];
|
|
74
|
+
});
|
|
40
75
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
: [],
|
|
70
|
-
),
|
|
71
|
-
[],
|
|
72
|
-
) || []
|
|
73
|
-
);
|
|
74
|
-
}
|
|
75
|
-
return [];
|
|
76
|
-
});
|
|
76
|
+
const menuData = computed<(MenuButton | MenuComponent)[]>(() => [
|
|
77
|
+
{
|
|
78
|
+
type: 'button',
|
|
79
|
+
text: '新增',
|
|
80
|
+
icon: markRaw(Plus),
|
|
81
|
+
display: () => node.value?.items,
|
|
82
|
+
items: getSubMenuData.value,
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
type: 'button',
|
|
86
|
+
text: '复制',
|
|
87
|
+
icon: markRaw(DocumentCopy),
|
|
88
|
+
display: () => !isRoot.value,
|
|
89
|
+
handler: () => {
|
|
90
|
+
node.value && services?.editorService.copy(node.value);
|
|
91
|
+
},
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
type: 'button',
|
|
95
|
+
text: '删除',
|
|
96
|
+
icon: markRaw(Delete),
|
|
97
|
+
display: () => !isRoot.value && !isPage.value,
|
|
98
|
+
handler: () => {
|
|
99
|
+
node.value && services?.editorService.remove(node.value);
|
|
100
|
+
},
|
|
101
|
+
},
|
|
102
|
+
...props.layerContentMenu,
|
|
103
|
+
]);
|
|
77
104
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
{
|
|
82
|
-
type: 'button',
|
|
83
|
-
text: '新增',
|
|
84
|
-
icon: markRaw(Plus),
|
|
85
|
-
display: () => node.value?.items,
|
|
86
|
-
items: getSubMenuData.value,
|
|
87
|
-
},
|
|
88
|
-
{
|
|
89
|
-
type: 'button',
|
|
90
|
-
text: '复制',
|
|
91
|
-
icon: markRaw(DocumentCopy),
|
|
92
|
-
display: () => !isRoot.value,
|
|
93
|
-
handler: () => {
|
|
94
|
-
node.value && services?.editorService.copy(node.value);
|
|
95
|
-
},
|
|
96
|
-
},
|
|
97
|
-
{
|
|
98
|
-
type: 'button',
|
|
99
|
-
text: '删除',
|
|
100
|
-
icon: markRaw(Delete),
|
|
101
|
-
display: () => !isRoot.value && !isPage.value,
|
|
102
|
-
handler: () => {
|
|
103
|
-
node.value && services?.editorService.remove(node.value);
|
|
104
|
-
},
|
|
105
|
-
},
|
|
106
|
-
...layerContentMenu,
|
|
107
|
-
]),
|
|
105
|
+
const show = (e: MouseEvent) => {
|
|
106
|
+
menu.value?.show(e);
|
|
107
|
+
};
|
|
108
108
|
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
},
|
|
112
|
-
};
|
|
113
|
-
},
|
|
109
|
+
defineExpose({
|
|
110
|
+
show,
|
|
114
111
|
});
|
|
115
112
|
</script>
|