@tmagic/editor 1.8.0-beta.23 → 1.8.0-beta.24
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/DataSourceFieldSelect/Index.vue_vue_type_script_setup_true_lang.js +5 -4
- 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/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/hooks/use-compare-form.js +1 -2
- package/dist/es/index.js +2 -2
- 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/utils/event.js +1 -1
- package/dist/es/utils/props.js +1 -29
- package/dist/tmagic-editor.umd.cjs +373 -368
- package/package.json +8 -8
- package/src/fields/CodeSelectCol.vue +4 -2
- package/src/fields/DataSourceFieldSelect/Index.vue +5 -3
- 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/EventSelect.vue +3 -3
- package/src/fields/KeyValue.vue +4 -3
- 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/types/index.d.ts +38 -60
|
@@ -2,7 +2,7 @@ import { SideItemKey } from "../type.js";
|
|
|
2
2
|
import { useServices } from "../hooks/use-services.js";
|
|
3
3
|
import Icon_default from "../components/Icon.js";
|
|
4
4
|
import CodeParams_default from "../components/CodeParams.js";
|
|
5
|
-
import { MContainer, MSelect, createValues, filterFunction } from "@tmagic/form";
|
|
5
|
+
import { FORM_SILENT_MODE_KEY, MContainer, MSelect, createValues, filterFunction } from "@tmagic/form";
|
|
6
6
|
import { TMagicButton } from "@tmagic/design";
|
|
7
7
|
import { computed, createBlock, createCommentVNode, createElementBlock, createElementVNode, createVNode, defineComponent, inject, openBlock, ref, unref, watch, withCtx } from "vue";
|
|
8
8
|
import { isEmpty, map } from "lodash-es";
|
|
@@ -34,6 +34,7 @@ var CodeSelectCol_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ de
|
|
|
34
34
|
emits: ["change"],
|
|
35
35
|
setup(__props, { emit: __emit }) {
|
|
36
36
|
const mForm = inject("mForm");
|
|
37
|
+
const silentMode = inject(FORM_SILENT_MODE_KEY, false);
|
|
37
38
|
const { codeBlockService, uiService } = useServices();
|
|
38
39
|
const eventBus = inject("eventBus");
|
|
39
40
|
const emit = __emit;
|
|
@@ -130,7 +131,7 @@ var CodeSelectCol_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ de
|
|
|
130
131
|
"last-values",
|
|
131
132
|
"size",
|
|
132
133
|
"prop"
|
|
133
|
-
])) : (openBlock(), createBlock(unref(MSelect), {
|
|
134
|
+
])) : !unref(silentMode) ? (openBlock(), createBlock(unref(MSelect), {
|
|
134
135
|
key: 1,
|
|
135
136
|
class: "select",
|
|
136
137
|
config: selectConfig,
|
|
@@ -144,9 +145,9 @@ var CodeSelectCol_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ de
|
|
|
144
145
|
"model",
|
|
145
146
|
"size",
|
|
146
147
|
"prop"
|
|
147
|
-
])),
|
|
148
|
+
])) : createCommentVNode("v-if", true),
|
|
148
149
|
createCommentVNode(" 查看/编辑按钮:对比模式为只读,不展示 "),
|
|
149
|
-
!isCompareMode.value && __props.model[__props.name] && hasCodeBlockSidePanel.value ? (openBlock(), createBlock(unref(TMagicButton), {
|
|
150
|
+
!isCompareMode.value && !unref(silentMode) && __props.model[__props.name] && hasCodeBlockSidePanel.value ? (openBlock(), createBlock(unref(TMagicButton), {
|
|
150
151
|
key: 2,
|
|
151
152
|
class: "m-fields-select-action-button",
|
|
152
153
|
size: __props.size,
|
|
@@ -2,7 +2,7 @@ import { useServices } from "../../hooks/use-services.js";
|
|
|
2
2
|
import Icon_default from "../../components/Icon.js";
|
|
3
3
|
import DatasourceIcon_default from "../../icons/DatasourceIcon.js";
|
|
4
4
|
import FieldSelect_default from "./FieldSelect.js";
|
|
5
|
-
import { getFormField } from "@tmagic/form";
|
|
5
|
+
import { FORM_SILENT_MODE_KEY, getFormField } from "@tmagic/form";
|
|
6
6
|
import { TMagicButton, TMagicTooltip, tMagicMessage } from "@tmagic/design";
|
|
7
7
|
import { DATA_SOURCE_FIELDS_SELECT_VALUE_PREFIX, removeDataSourceFieldPrefix } from "@tmagic/utils";
|
|
8
8
|
import { computed, createBlock, createCommentVNode, createElementBlock, createVNode, defineComponent, inject, normalizeClass, openBlock, ref, resolveComponent, resolveDynamicComponent, unref, watch, withCtx } from "vue";
|
|
@@ -40,6 +40,7 @@ var Index_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defineComp
|
|
|
40
40
|
}, { immediate: true });
|
|
41
41
|
const { dataSourceService, propsService } = useServices();
|
|
42
42
|
const mForm = inject("mForm");
|
|
43
|
+
const silentMode = inject(FORM_SILENT_MODE_KEY, false);
|
|
43
44
|
const dataSources = computed(() => dataSourceService.get("dataSources") || []);
|
|
44
45
|
const disabledDataSource = computed(() => propsService.getDisabledDataSource());
|
|
45
46
|
const type = computed(() => {
|
|
@@ -103,7 +104,7 @@ var Index_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defineComp
|
|
|
103
104
|
showDataSourceFieldSelect.value = !showDataSourceFieldSelect.value;
|
|
104
105
|
};
|
|
105
106
|
return (_ctx, _cache) => {
|
|
106
|
-
return openBlock(), createElementBlock("div", { class: normalizeClass(["m-fields-data-source-field-select", { [`data-source-field-${type.value}`]: !isSelectValid.value }]) }, [isSelectValid.value ? (openBlock(), createBlock(FieldSelect_default, {
|
|
107
|
+
return openBlock(), createElementBlock("div", { class: normalizeClass(["m-fields-data-source-field-select", { [`data-source-field-${type.value}`]: !isSelectValid.value }]) }, [isSelectValid.value && !unref(silentMode) ? (openBlock(), createBlock(FieldSelect_default, {
|
|
107
108
|
key: 0,
|
|
108
109
|
"model-value": __props.model[__props.name],
|
|
109
110
|
disabled: __props.disabled,
|
|
@@ -121,7 +122,7 @@ var Index_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defineComp
|
|
|
121
122
|
"checkStrictly",
|
|
122
123
|
"dataSourceFieldType",
|
|
123
124
|
"dataSourceId"
|
|
124
|
-
])) : (openBlock(), createBlock(resolveDynamicComponent(tagName.value), {
|
|
125
|
+
])) : !unref(silentMode) ? (openBlock(), createBlock(resolveDynamicComponent(tagName.value), {
|
|
125
126
|
key: 1,
|
|
126
127
|
config: __props.config.fieldConfig,
|
|
127
128
|
model: __props.model,
|
|
@@ -143,7 +144,7 @@ var Index_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defineComp
|
|
|
143
144
|
"init-values",
|
|
144
145
|
"values",
|
|
145
146
|
"prop"
|
|
146
|
-
])), __props.config.fieldConfig && !disabledDataSource.value && !unref(mForm)?.isCompare ? (openBlock(), createBlock(unref(TMagicTooltip), {
|
|
147
|
+
])) : createCommentVNode("v-if", true), !unref(silentMode) && __props.config.fieldConfig && !disabledDataSource.value && !unref(mForm)?.isCompare ? (openBlock(), createBlock(unref(TMagicTooltip), {
|
|
147
148
|
key: 2,
|
|
148
149
|
disabled: showDataSourceFieldSelect.value,
|
|
149
150
|
content: "选择数据源"
|
|
@@ -3,11 +3,11 @@ import { useEditorContentHeight } from "../hooks/use-editor-content-height.js";
|
|
|
3
3
|
import { useNextFloatBoxPosition } from "../hooks/use-next-float-box-position.js";
|
|
4
4
|
import { error } from "../utils/logger.js";
|
|
5
5
|
import FloatingBox_default from "../components/FloatingBox.js";
|
|
6
|
-
import { MFormBox } from "@tmagic/form";
|
|
6
|
+
import { FORM_SILENT_MODE_KEY, MFormBox } from "@tmagic/form";
|
|
7
7
|
import { MagicTable } from "@tmagic/table";
|
|
8
8
|
import { TMagicButton, tMagicMessage, tMagicMessageBox } from "@tmagic/design";
|
|
9
9
|
import { getDefaultValueFromFields } from "@tmagic/utils";
|
|
10
|
-
import { computed, createCommentVNode, createElementBlock, createTextVNode, createVNode, defineComponent, inject, isRef, mergeModels, onMounted, openBlock, provide, ref, unref, useModel, withCtx } from "vue";
|
|
10
|
+
import { computed, createBlock, createCommentVNode, createElementBlock, createTextVNode, createVNode, defineComponent, inject, isRef, mergeModels, onMounted, openBlock, provide, ref, unref, useModel, withCtx } from "vue";
|
|
11
11
|
//#region packages/editor/src/fields/DataSourceFields.vue?vue&type=script&setup=true&lang.ts
|
|
12
12
|
var _hoisted_1 = { class: "m-editor-data-source-fields" };
|
|
13
13
|
var _hoisted_2 = {
|
|
@@ -58,6 +58,7 @@ var DataSourceFields_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/
|
|
|
58
58
|
const emit = __emit;
|
|
59
59
|
const { uiService } = useServices();
|
|
60
60
|
const mForm = inject("mForm");
|
|
61
|
+
const silentMode = inject(FORM_SILENT_MODE_KEY, false);
|
|
61
62
|
/** 对比模式下隐藏新增/编辑/删除等操作按钮,仅保留只读展示。 */
|
|
62
63
|
const isCompare = computed(() => Boolean(mForm?.isCompare));
|
|
63
64
|
const fieldValues = ref({});
|
|
@@ -325,6 +326,7 @@ var DataSourceFields_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/
|
|
|
325
326
|
const editingFieldPath = inject("editingDataSourceFieldPath", computed(() => []));
|
|
326
327
|
provide("editingDataSourceFieldPath", computed(() => editingFieldPath.value.slice(1)));
|
|
327
328
|
onMounted(() => {
|
|
329
|
+
if (silentMode) return;
|
|
328
330
|
const path = editingFieldPath.value;
|
|
329
331
|
if (!path.length) return;
|
|
330
332
|
const fields = props.model[props.name] || [];
|
|
@@ -357,7 +359,8 @@ var DataSourceFields_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/
|
|
|
357
359
|
default: withCtx(() => [..._cache[9] || (_cache[9] = [createTextVNode("添加", -1)])]),
|
|
358
360
|
_: 1
|
|
359
361
|
}, 8, ["disabled"])])) : createCommentVNode("v-if", true),
|
|
360
|
-
|
|
362
|
+
!unref(silentMode) ? (openBlock(), createBlock(FloatingBox_default, {
|
|
363
|
+
key: 1,
|
|
361
364
|
"body-style": { padding: "0 16px" },
|
|
362
365
|
visible: addDialogVisible.value,
|
|
363
366
|
"onUpdate:visible": _cache[2] || (_cache[2] = ($event) => addDialogVisible.value = $event),
|
|
@@ -391,8 +394,9 @@ var DataSourceFields_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/
|
|
|
391
394
|
"title",
|
|
392
395
|
"framework-width",
|
|
393
396
|
"position"
|
|
394
|
-
]),
|
|
395
|
-
|
|
397
|
+
])) : createCommentVNode("v-if", true),
|
|
398
|
+
!unref(silentMode) ? (openBlock(), createBlock(FloatingBox_default, {
|
|
399
|
+
key: 2,
|
|
396
400
|
"body-style": { padding: "0 16px" },
|
|
397
401
|
visible: addFromJsonDialogVisible.value,
|
|
398
402
|
"onUpdate:visible": _cache[5] || (_cache[5] = ($event) => addFromJsonDialogVisible.value = $event),
|
|
@@ -417,7 +421,7 @@ var DataSourceFields_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/
|
|
|
417
421
|
"height",
|
|
418
422
|
"framework-width",
|
|
419
423
|
"position"
|
|
420
|
-
])
|
|
424
|
+
])) : createCommentVNode("v-if", true)
|
|
421
425
|
]);
|
|
422
426
|
};
|
|
423
427
|
}
|
package/dist/es/fields/DataSourceMethodSelect.vue_vue_type_script_setup_true_name_true_lang.js
CHANGED
|
@@ -3,7 +3,7 @@ import { useServices } from "../hooks/use-services.js";
|
|
|
3
3
|
import { getFieldType } from "../utils/data-source/index.js";
|
|
4
4
|
import Icon_default from "../components/Icon.js";
|
|
5
5
|
import CodeParams_default from "../components/CodeParams.js";
|
|
6
|
-
import { MCascader, createValues, filterFunction } from "@tmagic/form";
|
|
6
|
+
import { FORM_SILENT_MODE_KEY, MCascader, createValues, filterFunction } from "@tmagic/form";
|
|
7
7
|
import { TMagicButton, TMagicTooltip } from "@tmagic/design";
|
|
8
8
|
import { DATA_SOURCE_SET_DATA_METHOD_NAME } from "@tmagic/utils";
|
|
9
9
|
import { computed, createBlock, createCommentVNode, createElementBlock, createElementVNode, createVNode, defineComponent, inject, openBlock, ref, unref, withCtx } from "vue";
|
|
@@ -36,6 +36,7 @@ var DataSourceMethodSelect_vue_vue_type_script_setup_true_name_true_lang_default
|
|
|
36
36
|
setup(__props, { emit: __emit }) {
|
|
37
37
|
const { dataSourceService, uiService } = useServices();
|
|
38
38
|
const mForm = inject("mForm");
|
|
39
|
+
const silentMode = inject(FORM_SILENT_MODE_KEY, false);
|
|
39
40
|
const eventBus = inject("eventBus");
|
|
40
41
|
const emit = __emit;
|
|
41
42
|
const props = __props;
|
|
@@ -134,7 +135,8 @@ var DataSourceMethodSelect_vue_vue_type_script_setup_true_name_true_lang_default
|
|
|
134
135
|
eventBus?.emit("edit-data-source-method", id, methodName);
|
|
135
136
|
};
|
|
136
137
|
return (_ctx, _cache) => {
|
|
137
|
-
return openBlock(), createElementBlock("div", _hoisted_1, [createElementVNode("div", _hoisted_2, [
|
|
138
|
+
return openBlock(), createElementBlock("div", _hoisted_1, [createElementVNode("div", _hoisted_2, [!unref(silentMode) ? (openBlock(), createBlock(unref(MCascader), {
|
|
139
|
+
key: 0,
|
|
138
140
|
class: "select",
|
|
139
141
|
config: cascaderConfig.value,
|
|
140
142
|
model: __props.model,
|
|
@@ -150,8 +152,8 @@ var DataSourceMethodSelect_vue_vue_type_script_setup_true_name_true_lang_default
|
|
|
150
152
|
"size",
|
|
151
153
|
"disabled",
|
|
152
154
|
"prop"
|
|
153
|
-
]), __props.model[__props.name] && isCustomMethod.value && dataSourceSidePanel.value && !isCompare.value ? (openBlock(), createBlock(unref(TMagicTooltip), {
|
|
154
|
-
key:
|
|
155
|
+
])) : createCommentVNode("v-if", true), !unref(silentMode) && __props.model[__props.name] && isCustomMethod.value && dataSourceSidePanel.value && !isCompare.value ? (openBlock(), createBlock(unref(TMagicTooltip), {
|
|
156
|
+
key: 1,
|
|
155
157
|
content: notEditable.value ? "查看" : "编辑"
|
|
156
158
|
}, {
|
|
157
159
|
default: withCtx(() => [createVNode(unref(TMagicButton), {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import CodeBlockEditor_default from "../components/CodeBlockEditor.js";
|
|
2
|
+
import { FORM_SILENT_MODE_KEY } from "@tmagic/form";
|
|
2
3
|
import { MagicTable } from "@tmagic/table";
|
|
3
4
|
import { TMagicButton, tMagicMessageBox } from "@tmagic/design";
|
|
4
5
|
import { computed, createBlock, createCommentVNode, createElementBlock, createTextVNode, createVNode, defineComponent, inject, nextTick, onMounted, openBlock, ref, unref, useTemplateRef, withCtx } from "vue";
|
|
@@ -35,6 +36,7 @@ var DataSourceMethods_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*
|
|
|
35
36
|
const props = __props;
|
|
36
37
|
const emit = __emit;
|
|
37
38
|
const mForm = inject("mForm");
|
|
39
|
+
const silentMode = inject(FORM_SILENT_MODE_KEY, false);
|
|
38
40
|
/** 对比模式下隐藏新增/编辑/删除等操作按钮,仅保留只读展示。 */
|
|
39
41
|
const isCompare = computed(() => Boolean(mForm?.isCompare));
|
|
40
42
|
const codeConfig = ref();
|
|
@@ -128,6 +130,7 @@ var DataSourceMethods_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*
|
|
|
128
130
|
/** 由 DataSourceConfigPanel 注入:打开数据源详情后需要直接打开的方法名 */
|
|
129
131
|
const editingMethodName = inject("editingDataSourceMethodName", computed(() => ""));
|
|
130
132
|
onMounted(() => {
|
|
133
|
+
if (silentMode) return;
|
|
131
134
|
const methodName = editingMethodName.value;
|
|
132
135
|
if (!methodName) return;
|
|
133
136
|
const methods = props.model[props.name] || [];
|
|
@@ -152,7 +155,7 @@ var DataSourceMethods_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*
|
|
|
152
155
|
default: withCtx(() => [..._cache[0] || (_cache[0] = [createTextVNode("添加", -1)])]),
|
|
153
156
|
_: 1
|
|
154
157
|
}, 8, ["disabled"])])) : createCommentVNode("v-if", true),
|
|
155
|
-
codeConfig.value ? (openBlock(), createBlock(CodeBlockEditor_default, {
|
|
158
|
+
codeConfig.value && !unref(silentMode) ? (openBlock(), createBlock(CodeBlockEditor_default, {
|
|
156
159
|
key: 1,
|
|
157
160
|
ref: "codeBlockEditor",
|
|
158
161
|
disabled: __props.disabled,
|
|
@@ -3,11 +3,11 @@ import { useEditorContentHeight } from "../hooks/use-editor-content-height.js";
|
|
|
3
3
|
import { useNextFloatBoxPosition } from "../hooks/use-next-float-box-position.js";
|
|
4
4
|
import CodeEditor_default from "../layouts/CodeEditor.js";
|
|
5
5
|
import FloatingBox_default from "../components/FloatingBox.js";
|
|
6
|
-
import { MFormBox } from "@tmagic/form";
|
|
6
|
+
import { FORM_SILENT_MODE_KEY, MFormBox } from "@tmagic/form";
|
|
7
7
|
import { MagicTable } from "@tmagic/table";
|
|
8
8
|
import { TMagicButton, TMagicSwitch, tMagicMessageBox } from "@tmagic/design";
|
|
9
9
|
import { getDefaultValueFromFields } from "@tmagic/utils";
|
|
10
|
-
import { computed, createCommentVNode, createElementBlock, createTextVNode, createVNode, defineComponent, inject, isRef, mergeModels, openBlock, ref, unref, useModel, withCtx } from "vue";
|
|
10
|
+
import { computed, createBlock, createCommentVNode, createElementBlock, createTextVNode, createVNode, defineComponent, inject, isRef, mergeModels, openBlock, ref, unref, useModel, withCtx } from "vue";
|
|
11
11
|
//#region packages/editor/src/fields/DataSourceMocks.vue?vue&type=script&setup=true&lang.ts
|
|
12
12
|
var _hoisted_1 = { class: "m-editor-data-source-fields" };
|
|
13
13
|
var _hoisted_2 = {
|
|
@@ -49,6 +49,7 @@ var DataSourceMocks_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/
|
|
|
49
49
|
const emit = __emit;
|
|
50
50
|
const { uiService } = useServices();
|
|
51
51
|
const mForm = inject("mForm");
|
|
52
|
+
const silentMode = inject(FORM_SILENT_MODE_KEY, false);
|
|
52
53
|
/** 对比模式下隐藏新增/编辑/删除等操作按钮,仅保留只读展示。 */
|
|
53
54
|
const isCompare = computed(() => Boolean(mForm?.isCompare));
|
|
54
55
|
const width = useModel(__props, "width");
|
|
@@ -234,7 +235,8 @@ var DataSourceMocks_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/
|
|
|
234
235
|
default: withCtx(() => [..._cache[4] || (_cache[4] = [createTextVNode("添加", -1)])]),
|
|
235
236
|
_: 1
|
|
236
237
|
}, 8, ["disabled"])])) : createCommentVNode("v-if", true),
|
|
237
|
-
|
|
238
|
+
!unref(silentMode) ? (openBlock(), createBlock(FloatingBox_default, {
|
|
239
|
+
key: 1,
|
|
238
240
|
"body-style": { padding: "0 16px" },
|
|
239
241
|
visible: addDialogVisible.value,
|
|
240
242
|
"onUpdate:visible": _cache[1] || (_cache[1] = ($event) => addDialogVisible.value = $event),
|
|
@@ -266,7 +268,7 @@ var DataSourceMocks_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/
|
|
|
266
268
|
"title",
|
|
267
269
|
"framework-width",
|
|
268
270
|
"position"
|
|
269
|
-
])
|
|
271
|
+
])) : createCommentVNode("v-if", true)
|
|
270
272
|
]);
|
|
271
273
|
};
|
|
272
274
|
}
|
|
@@ -187,8 +187,8 @@ var EventSelect_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defi
|
|
|
187
187
|
name: "method",
|
|
188
188
|
label: "动作",
|
|
189
189
|
type: compActionConfig.value.type,
|
|
190
|
-
options: (mForm, { model }) => {
|
|
191
|
-
const node = editorService.getNodeById(model.to);
|
|
190
|
+
options: (mForm, { model, formValue }) => {
|
|
191
|
+
const node = editorService.getNodeById(model.to) || formValue;
|
|
192
192
|
if (!node?.type) return [];
|
|
193
193
|
return eventsService.getMethod(node.type, {
|
|
194
194
|
targetId: model.to,
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import CodeEditor_default from "../layouts/CodeEditor.js";
|
|
2
2
|
import CodeIcon_default from "../icons/CodeIcon.js";
|
|
3
|
+
import { FORM_SILENT_MODE_KEY } from "@tmagic/form";
|
|
3
4
|
import { TMagicButton, TMagicInput } from "@tmagic/design";
|
|
4
5
|
import { Fragment, computed, createBlock, createCommentVNode, createElementBlock, createElementVNode, createTextVNode, createVNode, defineComponent, inject, openBlock, ref, renderList, unref, watchEffect, withCtx } from "vue";
|
|
5
6
|
import { Delete, Plus } from "@element-plus/icons-vue";
|
|
@@ -32,6 +33,7 @@ var KeyValue_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defineC
|
|
|
32
33
|
const props = __props;
|
|
33
34
|
const emit = __emit;
|
|
34
35
|
const mForm = inject("mForm");
|
|
36
|
+
const silentMode = inject(FORM_SILENT_MODE_KEY, false);
|
|
35
37
|
/** 对比模式下隐藏增删/代码切换等操作按钮,仅保留只读展示。 */
|
|
36
38
|
const isCompare = computed(() => Boolean(mForm?.isCompare));
|
|
37
39
|
const records = ref([]);
|
|
@@ -137,7 +139,7 @@ var KeyValue_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defineC
|
|
|
137
139
|
"disabled",
|
|
138
140
|
"icon"
|
|
139
141
|
])) : createCommentVNode("v-if", true)])) : createCommentVNode("v-if", true),
|
|
140
|
-
__props.config.advanced && showCode.value ? (openBlock(), createBlock(CodeEditor_default, {
|
|
142
|
+
__props.config.advanced && showCode.value && !unref(silentMode) ? (openBlock(), createBlock(CodeEditor_default, {
|
|
141
143
|
key: 1,
|
|
142
144
|
"editor-custom-type": "m-fields-key-value",
|
|
143
145
|
language: "javascript",
|
|
@@ -150,7 +152,7 @@ var KeyValue_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defineC
|
|
|
150
152
|
parse: true,
|
|
151
153
|
onSave: save
|
|
152
154
|
}, null, 8, ["init-values", "options"])) : createCommentVNode("v-if", true),
|
|
153
|
-
__props.config.advanced && !isCompare.value ? (openBlock(), createBlock(unref(TMagicButton), {
|
|
155
|
+
__props.config.advanced && !isCompare.value && !unref(silentMode) ? (openBlock(), createBlock(unref(TMagicButton), {
|
|
154
156
|
key: 2,
|
|
155
157
|
size: "default",
|
|
156
158
|
disabled: __props.disabled,
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { getCodeBlockFormConfig } from "../utils/code-block.js";
|
|
2
|
-
import { removeStyleDisplayConfig } from "../utils/props.js";
|
|
3
2
|
import { computed, inject, provide, ref, useTemplateRef, watch, watchEffect } from "vue";
|
|
4
3
|
//#region packages/editor/src/hooks/use-compare-form.ts
|
|
5
4
|
/**
|
|
@@ -54,7 +53,7 @@ var useCompareForm = (props) => {
|
|
|
54
53
|
switch (props.category) {
|
|
55
54
|
case "node":
|
|
56
55
|
if (!props.type) return [];
|
|
57
|
-
return
|
|
56
|
+
return props.services.propsService.getPropsConfig(props.type, { node: props.value });
|
|
58
57
|
case "data-source": return props.services.dataSourceService.getFormConfig(props.type || "base").map((item) => "type" in item && item.type === "tab" ? {
|
|
59
58
|
...item,
|
|
60
59
|
active: "fields"
|
package/dist/es/index.js
CHANGED
|
@@ -2,8 +2,8 @@ import { CODE_DRAFT_STORAGE_KEY, CodeDeleteErrorType, ColumnLayout, DragType, Ke
|
|
|
2
2
|
import { useCodeBlockEdit } from "./hooks/use-code-block-edit.js";
|
|
3
3
|
import { getEditorConfig, isGlobalFlat, setEditorConfig } from "./utils/config.js";
|
|
4
4
|
import { getCodeBlockFormConfig } from "./utils/code-block.js";
|
|
5
|
-
import { advancedTabConfig, arrayOptions, booleanOptions, displayTabConfig, eqOptions, eventTabConfig, fillConfig, getCondOpOptionsByFieldType, numberOptions, removeStyleDisplayConfig, styleTabConfig } from "./utils/props.js";
|
|
6
5
|
import { useCompareForm } from "./hooks/use-compare-form.js";
|
|
6
|
+
import { advancedTabConfig, arrayOptions, booleanOptions, displayTabConfig, eqOptions, eventTabConfig, fillConfig, getCondOpOptionsByFieldType, numberOptions, styleTabConfig } from "./utils/props.js";
|
|
7
7
|
import props_default from "./services/props.js";
|
|
8
8
|
import { UndoRedo } from "./utils/undo-redo.js";
|
|
9
9
|
import { createStackStep, describeRevertStep, deserializeStacks, detectStackOpType, detectTargetId, detectTargetName, getLastPushedHistoryIds, getOrCreateStack, markStackSaved, mergeSteps, serializeStacks, undoFloor } from "./utils/history.js";
|
|
@@ -92,4 +92,4 @@ export * from "@tmagic/table";
|
|
|
92
92
|
export * from "@tmagic/stage";
|
|
93
93
|
export * from "@tmagic/design";
|
|
94
94
|
export * from "@tmagic/utils";
|
|
95
|
-
export { ALL_COND_OPS, CODE_DRAFT_STORAGE_KEY, COPY_CODE_STORAGE_KEY, COPY_DS_STORAGE_KEY, COPY_STORAGE_KEY, CodeBlockEditor_default as CodeBlockEditor, CodeBlockList_default as CodeBlockList, CodeBlockListPanel_default as CodeBlockListPanel, CodeDeleteErrorType, CodeSelect_default as CodeSelect, CodeSelectCol_default as CodeSelectCol, ColumnLayout, CompareForm_default as CompareForm, ComponentListPanel_default as ComponentListPanel, CondOpSelect_default as CondOpSelect, ContentMenu_default as ContentMenu, DEFAULT_LEFT_COLUMN_WIDTH, DEFAULT_RIGHT_COLUMN_WIDTH, DataSourceAddButton_default as DataSourceAddButton, DataSourceConfigPanel_default as DataSourceConfigPanel, Index_default as DataSourceFieldSelect, DataSourceFields_default as DataSourceFields, DataSourceInput_default as DataSourceInput, DataSourceMethodSelect_default as DataSourceMethodSelect, DataSourceMethods_default as DataSourceMethods, DataSourceMocks_default as DataSourceMocks, DataSourceSelect_default as DataSourceSelect, DepTargetType, DisplayConds_default as DisplayConds, DragType, EVENT_NAME_VALUE_SEPARATOR, EventSelect_default as EventSelect, Fixed2Other, FloatingBox_default as FloatingBox, H_GUIDE_LINE_STORAGE_KEY, HistoryDiffDialog_default as HistoryDiffDialog, Bucket_default as HistoryListBucket, BucketTab_default as HistoryListBucketTab, Icon_default as Icon, IdleTask, KeyBindingCommand, KeyValue_default as KeyValue, Keys, LEFT_COLUMN_WIDTH_STORAGE_KEY, LayerNodeContent_default as LayerNodeContent, LayerOffset, LayerPanel_default as LayerPanel, Layout, SplitView_default as LayoutContainer, MIN_CENTER_COLUMN_WIDTH, MIN_LEFT_COLUMN_WIDTH, MIN_RIGHT_COLUMN_WIDTH, PROPS_PANEL_WIDTH_STORAGE_KEY, PageFragmentSelect_default as PageFragmentSelect, FormPanel_default as PropsFormPanel, PropsPanel_default as PropsPanel, RIGHT_COLUMN_WIDTH_STORAGE_KEY, Resizer_default as Resizer, ScrollViewer, SideItemKey, SplitView_default as SplitView, StageCore, Index_default$1 as StyleSetter, CodeEditor_default as TMagicCodeEditor, Editor_default as TMagicEditor, ToolButton_default as ToolButton, Tree_default as Tree, TreeNode_default as TreeNode, UI_SELECT_MODE_EVENT_NAME, UndoRedo, V_GUIDE_LINE_STORAGE_KEY, ViewForm_default as ViewForm, advancedTabConfig, arrayOptions, beforePaste, booleanOptions, buildChangeRecords, calcAlignCenterStyle, calcLayerTargetIndex, calcMoveStyle, canUsePluginMethods, change2Fixed, classifyDragSources, codeBlock_default as codeBlockService, collectEventNameOptionValues, collectRelatedNodes, componentList_default as componentListService, confirmHistoryAction, createStackStep, dataSource_default as dataSourceService, debug, plugin_default as default, defaultIsExpandable, dep_default as depService, describeRevertStep, describeStepForRevert, deserializeStacks, designPlugin, detectStackOpType, detectTargetId, detectTargetName, displayTabConfig, editorNodeMergeCustomizer, editor_default as editorService, editorTypeMatchRules, eqOptions, error, eventTabConfig, events_default as eventsService, fillConfig, fixNodeLeft, fixNodePosition, formPlugin, generatePageName, generatePageNameByApp, getAddParent, getCascaderOptionsFromFields, getCodeBlockFormConfig, getCompActionAllowedValues, getCompActionOptions, getCondOpOptionsByFieldType, getDefaultConfig, getDisplayField, getEditorConfig, getEventNameAllowedValues, getEventNameOptions, getFieldType, getFormConfig, getFormValue, getGuideLineFromCache, getInitPositionStyle, getLastPushedHistoryIds, getNodeIndex, getOrCreateStack, getPageFragmentList, getPageList, getPageNameList, getPositionInContainer, getRelativeStyle, history_default as historyService, idbDelete, idbGet, idbSet, info, isEventNameCheckStrictly, isGlobalFlat, isIncludeDataSource, isIndexedDBSupported, keybinding_default as keybindingService, monaco_editor_default as loadMonaco, log, markStackSaved, mergeSteps, moveItemsInContainer, normalizeCompActionValue, numberOptions, openIndexedDB, props_default as propsService,
|
|
95
|
+
export { ALL_COND_OPS, CODE_DRAFT_STORAGE_KEY, COPY_CODE_STORAGE_KEY, COPY_DS_STORAGE_KEY, COPY_STORAGE_KEY, CodeBlockEditor_default as CodeBlockEditor, CodeBlockList_default as CodeBlockList, CodeBlockListPanel_default as CodeBlockListPanel, CodeDeleteErrorType, CodeSelect_default as CodeSelect, CodeSelectCol_default as CodeSelectCol, ColumnLayout, CompareForm_default as CompareForm, ComponentListPanel_default as ComponentListPanel, CondOpSelect_default as CondOpSelect, ContentMenu_default as ContentMenu, DEFAULT_LEFT_COLUMN_WIDTH, DEFAULT_RIGHT_COLUMN_WIDTH, DataSourceAddButton_default as DataSourceAddButton, DataSourceConfigPanel_default as DataSourceConfigPanel, Index_default as DataSourceFieldSelect, DataSourceFields_default as DataSourceFields, DataSourceInput_default as DataSourceInput, DataSourceMethodSelect_default as DataSourceMethodSelect, DataSourceMethods_default as DataSourceMethods, DataSourceMocks_default as DataSourceMocks, DataSourceSelect_default as DataSourceSelect, DepTargetType, DisplayConds_default as DisplayConds, DragType, EVENT_NAME_VALUE_SEPARATOR, EventSelect_default as EventSelect, Fixed2Other, FloatingBox_default as FloatingBox, H_GUIDE_LINE_STORAGE_KEY, HistoryDiffDialog_default as HistoryDiffDialog, Bucket_default as HistoryListBucket, BucketTab_default as HistoryListBucketTab, Icon_default as Icon, IdleTask, KeyBindingCommand, KeyValue_default as KeyValue, Keys, LEFT_COLUMN_WIDTH_STORAGE_KEY, LayerNodeContent_default as LayerNodeContent, LayerOffset, LayerPanel_default as LayerPanel, Layout, SplitView_default as LayoutContainer, MIN_CENTER_COLUMN_WIDTH, MIN_LEFT_COLUMN_WIDTH, MIN_RIGHT_COLUMN_WIDTH, PROPS_PANEL_WIDTH_STORAGE_KEY, PageFragmentSelect_default as PageFragmentSelect, FormPanel_default as PropsFormPanel, PropsPanel_default as PropsPanel, RIGHT_COLUMN_WIDTH_STORAGE_KEY, Resizer_default as Resizer, ScrollViewer, SideItemKey, SplitView_default as SplitView, StageCore, Index_default$1 as StyleSetter, CodeEditor_default as TMagicCodeEditor, Editor_default as TMagicEditor, ToolButton_default as ToolButton, Tree_default as Tree, TreeNode_default as TreeNode, UI_SELECT_MODE_EVENT_NAME, UndoRedo, V_GUIDE_LINE_STORAGE_KEY, ViewForm_default as ViewForm, advancedTabConfig, arrayOptions, beforePaste, booleanOptions, buildChangeRecords, calcAlignCenterStyle, calcLayerTargetIndex, calcMoveStyle, canUsePluginMethods, change2Fixed, classifyDragSources, codeBlock_default as codeBlockService, collectEventNameOptionValues, collectRelatedNodes, componentList_default as componentListService, confirmHistoryAction, createStackStep, dataSource_default as dataSourceService, debug, plugin_default as default, defaultIsExpandable, dep_default as depService, describeRevertStep, describeStepForRevert, deserializeStacks, designPlugin, detectStackOpType, detectTargetId, detectTargetName, displayTabConfig, editorNodeMergeCustomizer, editor_default as editorService, editorTypeMatchRules, eqOptions, error, eventTabConfig, events_default as eventsService, fillConfig, fixNodeLeft, fixNodePosition, formPlugin, generatePageName, generatePageNameByApp, getAddParent, getCascaderOptionsFromFields, getCodeBlockFormConfig, getCompActionAllowedValues, getCompActionOptions, getCondOpOptionsByFieldType, getDefaultConfig, getDisplayField, getEditorConfig, getEventNameAllowedValues, getEventNameOptions, getFieldType, getFormConfig, getFormValue, getGuideLineFromCache, getInitPositionStyle, getLastPushedHistoryIds, getNodeIndex, getOrCreateStack, getPageFragmentList, getPageList, getPageNameList, getPositionInContainer, getRelativeStyle, history_default as historyService, idbDelete, idbGet, idbSet, info, isEventNameCheckStrictly, isGlobalFlat, isIncludeDataSource, isIndexedDBSupported, keybinding_default as keybindingService, monaco_editor_default as loadMonaco, log, markStackSaved, mergeSteps, moveItemsInContainer, normalizeCompActionValue, numberOptions, openIndexedDB, props_default as propsService, resolveFieldByPath, resolveSelectedNode, serializeConfig, serializeStacks, setChildrenLayout, setEditorConfig, setLayout, stageOverlay_default as stageOverlayService, storage_default as storageService, styleTabConfig, tablePlugin, toggleFixedPosition, ui_default as uiService, undoFloor, updateStatus, useCodeBlockEdit, useCompareForm, useEditorContentHeight, useFilter, useFloatBox, useGetSo, useHistoryRevert, useNextFloatBoxPosition, useNodeStatus, useServices, useStage, useWindowRect, validateDataSourceFieldSelectValue, warn };
|
package/dist/es/plugin.js
CHANGED
|
@@ -21,7 +21,7 @@ import Code_default from "./fields/Code.js";
|
|
|
21
21
|
import CodeLink_default from "./fields/CodeLink.js";
|
|
22
22
|
import UISelect_default from "./fields/UISelect.js";
|
|
23
23
|
/* empty css */
|
|
24
|
-
import formPlugin, { registerTypeMatchRules } from "@tmagic/form";
|
|
24
|
+
import formPlugin, { registerSilentLeafFieldTypes, registerTypeMatchRules } from "@tmagic/form";
|
|
25
25
|
import tablePlugin from "@tmagic/table";
|
|
26
26
|
import designPlugin from "@tmagic/design";
|
|
27
27
|
//#region packages/editor/src/plugin.ts
|
|
@@ -37,6 +37,14 @@ var plugin_default = { install: (app, opt) => {
|
|
|
37
37
|
app.use(formPlugin, opt || {});
|
|
38
38
|
app.use(tablePlugin);
|
|
39
39
|
registerTypeMatchRules(editorTypeMatchRules);
|
|
40
|
+
registerSilentLeafFieldTypes([
|
|
41
|
+
"vs-code",
|
|
42
|
+
"ui-select",
|
|
43
|
+
"cond-op-select",
|
|
44
|
+
"page-fragment-select",
|
|
45
|
+
"data-source-select",
|
|
46
|
+
"data-source-input"
|
|
47
|
+
]);
|
|
40
48
|
app.config.globalProperties.$TMAGIC_EDITOR = option;
|
|
41
49
|
setEditorConfig(option);
|
|
42
50
|
app.component(`${Editor_default.name || "MEditor"}`, Editor_default);
|
|
@@ -12,6 +12,8 @@ import { NodeType } from "@tmagic/core";
|
|
|
12
12
|
import { nextTick, reactive, toRaw } from "vue";
|
|
13
13
|
import { cloneDeep as cloneDeep$1, isEmpty, isEqual, isObject, mergeWith, uniq } from "lodash-es";
|
|
14
14
|
//#region packages/editor/src/services/editor.ts
|
|
15
|
+
/** 历史插回时把记录的下标收敛到 [0, length],越界(含未记录)一律追加到末尾 */
|
|
16
|
+
var clampIndex = (index, length) => typeof index === "number" && index >= 0 && index <= length ? index : length;
|
|
15
17
|
/**
|
|
16
18
|
* 把「变更前后节点快照」列表归一成 update 类型的 {@link StepDiffItem} 列表,供 {@link StepValue.diff} 使用。
|
|
17
19
|
* `changeRecords` 来自 form 端的 propPath/value 列表,撤销/重做时只对这些 propPath 做局部更新;
|
|
@@ -51,6 +53,11 @@ var Editor = class extends BaseService {
|
|
|
51
53
|
* 普通操作不会读取它,调用前由 *AndGetHistoryId 重置为 null。
|
|
52
54
|
*/
|
|
53
55
|
lastPushedHistoryId = null;
|
|
56
|
+
/**
|
|
57
|
+
* 上一次 doAdd 的插入记忆:nodeId 为插入的节点,selectedId 为当时的选中节点。
|
|
58
|
+
* 仅在选中节点未变化时复用(连续 add / doNotSelect / 批量粘贴),选中变化后自动失效,无需手动清理。
|
|
59
|
+
*/
|
|
60
|
+
lastAdded = null;
|
|
54
61
|
constructor() {
|
|
55
62
|
super(canUsePluginMethods.async.map((methodName) => ({
|
|
56
63
|
name: methodName,
|
|
@@ -246,24 +253,29 @@ var Editor = class extends BaseService {
|
|
|
246
253
|
this.set("stage", null);
|
|
247
254
|
this.set("highlightNode", null);
|
|
248
255
|
}
|
|
249
|
-
async doAdd(node, parent) {
|
|
256
|
+
async doAdd(node, parent, _options = {}) {
|
|
250
257
|
const root = this.get("root");
|
|
251
258
|
if (!root) throw new Error("root为空");
|
|
252
259
|
const curNode = this.get("node");
|
|
253
260
|
const stage = this.get("stage");
|
|
254
261
|
if (!curNode) throw new Error("当前选中节点为空");
|
|
255
262
|
if ((parent.type === NodeType.ROOT || curNode?.type === NodeType.ROOT) && !isPageOrFragment(node)) throw new Error("app下不能添加组件");
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
263
|
+
const anchorId = this.lastAdded?.selectedId === curNode.id ? this.lastAdded.nodeId : curNode.id;
|
|
264
|
+
const anchorIndex = isPageOrFragment(node) ? -1 : Math.max(getNodeIndex(anchorId, parent), getNodeIndex(curNode.id, parent));
|
|
265
|
+
const insertIndex = anchorIndex < 0 ? parent.items.length : anchorIndex + 1;
|
|
266
|
+
parent.items.splice(insertIndex, 0, node);
|
|
267
|
+
this.lastAdded = {
|
|
268
|
+
selectedId: curNode.id,
|
|
269
|
+
nodeId: node.id
|
|
270
|
+
};
|
|
260
271
|
const layout = await this.getLayout(toRaw(parent), node);
|
|
261
272
|
node.style = getInitPositionStyle(node.style, layout);
|
|
262
273
|
await stage?.add({
|
|
263
274
|
config: cloneDeep$1(node),
|
|
264
275
|
parent: cloneDeep$1(parent),
|
|
265
276
|
parentId: parent.id,
|
|
266
|
-
root: cloneDeep$1(root)
|
|
277
|
+
root: cloneDeep$1(root),
|
|
278
|
+
index: insertIndex
|
|
267
279
|
});
|
|
268
280
|
const newStyle = fixNodePosition(node, parent, stage);
|
|
269
281
|
if (newStyle && (newStyle.top !== node.style.top || newStyle.left !== node.style.left)) {
|
|
@@ -281,14 +293,12 @@ var Editor = class extends BaseService {
|
|
|
281
293
|
* 向指点容器添加组件节点
|
|
282
294
|
* @param addConfig 将要添加的组件节点配置
|
|
283
295
|
* @param parent 要添加到的容器组件节点配置,如果不设置,默认为当前选中的组件的父节点
|
|
284
|
-
* @param options
|
|
285
|
-
* @param options.doNotSelect 添加后是否不更新当前选中节点(默认 false,添加后会选中新增的节点)
|
|
286
|
-
* @param options.doNotSwitchPage 添加后是否不切换当前页面(默认 false;新增页面 / 跨页新增时为 true 会跳过会引发页面切换的选中操作)
|
|
287
|
-
* @param options.doNotPushHistory 是否不写入历史记录(默认 false)
|
|
296
|
+
* @param options 可选配置,见 {@link DslOpOptions}
|
|
288
297
|
* @returns 添加后的节点
|
|
289
298
|
*/
|
|
290
|
-
async add(addNode, parent,
|
|
299
|
+
async add(addNode, parent, options = {}) {
|
|
291
300
|
this.captureSelectionBeforeOp();
|
|
301
|
+
const { doNotSelect = false, doNotSwitchPage = false, doNotPushHistory = false, historyDescription, historySource } = options;
|
|
292
302
|
const stage = this.get("stage");
|
|
293
303
|
const addNodes = [];
|
|
294
304
|
if (!Array.isArray(addNode)) {
|
|
@@ -296,13 +306,13 @@ var Editor = class extends BaseService {
|
|
|
296
306
|
if (!type) throw new Error("组件类型不能为空");
|
|
297
307
|
addNodes.push({ ...toRaw(await props_default.getPropsValue(type, config)) });
|
|
298
308
|
} else addNodes.push(...addNode);
|
|
299
|
-
const newNodes =
|
|
309
|
+
const newNodes = [];
|
|
310
|
+
for (const node of addNodes) {
|
|
300
311
|
const root = this.get("root");
|
|
301
|
-
|
|
302
|
-
const parentNode = parent ?? getAddParent(node);
|
|
312
|
+
const parentNode = isPageOrFragment(node) && root ? root : parent ?? getAddParent(node);
|
|
303
313
|
if (!parentNode) throw new Error("未找到父元素");
|
|
304
|
-
|
|
305
|
-
}
|
|
314
|
+
newNodes.push(await this.doAdd(node, parentNode, options));
|
|
315
|
+
}
|
|
306
316
|
if (newNodes.length > 1) {
|
|
307
317
|
const wouldSwitchPage = newNodes.some((n) => this.isOnDifferentPage(n));
|
|
308
318
|
if (!doNotSelect && !(doNotSwitchPage && wouldSwitchPage)) {
|
|
@@ -418,7 +428,8 @@ var Editor = class extends BaseService {
|
|
|
418
428
|
* @param options.doNotSwitchPage 删除后是否不切换当前页面(默认 false;删除页面 / 页面片段时为 true 会跳过自动切换到首个剩余页面)
|
|
419
429
|
* @param options.doNotPushHistory 是否不写入历史记录(默认 false)
|
|
420
430
|
*/
|
|
421
|
-
async remove(nodeOrNodeList,
|
|
431
|
+
async remove(nodeOrNodeList, options = {}) {
|
|
432
|
+
const { doNotPushHistory = false, historyDescription, historySource } = options;
|
|
422
433
|
this.captureSelectionBeforeOp();
|
|
423
434
|
const nodes = Array.isArray(nodeOrNodeList) ? nodeOrNodeList : [nodeOrNodeList];
|
|
424
435
|
const changeItems = nodes.map((node) => ({
|
|
@@ -442,10 +453,7 @@ var Editor = class extends BaseService {
|
|
|
442
453
|
});
|
|
443
454
|
}
|
|
444
455
|
}
|
|
445
|
-
await Promise.all(nodes.map((node) => this.doRemove(node,
|
|
446
|
-
doNotSelect,
|
|
447
|
-
doNotSwitchPage
|
|
448
|
-
})));
|
|
456
|
+
await Promise.all(nodes.map((node) => this.doRemove(node, options)));
|
|
449
457
|
this.removeInvalidNodesBySubtree(nodes);
|
|
450
458
|
if (removedItems.length > 0 && pageForOp) if (!doNotPushHistory) this.pushOpHistory("remove", {
|
|
451
459
|
diff: removedItems,
|
|
@@ -467,7 +475,8 @@ var Editor = class extends BaseService {
|
|
|
467
475
|
remove: removedPages
|
|
468
476
|
});
|
|
469
477
|
}
|
|
470
|
-
async doUpdate(config,
|
|
478
|
+
async doUpdate(config, data = {}) {
|
|
479
|
+
const { changeRecords = [], historySource, replace = false } = data;
|
|
471
480
|
if (!this.get("root")) throw new Error("root为空");
|
|
472
481
|
if (!config?.id) throw new Error("没有配置或者配置缺少id值");
|
|
473
482
|
const info = this.getNodeInfo(config.id, false);
|
|
@@ -516,24 +525,18 @@ var Editor = class extends BaseService {
|
|
|
516
525
|
* 更新节点
|
|
517
526
|
* update后会触发依赖收集,收集完后会掉stage.update方法
|
|
518
527
|
* @param config 新的节点配置,配置中需要有id信息
|
|
519
|
-
* @param data
|
|
520
|
-
* @param data.changeRecords 单节点 form 端变更记录(多节点场景下被忽略,使用 changeRecordList)
|
|
521
|
-
* @param data.changeRecordList 多节点 form 端变更记录列表,按 config 数组同序对应每个节点;优先级高于 changeRecords
|
|
522
|
-
* @param data.doNotPushHistory 是否不写入历史记录(默认 false)
|
|
523
|
-
* @param data.historyDescription 入栈时附带的人类可读描述,用于历史面板展示(不影响 undo/redo 行为)
|
|
524
|
-
* @param data.replace 是否整节点替换:为 true 时跳过 mergeWith / toggleFixedPosition / setChildrenLayout,直接用传入配置覆盖(默认 false)
|
|
528
|
+
* @param data 额外数据,见 {@link UpdateOptions}
|
|
525
529
|
* @returns 更新后的节点配置
|
|
526
530
|
*/
|
|
527
531
|
async update(config, data = {}) {
|
|
528
532
|
this.captureSelectionBeforeOp();
|
|
529
|
-
const { doNotPushHistory = false, changeRecordList, changeRecords, historyDescription, historySource,
|
|
533
|
+
const { doNotPushHistory = false, changeRecordList, changeRecords, historyDescription, historySource, invalidInfo } = data;
|
|
530
534
|
const nodes = Array.isArray(config) ? config : [config];
|
|
531
535
|
const updateData = await Promise.all(nodes.map((node, index) => {
|
|
532
536
|
const recordsForNode = changeRecordList ? changeRecordList[index] ?? [] : changeRecords ?? [];
|
|
533
537
|
return this.doUpdate(node, {
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
replace
|
|
538
|
+
...data,
|
|
539
|
+
changeRecords: recordsForNode
|
|
537
540
|
});
|
|
538
541
|
}));
|
|
539
542
|
this.applyInvalidInfo(config, invalidInfo);
|
|
@@ -1376,14 +1379,15 @@ var Editor = class extends BaseService {
|
|
|
1376
1379
|
const parent = this.getNodeById(parentId, false);
|
|
1377
1380
|
if (parent?.items) {
|
|
1378
1381
|
const addedNode = cloneDeep$1(newSchema);
|
|
1379
|
-
|
|
1380
|
-
|
|
1382
|
+
const insertIndex = clampIndex(index, parent.items.length);
|
|
1383
|
+
parent.items.splice(insertIndex, 0, addedNode);
|
|
1381
1384
|
addedNodes.push(addedNode);
|
|
1382
1385
|
await stage?.add({
|
|
1383
1386
|
config: cloneDeep$1(newSchema),
|
|
1384
1387
|
parent: cloneDeep$1(parent),
|
|
1385
1388
|
parentId: parent.id,
|
|
1386
|
-
root: cloneDeep$1(root)
|
|
1389
|
+
root: cloneDeep$1(root),
|
|
1390
|
+
index: insertIndex
|
|
1387
1391
|
});
|
|
1388
1392
|
}
|
|
1389
1393
|
}
|
|
@@ -1401,13 +1405,15 @@ var Editor = class extends BaseService {
|
|
|
1401
1405
|
const parent = this.getNodeById(parentId, false);
|
|
1402
1406
|
if (parent?.items) {
|
|
1403
1407
|
const addedNode = cloneDeep$1(oldSchema);
|
|
1404
|
-
|
|
1408
|
+
const insertIndex = clampIndex(index, parent.items.length);
|
|
1409
|
+
parent.items.splice(insertIndex, 0, addedNode);
|
|
1405
1410
|
addedNodes.push(addedNode);
|
|
1406
1411
|
await stage?.add({
|
|
1407
1412
|
config: cloneDeep$1(oldSchema),
|
|
1408
1413
|
parent: cloneDeep$1(parent),
|
|
1409
1414
|
parentId,
|
|
1410
|
-
root: cloneDeep$1(root)
|
|
1415
|
+
root: cloneDeep$1(root),
|
|
1416
|
+
index: insertIndex
|
|
1411
1417
|
});
|
|
1412
1418
|
}
|
|
1413
1419
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { fillConfig } from "../utils/props.js";
|
|
2
1
|
import BaseService from "./BaseService.js";
|
|
2
|
+
import { fillConfig } from "../utils/props.js";
|
|
3
3
|
import editor_default from "./editor.js";
|
|
4
4
|
import { getNodePath, getValueByKeyPath, guid, setValueByKeyPath, toLine } from "@tmagic/utils";
|
|
5
5
|
import { Target, Watcher } from "@tmagic/core";
|
package/dist/es/utils/event.js
CHANGED
|
@@ -19,7 +19,7 @@ var normalizeCompActionValue = (value) => {
|
|
|
19
19
|
var getEventNameOptions = (src, formValue = {}) => {
|
|
20
20
|
if (!formValue.type) return [];
|
|
21
21
|
if (src === "component") {
|
|
22
|
-
const sourceNode = editor_default.getNodeById(formValue.id);
|
|
22
|
+
const sourceNode = editor_default.getNodeById(formValue.id) || formValue;
|
|
23
23
|
let events = events_default.getEvent(formValue.type, { node: sourceNode }) || [];
|
|
24
24
|
if (formValue.type === "page-fragment-container" && formValue.pageFragmentId) {
|
|
25
25
|
const pageFragment = editor_default.get("root")?.items?.find((page) => page.id === formValue.pageFragmentId);
|
package/dist/es/utils/props.js
CHANGED
|
@@ -62,7 +62,6 @@ var getCondOpOptionsByFieldType = (type) => {
|
|
|
62
62
|
};
|
|
63
63
|
var styleTabConfig = {
|
|
64
64
|
title: "样式",
|
|
65
|
-
lazy: true,
|
|
66
65
|
display: ({ services }) => !(services?.uiService?.get("showStylePanel") ?? true),
|
|
67
66
|
items: [{
|
|
68
67
|
name: "style",
|
|
@@ -127,7 +126,6 @@ var styleTabConfig = {
|
|
|
127
126
|
};
|
|
128
127
|
var eventTabConfig = {
|
|
129
128
|
title: "事件",
|
|
130
|
-
lazy: true,
|
|
131
129
|
items: [{
|
|
132
130
|
name: "events",
|
|
133
131
|
src: "component",
|
|
@@ -138,7 +136,6 @@ var eventTabConfig = {
|
|
|
138
136
|
};
|
|
139
137
|
var advancedTabConfig = {
|
|
140
138
|
title: "高级",
|
|
141
|
-
lazy: true,
|
|
142
139
|
items: [
|
|
143
140
|
{
|
|
144
141
|
name: NODE_DISABLE_CODE_BLOCK_KEY,
|
|
@@ -288,30 +285,5 @@ var fillConfig = (config = [], { labelWidth = "80px", disabledDataSource = false
|
|
|
288
285
|
if (!disabledDataSource) tabConfig.items.push({ ...displayTabConfig });
|
|
289
286
|
return [tabConfig];
|
|
290
287
|
};
|
|
291
|
-
/**
|
|
292
|
-
* 将属性表单配置中「样式」tab-pane 的 `display` 强制置为 `true`。
|
|
293
|
-
*
|
|
294
|
-
* `propsService.getPropsConfig` 返回的样式 tab 默认带有
|
|
295
|
-
* `display: ({ services }) => !(services?.uiService?.get('showStylePanel') ?? true)`,
|
|
296
|
-
* 在对比 / 只读展示场景(CompareForm / ViewForm)下并不需要跟随 uiService 状态隐藏,
|
|
297
|
-
* 这里统一放开,保证样式 tab 始终可见。
|
|
298
|
-
*
|
|
299
|
-
* @param formConfig 组件属性表单配置
|
|
300
|
-
* @returns 处理后的表单配置(不修改入参,返回浅拷贝)
|
|
301
|
-
*/
|
|
302
|
-
var removeStyleDisplayConfig = (formConfig) => formConfig.map((item) => {
|
|
303
|
-
if (!("type" in item)) return item;
|
|
304
|
-
if (item?.type !== "tab" || !Array.isArray(item.items)) return item;
|
|
305
|
-
return {
|
|
306
|
-
...item,
|
|
307
|
-
items: item.items.map((tabPane) => {
|
|
308
|
-
if (tabPane?.title !== "样式" || !Array.isArray(tabPane.items)) return tabPane;
|
|
309
|
-
return {
|
|
310
|
-
...tabPane,
|
|
311
|
-
display: true
|
|
312
|
-
};
|
|
313
|
-
})
|
|
314
|
-
};
|
|
315
|
-
});
|
|
316
288
|
//#endregion
|
|
317
|
-
export { advancedTabConfig, arrayOptions, booleanOptions, displayTabConfig, eqOptions, eventTabConfig, fillConfig, getCondOpOptionsByFieldType, numberOptions,
|
|
289
|
+
export { advancedTabConfig, arrayOptions, booleanOptions, displayTabConfig, eqOptions, eventTabConfig, fillConfig, getCondOpOptionsByFieldType, numberOptions, styleTabConfig };
|