Skip to content

Commit

Permalink
Merge pull request #109 from CanopyTax/placeholder-fix
Browse files Browse the repository at this point in the history
Only update placeholder style if stylesheet is found
  • Loading branch information
parkm authored Mar 23, 2022
2 parents 95c7392 + 4d41659 commit d4feea2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "bandicoot",
"version": "4.5.1",
"version": "4.5.2",
"description": "React rich text editor",
"main": "dist/bandicoot.umd.js",
"module": "dist/bandicoot.esm.js",
Expand Down
10 changes: 6 additions & 4 deletions src/rich-text-editor.component.js
Original file line number Diff line number Diff line change
Expand Up @@ -160,10 +160,12 @@ export const RichTextEditor = forwardRef((props, editorRef) => {
document.head.appendChild(styleElement)

const styleSheet = Array.prototype.slice.call(document.styleSheets).find(s => s.ownerNode === styleElement)
const styleDeclaration = styleSheet.cssRules[0].style
const styles = props.placeholderStyle ? props.placeholderStyle : getDefaultPlaceholderStyles()
for (let propName in styles) {
styleDeclaration[propName] = props.placeholderStyle ? props.placeholderStyle[propName] : styles[propName]
if (styleSheet) {
const styleDeclaration = styleSheet.cssRules[0].style
const styles = props.placeholderStyle ? props.placeholderStyle : getDefaultPlaceholderStyles()
for (let propName in styles) {
styleDeclaration[propName] = props.placeholderStyle ? props.placeholderStyle[propName] : styles[propName]
}
}

return () => styleElement.parentNode.removeChild(styleElement)
Expand Down

0 comments on commit d4feea2

Please sign in to comment.