Skip to content

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

fix: disable md shortcuts in a codeblock (fixes streetwriters/notesnook#129)

thecodrre7f785922ae3
diff --git a/apps/web/patches/tinymce+5.10.2.patch b/apps/web/patches/tinymce+5.10.2.patch
index 380fe7ca2..90317f186 100644
--- a/apps/web/patches/tinymce+5.10.2.patch
+++ b/apps/web/patches/tinymce+5.10.2.patch
@@ -31,3 +31,45 @@ index e41249b..fb25fc5 100644
];
var handle$1 = function (event, editor, cellSelection) {
if (event.keyCode === global$1.TAB) {
+diff --git a/node_modules/tinymce/plugins/textpattern/plugin.js b/node_modules/tinymce/plugins/textpattern/plugin.js
+index 987d753..4c33998 100644
+--- a/node_modules/tinymce/plugins/textpattern/plugin.js
++++ b/node_modules/tinymce/plugins/textpattern/plugin.js
+@@ -1330,6 +1330,12 @@
+ });
+ };
+
++ var isCodeblock = function (editor) {
++ const node = editor.selection.getNode();
++ if (!node)return false;
++ return !!node.closest("pre");
++ }
++
+ var setup = function (editor, patternsState) {
+ var charCodes = [
+ ',',
+@@ -1341,6 +1347,8 @@
+ ];
+ var keyCodes = [32];
+ editor.on('keydown', function (e) {
++ if (isCodeblock(editor)) return;
++
+ if (e.keyCode === 13 && !global$3.modifierPressed(e)) {
+ if (handleEnter(editor, patternsState.get())) {
+ e.preventDefault();
+@@ -1348,11 +1356,15 @@
+ }
+ }, true);
+ editor.on('keyup', function (e) {
++ if (isCodeblock(editor)) return;
++
+ if (checkKeyCode(keyCodes, e)) {
+ handleInlineKey(editor, patternsState.get());
+ }
+ });
+ editor.on('keypress', function (e) {
++ if (isCodeblock(editor)) return;
++
+ if (checkCharCode(charCodes, e)) {
+ global$4.setEditorTimeout(editor, function () {
+ handleInlineKey(editor, patternsState.get());