mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-23 21:38:44 +08:00
feat(core): add track events for cmdk (#7668)
This commit is contained in:
+31
-1
@@ -102,6 +102,8 @@ export function useRegisterBlocksuiteEditorCommands() {
|
||||
icon: mode === 'page' ? <PageIcon /> : <EdgelessIcon />,
|
||||
label: t['com.affine.page-properties.page-info.view'](),
|
||||
run() {
|
||||
track.$.cmdk.docInfo.open();
|
||||
|
||||
openInfoModal();
|
||||
},
|
||||
})
|
||||
@@ -118,6 +120,8 @@ export function useRegisterBlocksuiteEditorCommands() {
|
||||
: t['com.affine.favoritePageOperation.add'](),
|
||||
run() {
|
||||
favAdapter.toggle(docId, 'doc');
|
||||
track.$.cmdk.editor.toggleFavorite();
|
||||
|
||||
toast(
|
||||
favorite
|
||||
? t['com.affine.cmdk.affine.editor.remove-from-favourites']()
|
||||
@@ -141,6 +145,10 @@ export function useRegisterBlocksuiteEditorCommands() {
|
||||
: t['com.affine.pageMode.page']()
|
||||
}`,
|
||||
run() {
|
||||
track.$.cmdk.editor.switchPageMode({
|
||||
mode: mode === 'page' ? 'edgeless' : 'page',
|
||||
});
|
||||
|
||||
doc.toggleMode();
|
||||
toast(
|
||||
mode === 'page'
|
||||
@@ -161,7 +169,7 @@ export function useRegisterBlocksuiteEditorCommands() {
|
||||
label: t['com.affine.header.option.duplicate'](),
|
||||
run() {
|
||||
duplicate(docId);
|
||||
track.$.cmdk.$.createDoc({
|
||||
track.$.cmdk.editor.createDoc({
|
||||
control: 'duplicate',
|
||||
});
|
||||
},
|
||||
@@ -176,6 +184,10 @@ export function useRegisterBlocksuiteEditorCommands() {
|
||||
icon: mode === 'page' ? <PageIcon /> : <EdgelessIcon />,
|
||||
label: t['Export to PDF'](),
|
||||
async run() {
|
||||
track.$.cmdk.editor.export({
|
||||
type: 'pdf',
|
||||
});
|
||||
|
||||
await exportHandler('pdf');
|
||||
},
|
||||
})
|
||||
@@ -189,6 +201,10 @@ export function useRegisterBlocksuiteEditorCommands() {
|
||||
icon: mode === 'page' ? <PageIcon /> : <EdgelessIcon />,
|
||||
label: t['Export to HTML'](),
|
||||
async run() {
|
||||
track.$.cmdk.editor.export({
|
||||
type: 'html',
|
||||
});
|
||||
|
||||
await exportHandler('html');
|
||||
},
|
||||
})
|
||||
@@ -202,6 +218,10 @@ export function useRegisterBlocksuiteEditorCommands() {
|
||||
icon: mode === 'page' ? <PageIcon /> : <EdgelessIcon />,
|
||||
label: t['Export to PNG'](),
|
||||
async run() {
|
||||
track.$.cmdk.editor.export({
|
||||
type: 'png',
|
||||
});
|
||||
|
||||
await exportHandler('png');
|
||||
},
|
||||
})
|
||||
@@ -215,6 +235,10 @@ export function useRegisterBlocksuiteEditorCommands() {
|
||||
icon: mode === 'page' ? <PageIcon /> : <EdgelessIcon />,
|
||||
label: t['Export to Markdown'](),
|
||||
async run() {
|
||||
track.$.cmdk.editor.export({
|
||||
type: 'markdown',
|
||||
});
|
||||
|
||||
await exportHandler('markdown');
|
||||
},
|
||||
})
|
||||
@@ -228,6 +252,8 @@ export function useRegisterBlocksuiteEditorCommands() {
|
||||
icon: mode === 'page' ? <PageIcon /> : <EdgelessIcon />,
|
||||
label: t['com.affine.moveToTrash.title'](),
|
||||
run() {
|
||||
track.$.cmdk.editor.deleteDoc();
|
||||
|
||||
onClickDelete(doc.title$.value);
|
||||
},
|
||||
})
|
||||
@@ -242,6 +268,8 @@ export function useRegisterBlocksuiteEditorCommands() {
|
||||
icon: mode === 'page' ? <PageIcon /> : <EdgelessIcon />,
|
||||
label: t['com.affine.cmdk.affine.editor.restore-from-trash'](),
|
||||
run() {
|
||||
track.$.cmdk.editor.restoreDoc();
|
||||
|
||||
doc.restoreFromTrash();
|
||||
},
|
||||
})
|
||||
@@ -255,6 +283,8 @@ export function useRegisterBlocksuiteEditorCommands() {
|
||||
icon: <HistoryIcon />,
|
||||
label: t['com.affine.cmdk.affine.editor.reveal-page-history-modal'](),
|
||||
run() {
|
||||
track.$.cmdk.docHistory.open();
|
||||
|
||||
openHistoryModal();
|
||||
},
|
||||
})
|
||||
|
||||
@@ -3,9 +3,10 @@ import {
|
||||
registerAffineCommand,
|
||||
} from '@affine/core/commands';
|
||||
import { useSharingUrl } from '@affine/core/hooks/affine/use-share-url';
|
||||
import { track } from '@affine/core/mixpanel';
|
||||
import { useIsActiveView } from '@affine/core/modules/workbench';
|
||||
import { WorkspaceFlavour } from '@affine/env/workspace';
|
||||
import type { WorkspaceMetadata } from '@toeverything/infra';
|
||||
import { type WorkspaceMetadata } from '@toeverything/infra';
|
||||
import { useEffect } from 'react';
|
||||
|
||||
export function useRegisterCopyLinkCommands({
|
||||
@@ -38,6 +39,8 @@ export function useRegisterCopyLinkCommands({
|
||||
label: '',
|
||||
icon: null,
|
||||
run() {
|
||||
track.$.cmdk.general.copyShareLink({ type: 'private' });
|
||||
|
||||
isActiveView && isCloud && onClickCopyLink();
|
||||
},
|
||||
})
|
||||
|
||||
@@ -2,6 +2,7 @@ import {
|
||||
PreconditionStrategy,
|
||||
registerAffineCommand,
|
||||
} from '@affine/core/commands';
|
||||
import { track } from '@affine/core/mixpanel';
|
||||
import { FindInPageService } from '@affine/core/modules/find-in-page/services/find-in-page';
|
||||
import { useService } from '@toeverything/infra';
|
||||
import { useCallback, useEffect } from 'react';
|
||||
@@ -24,13 +25,15 @@ export function useRegisterFindInPageCommands() {
|
||||
unsubs.push(
|
||||
registerAffineCommand({
|
||||
preconditionStrategy: PreconditionStrategy.Never,
|
||||
id: `editor:find-in-page`,
|
||||
id: `affine:find-in-page`,
|
||||
keyBinding: {
|
||||
binding: '$mod+f',
|
||||
},
|
||||
icon: null,
|
||||
label: '',
|
||||
run() {
|
||||
track.$.cmdk.general.findInPage();
|
||||
|
||||
toggleVisible();
|
||||
},
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user