From 271c543579fe5a399d7adf1743de885cfd2332db Mon Sep 17 00:00:00 2001 From: sairaj mote Date: Wed, 30 Mar 2022 16:04:58 +0530 Subject: [PATCH] fixed bug that wouldn't allow submitting only text formatted content --- index.html | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/index.html b/index.html index e2cb7f4..a5c361f 100644 --- a/index.html +++ b/index.html @@ -1483,9 +1483,12 @@ currentElement.remove() } }) + + let activeEntry getRef('article_wrapper').addEventListener("focusin", e => { if (e.target.closest('.content__area')) { const target = e.target.closest('.content__area') + activeEntry = target.closest('.content-card') document.addEventListener('selectionchange', detectFormatting) if (target.childNodes[0] === undefined) { target.innerHTML = `


` @@ -1508,6 +1511,7 @@ if (!e.relatedTarget?.closest('#text_toolbar')) { getRef('text_toolbar').classList.add('hide-completely') childObserver.disconnect() + activeEntry = undefined } } }) @@ -1527,6 +1531,7 @@ document.execCommand("defaultParagraphSeparator", false, "p"); function formatDoc(sCmd, sValue) { document.execCommand(sCmd, false, sValue); + checkEntry() } function incScore(value) { let currentScore = parseFloat(getRef('update_score_field').value) @@ -1796,11 +1801,11 @@ } const checkEntry = debounce(e => { - const contentCard = e.target.closest('.content-card') + const contentCard = activeEntry const contentArea = contentCard.querySelector('.content__area') const uid = contentCard.dataset.uid const isUniqueEntry = contentArea.dataset.type === 'origin' - if (contentArea.textContent.trim() === '') { + if (contentArea.innerText.trim() === '') { contentCard.querySelector('.submit-entry').classList.add('hide-completely') } else { const cleanHTML = DOMPurify.sanitize(contentArea.innerHTML.split('\n').map(v => v.trim()).filter(v => v).join('\n'), { FORBID_ATTR: ['style'], ADD_ATTR: ['target'] })