editor pdf exporting

This commit is contained in:
Nate Kelley 2025-08-08 10:40:47 -06:00
parent 1317190edf
commit f100dc723f
No known key found for this signature in database
GPG Key ID: FD90372AB8D98B4F
6 changed files with 19 additions and 20 deletions

View File

@ -1,6 +1,6 @@
'use client';
import React, { useImperativeHandle, useRef } from 'react';
import React, { useEffect, useImperativeHandle, useRef } from 'react';
import type { Value, AnyPluginConfig } from 'platejs';
import { Plate, type TPlateEditor } from 'platejs/react';
import { EditorContainer } from './EditorContainer';

View File

@ -1 +0,0 @@
export { registerReportEditor, unregisterReportEditor, getReportEditor } from './editorRegistry';

View File

@ -9,10 +9,7 @@ import { useDebounceFn } from '@/hooks/useDebounce';
import type { ReportElements } from '@buster/server-shared/reports';
//import DynamicReportEditor from '@/components/ui/report/DynamicReportEditor';
import { ReportEditor, type IReportEditor } from '@/components/ui/report/ReportEditor';
import {
registerReportEditor,
unregisterReportEditor
} from '@/components/ui/report/editorRegistry';
import { registerReportEditor, unregisterReportEditor } from './editorRegistry';
import { ReportEditorSkeleton } from '@/components/ui/report/ReportEditorSkeleton';
export const ReportPageController: React.FC<{

View File

@ -1,4 +1,4 @@
import type { IReportEditor } from './ReportEditor';
import type { IReportEditor } from '@/components/ui/report/ReportEditor';
// Simple in-memory registry to map reportId -> editor instance
const reportEditorRegistry = new Map<string, IReportEditor>();
@ -13,4 +13,4 @@ export const unregisterReportEditor = (reportId: string) => {
export const getReportEditor = (reportId: string): IReportEditor | undefined => {
return reportEditorRegistry.get(reportId);
};
};

View File

@ -1 +1,2 @@
export * from './ReportPageController';
export * from './editorRegistry';

View File

@ -26,7 +26,7 @@ import { useFavoriteStar } from '@/components/features/list/FavoriteStar';
import { useStatusDropdownContent } from '@/components/features/metrics/StatusBadgeIndicator/useStatusDropdownContent';
import type { VerificationStatus } from '@buster/server-shared/share';
import { useSaveToCollectionsDropdownContent } from '@/components/features/dropdowns/SaveToCollectionsDropdown';
import { getReportEditor } from '@/components/ui/report/editorRegistry';
import { getReportEditor } from '@/controllers/ReportPageControllers/ReportPageController/editorRegistry';
import { NodeTypeLabels } from '@/components/ui/report/config/labels';
import { useExportReport } from '@/components/ui/report/hooks';
@ -313,20 +313,22 @@ const useDuplicateReportSelectMenu = (): DropdownItem => {
// Download as PDF
const useDownloadPdfSelectMenu = ({ reportId }: { reportId: string }): DropdownItem => {
const { openErrorMessage, openInfoMessage } = useBusterNotifications();
const { openErrorMessage } = useBusterNotifications();
const editor = getReportEditor(reportId);
const { exportToPdf } = useExportReport();
const onClick = useMemoizedFn(async () => {
if (!editor) {
openErrorMessage(NodeTypeLabels.failedToExportPdf.label);
return;
const onClick = async () => {
try {
if (!editor) {
openErrorMessage(NodeTypeLabels.failedToExportPdf.label);
return;
}
await exportToPdf(editor);
} catch (error) {
openErrorMessage('Failed to export PDF');
}
await exportToPdf(editor);
//
});
};
return useMemo(
() => ({
@ -335,6 +337,6 @@ const useDownloadPdfSelectMenu = ({ reportId }: { reportId: string }): DropdownI
icon: <FileText />,
onClick
}),
[onClick]
[]
);
};