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

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 (66) hide show
  1. package/dist/es/components/CompareForm.vue_vue_type_script_setup_true_lang.js +15 -1
  2. package/dist/es/hooks/use-code-block-edit.js +6 -3
  3. package/dist/es/hooks/use-data-source-edit.js +5 -2
  4. package/dist/es/hooks/use-stage.js +6 -3
  5. package/dist/es/layouts/NavMenu.vue_vue_type_script_setup_true_lang.js +1 -1
  6. package/dist/es/layouts/history-list/Bucket.vue_vue_type_script_setup_true_lang.js +6 -2
  7. package/dist/es/layouts/history-list/BucketTab.vue_vue_type_script_setup_true_lang.js +3 -0
  8. package/dist/es/layouts/history-list/GroupRow.vue_vue_type_script_setup_true_lang.js +42 -29
  9. package/dist/es/layouts/history-list/HistoryDiffDialog.vue_vue_type_script_setup_true_lang.js +4 -2
  10. package/dist/es/layouts/history-list/HistoryListPanel.vue_vue_type_script_setup_true_lang.js +5 -1
  11. package/dist/es/layouts/history-list/PageTab.vue_vue_type_script_setup_true_lang.js +5 -2
  12. package/dist/es/layouts/history-list/composables.js +53 -1
  13. package/dist/es/layouts/props-panel/PropsPanel.vue_vue_type_script_setup_true_lang.js +5 -1
  14. package/dist/es/layouts/sidebar/ComponentListPanel.vue_vue_type_script_setup_true_lang.js +1 -1
  15. package/dist/es/layouts/sidebar/code-block/CodeBlockList.vue_vue_type_script_setup_true_lang.js +3 -3
  16. package/dist/es/layouts/sidebar/code-block/CodeBlockListPanel.vue_vue_type_script_setup_true_lang.js +1 -1
  17. package/dist/es/layouts/sidebar/code-block/useContentMenu.js +1 -1
  18. package/dist/es/layouts/sidebar/data-source/DataSourceListPanel.vue_vue_type_script_setup_true_lang.js +1 -1
  19. package/dist/es/layouts/sidebar/data-source/useContentMenu.js +1 -1
  20. package/dist/es/layouts/sidebar/layer/LayerMenu.vue_vue_type_script_setup_true_lang.js +5 -5
  21. package/dist/es/layouts/sidebar/layer/LayerNodeTool.vue_vue_type_script_setup_true_lang.js +1 -1
  22. package/dist/es/layouts/workspace/viewer/Stage.vue_vue_type_script_setup_true_lang.js +1 -1
  23. package/dist/es/layouts/workspace/viewer/ViewerMenu.vue_vue_type_script_setup_true_lang.js +8 -8
  24. package/dist/es/services/codeBlock.js +25 -10
  25. package/dist/es/services/dataSource.js +24 -10
  26. package/dist/es/services/editor.js +98 -46
  27. package/dist/es/services/history.js +2 -0
  28. package/dist/es/services/keybinding.js +3 -3
  29. package/dist/es/style.css +16 -4
  30. package/dist/es/utils/content-menu.js +17 -9
  31. package/dist/style.css +16 -4
  32. package/dist/tmagic-editor.umd.cjs +343 -144
  33. package/package.json +7 -7
  34. package/src/components/CompareForm.vue +19 -1
  35. package/src/hooks/use-code-block-edit.ts +4 -3
  36. package/src/hooks/use-data-source-edit.ts +2 -2
  37. package/src/hooks/use-stage.ts +3 -3
  38. package/src/layouts/NavMenu.vue +1 -1
  39. package/src/layouts/history-list/Bucket.vue +6 -2
  40. package/src/layouts/history-list/BucketTab.vue +3 -0
  41. package/src/layouts/history-list/GroupRow.vue +20 -3
  42. package/src/layouts/history-list/HistoryDiffDialog.vue +2 -1
  43. package/src/layouts/history-list/HistoryListPanel.vue +4 -0
  44. package/src/layouts/history-list/PageTab.vue +5 -1
  45. package/src/layouts/history-list/composables.ts +60 -0
  46. package/src/layouts/props-panel/PropsPanel.vue +5 -1
  47. package/src/layouts/sidebar/ComponentListPanel.vue +9 -5
  48. package/src/layouts/sidebar/code-block/CodeBlockList.vue +5 -5
  49. package/src/layouts/sidebar/code-block/CodeBlockListPanel.vue +1 -1
  50. package/src/layouts/sidebar/code-block/useContentMenu.ts +1 -1
  51. package/src/layouts/sidebar/data-source/DataSourceListPanel.vue +1 -1
  52. package/src/layouts/sidebar/data-source/useContentMenu.ts +1 -1
  53. package/src/layouts/sidebar/layer/LayerMenu.vue +19 -11
  54. package/src/layouts/sidebar/layer/LayerNodeTool.vue +7 -4
  55. package/src/layouts/workspace/viewer/Stage.vue +1 -1
  56. package/src/layouts/workspace/viewer/ViewerMenu.vue +8 -8
  57. package/src/services/codeBlock.ts +33 -9
  58. package/src/services/dataSource.ts +30 -8
  59. package/src/services/editor.ts +111 -34
  60. package/src/services/history.ts +7 -0
  61. package/src/services/keybinding.ts +3 -3
  62. package/src/theme/history-list-panel.scss +15 -1
  63. package/src/theme/props-panel.scss +3 -3
  64. package/src/type.ts +58 -2
  65. package/src/utils/content-menu.ts +18 -9
  66. package/types/index.d.ts +96 -25
