@tmagic/editor 1.2.0-beta.1 → 1.2.0-beta.3
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 +769 -768
- package/dist/tmagic-editor.mjs.map +1 -1
- package/dist/tmagic-editor.umd.js +773 -771
- package/dist/tmagic-editor.umd.js.map +1 -1
- package/package.json +9 -9
- package/src/Editor.vue +2 -2
- package/src/components/ContentMenu.vue +2 -2
- package/src/components/Icon.vue +6 -4
- package/src/components/ToolButton.vue +29 -14
- package/src/fields/Code.vue +4 -1
- package/src/fields/CodeLink.vue +19 -11
- package/src/fields/CodeSelect.vue +6 -6
- package/src/fields/UISelect.vue +8 -7
- package/src/index.ts +2 -1
- package/src/layouts/AddPageBox.vue +13 -20
- package/src/layouts/CodeEditor.vue +106 -120
- package/src/layouts/Framework.vue +3 -2
- package/src/layouts/PropsPanel.vue +3 -8
- package/src/layouts/sidebar/ComponentListPanel.vue +13 -11
- package/src/layouts/sidebar/LayerMenu.vue +86 -91
- package/src/layouts/sidebar/LayerPanel.vue +252 -162
- package/src/layouts/sidebar/Sidebar.vue +24 -28
- package/src/layouts/sidebar/TabPane.vue +43 -51
- package/src/layouts/sidebar/code-block/CodeBlockEditor.vue +22 -18
- package/src/layouts/sidebar/code-block/CodeBlockList.vue +21 -21
- package/src/layouts/workspace/PageBar.vue +11 -10
- package/src/services/codeBlock.ts +16 -10
- package/src/services/editor.ts +4 -4
- package/src/theme/index.scss +1 -15
- package/src/theme/theme.scss +15 -0
- package/src/type.ts +1 -1
- package/types/Editor.vue.d.ts +2 -2
- package/types/fields/Code.vue.d.ts +8 -0
- package/types/fields/CodeLink.vue.d.ts +4 -0
- package/types/index.d.ts +1 -0
- package/types/layouts/AddPageBox.vue.d.ts +45 -3
- package/types/layouts/CodeEditor.vue.d.ts +160 -45
- package/types/layouts/sidebar/LayerMenu.vue.d.ts +16 -64
- package/types/layouts/sidebar/LayerPanel.vue.d.ts +16 -1071
- package/types/layouts/sidebar/Sidebar.vue.d.ts +114 -17
- package/types/layouts/sidebar/TabPane.vue.d.ts +80 -12
- package/types/layouts/sidebar/code-block/CodeBlockList.vue.d.ts +1 -0
- package/types/services/codeBlock.d.ts +1 -1
- package/types/services/editor.d.ts +2 -2
- package/types/type.d.ts +1 -1
|
@@ -34,9 +34,9 @@
|
|
|
34
34
|
</template>
|
|
35
35
|
|
|
36
36
|
<template v-if="pageLength > 0" #right>
|
|
37
|
-
<
|
|
37
|
+
<TMagicScrollbar>
|
|
38
38
|
<slot name="props-panel"></slot>
|
|
39
|
-
</
|
|
39
|
+
</TMagicScrollbar>
|
|
40
40
|
</template>
|
|
41
41
|
</layout>
|
|
42
42
|
</div>
|
|
@@ -45,6 +45,7 @@
|
|
|
45
45
|
<script lang="ts" setup>
|
|
46
46
|
import { computed, inject, ref, watchEffect } from 'vue';
|
|
47
47
|
|
|
48
|
+
import { TMagicScrollbar } from '@tmagic/design';
|
|
48
49
|
import type { MApp } from '@tmagic/schema';
|
|
49
50
|
|
|
50
51
|
import { GetColumnWidth, Services } from '../type';
|
|
@@ -15,8 +15,8 @@
|
|
|
15
15
|
|
|
16
16
|
<script lang="ts" setup>
|
|
17
17
|
import { computed, getCurrentInstance, inject, onMounted, ref, watchEffect } from 'vue';
|
|
18
|
-
import { ElMessage } from 'element-plus';
|
|
19
18
|
|
|
19
|
+
import { tMagicMessage } from '@tmagic/design';
|
|
20
20
|
import type { FormValue, MForm } from '@tmagic/form';
|
|
21
21
|
import type { MNode } from '@tmagic/schema';
|
|
22
22
|
import type StageCore from '@tmagic/stage';
|
|
@@ -65,13 +65,8 @@ const submit = async () => {
|
|
|
65
65
|
services?.editorService.update(values);
|
|
66
66
|
} catch (e: any) {
|
|
67
67
|
console.error(e);
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
duration: 10000,
|
|
71
|
-
showClose: true,
|
|
72
|
-
message: e.message,
|
|
73
|
-
dangerouslyUseHTMLString: true,
|
|
74
|
-
});
|
|
68
|
+
tMagicMessage.closeAll();
|
|
69
|
+
tMagicMessage.error(e.message);
|
|
75
70
|
}
|
|
76
71
|
};
|
|
77
72
|
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<
|
|
2
|
+
<TMagicScrollbar>
|
|
3
3
|
<slot name="component-list-panel-header"></slot>
|
|
4
4
|
|
|
5
|
-
<
|
|
6
|
-
<
|
|
5
|
+
<TMagicCollapse class="ui-component-panel" :model-value="collapseValue">
|
|
6
|
+
<TMagicInput
|
|
7
7
|
prefix-icon="el-icon-search"
|
|
8
8
|
placeholder="输入关键字进行过滤"
|
|
9
9
|
class="search-input"
|
|
@@ -12,8 +12,8 @@
|
|
|
12
12
|
v-model="searchText"
|
|
13
13
|
/>
|
|
14
14
|
<template v-for="(group, index) in list">
|
|
15
|
-
<
|
|
16
|
-
<template #title><
|
|
15
|
+
<TMagicCollapseItem v-if="group.items && group.items.length" :key="index" :name="`${index}`">
|
|
16
|
+
<template #title><MIcon :icon="Grid"></MIcon>{{ group.title }}</template>
|
|
17
17
|
<div
|
|
18
18
|
v-for="item in group.items"
|
|
19
19
|
class="component-item"
|
|
@@ -27,21 +27,23 @@
|
|
|
27
27
|
<slot name="component-list-item" :component="item">
|
|
28
28
|
<MIcon :icon="item.icon"></MIcon>
|
|
29
29
|
|
|
30
|
-
<
|
|
30
|
+
<TMagicTooltip effect="dark" placement="bottom" :content="item.text">
|
|
31
31
|
<span>{{ item.text }}</span>
|
|
32
|
-
</
|
|
32
|
+
</TMagicTooltip>
|
|
33
33
|
</slot>
|
|
34
34
|
</div>
|
|
35
|
-
</
|
|
35
|
+
</TMagicCollapseItem>
|
|
36
36
|
</template>
|
|
37
|
-
</
|
|
38
|
-
</
|
|
37
|
+
</TMagicCollapse>
|
|
38
|
+
</TMagicScrollbar>
|
|
39
39
|
</template>
|
|
40
40
|
|
|
41
41
|
<script lang="ts" setup>
|
|
42
42
|
import { computed, inject, ref } from 'vue';
|
|
43
|
+
import { Grid } from '@element-plus/icons-vue';
|
|
43
44
|
import serialize from 'serialize-javascript';
|
|
44
45
|
|
|
46
|
+
import { TMagicCollapse, TMagicCollapseItem, TMagicInput, TMagicScrollbar, TMagicTooltip } from '@tmagic/design';
|
|
45
47
|
import type StageCore from '@tmagic/stage';
|
|
46
48
|
import { removeClassNameByClassName } from '@tmagic/utils';
|
|
47
49
|
|
|
@@ -62,7 +64,7 @@ const list = computed(() =>
|
|
|
62
64
|
const collapseValue = computed(() =>
|
|
63
65
|
Array(list.value?.length)
|
|
64
66
|
.fill(1)
|
|
65
|
-
.map((x, i) => i),
|
|
67
|
+
.map((x, i) => `${i}`),
|
|
66
68
|
);
|
|
67
69
|
|
|
68
70
|
let timeout: NodeJS.Timeout | undefined;
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
<content-menu :menu-data="menuData" ref="menu" style="overflow: initial"></content-menu>
|
|
3
3
|
</template>
|
|
4
4
|
|
|
5
|
-
<script lang="ts">
|
|
6
|
-
import { computed,
|
|
5
|
+
<script lang="ts" setup>
|
|
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,100 @@ 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 services = inject<Services>('services');
|
|
15
|
+
const menu = ref<InstanceType<typeof ContentMenu>>();
|
|
16
|
+
const node = computed(() => services?.editorService.get('node'));
|
|
17
|
+
const isRoot = computed(() => node.value?.type === NodeType.ROOT);
|
|
18
|
+
const isPage = computed(() => node.value?.type === NodeType.PAGE);
|
|
19
|
+
const componentList = computed(() => services?.componentListService.getList() || []);
|
|
16
20
|
|
|
17
|
-
|
|
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() || []);
|
|
21
|
+
const layerContentMenu = inject<(MenuComponent | MenuButton)[]>('layerContentMenu', []);
|
|
24
22
|
|
|
25
|
-
|
|
23
|
+
const createMenuItems = (group: ComponentGroup): MenuButton[] =>
|
|
24
|
+
group.items.map((component) => ({
|
|
25
|
+
text: component.text,
|
|
26
|
+
type: 'button',
|
|
27
|
+
icon: component.icon,
|
|
28
|
+
handler: () => {
|
|
29
|
+
services?.editorService.add({
|
|
30
|
+
name: component.text,
|
|
31
|
+
type: component.type,
|
|
32
|
+
...(component.data || {}),
|
|
33
|
+
});
|
|
34
|
+
},
|
|
35
|
+
}));
|
|
26
36
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
37
|
+
const getSubMenuData = computed<MenuButton[]>(() => {
|
|
38
|
+
if (node.value?.type === 'tabs') {
|
|
39
|
+
return [
|
|
40
|
+
{
|
|
41
|
+
text: '标签页',
|
|
30
42
|
type: 'button',
|
|
31
|
-
icon:
|
|
43
|
+
icon: Files,
|
|
32
44
|
handler: () => {
|
|
33
45
|
services?.editorService.add({
|
|
34
|
-
|
|
35
|
-
type: component.type,
|
|
36
|
-
...(component.data || {}),
|
|
46
|
+
type: 'tab-pane',
|
|
37
47
|
});
|
|
38
48
|
},
|
|
39
|
-
}
|
|
49
|
+
},
|
|
50
|
+
];
|
|
51
|
+
}
|
|
52
|
+
if (node.value?.items) {
|
|
53
|
+
return (
|
|
54
|
+
componentList.value.reduce(
|
|
55
|
+
(subMenuData: MenuButton[], group: ComponentGroup, index) =>
|
|
56
|
+
subMenuData.concat(
|
|
57
|
+
createMenuItems(group),
|
|
58
|
+
index < componentList.value.length - 1
|
|
59
|
+
? [
|
|
60
|
+
{
|
|
61
|
+
type: 'divider',
|
|
62
|
+
direction: 'horizontal',
|
|
63
|
+
},
|
|
64
|
+
]
|
|
65
|
+
: [],
|
|
66
|
+
),
|
|
67
|
+
[],
|
|
68
|
+
) || []
|
|
69
|
+
);
|
|
70
|
+
}
|
|
71
|
+
return [];
|
|
72
|
+
});
|
|
40
73
|
|
|
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
|
-
});
|
|
74
|
+
const menuData = computed<(MenuButton | MenuComponent)[]>(() => [
|
|
75
|
+
{
|
|
76
|
+
type: 'button',
|
|
77
|
+
text: '新增',
|
|
78
|
+
icon: markRaw(Plus),
|
|
79
|
+
display: () => node.value?.items,
|
|
80
|
+
items: getSubMenuData.value,
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
type: 'button',
|
|
84
|
+
text: '复制',
|
|
85
|
+
icon: markRaw(DocumentCopy),
|
|
86
|
+
display: () => !isRoot.value,
|
|
87
|
+
handler: () => {
|
|
88
|
+
node.value && services?.editorService.copy(node.value);
|
|
89
|
+
},
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
type: 'button',
|
|
93
|
+
text: '删除',
|
|
94
|
+
icon: markRaw(Delete),
|
|
95
|
+
display: () => !isRoot.value && !isPage.value,
|
|
96
|
+
handler: () => {
|
|
97
|
+
node.value && services?.editorService.remove(node.value);
|
|
98
|
+
},
|
|
99
|
+
},
|
|
100
|
+
...layerContentMenu,
|
|
101
|
+
]);
|
|
77
102
|
|
|
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
|
-
]),
|
|
103
|
+
const show = (e: MouseEvent) => {
|
|
104
|
+
menu.value?.show(e);
|
|
105
|
+
};
|
|
108
106
|
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
},
|
|
112
|
-
};
|
|
113
|
-
},
|
|
107
|
+
defineExpose({
|
|
108
|
+
show,
|
|
114
109
|
});
|
|
115
110
|
</script>
|