update
This commit is contained in:
parent
5827fdb1e4
commit
b5f96d53ed
|
|
@ -313,6 +313,23 @@ export default function DetailContent() {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function decodeHtmlString(raw: string = "") {
|
||||||
|
if (!raw) return "";
|
||||||
|
|
||||||
|
// 1️⃣ Hapus newline escape, backslash, dsb
|
||||||
|
let decoded = raw
|
||||||
|
.replace(/\\n/g, "\n")
|
||||||
|
.replace(/\\"/g, '"') // ubah \" jadi "
|
||||||
|
.replace(/\\'/g, "'") // ubah \' jadi '
|
||||||
|
.replace(/\\\\/g, "\\") // ubah \\ jadi \
|
||||||
|
.trim();
|
||||||
|
|
||||||
|
// 2️⃣ Decode entity HTML (misal ")
|
||||||
|
const el = document.createElement("textarea");
|
||||||
|
el.innerHTML = decoded;
|
||||||
|
return el.value;
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<div className="bg-white grid grid-cols-1 md:grid-cols-3 gap-6 px-8 py-8">
|
<div className="bg-white grid grid-cols-1 md:grid-cols-3 gap-6 px-8 py-8">
|
||||||
|
|
@ -472,7 +489,9 @@ export default function DetailContent() {
|
||||||
<div className="text-gray-700 leading-relaxed text-justify">
|
<div className="text-gray-700 leading-relaxed text-justify">
|
||||||
<div
|
<div
|
||||||
dangerouslySetInnerHTML={{
|
dangerouslySetInnerHTML={{
|
||||||
__html: articleDetail?.htmlDescription || "",
|
__html: decodeHtmlString(
|
||||||
|
articleDetail?.htmlDescription || ""
|
||||||
|
),
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -193,7 +193,13 @@ export default function EditArticleForm(props: { isDetail: boolean }) {
|
||||||
setValue("customCreatorName", data?.customCreatorName);
|
setValue("customCreatorName", data?.customCreatorName);
|
||||||
setValue("slug", data?.slug);
|
setValue("slug", data?.slug);
|
||||||
setValue("source", data?.source);
|
setValue("source", data?.source);
|
||||||
setValue("description", data?.htmlDescription);
|
const cleanDescription = data?.htmlDescription
|
||||||
|
? data.htmlDescription
|
||||||
|
.replace(/\\"/g, '"')
|
||||||
|
.replace(/\\n/g, "\n", "\\") // ubah newline escaped
|
||||||
|
.trim()
|
||||||
|
: "";
|
||||||
|
setValue("description", cleanDescription);
|
||||||
setValue("tags", data?.tags ? data.tags.split(",") : []);
|
setValue("tags", data?.tags ? data.tags.split(",") : []);
|
||||||
setThumbnail(data?.thumbnailUrl);
|
setThumbnail(data?.thumbnailUrl);
|
||||||
setDiseId(data?.aiArticleId);
|
setDiseId(data?.aiArticleId);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue