@tmagic/editor 1.8.0-beta.2 → 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.
- package/dist/es/Editor.vue_vue_type_script_setup_true_lang.js +9 -0
- package/dist/es/components/CompareForm.vue_vue_type_script_setup_true_lang.js +46 -28
- package/dist/es/editorProps.js +2 -0
- package/dist/es/fields/CodeLink.vue_vue_type_script_setup_true_lang.js +2 -5
- package/dist/es/hooks/use-code-block-edit.js +6 -3
- package/dist/es/hooks/use-data-source-edit.js +5 -2
- package/dist/es/hooks/use-stage.js +8 -4
- package/dist/es/index.js +3 -1
- package/dist/es/layouts/CodeEditor.vue_vue_type_script_setup_true_lang.js +2 -5
- package/dist/es/layouts/NavMenu.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 +37 -14
- package/dist/es/layouts/history-list/BucketTab.js +5 -0
- package/dist/es/layouts/history-list/{CodeBlockTab.vue_vue_type_script_setup_true_lang.js → BucketTab.vue_vue_type_script_setup_true_lang.js} +30 -16
- package/dist/es/layouts/history-list/GroupRow.vue_vue_type_script_setup_true_lang.js +91 -60
- package/dist/es/layouts/history-list/HistoryDiffDialog.vue_vue_type_script_setup_true_lang.js +82 -30
- package/dist/es/layouts/history-list/HistoryListPanel.vue_vue_type_script_setup_true_lang.js +140 -66
- package/dist/es/layouts/history-list/InitialRow.vue_vue_type_script_setup_true_lang.js +15 -9
- package/dist/es/layouts/history-list/PageTab.vue_vue_type_script_setup_true_lang.js +15 -6
- package/dist/es/layouts/history-list/composables.js +72 -2
- package/dist/es/layouts/props-panel/PropsPanel.vue_vue_type_script_setup_true_lang.js +5 -1
- package/dist/es/layouts/sidebar/ComponentListPanel.vue_vue_type_script_setup_true_lang.js +1 -1
- package/dist/es/layouts/sidebar/code-block/CodeBlockList.vue_vue_type_script_setup_true_lang.js +3 -3
- package/dist/es/layouts/sidebar/code-block/CodeBlockListPanel.vue_vue_type_script_setup_true_lang.js +1 -1
- package/dist/es/layouts/sidebar/code-block/useContentMenu.js +1 -1
- package/dist/es/layouts/sidebar/data-source/DataSourceListPanel.vue_vue_type_script_setup_true_lang.js +1 -1
- package/dist/es/layouts/sidebar/data-source/useContentMenu.js +1 -1
- package/dist/es/layouts/sidebar/layer/LayerMenu.vue_vue_type_script_setup_true_lang.js +5 -5
- package/dist/es/layouts/sidebar/layer/LayerNodeTool.vue_vue_type_script_setup_true_lang.js +1 -1
- package/dist/es/layouts/workspace/viewer/Stage.vue_vue_type_script_setup_true_lang.js +1 -1
- package/dist/es/layouts/workspace/viewer/ViewerMenu.vue_vue_type_script_setup_true_lang.js +8 -8
- package/dist/es/services/codeBlock.js +25 -10
- package/dist/es/services/dataSource.js +24 -10
- package/dist/es/services/editor.js +98 -46
- package/dist/es/services/history.js +7 -2
- package/dist/es/services/keybinding.js +3 -3
- package/dist/es/style.css +60 -16
- package/dist/es/utils/content-menu.js +17 -9
- package/dist/style.css +60 -16
- package/dist/tmagic-editor.umd.cjs +795 -443
- package/package.json +7 -7
- package/src/Editor.vue +8 -0
- package/src/components/CompareForm.vue +50 -19
- package/src/editorProps.ts +7 -0
- package/src/fields/CodeLink.vue +2 -5
- package/src/hooks/use-code-block-edit.ts +4 -3
- package/src/hooks/use-data-source-edit.ts +2 -2
- package/src/hooks/use-stage.ts +4 -3
- package/src/index.ts +2 -0
- package/src/layouts/CodeEditor.vue +2 -5
- package/src/layouts/NavMenu.vue +1 -1
- package/src/layouts/history-list/Bucket.vue +58 -29
- package/src/layouts/history-list/BucketTab.vue +80 -0
- package/src/layouts/history-list/GroupRow.vue +110 -58
- package/src/layouts/history-list/HistoryDiffDialog.vue +53 -33
- package/src/layouts/history-list/HistoryListPanel.vue +165 -52
- package/src/layouts/history-list/InitialRow.vue +17 -6
- package/src/layouts/history-list/PageTab.vue +25 -7
- package/src/layouts/history-list/composables.ts +92 -1
- package/src/layouts/props-panel/PropsPanel.vue +5 -1
- package/src/layouts/sidebar/ComponentListPanel.vue +9 -5
- package/src/layouts/sidebar/code-block/CodeBlockList.vue +5 -5
- package/src/layouts/sidebar/code-block/CodeBlockListPanel.vue +1 -1
- package/src/layouts/sidebar/code-block/useContentMenu.ts +1 -1
- package/src/layouts/sidebar/data-source/DataSourceListPanel.vue +1 -1
- package/src/layouts/sidebar/data-source/useContentMenu.ts +1 -1
- package/src/layouts/sidebar/layer/LayerMenu.vue +19 -11
- package/src/layouts/sidebar/layer/LayerNodeTool.vue +7 -4
- package/src/layouts/workspace/viewer/Stage.vue +1 -1
- package/src/layouts/workspace/viewer/ViewerMenu.vue +8 -8
- package/src/services/codeBlock.ts +33 -9
- package/src/services/dataSource.ts +30 -8
- package/src/services/editor.ts +111 -34
- package/src/services/history.ts +10 -0
- package/src/services/keybinding.ts +3 -3
- package/src/theme/history-list-panel.scss +67 -14
- package/src/theme/props-panel.scss +3 -3
- package/src/type.ts +146 -0
- package/src/utils/content-menu.ts +18 -9
- package/types/index.d.ts +387 -156
- package/dist/es/layouts/history-list/CodeBlockTab.js +0 -5
- package/dist/es/layouts/history-list/DataSourceTab.js +0 -5
- package/dist/es/layouts/history-list/DataSourceTab.vue_vue_type_script_setup_true_lang.js +0 -62
- package/src/layouts/history-list/CodeBlockTab.vue +0 -61
- package/src/layouts/history-list/DataSourceTab.vue +0 -61
package/src/type.ts
CHANGED
|
@@ -199,6 +199,11 @@ export interface StageOptions {
|
|
|
199
199
|
*/
|
|
200
200
|
alwaysMultiSelect?: boolean;
|
|
201
201
|
disabledRule?: boolean;
|
|
202
|
+
/**
|
|
203
|
+
* 禁用「非点击画布选中组件时(如从图层树、面包屑等外部选中),对选中区域做高亮闪烁提示」,
|
|
204
|
+
* 默认 false(即默认开启闪烁)
|
|
205
|
+
*/
|
|
206
|
+
disabledFlashTip?: boolean;
|
|
202
207
|
zoom?: number;
|
|
203
208
|
/** 画布双击前的钩子函数,返回 false 则阻止默认的双击行为 */
|
|
204
209
|
beforeDblclick?: (event: MouseEvent) => Promise<boolean | void> | boolean | void;
|
|
@@ -475,6 +480,63 @@ export interface SideComponent extends MenuComponent {
|
|
|
475
480
|
}
|
|
476
481
|
// #endregion SideComponent
|
|
477
482
|
|
|
483
|
+
// #region HistoryListExtraTab
|
|
484
|
+
/**
|
|
485
|
+
* 历史记录面板(HistoryListPanel)的自定义扩展 tab。
|
|
486
|
+
*
|
|
487
|
+
* 业务方可通过 Editor 的 `historyListExtraTabs` 注入额外的历史记录 tab,
|
|
488
|
+
* 例如某个自定义模块维护自己的操作历史时,可以在历史记录面板中增加一个
|
|
489
|
+
* 独立的 tab 来展示与回滚。内置的「页面 / 数据源 / 代码块」三个 tab 之后
|
|
490
|
+
* 会依次追加这些扩展 tab。
|
|
491
|
+
*/
|
|
492
|
+
export interface HistoryListExtraTab {
|
|
493
|
+
/** tab 唯一标识,作为 TMagicTabs 的 name */
|
|
494
|
+
name: string;
|
|
495
|
+
/** tab 显示文案,支持传入函数以展示动态内容(如记录数量) */
|
|
496
|
+
label: string | (() => string);
|
|
497
|
+
/** tab 内容区渲染的组件(Vue 组件或字符串标签) */
|
|
498
|
+
component: any;
|
|
499
|
+
/** 传入内容组件的 props */
|
|
500
|
+
props?: Record<string, any>;
|
|
501
|
+
/** 内容组件的事件监听 */
|
|
502
|
+
listeners?: Record<string, (..._args: any[]) => any>;
|
|
503
|
+
}
|
|
504
|
+
// #endregion HistoryListExtraTab
|
|
505
|
+
|
|
506
|
+
// #region CompareForm
|
|
507
|
+
/**
|
|
508
|
+
* 对比表单(CompareForm)的对比类型:
|
|
509
|
+
* - node: 节点组件,按 `type` 从 propsService 获取属性表单配置
|
|
510
|
+
* - data-source: 数据源,按 `type`(base/http/...) 从 dataSourceService 获取数据源表单配置
|
|
511
|
+
* - code-block: 数据源代码块,使用内置的代码块表单配置
|
|
512
|
+
*/
|
|
513
|
+
export type CompareCategory = 'node' | 'data-source' | 'code-block' | string;
|
|
514
|
+
|
|
515
|
+
/**
|
|
516
|
+
* 自定义 `loadConfig` 时回传的上下文,聚合了组件当前的对比入参,
|
|
517
|
+
* 方便调用方在外部按需拼装 FormConfig。
|
|
518
|
+
*/
|
|
519
|
+
export interface CompareFormLoadConfigContext {
|
|
520
|
+
/** 对比类型,见 CompareCategory */
|
|
521
|
+
category: string;
|
|
522
|
+
/** 节点 / 数据源类型 */
|
|
523
|
+
type?: string;
|
|
524
|
+
/** 数据源代码块场景下的数据源类型 */
|
|
525
|
+
dataSourceType?: string;
|
|
526
|
+
/**
|
|
527
|
+
* 内置的默认 FormConfig 加载逻辑(按 `category` 从 propsService / dataSourceService /
|
|
528
|
+
* 代码块工具取配置)。自定义 `loadConfig` 可调用它复用默认结果,再做二次加工。
|
|
529
|
+
*/
|
|
530
|
+
defaultLoadConfig: () => Promise<FormConfig>;
|
|
531
|
+
}
|
|
532
|
+
|
|
533
|
+
/**
|
|
534
|
+
* 自定义 FormConfig 加载逻辑。传入后将接管内置的按 `category` 取配置逻辑,
|
|
535
|
+
* 可通过 `ctx.defaultLoadConfig()` 复用默认结果再做二次加工。
|
|
536
|
+
*/
|
|
537
|
+
export type CompareFormLoadConfig = (ctx: CompareFormLoadConfigContext) => FormConfig | Promise<FormConfig>;
|
|
538
|
+
// #endregion CompareForm
|
|
539
|
+
|
|
478
540
|
// #region SideItemKey
|
|
479
541
|
export enum SideItemKey {
|
|
480
542
|
COMPONENT_LIST = 'component-list',
|
|
@@ -621,6 +683,44 @@ export interface CodeParamStatement {
|
|
|
621
683
|
export type HistoryOpType = 'add' | 'remove' | 'update';
|
|
622
684
|
// #endregion HistoryOpType
|
|
623
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
|
+
|
|
624
724
|
// #region StepValue
|
|
625
725
|
export interface StepValue {
|
|
626
726
|
/** 页面信息 */
|
|
@@ -651,6 +751,16 @@ export interface StepValue {
|
|
|
651
751
|
* 不影响 undo/redo 行为;缺省时面板会根据节点 / propPath 自动生成描述。
|
|
652
752
|
*/
|
|
653
753
|
historyDescription?: string;
|
|
754
|
+
/**
|
|
755
|
+
* 操作途径:标记本次变更由哪条交互入口触发,取值见 {@link HistoryOpSource}
|
|
756
|
+
* (画布 / 树面板 / 组件面板 / 配置面板 / 源码编辑器 / 右键菜单 / 工具栏 / 快捷键 / 回滚 / 接口 等)。
|
|
757
|
+
* 仅用于历史面板展示与业务埋点,不影响 undo/redo 行为;缺省时面板视为「未知」。
|
|
758
|
+
*/
|
|
759
|
+
source?: HistoryOpSource;
|
|
760
|
+
/**
|
|
761
|
+
* 入栈时间戳(毫秒)。在 historyService.push 时自动写入(若调用方未指定),仅用于历史面板展示。
|
|
762
|
+
*/
|
|
763
|
+
timestamp?: number;
|
|
654
764
|
}
|
|
655
765
|
// #endregion StepValue
|
|
656
766
|
|
|
@@ -675,6 +785,10 @@ export interface CodeBlockStepValue {
|
|
|
675
785
|
changeRecords?: ChangeRecord[];
|
|
676
786
|
/** 调用方可选传入的人类可读描述,用于历史面板展示;不影响 undo/redo 行为。 */
|
|
677
787
|
historyDescription?: string;
|
|
788
|
+
/** 操作途径:标记本次变更由哪条交互入口触发,取值见 {@link HistoryOpSource};仅用于历史面板展示与埋点,不影响 undo/redo 行为。 */
|
|
789
|
+
source?: HistoryOpSource;
|
|
790
|
+
/** 入栈时间戳(毫秒),入栈时自动写入,仅用于历史面板展示。 */
|
|
791
|
+
timestamp?: number;
|
|
678
792
|
}
|
|
679
793
|
// #endregion CodeBlockStepValue
|
|
680
794
|
|
|
@@ -699,6 +813,10 @@ export interface DataSourceStepValue {
|
|
|
699
813
|
changeRecords?: ChangeRecord[];
|
|
700
814
|
/** 调用方可选传入的人类可读描述,用于历史面板展示;不影响 undo/redo 行为。 */
|
|
701
815
|
historyDescription?: string;
|
|
816
|
+
/** 操作途径:标记本次变更由哪条交互入口触发,取值见 {@link HistoryOpSource};仅用于历史面板展示与埋点,不影响 undo/redo 行为。 */
|
|
817
|
+
source?: HistoryOpSource;
|
|
818
|
+
/** 入栈时间戳(毫秒),入栈时自动写入,仅用于历史面板展示。 */
|
|
819
|
+
timestamp?: number;
|
|
702
820
|
}
|
|
703
821
|
// #endregion DataSourceStepValue
|
|
704
822
|
|
|
@@ -1029,16 +1147,21 @@ export const canUsePluginMethods = {
|
|
|
1029
1147
|
|
|
1030
1148
|
export type AsyncMethodName = Writable<(typeof canUsePluginMethods)['async']>;
|
|
1031
1149
|
|
|
1150
|
+
// #region HistoryOpOptions
|
|
1032
1151
|
/**
|
|
1033
1152
|
* 历史记录写入相关的通用配置(codeBlock / dataSource / editor 共用)
|
|
1034
1153
|
* - doNotPushHistory: 操作完成后是否不要将本次操作压入历史栈(撤销/重做记录),默认 false
|
|
1035
1154
|
* - historyDescription: 入栈时附带的人类可读描述,用于历史面板展示;不影响 undo/redo 行为,缺省时面板会自动生成描述
|
|
1155
|
+
* - historySource: 操作途径,取值见 {@link HistoryOpSource}(画布 / 树面板 / 组件面板 / 配置面板 / 源码编辑器 / 右键菜单 / 工具栏 / 快捷键 / 回滚 / 接口 等),用于历史面板展示与埋点;不影响 undo/redo 行为
|
|
1036
1156
|
*/
|
|
1037
1157
|
export interface HistoryOpOptions {
|
|
1038
1158
|
doNotPushHistory?: boolean;
|
|
1039
1159
|
historyDescription?: string;
|
|
1160
|
+
historySource?: HistoryOpSource;
|
|
1040
1161
|
}
|
|
1162
|
+
// #endregion HistoryOpOptions
|
|
1041
1163
|
|
|
1164
|
+
// #region HistoryOpOptionsWithChangeRecords
|
|
1042
1165
|
/**
|
|
1043
1166
|
* 在 HistoryOpOptions 基础上携带 form 端 propPath/value 变更记录,
|
|
1044
1167
|
* 用于历史记录的精细化撤销/重做(按 propPath 局部 patch)。
|
|
@@ -1046,7 +1169,9 @@ export interface HistoryOpOptions {
|
|
|
1046
1169
|
export interface HistoryOpOptionsWithChangeRecords extends HistoryOpOptions {
|
|
1047
1170
|
changeRecords?: ChangeRecord[];
|
|
1048
1171
|
}
|
|
1172
|
+
// #endregion HistoryOpOptionsWithChangeRecords
|
|
1049
1173
|
|
|
1174
|
+
// #region DslOpOptions
|
|
1050
1175
|
/**
|
|
1051
1176
|
* DSL 修改类操作的通用配置
|
|
1052
1177
|
* - doNotSelect: 操作后是否不要自动触发选中(不调用 this.select / this.multiSelect / stage.select / stage.multiSelect)
|
|
@@ -1056,3 +1181,24 @@ export interface DslOpOptions extends HistoryOpOptions {
|
|
|
1056
1181
|
doNotSelect?: boolean;
|
|
1057
1182
|
doNotSwitchPage?: boolean;
|
|
1058
1183
|
}
|
|
1184
|
+
// #endregion DslOpOptions
|
|
1185
|
+
|
|
1186
|
+
/** 差异对话框的入参 */
|
|
1187
|
+
export interface DiffDialogPayload {
|
|
1188
|
+
/** 表单类别 */
|
|
1189
|
+
category?: CompareCategory;
|
|
1190
|
+
/** 节点类型 / 数据源类型 */
|
|
1191
|
+
type?: string;
|
|
1192
|
+
/** 代码块场景下的数据源类型 */
|
|
1193
|
+
dataSourceType?: string;
|
|
1194
|
+
/** 该 step 修改前的值(oldNode / oldSchema / oldContent) */
|
|
1195
|
+
lastValue: Record<string, any>;
|
|
1196
|
+
/** 该 step 修改后的值(newNode / newSchema / newContent) */
|
|
1197
|
+
value: Record<string, any>;
|
|
1198
|
+
/** 当前编辑器中实际的最新值;不传或为 null 时禁用「与当前对比」 */
|
|
1199
|
+
currentValue?: Record<string, any> | null;
|
|
1200
|
+
/** 用于标题展示的目标名称 */
|
|
1201
|
+
targetLabel?: string;
|
|
1202
|
+
/** 用于标题展示的目标 id */
|
|
1203
|
+
id?: string | number;
|
|
1204
|
+
}
|
|
@@ -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
|
-
|
|
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 = (
|
|
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
|
};
|