@tmagic/editor 1.8.0-beta.4 → 1.8.0-beta.6
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/components/CompareForm.vue_vue_type_script_setup_true_lang.js +1 -1
- package/dist/es/components/ToolButton.vue_vue_type_script_setup_true_lang.js +6 -6
- 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 +6 -3
- package/dist/es/initService.js +1 -1
- package/dist/es/layouts/Framework.vue_vue_type_script_setup_true_lang.js +1 -1
- package/dist/es/layouts/history-list/Bucket.vue_vue_type_script_setup_true_lang.js +19 -55
- package/dist/es/layouts/history-list/BucketTab.vue_vue_type_script_setup_true_lang.js +22 -39
- package/dist/es/layouts/history-list/GroupRow.vue_vue_type_script_setup_true_lang.js +149 -103
- package/dist/es/layouts/history-list/HistoryDiffDialog.vue_vue_type_script_setup_true_lang.js +32 -8
- package/dist/es/layouts/history-list/HistoryListPanel.vue_vue_type_script_setup_true_lang.js +335 -213
- package/dist/es/layouts/history-list/InitialRow.vue_vue_type_script_setup_true_lang.js +36 -7
- package/dist/es/layouts/history-list/PageTab.vue_vue_type_script_setup_true_lang.js +47 -60
- package/dist/es/layouts/history-list/composables.js +73 -32
- package/dist/es/layouts/page-bar/PageBar.vue_vue_type_script_setup_true_lang.js +4 -2
- package/dist/es/layouts/sidebar/Sidebar.vue_vue_type_script_setup_true_lang.js +5 -1
- 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 +96 -37
- package/dist/es/services/dataSource.js +70 -26
- package/dist/es/services/editor.js +266 -104
- package/dist/es/services/history.js +271 -212
- package/dist/es/services/ui.js +3 -0
- package/dist/es/style.css +53 -7
- package/dist/es/utils/data-source/index.js +2 -0
- package/dist/es/utils/editor.js +103 -49
- package/dist/es/utils/history.js +232 -0
- package/dist/es/utils/indexed-db.js +86 -0
- package/dist/es/utils/undo-redo.js +60 -1
- package/dist/style.css +53 -7
- package/dist/tmagic-editor.umd.cjs +2064 -1000
- package/package.json +7 -7
- package/src/components/CompareForm.vue +3 -1
- package/src/components/ToolButton.vue +2 -2
- 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/index.ts +1 -0
- package/src/initService.ts +1 -1
- package/src/layouts/Framework.vue +1 -1
- package/src/layouts/history-list/Bucket.vue +34 -71
- package/src/layouts/history-list/BucketTab.vue +46 -54
- package/src/layouts/history-list/GroupRow.vue +146 -111
- package/src/layouts/history-list/HistoryDiffDialog.vue +94 -68
- package/src/layouts/history-list/HistoryListPanel.vue +298 -115
- package/src/layouts/history-list/InitialRow.vue +28 -9
- package/src/layouts/history-list/PageTab.vue +57 -51
- package/src/layouts/history-list/composables.ts +157 -36
- package/src/layouts/page-bar/PageBar.vue +4 -2
- package/src/layouts/sidebar/Sidebar.vue +6 -1
- package/src/layouts/sidebar/data-source/DataSourceConfigPanel.vue +30 -2
- package/src/layouts/sidebar/data-source/DataSourceListPanel.vue +26 -1
- package/src/services/codeBlock.ts +113 -37
- package/src/services/dataSource.ts +94 -40
- package/src/services/editor.ts +376 -136
- package/src/services/history.ts +306 -209
- package/src/services/ui.ts +7 -0
- package/src/theme/history-list-panel.scss +72 -5
- package/src/theme/page-bar.scss +0 -4
- package/src/theme/style-setter/border.scss +4 -1
- package/src/type.ts +183 -64
- package/src/utils/data-source/index.ts +2 -0
- package/src/utils/editor.ts +166 -60
- package/src/utils/history.ts +308 -0
- package/src/utils/index.ts +2 -0
- package/src/utils/indexed-db.ts +122 -0
- package/src/utils/undo-redo.ts +88 -0
- package/types/index.d.ts +813 -302
|
@@ -1,6 +1,32 @@
|
|
|
1
1
|
import { cloneDeep } from "lodash-es";
|
|
2
2
|
//#region packages/editor/src/utils/undo-redo.ts
|
|
3
|
-
var UndoRedo = class {
|
|
3
|
+
var UndoRedo = class UndoRedo {
|
|
4
|
+
/**
|
|
5
|
+
* 由 {@link UndoRedo.serialize} 产出的快照重建一个 UndoRedo 实例。
|
|
6
|
+
* 游标会被夹紧到 [0, length] 区间,避免脏数据导致越界。
|
|
7
|
+
*
|
|
8
|
+
* @param options.isSavedStep 可选谓词:若提供,则把游标定位到「最近一条满足该谓词的记录」之后
|
|
9
|
+
* (即恢复到最近一个已保存点);找不到匹配记录时退回快照中的原游标。
|
|
10
|
+
*/
|
|
11
|
+
static fromSerialized(data, options = {}) {
|
|
12
|
+
const undoRedo = new UndoRedo(data.listMaxSize);
|
|
13
|
+
const list = Array.isArray(data.elementList) ? data.elementList.map((item) => cloneDeep(item)) : [];
|
|
14
|
+
let cursor = Number.isFinite(data.listCursor) ? data.listCursor : list.length;
|
|
15
|
+
const overflow = list.length - undoRedo.listMaxSize;
|
|
16
|
+
if (overflow > 0) {
|
|
17
|
+
list.splice(0, overflow);
|
|
18
|
+
cursor -= overflow;
|
|
19
|
+
}
|
|
20
|
+
if (options.isSavedStep) {
|
|
21
|
+
for (let i = list.length - 1; i >= 0; i--) if (options.isSavedStep(list[i])) {
|
|
22
|
+
cursor = i + 1;
|
|
23
|
+
break;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
undoRedo.elementList = list;
|
|
27
|
+
undoRedo.listCursor = Math.max(0, Math.min(cursor, list.length));
|
|
28
|
+
return undoRedo;
|
|
29
|
+
}
|
|
4
30
|
elementList;
|
|
5
31
|
listCursor;
|
|
6
32
|
listMaxSize;
|
|
@@ -10,6 +36,17 @@ var UndoRedo = class {
|
|
|
10
36
|
this.listCursor = 0;
|
|
11
37
|
this.listMaxSize = listMaxSize > minListMaxSize ? listMaxSize : minListMaxSize;
|
|
12
38
|
}
|
|
39
|
+
/**
|
|
40
|
+
* 导出当前栈的可序列化快照(深克隆,避免外部改动污染内部状态)。
|
|
41
|
+
* 配合 {@link UndoRedo.fromSerialized} 可在持久化后完整还原撤销/重做栈。
|
|
42
|
+
*/
|
|
43
|
+
serialize() {
|
|
44
|
+
return {
|
|
45
|
+
elementList: this.elementList.map((item) => cloneDeep(item)),
|
|
46
|
+
listCursor: this.listCursor,
|
|
47
|
+
listMaxSize: this.listMaxSize
|
|
48
|
+
};
|
|
49
|
+
}
|
|
13
50
|
pushElement(element) {
|
|
14
51
|
this.elementList.splice(this.listCursor, this.elementList.length - this.listCursor, cloneDeep(element));
|
|
15
52
|
this.listCursor += 1;
|
|
@@ -42,6 +79,28 @@ var UndoRedo = class {
|
|
|
42
79
|
return cloneDeep(this.elementList[this.listCursor - 1]);
|
|
43
80
|
}
|
|
44
81
|
/**
|
|
82
|
+
* 用 `element` 替换当前游标所在元素(cursor - 1),并丢弃其后的重做尾部(与 {@link pushElement} 的丢尾一致),
|
|
83
|
+
* 游标位置保持不变(元素数量不增)。cursor 为 0(无已应用元素)时不做任何操作并返回 false。
|
|
84
|
+
* 用于「连续同类记录合并」等就地替换最新一条的场景。
|
|
85
|
+
*/
|
|
86
|
+
replaceCurrentElement(element) {
|
|
87
|
+
if (this.listCursor < 1) return false;
|
|
88
|
+
this.elementList.splice(this.listCursor - 1, this.elementList.length - (this.listCursor - 1), cloneDeep(element));
|
|
89
|
+
return true;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* 对当前游标所在元素(cursor - 1)做就地更新;cursor 为 0(全部已撤销)时不做任何操作。
|
|
93
|
+
* 用于给「当前步骤」打标记(如标记为已保存)等元数据写入场景。
|
|
94
|
+
*/
|
|
95
|
+
updateCurrentElement(updater) {
|
|
96
|
+
if (this.listCursor < 1) return;
|
|
97
|
+
updater(this.elementList[this.listCursor - 1]);
|
|
98
|
+
}
|
|
99
|
+
/** 对栈内全部元素做就地更新。用于批量清理元数据(如清空所有元素的已保存标记)。 */
|
|
100
|
+
updateElements(updater) {
|
|
101
|
+
this.elementList.forEach(updater);
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
45
104
|
* 返回栈内全部元素的浅克隆数组(按时间顺序,索引 0 为最早一步)。
|
|
46
105
|
* 仅用于历史面板等只读展示场景,不应直接修改返回值。
|
|
47
106
|
*/
|
package/dist/style.css
CHANGED
|
@@ -617,6 +617,23 @@ fieldset.m-fieldset .m-form-tip {
|
|
|
617
617
|
padding: 0;
|
|
618
618
|
list-style: none;
|
|
619
619
|
}
|
|
620
|
+
.m-editor-history-list-popover .m-editor-history-list-toolbar {
|
|
621
|
+
display: flex;
|
|
622
|
+
align-items: center;
|
|
623
|
+
justify-content: flex-end;
|
|
624
|
+
padding: 0 4px 4px;
|
|
625
|
+
}
|
|
626
|
+
.m-editor-history-list-popover .m-editor-history-list-clear {
|
|
627
|
+
padding: 2px 8px;
|
|
628
|
+
border-radius: 4px;
|
|
629
|
+
font-size: 12px;
|
|
630
|
+
color: #f56c6c;
|
|
631
|
+
cursor: pointer;
|
|
632
|
+
user-select: none;
|
|
633
|
+
}
|
|
634
|
+
.m-editor-history-list-popover .m-editor-history-list-clear:hover {
|
|
635
|
+
background-color: rgba(245, 108, 108, 0.12);
|
|
636
|
+
}
|
|
620
637
|
.m-editor-history-list-popover .m-editor-history-list-item {
|
|
621
638
|
display: flex;
|
|
622
639
|
align-items: center;
|
|
@@ -750,12 +767,18 @@ fieldset.m-fieldset .m-form-tip {
|
|
|
750
767
|
}
|
|
751
768
|
.m-editor-history-list-popover .m-editor-history-list-item-index {
|
|
752
769
|
flex: 0 0 auto;
|
|
770
|
+
min-width: 30px;
|
|
771
|
+
text-align: right;
|
|
753
772
|
color: #909399;
|
|
754
773
|
font-family: Menlo, Monaco, Consolas, "Courier New", monospace;
|
|
755
774
|
font-size: 11px;
|
|
756
775
|
font-weight: 400;
|
|
757
776
|
white-space: nowrap;
|
|
758
777
|
}
|
|
778
|
+
.m-editor-history-list-popover .m-editor-history-list-group.is-merged > .m-editor-history-list-group-head > .m-editor-history-list-item-index {
|
|
779
|
+
min-width: 0;
|
|
780
|
+
text-align: left;
|
|
781
|
+
}
|
|
759
782
|
.m-editor-history-list-popover .m-editor-history-list-item-time {
|
|
760
783
|
flex: 0 0 auto;
|
|
761
784
|
color: #a8abb2;
|
|
@@ -816,6 +839,18 @@ fieldset.m-fieldset .m-form-tip {
|
|
|
816
839
|
white-space: nowrap;
|
|
817
840
|
font-weight: 400;
|
|
818
841
|
}
|
|
842
|
+
.m-editor-history-list-popover .m-editor-history-list-item-saved {
|
|
843
|
+
flex: 0 0 auto;
|
|
844
|
+
padding: 0 6px;
|
|
845
|
+
border-radius: 8px;
|
|
846
|
+
font-size: 10px;
|
|
847
|
+
line-height: 16px;
|
|
848
|
+
color: #fff;
|
|
849
|
+
background-color: #67c23a;
|
|
850
|
+
white-space: nowrap;
|
|
851
|
+
font-weight: 500;
|
|
852
|
+
letter-spacing: 0.2px;
|
|
853
|
+
}
|
|
819
854
|
.m-editor-history-list-popover .m-editor-history-list-item-merge {
|
|
820
855
|
flex: 0 0 auto;
|
|
821
856
|
padding: 0 8px;
|
|
@@ -827,6 +862,17 @@ fieldset.m-fieldset .m-form-tip {
|
|
|
827
862
|
font-weight: 500;
|
|
828
863
|
letter-spacing: 0.2px;
|
|
829
864
|
}
|
|
865
|
+
.m-editor-history-list-popover .m-editor-history-list-item-actions {
|
|
866
|
+
display: none;
|
|
867
|
+
flex: 0 0 auto;
|
|
868
|
+
align-items: center;
|
|
869
|
+
gap: 6px;
|
|
870
|
+
}
|
|
871
|
+
.m-editor-history-list-popover .m-editor-history-list-group-head:hover > .m-editor-history-list-item-actions,
|
|
872
|
+
.m-editor-history-list-popover .m-editor-history-list-substeps > li:hover > .m-editor-history-list-item-actions,
|
|
873
|
+
.m-editor-history-list-popover .m-editor-history-list-initial:hover > .m-editor-history-list-item-actions {
|
|
874
|
+
display: flex;
|
|
875
|
+
}
|
|
830
876
|
.m-editor-history-list-popover .m-editor-history-list-item-diff {
|
|
831
877
|
flex: 0 0 auto;
|
|
832
878
|
padding: 0 6px;
|
|
@@ -847,13 +893,13 @@ fieldset.m-fieldset .m-form-tip {
|
|
|
847
893
|
border-radius: 2px;
|
|
848
894
|
font-size: 10px;
|
|
849
895
|
line-height: 16px;
|
|
850
|
-
color: #
|
|
851
|
-
background-color: rgba(
|
|
896
|
+
color: #529b2e;
|
|
897
|
+
background-color: rgba(103, 194, 58, 0.12);
|
|
852
898
|
cursor: pointer;
|
|
853
899
|
user-select: none;
|
|
854
900
|
}
|
|
855
901
|
.m-editor-history-list-popover .m-editor-history-list-item-goto:hover {
|
|
856
|
-
background-color: rgba(
|
|
902
|
+
background-color: rgba(103, 194, 58, 0.24);
|
|
857
903
|
}
|
|
858
904
|
.m-editor-history-list-popover .m-editor-history-list-item-revert {
|
|
859
905
|
flex: 0 0 auto;
|
|
@@ -1396,9 +1442,6 @@ fieldset.m-fieldset .m-form-tip {
|
|
|
1396
1442
|
transition: all 0.2s ease 0s;
|
|
1397
1443
|
padding: 5px 14px;
|
|
1398
1444
|
}
|
|
1399
|
-
.page-bar-popover .menu-item .tmagic-design-button {
|
|
1400
|
-
color: #313a40;
|
|
1401
|
-
}
|
|
1402
1445
|
.page-bar-popover .menu-item:hover {
|
|
1403
1446
|
background-color: #f3f5f9;
|
|
1404
1447
|
}
|
|
@@ -2050,9 +2093,12 @@ fieldset.m-fieldset .m-form-tip {
|
|
|
2050
2093
|
.border-box-container .border-icon-container .border-icon + .border-icon {
|
|
2051
2094
|
margin-left: 8px;
|
|
2052
2095
|
}
|
|
2096
|
+
.border-box-container .border-icon-container .border-icon.configured {
|
|
2097
|
+
border-color: var(--el-color-success, var(--td-success-color, #2ba471));
|
|
2098
|
+
}
|
|
2053
2099
|
.border-box-container .border-icon-container .border-icon.active {
|
|
2054
2100
|
border-width: 1px;
|
|
2055
|
-
border-color: var(--el-color-primary);
|
|
2101
|
+
border-color: var(--el-color-primary, var(--td-brand-color, #0052d9));
|
|
2056
2102
|
}
|
|
2057
2103
|
.border-box-container .border-icon-container .border-icon.border-icon-top {
|
|
2058
2104
|
border-top-width: 2px;
|