@tmagic/editor 1.3.0-alpha.0 → 1.3.0-alpha.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 +46 -9
- package/dist/tmagic-editor.js +1764 -871
- package/dist/tmagic-editor.js.map +1 -1
- package/dist/tmagic-editor.umd.cjs +1781 -882
- package/dist/tmagic-editor.umd.cjs.map +1 -1
- package/package.json +19 -20
- package/src/Editor.vue +29 -3
- package/src/components/CodeDraftEditor.vue +5 -1
- package/src/components/ContentMenu.vue +30 -11
- package/src/components/FunctionEditor.vue +12 -5
- package/src/components/Icon.vue +5 -1
- package/src/components/Resizer.vue +45 -0
- package/src/components/ScrollBar.vue +5 -1
- package/src/components/ScrollViewer.vue +5 -1
- package/src/components/SearchInput.vue +4 -0
- package/src/components/{Layout.vue → SplitView.vue} +8 -4
- package/src/components/ToolButton.vue +5 -1
- package/src/editorProps.ts +5 -1
- package/src/fields/Code.vue +5 -1
- package/src/fields/CodeLink.vue +9 -3
- package/src/fields/CodeSelect.vue +8 -2
- package/src/fields/CodeSelectCol.vue +6 -2
- package/src/fields/DataSourceFields.vue +5 -1
- package/src/fields/DataSourceInput.vue +358 -0
- package/src/fields/DataSourceSelect.vue +75 -0
- package/src/fields/EventSelect.vue +9 -3
- package/src/fields/KeyValue.vue +4 -0
- package/src/fields/UISelect.vue +5 -1
- package/src/icons/AppManageIcon.vue +5 -1
- package/src/icons/CenterIcon.vue +13 -0
- package/src/icons/CodeIcon.vue +5 -1
- package/src/index.ts +13 -3
- package/src/initService.ts +73 -0
- package/src/layouts/AddPageBox.vue +5 -1
- package/src/layouts/CodeEditor.vue +34 -10
- package/src/layouts/Framework.vue +25 -25
- package/src/layouts/NavMenu.vue +5 -1
- package/src/layouts/PropsPanel.vue +14 -4
- package/src/layouts/sidebar/ComponentListPanel.vue +8 -5
- package/src/layouts/sidebar/LayerMenu.vue +13 -25
- package/src/layouts/sidebar/LayerNode.vue +40 -0
- package/src/layouts/sidebar/LayerPanel.vue +70 -27
- package/src/layouts/sidebar/Sidebar.vue +11 -7
- package/src/layouts/sidebar/code-block/CodeBlockEditor.vue +8 -4
- package/src/layouts/sidebar/code-block/CodeBlockList.vue +5 -1
- package/src/layouts/sidebar/data-source/DataSourceConfigPanel.vue +4 -0
- package/src/layouts/sidebar/data-source/DataSourceListPanel.vue +22 -2
- package/src/layouts/workspace/Breadcrumb.vue +5 -1
- package/src/layouts/workspace/PageBar.vue +5 -1
- package/src/layouts/workspace/PageBarScrollContainer.vue +5 -1
- package/src/layouts/workspace/Stage.vue +29 -7
- package/src/layouts/workspace/ViewerMenu.vue +15 -36
- package/src/layouts/workspace/Workspace.vue +9 -134
- package/src/services/codeBlock.ts +3 -2
- package/src/services/dep.ts +4 -0
- package/src/services/keybinding.ts +185 -0
- package/src/services/storage.ts +3 -2
- package/src/theme/content-menu.scss +1 -1
- package/src/theme/data-source-input.scss +18 -0
- package/src/theme/framework.scss +0 -3
- package/src/theme/layer-panel.scss +6 -0
- package/src/theme/layout.scss +4 -0
- package/src/theme/resizer.scss +25 -10
- package/src/theme/stage.scss +4 -0
- package/src/theme/theme.scss +1 -0
- package/src/type.ts +59 -1
- package/src/utils/config.ts +1 -1
- package/src/utils/content-menu.ts +92 -0
- package/src/utils/dep.ts +7 -1
- package/src/utils/keybinding-config.ts +120 -0
- package/src/utils/props.ts +34 -0
- package/types/Editor.vue.d.ts +7 -1
- package/types/components/CodeDraftEditor.vue.d.ts +6 -3
- package/types/components/ContentMenu.vue.d.ts +10 -5
- package/types/components/FunctionEditor.vue.d.ts +74 -51
- package/types/components/Icon.vue.d.ts +2 -2
- package/types/{layouts → components}/Resizer.vue.d.ts +2 -2
- package/types/components/ScrollBar.vue.d.ts +1 -1
- package/types/components/ScrollViewer.vue.d.ts +8 -5
- package/types/components/SearchInput.vue.d.ts +1 -1
- package/types/components/{Layout.vue.d.ts → SplitView.vue.d.ts} +9 -6
- package/types/components/ToolButton.vue.d.ts +8 -5
- package/types/editorProps.d.ts +4 -1
- package/types/fields/Code.vue.d.ts +1 -1
- package/types/fields/CodeLink.vue.d.ts +9 -9
- package/types/fields/CodeSelect.vue.d.ts +10 -7
- package/types/fields/CodeSelectCol.vue.d.ts +8 -5
- package/types/fields/DataSourceFields.vue.d.ts +8 -5
- package/types/fields/DataSourceInput.vue.d.ts +54 -0
- package/types/fields/DataSourceSelect.vue.d.ts +56 -0
- package/types/fields/EventSelect.vue.d.ts +3 -3
- package/types/fields/KeyValue.vue.d.ts +8 -5
- package/types/fields/UISelect.vue.d.ts +1 -1
- package/types/icons/AppManageIcon.vue.d.ts +1 -1
- package/types/icons/CenterIcon.vue.d.ts +2 -0
- package/types/icons/CodeIcon.vue.d.ts +1 -1
- package/types/index.d.ts +7 -2
- package/types/initService.d.ts +1 -1
- package/types/layouts/AddPageBox.vue.d.ts +1 -1
- package/types/layouts/CodeEditor.vue.d.ts +16 -10
- package/types/layouts/Framework.vue.d.ts +11 -32
- package/types/layouts/NavMenu.vue.d.ts +7 -4
- package/types/layouts/PropsPanel.vue.d.ts +276 -4
- package/types/layouts/sidebar/ComponentListPanel.vue.d.ts +4 -4
- package/types/layouts/sidebar/LayerMenu.vue.d.ts +2 -2
- package/types/layouts/sidebar/LayerNode.vue.d.ts +16 -0
- package/types/layouts/sidebar/LayerPanel.vue.d.ts +5 -5
- package/types/layouts/sidebar/Sidebar.vue.d.ts +18 -15
- package/types/layouts/sidebar/code-block/CodeBlockEditor.vue.d.ts +4 -4
- package/types/layouts/sidebar/code-block/CodeBlockList.vue.d.ts +7 -7
- package/types/layouts/sidebar/data-source/DataSourceConfigPanel.vue.d.ts +1 -1
- package/types/layouts/sidebar/data-source/DataSourceListPanel.vue.d.ts +3 -3
- package/types/layouts/workspace/Breadcrumb.vue.d.ts +1 -1
- package/types/layouts/workspace/PageBar.vue.d.ts +5 -5
- package/types/layouts/workspace/PageBarScrollContainer.vue.d.ts +2 -2
- package/types/layouts/workspace/Stage.vue.d.ts +2 -2
- package/types/layouts/workspace/ViewerMenu.vue.d.ts +7 -4
- package/types/layouts/workspace/Workspace.vue.d.ts +9 -9
- package/types/services/keybinding.d.ts +20 -0
- package/types/type.d.ts +56 -1
- package/types/utils/config.d.ts +1 -1
- package/types/utils/content-menu.d.ts +7 -0
- package/types/utils/keybinding-config.d.ts +3 -0
- package/src/layouts/Resizer.vue +0 -32
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "1.3.0-alpha.
|
|
2
|
+
"version": "1.3.0-alpha.10",
|
|
3
3
|
"name": "@tmagic/editor",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"sideEffects": [
|
|
@@ -46,43 +46,42 @@
|
|
|
46
46
|
"dependencies": {
|
|
47
47
|
"@babel/core": "^7.18.0",
|
|
48
48
|
"@element-plus/icons-vue": "^2.0.9",
|
|
49
|
-
"@tmagic/core": "1.3.0-alpha.
|
|
50
|
-
"@tmagic/design": "1.3.0-alpha.
|
|
51
|
-
"@tmagic/form": "1.3.0-alpha.
|
|
52
|
-
"@tmagic/schema": "1.3.0-alpha.
|
|
53
|
-
"@tmagic/stage": "1.3.0-alpha.
|
|
54
|
-
"@tmagic/table": "1.3.0-alpha.
|
|
55
|
-
"@tmagic/utils": "1.3.0-alpha.
|
|
49
|
+
"@tmagic/core": "1.3.0-alpha.10",
|
|
50
|
+
"@tmagic/design": "1.3.0-alpha.10",
|
|
51
|
+
"@tmagic/form": "1.3.0-alpha.10",
|
|
52
|
+
"@tmagic/schema": "1.3.0-alpha.10",
|
|
53
|
+
"@tmagic/stage": "1.3.0-alpha.10",
|
|
54
|
+
"@tmagic/table": "1.3.0-alpha.10",
|
|
55
|
+
"@tmagic/utils": "1.3.0-alpha.10",
|
|
56
56
|
"buffer": "^6.0.3",
|
|
57
57
|
"color": "^3.1.3",
|
|
58
58
|
"events": "^3.3.0",
|
|
59
59
|
"gesto": "^1.7.0",
|
|
60
60
|
"keycon": "^1.1.2",
|
|
61
61
|
"lodash-es": "^4.17.21",
|
|
62
|
-
"monaco-editor": "^0.
|
|
62
|
+
"monaco-editor": "^0.39.0",
|
|
63
63
|
"serialize-javascript": "^6.0.0",
|
|
64
|
-
"vue": "^3.
|
|
64
|
+
"vue": "^3.3.4"
|
|
65
65
|
},
|
|
66
66
|
"peerDependencies": {
|
|
67
|
-
"@tmagic/design": "1.3.0-alpha.
|
|
68
|
-
"@tmagic/form": "1.3.0-alpha.
|
|
69
|
-
"monaco-editor": "^0.
|
|
70
|
-
"vue": "^3.
|
|
67
|
+
"@tmagic/design": "1.3.0-alpha.10",
|
|
68
|
+
"@tmagic/form": "1.3.0-alpha.10",
|
|
69
|
+
"monaco-editor": "^0.39.0",
|
|
70
|
+
"vue": "^3.3.4"
|
|
71
71
|
},
|
|
72
72
|
"devDependencies": {
|
|
73
73
|
"@types/events": "^3.0.0",
|
|
74
74
|
"@types/lodash-es": "^4.17.4",
|
|
75
75
|
"@types/node": "^15.12.4",
|
|
76
76
|
"@types/serialize-javascript": "^5.0.1",
|
|
77
|
-
"@vitejs/plugin-vue": "^4.
|
|
78
|
-
"@vue/compiler-sfc": "^3.
|
|
79
|
-
"@vue/test-utils": "^2.
|
|
77
|
+
"@vitejs/plugin-vue": "^4.2.3",
|
|
78
|
+
"@vue/compiler-sfc": "^3.3.4",
|
|
79
|
+
"@vue/test-utils": "^2.3.2",
|
|
80
80
|
"rimraf": "^3.0.2",
|
|
81
81
|
"sass": "^1.35.1",
|
|
82
82
|
"tsc-alias": "^1.8.5",
|
|
83
83
|
"typescript": "^5.0.4",
|
|
84
|
-
"vite": "^4.
|
|
85
|
-
"
|
|
86
|
-
"vue-tsc": "^1.0.11"
|
|
84
|
+
"vite": "^4.3.8",
|
|
85
|
+
"vue-tsc": "^1.6.5"
|
|
87
86
|
}
|
|
88
87
|
}
|
package/src/Editor.vue
CHANGED
|
@@ -1,9 +1,19 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<Framework
|
|
2
|
+
<Framework>
|
|
3
|
+
<template #header>
|
|
4
|
+
<slot name="header"></slot>
|
|
5
|
+
</template>
|
|
6
|
+
|
|
3
7
|
<template #nav>
|
|
4
8
|
<slot name="nav" :editorService="editorService"><TMagicNavMenu :data="menu"></TMagicNavMenu></slot>
|
|
5
9
|
</template>
|
|
6
10
|
|
|
11
|
+
<template #content-before>
|
|
12
|
+
<slot name="content-before"></slot>
|
|
13
|
+
</template>
|
|
14
|
+
|
|
15
|
+
<template #src-code><slot name="src-code" :editorService="editorService"></slot></template>
|
|
16
|
+
|
|
7
17
|
<template #sidebar>
|
|
8
18
|
<slot name="sidebar" :editorService="editorService">
|
|
9
19
|
<Sidebar :data="sidebar" :layer-content-menu="layerContentMenu">
|
|
@@ -51,7 +61,10 @@
|
|
|
51
61
|
|
|
52
62
|
<template #props-panel>
|
|
53
63
|
<slot name="props-panel">
|
|
54
|
-
<PropsPanel
|
|
64
|
+
<PropsPanel
|
|
65
|
+
:extend-state="extendFormState"
|
|
66
|
+
@mounted="(instance: any) => $emit('props-panel-mounted', instance)"
|
|
67
|
+
>
|
|
55
68
|
<template #props-panel-header>
|
|
56
69
|
<slot name="props-panel-header"></slot>
|
|
57
70
|
</template>
|
|
@@ -60,6 +73,14 @@
|
|
|
60
73
|
</template>
|
|
61
74
|
|
|
62
75
|
<template #empty><slot name="empty" :editorService="editorService"></slot></template>
|
|
76
|
+
|
|
77
|
+
<template #content-after>
|
|
78
|
+
<slot name="content-after"></slot>
|
|
79
|
+
</template>
|
|
80
|
+
|
|
81
|
+
<template #footer>
|
|
82
|
+
<slot name="footer"></slot>
|
|
83
|
+
</template>
|
|
63
84
|
</Framework>
|
|
64
85
|
</template>
|
|
65
86
|
|
|
@@ -78,15 +99,17 @@ import depService from './services/dep';
|
|
|
78
99
|
import editorService from './services/editor';
|
|
79
100
|
import eventsService from './services/events';
|
|
80
101
|
import historyService from './services/history';
|
|
102
|
+
import keybindingService from './services/keybinding';
|
|
81
103
|
import propsService from './services/props';
|
|
82
104
|
import storageService from './services/storage';
|
|
83
105
|
import uiService from './services/ui';
|
|
106
|
+
import keybindingConfig from './utils/keybinding-config';
|
|
84
107
|
import editorProps from './editorProps';
|
|
85
108
|
import { initServiceEvents, initServiceState } from './initService';
|
|
86
109
|
import type { Services } from './type';
|
|
87
110
|
|
|
88
111
|
export default defineComponent({
|
|
89
|
-
name: '
|
|
112
|
+
name: 'MEditor',
|
|
90
113
|
|
|
91
114
|
components: {
|
|
92
115
|
TMagicNavMenu: NavMenu,
|
|
@@ -112,10 +135,13 @@ export default defineComponent({
|
|
|
112
135
|
codeBlockService,
|
|
113
136
|
depService,
|
|
114
137
|
dataSourceService,
|
|
138
|
+
keybindingService,
|
|
115
139
|
};
|
|
116
140
|
|
|
117
141
|
initServiceEvents(props, emit, services);
|
|
118
142
|
initServiceState(props, services);
|
|
143
|
+
keybindingService.registe(keybindingConfig);
|
|
144
|
+
keybindingService.registeEl('global');
|
|
119
145
|
|
|
120
146
|
provide('services', services);
|
|
121
147
|
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
</div>
|
|
24
24
|
</div>
|
|
25
25
|
</template>
|
|
26
|
-
<script lang="ts" setup
|
|
26
|
+
<script lang="ts" setup>
|
|
27
27
|
import { computed, inject, ref, watchEffect } from 'vue';
|
|
28
28
|
import type * as monaco from 'monaco-editor';
|
|
29
29
|
|
|
@@ -34,6 +34,10 @@ import { datetimeFormatter } from '@tmagic/utils';
|
|
|
34
34
|
import MagicCodeEditor from '@editor/layouts/CodeEditor.vue';
|
|
35
35
|
import type { Services } from '@editor/type';
|
|
36
36
|
|
|
37
|
+
defineOptions({
|
|
38
|
+
name: 'MEditorCodeDraftEditor',
|
|
39
|
+
});
|
|
40
|
+
|
|
37
41
|
const props = withDefaults(
|
|
38
42
|
defineProps<{
|
|
39
43
|
/** 代码id */
|
|
@@ -4,14 +4,16 @@
|
|
|
4
4
|
<ToolButton
|
|
5
5
|
v-for="(item, index) in menuData"
|
|
6
6
|
event-type="mouseup"
|
|
7
|
+
ref="buttons"
|
|
7
8
|
:data="item"
|
|
8
9
|
:key="index"
|
|
9
10
|
@mouseup="hide"
|
|
10
|
-
@mouseenter="showSubMenu(item)"
|
|
11
|
+
@mouseenter="showSubMenu(item, index)"
|
|
11
12
|
></ToolButton>
|
|
12
13
|
</div>
|
|
13
14
|
<teleport to="body">
|
|
14
15
|
<content-menu
|
|
16
|
+
v-if="subMenuData.length"
|
|
15
17
|
class="sub-menu"
|
|
16
18
|
ref="subMenu"
|
|
17
19
|
:menu-data="subMenuData"
|
|
@@ -22,13 +24,17 @@
|
|
|
22
24
|
</div>
|
|
23
25
|
</template>
|
|
24
26
|
|
|
25
|
-
<script lang="ts" setup
|
|
27
|
+
<script lang="ts" setup>
|
|
26
28
|
import { nextTick, onMounted, onUnmounted, ref } from 'vue';
|
|
27
29
|
|
|
28
30
|
import { MenuButton, MenuComponent } from '@editor/type';
|
|
29
31
|
|
|
30
32
|
import ToolButton from './ToolButton.vue';
|
|
31
33
|
|
|
34
|
+
defineOptions({
|
|
35
|
+
name: 'MEditorContentMenu',
|
|
36
|
+
});
|
|
37
|
+
|
|
32
38
|
const props = withDefaults(
|
|
33
39
|
defineProps<{
|
|
34
40
|
menuData?: (MenuButton | MenuComponent)[];
|
|
@@ -43,6 +49,7 @@ const props = withDefaults(
|
|
|
43
49
|
const emit = defineEmits(['hide', 'show']);
|
|
44
50
|
|
|
45
51
|
const menu = ref<HTMLDivElement>();
|
|
52
|
+
const buttons = ref<InstanceType<typeof ToolButton>[]>();
|
|
46
53
|
const subMenu = ref<any>();
|
|
47
54
|
const visible = ref(false);
|
|
48
55
|
const subMenuData = ref<(MenuButton | MenuComponent)[]>([]);
|
|
@@ -51,6 +58,8 @@ const menuStyle = ref({
|
|
|
51
58
|
top: '0',
|
|
52
59
|
});
|
|
53
60
|
|
|
61
|
+
const contains = (el: HTMLElement) => menu.value?.contains(el) || subMenu.value?.contains(el);
|
|
62
|
+
|
|
54
63
|
const hide = () => {
|
|
55
64
|
if (!visible.value) return;
|
|
56
65
|
|
|
@@ -65,7 +74,7 @@ const hideHandler = (e: MouseEvent) => {
|
|
|
65
74
|
if (!visible.value || !target) {
|
|
66
75
|
return;
|
|
67
76
|
}
|
|
68
|
-
if (
|
|
77
|
+
if (contains(target)) {
|
|
69
78
|
return;
|
|
70
79
|
}
|
|
71
80
|
hide();
|
|
@@ -94,19 +103,27 @@ const show = (e: MouseEvent) => {
|
|
|
94
103
|
}, 300);
|
|
95
104
|
};
|
|
96
105
|
|
|
97
|
-
const showSubMenu = (item: MenuButton | MenuComponent) => {
|
|
106
|
+
const showSubMenu = (item: MenuButton | MenuComponent, index: number) => {
|
|
98
107
|
const menuItem = item as MenuButton;
|
|
99
108
|
if (typeof item !== 'object' || !menuItem.items?.length) {
|
|
100
109
|
return;
|
|
101
110
|
}
|
|
102
111
|
|
|
103
|
-
subMenuData.value = menuItem.items;
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
112
|
+
subMenuData.value = menuItem.items || [];
|
|
113
|
+
setTimeout(() => {
|
|
114
|
+
if (menu.value) {
|
|
115
|
+
// 将子菜单放置在按钮右侧,与按钮齐平
|
|
116
|
+
let y = menu.value.offsetTop;
|
|
117
|
+
if (buttons.value?.[index].$el) {
|
|
118
|
+
const rect = buttons.value?.[index].$el.getBoundingClientRect();
|
|
119
|
+
y = rect.top;
|
|
120
|
+
}
|
|
121
|
+
subMenu.value?.show({
|
|
122
|
+
clientX: menu.value.offsetLeft + menu.value.clientWidth,
|
|
123
|
+
clientY: y,
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
}, 0);
|
|
110
127
|
};
|
|
111
128
|
|
|
112
129
|
onMounted(() => {
|
|
@@ -122,7 +139,9 @@ onUnmounted(() => {
|
|
|
122
139
|
});
|
|
123
140
|
|
|
124
141
|
defineExpose({
|
|
142
|
+
menu,
|
|
125
143
|
hide,
|
|
126
144
|
show,
|
|
145
|
+
contains,
|
|
127
146
|
});
|
|
128
147
|
</script>
|
|
@@ -32,8 +32,8 @@
|
|
|
32
32
|
></CodeDraftEditor>
|
|
33
33
|
</TMagicCard>
|
|
34
34
|
</template>
|
|
35
|
-
<script lang="ts" setup
|
|
36
|
-
import { inject, ref, watchEffect } from 'vue';
|
|
35
|
+
<script lang="ts" setup>
|
|
36
|
+
import { inject, provide, ref, watchEffect } from 'vue';
|
|
37
37
|
import { cloneDeep } from 'lodash-es';
|
|
38
38
|
|
|
39
39
|
import { TMagicCard, TMagicInput, tMagicMessage } from '@tmagic/design';
|
|
@@ -41,8 +41,16 @@ import { ColumnConfig, TableConfig } from '@tmagic/form';
|
|
|
41
41
|
import { CodeParam, Id } from '@tmagic/schema';
|
|
42
42
|
|
|
43
43
|
import type { Services } from '@editor/type';
|
|
44
|
+
import { getConfig } from '@editor/utils/config';
|
|
44
45
|
|
|
45
46
|
import CodeDraftEditor from './CodeDraftEditor.vue';
|
|
47
|
+
|
|
48
|
+
defineOptions({
|
|
49
|
+
name: 'MEditorFunctionEditor',
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
provide('mForm', null);
|
|
53
|
+
|
|
46
54
|
const defaultParamColConfig: ColumnConfig = {
|
|
47
55
|
type: 'row',
|
|
48
56
|
label: '参数类型',
|
|
@@ -142,9 +150,8 @@ initTableModel();
|
|
|
142
150
|
// 保存前钩子
|
|
143
151
|
const beforeSave = (codeValue: string): boolean => {
|
|
144
152
|
try {
|
|
145
|
-
//
|
|
146
|
-
|
|
147
|
-
eval(codeValue);
|
|
153
|
+
// 检测js代码是否存在语法错误
|
|
154
|
+
getConfig('parseDSL')(codeValue);
|
|
148
155
|
return true;
|
|
149
156
|
} catch (e: any) {
|
|
150
157
|
tMagicMessage.error(e.stack);
|
package/src/components/Icon.vue
CHANGED
|
@@ -7,12 +7,16 @@
|
|
|
7
7
|
<TMagicIcon v-else class="magic-editor-icon"><component :is="toRaw(icon)"></component></TMagicIcon>
|
|
8
8
|
</template>
|
|
9
9
|
|
|
10
|
-
<script lang="ts" setup
|
|
10
|
+
<script lang="ts" setup>
|
|
11
11
|
import { toRaw } from 'vue';
|
|
12
12
|
import { Edit } from '@element-plus/icons-vue';
|
|
13
13
|
|
|
14
14
|
import { TMagicIcon } from '@tmagic/design';
|
|
15
15
|
|
|
16
|
+
defineOptions({
|
|
17
|
+
name: 'MEditorIcon',
|
|
18
|
+
});
|
|
19
|
+
|
|
16
20
|
defineProps<{
|
|
17
21
|
icon?: any;
|
|
18
22
|
}>();
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<span ref="target" class="m-editor-resizer" :class="{ 'm-editor-resizer-draging': isDraging }">
|
|
3
|
+
<slot></slot>
|
|
4
|
+
</span>
|
|
5
|
+
</template>
|
|
6
|
+
|
|
7
|
+
<script lang="ts" setup>
|
|
8
|
+
import { onMounted, onUnmounted, ref } from 'vue';
|
|
9
|
+
import Gesto from 'gesto';
|
|
10
|
+
|
|
11
|
+
defineOptions({
|
|
12
|
+
name: 'MEditorResizer',
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
const emit = defineEmits(['change']);
|
|
16
|
+
|
|
17
|
+
const target = ref<HTMLSpanElement>();
|
|
18
|
+
const isDraging = ref(false);
|
|
19
|
+
|
|
20
|
+
let getso: Gesto;
|
|
21
|
+
|
|
22
|
+
onMounted(() => {
|
|
23
|
+
if (!target.value) return;
|
|
24
|
+
getso = new Gesto(target.value, {
|
|
25
|
+
container: window,
|
|
26
|
+
pinchOutside: true,
|
|
27
|
+
})
|
|
28
|
+
.on('drag', (e) => {
|
|
29
|
+
if (!target.value) return;
|
|
30
|
+
|
|
31
|
+
emit('change', e.deltaX);
|
|
32
|
+
})
|
|
33
|
+
.on('dragStart', () => {
|
|
34
|
+
isDraging.value = true;
|
|
35
|
+
})
|
|
36
|
+
.on('dragEnd', () => {
|
|
37
|
+
isDraging.value = false;
|
|
38
|
+
});
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
onUnmounted(() => {
|
|
42
|
+
getso?.unset();
|
|
43
|
+
isDraging.value = false;
|
|
44
|
+
});
|
|
45
|
+
</script>
|
|
@@ -4,10 +4,14 @@
|
|
|
4
4
|
</div>
|
|
5
5
|
</template>
|
|
6
6
|
|
|
7
|
-
<script lang="ts" setup
|
|
7
|
+
<script lang="ts" setup>
|
|
8
8
|
import { computed, onMounted, onUnmounted, ref } from 'vue';
|
|
9
9
|
import Gesto from 'gesto';
|
|
10
10
|
|
|
11
|
+
defineOptions({
|
|
12
|
+
name: 'MEditorScrollBar',
|
|
13
|
+
});
|
|
14
|
+
|
|
11
15
|
const props = defineProps<{
|
|
12
16
|
size: number;
|
|
13
17
|
scrollSize: number;
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
</div>
|
|
23
23
|
</template>
|
|
24
24
|
|
|
25
|
-
<script lang="ts" setup
|
|
25
|
+
<script lang="ts" setup>
|
|
26
26
|
import { computed, onMounted, onUnmounted, ref, watch } from 'vue';
|
|
27
27
|
|
|
28
28
|
import type { ScrollViewerEvent } from '@editor/type';
|
|
@@ -30,6 +30,10 @@ import { ScrollViewer } from '@editor/utils/scroll-viewer';
|
|
|
30
30
|
|
|
31
31
|
import ScrollBar from './ScrollBar.vue';
|
|
32
32
|
|
|
33
|
+
defineOptions({
|
|
34
|
+
name: 'MEditorScrollViewer',
|
|
35
|
+
});
|
|
36
|
+
|
|
33
37
|
const props = withDefaults(
|
|
34
38
|
defineProps<{
|
|
35
39
|
width?: number;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<div ref="el" class="m-editor-layout">
|
|
3
|
-
<template v-if="hasLeft">
|
|
3
|
+
<template v-if="hasLeft && $slots.left">
|
|
4
4
|
<div class="m-editor-layout-left" :class="leftClass" :style="`width: ${left}px`">
|
|
5
5
|
<slot name="left"></slot>
|
|
6
6
|
</div>
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
<slot name="center"></slot>
|
|
12
12
|
</div>
|
|
13
13
|
|
|
14
|
-
<template v-if="hasRight">
|
|
14
|
+
<template v-if="hasRight && $slots.right">
|
|
15
15
|
<Resizer @change="changeRight"></Resizer>
|
|
16
16
|
<div class="m-editor-layout-right" :class="rightClass" :style="`width: ${right}px`">
|
|
17
17
|
<slot name="right"></slot>
|
|
@@ -20,10 +20,14 @@
|
|
|
20
20
|
</div>
|
|
21
21
|
</template>
|
|
22
22
|
|
|
23
|
-
<script lang="ts" setup
|
|
23
|
+
<script lang="ts" setup>
|
|
24
24
|
import { computed, onMounted, onUnmounted, ref } from 'vue';
|
|
25
25
|
|
|
26
|
-
import Resizer from '
|
|
26
|
+
import Resizer from './Resizer.vue';
|
|
27
|
+
|
|
28
|
+
defineOptions({
|
|
29
|
+
name: 'MEditorLayout',
|
|
30
|
+
});
|
|
27
31
|
|
|
28
32
|
const emit = defineEmits(['update:left', 'change', 'update:right']);
|
|
29
33
|
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
</div>
|
|
44
44
|
</template>
|
|
45
45
|
|
|
46
|
-
<script lang="ts" setup
|
|
46
|
+
<script lang="ts" setup>
|
|
47
47
|
import { computed, inject } from 'vue';
|
|
48
48
|
import { ArrowDown } from '@element-plus/icons-vue';
|
|
49
49
|
|
|
@@ -60,6 +60,10 @@ import {
|
|
|
60
60
|
import MIcon from '../components/Icon.vue';
|
|
61
61
|
import type { MenuButton, MenuComponent, Services } from '../type';
|
|
62
62
|
|
|
63
|
+
defineOptions({
|
|
64
|
+
name: 'MEditorToolButton',
|
|
65
|
+
});
|
|
66
|
+
|
|
63
67
|
const props = withDefaults(
|
|
64
68
|
defineProps<{
|
|
65
69
|
data?: MenuButton | MenuComponent;
|
package/src/editorProps.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { PropType } from 'vue';
|
|
2
2
|
|
|
3
3
|
import type { EventOption } from '@tmagic/core';
|
|
4
|
-
import type { FormConfig } from '@tmagic/form';
|
|
4
|
+
import type { FormConfig, FormState } from '@tmagic/form';
|
|
5
5
|
import type { MApp, MNode } from '@tmagic/schema';
|
|
6
6
|
import StageCore, {
|
|
7
7
|
CONTAINER_HIGHLIGHT_CLASS_NAME,
|
|
@@ -137,4 +137,8 @@ export default {
|
|
|
137
137
|
disabledDragStart: {
|
|
138
138
|
type: Boolean,
|
|
139
139
|
},
|
|
140
|
+
|
|
141
|
+
extendFormState: {
|
|
142
|
+
type: Function as PropType<(state: FormState) => Record<string, any> | Promise<Record<string, any>>>,
|
|
143
|
+
},
|
|
140
144
|
};
|
package/src/fields/Code.vue
CHANGED
|
@@ -8,9 +8,13 @@
|
|
|
8
8
|
></magic-code-editor>
|
|
9
9
|
</template>
|
|
10
10
|
|
|
11
|
-
<script lang="ts" setup
|
|
11
|
+
<script lang="ts" setup>
|
|
12
12
|
import { computed } from 'vue';
|
|
13
13
|
|
|
14
|
+
defineOptions({
|
|
15
|
+
name: 'MEditorCode',
|
|
16
|
+
});
|
|
17
|
+
|
|
14
18
|
const emit = defineEmits(['change']);
|
|
15
19
|
|
|
16
20
|
const props = defineProps<{
|
package/src/fields/CodeLink.vue
CHANGED
|
@@ -2,10 +2,16 @@
|
|
|
2
2
|
<m-fields-link :config="formConfig" :model="modelValue" name="form" @change="changeHandler"></m-fields-link>
|
|
3
3
|
</template>
|
|
4
4
|
|
|
5
|
-
<script lang="ts" setup
|
|
5
|
+
<script lang="ts" setup>
|
|
6
6
|
import { computed, reactive, watch } from 'vue';
|
|
7
7
|
import serialize from 'serialize-javascript';
|
|
8
8
|
|
|
9
|
+
import { getConfig } from '@editor/utils/config';
|
|
10
|
+
|
|
11
|
+
defineOptions({
|
|
12
|
+
name: 'MEditorCodeLink',
|
|
13
|
+
});
|
|
14
|
+
|
|
9
15
|
const props = defineProps<{
|
|
10
16
|
config: {
|
|
11
17
|
type: 'code-link';
|
|
@@ -65,8 +71,8 @@ const changeHandler = (v: Record<string, any>) => {
|
|
|
65
71
|
if (!props.name || !props.model) return;
|
|
66
72
|
|
|
67
73
|
try {
|
|
68
|
-
|
|
69
|
-
props.model[props.name] =
|
|
74
|
+
const parseDSL = getConfig('parseDSL');
|
|
75
|
+
props.model[props.name] = parseDSL(`(${v[props.name]})`);
|
|
70
76
|
emit('change', props.model[props.name]);
|
|
71
77
|
} catch (e) {
|
|
72
78
|
console.error(e);
|
|
@@ -6,13 +6,17 @@
|
|
|
6
6
|
</div>
|
|
7
7
|
</template>
|
|
8
8
|
|
|
9
|
-
<script lang="ts" setup
|
|
10
|
-
import { computed,
|
|
9
|
+
<script lang="ts" setup>
|
|
10
|
+
import { computed, watch } from 'vue';
|
|
11
11
|
import { isEmpty } from 'lodash-es';
|
|
12
12
|
|
|
13
13
|
import { TMagicCard } from '@tmagic/design';
|
|
14
14
|
import { HookType } from '@tmagic/schema';
|
|
15
15
|
|
|
16
|
+
defineOptions({
|
|
17
|
+
name: 'MEditorCodeSelect',
|
|
18
|
+
});
|
|
19
|
+
|
|
16
20
|
const emit = defineEmits(['change']);
|
|
17
21
|
|
|
18
22
|
const props = withDefaults(
|
|
@@ -32,6 +36,8 @@ const codeConfig = computed(() => ({
|
|
|
32
36
|
type: 'group-list',
|
|
33
37
|
name: 'hookData',
|
|
34
38
|
enableToggleMode: false,
|
|
39
|
+
expandAll: true,
|
|
40
|
+
titleKey: 'codeId',
|
|
35
41
|
items: [
|
|
36
42
|
{
|
|
37
43
|
type: 'code-select-col',
|
|
@@ -16,8 +16,8 @@
|
|
|
16
16
|
</div>
|
|
17
17
|
</template>
|
|
18
18
|
|
|
19
|
-
<script lang="ts" setup name="
|
|
20
|
-
import { computed,
|
|
19
|
+
<script lang="ts" setup name="">
|
|
20
|
+
import { computed, inject, ref, watch } from 'vue';
|
|
21
21
|
import { Edit, View } from '@element-plus/icons-vue';
|
|
22
22
|
import { isEmpty, map } from 'lodash-es';
|
|
23
23
|
|
|
@@ -27,6 +27,10 @@ import { Id } from '@tmagic/schema';
|
|
|
27
27
|
import Icon from '@editor/components/Icon.vue';
|
|
28
28
|
import type { CodeParamStatement, Services } from '@editor/type';
|
|
29
29
|
|
|
30
|
+
defineOptions({
|
|
31
|
+
name: 'MEditorCodeSelectCol',
|
|
32
|
+
});
|
|
33
|
+
|
|
30
34
|
const services = inject<Services>('services');
|
|
31
35
|
const mForm = inject<FormState>('mForm');
|
|
32
36
|
const emit = defineEmits(['change']);
|
|
@@ -24,6 +24,10 @@ import { TMagicButton, tMagicMessageBox } from '@tmagic/design';
|
|
|
24
24
|
import { FormConfig, FormState, MFormDialog } from '@tmagic/form';
|
|
25
25
|
import { MagicTable } from '@tmagic/table';
|
|
26
26
|
|
|
27
|
+
defineOptions({
|
|
28
|
+
name: 'MEditorDataSourceFields',
|
|
29
|
+
});
|
|
30
|
+
|
|
27
31
|
const props = withDefaults(
|
|
28
32
|
defineProps<{
|
|
29
33
|
config: {
|
|
@@ -136,7 +140,7 @@ const dataSourceFieldsConfig: FormConfig = [
|
|
|
136
140
|
{
|
|
137
141
|
validator: ({ value, callback }, { model, parent }) => {
|
|
138
142
|
const index = parent.findIndex((item: Record<string, any>) => item.name === value);
|
|
139
|
-
if ((model.index === -1 && index > -1) || (model.index > -1 && index !== model.index)) {
|
|
143
|
+
if ((model.index === -1 && index > -1) || (model.index > -1 && index > -1 && index !== model.index)) {
|
|
140
144
|
return callback(`属性key(${value})已存在`);
|
|
141
145
|
}
|
|
142
146
|
callback();
|