From e7d1d55a5792e8bcc00d6da1975588df930500e0 Mon Sep 17 00:00:00 2001 From: thecodrr Date: Sat, 24 Jul 2021 11:28:40 +0500 Subject: [PATCH] fix: strip down pasted code blocks --- apps/web/src/components/editor/tinymce.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/apps/web/src/components/editor/tinymce.js b/apps/web/src/components/editor/tinymce.js index 3b190f87b..baf3b0455 100644 --- a/apps/web/src/components/editor/tinymce.js +++ b/apps/web/src/components/editor/tinymce.js @@ -209,7 +209,18 @@ function TinyMCE(props) { browser_spellcheck: true, inline: true, fixed_toolbar_container: "#editorToolbar", - autoresize_bottom_margin: 100, + paste_postprocess: function (_, args) { + const { node } = args; + if (node.childNodes) { + for (let childNode of node.childNodes) { + if (childNode.tagName === "PRE") { + childNode.className = "hljs"; + const code = childNode.textContent || childNode.innerText; + childNode.innerHTML = code; + } + } + } + }, }} onBeforeExecCommand={async (command) => { if (