refactor(editor): remove legacy dnd config (#9291)

This commit is contained in:
Saul-Mirone
2024-12-24 13:59:36 +00:00
parent 052d74896e
commit f5dea2a990
18 changed files with 43 additions and 385 deletions

View File

@@ -8,16 +8,8 @@ import {
EMBED_CARD_MIN_WIDTH,
EMBED_CARD_WIDTH,
} from '@blocksuite/affine-shared/consts';
import {
DocModeProvider,
DragHandleConfigExtension,
} from '@blocksuite/affine-shared/services';
import {
captureEventTarget,
convertDragPreviewDocToEdgeless,
convertDragPreviewEdgelessToDoc,
} from '@blocksuite/affine-shared/utils';
import { type BlockService, isGfxBlockComponent } from '@blocksuite/block-std';
import { DocModeProvider } from '@blocksuite/affine-shared/services';
import type { BlockService } from '@blocksuite/block-std';
import type { GfxCompatibleProps } from '@blocksuite/block-std/gfx';
import type { BlockModel } from '@blocksuite/store';
import type { TemplateResult } from 'lit';
@@ -26,48 +18,6 @@ import { query } from 'lit/decorators.js';
import { classMap } from 'lit/directives/class-map.js';
import { type StyleInfo, styleMap } from 'lit/directives/style-map.js';
export const EmbedDragHandleOption = DragHandleConfigExtension({
flavour: /affine:embed-*/,
edgeless: true,
onDragEnd: props => {
const { state, draggingElements } = props;
if (
draggingElements.length !== 1 ||
draggingElements[0].model.flavour.match(/affine:embed-*/) === null
)
return false;
const blockComponent = draggingElements[0] as EmbedBlockComponent;
const isInSurface = isGfxBlockComponent(blockComponent);
const target = captureEventTarget(state.raw.target);
const isTargetEdgelessContainer =
target?.classList.contains('edgeless-container');
if (isInSurface) {
const style = blockComponent._cardStyle;
const targetStyle =
style === 'vertical' || style === 'cube' ? 'horizontal' : style;
return convertDragPreviewEdgelessToDoc({
blockComponent,
style: targetStyle,
...props,
});
} else if (isTargetEdgelessContainer) {
const style = blockComponent._cardStyle;
return convertDragPreviewDocToEdgeless({
blockComponent,
cssSelector: '.embed-block-container',
width: EMBED_CARD_WIDTH[style],
height: EMBED_CARD_HEIGHT[style],
...props,
});
}
return false;
},
});
export class EmbedBlockComponent<
Model extends BlockModel<GfxCompatibleProps> = BlockModel<GfxCompatibleProps>,
Service extends BlockService = BlockService,

View File

@@ -1,6 +1,5 @@
import type { ExtensionType } from '@blocksuite/block-std';
import { EmbedDragHandleOption } from './common/embed-block-element.js';
import { EmbedFigmaBlockSpec } from './embed-figma-block/index.js';
import { EmbedGithubBlockSpec } from './embed-github-block/index.js';
import { EmbedHtmlBlockSpec } from './embed-html-block/index.js';
@@ -10,7 +9,6 @@ import { EmbedSyncedDocBlockSpec } from './embed-synced-doc-block/index.js';
import { EmbedYoutubeBlockSpec } from './embed-youtube-block/index.js';
export const EmbedExtensions: ExtensionType[] = [
EmbedDragHandleOption,
EmbedFigmaBlockSpec,
EmbedGithubBlockSpec,
EmbedHtmlBlockSpec,