@tmagic/editor 1.8.1 → 1.8.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/es/Editor.vue_vue_type_script_setup_true_lang.js +1 -1
- package/dist/es/editorProps.js +3 -0
- package/dist/es/layouts/props-panel/FormPanel.vue_vue_type_script_setup_true_lang.js +8 -6
- package/dist/es/layouts/props-panel/PropsPanel.vue_vue_type_script_setup_true_lang.js +2 -2
- package/dist/tmagic-editor.umd.cjs +14 -9
- package/package.json +7 -7
- package/src/Editor.vue +6 -1
- package/src/editorProps.ts +5 -2
- package/src/layouts/props-panel/FormPanel.vue +8 -5
- package/src/layouts/props-panel/PropsPanel.vue +7 -2
|
@@ -136,7 +136,7 @@ var Editor_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defineCom
|
|
|
136
136
|
provide("codeOptions", props.codeOptions);
|
|
137
137
|
provide("stageOptions", stageOptions);
|
|
138
138
|
/** 是否启用「属性配置表单校验」联动能力,供 PropsPanel / FormPanel 判断校验失败时是否仍更新节点并记录错误 */
|
|
139
|
-
provide(ENABLE_PROPS_FORM_VALIDATE, props.enablePropsFormValidate ?? false);
|
|
139
|
+
provide(ENABLE_PROPS_FORM_VALIDATE, computed(() => props.enablePropsFormValidate ?? false));
|
|
140
140
|
/**
|
|
141
141
|
* 编辑器注入给整棵表单树的业务上下文(`services` / `stage`),属性面板、对比表单、
|
|
142
142
|
* 侧边栏里的嵌套 MForm 都通过 inject 自动继承。
|
package/dist/es/editorProps.js
CHANGED
|
@@ -4,6 +4,9 @@ import { getIdFromEl } from "@tmagic/utils";
|
|
|
4
4
|
/**
|
|
5
5
|
* 「属性配置表单校验」联动能力的 provide/inject 注入键。
|
|
6
6
|
* 使用 Symbol 避免与其它字符串键冲突,供 PropsPanel / FormPanel 注入判断校验失败时是否仍更新节点并记录错误。
|
|
7
|
+
*
|
|
8
|
+
* 注入值是 ComputedRef:Editor 用 `computed(() => props.enablePropsFormValidate ?? false)` 提供,
|
|
9
|
+
* 保证外部动态切换该 prop 时子孙组件能同步拿到最新值;子孙侧用 `.value` 读取。
|
|
7
10
|
*/
|
|
8
11
|
var ENABLE_PROPS_FORM_VALIDATE = Symbol("enablePropsFormValidate");
|
|
9
12
|
var defaultEditorProps = {
|
|
@@ -32,7 +32,7 @@ var FormPanel_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ define
|
|
|
32
32
|
setup(__props, { expose: __expose, emit: __emit }) {
|
|
33
33
|
const props = __props;
|
|
34
34
|
const emit = __emit;
|
|
35
|
-
const enablePropsFormValidate = inject(ENABLE_PROPS_FORM_VALIDATE, false);
|
|
35
|
+
const enablePropsFormValidate = inject(ENABLE_PROPS_FORM_VALIDATE, computed(() => false));
|
|
36
36
|
const services = useServices();
|
|
37
37
|
const { uiService } = services;
|
|
38
38
|
const codeOptions = inject("codeOptions", {});
|
|
@@ -53,7 +53,7 @@ var FormPanel_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ define
|
|
|
53
53
|
const values = await configFormRef.value?.submitForm();
|
|
54
54
|
emit("submit", values, eventData);
|
|
55
55
|
} catch (e) {
|
|
56
|
-
if (enablePropsFormValidate) emit("submit", v, eventData, e);
|
|
56
|
+
if (enablePropsFormValidate.value) emit("submit", v, eventData, e);
|
|
57
57
|
else emit("submit-error", e);
|
|
58
58
|
}
|
|
59
59
|
};
|
|
@@ -70,7 +70,7 @@ var FormPanel_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ define
|
|
|
70
70
|
const formatValidateErrorHtml = (error) => error.split(/<br\s*\/?>/i).map((segment) => filterXSS(segment).replaceAll("\n", "<br>")).join("<br>");
|
|
71
71
|
const saveCode = async (values) => {
|
|
72
72
|
const newValues = props.codeValueKey ? { [props.codeValueKey]: values } : values;
|
|
73
|
-
if (!enablePropsFormValidate) {
|
|
73
|
+
if (!enablePropsFormValidate.value) {
|
|
74
74
|
emit("submit", newValues);
|
|
75
75
|
return;
|
|
76
76
|
}
|
|
@@ -109,9 +109,9 @@ var FormPanel_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ define
|
|
|
109
109
|
size: propsPanelSize.value,
|
|
110
110
|
"init-values": __props.values,
|
|
111
111
|
config: __props.config,
|
|
112
|
-
"type-match-valid":
|
|
112
|
+
"type-match-valid": unref(enablePropsFormValidate),
|
|
113
113
|
context: unref(formContext),
|
|
114
|
-
"validate-on-init":
|
|
114
|
+
"validate-on-init": unref(enablePropsFormValidate),
|
|
115
115
|
onChange: submit,
|
|
116
116
|
onError: errorHandler
|
|
117
117
|
}, null, 8, [
|
|
@@ -122,7 +122,9 @@ var FormPanel_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ define
|
|
|
122
122
|
"size",
|
|
123
123
|
"init-values",
|
|
124
124
|
"config",
|
|
125
|
-
"
|
|
125
|
+
"type-match-valid",
|
|
126
|
+
"context",
|
|
127
|
+
"validate-on-init"
|
|
126
128
|
])]),
|
|
127
129
|
_: 1
|
|
128
130
|
}),
|
|
@@ -30,7 +30,7 @@ var PropsPanel_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defin
|
|
|
30
30
|
setup(__props, { expose: __expose, emit: __emit }) {
|
|
31
31
|
const emit = __emit;
|
|
32
32
|
const { editorService, uiService, propsService, storageService } = useServices();
|
|
33
|
-
const enablePropsFormValidate = inject(ENABLE_PROPS_FORM_VALIDATE, false);
|
|
33
|
+
const enablePropsFormValidate = inject(ENABLE_PROPS_FORM_VALIDATE, computed(() => false));
|
|
34
34
|
const values = ref({});
|
|
35
35
|
const curFormConfig = ref([]);
|
|
36
36
|
const node = computed(() => editorService.get("node"));
|
|
@@ -93,7 +93,7 @@ var PropsPanel_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defin
|
|
|
93
93
|
changeRecords: eventData?.changeRecords,
|
|
94
94
|
historySource,
|
|
95
95
|
replace,
|
|
96
|
-
...enablePropsFormValidate && error ? { invalidInfo: {
|
|
96
|
+
...enablePropsFormValidate.value && error ? { invalidInfo: {
|
|
97
97
|
id: newValue.id,
|
|
98
98
|
source,
|
|
99
99
|
error: error?.message
|
|
@@ -14869,6 +14869,9 @@
|
|
|
14869
14869
|
/**
|
|
14870
14870
|
* 「属性配置表单校验」联动能力的 provide/inject 注入键。
|
|
14871
14871
|
* 使用 Symbol 避免与其它字符串键冲突,供 PropsPanel / FormPanel 注入判断校验失败时是否仍更新节点并记录错误。
|
|
14872
|
+
*
|
|
14873
|
+
* 注入值是 ComputedRef:Editor 用 `computed(() => props.enablePropsFormValidate ?? false)` 提供,
|
|
14874
|
+
* 保证外部动态切换该 prop 时子孙组件能同步拿到最新值;子孙侧用 `.value` 读取。
|
|
14872
14875
|
*/
|
|
14873
14876
|
var ENABLE_PROPS_FORM_VALIDATE = Symbol("enablePropsFormValidate");
|
|
14874
14877
|
var defaultEditorProps = {
|
|
@@ -14931,7 +14934,7 @@
|
|
|
14931
14934
|
setup(__props, { expose: __expose, emit: __emit }) {
|
|
14932
14935
|
const props = __props;
|
|
14933
14936
|
const emit = __emit;
|
|
14934
|
-
const enablePropsFormValidate = (0, vue.inject)(ENABLE_PROPS_FORM_VALIDATE, false);
|
|
14937
|
+
const enablePropsFormValidate = (0, vue.inject)(ENABLE_PROPS_FORM_VALIDATE, (0, vue.computed)(() => false));
|
|
14935
14938
|
const services = useServices();
|
|
14936
14939
|
const { uiService } = services;
|
|
14937
14940
|
const codeOptions = (0, vue.inject)("codeOptions", {});
|
|
@@ -14952,7 +14955,7 @@
|
|
|
14952
14955
|
const values = await configFormRef.value?.submitForm();
|
|
14953
14956
|
emit("submit", values, eventData);
|
|
14954
14957
|
} catch (e) {
|
|
14955
|
-
if (enablePropsFormValidate) emit("submit", v, eventData, e);
|
|
14958
|
+
if (enablePropsFormValidate.value) emit("submit", v, eventData, e);
|
|
14956
14959
|
else emit("submit-error", e);
|
|
14957
14960
|
}
|
|
14958
14961
|
};
|
|
@@ -14969,7 +14972,7 @@
|
|
|
14969
14972
|
const formatValidateErrorHtml = (error) => error.split(/<br\s*\/?>/i).map((segment) => (0, _tmagic_utils.filterXSS)(segment).replaceAll("\n", "<br>")).join("<br>");
|
|
14970
14973
|
const saveCode = async (values) => {
|
|
14971
14974
|
const newValues = props.codeValueKey ? { [props.codeValueKey]: values } : values;
|
|
14972
|
-
if (!enablePropsFormValidate) {
|
|
14975
|
+
if (!enablePropsFormValidate.value) {
|
|
14973
14976
|
emit("submit", newValues);
|
|
14974
14977
|
return;
|
|
14975
14978
|
}
|
|
@@ -15008,9 +15011,9 @@
|
|
|
15008
15011
|
size: propsPanelSize.value,
|
|
15009
15012
|
"init-values": __props.values,
|
|
15010
15013
|
config: __props.config,
|
|
15011
|
-
"type-match-valid":
|
|
15014
|
+
"type-match-valid": (0, vue.unref)(enablePropsFormValidate),
|
|
15012
15015
|
context: (0, vue.unref)(formContext),
|
|
15013
|
-
"validate-on-init":
|
|
15016
|
+
"validate-on-init": (0, vue.unref)(enablePropsFormValidate),
|
|
15014
15017
|
onChange: submit,
|
|
15015
15018
|
onError: errorHandler
|
|
15016
15019
|
}, null, 8, [
|
|
@@ -15021,7 +15024,9 @@
|
|
|
15021
15024
|
"size",
|
|
15022
15025
|
"init-values",
|
|
15023
15026
|
"config",
|
|
15024
|
-
"
|
|
15027
|
+
"type-match-valid",
|
|
15028
|
+
"context",
|
|
15029
|
+
"validate-on-init"
|
|
15025
15030
|
])]),
|
|
15026
15031
|
_: 1
|
|
15027
15032
|
}),
|
|
@@ -15115,7 +15120,7 @@
|
|
|
15115
15120
|
setup(__props, { expose: __expose, emit: __emit }) {
|
|
15116
15121
|
const emit = __emit;
|
|
15117
15122
|
const { editorService, uiService, propsService, storageService } = useServices();
|
|
15118
|
-
const enablePropsFormValidate = (0, vue.inject)(ENABLE_PROPS_FORM_VALIDATE, false);
|
|
15123
|
+
const enablePropsFormValidate = (0, vue.inject)(ENABLE_PROPS_FORM_VALIDATE, (0, vue.computed)(() => false));
|
|
15119
15124
|
const values = (0, vue.ref)({});
|
|
15120
15125
|
const curFormConfig = (0, vue.ref)([]);
|
|
15121
15126
|
const node = (0, vue.computed)(() => editorService.get("node"));
|
|
@@ -15178,7 +15183,7 @@
|
|
|
15178
15183
|
changeRecords: eventData?.changeRecords,
|
|
15179
15184
|
historySource,
|
|
15180
15185
|
replace,
|
|
15181
|
-
...enablePropsFormValidate && error ? { invalidInfo: {
|
|
15186
|
+
...enablePropsFormValidate.value && error ? { invalidInfo: {
|
|
15182
15187
|
id: newValue.id,
|
|
15183
15188
|
source,
|
|
15184
15189
|
error: error?.message
|
|
@@ -20661,7 +20666,7 @@
|
|
|
20661
20666
|
(0, vue.provide)("codeOptions", props.codeOptions);
|
|
20662
20667
|
(0, vue.provide)("stageOptions", stageOptions);
|
|
20663
20668
|
/** 是否启用「属性配置表单校验」联动能力,供 PropsPanel / FormPanel 判断校验失败时是否仍更新节点并记录错误 */
|
|
20664
|
-
(0, vue.provide)(ENABLE_PROPS_FORM_VALIDATE, props.enablePropsFormValidate ?? false);
|
|
20669
|
+
(0, vue.provide)(ENABLE_PROPS_FORM_VALIDATE, (0, vue.computed)(() => props.enablePropsFormValidate ?? false));
|
|
20665
20670
|
/**
|
|
20666
20671
|
* 编辑器注入给整棵表单树的业务上下文(`services` / `stage`),属性面板、对比表单、
|
|
20667
20672
|
* 侧边栏里的嵌套 MForm 都通过 inject 自动继承。
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "1.8.
|
|
2
|
+
"version": "1.8.2",
|
|
3
3
|
"name": "@tmagic/editor",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"sideEffects": [
|
|
@@ -63,11 +63,11 @@
|
|
|
63
63
|
"moveable": "^0.53.0",
|
|
64
64
|
"serialize-javascript": "^7.1.1",
|
|
65
65
|
"sortablejs": "^1.15.7",
|
|
66
|
-
"@tmagic/design": "1.8.
|
|
67
|
-
"@tmagic/form": "1.8.
|
|
68
|
-
"@tmagic/stage": "1.8.
|
|
69
|
-
"@tmagic/table": "1.8.
|
|
70
|
-
"@tmagic/utils": "1.8.
|
|
66
|
+
"@tmagic/design": "1.8.2",
|
|
67
|
+
"@tmagic/form": "1.8.2",
|
|
68
|
+
"@tmagic/stage": "1.8.2",
|
|
69
|
+
"@tmagic/table": "1.8.2",
|
|
70
|
+
"@tmagic/utils": "1.8.2"
|
|
71
71
|
},
|
|
72
72
|
"devDependencies": {
|
|
73
73
|
"@types/events": "^3.0.3",
|
|
@@ -81,7 +81,7 @@
|
|
|
81
81
|
"type-fest": "^5.2.0",
|
|
82
82
|
"typescript": "^6.0.3",
|
|
83
83
|
"vue": "^3.5.43",
|
|
84
|
-
"@tmagic/core": "1.8.
|
|
84
|
+
"@tmagic/core": "1.8.2"
|
|
85
85
|
},
|
|
86
86
|
"peerDependenciesMeta": {
|
|
87
87
|
"typescript": {
|
package/src/Editor.vue
CHANGED
|
@@ -236,7 +236,12 @@ provide('services', services);
|
|
|
236
236
|
provide('codeOptions', props.codeOptions);
|
|
237
237
|
provide('stageOptions', stageOptions);
|
|
238
238
|
/** 是否启用「属性配置表单校验」联动能力,供 PropsPanel / FormPanel 判断校验失败时是否仍更新节点并记录错误 */
|
|
239
|
-
|
|
239
|
+
// 同 isLargeStageContainer:用 computed 包一层,否则传下去的是 provide 那一刻的值快照,
|
|
240
|
+
// props.enablePropsFormValidate 后续变化不会同步到子孙。
|
|
241
|
+
provide(
|
|
242
|
+
ENABLE_PROPS_FORM_VALIDATE,
|
|
243
|
+
computed(() => props.enablePropsFormValidate ?? false),
|
|
244
|
+
);
|
|
240
245
|
/**
|
|
241
246
|
* 编辑器注入给整棵表单树的业务上下文(`services` / `stage`),属性面板、对比表单、
|
|
242
247
|
* 侧边栏里的嵌套 MForm 都通过 inject 自动继承。
|
package/src/editorProps.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { InjectionKey } from 'vue';
|
|
1
|
+
import type { ComputedRef, InjectionKey } from 'vue';
|
|
2
2
|
|
|
3
3
|
import type { DataSourceSchema, EventOption, Id, MApp, MNode, MPage, MPageFragment } from '@tmagic/core';
|
|
4
4
|
import type { FormConfig } from '@tmagic/form';
|
|
@@ -31,8 +31,11 @@ import type {
|
|
|
31
31
|
/**
|
|
32
32
|
* 「属性配置表单校验」联动能力的 provide/inject 注入键。
|
|
33
33
|
* 使用 Symbol 避免与其它字符串键冲突,供 PropsPanel / FormPanel 注入判断校验失败时是否仍更新节点并记录错误。
|
|
34
|
+
*
|
|
35
|
+
* 注入值是 ComputedRef:Editor 用 `computed(() => props.enablePropsFormValidate ?? false)` 提供,
|
|
36
|
+
* 保证外部动态切换该 prop 时子孙组件能同步拿到最新值;子孙侧用 `.value` 读取。
|
|
34
37
|
*/
|
|
35
|
-
export const ENABLE_PROPS_FORM_VALIDATE: InjectionKey<boolean
|
|
38
|
+
export const ENABLE_PROPS_FORM_VALIDATE: InjectionKey<ComputedRef<boolean>> = Symbol('enablePropsFormValidate');
|
|
36
39
|
|
|
37
40
|
export interface EditorProps {
|
|
38
41
|
/** 是否是大屏模拟器容器,大屏容器时,左侧属性面板会扩展为两列(正常3列),颜色表单不扩展两列等 */
|
|
@@ -12,9 +12,9 @@
|
|
|
12
12
|
:size="propsPanelSize"
|
|
13
13
|
:init-values="values"
|
|
14
14
|
:config="config"
|
|
15
|
-
:type-match-valid="
|
|
15
|
+
:type-match-valid="enablePropsFormValidate"
|
|
16
16
|
:context="formContext"
|
|
17
|
-
:validate-on-init="
|
|
17
|
+
:validate-on-init="enablePropsFormValidate"
|
|
18
18
|
@change="submit"
|
|
19
19
|
@error="errorHandler"
|
|
20
20
|
></MForm>
|
|
@@ -86,7 +86,10 @@ const emit = defineEmits<{
|
|
|
86
86
|
unmounted: [];
|
|
87
87
|
}>();
|
|
88
88
|
|
|
89
|
-
const enablePropsFormValidate = inject(
|
|
89
|
+
const enablePropsFormValidate = inject(
|
|
90
|
+
ENABLE_PROPS_FORM_VALIDATE,
|
|
91
|
+
computed(() => false),
|
|
92
|
+
);
|
|
90
93
|
|
|
91
94
|
const services = useServices();
|
|
92
95
|
const { uiService } = services;
|
|
@@ -116,7 +119,7 @@ const submit = async (v: FormValue, eventData: ContainerChangeEventData) => {
|
|
|
116
119
|
// 校验成功:正常更新节点(第三个参数 error 为空,表示清除该来源的错误记录)
|
|
117
120
|
emit('submit', values, eventData);
|
|
118
121
|
} catch (e: any) {
|
|
119
|
-
if (enablePropsFormValidate) {
|
|
122
|
+
if (enablePropsFormValidate.value) {
|
|
120
123
|
// 启用校验联动:校验失败时仍以当前表单值更新节点,并把错误信息一并抛给上层记录
|
|
121
124
|
emit('submit', v, eventData, e);
|
|
122
125
|
} else {
|
|
@@ -146,7 +149,7 @@ const formatValidateErrorHtml = (error: string): string =>
|
|
|
146
149
|
const saveCode = async (values: any) => {
|
|
147
150
|
const newValues = props.codeValueKey ? { [props.codeValueKey]: values } : values;
|
|
148
151
|
|
|
149
|
-
if (!enablePropsFormValidate) {
|
|
152
|
+
if (!enablePropsFormValidate.value) {
|
|
150
153
|
// 未启用校验联动:保持原行为,直接提交源码保存的值
|
|
151
154
|
emit('submit', newValues);
|
|
152
155
|
return;
|
|
@@ -93,7 +93,10 @@ const emit = defineEmits<{
|
|
|
93
93
|
|
|
94
94
|
const { editorService, uiService, propsService, storageService } = useServices();
|
|
95
95
|
|
|
96
|
-
const enablePropsFormValidate = inject(
|
|
96
|
+
const enablePropsFormValidate = inject(
|
|
97
|
+
ENABLE_PROPS_FORM_VALIDATE,
|
|
98
|
+
computed(() => false),
|
|
99
|
+
);
|
|
97
100
|
|
|
98
101
|
const values = ref<FormValue>({});
|
|
99
102
|
// ts类型应该是FormConfig, 但是打包时会出错,所以暂时用any
|
|
@@ -205,7 +208,9 @@ const submit = async (
|
|
|
205
208
|
replace,
|
|
206
209
|
// 启用校验联动时,仅校验失败(error 存在)才把错误信息随更新传入 editorService 记录;
|
|
207
210
|
// 其余情况(含表单校验成功、CodeEditor 源码保存)不携带 invalidInfo,由 editorService 在执行 update 时统一清除该节点错误。
|
|
208
|
-
...(enablePropsFormValidate && error
|
|
211
|
+
...(enablePropsFormValidate.value && error
|
|
212
|
+
? { invalidInfo: { id: newValue.id, source, error: error?.message } }
|
|
213
|
+
: {}),
|
|
209
214
|
});
|
|
210
215
|
} catch (e: any) {
|
|
211
216
|
emit('submit-error', e);
|