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
chore(mobile): disable some toolbar widgets for mobile (#8742)
L-Sun1284f33a4b9d
diff --git a/packages/frontend/core/src/components/blocksuite/block-suite-editor/lit-adaper.tsx b/packages/frontend/core/src/components/blocksuite/block-suite-editor/lit-adaper.tsxindex 52c903b3a6..3def42d10f 100644--- a/packages/frontend/core/src/components/blocksuite/block-suite-editor/lit-adaper.tsx+++ b/packages/frontend/core/src/components/blocksuite/block-suite-editor/lit-adaper.tsx@@ -54,6 +54,7 @@ import {patchDocModeService,patchEdgelessClipboard,patchEmbedLinkedDocBlockConfig,+ patchForMobile,patchForSharedPage,patchNotificationService,patchParseDocUrlExtension,@@ -150,6 +151,9 @@ const usePatchSpecs = (shared: boolean, mode: DocMode) => {if (shared) {patched = patched.concat(patchForSharedPage());}+ if (BUILD_CONFIG.isMobileEdition) {+ patched = patched.concat(patchForMobile());+ }patched = patched.concat(patchDocModeService(docService, docsService, editorService));diff --git a/packages/frontend/core/src/components/blocksuite/block-suite-editor/specs/custom/root-block.ts b/packages/frontend/core/src/components/blocksuite/block-suite-editor/specs/custom/root-block.tsindex c23b6e13ab..5bc15753c1 100644--- a/packages/frontend/core/src/components/blocksuite/block-suite-editor/specs/custom/root-block.ts+++ b/packages/frontend/core/src/components/blocksuite/block-suite-editor/specs/custom/root-block.ts@@ -42,7 +42,6 @@ import { combineLatest, map } from 'rxjs';import { getFontConfigExtension } from '../font-extension';import { createDatabaseOptionsConfig } from './database-block';-import { createKeyboardToolbarConfig } from './widgets/keyboard-toolbar';import { createLinkedWidgetConfig } from './widgets/linked';import { createToolbarMoreMenuConfig } from './widgets/toolbar';@@ -150,7 +149,6 @@ function getEditorConfigExtension(linkedWidget: createLinkedWidgetConfig(framework),toolbarMoreMenu: createToolbarMoreMenuConfig(framework),databaseOptions: createDatabaseOptionsConfig(framework),- keyboardToolbar: createKeyboardToolbarConfig(),} satisfies RootBlockConfig),];}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.tsxindex 199dd1414b..7bfe35ca90 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@@ -26,8 +26,11 @@ import { track } from '@affine/track';import {type BlockService,BlockViewIdentifier,+ ConfigIdentifier,type ExtensionType,type WidgetComponent,+ WidgetViewMapIdentifier,+ type WidgetViewMapType,} from '@blocksuite/affine/block-std';import { BlockServiceWatcher } from '@blocksuite/affine/block-std';import type {@@ -37,15 +40,19 @@ import type {PeekOptions,PeekViewService as BSPeekViewService,QuickSearchResult,+ RootBlockConfig,RootService,} from '@blocksuite/affine/blocks';import {+ AFFINE_EMBED_CARD_TOOLBAR_WIDGET,+ AFFINE_FORMAT_BAR_WIDGET,AffineSlashMenuWidget,DocModeExtension,EdgelessRootBlockComponent,EmbedLinkedDocBlockComponent,EmbedLinkedDocBlockConfigExtension,NotificationExtension,+ pageRootWidgetViewMap,ParseDocUrlExtension,PeekViewExtension,QuickSearchExtension,@@ -65,6 +72,8 @@ import { customElement } from 'lit/decorators.js';import { literal } from 'lit/static-html.js';import { pick } from 'lodash-es';+import { createKeyboardToolbarConfig } from './widgets/keyboard-toolbar';+export type ReferenceReactRenderer = (reference: AffineReference) => React.ReactElement;@@ -541,3 +550,60 @@ export function patchForSharedPage() {};return extension;}++export function patchForMobile() {+ const extension: ExtensionType = {+ setup: di => {+ // page configs+ {+ const pageConfigIdentifier = ConfigIdentifier('affine:page');+ const prev = di.getFactory(ConfigIdentifier);++ di.override(pageConfigIdentifier, provider => {+ return {+ ...prev?.(provider),+ keyboardToolbar: createKeyboardToolbarConfig(),+ } satisfies RootBlockConfig;+ });+ }++ // Disable some toolbar widgets for mobile.+ {+ di.override(WidgetViewMapIdentifier('affine:page'), () => {+ const ignoreWidgets = [+ 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.includes(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;+}