@tmagic/editor 1.8.0-beta.2 → 1.8.0-beta.3

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.
Files changed (45) hide show
  1. package/dist/es/Editor.vue_vue_type_script_setup_true_lang.js +9 -0
  2. package/dist/es/components/CompareForm.vue_vue_type_script_setup_true_lang.js +32 -28
  3. package/dist/es/editorProps.js +2 -0
  4. package/dist/es/fields/CodeLink.vue_vue_type_script_setup_true_lang.js +2 -5
  5. package/dist/es/hooks/use-stage.js +2 -1
  6. package/dist/es/index.js +3 -1
  7. package/dist/es/layouts/CodeEditor.vue_vue_type_script_setup_true_lang.js +2 -5
  8. package/dist/es/layouts/history-list/Bucket.vue_vue_type_script_setup_true_lang.js +33 -14
  9. package/dist/es/layouts/history-list/BucketTab.js +5 -0
  10. package/dist/es/layouts/history-list/{CodeBlockTab.vue_vue_type_script_setup_true_lang.js → BucketTab.vue_vue_type_script_setup_true_lang.js} +27 -16
  11. package/dist/es/layouts/history-list/GroupRow.vue_vue_type_script_setup_true_lang.js +71 -53
  12. package/dist/es/layouts/history-list/HistoryDiffDialog.vue_vue_type_script_setup_true_lang.js +78 -28
  13. package/dist/es/layouts/history-list/HistoryListPanel.vue_vue_type_script_setup_true_lang.js +136 -66
  14. package/dist/es/layouts/history-list/InitialRow.vue_vue_type_script_setup_true_lang.js +15 -9
  15. package/dist/es/layouts/history-list/PageTab.vue_vue_type_script_setup_true_lang.js +12 -6
  16. package/dist/es/layouts/history-list/composables.js +20 -2
  17. package/dist/es/services/history.js +5 -2
  18. package/dist/es/style.css +44 -12
  19. package/dist/style.css +44 -12
  20. package/dist/tmagic-editor.umd.cjs +479 -326
  21. package/package.json +7 -7
  22. package/src/Editor.vue +8 -0
  23. package/src/components/CompareForm.vue +32 -19
  24. package/src/editorProps.ts +7 -0
  25. package/src/fields/CodeLink.vue +2 -5
  26. package/src/hooks/use-stage.ts +1 -0
  27. package/src/index.ts +2 -0
  28. package/src/layouts/CodeEditor.vue +2 -5
  29. package/src/layouts/history-list/Bucket.vue +53 -28
  30. package/src/layouts/history-list/BucketTab.vue +77 -0
  31. package/src/layouts/history-list/GroupRow.vue +95 -60
  32. package/src/layouts/history-list/HistoryDiffDialog.vue +51 -32
  33. package/src/layouts/history-list/HistoryListPanel.vue +161 -52
  34. package/src/layouts/history-list/InitialRow.vue +17 -6
  35. package/src/layouts/history-list/PageTab.vue +20 -6
  36. package/src/layouts/history-list/composables.ts +32 -1
  37. package/src/services/history.ts +3 -0
  38. package/src/theme/history-list-panel.scss +52 -13
  39. package/src/type.ts +90 -0
  40. package/types/index.d.ts +295 -135
  41. package/dist/es/layouts/history-list/CodeBlockTab.js +0 -5
  42. package/dist/es/layouts/history-list/DataSourceTab.js +0 -5
  43. package/dist/es/layouts/history-list/DataSourceTab.vue_vue_type_script_setup_true_lang.js +0 -62
  44. package/src/layouts/history-list/CodeBlockTab.vue +0 -61
  45. package/src/layouts/history-list/DataSourceTab.vue +0 -61
@@ -1,4 +1,5 @@
1
1
  import { useServices } from "../../hooks/use-services.js";
2
+ import { datetimeFormatter } from "@tmagic/form";
2
3
  import { computed, reactive } from "vue";
3
4
  //#region packages/editor/src/layouts/history-list/composables.ts
4
5
  /**
@@ -11,7 +12,10 @@ import { computed, reactive } from "vue";
11
12
  */
