mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-08-18 18:41:52 +08:00
chore: populate page prop for mixpanel (#7425)
This commit is contained in:
+6
@@ -24,6 +24,7 @@ import type { BlockSpec, WidgetElement } from '@blocksuite/block-std';
|
|||||||
import {
|
import {
|
||||||
type AffineReference,
|
type AffineReference,
|
||||||
AffineSlashMenuWidget,
|
AffineSlashMenuWidget,
|
||||||
|
EdgelessRootBlockComponent,
|
||||||
EmbedLinkedDocBlockComponent,
|
EmbedLinkedDocBlockComponent,
|
||||||
type ParagraphBlockService,
|
type ParagraphBlockService,
|
||||||
type RootService,
|
type RootService,
|
||||||
@@ -463,23 +464,28 @@ export function patchQuickSearchService(
|
|||||||
pageId: linkedDoc.id,
|
pageId: linkedDoc.id,
|
||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
|
const isEdgeless =
|
||||||
|
rootElement instanceof EdgelessRootBlockComponent;
|
||||||
if (result.isNewDoc) {
|
if (result.isNewDoc) {
|
||||||
mixpanel.track('DocCreated', {
|
mixpanel.track('DocCreated', {
|
||||||
control: 'linked doc',
|
control: 'linked doc',
|
||||||
module: 'slash commands',
|
module: 'slash commands',
|
||||||
type: 'linked doc',
|
type: 'linked doc',
|
||||||
category: 'doc',
|
category: 'doc',
|
||||||
|
page: isEdgeless ? 'whiteboard editor' : 'page editor',
|
||||||
});
|
});
|
||||||
mixpanel.track('LinkedDocCreated', {
|
mixpanel.track('LinkedDocCreated', {
|
||||||
control: 'new doc',
|
control: 'new doc',
|
||||||
module: 'slash commands',
|
module: 'slash commands',
|
||||||
type: 'doc',
|
type: 'doc',
|
||||||
|
page: isEdgeless ? 'whiteboard editor' : 'page editor',
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
mixpanel.track('LinkedDocCreated', {
|
mixpanel.track('LinkedDocCreated', {
|
||||||
control: 'linked doc',
|
control: 'linked doc',
|
||||||
module: 'slash commands',
|
module: 'slash commands',
|
||||||
type: 'doc',
|
type: 'doc',
|
||||||
|
page: isEdgeless ? 'whiteboard editor' : 'page editor',
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
} else if ('userInput' in result) {
|
} else if ('userInput' in result) {
|
||||||
|
|||||||
@@ -110,18 +110,20 @@ export const PageHeaderMenuButton = ({
|
|||||||
duplicate(pageId);
|
duplicate(pageId);
|
||||||
mixpanel.track('DocCreated', {
|
mixpanel.track('DocCreated', {
|
||||||
segment: 'editor header',
|
segment: 'editor header',
|
||||||
|
page: doc.mode$.value === 'page' ? 'page editor' : 'edgeless editor',
|
||||||
module: 'header menu',
|
module: 'header menu',
|
||||||
control: 'copy doc',
|
control: 'copy doc',
|
||||||
type: 'doc duplicate',
|
type: 'doc duplicate',
|
||||||
category: 'doc',
|
category: 'doc',
|
||||||
});
|
});
|
||||||
}, [duplicate, pageId]);
|
}, [doc.mode$.value, duplicate, pageId]);
|
||||||
|
|
||||||
const onImportFile = useAsyncCallback(async () => {
|
const onImportFile = useAsyncCallback(async () => {
|
||||||
const options = await importFile();
|
const options = await importFile();
|
||||||
if (options.isWorkspaceFile) {
|
if (options.isWorkspaceFile) {
|
||||||
mixpanel.track('WorkspaceCreated', {
|
mixpanel.track('WorkspaceCreated', {
|
||||||
segment: 'editor header',
|
segment: 'editor header',
|
||||||
|
page: doc.mode$.value === 'page' ? 'page editor' : 'edgeless editor',
|
||||||
module: 'header menu',
|
module: 'header menu',
|
||||||
control: 'import button',
|
control: 'import button',
|
||||||
type: 'imported workspace',
|
type: 'imported workspace',
|
||||||
@@ -129,12 +131,13 @@ export const PageHeaderMenuButton = ({
|
|||||||
} else {
|
} else {
|
||||||
mixpanel.track('DocCreated', {
|
mixpanel.track('DocCreated', {
|
||||||
segment: 'editor header',
|
segment: 'editor header',
|
||||||
|
page: doc.mode$.value === 'page' ? 'page editor' : 'edgeless editor',
|
||||||
module: 'header menu',
|
module: 'header menu',
|
||||||
control: 'import button',
|
control: 'import button',
|
||||||
type: 'imported doc',
|
type: 'imported doc',
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}, [importFile]);
|
}, [doc.mode$.value, importFile]);
|
||||||
|
|
||||||
const showResponsiveMenu = hideShare;
|
const showResponsiveMenu = hideShare;
|
||||||
const ResponsiveMenuItems = (
|
const ResponsiveMenuItems = (
|
||||||
|
|||||||
@@ -102,6 +102,7 @@ export const PageOperationCell = ({
|
|||||||
control: 'copy doc',
|
control: 'copy doc',
|
||||||
type: 'doc duplicate',
|
type: 'doc duplicate',
|
||||||
category: 'doc',
|
category: 'doc',
|
||||||
|
page: 'doc library',
|
||||||
});
|
});
|
||||||
}, [duplicate, page.id]);
|
}, [duplicate, page.id]);
|
||||||
|
|
||||||
|
|||||||
+7
-1
@@ -1,6 +1,7 @@
|
|||||||
import { IconButton } from '@affine/component/ui/button';
|
import { IconButton } from '@affine/component/ui/button';
|
||||||
import { useAsyncCallback } from '@affine/core/hooks/affine-async-hooks';
|
import { useAsyncCallback } from '@affine/core/hooks/affine-async-hooks';
|
||||||
import { FavoriteItemsAdapter } from '@affine/core/modules/properties';
|
import { FavoriteItemsAdapter } from '@affine/core/modules/properties';
|
||||||
|
import { TelemetryWorkspaceContextService } from '@affine/core/modules/telemetry/services/telemetry';
|
||||||
import { mixpanel } from '@affine/core/utils';
|
import { mixpanel } from '@affine/core/utils';
|
||||||
import { PlusIcon } from '@blocksuite/icons/rc';
|
import { PlusIcon } from '@blocksuite/icons/rc';
|
||||||
import { useService, useServices, WorkspaceService } from '@toeverything/infra';
|
import { useService, useServices, WorkspaceService } from '@toeverything/infra';
|
||||||
@@ -19,8 +20,11 @@ export const AddFavouriteButton = ({ pageId }: AddFavouriteButtonProps) => {
|
|||||||
workspaceService.workspace.docCollection
|
workspaceService.workspace.docCollection
|
||||||
);
|
);
|
||||||
const favAdapter = useService(FavoriteItemsAdapter);
|
const favAdapter = useService(FavoriteItemsAdapter);
|
||||||
|
const telemetry = useService(TelemetryWorkspaceContextService);
|
||||||
const handleAddFavorite = useAsyncCallback(
|
const handleAddFavorite = useAsyncCallback(
|
||||||
async e => {
|
async e => {
|
||||||
|
const page = telemetry.getPageContext();
|
||||||
|
|
||||||
if (pageId) {
|
if (pageId) {
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
@@ -32,6 +36,7 @@ export const AddFavouriteButton = ({ pageId }: AddFavouriteButtonProps) => {
|
|||||||
control: 'new fav sub doc',
|
control: 'new fav sub doc',
|
||||||
type: 'doc',
|
type: 'doc',
|
||||||
category: 'page',
|
category: 'page',
|
||||||
|
page: page,
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
const page = createPage();
|
const page = createPage();
|
||||||
@@ -44,10 +49,11 @@ export const AddFavouriteButton = ({ pageId }: AddFavouriteButtonProps) => {
|
|||||||
control: 'new fav doc',
|
control: 'new fav doc',
|
||||||
type: 'doc',
|
type: 'doc',
|
||||||
category: 'page',
|
category: 'page',
|
||||||
|
page: page,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
[pageId, createLinkedPage, createPage, favAdapter]
|
[telemetry, pageId, createLinkedPage, createPage, favAdapter]
|
||||||
);
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -1,7 +1,9 @@
|
|||||||
import { useAsyncCallback } from '@affine/core/hooks/affine-async-hooks';
|
import { useAsyncCallback } from '@affine/core/hooks/affine-async-hooks';
|
||||||
|
import { TelemetryWorkspaceContextService } from '@affine/core/modules/telemetry/services/telemetry';
|
||||||
import { mixpanel } from '@affine/core/utils';
|
import { mixpanel } from '@affine/core/utils';
|
||||||
import { useI18n } from '@affine/i18n';
|
import { useI18n } from '@affine/i18n';
|
||||||
import { ImportIcon } from '@blocksuite/icons/rc';
|
import { ImportIcon } from '@blocksuite/icons/rc';
|
||||||
|
import { useService } from '@toeverything/infra';
|
||||||
|
|
||||||
import type { DocCollection } from '../../shared';
|
import type { DocCollection } from '../../shared';
|
||||||
import { MenuItem } from '../app-sidebar';
|
import { MenuItem } from '../app-sidebar';
|
||||||
@@ -10,12 +12,14 @@ import { usePageHelper } from '../blocksuite/block-suite-page-list/utils';
|
|||||||
const ImportPage = ({ docCollection }: { docCollection: DocCollection }) => {
|
const ImportPage = ({ docCollection }: { docCollection: DocCollection }) => {
|
||||||
const t = useI18n();
|
const t = useI18n();
|
||||||
const { importFile } = usePageHelper(docCollection);
|
const { importFile } = usePageHelper(docCollection);
|
||||||
|
const telemetry = useService(TelemetryWorkspaceContextService);
|
||||||
|
|
||||||
const onImportFile = useAsyncCallback(async () => {
|
const onImportFile = useAsyncCallback(async () => {
|
||||||
const options = await importFile();
|
const options = await importFile();
|
||||||
|
const page = telemetry.getPageContext();
|
||||||
if (options.isWorkspaceFile) {
|
if (options.isWorkspaceFile) {
|
||||||
mixpanel.track('WorkspaceCreated', {
|
mixpanel.track('WorkspaceCreated', {
|
||||||
page: 'doc library',
|
page,
|
||||||
segment: 'navigation panel',
|
segment: 'navigation panel',
|
||||||
module: 'doc list header',
|
module: 'doc list header',
|
||||||
control: 'import button',
|
control: 'import button',
|
||||||
@@ -23,7 +27,7 @@ const ImportPage = ({ docCollection }: { docCollection: DocCollection }) => {
|
|||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
mixpanel.track('DocCreated', {
|
mixpanel.track('DocCreated', {
|
||||||
page: 'doc library',
|
page,
|
||||||
segment: 'navigation panel',
|
segment: 'navigation panel',
|
||||||
module: 'doc list header',
|
module: 'doc list header',
|
||||||
control: 'import button',
|
control: 'import button',
|
||||||
@@ -31,7 +35,7 @@ const ImportPage = ({ docCollection }: { docCollection: DocCollection }) => {
|
|||||||
// category
|
// category
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}, [importFile]);
|
}, [importFile, telemetry]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<MenuItem icon={<ImportIcon />} onClick={onImportFile}>
|
<MenuItem icon={<ImportIcon />} onClick={onImportFile}>
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import { AnimatedDeleteIcon } from '@affine/component';
|
|||||||
import { getDNDId } from '@affine/core/hooks/affine/use-global-dnd-helper';
|
import { getDNDId } from '@affine/core/hooks/affine/use-global-dnd-helper';
|
||||||
import { useAsyncCallback } from '@affine/core/hooks/affine-async-hooks';
|
import { useAsyncCallback } from '@affine/core/hooks/affine-async-hooks';
|
||||||
import { CollectionService } from '@affine/core/modules/collection';
|
import { CollectionService } from '@affine/core/modules/collection';
|
||||||
|
import { TelemetryWorkspaceContextService } from '@affine/core/modules/telemetry/services/telemetry';
|
||||||
import { mixpanel } from '@affine/core/utils';
|
import { mixpanel } from '@affine/core/utils';
|
||||||
import { apis, events } from '@affine/electron-api';
|
import { apis, events } from '@affine/electron-api';
|
||||||
import { useI18n } from '@affine/i18n';
|
import { useI18n } from '@affine/i18n';
|
||||||
@@ -103,6 +104,8 @@ export const RootAppSidebar = memo(
|
|||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const telemetry = useService(TelemetryWorkspaceContextService);
|
||||||
|
|
||||||
const allPageActive = currentPath === '/all';
|
const allPageActive = currentPath === '/all';
|
||||||
|
|
||||||
const trashActive = currentPath === '/trash';
|
const trashActive = currentPath === '/trash';
|
||||||
@@ -112,14 +115,14 @@ export const RootAppSidebar = memo(
|
|||||||
page.load();
|
page.load();
|
||||||
openPage(page.id);
|
openPage(page.id);
|
||||||
mixpanel.track('DocCreated', {
|
mixpanel.track('DocCreated', {
|
||||||
page: allPageActive ? 'all' : trashActive ? 'trash' : 'other',
|
page: telemetry.getPageContext(),
|
||||||
segment: 'navigation panel',
|
segment: 'navigation panel',
|
||||||
module: 'bottom button',
|
module: 'bottom button',
|
||||||
control: 'new doc button',
|
control: 'new doc button',
|
||||||
category: 'page',
|
category: 'page',
|
||||||
type: 'doc',
|
type: 'doc',
|
||||||
});
|
});
|
||||||
}, [allPageActive, createPage, openPage, trashActive]);
|
}, [createPage, openPage, telemetry]);
|
||||||
|
|
||||||
const navigateHelper = useNavigateHelper();
|
const navigateHelper = useNavigateHelper();
|
||||||
// Listen to the "New Page" action from the menu
|
// Listen to the "New Page" action from the menu
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import {
|
|||||||
registerAffineCommand,
|
registerAffineCommand,
|
||||||
} from '@affine/core/commands';
|
} from '@affine/core/commands';
|
||||||
import { FavoriteItemsAdapter } from '@affine/core/modules/properties';
|
import { FavoriteItemsAdapter } from '@affine/core/modules/properties';
|
||||||
|
import { TelemetryWorkspaceContextService } from '@affine/core/modules/telemetry/services/telemetry';
|
||||||
import { mixpanel } from '@affine/core/utils';
|
import { mixpanel } from '@affine/core/utils';
|
||||||
import { WorkspaceFlavour } from '@affine/env/workspace';
|
import { WorkspaceFlavour } from '@affine/env/workspace';
|
||||||
import { useI18n } from '@affine/i18n';
|
import { useI18n } from '@affine/i18n';
|
||||||
@@ -58,6 +59,8 @@ export function useRegisterBlocksuiteEditorCommands() {
|
|||||||
[docId, setTrashModal]
|
[docId, setTrashModal]
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const telemetry = useService(TelemetryWorkspaceContextService);
|
||||||
|
|
||||||
const isCloudWorkspace = workspace.flavour === WorkspaceFlavour.AFFINE_CLOUD;
|
const isCloudWorkspace = workspace.flavour === WorkspaceFlavour.AFFINE_CLOUD;
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@@ -144,6 +147,7 @@ export function useRegisterBlocksuiteEditorCommands() {
|
|||||||
control: 'cmdk',
|
control: 'cmdk',
|
||||||
type: 'doc duplicate',
|
type: 'doc duplicate',
|
||||||
category: 'doc',
|
category: 'doc',
|
||||||
|
page: telemetry.getPageContext(),
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
@@ -275,5 +279,6 @@ export function useRegisterBlocksuiteEditorCommands() {
|
|||||||
favAdapter,
|
favAdapter,
|
||||||
docId,
|
docId,
|
||||||
doc,
|
doc,
|
||||||
|
telemetry,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
export { Navigator } from './entities/navigator';
|
export { Navigator } from './entities/navigator';
|
||||||
export { resolveLinkToDoc } from './utils';
|
export { resolveLinkToDoc, resolveRouteLinkMeta } from './utils';
|
||||||
export { NavigationButtons } from './view/navigation-buttons';
|
export { NavigationButtons } from './view/navigation-buttons';
|
||||||
|
|
||||||
import { type Framework, WorkspaceScope } from '@toeverything/infra';
|
import { type Framework, WorkspaceScope } from '@toeverything/infra';
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ function maybeAffineOrigin(origin: string) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
export const resolveLinkToDoc = (href: string) => {
|
export const resolveRouteLinkMeta = (href: string) => {
|
||||||
try {
|
try {
|
||||||
const url = new URL(href, location.origin);
|
const url = new URL(href, location.origin);
|
||||||
|
|
||||||
@@ -18,23 +18,49 @@ export const resolveLinkToDoc = (href: string) => {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
// http://xxx/workspace/48__RTCSwASvWZxyAk3Jw/-Uge-K6SYcAbcNYfQ5U-j#xxxx
|
// http://xxx/workspace/all/yyy
|
||||||
// to { workspaceId: '48__RTCSwASvWZxyAk3Jw', docId: '-Uge-K6SYcAbcNYfQ5U-j', blockId: 'xxxx' }
|
// to { workspaceId: '48__RTCSwASvWZxyAk3Jw', docId: '-Uge-K6SYcAbcNYfQ5U-j', blockId: 'xxxx' }
|
||||||
|
|
||||||
const [_, workspaceId, docId, blockId] =
|
const [_, workspaceId, moduleName, subModuleName] =
|
||||||
url.toString().match(/\/workspace\/([^/]+)\/([^#]+)(?:#(.+))?/) || [];
|
url.toString().match(/\/workspace\/([^/]+)\/([^#]+)(?:#(.+))?/) || [];
|
||||||
|
|
||||||
/**
|
if (isRouteModulePath(moduleName)) {
|
||||||
* @see /packages/frontend/core/src/router.tsx
|
return {
|
||||||
*/
|
workspaceId,
|
||||||
const excludedPaths = ['all', 'collection', 'tag', 'trash'];
|
moduleName,
|
||||||
|
subModuleName,
|
||||||
if (!docId || excludedPaths.includes(docId)) {
|
};
|
||||||
return null;
|
} else if (moduleName) {
|
||||||
|
// for now we assume all other cases are doc links
|
||||||
|
return {
|
||||||
|
workspaceId,
|
||||||
|
moduleName: 'doc' as const,
|
||||||
|
docId: moduleName,
|
||||||
|
blockId: subModuleName,
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
return;
|
||||||
return { workspaceId, docId, blockId };
|
|
||||||
} catch {
|
} catch {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see /packages/frontend/core/src/router.tsx
|
||||||
|
*/
|
||||||
|
const routeModulePaths = ['all', 'collection', 'tag', 'trash'] as const;
|
||||||
|
|
||||||
|
const isRouteModulePath = (
|
||||||
|
path: string
|
||||||
|
): path is (typeof routeModulePaths)[number] =>
|
||||||
|
routeModulePaths.includes(path as any);
|
||||||
|
|
||||||
|
export const resolveLinkToDoc = (href: string) => {
|
||||||
|
const meta = resolveRouteLinkMeta(href);
|
||||||
|
if (!meta || meta.moduleName !== 'doc') return null;
|
||||||
|
return {
|
||||||
|
workspaceId: meta.workspaceId,
|
||||||
|
docId: meta.docId,
|
||||||
|
blockId: meta.blockId,
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|||||||
@@ -1,8 +1,14 @@
|
|||||||
import type { Framework } from '@toeverything/infra';
|
import { type Framework, WorkspaceScope } from '@toeverything/infra';
|
||||||
|
|
||||||
import { AuthService } from '../cloud';
|
import { AuthService } from '../cloud';
|
||||||
import { TelemetryService } from './services/telemetry';
|
import {
|
||||||
|
TelemetryService,
|
||||||
|
TelemetryWorkspaceContextService,
|
||||||
|
} from './services/telemetry';
|
||||||
|
|
||||||
export function configureTelemetryModule(framework: Framework) {
|
export function configureTelemetryModule(framework: Framework) {
|
||||||
framework.service(TelemetryService, [AuthService]);
|
framework.service(TelemetryService, [AuthService]);
|
||||||
|
framework
|
||||||
|
.scope(WorkspaceScope)
|
||||||
|
.service(TelemetryWorkspaceContextService, [WorkspaceScope]);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,12 @@
|
|||||||
import { mixpanel } from '@affine/core/utils';
|
import { mixpanel } from '@affine/core/utils';
|
||||||
import type { QuotaQuery } from '@affine/graphql';
|
import type { QuotaQuery } from '@affine/graphql';
|
||||||
import { ApplicationStarted, OnEvent, Service } from '@toeverything/infra';
|
import type { WorkspaceScope } from '@toeverything/infra';
|
||||||
|
import {
|
||||||
|
ApplicationStarted,
|
||||||
|
DocsService,
|
||||||
|
OnEvent,
|
||||||
|
Service,
|
||||||
|
} from '@toeverything/infra';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
AccountChanged,
|
AccountChanged,
|
||||||
@@ -9,6 +15,8 @@ import {
|
|||||||
} from '../../cloud';
|
} from '../../cloud';
|
||||||
import { AccountLoggedOut } from '../../cloud/services/auth';
|
import { AccountLoggedOut } from '../../cloud/services/auth';
|
||||||
import { UserQuotaChanged } from '../../cloud/services/user-quota';
|
import { UserQuotaChanged } from '../../cloud/services/user-quota';
|
||||||
|
import { resolveRouteLinkMeta } from '../../navigation';
|
||||||
|
import { WorkbenchService } from '../../workbench';
|
||||||
|
|
||||||
@OnEvent(ApplicationStarted, e => e.onApplicationStart)
|
@OnEvent(ApplicationStarted, e => e.onApplicationStart)
|
||||||
@OnEvent(AccountChanged, e => e.updateIdentity)
|
@OnEvent(AccountChanged, e => e.updateIdentity)
|
||||||
@@ -67,3 +75,38 @@ export class TelemetryService extends Service {
|
|||||||
this.prevQuota = quota;
|
this.prevQuota = quota;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// get telemetry related context in Workspace scope
|
||||||
|
export class TelemetryWorkspaceContextService extends Service {
|
||||||
|
constructor(private readonly provider: WorkspaceScope) {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
getPageContext() {
|
||||||
|
const workbench = this.provider?.getOptional(WorkbenchService)?.workbench;
|
||||||
|
const docs = this.provider?.getOptional(DocsService);
|
||||||
|
|
||||||
|
if (!workbench || !docs) return '';
|
||||||
|
|
||||||
|
const basename = workbench.basename$.value;
|
||||||
|
const path = workbench.location$.value;
|
||||||
|
const fullPath = basename + path.pathname + path.search + path.hash;
|
||||||
|
const linkMeta = resolveRouteLinkMeta(fullPath);
|
||||||
|
return (() => {
|
||||||
|
const moduleName =
|
||||||
|
linkMeta?.moduleName === 'doc'
|
||||||
|
? docs.list.getMode(linkMeta.docId)
|
||||||
|
: linkMeta?.moduleName;
|
||||||
|
switch (moduleName) {
|
||||||
|
case 'page':
|
||||||
|
return 'page editor';
|
||||||
|
case 'edgeless':
|
||||||
|
return 'whiteboard editor';
|
||||||
|
case 'trash':
|
||||||
|
return 'trash';
|
||||||
|
default:
|
||||||
|
return 'doc library';
|
||||||
|
}
|
||||||
|
})();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user