@tmagic/editor 1.8.0-beta.1 → 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 (119) hide show
  1. package/dist/es/Editor.vue_vue_type_script_setup_true_lang.js +20 -2
  2. package/dist/es/components/CodeBlockEditor.vue_vue_type_script_setup_true_lang.js +18 -110
  3. package/dist/es/components/CodeParams.vue_vue_type_script_setup_true_lang.js +6 -0
  4. package/dist/es/components/CompareForm.js +5 -0
  5. package/dist/es/components/CompareForm.vue_vue_type_script_setup_true_lang.js +171 -0
  6. package/dist/es/editorProps.js +2 -0
  7. package/dist/es/fields/Code.vue_vue_type_script_setup_true_lang.js +19 -3
  8. package/dist/es/fields/CodeLink.vue_vue_type_script_setup_true_lang.js +2 -5
  9. package/dist/es/fields/CodeSelect.vue_vue_type_script_setup_true_lang.js +18 -2
  10. package/dist/es/fields/CodeSelectCol.vue_vue_type_script_setup_true_lang.js +37 -6
  11. package/dist/es/fields/DataSourceFieldSelect/FieldSelect.vue_vue_type_script_setup_true_lang.js +3 -1
  12. package/dist/es/fields/DataSourceFieldSelect/Index.vue_vue_type_script_setup_true_lang.js +2 -2
  13. package/dist/es/fields/DataSourceFields.vue_vue_type_script_setup_true_lang.js +14 -6
  14. package/dist/es/fields/DataSourceMethodSelect.vue_vue_type_script_setup_true_name_true_lang.js +3 -1
  15. package/dist/es/fields/DataSourceMethods.vue_vue_type_script_setup_true_lang.js +15 -7
  16. package/dist/es/fields/DataSourceMocks.vue_vue_type_script_setup_true_lang.js +14 -6
  17. package/dist/es/fields/DataSourceSelect.vue_vue_type_script_setup_true_lang.js +3 -1
  18. package/dist/es/fields/EventSelect.vue_vue_type_script_setup_true_lang.js +58 -11
  19. package/dist/es/fields/KeyValue.vue_vue_type_script_setup_true_lang.js +11 -6
  20. package/dist/es/fields/UISelect.vue_vue_type_script_setup_true_lang.js +8 -5
  21. package/dist/es/hooks/use-code-block-edit.js +2 -2
  22. package/dist/es/hooks/use-stage.js +17 -8
  23. package/dist/es/index.js +5 -1
  24. package/dist/es/initService.js +6 -6
  25. package/dist/es/layouts/CodeEditor.vue_vue_type_script_setup_true_lang.js +6 -5
  26. package/dist/es/layouts/Framework.vue_vue_type_script_setup_true_lang.js +12 -7
  27. package/dist/es/layouts/NavMenu.vue_vue_type_script_setup_true_lang.js +8 -0
  28. package/dist/es/layouts/history-list/Bucket.js +5 -0
  29. package/dist/es/layouts/history-list/Bucket.vue_vue_type_script_setup_true_lang.js +103 -0
  30. package/dist/es/layouts/history-list/BucketTab.js +5 -0
  31. package/dist/es/layouts/history-list/BucketTab.vue_vue_type_script_setup_true_lang.js +73 -0
  32. package/dist/es/layouts/history-list/GroupRow.js +5 -0
  33. package/dist/es/layouts/history-list/GroupRow.vue_vue_type_script_setup_true_lang.js +198 -0
  34. package/dist/es/layouts/history-list/HistoryDiffDialog.js +5 -0
  35. package/dist/es/layouts/history-list/HistoryDiffDialog.vue_vue_type_script_setup_true_lang.js +245 -0
  36. package/dist/es/layouts/history-list/HistoryListPanel.js +5 -0
  37. package/dist/es/layouts/history-list/HistoryListPanel.vue_vue_type_script_setup_true_lang.js +340 -0
  38. package/dist/es/layouts/history-list/InitialRow.js +5 -0
  39. package/dist/es/layouts/history-list/InitialRow.vue_vue_type_script_setup_true_lang.js +54 -0
  40. package/dist/es/layouts/history-list/PageTab.js +5 -0
  41. package/dist/es/layouts/history-list/PageTab.vue_vue_type_script_setup_true_lang.js +105 -0
  42. package/dist/es/layouts/history-list/composables.js +172 -0
  43. package/dist/es/layouts/sidebar/layer/use-node-status.js +1 -1
  44. package/dist/es/services/BaseService.js +31 -68
  45. package/dist/es/services/codeBlock.js +205 -8
  46. package/dist/es/services/componentList.js +2 -2
  47. package/dist/es/services/dataSource.js +217 -8
  48. package/dist/es/services/dep.js +21 -9
  49. package/dist/es/services/editor.js +350 -160
  50. package/dist/es/services/events.js +2 -2
  51. package/dist/es/services/history.js +410 -12
  52. package/dist/es/services/keybinding.js +2 -2
  53. package/dist/es/services/props.js +8 -8
  54. package/dist/es/services/stageOverlay.js +2 -2
  55. package/dist/es/services/storage.js +2 -2
  56. package/dist/es/services/ui.js +2 -2
  57. package/dist/es/style.css +379 -1
  58. package/dist/es/utils/code-block.js +122 -0
  59. package/dist/es/utils/content-menu.js +4 -5
  60. package/dist/es/utils/dep/worker.js +1 -1
  61. package/dist/es/utils/editor.js +2 -2
  62. package/dist/es/utils/undo-redo.js +20 -0
  63. package/dist/style.css +379 -1
  64. package/dist/tmagic-editor.umd.cjs +3331 -787
  65. package/package.json +7 -7
  66. package/src/Editor.vue +15 -0
  67. package/src/components/CodeBlockEditor.vue +20 -109
  68. package/src/components/CodeParams.vue +6 -0
  69. package/src/components/CompareForm.vue +238 -0
  70. package/src/editorProps.ts +9 -0
  71. package/src/fields/Code.vue +19 -3
  72. package/src/fields/CodeLink.vue +2 -5
  73. package/src/fields/CodeSelect.vue +17 -1
  74. package/src/fields/CodeSelectCol.vue +30 -2
  75. package/src/fields/DataSourceFieldSelect/FieldSelect.vue +7 -1
  76. package/src/fields/DataSourceFieldSelect/Index.vue +2 -2
  77. package/src/fields/DataSourceFields.vue +12 -3
  78. package/src/fields/DataSourceMethodSelect.vue +4 -1
  79. package/src/fields/DataSourceMethods.vue +14 -4
  80. package/src/fields/DataSourceMocks.vue +13 -3
  81. package/src/fields/DataSourceSelect.vue +4 -1
  82. package/src/fields/EventSelect.vue +57 -8
  83. package/src/fields/KeyValue.vue +17 -4
  84. package/src/fields/UISelect.vue +5 -2
  85. package/src/hooks/use-code-block-edit.ts +5 -2
  86. package/src/hooks/use-stage.ts +24 -7
  87. package/src/index.ts +3 -0
  88. package/src/layouts/CodeEditor.vue +17 -5
  89. package/src/layouts/Framework.vue +10 -5
  90. package/src/layouts/NavMenu.vue +9 -0
  91. package/src/layouts/history-list/Bucket.vue +124 -0
  92. package/src/layouts/history-list/BucketTab.vue +77 -0
  93. package/src/layouts/history-list/GroupRow.vue +242 -0
  94. package/src/layouts/history-list/HistoryDiffDialog.vue +231 -0
  95. package/src/layouts/history-list/HistoryListPanel.vue +380 -0
  96. package/src/layouts/history-list/InitialRow.vue +52 -0
  97. package/src/layouts/history-list/PageTab.vue +108 -0
  98. package/src/layouts/history-list/composables.ts +226 -0
  99. package/src/layouts/sidebar/layer/use-node-status.ts +9 -6
  100. package/src/services/BaseService.ts +35 -86
  101. package/src/services/codeBlock.ts +256 -5
  102. package/src/services/dataSource.ts +257 -6
  103. package/src/services/dep.ts +32 -9
  104. package/src/services/editor.ts +454 -171
  105. package/src/services/history.ts +455 -8
  106. package/src/services/props.ts +2 -2
  107. package/src/theme/history-list-panel.scss +462 -0
  108. package/src/theme/theme.scss +1 -0
  109. package/src/type.ts +269 -6
  110. package/src/utils/code-block.ts +150 -0
  111. package/src/utils/content-menu.ts +8 -5
  112. package/src/utils/dep/worker.ts +5 -3
  113. package/src/utils/index.ts +1 -0
  114. package/src/utils/undo-redo.ts +23 -0
  115. package/types/index.d.ts +2274 -819
  116. package/dist/es/utils/compose.js +0 -44
  117. package/dist/es/utils/editor-history.js +0 -100
  118. package/src/utils/compose.ts +0 -52
  119. package/src/utils/editor-history.ts +0 -138
