fix(core): canDrop check for external (#9058)

This commit is contained in:
pengx17
2024-12-09 10:25:38 +00:00
parent 9365958a02
commit 814b4c9cb0
12 changed files with 141 additions and 55 deletions

View File

@@ -1,4 +1,7 @@
import type { ExternalGetDataFeedbackArgs } from '@affine/component';
import type {
ExternalDataAdapter,
ExternalGetDataFeedbackArgs,
} from '@affine/component';
import type { AffineDNDData } from '@affine/core/types/dnd';
import type { DocsService, WorkspaceService } from '@toeverything/infra';
import { Service } from '@toeverything/infra';
@@ -23,7 +26,13 @@ export class DndService extends Service {
private readonly resolvers = new Map<string, EntityResolver>();
externalDataAdapter = (args: ExternalGetDataFeedbackArgs) => {
externalDataAdapter: ExternalDataAdapter<AffineDNDData> = (
args: ExternalGetDataFeedbackArgs,
isDropEvent?: boolean
) => {
if (!isDropEvent) {
return {};
}
const from: AffineDNDData['draggable']['from'] = {
at: 'external',
};
@@ -43,6 +52,10 @@ export class DndService extends Service {
}
}
if (!entity) {
return {}; // no resolver can handle this data
}
return {
from,
entity,