Skip to content

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

fix: improve code block & checklist styling

thecodrr7e98162ac5ed
diff --git a/apps/web/src/components/editor/editor.css b/apps/web/src/components/editor/editor.css
index fb4491076..5ef22352f 100644
--- a/apps/web/src/components/editor/editor.css
+++ b/apps/web/src/components/editor/editor.css
@@ -83,7 +83,11 @@ tox-tbtn tox-tbtn--select {
margin-top: 1em !important;
}
-.mce-content-body *::before {
+.mce-content-body h2::before,
+h3::before,
+h4::before,
+h5::before,
+h6::before {
font-size: 12px;
font-weight: normal;
color: var(--fontTertiary);
@@ -119,3 +123,40 @@ tox-tbtn tox-tbtn--select {
.h {
display: none;
}
+
+.mce-content-body pre.codeblock > code {
+ font-family: inherit;
+ background-color: transparent !important;
+ border: none;
+ color: inherit;
+}
+
+pre.codeblock {
+ color: #24292e;
+ background-color: #f6f8fa;
+ line-height: 1.2;
+ padding: 15px;
+ border: 1px solid var(--border);
+ border-radius: 5px;
+}
+
+.mce-content-body code[data-mce-selected="inline-boundary"] {
+ background-color: rgb(27 31 35 / 5%);
+}
+
+.mce-content-body code {
+ background-color: rgb(27 31 35 / 5%);
+ font-size: 14px;
+ border: 1px solid var(--border);
+ border-radius: 5px;
+}
+
+.mce-content-body pre.codeblock > code[data-mce-selected="inline-boundary"] {
+ background-color: transparent !important;
+}
+
+code,
+pre {
+ font-family: ui-monospace, SFMono-Regular, SF Mono, Consolas, Liberation Mono,
+ Menlo, monospace;
+}
diff --git a/apps/web/src/components/editor/plugins/code/plugin.js b/apps/web/src/components/editor/plugins/code/plugin.js
index 44bdab2f4..dd08ee74d 100644
--- a/apps/web/src/components/editor/plugins/code/plugin.js
+++ b/apps/web/src/components/editor/plugins/code/plugin.js
@@ -16,7 +16,11 @@ import tinymce from "tinymce/tinymce";
if (innerText.length <= 0) {
replaceContent(
editor,
- (html) => `<p>${html.replace(/\n/gm, "<br>")}</p>`
+ (html) =>
+ `<p><code class='codeblock'>${html.replace(
+ /\n/gm,
+ "<br>"
+ )}</code></p>`
);
} else {
editor.execCommand("mceInsertNewLine", false, { shiftKey: true });
@@ -31,7 +35,7 @@ import tinymce from "tinymce/tinymce";
editor.execCommand(
"mceInsertContent",
false,
- `<pre class='codeblock'>${content}</pre>`
+ `<pre class='codeblock'><code>${content}</code></pre>`
);
});
editor.selection.setRng(rng);
@@ -40,7 +44,10 @@ import tinymce from "tinymce/tinymce";
replaceContent(
editor,
(html) =>
- `<pre class='codeblock'>${html.replace(/\n/gm, "<br>")}</pre>`
+ `<pre class='codeblock'><code>${html.replace(
+ /\n/gm,
+ "<br>"
+ )}</code></pre>`
);
}
}