@tmagic/editor 1.0.6 → 1.1.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 +5 -1
- package/dist/{tmagic-editor.es.js → tmagic-editor.mjs} +1522 -1177
- package/dist/tmagic-editor.mjs.map +1 -0
- package/dist/tmagic-editor.umd.js +1606 -1259
- package/dist/tmagic-editor.umd.js.map +1 -1
- package/package.json +22 -20
- package/src/Editor.vue +41 -15
- package/src/components/ContentMenu.vue +87 -99
- package/src/components/Icon.vue +2 -2
- package/src/components/ScrollViewer.vue +2 -2
- package/src/components/ToolButton.vue +151 -168
- package/src/fields/UISelect.vue +49 -70
- package/src/index.ts +2 -1
- package/src/layouts/AddPageBox.vue +3 -3
- 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 +43 -2
- package/src/layouts/sidebar/LayerMenu.vue +3 -3
- package/src/layouts/sidebar/LayerPanel.vue +13 -4
- package/src/layouts/sidebar/Sidebar.vue +1 -1
- package/src/layouts/sidebar/TabPane.vue +3 -3
- package/src/layouts/workspace/PageBar.vue +63 -192
- package/src/layouts/workspace/PageBarScrollContainer.vue +111 -0
- package/src/layouts/workspace/Stage.vue +208 -188
- package/src/layouts/workspace/ViewerMenu.vue +141 -148
- package/src/layouts/workspace/Workspace.vue +11 -11
- package/src/services/BaseService.ts +5 -10
- package/src/services/componentList.ts +3 -3
- package/src/services/editor.ts +247 -140
- 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/component-list-panel.scss +5 -0
- package/src/theme/framework.scss +1 -1
- package/src/theme/stage.scss +2 -2
- package/src/type.ts +28 -7
- package/src/utils/config.ts +1 -1
- package/src/utils/editor.ts +53 -35
- package/src/utils/operator.ts +109 -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 +44 -9
- 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 +83 -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/PageBarScrollContainer.vue.d.ts +48 -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 +27 -14
- 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 +21 -1
- 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 +11 -4
- 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 +21 -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 -14
- 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/package.json
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "1.0.
|
|
2
|
+
"version": "1.1.0-beta.10",
|
|
3
3
|
"name": "@tmagic/editor",
|
|
4
4
|
"sideEffects": [
|
|
5
5
|
"dist/*",
|
|
6
6
|
"src/theme/*"
|
|
7
7
|
],
|
|
8
8
|
"main": "dist/tmagic-editor.umd.js",
|
|
9
|
-
"module": "dist/tmagic-editor.
|
|
9
|
+
"module": "dist/tmagic-editor.mjs",
|
|
10
10
|
"style": "dist/style.css",
|
|
11
|
-
"types": "
|
|
11
|
+
"types": "types/index.d.ts",
|
|
12
12
|
"exports": {
|
|
13
13
|
".": {
|
|
14
|
-
"import": "./dist/tmagic-editor.
|
|
14
|
+
"import": "./dist/tmagic-editor.mjs",
|
|
15
15
|
"require": "./dist/tmagic-editor.umd.js"
|
|
16
16
|
},
|
|
17
17
|
"./dist/style.css": {
|
|
@@ -22,7 +22,9 @@
|
|
|
22
22
|
},
|
|
23
23
|
"license": "Apache-2.0",
|
|
24
24
|
"scripts": {
|
|
25
|
-
"build": "
|
|
25
|
+
"build": "npm run build:type && vite build",
|
|
26
|
+
"build:type": "npm run clear:type && vue-tsc --declaration --emitDeclarationOnly --project tsconfig.build.json",
|
|
27
|
+
"clear:type": "rimraf ./types"
|
|
26
28
|
},
|
|
27
29
|
"engines": {
|
|
28
30
|
"node": ">=14"
|
|
@@ -42,12 +44,12 @@
|
|
|
42
44
|
],
|
|
43
45
|
"dependencies": {
|
|
44
46
|
"@babel/core": "^7.18.0",
|
|
45
|
-
"@element-plus/icons": "
|
|
46
|
-
"@tmagic/core": "1.0.
|
|
47
|
-
"@tmagic/form": "1.0.
|
|
48
|
-
"@tmagic/schema": "1.0.
|
|
49
|
-
"@tmagic/stage": "1.0.
|
|
50
|
-
"@tmagic/utils": "1.0.
|
|
47
|
+
"@element-plus/icons-vue": "^2.0.6",
|
|
48
|
+
"@tmagic/core": "1.1.0-beta.10",
|
|
49
|
+
"@tmagic/form": "1.1.0-beta.10",
|
|
50
|
+
"@tmagic/schema": "1.1.0-beta.10",
|
|
51
|
+
"@tmagic/stage": "1.1.0-beta.10",
|
|
52
|
+
"@tmagic/utils": "1.1.0-beta.10",
|
|
51
53
|
"buffer": "^6.0.3",
|
|
52
54
|
"color": "^3.1.3",
|
|
53
55
|
"element-plus": "^2.2.6",
|
|
@@ -57,26 +59,26 @@
|
|
|
57
59
|
"lodash-es": "^4.17.21",
|
|
58
60
|
"monaco-editor": "^0.32.1",
|
|
59
61
|
"serialize-javascript": "^6.0.0",
|
|
60
|
-
"vue": "^3.2.
|
|
62
|
+
"vue": "^3.2.37"
|
|
61
63
|
},
|
|
62
64
|
"peerDependencies": {
|
|
63
|
-
"@tmagic/form": "1.0.
|
|
65
|
+
"@tmagic/form": "1.1.0-beta.10",
|
|
64
66
|
"element-plus": "^2.2.6",
|
|
65
67
|
"monaco-editor": "^0.32.1",
|
|
66
|
-
"vue": "^3.2.
|
|
68
|
+
"vue": "^3.2.37"
|
|
67
69
|
},
|
|
68
70
|
"devDependencies": {
|
|
69
71
|
"@types/events": "^3.0.0",
|
|
70
72
|
"@types/lodash-es": "^4.17.4",
|
|
71
73
|
"@types/node": "^15.12.4",
|
|
72
74
|
"@types/serialize-javascript": "^5.0.1",
|
|
73
|
-
"@vitejs/plugin-vue": "^
|
|
74
|
-
"@vue/compiler-sfc": "^3.2.
|
|
75
|
+
"@vitejs/plugin-vue": "^3.0.1",
|
|
76
|
+
"@vue/compiler-sfc": "^3.2.37",
|
|
75
77
|
"@vue/test-utils": "^2.0.0",
|
|
78
|
+
"rimraf": "^3.0.2",
|
|
76
79
|
"sass": "^1.35.1",
|
|
77
|
-
"typescript": "^4.
|
|
78
|
-
"vite": "^
|
|
79
|
-
"
|
|
80
|
-
"vue-tsc": "^0.38.2"
|
|
80
|
+
"typescript": "^4.7.4",
|
|
81
|
+
"vite": "^3.0.4",
|
|
82
|
+
"vue-tsc": "^0.39.4"
|
|
81
83
|
}
|
|
82
84
|
}
|
package/src/Editor.vue
CHANGED
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
|
|
31
31
|
<template #props-panel>
|
|
32
32
|
<slot name="props-panel">
|
|
33
|
-
<props-panel ref="propsPanel" @mounted="(instance) => $emit('props-panel-mounted', instance)">
|
|
33
|
+
<props-panel ref="propsPanel" @mounted="(instance: any) => $emit('props-panel-mounted', instance)">
|
|
34
34
|
<template #props-panel-header>
|
|
35
35
|
<slot name="props-panel-header"></slot>
|
|
36
36
|
</template>
|
|
@@ -49,20 +49,21 @@ import { EventOption } from '@tmagic/core';
|
|
|
49
49
|
import type { FormConfig } from '@tmagic/form';
|
|
50
50
|
import type { MApp, MNode } from '@tmagic/schema';
|
|
51
51
|
import type StageCore from '@tmagic/stage';
|
|
52
|
-
import
|
|
53
|
-
|
|
54
|
-
import Framework from '
|
|
55
|
-
import NavMenu from '
|
|
56
|
-
import PropsPanel from '
|
|
57
|
-
import Sidebar from '
|
|
58
|
-
import Workspace from '
|
|
59
|
-
import componentListService from '
|
|
60
|
-
import editorService from '
|
|
61
|
-
import eventsService from '
|
|
62
|
-
import historyService from '
|
|
63
|
-
import propsService from '
|
|
64
|
-
import
|
|
65
|
-
import
|
|
52
|
+
import { CONTAINER_HIGHLIGHT_CLASS, ContainerHighlightType, MoveableOptions } from '@tmagic/stage';
|
|
53
|
+
|
|
54
|
+
import Framework from './layouts/Framework.vue';
|
|
55
|
+
import NavMenu from './layouts/NavMenu.vue';
|
|
56
|
+
import PropsPanel from './layouts/PropsPanel.vue';
|
|
57
|
+
import Sidebar from './layouts/sidebar/Sidebar.vue';
|
|
58
|
+
import Workspace from './layouts/workspace/Workspace.vue';
|
|
59
|
+
import componentListService from './services/componentList';
|
|
60
|
+
import editorService from './services/editor';
|
|
61
|
+
import eventsService from './services/events';
|
|
62
|
+
import historyService from './services/history';
|
|
63
|
+
import propsService from './services/props';
|
|
64
|
+
import storageService from './services/storage';
|
|
65
|
+
import uiService from './services/ui';
|
|
66
|
+
import type { ComponentGroup, MenuBarData, MenuItem, Services, SideBarData, StageRect } from './type';
|
|
66
67
|
|
|
67
68
|
export default defineComponent({
|
|
68
69
|
name: 'm-editor',
|
|
@@ -154,6 +155,26 @@ export default defineComponent({
|
|
|
154
155
|
default: (el: HTMLElement) => Boolean(el.id),
|
|
155
156
|
},
|
|
156
157
|
|
|
158
|
+
isContainer: {
|
|
159
|
+
type: Function as PropType<(el: HTMLElement) => boolean | Promise<boolean>>,
|
|
160
|
+
default: (el: HTMLElement) => el.classList.contains('magic-ui-container'),
|
|
161
|
+
},
|
|
162
|
+
|
|
163
|
+
containerHighlightClassName: {
|
|
164
|
+
type: String,
|
|
165
|
+
default: CONTAINER_HIGHLIGHT_CLASS,
|
|
166
|
+
},
|
|
167
|
+
|
|
168
|
+
containerHighlightDuration: {
|
|
169
|
+
type: Number,
|
|
170
|
+
default: 800,
|
|
171
|
+
},
|
|
172
|
+
|
|
173
|
+
containerHighlightType: {
|
|
174
|
+
type: String as PropType<ContainerHighlightType>,
|
|
175
|
+
default: ContainerHighlightType.DEFAULT,
|
|
176
|
+
},
|
|
177
|
+
|
|
157
178
|
stageRect: {
|
|
158
179
|
type: [String, Object] as PropType<StageRect>,
|
|
159
180
|
},
|
|
@@ -254,6 +275,7 @@ export default defineComponent({
|
|
|
254
275
|
propsService,
|
|
255
276
|
editorService,
|
|
256
277
|
uiService,
|
|
278
|
+
storageService,
|
|
257
279
|
};
|
|
258
280
|
|
|
259
281
|
provide('services', services);
|
|
@@ -269,6 +291,10 @@ export default defineComponent({
|
|
|
269
291
|
moveableOptions: props.moveableOptions,
|
|
270
292
|
canSelect: props.canSelect,
|
|
271
293
|
updateDragEl: props.updateDragEl,
|
|
294
|
+
isContainer: props.isContainer,
|
|
295
|
+
containerHighlightClassName: props.containerHighlightClassName,
|
|
296
|
+
containerHighlightDuration: props.containerHighlightDuration,
|
|
297
|
+
containerHighlightType: props.containerHighlightType,
|
|
272
298
|
}),
|
|
273
299
|
);
|
|
274
300
|
|
|
@@ -22,119 +22,107 @@
|
|
|
22
22
|
</div>
|
|
23
23
|
</template>
|
|
24
24
|
|
|
25
|
-
<script lang="ts">
|
|
26
|
-
import {
|
|
25
|
+
<script lang="ts" setup>
|
|
26
|
+
import { nextTick, onMounted, onUnmounted, ref } from 'vue';
|
|
27
27
|
|
|
28
|
-
import { MenuButton, MenuItem } from '
|
|
28
|
+
import { MenuButton, MenuItem } from '../type';
|
|
29
29
|
|
|
30
30
|
import ToolButton from './ToolButton.vue';
|
|
31
31
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
isSubMenu: {
|
|
42
|
-
type: Boolean,
|
|
43
|
-
default: false,
|
|
44
|
-
},
|
|
32
|
+
const props = withDefaults(
|
|
33
|
+
defineProps<{
|
|
34
|
+
menuData?: MenuItem[];
|
|
35
|
+
isSubMenu?: boolean;
|
|
36
|
+
}>(),
|
|
37
|
+
{
|
|
38
|
+
menuData: () => [],
|
|
39
|
+
isSubMenu: false,
|
|
45
40
|
},
|
|
41
|
+
);
|
|
46
42
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
setup(props, { emit }) {
|
|
50
|
-
const menu = ref<HTMLDivElement>();
|
|
51
|
-
const subMenu = ref<any>();
|
|
52
|
-
const visible = ref(false);
|
|
53
|
-
const subMenuData = ref<MenuItem[]>([]);
|
|
54
|
-
const menuStyle = ref({
|
|
55
|
-
left: '0',
|
|
56
|
-
top: '0',
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
const hide = () => {
|
|
60
|
-
if (!visible.value) return;
|
|
61
|
-
|
|
62
|
-
visible.value = false;
|
|
63
|
-
subMenu.value?.hide();
|
|
43
|
+
const emit = defineEmits(['hide', 'show']);
|
|
64
44
|
|
|
65
|
-
|
|
66
|
-
|
|
45
|
+
const menu = ref<HTMLDivElement>();
|
|
46
|
+
const subMenu = ref<any>();
|
|
47
|
+
const visible = ref(false);
|
|
48
|
+
const subMenuData = ref<MenuItem[]>([]);
|
|
49
|
+
const menuStyle = ref({
|
|
50
|
+
left: '0',
|
|
51
|
+
top: '0',
|
|
52
|
+
});
|
|
67
53
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
54
|
+
const hide = () => {
|
|
55
|
+
if (!visible.value) return;
|
|
56
|
+
|
|
57
|
+
visible.value = false;
|
|
58
|
+
subMenu.value?.hide();
|
|
59
|
+
|
|
60
|
+
emit('hide');
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
const hideHandler = (e: MouseEvent) => {
|
|
64
|
+
const target = e.target as HTMLElement | undefined;
|
|
65
|
+
if (!visible.value || !target) {
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
if (menu.value?.contains(target) || subMenu.value?.$el?.contains(target)) {
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
hide();
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
const show = (e: MouseEvent) => {
|
|
75
|
+
// 加settimeout是以为,如果菜单中的按钮监听的是mouseup,那么菜单显示出来时鼠标如果正好在菜单上就会马上触发按钮的mouseup
|
|
76
|
+
setTimeout(() => {
|
|
77
|
+
visible.value = true;
|
|
78
|
+
|
|
79
|
+
nextTick(() => {
|
|
80
|
+
const menuHeight = menu.value?.clientHeight || 0;
|
|
81
|
+
|
|
82
|
+
let top = e.clientY;
|
|
83
|
+
if (menuHeight + e.clientY > document.body.clientHeight) {
|
|
84
|
+
top = document.body.clientHeight - menuHeight;
|
|
75
85
|
}
|
|
76
|
-
hide();
|
|
77
|
-
};
|
|
78
86
|
|
|
79
|
-
|
|
80
|
-
|
|
87
|
+
menuStyle.value = {
|
|
88
|
+
top: `${top}px`,
|
|
89
|
+
left: `${e.clientX}px`,
|
|
90
|
+
};
|
|
81
91
|
|
|
82
|
-
|
|
92
|
+
emit('show');
|
|
83
93
|
});
|
|
94
|
+
}, 300);
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
const showSubMenu = (item: MenuItem) => {
|
|
98
|
+
const menuItem = item as MenuButton;
|
|
99
|
+
if (typeof item !== 'object' || !menuItem.items?.length) {
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
subMenuData.value = menuItem.items;
|
|
104
|
+
if (menu.value) {
|
|
105
|
+
subMenu.value.show({
|
|
106
|
+
clientX: menu.value.offsetLeft + menu.value.clientWidth,
|
|
107
|
+
clientY: menu.value.offsetTop,
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
};
|
|
84
111
|
|
|
85
|
-
|
|
86
|
-
|
|
112
|
+
onMounted(() => {
|
|
113
|
+
if (props.isSubMenu) return;
|
|
87
114
|
|
|
88
|
-
|
|
89
|
-
|
|
115
|
+
globalThis.addEventListener('mousedown', hideHandler, true);
|
|
116
|
+
});
|
|
90
117
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
show(e: MouseEvent) {
|
|
101
|
-
// 加settimeout是以为,如果菜单中的按钮监听的是mouseup,那么菜单显示出来时鼠标如果正好在菜单上就会马上触发按钮的mouseup
|
|
102
|
-
setTimeout(() => {
|
|
103
|
-
visible.value = true;
|
|
104
|
-
|
|
105
|
-
nextTick(() => {
|
|
106
|
-
const menuHeight = menu.value?.clientHeight || 0;
|
|
107
|
-
|
|
108
|
-
let top = e.clientY;
|
|
109
|
-
if (menuHeight + e.clientY > document.body.clientHeight) {
|
|
110
|
-
top = document.body.clientHeight - menuHeight;
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
menuStyle.value = {
|
|
114
|
-
top: `${top}px`,
|
|
115
|
-
left: `${e.clientX}px`,
|
|
116
|
-
};
|
|
117
|
-
|
|
118
|
-
emit('show');
|
|
119
|
-
});
|
|
120
|
-
}, 300);
|
|
121
|
-
},
|
|
122
|
-
|
|
123
|
-
showSubMenu(item: MenuItem) {
|
|
124
|
-
const menuItem = item as MenuButton;
|
|
125
|
-
if (typeof item !== 'object' || !menuItem.items?.length) {
|
|
126
|
-
return;
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
subMenuData.value = menuItem.items;
|
|
130
|
-
if (menu.value) {
|
|
131
|
-
subMenu.value.show({
|
|
132
|
-
clientX: menu.value.offsetLeft + menu.value.clientWidth,
|
|
133
|
-
clientY: menu.value.offsetTop,
|
|
134
|
-
});
|
|
135
|
-
}
|
|
136
|
-
},
|
|
137
|
-
};
|
|
138
|
-
},
|
|
118
|
+
onUnmounted(() => {
|
|
119
|
+
if (props.isSubMenu) return;
|
|
120
|
+
|
|
121
|
+
globalThis.removeEventListener('mousedown', hideHandler, true);
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
defineExpose({
|
|
125
|
+
hide,
|
|
126
|
+
show,
|
|
139
127
|
});
|
|
140
128
|
</script>
|
package/src/components/Icon.vue
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<el-icon v-if="!icon"><edit></edit></el-icon>
|
|
3
|
-
<
|
|
3
|
+
<el-icon v-else-if="typeof icon === 'string' && icon.startsWith('http')"><img :src="icon" /></el-icon>
|
|
4
4
|
<i v-else-if="typeof icon === 'string'" :class="icon"></i>
|
|
5
5
|
<el-icon v-else><component :is="toRaw(icon)"></component></el-icon>
|
|
6
6
|
</template>
|
|
7
7
|
|
|
8
8
|
<script lang="ts">
|
|
9
9
|
import { Component, defineComponent, PropType, toRaw } from 'vue';
|
|
10
|
-
import { Edit } from '@element-plus/icons';
|
|
10
|
+
import { Edit } from '@element-plus/icons-vue';
|
|
11
11
|
|
|
12
12
|
export default defineComponent({
|
|
13
13
|
name: 'm-icon',
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
<script lang="ts">
|
|
10
10
|
import { computed, defineComponent, onMounted, onUnmounted, ref, watch } from 'vue';
|
|
11
11
|
|
|
12
|
-
import { ScrollViewer } from '
|
|
12
|
+
import { ScrollViewer } from '../utils/scroll-viewer';
|
|
13
13
|
|
|
14
14
|
export default defineComponent({
|
|
15
15
|
name: 'm-editor-scroll-viewer',
|
|
@@ -55,7 +55,7 @@ export default defineComponent({
|
|
|
55
55
|
style: computed(
|
|
56
56
|
() => `
|
|
57
57
|
width: ${props.width}px;
|
|
58
|
-
height: ${
|
|
58
|
+
height: ${props.height}px;
|
|
59
59
|
position: absolute;
|
|
60
60
|
margin-top: 30px;
|
|
61
61
|
`,
|