mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-19 02:56:23 +08:00
chore(editor): remove unused inner modal widget (#11552)
This commit is contained in:
@@ -43,12 +43,7 @@ import { RootBlockAdapterExtensions } from '../adapters/extension';
|
||||
import { clipboardConfigs } from '../clipboard';
|
||||
import { builtinToolbarConfig } from '../configs/toolbar';
|
||||
import { fallbackKeymap } from '../keyboard/keymap';
|
||||
import {
|
||||
innerModalWidget,
|
||||
linkedDocWidget,
|
||||
modalWidget,
|
||||
viewportOverlayWidget,
|
||||
} from './widgets';
|
||||
import { linkedDocWidget, modalWidget, viewportOverlayWidget } from './widgets';
|
||||
|
||||
/**
|
||||
* Why do we add these extensions into CommonSpecs?
|
||||
@@ -87,7 +82,6 @@ export const CommonSpecs: ExtensionType[] = [
|
||||
...EdgelessElementViews,
|
||||
...EdgelessElementRendererExtension,
|
||||
modalWidget,
|
||||
innerModalWidget,
|
||||
SlashMenuExtension,
|
||||
linkedDocWidget,
|
||||
dragHandleWidget,
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import { WidgetViewExtension } from '@blocksuite/std';
|
||||
import { literal, unsafeStatic } from 'lit/static-html.js';
|
||||
|
||||
import { AFFINE_INNER_MODAL_WIDGET } from '../widgets/inner-modal/inner-modal.js';
|
||||
import { AFFINE_LINKED_DOC_WIDGET } from '../widgets/linked-doc/config.js';
|
||||
import { AFFINE_MODAL_WIDGET } from '../widgets/modal/modal.js';
|
||||
import { AFFINE_VIEWPORT_OVERLAY_WIDGET } from '../widgets/viewport-overlay/viewport-overlay.js';
|
||||
@@ -11,11 +10,6 @@ export const modalWidget = WidgetViewExtension(
|
||||
AFFINE_MODAL_WIDGET,
|
||||
literal`${unsafeStatic(AFFINE_MODAL_WIDGET)}`
|
||||
);
|
||||
export const innerModalWidget = WidgetViewExtension(
|
||||
'affine:page',
|
||||
AFFINE_INNER_MODAL_WIDGET,
|
||||
literal`${unsafeStatic(AFFINE_INNER_MODAL_WIDGET)}`
|
||||
);
|
||||
export const linkedDocWidget = WidgetViewExtension(
|
||||
'affine:page',
|
||||
AFFINE_LINKED_DOC_WIDGET,
|
||||
|
||||
@@ -43,10 +43,6 @@ import {
|
||||
} from './widgets/edgeless-zoom-toolbar/index.js';
|
||||
import { ZoomBarToggleButton } from './widgets/edgeless-zoom-toolbar/zoom-bar-toggle-button.js';
|
||||
import { EdgelessZoomToolbar } from './widgets/edgeless-zoom-toolbar/zoom-toolbar.js';
|
||||
import {
|
||||
AFFINE_INNER_MODAL_WIDGET,
|
||||
AffineInnerModalWidget,
|
||||
} from './widgets/inner-modal/inner-modal.js';
|
||||
import { effects as widgetMobileToolbarEffects } from './widgets/keyboard-toolbar/effects.js';
|
||||
import { effects as widgetLinkedDocEffects } from './widgets/linked-doc/effects.js';
|
||||
import { Loader } from './widgets/linked-doc/import-doc/loader.js';
|
||||
@@ -97,7 +93,6 @@ function registerGfxEffects() {
|
||||
}
|
||||
|
||||
function registerWidgets() {
|
||||
customElements.define(AFFINE_INNER_MODAL_WIDGET, AffineInnerModalWidget);
|
||||
customElements.define(AFFINE_MODAL_WIDGET, AffineModalWidget);
|
||||
customElements.define(
|
||||
AFFINE_PAGE_DRAGGING_AREA_WIDGET,
|
||||
@@ -185,6 +180,5 @@ declare global {
|
||||
'edgeless-zoom-toolbar': EdgelessZoomToolbar;
|
||||
|
||||
[AFFINE_EDGELESS_ZOOM_TOOLBAR_WIDGET]: AffineEdgelessZoomToolbarWidget;
|
||||
[AFFINE_INNER_MODAL_WIDGET]: AffineInnerModalWidget;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,7 +10,6 @@ import type { EdgelessRootBlockComponent } from './edgeless/edgeless-root-block.
|
||||
import type { PageRootBlockComponent } from './page/page-root-block.js';
|
||||
import type { AFFINE_EDGELESS_ZOOM_TOOLBAR_WIDGET } from './widgets/edgeless-zoom-toolbar/index.js';
|
||||
import type { AFFINE_KEYBOARD_TOOLBAR_WIDGET } from './widgets/index.js';
|
||||
import type { AFFINE_INNER_MODAL_WIDGET } from './widgets/inner-modal/inner-modal.js';
|
||||
import type { AFFINE_LINKED_DOC_WIDGET } from './widgets/linked-doc/config.js';
|
||||
import type { AFFINE_MODAL_WIDGET } from './widgets/modal/modal.js';
|
||||
import type { AFFINE_PAGE_DRAGGING_AREA_WIDGET } from './widgets/page-dragging-area/page-dragging-area.js';
|
||||
@@ -19,7 +18,6 @@ import type { AFFINE_VIEWPORT_OVERLAY_WIDGET } from './widgets/viewport-overlay/
|
||||
export type PageRootBlockWidgetName =
|
||||
| typeof AFFINE_KEYBOARD_TOOLBAR_WIDGET
|
||||
| typeof AFFINE_MODAL_WIDGET
|
||||
| typeof AFFINE_INNER_MODAL_WIDGET
|
||||
| typeof AFFINE_SLASH_MENU_WIDGET
|
||||
| typeof AFFINE_LINKED_DOC_WIDGET
|
||||
| typeof AFFINE_PAGE_DRAGGING_AREA_WIDGET
|
||||
@@ -29,7 +27,6 @@ export type PageRootBlockWidgetName =
|
||||
|
||||
export type EdgelessRootBlockWidgetName =
|
||||
| typeof AFFINE_MODAL_WIDGET
|
||||
| typeof AFFINE_INNER_MODAL_WIDGET
|
||||
| typeof AFFINE_SLASH_MENU_WIDGET
|
||||
| typeof AFFINE_LINKED_DOC_WIDGET
|
||||
| typeof AFFINE_DRAG_HANDLE_WIDGET
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
export { AffineEdgelessZoomToolbarWidget } from './edgeless-zoom-toolbar/index.js';
|
||||
export { AffineInnerModalWidget } from './inner-modal/inner-modal.js';
|
||||
export * from './keyboard-toolbar/index.js';
|
||||
export {
|
||||
type LinkedMenuAction,
|
||||
|
||||
@@ -1,58 +0,0 @@
|
||||
import { WidgetComponent } from '@blocksuite/std';
|
||||
import {
|
||||
autoUpdate,
|
||||
computePosition,
|
||||
type FloatingElement,
|
||||
type ReferenceElement,
|
||||
size,
|
||||
} from '@floating-ui/dom';
|
||||
import { nothing } from 'lit';
|
||||
|
||||
export const AFFINE_INNER_MODAL_WIDGET = 'affine-inner-modal-widget';
|
||||
|
||||
export class AffineInnerModalWidget extends WidgetComponent {
|
||||
private _getTarget?: () => ReferenceElement;
|
||||
|
||||
get target(): ReferenceElement {
|
||||
if (this._getTarget) {
|
||||
return this._getTarget();
|
||||
}
|
||||
return document.body;
|
||||
}
|
||||
|
||||
open(
|
||||
modal: FloatingElement,
|
||||
ops: { onClose?: () => void }
|
||||
): { close(): void } {
|
||||
const cancel = autoUpdate(this.target, modal, () => {
|
||||
computePosition(this.target, modal, {
|
||||
middleware: [
|
||||
size({
|
||||
apply: ({ rects }) => {
|
||||
Object.assign(modal.style, {
|
||||
left: `${rects.reference.x}px`,
|
||||
top: `${rects.reference.y}px`,
|
||||
width: `${rects.reference.width}px`,
|
||||
height: `${rects.reference.height}px`,
|
||||
});
|
||||
},
|
||||
}),
|
||||
],
|
||||
}).catch(console.error);
|
||||
});
|
||||
const close = () => {
|
||||
modal.remove();
|
||||
ops.onClose?.();
|
||||
cancel();
|
||||
};
|
||||
return { close };
|
||||
}
|
||||
|
||||
override render() {
|
||||
return nothing;
|
||||
}
|
||||
|
||||
setTarget(fn: () => ReferenceElement) {
|
||||
this._getTarget = fn;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user