Skip to content

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.

chore(editor): hide file and doc import entries for mobile (#11648)

L-Sun26d2ed8afb4b
diff --git a/blocksuite/affine/blocks/root/src/widgets/keyboard-toolbar/config.ts b/blocksuite/affine/blocks/root/src/widgets/keyboard-toolbar/config.ts
index 31cc1bbf89..47c656cfec 100644
--- a/blocksuite/affine/blocks/root/src/widgets/keyboard-toolbar/config.ts
+++ b/blocksuite/affine/blocks/root/src/widgets/keyboard-toolbar/config.ts
@@ -428,8 +428,7 @@ const contentMediaToolGroup: KeyboardToolPanelGroup = {
{
name: 'Attachment',
icon: AttachmentIcon(),
- showWhen: ({ std }) =>
- std.store.schema.flavourSchemaMap.has('affine:attachment'),
+ showWhen: () => false,
action: async ({ std }) => {
const [_, { selectedModels }] = std.command.exec(
getSelectedModelsCommand
@@ -1029,8 +1028,7 @@ export const defaultKeyboardToolbarConfig: KeyboardToolbarConfig = {
{
name: 'Attachment',
icon: AttachmentIcon(),
- showWhen: ({ std }) =>
- std.store.schema.flavourSchemaMap.has('affine:attachment'),
+ showWhen: () => false,
action: async ({ std }) => {
const [_, { selectedModels }] = std.command.exec(
getSelectedModelsCommand
diff --git a/blocksuite/affine/widgets/linked-doc/src/config.ts b/blocksuite/affine/widgets/linked-doc/src/config.ts
index 42f04914bb..44d841989f 100644
--- a/blocksuite/affine/widgets/linked-doc/src/config.ts
+++ b/blocksuite/affine/widgets/linked-doc/src/config.ts
@@ -16,6 +16,7 @@ import {
isFuzzyMatch,
type Signal,
} from '@blocksuite/affine-shared/utils';
+import { IS_MOBILE } from '@blocksuite/global/env';
import {
type BlockStdScope,
ConfigExtensionFactory,
@@ -175,73 +176,77 @@ export function createNewDocMenuGroup(
docName.slice(0, DISPLAY_NAME_LENGTH) +
(docName.length > DISPLAY_NAME_LENGTH ? '..' : '');
- return {
- name: 'New Doc',
- items: [
- {
- key: 'create',
- name: `Create "${displayDocName}" doc`,
- icon: NewDocIcon,
- action: () => {
- abort();
- const docName = query;
- const newDoc = createDefaultDoc(doc.workspace, {
- title: docName,
- });
- insertLinkedNode({
- inlineEditor,
- docId: newDoc.id,
- });
- const telemetryService =
- editorHost.std.getOptional(TelemetryProvider);
- telemetryService?.track('LinkedDocCreated', {
- control: 'new doc',
- module: 'inline @',
- type: 'doc',
- other: 'new doc',
- });
- telemetryService?.track('DocCreated', {
- control: 'new doc',
- module: 'inline @',
- type: 'doc',
- });
- },
+ const items: LinkedMenuItem[] = [
+ {
+ key: 'create',
+ name: `Create "${displayDocName}" doc`,
+ icon: NewDocIcon,
+ action: () => {
+ abort();
+ const docName = query;
+ const newDoc = createDefaultDoc(doc.workspace, {
+ title: docName,
+ });
+ insertLinkedNode({
+ inlineEditor,
+ docId: newDoc.id,
+ });
+ const telemetryService = editorHost.std.getOptional(TelemetryProvider);
+ telemetryService?.track('LinkedDocCreated', {
+ control: 'new doc',
+ module: 'inline @',
+ type: 'doc',
+ other: 'new doc',
+ });
+ telemetryService?.track('DocCreated', {
+ control: 'new doc',
+ module: 'inline @',
+ type: 'doc',
+ });
},
- {
- key: 'import',
- name: 'Import',
- icon: ImportIcon,
- action: () => {
- abort();
- const onSuccess = (
- docIds: string[],
- options: {
- importedCount: number;
- }
- ) => {
- toast(
- editorHost,
- `Successfully imported ${options.importedCount} Doc${options.importedCount > 1 ? 's' : ''}.`
- );
- for (const docId of docIds) {
- insertLinkedNode({
- inlineEditor,
- docId,
- });
- }
- };
- const onFail = (message: string) => {
- toast(editorHost, message);
- };
- showImportModal({
- collection: doc.workspace,
- schema: doc.schema,
- onSuccess,
- onFail,
- });
- },
+ },
+ ];
+
+ if (!IS_MOBILE) {
+ items.push({
+ key: 'import',
+ name: 'Import',
+ icon: ImportIcon,
+ action: () => {
+ abort();
+ const onSuccess = (
+ docIds: string[],
+ options: {
+ importedCount: number;
+ }
+ ) => {
+ toast(
+ editorHost,
+ `Successfully imported ${options.importedCount} Doc${options.importedCount > 1 ? 's' : ''}.`
+ );
+ for (const docId of docIds) {
+ insertLinkedNode({
+ inlineEditor,
+ docId,
+ });
+ }
+ };
+ const onFail = (message: string) => {
+ toast(editorHost, message);
+ };
+ showImportModal({
+ collection: doc.workspace,
+ schema: doc.schema,
+ onSuccess,
+ onFail,
+ });
},
- ],
+ });
+ }
+
+ return {
+ name: 'New Doc',
+ items,
};
}