@tmagic/editor 1.5.0 → 1.5.2
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 +153 -6
- package/dist/tmagic-editor.js +907 -528
- package/dist/tmagic-editor.umd.cjs +932 -552
- package/package.json +10 -10
- package/src/Editor.vue +18 -5
- package/src/components/CodeBlockEditor.vue +3 -3
- package/src/components/CodeParams.vue +2 -2
- 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 +3 -1
- package/src/fields/DataSourceFieldSelect/Index.vue +6 -6
- package/src/fields/DataSourceInput.vue +2 -2
- package/src/fields/DataSourceMethods.vue +2 -2
- package/src/fields/DataSourceMocks.vue +0 -1
- package/src/fields/EventSelect.vue +0 -1
- package/src/fields/KeyValue.vue +2 -2
- package/src/hooks/use-code-block-edit.ts +2 -2
- package/src/hooks/use-getso.ts +7 -7
- package/src/index.ts +2 -1
- package/src/layouts/CodeEditor.vue +2 -2
- package/src/layouts/Framework.vue +5 -8
- package/src/layouts/NavMenu.vue +2 -2
- package/src/layouts/page-bar/PageBar.vue +3 -3
- package/src/layouts/page-bar/PageBarScrollContainer.vue +3 -3
- 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 +4 -1
- package/src/layouts/sidebar/code-block/CodeBlockList.vue +12 -1
- 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/DataSourceList.vue +8 -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/workspace/Workspace.vue +9 -2
- package/src/layouts/workspace/viewer/NodeListMenu.vue +3 -3
- package/src/layouts/workspace/viewer/Stage.vue +18 -6
- package/src/layouts/workspace/viewer/StageOverlay.vue +2 -2
- package/src/layouts/workspace/viewer/ViewerMenu.vue +4 -6
- 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 +17 -15
- package/src/theme/props-panel.scss +81 -1
- package/src/theme/resizer.scss +1 -1
- 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 +8 -0
- package/src/utils/content-menu.ts +2 -2
- package/src/utils/props.ts +45 -3
- package/types/index.d.ts +1796 -1230
- package/src/layouts/PropsPanel.vue +0 -131
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "1.5.
|
|
2
|
+
"version": "1.5.2",
|
|
3
3
|
"name": "@tmagic/editor",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"sideEffects": [
|
|
@@ -58,11 +58,11 @@
|
|
|
58
58
|
"moveable": "^0.53.0",
|
|
59
59
|
"serialize-javascript": "^6.0.0",
|
|
60
60
|
"sortablejs": "^1.15.2",
|
|
61
|
-
"@tmagic/design": "1.5.
|
|
62
|
-
"@tmagic/
|
|
63
|
-
"@tmagic/stage": "1.5.
|
|
64
|
-
"@tmagic/utils": "1.5.
|
|
65
|
-
"@tmagic/
|
|
61
|
+
"@tmagic/design": "1.5.2",
|
|
62
|
+
"@tmagic/table": "1.5.2",
|
|
63
|
+
"@tmagic/stage": "1.5.2",
|
|
64
|
+
"@tmagic/utils": "1.5.2",
|
|
65
|
+
"@tmagic/form": "1.5.2"
|
|
66
66
|
},
|
|
67
67
|
"devDependencies": {
|
|
68
68
|
"@types/events": "^3.0.0",
|
|
@@ -70,20 +70,20 @@
|
|
|
70
70
|
"@types/node": "^18.19.0",
|
|
71
71
|
"@types/serialize-javascript": "^5.0.1",
|
|
72
72
|
"@types/sortablejs": "^1.15.8",
|
|
73
|
-
"@vitejs/plugin-vue": "^5.1
|
|
73
|
+
"@vitejs/plugin-vue": "^5.2.1",
|
|
74
74
|
"@vue/compiler-sfc": "^3.5.12",
|
|
75
75
|
"@vue/test-utils": "^2.4.6",
|
|
76
76
|
"rimraf": "^3.0.2",
|
|
77
|
-
"sass": "^1.
|
|
77
|
+
"sass": "^1.83.0",
|
|
78
78
|
"tsc-alias": "^1.8.5",
|
|
79
79
|
"type-fest": "^4.10.3",
|
|
80
|
-
"vite": "^
|
|
80
|
+
"vite": "^6.0.3"
|
|
81
81
|
},
|
|
82
82
|
"peerDependencies": {
|
|
83
83
|
"monaco-editor": "^0.48.0",
|
|
84
84
|
"typescript": "*",
|
|
85
85
|
"vue": ">=3.5.0",
|
|
86
|
-
"@tmagic/core": "1.5.
|
|
86
|
+
"@tmagic/core": "1.5.2"
|
|
87
87
|
},
|
|
88
88
|
"peerDependenciesMeta": {
|
|
89
89
|
"typescript": {
|
package/src/Editor.vue
CHANGED
|
@@ -96,9 +96,9 @@
|
|
|
96
96
|
<PropsPanel
|
|
97
97
|
:extend-state="extendFormState"
|
|
98
98
|
:disabled-show-src="disabledShowSrc"
|
|
99
|
-
@mounted="
|
|
100
|
-
@form-error="
|
|
101
|
-
@submit-error="
|
|
99
|
+
@mounted="propsPanelMountedHandler"
|
|
100
|
+
@form-error="propsPanelFormErrorHandler"
|
|
101
|
+
@submit-error="propsPanelSubmitErrorHandler"
|
|
102
102
|
>
|
|
103
103
|
<template #props-panel-header>
|
|
104
104
|
<slot name="props-panel-header"></slot>
|
|
@@ -134,7 +134,8 @@ import type { MApp } from '@tmagic/core';
|
|
|
134
134
|
|
|
135
135
|
import Framework from './layouts/Framework.vue';
|
|
136
136
|
import TMagicNavMenu from './layouts/NavMenu.vue';
|
|
137
|
-
import
|
|
137
|
+
import FormPanel from './layouts/props-panel/FormPanel.vue';
|
|
138
|
+
import PropsPanel from './layouts/props-panel/PropsPanel.vue';
|
|
138
139
|
import Sidebar from './layouts/sidebar/Sidebar.vue';
|
|
139
140
|
import Workspace from './layouts/workspace/Workspace.vue';
|
|
140
141
|
import codeBlockService from './services/codeBlock';
|
|
@@ -177,7 +178,7 @@ defineOptions({
|
|
|
177
178
|
});
|
|
178
179
|
|
|
179
180
|
const emit = defineEmits<{
|
|
180
|
-
'props-panel-mounted': [instance: InstanceType<typeof
|
|
181
|
+
'props-panel-mounted': [instance: InstanceType<typeof FormPanel>];
|
|
181
182
|
'update:modelValue': [value: MApp | null];
|
|
182
183
|
'props-form-error': [e: any];
|
|
183
184
|
'props-submit-error': [e: any];
|
|
@@ -231,5 +232,17 @@ provide('stageOptions', stageOptions);
|
|
|
231
232
|
|
|
232
233
|
provide<EventBus>('eventBus', new EventEmitter());
|
|
233
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
|
+
|
|
234
247
|
defineExpose(services);
|
|
235
248
|
</script>
|
|
@@ -59,7 +59,7 @@
|
|
|
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';
|
|
@@ -104,7 +104,7 @@ const { height: codeBlockEditorHeight } = useEditorContentHeight();
|
|
|
104
104
|
const difVisible = ref(false);
|
|
105
105
|
const { rect: windowRect } = useWindowRect();
|
|
106
106
|
|
|
107
|
-
const magicVsEditor =
|
|
107
|
+
const magicVsEditor = useTemplateRef<InstanceType<typeof CodeEditor>>('magicVsEditor');
|
|
108
108
|
|
|
109
109
|
const diffChange = () => {
|
|
110
110
|
if (!magicVsEditor.value || !formBox.value?.form) {
|
|
@@ -224,7 +224,7 @@ const errorHandler = (error: any) => {
|
|
|
224
224
|
tMagicMessage.error(error.message);
|
|
225
225
|
};
|
|
226
226
|
|
|
227
|
-
const formBox =
|
|
227
|
+
const formBox = useTemplateRef<InstanceType<typeof MFormBox>>('formBox');
|
|
228
228
|
|
|
229
229
|
const changedValue = ref<CodeBlockContent>();
|
|
230
230
|
const changeHandler = (values: CodeBlockContent) => {
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
</template>
|
|
12
12
|
|
|
13
13
|
<script lang="ts" setup>
|
|
14
|
-
import { computed,
|
|
14
|
+
import { computed, useTemplateRef } from 'vue';
|
|
15
15
|
|
|
16
16
|
import { type ContainerChangeEventData, type FormConfig, type FormValue, MForm } from '@tmagic/form';
|
|
17
17
|
|
|
@@ -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
|
{
|
|
@@ -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
|
@@ -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,7 +94,7 @@ 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;
|
|
@@ -123,4 +124,5 @@ export const defaultEditorProps = {
|
|
|
123
124
|
canSelect: (el: HTMLElement) => Boolean(getIdFromEl()(el)),
|
|
124
125
|
isContainer: (el: HTMLElement) => el.classList.contains('magic-ui-container'),
|
|
125
126
|
codeOptions: () => ({}),
|
|
127
|
+
customContentMenu: (menus: (MenuButton | MenuComponent)[]) => menus,
|
|
126
128
|
};
|
|
@@ -44,7 +44,7 @@ import { Coin } from '@element-plus/icons-vue';
|
|
|
44
44
|
|
|
45
45
|
import { DataSchema } from '@tmagic/core';
|
|
46
46
|
import { TMagicButton, tMagicMessage, TMagicTooltip } from '@tmagic/design';
|
|
47
|
-
import type { FieldProps, FormState } from '@tmagic/form';
|
|
47
|
+
import type { ContainerChangeEventData, FieldProps, FormState } from '@tmagic/form';
|
|
48
48
|
import { DATA_SOURCE_FIELDS_SELECT_VALUE_PREFIX } from '@tmagic/utils';
|
|
49
49
|
|
|
50
50
|
import MIcon from '@editor/components/Icon.vue';
|
|
@@ -129,9 +129,9 @@ const checkStrictly = computed(() => {
|
|
|
129
129
|
return value ?? props.config.value === 'key';
|
|
130
130
|
});
|
|
131
131
|
|
|
132
|
-
const onChangeHandler = (value: string[]) => {
|
|
132
|
+
const onChangeHandler = (value: string[], eventData?: ContainerChangeEventData) => {
|
|
133
133
|
if (!Array.isArray(value)) {
|
|
134
|
-
emit('change', value);
|
|
134
|
+
emit('change', value, eventData);
|
|
135
135
|
return;
|
|
136
136
|
}
|
|
137
137
|
|
|
@@ -139,7 +139,7 @@ const onChangeHandler = (value: string[]) => {
|
|
|
139
139
|
const dataSource = dataSources.value.find((ds) => ds.id === removeDataSourceFieldPrefix(dsId));
|
|
140
140
|
|
|
141
141
|
if (!dataSource) {
|
|
142
|
-
emit('change', value);
|
|
142
|
+
emit('change', value, eventData);
|
|
143
143
|
return;
|
|
144
144
|
}
|
|
145
145
|
|
|
@@ -160,10 +160,10 @@ const onChangeHandler = (value: string[]) => {
|
|
|
160
160
|
(field?.type &&
|
|
161
161
|
(field.type === 'any' || dataSourceFieldType.includes('any') || dataSourceFieldType.includes(field.type)))
|
|
162
162
|
) {
|
|
163
|
-
emit('change', value);
|
|
163
|
+
emit('change', value, eventData);
|
|
164
164
|
} else {
|
|
165
165
|
tMagicMessage.error(`请选择类型为${dataSourceFieldType.join('或')}的字段`);
|
|
166
|
-
emit('change', [dsId]);
|
|
166
|
+
emit('change', [dsId], eventData);
|
|
167
167
|
}
|
|
168
168
|
};
|
|
169
169
|
</script>
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
</template>
|
|
49
49
|
|
|
50
50
|
<script setup lang="ts">
|
|
51
|
-
import { computed, inject, nextTick, ref, watch } from 'vue';
|
|
51
|
+
import { computed, inject, nextTick, ref, useTemplateRef, watch } from 'vue';
|
|
52
52
|
import { Coin } from '@element-plus/icons-vue';
|
|
53
53
|
|
|
54
54
|
import type { DataSchema, DataSourceSchema } from '@tmagic/core';
|
|
@@ -83,7 +83,7 @@ const emit = defineEmits<{
|
|
|
83
83
|
|
|
84
84
|
const { dataSourceService } = inject<Services>('services') || {};
|
|
85
85
|
|
|
86
|
-
const autocomplete =
|
|
86
|
+
const autocomplete = useTemplateRef<InstanceType<typeof TMagicAutocomplete>>('autocomplete');
|
|
87
87
|
const isFocused = ref(false);
|
|
88
88
|
const state = ref('');
|
|
89
89
|
const displayState = ref<{ value: string; type: 'var' | 'text' }[]>([]);
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
</template>
|
|
22
22
|
|
|
23
23
|
<script setup lang="ts">
|
|
24
|
-
import { nextTick, ref } from 'vue';
|
|
24
|
+
import { nextTick, ref, useTemplateRef } from 'vue';
|
|
25
25
|
import { cloneDeep } from 'lodash-es';
|
|
26
26
|
|
|
27
27
|
import type { CodeBlockContent } from '@tmagic/core';
|
|
@@ -51,7 +51,7 @@ const props = withDefaults(
|
|
|
51
51
|
const emit = defineEmits(['change']);
|
|
52
52
|
|
|
53
53
|
const codeConfig = ref<CodeBlockContent>();
|
|
54
|
-
const codeBlockEditor =
|
|
54
|
+
const codeBlockEditor = useTemplateRef<InstanceType<typeof CodeBlockEditor>>('codeBlockEditor');
|
|
55
55
|
|
|
56
56
|
let editIndex = -1;
|
|
57
57
|
|
package/src/fields/KeyValue.vue
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
:size="size"
|
|
10
10
|
@change="keyChangeHandler"
|
|
11
11
|
></TMagicInput>
|
|
12
|
-
<span class="m-
|
|
12
|
+
<span class="m-fields-key-value-delimiter">:</span>
|
|
13
13
|
<TMagicInput
|
|
14
14
|
placeholder="value"
|
|
15
15
|
v-model="records[index][1]"
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
></TMagicInput>
|
|
20
20
|
|
|
21
21
|
<TMagicButton
|
|
22
|
-
class="m-
|
|
22
|
+
class="m-fields-key-value-delete"
|
|
23
23
|
type="danger"
|
|
24
24
|
:size="size"
|
|
25
25
|
:disabled="disabled"
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { nextTick, ref } from 'vue';
|
|
1
|
+
import { nextTick, ref, useTemplateRef } from 'vue';
|
|
2
2
|
import { cloneDeep } from 'lodash-es';
|
|
3
3
|
|
|
4
4
|
import type { CodeBlockContent } from '@tmagic/core';
|
|
@@ -10,7 +10,7 @@ import type { CodeBlockService } from '@editor/services/codeBlock';
|
|
|
10
10
|
export const useCodeBlockEdit = (codeBlockService?: CodeBlockService) => {
|
|
11
11
|
const codeConfig = ref<CodeBlockContent>();
|
|
12
12
|
const codeId = ref<string>();
|
|
13
|
-
const codeBlockEditor =
|
|
13
|
+
const codeBlockEditor = useTemplateRef<InstanceType<typeof CodeBlockEditor>>('codeBlockEditor');
|
|
14
14
|
|
|
15
15
|
// 新增代码块
|
|
16
16
|
const createCodeBlock = async () => {
|
package/src/hooks/use-getso.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { onBeforeUnmount, onMounted, type
|
|
1
|
+
import { onBeforeUnmount, onMounted, ref, type ShallowRef } from 'vue';
|
|
2
2
|
import Gesto, { type OnDrag } from 'gesto';
|
|
3
3
|
|
|
4
|
-
export const useGetSo = (target:
|
|
4
|
+
export const useGetSo = (target: ShallowRef<HTMLElement | null>, emit: (evt: 'change', e: OnDrag<Gesto>) => void) => {
|
|
5
5
|
let getso: Gesto;
|
|
6
|
-
const
|
|
6
|
+
const isDragging = ref(false);
|
|
7
7
|
|
|
8
8
|
onMounted(() => {
|
|
9
9
|
if (!target.value) return;
|
|
@@ -17,19 +17,19 @@ export const useGetSo = (target: Ref<HTMLElement | undefined>, emit: (evt: 'chan
|
|
|
17
17
|
emit('change', e);
|
|
18
18
|
})
|
|
19
19
|
.on('dragStart', () => {
|
|
20
|
-
|
|
20
|
+
isDragging.value = true;
|
|
21
21
|
})
|
|
22
22
|
.on('dragEnd', () => {
|
|
23
|
-
|
|
23
|
+
isDragging.value = false;
|
|
24
24
|
});
|
|
25
25
|
});
|
|
26
26
|
|
|
27
27
|
onBeforeUnmount(() => {
|
|
28
28
|
getso?.unset();
|
|
29
|
-
|
|
29
|
+
isDragging.value = false;
|
|
30
30
|
});
|
|
31
31
|
|
|
32
32
|
return {
|
|
33
|
-
|
|
33
|
+
isDragging,
|
|
34
34
|
};
|
|
35
35
|
};
|
package/src/index.ts
CHANGED
|
@@ -91,7 +91,8 @@ export { default as KeyValue } from './fields/KeyValue.vue';
|
|
|
91
91
|
export { default as CodeBlockList } from './layouts/sidebar/code-block/CodeBlockList.vue';
|
|
92
92
|
export { default as CodeBlockListPanel } from './layouts/sidebar/code-block/CodeBlockListPanel.vue';
|
|
93
93
|
export { default as DataSourceConfigPanel } from './layouts/sidebar/data-source/DataSourceConfigPanel.vue';
|
|
94
|
-
export { default as PropsPanel } from './layouts/PropsPanel.vue';
|
|
94
|
+
export { default as PropsPanel } from './layouts/props-panel/PropsPanel.vue';
|
|
95
|
+
export { default as PropsFormPanel } from './layouts/props-panel/FormPanel.vue';
|
|
95
96
|
export { default as ToolButton } from './components/ToolButton.vue';
|
|
96
97
|
export { default as ContentMenu } from './components/ContentMenu.vue';
|
|
97
98
|
export { default as Icon } from './components/Icon.vue';
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
</template>
|
|
16
16
|
|
|
17
17
|
<script lang="ts" setup>
|
|
18
|
-
import { onBeforeUnmount, onMounted, ref, watch } from 'vue';
|
|
18
|
+
import { onBeforeUnmount, onMounted, ref, useTemplateRef, watch } from 'vue';
|
|
19
19
|
import { FullScreen } from '@element-plus/icons-vue';
|
|
20
20
|
import { throttle } from 'lodash-es';
|
|
21
21
|
import serialize from 'serialize-javascript';
|
|
@@ -93,7 +93,7 @@ let vsDiffEditor: monaco.editor.IStandaloneDiffEditor | null = null;
|
|
|
93
93
|
|
|
94
94
|
const values = ref('');
|
|
95
95
|
const loading = ref(false);
|
|
96
|
-
const codeEditor =
|
|
96
|
+
const codeEditor = useTemplateRef<HTMLDivElement>('codeEditor');
|
|
97
97
|
|
|
98
98
|
const resizeObserver = new globalThis.ResizeObserver(
|
|
99
99
|
throttle((): void => {
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
v-model:left="columnWidth.left"
|
|
21
21
|
v-model:right="columnWidth.right"
|
|
22
22
|
:min-left="65"
|
|
23
|
-
:min-right="
|
|
23
|
+
:min-right="420"
|
|
24
24
|
:min-center="100"
|
|
25
25
|
:width="frameworkRect?.width || 0"
|
|
26
26
|
@change="columnWidthChange"
|
|
@@ -50,9 +50,7 @@
|
|
|
50
50
|
</template>
|
|
51
51
|
|
|
52
52
|
<template v-if="page" #right>
|
|
53
|
-
<
|
|
54
|
-
<slot name="props-panel"></slot>
|
|
55
|
-
</TMagicScrollbar>
|
|
53
|
+
<slot name="props-panel"></slot>
|
|
56
54
|
</template>
|
|
57
55
|
</SplitView>
|
|
58
56
|
|
|
@@ -62,10 +60,9 @@
|
|
|
62
60
|
</template>
|
|
63
61
|
|
|
64
62
|
<script lang="ts" setup>
|
|
65
|
-
import { computed, inject, onBeforeUnmount, onMounted, ref, watch } from 'vue';
|
|
63
|
+
import { computed, inject, onBeforeUnmount, onMounted, ref, useTemplateRef, watch } from 'vue';
|
|
66
64
|
|
|
67
65
|
import type { MPage, MPageFragment } from '@tmagic/core';
|
|
68
|
-
import { TMagicScrollbar } from '@tmagic/design';
|
|
69
66
|
|
|
70
67
|
import SplitView from '@editor/components/SplitView.vue';
|
|
71
68
|
import type { FrameworkSlots, GetColumnWidth, PageBarSortOptions, Services } from '@editor/type';
|
|
@@ -93,8 +90,8 @@ const DEFAULT_RIGHT_COLUMN_WIDTH = 480;
|
|
|
93
90
|
const codeOptions = inject('codeOptions', {});
|
|
94
91
|
const { editorService, uiService } = inject<Services>('services') || {};
|
|
95
92
|
|
|
96
|
-
const content =
|
|
97
|
-
const splitView =
|
|
93
|
+
const content = useTemplateRef<HTMLDivElement>('content');
|
|
94
|
+
const splitView = useTemplateRef<InstanceType<typeof SplitView>>('splitView');
|
|
98
95
|
|
|
99
96
|
const root = computed(() => editorService?.get('root'));
|
|
100
97
|
const page = computed(() => editorService?.get('page'));
|
package/src/layouts/NavMenu.vue
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
</template>
|
|
8
8
|
|
|
9
9
|
<script lang="ts" setup>
|
|
10
|
-
import { computed, inject, markRaw, onBeforeUnmount, onMounted,
|
|
10
|
+
import { computed, inject, markRaw, onBeforeUnmount, onMounted, useTemplateRef } from 'vue';
|
|
11
11
|
import { Back, Delete, FullScreen, Grid, Memo, Right, ScaleToOriginal, ZoomIn, ZoomOut } from '@element-plus/icons-vue';
|
|
12
12
|
|
|
13
13
|
import { NodeType } from '@tmagic/core';
|
|
@@ -190,7 +190,7 @@ const resizeObserver = new ResizeObserver(() => {
|
|
|
190
190
|
});
|
|
191
191
|
}
|
|
192
192
|
});
|
|
193
|
-
const navMenu =
|
|
193
|
+
const navMenu = useTemplateRef<HTMLDivElement>('navMenu');
|
|
194
194
|
onMounted(() => {
|
|
195
195
|
navMenu.value && resizeObserver.observe(navMenu.value);
|
|
196
196
|
});
|
|
@@ -68,7 +68,7 @@
|
|
|
68
68
|
</template>
|
|
69
69
|
|
|
70
70
|
<script lang="ts" setup>
|
|
71
|
-
import { computed, inject, ref, watch } from 'vue';
|
|
71
|
+
import { computed, inject, ref, useTemplateRef, watch } from 'vue';
|
|
72
72
|
import { CaretBottom, Delete, DocumentCopy } from '@element-plus/icons-vue';
|
|
73
73
|
|
|
74
74
|
import { type Id, type MPage, type MPageFragment, NodeType } from '@tmagic/core';
|
|
@@ -144,8 +144,8 @@ const remove = (node: MPage | MPageFragment) => {
|
|
|
144
144
|
editorService?.remove(node);
|
|
145
145
|
};
|
|
146
146
|
|
|
147
|
-
const pageBarScrollContainer =
|
|
148
|
-
const pageBarItems =
|
|
147
|
+
const pageBarScrollContainer = useTemplateRef<InstanceType<typeof PageBarScrollContainer>>('pageBarScrollContainer');
|
|
148
|
+
const pageBarItems = useTemplateRef<HTMLDivElement[]>('pageBarItems');
|
|
149
149
|
watch(page, (page) => {
|
|
150
150
|
if (
|
|
151
151
|
!page ||
|