diff --git a/components/form/static-page/static-page-edit-form.tsx b/components/form/static-page/static-page-edit-form.tsx index c4601d1..13d6385 100644 --- a/components/form/static-page/static-page-edit-form.tsx +++ b/components/form/static-page/static-page-edit-form.tsx @@ -15,6 +15,14 @@ import { close, error, loading } from "@/config/swal"; import Swal from "sweetalert2"; import withReactContent from "sweetalert2-react-content"; import { useParams, useRouter } from "next/navigation"; +import dynamic from "next/dynamic"; + +const CustomEditor = dynamic( + () => { + return import("@/components/editor/custom-editor"); + }, + { ssr: false } +); const formSchema = z.object({ slug: z.string().min(2, { @@ -60,15 +68,30 @@ export default function StaticPageBuilderEdit() { setValue("title", data?.title); setValue("slug", data?.slug); setValue("description", data?.description); - setValue("htmlBody", data?.htmlBody); + setValue("htmlBody", addPreCode(data?.htmlBody)); + console.log("asdasd", addPreCode(data?.htmlBody)); + }; + + const addPreCode = (htmlString: string): string => { + const parser = new DOMParser(); + const doc = parser.parseFromString(htmlString, "text/html"); + + const bodyContent = doc.body.innerHTML.trim(); + + return `
${bodyContent
+ .replace(//g, ">")}`;
};
const content = watch("htmlBody");
const generatedPage = useCallback(() => {
- const sanitizedContent = DOMPurify.sanitize(getValues("htmlBody"));
+ const sanitizedContent = DOMPurify.sanitize(content);
+ const textArea = document.createElement("textarea");
+ textArea.innerHTML = sanitizedContent;
+
return (