Skip to content

A fully open source & end-to-end encrypted note taking alternative to Evernote.

fix: strip down pasted code blocks

thecodrre7d1d55a5792
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 (