@tmagic/editor 1.8.0-beta.12 → 1.8.0-beta.14
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/es/Editor.vue_vue_type_script_setup_true_lang.js +15 -3
- package/dist/es/components/CodeBlockEditor.vue_vue_type_script_setup_true_lang.js +1 -1
- package/dist/es/components/CompareForm.vue_vue_type_script_setup_true_lang.js +13 -121
- package/dist/es/components/ContentMenu.vue_vue_type_script_setup_true_lang.js +11 -4
- package/dist/es/components/FloatingBox.vue_vue_type_script_setup_true_lang.js +7 -2
- package/dist/es/components/ViewForm.js +5 -0
- package/dist/es/components/ViewForm.vue_vue_type_script_setup_true_lang.js +58 -0
- package/dist/es/fields/Code.vue_vue_type_script_setup_true_lang.js +4 -1
- package/dist/es/fields/CodeLink.vue_vue_type_script_setup_true_lang.js +4 -1
- package/dist/es/fields/CodeSelect.vue_vue_type_script_setup_true_lang.js +80 -55
- package/dist/es/fields/CodeSelectCol.vue_vue_type_script_setup_true_lang.js +5 -1
- package/dist/es/fields/CondOpSelect.vue_vue_type_script_setup_true_lang.js +4 -1
- package/dist/es/fields/DataSourceFieldSelect/Index.vue_vue_type_script_setup_true_lang.js +10 -7
- package/dist/es/fields/DataSourceFields.vue_vue_type_script_setup_true_lang.js +4 -1
- package/dist/es/fields/DataSourceInput.vue_vue_type_script_setup_true_lang.js +4 -1
- package/dist/es/fields/DataSourceMethodSelect.vue_vue_type_script_setup_true_name_true_lang.js +4 -1
- package/dist/es/fields/DataSourceMethods.vue_vue_type_script_setup_true_lang.js +4 -1
- package/dist/es/fields/DataSourceMocks.vue_vue_type_script_setup_true_lang.js +4 -1
- package/dist/es/fields/DataSourceSelect.vue_vue_type_script_setup_true_lang.js +4 -1
- package/dist/es/fields/DisplayConds.vue_vue_type_script_setup_true_lang.js +8 -2
- package/dist/es/fields/EventSelect.vue_vue_type_script_setup_true_lang.js +99 -64
- package/dist/es/fields/KeyValue.vue_vue_type_script_setup_true_lang.js +4 -1
- package/dist/es/fields/PageFragmentSelect.vue_vue_type_script_setup_true_lang.js +4 -1
- package/dist/es/fields/StyleSetter/Index.vue_vue_type_script_setup_true_lang.js +5 -4
- package/dist/es/fields/StyleSetter/components/BackgroundPosition.vue_vue_type_script_setup_true_lang.js +4 -1
- package/dist/es/fields/StyleSetter/components/Border.vue_vue_type_script_setup_true_lang.js +1 -1
- package/dist/es/fields/StyleSetter/icons/align-items/Center.js +31 -0
- package/dist/es/fields/StyleSetter/icons/align-items/FlexEnd.js +31 -0
- package/dist/es/fields/StyleSetter/icons/align-items/FlexStart.js +31 -0
- package/dist/es/fields/StyleSetter/icons/align-items/SpaceAround.js +50 -0
- package/dist/es/fields/StyleSetter/icons/align-items/SpaceBetween.js +50 -0
- package/dist/es/fields/StyleSetter/icons/background-repeat/NoRepeat.js +6 -6
- package/dist/es/fields/StyleSetter/icons/background-repeat/Repeat.js +5 -2
- package/dist/es/fields/StyleSetter/icons/background-repeat/RepeatX.js +28 -5
- package/dist/es/fields/StyleSetter/icons/background-repeat/RepeatY.js +31 -5
- package/dist/es/fields/StyleSetter/icons/flex-direction/Column.js +10 -2
- package/dist/es/fields/StyleSetter/icons/flex-direction/ColumnReverse.js +10 -2
- package/dist/es/fields/StyleSetter/icons/flex-direction/Row.js +10 -2
- package/dist/es/fields/StyleSetter/icons/flex-direction/RowReverse.js +10 -2
- package/dist/es/fields/StyleSetter/icons/justify-content/Center.js +16 -2
- package/dist/es/fields/StyleSetter/icons/justify-content/FlexEnd.js +18 -2
- package/dist/es/fields/StyleSetter/icons/justify-content/FlexStart.js +18 -2
- package/dist/es/fields/StyleSetter/icons/justify-content/SpaceAround.js +36 -2
- package/dist/es/fields/StyleSetter/icons/justify-content/SpaceBetween.js +32 -2
- package/dist/es/fields/StyleSetter/pro/Background.vue_vue_type_script_setup_true_lang.js +7 -6
- package/dist/es/fields/StyleSetter/pro/Font.vue_vue_type_script_setup_true_lang.js +6 -3
- package/dist/es/fields/StyleSetter/pro/Layout.vue_vue_type_script_setup_true_lang.js +47 -25
- package/dist/es/fields/UISelect.vue_vue_type_script_setup_true_lang.js +4 -1
- package/dist/es/hooks/use-compare-form.js +119 -0
- package/dist/es/icons/DatasourceIcon.js +17 -0
- package/dist/es/index.js +6 -4
- package/dist/es/layouts/Framework.vue_vue_type_script_setup_true_lang.js +14 -10
- package/dist/es/layouts/props-panel/PropsPanel.vue_vue_type_script_setup_true_lang.js +10 -1
- package/dist/es/layouts/sidebar/Sidebar.vue_vue_type_script_setup_true_lang.js +3 -3
- package/dist/es/plugin.js +2 -1
- package/dist/es/services/codeBlock.js +1 -1
- package/dist/es/services/editor.js +54 -13
- package/dist/es/services/history.js +1 -1
- package/dist/es/services/props.js +1 -1
- package/dist/es/services/storage.js +1 -1
- package/dist/es/services/ui.js +5 -3
- package/dist/es/style.css +303 -40
- package/dist/es/utils/config.js +4 -1
- package/dist/es/utils/const.js +2 -2
- package/dist/es/utils/props.js +69 -30
- package/dist/style.css +303 -40
- package/dist/themes/magic-admin.css +3000 -0
- package/dist/tmagic-editor.umd.cjs +1748 -1079
- package/package.json +7 -7
- package/src/Editor.vue +22 -1
- package/src/components/CompareForm.vue +15 -202
- package/src/components/ContentMenu.vue +10 -2
- package/src/components/FloatingBox.vue +8 -2
- package/src/components/ViewForm.vue +55 -0
- package/src/editorProps.ts +4 -0
- package/src/fields/CodeSelect.vue +54 -43
- package/src/fields/CodeSelectCol.vue +1 -0
- package/src/fields/DataSourceFieldSelect/Index.vue +14 -5
- package/src/fields/DisplayConds.vue +4 -1
- package/src/fields/EventSelect.vue +56 -32
- package/src/fields/StyleSetter/Index.vue +1 -4
- package/src/fields/StyleSetter/components/Border.vue +1 -1
- package/src/fields/StyleSetter/icons/align-items/Center.vue +19 -0
- package/src/fields/StyleSetter/icons/align-items/FlexEnd.vue +19 -0
- package/src/fields/StyleSetter/icons/align-items/FlexStart.vue +19 -0
- package/src/fields/StyleSetter/icons/align-items/SpaceAround.vue +34 -0
- package/src/fields/StyleSetter/icons/align-items/SpaceBetween.vue +34 -0
- package/src/fields/StyleSetter/icons/align-items/index.ts +5 -0
- package/src/fields/StyleSetter/icons/background-repeat/NoRepeat.vue +20 -4
- package/src/fields/StyleSetter/icons/background-repeat/Repeat.vue +10 -28
- package/src/fields/StyleSetter/icons/background-repeat/RepeatX.vue +4 -5
- package/src/fields/StyleSetter/icons/background-repeat/RepeatY.vue +4 -5
- package/src/fields/StyleSetter/icons/flex-direction/Column.vue +4 -3
- package/src/fields/StyleSetter/icons/flex-direction/ColumnReverse.vue +4 -3
- package/src/fields/StyleSetter/icons/flex-direction/Row.vue +4 -3
- package/src/fields/StyleSetter/icons/flex-direction/RowReverse.vue +4 -3
- package/src/fields/StyleSetter/icons/justify-content/Center.vue +5 -2
- package/src/fields/StyleSetter/icons/justify-content/FlexEnd.vue +15 -2
- package/src/fields/StyleSetter/icons/justify-content/FlexStart.vue +15 -2
- package/src/fields/StyleSetter/icons/justify-content/SpaceAround.vue +28 -3
- package/src/fields/StyleSetter/icons/justify-content/SpaceBetween.vue +28 -2
- package/src/fields/StyleSetter/pro/Background.vue +7 -2
- package/src/fields/StyleSetter/pro/Font.vue +3 -3
- package/src/fields/StyleSetter/pro/Layout.vue +98 -28
- package/src/hooks/index.ts +1 -0
- package/src/hooks/use-compare-form.ts +187 -0
- package/src/icons/DatasourceIcon.vue +7 -0
- package/src/index.ts +4 -0
- package/src/layouts/Framework.vue +7 -1
- package/src/layouts/props-panel/PropsPanel.vue +19 -1
- package/src/layouts/sidebar/Sidebar.vue +3 -3
- package/src/plugin.ts +3 -2
- package/src/services/editor.ts +54 -11
- package/src/services/ui.ts +20 -5
- package/src/theme/code-block.scss +37 -0
- package/src/theme/common/var.scss +1 -1
- package/src/theme/component-list-panel.scss +2 -2
- package/src/theme/data-source-field.scss +4 -0
- package/src/theme/display-conds.scss +11 -0
- package/src/theme/event.scss +58 -4
- package/src/theme/framework.scss +4 -1
- package/src/theme/history-list-panel.scss +9 -9
- package/src/theme/nav-menu.scss +5 -1
- package/src/theme/props-panel.scss +2 -1
- package/src/theme/style-setter/border.scss +14 -5
- package/src/theme/theme.scss +1 -0
- package/src/theme/themes/magic-admin/index.scss +214 -0
- package/src/theme/ui-select.scss +1 -1
- package/src/type.ts +79 -6
- package/src/utils/config.ts +9 -1
- package/src/utils/const.ts +3 -2
- package/src/utils/props.ts +51 -9
- package/types/index.d.ts +314 -203
|
@@ -1,5 +1,31 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0
|
|
3
|
-
<path
|
|
2
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16" fill="currentColor">
|
|
3
|
+
<path
|
|
4
|
+
d="M6 4C6.55228 4 7 4.44772 7 5V11C7 11.5523 6.55228 12 6 12H4C3.44772 12 3 11.5523 3 11V5C3 4.44772 3.44772 4 4 4H6ZM4.5 5C4.22386 5 4 5.22386 4 5.5V10.5C4 10.7761 4.22386 11 4.5 11H5.5C5.77614 11 6 10.7761 6 10.5V5.5C6 5.22386 5.77614 5 5.5 5H4.5Z"
|
|
5
|
+
/>
|
|
6
|
+
<path
|
|
7
|
+
d="M12 4C12.5523 4 13 4.44772 13 5V11C13 11.5523 12.5523 12 12 12H10C9.44772 12 9 11.5523 9 11V5C9 4.44772 9.44772 4 10 4H12ZM10.5 5C10.2239 5 10 5.22386 10 5.5V10.5C10 10.7761 10.2239 11 10.5 11H11.5C11.7761 11 12 10.7761 12 10.5V5.5C12 5.22386 11.7761 5 11.5 5H10.5Z"
|
|
8
|
+
/>
|
|
9
|
+
<rect
|
|
10
|
+
x="14.25"
|
|
11
|
+
y="2.25"
|
|
12
|
+
width="0.5"
|
|
13
|
+
height="11.5"
|
|
14
|
+
rx="0.25"
|
|
15
|
+
stroke="black"
|
|
16
|
+
stroke-opacity="0.3"
|
|
17
|
+
stroke-width="0.5"
|
|
18
|
+
/>
|
|
19
|
+
<rect
|
|
20
|
+
x="1.25"
|
|
21
|
+
y="2.25"
|
|
22
|
+
width="0.5"
|
|
23
|
+
height="11.5"
|
|
24
|
+
rx="0.25"
|
|
25
|
+
stroke="black"
|
|
26
|
+
stroke-opacity="0.3"
|
|
27
|
+
style="stroke: black; stroke-opacity: 0.3"
|
|
28
|
+
stroke-width="0.5"
|
|
29
|
+
/>
|
|
4
30
|
</svg>
|
|
5
31
|
</template>
|
|
@@ -29,6 +29,7 @@ defineProps<{
|
|
|
29
29
|
isCompare?: boolean;
|
|
30
30
|
disabled?: boolean;
|
|
31
31
|
size?: 'large' | 'default' | 'small';
|
|
32
|
+
theme?: string;
|
|
32
33
|
prop?: string;
|
|
33
34
|
}>();
|
|
34
35
|
|
|
@@ -112,10 +113,14 @@ const formConfig = defineFormConfig([
|
|
|
112
113
|
childType: 'button',
|
|
113
114
|
labelWidth: '68px',
|
|
114
115
|
options: [
|
|
115
|
-
{ value: 'repeat', icon: markRaw(
|
|
116
|
+
{ value: 'no-repeat', icon: markRaw(BackgroundNoRepeat), tooltip: '不重复 no-repeat' },
|
|
116
117
|
{ value: 'repeat-x', icon: markRaw(BackgroundRepeatX), tooltip: '水平方向重复 repeat-x' },
|
|
117
118
|
{ value: 'repeat-y', icon: markRaw(BackgroundRepeatY), tooltip: '垂直方向重复 repeat-y' },
|
|
118
|
-
{
|
|
119
|
+
{
|
|
120
|
+
value: 'repeat',
|
|
121
|
+
icon: markRaw(BackgroundRepeat),
|
|
122
|
+
tooltip: '垂直和水平方向重复 repeat',
|
|
123
|
+
},
|
|
119
124
|
],
|
|
120
125
|
},
|
|
121
126
|
{
|
|
@@ -95,9 +95,9 @@ const formConfig = defineFormConfig([
|
|
|
95
95
|
childType: 'button',
|
|
96
96
|
labelWidth: '68px',
|
|
97
97
|
options: [
|
|
98
|
-
{ value: 'left', icon: markRaw(AlignLeft), tooltip: '左对齐 row' },
|
|
99
|
-
{ value: 'center', icon: markRaw(AlignCenter), tooltip: '居中对齐 center' },
|
|
100
|
-
{ value: 'right', icon: markRaw(AlignRight), tooltip: '右对齐 right' },
|
|
98
|
+
{ value: 'left', icon: markRaw(AlignLeft), tooltip: '左对齐 row', text: '左对齐' },
|
|
99
|
+
{ value: 'center', icon: markRaw(AlignCenter), tooltip: '居中对齐 center', text: '居中对齐' },
|
|
100
|
+
{ value: 'right', icon: markRaw(AlignRight), tooltip: '右对齐 right', text: '右对齐' },
|
|
101
101
|
],
|
|
102
102
|
},
|
|
103
103
|
]);
|
|
@@ -26,11 +26,19 @@
|
|
|
26
26
|
<script lang="ts" setup>
|
|
27
27
|
import { markRaw } from 'vue';
|
|
28
28
|
|
|
29
|
+
import { useTheme } from '@tmagic/design';
|
|
29
30
|
import type { ContainerChangeEventData } from '@tmagic/form';
|
|
30
31
|
import { defineFormConfig, MContainer } from '@tmagic/form';
|
|
31
32
|
import type { StyleSchema } from '@tmagic/schema';
|
|
32
33
|
|
|
33
34
|
import Box from '../components/Box.vue';
|
|
35
|
+
import {
|
|
36
|
+
AlignItemsCenter,
|
|
37
|
+
AlignItemsFlexEnd,
|
|
38
|
+
AlignItemsFlexStart,
|
|
39
|
+
AlignItemsSpaceAround,
|
|
40
|
+
AlignItemsSpaceBetween,
|
|
41
|
+
} from '../icons/align-items';
|
|
34
42
|
import { DisplayBlock, DisplayFlex, DisplayInline, DisplayInlineBlock, DisplayNone } from '../icons/display';
|
|
35
43
|
import {
|
|
36
44
|
FlexDirectionColumn,
|
|
@@ -46,12 +54,13 @@ import {
|
|
|
46
54
|
JustifyContentSpaceBetween,
|
|
47
55
|
} from '../icons/justify-content';
|
|
48
56
|
|
|
49
|
-
defineProps<{
|
|
57
|
+
const props = defineProps<{
|
|
50
58
|
values: Partial<StyleSchema>;
|
|
51
59
|
lastValues?: Partial<StyleSchema>;
|
|
52
60
|
isCompare?: boolean;
|
|
53
61
|
disabled?: boolean;
|
|
54
62
|
size?: 'large' | 'default' | 'small';
|
|
63
|
+
theme?: string;
|
|
55
64
|
prop?: string;
|
|
56
65
|
}>();
|
|
57
66
|
|
|
@@ -60,19 +69,42 @@ const emit = defineEmits<{
|
|
|
60
69
|
addDiffCount: [];
|
|
61
70
|
}>();
|
|
62
71
|
|
|
72
|
+
const displayTheme = useTheme(props);
|
|
73
|
+
|
|
63
74
|
const formConfig = defineFormConfig([
|
|
64
75
|
{
|
|
65
76
|
name: 'display',
|
|
66
77
|
text: '模式',
|
|
67
78
|
type: 'radioGroup',
|
|
68
79
|
childType: 'button',
|
|
69
|
-
labelWidth: '
|
|
80
|
+
labelWidth: '90px',
|
|
81
|
+
iconSize: '24px',
|
|
70
82
|
options: [
|
|
71
|
-
{
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
83
|
+
{
|
|
84
|
+
value: 'inline',
|
|
85
|
+
icon: markRaw(DisplayInline),
|
|
86
|
+
tooltip: '内联布局 inline',
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
value: 'flex',
|
|
90
|
+
icon: markRaw(DisplayFlex),
|
|
91
|
+
tooltip: '弹性布局 flex',
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
value: 'block',
|
|
95
|
+
icon: markRaw(DisplayBlock),
|
|
96
|
+
tooltip: '块级布局 block',
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
value: 'inline-block',
|
|
100
|
+
icon: markRaw(DisplayInlineBlock),
|
|
101
|
+
tooltip: '内联块布局 inline-block',
|
|
102
|
+
},
|
|
103
|
+
{
|
|
104
|
+
value: 'none',
|
|
105
|
+
icon: markRaw(DisplayNone),
|
|
106
|
+
tooltip: '隐藏 none',
|
|
107
|
+
},
|
|
76
108
|
],
|
|
77
109
|
},
|
|
78
110
|
{
|
|
@@ -80,11 +112,20 @@ const formConfig = defineFormConfig([
|
|
|
80
112
|
text: '主轴方向',
|
|
81
113
|
type: 'radioGroup',
|
|
82
114
|
childType: 'button',
|
|
83
|
-
labelWidth: '
|
|
115
|
+
labelWidth: '90px',
|
|
116
|
+
iconSize: '24px',
|
|
84
117
|
options: [
|
|
85
118
|
{ value: 'row', icon: markRaw(FlexDirectionRow), tooltip: '水平方向 起点在左侧 row' },
|
|
86
|
-
{
|
|
87
|
-
|
|
119
|
+
{
|
|
120
|
+
value: 'row-reverse',
|
|
121
|
+
icon: markRaw(FlexDirectionRowReverse),
|
|
122
|
+
tooltip: '水平方向 起点在右侧 row-reverse',
|
|
123
|
+
},
|
|
124
|
+
{
|
|
125
|
+
value: 'column',
|
|
126
|
+
icon: markRaw(FlexDirectionColumn),
|
|
127
|
+
tooltip: '垂直方向 起点在上沿 column',
|
|
128
|
+
},
|
|
88
129
|
{
|
|
89
130
|
value: 'column-reverse',
|
|
90
131
|
icon: markRaw(FlexDirectionColumnReverse),
|
|
@@ -98,13 +139,22 @@ const formConfig = defineFormConfig([
|
|
|
98
139
|
text: '主轴对齐',
|
|
99
140
|
type: 'radioGroup',
|
|
100
141
|
childType: 'button',
|
|
101
|
-
labelWidth: '
|
|
142
|
+
labelWidth: '90px',
|
|
143
|
+
iconSize: '24px',
|
|
102
144
|
options: [
|
|
103
145
|
{ value: 'flex-start', icon: markRaw(JustifyContentFlexStart), tooltip: '左对齐 flex-start' },
|
|
104
146
|
{ value: 'flex-end', icon: markRaw(JustifyContentFlexEnd), tooltip: '右对齐 flex-end' },
|
|
105
147
|
{ value: 'center', icon: markRaw(JustifyContentCenter), tooltip: '居中 center' },
|
|
106
|
-
{
|
|
107
|
-
|
|
148
|
+
{
|
|
149
|
+
value: 'space-between',
|
|
150
|
+
icon: markRaw(JustifyContentSpaceBetween),
|
|
151
|
+
tooltip: '两端对齐 space-between',
|
|
152
|
+
},
|
|
153
|
+
{
|
|
154
|
+
value: 'space-around',
|
|
155
|
+
icon: markRaw(JustifyContentSpaceAround),
|
|
156
|
+
tooltip: '横向平分 space-around',
|
|
157
|
+
},
|
|
108
158
|
],
|
|
109
159
|
display: (_mForm, { model }: { model: Record<any, any> }) => model.display === 'flex',
|
|
110
160
|
},
|
|
@@ -113,13 +163,22 @@ const formConfig = defineFormConfig([
|
|
|
113
163
|
text: '辅轴对齐',
|
|
114
164
|
type: 'radioGroup',
|
|
115
165
|
childType: 'button',
|
|
116
|
-
labelWidth: '
|
|
166
|
+
labelWidth: '90px',
|
|
167
|
+
iconSize: '24px',
|
|
117
168
|
options: [
|
|
118
|
-
{ value: 'flex-start', icon: markRaw(
|
|
119
|
-
{ value: 'flex-end', icon: markRaw(
|
|
120
|
-
{ value: 'center', icon: markRaw(
|
|
121
|
-
{
|
|
122
|
-
|
|
169
|
+
{ value: 'flex-start', icon: markRaw(AlignItemsFlexStart), tooltip: '左对齐 flex-start' },
|
|
170
|
+
{ value: 'flex-end', icon: markRaw(AlignItemsFlexEnd), tooltip: '右对齐 flex-end' },
|
|
171
|
+
{ value: 'center', icon: markRaw(AlignItemsCenter), tooltip: '居中 center' },
|
|
172
|
+
{
|
|
173
|
+
value: 'space-between',
|
|
174
|
+
icon: markRaw(AlignItemsSpaceBetween),
|
|
175
|
+
tooltip: '两端对齐 space-between',
|
|
176
|
+
},
|
|
177
|
+
{
|
|
178
|
+
value: 'space-around',
|
|
179
|
+
icon: markRaw(AlignItemsSpaceAround),
|
|
180
|
+
tooltip: '横向平分 space-around',
|
|
181
|
+
},
|
|
123
182
|
],
|
|
124
183
|
display: (_mForm, { model }: { model: Record<any, any> }) => model.display === 'flex',
|
|
125
184
|
},
|
|
@@ -127,8 +186,9 @@ const formConfig = defineFormConfig([
|
|
|
127
186
|
name: 'flexWrap',
|
|
128
187
|
text: '换行',
|
|
129
188
|
type: 'radioGroup',
|
|
130
|
-
childType: 'button',
|
|
131
|
-
labelWidth: '
|
|
189
|
+
childType: displayTheme.value !== 'magic-admin' ? 'button' : 'default',
|
|
190
|
+
labelWidth: '90px',
|
|
191
|
+
iconSize: '24px',
|
|
132
192
|
options: [
|
|
133
193
|
{ value: 'nowrap', text: '不换行', tooltip: '不换行 nowrap' },
|
|
134
194
|
{ value: 'wrap', text: '正换行', tooltip: '第一行在上方 wrap' },
|
|
@@ -141,17 +201,22 @@ const formConfig = defineFormConfig([
|
|
|
141
201
|
items: [
|
|
142
202
|
{
|
|
143
203
|
name: 'width',
|
|
144
|
-
text: '
|
|
145
|
-
labelWidth: '
|
|
204
|
+
text: '宽度(px)',
|
|
205
|
+
labelWidth: '90px',
|
|
146
206
|
type: 'data-source-field-select',
|
|
147
207
|
fieldConfig: {
|
|
148
208
|
type: 'text',
|
|
149
209
|
},
|
|
150
210
|
},
|
|
211
|
+
],
|
|
212
|
+
},
|
|
213
|
+
{
|
|
214
|
+
type: 'row',
|
|
215
|
+
items: [
|
|
151
216
|
{
|
|
152
217
|
name: 'height',
|
|
153
|
-
text: '
|
|
154
|
-
labelWidth: '
|
|
218
|
+
text: '高度(px)',
|
|
219
|
+
labelWidth: '90px',
|
|
155
220
|
type: 'data-source-field-select',
|
|
156
221
|
fieldConfig: {
|
|
157
222
|
type: 'text',
|
|
@@ -166,7 +231,7 @@ const formConfig = defineFormConfig([
|
|
|
166
231
|
type: 'data-source-field-select',
|
|
167
232
|
text: 'overflow',
|
|
168
233
|
name: 'overflow',
|
|
169
|
-
labelWidth: '
|
|
234
|
+
labelWidth: '90px',
|
|
170
235
|
checkStrictly: false,
|
|
171
236
|
dataSourceFieldType: ['string'],
|
|
172
237
|
fieldConfig: {
|
|
@@ -184,11 +249,16 @@ const formConfig = defineFormConfig([
|
|
|
184
249
|
],
|
|
185
250
|
},
|
|
186
251
|
},
|
|
252
|
+
],
|
|
253
|
+
},
|
|
254
|
+
{
|
|
255
|
+
type: 'row',
|
|
256
|
+
items: [
|
|
187
257
|
{
|
|
188
258
|
type: 'data-source-field-select',
|
|
189
|
-
text: '
|
|
259
|
+
text: '透明度(%)',
|
|
190
260
|
name: 'opacity',
|
|
191
|
-
labelWidth: '
|
|
261
|
+
labelWidth: '90px',
|
|
192
262
|
dataSourceFieldType: ['string', 'number'],
|
|
193
263
|
fieldConfig: {
|
|
194
264
|
type: 'text',
|
package/src/hooks/index.ts
CHANGED
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Tencent is pleased to support the open source community by making TMagicEditor available.
|
|
3
|
+
*
|
|
4
|
+
* Copyright (C) 2025 Tencent. All rights reserved.
|
|
5
|
+
*
|
|
6
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
|
+
* you may not use this file except in compliance with the License.
|
|
8
|
+
* You may obtain a copy of the License at
|
|
9
|
+
*
|
|
10
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
*
|
|
12
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
13
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
14
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
|
+
* See the License for the specific language governing permissions and
|
|
16
|
+
* limitations under the License.
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
import { computed, type ComputedRef, inject, provide, type Ref, ref, useTemplateRef, watch, watchEffect } from 'vue';
|
|
20
|
+
|
|
21
|
+
import type { CodeBlockContent, MNode } from '@tmagic/core';
|
|
22
|
+
import { type FormConfig, type FormState, type FormValue, MForm } from '@tmagic/form';
|
|
23
|
+
|
|
24
|
+
import type { CompareFormBaseProps } from '@editor/type';
|
|
25
|
+
import { getCodeBlockFormConfig } from '@editor/utils/code-block';
|
|
26
|
+
import { removeStyleDisplayConfig } from '@editor/utils/props';
|
|
27
|
+
|
|
28
|
+
export interface UseCompareFormReturn {
|
|
29
|
+
config: Ref<FormConfig>;
|
|
30
|
+
currentValues: ComputedRef<FormValue>;
|
|
31
|
+
wrapperStyle: ComputedRef<Record<string, string> | undefined>;
|
|
32
|
+
mergedExtendState: (state: FormState) => Record<string, any> | Promise<Record<string, any>>;
|
|
33
|
+
loadConfig: () => Promise<void>;
|
|
34
|
+
formRef: Readonly<Ref<InstanceType<typeof MForm> | null>>;
|
|
35
|
+
normalizeCodeBlockValue: (v: Partial<CodeBlockContent> | Record<string, any> | undefined) => Record<string, any>;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* CompareForm / ViewForm 共用逻辑:
|
|
40
|
+
* - 按 `category`(node / data-source / code-block) 加载 FormConfig(支持自定义 `loadConfig`);
|
|
41
|
+
* - 代码块 `content` 归一化为字符串;
|
|
42
|
+
* - 外层容器固定高度 + 内部滚动的 `wrapperStyle`;
|
|
43
|
+
* - 将 services / stage 注入 MForm.formState,保证 filterFunction 上下文一致。
|
|
44
|
+
*
|
|
45
|
+
* 两个组件的差异仅在于是否做新旧值对比,这部分逻辑保留在各自组件中。
|
|
46
|
+
*/
|
|
47
|
+
export const useCompareForm = (props: CompareFormBaseProps): UseCompareFormReturn => {
|
|
48
|
+
provide('services', props.services);
|
|
49
|
+
|
|
50
|
+
const config = ref<FormConfig>([]);
|
|
51
|
+
|
|
52
|
+
/** vs-code 编辑器的 monaco 配置项,沿用 Editor 顶层 provide('codeOptions', ...) 的注入。 */
|
|
53
|
+
const codeOptions = inject<Record<string, any>>('codeOptions', {});
|
|
54
|
+
|
|
55
|
+
/** 将代码块的 content 字段统一成字符串,便于在表单 / 对比中展示 */
|
|
56
|
+
const normalizeCodeBlockValue = (
|
|
57
|
+
v: Partial<CodeBlockContent> | Record<string, any> | undefined,
|
|
58
|
+
): Record<string, any> => {
|
|
59
|
+
if (!v) return {};
|
|
60
|
+
const next: Record<string, any> = { ...v };
|
|
61
|
+
if (next.content && typeof next.content !== 'string') {
|
|
62
|
+
try {
|
|
63
|
+
next.content = next.content.toString();
|
|
64
|
+
} catch {
|
|
65
|
+
next.content = '';
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
return next;
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
const currentValues = computed<FormValue>(() => {
|
|
72
|
+
if (props.category === 'code-block') {
|
|
73
|
+
return normalizeCodeBlockValue(props.value as Partial<CodeBlockContent>);
|
|
74
|
+
}
|
|
75
|
+
return (props.value || {}) as FormValue;
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* 外层包裹层的样式:当传入 `height` 时启用固定高度 + 内部滚动,
|
|
80
|
+
* 这样滚动条会出现在组件内部,避免父容器(如 Dialog)自身也产生滚动。
|
|
81
|
+
*/
|
|
82
|
+
const wrapperStyle = computed(() => {
|
|
83
|
+
if (!props.height) return undefined;
|
|
84
|
+
const style: Record<string, string> = {
|
|
85
|
+
height: props.height,
|
|
86
|
+
overflow: 'auto',
|
|
87
|
+
};
|
|
88
|
+
return style;
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
const mergedExtendState = (state: FormState) => {
|
|
92
|
+
const extendState = props.extendState ?? ((s: FormState) => s);
|
|
93
|
+
return extendState(props.baseFormState || state);
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* 内置的默认 FormConfig 加载逻辑:按 `category` 从对应 service / 工具取配置。
|
|
98
|
+
* 作为 ctx.defaultLoadConfig 透传给自定义 `loadConfig`,方便复用与二次加工。
|
|
99
|
+
*/
|
|
100
|
+
const defaultLoadConfig = async (): Promise<FormConfig> => {
|
|
101
|
+
if (!props.services) {
|
|
102
|
+
return [];
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
switch (props.category) {
|
|
106
|
+
case 'node': {
|
|
107
|
+
if (!props.type) {
|
|
108
|
+
return [];
|
|
109
|
+
}
|
|
110
|
+
return removeStyleDisplayConfig(
|
|
111
|
+
await props.services.propsService.getPropsConfig(props.type, { node: props.value as unknown as MNode }),
|
|
112
|
+
);
|
|
113
|
+
}
|
|
114
|
+
case 'data-source': {
|
|
115
|
+
const config = props.services.dataSourceService.getFormConfig(props.type || 'base');
|
|
116
|
+
// 数据源表单外层 tab 的「数据定义」项 status 为 'fields',tab-pane name 随之为 'fields'。
|
|
117
|
+
// 未显式设置 active 时,Tabs 默认取 '0',与 'fields' 不匹配会导致打开弹窗时无默认激活项,
|
|
118
|
+
// 这里与 DataSourceConfigPanel 保持一致,默认激活「数据定义」tab。
|
|
119
|
+
return config.map((item) => ('type' in item && item.type === 'tab' ? { ...item, active: 'fields' } : item));
|
|
120
|
+
}
|
|
121
|
+
case 'code-block': {
|
|
122
|
+
return getCodeBlockFormConfig({
|
|
123
|
+
paramColConfig: props.services.codeBlockService.getParamsColConfig(),
|
|
124
|
+
// 通过传入 dataSourceType 间接表达"是数据源代码块"——在对比 / 展示场景下 props.dataSourceType
|
|
125
|
+
// 由调用方按 step 上下文显式传入,未传则视为普通代码块,「执行时机」字段隐藏。
|
|
126
|
+
isDataSource: () => Boolean(props.dataSourceType),
|
|
127
|
+
dataSourceType: () => props.dataSourceType,
|
|
128
|
+
codeOptions,
|
|
129
|
+
// 对比 / 展示模式只读,不需要校验/语法检查
|
|
130
|
+
editable: false,
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
default:
|
|
134
|
+
return [];
|
|
135
|
+
}
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
const loadConfig = async () => {
|
|
139
|
+
if (props.loadConfig) {
|
|
140
|
+
config.value = await props.loadConfig({
|
|
141
|
+
category: props.category as string,
|
|
142
|
+
type: props.type,
|
|
143
|
+
dataSourceType: props.dataSourceType,
|
|
144
|
+
defaultLoadConfig,
|
|
145
|
+
});
|
|
146
|
+
return;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
config.value = await defaultLoadConfig();
|
|
150
|
+
};
|
|
151
|
+
|
|
152
|
+
watch(
|
|
153
|
+
[() => props.category, () => props.type, () => props.dataSourceType, () => props.loadConfig],
|
|
154
|
+
() => {
|
|
155
|
+
loadConfig();
|
|
156
|
+
},
|
|
157
|
+
{ immediate: true },
|
|
158
|
+
);
|
|
159
|
+
|
|
160
|
+
const formRef = useTemplateRef<InstanceType<typeof MForm>>('form');
|
|
161
|
+
|
|
162
|
+
/**
|
|
163
|
+
* 把 services / stage 注入 MForm 的 formState,避免 propsService 注入的表单配置中
|
|
164
|
+
* 形如 `display: ({ services }) => services.uiService.get(...)` 的 filterFunction
|
|
165
|
+
* 在执行时拿不到 `formState.services` 而报错。
|
|
166
|
+
*
|
|
167
|
+
* 与 props-panel/FormPanel.vue 中的注入方式保持一致:
|
|
168
|
+
* - services:整个 useServices() 返回的服务集合;
|
|
169
|
+
* - stage:当前 editorService.get('stage') 的最新值。
|
|
170
|
+
*/
|
|
171
|
+
watchEffect(() => {
|
|
172
|
+
if (formRef.value && props.services) {
|
|
173
|
+
formRef.value.formState.stage = props.services.editorService.get('stage');
|
|
174
|
+
formRef.value.formState.services = props.services;
|
|
175
|
+
}
|
|
176
|
+
});
|
|
177
|
+
|
|
178
|
+
return {
|
|
179
|
+
config,
|
|
180
|
+
currentValues,
|
|
181
|
+
wrapperStyle,
|
|
182
|
+
mergedExtendState,
|
|
183
|
+
loadConfig,
|
|
184
|
+
formRef,
|
|
185
|
+
normalizeCodeBlockValue,
|
|
186
|
+
};
|
|
187
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16" fill="currentColor">
|
|
3
|
+
<path
|
|
4
|
+
d="M6.25 9.723C4.392 9.6095 2.804 9.137 1.875 8.4775V9.7495C1.875 10.6165 3.7665 11.3365 6.25 11.4745V12.348C4.392 12.2345 2.804 11.763 1.875 11.102V12.3745H1V4.0625C1 2.371 3.742 1 7.125 1C10.507 1 13.249 2.371 13.249 4.0625V6.8255H12.374V5.6405C11.3025 6.5295 9.352 7.1245 7.1245 7.1245C4.897 7.1245 2.947 6.5295 1.8745 5.6405V7.1245C1.8745 7.9915 3.7665 8.712 6.2495 8.85L6.25 9.723ZM7.125 14.999C3.742 14.999 1 13.8245 1 12.3745H1.875C1.875 13.3415 4.225 14.124 7.125 14.124V14.999ZM7.125 6.2495C10.024 6.2495 12.3745 5.2695 12.3745 4.0625C12.3745 2.855 10.0245 1.875 7.1245 1.875C4.225 1.875 1.8745 2.855 1.8745 4.0625C1.8745 5.2695 4.2255 6.2495 7.125 6.2495ZM14.7385 11.9895L14.1295 11.6345C14.1635 11.4485 14.1855 11.2585 14.1855 11.062C14.1843 10.8697 14.1655 10.6779 14.1295 10.489L14.7385 10.134C14.988 9.987 15.073 9.667 14.929 9.416L14.409 8.507C14.3752 8.44726 14.3299 8.39483 14.2757 8.35275C14.2215 8.31066 14.1595 8.27977 14.0933 8.26186C14.027 8.24395 13.9579 8.23938 13.8898 8.24842C13.8218 8.25745 13.7563 8.27992 13.697 8.3145L13.081 8.6735C12.7931 8.42269 12.4616 8.22694 12.103 8.096V7.6495C12.103 7.36 11.8705 7.1245 11.5825 7.1245H10.5415C10.4728 7.12476 10.4049 7.13855 10.3415 7.16507C10.2782 7.1916 10.2206 7.23034 10.1723 7.2791C10.1239 7.32785 10.0856 7.38565 10.0595 7.4492C10.0335 7.51276 10.0202 7.58082 10.0205 7.6495V8.096C9.66186 8.22694 9.33035 8.42269 9.0425 8.6735L8.4265 8.3145C8.36725 8.27999 8.30174 8.2576 8.23377 8.2486C8.1658 8.23961 8.09672 8.24419 8.03053 8.2621C7.96435 8.28001 7.90238 8.31088 7.84821 8.35292C7.79405 8.39495 7.74877 8.44733 7.715 8.507L7.195 9.417C7.12576 9.53751 7.10688 9.68047 7.14246 9.81482C7.17804 9.94917 7.2652 10.0641 7.385 10.1345L7.9945 10.489C7.9585 10.6775 7.9395 10.8695 7.9385 11.062C7.9385 11.2585 7.96 11.4485 7.9945 11.635L7.3855 11.99C7.1355 12.1365 7.0505 12.4565 7.1945 12.7075L7.715 13.6165C7.74877 13.6762 7.79405 13.7285 7.84821 13.7706C7.90238 13.8126 7.96435 13.8435 8.03053 13.8614C8.09672 13.8793 8.1658 13.8839 8.23377 13.8749C8.30174 13.8659 8.36725 13.8435 8.4265 13.809L9.0425 13.4505C9.33023 13.7015 9.66178 13.8972 10.0205 14.028V14.474C10.0205 14.764 10.2535 14.999 10.5415 14.999H11.5825C11.7211 14.9983 11.8538 14.9427 11.9514 14.8442C12.049 14.7458 12.1035 14.6126 12.103 14.474V14.028C12.4616 13.8971 12.7931 13.7013 13.081 13.4505L13.697 13.809C13.7563 13.8434 13.8218 13.8657 13.8897 13.8746C13.9577 13.8835 14.0267 13.8789 14.0929 13.861C14.159 13.8431 14.221 13.8123 14.2751 13.7703C14.3293 13.7283 14.3746 13.6761 14.4085 13.6165L14.929 12.7065C14.998 12.586 15.0168 12.4431 14.9811 12.3089C14.9454 12.1746 14.8583 12.0599 14.7385 11.9895ZM14.092 12.5065L13.852 12.915C13.8193 12.9693 13.7667 13.0086 13.7054 13.0246C13.6441 13.0406 13.579 13.0319 13.524 13.0005L12.8575 12.623C12.5109 13.0069 12.0497 13.2688 11.5425 13.37V13.889C11.5425 14.0185 11.4345 14.124 11.3015 14.124H10.822C10.7907 14.1243 10.7597 14.1184 10.7308 14.1067C10.7018 14.0949 10.6754 14.0776 10.6531 14.0557C10.6308 14.0338 10.6131 14.0077 10.6009 13.9789C10.5887 13.9502 10.5823 13.9193 10.582 13.888V13.37C10.0746 13.2689 9.61328 13.007 9.2665 12.623L8.6 13C8.54495 13.0316 8.47971 13.0403 8.4183 13.0243C8.35688 13.0083 8.30418 12.9689 8.2715 12.9145L8.0315 12.506C8.01582 12.4792 8.00564 12.4496 8.00158 12.4189C7.99752 12.3881 7.99965 12.3569 8.00785 12.327C8.01605 12.297 8.03016 12.2691 8.04933 12.2447C8.0685 12.2203 8.09236 12.2 8.1195 12.185L8.789 11.805C8.70604 11.5658 8.66313 11.3146 8.662 11.0615C8.662 10.8005 8.709 10.552 8.7895 10.3175L8.1195 9.9375C8.09247 9.92244 8.06872 9.90213 8.04964 9.87777C8.03056 9.85341 8.01654 9.82549 8.00839 9.79564C8.00024 9.76579 7.99813 9.73461 8.00218 9.70394C8.00624 9.67326 8.01637 9.64371 8.032 9.617L8.272 9.208C8.30467 9.15373 8.35729 9.1144 8.41858 9.09843C8.47988 9.08245 8.54499 9.09109 8.6 9.1225L9.2665 9.5005C9.61315 9.11663 10.0743 8.85468 10.5815 8.7535V8.235C10.5815 8.105 10.689 8 10.822 8H11.302C11.4345 8 11.542 8.105 11.542 8.236V8.754C12.0492 8.85518 12.5104 9.11713 12.857 9.501L13.524 9.123C13.579 9.09159 13.6441 9.08295 13.7054 9.09893C13.7667 9.1149 13.8193 9.15423 13.852 9.2085L14.092 9.6175C14.1077 9.64423 14.1179 9.67383 14.122 9.70455C14.1261 9.73528 14.124 9.76652 14.1159 9.79643C14.1077 9.82634 14.0937 9.85431 14.0745 9.87871C14.0554 9.90311 14.0316 9.92344 14.0045 9.9385L13.335 10.3185C13.4135 10.5525 13.462 10.801 13.462 11.062C13.462 11.3225 13.4145 11.571 13.335 11.8055L14.0045 12.1855C14.0316 12.2006 14.0554 12.2209 14.0745 12.2453C14.0937 12.2697 14.1077 12.2977 14.1159 12.3276C14.124 12.3575 14.1261 12.3887 14.122 12.4194C14.1179 12.4502 14.1077 12.4798 14.092 12.5065ZM11.062 9.7495C10.7139 9.7495 10.3801 9.88778 10.1339 10.1339C9.88778 10.3801 9.7495 10.7139 9.7495 11.062C9.7495 11.4101 9.88778 11.7439 10.1339 11.9901C10.3801 12.2362 10.7139 12.3745 11.062 12.3745C11.4101 12.3745 11.7439 12.2362 11.9901 11.9901C12.2362 11.7439 12.3745 11.4101 12.3745 11.062C12.3745 10.7139 12.2362 10.3801 11.9901 10.1339C11.7439 9.88778 11.4101 9.7495 11.062 9.7495ZM11.062 11.4995C10.946 11.4995 10.8347 11.4534 10.7526 11.3714C10.6706 11.2893 10.6245 11.178 10.6245 11.062C10.6245 10.946 10.6706 10.8347 10.7526 10.7526C10.8347 10.6706 10.946 10.6245 11.062 10.6245C11.178 10.6245 11.2893 10.6706 11.3714 10.7526C11.4534 10.8347 11.4995 10.946 11.4995 11.062C11.4995 11.178 11.4534 11.2893 11.3714 11.3714C11.2893 11.4534 11.178 11.4995 11.062 11.4995Z"
|
|
5
|
+
/>
|
|
6
|
+
</svg>
|
|
7
|
+
</template>
|
package/src/index.ts
CHANGED
|
@@ -32,6 +32,9 @@ export { DepTargetType } from '@tmagic/core';
|
|
|
32
32
|
export * from './type';
|
|
33
33
|
export * from './hooks';
|
|
34
34
|
export * from './utils';
|
|
35
|
+
// `isGlobalFlat` 同时在 `@tmagic/design` 和 `./utils/config` 中存在,
|
|
36
|
+
// 通过显式重导一次消除 `export *` 带来的歧义,并固定使用 editor 自己那份。
|
|
37
|
+
export { isGlobalFlat } from './utils/config';
|
|
35
38
|
export { default as TMagicEditor } from './Editor.vue';
|
|
36
39
|
export { default as TMagicCodeEditor } from './layouts/CodeEditor.vue';
|
|
37
40
|
export { default as editorService } from './services/editor';
|
|
@@ -74,6 +77,7 @@ export { default as SplitView } from './components/SplitView.vue';
|
|
|
74
77
|
export { default as Resizer } from './components/Resizer.vue';
|
|
75
78
|
export { default as CodeBlockEditor } from './components/CodeBlockEditor.vue';
|
|
76
79
|
export { default as CompareForm } from './components/CompareForm.vue';
|
|
80
|
+
export { default as ViewForm } from './components/ViewForm.vue';
|
|
77
81
|
export { default as HistoryListBucket } from './layouts/history-list/Bucket.vue';
|
|
78
82
|
export { default as HistoryListBucketTab } from './layouts/history-list/BucketTab.vue';
|
|
79
83
|
export { default as HistoryDiffDialog } from './layouts/history-list/HistoryDiffDialog.vue';
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<div
|
|
2
|
+
<div
|
|
3
|
+
ref="content"
|
|
4
|
+
:class="['m-editor', theme ? `m-editor--${theme}` : '', theme ? `m-theme--${theme}` : '']"
|
|
5
|
+
style="min-width: 900px"
|
|
6
|
+
>
|
|
3
7
|
<slot name="header"></slot>
|
|
4
8
|
|
|
5
9
|
<slot name="nav"></slot>
|
|
@@ -97,6 +101,8 @@ const props = defineProps<{
|
|
|
97
101
|
pageFilterFunction?: (_page: MPage | MPageFragment, _keyword: string) => boolean;
|
|
98
102
|
/** 是否隐藏左侧面板 */
|
|
99
103
|
hideSidebar?: boolean;
|
|
104
|
+
/** 主题名称,会在根节点追加 `m-editor--<theme>` 修饰类 */
|
|
105
|
+
theme?: string;
|
|
100
106
|
}>();
|
|
101
107
|
|
|
102
108
|
const codeOptions = inject('codeOptions', {});
|
|
@@ -111,14 +111,31 @@ const styleFormConfig = [
|
|
|
111
111
|
},
|
|
112
112
|
];
|
|
113
113
|
|
|
114
|
+
// 用单调递增序号标记每次 init 调用,只让"最新一次"的 await 结果落到 ref 上。
|
|
115
|
+
// 避免节点快速切换时多个 init 并发 + 解析顺序错乱导致 stale config 覆盖最新选中节点,
|
|
116
|
+
// 以及组件已卸载 / FormPanel 正在 remount 的中间态下写 ref 触发 Vue setRef 把 __vnode
|
|
117
|
+
// 设到 null 上的报错(TypeError: Cannot set properties of null (setting '__vnode'))。
|
|
118
|
+
let initSeq = 0;
|
|
119
|
+
let mounted = true;
|
|
120
|
+
|
|
114
121
|
const init = async () => {
|
|
122
|
+
initSeq += 1;
|
|
123
|
+
const seq = initSeq;
|
|
124
|
+
|
|
115
125
|
if (!node.value) {
|
|
126
|
+
if (seq !== initSeq || !mounted) return;
|
|
116
127
|
curFormConfig.value = [];
|
|
117
128
|
return;
|
|
118
129
|
}
|
|
119
130
|
|
|
120
131
|
const type = node.value.type || (node.value.items ? 'container' : 'text');
|
|
121
|
-
|
|
132
|
+
const config = await propsService.getPropsConfig(type, { node: node.value });
|
|
133
|
+
|
|
134
|
+
// 期间被新一次 init 取代 / 组件已卸载,丢弃本次结果
|
|
135
|
+
if (seq !== initSeq || !mounted) return;
|
|
136
|
+
if (!node.value) return;
|
|
137
|
+
|
|
138
|
+
curFormConfig.value = config;
|
|
122
139
|
values.value = node.value;
|
|
123
140
|
};
|
|
124
141
|
|
|
@@ -126,6 +143,7 @@ watchEffect(init);
|
|
|
126
143
|
propsService.on('props-configs-change', init);
|
|
127
144
|
|
|
128
145
|
onBeforeUnmount(() => {
|
|
146
|
+
mounted = false;
|
|
129
147
|
propsService.off('props-configs-change', init);
|
|
130
148
|
});
|
|
131
149
|
|
|
@@ -155,7 +155,7 @@
|
|
|
155
155
|
|
|
156
156
|
<script setup lang="ts">
|
|
157
157
|
import { computed, nextTick, ref, watch } from 'vue';
|
|
158
|
-
import { Close, Coin, EditPen,
|
|
158
|
+
import { Box, Close, Coin, EditPen, Finished } from '@element-plus/icons-vue';
|
|
159
159
|
|
|
160
160
|
import FloatingBox from '@editor/components/FloatingBox.vue';
|
|
161
161
|
import MIcon from '@editor/components/Icon.vue';
|
|
@@ -253,7 +253,7 @@ const getItemConfig = (data: SideItem): SideComponent => {
|
|
|
253
253
|
[SideItemKey.COMPONENT_LIST]: {
|
|
254
254
|
$key: SideItemKey.COMPONENT_LIST,
|
|
255
255
|
type: 'component',
|
|
256
|
-
icon:
|
|
256
|
+
icon: Box,
|
|
257
257
|
text: '组件',
|
|
258
258
|
component: ComponentListPanel,
|
|
259
259
|
slots: {},
|
|
@@ -261,7 +261,7 @@ const getItemConfig = (data: SideItem): SideComponent => {
|
|
|
261
261
|
layer: {
|
|
262
262
|
$key: SideItemKey.LAYER,
|
|
263
263
|
type: 'component',
|
|
264
|
-
icon:
|
|
264
|
+
icon: Finished,
|
|
265
265
|
text: '已选组件',
|
|
266
266
|
props: {
|
|
267
267
|
layerContentMenu: props.layerContentMenu,
|
package/src/plugin.ts
CHANGED
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
* limitations under the License.
|
|
17
17
|
*/
|
|
18
18
|
|
|
19
|
-
import type
|
|
19
|
+
import { type App } from 'vue';
|
|
20
20
|
|
|
21
21
|
import type { DesignPluginOptions } from '@tmagic/design';
|
|
22
22
|
import designPlugin from '@tmagic/design';
|
|
@@ -56,6 +56,8 @@ const defaultInstallOpt: EditorInstallOptions = {
|
|
|
56
56
|
customCreateMonacoEditor: (monaco, codeEditorEl, options) => monaco.editor.create(codeEditorEl, options),
|
|
57
57
|
customCreateMonacoDiffEditor: (monaco, codeEditorEl, options) =>
|
|
58
58
|
monaco.editor.createDiffEditor(codeEditorEl, options),
|
|
59
|
+
|
|
60
|
+
flat: false,
|
|
59
61
|
};
|
|
60
62
|
|
|
61
63
|
export default {
|
|
@@ -69,7 +71,6 @@ export default {
|
|
|
69
71
|
|
|
70
72
|
app.config.globalProperties.$TMAGIC_EDITOR = option;
|
|
71
73
|
setEditorConfig(option);
|
|
72
|
-
|
|
73
74
|
app.component(`${Editor.name || 'MEditor'}`, Editor);
|
|
74
75
|
app.component('magic-code-editor', CodeEditor);
|
|
75
76
|
app.component('m-fields-ui-select', uiSelect);
|