mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-25 22:38:56 +08:00
refactor(mobile): use bs mobile spec patch (#9046)
Close [BS-2068](https://linear.app/affine-design/issue/BS-2068/移动端-placeholder,去除-space-with-ai)
This commit is contained in:
+8
-62
@@ -29,8 +29,6 @@ import {
|
|||||||
ConfigIdentifier,
|
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 {
|
||||||
@@ -40,25 +38,21 @@ import type {
|
|||||||
PeekOptions,
|
PeekOptions,
|
||||||
PeekViewService as BSPeekViewService,
|
PeekViewService as BSPeekViewService,
|
||||||
QuickSearchResult,
|
QuickSearchResult,
|
||||||
ReferenceNodeConfig,
|
|
||||||
RootBlockConfig,
|
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,
|
||||||
|
MobileSpecsPatches,
|
||||||
NotificationExtension,
|
NotificationExtension,
|
||||||
pageRootWidgetViewMap,
|
|
||||||
ParseDocUrlExtension,
|
ParseDocUrlExtension,
|
||||||
PeekViewExtension,
|
PeekViewExtension,
|
||||||
QuickSearchExtension,
|
QuickSearchExtension,
|
||||||
ReferenceNodeConfigExtension,
|
ReferenceNodeConfigExtension,
|
||||||
ReferenceNodeConfigIdentifier,
|
|
||||||
} from '@blocksuite/affine/blocks';
|
} from '@blocksuite/affine/blocks';
|
||||||
import { type BlockSnapshot, Text } from '@blocksuite/affine/store';
|
import { type BlockSnapshot, Text } from '@blocksuite/affine/store';
|
||||||
import {
|
import {
|
||||||
@@ -555,10 +549,9 @@ export function patchForSharedPage() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function patchForMobile() {
|
export function patchForMobile() {
|
||||||
const extension: ExtensionType = {
|
const extensions: ExtensionType[] = [
|
||||||
setup: di => {
|
{
|
||||||
// page configs
|
setup: di => {
|
||||||
{
|
|
||||||
const pageConfigIdentifier = ConfigIdentifier('affine:page');
|
const pageConfigIdentifier = ConfigIdentifier('affine:page');
|
||||||
const prev = di.getFactory(pageConfigIdentifier);
|
const prev = di.getFactory(pageConfigIdentifier);
|
||||||
|
|
||||||
@@ -568,56 +561,9 @@ export function patchForMobile() {
|
|||||||
keyboardToolbar: createKeyboardToolbarConfig(),
|
keyboardToolbar: createKeyboardToolbarConfig(),
|
||||||
} satisfies RootBlockConfig;
|
} 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 => ({})
|
|
||||||
);
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
};
|
MobileSpecsPatches,
|
||||||
return extension;
|
];
|
||||||
|
return extensions;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user