Skip to content
This repository was archived by the owner on May 19, 2026. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion apps/client/public/locales/de-DE/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -801,5 +801,6 @@
"Google Drive": "Google Drive",
"Embed Google Drive content": "Google Drive-Inhalte einbetten",
"Google Sheets": "Google Sheets",
"Embed Google Sheets content": "Google Sheets-Inhalte einbetten"
"Embed Google Sheets content": "Google Sheets-Inhalte einbetten",
"Not available": "Nicht verfügbar"
}
3 changes: 2 additions & 1 deletion apps/client/public/locales/en-US/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -816,5 +816,6 @@
"Google Drive": "Google Drive",
"Embed Google Drive content": "Embed Google Drive content",
"Google Sheets": "Google Sheets",
"Embed Google Sheets content": "Embed Google Sheets content"
"Embed Google Sheets content": "Embed Google Sheets content",
"Not available": "Not available"
}
42 changes: 30 additions & 12 deletions apps/client/src/features/editor/components/mention/mention-view.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
import { NodeViewProps, NodeViewWrapper } from "@tiptap/react";
import { ActionIcon, Anchor, Text } from "@mantine/core";
import { ActionIcon, Anchor, Text, Tooltip } from "@mantine/core";
import { useTranslation } from "react-i18next";
import { IconFileDescription } from "@tabler/icons-react";
import { Link, useLocation, useNavigate, useParams } from "react-router-dom";
import { usePageQuery } from "@/features/page/queries/page-query.ts";
import { useAtomValue } from "jotai";
import { sharedTreeDataAtom } from "@/features/share/atoms/shared-page-atom";
import { isPageInTree } from "@/features/share/utils";
import {
buildPageUrl,
buildSharedPageUrl,
Expand All @@ -17,18 +21,28 @@ const truncateText = (text: string, maxLength: number = 30): string => {

export default function MentionView(props: NodeViewProps) {
const { node } = props;
const { label, entityType, entityId, slugId, anchorSlug, anchorText } = node.attrs;
const { t } = useTranslation();
const { label, entityType, slugId, anchorSlug, anchorText } = node.attrs;
const { spaceSlug, pageSlug } = useParams();
const { shareId } = useParams();
const navigate = useNavigate();
const sharedTreeData = useAtomValue(sharedTreeDataAtom);

const location = useLocation();
const isShareRoute = location.pathname.startsWith("/share");

const {
data: page,
isLoading,
isError,
} = usePageQuery({ pageId: entityType === "page" ? slugId : null });
} = usePageQuery({
pageId: entityType === "page" && !isShareRoute ? slugId : null,
});

const location = useLocation();
const isShareRoute = location.pathname.startsWith("/share");
const isPageAvailableInShareTree =
isShareRoute &&
!!sharedTreeData &&
entityType === "page" &&
isPageInTree(sharedTreeData, slugId);

const currentPageSlugId = extractPageSlugId(pageSlug);
const isSamePage = currentPageSlugId === slugId;
Expand All @@ -51,7 +65,9 @@ export default function MentionView(props: NodeViewProps) {
anchorId: anchorSlug,
});

const pageUrl = buildPageUrl(spaceSlug, slugId, label, anchorSlug);
const canNavigateToPageMention =
entityType === "page" &&
(isShareRoute ? isPageAvailableInShareTree : !isError);

return (
<NodeViewWrapper style={{ display: "inline" }} data-drag-handle>
Expand All @@ -61,13 +77,15 @@ export default function MentionView(props: NodeViewProps) {
</Text>
)}

{entityType === "page" && isError && (
<Text component="span" c="dimmed" size="sm">
{label}
</Text>
{entityType === "page" && !canNavigateToPageMention && (
<Tooltip label={t("Not available")} withArrow>
<Text component="span" c="dimmed" size="sm">
{label}
</Text>
</Tooltip>
)}

{entityType === "page" && !isError && (
{entityType === "page" && canNavigateToPageMention && (
<Anchor
component={Link}
fw={500}
Expand Down
Loading