Skip to content

Commit

Permalink
refactor: move doc page block slots to service (toeverything#6196)
Browse files Browse the repository at this point in the history
  • Loading branch information
donteatfriedrice authored Feb 5, 2024
1 parent f844711 commit 6b04654
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 18 deletions.
23 changes: 6 additions & 17 deletions packages/blocks/src/page-block/doc/doc-page-block.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { PathFinder, type PointerEventState } from '@blocksuite/block-std';
import { assertExists, Slot } from '@blocksuite/global/utils';
import { assertExists } from '@blocksuite/global/utils';
import { BlockElement } from '@blocksuite/lit';
import type { Text } from '@blocksuite/store';
import { css, html } from 'lit';
import { customElement, query } from 'lit/decorators.js';
import { repeat } from 'lit/directives/repeat.js';

import type { EditingState, Viewport } from '../../_common/utils/index.js';
import type { Viewport } from '../../_common/utils/index.js';
import {
asyncFocusRichText,
getDocTitleInlineEditor,
Expand Down Expand Up @@ -98,23 +98,12 @@ export class DocPageBlockComponent extends BlockElement<
@query('.affine-doc-page-block-container')
pageBlockContainer!: HTMLDivElement;

slots = {
draggingAreaUpdated: new Slot<DOMRect | null>(),
selectedRectsUpdated: new Slot<DOMRect[]>(),
embedRectsUpdated: new Slot<DOMRect[]>(),
embedEditingStateUpdated: new Slot<EditingState | null>(),
pageLinkClicked: new Slot<{
pageId: string;
blockId?: string;
}>(),
tagClicked: new Slot<{
tagId: string;
}>(),
viewportUpdated: new Slot<Viewport>(),
};

private _viewportElement: HTMLDivElement | null = null;

get slots() {
return this.service.slots;
}

get viewportElement(): HTMLDivElement {
if (this._viewportElement) return this._viewportElement;
this._viewportElement = this.host.closest(
Expand Down
16 changes: 15 additions & 1 deletion packages/blocks/src/page-block/doc/doc-page-service.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
import { Slot } from '@blocksuite/store';

import type { Viewport } from '../../_common/utils/index.js';
import { PageService } from '../page-service.js';

export class DocPageService extends PageService {}
export class DocPageService extends PageService {
slots = {
pageLinkClicked: new Slot<{
pageId: string;
blockId?: string;
}>(),
tagClicked: new Slot<{
tagId: string;
}>(),
viewportUpdated: new Slot<Viewport>(),
};
}

0 comments on commit 6b04654

Please sign in to comment.