mirror of
https://github.com/streetwriters/notesnook.git
synced 2025-12-23 15:09:33 +01:00
fix: disable md shortcuts in a codeblock
(fixes streetwriters/notesnook#129)
This commit is contained in:
@@ -31,3 +31,45 @@ index e41249b..fb25fc5 100644
|
|||||||
];
|
];
|
||||||
var handle$1 = function (event, editor, cellSelection) {
|
var handle$1 = function (event, editor, cellSelection) {
|
||||||
if (event.keyCode === global$1.TAB) {
|
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());
|
||||||
|
|||||||
Reference in New Issue
Block a user