refactor(editor): remove legacy dnd config (#9291)
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
export * from './adapters/index.js';
|
||||
export { correctNumberedListsOrderToPrev } from './commands/utils';
|
||||
export * from './list-block.js';
|
||||
export * from './list-service.js';
|
||||
export * from './list-spec.js';
|
||||
|
||||
@@ -1,33 +1,6 @@
|
||||
import { ListBlockSchema } from '@blocksuite/affine-model';
|
||||
import { DragHandleConfigExtension } from '@blocksuite/affine-shared/services';
|
||||
import { matchFlavours } from '@blocksuite/affine-shared/utils';
|
||||
import type { BlockComponent } from '@blocksuite/block-std';
|
||||
import { BlockService } from '@blocksuite/block-std';
|
||||
|
||||
import { correctNumberedListsOrderToPrev } from './commands/utils.js';
|
||||
|
||||
export class ListBlockService extends BlockService {
|
||||
static override readonly flavour = ListBlockSchema.model.flavour;
|
||||
}
|
||||
|
||||
export const ListDragHandleOption = DragHandleConfigExtension({
|
||||
flavour: ListBlockSchema.model.flavour,
|
||||
onDragEnd: ({ draggingElements, editorHost }) => {
|
||||
draggingElements.forEach((el: BlockComponent) => {
|
||||
const model = el.model;
|
||||
const doc = el.doc;
|
||||
if (matchFlavours(model, ['affine:list']) && model.type === 'numbered') {
|
||||
const next = el.doc.getNext(model);
|
||||
editorHost.updateComplete
|
||||
.then(() => {
|
||||
correctNumberedListsOrderToPrev(doc, model);
|
||||
if (next) {
|
||||
correctNumberedListsOrderToPrev(doc, next);
|
||||
}
|
||||
})
|
||||
.catch(console.error);
|
||||
}
|
||||
});
|
||||
return false;
|
||||
},
|
||||
});
|
||||
|
||||
@@ -9,7 +9,7 @@ import { literal } from 'lit/static-html.js';
|
||||
import { ListBlockAdapterExtensions } from './adapters/extension.js';
|
||||
import { commands } from './commands/index.js';
|
||||
import { ListKeymapExtension, ListTextKeymapExtension } from './list-keymap.js';
|
||||
import { ListBlockService, ListDragHandleOption } from './list-service.js';
|
||||
import { ListBlockService } from './list-service.js';
|
||||
|
||||
export const ListBlockSpec: ExtensionType[] = [
|
||||
FlavourExtension('affine:list'),
|
||||
@@ -18,6 +18,5 @@ export const ListBlockSpec: ExtensionType[] = [
|
||||
BlockViewExtension('affine:list', literal`affine-list`),
|
||||
ListKeymapExtension,
|
||||
ListTextKeymapExtension,
|
||||
ListDragHandleOption,
|
||||
ListBlockAdapterExtensions,
|
||||
].flat();
|
||||
|
||||
Reference in New Issue
Block a user