fix: Link to share link in document should be treated as external. closes #6347
This commit is contained in:
@@ -5,11 +5,12 @@ import { isModKey } from "~/utils/keyboard";
|
||||
import { sharedDocumentPath } from "~/utils/routeHelpers";
|
||||
import { isHash } from "~/utils/urls";
|
||||
|
||||
export default function useEditorClickHandlers({
|
||||
shareId,
|
||||
}: {
|
||||
type Params = {
|
||||
/** The share ID of the document being viewed, if any */
|
||||
shareId?: string;
|
||||
}) {
|
||||
};
|
||||
|
||||
export default function useEditorClickHandlers({ shareId }: Params) {
|
||||
const history = useHistory();
|
||||
const handleClickLink = React.useCallback(
|
||||
(href: string, event: MouseEvent) => {
|
||||
@@ -39,6 +40,12 @@ export default function useEditorClickHandlers({
|
||||
return;
|
||||
}
|
||||
|
||||
// If we're navigating to a share link from a non-share link then open it in a new tab
|
||||
if (shareId && navigateTo.startsWith("/s/")) {
|
||||
window.open(href, "_blank");
|
||||
return;
|
||||
}
|
||||
|
||||
// If we're navigating to an internal document link then prepend the
|
||||
// share route to the URL so that the document is loaded in context
|
||||
if (shareId && navigateTo.includes("/doc/")) {
|
||||
|
||||
Reference in New Issue
Block a user