mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-26 10:45:57 +08:00
chore(mobile): disable some toolbar widgets for mobile (#8742)
This PR disable some toolbar widgets on mobile. Close [BS-1730](https://linear.app/affine-design/issue/BS-1730/%E7%A6%81%E7%94%A8-block-yuan%E7%B4%A0%E7%9A%84-toolbar)
This commit is contained in:
@@ -54,6 +54,7 @@ import {
|
|||||||
patchDocModeService,
|
patchDocModeService,
|
||||||
patchEdgelessClipboard,
|
patchEdgelessClipboard,
|
||||||
patchEmbedLinkedDocBlockConfig,
|
patchEmbedLinkedDocBlockConfig,
|
||||||
|
patchForMobile,
|
||||||
patchForSharedPage,
|
patchForSharedPage,
|
||||||
patchNotificationService,
|
patchNotificationService,
|
||||||
patchParseDocUrlExtension,
|
patchParseDocUrlExtension,
|
||||||
@@ -150,6 +151,9 @@ const usePatchSpecs = (shared: boolean, mode: DocMode) => {
|
|||||||
if (shared) {
|
if (shared) {
|
||||||
patched = patched.concat(patchForSharedPage());
|
patched = patched.concat(patchForSharedPage());
|
||||||
}
|
}
|
||||||
|
if (BUILD_CONFIG.isMobileEdition) {
|
||||||
|
patched = patched.concat(patchForMobile());
|
||||||
|
}
|
||||||
patched = patched.concat(
|
patched = patched.concat(
|
||||||
patchDocModeService(docService, docsService, editorService)
|
patchDocModeService(docService, docsService, editorService)
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -42,7 +42,6 @@ import { combineLatest, map } from 'rxjs';
|
|||||||
|
|
||||||
import { getFontConfigExtension } from '../font-extension';
|
import { getFontConfigExtension } from '../font-extension';
|
||||||
import { createDatabaseOptionsConfig } from './database-block';
|
import { createDatabaseOptionsConfig } from './database-block';
|
||||||
import { createKeyboardToolbarConfig } from './widgets/keyboard-toolbar';
|
|
||||||
import { createLinkedWidgetConfig } from './widgets/linked';
|
import { createLinkedWidgetConfig } from './widgets/linked';
|
||||||
import { createToolbarMoreMenuConfig } from './widgets/toolbar';
|
import { createToolbarMoreMenuConfig } from './widgets/toolbar';
|
||||||
|
|
||||||
@@ -150,7 +149,6 @@ function getEditorConfigExtension(
|
|||||||
linkedWidget: createLinkedWidgetConfig(framework),
|
linkedWidget: createLinkedWidgetConfig(framework),
|
||||||
toolbarMoreMenu: createToolbarMoreMenuConfig(framework),
|
toolbarMoreMenu: createToolbarMoreMenuConfig(framework),
|
||||||
databaseOptions: createDatabaseOptionsConfig(framework),
|
databaseOptions: createDatabaseOptionsConfig(framework),
|
||||||
keyboardToolbar: createKeyboardToolbarConfig(),
|
|
||||||
} satisfies RootBlockConfig),
|
} satisfies RootBlockConfig),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,8 +26,11 @@ import { track } from '@affine/track';
|
|||||||
import {
|
import {
|
||||||
type BlockService,
|
type BlockService,
|
||||||
BlockViewIdentifier,
|
BlockViewIdentifier,
|
||||||
|
ConfigIdentifier,
|
||||||
type ExtensionType,
|
type ExtensionType,
|
||||||
type WidgetComponent,
|
type WidgetComponent,
|
||||||
|
WidgetViewMapIdentifier,
|
||||||
|
type WidgetViewMapType,
|
||||||
} from '@blocksuite/affine/block-std';
|
} from '@blocksuite/affine/block-std';
|
||||||
import { BlockServiceWatcher } from '@blocksuite/affine/block-std';
|
import { BlockServiceWatcher } from '@blocksuite/affine/block-std';
|
||||||
import type {
|
import type {
|
||||||
@@ -37,15 +40,19 @@ import type {
|
|||||||
PeekOptions,
|
PeekOptions,
|
||||||
PeekViewService as BSPeekViewService,
|
PeekViewService as BSPeekViewService,
|
||||||
QuickSearchResult,
|
QuickSearchResult,
|
||||||
|
RootBlockConfig,
|
||||||
RootService,
|
RootService,
|
||||||
} from '@blocksuite/affine/blocks';
|
} from '@blocksuite/affine/blocks';
|
||||||
import {
|
import {
|
||||||
|
AFFINE_EMBED_CARD_TOOLBAR_WIDGET,
|
||||||
|
AFFINE_FORMAT_BAR_WIDGET,
|
||||||
AffineSlashMenuWidget,
|
AffineSlashMenuWidget,
|
||||||
DocModeExtension,
|
DocModeExtension,
|
||||||
EdgelessRootBlockComponent,
|
EdgelessRootBlockComponent,
|
||||||
EmbedLinkedDocBlockComponent,
|
EmbedLinkedDocBlockComponent,
|
||||||
EmbedLinkedDocBlockConfigExtension,
|
EmbedLinkedDocBlockConfigExtension,
|
||||||
NotificationExtension,
|
NotificationExtension,
|
||||||
|
pageRootWidgetViewMap,
|
||||||
ParseDocUrlExtension,
|
ParseDocUrlExtension,
|
||||||
PeekViewExtension,
|
PeekViewExtension,
|
||||||
QuickSearchExtension,
|
QuickSearchExtension,
|
||||||
@@ -65,6 +72,8 @@ import { customElement } from 'lit/decorators.js';
|
|||||||
import { literal } from 'lit/static-html.js';
|
import { literal } from 'lit/static-html.js';
|
||||||
import { pick } from 'lodash-es';
|
import { pick } from 'lodash-es';
|
||||||
|
|
||||||
|
import { createKeyboardToolbarConfig } from './widgets/keyboard-toolbar';
|
||||||
|
|
||||||
export type ReferenceReactRenderer = (
|
export type ReferenceReactRenderer = (
|
||||||
reference: AffineReference
|
reference: AffineReference
|
||||||
) => React.ReactElement;
|
) => React.ReactElement;
|
||||||
@@ -541,3 +550,60 @@ export function patchForSharedPage() {
|
|||||||
};
|
};
|
||||||
return extension;
|
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;
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user