chore(editor): hide file and doc import entries for mobile (#11648)
Close [BS-2926](https://linear.app/affine-design/issue/BS-2926/【移动端-ios】-选择import,无反应) Close [BS-2927](https://linear.app/affine-design/issue/BS-2927/【移动端-ios】隐藏toolbar上附件入口)
This commit is contained in:
@@ -428,8 +428,7 @@ const contentMediaToolGroup: KeyboardToolPanelGroup = {
|
|||||||
{
|
{
|
||||||
name: 'Attachment',
|
name: 'Attachment',
|
||||||
icon: AttachmentIcon(),
|
icon: AttachmentIcon(),
|
||||||
showWhen: ({ std }) =>
|
showWhen: () => false,
|
||||||
std.store.schema.flavourSchemaMap.has('affine:attachment'),
|
|
||||||
action: async ({ std }) => {
|
action: async ({ std }) => {
|
||||||
const [_, { selectedModels }] = std.command.exec(
|
const [_, { selectedModels }] = std.command.exec(
|
||||||
getSelectedModelsCommand
|
getSelectedModelsCommand
|
||||||
@@ -1029,8 +1028,7 @@ export const defaultKeyboardToolbarConfig: KeyboardToolbarConfig = {
|
|||||||
{
|
{
|
||||||
name: 'Attachment',
|
name: 'Attachment',
|
||||||
icon: AttachmentIcon(),
|
icon: AttachmentIcon(),
|
||||||
showWhen: ({ std }) =>
|
showWhen: () => false,
|
||||||
std.store.schema.flavourSchemaMap.has('affine:attachment'),
|
|
||||||
action: async ({ std }) => {
|
action: async ({ std }) => {
|
||||||
const [_, { selectedModels }] = std.command.exec(
|
const [_, { selectedModels }] = std.command.exec(
|
||||||
getSelectedModelsCommand
|
getSelectedModelsCommand
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ import {
|
|||||||
isFuzzyMatch,
|
isFuzzyMatch,
|
||||||
type Signal,
|
type Signal,
|
||||||
} from '@blocksuite/affine-shared/utils';
|
} from '@blocksuite/affine-shared/utils';
|
||||||
|
import { IS_MOBILE } from '@blocksuite/global/env';
|
||||||
import {
|
import {
|
||||||
type BlockStdScope,
|
type BlockStdScope,
|
||||||
ConfigExtensionFactory,
|
ConfigExtensionFactory,
|
||||||
@@ -175,73 +176,77 @@ export function createNewDocMenuGroup(
|
|||||||
docName.slice(0, DISPLAY_NAME_LENGTH) +
|
docName.slice(0, DISPLAY_NAME_LENGTH) +
|
||||||
(docName.length > DISPLAY_NAME_LENGTH ? '..' : '');
|
(docName.length > DISPLAY_NAME_LENGTH ? '..' : '');
|
||||||
|
|
||||||
|
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',
|
||||||
|
});
|
||||||
|
},
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
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 {
|
return {
|
||||||
name: 'New Doc',
|
name: 'New Doc',
|
||||||
items: [
|
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',
|
|
||||||
});
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
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,
|
|
||||||
});
|
|
||||||
},
|
|
||||||
},
|
|
||||||
],
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user