@tmagic/editor 1.8.0-beta.5 → 1.8.0-beta.7
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 +4 -1
- package/dist/es/fields/DataSourceFieldSelect/FieldSelect.vue_vue_type_script_setup_true_lang.js +8 -2
- package/dist/es/fields/DataSourceFields.vue_vue_type_script_setup_true_lang.js +25 -8
- 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 +25 -12
- package/dist/es/fields/StyleSetter/components/Border.vue_vue_type_script_setup_true_lang.js +27 -5
- package/dist/es/index.js +2 -2
- package/dist/es/layouts/history-list/HistoryListPanel.vue_vue_type_script_setup_true_lang.js +10 -14
- package/dist/es/layouts/history-list/InitialRow.vue_vue_type_script_setup_true_lang.js +12 -4
- package/dist/es/layouts/history-list/composables.js +28 -77
- package/dist/es/layouts/sidebar/Sidebar.vue_vue_type_script_setup_true_lang.js +2 -2
- package/dist/es/layouts/sidebar/data-source/DataSourceConfigPanel.vue_vue_type_script_setup_true_lang.js +16 -3
- package/dist/es/layouts/sidebar/data-source/DataSourceListPanel.vue_vue_type_script_setup_true_lang.js +23 -1
- package/dist/es/services/codeBlock.js +30 -19
- package/dist/es/services/dataSource.js +29 -21
- package/dist/es/services/editor.js +52 -33
- package/dist/es/services/history.js +10 -15
- package/dist/es/style.css +4 -1
- package/dist/es/utils/data-source/index.js +2 -0
- package/dist/es/utils/editor.js +68 -48
- package/dist/es/utils/history.js +42 -33
- package/dist/style.css +4 -1
- package/dist/tmagic-editor.umd.cjs +412 -295
- package/package.json +7 -7
- package/src/fields/CodeSelectCol.vue +7 -1
- package/src/fields/DataSourceFieldSelect/FieldSelect.vue +16 -2
- package/src/fields/DataSourceFields.vue +37 -8
- package/src/fields/DataSourceMethodSelect.vue +9 -4
- package/src/fields/DataSourceMethods.vue +42 -21
- package/src/fields/StyleSetter/components/Border.vue +15 -6
- package/src/layouts/history-list/HistoryListPanel.vue +12 -25
- package/src/layouts/history-list/InitialRow.vue +3 -0
- package/src/layouts/history-list/composables.ts +34 -94
- package/src/layouts/sidebar/Sidebar.vue +2 -2
- package/src/layouts/sidebar/data-source/DataSourceConfigPanel.vue +31 -2
- package/src/layouts/sidebar/data-source/DataSourceListPanel.vue +26 -1
- package/src/services/codeBlock.ts +28 -22
- package/src/services/dataSource.ts +29 -24
- package/src/services/editor.ts +41 -37
- package/src/services/history.ts +19 -25
- package/src/theme/style-setter/border.scss +4 -1
- package/src/type.ts +38 -26
- package/src/utils/data-source/index.ts +2 -0
- package/src/utils/editor.ts +125 -59
- package/src/utils/history.ts +48 -45
- package/types/index.d.ts +109 -112
|
@@ -47,7 +47,8 @@ var CodeSelectCol_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */
|
|
|
47
47
|
*/
|
|
48
48
|
const isCompareMode = computed(() => Boolean(props.isCompare && props.lastValues));
|
|
49
49
|
const notEditable = computed(() => filterFunction(mForm, props.config.notEditable, props));
|
|
50
|
-
const
|
|
50
|
+
const codeBlockSidePanel = computed(() => (uiService.get("sideBarItems") || []).find((item) => item.$key === SideItemKey.CODE_BLOCK));
|
|
51
|
+
const hasCodeBlockSidePanel = computed(() => codeBlockSidePanel.value);
|
|
51
52
|
/**
|
|
52
53
|
* 根据代码块id获取代码块参数配置
|
|
53
54
|
* @param codeId 代码块ID
|
|
@@ -102,6 +103,8 @@ var CodeSelectCol_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */
|
|
|
102
103
|
emit("change", props.model[props.name], eventData);
|
|
103
104
|
};
|
|
104
105
|
const editCode = (id) => {
|
|
106
|
+
const sideBarItem = codeBlockSidePanel.value;
|
|
107
|
+
if (sideBarItem) uiService.set("sideBarActiveTabName", sideBarItem.text || sideBarItem.$key || SideItemKey.CODE_BLOCK);
|
|
105
108
|
eventBus?.emit("edit-code", id);
|
|
106
109
|
};
|
|
107
110
|
return (_ctx, _cache) => {
|
package/dist/es/fields/DataSourceFieldSelect/FieldSelect.vue_vue_type_script_setup_true_lang.js
CHANGED
|
@@ -89,9 +89,15 @@ var FieldSelect_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ de
|
|
|
89
89
|
modelValue.value = v;
|
|
90
90
|
emit("change", v);
|
|
91
91
|
};
|
|
92
|
-
const
|
|
92
|
+
const dataSourceSidePanel = computed(() => uiService.get("sideBarItems").find((item) => item.$key === SideItemKey.DATA_SOURCE));
|
|
93
|
+
const hasDataSourceSidePanel = computed(() => dataSourceSidePanel.value);
|
|
93
94
|
const editHandler = (id) => {
|
|
94
|
-
|
|
95
|
+
const sideBarItem = dataSourceSidePanel.value;
|
|
96
|
+
if (sideBarItem) uiService.set("sideBarActiveTabName", sideBarItem.text || sideBarItem.$key || SideItemKey.DATA_SOURCE);
|
|
97
|
+
const dataSourceId = removeDataSourceFieldPrefix(id);
|
|
98
|
+
const fieldPath = selectFieldsId.value;
|
|
99
|
+
if (fieldPath.length) eventBus?.emit("edit-data-source-field", dataSourceId, [...fieldPath]);
|
|
100
|
+
else eventBus?.emit("edit-data-source", dataSourceId);
|
|
95
101
|
};
|
|
96
102
|
return (_ctx, _cache) => {
|
|
97
103
|
return openBlock(), createElementBlock("div", _hoisted_1, [__props.dataSourceId ? (openBlock(), createBlock(unref(TMagicCascader), {
|
|
@@ -7,7 +7,7 @@ import { 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, openBlock, ref, unref, useModel, withCtx } from "vue";
|
|
10
|
+
import { computed, 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 = {
|
|
@@ -66,6 +66,15 @@ var DataSourceFields_vue_vue_type_script_setup_true_lang_default = /* @__PURE__
|
|
|
66
66
|
calcBoxPosition();
|
|
67
67
|
addDialogVisible.value = true;
|
|
68
68
|
};
|
|
69
|
+
const editField = (row, index) => {
|
|
70
|
+
fieldValues.value = {
|
|
71
|
+
...row,
|
|
72
|
+
index
|
|
73
|
+
};
|
|
74
|
+
fieldTitle.value = `编辑${row.title}`;
|
|
75
|
+
calcBoxPosition();
|
|
76
|
+
addDialogVisible.value = true;
|
|
77
|
+
};
|
|
69
78
|
const fieldChange = ({ index, ...value }, data) => {
|
|
70
79
|
addDialogVisible.value = false;
|
|
71
80
|
if (index > -1) emit("change", value, {
|
|
@@ -117,13 +126,7 @@ var DataSourceFields_vue_vue_type_script_setup_true_lang_default = /* @__PURE__
|
|
|
117
126
|
actions: [{
|
|
118
127
|
text: "编辑",
|
|
119
128
|
handler: (row, index) => {
|
|
120
|
-
|
|
121
|
-
...row,
|
|
122
|
-
index
|
|
123
|
-
};
|
|
124
|
-
fieldTitle.value = `编辑${row.title}`;
|
|
125
|
-
calcBoxPosition();
|
|
126
|
-
addDialogVisible.value = true;
|
|
129
|
+
editField(row, index);
|
|
127
130
|
}
|
|
128
131
|
}, {
|
|
129
132
|
text: "删除",
|
|
@@ -310,6 +313,20 @@ var DataSourceFields_vue_vue_type_script_setup_true_lang_default = /* @__PURE__
|
|
|
310
313
|
const addFromJsonDialogVisible = useModel(__props, "visible1");
|
|
311
314
|
const { height: editorHeight } = useEditorContentHeight();
|
|
312
315
|
const { boxPosition, calcBoxPosition } = useNextFloatBoxPosition(uiService, inject("parentFloating", ref(null)));
|
|
316
|
+
/**
|
|
317
|
+
* 由 DataSourceConfigPanel 注入:打开数据源详情后需要直接打开的字段路径(字段名数组)。
|
|
318
|
+
* 当前层消费 path[0],并把剩余路径下发给嵌套字段,实现逐层打开。
|
|
319
|
+
*/
|
|
320
|
+
const editingFieldPath = inject("editingDataSourceFieldPath", computed(() => []));
|
|
321
|
+
provide("editingDataSourceFieldPath", computed(() => editingFieldPath.value.slice(1)));
|
|
322
|
+
onMounted(() => {
|
|
323
|
+
const path = editingFieldPath.value;
|
|
324
|
+
if (!path.length) return;
|
|
325
|
+
const fields = props.model[props.name] || [];
|
|
326
|
+
const index = fields.findIndex((field) => field.name === path[0]);
|
|
327
|
+
if (index === -1) return;
|
|
328
|
+
editField(fields[index], index);
|
|
329
|
+
});
|
|
313
330
|
return (_ctx, _cache) => {
|
|
314
331
|
return openBlock(), createElementBlock("div", _hoisted_1, [
|
|
315
332
|
createVNode(unref(MagicTable), {
|
package/dist/es/fields/DataSourceMethodSelect.vue_vue_type_script_setup_true_name_true_lang.js
CHANGED
|
@@ -36,7 +36,7 @@ var DataSourceMethodSelect_vue_vue_type_script_setup_true_name_true_lang_default
|
|
|
36
36
|
const eventBus = inject("eventBus");
|
|
37
37
|
const emit = __emit;
|
|
38
38
|
const props = __props;
|
|
39
|
-
const
|
|
39
|
+
const dataSourceSidePanel = computed(() => (uiService.get("sideBarItems") || []).find((item) => item.$key === SideItemKey.DATA_SOURCE));
|
|
40
40
|
const notEditable = computed(() => filterFunction(mForm, props.config.notEditable, props));
|
|
41
41
|
/** 对比模式下隐藏查看/编辑操作按钮,仅保留只读展示。 */
|
|
42
42
|
const isCompare = computed(() => Boolean(mForm?.isCompare));
|
|
@@ -124,9 +124,11 @@ var DataSourceMethodSelect_vue_vue_type_script_setup_true_name_true_lang_default
|
|
|
124
124
|
emit("change", props.model[props.name], eventData);
|
|
125
125
|
};
|
|
126
126
|
const editCodeHandler = () => {
|
|
127
|
-
const [id] = props.model[props.name];
|
|
127
|
+
const [id, methodName] = props.model[props.name];
|
|
128
128
|
if (!dataSourceService.getDataSourceById(id)) return;
|
|
129
|
-
|
|
129
|
+
const sideBarItem = dataSourceSidePanel.value;
|
|
130
|
+
if (sideBarItem) uiService.set("sideBarActiveTabName", sideBarItem.text || sideBarItem.$key || SideItemKey.DATA_SOURCE);
|
|
131
|
+
eventBus?.emit("edit-data-source-method", id, methodName);
|
|
130
132
|
};
|
|
131
133
|
return (_ctx, _cache) => {
|
|
132
134
|
return openBlock(), createElementBlock("div", _hoisted_1, [createElementVNode("div", _hoisted_2, [createVNode(unref(MCascader), {
|
|
@@ -145,7 +147,7 @@ var DataSourceMethodSelect_vue_vue_type_script_setup_true_name_true_lang_default
|
|
|
145
147
|
"size",
|
|
146
148
|
"disabled",
|
|
147
149
|
"prop"
|
|
148
|
-
]), __props.model[__props.name] && isCustomMethod.value &&
|
|
150
|
+
]), __props.model[__props.name] && isCustomMethod.value && dataSourceSidePanel.value && !isCompare.value ? (openBlock(), createBlock(unref(TMagicTooltip), {
|
|
149
151
|
key: 0,
|
|
150
152
|
content: notEditable.value ? "查看" : "编辑"
|
|
151
153
|
}, {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import CodeBlockEditor_default from "../components/CodeBlockEditor.js";
|
|
2
2
|
import { MagicTable } from "@tmagic/table";
|
|
3
3
|
import { TMagicButton, tMagicMessageBox } from "@tmagic/design";
|
|
4
|
-
import { computed, createBlock, createCommentVNode, createElementBlock, createTextVNode, createVNode, defineComponent, inject, nextTick, openBlock, ref, unref, useTemplateRef, withCtx } from "vue";
|
|
4
|
+
import { computed, createBlock, createCommentVNode, createElementBlock, createTextVNode, createVNode, defineComponent, inject, nextTick, onMounted, openBlock, ref, unref, useTemplateRef, withCtx } from "vue";
|
|
5
5
|
import { cloneDeep } from "lodash-es";
|
|
6
6
|
//#region packages/editor/src/fields/DataSourceMethods.vue?vue&type=script&setup=true&lang.ts
|
|
7
7
|
var _hoisted_1 = { class: "m-editor-data-source-methods" };
|
|
@@ -37,6 +37,19 @@ var DataSourceMethods_vue_vue_type_script_setup_true_lang_default = /* @__PURE__
|
|
|
37
37
|
const codeConfig = ref();
|
|
38
38
|
const codeBlockEditorRef = useTemplateRef("codeBlockEditor");
|
|
39
39
|
let editIndex = -1;
|
|
40
|
+
const editMethod = (method, index) => {
|
|
41
|
+
let codeContent = "({ params, dataSource, app }) => {\n // place your code here\n}";
|
|
42
|
+
if (method.content) if (typeof method.content !== "string") codeContent = method.content.toString();
|
|
43
|
+
else codeContent = method.content;
|
|
44
|
+
codeConfig.value = {
|
|
45
|
+
...cloneDeep(method),
|
|
46
|
+
content: codeContent
|
|
47
|
+
};
|
|
48
|
+
editIndex = index;
|
|
49
|
+
nextTick(() => {
|
|
50
|
+
codeBlockEditorRef.value?.show();
|
|
51
|
+
});
|
|
52
|
+
};
|
|
40
53
|
const methodColumns = [
|
|
41
54
|
{
|
|
42
55
|
label: "名称",
|
|
@@ -61,17 +74,7 @@ var DataSourceMethods_vue_vue_type_script_setup_true_lang_default = /* @__PURE__
|
|
|
61
74
|
actions: [{
|
|
62
75
|
text: "编辑",
|
|
63
76
|
handler: (method, index) => {
|
|
64
|
-
|
|
65
|
-
if (method.content) if (typeof method.content !== "string") codeContent = method.content.toString();
|
|
66
|
-
else codeContent = method.content;
|
|
67
|
-
codeConfig.value = {
|
|
68
|
-
...cloneDeep(method),
|
|
69
|
-
content: codeContent
|
|
70
|
-
};
|
|
71
|
-
editIndex = index;
|
|
72
|
-
nextTick(() => {
|
|
73
|
-
codeBlockEditorRef.value?.show();
|
|
74
|
-
});
|
|
77
|
+
editMethod(method, index);
|
|
75
78
|
}
|
|
76
79
|
}, {
|
|
77
80
|
text: "删除",
|
|
@@ -119,6 +122,16 @@ var DataSourceMethods_vue_vue_type_script_setup_true_lang_default = /* @__PURE__
|
|
|
119
122
|
codeConfig.value = void 0;
|
|
120
123
|
codeBlockEditorRef.value?.hide();
|
|
121
124
|
};
|
|
125
|
+
/** 由 DataSourceConfigPanel 注入:打开数据源详情后需要直接打开的方法名 */
|
|
126
|
+
const editingMethodName = inject("editingDataSourceMethodName", computed(() => ""));
|
|
127
|
+
onMounted(() => {
|
|
128
|
+
const methodName = editingMethodName.value;
|
|
129
|
+
if (!methodName) return;
|
|
130
|
+
const methods = props.model[props.name] || [];
|
|
131
|
+
const index = methods.findIndex((method) => method.name === methodName);
|
|
132
|
+
if (index === -1) return;
|
|
133
|
+
editMethod(methods[index], index);
|
|
134
|
+
});
|
|
122
135
|
return (_ctx, _cache) => {
|
|
123
136
|
return openBlock(), createElementBlock("div", _hoisted_1, [
|
|
124
137
|
createVNode(unref(MagicTable), {
|
|
@@ -54,6 +54,13 @@ var Border_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineC
|
|
|
54
54
|
] }));
|
|
55
55
|
const selectDirection = (d) => direction.value = d || "";
|
|
56
56
|
const emit = __emit;
|
|
57
|
+
const props = __props;
|
|
58
|
+
const hasValue = (value) => value !== void 0 && value !== null && value !== "";
|
|
59
|
+
const isConfigured = (d) => [
|
|
60
|
+
"Width",
|
|
61
|
+
"Color",
|
|
62
|
+
"Style"
|
|
63
|
+
].some((key) => hasValue(props.model?.[`border${d}${key}`]));
|
|
57
64
|
const change = (value, eventData) => {
|
|
58
65
|
eventData.changeRecords?.forEach((record) => {
|
|
59
66
|
emit("change", record.value, { modifyKey: record.propPath });
|
|
@@ -63,25 +70,40 @@ var Border_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineC
|
|
|
63
70
|
return (_ctx, _cache) => {
|
|
64
71
|
return openBlock(), createElementBlock("div", _hoisted_1, [createElementVNode("div", _hoisted_2, [
|
|
65
72
|
createElementVNode("div", _hoisted_3, [createElementVNode("div", {
|
|
66
|
-
class: normalizeClass(["border-icon border-icon-top", {
|
|
73
|
+
class: normalizeClass(["border-icon border-icon-top", {
|
|
74
|
+
active: direction.value === "Top",
|
|
75
|
+
configured: isConfigured("Top")
|
|
76
|
+
}]),
|
|
67
77
|
onClick: _cache[0] || (_cache[0] = ($event) => selectDirection("Top"))
|
|
68
78
|
}, null, 2)]),
|
|
69
79
|
createElementVNode("div", _hoisted_4, [
|
|
70
80
|
createElementVNode("div", {
|
|
71
|
-
class: normalizeClass(["border-icon border-icon-left", {
|
|
81
|
+
class: normalizeClass(["border-icon border-icon-left", {
|
|
82
|
+
active: direction.value === "Left",
|
|
83
|
+
configured: isConfigured("Left")
|
|
84
|
+
}]),
|
|
72
85
|
onClick: _cache[1] || (_cache[1] = ($event) => selectDirection("Left"))
|
|
73
86
|
}, null, 2),
|
|
74
87
|
createElementVNode("div", {
|
|
75
|
-
class: normalizeClass(["border-icon", {
|
|
88
|
+
class: normalizeClass(["border-icon", {
|
|
89
|
+
active: direction.value === "",
|
|
90
|
+
configured: isConfigured("")
|
|
91
|
+
}]),
|
|
76
92
|
onClick: _cache[2] || (_cache[2] = ($event) => selectDirection())
|
|
77
93
|
}, null, 2),
|
|
78
94
|
createElementVNode("div", {
|
|
79
|
-
class: normalizeClass(["border-icon border-icon-right", {
|
|
95
|
+
class: normalizeClass(["border-icon border-icon-right", {
|
|
96
|
+
active: direction.value === "Right",
|
|
97
|
+
configured: isConfigured("Right")
|
|
98
|
+
}]),
|
|
80
99
|
onClick: _cache[3] || (_cache[3] = ($event) => selectDirection("Right"))
|
|
81
100
|
}, null, 2)
|
|
82
101
|
]),
|
|
83
102
|
createElementVNode("div", _hoisted_5, [createElementVNode("div", {
|
|
84
|
-
class: normalizeClass(["border-icon border-icon-bottom", {
|
|
103
|
+
class: normalizeClass(["border-icon border-icon-bottom", {
|
|
104
|
+
active: direction.value === "Bottom",
|
|
105
|
+
configured: isConfigured("Bottom")
|
|
106
|
+
}]),
|
|
85
107
|
onClick: _cache[4] || (_cache[4] = ($event) => selectDirection("Bottom"))
|
|
86
108
|
}, null, 2)])
|
|
87
109
|
]), createElementVNode("div", _hoisted_6, [createVNode(unref(MContainer), {
|
package/dist/es/index.js
CHANGED
|
@@ -4,7 +4,7 @@ import { advancedTabConfig, arrayOptions, displayTabConfig, eqOptions, eventTabC
|
|
|
4
4
|
import props_default from "./services/props.js";
|
|
5
5
|
import { getEditorConfig, setEditorConfig } from "./utils/config.js";
|
|
6
6
|
import { UndoRedo } from "./utils/undo-redo.js";
|
|
7
|
-
import { createStackStep, describeRevertStep, deserializeStacks, detectPageTargetId, detectPageTargetName, detectStackOpType, getOrCreateStack, markStackSaved, mergePageSteps, mergeStackSteps, serializeStacks, undoFloor } from "./utils/history.js";
|
|
7
|
+
import { createStackStep, describeRevertStep, deserializeStacks, detectPageTargetId, detectPageTargetName, detectStackOpType, getLastPushedHistoryIds, getOrCreateStack, markStackSaved, mergePageSteps, mergeStackSteps, serializeStacks, undoFloor } from "./utils/history.js";
|
|
8
8
|
import { idbDelete, idbGet, idbSet, isIndexedDBSupported, openIndexedDB } from "./utils/indexed-db.js";
|
|
9
9
|
import history_default from "./services/history.js";
|
|
10
10
|
import storage_default from "./services/storage.js";
|
|
@@ -83,4 +83,4 @@ export * from "@tmagic/table";
|
|
|
83
83
|
export * from "@tmagic/stage";
|
|
84
84
|
export * from "@tmagic/design";
|
|
85
85
|
export * from "@tmagic/utils";
|
|
86
|
-
export { 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, 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, 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, advancedTabConfig, arrayOptions, beforePaste, buildChangeRecords, calcAlignCenterStyle, calcLayerTargetIndex, calcMoveStyle, canUsePluginMethods, change2Fixed, classifyDragSources, codeBlock_default as codeBlockService, collectRelatedNodes, createStackStep, dataSource_default as dataSourceService, debug, plugin_default as default, defaultIsExpandable, dep_default as depService, describeRevertStep, describeStepForRevert, deserializeStacks, designPlugin, detectPageTargetId, detectPageTargetName, detectStackOpType, displayTabConfig, editorNodeMergeCustomizer, editor_default as editorService, eqOptions, error, eventTabConfig, events_default as eventsService, fillConfig, fixNodeLeft, fixNodePosition, formPlugin, generatePageName, generatePageNameByApp, getAddParent, getCascaderOptionsFromFields, getCodeBlockFormConfig, getDefaultConfig, getDisplayField, getEditorConfig, getFieldType, getFormConfig, getFormValue, getGuideLineFromCache, getInitPositionStyle, getNodeIndex, getOrCreateStack, getPageFragmentList, getPageList, getPageNameList, getPositionInContainer, getRelativeStyle, history_default as historyService, idbDelete, idbGet, idbSet, info, isIncludeDataSource, isIndexedDBSupported, monaco_editor_default as loadMonaco, log, markStackSaved, mergePageSteps, mergeStackSteps, moveItemsInContainer, numberOptions, openIndexedDB, props_default as propsService, resolveSelectedNode, serializeConfig, serializeStacks, setChildrenLayout, setEditorConfig, setLayout, stageOverlay_default as stageOverlayService, storage_default as storageService, styleTabConfig, tablePlugin, toggleFixedPosition, ui_default as uiService, undoFloor, updateStatus, useCodeBlockEdit, useEditorContentHeight, useFilter, useFloatBox, useGetSo, useNextFloatBoxPosition, useNodeStatus, useServices, useStage, useWindowRect, warn };
|
|
86
|
+
export { 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, 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, 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, advancedTabConfig, arrayOptions, beforePaste, buildChangeRecords, calcAlignCenterStyle, calcLayerTargetIndex, calcMoveStyle, canUsePluginMethods, change2Fixed, classifyDragSources, codeBlock_default as codeBlockService, collectRelatedNodes, createStackStep, dataSource_default as dataSourceService, debug, plugin_default as default, defaultIsExpandable, dep_default as depService, describeRevertStep, describeStepForRevert, deserializeStacks, designPlugin, detectPageTargetId, detectPageTargetName, detectStackOpType, displayTabConfig, editorNodeMergeCustomizer, editor_default as editorService, eqOptions, error, eventTabConfig, events_default as eventsService, fillConfig, fixNodeLeft, fixNodePosition, formPlugin, generatePageName, generatePageNameByApp, getAddParent, getCascaderOptionsFromFields, getCodeBlockFormConfig, getDefaultConfig, getDisplayField, getEditorConfig, getFieldType, getFormConfig, getFormValue, getGuideLineFromCache, getInitPositionStyle, getLastPushedHistoryIds, getNodeIndex, getOrCreateStack, getPageFragmentList, getPageList, getPageNameList, getPositionInContainer, getRelativeStyle, history_default as historyService, idbDelete, idbGet, idbSet, info, isIncludeDataSource, isIndexedDBSupported, monaco_editor_default as loadMonaco, log, markStackSaved, mergePageSteps, mergeStackSteps, moveItemsInContainer, numberOptions, openIndexedDB, props_default as propsService, resolveSelectedNode, serializeConfig, serializeStacks, setChildrenLayout, setEditorConfig, setLayout, stageOverlay_default as stageOverlayService, storage_default as storageService, styleTabConfig, tablePlugin, toggleFixedPosition, ui_default as uiService, undoFloor, updateStatus, useCodeBlockEdit, useEditorContentHeight, useFilter, useFloatBox, useGetSo, useNextFloatBoxPosition, useNodeStatus, useServices, useStage, useWindowRect, warn };
|
package/dist/es/layouts/history-list/HistoryListPanel.vue_vue_type_script_setup_true_lang.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useServices } from "../../hooks/use-services.js";
|
|
2
2
|
import Icon_default from "../../components/Icon.js";
|
|
3
|
-
import {
|
|
3
|
+
import { describeStep, isSingleDiffStepRevertable, useHistoryList } from "./composables.js";
|
|
4
4
|
import BucketTab_default from "./BucketTab.js";
|
|
5
5
|
import HistoryDiffDialog_default from "./HistoryDiffDialog.js";
|
|
6
6
|
import PageTab_default from "./PageTab.js";
|
|
@@ -22,8 +22,8 @@ var HistoryListPanel_vue_vue_type_script_setup_true_lang_default = /* @__PURE__
|
|
|
22
22
|
/**
|
|
23
23
|
* 历史记录面板:在顶部 NavMenu 上点击图标打开 popover,分三个 tab:
|
|
24
24
|
* - 页面:当前活动页面的历史栈,连续修改同一节点的多步会被合并成一组
|
|
25
|
-
* - 数据源:以 dataSource.id
|
|
26
|
-
* - 代码块:同上,按 codeBlock.id
|
|
25
|
+
* - 数据源:以 dataSource.id 分桶,每条操作记录独立展示
|
|
26
|
+
* - 代码块:同上,按 codeBlock.id 分桶,每条操作记录独立展示
|
|
27
27
|
*
|
|
28
28
|
* 数据通过 historyService 暴露的聚合 API 读取,UI 仅用于只读展示,
|
|
29
29
|
* 同时支持点击任意一条记录跳转至该状态:
|
|
@@ -78,10 +78,8 @@ var HistoryListPanel_vue_vue_type_script_setup_true_lang_default = /* @__PURE__
|
|
|
78
78
|
* 基于 historyService 的 reactive state 派生,活动页切换或标记写入后自动刷新。
|
|
79
79
|
*/
|
|
80
80
|
const pageMarker = computed(() => historyService.getPageMarker());
|
|
81
|
-
/** 数据源 step 仅 update(前后 schema 都存在)时可查看差异。 */
|
|
82
|
-
const isDataSourceStepDiffable = (step) => Boolean(step.diff?.[0]?.oldSchema && step.diff?.[0]?.newSchema);
|
|
83
81
|
/** 代码块 step 仅 update(前后 content 都存在)时可查看差异。 */
|
|
84
|
-
const
|
|
82
|
+
const isStepDiffable = (step) => Boolean(step.diff?.[0]?.oldSchema && step.diff?.[0]?.newSchema);
|
|
85
83
|
/**
|
|
86
84
|
* 数据源 / 代码块两类 bucket 历史的整体渲染配置:把 title / prefix 与各自的描述、
|
|
87
85
|
* 可差异、可回滚判定收敛为单一对象整体注入 BucketTab,组件内部按需读取。
|
|
@@ -89,18 +87,16 @@ var HistoryListPanel_vue_vue_type_script_setup_true_lang_default = /* @__PURE__
|
|
|
89
87
|
const dataSourceConfig = {
|
|
90
88
|
title: "数据源",
|
|
91
89
|
prefix: "ds",
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
isStepRevertable: isDataSourceStepRevertable
|
|
90
|
+
describeStep: (step) => describeStep(step, (schema) => schema?.title, "数据源"),
|
|
91
|
+
isStepDiffable,
|
|
92
|
+
isStepRevertable: isSingleDiffStepRevertable
|
|
96
93
|
};
|
|
97
94
|
const codeBlockConfig = {
|
|
98
95
|
title: "代码块",
|
|
99
96
|
prefix: "cb",
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
isStepRevertable: isCodeBlockStepRevertable
|
|
97
|
+
describeStep: (step) => describeStep(step, (content) => content?.name, "代码块"),
|
|
98
|
+
isStepDiffable,
|
|
99
|
+
isStepRevertable: isSingleDiffStepRevertable
|
|
104
100
|
};
|
|
105
101
|
/** 把"目标 step 索引"翻译成"目标 cursor"(已应用步骤数量)。 */
|
|
106
102
|
const indexToCursor = (index) => index + 1;
|
|
@@ -5,9 +5,14 @@ var _hoisted_1 = ["title"];
|
|
|
5
5
|
var _hoisted_2 = { class: "m-editor-history-list-item-desc" };
|
|
6
6
|
var _hoisted_3 = {
|
|
7
7
|
key: 0,
|
|
8
|
+
class: "m-editor-history-list-item-saved",
|
|
9
|
+
title: "该记录为最近一次保存的状态"
|
|
10
|
+
};
|
|
11
|
+
var _hoisted_4 = {
|
|
12
|
+
key: 1,
|
|
8
13
|
class: "m-editor-history-list-item-actions"
|
|
9
14
|
};
|
|
10
|
-
var
|
|
15
|
+
var _hoisted_5 = ["title"];
|
|
11
16
|
var InitialRow_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineComponent({
|
|
12
17
|
name: "MEditorHistoryListInitialRow",
|
|
13
18
|
__name: "InitialRow",
|
|
@@ -32,6 +37,8 @@ var InitialRow_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ def
|
|
|
32
37
|
*/
|
|
33
38
|
const props = __props;
|
|
34
39
|
const desc = computed(() => props.marker?.historyDescription || "未修改的初始状态");
|
|
40
|
+
/** 基线(初始状态)是否为最近一次保存点:仅页面栈的 `initial` 基线 step 会被 markSaved 标记。 */
|
|
41
|
+
const saved = computed(() => Boolean(props.marker?.saved));
|
|
35
42
|
const time = computed(() => formatHistoryTime(props.marker?.timestamp));
|
|
36
43
|
const timeTitle = computed(() => formatHistoryFullTime(props.marker?.timestamp));
|
|
37
44
|
const rowTitle = computed(() => {
|
|
@@ -57,16 +64,17 @@ var InitialRow_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ def
|
|
|
57
64
|
}, "#0", -1)),
|
|
58
65
|
_cache[1] || (_cache[1] = createElementVNode("span", { class: "m-editor-history-list-item-op op-initial" }, "初始", -1)),
|
|
59
66
|
createElementVNode("span", _hoisted_2, toDisplayString(desc.value), 1),
|
|
60
|
-
|
|
67
|
+
saved.value ? (openBlock(), createElementBlock("span", _hoisted_3, "已保存")) : createCommentVNode("v-if", true),
|
|
68
|
+
__props.gotoEnabled && !__props.isCurrent ? (openBlock(), createElementBlock("span", _hoisted_4, [createElementVNode("span", {
|
|
61
69
|
class: "m-editor-history-list-item-goto",
|
|
62
70
|
title: "回到该记录",
|
|
63
71
|
onClick: withModifiers(onClick, ["stop"])
|
|
64
72
|
}, "回到")])) : createCommentVNode("v-if", true),
|
|
65
73
|
time.value ? (openBlock(), createElementBlock("span", {
|
|
66
|
-
key:
|
|
74
|
+
key: 2,
|
|
67
75
|
class: "m-editor-history-list-item-time",
|
|
68
76
|
title: timeTitle.value
|
|
69
|
-
}, toDisplayString(time.value), 9,
|
|
77
|
+
}, toDisplayString(time.value), 9, _hoisted_5)) : createCommentVNode("v-if", true)
|
|
70
78
|
], 10, _hoisted_1);
|
|
71
79
|
};
|
|
72
80
|
}
|
|
@@ -109,12 +109,13 @@ var groupSource = (group) => group.steps[group.steps.length - 1]?.step.source;
|
|
|
109
109
|
var toRowGroup = (group, key, descriptor) => {
|
|
110
110
|
const { describeGroup, describeStep, isStepDiffable, isStepRevertable } = descriptor;
|
|
111
111
|
const timestamp = groupTimestamp(group);
|
|
112
|
+
const lastStep = group.steps[group.steps.length - 1]?.step;
|
|
112
113
|
return {
|
|
113
114
|
key,
|
|
114
115
|
applied: group.applied,
|
|
115
116
|
isCurrent: Boolean(group.isCurrent),
|
|
116
117
|
opType: group.opType,
|
|
117
|
-
desc: describeGroup(group),
|
|
118
|
+
desc: describeGroup ? describeGroup(group) : describeStep(lastStep),
|
|
118
119
|
source: groupSource(group),
|
|
119
120
|
time: formatHistoryTime(timestamp),
|
|
120
121
|
timeTitle: formatHistoryFullTime(timestamp),
|
|
@@ -147,28 +148,36 @@ var labelWithId = (label, id) => {
|
|
|
147
148
|
var pickLastDescription = (descs) => {
|
|
148
149
|
for (let i = descs.length - 1; i >= 0; i--) if (descs[i]) return descs[i];
|
|
149
150
|
};
|
|
150
|
-
|
|
151
|
+
/**
|
|
152
|
+
* 页面 / 数据源 / 代码块三类历史共用的单步描述核心。
|
|
153
|
+
* 各类型只在「取展示名」与「实体单位名」上有差异,通过参数注入,文案模板完全一致:
|
|
154
|
+
* - 新增 / 删除:单实体展示「label」,多实体(仅页面可能出现)退化为「N 个X」;
|
|
155
|
+
* - 修改:展示「label · propPath」,无 diff 时兜底「X」,多实体退化为「N 个X」。
|
|
156
|
+
* 操作类型(新增 / 删除 / 修改)已由列表行的 op 徽标单独展示,故描述文案不再重复动词。
|
|
157
|
+
* 展示 id 统一取 schema.id;调用方显式传入的 historyDescription 永远优先。
|
|
158
|
+
*/
|
|
159
|
+
var describeStep = (step, getLabel, unit) => {
|
|
151
160
|
if (step.historyDescription) return step.historyDescription;
|
|
152
|
-
const { opType } = step;
|
|
153
161
|
const items = step.diff ?? [];
|
|
154
|
-
|
|
155
|
-
|
|
162
|
+
const label = (schema) => labelWithId(getLabel(schema), schema?.id);
|
|
163
|
+
if (step.opType === "add") {
|
|
156
164
|
const node = items[0]?.newSchema;
|
|
157
|
-
return
|
|
165
|
+
return items.length === 1 && node ? label(node) : `${items.length} 个${unit}`;
|
|
158
166
|
}
|
|
159
|
-
if (opType === "remove") {
|
|
160
|
-
const count = items.length;
|
|
167
|
+
if (step.opType === "remove") {
|
|
161
168
|
const node = items[0]?.oldSchema;
|
|
162
|
-
return
|
|
169
|
+
return items.length === 1 && node ? label(node) : `${items.length} 个${unit}`;
|
|
163
170
|
}
|
|
164
|
-
if (!items.length) return
|
|
171
|
+
if (!items.length) return unit;
|
|
165
172
|
if (items.length === 1) {
|
|
166
|
-
const { newSchema, changeRecords } = items[0];
|
|
167
|
-
const propPath = changeRecords?.
|
|
168
|
-
|
|
173
|
+
const { newSchema, oldSchema, changeRecords } = items[0];
|
|
174
|
+
const propPath = changeRecords?.map((changeRecord) => changeRecord.propPath).join(",");
|
|
175
|
+
const target = label(newSchema ?? oldSchema);
|
|
176
|
+
return propPath ? `${target} · ${propPath}` : target;
|
|
169
177
|
}
|
|
170
|
-
return
|
|
178
|
+
return `${items.length} 个${unit}`;
|
|
171
179
|
};
|
|
180
|
+
var describePageStep = (step) => describeStep(step, (node) => nameOf(node), "节点");
|
|
172
181
|
/**
|
|
173
182
|
* 合并组的展示文案:
|
|
174
183
|
* - 若组内任一步显式提供了 historyDescription:取最后一条非空 historyDescription(最近一次的描述更准确);
|
|
@@ -179,55 +188,7 @@ var describePageGroup = (group) => {
|
|
|
179
188
|
const lastDesc = pickLastDescription(group.steps.map((s) => s.step.historyDescription));
|
|
180
189
|
if (lastDesc) return lastDesc;
|
|
181
190
|
if (group.steps.length === 1) return describePageStep(group.steps[0].step);
|
|
182
|
-
|
|
183
|
-
group.steps.forEach((s) => {
|
|
184
|
-
s.step.diff?.[0]?.changeRecords?.forEach((r) => r.propPath && paths.add(r.propPath));
|
|
185
|
-
});
|
|
186
|
-
const pathList = Array.from(paths).slice(0, 3).join(", ");
|
|
187
|
-
const target = labelWithId(group.targetName ?? (group.targetId !== void 0 ? `${group.targetId}` : "节点"), group.targetId);
|
|
188
|
-
return pathList ? `修改 ${target} · ${pathList}${paths.size > 3 ? "…" : ""}` : `修改 ${target}`;
|
|
189
|
-
};
|
|
190
|
-
var describeDataSourceStep = (step) => {
|
|
191
|
-
if (step.historyDescription) return step.historyDescription;
|
|
192
|
-
const { oldSchema, newSchema, changeRecords } = step.diff?.[0] ?? {};
|
|
193
|
-
if (!oldSchema && newSchema) return `创建 ${labelWithId(newSchema.title, newSchema.id ?? step.id)}`;
|
|
194
|
-
if (!newSchema && oldSchema) return `删除 ${labelWithId(oldSchema.title, oldSchema.id ?? step.id)}`;
|
|
195
|
-
const propPath = changeRecords?.[0]?.propPath;
|
|
196
|
-
const title = labelWithId(newSchema?.title || oldSchema?.title, step.id);
|
|
197
|
-
return propPath ? `修改 ${title} · ${propPath}` : `修改 ${title}`;
|
|
198
|
-
};
|
|
199
|
-
var describeDataSourceGroup = (group) => {
|
|
200
|
-
const lastDesc = pickLastDescription(group.steps.map((s) => s.step.historyDescription));
|
|
201
|
-
if (lastDesc) return lastDesc;
|
|
202
|
-
if (group.steps.length === 1) return describeDataSourceStep(group.steps[0].step);
|
|
203
|
-
const paths = /* @__PURE__ */ new Set();
|
|
204
|
-
group.steps.forEach((s) => {
|
|
205
|
-
s.step.diff?.[0]?.changeRecords?.forEach((r) => r.propPath && paths.add(r.propPath));
|
|
206
|
-
});
|
|
207
|
-
const pathList = Array.from(paths).slice(0, 3).join(", ");
|
|
208
|
-
const target = labelWithId(group.steps[group.steps.length - 1].step.diff?.[0]?.newSchema?.title || group.steps[0].step.diff?.[0]?.oldSchema?.title, group.id);
|
|
209
|
-
return pathList ? `修改 ${target} · ${pathList}${paths.size > 3 ? "…" : ""}` : `修改 ${target}`;
|
|
210
|
-
};
|
|
211
|
-
var describeCodeBlockStep = (step) => {
|
|
212
|
-
if (step.historyDescription) return step.historyDescription;
|
|
213
|
-
const { oldSchema: oldContent, newSchema: newContent, changeRecords } = step.diff?.[0] ?? {};
|
|
214
|
-
if (!oldContent && newContent) return `创建 ${labelWithId(newContent.name, newContent.id ?? step.id)}`;
|
|
215
|
-
if (!newContent && oldContent) return `删除 ${labelWithId(oldContent.name, oldContent.id ?? step.id)}`;
|
|
216
|
-
const propPath = changeRecords?.[0]?.propPath;
|
|
217
|
-
const title = labelWithId(newContent?.name || oldContent?.name, step.id);
|
|
218
|
-
return propPath ? `修改 ${title} · ${propPath}` : `修改 ${title}`;
|
|
219
|
-
};
|
|
220
|
-
var describeCodeBlockGroup = (group) => {
|
|
221
|
-
const lastDesc = pickLastDescription(group.steps.map((s) => s.step.historyDescription));
|
|
222
|
-
if (lastDesc) return lastDesc;
|
|
223
|
-
if (group.steps.length === 1) return describeCodeBlockStep(group.steps[0].step);
|
|
224
|
-
const paths = /* @__PURE__ */ new Set();
|
|
225
|
-
group.steps.forEach((s) => {
|
|
226
|
-
s.step.diff?.[0]?.changeRecords?.forEach((r) => r.propPath && paths.add(r.propPath));
|
|
227
|
-
});
|
|
228
|
-
const pathList = Array.from(paths).slice(0, 3).join(", ");
|
|
229
|
-
const target = labelWithId(group.steps[group.steps.length - 1].step.diff?.[0]?.newSchema?.name || group.steps[0].step.diff?.[0]?.oldSchema?.name, group.id);
|
|
230
|
-
return pathList ? `修改 ${target} · ${pathList}${paths.size > 3 ? "…" : ""}` : `修改 ${target}`;
|
|
191
|
+
return labelWithId(group.targetName ?? (group.targetId !== void 0 ? `${group.targetId}` : "节点"), group.targetId);
|
|
231
192
|
};
|
|
232
193
|
/**
|
|
233
194
|
* 页面 step 是否支持「回滚」(类 git revert):
|
|
@@ -242,24 +203,14 @@ var isPageStepRevertable = (step) => {
|
|
|
242
203
|
return items.every((item) => Boolean(item.changeRecords?.length));
|
|
243
204
|
};
|
|
244
205
|
/**
|
|
245
|
-
*
|
|
246
|
-
* - 新增(无 oldSchema)/ 删除(无 newSchema):不依赖 changeRecords,始终可回滚;
|
|
247
|
-
* - 更新(前后 schema 都存在):必须有 changeRecords 才支持局部反向 patch,否则不支持回滚。
|
|
248
|
-
*/
|
|
249
|
-
var isDataSourceStepRevertable = (step) => {
|
|
250
|
-
const item = step.diff?.[0];
|
|
251
|
-
if (!item?.oldSchema || !item?.newSchema) return true;
|
|
252
|
-
return Boolean(item.changeRecords?.length);
|
|
253
|
-
};
|
|
254
|
-
/**
|
|
255
|
-
* 代码块 step 是否支持「回滚」:
|
|
206
|
+
* 单 diff 项历史(数据源 / 代码块)是否支持「回滚」:
|
|
256
207
|
* - 新增(无 oldSchema)/ 删除(无 newSchema):不依赖 changeRecords,始终可回滚;
|
|
257
|
-
* -
|
|
208
|
+
* - 更新(前后内容都存在):必须有 changeRecords 才支持局部反向 patch,否则不支持回滚。
|
|
258
209
|
*/
|
|
259
|
-
var
|
|
210
|
+
var isSingleDiffStepRevertable = (step) => {
|
|
260
211
|
const item = step.diff?.[0];
|
|
261
212
|
if (!item?.oldSchema || !item?.newSchema) return true;
|
|
262
213
|
return Boolean(item.changeRecords?.length);
|
|
263
214
|
};
|
|
264
215
|
//#endregion
|
|
265
|
-
export {
|
|
216
|
+
export { describePageGroup, describePageStep, describeStep, formatHistoryFullTime, formatHistoryTime, isHistoryGroupExpanded, isPageStepRevertable, isSingleDiffStepRevertable, opLabel, sourceLabel, toRowGroup, useHistoryList };
|
|
@@ -87,7 +87,7 @@ var Sidebar_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ define
|
|
|
87
87
|
slots: {}
|
|
88
88
|
},
|
|
89
89
|
layer: {
|
|
90
|
-
$key:
|
|
90
|
+
$key: SideItemKey.LAYER,
|
|
91
91
|
type: "component",
|
|
92
92
|
icon: List,
|
|
93
93
|
text: "已选组件",
|
|
@@ -105,7 +105,7 @@ var Sidebar_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ define
|
|
|
105
105
|
slots: {}
|
|
106
106
|
},
|
|
107
107
|
[SideItemKey.CODE_BLOCK]: {
|
|
108
|
-
$key:
|
|
108
|
+
$key: SideItemKey.CODE_BLOCK,
|
|
109
109
|
type: "component",
|
|
110
110
|
icon: EditPen,
|
|
111
111
|
text: "代码编辑",
|
|
@@ -4,7 +4,7 @@ import { useNextFloatBoxPosition } from "../../../hooks/use-next-float-box-posit
|
|
|
4
4
|
import FloatingBox_default from "../../../components/FloatingBox.js";
|
|
5
5
|
import { MFormBox } from "@tmagic/form";
|
|
6
6
|
import { tMagicMessage } from "@tmagic/design";
|
|
7
|
-
import { createBlock, createVNode, defineComponent, inject, isRef, mergeModels, nextTick, openBlock, ref, unref, useModel, watch, watchEffect, withCtx } from "vue";
|
|
7
|
+
import { computed, createBlock, createVNode, defineComponent, inject, isRef, mergeModels, nextTick, openBlock, provide, ref, unref, useModel, watch, watchEffect, withCtx } from "vue";
|
|
8
8
|
//#region packages/editor/src/layouts/sidebar/data-source/DataSourceConfigPanel.vue?vue&type=script&setup=true&lang.ts
|
|
9
9
|
var DataSourceConfigPanel_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineComponent({
|
|
10
10
|
name: "MEditorDataSourceConfigPanel",
|
|
@@ -12,7 +12,9 @@ var DataSourceConfigPanel_vue_vue_type_script_setup_true_lang_default = /* @__PU
|
|
|
12
12
|
props: /* @__PURE__ */ mergeModels({
|
|
13
13
|
title: {},
|
|
14
14
|
values: {},
|
|
15
|
-
disabled: { type: Boolean }
|
|
15
|
+
disabled: { type: Boolean },
|
|
16
|
+
editMethodName: {},
|
|
17
|
+
editFieldPath: {}
|
|
16
18
|
}, {
|
|
17
19
|
"visible": {
|
|
18
20
|
type: Boolean,
|
|
@@ -37,9 +39,20 @@ var DataSourceConfigPanel_vue_vue_type_script_setup_true_lang_default = /* @__PU
|
|
|
37
39
|
const dataSourceConfig = ref([]);
|
|
38
40
|
const { height: editorHeight } = useEditorContentHeight();
|
|
39
41
|
const { boxPosition, calcBoxPosition } = useNextFloatBoxPosition(uiService, inject("parentFloating", ref(null)));
|
|
42
|
+
/** 供「方法定义」tab 内的字段消费,用于打开数据源详情后自动打开指定方法 */
|
|
43
|
+
provide("editingDataSourceMethodName", computed(() => props.editMethodName));
|
|
44
|
+
/** 供「数据定义」tab 内的字段消费,用于打开数据源详情后自动打开指定字段 */
|
|
45
|
+
provide("editingDataSourceFieldPath", computed(() => props.editFieldPath || []));
|
|
40
46
|
watchEffect(() => {
|
|
41
47
|
initValues.value = props.values;
|
|
42
|
-
|
|
48
|
+
const config = dataSourceService.getFormConfig(initValues.value.type);
|
|
49
|
+
let activeTab = "fields";
|
|
50
|
+
if (props.editMethodName) activeTab = "methods";
|
|
51
|
+
else if (props.editFieldPath?.length) activeTab = "fields";
|
|
52
|
+
dataSourceConfig.value = config.map((item) => item.type === "tab" ? {
|
|
53
|
+
...item,
|
|
54
|
+
active: activeTab
|
|
55
|
+
} : item);
|
|
43
56
|
});
|
|
44
57
|
const submitHandler = (values, data) => {
|
|
45
58
|
emit("submit", values, data);
|