Skip to content

Commit

Permalink
Prevent tiptap from creating duplicate style tags when injecting css
Browse files Browse the repository at this point in the history
  • Loading branch information
mmachatschek committed May 31, 2021
1 parent 71221f5 commit 52dd6e0
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions packages/core/src/utilities/createStyleTag.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
export default function createStyleTag(style: string): HTMLStyleElement {
const tipTapStyleTag = (<HTMLStyleElement>document.querySelector('style[data-tiptap-style]'))

if (tipTapStyleTag !== null) {
return tipTapStyleTag
}

const styleNode = document.createElement('style')

styleNode.setAttribute('data-tiptap-style', '');
styleNode.innerHTML = style
document.getElementsByTagName('head')[0].appendChild(styleNode)

Expand Down

0 comments on commit 52dd6e0

Please sign in to comment.