@@ -0,0 +1,462 @@
1
+ .m-editor-history-list-popover {
2
+ padding: 0 !important;
3
+
4
+ .m-editor-history-list {
5
+ position: relative;
6
+ padding: 4px 8px 8px;
7
+ }
8
+
9
+ // 关闭按钮悬浮在 tab 标题同一行(绝对定位,不占布局空间)。
10
+ // top 对齐容器顶部内边距,height 跟 el-tabs/t-tabs 头部默认高度一致,
11
+ // 再用 flex 居中让图标与 tab 标题视觉对齐。
12
+ .m-editor-history-list-close {
13
+ position: absolute;
14
+ top: 4px;
15
+ right: 4px;
16
+ z-index: 1;
17
+ display: flex;
18
+ align-items: center;
19
+ height: 40px;
20
+ margin: 0;
21
+ color: #909399;
22
+
23
+ &:hover {
24
+ color: #409eff;
25
+ }
26
+ }
27
+
28
+ .m-editor-history-list-tabs {
29
+ .el-tabs__header,
30
+ .t-tabs__header {
31
+ margin-bottom: 4px;
32
+ }
33
+ }
34
+
35
+ .m-editor-history-list-empty {
36
+ padding: 24px 0;
37
+ text-align: center;
38
+ color: #909399;
39
+ font-size: 12px;
40
+ }
41
+
42
+ .m-editor-history-list-ul {
43
+ margin: 0;
44
+ padding: 0;
45
+ list-style: none;
46
+ }
47
+
48
+ .m-editor-history-list-item {
49
+ display: flex;
50
+ align-items: center;
51
+ gap: 6px;
52
+ padding: 6px 8px;
53
+ border-radius: 4px;
54
+ font-size: 12px;
55
+ line-height: 1.4;
56
+ color: #303133;
57
+ cursor: default;
58
+
59
+ // 合并组(卡片)自己定义了 hover/active 视觉,跳过通用单步 hover 避免色彩叠加
60
+ &:not(.m-editor-history-list-group.is-merged):hover {
61
+ background-color: rgba(0, 0, 0, 0.04);
62
+ }
63
+
64
+ &.is-undone {
65
+ color: #c0c4cc;
66
+
67
+ .m-editor-history-list-item-op {
68
+ opacity: 0.5;
69
+ }
70
+ }
71
+
72
+ // 当前所在的「单步」记录:左侧蓝条 + 浅蓝底;
73
+ // 合并组的当前态由 `.is-merged.is-current` 单独覆盖(border-left + 卡片背景),
74
+ // 故这里仅作用于「非合并组」的单步条目,避免与卡片样式互相干扰。
75
+ &.is-current:not(.m-editor-history-list-group.is-merged) {
76
+ background-color: rgba(64, 158, 255, 0.1);
77
+ box-shadow: inset 2px 0 0 #409eff;
78
+
79
+ &:hover {
80
+ background-color: rgba(64, 158, 255, 0.16);
81
+ }
82
+
83
+ .m-editor-history-list-item-desc {
84
+ font-weight: 600;
85
+ color: #409eff;
86
+ }
87
+ }
88
+ }
89
+
90
+ .m-editor-history-list-group {
91
+ flex-direction: column;
92
+ align-items: stretch;
93
+ gap: 0;
94
+
95
+ .m-editor-history-list-group-head {
96
+ display: flex;
97
+ align-items: center;
98
+ gap: 6px;
99
+ cursor: default;
100
+
101
+ &.is-clickable {
102
+ cursor: pointer;
103
+ }
104
+ }
105
+
106
+ .m-editor-history-list-group-toggle {
107
+ flex: 0 0 auto;
108
+ width: 16px;
109
+ text-align: center;
110
+ color: #909399;
111
+ font-size: 12px;
112
+ user-select: none;
113
+ transition: transform 0.15s ease;
114
+ pointer-events: none;
115
+
116
+ &.is-expanded {
117
+ transform: rotate(180deg);
118
+ }
119
+ }
120
+
121
+ // 合并组(≥2 个连续同节点的修改被聚合)需要与单步条目明显区分:
122
+ // - 左侧 3px 紫色色条暗示「这是一组」;
123
+ // - 浅紫背景 + 边框把整个组视觉化为一张「卡片」;
124
+ // - 头部加 padding,避免和单步条目混在一起难以辨认。
125
+ &.is-merged {
126
+ margin: 4px 0;
127
+ padding: 4px 8px 6px;
128
+ background-color: rgba(47, 84, 235, 0.06);
129
+ border: 1px solid rgba(47, 84, 235, 0.18);
130
+ border-left: 3px solid #2f54eb;
131
+ border-radius: 4px;
132
+
133
+ // 卡片本体已经有背景色,hover 状态以更深的同色提示交互
134
+ &:hover {
135
+ background-color: rgba(47, 84, 235, 0.1);
136
+ }
137
+
138
+ .m-editor-history-list-group-head {
139
+ font-weight: 600;
140
+ color: #1d39c4;
141
+ }
142
+
143
+ // 已撤销态:整张卡片去色
144
+ &.is-undone {
145
+ background-color: rgba(192, 196, 204, 0.08);
146
+ border-color: rgba(192, 196, 204, 0.4);
147
+ border-left-color: #c0c4cc;
148
+
149
+ .m-editor-history-list-group-head {
150
+ color: #c0c4cc;
151
+ }
152
+ }
153
+
154
+ // 当前组:卡片左条变蓝,与单步「当前」高亮一致
155
+ &.is-current {
156
+ background-color: rgba(64, 158, 255, 0.08);
157
+ border-color: rgba(64, 158, 255, 0.3);
158
+ border-left-color: #409eff;
159
+ box-shadow: none; // 覆盖 .is-current 公共的 inset 阴影
160
+
161
+ .m-editor-history-list-group-head {
162
+ color: #409eff;
163
+ }
164
+ }
165
+ }
166
+ }
167
+
168
+ .m-editor-history-list-substeps {
169
+ margin: 6px 0 0 6px;
170
+ padding: 0;
171
+ list-style: none;
172
+ border-left: 1px dashed rgba(47, 84, 235, 0.45);
173
+
174
+ li {
175
+ display: flex;
176
+ align-items: center;
177
+ gap: 6px;
178
+ padding: 3px 8px;
179
+ font-size: 11px;
180
+ color: #606266;
181
+ cursor: default;
182
+ border-radius: 3px;
183
+
184
+ &.is-clickable {
185
+ cursor: pointer;
186
+
187
+ &:hover {
188
+ background-color: rgba(47, 84, 235, 0.1);
189
+ }
190
+ }
191
+
192
+ &.is-undone {
193
+ color: #c0c4cc;
194
+ }
195
+
196
+ &.is-current {
197
+ color: #409eff;
198
+ font-weight: 600;
199
+ background-color: rgba(64, 158, 255, 0.08);
200
+ border-radius: 3px;
201
+ }
202
+ }
203
+ }
204
+
205
+ .m-editor-history-list-item-current {
206
+ flex: 0 0 auto;
207
+ padding: 0 6px;
208
+ border-radius: 2px;
209
+ font-size: 10px;
210
+ line-height: 16px;
211
+ color: #fff;
212
+ background-color: #409eff;
213
+ font-weight: 500;
214
+ }
215
+
216
+ .m-editor-history-list-item-index {
217
+ flex: 0 0 auto;
218
+ color: #909399;
219
+ font-family: Menlo, Monaco, Consolas, "Courier New", monospace;
220
+ font-size: 11px;
221
+ font-weight: 400; // 防止被合并组头部的粗体继承
222
+ white-space: nowrap;
223
+ }
224
+
225
+ // 操作时间:弱化展示,紧贴在描述之后、各操作按钮之前。
226
+ .m-editor-history-list-item-time {
227
+ flex: 0 0 auto;
228
+ color: #a8abb2;
229
+ font-family: Menlo, Monaco, Consolas, "Courier New", monospace;
230
+ font-size: 11px;
231
+ font-weight: 400; // 防止被合并组头部的粗体继承
232
+ white-space: nowrap;
233
+ }
234
+
235
+ .m-editor-history-list-item-op {
236
+ flex: 0 0 auto;
237
+ padding: 0 6px;
238
+ border-radius: 2px;
239
+ font-size: 11px;
240
+ line-height: 18px;
241
+ color: #fff;
242
+ background-color: #909399;
243
+
244
+ &.op-add {
245
+ background-color: #67c23a;
246
+ }
247
+
248
+ &.op-remove {
249
+ background-color: #f56c6c;
250
+ }
251
+
252
+ &.op-update {
253
+ background-color: #e6a23c;
254
+ }
255
+
256
+ &.op-initial {
257
+ background-color: #909399;
258
+ }
259
+ }
260
+
261
+ .m-editor-history-list-initial {
262
+ cursor: default;
263
+ color: #606266;
264
+ border-top: 1px dashed #dcdfe6;
265
+ margin-top: 4px;
266
+ padding-top: 8px;
267
+
268
+ &.is-clickable {
269
+ cursor: pointer;
270
+ }
271
+
272
+ .m-editor-history-list-item-desc {
273
+ font-style: italic;
274
+ }
275
+ }
276
+
277
+ .m-editor-history-list-item-desc {
278
+ flex: 1 1 auto;
279
+ overflow: hidden;
280
+ text-overflow: ellipsis;
281
+ white-space: nowrap;
282
+ }
283
+
284
+ // 「合并 N 步」徽标:紫色实心胶囊,与合并组卡片色系一致,醒目区分单步条目。
285
+ .m-editor-history-list-item-merge {
286
+ flex: 0 0 auto;
287
+ padding: 0 8px;
288
+ border-radius: 8px;
289
+ font-size: 10px;
290
+ line-height: 16px;
291
+ color: #fff;
292
+ background-color: #2f54eb;
293
+ font-weight: 500;
294
+ letter-spacing: 0.2px;
295
+ }
296
+
297
+ .m-editor-history-list-item-diff {
298
+ flex: 0 0 auto;
299
+ padding: 0 6px;
300
+ border-radius: 2px;
301
+ font-size: 10px;
302
+ line-height: 16px;
303
+ color: #409eff;
304
+ background-color: rgba(64, 158, 255, 0.1);
305
+ cursor: pointer;
306
+ user-select: none;
307
+
308
+ &:hover {
309
+ background-color: rgba(64, 158, 255, 0.2);
310
+ }
311
+ }
312
+
313
+ // 「跳转」按钮:将历史游标移动到该 step,替代原先点击整行跳转的交互。
314
+ // 使用与组卡片一致的紫色色系,与「查看差异」「回滚」区分开。
315
+ .m-editor-history-list-item-goto {
316
+ flex: 0 0 auto;
317
+ padding: 0 6px;
318
+ border-radius: 2px;
319
+ font-size: 10px;
320
+ line-height: 16px;
321
+ color: #606266;
322
+ background-color: rgba(96, 98, 102, 0.1);
323
+ cursor: pointer;
324
+ user-select: none;
325
+
326
+ &:hover {
327
+ background-color: rgba(96, 98, 102, 0.18);
328
+ }
329
+ }
330
+
331
+ // 「回滚」按钮:类 git revert,把目标 step 反向应用一次作为新提交。
332
+ // 使用红色色调,强调其为"破坏性/可逆操作",与「查看差异」「跳转」区分开。
333
+ .m-editor-history-list-item-revert {
334
+ flex: 0 0 auto;
335
+ padding: 0 6px;
336
+ border-radius: 2px;
337
+ font-size: 10px;
338
+ line-height: 16px;
339
+ color: #f56c6c;
340
+ background-color: rgba(245, 108, 108, 0.12);
341
+ cursor: pointer;
342
+ user-select: none;
343
+
344
+ &:hover {
345
+ background-color: rgba(245, 108, 108, 0.25);
346
+ }
347
+ }
348
+
349
+ .m-editor-history-list-substep-desc {
350
+ flex: 1 1 auto;
351
+ overflow: hidden;
352
+ text-overflow: ellipsis;
353
+ white-space: nowrap;
354
+ }
355
+
356
+ .m-editor-history-list-bucket {
357
+ margin-bottom: 8px;
358
+
359
+ &:last-child {
360
+ margin-bottom: 0;
361
+ }
362
+ }
363
+
364
+ .m-editor-history-list-bucket-title {
365
+ display: flex;
366
+ align-items: center;
367
+ gap: 6px;
368
+ padding: 4px 8px;
369
+ font-size: 12px;
370
+ font-weight: 500;
371
+ color: #606266;
372
+ background-color: #f5f7fa;
373
+ border-radius: 4px;
374
+
375
+ code {
376
+ flex: 1 1 auto;
377
+ font-family: Menlo, Monaco, Consolas, "Courier New", monospace;
378
+ font-size: 11px;
379
+ color: #409eff;
380
+ overflow: hidden;
381
+ text-overflow: ellipsis;
382
+ white-space: nowrap;
383
+ }
384
+ }
385
+
386
+ .m-editor-history-list-bucket-count {
387
+ flex: 0 0 auto;
388
+ color: #909399;
389
+ font-weight: 400;
390
+ font-size: 11px;
391
+ }
392
+ }
393
+
394
+ .m-editor-history-diff-dialog {
395
+ .m-editor-history-diff-dialog-body {
396
+ display: flex;
397
+ flex-direction: column;
398
+ }
399
+
400
+ .m-editor-history-diff-dialog-notice {
401
+ margin-bottom: 8px;
402
+ padding: 8px 12px;
403
+ background-color: #fdf6ec;
404
+ border: 1px solid #faecd8;
405
+ border-radius: 4px;
406
+ color: #e6a23c;
407
+ font-size: 13px;
408
+ line-height: 1.5;
409
+ }
410
+
411
+ .m-editor-history-diff-dialog-header {
412
+ display: flex;
413
+ align-items: center;
414
+ justify-content: space-between;
415
+ margin-bottom: 8px;
416
+ padding: 8px 12px;
417
+ background-color: #f5f7fa;
418
+ border-radius: 4px;
419
+ gap: 12px;
420
+ }
421
+
422
+ .m-editor-history-diff-dialog-controls {
423
+ display: flex;
424
+ align-items: center;
425
+ flex: 0 0 auto;
426
+ gap: 8px;
427
+ }
428
+
429
+ .m-editor-history-diff-dialog-view,
430
+ .m-editor-history-diff-dialog-mode {
431
+ flex: 0 0 auto;
432
+ }
433
+
434
+ .m-editor-history-diff-dialog-target {
435
+ flex: 1 1 auto;
436
+ font-size: 13px;
437
+ font-weight: 500;
438
+ color: #303133;
439
+ overflow: hidden;
440
+ text-overflow: ellipsis;
441
+ white-space: nowrap;
442
+ }
443
+
444
+ .m-editor-history-diff-dialog-legend {
445
+ display: flex;
446
+ align-items: center;
447
+ gap: 6px;
448
+ margin-bottom: 12px;
449
+ padding: 0 4px;
450
+ }
451
+
452
+ .m-editor-history-diff-dialog-arrow {
453
+ color: #909399;
454
+ font-size: 12px;
455
+ }
456
+
457
+ .m-editor-history-diff-dialog-tip {
458
+ margin-left: 8px;
459
+ color: #e6a23c;
460
+ font-size: 12px;
461
+ }
462
+ }
@@ -1,5 +1,6 @@
1
1
  @use "./search-input.scss";
2
2
  @use "./nav-menu.scss";
3
+ @use "./history-list-panel.scss";
3
4
  @use "./framework.scss";
4
5
  @use "./sidebar.scss";
5
6
  @use "./layer-panel.scss";