Prevent tiptap from creating duplicate style tags when injecting css

This commit is contained in:
Markus Machatschek 2021-05-31 19:05:46 +02:00
parent 71221f54d1
commit 52dd6e0e64

View File

@ -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)