mirror of https://github.com/buster-so/buster.git
editor pdf exporting
This commit is contained in:
parent
1317190edf
commit
f100dc723f
|
@ -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';
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
export { registerReportEditor, unregisterReportEditor, getReportEditor } from './editorRegistry';
|
|
@ -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<{
|
||||
|
|
|
@ -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);
|
||||
};
|
||||
};
|
|
@ -1 +1,2 @@
|
|||
export * from './ReportPageController';
|
||||
export * from './editorRegistry';
|
||||
|
|
|
@ -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]
|
||||
[]
|
||||
);
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue