|
|
@@ -12,6 +12,7 @@ import {
|
|
|
WorkflowNodeMeta,
|
|
|
WorkflowSelectService,
|
|
|
HistoryService,
|
|
|
+ PlaygroundConfigEntity,
|
|
|
} from '@flowgram.ai/free-layout-editor';
|
|
|
import { Toast } from '@douyinfe/semi-ui';
|
|
|
|
|
|
@@ -23,6 +24,8 @@ export class DeleteShortcut implements ShortcutsHandler {
|
|
|
|
|
|
public shortcuts = ['backspace', 'delete'];
|
|
|
|
|
|
+ private playgroundConfig: PlaygroundConfigEntity;
|
|
|
+
|
|
|
private document: WorkflowDocument;
|
|
|
|
|
|
private selectService: WorkflowSelectService;
|
|
|
@@ -33,6 +36,7 @@ export class DeleteShortcut implements ShortcutsHandler {
|
|
|
* initialize delete shortcut - 初始化删除快捷键
|
|
|
*/
|
|
|
constructor(context: FreeLayoutPluginContext) {
|
|
|
+ this.playgroundConfig = context.playground.config;
|
|
|
this.document = context.get(WorkflowDocument);
|
|
|
this.selectService = context.get(WorkflowSelectService);
|
|
|
this.historyService = context.get(HistoryService);
|
|
|
@@ -43,6 +47,9 @@ export class DeleteShortcut implements ShortcutsHandler {
|
|
|
* execute delete operation - 执行删除操作
|
|
|
*/
|
|
|
public async execute(nodes?: WorkflowNodeEntity[]): Promise<void> {
|
|
|
+ if (this.readonly) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
const selection = Array.isArray(nodes) ? nodes : this.selectService.selection;
|
|
|
if (
|
|
|
!this.isValid(
|
|
|
@@ -68,6 +75,13 @@ export class DeleteShortcut implements ShortcutsHandler {
|
|
|
this.historyService.endTransaction();
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * readonly - 是否只读
|
|
|
+ */
|
|
|
+ private get readonly(): boolean {
|
|
|
+ return this.playgroundConfig.readonly;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* validate if nodes can be deleted - 验证节点是否可以删除
|
|
|
*/
|