package/src/type.ts CHANGED
@@ -510,7 +510,7 @@ export interface HistoryListExtraTab {
510
510
  * - data-source: 数据源,按 `type`(base/http/...) 从 dataSourceService 获取数据源表单配置
511
511
  * - code-block: 数据源代码块,使用内置的代码块表单配置
512
512
  */
513
- export type CompareCategory = 'node' | 'data-source' | 'code-block';
513
+ export type CompareCategory = 'node' | 'data-source' | 'code-block' | string;
514
514
 
515
515
  /**
516
516
  * 自定义 `loadConfig` 时回传的上下文,聚合了组件当前的对比入参,
@@ -683,6 +683,44 @@ export interface CodeParamStatement {
683
683
  export type HistoryOpType = 'add' | 'remove' | 'update';
684
684
  // #endregion HistoryOpType
685
685
 
686
+ // #region HistoryOpSource
687
+ /**
688
+ * 历史记录的「操作途径」——标记本次变更由哪条交互入口触发,仅用于历史面板展示 / 业务埋点,
689
+ * 不影响 undo/redo 行为。缺省(未传)时 UI 视为「未知」。
690
+ *
691
+ * - `stage`:画布(拖拽 / 缩放 / 排序等舞台直接操作)
692
+ * - `tree`:树形面板(图层 / 数据源 / 代码块等树形结构里的拖拽 / 菜单操作)
693
+ * - `component-panel`:组件面板(左侧组件列表点击 / 拖拽新增组件)
694
+ * - `props`:配置面板表单(属性表单字段编辑)
695
+ * - `code`:源码编辑器(配置面板「源码」面板里直接编辑 JSON/代码后保存)
696
+ * - `stage-contextmenu`:画布右键菜单(舞台上节点的右键上下文菜单)
697
+ * - `tree-contextmenu`:树面板右键菜单(图层 / 数据源 / 代码块等树形列表上的右键上下文菜单)
698
+ * - `toolbar`:工具栏菜单(顶部导航工具栏按钮)
699
+ * - `shortcut`:键盘快捷键
700
+ * - `rollback`:历史回滚(历史面板里对某条历史「回滚」,反向应用为一条新记录,类 git revert)
701
+ * - `api`:代码 / 接口调用(程序化触发)
702
+ * - `ai`:AI 生成 / 智能助手触发的变更
703
+ * - `unknown`:未知来源
704
+ *
705
+ * 通过 `(string & {})` 允许业务侧扩展自定义途径字符串,同时保留内置值的自动补全。
706
+ */
707
+ export type HistoryOpSource =
708
+ | 'stage'
709
+ | 'tree'
710
+ | 'component-panel'
711
+ | 'props'
712
+ | 'code'
713
+ | 'stage-contextmenu'
714
+ | 'tree-contextmenu'
715
+ | 'toolbar'
716
+ | 'shortcut'
717
+ | 'rollback'
718
+ | 'api'
719
+ | 'ai'
720
+ | 'unknown'
721
+ | (string & {});
722
+ // #endregion HistoryOpSource
723
+
686
724
  // #region StepValue
687
725
  export interface StepValue {
688
726
  /** 页面信息 */
@@ -713,6 +751,12 @@ export interface StepValue {
713
751
  * 不影响 undo/redo 行为;缺省时面板会根据节点 / propPath 自动生成描述。
714
752
  */
715
753
  historyDescription?: string;
754
+ /**
755
+ * 操作途径:标记本次变更由哪条交互入口触发,取值见 {@link HistoryOpSource}
756
+ * (画布 / 树面板 / 组件面板 / 配置面板 / 源码编辑器 / 右键菜单 / 工具栏 / 快捷键 / 回滚 / 接口 等)。
757
+ * 仅用于历史面板展示与业务埋点,不影响 undo/redo 行为;缺省时面板视为「未知」。
758
+ */
759
+ source?: HistoryOpSource;
716
760
  /**
717
761
  * 入栈时间戳(毫秒)。在 historyService.push 时自动写入(若调用方未指定),仅用于历史面板展示。
718
762
  */
@@ -741,6 +785,8 @@ export interface CodeBlockStepValue {
741
785
  changeRecords?: ChangeRecord[];
742
786
  /** 调用方可选传入的人类可读描述,用于历史面板展示;不影响 undo/redo 行为。 */
743
787
  historyDescription?: string;
788
+ /** 操作途径:标记本次变更由哪条交互入口触发,取值见 {@link HistoryOpSource};仅用于历史面板展示与埋点,不影响 undo/redo 行为。 */
789
+ source?: HistoryOpSource;
744
790
  /** 入栈时间戳(毫秒),入栈时自动写入,仅用于历史面板展示。 */
745
791
  timestamp?: number;
746
792
  }
@@ -767,6 +813,8 @@ export interface DataSourceStepValue {
767
813
  changeRecords?: ChangeRecord[];
768
814
  /** 调用方可选传入的人类可读描述,用于历史面板展示;不影响 undo/redo 行为。 */
769
815
  historyDescription?: string;
816
+ /** 操作途径:标记本次变更由哪条交互入口触发,取值见 {@link HistoryOpSource};仅用于历史面板展示与埋点,不影响 undo/redo 行为。 */
817
+ source?: HistoryOpSource;
770
818
  /** 入栈时间戳(毫秒),入栈时自动写入,仅用于历史面板展示。 */
771
819
  timestamp?: number;
772
820
  }
@@ -1099,16 +1147,21 @@ export const canUsePluginMethods = {
1099
1147
 
1100
1148
  export type AsyncMethodName = Writable<(typeof canUsePluginMethods)['async']>;
1101
1149
 
1150
+ // #region HistoryOpOptions
1102
1151
  /**
1103
1152
  * 历史记录写入相关的通用配置(codeBlock / dataSource / editor 共用)
1104
1153
  * - doNotPushHistory: 操作完成后是否不要将本次操作压入历史栈(撤销/重做记录),默认 false
1105
1154
  * - historyDescription: 入栈时附带的人类可读描述,用于历史面板展示;不影响 undo/redo 行为,缺省时面板会自动生成描述
1155
+ * - historySource: 操作途径,取值见 {@link HistoryOpSource}(画布 / 树面板 / 组件面板 / 配置面板 / 源码编辑器 / 右键菜单 / 工具栏 / 快捷键 / 回滚 / 接口 等),用于历史面板展示与埋点;不影响 undo/redo 行为
1106
1156
  */
1107
1157
  export interface HistoryOpOptions {
1108
1158
  doNotPushHistory?: boolean;
1109
1159
  historyDescription?: string;
1160
+ historySource?: HistoryOpSource;
1110
1161
  }
1162
+ // #endregion HistoryOpOptions
1111
1163
 
1164
+ // #region HistoryOpOptionsWithChangeRecords
1112
1165
  /**
1113
1166
  * 在 HistoryOpOptions 基础上携带 form 端 propPath/value 变更记录,
1114
1167
  * 用于历史记录的精细化撤销/重做(按 propPath 局部 patch)。
@@ -1116,7 +1169,9 @@ export interface HistoryOpOptions {
1116
1169
  export interface HistoryOpOptionsWithChangeRecords extends HistoryOpOptions {
1117
1170
  changeRecords?: ChangeRecord[];
1118
1171
  }
1172
+ // #endregion HistoryOpOptionsWithChangeRecords
1119
1173
 
1174
+ // #region DslOpOptions
1120
1175
  /**
1121
1176
  * DSL 修改类操作的通用配置
1122
1177
  * - doNotSelect: 操作后是否不要自动触发选中(不调用 this.select / this.multiSelect / stage.select / stage.multiSelect)
@@ -1126,11 +1181,12 @@ export interface DslOpOptions extends HistoryOpOptions {
1126
1181
  doNotSelect?: boolean;
1127
1182
  doNotSwitchPage?: boolean;
1128
1183
  }
1184
+ // #endregion DslOpOptions
1129
1185
 
1130
1186
  /** 差异对话框的入参 */
1131
1187
  export interface DiffDialogPayload {
1132
1188
  /** 表单类别 */
1133
- category: CompareCategory;
1189
+ category?: CompareCategory;
1134
1190
  /** 节点类型 / 数据源类型 */
1135
1191
  type?: string;
1136
1192
  /** 代码块场景下的数据源类型 */
@@ -5,11 +5,16 @@ import { cloneDeep, Id, MContainer, NodeType } from '@tmagic/core';
5
5
  import { calcValueByFontsize, isPage, isPageFragment } from '@tmagic/utils';
6
6
 
7
7
  import ContentMenu from '@editor/components/ContentMenu.vue';
8
- import type { MenuButton, Services } from '@editor/type';
8
+ import type { HistoryOpSource, MenuButton, Services } from '@editor/type';
9
9
 
10
10
  import { COPY_STORAGE_KEY } from './editor';
11
11
 
12
- export const useDeleteMenu = (): MenuButton => ({
12
+ /**
13
+ * 共享的右键菜单项构造器(画布 ViewerMenu 与图层树 LayerMenu 共用)。
14
+ * `historySource` 用于标记本次操作的途径,调用方按所在面板传入:
15
+ * 画布传 `'stage-contextmenu'`,树形面板传 `'tree-contextmenu'`。
16
+ */
17
+ export const useDeleteMenu = (historySource?: HistoryOpSource): MenuButton => ({
13
18
  type: 'button',
14
19
  text: '删除',
15
20
  icon: Delete,
@@ -19,7 +24,7 @@ export const useDeleteMenu = (): MenuButton => ({
19
24
  },
20
25
  handler: ({ editorService }) => {
21
26
  const nodes = editorService.get('nodes');
22
- nodes && editorService.remove(nodes);
27
+ nodes && editorService.remove(nodes, { historySource });
23
28
  },
24
29
  });
25
30
 
@@ -33,7 +38,10 @@ export const useCopyMenu = (): MenuButton => ({
33
38
  },
34
39
  });
35
40
 
36
- export const usePasteMenu = (menu?: ShallowRef<InstanceType<typeof ContentMenu> | null>): MenuButton => ({
41
+ export const usePasteMenu = (
42
+ historySource?: HistoryOpSource,
43
+ menu?: ShallowRef<InstanceType<typeof ContentMenu> | null>,
44
+ ): MenuButton => ({
37
45
  type: 'button',
38
46
  text: '粘贴',
39
47
  icon: markRaw(DocumentCopy),
@@ -52,14 +60,14 @@ export const usePasteMenu = (menu?: ShallowRef<InstanceType<typeof ContentMenu>
52
60
  const initialTop =
53
61
  calcValueByFontsize(stage?.renderer?.getDocument(), (rect.top || 0) - (parentRect?.top || 0)) /
54
62
  uiService.get('zoom');
55
- editorService.paste({ left: initialLeft, top: initialTop });
63
+ editorService.paste({ left: initialLeft, top: initialTop }, undefined, { historySource });
56
64
  } else {
57
- editorService.paste();
65
+ editorService.paste(undefined, undefined, { historySource });
58
66
  }
59
67
  },
60
68
  });
61
69
 
62
- const moveTo = async (id: Id, { editorService }: Services) => {
70
+ const moveTo = async (id: Id, { editorService }: Services, historySource?: HistoryOpSource) => {
63
71
  const nodes = editorService.get('nodes') || [];
64
72
  const parent = editorService.getNodeById(id) as MContainer;
65
73
 
@@ -69,10 +77,11 @@ const moveTo = async (id: Id, { editorService }: Services) => {
69
77
  // 不要再走 remove + add 两步,否则会被切成两条历史(且语义也不正确)。
70
78
  await editorService.moveToContainer(cloneDeep(nodes), parent.id, {
71
79
  doNotSwitchPage: true,
80
+ historySource,
72
81
  });
73
82
  };
74
83
 
75
- export const useMoveToMenu = ({ editorService }: Services): MenuButton => {
84
+ export const useMoveToMenu = ({ editorService }: Services, historySource?: HistoryOpSource): MenuButton => {
76
85
  const root = computed(() => editorService.get('root'));
77
86
 
78
87
  return {
@@ -89,7 +98,7 @@ export const useMoveToMenu = ({ editorService }: Services): MenuButton => {
89
98
  text: `${page.name}(${page.id})`,
90
99
  type: 'button',
91
100
  handler: (services: Services) => {
92
- moveTo(page.id, services);
101
+ moveTo(page.id, services, historySource);
93
102
  },
94
103
  })),
95
104
  };
package/types/index.d.ts CHANGED
@@ -100,7 +100,9 @@ declare class CodeBlock extends BaseService {
100
100
  */
101
101
  setCodeDslById(id: Id, codeConfig: Partial<CodeBlockContent>, {
102
102
  changeRecords,
103
- doNotPushHistory
103
+ doNotPushHistory,
104
+ historyDescription,
105
+ historySource
104
106
  }?: HistoryOpOptionsWithChangeRecords): Promise<void>;
105
107
  /**
106
108
  * 为了兼容历史原因
@@ -117,7 +119,8 @@ declare class CodeBlock extends BaseService {
117
119
  setCodeDslByIdSync(id: Id, codeConfig: Partial<CodeBlockContent>, force?: boolean, {
118
120
  changeRecords,
119
121
  doNotPushHistory,
120
- historyDescription
122
+ historyDescription,
123
+ historySource
121
124
  }?: HistoryOpOptionsWithChangeRecords): void;
122
125
  /**
123
126
  * 根据代码块id数组获取代码dsl
@@ -178,7 +181,8 @@ declare class CodeBlock extends BaseService {
178
181
  */
179
182
  deleteCodeDslByIds(codeIds: Id[], {
180
183
  doNotPushHistory,
181
- historyDescription
184
+ historyDescription,
185
+ historySource
182
186
  }?: HistoryOpOptions): Promise<void>;
183
187
  setParamsColConfig(config: TableColumnConfig): void;
184
188
  getParamsColConfig(): TableColumnConfig | undefined;
@@ -318,7 +322,8 @@ declare class DataSource extends BaseService {
318
322
  */
319
323
  add(config: DataSourceSchema, {
320
324
  doNotPushHistory,
321
- historyDescription
325
+ historyDescription,
326
+ historySource
322
327
  }?: HistoryOpOptions): {
323
328
  id: string;
324
329
  type: string;
@@ -341,7 +346,8 @@ declare class DataSource extends BaseService {
341
346
  update(config: DataSourceSchema, {
342
347
  changeRecords,
343
348
  doNotPushHistory,
344
- historyDescription
349
+ historyDescription,
350
+ historySource
345
351
  }?: HistoryOpOptionsWithChangeRecords): DataSourceSchema;
346
352
  /**
347
353
  * 删除数据源
@@ -352,7 +358,8 @@ declare class DataSource extends BaseService {
352
358
  */
353
359
  remove(id: string, {
354
360
  doNotPushHistory,
355
- historyDescription
361
+ historyDescription,
362
+ historySource
356
363
  }?: HistoryOpOptions): void;
357
364
  /**
358
365
  * 撤销指定数据源的最近一次变更。
@@ -571,7 +578,8 @@ declare class Editor extends BaseService {
571
578
  doNotSelect,
572
579
  doNotSwitchPage,
573
580
  doNotPushHistory,
574
- historyDescription
581
+ historyDescription,
582
+ historySource
575
583
  }?: DslOpOptions): Promise<MNode | MNode[]>;
576
584
  doRemove(node: MNode, {
577
585
  doNotSelect,
@@ -589,7 +597,8 @@ declare class Editor extends BaseService {
589
597
  doNotSelect,
590
598
  doNotSwitchPage,
591
599
  doNotPushHistory,
592
- historyDescription
600
+ historyDescription,
601
+ historySource
593
602
  }?: DslOpOptions): Promise<void>;
594
603
  doUpdate(config: MNode, {
595
604
  changeRecords
@@ -616,6 +625,7 @@ declare class Editor extends BaseService {
616
625
  changeRecordList?: ChangeRecord[][];
617
626
  doNotPushHistory?: boolean;
618
627
  historyDescription?: string;
628
+ historySource?: HistoryOpSource;
619
629
  }): Promise<MNode | MNode[]>;
620
630
  /**
621
631
  * 将id为id1的组件移动到id为id2的组件位置上,例如:[1,2,3,4] -> sort(1,3) -> [2,1,3,4]
@@ -629,7 +639,8 @@ declare class Editor extends BaseService {
629
639
  */
630
640
  sort(id1: Id, id2: Id, {
631
641
  doNotSelect,
632
- doNotPushHistory
642
+ doNotPushHistory,
643
+ historySource
633
644
  }?: DslOpOptions): Promise<void>;
634
645
  /**
635
646
  * 将组件节点配置存储到localStorage中
@@ -656,7 +667,9 @@ declare class Editor extends BaseService {
656
667
  paste(position?: PastePosition, collectorOptions?: TargetOptions, {
657
668
  doNotSelect,
658
669
  doNotSwitchPage,
659
- doNotPushHistory
670
+ doNotPushHistory,
671
+ historyDescription,
672
+ historySource
660
673
  }?: DslOpOptions): Promise<MNode | MNode[] | void>;
661
674
  doPaste(config: MNode[], position?: PastePosition): Promise<MNode[]>;
662
675
  doAlignCenter(config: MNode): Promise<MNode>;
@@ -671,7 +684,9 @@ declare class Editor extends BaseService {
671
684
  */
672
685
  alignCenter(config: MNode | MNode[], {
673
686
  doNotSelect,
674
- doNotPushHistory
687
+ doNotPushHistory,
688
+ historyDescription,
689
+ historySource
675
690
  }?: DslOpOptions): Promise<MNode | MNode[]>;
676
691
  /**
677
692
  * 移动当前选中节点位置
@@ -680,7 +695,9 @@ declare class Editor extends BaseService {
680
695
  * @param options.doNotPushHistory 是否不写入历史记录(默认 false)
681
696
  */
682
697
  moveLayer(offset: number | LayerOffset, {
683
- doNotPushHistory
698
+ doNotPushHistory,
699
+ historyDescription,
700
+ historySource
684
701
  }?: DslOpOptions): Promise<void>;
685
702
  /**
686
703
  * 移动一个或多个节点到指定容器中。
@@ -699,10 +716,14 @@ declare class Editor extends BaseService {
699
716
  moveToContainer(config: MNode | MNode[], targetId: Id, {
700
717
  doNotSelect,
701
718
  doNotSwitchPage,
702
- doNotPushHistory
719
+ doNotPushHistory,
720
+ historyDescription,
721
+ historySource
703
722
  }?: DslOpOptions): Promise<MNode | MNode[]>;
704
723
  dragTo(config: MNode | MNode[], targetParent: MContainer, targetIndex: number, {
705
- doNotPushHistory
724
+ doNotPushHistory,
725
+ historyDescription,
726
+ historySource
706
727
  }?: DslOpOptions): Promise<void>;
707
728
  /**
708
729
  * 撤销当前操作
@@ -742,7 +763,9 @@ declare class Editor extends BaseService {
742
763
  */
743
764
  gotoPageStep(targetCursor: number): Promise<number>;
744
765
  move(left: number, top: number, {
745
- doNotPushHistory
766
+ doNotPushHistory,
767
+ historyDescription,
768
+ historySource
746
769
  }?: DslOpOptions): Promise<void>;
747
770
  resetState(): void;
748
771
  destroy(): void;
@@ -885,7 +908,8 @@ declare class History extends BaseService {
885
908
  oldContent: CodeBlockContent | null;
886
909
  newContent: CodeBlockContent | null;
887
910
  changeRecords?: ChangeRecord[]; /** 可选的人类可读描述(如「修改按钮颜色」),仅用于历史面板展示。 */
888
- historyDescription?: string;
911
+ historyDescription?: string; /** 可选的操作途径(配置面板 / 菜单 / 接口等),仅用于历史面板展示与埋点。 */
912
+ source?: HistoryOpSource;
889
913
  }): CodeBlockStepValue | null;
890
914
  /**
891
915
  * 推入一条数据源变更记录(与页面/节点完全无关),按 `dataSourceId` 维度独立一份 UndoRedo 栈。
@@ -895,7 +919,8 @@ declare class History extends BaseService {
895
919
  oldSchema: DataSourceSchema | null;
896
920
  newSchema: DataSourceSchema | null;
897
921
  changeRecords?: ChangeRecord[]; /** 可选的人类可读描述,仅用于历史面板展示。 */
898
- historyDescription?: string;
922
+ historyDescription?: string; /** 可选的操作途径(配置面板 / 菜单 / 接口等),仅用于历史面板展示与埋点。 */
923
+ source?: HistoryOpSource;
899
924
  }): DataSourceStepValue | null;
900
925
  /** 撤销指定代码块的最近一次变更。 */
901
926
  undoCodeBlock(codeBlockId: Id): CodeBlockStepValue | null;
@@ -1628,7 +1653,7 @@ interface HistoryListExtraTab {
1628
1653
  * - data-source: 数据源,按 `type`(base/http/...) 从 dataSourceService 获取数据源表单配置
1629
1654
  * - code-block: 数据源代码块,使用内置的代码块表单配置
1630
1655
  */
1631
- type CompareCategory = 'node' | 'data-source' | 'code-block';
1656
+ type CompareCategory = 'node' | 'data-source' | 'code-block' | string;
1632
1657
  /**
1633
1658
  * 自定义 `loadConfig` 时回传的上下文,聚合了组件当前的对比入参,
1634
1659
  * 方便调用方在外部按需拼装 FormConfig。
@@ -1759,6 +1784,27 @@ interface CodeParamStatement {
1759
1784
  [key: string]: any;
1760
1785
  }
1761
1786
  type HistoryOpType = 'add' | 'remove' | 'update';
1787
+ /**
1788
+ * 历史记录的「操作途径」——标记本次变更由哪条交互入口触发,仅用于历史面板展示 / 业务埋点,
1789
+ * 不影响 undo/redo 行为。缺省(未传)时 UI 视为「未知」。
1790
+ *
1791
+ * - `stage`:画布(拖拽 / 缩放 / 排序等舞台直接操作)
1792
+ * - `tree`:树形面板(图层 / 数据源 / 代码块等树形结构里的拖拽 / 菜单操作)
1793
+ * - `component-panel`:组件面板(左侧组件列表点击 / 拖拽新增组件)
1794
+ * - `props`:配置面板表单(属性表单字段编辑)
1795
+ * - `code`:源码编辑器(配置面板「源码」面板里直接编辑 JSON/代码后保存)
1796
+ * - `stage-contextmenu`:画布右键菜单(舞台上节点的右键上下文菜单)
1797
+ * - `tree-contextmenu`:树面板右键菜单(图层 / 数据源 / 代码块等树形列表上的右键上下文菜单)
1798
+ * - `toolbar`:工具栏菜单(顶部导航工具栏按钮)
1799
+ * - `shortcut`:键盘快捷键
1800
+ * - `rollback`:历史回滚(历史面板里对某条历史「回滚」,反向应用为一条新记录,类 git revert)
1801
+ * - `api`:代码 / 接口调用(程序化触发)
1802
+ * - `ai`:AI 生成 / 智能助手触发的变更
1803
+ * - `unknown`:未知来源
1804
+ *
1805
+ * 通过 `(string & {})` 允许业务侧扩展自定义途径字符串,同时保留内置值的自动补全。
1806
+ */
1807
+ type HistoryOpSource = 'stage' | 'tree' | 'component-panel' | 'props' | 'code' | 'stage-contextmenu' | 'tree-contextmenu' | 'toolbar' | 'shortcut' | 'rollback' | 'api' | 'ai' | 'unknown' | (string & {});
1762
1808
  interface StepValue {
1763
1809
  /** 页面信息 */
1764
1810
  data: {
@@ -1799,6 +1845,12 @@ interface StepValue {
1799
1845
  * 不影响 undo/redo 行为;缺省时面板会根据节点 / propPath 自动生成描述。
1800
1846
  */
1801
1847
  historyDescription?: string;
1848
+ /**
1849
+ * 操作途径:标记本次变更由哪条交互入口触发,取值见 {@link HistoryOpSource}
1850
+ * (画布 / 树面板 / 组件面板 / 配置面板 / 源码编辑器 / 右键菜单 / 工具栏 / 快捷键 / 回滚 / 接口 等)。
1851
+ * 仅用于历史面板展示与业务埋点,不影响 undo/redo 行为;缺省时面板视为「未知」。
1852
+ */
1853
+ source?: HistoryOpSource;
1802
1854
  /**
1803
1855
  * 入栈时间戳(毫秒)。在 historyService.push 时自动写入(若调用方未指定),仅用于历史面板展示。
1804
1856
  */
@@ -1824,6 +1876,8 @@ interface CodeBlockStepValue {
1824
1876
  changeRecords?: ChangeRecord[];
1825
1877
  /** 调用方可选传入的人类可读描述,用于历史面板展示;不影响 undo/redo 行为。 */
1826
1878
  historyDescription?: string;
1879
+ /** 操作途径:标记本次变更由哪条交互入口触发,取值见 {@link HistoryOpSource};仅用于历史面板展示与埋点,不影响 undo/redo 行为。 */
1880
+ source?: HistoryOpSource;
1827
1881
  /** 入栈时间戳(毫秒),入栈时自动写入,仅用于历史面板展示。 */
1828
1882
  timestamp?: number;
1829
1883
  }
@@ -1847,6 +1901,8 @@ interface DataSourceStepValue {
1847
1901
  changeRecords?: ChangeRecord[];
1848
1902
  /** 调用方可选传入的人类可读描述,用于历史面板展示;不影响 undo/redo 行为。 */
1849
1903
  historyDescription?: string;
1904
+ /** 操作途径:标记本次变更由哪条交互入口触发,取值见 {@link HistoryOpSource};仅用于历史面板展示与埋点,不影响 undo/redo 行为。 */
1905
+ source?: HistoryOpSource;
1850
1906
  /** 入栈时间戳(毫秒),入栈时自动写入,仅用于历史面板展示。 */
1851
1907
  timestamp?: number;
1852
1908
  }
@@ -2107,10 +2163,12 @@ type AsyncMethodName = Writable<(typeof canUsePluginMethods)['async']>;
2107
2163
  * 历史记录写入相关的通用配置(codeBlock / dataSource / editor 共用)
2108
2164
  * - doNotPushHistory: 操作完成后是否不要将本次操作压入历史栈(撤销/重做记录),默认 false
2109
2165
  * - historyDescription: 入栈时附带的人类可读描述,用于历史面板展示;不影响 undo/redo 行为,缺省时面板会自动生成描述
2166
+ * - historySource: 操作途径,取值见 {@link HistoryOpSource}(画布 / 树面板 / 组件面板 / 配置面板 / 源码编辑器 / 右键菜单 / 工具栏 / 快捷键 / 回滚 / 接口 等),用于历史面板展示与埋点;不影响 undo/redo 行为
2110
2167
  */
2111
2168
  interface HistoryOpOptions {
2112
2169
  doNotPushHistory?: boolean;
2113
2170
  historyDescription?: string;
2171
+ historySource?: HistoryOpSource;
2114
2172
  }
2115
2173
  /**
2116
2174
  * 在 HistoryOpOptions 基础上携带 form 端 propPath/value 变更记录,
@@ -2131,7 +2189,7 @@ interface DslOpOptions extends HistoryOpOptions {
2131
2189
  /** 差异对话框的入参 */
2132
2190
  interface DiffDialogPayload {
2133
2191
  /** 表单类别 */
2134
- category: CompareCategory;
2192
+ category?: CompareCategory;
2135
2193
  /** 节点类型 / 数据源类型 */
2136
2194
  type?: string;
2137
2195
  /** 代码块场景下的数据源类型 */
@@ -2210,7 +2268,11 @@ declare const useCodeBlockEdit: (codeBlockService: Services["codeBlockService"])
2210
2268
  }, {}, {}, {}, {}> | null>>;
2211
2269
  createCodeBlock: () => Promise<void>;
2212
2270
  editCode: (id: string) => Promise<void>;
2213
- deleteCode: (key: string) => Promise<void>;
2271
+ deleteCode: (key: string, {
2272
+ historySource
2273
+ }?: {
2274
+ historySource?: HistoryOpSource;
2275
+ }) => Promise<void>;
2214
2276
  submitCodeBlockHandler: (values: CodeBlockContent, eventData?: ContainerChangeEventData) => Promise<void>;
2215
2277
  };
2216
2278
  //#endregion
@@ -3947,13 +4009,21 @@ declare const __VLS_base$9: import("@vue/runtime-core").DefineComponent<__VLS_Pr
3947
4009
  draggable: boolean;
3948
4010
  }> & Omit<Map<Id, LayerNodeStatus>, keyof Map<any, any>>)>;
3949
4011
  filter: (text: string | string[]) => void;
3950
- deleteCode: (id: string) => Promise<void>;
4012
+ deleteCode: (id: string, {
4013
+ historySource
4014
+ }?: {
4015
+ historySource?: HistoryOpSource;
4016
+ }) => Promise<void>;
3951
4017
  }, {}, {}, {}, import("@vue/runtime-core").ComponentOptionsMixin, import("@vue/runtime-core").ComponentOptionsMixin, {
3952
- remove: (id: string) => any;
4018
+ remove: (id: string, args_1: {
4019
+ historySource?: HistoryOpSource;
4020
+ }) => any;
3953
4021
  edit: (id: string) => any;
3954
4022
  "node-contextmenu": (event: MouseEvent, data: TreeNodeData) => any;
3955
4023
  }, string, import("@vue/runtime-core").PublicProps, Readonly<__VLS_Props$20> & Readonly<{
3956
- onRemove?: ((id: string) => any) | undefined;
4024
+ onRemove?: ((id: string, args_1: {
4025
+ historySource?: HistoryOpSource;
4026
+ }) => any) | undefined;
3957
4027
  onEdit?: ((id: string) => any) | undefined;
3958
4028
  "onNode-contextmenu"?: ((event: MouseEvent, data: TreeNodeData) => any) | undefined;
3959
4029
  }>, {}, {}, {}, {}, string, import("@vue/runtime-core").ComponentProvideOptions, false, {}, any>;
@@ -5391,7 +5461,8 @@ type __VLS_Props$8 = {
5391
5461
  }[]; /** 组级描述文案生成器,接收一个 group,返回展示文本。由父组件按业务类型注入。 */
5392
5462
  describeGroup: (_group: any) => string; /** 单步描述文案生成器,接收一个 step,返回展示文本。用于合并组展开后的子步列表。 */
5393
5463
  describeStep: (_step: any) => string; /** 判断某个 step 是否可查看差异(前后值都存在)。由父组件按业务类型注入;不传则一律不展示差异入口。 */
5394
- isStepDiffable?: (_step: any) => boolean; /** 共享的折叠状态表(key -> 是否展开),由顶层 panel 统一维护以便跨 tab 复用。 */
5464
+ isStepDiffable?: (_step: any) => boolean; /** 判断某个 step 是否支持回滚(如更新需带 changeRecords)。由父组件按业务类型注入;不传则已应用即可回滚。 */
5465
+ isStepRevertable?: (_step: any) => boolean; /** 共享的折叠状态表(key -> 是否展开),由顶层 panel 统一维护以便跨 tab 复用。 */
5395
5466
  expanded: Record<string, boolean>; /** 是否支持「跳转到该记录」(goto)。默认 true。 */
5396
5467
  gotoEnabled?: boolean;
5397
5468
  };
@@ -5636,4 +5707,4 @@ declare const _default$39: {
5636
5707
  install: (app: App, opt?: Partial<EditorInstallOptions | DesignPluginOptions | FormInstallOptions>) => void;
5637
5708
  };
5638
5709
  //#endregion
5639
- export { AddMNode, AddPrefixToObject, AsyncAfterHook, AsyncBeforeHook, AsyncHookPlugin, AsyncMethodName, BeforeAdd, CODE_DRAFT_STORAGE_KEY, COPY_CODE_STORAGE_KEY, COPY_DS_STORAGE_KEY, COPY_STORAGE_KEY, CanDropInFunction, CanDropInScene, _default as CodeBlockEditor, CodeBlockHistoryGroup, _default$1 as CodeBlockList, _default$2 as CodeBlockListPanel, CodeBlockListPanelSlots, CodeBlockListSlots, CodeBlockStepValue, CodeDeleteErrorType, CodeDslItem, CodeParamStatement, CodeRelation, _default$3 as CodeSelect, _default$4 as CodeSelectCol, CodeState, ColumnLayout, CombineInfo, CompareCategory, _default$5 as CompareForm, CompareFormLoadConfig, CompareFormLoadConfigContext, ComponentGroup, ComponentGroupState, ComponentItem, _default$6 as ComponentListPanel, ComponentListPanelSlots, _default$7 as CondOpSelect, _default$8 as ContentMenu, CustomContentMenuFunction, DEFAULT_LEFT_COLUMN_WIDTH, DEFAULT_RIGHT_COLUMN_WIDTH, _default$9 as DataSourceAddButton, _default$10 as DataSourceConfigPanel, _default$11 as DataSourceFieldSelect, _default$12 as DataSourceFields, DataSourceHistoryGroup, _default$13 as DataSourceInput, DataSourceListSlots, _default$14 as DataSourceMethodSelect, _default$15 as DataSourceMethods, _default$16 as DataSourceMocks, _default$17 as DataSourceSelect, DataSourceStepValue, DatasourceTypeOption, DepTargetType, DiffDialogPayload, _default$18 as DisplayConds, DragClassification, DragType, DslOpOptions, EditorEvents, EditorInstallOptions, EditorNodeInfo, EditorSlots, EventBus, EventBusEvent, _default$19 as EventSelect, Fixed2Other, _default$20 as FloatingBox, FrameworkSlots, GetCodeBlockFormConfigOptions, GetColumnWidth, GetConfig, H_GUIDE_LINE_STORAGE_KEY, _default$21 as HistoryDiffDialog, _default$22 as HistoryListBucket, HistoryListExtraTab, HistoryOpOptions, HistoryOpOptionsWithChangeRecords, HistoryOpType, HistoryState, _default$23 as Icon, IdleTask, IdleTaskEvents, IsExpandableFunction, KeyBindingCacheItem, KeyBindingCommand, KeyBindingItem, _default$24 as KeyValue, Keys, LEFT_COLUMN_WIDTH_STORAGE_KEY, LayerNodeSlots, LayerNodeStatus, LayerOffset, _default$25 as LayerPanel, LayerPanelSlots, Layout, _default$26 as LayoutContainer, _default$26 as SplitView, ListState, MIN_CENTER_COLUMN_WIDTH, MIN_LEFT_COLUMN_WIDTH, MIN_RIGHT_COLUMN_WIDTH, MenuBarData, MenuButton, MenuComponent, MenuItem, type OnDrag, PROPS_PANEL_WIDTH_STORAGE_KEY, PageBarSortOptions, _default$27 as PageFragmentSelect, PageHistoryGroup, PageHistoryStepEntry, PartSortableOptions, PastePosition, PropsFormConfigFunction, _default$28 as PropsFormPanel, PropsFormValueFunction, _default$29 as PropsPanel, PropsPanelSlots, PropsState, RIGHT_COLUMN_WIDTH_STORAGE_KEY, _default$30 as Resizer, ScrollViewer, ScrollViewerEvent, ScrollViewerSlots, Services, SetColumnWidth, SideBarData, SideComponent, SideItem, SideItemKey, SidebarSlots, StageCore, StageOptions, StageOverlayState, StageRect, StageSlots, StepValue, StoreState, StoreStateKey, _default$31 as StyleSetter, SyncAfterHook, SyncBeforeHook, SyncHookPlugin, _default$32 as TMagicCodeEditor, _default$33 as TMagicEditor, _default$34 as ToolButton, _default$35 as Tree, _default$36 as TreeNode, TreeNodeData, UI_SELECT_MODE_EVENT_NAME, UiState, UndoRedo, V_GUIDE_LINE_STORAGE_KEY, WorkspaceSlots, advancedTabConfig, arrayOptions, beforePaste, buildChangeRecords, calcAlignCenterStyle, calcLayerTargetIndex, calcMoveStyle, canUsePluginMethods, change2Fixed, classifyDragSources, _default$37 as codeBlockService, collectRelatedNodes, _default$38 as dataSourceService, debug, _default$39 as default, defaultIsExpandable, _default$40 as depService, designPlugin, displayTabConfig, editorNodeMergeCustomizer, _default$41 as editorService, eqOptions, error, eventTabConfig, _default$42 as eventsService, fillConfig, fixNodeLeft, fixNodePosition, formPlugin, generatePageName, generatePageNameByApp, getAddParent, getCascaderOptionsFromFields, getCodeBlockFormConfig, getDefaultConfig, getDisplayField, getEditorConfig, getFieldType, getFormConfig, getFormValue, getGuideLineFromCache, getInitPositionStyle, getNodeIndex, getPageFragmentList, getPageList, getPageNameList, getPositionInContainer, getRelativeStyle, _default$43 as historyService, info, isIncludeDataSource, _default$44 as loadMonaco, log, moveItemsInContainer, numberOptions, _default$45 as propsService, resolveSelectedNode, serializeConfig, setChildrenLayout, setEditorConfig, setLayout, _default$46 as stageOverlayService, _default$47 as storageService, styleTabConfig, tablePlugin, toggleFixedPosition, _default$48 as uiService, updateStatus, useCodeBlockEdit, useEditorContentHeight, useFilter, useFloatBox, useGetSo, useNextFloatBoxPosition, useNodeStatus, useServices, useStage, useWindowRect, warn };
5710
+ export { AddMNode, AddPrefixToObject, AsyncAfterHook, AsyncBeforeHook, AsyncHookPlugin, AsyncMethodName, BeforeAdd, CODE_DRAFT_STORAGE_KEY, COPY_CODE_STORAGE_KEY, COPY_DS_STORAGE_KEY, COPY_STORAGE_KEY, CanDropInFunction, CanDropInScene, _default as CodeBlockEditor, CodeBlockHistoryGroup, _default$1 as CodeBlockList, _default$2 as CodeBlockListPanel, CodeBlockListPanelSlots, CodeBlockListSlots, CodeBlockStepValue, CodeDeleteErrorType, CodeDslItem, CodeParamStatement, CodeRelation, _default$3 as CodeSelect, _default$4 as CodeSelectCol, CodeState, ColumnLayout, CombineInfo, CompareCategory, _default$5 as CompareForm, CompareFormLoadConfig, CompareFormLoadConfigContext, ComponentGroup, ComponentGroupState, ComponentItem, _default$6 as ComponentListPanel, ComponentListPanelSlots, _default$7 as CondOpSelect, _default$8 as ContentMenu, CustomContentMenuFunction, DEFAULT_LEFT_COLUMN_WIDTH, DEFAULT_RIGHT_COLUMN_WIDTH, _default$9 as DataSourceAddButton, _default$10 as DataSourceConfigPanel, _default$11 as DataSourceFieldSelect, _default$12 as DataSourceFields, DataSourceHistoryGroup, _default$13 as DataSourceInput, DataSourceListSlots, _default$14 as DataSourceMethodSelect, _default$15 as DataSourceMethods, _default$16 as DataSourceMocks, _default$17 as DataSourceSelect, DataSourceStepValue, DatasourceTypeOption, DepTargetType, DiffDialogPayload, _default$18 as DisplayConds, DragClassification, DragType, DslOpOptions, EditorEvents, EditorInstallOptions, EditorNodeInfo, EditorSlots, EventBus, EventBusEvent, _default$19 as EventSelect, Fixed2Other, _default$20 as FloatingBox, FrameworkSlots, GetCodeBlockFormConfigOptions, GetColumnWidth, GetConfig, H_GUIDE_LINE_STORAGE_KEY, _default$21 as HistoryDiffDialog, _default$22 as HistoryListBucket, HistoryListExtraTab, HistoryOpOptions, HistoryOpOptionsWithChangeRecords, HistoryOpSource, HistoryOpType, HistoryState, _default$23 as Icon, IdleTask, IdleTaskEvents, IsExpandableFunction, KeyBindingCacheItem, KeyBindingCommand, KeyBindingItem, _default$24 as KeyValue, Keys, LEFT_COLUMN_WIDTH_STORAGE_KEY, LayerNodeSlots, LayerNodeStatus, LayerOffset, _default$25 as LayerPanel, LayerPanelSlots, Layout, _default$26 as LayoutContainer, _default$26 as SplitView, ListState, MIN_CENTER_COLUMN_WIDTH, MIN_LEFT_COLUMN_WIDTH, MIN_RIGHT_COLUMN_WIDTH, MenuBarData, MenuButton, MenuComponent, MenuItem, type OnDrag, PROPS_PANEL_WIDTH_STORAGE_KEY, PageBarSortOptions, _default$27 as PageFragmentSelect, PageHistoryGroup, PageHistoryStepEntry, PartSortableOptions, PastePosition, PropsFormConfigFunction, _default$28 as PropsFormPanel, PropsFormValueFunction, _default$29 as PropsPanel, PropsPanelSlots, PropsState, RIGHT_COLUMN_WIDTH_STORAGE_KEY, _default$30 as Resizer, ScrollViewer, ScrollViewerEvent, ScrollViewerSlots, Services, SetColumnWidth, SideBarData, SideComponent, SideItem, SideItemKey, SidebarSlots, StageCore, StageOptions, StageOverlayState, StageRect, StageSlots, StepValue, StoreState, StoreStateKey, _default$31 as StyleSetter, SyncAfterHook, SyncBeforeHook, SyncHookPlugin, _default$32 as TMagicCodeEditor, _default$33 as TMagicEditor, _default$34 as ToolButton, _default$35 as Tree, _default$36 as TreeNode, TreeNodeData, UI_SELECT_MODE_EVENT_NAME, UiState, UndoRedo, V_GUIDE_LINE_STORAGE_KEY, WorkspaceSlots, advancedTabConfig, arrayOptions, beforePaste, buildChangeRecords, calcAlignCenterStyle, calcLayerTargetIndex, calcMoveStyle, canUsePluginMethods, change2Fixed, classifyDragSources, _default$37 as codeBlockService, collectRelatedNodes, _default$38 as dataSourceService, debug, _default$39 as default, defaultIsExpandable, _default$40 as depService, designPlugin, displayTabConfig, editorNodeMergeCustomizer, _default$41 as editorService, eqOptions, error, eventTabConfig, _default$42 as eventsService, fillConfig, fixNodeLeft, fixNodePosition, formPlugin, generatePageName, generatePageNameByApp, getAddParent, getCascaderOptionsFromFields, getCodeBlockFormConfig, getDefaultConfig, getDisplayField, getEditorConfig, getFieldType, getFormConfig, getFormValue, getGuideLineFromCache, getInitPositionStyle, getNodeIndex, getPageFragmentList, getPageList, getPageNameList, getPositionInContainer, getRelativeStyle, _default$43 as historyService, info, isIncludeDataSource, _default$44 as loadMonaco, log, moveItemsInContainer, numberOptions, _default$45 as propsService, resolveSelectedNode, serializeConfig, setChildrenLayout, setEditorConfig, setLayout, _default$46 as stageOverlayService, _default$47 as storageService, styleTabConfig, tablePlugin, toggleFixedPosition, _default$48 as uiService, updateStatus, useCodeBlockEdit, useEditorContentHeight, useFilter, useFloatBox, useGetSo, useNextFloatBoxPosition, useNodeStatus, useServices, useStage, useWindowRect, warn };