@tmagic/editor 1.8.6 → 1.8.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/layouts/history-list/Bucket.vue.js +20 -4
- package/dist/es/layouts/history-list/BucketTab.vue.js +7 -2
- package/dist/es/layouts/history-list/HistoryListPanel.vue.js +18 -0
- package/dist/es/layouts/history-list/InitialRow.vue.js +15 -4
- package/dist/es/layouts/history-list/PageTab.vue.js +16 -4
- package/dist/es/sdk/services/Editor.js +56 -23
- package/dist/es/sdk/services/History.js +44 -6
- package/dist/es/utils/history.js +27 -8
- package/dist/es/utils/undo-redo.js +57 -9
- package/dist/tmagic-editor-headless.umd.cjs +184 -46
- package/dist/tmagic-editor-sdk.umd.cjs +184 -46
- package/dist/tmagic-editor.umd.cjs +260 -60
- package/package.json +7 -7
- package/src/layouts/history-list/Bucket.vue +30 -16
- package/src/layouts/history-list/BucketTab.vue +8 -1
- package/src/layouts/history-list/HistoryListPanel.vue +27 -0
- package/src/layouts/history-list/InitialRow.vue +17 -5
- package/src/layouts/history-list/PageTab.vue +32 -18
- package/src/sdk/services/Editor.ts +50 -22
- package/src/sdk/services/History.ts +58 -11
- package/src/type.ts +17 -3
- package/src/utils/history.ts +35 -10
- package/src/utils/undo-redo.ts +76 -12
- package/types/index.d.ts +97 -16
- package/types/sdk.d.ts +76 -16
|
@@ -5640,6 +5640,13 @@
|
|
|
5640
5640
|
}));
|
|
5641
5641
|
// packages/editor/src/utils/undo-redo.ts
|
|
5642
5642
|
init_lodash();
|
|
5643
|
+
/** 各历史栈 index 0 的 initial 是撤销下限(见 utils/history.ts 的 undoFloor),裁剪时不能把它挤掉。 */
|
|
5644
|
+
var isInitialStep = (step) => step?.opType === "initial";
|
|
5645
|
+
/**
|
|
5646
|
+
* 容量按「真实步骤数」计算:index 0 的 initial 基线额外占一个位置,不挤掉真实记录。
|
|
5647
|
+
* 只要真实步骤没超限,最老一条的 oldSchema 仍指向加载时的 DSL,「回到初始」就是可达的。
|
|
5648
|
+
*/
|
|
5649
|
+
var maxLength = (list, listMaxSize) => listMaxSize + (isInitialStep(list[0]) ? 1 : 0);
|
|
5643
5650
|
var UndoRedo = class UndoRedo {
|
|
5644
5651
|
/**
|
|
5645
5652
|
* 由 {@link UndoRedo.serialize} 产出的快照重建一个 UndoRedo 实例。
|
|
@@ -5650,13 +5657,9 @@
|
|
|
5650
5657
|
*/
|
|
5651
5658
|
static fromSerialized(data, options = {}) {
|
|
5652
5659
|
const undoRedo = new UndoRedo(data.listMaxSize);
|
|
5660
|
+
undoRedo.initialReachable = data.initialReachable !== false;
|
|
5653
5661
|
const list = Array.isArray(data.elementList) ? data.elementList.map((item) => cloneDeep$1(item)) : [];
|
|
5654
5662
|
let cursor = Number.isFinite(data.listCursor) ? data.listCursor : list.length;
|
|
5655
|
-
const overflow = list.length - undoRedo.listMaxSize;
|
|
5656
|
-
if (overflow > 0) {
|
|
5657
|
-
list.splice(0, overflow);
|
|
5658
|
-
cursor -= overflow;
|
|
5659
|
-
}
|
|
5660
5663
|
if (options.isSavedStep) {
|
|
5661
5664
|
for (let i = list.length - 1; i >= 0; i--) if (options.isSavedStep(list[i])) {
|
|
5662
5665
|
cursor = i + 1;
|
|
@@ -5670,7 +5673,9 @@
|
|
|
5670
5673
|
elementList;
|
|
5671
5674
|
listCursor;
|
|
5672
5675
|
listMaxSize;
|
|
5673
|
-
|
|
5676
|
+
/** 容量裁剪是否删掉过已应用的真实步骤(撤销链已断,「回到初始」不可达)。 */
|
|
5677
|
+
initialReachable = true;
|
|
5678
|
+
constructor(listMaxSize = 1e3) {
|
|
5674
5679
|
const minListMaxSize = 2;
|
|
5675
5680
|
this.elementList = [];
|
|
5676
5681
|
this.listCursor = 0;
|
|
@@ -5684,16 +5689,55 @@
|
|
|
5684
5689
|
return {
|
|
5685
5690
|
elementList: this.elementList.map((item) => cloneDeep$1(item)),
|
|
5686
5691
|
listCursor: this.listCursor,
|
|
5687
|
-
listMaxSize: this.listMaxSize
|
|
5692
|
+
listMaxSize: this.listMaxSize,
|
|
5693
|
+
initialReachable: this.initialReachable
|
|
5688
5694
|
};
|
|
5689
5695
|
}
|
|
5690
5696
|
pushElement(element) {
|
|
5691
5697
|
this.elementList.splice(this.listCursor, this.elementList.length - this.listCursor, cloneDeep$1(element));
|
|
5692
5698
|
this.listCursor += 1;
|
|
5693
|
-
|
|
5694
|
-
|
|
5699
|
+
}
|
|
5700
|
+
/**
|
|
5701
|
+
* 把栈裁剪到容量上限(`listMaxSize` 条真实步骤,index 0 的 initial 基线额外占一个位置)。
|
|
5702
|
+
*
|
|
5703
|
+
* 只在保存后调用(见 historyService.markSaved):保存前不裁剪,避免用户还没落库就丢掉可撤销的历史。
|
|
5704
|
+
* **永不删除** initial 基线与「整体设置 root」产生的记录(`rootStep`);
|
|
5705
|
+
* 受保护记录本身占满容量时栈保持超限。
|
|
5706
|
+
*
|
|
5707
|
+
* 分两个阶段删除,保证撤销链与重做链各自连续:
|
|
5708
|
+
* 1. 先从最旧的记录开始删**已应用**区(游标之前)的可删记录,撤销链仍然连续;
|
|
5709
|
+
* 2. 已应用区删无可删仍超限时,溢出量落在重做区。重做链必须连续——后一条是按前一条的 DSL 打的补丁,
|
|
5710
|
+
* 只删掉开头几条会让留下的步骤叠在缺失的基线上,因此整段丢弃游标之后的步骤。
|
|
5711
|
+
* (不从重做区末尾往前删:重做区里可能有受保护的 `rootStep`,跳过它去删它前面的步骤同样会留空洞。)
|
|
5712
|
+
*
|
|
5713
|
+
* 「回到初始」是否仍可达,取决于被删的已应用步骤相对最早一条 `rootStep` 的位置:
|
|
5714
|
+
* - 位于其**之后**:撤销链完整——一直撤销会退到这条整页快照,再撤销它即回到加载时的 DSL,仍可达;
|
|
5715
|
+
* - 位于其**之前**(或栈内没有 `rootStep`):撤到底只能停在中途版本,标记为不可达。
|
|
5716
|
+
* 只删掉重做区记录时不影响可达性。
|
|
5717
|
+
*/
|
|
5718
|
+
trim() {
|
|
5719
|
+
let overflow = this.elementList.length - maxLength(this.elementList, this.listMaxSize);
|
|
5720
|
+
if (overflow <= 0) return;
|
|
5721
|
+
let seenRootStep = false;
|
|
5722
|
+
let brokenChain = false;
|
|
5723
|
+
for (let index = 0; index < this.listCursor && overflow > 0;) {
|
|
5724
|
+
const step = this.elementList[index];
|
|
5725
|
+
if (isInitialStep(step)) {
|
|
5726
|
+
index += 1;
|
|
5727
|
+
continue;
|
|
5728
|
+
}
|
|
5729
|
+
if (step?.rootStep === true) {
|
|
5730
|
+
seenRootStep = true;
|
|
5731
|
+
index += 1;
|
|
5732
|
+
continue;
|
|
5733
|
+
}
|
|
5734
|
+
this.elementList.splice(index, 1);
|
|
5735
|
+
overflow -= 1;
|
|
5695
5736
|
this.listCursor -= 1;
|
|
5737
|
+
if (!seenRootStep) brokenChain = true;
|
|
5696
5738
|
}
|
|
5739
|
+
if (overflow > 0 && this.elementList.length > this.listCursor) this.elementList.length = this.listCursor;
|
|
5740
|
+
if (brokenChain) this.initialReachable = false;
|
|
5697
5741
|
}
|
|
5698
5742
|
canUndo() {
|
|
5699
5743
|
return this.listCursor > 0;
|
|
@@ -5760,6 +5804,10 @@
|
|
|
5760
5804
|
getLength() {
|
|
5761
5805
|
return this.elementList.length;
|
|
5762
5806
|
}
|
|
5807
|
+
/** 「回到初始」是否可达:容量裁剪删掉已应用的真实步骤后撤销链断开,返回 false。 */
|
|
5808
|
+
isInitialReachable() {
|
|
5809
|
+
return this.initialReachable;
|
|
5810
|
+
}
|
|
5763
5811
|
};
|
|
5764
5812
|
// packages/editor/src/utils/history.ts
|
|
5765
5813
|
init_lodash();
|
|
@@ -5824,6 +5872,11 @@
|
|
|
5824
5872
|
extra: payload.extra
|
|
5825
5873
|
};
|
|
5826
5874
|
};
|
|
5875
|
+
/**
|
|
5876
|
+
* 把栈当前游标所在的记录标记为「已保存」,随后把栈裁剪到容量上限(见 {@link UndoRedo.trim})。
|
|
5877
|
+
* 入栈与还原都不裁剪,只有保存后才收敛,避免用户在落库前丢掉可撤销的历史;
|
|
5878
|
+
* initial 基线与「整体设置 root」产生的记录(`rootStep`)不会被裁掉。
|
|
5879
|
+
*/
|
|
5827
5880
|
var markStackSaved = (undoRedo) => {
|
|
5828
5881
|
if (!undoRedo) return;
|
|
5829
5882
|
undoRedo.updateElements((element) => {
|
|
@@ -5832,6 +5885,7 @@
|
|
|
5832
5885
|
undoRedo.updateCurrentElement((element) => {
|
|
5833
5886
|
element.saved = true;
|
|
5834
5887
|
});
|
|
5888
|
+
undoRedo.trim();
|
|
5835
5889
|
};
|
|
5836
5890
|
/**
|
|
5837
5891
|
* 把单个历史栈(页面 / 代码块 / 数据源 / 扩展类型)的步骤列表按"目标"做相邻合并:
|
|
@@ -5943,20 +5997,33 @@
|
|
|
5943
5997
|
*
|
|
5944
5998
|
* 与 {@link serializeStacks} 相反:当传入 `parse`(parseDSL)时,把每条 step 中以字符串形式存储的 `diff`
|
|
5945
5999
|
* 解析回真实对象(含函数);不含 `diff` 的元素(如通用栈)原样透传。
|
|
6000
|
+
*
|
|
6001
|
+
* 单个栈解析失败只丢弃该栈,其余栈照常还原:一条损坏的快照不应该让整份本地历史都不可用。
|
|
6002
|
+
* 结构性损坏(`elementList` 不是数组)同样按空栈处理,交给 {@link UndoRedo.fromSerialized} 兜底。
|
|
6003
|
+
* 全部栈都失败时抛出首个错误,避免调用方把「什么都没恢复」当成一次成功的还原。
|
|
5946
6004
|
*/
|
|
5947
6005
|
var deserializeStacks = (stacks = {}, parse) => {
|
|
5948
6006
|
const result = {};
|
|
6007
|
+
let firstError;
|
|
6008
|
+
let failedCount = 0;
|
|
5949
6009
|
Object.entries(stacks).forEach(([id, serialized]) => {
|
|
5950
6010
|
if (!serialized) return;
|
|
5951
|
-
const
|
|
5952
|
-
|
|
5953
|
-
|
|
5954
|
-
|
|
5955
|
-
|
|
5956
|
-
|
|
5957
|
-
|
|
5958
|
-
|
|
6011
|
+
const source = Array.isArray(serialized.elementList) ? serialized.elementList : [];
|
|
6012
|
+
try {
|
|
6013
|
+
const elementList = parse ? source.map((step) => {
|
|
6014
|
+
const { diff } = step;
|
|
6015
|
+
return typeof diff === "string" ? Object.assign({}, step, { diff: parse(`(${diff})`) }) : step;
|
|
6016
|
+
}) : source;
|
|
6017
|
+
result[id] = UndoRedo.fromSerialized({
|
|
6018
|
+
...serialized,
|
|
6019
|
+
elementList
|
|
6020
|
+
}, { isSavedStep: (element) => element.saved === true });
|
|
6021
|
+
} catch (error) {
|
|
6022
|
+
failedCount += 1;
|
|
6023
|
+
firstError ??= error;
|
|
6024
|
+
}
|
|
5959
6025
|
});
|
|
6026
|
+
if (failedCount > 0 && Object.keys(result).length === 0) throw firstError;
|
|
5960
6027
|
return result;
|
|
5961
6028
|
};
|
|
5962
6029
|
/**
|
|
@@ -8155,6 +8222,14 @@
|
|
|
8155
8222
|
init_type();
|
|
8156
8223
|
init_editor();
|
|
8157
8224
|
init_position();
|
|
8225
|
+
/**
|
|
8226
|
+
* 撤销 / 重做回放的内部标记键:不导出,也不出现在公开的 {@link HistoryOpOptions} 里。
|
|
8227
|
+
* 回放链路用它把 `isHistoryOp` 带进 `change` 事件;外部调用方即使传同名字符串字段也不会被读取,
|
|
8228
|
+
* 避免一次真实编辑被误标成历史回放,从而绕过业务侧的加锁 / 埋点 / 自动保存。
|
|
8229
|
+
*/
|
|
8230
|
+
var HISTORY_OP = Symbol("isHistoryOp");
|
|
8231
|
+
/** 读取仅供编辑器内部使用的回放标记。 */
|
|
8232
|
+
var isReplay = (options) => options[HISTORY_OP] === true;
|
|
8158
8233
|
/** 把插入下标收敛到 [0, length]:非整数取整,非法 / 越界(含未记录)一律追加到末尾 */
|
|
8159
8234
|
var clampIndex = (index, length) => {
|
|
8160
8235
|
const normalized = typeof index === "number" ? Math.trunc(index) : length;
|
|
@@ -8469,6 +8544,7 @@
|
|
|
8469
8544
|
async add(addNode, parent, options = {}) {
|
|
8470
8545
|
this.captureSelectionBeforeOp();
|
|
8471
8546
|
const { doNotSelect = false, doNotSwitchPage = false, doNotPushHistory = false, historyDescription, historySource } = options;
|
|
8547
|
+
const isHistoryOp = isReplay(options);
|
|
8472
8548
|
const stage = this.get("stage");
|
|
8473
8549
|
const addNodes = [];
|
|
8474
8550
|
if (!Array.isArray(addNode)) {
|
|
@@ -8546,7 +8622,8 @@
|
|
|
8546
8622
|
page: this.getPageOfNode(node.id)
|
|
8547
8623
|
})),
|
|
8548
8624
|
historySource,
|
|
8549
|
-
doNotPushHistory
|
|
8625
|
+
doNotPushHistory,
|
|
8626
|
+
isHistoryOp
|
|
8550
8627
|
});
|
|
8551
8628
|
const addedPages = newNodes.filter((node) => (0, _tmagic_utils.isPageOrFragment)(node));
|
|
8552
8629
|
if (addedPages.length) this.ctx.history.notifyPageStructureChange({
|
|
@@ -8617,6 +8694,7 @@
|
|
|
8617
8694
|
*/
|
|
8618
8695
|
async remove(nodeOrNodeList, options = {}) {
|
|
8619
8696
|
const { doNotPushHistory = false, historyDescription, historySource } = options;
|
|
8697
|
+
const isHistoryOp = isReplay(options);
|
|
8620
8698
|
this.captureSelectionBeforeOp();
|
|
8621
8699
|
const nodes = Array.isArray(nodeOrNodeList) ? nodeOrNodeList : [nodeOrNodeList];
|
|
8622
8700
|
const changeItems = nodes.map((node) => ({
|
|
@@ -8656,7 +8734,8 @@
|
|
|
8656
8734
|
type: "remove",
|
|
8657
8735
|
data: changeItems,
|
|
8658
8736
|
historySource,
|
|
8659
|
-
doNotPushHistory
|
|
8737
|
+
doNotPushHistory,
|
|
8738
|
+
isHistoryOp
|
|
8660
8739
|
});
|
|
8661
8740
|
const removedPages = nodes.filter((node) => (0, _tmagic_utils.isPageOrFragment)(node));
|
|
8662
8741
|
if (removedPages.length) this.ctx.history.notifyPageStructureChange({
|
|
@@ -8720,6 +8799,7 @@
|
|
|
8720
8799
|
async update(config, data = {}) {
|
|
8721
8800
|
this.captureSelectionBeforeOp();
|
|
8722
8801
|
const { doNotPushHistory = false, changeRecordList, changeRecords, historyDescription, historySource, invalidInfo } = data;
|
|
8802
|
+
const isHistoryOp = isReplay(data);
|
|
8723
8803
|
const nodes = Array.isArray(config) ? config : [config];
|
|
8724
8804
|
const commitInvalid = await this.runGuard(() => this.ctx.validator.guardUpdate(nodes, { replace: data.replace }));
|
|
8725
8805
|
const updateData = await Promise.all(nodes.map((node, index) => {
|
|
@@ -8759,7 +8839,8 @@
|
|
|
8759
8839
|
page: this.getPageOfNode(node.newNode.id)
|
|
8760
8840
|
})),
|
|
8761
8841
|
historySource,
|
|
8762
|
-
doNotPushHistory
|
|
8842
|
+
doNotPushHistory,
|
|
8843
|
+
isHistoryOp
|
|
8763
8844
|
});
|
|
8764
8845
|
return Array.isArray(config) ? updateData.map((item) => item.newNode) : updateData[0].newNode;
|
|
8765
8846
|
}
|
|
@@ -8889,7 +8970,9 @@
|
|
|
8889
8970
|
* @param options 可选配置
|
|
8890
8971
|
* @param options.doNotPushHistory 是否不写入历史记录(默认 false)
|
|
8891
8972
|
*/
|
|
8892
|
-
async moveLayer(offset,
|
|
8973
|
+
async moveLayer(offset, options = {}) {
|
|
8974
|
+
const { doNotPushHistory = false, historyDescription, historySource } = options;
|
|
8975
|
+
const isHistoryOp = isReplay(options);
|
|
8893
8976
|
this.captureSelectionBeforeOp();
|
|
8894
8977
|
const root = this.get("root");
|
|
8895
8978
|
if (!root) throw new Error("root为空");
|
|
@@ -8936,7 +9019,8 @@
|
|
|
8936
9019
|
}],
|
|
8937
9020
|
offset,
|
|
8938
9021
|
historySource,
|
|
8939
|
-
doNotPushHistory
|
|
9022
|
+
doNotPushHistory,
|
|
9023
|
+
isHistoryOp
|
|
8940
9024
|
});
|
|
8941
9025
|
}
|
|
8942
9026
|
/**
|
|
@@ -9009,7 +9093,9 @@
|
|
|
9009
9093
|
} else this.selectionBeforeOp = null;
|
|
9010
9094
|
return isBatch ? newConfigs : newConfigs[0];
|
|
9011
9095
|
}
|
|
9012
|
-
async dragTo(config, targetParent, targetIndex,
|
|
9096
|
+
async dragTo(config, targetParent, targetIndex, options = {}) {
|
|
9097
|
+
const { doNotPushHistory = false, historyDescription, historySource } = options;
|
|
9098
|
+
const isHistoryOp = isReplay(options);
|
|
9013
9099
|
this.captureSelectionBeforeOp();
|
|
9014
9100
|
if (!targetParent || !Array.isArray(targetParent.items)) return;
|
|
9015
9101
|
const configs = Array.isArray(config) ? config : [config];
|
|
@@ -9076,7 +9162,8 @@
|
|
|
9076
9162
|
targetIndex,
|
|
9077
9163
|
targetParent,
|
|
9078
9164
|
historySource,
|
|
9079
|
-
doNotPushHistory
|
|
9165
|
+
doNotPushHistory,
|
|
9166
|
+
isHistoryOp
|
|
9080
9167
|
});
|
|
9081
9168
|
}
|
|
9082
9169
|
/**
|
|
@@ -9176,7 +9263,8 @@
|
|
|
9176
9263
|
* @returns 反向后产生的新 step;目标不存在 / 未应用 / 反向失败时返回 null
|
|
9177
9264
|
*/
|
|
9178
9265
|
async revertPageStep(index) {
|
|
9179
|
-
const
|
|
9266
|
+
const pageId = this.get("page")?.id;
|
|
9267
|
+
const entry = this.ctx.history.getStepList("page", pageId)[index];
|
|
9180
9268
|
if (!entry?.applied) return null;
|
|
9181
9269
|
const { step } = entry;
|
|
9182
9270
|
if (step.opType === "initial") return null;
|
|
@@ -9186,10 +9274,10 @@
|
|
|
9186
9274
|
if (!items.length || !items.every((item) => item.changeRecords?.length)) return null;
|
|
9187
9275
|
}
|
|
9188
9276
|
let revertedStep = null;
|
|
9189
|
-
const captureRevert = (
|
|
9190
|
-
revertedStep = s;
|
|
9277
|
+
const captureRevert = (s, type, id) => {
|
|
9278
|
+
if (type === "page" && id === pageId && !revertedStep) revertedStep = s;
|
|
9191
9279
|
};
|
|
9192
|
-
this.ctx.history.
|
|
9280
|
+
this.ctx.history.on("change", captureRevert);
|
|
9193
9281
|
const historyDescription = `回滚 #${index + 1}: ${describeStepForRevert(step)}`;
|
|
9194
9282
|
const opts = {
|
|
9195
9283
|
doNotSelect: true,
|
|
@@ -9499,9 +9587,11 @@
|
|
|
9499
9587
|
/**
|
|
9500
9588
|
* 构造一条页面级「set root」历史记录(不携带选区 / modifiedNodeIds 上下文)并落到该页面自己的栈。
|
|
9501
9589
|
*
|
|
9502
|
-
* 连续 set root
|
|
9503
|
-
*
|
|
9504
|
-
*
|
|
9590
|
+
* 连续 set root 替换:若该页栈最新一条已是**同来源、同为整页 update**的 set root 记录
|
|
9591
|
+
* ({@link StepValue.rootStep} 且 `source` 相同),则用本次记录**替换**它而非新增,避免源码反复保存时堆积记录。
|
|
9592
|
+
* 替换时必须把 `oldSchema` 追溯到最早那一跳,并沿用原 uuid:否则只剩「上一版 → 本版」,
|
|
9593
|
+
* 撤销到基线时 DSL 会停在中途版本且无法继续回退,已发出的 historyId 也会失效。
|
|
9594
|
+
* 其余情况(来源不同 / 页面增删)照常新增,保留完整变更链条。
|
|
9505
9595
|
*/
|
|
9506
9596
|
pushPageDiffStep(opType, page, diffItem, source) {
|
|
9507
9597
|
const step = {
|
|
@@ -9521,8 +9611,19 @@
|
|
|
9521
9611
|
};
|
|
9522
9612
|
if (source) step.source = source;
|
|
9523
9613
|
const top = this.ctx.history.getCurrentPageStep(page.id);
|
|
9524
|
-
|
|
9525
|
-
|
|
9614
|
+
const earliestOldSchema = top?.diff?.[0]?.oldSchema;
|
|
9615
|
+
if (top?.rootStep && top.source === source && opType === "update" && top.opType === "update" && earliestOldSchema) {
|
|
9616
|
+
this.ctx.history.replaceCurrentStep("page", {
|
|
9617
|
+
...step,
|
|
9618
|
+
uuid: top.uuid,
|
|
9619
|
+
diff: [{
|
|
9620
|
+
...diffItem,
|
|
9621
|
+
oldSchema: earliestOldSchema
|
|
9622
|
+
}]
|
|
9623
|
+
}, page.id);
|
|
9624
|
+
return;
|
|
9625
|
+
}
|
|
9626
|
+
this.ctx.history.push("page", step, page.id);
|
|
9526
9627
|
}
|
|
9527
9628
|
pushOpHistory(opType, { diff, pageData, historyDescription, source }) {
|
|
9528
9629
|
const step = {
|
|
@@ -9554,8 +9655,8 @@
|
|
|
9554
9655
|
* 「重新插回节点」(撤销 remove / 重做 add)需按 step 记录的 parentId / index 精确还原,
|
|
9555
9656
|
* 不走 this.add,由手工 splice + stage.add 完成后补发等价的 add / change 事件(见 emitHistoryInsertEvents)。
|
|
9556
9657
|
*
|
|
9557
|
-
* 注意:这些路径都会发出 add / remove / update / change
|
|
9558
|
-
*
|
|
9658
|
+
* 注意:这些路径都会发出 add / remove / update / change 事件,且 `change` 事件带 `isHistoryOp: true`,
|
|
9659
|
+
* 业务侧可据此跳过仅针对「用户主动编辑」的副作用(加锁 / 埋点 / 自动保存等)。
|
|
9559
9660
|
*
|
|
9560
9661
|
* @param step 操作记录
|
|
9561
9662
|
* @param reverse true = 撤销,false = 重做
|
|
@@ -9569,6 +9670,7 @@
|
|
|
9569
9670
|
doNotSelect: true,
|
|
9570
9671
|
doNotSwitchPage: true,
|
|
9571
9672
|
doNotPushHistory: true,
|
|
9673
|
+
[HISTORY_OP]: true,
|
|
9572
9674
|
historySource: step.source
|
|
9573
9675
|
};
|
|
9574
9676
|
switch (step.opType) {
|
|
@@ -9652,10 +9754,7 @@
|
|
|
9652
9754
|
}
|
|
9653
9755
|
return cloneDeep$1(reverse ? oldNode : newNode);
|
|
9654
9756
|
});
|
|
9655
|
-
if (configs.length) await this.update(configs,
|
|
9656
|
-
doNotPushHistory: true,
|
|
9657
|
-
historySource: step.source
|
|
9658
|
-
});
|
|
9757
|
+
if (configs.length) await this.update(configs, commonOpts);
|
|
9659
9758
|
break;
|
|
9660
9759
|
}
|
|
9661
9760
|
}
|
|
@@ -9693,7 +9792,8 @@
|
|
|
9693
9792
|
page: this.getPageOfNode(node.id)
|
|
9694
9793
|
})),
|
|
9695
9794
|
historySource: source,
|
|
9696
|
-
doNotPushHistory: true
|
|
9795
|
+
doNotPushHistory: true,
|
|
9796
|
+
isHistoryOp: true
|
|
9697
9797
|
});
|
|
9698
9798
|
}
|
|
9699
9799
|
/** 经由 reactivity 注入的 toRaw(默认是 Vue 的 toRaw) */
|
|
@@ -9841,8 +9941,9 @@
|
|
|
9841
9941
|
* 注册一个扩展历史类型,使其可与内置 `page` / `codeBlock` / `dataSource` 一样走统一的
|
|
9842
9942
|
* {@link push} / {@link undo} / {@link redo}(按 id 分栈、独立 undo/redo)。
|
|
9843
9943
|
*
|
|
9944
|
+
* 扩展类型与内置类型一样统一派发 `change` 事件,无需(也不支持)单独指定事件名。
|
|
9945
|
+
*
|
|
9844
9946
|
* @param stepType 自定义历史类型标识(勿与内置类型重名)
|
|
9845
|
-
* @param options.event push/undo/redo 后派发的事件名,缺省为 `${stepType}-history-change`
|
|
9846
9947
|
* @param options.name 历史面板中的展示名称(tab / 分组标题等),缺省回退到 stepType 本身
|
|
9847
9948
|
*/
|
|
9848
9949
|
registerStepType(stepType, options = {}) {
|
|
@@ -9926,11 +10027,20 @@
|
|
|
9926
10027
|
const first = this.state.steps[stepType]?.[id]?.getElementList()[0];
|
|
9927
10028
|
return first?.opType === "initial" ? first : void 0;
|
|
9928
10029
|
}
|
|
10030
|
+
/**
|
|
10031
|
+
* 目标栈「回到初始」是否可达:容量裁剪删掉已应用的真实步骤后撤销链断开,返回 false。
|
|
10032
|
+
* 与是否存在 {@link getMarker} 基线无关——没有基线的栈同样可能因裁剪回不到加载时的 DSL,
|
|
10033
|
+
* 历史面板的各 tab 统一用它判断初始行是否可高亮 / 可点击。
|
|
10034
|
+
*/
|
|
10035
|
+
isInitialReachable(stepType, id) {
|
|
10036
|
+
if (!this.isValidStackId(id)) return true;
|
|
10037
|
+
return this.state.steps[stepType]?.[id]?.isInitialReachable() ?? true;
|
|
10038
|
+
}
|
|
9929
10039
|
push(stepType, step, id) {
|
|
9930
10040
|
if (!this.isValidStackId(id)) return null;
|
|
9931
10041
|
this.fillStepMeta(step);
|
|
9932
10042
|
getOrCreateStack(this.getStepBucket(stepType), id).pushElement(step);
|
|
9933
|
-
this.
|
|
10043
|
+
this.emitStepChange(step, stepType, id);
|
|
9934
10044
|
return step;
|
|
9935
10045
|
}
|
|
9936
10046
|
undo(stepType, id) {
|
|
@@ -9939,7 +10049,7 @@
|
|
|
9939
10049
|
if (!undoRedo) return null;
|
|
9940
10050
|
if (undoRedo.getCursor() <= undoFloor(undoRedo)) return null;
|
|
9941
10051
|
const step = undoRedo.undo();
|
|
9942
|
-
if (step) this.
|
|
10052
|
+
if (step) this.emitStepChange(step, stepType, id, true);
|
|
9943
10053
|
return step;
|
|
9944
10054
|
}
|
|
9945
10055
|
redo(stepType, id) {
|
|
@@ -9947,7 +10057,7 @@
|
|
|
9947
10057
|
const undoRedo = this.state.steps[stepType]?.[id];
|
|
9948
10058
|
if (!undoRedo) return null;
|
|
9949
10059
|
const step = undoRedo.redo();
|
|
9950
|
-
if (step) this.
|
|
10060
|
+
if (step) this.emitStepChange(step, stepType, id, true);
|
|
9951
10061
|
return step;
|
|
9952
10062
|
}
|
|
9953
10063
|
/**
|
|
@@ -9983,7 +10093,7 @@
|
|
|
9983
10093
|
const undoRedo = getOrCreateStack(this.getStepBucket(stepType), id);
|
|
9984
10094
|
this.fillStepMeta(state);
|
|
9985
10095
|
if (!undoRedo.replaceCurrentElement(state)) return null;
|
|
9986
|
-
this.
|
|
10096
|
+
this.emitStepChange(state, stepType, id);
|
|
9987
10097
|
return state;
|
|
9988
10098
|
}
|
|
9989
10099
|
destroy() {
|
|
@@ -10020,6 +10130,9 @@
|
|
|
10020
10130
|
*
|
|
10021
10131
|
* 同一栈内任意时刻最多只有一条记录为 `saved`;从 IndexedDB 恢复时游标会被定位到最近一条已保存记录之后。
|
|
10022
10132
|
*
|
|
10133
|
+
* 标记后把对应栈裁剪到容量上限({@link markStackSaved} → {@link UndoRedo.trim}):入栈与还原都不裁剪,
|
|
10134
|
+
* 只有保存后才收敛,避免用户在落库前丢掉可撤销的历史;initial 基线与 set root 产生的记录不会被裁掉。
|
|
10135
|
+
*
|
|
10023
10136
|
* @param stepType 历史类型
|
|
10024
10137
|
* @param id 目标栈 id;缺省表示标记全部类型 / 全部栈
|
|
10025
10138
|
*/
|
|
@@ -10090,6 +10203,10 @@
|
|
|
10090
10203
|
}
|
|
10091
10204
|
/**
|
|
10092
10205
|
* 用 {@link serialize} 导出的快照重建全部撤销/重做栈,会整体覆盖当前内存中的历史状态。
|
|
10206
|
+
*
|
|
10207
|
+
* 单个栈 / 单个类型的快照损坏只丢弃该部分,其余照常还原;
|
|
10208
|
+
* 快照里的栈全部还原失败时抛出首个错误,此时内存中的历史状态保持不变
|
|
10209
|
+
* (不会把「什么都没恢复」当成一次成功的还原)。
|
|
10093
10210
|
*/
|
|
10094
10211
|
restore(snapshot) {
|
|
10095
10212
|
const steps = {
|
|
@@ -10097,9 +10214,20 @@
|
|
|
10097
10214
|
codeBlock: {},
|
|
10098
10215
|
dataSource: {}
|
|
10099
10216
|
};
|
|
10217
|
+
let firstError;
|
|
10218
|
+
let stackCount = 0;
|
|
10219
|
+
let restoredStackCount = 0;
|
|
10100
10220
|
Object.entries(snapshot.steps).forEach(([stepType, bucket]) => {
|
|
10101
|
-
|
|
10221
|
+
try {
|
|
10222
|
+
const restored = deserializeStacks(convertExtraMaps(bucket, true), this.ctx.parseDSL);
|
|
10223
|
+
steps[stepType] = restored;
|
|
10224
|
+
restoredStackCount += Object.keys(restored).length;
|
|
10225
|
+
} catch (error) {
|
|
10226
|
+
firstError ??= error;
|
|
10227
|
+
}
|
|
10228
|
+
stackCount += Object.keys(bucket ?? {}).length;
|
|
10102
10229
|
});
|
|
10230
|
+
if (firstError && stackCount > 0 && restoredStackCount === 0) throw firstError;
|
|
10103
10231
|
this.state.steps = steps;
|
|
10104
10232
|
return snapshot;
|
|
10105
10233
|
}
|
|
@@ -10195,6 +10323,16 @@
|
|
|
10195
10323
|
return super.emit(eventName, ...args);
|
|
10196
10324
|
}
|
|
10197
10325
|
/**
|
|
10326
|
+
* 所有历史类型统一派发 `change`(签名 `(step, stepType, id, isHistoryOp)`);
|
|
10327
|
+
* 代码块 / 数据源额外派发文档约定的同构事件(签名 `(id, step, isHistoryOp)`)。
|
|
10328
|
+
* `isHistoryOp` 仅在 `undo` / `redo` 时为 true,供业务侧跳过历史回放触发的副作用。
|
|
10329
|
+
*/
|
|
10330
|
+
emitStepChange(step, stepType, id, isHistoryOp = false) {
|
|
10331
|
+
this.emit("change", step, stepType, id, isHistoryOp);
|
|
10332
|
+
if (stepType === "codeBlock") this.emit("code-block-history-change", id, step, isHistoryOp);
|
|
10333
|
+
else if (stepType === "dataSource") this.emit("data-source-history-change", id, step, isHistoryOp);
|
|
10334
|
+
}
|
|
10335
|
+
/**
|
|
10198
10336
|
* 取出指定历史类型的栈桶(`Record<id, UndoRedo>`);不存在时按需创建空桶,
|
|
10199
10337
|
* 从而支持通过 {@link registerStepType} 或首次 push 动态扩展历史类型。
|
|
10200
10338
|
*/
|
|
@@ -14495,6 +14633,10 @@
|
|
|
14495
14633
|
type: Boolean,
|
|
14496
14634
|
default: true
|
|
14497
14635
|
},
|
|
14636
|
+
initialReachable: {
|
|
14637
|
+
type: Boolean,
|
|
14638
|
+
default: true
|
|
14639
|
+
},
|
|
14498
14640
|
marker: { default: void 0 }
|
|
14499
14641
|
},
|
|
14500
14642
|
emits: ["goto-initial"],
|
|
@@ -14507,27 +14649,34 @@
|
|
|
14507
14649
|
* 用标记的文案与时间渲染本行;标记不进入撤销/重做栈,仅作为该页基线展示。
|
|
14508
14650
|
*
|
|
14509
14651
|
* 该行不是真实 step,仅作为 UI 入口;上层负责把"点击"翻译为 `service.goto*(0)`。
|
|
14652
|
+
* 若上层注入 `initialReachable === false`(早期记录已被容量裁剪),
|
|
14653
|
+
* 则如实显示「不可达」并禁用「回到」,避免把撤销下限误报成初始状态。
|
|
14510
14654
|
*/
|
|
14511
14655
|
const props = __props;
|
|
14512
|
-
|
|
14656
|
+
/**
|
|
14657
|
+
* 早期真实步骤被容量裁剪后撤销链已断:撤到底只能停在剩余最老一步的 oldSchema,
|
|
14658
|
+
* 不是加载时的初始 DSL,此时该行需明确标注不可达且不再提供「回到」。
|
|
14659
|
+
*/
|
|
14660
|
+
const desc = (0, vue.computed)(() => props.initialReachable ? props.marker?.historyDescription || "未修改的初始状态" : "初始状态不可达(早期记录已清理)");
|
|
14513
14661
|
/** 基线(初始状态)是否为最近一次保存点:仅页面栈的 `initial` 基线 step 会被 markSaved 标记。 */
|
|
14514
14662
|
const saved = (0, vue.computed)(() => Boolean(props.marker?.saved));
|
|
14515
14663
|
const time = (0, vue.computed)(() => formatHistoryTime(props.marker?.timestamp));
|
|
14516
14664
|
const timeTitle = (0, vue.computed)(() => formatHistoryFullTime(props.marker?.timestamp));
|
|
14517
14665
|
const rowTitle = (0, vue.computed)(() => {
|
|
14666
|
+
if (!props.initialReachable) return "早期历史记录已被容量裁剪,无法回到加载时的初始 DSL";
|
|
14518
14667
|
const base = props.marker?.historyDescription || "未修改的初始状态";
|
|
14519
14668
|
return props.isCurrent ? `当前已回到${base}` : `点击回到${base}`;
|
|
14520
14669
|
});
|
|
14521
14670
|
const emit = __emit;
|
|
14522
14671
|
const onClick = () => {
|
|
14523
|
-
if (props.isCurrent) return;
|
|
14672
|
+
if (props.isCurrent || !props.initialReachable) return;
|
|
14524
14673
|
emit("goto-initial");
|
|
14525
14674
|
};
|
|
14526
14675
|
return (_ctx, _cache) => {
|
|
14527
14676
|
return (0, vue.openBlock)(), (0, vue.createElementBlock)("li", {
|
|
14528
14677
|
class: (0, vue.normalizeClass)(["m-editor-history-list-item m-editor-history-list-initial", {
|
|
14529
14678
|
"is-current": __props.isCurrent,
|
|
14530
|
-
"is-clickable": !__props.isCurrent
|
|
14679
|
+
"is-clickable": !__props.isCurrent && __props.initialReachable
|
|
14531
14680
|
}]),
|
|
14532
14681
|
title: rowTitle.value
|
|
14533
14682
|
}, [
|
|
@@ -14538,7 +14687,7 @@
|
|
|
14538
14687
|
_cache[1] || (_cache[1] = (0, vue.createElementVNode)("span", { class: "m-editor-history-list-item-op op-initial" }, "初始", -1)),
|
|
14539
14688
|
(0, vue.createElementVNode)("span", _hoisted_2$24, (0, vue.toDisplayString)(desc.value), 1),
|
|
14540
14689
|
saved.value ? ((0, vue.openBlock)(), (0, vue.createElementBlock)("span", _hoisted_3$11, "已保存")) : (0, vue.createCommentVNode)("v-if", true),
|
|
14541
|
-
__props.gotoEnabled && !__props.isCurrent ? ((0, vue.openBlock)(), (0, vue.createElementBlock)("span", _hoisted_4$7, [(0, vue.createElementVNode)("span", {
|
|
14690
|
+
__props.gotoEnabled && !__props.isCurrent && __props.initialReachable ? ((0, vue.openBlock)(), (0, vue.createElementBlock)("span", _hoisted_4$7, [(0, vue.createElementVNode)("span", {
|
|
14542
14691
|
class: "m-editor-history-list-item-goto",
|
|
14543
14692
|
title: "回到该记录",
|
|
14544
14693
|
onClick: (0, vue.withModifiers)(onClick, ["stop"])
|
|
@@ -14566,7 +14715,12 @@
|
|
|
14566
14715
|
config: {},
|
|
14567
14716
|
bucketId: {},
|
|
14568
14717
|
groups: {},
|
|
14569
|
-
expanded: {}
|
|
14718
|
+
expanded: {},
|
|
14719
|
+
marker: {},
|
|
14720
|
+
initialReachable: {
|
|
14721
|
+
type: Boolean,
|
|
14722
|
+
default: true
|
|
14723
|
+
}
|
|
14570
14724
|
},
|
|
14571
14725
|
emits: [
|
|
14572
14726
|
"toggle",
|
|
@@ -14584,8 +14738,12 @@
|
|
|
14584
14738
|
const rowKey = (group) => `${props.config.prefix}-${props.bucketId}-${group.steps[0]?.index}`;
|
|
14585
14739
|
/** 把原始分组派生为 GroupRow 直接消费的视图模型。 */
|
|
14586
14740
|
const toRow = (group) => toRowGroup(group, rowKey(group), props.config);
|
|
14587
|
-
/**
|
|
14588
|
-
|
|
14741
|
+
/**
|
|
14742
|
+
* 该 bucket 是否处于初始状态:全部 group 都未 applied,且撤销链未因容量裁剪断开。
|
|
14743
|
+
* 与 PageTab 使用同一判断条件——空列表 `every` 返回 true,即只有基线、没有任何真实步骤时也视为初始状态;
|
|
14744
|
+
* 没有基线的栈也通过 initialReachable 参与判断。
|
|
14745
|
+
*/
|
|
14746
|
+
const isInitial = (0, vue.computed)(() => props.initialReachable && props.groups.every((g) => !g.applied));
|
|
14589
14747
|
return (_ctx, _cache) => {
|
|
14590
14748
|
return (0, vue.openBlock)(), (0, vue.createElementBlock)("div", _hoisted_1$82, [(0, vue.createElementVNode)("div", _hoisted_2$23, [
|
|
14591
14749
|
(0, vue.createElementVNode)("span", null, (0, vue.toDisplayString)(__props.config.title), 1),
|
|
@@ -14612,9 +14770,16 @@
|
|
|
14612
14770
|
__props.config.showInitial !== false ? ((0, vue.openBlock)(), (0, vue.createBlock)(InitialRow_default, {
|
|
14613
14771
|
key: 0,
|
|
14614
14772
|
"is-current": isInitial.value,
|
|
14773
|
+
"initial-reachable": __props.initialReachable,
|
|
14774
|
+
marker: __props.marker,
|
|
14615
14775
|
"goto-enabled": __props.config.gotoEnabled,
|
|
14616
14776
|
onGotoInitial: _cache[4] || (_cache[4] = ($event) => _ctx.$emit("goto-initial", __props.bucketId))
|
|
14617
|
-
}, null, 8, [
|
|
14777
|
+
}, null, 8, [
|
|
14778
|
+
"is-current",
|
|
14779
|
+
"initial-reachable",
|
|
14780
|
+
"marker",
|
|
14781
|
+
"goto-enabled"
|
|
14782
|
+
])) : (0, vue.createCommentVNode)("v-if", true)
|
|
14618
14783
|
])]);
|
|
14619
14784
|
};
|
|
14620
14785
|
}
|
|
@@ -14637,7 +14802,8 @@
|
|
|
14637
14802
|
props: {
|
|
14638
14803
|
config: {},
|
|
14639
14804
|
buckets: {},
|
|
14640
|
-
expanded: {}
|
|
14805
|
+
expanded: {},
|
|
14806
|
+
initialState: {}
|
|
14641
14807
|
},
|
|
14642
14808
|
emits: [
|
|
14643
14809
|
"toggle",
|
|
@@ -14661,6 +14827,8 @@
|
|
|
14661
14827
|
"bucket-id": bucket.id,
|
|
14662
14828
|
groups: bucket.groups,
|
|
14663
14829
|
expanded: __props.expanded,
|
|
14830
|
+
marker: __props.initialState?.[bucket.id]?.marker,
|
|
14831
|
+
"initial-reachable": __props.initialState?.[bucket.id]?.initialReachable,
|
|
14664
14832
|
onToggle: _cache[1] || (_cache[1] = (key) => _ctx.$emit("toggle", key)),
|
|
14665
14833
|
onGoto: _cache[2] || (_cache[2] = (id, index) => _ctx.$emit("goto", id, index)),
|
|
14666
14834
|
onGotoInitial: _cache[3] || (_cache[3] = (id) => _ctx.$emit("goto-initial", id)),
|
|
@@ -14670,7 +14838,9 @@
|
|
|
14670
14838
|
"config",
|
|
14671
14839
|
"bucket-id",
|
|
14672
14840
|
"groups",
|
|
14673
|
-
"expanded"
|
|
14841
|
+
"expanded",
|
|
14842
|
+
"marker",
|
|
14843
|
+
"initial-reachable"
|
|
14674
14844
|
]);
|
|
14675
14845
|
}), 128))]),
|
|
14676
14846
|
_: 1
|
|
@@ -14696,7 +14866,11 @@
|
|
|
14696
14866
|
props: {
|
|
14697
14867
|
list: {},
|
|
14698
14868
|
expanded: {},
|
|
14699
|
-
marker: {}
|
|
14869
|
+
marker: {},
|
|
14870
|
+
initialReachable: {
|
|
14871
|
+
type: Boolean,
|
|
14872
|
+
default: true
|
|
14873
|
+
}
|
|
14700
14874
|
},
|
|
14701
14875
|
emits: [
|
|
14702
14876
|
"toggle",
|
|
@@ -14731,11 +14905,14 @@
|
|
|
14731
14905
|
const rowKey = (group) => `pg-${group.steps[0]?.index}`;
|
|
14732
14906
|
const toRow = (group) => toRowGroup(group, rowKey(group), descriptor);
|
|
14733
14907
|
/**
|
|
14734
|
-
* 是否处于"初始状态"
|
|
14908
|
+
* 是否处于"初始状态"——即对应页面历史栈撤到底:
|
|
14735
14909
|
* 当 list 中所有 group 的 applied 都为 false 时即为该状态(空列表 `every` 返回 true,
|
|
14736
14910
|
* 即仅有 marker、无任何操作记录时也视为处于初始状态)。
|
|
14911
|
+
*
|
|
14912
|
+
* 例外:早期真实步骤被容量裁剪后(initialReachable === false),
|
|
14913
|
+
* 撤到底只能停在剩余最老一步的 oldSchema,并非加载时的初始 DSL,此时不再高亮初始行。
|
|
14737
14914
|
*/
|
|
14738
|
-
const isInitial = (0, vue.computed)(() => props.list.every((g) => !g.applied));
|
|
14915
|
+
const isInitial = (0, vue.computed)(() => props.initialReachable && props.list.every((g) => !g.applied));
|
|
14739
14916
|
return (_ctx, _cache) => {
|
|
14740
14917
|
return !__props.list.length && !__props.marker ? ((0, vue.openBlock)(), (0, vue.createElementBlock)("div", _hoisted_1$80, "暂无操作记录")) : ((0, vue.openBlock)(), (0, vue.createElementBlock)(vue.Fragment, { key: 1 }, [__props.list.length ? ((0, vue.openBlock)(), (0, vue.createElementBlock)("div", _hoisted_2$21, [(0, vue.createElementVNode)("span", {
|
|
14741
14918
|
class: "m-editor-history-list-clear",
|
|
@@ -14759,9 +14936,14 @@
|
|
|
14759
14936
|
(0, vue.createCommentVNode)("\n 初始状态项:永远位于列表底部(页面 tab 倒序展示,最底部=最早),\n 作为\"未修改\"零点。当所有 group 都未 applied 时它即为当前位置。\n 设置 root 时生成的「未修改的初始状态」标记(marker)会作为该行的文案与时间来源。\n "),
|
|
14760
14937
|
(0, vue.createVNode)(InitialRow_default, {
|
|
14761
14938
|
"is-current": isInitial.value,
|
|
14939
|
+
"initial-reachable": __props.initialReachable,
|
|
14762
14940
|
marker: __props.marker,
|
|
14763
14941
|
onGotoInitial: _cache[6] || (_cache[6] = ($event) => _ctx.$emit("goto-initial"))
|
|
14764
|
-
}, null, 8, [
|
|
14942
|
+
}, null, 8, [
|
|
14943
|
+
"is-current",
|
|
14944
|
+
"initial-reachable",
|
|
14945
|
+
"marker"
|
|
14946
|
+
])
|
|
14765
14947
|
])]),
|
|
14766
14948
|
_: 1
|
|
14767
14949
|
})], 64));
|
|
@@ -15577,6 +15759,18 @@
|
|
|
15577
15759
|
* 基于 historyService 的 reactive state 派生,活动页切换或标记写入后自动刷新。
|
|
15578
15760
|
*/
|
|
15579
15761
|
const pageMarker = (0, vue.computed)(() => historyService.getMarker("page", editorService.get("page")?.id));
|
|
15762
|
+
/** 当前活动页「回到初始」是否可达(基于栈实例状态,无基线的栈同样适用)。 */
|
|
15763
|
+
const pageInitialReachable = (0, vue.computed)(() => historyService.isInitialReachable("page", editorService.get("page")?.id));
|
|
15764
|
+
/**
|
|
15765
|
+
* 数据源 / 代码块按目标 id 聚合初始基线与可达性,透传给 BucketTab → Bucket,
|
|
15766
|
+
* 让这两类 tab 的初始行与 PageTab 使用同一套高亮 / 不可达判定。
|
|
15767
|
+
*/
|
|
15768
|
+
const bucketInitialState = (stepType) => (0, vue.computed)(() => Object.fromEntries(Object.keys(historyService.state.steps[stepType]).map((id) => [id, {
|
|
15769
|
+
marker: historyService.getMarker(stepType, id),
|
|
15770
|
+
initialReachable: historyService.isInitialReachable(stepType, id)
|
|
15771
|
+
}])));
|
|
15772
|
+
const dataSourceInitialState = bucketInitialState("dataSource");
|
|
15773
|
+
const codeBlockInitialState = bucketInitialState("codeBlock");
|
|
15580
15774
|
/**
|
|
15581
15775
|
* 各历史类型的展示名称(页面 / 数据源 / 代码块),由 historyService.state.stepNames 配置,
|
|
15582
15776
|
* 业务方可通过 historyService.setStepName / registerStepType 覆盖。基于 reactive state 派生,配置变更后自动刷新。
|
|
@@ -15737,6 +15931,7 @@
|
|
|
15737
15931
|
list: (0, vue.unref)(pageGroupsDisplay),
|
|
15738
15932
|
expanded: (0, vue.unref)(expanded),
|
|
15739
15933
|
marker: pageMarker.value,
|
|
15934
|
+
"initial-reachable": pageInitialReachable.value,
|
|
15740
15935
|
onToggle: (0, vue.unref)(toggleGroup),
|
|
15741
15936
|
onGoto: onPageGoto,
|
|
15742
15937
|
onGotoInitial: onPageGotoInitial,
|
|
@@ -15748,6 +15943,7 @@
|
|
|
15748
15943
|
"list",
|
|
15749
15944
|
"expanded",
|
|
15750
15945
|
"marker",
|
|
15946
|
+
"initial-reachable",
|
|
15751
15947
|
"onToggle",
|
|
15752
15948
|
"onDiffStep",
|
|
15753
15949
|
"onRevertStep"
|
|
@@ -15763,6 +15959,7 @@
|
|
|
15763
15959
|
config: dataSourceConfig.value,
|
|
15764
15960
|
buckets: (0, vue.unref)(dataSourceGroupsByTarget),
|
|
15765
15961
|
expanded: (0, vue.unref)(expanded),
|
|
15962
|
+
"initial-state": (0, vue.unref)(dataSourceInitialState),
|
|
15766
15963
|
onToggle: (0, vue.unref)(toggleGroup),
|
|
15767
15964
|
onGoto: onDataSourceGoto,
|
|
15768
15965
|
onGotoInitial: onDataSourceGotoInitial,
|
|
@@ -15773,6 +15970,7 @@
|
|
|
15773
15970
|
"config",
|
|
15774
15971
|
"buckets",
|
|
15775
15972
|
"expanded",
|
|
15973
|
+
"initial-state",
|
|
15776
15974
|
"onToggle",
|
|
15777
15975
|
"onDiffStep",
|
|
15778
15976
|
"onRevertStep"
|
|
@@ -15788,6 +15986,7 @@
|
|
|
15788
15986
|
config: codeBlockConfig.value,
|
|
15789
15987
|
buckets: (0, vue.unref)(codeBlockGroupsByTarget),
|
|
15790
15988
|
expanded: (0, vue.unref)(expanded),
|
|
15989
|
+
"initial-state": (0, vue.unref)(codeBlockInitialState),
|
|
15791
15990
|
onToggle: (0, vue.unref)(toggleGroup),
|
|
15792
15991
|
onGoto: onCodeBlockGoto,
|
|
15793
15992
|
onGotoInitial: onCodeBlockGotoInitial,
|
|
@@ -15798,6 +15997,7 @@
|
|
|
15798
15997
|
"config",
|
|
15799
15998
|
"buckets",
|
|
15800
15999
|
"expanded",
|
|
16000
|
+
"initial-state",
|
|
15801
16001
|
"onToggle",
|
|
15802
16002
|
"onDiffStep",
|
|
15803
16003
|
"onRevertStep"
|