Skip to content

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

feat: reenable code-blocks in md

thecodrr7afce174df59
diff --git a/apps/web/src/components/editor/modules/markdown/index.js b/apps/web/src/components/editor/modules/markdown/index.js
index 2157e9f0b..e8efecd10 100644
--- a/apps/web/src/components/editor/modules/markdown/index.js
+++ b/apps/web/src/components/editor/modules/markdown/index.js
@@ -63,6 +63,17 @@ class MarkdownShortcuts {
}, 0);
}
},
+ {
+ name: "code-block",
+ pattern: /^`{3}(?:\s|\n)/g,
+ action: (text, selection) => {
+ // Need to defer this action https://github.com/quilljs/quill/issues/1134
+ setTimeout(() => {
+ this.quill.formatLine(selection.index, 1, "code-block", true);
+ this.quill.deleteText(selection.index - 4, 4);
+ }, 0);
+ }
+ },
{
name: "bolditalic",
pattern: /(?:\*|_){3}(.+?)(?:\*|_){3}/g,
@@ -142,7 +153,7 @@ class MarkdownShortcuts {
}, 0);
}
},
- /* {
+ {
name: "code",
pattern: /(?:`)(.+?)(?:`)/g,
action: (text, selection, pattern, lineStart) => {
@@ -161,7 +172,7 @@ class MarkdownShortcuts {
this.quill.insertText(this.quill.getSelection(), " ");
}, 0);
}
- }, */
+ },
{
name: "hr",
pattern: /^([-*]\s?){3}/g,