Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Inelegant Formatting Solution
useEffect(() => {
// Cleans up the text provided by QuillJS wysiwyg
function styleChildren(children) {
children.forEach((child) => {
if (child.tagName === 'H1') {
child.classList = quillStyle.h1
}
if (child.tagName === 'H2') {
child.classList = quillStyle.h2
}
if (child.tagName === 'H3') {
child.classList = quillStyle.h3
}
if (child.tagName === 'P') {
child.classList = quillStyle.p
}
if (child.tagName === 'A') {
child.classList = quillStyle.a
}
if (child.tagName === 'OL') {
child.classList = quillStyle.ol
let listItems = [...child.children]
listItems.forEach((listItem) => {
listItem.classList = quillStyle.li
})
}
if (child.tagName === 'UL') {
child.classList = quillStyle.ul
let listItems = [...child.children]
listItems.forEach((listItem) => {
listItem.classList = quillStyle.li
})
}
if (child.tagName === 'LI') {
child.classList = quillStyle.li
}
})
}
var jobDesc = document.getElementById('jobDesc')
var jobChildren = [...jobDesc.children]
styleChildren(jobChildren)
// removed other code that doesn't apply to this post...
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.