Skip to content

Commit 0054280

Browse files
committed
fix: improve HTML content validation in TaskModal
- Enhanced the isEmptyQuill function to treat images as non-empty content. - Updated logic to replace common HTML entities and remove all tags before checking for remaining text. - Ensured whitespace is collapsed correctly to improve content validation accuracy.
1 parent 2d1ade1 commit 0054280

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

frontend/src/components/TaskModal.tsx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -364,17 +364,19 @@ export default function TaskModal({
364364

365365
function isEmptyQuill(html?: string | null) {
366366
if (!html) return true;
367-
// replace   and other common entities
367+
368+
// jika ada <img ...> treat as non-empty
369+
if (/<img[\s\S]*src=/.test(String(html))) return false;
370+
371+
// replace common html entities
368372
let s = String(html)
369373
.replace(/&nbsp;/g, " ")
370374
.replace(/&amp;/g, "&")
371375
.replace(/&lt;/g, "<")
372376
.replace(/&gt;/g, ">");
373377

374-
// remove all HTML tags
378+
// remove all tags and test remaining text
375379
s = s.replace(/<[^>]*>/g, "");
376-
377-
// collapse whitespace
378380
s = s.replace(/\s+/g, "");
379381

380382
return s.length === 0;

0 commit comments

Comments
 (0)