mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-17 14:27:02 +08:00
refactor(editor): remove legacy dnd config (#9291)
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user