-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(core): add private anchor link for sharing (#6966)
close AFF-1085
- Loading branch information
Showing
9 changed files
with
162 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
packages/frontend/core/src/hooks/affine/use-register-copy-link-commands.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import { useSharingUrl } from '@affine/core/hooks/affine/use-share-url'; | ||
import { registerAffineCommand } from '@toeverything/infra'; | ||
import { useEffect } from 'react'; | ||
|
||
export function useRegisterCopyLinkCommands({ | ||
workspaceId, | ||
docId, | ||
isActiveView, | ||
}: { | ||
workspaceId: string; | ||
docId: string; | ||
isActiveView: boolean; | ||
}) { | ||
const { onClickCopyLink } = useSharingUrl({ | ||
workspaceId, | ||
pageId: docId, | ||
urlType: 'workspace', | ||
}); | ||
|
||
useEffect(() => { | ||
const unsubs: Array<() => void> = []; | ||
|
||
unsubs.push( | ||
registerAffineCommand({ | ||
id: `affine:share-private-link:${docId}`, | ||
category: 'affine:general', | ||
preconditionStrategy: () => isActiveView, | ||
keyBinding: { | ||
binding: '$mod+Shift+c', | ||
}, | ||
label: '', | ||
icon: null, | ||
run() { | ||
isActiveView && onClickCopyLink(); | ||
}, | ||
}) | ||
); | ||
return () => { | ||
unsubs.forEach(unsub => unsub()); | ||
}; | ||
}, [docId, isActiveView, onClickCopyLink]); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters