Skip to content

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

feat: add code highlighting in quilljs

thecodrr0b60f2b9a6a1
diff --git a/apps/web/public/index.html b/apps/web/public/index.html
index c240d2ca8..42ad1094b 100644
--- a/apps/web/public/index.html
+++ b/apps/web/public/index.html
@@ -9,6 +9,10 @@
name="description"
content="Web site created using create-react-app"
/>
+ <link
+ rel="stylesheet"
+ href="https://cdn.jsdelivr.net/npm/[email protected]/styles/monokai.css"
+ />
<link rel="apple-touch-icon" href="logo192.png" />
<!--
manifest.json provides metadata used when your web app is installed on a
@@ -39,5 +43,9 @@
To begin the development, run `npm start` or `yarn start`.
To create a production bundle, use `npm run build` or `yarn build`.
-->
+ <script
+ async="true"
+ src="https://cdn.jsdelivr.net/npm/[email protected]/highlight.pack.min.js"
+ ></script>
</body>
</html>
diff --git a/apps/web/src/components/editor/index.js b/apps/web/src/components/editor/index.js
index b698e0676..d485ffbb9 100644
--- a/apps/web/src/components/editor/index.js
+++ b/apps/web/src/components/editor/index.js
@@ -37,6 +37,7 @@ const modules = {
["link", "image", "video"],
[{ direction: "rtl" }, "clean"]
],
+ syntax: true,
markdownShortcuts: {},
magicUrl: true
};
diff --git a/apps/web/src/components/editor/modules/markdown/index.js b/apps/web/src/components/editor/modules/markdown/index.js
index e8efecd10..2157e9f0b 100644
--- a/apps/web/src/components/editor/modules/markdown/index.js
+++ b/apps/web/src/components/editor/modules/markdown/index.js
@@ -63,17 +63,6 @@ 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,
@@ -153,7 +142,7 @@ class MarkdownShortcuts {
}, 0);
}
},
- {
+ /* {
name: "code",
pattern: /(?:`)(.+?)(?:`)/g,
action: (text, selection, pattern, lineStart) => {
@@ -172,7 +161,7 @@ class MarkdownShortcuts {
this.quill.insertText(this.quill.getSelection(), " ");
}, 0);
}
- },
+ }, */
{
name: "hr",
pattern: /^([-*]\s?){3}/g,