Skip to content

Commit 0cd3340

Browse files
committed
feat(editor): soften show-spaces whitespace markers for better readability
1 parent b1bc17d commit 0cd3340

File tree

3 files changed

+39
-7
lines changed

3 files changed

+39
-7
lines changed

bun.lock

Lines changed: 8 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,8 +151,8 @@
151151
"cordova": "13.0.0",
152152
"core-js": "^3.47.0",
153153
"crypto-js": "^4.2.0",
154-
"dompurify": "^3.3.0",
155154
"dayjs": "^1.11.19",
155+
"dompurify": "^3.3.0",
156156
"escape-string-regexp": "^5.0.0",
157157
"esprima": "^4.0.1",
158158
"filesize": "^11.0.13",

src/lib/editorManager.js

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,31 @@ async function EditorManager($header, $body) {
296296
};
297297
}
298298

299+
function makeWhitespaceTheme() {
300+
return EditorView.theme({
301+
".cm-highlightSpace": {
302+
backgroundImage:
303+
"radial-gradient(circle at 50% 54%, var(--cm-space-marker-color) 0.08em, transparent 0.1em)",
304+
backgroundPosition: "center",
305+
backgroundRepeat: "no-repeat",
306+
opacity: "0.5",
307+
},
308+
".cm-highlightTab": {
309+
backgroundSize: "auto 70%",
310+
backgroundPosition: "right 60%",
311+
opacity: "0.65",
312+
},
313+
".cm-trailingSpace": {
314+
backgroundColor: "var(--cm-trailing-space-color)",
315+
borderRadius: "2px",
316+
},
317+
"&": {
318+
"--cm-space-marker-color": "rgba(127, 127, 127, 0.6)",
319+
"--cm-trailing-space-color": "rgba(255, 77, 77, 0.2)",
320+
},
321+
});
322+
}
323+
299324
// Centralised CodeMirror options registry for organized configuration
300325
// Each spec declares related settings keys, its compartment(s), and a builder returning extension(s)
301326
const cmOptionSpecs = [
@@ -365,7 +390,11 @@ async function EditorManager($header, $body) {
365390
build() {
366391
const show = !!appSettings?.value?.showSpaces;
367392
return show
368-
? [highlightWhitespace(), highlightTrailingWhitespace()]
393+
? [
394+
highlightWhitespace(),
395+
highlightTrailingWhitespace(),
396+
makeWhitespaceTheme(),
397+
]
369398
: [];
370399
},
371400
},

0 commit comments

Comments
 (0)