refactor(editor): move file drop manager to components (#9264)

This commit is contained in:
Saul-Mirone
2024-12-24 02:20:03 +00:00
parent 74a168222c
commit b29cb5945a
16 changed files with 321 additions and 261 deletions

View File

@@ -2,10 +2,6 @@ import { RootBlockSchema } from '@blocksuite/affine-model';
import type { BlockComponent } from '@blocksuite/block-std';
import { BlockService } from '@blocksuite/block-std';
import {
FileDropManager,
type FileDropOptions,
} from '../_common/components/file-drop-manager.js';
import {
HtmlTransformer,
MarkdownTransformer,
@@ -16,12 +12,6 @@ import type { RootBlockComponent } from './types.js';
export abstract class RootService extends BlockService {
static override readonly flavour = RootBlockSchema.model.flavour;
private readonly _fileDropOptions: FileDropOptions = {
flavour: this.flavour,
};
readonly fileDropManager = new FileDropManager(this, this._fileDropOptions);
transformers = {
markdown: MarkdownTransformer,
html: HtmlTransformer,
@@ -64,18 +54,6 @@ export abstract class RootService extends BlockService {
override mounted() {
super.mounted();
this.disposables.addFromEvent(
this.host,
'dragover',
this.fileDropManager.onDragOver
);
this.disposables.addFromEvent(
this.host,
'dragleave',
this.fileDropManager.onDragLeave
);
this.disposables.add(
this.std.event.add('pointerDown', ctx => {
const state = ctx.get('pointerState');