Skip to content

Commit

Permalink
Merge pull request #1399 from mmachatschek/issue/fix-duplicate-style-…
Browse files Browse the repository at this point in the history
…tags

Prevent tiptap from creating duplicate style tags when injecting css
  • Loading branch information
philippkuehn authored May 31, 2021
2 parents 71221f5 + 52dd6e0 commit 4175838
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 4175838

Please sign in to comment.