Style a line containng only "#" as if it were to become a tag instead of a header

pull/925/head
Zef Hemel 2024-07-07 10:32:13 +02:00
parent 4fa58aaafd
commit 7ddd7c4011
2 changed files with 22 additions and 0 deletions

View File

@ -92,6 +92,17 @@ export function hideHeaderMarkPlugin() {
}
// Get the active line
const line = state.sliceDoc(from, to);
if (line === "#") {
// Empty header, potentially a tag, style it as such
widgets.push(
Decoration.mark({
tagName: "span",
class: "sb-hashtag",
}).range(from, from + 1),
);
return;
}
if (isCursorInRange(state, [from, to])) {
widgets.push(
Decoration.line({ class: "sb-header-inside" }).range(from),

View File

@ -50,6 +50,17 @@
font-size: 1em;
}
// If a header only contains a tag, it's likely a line containging "#" which may turn into a hashtag, so style it as such instead of a header
.sb-line-h1:has(> span.sb-hashtag:only-child) {
font-size: 1em;
padding: 0;
font-weight: normal;
.sb-meta {
color: var(--editor-hashtag-color);
}
}
.sb-inline-img {
max-width: 100%;
}