mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-14 13:25:12 +00:00
refactor(editor): cleanup dead code (#9294)
This commit is contained in:
@@ -1,8 +1,5 @@
|
||||
import type {
|
||||
DragHandleOption,
|
||||
DropType,
|
||||
} from '@blocksuite/affine-shared/services';
|
||||
import type { Disposable, Rect } from '@blocksuite/global/utils';
|
||||
import type { DropType } from '@blocksuite/affine-shared/services';
|
||||
import type { Rect } from '@blocksuite/global/utils';
|
||||
|
||||
export const DRAG_HANDLE_CONTAINER_HEIGHT = 24;
|
||||
export const DRAG_HANDLE_CONTAINER_WIDTH = 16;
|
||||
@@ -29,51 +26,3 @@ export type DropResult = {
|
||||
dropBlockId: string;
|
||||
dropType: DropType;
|
||||
};
|
||||
|
||||
export class DragHandleOptionsRunner {
|
||||
private readonly optionMap = new Map<DragHandleOption, number>();
|
||||
|
||||
get options(): DragHandleOption[] {
|
||||
return Array.from(this.optionMap.keys());
|
||||
}
|
||||
|
||||
private _decreaseOptionCount(option: DragHandleOption) {
|
||||
const count = this.optionMap.get(option) || 0;
|
||||
if (count > 1) {
|
||||
this.optionMap.set(option, count - 1);
|
||||
} else {
|
||||
this.optionMap.delete(option);
|
||||
}
|
||||
}
|
||||
|
||||
private _getExistingOptionWithSameFlavour(
|
||||
option: DragHandleOption
|
||||
): DragHandleOption | undefined {
|
||||
return Array.from(this.optionMap.keys()).find(
|
||||
op => op.flavour === option.flavour
|
||||
);
|
||||
}
|
||||
|
||||
getOption(flavour: string): DragHandleOption | undefined {
|
||||
return this.options.find(option => {
|
||||
if (typeof option.flavour === 'string') {
|
||||
return option.flavour === flavour;
|
||||
} else {
|
||||
return option.flavour.test(flavour);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
register(option: DragHandleOption): Disposable {
|
||||
const currentOption =
|
||||
this._getExistingOptionWithSameFlavour(option) || option;
|
||||
const count = this.optionMap.get(currentOption) || 0;
|
||||
this.optionMap.set(currentOption, count + 1);
|
||||
|
||||
return {
|
||||
dispose: () => {
|
||||
this._decreaseOptionCount(currentOption);
|
||||
},
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,7 +28,6 @@ import type { EdgelessRootService } from '../../edgeless/index.js';
|
||||
import type { DragPreview } from './components/drag-preview.js';
|
||||
import type { DropIndicator } from './components/drop-indicator.js';
|
||||
import type { DropResult } from './config.js';
|
||||
import { DragHandleOptionsRunner } from './config.js';
|
||||
import type { AFFINE_DRAG_HANDLE_WIDGET } from './consts.js';
|
||||
import { PreviewHelper } from './helpers/preview-helper.js';
|
||||
import { RectHelper } from './helpers/rect-helper.js';
|
||||
@@ -289,8 +288,6 @@ export class AffineDragHandleWidget extends WidgetComponent<RootBlockModel> {
|
||||
|
||||
noteScale = signal(1);
|
||||
|
||||
readonly optionRunner = new DragHandleOptionsRunner();
|
||||
|
||||
pointerEventWatcher = new PointerEventWatcher(this);
|
||||
|
||||
previewHelper = new PreviewHelper(this);
|
||||
|
||||
Reference in New Issue
Block a user