12
13
  var useHistoryList = () => {
13
14
  const { historyService } = useServices();
14
- /** 折叠状态:key 形如 `pg-${groupIdx}` / `ds-${id}-${groupIdx}` / `cb-${id}-${groupIdx}`。 */
15
+ /**
16
+ * 折叠状态:key 形如 `pg-${组内首步 index}` / `ds-${id}-${组内首步 index}` / `cb-${id}-${组内首步 index}`。
17
+ * 用组内首步的稳定 index(而非展示位置)作为 key,确保历史数据更新后已展开的分组状态保持不变。
18
+ */
15
19
  const expanded = reactive({});
16
20
  const toggleGroup = (key) => {
17
21
  expanded[key] = !expanded[key];
@@ -48,6 +52,20 @@ var useHistoryList = () => {
48
52
  codeBlockGroupsByTarget: computed(() => groupByTarget(codeBlockGroups.value))
49
53
  };
50
54
  };
55
+ /**
56
+ * 历史面板的时间展示:
57
+ * - 当天的记录只显示 `HH:mm:ss`;
58
+ * - 跨天的记录显示 `MM-DD HH:mm:ss`。
59
+ * 无时间戳(旧数据 / 未写入)时返回空串,UI 据此不渲染时间。
60
+ */
61
+ var formatHistoryTime = (timestamp) => {
62
+ if (!timestamp) return "";
63
+ return `${datetimeFormatter(new Date(timestamp), "", "YYYY-MM-DD") === datetimeFormatter(/* @__PURE__ */ new Date(), "", "YYYY-MM-DD") ? datetimeFormatter(new Date(timestamp), "", "HH:mm:ss") : datetimeFormatter(new Date(timestamp), "", "MM-DD HH:mm:ss")}`;
64
+ };
65
+ /** 完整时间(含年份与秒),用于 title 悬浮提示。无时间戳时返回空串。 */
66
+ var formatHistoryFullTime = (timestamp) => timestamp ? `${datetimeFormatter(new Date(timestamp), "", "YYYY-MM-DD HH:mm:ss")}` : "";
67
+ /** 取一组历史步骤里最后一步(最近一次)的时间戳,用于组头部展示。 */
68
+ var groupTimestamp = (group) => group.steps[group.steps.length - 1]?.step.timestamp;
51
69
  var opLabel = (op) => {
52
70
  switch (op) {
53
71
  case "add": return "新增";
@@ -151,4 +169,4 @@ var describeCodeBlockGroup = (group) => {
151
169
  return pathList ? `修改 ${target} · ${pathList}${paths.size > 3 ? "…" : ""}` : `修改 ${target}`;
152
170
  };
153
171
  //#endregion
154
- export { describeCodeBlockGroup, describeCodeBlockStep, describeDataSourceGroup, describeDataSourceStep, describePageGroup, describePageStep, opLabel, useHistoryList };
172
+ export { describeCodeBlockGroup, describeCodeBlockStep, describeDataSourceGroup, describeDataSourceStep, describePageGroup, describePageStep, formatHistoryFullTime, formatHistoryTime, groupTimestamp, opLabel, useHistoryList };
@@ -214,6 +214,7 @@ var history_default = new class History extends BaseService {
214
214
  push(state, pageId) {
215
215
  const undoRedo = this.getUndoRedo(pageId);
216
216
  if (!undoRedo) return null;
217
+ if (state.timestamp === void 0) state.timestamp = Date.now();
217
218
  undoRedo.pushElement(state);
218
219
  if (pageId === void 0 || `${pageId}` === `${this.state.pageId}`) this.emit("change", state);
219
220
  return state;
@@ -234,7 +235,8 @@ var history_default = new class History extends BaseService {
234
235
  oldContent: payload.oldContent ? cloneDeep(payload.oldContent) : null,
235
236
  newContent: payload.newContent ? cloneDeep(payload.newContent) : null,
236
237
  changeRecords: payload.changeRecords?.length ? cloneDeep(payload.changeRecords) : void 0,
237
- historyDescription: payload.historyDescription
238
+ historyDescription: payload.historyDescription,
239
+ timestamp: Date.now()
238
240
  };
239
241
  this.getCodeBlockUndoRedo(codeBlockId).pushElement(step);
240
242
  this.emit("code-block-history-change", codeBlockId, step);
@@ -251,7 +253,8 @@ var history_default = new class History extends BaseService {
251
253
  oldSchema: payload.oldSchema ? cloneDeep(payload.oldSchema) : null,
252
254
  newSchema: payload.newSchema ? cloneDeep(payload.newSchema) : null,
253
255
  changeRecords: payload.changeRecords?.length ? cloneDeep(payload.changeRecords) : void 0,
254
- historyDescription: payload.historyDescription
256
+ historyDescription: payload.historyDescription,
257
+ timestamp: Date.now()
255
258
  };
256
259
  this.getDataSourceUndoRedo(dataSourceId).pushElement(step);
257
260
  this.emit("data-source-history-change", dataSourceId, step);
package/dist/es/style.css CHANGED
@@ -678,17 +678,17 @@ fieldset.m-fieldset .m-form-tip {
678
678
  .m-editor-history-list-popover .m-editor-history-list-group.is-merged {
679
679
  margin: 4px 0;
680
680
  padding: 4px 8px 6px;
681
- background-color: rgba(144, 105, 219, 0.06);
682
- border: 1px solid rgba(144, 105, 219, 0.18);
683
- border-left: 3px solid #9069db;
681
+ background-color: rgba(47, 84, 235, 0.06);
682
+ border: 1px solid rgba(47, 84, 235, 0.18);
683
+ border-left: 3px solid #2f54eb;
684
684
  border-radius: 4px;
685
685
  }
686
686
  .m-editor-history-list-popover .m-editor-history-list-group.is-merged:hover {
687
- background-color: rgba(144, 105, 219, 0.1);
687
+ background-color: rgba(47, 84, 235, 0.1);
688
688
  }
689
689
  .m-editor-history-list-popover .m-editor-history-list-group.is-merged .m-editor-history-list-group-head {
690
690
  font-weight: 600;
691
- color: #5b3fa5;
691
+ color: #1d39c4;
692
692
  }
693
693
  .m-editor-history-list-popover .m-editor-history-list-group.is-merged.is-undone {
694
694
  background-color: rgba(192, 196, 204, 0.08);
@@ -711,7 +711,7 @@ fieldset.m-fieldset .m-form-tip {
711
711
  margin: 6px 0 0 6px;
712
712
  padding: 0;
713
713
  list-style: none;
714
- border-left: 1px dashed rgba(144, 105, 219, 0.45);
714
+ border-left: 1px dashed rgba(47, 84, 235, 0.45);
715
715
  }
716
716
  .m-editor-history-list-popover .m-editor-history-list-substeps li {
717
717
  display: flex;
@@ -727,7 +727,7 @@ fieldset.m-fieldset .m-form-tip {
727
727
  cursor: pointer;
728
728
  }
729
729
  .m-editor-history-list-popover .m-editor-history-list-substeps li.is-clickable:hover {
730
- background-color: rgba(144, 105, 219, 0.1);
730
+ background-color: rgba(47, 84, 235, 0.1);
731
731
  }
732
732
  .m-editor-history-list-popover .m-editor-history-list-substeps li.is-undone {
733
733
  color: #c0c4cc;
@@ -756,6 +756,14 @@ fieldset.m-fieldset .m-form-tip {
756
756
  font-weight: 400;
757
757
  white-space: nowrap;
758
758
  }
759
+ .m-editor-history-list-popover .m-editor-history-list-item-time {
760
+ flex: 0 0 auto;
761
+ color: #a8abb2;
762
+ font-family: Menlo, Monaco, Consolas, "Courier New", monospace;
763
+ font-size: 11px;
764
+ font-weight: 400;
765
+ white-space: nowrap;
766
+ }
759
767
  .m-editor-history-list-popover .m-editor-history-list-item-op {
760
768
  flex: 0 0 auto;
761
769
  padding: 0 6px;
@@ -772,7 +780,7 @@ fieldset.m-fieldset .m-form-tip {
772
780
  background-color: #f56c6c;
773
781
  }
774
782
  .m-editor-history-list-popover .m-editor-history-list-item-op.op-update {
775
- background-color: #409eff;
783
+ background-color: #e6a23c;
776
784
  }
777
785
  .m-editor-history-list-popover .m-editor-history-list-item-op.op-initial {
778
786
  background-color: #909399;
@@ -803,7 +811,7 @@ fieldset.m-fieldset .m-form-tip {
803
811
  font-size: 10px;
804
812
  line-height: 16px;
805
813
  color: #fff;
806
- background-color: #9069db;
814
+ background-color: #2f54eb;
807
815
  font-weight: 500;
808
816
  letter-spacing: 0.2px;
809
817
  }
@@ -821,19 +829,33 @@ fieldset.m-fieldset .m-form-tip {
821
829
  .m-editor-history-list-popover .m-editor-history-list-item-diff:hover {
822
830
  background-color: rgba(64, 158, 255, 0.2);
823
831
  }
832
+ .m-editor-history-list-popover .m-editor-history-list-item-goto {
833
+ flex: 0 0 auto;
834
+ padding: 0 6px;
835
+ border-radius: 2px;
836
+ font-size: 10px;
837
+ line-height: 16px;
838
+ color: #606266;
839
+ background-color: rgba(96, 98, 102, 0.1);
840
+ cursor: pointer;
841
+ user-select: none;
842
+ }
843
+ .m-editor-history-list-popover .m-editor-history-list-item-goto:hover {
844
+ background-color: rgba(96, 98, 102, 0.18);
845
+ }
824
846
  .m-editor-history-list-popover .m-editor-history-list-item-revert {
825
847
  flex: 0 0 auto;
826
848
  padding: 0 6px;
827
849
  border-radius: 2px;
828
850
  font-size: 10px;
829
851
  line-height: 16px;
830
- color: #e6a23c;
831
- background-color: rgba(230, 162, 60, 0.12);
852
+ color: #f56c6c;
853
+ background-color: rgba(245, 108, 108, 0.12);
832
854
  cursor: pointer;
833
855
  user-select: none;
834
856
  }
835
857
  .m-editor-history-list-popover .m-editor-history-list-item-revert:hover {
836
- background-color: rgba(230, 162, 60, 0.25);
858
+ background-color: rgba(245, 108, 108, 0.25);
837
859
  }
838
860
  .m-editor-history-list-popover .m-editor-history-list-substep-desc {
839
861
  flex: 1 1 auto;
@@ -878,6 +900,16 @@ fieldset.m-fieldset .m-form-tip {
878
900
  display: flex;
879
901
  flex-direction: column;
880
902
  }
903
+ .m-editor-history-diff-dialog .m-editor-history-diff-dialog-notice {
904
+ margin-bottom: 8px;
905
+ padding: 8px 12px;
906
+ background-color: #fdf6ec;
907
+ border: 1px solid #faecd8;
908
+ border-radius: 4px;
909
+ color: #e6a23c;
910
+ font-size: 13px;
911
+ line-height: 1.5;
912
+ }
881
913
  .m-editor-history-diff-dialog .m-editor-history-diff-dialog-header {
882
914
  display: flex;
883
915
  align-items: center;
package/dist/style.css CHANGED
@@ -678,17 +678,17 @@ fieldset.m-fieldset .m-form-tip {
678
678
  .m-editor-history-list-popover .m-editor-history-list-group.is-merged {
679
679
  margin: 4px 0;
680
680
  padding: 4px 8px 6px;
681
- background-color: rgba(144, 105, 219, 0.06);
682
- border: 1px solid rgba(144, 105, 219, 0.18);
683
- border-left: 3px solid #9069db;
681
+ background-color: rgba(47, 84, 235, 0.06);
682
+ border: 1px solid rgba(47, 84, 235, 0.18);
683
+ border-left: 3px solid #2f54eb;
684
684
  border-radius: 4px;
685
685
  }
686
686
  .m-editor-history-list-popover .m-editor-history-list-group.is-merged:hover {
687
- background-color: rgba(144, 105, 219, 0.1);
687
+ background-color: rgba(47, 84, 235, 0.1);
688
688
  }
689
689
  .m-editor-history-list-popover .m-editor-history-list-group.is-merged .m-editor-history-list-group-head {
690
690
  font-weight: 600;
691
- color: #5b3fa5;
691
+ color: #1d39c4;
692
692
  }
693
693
  .m-editor-history-list-popover .m-editor-history-list-group.is-merged.is-undone {
694
694
  background-color: rgba(192, 196, 204, 0.08);
@@ -711,7 +711,7 @@ fieldset.m-fieldset .m-form-tip {
711
711
  margin: 6px 0 0 6px;
712
712
  padding: 0;
713
713
  list-style: none;
714
- border-left: 1px dashed rgba(144, 105, 219, 0.45);
714
+ border-left: 1px dashed rgba(47, 84, 235, 0.45);
715
715
  }
716
716
  .m-editor-history-list-popover .m-editor-history-list-substeps li {
717
717
  display: flex;
@@ -727,7 +727,7 @@ fieldset.m-fieldset .m-form-tip {
727
727
  cursor: pointer;
728
728
  }
729
729
  .m-editor-history-list-popover .m-editor-history-list-substeps li.is-clickable:hover {
730
- background-color: rgba(144, 105, 219, 0.1);
730
+ background-color: rgba(47, 84, 235, 0.1);
731
731
  }
732
732
  .m-editor-history-list-popover .m-editor-history-list-substeps li.is-undone {
733
733
  color: #c0c4cc;
@@ -756,6 +756,14 @@ fieldset.m-fieldset .m-form-tip {
756
756
  font-weight: 400;
757
757
  white-space: nowrap;
758
758
  }
759
+ .m-editor-history-list-popover .m-editor-history-list-item-time {
760
+ flex: 0 0 auto;
761
+ color: #a8abb2;
762
+ font-family: Menlo, Monaco, Consolas, "Courier New", monospace;
763
+ font-size: 11px;
764
+ font-weight: 400;
765
+ white-space: nowrap;
766
+ }
759
767
  .m-editor-history-list-popover .m-editor-history-list-item-op {
760
768
  flex: 0 0 auto;
761
769
  padding: 0 6px;
@@ -772,7 +780,7 @@ fieldset.m-fieldset .m-form-tip {
772
780
  background-color: #f56c6c;
773
781
  }
774
782
  .m-editor-history-list-popover .m-editor-history-list-item-op.op-update {
775
- background-color: #409eff;
783
+ background-color: #e6a23c;
776
784
  }
777
785
  .m-editor-history-list-popover .m-editor-history-list-item-op.op-initial {
778
786
  background-color: #909399;
@@ -803,7 +811,7 @@ fieldset.m-fieldset .m-form-tip {
803
811
  font-size: 10px;
804
812
  line-height: 16px;
805
813
  color: #fff;
806
- background-color: #9069db;
814
+ background-color: #2f54eb;
807
815
  font-weight: 500;
808
816
  letter-spacing: 0.2px;
809
817
  }
@@ -821,19 +829,33 @@ fieldset.m-fieldset .m-form-tip {
821
829
  .m-editor-history-list-popover .m-editor-history-list-item-diff:hover {
822
830
  background-color: rgba(64, 158, 255, 0.2);
823
831
  }
832
+ .m-editor-history-list-popover .m-editor-history-list-item-goto {
833
+ flex: 0 0 auto;
834
+ padding: 0 6px;
835
+ border-radius: 2px;
836
+ font-size: 10px;
837
+ line-height: 16px;
838
+ color: #606266;
839
+ background-color: rgba(96, 98, 102, 0.1);
840
+ cursor: pointer;
841
+ user-select: none;
842
+ }
843
+ .m-editor-history-list-popover .m-editor-history-list-item-goto:hover {
844
+ background-color: rgba(96, 98, 102, 0.18);
845
+ }
824
846
  .m-editor-history-list-popover .m-editor-history-list-item-revert {
825
847
  flex: 0 0 auto;
826
848
  padding: 0 6px;
827
849
  border-radius: 2px;
828
850
  font-size: 10px;
829
851
  line-height: 16px;
830
- color: #e6a23c;
831
- background-color: rgba(230, 162, 60, 0.12);
852
+ color: #f56c6c;
853
+ background-color: rgba(245, 108, 108, 0.12);
832
854
  cursor: pointer;
833
855
  user-select: none;
834
856
  }
835
857
  .m-editor-history-list-popover .m-editor-history-list-item-revert:hover {
836
- background-color: rgba(230, 162, 60, 0.25);
858
+ background-color: rgba(245, 108, 108, 0.25);
837
859
  }
838
860
  .m-editor-history-list-popover .m-editor-history-list-substep-desc {
839
861
  flex: 1 1 auto;
@@ -878,6 +900,16 @@ fieldset.m-fieldset .m-form-tip {
878
900
  display: flex;
879
901
  flex-direction: column;
880
902
  }
903
+ .m-editor-history-diff-dialog .m-editor-history-diff-dialog-notice {
904
+ margin-bottom: 8px;
905
+ padding: 8px 12px;
906
+ background-color: #fdf6ec;
907
+ border: 1px solid #faecd8;
908
+ border-radius: 4px;
909
+ color: #e6a23c;
910
+ font-size: 13px;
911
+ line-height: 1.5;
912
+ }
881
913
  .m-editor-history-diff-dialog .m-editor-history-diff-dialog-header {
882
914
  display: flex;
883
915
  align-items: center;