@tmagic/editor 1.8.0-beta.8 → 1.8.0-manmanyu.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/es/Editor.vue_vue_type_script_setup_true_lang.js +13 -3
- package/dist/es/components/CompareForm.vue_vue_type_script_setup_true_lang.js +1 -4
- package/dist/es/components/ContentMenu.vue_vue_type_script_setup_true_lang.js +11 -4
- package/dist/es/components/FloatingBox.vue_vue_type_script_setup_true_lang.js +9 -4
- package/dist/es/fields/Code.vue_vue_type_script_setup_true_lang.js +4 -1
- package/dist/es/fields/CodeLink.vue_vue_type_script_setup_true_lang.js +4 -1
- package/dist/es/fields/CodeSelect.vue_vue_type_script_setup_true_lang.js +68 -43
- package/dist/es/fields/CodeSelectCol.vue_vue_type_script_setup_true_lang.js +5 -1
- package/dist/es/fields/CondOpSelect.vue_vue_type_script_setup_true_lang.js +4 -1
- package/dist/es/fields/DataSourceFieldSelect/Index.vue_vue_type_script_setup_true_lang.js +10 -7
- package/dist/es/fields/DataSourceFields.vue_vue_type_script_setup_true_lang.js +4 -1
- package/dist/es/fields/DataSourceInput.vue_vue_type_script_setup_true_lang.js +4 -1
- package/dist/es/fields/DataSourceMethodSelect.vue_vue_type_script_setup_true_name_true_lang.js +4 -1
- 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 +4 -1
- package/dist/es/fields/DataSourceSelect.vue_vue_type_script_setup_true_lang.js +4 -1
- package/dist/es/fields/DisplayConds.vue_vue_type_script_setup_true_lang.js +8 -2
- package/dist/es/fields/EventSelect.vue_vue_type_script_setup_true_lang.js +101 -64
- package/dist/es/fields/KeyValue.vue_vue_type_script_setup_true_lang.js +4 -1
- package/dist/es/fields/PageFragmentSelect.vue_vue_type_script_setup_true_lang.js +4 -1
- package/dist/es/fields/StyleSetter/Index.vue_vue_type_script_setup_true_lang.js +5 -4
- package/dist/es/fields/StyleSetter/components/BackgroundPosition.vue_vue_type_script_setup_true_lang.js +4 -1
- package/dist/es/fields/StyleSetter/components/Border.vue_vue_type_script_setup_true_lang.js +1 -1
- package/dist/es/fields/StyleSetter/icons/align-items/Center.js +31 -0
- package/dist/es/fields/StyleSetter/icons/align-items/FlexEnd.js +31 -0
- package/dist/es/fields/StyleSetter/icons/align-items/FlexStart.js +31 -0
- package/dist/es/fields/StyleSetter/icons/align-items/SpaceAround.js +50 -0
- package/dist/es/fields/StyleSetter/icons/align-items/SpaceBetween.js +50 -0
- package/dist/es/fields/StyleSetter/icons/background-repeat/NoRepeat.js +6 -6
- package/dist/es/fields/StyleSetter/icons/background-repeat/Repeat.js +5 -2
- package/dist/es/fields/StyleSetter/icons/background-repeat/RepeatX.js +28 -5
- package/dist/es/fields/StyleSetter/icons/background-repeat/RepeatY.js +31 -5
- package/dist/es/fields/StyleSetter/icons/flex-direction/Column.js +10 -2
- package/dist/es/fields/StyleSetter/icons/flex-direction/ColumnReverse.js +10 -2
- package/dist/es/fields/StyleSetter/icons/flex-direction/Row.js +10 -2
- package/dist/es/fields/StyleSetter/icons/flex-direction/RowReverse.js +10 -2
- package/dist/es/fields/StyleSetter/icons/justify-content/Center.js +16 -2
- package/dist/es/fields/StyleSetter/icons/justify-content/FlexEnd.js +18 -2
- package/dist/es/fields/StyleSetter/icons/justify-content/FlexStart.js +18 -2
- package/dist/es/fields/StyleSetter/icons/justify-content/SpaceAround.js +36 -2
- package/dist/es/fields/StyleSetter/icons/justify-content/SpaceBetween.js +32 -2
- package/dist/es/fields/StyleSetter/pro/Background.vue_vue_type_script_setup_true_lang.js +11 -6
- package/dist/es/fields/StyleSetter/pro/Font.vue_vue_type_script_setup_true_lang.js +6 -3
- package/dist/es/fields/StyleSetter/pro/Layout.vue_vue_type_script_setup_true_lang.js +82 -46
- package/dist/es/fields/UISelect.vue_vue_type_script_setup_true_lang.js +4 -1
- package/dist/es/icons/DatasourceIcon.js +17 -0
- package/dist/es/index.js +2 -2
- package/dist/es/layouts/Framework.vue_vue_type_script_setup_true_lang.js +14 -10
- package/dist/es/layouts/NavMenu.vue_vue_type_script_setup_true_lang.js +2 -2
- package/dist/es/layouts/history-list/HistoryListPanel.vue_vue_type_script_setup_true_lang.js +18 -28
- package/dist/es/layouts/history-list/useHistoryList.js +4 -4
- package/dist/es/layouts/history-list/useHistoryRevert.js +6 -6
- package/dist/es/services/codeBlock.js +28 -32
- package/dist/es/services/dataSource.js +34 -43
- package/dist/es/services/editor.js +26 -31
- package/dist/es/services/history.js +392 -259
- package/dist/es/style.css +294 -37
- package/dist/es/utils/const.js +1 -1
- package/dist/es/utils/history.js +47 -35
- package/dist/es/utils/props.js +137 -31
- package/dist/style.css +294 -37
- package/dist/themes/magic-admin.css +2316 -0
- package/dist/tmagic-editor.umd.cjs +1665 -880
- package/package.json +7 -7
- package/src/Editor.vue +13 -1
- package/src/components/ContentMenu.vue +10 -2
- package/src/components/FloatingBox.vue +13 -2
- package/src/editorProps.ts +9 -0
- package/src/fields/CodeSelect.vue +51 -40
- package/src/fields/CodeSelectCol.vue +1 -0
- package/src/fields/DataSourceFieldSelect/Index.vue +14 -5
- package/src/fields/DisplayConds.vue +4 -1
- package/src/fields/EventSelect.vue +58 -32
- package/src/fields/StyleSetter/Index.vue +1 -4
- package/src/fields/StyleSetter/components/Border.vue +1 -1
- package/src/fields/StyleSetter/icons/align-items/Center.vue +19 -0
- package/src/fields/StyleSetter/icons/align-items/FlexEnd.vue +19 -0
- package/src/fields/StyleSetter/icons/align-items/FlexStart.vue +19 -0
- package/src/fields/StyleSetter/icons/align-items/SpaceAround.vue +34 -0
- package/src/fields/StyleSetter/icons/align-items/SpaceBetween.vue +34 -0
- package/src/fields/StyleSetter/icons/align-items/index copy.ts +5 -0
- package/src/fields/StyleSetter/icons/align-items/index.ts +5 -0
- package/src/fields/StyleSetter/icons/background-repeat/NoRepeat.vue +20 -4
- package/src/fields/StyleSetter/icons/background-repeat/Repeat.vue +10 -28
- package/src/fields/StyleSetter/icons/background-repeat/RepeatX.vue +4 -5
- package/src/fields/StyleSetter/icons/background-repeat/RepeatY.vue +4 -5
- package/src/fields/StyleSetter/icons/flex-direction/Column.vue +4 -3
- package/src/fields/StyleSetter/icons/flex-direction/ColumnReverse.vue +4 -3
- package/src/fields/StyleSetter/icons/flex-direction/Row.vue +4 -3
- package/src/fields/StyleSetter/icons/flex-direction/RowReverse.vue +4 -3
- package/src/fields/StyleSetter/icons/justify-content/Center.vue +5 -2
- package/src/fields/StyleSetter/icons/justify-content/FlexEnd.vue +15 -2
- package/src/fields/StyleSetter/icons/justify-content/FlexStart.vue +15 -2
- package/src/fields/StyleSetter/icons/justify-content/SpaceAround.vue +28 -3
- package/src/fields/StyleSetter/icons/justify-content/SpaceBetween.vue +28 -2
- package/src/fields/StyleSetter/pro/Background.vue +11 -5
- package/src/fields/StyleSetter/pro/Font.vue +3 -3
- package/src/fields/StyleSetter/pro/Layout.vue +105 -28
- package/src/fields/UISelect.vue +1 -1
- package/src/icons/DatasourceIcon.vue +7 -0
- package/src/layouts/Framework.vue +7 -1
- package/src/theme/code-block.scss +37 -0
- package/src/theme/common/var.scss +1 -1
- package/src/theme/component-list-panel.scss +2 -2
- package/src/theme/data-source-field.scss +4 -0
- package/src/theme/display-conds.scss +11 -0
- package/src/theme/event.scss +55 -1
- package/src/theme/history-list-panel.scss +9 -9
- package/src/theme/props-panel.scss +2 -1
- package/src/theme/style-setter/border.scss +14 -5
- package/src/theme/theme.scss +1 -0
- package/src/theme/themes/magic-admin/index.scss +125 -0
- package/src/utils/const.ts +2 -1
- package/src/utils/props.ts +138 -9
- package/types/index.d.ts +310 -315
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import BaseService from "./BaseService.js";
|
|
2
|
-
import {
|
|
2
|
+
import { describeRevertStep, getLastPushedHistoryIds } from "../utils/history.js";
|
|
3
3
|
import history_default from "./history.js";
|
|
4
4
|
import storage_default, { Protocol } from "./storage.js";
|
|
5
5
|
import { COPY_DS_STORAGE_KEY } from "../utils/editor.js";
|
|
@@ -92,15 +92,12 @@ var DataSource = class extends BaseService {
|
|
|
92
92
|
id: config.id && !this.getDataSourceById(config.id) ? config.id : this.createId()
|
|
93
93
|
};
|
|
94
94
|
this.get("dataSources").push(newConfig);
|
|
95
|
-
if (!doNotPushHistory) {
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
});
|
|
102
|
-
this.lastPushedHistoryId = (step ? history_default.push("dataSource", step, newConfig.id) : null)?.uuid ?? null;
|
|
103
|
-
}
|
|
95
|
+
if (!doNotPushHistory) this.lastPushedHistoryId = history_default.pushDataSource(newConfig.id, {
|
|
96
|
+
oldSchema: null,
|
|
97
|
+
newSchema: newConfig,
|
|
98
|
+
historyDescription,
|
|
99
|
+
source: historySource
|
|
100
|
+
})?.uuid ?? null;
|
|
104
101
|
this.emit("add", newConfig);
|
|
105
102
|
return newConfig;
|
|
106
103
|
}
|
|
@@ -118,16 +115,13 @@ var DataSource = class extends BaseService {
|
|
|
118
115
|
const oldConfig = dataSources[index];
|
|
119
116
|
const newConfig = cloneDeep$1(config);
|
|
120
117
|
dataSources[index] = newConfig;
|
|
121
|
-
if (!doNotPushHistory) {
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
});
|
|
129
|
-
this.lastPushedHistoryId = (step ? history_default.push("dataSource", step, newConfig.id) : null)?.uuid ?? null;
|
|
130
|
-
}
|
|
118
|
+
if (!doNotPushHistory) this.lastPushedHistoryId = history_default.pushDataSource(newConfig.id, {
|
|
119
|
+
oldSchema: oldConfig ? cloneDeep$1(oldConfig) : null,
|
|
120
|
+
newSchema: newConfig,
|
|
121
|
+
changeRecords,
|
|
122
|
+
historyDescription,
|
|
123
|
+
source: historySource
|
|
124
|
+
})?.uuid ?? null;
|
|
131
125
|
this.emit("update", newConfig, {
|
|
132
126
|
oldConfig,
|
|
133
127
|
changeRecords
|
|
@@ -146,15 +140,12 @@ var DataSource = class extends BaseService {
|
|
|
146
140
|
const index = dataSources.findIndex((ds) => ds.id === id);
|
|
147
141
|
const oldConfig = index !== -1 ? dataSources[index] : null;
|
|
148
142
|
dataSources.splice(index, 1);
|
|
149
|
-
if (oldConfig && !doNotPushHistory) {
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
});
|
|
156
|
-
this.lastPushedHistoryId = (step ? history_default.push("dataSource", step, id) : null)?.uuid ?? null;
|
|
157
|
-
}
|
|
143
|
+
if (oldConfig && !doNotPushHistory) this.lastPushedHistoryId = history_default.pushDataSource(id, {
|
|
144
|
+
oldSchema: cloneDeep$1(oldConfig),
|
|
145
|
+
newSchema: null,
|
|
146
|
+
historyDescription,
|
|
147
|
+
source: historySource
|
|
148
|
+
})?.uuid ?? null;
|
|
158
149
|
this.emit("remove", id);
|
|
159
150
|
}
|
|
160
151
|
/**
|
|
@@ -200,7 +191,7 @@ var DataSource = class extends BaseService {
|
|
|
200
191
|
* @returns 撤销的 step;栈不存在或已无可撤销时返回 null
|
|
201
192
|
*/
|
|
202
193
|
undo(id) {
|
|
203
|
-
const step = history_default.
|
|
194
|
+
const step = history_default.undoDataSource(id);
|
|
204
195
|
if (!step) return null;
|
|
205
196
|
this.applyHistoryStep(step, true);
|
|
206
197
|
return step;
|
|
@@ -211,18 +202,18 @@ var DataSource = class extends BaseService {
|
|
|
211
202
|
* @returns 重做的 step;栈不存在或已无可重做时返回 null
|
|
212
203
|
*/
|
|
213
204
|
redo(id) {
|
|
214
|
-
const step = history_default.
|
|
205
|
+
const step = history_default.redoDataSource(id);
|
|
215
206
|
if (!step) return null;
|
|
216
207
|
this.applyHistoryStep(step, false);
|
|
217
208
|
return step;
|
|
218
209
|
}
|
|
219
210
|
/** 是否可对指定数据源撤销。 */
|
|
220
211
|
canUndo(id) {
|
|
221
|
-
return history_default.
|
|
212
|
+
return history_default.canUndoDataSource(id);
|
|
222
213
|
}
|
|
223
214
|
/** 是否可对指定数据源重做。 */
|
|
224
215
|
canRedo(id) {
|
|
225
|
-
return history_default.
|
|
216
|
+
return history_default.canRedoDataSource(id);
|
|
226
217
|
}
|
|
227
218
|
/**
|
|
228
219
|
* 跳转指定数据源的历史栈到目标游标。语义同 editor.gotoPageStep。
|
|
@@ -232,7 +223,7 @@ var DataSource = class extends BaseService {
|
|
|
232
223
|
* @returns 实际移动到的最终游标位置
|
|
233
224
|
*/
|
|
234
225
|
goto(id, targetCursor) {
|
|
235
|
-
let cursor = history_default.
|
|
226
|
+
let cursor = history_default.getDataSourceCursor(id);
|
|
236
227
|
const target = Math.max(0, targetCursor);
|
|
237
228
|
while (cursor > target) {
|
|
238
229
|
if (!this.undo(id)) break;
|
|
@@ -255,11 +246,11 @@ var DataSource = class extends BaseService {
|
|
|
255
246
|
* @returns 反向后产生的新 step;目标不存在 / 未应用时返回 null
|
|
256
247
|
*/
|
|
257
248
|
revert(id, index) {
|
|
258
|
-
const entry = history_default.
|
|
249
|
+
const entry = history_default.getDataSourceStepList(id)[index];
|
|
259
250
|
if (!entry?.applied) return null;
|
|
260
251
|
const { oldSchema, newSchema, changeRecords } = entry.step.diff?.[0] ?? {};
|
|
261
252
|
if (oldSchema && newSchema && !changeRecords?.length) return null;
|
|
262
|
-
const description = `回滚 #${index + 1}: ${describeRevertStep(entry.step.
|
|
253
|
+
const description = `回滚 #${index + 1}: ${describeRevertStep(entry.step.id, entry.step.diff?.[0], (s) => s.title)}`;
|
|
263
254
|
return this.applyRevertStep(entry.step, description);
|
|
264
255
|
}
|
|
265
256
|
/**
|
|
@@ -271,7 +262,7 @@ var DataSource = class extends BaseService {
|
|
|
271
262
|
*/
|
|
272
263
|
revertById(uuids) {
|
|
273
264
|
return uuids.map((uuid) => {
|
|
274
|
-
const location = history_default.
|
|
265
|
+
const location = history_default.findDataSourceStepLocationByUuid(uuid);
|
|
275
266
|
if (!location) return null;
|
|
276
267
|
return this.revert(location.id, location.index);
|
|
277
268
|
});
|
|
@@ -334,21 +325,21 @@ var DataSource = class extends BaseService {
|
|
|
334
325
|
* 同构,差异仅在于走对应的公共 add / update / remove 而不是带 doNotPushHistory 的版本。
|
|
335
326
|
*/
|
|
336
327
|
applyRevertStep(step, historyDescription) {
|
|
337
|
-
const { id } = step
|
|
328
|
+
const { id } = step;
|
|
338
329
|
const { oldSchema, newSchema, changeRecords } = step.diff?.[0] ?? {};
|
|
339
330
|
if (!oldSchema && newSchema) {
|
|
340
331
|
this.remove(`${id}`, {
|
|
341
332
|
historyDescription,
|
|
342
333
|
historySource: "rollback"
|
|
343
334
|
});
|
|
344
|
-
return history_default.
|
|
335
|
+
return history_default.getDataSourceStepList(id).slice(-1)[0]?.step ?? null;
|
|
345
336
|
}
|
|
346
337
|
if (oldSchema && !newSchema) {
|
|
347
338
|
this.add(cloneDeep$1(oldSchema), {
|
|
348
339
|
historyDescription,
|
|
349
340
|
historySource: "rollback"
|
|
350
341
|
});
|
|
351
|
-
return history_default.
|
|
342
|
+
return history_default.getDataSourceStepList(id).slice(-1)[0]?.step ?? null;
|
|
352
343
|
}
|
|
353
344
|
if (!oldSchema || !newSchema) return null;
|
|
354
345
|
if (changeRecords?.length) {
|
|
@@ -369,13 +360,13 @@ var DataSource = class extends BaseService {
|
|
|
369
360
|
historyDescription,
|
|
370
361
|
historySource: "rollback"
|
|
371
362
|
});
|
|
372
|
-
return history_default.
|
|
363
|
+
return history_default.getDataSourceStepList(id).slice(-1)[0]?.step ?? null;
|
|
373
364
|
}
|
|
374
365
|
this.update(cloneDeep$1(oldSchema), {
|
|
375
366
|
historyDescription,
|
|
376
367
|
historySource: "rollback"
|
|
377
368
|
});
|
|
378
|
-
return history_default.
|
|
369
|
+
return history_default.getDataSourceStepList(id).slice(-1)[0]?.step ?? null;
|
|
379
370
|
}
|
|
380
371
|
/**
|
|
381
372
|
* 把一条历史 step 应用到当前数据源服务上。
|
|
@@ -392,7 +383,7 @@ var DataSource = class extends BaseService {
|
|
|
392
383
|
* @param reverse true=撤销,false=重做
|
|
393
384
|
*/
|
|
394
385
|
applyHistoryStep(step, reverse) {
|
|
395
|
-
const { id } = step
|
|
386
|
+
const { id } = step;
|
|
396
387
|
const { oldSchema, newSchema, changeRecords } = step.diff?.[0] ?? {};
|
|
397
388
|
if (!oldSchema && newSchema) {
|
|
398
389
|
if (reverse) this.remove(`${id}`, { doNotPushHistory: true });
|
|
@@ -74,7 +74,7 @@ var Editor = class extends BaseService {
|
|
|
74
74
|
this.state.stageLoading = this.state.pageLength !== 0;
|
|
75
75
|
if (preValue && !isEmpty(preValue)) this.pushRootDiffHistory(preValue, app, options.historySource);
|
|
76
76
|
else app.items?.forEach((pageNode) => {
|
|
77
|
-
if (pageNode?.id !== void 0 && !history_default.
|
|
77
|
+
if (pageNode?.id !== void 0 && !history_default.getPageMarker(pageNode.id)) history_default.setPageMarker(pageNode.id, {
|
|
78
78
|
name: pageNode.name,
|
|
79
79
|
source: options.historySource
|
|
80
80
|
});
|
|
@@ -176,6 +176,8 @@ var Editor = class extends BaseService {
|
|
|
176
176
|
this.set("nodes", node ? [node] : []);
|
|
177
177
|
this.set("page", page);
|
|
178
178
|
this.set("parent", parent);
|
|
179
|
+
if (page) history_default.changePage(toRaw(page));
|
|
180
|
+
else history_default.resetState();
|
|
179
181
|
if (node?.id) this.get("stage")?.renderer?.runtime?.getApp?.()?.page?.emit("editor:select", {
|
|
180
182
|
node,
|
|
181
183
|
page,
|
|
@@ -366,7 +368,10 @@ var Editor = class extends BaseService {
|
|
|
366
368
|
if (pages[0]) {
|
|
367
369
|
await this.select(pages[0]);
|
|
368
370
|
stage?.select(pages[0].id);
|
|
369
|
-
} else
|
|
371
|
+
} else {
|
|
372
|
+
this.selectRoot();
|
|
373
|
+
history_default.resetPage();
|
|
374
|
+
}
|
|
370
375
|
};
|
|
371
376
|
const rootItems = root.items || [];
|
|
372
377
|
if (isPage(node)) {
|
|
@@ -870,9 +875,7 @@ var Editor = class extends BaseService {
|
|
|
870
875
|
* @returns 被撤销的操作
|
|
871
876
|
*/
|
|
872
877
|
async undo() {
|
|
873
|
-
const
|
|
874
|
-
if (pageId === void 0) return null;
|
|
875
|
-
const value = history_default.undo("page", pageId);
|
|
878
|
+
const value = history_default.undo();
|
|
876
879
|
if (value) await this.applyHistoryOp(value, true);
|
|
877
880
|
return value;
|
|
878
881
|
}
|
|
@@ -881,9 +884,7 @@ var Editor = class extends BaseService {
|
|
|
881
884
|
* @returns 被恢复的操作
|
|
882
885
|
*/
|
|
883
886
|
async redo() {
|
|
884
|
-
const
|
|
885
|
-
if (pageId === void 0) return null;
|
|
886
|
-
const value = history_default.redo("page", pageId);
|
|
887
|
+
const value = history_default.redo();
|
|
887
888
|
if (value) await this.applyHistoryOp(value, false);
|
|
888
889
|
return value;
|
|
889
890
|
}
|
|
@@ -904,7 +905,7 @@ var Editor = class extends BaseService {
|
|
|
904
905
|
* @returns 反向后产生的新 step;目标不存在 / 未应用 / 反向失败时返回 null
|
|
905
906
|
*/
|
|
906
907
|
async revertPageStep(index) {
|
|
907
|
-
const entry = history_default.
|
|
908
|
+
const entry = history_default.getPageStepList()[index];
|
|
908
909
|
if (!entry?.applied) return null;
|
|
909
910
|
const { step } = entry;
|
|
910
911
|
if (step.opType === "initial") return null;
|
|
@@ -914,7 +915,7 @@ var Editor = class extends BaseService {
|
|
|
914
915
|
if (!items.length || !items.every((item) => item.changeRecords?.length)) return null;
|
|
915
916
|
}
|
|
916
917
|
let revertedStep = null;
|
|
917
|
-
const captureRevert = (
|
|
918
|
+
const captureRevert = (s) => {
|
|
918
919
|
revertedStep = s;
|
|
919
920
|
};
|
|
920
921
|
history_default.once("change", captureRevert);
|
|
@@ -984,10 +985,9 @@ var Editor = class extends BaseService {
|
|
|
984
985
|
*/
|
|
985
986
|
async revertPageStepById(uuids) {
|
|
986
987
|
const results = [];
|
|
987
|
-
const pageId = this.get("page")?.id;
|
|
988
988
|
for (const uuid of uuids) {
|
|
989
|
-
const
|
|
990
|
-
results.push(
|
|
989
|
+
const index = history_default.getPageStepIndexByUuid(uuid);
|
|
990
|
+
results.push(index < 0 ? null : await this.revertPageStep(index));
|
|
991
991
|
}
|
|
992
992
|
return results;
|
|
993
993
|
}
|
|
@@ -1001,9 +1001,8 @@ var Editor = class extends BaseService {
|
|
|
1001
1001
|
* @returns 实际移动到的最终游标位置
|
|
1002
1002
|
*/
|
|
1003
1003
|
async gotoPageStep(targetCursor) {
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
const { length } = history_default.getStepList("page", pageId);
|
|
1004
|
+
let cursor = history_default.getPageCursor();
|
|
1005
|
+
const { length } = history_default.getPageStepList();
|
|
1007
1006
|
const target = Math.max(0, Math.min(targetCursor, length));
|
|
1008
1007
|
while (cursor > target) {
|
|
1009
1008
|
if (!await this.undo()) break;
|
|
@@ -1118,34 +1117,30 @@ var Editor = class extends BaseService {
|
|
|
1118
1117
|
id: page.id
|
|
1119
1118
|
},
|
|
1120
1119
|
opType,
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
modifiedNodeIds: /* @__PURE__ */ new Map()
|
|
1125
|
-
},
|
|
1120
|
+
selectedBefore: [],
|
|
1121
|
+
selectedAfter: [],
|
|
1122
|
+
modifiedNodeIds: /* @__PURE__ */ new Map(),
|
|
1126
1123
|
diff: [diffItem],
|
|
1127
1124
|
rootStep: true
|
|
1128
1125
|
};
|
|
1129
1126
|
if (source) step.source = source;
|
|
1130
1127
|
const top = history_default.getCurrentPageStep(page.id);
|
|
1131
|
-
if (top?.rootStep && top.source === source) history_default.
|
|
1132
|
-
else history_default.push(
|
|
1128
|
+
if (top?.rootStep && top.source === source) history_default.replaceCurrentPageStep(step, page.id);
|
|
1129
|
+
else history_default.push(step, page.id);
|
|
1133
1130
|
}
|
|
1134
1131
|
pushOpHistory(opType, { diff, pageData, historyDescription, source }) {
|
|
1135
1132
|
const step = {
|
|
1136
1133
|
uuid: guid(),
|
|
1137
1134
|
data: pageData,
|
|
1138
1135
|
opType,
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
modifiedNodeIds: new Map(this.get("modifiedNodeIds"))
|
|
1143
|
-
},
|
|
1136
|
+
selectedBefore: this.selectionBeforeOp ?? [],
|
|
1137
|
+
selectedAfter: this.get("nodes").map((n) => n.id),
|
|
1138
|
+
modifiedNodeIds: new Map(this.get("modifiedNodeIds")),
|
|
1144
1139
|
diff
|
|
1145
1140
|
};
|
|
1146
1141
|
if (historyDescription) step.historyDescription = historyDescription;
|
|
1147
1142
|
if (source) step.source = source;
|
|
1148
|
-
const historyId = history_default.push(
|
|
1143
|
+
const historyId = history_default.push(step, pageData.id) ? step.uuid : null;
|
|
1149
1144
|
this.lastPushedHistoryId = historyId;
|
|
1150
1145
|
this.selectionBeforeOp = null;
|
|
1151
1146
|
return historyId;
|
|
@@ -1246,10 +1241,10 @@ var Editor = class extends BaseService {
|
|
|
1246
1241
|
break;
|
|
1247
1242
|
}
|
|
1248
1243
|
}
|
|
1249
|
-
this.set("modifiedNodeIds", step.
|
|
1244
|
+
this.set("modifiedNodeIds", step.modifiedNodeIds);
|
|
1250
1245
|
const page = toRaw(this.get("page"));
|
|
1251
1246
|
if (page) {
|
|
1252
|
-
const selectIds =
|
|
1247
|
+
const selectIds = reverse ? step.selectedBefore : step.selectedAfter;
|
|
1253
1248
|
setTimeout(() => {
|
|
1254
1249
|
if (!selectIds.length) return;
|
|
1255
1250
|
if (selectIds.length > 1) {
|