fixed bug that wouldn't allow submitting only text formatted content
This commit is contained in:
parent
fba92592aa
commit
271c543579
@ -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 = `<p><br/></p>`
|
||||
@ -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'] })
|
||||
|
||||
Loading…
Reference in New Issue
Block a user