feat(acadenice): wire /template slash command to TemplatePickerModal via DOM event
R4.8 — PageContent now listens for acadenice:open-template-picker on document and opens TemplatePickerModal via useDisclosure. The slash command dispatched the event but nothing handled it, so the modal never opened. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
9139fb8728
commit
243168a3f8
1 changed files with 25 additions and 1 deletions
|
|
@ -7,12 +7,15 @@ import PageHeader from "@/features/page/components/header/page-header.tsx";
|
||||||
import { extractPageSlugId } from "@/lib";
|
import { extractPageSlugId } from "@/lib";
|
||||||
import { useGetSpaceBySlugQuery } from "@/features/space/queries/space-query.ts";
|
import { useGetSpaceBySlugQuery } from "@/features/space/queries/space-query.ts";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import React from "react";
|
import React, { useEffect } from "react";
|
||||||
import { EmptyState } from "@/components/ui/empty-state.tsx";
|
import { EmptyState } from "@/components/ui/empty-state.tsx";
|
||||||
import { IconAlertTriangle, IconFileOff } from "@tabler/icons-react";
|
import { IconAlertTriangle, IconFileOff } from "@tabler/icons-react";
|
||||||
import { Button } from "@mantine/core";
|
import { Button } from "@mantine/core";
|
||||||
import { Link } from "react-router-dom";
|
import { Link } from "react-router-dom";
|
||||||
import { ErrorBoundary } from "react-error-boundary";
|
import { ErrorBoundary } from "react-error-boundary";
|
||||||
|
import { useDisclosure } from "@mantine/hooks";
|
||||||
|
// Acadenice R4.8 — /template slash command wires to TemplatePickerModal via DOM event
|
||||||
|
import TemplatePickerModal from "@/features/acadenice/templates/components/template-picker-modal";
|
||||||
const MemoizedFullEditor = React.memo(FullEditor);
|
const MemoizedFullEditor = React.memo(FullEditor);
|
||||||
const MemoizedPageHeader = React.memo(PageHeader);
|
const MemoizedPageHeader = React.memo(PageHeader);
|
||||||
const MemoizedHistoryModal = React.memo(HistoryModal);
|
const MemoizedHistoryModal = React.memo(HistoryModal);
|
||||||
|
|
@ -43,6 +46,17 @@ export default function Page() {
|
||||||
|
|
||||||
function PageContent({ pageSlug }: { pageSlug: string | undefined }) {
|
function PageContent({ pageSlug }: { pageSlug: string | undefined }) {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
|
// Acadenice R4.8 — /template slash command opens TemplatePickerModal via DOM event.
|
||||||
|
// The slash command in menu-items.ts dispatches 'acadenice:open-template-picker'.
|
||||||
|
// We listen here (page level) so the modal has access to the current page/space context.
|
||||||
|
const [templatePickerOpened, { open: openTemplatePicker, close: closeTemplatePicker }] =
|
||||||
|
useDisclosure(false);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
const handler = () => openTemplatePicker();
|
||||||
|
document.addEventListener("acadenice:open-template-picker", handler);
|
||||||
|
return () => document.removeEventListener("acadenice:open-template-picker", handler);
|
||||||
|
}, [openTemplatePicker]);
|
||||||
|
|
||||||
const {
|
const {
|
||||||
data: page,
|
data: page,
|
||||||
|
|
@ -112,6 +126,16 @@ function PageContent({ pageSlug }: { pageSlug: string | undefined }) {
|
||||||
canComment={canComment}
|
canComment={canComment}
|
||||||
/>
|
/>
|
||||||
<MemoizedHistoryModal pageId={page.id} />
|
<MemoizedHistoryModal pageId={page.id} />
|
||||||
|
|
||||||
|
{/* Acadenice R4.8 — template picker opened via /template slash command */}
|
||||||
|
{page.space?.id && (
|
||||||
|
<TemplatePickerModal
|
||||||
|
opened={templatePickerOpened}
|
||||||
|
onClose={closeTemplatePicker}
|
||||||
|
spaceId={page.space.id}
|
||||||
|
parentPageId={page.id}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue