refactor: migrate elements clone from default-tool to extension (#11703)

### Changed
- Add `onRequestElementsClone` action to allow extension to define how to clone gfx elements
This commit is contained in:
doouding
2025-04-22 08:18:23 +00:00
parent 52953ce8e3
commit 21bf009553
6 changed files with 92 additions and 23 deletions

View File

@@ -12,6 +12,7 @@ import {
InteractivityExtensionIdentifier,
} from './extension/base.js';
import { GfxViewEventManager } from './gfx-view-event-handler.js';
import type { RequestElementsCloneContext } from './types/clone.js';
import type {
DragExtensionInitializeContext,
DragInitializationOption,
@@ -288,4 +289,21 @@ export class InteractivityManager extends GfxExtension {
listenEvent();
dragStart();
}
requestElementsClone(options: RequestElementsCloneContext) {
const extensions = this.interactExtensions;
for (let ext of extensions.values()) {
const cloneData = (ext.action as InteractivityActionAPI).emit(
'elementsClone',
options
);
if (cloneData) {
return cloneData;
}
}
return Promise.resolve(undefined);
}
}