From 559b485ae4a4e5f1fdfe5b553e4f95cfe14699a0 Mon Sep 17 00:00:00 2001 From: Henry Heino Date: Tue, 20 Feb 2024 13:02:12 -0800 Subject: [PATCH 1/2] CodeMirror 6: Fix header token position and image fade-in --- src/style/focus.css | 9 +++++++-- src/style/stylish.css | 24 ++++++++++++++++-------- 2 files changed, 23 insertions(+), 10 deletions(-) diff --git a/src/style/focus.css b/src/style/focus.css index 1395643..75a62ae 100644 --- a/src/style/focus.css +++ b/src/style/focus.css @@ -1,12 +1,17 @@ -div.CodeMirror .CodeMirror-line, div.CodeMirror img { +div.CodeMirror .CodeMirror-line, +div.CodeMirror img, +div.cm-editor .cm-line { opacity: 0.4; color: var(--joplin-color) !important; transition: opacity 0.2s; } div.CodeMirror .CodeMirror-activeline .CodeMirror-line, +div.CodeMirror .CodeMirror-activeline img, + div.CodeMirror .CodeMirror-activeline.cm-line, -div.CodeMirror .CodeMirror-activeline img { +div.cm-editor .CodeMirror-activeline + .rich-markdown-resource.cm-line > img, +div.cm-editor .CodeMirror-activeline + .rich-markdown-resource.cm-line { opacity: 1.0; transition: opacity 0.4s; } diff --git a/src/style/stylish.css b/src/style/stylish.css index 06a5719..5d2cb0f 100644 --- a/src/style/stylish.css +++ b/src/style/stylish.css @@ -13,7 +13,8 @@ div.CodeMirror span.cm-hr { /* END Horizontal Rule*/ /* Blockquotes */ -pre.cm-rm-blockquote.CodeMirror-line { +pre.cm-rm-blockquote.CodeMirror-line, +pre.cm-rm-blockquote.cm-line { border-left: 4px solid var(--joplin-code-border-color); opacity: 0.7; } @@ -61,35 +62,42 @@ div.CodeMirror .cm-jn-code-block .cm-katex-marker-close { /* END Fade tokens*/ /* Headers */ -div.CodeMirror .cm-header.cm-rm-header-token:not(.cm-whitespace-a, .cm-whitespace-b) { +div.CodeMirror .cm-header.cm-rm-header-token:not(.cm-whitespace-a, .cm-whitespace-b), +div.cm-editor .cm-header > .cm-rm-header-token { font-family: monospace; font-size: 0.9em; /* Add some spacing for breathing room */ margin-right: 0.3ex; } -div.CodeMirror .cm-rm-header-token.cm-header-1:not(.cm-whitespace-a, .cm-whitespace-b) { +div.CodeMirror .cm-rm-header-token.cm-header-1:not(.cm-whitespace-a, .cm-whitespace-b), +div.cm-editor .cm-header.cm-h1 > .cm-rm-header-token { /* 1ex is the height of a lowercase x, it's an approximation for width */ /* We need 2ex to account for the space character */ margin-left: -2ex; } -div.CodeMirror .cm-rm-header-token.cm-header-2:not(.cm-whitespace-a, .cm-whitespace-b) { +div.CodeMirror .cm-rm-header-token.cm-header-2:not(.cm-whitespace-a, .cm-whitespace-b), +div.cm-editor .cm-header.cm-h2 > .cm-rm-header-token { margin-left: -3ex; } -div.CodeMirror .cm-rm-header-token.cm-header-3:not(.cm-whitespace-a, .cm-whitespace-b) { +div.CodeMirror .cm-rm-header-token.cm-header-3:not(.cm-whitespace-a, .cm-whitespace-b), +div.cm-editor .cm-header.cm-h3 > .cm-rm-header-token { margin-left: -4ex; } -div.CodeMirror .cm-rm-header-token.cm-header-4:not(.cm-whitespace-a, .cm-whitespace-b) { +div.CodeMirror .cm-rm-header-token.cm-header-4:not(.cm-whitespace-a, .cm-whitespace-b), +div.cm-editor .cm-header.cm-h4 > .cm-rm-header-token { margin-left: -5ex; } -div.CodeMirror .cm-rm-header-token.cm-header-5:not(.cm-whitespace-a, .cm-whitespace-b) { +div.CodeMirror .cm-rm-header-token.cm-header-5:not(.cm-whitespace-a, .cm-whitespace-b), +div.cm-editor .cm-header.cm-h5 > .cm-rm-header-token { margin-left: -6ex; } -div.CodeMirror .cm-rm-header-token.cm-header-6:not(.cm-whitespace-a, .cm-whitespace-b) { +div.CodeMirror .cm-rm-header-token.cm-header-6:not(.cm-whitespace-a, .cm-whitespace-b), +div.cm-editor .cm-header.cm-h6 > .cm-rm-header-token { margin-left: -7ex; } /* END Headers */ From 8f8e86659d5e028c5ee3b13dd98eb4e4696c38e2 Mon Sep 17 00:00:00 2001 From: Henry Heino Date: Tue, 20 Feb 2024 13:21:30 -0800 Subject: [PATCH 2/2] Adjust order of selectors --- src/style/focus.css | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/style/focus.css b/src/style/focus.css index 75a62ae..35e2fc5 100644 --- a/src/style/focus.css +++ b/src/style/focus.css @@ -1,6 +1,6 @@ div.CodeMirror .CodeMirror-line, -div.CodeMirror img, -div.cm-editor .cm-line { +div.cm-editor .cm-line, +div.CodeMirror img { opacity: 0.4; color: var(--joplin-color) !important; transition: opacity 0.2s; @@ -8,7 +8,6 @@ div.cm-editor .cm-line { div.CodeMirror .CodeMirror-activeline .CodeMirror-line, div.CodeMirror .CodeMirror-activeline img, - div.CodeMirror .CodeMirror-activeline.cm-line, div.cm-editor .CodeMirror-activeline + .rich-markdown-resource.cm-line > img, div.cm-editor .CodeMirror-activeline + .rich-markdown-resource.cm-line {