From 52dd6e0e64d82530b24a06b367af0066fd937d24 Mon Sep 17 00:00:00 2001 From: Markus Machatschek Date: Mon, 31 May 2021 19:05:46 +0200 Subject: [PATCH] Prevent tiptap from creating duplicate style tags when injecting css --- packages/core/src/utilities/createStyleTag.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/packages/core/src/utilities/createStyleTag.ts b/packages/core/src/utilities/createStyleTag.ts index b90780343..2d40aedc6 100644 --- a/packages/core/src/utilities/createStyleTag.ts +++ b/packages/core/src/utilities/createStyleTag.ts @@ -1,6 +1,13 @@ export default function createStyleTag(style: string): HTMLStyleElement { + const tipTapStyleTag = (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)