@tmagic/editor 1.5.0-beta.9 → 1.5.1
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 → tmagic-editor.css} +228 -22
- package/dist/tmagic-editor.js +1670 -1012
- package/dist/tmagic-editor.umd.cjs +1705 -1048
- package/package.json +14 -12
- package/src/Editor.vue +24 -6
- package/src/components/CodeBlockEditor.vue +14 -8
- package/src/components/CodeParams.vue +5 -5
- package/src/components/ContentMenu.vue +18 -18
- package/src/components/FloatingBox.vue +3 -3
- package/src/components/Resizer.vue +4 -4
- package/src/components/ScrollBar.vue +3 -3
- package/src/components/ScrollViewer.vue +3 -3
- package/src/components/SplitView.vue +2 -2
- package/src/components/ToolButton.vue +2 -1
- package/src/editorProps.ts +6 -2
- package/src/fields/Code.vue +1 -2
- package/src/fields/CodeSelect.vue +13 -11
- package/src/fields/CodeSelectCol.vue +32 -5
- package/src/fields/CondOpSelect.vue +5 -2
- package/src/fields/DataSourceFields.vue +31 -12
- package/src/fields/DataSourceInput.vue +2 -2
- package/src/fields/DataSourceMethods.vue +72 -14
- package/src/fields/DataSourceMocks.vue +0 -1
- package/src/fields/DisplayConds.vue +8 -3
- package/src/fields/EventSelect.vue +28 -12
- package/src/fields/KeyValue.vue +17 -12
- package/src/fields/UISelect.vue +6 -3
- package/src/hooks/index.ts +0 -1
- package/src/hooks/use-code-block-edit.ts +3 -3
- package/src/hooks/use-data-source-edit.ts +3 -2
- package/src/hooks/use-filter.ts +1 -1
- package/src/hooks/use-getso.ts +7 -7
- package/src/hooks/use-node-status.ts +2 -2
- package/src/index.ts +2 -1
- package/src/initService.ts +177 -74
- package/src/layouts/CodeEditor.vue +2 -2
- package/src/layouts/Framework.vue +13 -12
- package/src/layouts/NavMenu.vue +2 -2
- package/src/layouts/page-bar/AddButton.vue +29 -9
- package/src/layouts/page-bar/PageBar.vue +79 -66
- package/src/layouts/page-bar/PageBarScrollContainer.vue +84 -98
- package/src/layouts/page-bar/PageList.vue +5 -3
- package/src/layouts/page-bar/Search.vue +67 -0
- package/src/layouts/props-panel/FormPanel.vue +123 -0
- package/src/layouts/props-panel/PropsPanel.vue +146 -0
- package/src/layouts/props-panel/use-style-panel.ts +29 -0
- package/src/layouts/sidebar/Sidebar.vue +7 -1
- package/src/layouts/sidebar/code-block/CodeBlockList.vue +18 -2
- package/src/layouts/sidebar/code-block/CodeBlockListPanel.vue +35 -4
- package/src/layouts/sidebar/code-block/useContentMenu.ts +83 -0
- package/src/layouts/sidebar/data-source/DataSourceConfigPanel.vue +7 -5
- package/src/layouts/sidebar/data-source/DataSourceList.vue +13 -8
- package/src/layouts/sidebar/data-source/DataSourceListPanel.vue +40 -4
- package/src/layouts/sidebar/data-source/useContentMenu.ts +81 -0
- package/src/layouts/sidebar/layer/LayerMenu.vue +7 -13
- package/src/layouts/sidebar/layer/LayerPanel.vue +11 -4
- package/src/layouts/sidebar/layer/use-click.ts +2 -2
- package/src/layouts/sidebar/layer/use-keybinding.ts +2 -2
- package/src/layouts/sidebar/layer/use-node-status.ts +2 -3
- package/src/layouts/workspace/Workspace.vue +13 -3
- package/src/layouts/workspace/viewer/NodeListMenu.vue +3 -3
- package/src/layouts/workspace/viewer/Stage.vue +41 -11
- package/src/layouts/workspace/viewer/StageOverlay.vue +2 -2
- package/src/layouts/workspace/viewer/ViewerMenu.vue +4 -6
- package/src/services/dataSource.ts +12 -5
- package/src/services/dep.ts +61 -13
- package/src/services/editor.ts +46 -51
- package/src/services/storage.ts +2 -1
- package/src/services/ui.ts +1 -0
- package/src/theme/common/var.scss +12 -10
- package/src/theme/component-list-panel.scss +9 -7
- package/src/theme/content-menu.scss +7 -5
- package/src/theme/data-source.scss +3 -1
- package/src/theme/floating-box.scss +4 -2
- package/src/theme/framework.scss +7 -5
- package/src/theme/index.scss +4 -5
- package/src/theme/key-value.scss +2 -2
- package/src/theme/layer-panel.scss +3 -1
- package/src/theme/layout.scss +1 -1
- package/src/theme/nav-menu.scss +7 -5
- package/src/theme/page-bar.scss +51 -27
- package/src/theme/props-panel.scss +81 -1
- package/src/theme/resizer.scss +1 -1
- package/src/theme/search-input.scss +1 -0
- package/src/theme/sidebar.scss +4 -2
- package/src/theme/stage.scss +3 -1
- package/src/theme/theme.scss +28 -28
- package/src/theme/tree.scss +14 -12
- package/src/type.ts +10 -1
- package/src/utils/content-menu.ts +2 -2
- package/src/utils/data-source/formConfigs/http.ts +2 -0
- package/src/utils/data-source/index.ts +2 -2
- package/src/utils/editor.ts +78 -22
- package/src/utils/idle-task.ts +36 -4
- package/src/utils/props.ts +48 -6
- package/types/index.d.ts +2312 -2080
- package/src/hooks/use-data-source-method.ts +0 -100
- package/src/layouts/PropsPanel.vue +0 -131
- package/src/layouts/page-bar/SwitchTypeButton.vue +0 -45
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "1.5.
|
|
2
|
+
"version": "1.5.1",
|
|
3
3
|
"name": "@tmagic/editor",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"sideEffects": [
|
|
@@ -32,6 +32,7 @@
|
|
|
32
32
|
"node": ">=18"
|
|
33
33
|
},
|
|
34
34
|
"repository": {
|
|
35
|
+
"directory": "packages/editor",
|
|
35
36
|
"type": "git",
|
|
36
37
|
"url": "https://github.com/Tencent/tmagic-editor.git"
|
|
37
38
|
},
|
|
@@ -48,6 +49,7 @@
|
|
|
48
49
|
"@element-plus/icons-vue": "^2.3.1",
|
|
49
50
|
"buffer": "^6.0.3",
|
|
50
51
|
"color": "^3.1.3",
|
|
52
|
+
"deep-object-diff": "^1.1.9",
|
|
51
53
|
"emmet-monaco-es": "^5.3.0",
|
|
52
54
|
"events": "^3.3.0",
|
|
53
55
|
"gesto": "^1.19.1",
|
|
@@ -56,11 +58,11 @@
|
|
|
56
58
|
"moveable": "^0.53.0",
|
|
57
59
|
"serialize-javascript": "^6.0.0",
|
|
58
60
|
"sortablejs": "^1.15.2",
|
|
59
|
-
"@tmagic/
|
|
60
|
-
"@tmagic/
|
|
61
|
-
"@tmagic/form": "1.5.
|
|
62
|
-
"@tmagic/
|
|
63
|
-
"@tmagic/utils": "1.5.
|
|
61
|
+
"@tmagic/design": "1.5.1",
|
|
62
|
+
"@tmagic/stage": "1.5.1",
|
|
63
|
+
"@tmagic/form": "1.5.1",
|
|
64
|
+
"@tmagic/table": "1.5.1",
|
|
65
|
+
"@tmagic/utils": "1.5.1"
|
|
64
66
|
},
|
|
65
67
|
"devDependencies": {
|
|
66
68
|
"@types/events": "^3.0.0",
|
|
@@ -68,20 +70,20 @@
|
|
|
68
70
|
"@types/node": "^18.19.0",
|
|
69
71
|
"@types/serialize-javascript": "^5.0.1",
|
|
70
72
|
"@types/sortablejs": "^1.15.8",
|
|
71
|
-
"@vitejs/plugin-vue": "^5.1
|
|
72
|
-
"@vue/compiler-sfc": "^3.5.
|
|
73
|
+
"@vitejs/plugin-vue": "^5.2.1",
|
|
74
|
+
"@vue/compiler-sfc": "^3.5.12",
|
|
73
75
|
"@vue/test-utils": "^2.4.6",
|
|
74
76
|
"rimraf": "^3.0.2",
|
|
75
|
-
"sass": "^1.
|
|
77
|
+
"sass": "^1.83.0",
|
|
76
78
|
"tsc-alias": "^1.8.5",
|
|
77
79
|
"type-fest": "^4.10.3",
|
|
78
|
-
"vite": "^
|
|
80
|
+
"vite": "^6.0.3"
|
|
79
81
|
},
|
|
80
82
|
"peerDependencies": {
|
|
81
83
|
"monaco-editor": "^0.48.0",
|
|
82
84
|
"typescript": "*",
|
|
83
|
-
"vue": "
|
|
84
|
-
"@tmagic/core": "1.5.
|
|
85
|
+
"vue": ">=3.5.0",
|
|
86
|
+
"@tmagic/core": "1.5.1"
|
|
85
87
|
},
|
|
86
88
|
"peerDependenciesMeta": {
|
|
87
89
|
"typescript": {
|
package/src/Editor.vue
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<Framework
|
|
2
|
+
<Framework
|
|
3
|
+
:disabled-page-fragment="disabledPageFragment"
|
|
4
|
+
:page-bar-sort-options="pageBarSortOptions"
|
|
5
|
+
:page-filter-function="pageFilterFunction"
|
|
6
|
+
>
|
|
3
7
|
<template #header>
|
|
4
8
|
<slot name="header"></slot>
|
|
5
9
|
</template>
|
|
@@ -92,9 +96,9 @@
|
|
|
92
96
|
<PropsPanel
|
|
93
97
|
:extend-state="extendFormState"
|
|
94
98
|
:disabled-show-src="disabledShowSrc"
|
|
95
|
-
@mounted="
|
|
96
|
-
@form-error="
|
|
97
|
-
@submit-error="
|
|
99
|
+
@mounted="propsPanelMountedHandler"
|
|
100
|
+
@form-error="propsPanelFormErrorHandler"
|
|
101
|
+
@submit-error="propsPanelSubmitErrorHandler"
|
|
98
102
|
>
|
|
99
103
|
<template #props-panel-header>
|
|
100
104
|
<slot name="props-panel-header"></slot>
|
|
@@ -114,6 +118,7 @@
|
|
|
114
118
|
</template>
|
|
115
119
|
|
|
116
120
|
<template #page-bar><slot name="page-bar"></slot></template>
|
|
121
|
+
<template #page-bar-add-button><slot name="page-bar-add-button"></slot></template>
|
|
117
122
|
<template #page-bar-title="{ page }"><slot name="page-bar-title" :page="page"></slot></template>
|
|
118
123
|
<template #page-bar-popover="{ page }"><slot name="page-bar-popover" :page="page"></slot></template>
|
|
119
124
|
<template #page-list-popover="{ list }"><slot name="page-list-popover" :list="list"></slot></template>
|
|
@@ -129,7 +134,8 @@ import type { MApp } from '@tmagic/core';
|
|
|
129
134
|
|
|
130
135
|
import Framework from './layouts/Framework.vue';
|
|
131
136
|
import TMagicNavMenu from './layouts/NavMenu.vue';
|
|
132
|
-
import
|
|
137
|
+
import FormPanel from './layouts/props-panel/FormPanel.vue';
|
|
138
|
+
import PropsPanel from './layouts/props-panel/PropsPanel.vue';
|
|
133
139
|
import Sidebar from './layouts/sidebar/Sidebar.vue';
|
|
134
140
|
import Workspace from './layouts/workspace/Workspace.vue';
|
|
135
141
|
import codeBlockService from './services/codeBlock';
|
|
@@ -172,7 +178,7 @@ defineOptions({
|
|
|
172
178
|
});
|
|
173
179
|
|
|
174
180
|
const emit = defineEmits<{
|
|
175
|
-
'props-panel-mounted': [instance: InstanceType<typeof
|
|
181
|
+
'props-panel-mounted': [instance: InstanceType<typeof FormPanel>];
|
|
176
182
|
'update:modelValue': [value: MApp | null];
|
|
177
183
|
'props-form-error': [e: any];
|
|
178
184
|
'props-submit-error': [e: any];
|
|
@@ -226,5 +232,17 @@ provide('stageOptions', stageOptions);
|
|
|
226
232
|
|
|
227
233
|
provide<EventBus>('eventBus', new EventEmitter());
|
|
228
234
|
|
|
235
|
+
const propsPanelMountedHandler = (e: InstanceType<typeof FormPanel>) => {
|
|
236
|
+
emit('props-panel-mounted', e);
|
|
237
|
+
};
|
|
238
|
+
|
|
239
|
+
const propsPanelSubmitErrorHandler = (e: any) => {
|
|
240
|
+
emit('props-submit-error', e);
|
|
241
|
+
};
|
|
242
|
+
|
|
243
|
+
const propsPanelFormErrorHandler = (e: any) => {
|
|
244
|
+
emit('props-form-error', e);
|
|
245
|
+
};
|
|
246
|
+
|
|
229
247
|
defineExpose(services);
|
|
230
248
|
</script>
|
|
@@ -59,11 +59,17 @@
|
|
|
59
59
|
</template>
|
|
60
60
|
|
|
61
61
|
<script lang="ts" setup>
|
|
62
|
-
import { computed, inject, Ref, ref } from 'vue';
|
|
62
|
+
import { computed, inject, Ref, ref, useTemplateRef } from 'vue';
|
|
63
63
|
|
|
64
64
|
import type { CodeBlockContent } from '@tmagic/core';
|
|
65
65
|
import { TMagicButton, TMagicDialog, tMagicMessage, tMagicMessageBox, TMagicTag } from '@tmagic/design';
|
|
66
|
-
import {
|
|
66
|
+
import {
|
|
67
|
+
type ContainerChangeEventData,
|
|
68
|
+
type FormConfig,
|
|
69
|
+
type FormState,
|
|
70
|
+
MFormBox,
|
|
71
|
+
type TableColumnConfig,
|
|
72
|
+
} from '@tmagic/form';
|
|
67
73
|
|
|
68
74
|
import FloatingBox from '@editor/components/FloatingBox.vue';
|
|
69
75
|
import { useEditorContentHeight } from '@editor/hooks/use-editor-content-height';
|
|
@@ -88,7 +94,7 @@ const props = defineProps<{
|
|
|
88
94
|
}>();
|
|
89
95
|
|
|
90
96
|
const emit = defineEmits<{
|
|
91
|
-
submit: [values: CodeBlockContent];
|
|
97
|
+
submit: [values: CodeBlockContent, eventData: ContainerChangeEventData];
|
|
92
98
|
}>();
|
|
93
99
|
|
|
94
100
|
const services = inject<Services>('services');
|
|
@@ -98,7 +104,7 @@ const { height: codeBlockEditorHeight } = useEditorContentHeight();
|
|
|
98
104
|
const difVisible = ref(false);
|
|
99
105
|
const { rect: windowRect } = useWindowRect();
|
|
100
106
|
|
|
101
|
-
const magicVsEditor =
|
|
107
|
+
const magicVsEditor = useTemplateRef<InstanceType<typeof CodeEditor>>('magicVsEditor');
|
|
102
108
|
|
|
103
109
|
const diffChange = () => {
|
|
104
110
|
if (!magicVsEditor.value || !formBox.value?.form) {
|
|
@@ -209,16 +215,16 @@ const functionConfig = computed<FormConfig>(() => [
|
|
|
209
215
|
},
|
|
210
216
|
]);
|
|
211
217
|
|
|
212
|
-
const submitForm = (values: CodeBlockContent) => {
|
|
218
|
+
const submitForm = (values: CodeBlockContent, data: ContainerChangeEventData) => {
|
|
213
219
|
changedValue.value = undefined;
|
|
214
|
-
emit('submit', values);
|
|
220
|
+
emit('submit', values, data);
|
|
215
221
|
};
|
|
216
222
|
|
|
217
223
|
const errorHandler = (error: any) => {
|
|
218
224
|
tMagicMessage.error(error.message);
|
|
219
225
|
};
|
|
220
226
|
|
|
221
|
-
const formBox =
|
|
227
|
+
const formBox = useTemplateRef<InstanceType<typeof MFormBox>>('formBox');
|
|
222
228
|
|
|
223
229
|
const changedValue = ref<CodeBlockContent>();
|
|
224
230
|
const changeHandler = (values: CodeBlockContent) => {
|
|
@@ -238,7 +244,7 @@ const beforeClose = (done: (cancel?: boolean) => void) => {
|
|
|
238
244
|
distinguishCancelAndClose: true,
|
|
239
245
|
})
|
|
240
246
|
.then(() => {
|
|
241
|
-
changedValue.value && submitForm(changedValue.value);
|
|
247
|
+
changedValue.value && submitForm(changedValue.value, { changeRecords: formBox.value?.form?.changeRecords });
|
|
242
248
|
done();
|
|
243
249
|
})
|
|
244
250
|
.catch((action: string) => {
|
|
@@ -11,9 +11,9 @@
|
|
|
11
11
|
</template>
|
|
12
12
|
|
|
13
13
|
<script lang="ts" setup>
|
|
14
|
-
import { computed,
|
|
14
|
+
import { computed, useTemplateRef } from 'vue';
|
|
15
15
|
|
|
16
|
-
import { FormConfig, MForm } from '@tmagic/form';
|
|
16
|
+
import { type ContainerChangeEventData, type FormConfig, type FormValue, MForm } from '@tmagic/form';
|
|
17
17
|
|
|
18
18
|
import type { CodeParamStatement } from '@editor/type';
|
|
19
19
|
import { error } from '@editor/utils';
|
|
@@ -32,7 +32,7 @@ const props = defineProps<{
|
|
|
32
32
|
|
|
33
33
|
const emit = defineEmits(['change']);
|
|
34
34
|
|
|
35
|
-
const form =
|
|
35
|
+
const form = useTemplateRef<InstanceType<typeof MForm>>('form');
|
|
36
36
|
|
|
37
37
|
const getFormConfig = (items: FormConfig = []) => [
|
|
38
38
|
{
|
|
@@ -59,10 +59,10 @@ const codeParamsConfig = computed(() =>
|
|
|
59
59
|
/**
|
|
60
60
|
* 参数值修改更新
|
|
61
61
|
*/
|
|
62
|
-
const onParamsChangeHandler = async () => {
|
|
62
|
+
const onParamsChangeHandler = async (v: FormValue, eventData: ContainerChangeEventData) => {
|
|
63
63
|
try {
|
|
64
64
|
const value = await form.value?.submitForm(true);
|
|
65
|
-
emit('change', value);
|
|
65
|
+
emit('change', value, eventData);
|
|
66
66
|
} catch (e) {
|
|
67
67
|
error(e);
|
|
68
68
|
}
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
ref="menu"
|
|
7
7
|
:style="menuStyle"
|
|
8
8
|
@mouseenter="mouseenterHandler()"
|
|
9
|
+
@contextmenu.prevent
|
|
9
10
|
>
|
|
10
11
|
<slot name="title"></slot>
|
|
11
12
|
<div>
|
|
@@ -36,7 +37,7 @@
|
|
|
36
37
|
</template>
|
|
37
38
|
|
|
38
39
|
<script lang="ts" setup>
|
|
39
|
-
import { computed, nextTick, onBeforeUnmount, onMounted, ref } from 'vue';
|
|
40
|
+
import { computed, nextTick, onBeforeUnmount, onMounted, ref, useTemplateRef } from 'vue';
|
|
40
41
|
|
|
41
42
|
import { useZIndex } from '@tmagic/design';
|
|
42
43
|
|
|
@@ -68,9 +69,9 @@ const emit = defineEmits<{
|
|
|
68
69
|
mouseenter: [];
|
|
69
70
|
}>();
|
|
70
71
|
|
|
71
|
-
const menu =
|
|
72
|
-
const buttons =
|
|
73
|
-
const subMenu =
|
|
72
|
+
const menu = useTemplateRef<HTMLDivElement>('menu');
|
|
73
|
+
const buttons = useTemplateRef<InstanceType<typeof ToolButton>[]>('buttons');
|
|
74
|
+
const subMenu = useTemplateRef<any>('subMenu');
|
|
74
75
|
const visible = ref(false);
|
|
75
76
|
const subMenuData = ref<(MenuButton | MenuComponent)[]>([]);
|
|
76
77
|
const zIndex = useZIndex();
|
|
@@ -82,8 +83,8 @@ const menuPosition = ref({
|
|
|
82
83
|
});
|
|
83
84
|
|
|
84
85
|
const menuStyle = computed(() => ({
|
|
85
|
-
top: `${menuPosition.value.top}px`,
|
|
86
|
-
left: `${menuPosition.value.left}px`,
|
|
86
|
+
top: `${menuPosition.value.top + 2}px`,
|
|
87
|
+
left: `${menuPosition.value.left + 2}px`,
|
|
87
88
|
zIndex: curZIndex.value,
|
|
88
89
|
}));
|
|
89
90
|
|
|
@@ -98,10 +99,12 @@ const hide = () => {
|
|
|
98
99
|
emit('hide');
|
|
99
100
|
};
|
|
100
101
|
|
|
101
|
-
const clickHandler = () => {
|
|
102
|
+
const clickHandler = (event: MouseEvent) => {
|
|
102
103
|
if (!props.autoHide) return;
|
|
103
104
|
|
|
104
|
-
|
|
105
|
+
if (event.button === 0) {
|
|
106
|
+
hide();
|
|
107
|
+
}
|
|
105
108
|
};
|
|
106
109
|
|
|
107
110
|
const outsideClickHideHandler = (e: MouseEvent) => {
|
|
@@ -132,18 +135,15 @@ const setPosition = (e: { clientY: number; clientX: number }) => {
|
|
|
132
135
|
};
|
|
133
136
|
|
|
134
137
|
const show = (e?: { clientY: number; clientX: number }) => {
|
|
135
|
-
|
|
136
|
-
setTimeout(() => {
|
|
137
|
-
visible.value = true;
|
|
138
|
+
visible.value = true;
|
|
138
139
|
|
|
139
|
-
|
|
140
|
-
|
|
140
|
+
nextTick(() => {
|
|
141
|
+
e && setPosition(e);
|
|
141
142
|
|
|
142
|
-
|
|
143
|
+
curZIndex.value = zIndex.nextZIndex();
|
|
143
144
|
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
}, 300);
|
|
145
|
+
emit('show');
|
|
146
|
+
});
|
|
147
147
|
};
|
|
148
148
|
|
|
149
149
|
const showSubMenu = (item: MenuButton | MenuComponent, index: number) => {
|
|
@@ -166,7 +166,7 @@ const showSubMenu = (item: MenuButton | MenuComponent, index: number) => {
|
|
|
166
166
|
y = rect.top;
|
|
167
167
|
}
|
|
168
168
|
subMenu.value?.show({
|
|
169
|
-
clientX: menu.value.offsetLeft + menu.value.clientWidth,
|
|
169
|
+
clientX: menu.value.offsetLeft + menu.value.clientWidth - 2,
|
|
170
170
|
clientY: y,
|
|
171
171
|
});
|
|
172
172
|
}
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
</template>
|
|
18
18
|
|
|
19
19
|
<script setup lang="ts">
|
|
20
|
-
import { computed, inject, nextTick, onBeforeUnmount, provide, ref, watch } from 'vue';
|
|
20
|
+
import { computed, inject, nextTick, onBeforeUnmount, provide, ref, useTemplateRef, watch } from 'vue';
|
|
21
21
|
import { Close } from '@element-plus/icons-vue';
|
|
22
22
|
import VanillaMoveable from 'moveable';
|
|
23
23
|
|
|
@@ -47,8 +47,8 @@ const props = withDefaults(
|
|
|
47
47
|
},
|
|
48
48
|
);
|
|
49
49
|
|
|
50
|
-
const target =
|
|
51
|
-
const titleEl =
|
|
50
|
+
const target = useTemplateRef<HTMLDivElement>('target');
|
|
51
|
+
const titleEl = useTemplateRef<HTMLDivElement>('titleEl');
|
|
52
52
|
|
|
53
53
|
const zIndex = useZIndex();
|
|
54
54
|
const curZIndex = ref<number>(0);
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<span ref="target" class="m-editor-resizer" :class="{ 'm-editor-resizer-
|
|
2
|
+
<span ref="target" class="m-editor-resizer" :class="{ 'm-editor-resizer-dragging': isDragging }">
|
|
3
3
|
<slot></slot>
|
|
4
4
|
</span>
|
|
5
5
|
</template>
|
|
6
6
|
|
|
7
7
|
<script lang="ts" setup>
|
|
8
|
-
import {
|
|
8
|
+
import { useTemplateRef } from 'vue';
|
|
9
9
|
import type { OnDrag } from 'gesto';
|
|
10
10
|
|
|
11
11
|
import { useGetSo } from '@editor/hooks/use-getso';
|
|
@@ -18,6 +18,6 @@ const emit = defineEmits<{
|
|
|
18
18
|
change: [e: OnDrag];
|
|
19
19
|
}>();
|
|
20
20
|
|
|
21
|
-
const target =
|
|
22
|
-
const {
|
|
21
|
+
const target = useTemplateRef<HTMLSpanElement>('target');
|
|
22
|
+
const { isDragging } = useGetSo(target, emit);
|
|
23
23
|
</script>
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
</template>
|
|
6
6
|
|
|
7
7
|
<script lang="ts" setup>
|
|
8
|
-
import { computed, onBeforeUnmount, onMounted,
|
|
8
|
+
import { computed, onBeforeUnmount, onMounted, useTemplateRef } from 'vue';
|
|
9
9
|
import Gesto from 'gesto';
|
|
10
10
|
|
|
11
11
|
defineOptions({
|
|
@@ -21,8 +21,8 @@ const props = defineProps<{
|
|
|
21
21
|
|
|
22
22
|
const emit = defineEmits(['scroll']);
|
|
23
23
|
|
|
24
|
-
const bar =
|
|
25
|
-
const thumb =
|
|
24
|
+
const bar = useTemplateRef<HTMLDivElement>('bar');
|
|
25
|
+
const thumb = useTemplateRef<HTMLDivElement>('thumb');
|
|
26
26
|
|
|
27
27
|
const thumbSize = computed(() => props.size * (props.size / props.scrollSize));
|
|
28
28
|
const thumbPos = computed(() => (props.pos / props.scrollSize) * props.size);
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
</template>
|
|
26
26
|
|
|
27
27
|
<script lang="ts" setup>
|
|
28
|
-
import { computed, onBeforeUnmount, onMounted, ref, watch } from 'vue';
|
|
28
|
+
import { computed, onBeforeUnmount, onMounted, ref, useTemplateRef, watch } from 'vue';
|
|
29
29
|
|
|
30
30
|
import { isNumber } from '@tmagic/utils';
|
|
31
31
|
|
|
@@ -63,8 +63,8 @@ const props = withDefaults(
|
|
|
63
63
|
},
|
|
64
64
|
);
|
|
65
65
|
|
|
66
|
-
const container =
|
|
67
|
-
const el =
|
|
66
|
+
const container = useTemplateRef<HTMLDivElement>('container');
|
|
67
|
+
const el = useTemplateRef<HTMLDivElement>('el');
|
|
68
68
|
const style = computed(
|
|
69
69
|
() => `
|
|
70
70
|
width: ${isNumber(`${props.width}`) ? `${props.width}px` : props.width};
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
</template>
|
|
22
22
|
|
|
23
23
|
<script lang="ts" setup>
|
|
24
|
-
import { computed, onBeforeUnmount, onMounted, ref, watchEffect } from 'vue';
|
|
24
|
+
import { computed, onBeforeUnmount, onMounted, ref, useTemplateRef, watchEffect } from 'vue';
|
|
25
25
|
import { OnDrag } from 'gesto';
|
|
26
26
|
|
|
27
27
|
import Resizer from './Resizer.vue';
|
|
@@ -51,7 +51,7 @@ const props = withDefaults(
|
|
|
51
51
|
},
|
|
52
52
|
);
|
|
53
53
|
|
|
54
|
-
const el =
|
|
54
|
+
const el = useTemplateRef<HTMLElement>('el');
|
|
55
55
|
|
|
56
56
|
const hasLeft = computed(() => typeof props.left !== 'undefined');
|
|
57
57
|
const hasRight = computed(() => typeof props.right !== 'undefined');
|
|
@@ -131,7 +131,8 @@ const mousedownHandler = (item: MenuButton | MenuComponent, event: MouseEvent) =
|
|
|
131
131
|
|
|
132
132
|
const mouseupHandler = (item: MenuButton | MenuComponent, event: MouseEvent) => {
|
|
133
133
|
if (props.eventType !== 'mouseup') return;
|
|
134
|
-
|
|
134
|
+
|
|
135
|
+
if (item.type === 'button' && event.button === 0) {
|
|
135
136
|
buttonHandler(item, event);
|
|
136
137
|
}
|
|
137
138
|
};
|
package/src/editorProps.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { DataSourceSchema, EventOption, Id, MApp, MNode } from '@tmagic/core';
|
|
1
|
+
import type { DataSourceSchema, EventOption, Id, MApp, MNode, MPage, MPageFragment } from '@tmagic/core';
|
|
2
2
|
import type { FormConfig, FormState } from '@tmagic/form';
|
|
3
3
|
import StageCore, {
|
|
4
4
|
CONTAINER_HIGHLIGHT_CLASS_NAME,
|
|
@@ -13,6 +13,7 @@ import { getIdFromEl } from '@tmagic/utils';
|
|
|
13
13
|
|
|
14
14
|
import type {
|
|
15
15
|
ComponentGroup,
|
|
16
|
+
CustomContentMenuFunction,
|
|
16
17
|
DatasourceTypeOption,
|
|
17
18
|
MenuBarData,
|
|
18
19
|
MenuButton,
|
|
@@ -93,10 +94,12 @@ export interface EditorProps {
|
|
|
93
94
|
/** 用于设置画布上的dom是否可以被拖入其中 */
|
|
94
95
|
isContainer?: (el: HTMLElement) => boolean | Promise<boolean>;
|
|
95
96
|
/** 用于自定义组件树与画布的右键菜单 */
|
|
96
|
-
customContentMenu?:
|
|
97
|
+
customContentMenu?: CustomContentMenuFunction;
|
|
97
98
|
extendFormState?: (state: FormState) => Record<string, any> | Promise<Record<string, any>>;
|
|
98
99
|
/** 页面顺序拖拽配置参数 */
|
|
99
100
|
pageBarSortOptions?: PageBarSortOptions;
|
|
101
|
+
/** 页面搜索函数 */
|
|
102
|
+
pageFilterFunction?: (page: MPage | MPageFragment, keyword: string) => boolean;
|
|
100
103
|
}
|
|
101
104
|
|
|
102
105
|
export const defaultEditorProps = {
|
|
@@ -121,4 +124,5 @@ export const defaultEditorProps = {
|
|
|
121
124
|
canSelect: (el: HTMLElement) => Boolean(getIdFromEl()(el)),
|
|
122
125
|
isContainer: (el: HTMLElement) => el.classList.contains('magic-ui-container'),
|
|
123
126
|
codeOptions: () => ({}),
|
|
127
|
+
customContentMenu: (menus: (MenuButton | MenuComponent)[]) => menus,
|
|
124
128
|
};
|
package/src/fields/Code.vue
CHANGED
|
@@ -25,7 +25,7 @@ const emit = defineEmits<{
|
|
|
25
25
|
change: [value: string | any];
|
|
26
26
|
}>();
|
|
27
27
|
|
|
28
|
-
|
|
28
|
+
withDefaults(
|
|
29
29
|
defineProps<
|
|
30
30
|
FieldProps<
|
|
31
31
|
{
|
|
@@ -44,7 +44,6 @@ const props = withDefaults(
|
|
|
44
44
|
);
|
|
45
45
|
|
|
46
46
|
const save = (v: string | any) => {
|
|
47
|
-
props.model[props.name] = v;
|
|
48
47
|
emit('change', v);
|
|
49
48
|
};
|
|
50
49
|
</script>
|
|
@@ -21,8 +21,8 @@ import { isEmpty } from 'lodash-es';
|
|
|
21
21
|
|
|
22
22
|
import { HookCodeType, HookType } from '@tmagic/core';
|
|
23
23
|
import { TMagicCard } from '@tmagic/design';
|
|
24
|
-
import type { FieldProps, FormItem } from '@tmagic/form';
|
|
25
|
-
import {
|
|
24
|
+
import type { ContainerChangeEventData, FieldProps, FormItem, GroupListConfig } from '@tmagic/form';
|
|
25
|
+
import { MContainer } from '@tmagic/form';
|
|
26
26
|
|
|
27
27
|
import type { Services } from '@editor/type';
|
|
28
28
|
|
|
@@ -30,7 +30,9 @@ defineOptions({
|
|
|
30
30
|
name: 'MFieldsCodeSelect',
|
|
31
31
|
});
|
|
32
32
|
|
|
33
|
-
const emit = defineEmits
|
|
33
|
+
const emit = defineEmits<{
|
|
34
|
+
change: [v: any, eventData: ContainerChangeEventData];
|
|
35
|
+
}>();
|
|
34
36
|
|
|
35
37
|
const services = inject<Services>('services');
|
|
36
38
|
|
|
@@ -45,12 +47,12 @@ const props = withDefaults(
|
|
|
45
47
|
{},
|
|
46
48
|
);
|
|
47
49
|
|
|
48
|
-
const codeConfig = computed(() => ({
|
|
50
|
+
const codeConfig = computed<GroupListConfig>(() => ({
|
|
49
51
|
type: 'group-list',
|
|
50
52
|
name: 'hookData',
|
|
51
53
|
enableToggleMode: false,
|
|
52
54
|
expandAll: true,
|
|
53
|
-
title: (mForm
|
|
55
|
+
title: (mForm, { model, index }: any) => {
|
|
54
56
|
if (model.codeType === HookCodeType.DATA_SOURCE_METHOD) {
|
|
55
57
|
if (Array.isArray(model.codeId)) {
|
|
56
58
|
if (model.codeId.length < 2) {
|
|
@@ -78,11 +80,13 @@ const codeConfig = computed(() => ({
|
|
|
78
80
|
{ value: HookCodeType.DATA_SOURCE_METHOD, text: '数据源方法' },
|
|
79
81
|
],
|
|
80
82
|
defaultValue: 'code',
|
|
81
|
-
onChange: (mForm
|
|
83
|
+
onChange: (mForm, v: HookCodeType, { model, prop, changeRecords }) => {
|
|
82
84
|
if (v === HookCodeType.DATA_SOURCE_METHOD) {
|
|
83
85
|
model.codeId = [];
|
|
86
|
+
changeRecords.push({ propPath: prop.replace('codeType', 'codeId'), value: [] });
|
|
84
87
|
} else {
|
|
85
88
|
model.codeId = '';
|
|
89
|
+
changeRecords.push({ propPath: prop.replace('codeType', 'codeId'), value: '' });
|
|
86
90
|
}
|
|
87
91
|
|
|
88
92
|
return v;
|
|
@@ -93,7 +97,7 @@ const codeConfig = computed(() => ({
|
|
|
93
97
|
name: 'codeId',
|
|
94
98
|
span: 18,
|
|
95
99
|
labelWidth: 0,
|
|
96
|
-
display: (mForm
|
|
100
|
+
display: (mForm, { model }) => model.codeType !== HookCodeType.DATA_SOURCE_METHOD,
|
|
97
101
|
notEditable: () => !services?.codeBlockService.getEditStatus(),
|
|
98
102
|
},
|
|
99
103
|
{
|
|
@@ -101,7 +105,7 @@ const codeConfig = computed(() => ({
|
|
|
101
105
|
name: 'codeId',
|
|
102
106
|
span: 18,
|
|
103
107
|
labelWidth: 0,
|
|
104
|
-
display: (mForm
|
|
108
|
+
display: (mForm, { model }) => model.codeType === HookCodeType.DATA_SOURCE_METHOD,
|
|
105
109
|
notEditable: () => !services?.dataSourceService.get('editable'),
|
|
106
110
|
},
|
|
107
111
|
],
|
|
@@ -126,7 +130,5 @@ watch(
|
|
|
126
130
|
},
|
|
127
131
|
);
|
|
128
132
|
|
|
129
|
-
const changeHandler =
|
|
130
|
-
emit('change', props.model[props.name]);
|
|
131
|
-
};
|
|
133
|
+
const changeHandler = (v: any, eventData: ContainerChangeEventData) => emit('change', v, eventData);
|
|
132
134
|
</script>
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
:config="selectConfig"
|
|
8
8
|
:model="model"
|
|
9
9
|
:size="size"
|
|
10
|
-
@change="
|
|
10
|
+
@change="onCodeIdChangeHandler"
|
|
11
11
|
></MContainer>
|
|
12
12
|
|
|
13
13
|
<!-- 查看/编辑按钮 -->
|
|
@@ -41,7 +41,14 @@ import { isEmpty, map } from 'lodash-es';
|
|
|
41
41
|
|
|
42
42
|
import type { Id } from '@tmagic/core';
|
|
43
43
|
import { TMagicButton } from '@tmagic/design';
|
|
44
|
-
import {
|
|
44
|
+
import {
|
|
45
|
+
type ContainerChangeEventData,
|
|
46
|
+
createValues,
|
|
47
|
+
type FieldProps,
|
|
48
|
+
filterFunction,
|
|
49
|
+
type FormState,
|
|
50
|
+
MContainer,
|
|
51
|
+
} from '@tmagic/form';
|
|
45
52
|
|
|
46
53
|
import CodeParams from '@editor/components/CodeParams.vue';
|
|
47
54
|
import MIcon from '@editor/components/Icon.vue';
|
|
@@ -55,7 +62,9 @@ defineOptions({
|
|
|
55
62
|
const mForm = inject<FormState | undefined>('mForm');
|
|
56
63
|
const services = inject<Services>('services');
|
|
57
64
|
const eventBus = inject<EventBus>('eventBus');
|
|
58
|
-
const emit = defineEmits
|
|
65
|
+
const emit = defineEmits<{
|
|
66
|
+
change: [v: any, eventData: ContainerChangeEventData];
|
|
67
|
+
}>();
|
|
59
68
|
|
|
60
69
|
const props = withDefaults(defineProps<FieldProps<CodeSelectColConfig>>(), {
|
|
61
70
|
disabled: false,
|
|
@@ -125,12 +134,30 @@ const selectConfig = {
|
|
|
125
134
|
},
|
|
126
135
|
};
|
|
127
136
|
|
|
137
|
+
const onCodeIdChangeHandler = (value: any) => {
|
|
138
|
+
props.model.params = value.params;
|
|
139
|
+
emit('change', props.model, {
|
|
140
|
+
changeRecords: [
|
|
141
|
+
{
|
|
142
|
+
propPath: props.prop,
|
|
143
|
+
value: value[props.name],
|
|
144
|
+
},
|
|
145
|
+
],
|
|
146
|
+
});
|
|
147
|
+
};
|
|
148
|
+
|
|
128
149
|
/**
|
|
129
150
|
* 参数值修改更新
|
|
130
151
|
*/
|
|
131
|
-
const onParamsChangeHandler = (value: any) => {
|
|
152
|
+
const onParamsChangeHandler = (value: any, eventData: ContainerChangeEventData) => {
|
|
132
153
|
props.model.params = value.params;
|
|
133
|
-
emit('change', props.model
|
|
154
|
+
emit('change', props.model, {
|
|
155
|
+
...eventData,
|
|
156
|
+
changeRecords: (eventData.changeRecords || []).map((item) => ({
|
|
157
|
+
prop: `${props.prop.replace(props.name, '')}${item.propPath}`,
|
|
158
|
+
value: item.value,
|
|
159
|
+
})),
|
|
160
|
+
});
|
|
134
161
|
};
|
|
135
162
|
|
|
136
163
|
const editCode = (id: string) => {
|
|
@@ -39,7 +39,10 @@ defineOptions({
|
|
|
39
39
|
name: 'MFieldsCondOpSelect',
|
|
40
40
|
});
|
|
41
41
|
|
|
42
|
-
const emit = defineEmits
|
|
42
|
+
const emit = defineEmits<{
|
|
43
|
+
change: [value: string];
|
|
44
|
+
}>();
|
|
45
|
+
|
|
43
46
|
const { dataSourceService } = inject<Services>('services') || {};
|
|
44
47
|
|
|
45
48
|
const props = defineProps<FieldProps<CondOpSelectConfig>>();
|
|
@@ -81,7 +84,7 @@ const options = computed(() => {
|
|
|
81
84
|
return [...arrayOptions, ...eqOptions, ...numberOptions];
|
|
82
85
|
});
|
|
83
86
|
|
|
84
|
-
const fieldChangeHandler = (v: string
|
|
87
|
+
const fieldChangeHandler = (v: string) => {
|
|
85
88
|
emit('change', v);
|
|
86
89
|
};
|
|
87
90
|
</script>
|