There can be more than Notion and Miro. AFFiNE(pronounced [ə‘fain]) is a next-gen knowledge base that brings planning, sorting and creating all together. Privacy first, open-source, customizable and ready to use.
TypeScript appcrdteditorelectronknowledge-basemarkdownmironotesnotionnotion-alternativerustrust-langrust-languagetabletableviewwhiteboardwikiworkspace
refactor(editor): cleanup dead code (#9300)
Saul-Mirone7c845456472d
diff --git a/blocksuite/affine/block-list/src/effects.ts b/blocksuite/affine/block-list/src/effects.tsindex bff302c6dc..791fc336e5 100644--- a/blocksuite/affine/block-list/src/effects.ts+++ b/blocksuite/affine/block-list/src/effects.ts@@ -12,7 +12,6 @@ import type {import type { listToParagraphCommand } from './commands/list-to-paragraph.js';import type { splitListCommand } from './commands/split-list.js';import { ListBlockComponent } from './list-block.js';-import type { ListBlockService } from './list-service.js';export function effects() {customElements.define('affine-list', ListBlockComponent);@@ -20,10 +19,6 @@ export function effects() {declare global {namespace BlockSuite {- interface BlockServices {- 'affine:list': ListBlockService;- }-interface CommandContext {listConvertedId?: string;indentContext?: IndentContext;diff --git a/blocksuite/affine/block-list/src/index.ts b/blocksuite/affine/block-list/src/index.tsindex 76178a16ea..f8f82f1d5f 100644--- a/blocksuite/affine/block-list/src/index.ts+++ b/blocksuite/affine/block-list/src/index.ts@@ -1,5 +1,4 @@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';diff --git a/blocksuite/affine/block-list/src/list-block.ts b/blocksuite/affine/block-list/src/list-block.tsindex 22a076468b..a454c3a3d8 100644--- a/blocksuite/affine/block-list/src/list-block.ts+++ b/blocksuite/affine/block-list/src/list-block.ts@@ -24,14 +24,10 @@ import { classMap } from 'lit/directives/class-map.js';import { styleMap } from 'lit/directives/style-map.js';import { correctNumberedListsOrderToPrev } from './commands/utils.js';-import type { ListBlockService } from './list-service.js';import { listBlockStyles } from './styles.js';import { getListIcon } from './utils/get-list-icon.js';-export class ListBlockComponent extends CaptionedBlockComponent<- ListBlockModel,- ListBlockService-> {+export class ListBlockComponent extends CaptionedBlockComponent<ListBlockModel> {static override styles = listBlockStyles;private _inlineRangeProvider: InlineRangeProvider | null = null;diff --git a/blocksuite/affine/block-list/src/list-service.ts b/blocksuite/affine/block-list/src/list-service.tsdeleted file mode 100644index 28895d59f8..0000000000--- a/blocksuite/affine/block-list/src/list-service.ts+++ /dev/null@@ -1,6 +0,0 @@-import { ListBlockSchema } from '@blocksuite/affine-model';-import { BlockService } from '@blocksuite/block-std';--export class ListBlockService extends BlockService {- static override readonly flavour = ListBlockSchema.model.flavour;-}diff --git a/blocksuite/affine/block-list/src/list-spec.ts b/blocksuite/affine/block-list/src/list-spec.tsindex 83e59de3e0..7d4fbafdba 100644--- a/blocksuite/affine/block-list/src/list-spec.ts+++ b/blocksuite/affine/block-list/src/list-spec.ts@@ -9,11 +9,9 @@ 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 } from './list-service.js';export const ListBlockSpec: ExtensionType[] = [FlavourExtension('affine:list'),- ListBlockService,CommandExtension(commands),BlockViewExtension('affine:list', literal`affine-list`),ListKeymapExtension,diff --git a/blocksuite/blocks/src/data-view-block/data-view-spec.ts b/blocksuite/blocks/src/data-view-block/data-view-spec.tsindex 342e5f2013..e0a9aceebc 100644--- a/blocksuite/blocks/src/data-view-block/data-view-spec.ts+++ b/blocksuite/blocks/src/data-view-block/data-view-spec.ts@@ -5,10 +5,7 @@ import {} from '@blocksuite/block-std';import { literal } from 'lit/static-html.js';-import { DataViewBlockService } from './database-service.js';-export const DataViewBlockSpec: ExtensionType[] = [FlavourExtension('affine:data-view'),- DataViewBlockService,BlockViewExtension('affine:data-view', literal`affine-data-view`),];diff --git a/blocksuite/blocks/src/data-view-block/database-service.ts b/blocksuite/blocks/src/data-view-block/database-service.tsdeleted file mode 100644index 1c21b4d87e..0000000000--- a/blocksuite/blocks/src/data-view-block/database-service.ts+++ /dev/null@@ -1,13 +0,0 @@-import { BlockService } from '@blocksuite/block-std';-import { DatabaseSelection } from '@blocksuite/data-view';--import { DataViewBlockSchema } from './data-view-model.js';--export class DataViewBlockService extends BlockService {- static override readonly flavour = DataViewBlockSchema.model.flavour;-- override mounted(): void {- super.mounted();- this.selectionManager.register(DatabaseSelection);- }-}diff --git a/blocksuite/blocks/src/effects.ts b/blocksuite/blocks/src/effects.tsindex b35d2f1a31..fb3756e663 100644--- a/blocksuite/blocks/src/effects.ts+++ b/blocksuite/blocks/src/effects.ts@@ -271,7 +271,6 @@ import { effects as blockSurfaceRefEffects } from './surface-ref-block/effects.jimport {EdgelessSurfaceRefBlockComponent,SurfaceRefBlockComponent,- type SurfaceRefBlockService,} from './surface-ref-block/index.js';import { SurfaceRefGenericBlockPortal } from './surface-ref-block/portal/generic-block.js';import { SurfaceRefNotePortal } from './surface-ref-block/portal/note.js';@@ -611,7 +610,6 @@ declare global {'affine:bookmark': BookmarkBlockService;'affine:database': DatabaseBlockService;'affine:image': ImageBlockService;- 'affine:surface-ref': SurfaceRefBlockService;}}}diff --git a/blocksuite/blocks/src/surface-ref-block/index.ts b/blocksuite/blocks/src/surface-ref-block/index.tsindex 8c9e461758..91f9567b93 100644--- a/blocksuite/blocks/src/surface-ref-block/index.ts+++ b/blocksuite/blocks/src/surface-ref-block/index.ts@@ -1,6 +1,5 @@export * from './surface-ref-block.js';export * from './surface-ref-block-edgeless.js';-export * from './surface-ref-service.js';export {EdgelessSurfaceRefBlockSpec,PageSurfaceRefBlockSpec,diff --git a/blocksuite/blocks/src/surface-ref-block/surface-ref-block.ts b/blocksuite/blocks/src/surface-ref-block/surface-ref-block.tsindex 8c6b3cfffd..9da959dcca 100644--- a/blocksuite/blocks/src/surface-ref-block/surface-ref-block.ts+++ b/blocksuite/blocks/src/surface-ref-block/surface-ref-block.ts@@ -1,4 +1,3 @@-/* eslint-disable @typescript-eslint/no-non-null-assertion */import {type SurfaceBlockModel,SurfaceElementModel,@@ -46,7 +45,6 @@ import { styleMap } from 'lit/directives/style-map.js';import { SpecProvider } from '../_specs/index.js';import type { EdgelessRootPreviewBlockComponent } from '../root-block/edgeless/edgeless-root-preview-block.js';import { EdgelessRootService } from '../root-block/index.js';-import type { SurfaceRefBlockService } from './surface-ref-service.js';import { noContentPlaceholder } from './utils.js';const REF_LABEL_ICON = {@@ -66,10 +64,7 @@ const NO_CONTENT_REASON = {} as Record<string, string>;@Peekable()-export class SurfaceRefBlockComponent extends BlockComponent<- SurfaceRefBlockModel,- SurfaceRefBlockService-> {+export class SurfaceRefBlockComponent extends BlockComponent<SurfaceRefBlockModel> {static override styles = css`.affine-surface-ref {position: relative;@@ -599,8 +594,6 @@ export class SurfaceRefBlockComponent extends BlockComponent<if (!this._shouldRender) return;- const service = this.service;- assertExists(service, `Surface ref block must run with its service.`);this._initHotkey();this._initSpec();this._initReferencedModel();diff --git a/blocksuite/blocks/src/surface-ref-block/surface-ref-service.ts b/blocksuite/blocks/src/surface-ref-block/surface-ref-service.tsdeleted file mode 100644index 894f4c2b87..0000000000--- a/blocksuite/blocks/src/surface-ref-block/surface-ref-service.ts+++ /dev/null@@ -1,6 +0,0 @@-import { SurfaceRefBlockSchema } from '@blocksuite/affine-model';-import { BlockService } from '@blocksuite/block-std';--export class SurfaceRefBlockService extends BlockService {- static override readonly flavour = SurfaceRefBlockSchema.model.flavour;-}diff --git a/blocksuite/blocks/src/surface-ref-block/surface-ref-spec.ts b/blocksuite/blocks/src/surface-ref-block/surface-ref-spec.tsindex 80ba7792c6..b0394351d3 100644--- a/blocksuite/blocks/src/surface-ref-block/surface-ref-spec.ts+++ b/blocksuite/blocks/src/surface-ref-block/surface-ref-spec.ts@@ -8,11 +8,9 @@ import {import { literal } from 'lit/static-html.js';import { commands } from './commands.js';-import { SurfaceRefBlockService } from './surface-ref-service.js';export const PageSurfaceRefBlockSpec: ExtensionType[] = [FlavourExtension('affine:surface-ref'),- SurfaceRefBlockService,CommandExtension(commands),BlockViewExtension('affine:surface-ref', literal`affine-surface-ref`),WidgetViewMapExtension('affine:surface-ref', {@@ -22,7 +20,6 @@ export const PageSurfaceRefBlockSpec: ExtensionType[] = [export const EdgelessSurfaceRefBlockSpec: ExtensionType[] = [FlavourExtension('affine:surface-ref'),- SurfaceRefBlockService,BlockViewExtension('affine:surface-ref',literal`affine-edgeless-surface-ref`diff --git a/blocksuite/framework/block-std/src/view/element/widget-component.ts b/blocksuite/framework/block-std/src/view/element/widget-component.tsindex 6e0f1de165..f9b9e77761 100644--- a/blocksuite/framework/block-std/src/view/element/widget-component.ts+++ b/blocksuite/framework/block-std/src/view/element/widget-component.ts@@ -74,7 +74,7 @@ export class WidgetComponent<super.connectedCallback();this.std.view.setWidget(this);- this.service.specSlots.widgetConnected.emit({+ this.service?.specSlots.widgetConnected.emit({service: this.service,component: this,});@@ -83,7 +83,7 @@ export class WidgetComponent<override disconnectedCallback() {super.disconnectedCallback();this.std?.view.deleteWidget(this);- this.service.specSlots.widgetDisconnected.emit({+ this.service?.specSlots.widgetDisconnected.emit({service: this.service,component: this,});diff --git a/blocksuite/playground/apps/default/specs-examples/custom-attachment/custom-attachment.ts b/blocksuite/playground/apps/default/specs-examples/custom-attachment/custom-attachment.tsdeleted file mode 100644index 4e96051aff..0000000000--- a/blocksuite/playground/apps/default/specs-examples/custom-attachment/custom-attachment.ts+++ /dev/null@@ -1,50 +0,0 @@-import {- BlockFlavourIdentifier,- BlockServiceIdentifier,- type ExtensionType,- StdIdentifier,-} from '@blocksuite/block-std';-import {- AttachmentBlockService,- EdgelessEditorBlockSpecs,- PageEditorBlockSpecs,-} from '@blocksuite/blocks';--class CustomAttachmentBlockService extends AttachmentBlockService {- override mounted(): void {- super.mounted();- this.maxFileSize = 100 * 1000 * 1000; // 100MB- }-}--export function getCustomAttachmentSpecs() {- const pageModeSpecs: ExtensionType[] = [- ...PageEditorBlockSpecs,- {- setup: di => {- di.override(- BlockServiceIdentifier('affine:attachment'),- CustomAttachmentBlockService,- [StdIdentifier, BlockFlavourIdentifier('affine:attachment')]- );- },- },- ];- const edgelessModeSpecs: ExtensionType[] = [- ...EdgelessEditorBlockSpecs,- {- setup: di => {- di.override(- BlockServiceIdentifier('affine:attachment'),- CustomAttachmentBlockService,- [StdIdentifier, BlockFlavourIdentifier('affine:attachment')]- );- },- },- ];-- return {- pageModeSpecs,- edgelessModeSpecs,- };-}diff --git a/blocksuite/playground/apps/default/specs-examples/index.ts b/blocksuite/playground/apps/default/specs-examples/index.tsindex d68a3a07f8..c0fe99686d 100644--- a/blocksuite/playground/apps/default/specs-examples/index.ts+++ b/blocksuite/playground/apps/default/specs-examples/index.ts@@ -3,21 +3,9 @@ import {PageEditorBlockSpecs,} from '@blocksuite/blocks';-import { getCustomAttachmentSpecs } from './custom-attachment/custom-attachment.js';--const params = new URLSearchParams(location.search);-export function getExampleSpecs() {- const type = params.get('exampleSpec');-- let pageModeSpecs = PageEditorBlockSpecs;- let edgelessModeSpecs = EdgelessEditorBlockSpecs;-- if (type === 'attachment') {- const specs = getCustomAttachmentSpecs();- pageModeSpecs = specs.pageModeSpecs;- edgelessModeSpecs = specs.edgelessModeSpecs;- }+ const pageModeSpecs = PageEditorBlockSpecs;+ const edgelessModeSpecs = EdgelessEditorBlockSpecs;return {pageModeSpecs,diff --git a/packages/frontend/core/src/components/blocksuite/block-suite-editor/specs/common.ts b/packages/frontend/core/src/components/blocksuite/block-suite-editor/specs/common.tsindex eb35be71e6..4a94175c80 100644--- a/packages/frontend/core/src/components/blocksuite/block-suite-editor/specs/common.ts+++ b/packages/frontend/core/src/components/blocksuite/block-suite-editor/specs/common.ts@@ -7,6 +7,7 @@ import { AIChatBlockSpec } from '@affine/core/blocksuite/presets/blocks/ai-chat-import type { ExtensionType } from '@blocksuite/affine/block-std';import {AdapterFactoryExtensions,+ AttachmentBlockSpec,BookmarkBlockSpec,CodeBlockSpec,DatabaseBlockSpec,@@ -28,8 +29,6 @@ import {RichTextExtensions,} from '@blocksuite/affine/blocks';-import { CustomAttachmentBlockSpec } from './custom/attachment-block';-const CommonBlockSpecs: ExtensionType[] = [RefNodeSlotsExtension(),EditPropsStore,@@ -47,8 +46,8 @@ const CommonBlockSpecs: ExtensionType[] = [EmbedHtmlBlockSpec,EmbedSyncedDocBlockSpec,EmbedLinkedDocBlockSpec,+ AttachmentBlockSpec,// special- CustomAttachmentBlockSpec,AdapterFactoryExtensions,].flat();diff --git a/packages/frontend/core/src/components/blocksuite/block-suite-editor/specs/custom/attachment-block.ts b/packages/frontend/core/src/components/blocksuite/block-suite-editor/specs/custom/attachment-block.tsdeleted file mode 100644index 128cc458b4..0000000000--- a/packages/frontend/core/src/components/blocksuite/block-suite-editor/specs/custom/attachment-block.ts+++ /dev/null@@ -1,50 +0,0 @@-import {- BlockFlavourIdentifier,- BlockServiceIdentifier,- type ExtensionType,- StdIdentifier,-} from '@blocksuite/affine/block-std';-import {- AttachmentBlockService,- AttachmentBlockSpec,- ImageBlockService,-} from '@blocksuite/affine/blocks';--// bytes.parse('2GB')-const MAX_FILE_SIZE = 2147483648;--class CustomAttachmentBlockService extends AttachmentBlockService {- override mounted(): void {- // blocksuite default max file size is 10MB, we override it to 2GB- // but the real place to limit blob size is CloudQuotaModal / LocalQuotaModal- this.maxFileSize = MAX_FILE_SIZE;- super.mounted();- }-}--class CustomImageBlockService extends ImageBlockService {- override mounted(): void {- // blocksuite default max file size is 10MB, we override it to 2GB- // but the real place to limit blob size is CloudQuotaModal / LocalQuotaModal- this.maxFileSize = MAX_FILE_SIZE;- super.mounted();- }-}--export const CustomAttachmentBlockSpec: ExtensionType[] = [- ...AttachmentBlockSpec,- {- setup: di => {- di.override(- BlockServiceIdentifier('affine:attachment'),- CustomAttachmentBlockService,- [StdIdentifier, BlockFlavourIdentifier('affine:attachment')]- );- di.override(- BlockServiceIdentifier('affine:image'),- CustomImageBlockService,- [StdIdentifier, BlockFlavourIdentifier('affine:image')]- );- },- },-];