Skip to content

Instantly share code, notes, and snippets.

@pickleat
Created May 22, 2020 00:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pickleat/0474d89b4df1f0632992f541c44129b5 to your computer and use it in GitHub Desktop.
Save pickleat/0474d89b4df1f0632992f541c44129b5 to your computer and use it in GitHub Desktop.
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