update
This commit is contained in:
parent
db08a8051a
commit
87e391a5bf
|
|
@ -310,6 +310,22 @@ export default function DetailContent() {
|
|||
// </div>
|
||||
// );
|
||||
// }
|
||||
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 (
|
||||
<>
|
||||
|
|
@ -492,7 +508,9 @@ export default function DetailContent() {
|
|||
<div className="prose max-w-none text-justify">
|
||||
<div
|
||||
dangerouslySetInnerHTML={{
|
||||
__html: articleDetail?.htmlDescription || "",
|
||||
__html: decodeHtmlString(
|
||||
articleDetail?.htmlDescription || ""
|
||||
),
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -193,7 +193,13 @@ export default function EditArticleForm(props: { isDetail: boolean }) {
|
|||
setValue("customCreatorName", data?.customCreatorName);
|
||||
setValue("slug", data?.slug);
|
||||
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(",") : []);
|
||||
setThumbnail(data?.thumbnailUrl);
|
||||
setDiseId(data?.aiArticleId);
|
||||
|
|
|
|||
Loading…
Reference in New Issue