Skip to content

Commit

Permalink
Only update placeholder style if stylesheet is found
Browse files Browse the repository at this point in the history
v4.5.2
  • Loading branch information
parkm committed Mar 23, 2022
1 parent 95c7392 commit 4d41659
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 4d41659

Please sign in to comment.