mirror of
https://github.com/toeverything/AFFiNE.git
synced 2024-12-22 18:11:32 +03: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:
parent
39c65051ac
commit
1284f33a4b
@ -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)
|
||||
);
|
||||
|
@ -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),
|
||||
];
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user