@tmagic/editor 1.8.0-beta.23 → 1.8.0-beta.25
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/fields/CodeSelectCol.vue_vue_type_script_setup_true_lang.js +5 -4
- package/dist/es/fields/CondOpSelect.vue_vue_type_script_setup_true_lang.js +3 -2
- package/dist/es/fields/DataSourceFieldSelect/Index.vue_vue_type_script_setup_true_lang.js +8 -5
- package/dist/es/fields/DataSourceFields.vue_vue_type_script_setup_true_lang.js +10 -6
- package/dist/es/fields/DataSourceMethodSelect.vue_vue_type_script_setup_true_name_true_lang.js +6 -4
- 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 +6 -4
- package/dist/es/fields/DisplayConds.vue_vue_type_script_setup_true_lang.js +12 -7
- package/dist/es/fields/EventSelect.vue_vue_type_script_setup_true_lang.js +2 -2
- package/dist/es/fields/KeyValue.vue_vue_type_script_setup_true_lang.js +4 -2
- package/dist/es/fields/StyleSetter/pro/Font.vue_vue_type_script_setup_true_lang.js +2 -2
- package/dist/es/hooks/use-compare-form.js +1 -2
- package/dist/es/index.js +3 -3
- package/dist/es/plugin.js +9 -1
- package/dist/es/services/editor.js +43 -37
- package/dist/es/services/props.js +1 -1
- package/dist/es/style.css +4 -0
- package/dist/es/utils/event.js +1 -1
- package/dist/es/utils/props.js +1 -29
- package/dist/es/utils/type-match-rules.js +21 -20
- package/dist/style.css +4 -0
- package/dist/themes/magic-admin.css +4 -0
- package/dist/tmagic-editor.umd.cjs +412 -398
- package/package.json +8 -8
- package/src/fields/CodeSelectCol.vue +4 -2
- package/src/fields/CondOpSelect.vue +3 -2
- package/src/fields/DataSourceFieldSelect/Index.vue +9 -4
- package/src/fields/DataSourceFields.vue +6 -0
- package/src/fields/DataSourceMethodSelect.vue +4 -1
- package/src/fields/DataSourceMethods.vue +11 -2
- package/src/fields/DataSourceMocks.vue +10 -1
- package/src/fields/DisplayConds.vue +11 -7
- package/src/fields/EventSelect.vue +3 -3
- package/src/fields/KeyValue.vue +4 -3
- package/src/fields/StyleSetter/pro/Font.vue +2 -2
- package/src/hooks/use-compare-form.ts +1 -4
- package/src/plugin.ts +9 -1
- package/src/services/editor.ts +53 -85
- package/src/type.ts +23 -0
- package/src/utils/event.ts +2 -2
- package/src/utils/props.ts +0 -32
- package/src/utils/type-match-rules.ts +29 -28
- package/types/index.d.ts +39 -61
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "1.8.0-beta.
|
|
2
|
+
"version": "1.8.0-beta.25",
|
|
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": "^7.0.7",
|
|
60
60
|
"sortablejs": "^1.15.7",
|
|
61
|
-
"@tmagic/design": "1.8.0-beta.
|
|
62
|
-
"@tmagic/stage": "1.8.0-beta.
|
|
63
|
-
"@tmagic/utils": "1.8.0-beta.
|
|
64
|
-
"@tmagic/table": "1.8.0-beta.
|
|
65
|
-
"@tmagic/form": "1.8.0-beta.
|
|
61
|
+
"@tmagic/design": "1.8.0-beta.25",
|
|
62
|
+
"@tmagic/stage": "1.8.0-beta.25",
|
|
63
|
+
"@tmagic/utils": "1.8.0-beta.25",
|
|
64
|
+
"@tmagic/table": "1.8.0-beta.25",
|
|
65
|
+
"@tmagic/form": "1.8.0-beta.25"
|
|
66
66
|
},
|
|
67
67
|
"devDependencies": {
|
|
68
68
|
"@types/events": "^3.0.3",
|
|
@@ -75,8 +75,8 @@
|
|
|
75
75
|
"monaco-editor": "^0.55.1 ",
|
|
76
76
|
"type-fest": "^5.2.0",
|
|
77
77
|
"typescript": "^6.0.3",
|
|
78
|
-
"vue": "^3.5.
|
|
79
|
-
"@tmagic/core": "1.8.0-beta.
|
|
78
|
+
"vue": "^3.5.41",
|
|
79
|
+
"@tmagic/core": "1.8.0-beta.25"
|
|
80
80
|
},
|
|
81
81
|
"peerDependenciesMeta": {
|
|
82
82
|
"typescript": {
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
:prop="prop"
|
|
16
16
|
></MFormContainer>
|
|
17
17
|
<MSelect
|
|
18
|
-
v-else
|
|
18
|
+
v-else-if="!silentMode"
|
|
19
19
|
class="select"
|
|
20
20
|
:config="selectConfig"
|
|
21
21
|
:name="name"
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
|
|
28
28
|
<!-- 查看/编辑按钮:对比模式为只读,不展示 -->
|
|
29
29
|
<TMagicButton
|
|
30
|
-
v-if="!isCompareMode && model[name] && hasCodeBlockSidePanel"
|
|
30
|
+
v-if="!isCompareMode && !silentMode && model[name] && hasCodeBlockSidePanel"
|
|
31
31
|
class="m-fields-select-action-button"
|
|
32
32
|
:size="size"
|
|
33
33
|
@click="editCode(model[name])"
|
|
@@ -65,6 +65,7 @@ import {
|
|
|
65
65
|
createValues,
|
|
66
66
|
type FieldProps,
|
|
67
67
|
filterFunction,
|
|
68
|
+
FORM_SILENT_MODE_KEY,
|
|
68
69
|
type FormItemConfig,
|
|
69
70
|
type FormState,
|
|
70
71
|
MContainer as MFormContainer,
|
|
@@ -83,6 +84,7 @@ defineOptions({
|
|
|
83
84
|
});
|
|
84
85
|
|
|
85
86
|
const mForm = inject<FormState | undefined>('mForm');
|
|
87
|
+
const silentMode = inject(FORM_SILENT_MODE_KEY, false);
|
|
86
88
|
const { codeBlockService, uiService } = useServices();
|
|
87
89
|
const eventBus = inject<EventBus>('eventBus');
|
|
88
90
|
const emit = defineEmits<{
|
|
@@ -31,6 +31,7 @@ import { computed } from 'vue';
|
|
|
31
31
|
|
|
32
32
|
import { getDesignConfig, TMagicSelect } from '@tmagic/design';
|
|
33
33
|
import type { CondOpSelectConfig, FieldProps } from '@tmagic/form';
|
|
34
|
+
import { removeDataSourceFieldPrefix } from '@tmagic/utils';
|
|
34
35
|
|
|
35
36
|
import { useServices } from '@editor/hooks/use-services';
|
|
36
37
|
import { getCondOpOptionsByFieldType, getFieldType } from '@editor/utils';
|
|
@@ -50,8 +51,8 @@ const props = defineProps<FieldProps<CondOpSelectConfig>>();
|
|
|
50
51
|
const optionComponent = getDesignConfig('components')?.option;
|
|
51
52
|
|
|
52
53
|
const options = computed(() => {
|
|
53
|
-
const [id, ...fieldNames] = [...(props.config.parentFields || []), ...props.model.field];
|
|
54
|
-
const ds = dataSourceService.getDataSourceById(id);
|
|
54
|
+
const [id, ...fieldNames] = [...(props.config.parentFields || []), ...(props.model.field || [])];
|
|
55
|
+
const ds = id ? dataSourceService.getDataSourceById(removeDataSourceFieldPrefix(id)) : undefined;
|
|
55
56
|
const type = getFieldType(ds, fieldNames);
|
|
56
57
|
return getCondOpOptionsByFieldType(type);
|
|
57
58
|
});
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
}"
|
|
7
7
|
>
|
|
8
8
|
<FieldSelect
|
|
9
|
-
v-if="isSelectValid"
|
|
9
|
+
v-if="isSelectValid && !silentMode"
|
|
10
10
|
:model-value="model[name]"
|
|
11
11
|
:disabled="disabled"
|
|
12
12
|
:size="size"
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
></FieldSelect>
|
|
19
19
|
|
|
20
20
|
<component
|
|
21
|
-
v-else
|
|
21
|
+
v-else-if="!silentMode"
|
|
22
22
|
:is="tagName"
|
|
23
23
|
:config="config.fieldConfig"
|
|
24
24
|
:model="model"
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
></component>
|
|
34
34
|
|
|
35
35
|
<TMagicTooltip
|
|
36
|
-
v-if="config.fieldConfig && !disabledDataSource && !mForm?.isCompare"
|
|
36
|
+
v-if="!silentMode && config.fieldConfig && !disabledDataSource && !mForm?.isCompare"
|
|
37
37
|
:disabled="showDataSourceFieldSelect"
|
|
38
38
|
content="选择数据源"
|
|
39
39
|
>
|
|
@@ -57,6 +57,7 @@ import {
|
|
|
57
57
|
type ContainerChangeEventData,
|
|
58
58
|
type DataSourceFieldSelectConfig,
|
|
59
59
|
type FieldProps,
|
|
60
|
+
FORM_SILENT_MODE_KEY,
|
|
60
61
|
type FormState,
|
|
61
62
|
getFormField,
|
|
62
63
|
} from '@tmagic/form';
|
|
@@ -104,6 +105,7 @@ watch(
|
|
|
104
105
|
|
|
105
106
|
const { dataSourceService, propsService } = useServices();
|
|
106
107
|
const mForm = inject<FormState | undefined>('mForm');
|
|
108
|
+
const silentMode = inject(FORM_SILENT_MODE_KEY, false);
|
|
107
109
|
|
|
108
110
|
const dataSources = computed(() => dataSourceService.get('dataSources') || []);
|
|
109
111
|
const disabledDataSource = computed(() => propsService.getDisabledDataSource());
|
|
@@ -141,7 +143,10 @@ const checkStrictly = computed(() => {
|
|
|
141
143
|
if (typeof props.config.checkStrictly !== 'function') {
|
|
142
144
|
value = props.config.checkStrictly;
|
|
143
145
|
} else {
|
|
144
|
-
const
|
|
146
|
+
const fieldValue = props.model[props.name];
|
|
147
|
+
// 指定了 dataSourceId 时取值里只有字段名,数据源 id 只能取自 config
|
|
148
|
+
const rawDsId = props.config.dataSourceId ?? (Array.isArray(fieldValue) ? fieldValue[0] : fieldValue);
|
|
149
|
+
const dsId = removeDataSourceFieldPrefix(`${rawDsId}`);
|
|
145
150
|
const dataSource = dataSources.value.find((ds) => ds.id === dsId);
|
|
146
151
|
|
|
147
152
|
value = props.config.checkStrictly(mForm, {
|
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
</div>
|
|
9
9
|
|
|
10
10
|
<FloatingBox
|
|
11
|
+
v-if="!silentMode"
|
|
11
12
|
:body-style="{ padding: '0 16px' }"
|
|
12
13
|
v-model:visible="addDialogVisible"
|
|
13
14
|
v-model:width="width"
|
|
@@ -30,6 +31,7 @@
|
|
|
30
31
|
</FloatingBox>
|
|
31
32
|
|
|
32
33
|
<FloatingBox
|
|
34
|
+
v-if="!silentMode"
|
|
33
35
|
:body-style="{ padding: '0 16px' }"
|
|
34
36
|
v-model:visible="addFromJsonDialogVisible"
|
|
35
37
|
v-model:width="width"
|
|
@@ -60,6 +62,7 @@ import {
|
|
|
60
62
|
type ContainerChangeEventData,
|
|
61
63
|
type DataSourceFieldsConfig,
|
|
62
64
|
type FieldProps,
|
|
65
|
+
FORM_SILENT_MODE_KEY,
|
|
63
66
|
type FormConfig,
|
|
64
67
|
type FormState,
|
|
65
68
|
MFormBox,
|
|
@@ -89,6 +92,7 @@ const emit = defineEmits<{
|
|
|
89
92
|
|
|
90
93
|
const { uiService } = useServices();
|
|
91
94
|
const mForm = inject<FormState | undefined>('mForm');
|
|
95
|
+
const silentMode = inject(FORM_SILENT_MODE_KEY, false);
|
|
92
96
|
|
|
93
97
|
/** 对比模式下隐藏新增/编辑/删除等操作按钮,仅保留只读展示。 */
|
|
94
98
|
const isCompare = computed(() => Boolean(mForm?.isCompare));
|
|
@@ -379,6 +383,8 @@ provide(
|
|
|
379
383
|
);
|
|
380
384
|
|
|
381
385
|
onMounted(() => {
|
|
386
|
+
if (silentMode) return;
|
|
387
|
+
|
|
382
388
|
const path = editingFieldPath.value;
|
|
383
389
|
if (!path.length) return;
|
|
384
390
|
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
<div class="m-fields-data-source-method-select">
|
|
3
3
|
<div class="data-source-method-select-container">
|
|
4
4
|
<MCascader
|
|
5
|
+
v-if="!silentMode"
|
|
5
6
|
class="select"
|
|
6
7
|
:config="cascaderConfig"
|
|
7
8
|
:model="model"
|
|
@@ -13,7 +14,7 @@
|
|
|
13
14
|
></MCascader>
|
|
14
15
|
|
|
15
16
|
<TMagicTooltip
|
|
16
|
-
v-if="model[name] && isCustomMethod && dataSourceSidePanel && !isCompare"
|
|
17
|
+
v-if="!silentMode && model[name] && isCustomMethod && dataSourceSidePanel && !isCompare"
|
|
17
18
|
:content="notEditable ? '查看' : '编辑'"
|
|
18
19
|
>
|
|
19
20
|
<TMagicButton class="m-fields-select-action-button" :size="size" @click="editCodeHandler">
|
|
@@ -48,6 +49,7 @@ import {
|
|
|
48
49
|
type DataSourceMethodSelectConfig,
|
|
49
50
|
type FieldProps,
|
|
50
51
|
filterFunction,
|
|
52
|
+
FORM_SILENT_MODE_KEY,
|
|
51
53
|
type FormItemConfig,
|
|
52
54
|
type FormState,
|
|
53
55
|
MCascader,
|
|
@@ -67,6 +69,7 @@ defineOptions({
|
|
|
67
69
|
|
|
68
70
|
const { dataSourceService, uiService } = useServices();
|
|
69
71
|
const mForm = inject<FormState | undefined>('mForm');
|
|
72
|
+
const silentMode = inject(FORM_SILENT_MODE_KEY, false);
|
|
70
73
|
const eventBus = inject<EventBus>('eventBus');
|
|
71
74
|
|
|
72
75
|
const emit = defineEmits(['change']);
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
</div>
|
|
10
10
|
|
|
11
11
|
<CodeBlockEditor
|
|
12
|
-
v-if="codeConfig"
|
|
12
|
+
v-if="codeConfig && !silentMode"
|
|
13
13
|
ref="codeBlockEditor"
|
|
14
14
|
:disabled="disabled"
|
|
15
15
|
:content="codeConfig"
|
|
@@ -26,7 +26,13 @@ import { cloneDeep } from 'lodash-es';
|
|
|
26
26
|
|
|
27
27
|
import type { CodeBlockContent } from '@tmagic/core';
|
|
28
28
|
import { TMagicButton, tMagicMessageBox } from '@tmagic/design';
|
|
29
|
-
import
|
|
29
|
+
import {
|
|
30
|
+
type ContainerChangeEventData,
|
|
31
|
+
type DataSourceMethodsConfig,
|
|
32
|
+
type FieldProps,
|
|
33
|
+
FORM_SILENT_MODE_KEY,
|
|
34
|
+
type FormState,
|
|
35
|
+
} from '@tmagic/form';
|
|
30
36
|
import { type ColumnConfig, MagicTable } from '@tmagic/table';
|
|
31
37
|
|
|
32
38
|
import CodeBlockEditor from '@editor/components/CodeBlockEditor.vue';
|
|
@@ -43,6 +49,7 @@ const props = withDefaults(defineProps<FieldProps<DataSourceMethodsConfig>>(), {
|
|
|
43
49
|
const emit = defineEmits(['change']);
|
|
44
50
|
|
|
45
51
|
const mForm = inject<FormState | undefined>('mForm');
|
|
52
|
+
const silentMode = inject(FORM_SILENT_MODE_KEY, false);
|
|
46
53
|
|
|
47
54
|
/** 对比模式下隐藏新增/编辑/删除等操作按钮,仅保留只读展示。 */
|
|
48
55
|
const isCompare = computed(() => Boolean(mForm?.isCompare));
|
|
@@ -170,6 +177,8 @@ const editingMethodName = inject<ComputedRef<string | undefined>>(
|
|
|
170
177
|
);
|
|
171
178
|
|
|
172
179
|
onMounted(() => {
|
|
180
|
+
if (silentMode) return;
|
|
181
|
+
|
|
173
182
|
const methodName = editingMethodName.value;
|
|
174
183
|
if (!methodName) return;
|
|
175
184
|
|
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
</div>
|
|
8
8
|
|
|
9
9
|
<FloatingBox
|
|
10
|
+
v-if="!silentMode"
|
|
10
11
|
:body-style="{ padding: '0 16px' }"
|
|
11
12
|
v-model:visible="addDialogVisible"
|
|
12
13
|
v-model:width="width"
|
|
@@ -34,7 +35,14 @@ import { computed, inject, Ref, ref } from 'vue';
|
|
|
34
35
|
|
|
35
36
|
import type { MockSchema } from '@tmagic/core';
|
|
36
37
|
import { TMagicButton, tMagicMessageBox, TMagicSwitch } from '@tmagic/design';
|
|
37
|
-
import {
|
|
38
|
+
import {
|
|
39
|
+
type DataSourceMocksConfig,
|
|
40
|
+
type FieldProps,
|
|
41
|
+
FORM_SILENT_MODE_KEY,
|
|
42
|
+
type FormConfig,
|
|
43
|
+
type FormState,
|
|
44
|
+
MFormBox,
|
|
45
|
+
} from '@tmagic/form';
|
|
38
46
|
import { type ColumnConfig, MagicTable } from '@tmagic/table';
|
|
39
47
|
import { getDefaultValueFromFields } from '@tmagic/utils';
|
|
40
48
|
|
|
@@ -57,6 +65,7 @@ const emit = defineEmits(['change']);
|
|
|
57
65
|
|
|
58
66
|
const { uiService } = useServices();
|
|
59
67
|
const mForm = inject<FormState | undefined>('mForm');
|
|
68
|
+
const silentMode = inject(FORM_SILENT_MODE_KEY, false);
|
|
60
69
|
|
|
61
70
|
/** 对比模式下隐藏新增/编辑/删除等操作按钮,仅保留只读展示。 */
|
|
62
71
|
const isCompare = computed(() => Boolean(mForm?.isCompare));
|
|
@@ -25,6 +25,7 @@ import {
|
|
|
25
25
|
type GroupListConfig,
|
|
26
26
|
MGroupList,
|
|
27
27
|
} from '@tmagic/form';
|
|
28
|
+
import { removeDataSourceFieldPrefix } from '@tmagic/utils';
|
|
28
29
|
|
|
29
30
|
import { useServices } from '@editor/hooks/use-services';
|
|
30
31
|
import { getCascaderOptionsFromFields, getFieldType } from '@editor/utils';
|
|
@@ -46,9 +47,14 @@ const mForm = inject<FormState | undefined>('mForm');
|
|
|
46
47
|
|
|
47
48
|
const parentFields = computed(() => filterFunction<string[]>(mForm, props.config.parentFields, props) || []);
|
|
48
49
|
|
|
50
|
+
const resolveFieldPath = (path: string[]) => {
|
|
51
|
+
const [id, ...fieldNames] = path;
|
|
52
|
+
const ds = id ? dataSourceService.getDataSourceById(removeDataSourceFieldPrefix(`${id}`)) : undefined;
|
|
53
|
+
return { ds, fieldNames };
|
|
54
|
+
};
|
|
55
|
+
|
|
49
56
|
const fieldOnChange = (_formState: FormState | undefined, v: string[], { model }: { model: Record<string, any> }) => {
|
|
50
|
-
const
|
|
51
|
-
const ds = dataSourceService.getDataSourceById(id);
|
|
57
|
+
const { ds, fieldNames } = resolveFieldPath([...parentFields.value, ...v]);
|
|
52
58
|
const type = getFieldType(ds, fieldNames);
|
|
53
59
|
if (type === 'number') {
|
|
54
60
|
model.value = Number(model.value);
|
|
@@ -82,14 +88,13 @@ const config = computed<GroupListConfig>(() => ({
|
|
|
82
88
|
? {
|
|
83
89
|
type: 'cascader',
|
|
84
90
|
options: () => {
|
|
85
|
-
const
|
|
86
|
-
const ds = dataSourceService.getDataSourceById(dsId);
|
|
91
|
+
const { ds, fieldNames } = resolveFieldPath(parentFields.value);
|
|
87
92
|
if (!ds) {
|
|
88
93
|
return [];
|
|
89
94
|
}
|
|
90
95
|
|
|
91
96
|
let fields = ds.fields || [];
|
|
92
|
-
|
|
97
|
+
fieldNames.forEach((key) => {
|
|
93
98
|
const field = fields.find((f) => f.name === key);
|
|
94
99
|
fields = field?.fields || [];
|
|
95
100
|
});
|
|
@@ -139,8 +144,7 @@ const config = computed<GroupListConfig>(() => ({
|
|
|
139
144
|
{
|
|
140
145
|
name: 'value',
|
|
141
146
|
type: (_mForm, { model }) => {
|
|
142
|
-
const
|
|
143
|
-
const ds = dataSourceService.getDataSourceById(id);
|
|
147
|
+
const { ds, fieldNames } = resolveFieldPath([...parentFields.value, ...(model.field || [])]);
|
|
144
148
|
const type = getFieldType(ds, fieldNames);
|
|
145
149
|
|
|
146
150
|
if (type === 'number') {
|
|
@@ -85,7 +85,7 @@ import { Delete } from '@element-plus/icons-vue';
|
|
|
85
85
|
import { Plus } from '@element-plus/icons-vue';
|
|
86
86
|
import { has } from 'lodash-es';
|
|
87
87
|
|
|
88
|
-
import { ActionType } from '@tmagic/core';
|
|
88
|
+
import { ActionType, MNode } from '@tmagic/core';
|
|
89
89
|
import { TMagicButton } from '@tmagic/design';
|
|
90
90
|
import type {
|
|
91
91
|
CodeSelectColConfig,
|
|
@@ -327,8 +327,8 @@ const tableConfig = computed(
|
|
|
327
327
|
name: 'method',
|
|
328
328
|
label: '动作',
|
|
329
329
|
type: compActionConfig.value.type,
|
|
330
|
-
options: (mForm: FormState, { model }: any) => {
|
|
331
|
-
const node = editorService.getNodeById(model.to);
|
|
330
|
+
options: (mForm: FormState, { model, formValue }: any) => {
|
|
331
|
+
const node = editorService.getNodeById(model.to) || (formValue as MNode);
|
|
332
332
|
if (!node?.type) return [];
|
|
333
333
|
|
|
334
334
|
return eventsService.getMethod(node.type, { targetId: model.to, node }).map((option: any) => ({
|
package/src/fields/KeyValue.vue
CHANGED
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
</div>
|
|
45
45
|
|
|
46
46
|
<MagicCodeEditor
|
|
47
|
-
v-if="config.advanced && showCode"
|
|
47
|
+
v-if="config.advanced && showCode && !silentMode"
|
|
48
48
|
editor-custom-type="m-fields-key-value"
|
|
49
49
|
language="javascript"
|
|
50
50
|
:init-values="model[name]"
|
|
@@ -60,7 +60,7 @@
|
|
|
60
60
|
></MagicCodeEditor>
|
|
61
61
|
|
|
62
62
|
<TMagicButton
|
|
63
|
-
v-if="config.advanced && !isCompare"
|
|
63
|
+
v-if="config.advanced && !isCompare && !silentMode"
|
|
64
64
|
size="default"
|
|
65
65
|
:disabled="disabled"
|
|
66
66
|
link
|
|
@@ -75,7 +75,7 @@ import { computed, inject, ref, watchEffect } from 'vue';
|
|
|
75
75
|
import { Delete, Plus } from '@element-plus/icons-vue';
|
|
76
76
|
|
|
77
77
|
import { TMagicButton, TMagicInput } from '@tmagic/design';
|
|
78
|
-
import type
|
|
78
|
+
import { type FieldProps, FORM_SILENT_MODE_KEY, type FormState, type KeyValueConfig } from '@tmagic/form';
|
|
79
79
|
|
|
80
80
|
import CodeIcon from '@editor/icons/CodeIcon.vue';
|
|
81
81
|
import MagicCodeEditor from '@editor/layouts/CodeEditor.vue';
|
|
@@ -93,6 +93,7 @@ const emit = defineEmits<{
|
|
|
93
93
|
}>();
|
|
94
94
|
|
|
95
95
|
const mForm = inject<FormState | undefined>('mForm');
|
|
96
|
+
const silentMode = inject(FORM_SILENT_MODE_KEY, false);
|
|
96
97
|
|
|
97
98
|
/** 对比模式下隐藏增删/代码切换等操作按钮,仅保留只读展示。 */
|
|
98
99
|
const isCompare = computed(() => Boolean(mForm?.isCompare));
|
|
@@ -21,7 +21,7 @@ import { appendValidateSuggestion } from '@tmagic/design';
|
|
|
21
21
|
import { type ContainerChangeEventData, defineFormConfig, MContainer } from '@tmagic/form';
|
|
22
22
|
import type { StyleSchema } from '@tmagic/schema';
|
|
23
23
|
|
|
24
|
-
import {
|
|
24
|
+
import { validateDataSourceFieldSelect } from '@editor/utils/type-match-rules';
|
|
25
25
|
|
|
26
26
|
import { AlignCenter, AlignLeft, AlignRight } from '../icons/text-align';
|
|
27
27
|
|
|
@@ -99,7 +99,7 @@ const formConfig = defineFormConfig([
|
|
|
99
99
|
return callback();
|
|
100
100
|
}
|
|
101
101
|
|
|
102
|
-
const result =
|
|
102
|
+
const result = validateDataSourceFieldSelect(
|
|
103
103
|
value,
|
|
104
104
|
{
|
|
105
105
|
fieldType: 'data-source-field-select',
|
|
@@ -23,7 +23,6 @@ import { type FormConfig, type FormState, type FormValue, MForm } from '@tmagic/
|
|
|
23
23
|
|
|
24
24
|
import type { CompareFormBaseProps } from '@editor/type';
|
|
25
25
|
import { getCodeBlockFormConfig } from '@editor/utils/code-block';
|
|
26
|
-
import { removeStyleDisplayConfig } from '@editor/utils/props';
|
|
27
26
|
|
|
28
27
|
export interface UseCompareFormReturn {
|
|
29
28
|
config: Ref<FormConfig>;
|
|
@@ -107,9 +106,7 @@ export const useCompareForm = (props: CompareFormBaseProps): UseCompareFormRetur
|
|
|
107
106
|
if (!props.type) {
|
|
108
107
|
return [];
|
|
109
108
|
}
|
|
110
|
-
return
|
|
111
|
-
await props.services.propsService.getPropsConfig(props.type, { node: props.value as unknown as MNode }),
|
|
112
|
-
);
|
|
109
|
+
return props.services.propsService.getPropsConfig(props.type, { node: props.value as unknown as MNode });
|
|
113
110
|
}
|
|
114
111
|
case 'data-source': {
|
|
115
112
|
const config = props.services.dataSourceService.getFormConfig(props.type || 'base');
|
package/src/plugin.ts
CHANGED
|
@@ -21,7 +21,7 @@ import { type App } from 'vue';
|
|
|
21
21
|
import type { DesignPluginOptions } from '@tmagic/design';
|
|
22
22
|
import designPlugin from '@tmagic/design';
|
|
23
23
|
import type { FormInstallOptions } from '@tmagic/form';
|
|
24
|
-
import formPlugin, { registerTypeMatchRules } from '@tmagic/form';
|
|
24
|
+
import formPlugin, { registerSilentLeafFieldTypes, registerTypeMatchRules } from '@tmagic/form';
|
|
25
25
|
import tablePlugin from '@tmagic/table';
|
|
26
26
|
|
|
27
27
|
import Code from './fields/Code.vue';
|
|
@@ -68,6 +68,14 @@ export default {
|
|
|
68
68
|
app.use(formPlugin, opt || {});
|
|
69
69
|
app.use(tablePlugin);
|
|
70
70
|
registerTypeMatchRules(editorTypeMatchRules);
|
|
71
|
+
registerSilentLeafFieldTypes([
|
|
72
|
+
'vs-code',
|
|
73
|
+
'ui-select',
|
|
74
|
+
'cond-op-select',
|
|
75
|
+
'page-fragment-select',
|
|
76
|
+
'data-source-select',
|
|
77
|
+
'data-source-input',
|
|
78
|
+
]);
|
|
71
79
|
|
|
72
80
|
app.config.globalProperties.$TMAGIC_EDITOR = option;
|
|
73
81
|
setEditorConfig(option);
|