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
@@ -0,0 +1,24 @@
import { correctNumberedListsOrderToPrev } from '@blocksuite/affine-block-list';
import { matchFlavours } from '@blocksuite/affine-shared/utils';
import type { BlockStdScope } from '@blocksuite/block-std';
import type { JobMiddleware } from '@blocksuite/store';
export const reorderList =
(std: BlockStdScope): JobMiddleware =>
({ slots }) => {
slots.afterImport.on(payload => {
if (payload.type === 'block') {
const model = payload.model;
if (
matchFlavours(model, ['affine:list']) &&
model.type === 'numbered'
) {
const next = std.doc.getNext(model);
correctNumberedListsOrderToPrev(std.doc, model);
if (next) {
correctNumberedListsOrderToPrev(std.doc, next);
}
}
}
});
};
@@ -34,6 +34,7 @@ import { DropIndicator } from '../components/drop-indicator.js';
import { AFFINE_DRAG_HANDLE_WIDGET } from '../consts.js';
import type { AffineDragHandleWidget } from '../drag-handle.js';
import { newIdCrossDoc } from '../middleware/new-id-cross-doc.js';
import { reorderList } from '../middleware/reorder-list';
import { surfaceRefToEmbed } from '../middleware/surface-ref-to-embed.js';
import { containBlock, includeTextSelection } from '../utils.js';
@@ -537,7 +538,11 @@ export class DragEventWatcher {
const std = this._std;
return new Job({
collection: std.collection,
middlewares: [newIdCrossDoc(std), surfaceRefToEmbed(std)],
middlewares: [
newIdCrossDoc(std),
reorderList(std),
surfaceRefToEmbed(std),
],
});
}