From b1c8fca25ea887332f9eb96e8d21cc970bc0d27a Mon Sep 17 00:00:00 2001 From: L-Sun Date: Fri, 6 Dec 2024 09:07:19 +0000 Subject: [PATCH] refactor(mobile): use bs mobile spec patch (#9046) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Close [BS-2068](https://linear.app/affine-design/issue/BS-2068/移动端-placeholder,去除-space-with-ai) --- .../specs/custom/spec-patchers.tsx | 70 +++---------------- 1 file changed, 8 insertions(+), 62 deletions(-) diff --git a/packages/frontend/core/src/components/blocksuite/block-suite-editor/specs/custom/spec-patchers.tsx b/packages/frontend/core/src/components/blocksuite/block-suite-editor/specs/custom/spec-patchers.tsx index 10dac44335..d34022db3d 100644 --- a/packages/frontend/core/src/components/blocksuite/block-suite-editor/specs/custom/spec-patchers.tsx +++ b/packages/frontend/core/src/components/blocksuite/block-suite-editor/specs/custom/spec-patchers.tsx @@ -29,8 +29,6 @@ import { ConfigIdentifier, type ExtensionType, type WidgetComponent, - WidgetViewMapIdentifier, - type WidgetViewMapType, } from '@blocksuite/affine/block-std'; import { BlockServiceWatcher } from '@blocksuite/affine/block-std'; import type { @@ -40,25 +38,21 @@ import type { PeekOptions, PeekViewService as BSPeekViewService, QuickSearchResult, - ReferenceNodeConfig, RootBlockConfig, RootService, } from '@blocksuite/affine/blocks'; import { - AFFINE_EMBED_CARD_TOOLBAR_WIDGET, - AFFINE_FORMAT_BAR_WIDGET, AffineSlashMenuWidget, DocModeExtension, EdgelessRootBlockComponent, EmbedLinkedDocBlockComponent, EmbedLinkedDocBlockConfigExtension, + MobileSpecsPatches, NotificationExtension, - pageRootWidgetViewMap, ParseDocUrlExtension, PeekViewExtension, QuickSearchExtension, ReferenceNodeConfigExtension, - ReferenceNodeConfigIdentifier, } from '@blocksuite/affine/blocks'; import { type BlockSnapshot, Text } from '@blocksuite/affine/store'; import { @@ -555,10 +549,9 @@ export function patchForSharedPage() { } export function patchForMobile() { - const extension: ExtensionType = { - setup: di => { - // page configs - { + const extensions: ExtensionType[] = [ + { + setup: di => { const pageConfigIdentifier = ConfigIdentifier('affine:page'); const prev = di.getFactory(pageConfigIdentifier); @@ -568,56 +561,9 @@ export function patchForMobile() { keyboardToolbar: createKeyboardToolbarConfig(), } satisfies RootBlockConfig; }); - } - - // Hide reference popup on mobile. - { - const prev = di.getFactory(ReferenceNodeConfigIdentifier); - di.override(ReferenceNodeConfigIdentifier, provider => { - return { - ...prev?.(provider), - hidePopup: true, - } satisfies ReferenceNodeConfig; - }); - } - - // Disable some toolbar widgets for mobile. - { - di.override(WidgetViewMapIdentifier('affine:page'), () => { - const ignoreWidgets = new Set([ - AFFINE_FORMAT_BAR_WIDGET, - AFFINE_EMBED_CARD_TOOLBAR_WIDGET, - ]); - - type pageRootWidgetViewMapKey = keyof typeof pageRootWidgetViewMap; - return ( - Object.keys(pageRootWidgetViewMap) as pageRootWidgetViewMapKey[] - ).reduce( - (acc, key) => { - if (ignoreWidgets.has(key)) return acc; - acc[key] = pageRootWidgetViewMap[key]; - return acc; - }, - {} as typeof pageRootWidgetViewMap - ); - }); - - di.override( - WidgetViewMapIdentifier('affine:code'), - (): WidgetViewMapType => ({}) - ); - - di.override( - WidgetViewMapIdentifier('affine:image'), - (): WidgetViewMapType => ({}) - ); - - di.override( - WidgetViewMapIdentifier('affine:surface-ref'), - (): WidgetViewMapType => ({}) - ); - } + }, }, - }; - return extension; + MobileSpecsPatches, + ]; + return extensions; }