From 7e40fbd7695a30124293533a838c86f2a8728ec5 Mon Sep 17 00:00:00 2001 From: Nate Kelley Date: Thu, 7 Aug 2025 13:34:35 -0600 Subject: [PATCH] Editor is working --- apps/web/src/components/ui/report/Editor.tsx | 1 - .../src/components/ui/report/ReportEditor.tsx | 23 +++++++++++++++++-- .../ReportPageController.tsx | 2 +- 3 files changed, 22 insertions(+), 4 deletions(-) diff --git a/apps/web/src/components/ui/report/Editor.tsx b/apps/web/src/components/ui/report/Editor.tsx index 05c774fad..948f39b7a 100644 --- a/apps/web/src/components/ui/report/Editor.tsx +++ b/apps/web/src/components/ui/report/Editor.tsx @@ -42,7 +42,6 @@ export type EditorProps = PlateContentProps & VariantProps( ({ className, disabled, focused, variant, ...props }, ref) => { - console.log('Editor', { className, disabled, focused, variant, ...props }); return ( }) => { - onValueChange?.(value as ReportElements); + onValueChange?.(cleanValueToReportElements(value)); } ); @@ -92,3 +92,22 @@ export const ReportEditor = React.memo( ); ReportEditor.displayName = 'ReportEditor'; + +const cleanValueToReportElements = (value: Value): ReportElements => { + const filteredElements: ReportElements = value + .filter((element) => element.type !== 'slash_input') + .map((element) => { + // If the element has a children array, filter its children as well + if (Array.isArray(element.children)) { + return { + ...element, + children: element.children.filter((child) => { + return child.type !== 'slash_input'; + }) + } as ReportElement; + } + return element as ReportElement; + }); + + return filteredElements; +}; diff --git a/apps/web/src/controllers/ReportPageControllers/ReportPageController/ReportPageController.tsx b/apps/web/src/controllers/ReportPageControllers/ReportPageController/ReportPageController.tsx index 8c6057813..06f318c3f 100644 --- a/apps/web/src/controllers/ReportPageControllers/ReportPageController/ReportPageController.tsx +++ b/apps/web/src/controllers/ReportPageControllers/ReportPageController/ReportPageController.tsx @@ -26,7 +26,7 @@ export const ReportPageController: React.FC<{ updateReport({ reportId, name }); }); - const { run: debouncedUpdateReport } = useDebounceFn(updateReport, { wait: 300 }); + const { run: debouncedUpdateReport } = useDebounceFn(updateReport, { wait: 650 }); const onChangeContent = useMemoizedFn((content: ReportElements) => { debouncedUpdateReport({ reportId, content });