Created
May 22, 2020 00:52
-
-
Save pickleat/0474d89b4df1f0632992f541c44129b5 to your computer and use it in GitHub Desktop.
Inelegant Formatting Solution
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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