feat: ckeditor in article form

This commit is contained in:
hanif salafi 2025-01-21 00:04:10 +07:00
parent f3febf88c3
commit 082ee41058
3 changed files with 47 additions and 23 deletions

View File

@ -29,12 +29,12 @@ import { useRouter } from "next/navigation";
import Link from "next/link";
import { getCategoryById } from "@/service/master-categories";
// const CustomEditor = dynamic(
// () => {
// return import("@/components/editor/custom-editor");
// },
// { ssr: false }
// );
const CustomEditor = dynamic(
() => {
return import("@/components/editor/custom-editor");
},
{ ssr: false }
);
interface FileWithPreview extends File {
preview: string;
@ -405,12 +405,17 @@ export default function CreateArticleForm() {
name="description"
render={({ field: { onChange, value } }) => (
// <CustomEditor onChange={onChange} initialData={value} />
<JoditEditor
ref={editor}
value={value}
// <JoditEditor
// ref={editor}
// value={value}
// onChange={onChange}
// className="dark:text-black"
// />
<CustomEditor
onChange={onChange}
className="dark:text-black"
initialData={value}
/>
)}
/>
{errors?.description && (

View File

@ -33,12 +33,18 @@ import GetSeoScore from "./get-seo-score-form";
import Link from "next/link";
import { stringify } from "querystring";
// const CustomEditor = dynamic(
// () => {
// return import("@/components/editor/custom-editor");
// },
// { ssr: false }
// );
const ViewEditor = dynamic(
() => {
return import("@/components/editor/view-editor");
},
{ ssr: false }
);
const CustomEditor = dynamic(
() => {
return import("@/components/editor/custom-editor");
},
{ ssr: false }
);
interface FileWithPreview extends File {
preview: string;
@ -413,13 +419,22 @@ export default function EditArticleForm(props: { isDetail: boolean }) {
name="description"
render={({ field: { onChange, value } }) => (
// <CustomEditor onChange={onChange} initialData={value} />
<JoditEditor
ref={editor}
value={value}
onChange={onChange}
config={{ readonly: isDetail }}
className="dark:text-black"
/>
// <JoditEditor
// ref={editor}
// value={value}
// onChange={onChange}
// config={{ readonly: isDetail }}
// className="dark:text-black"
// />
isDetail ?
<ViewEditor
initialData={value}
/>
:
<CustomEditor
onChange={onChange}
initialData={value}
/>
)}
/>
{errors?.description && (

View File

@ -28,6 +28,10 @@
display: none;
}
.ck-editor__editable_inline {
min-height: 200px;
}
.sidebar-scrollbar {
--scroll-shadow-size: 40px;
}