Files
plainleaf/web/styles/editor.scss
T
aa0b95b31d The one about refs (#1496)
* [Major] Introduce a new `Ref` and `Path` type

This introduces a new `Ref` and `Path` type, which try to be as lightweight and rigorous as possible. More description in the PR

* [Minor] Updated Syntax

* [Minor] Updated Type

* [Minor] Renamed file

* [Minor] Updated type

* [Minor] Updated Syntax

* [Major] Rename css classes for wiki links

Previously all the parts of a wiki link were tagged with `sb-wiki-link-page`. This didn't make a whole lot of sense. Also the tag `sb-wiki-link` was could never render, because of the way `HighlightStyle` works. Now every part of a wiki link will be tagged with `sb-wiki-link` (i.e. the link, the alias, the dimensions). Invalid and missing links will be styled separately in a later commit.

* [Minor] Adjust to new API

* [Minor] Small changes

* [Minor] Function and file renames

* [Major] Syscall adjusments

Change behavior of `getCurrentPath` to actually return what's now considered a `Path`. `getCurrentPage(Meta)` now also correctly returns for documents. We could consider a rename to get rid of the `page` association

* [Major] Rework `Client`

Mostly minor adjustments for the new API. Some major changes in `navigateWithinPage` and some unecessary checks removed now

* [Major] Errors on navigate

This now throws an error when the user tries to navigate to a link that is invalid

* [Major] Minor adjustments and remove some old bulk

This does the typicall adjustments to the new API. A thing to consider is that invalid links aren't indexed. Also removed old code about template and query stuff. And reused a regex instead of copy pasting it.

* [Minor] Cleanup editor ui

* [Minor] Adjust to new API

* [Minor] Adjust to new API and reduce ugly regex

* [Minor] New API

* [Minor] Rework link cm plugin

* [Major] Rework wiki links

A lot of code cleanup, reworked for new APIs and also introduces "invalid links"

* [Minor] Part of the editor ui rework

* [Major] Adjust to new API

This also removes the `looksLikePathWithExtension` check. I don't think it was necessary.

* [Minor] PArt of editor ui rewrite

* [Minor] Adjust to new API

* [Major] Adjust renderer to new API

Invalid links now link to `#`

* [Major] Rewrite navigator

This still needs major rework, currently in a "got it working" state

* [Minor] Adjust file name

* [Minor] Mistake during rebase

* [Minor] Navigate to end of header

* [Minor] Remove `tweakEditorDOM` and use proper CM extensions

* [Major] Heavily clean up the navigation code

* [Minor] Make `PageNavigator` closable again

* [Minor] Small fixes to reduce errors bubbling up

* [Minor] Show error message if navigate fails

* [Major] Remove legacy `navigate({ kind = ` syntax

This removes the old navigation syntax. It's still supported but the user will be warned then using it. I also added some validation to editor.navigate for user provided refs.

* [Minor] Make notifications errors

* [Minor] Don't fail if header isn't found

* [Minor] Typo

* [Major] Remove cleanPageRef

* [Minor] Small bug

* [Minor] Align behavior between render and editor

* [Major] Remove `PageRef`. Pretty sure it's obsolete

* [Major] Remove pos from header as it's an invalid ref

* [Minor] Align with original behavior

* [Minor] Get tests working again

* [Minor] check that indexPage is valid

* [Major] Rewrite `resolve.ts` file

* [Minor] More tests, more fixes

* [Minor] Don't just append .md this is weird

* [Minor] More edge cases

* [Minor] Version bumping hono somehow fixes the `/` case

* [Minor] Smaller TODOs

* [Major] We can be a littler looser on the restrictions

* [Major] Change header indexing, to index with pos

* [Minor] More fixes for headers

* [Minor] Rename for clarity

* [Minor] Change more regexes to named groups

* [Major] Inline content rewrite

* [Minor] Fix TODO

* [Minor] Bump index version

* [Major] New Space Primitive to check paths

* [Minor] Fix #1214

* [Minor] Fix #1169

* [Minor] Remove TODO

This check is probably not needed anymore. Unsure. May look into it later

* [Minor] small bug

* [Minor] Not a good rebase without me needing to fix it afterwards

* [Minor] Improve fallback for file upload

* [Minor] Some fixes on the for resolving

* [Minor] Removed doubled test case

* [Minor] Resolve #860

* [Minor] Turn flash notification into an error

* [Minor] Change handling of `.` paths

* [Minor] Show empty URL for index page

* [Minor] Push correct ref to history

* [Major] Capture mini editor events in capture phase

This fixes the issue were when pressing arrowup or arrowdown changed the cursor position inside the editor

* [Major] Add prefix to `FilterList`

This now fixes issues were if you had a prefixed page you  con't properly search for it, because the search considered the prefix as part of the name

* [Minor] A little rigor for empty headers

* [Major] Fix #1404

* [Minor] `parseInt` returns `NaN` handle that

* [Minor] Use `fileName`

* [Minor] Fix comment

* [Minor] Fixes

* [Major] disallow `foo.png.md` and `/../`, etc. cases

* [Major] Change name of conflicted pages

* [Minor] Remove unecessary check

* [Minor] Remove some split code

* [Minor] Allow deletion of invalid files

* [Minor] Bug in the regex

* [Minor] Give some possibility of fixing incorrect names

* [Minor] Tiny bug with header completion

* [Major] Docs

* [Minor] Ignore errors for navigation inside of a page

This could be a problem when SB e.g. cached a scrollTop for a page, which, because e.g. the file is now deleted, doesn't exist anymore and thus CM throws an error, when trying to navigate

* Update conflicted copy regex in Maintenance.md

---------

Co-authored-by: Zef Hemel <zef@zef.me>
2025-08-24 16:16:19 +02:00

716 lines
13 KiB
SCSS

.cm-focused {
outline: none !important;
}
#sb-main .cm-editor {
font-size: 18px;
height: 100%;
.cm-content {
width: 100%;
margin-left: auto;
margin-right: auto;
max-width: var(--#{"editor-width"});
padding: 5px 20px;
}
.cm-line {
padding: 0;
&.sb-line-h1,
&.sb-line-h2,
&.sb-line-h3,
&.sb-line-h4,
&.sb-line-h5,
&.sb-line-h6 {
font-weight: bold;
padding: 2px;
}
}
.cm-line:has(.sb-directive) {
background-color: var(--editor-directive-background-color);
}
.sb-line-h1,
h1 {
font-size: 1.5em;
}
.sb-line-h2,
h2 {
font-size: 1.2em;
}
.sb-line-h3,
h3 {
font-size: 1.1em;
}
.sb-line-h4,
h4,
.sb-line-h5,
h5,
.sb-line-h6,
h6 {
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(> a.sb-hashtag:only-child) {
font-size: 1em;
padding: 0;
font-weight: normal;
.sb-meta {
color: var(--editor-hashtag-color);
}
}
.cm-panels-bottom .cm-vim-panel {
padding: 0 20px;
max-width: var(--editor-width);
margin: auto;
font-family: var(--editor-font);
height: 1.5em;
line-height: 1.5em;
input {
font-family: var(--editor-font);
font-size: 1em;
}
}
// Gutter styling
.cm-gutters {
background-color: transparent;
border-right: none;
}
.cm-foldPlaceholder {
background-color: transparent;
border: 0;
}
// Indentation of follow-up lines
@mixin lineOverflow($baseIndent, $bulletIndent: 0) {
text-indent: calc(-1 * (#{$baseIndent}ch + 2ch));
padding-left: calc(#{$baseIndent}ch + 2ch);
&.sb-line-task {
text-indent: calc(-1 * (#{$baseIndent}ch + 5ch));
padding-left: calc(#{$baseIndent}ch + 5ch);
.cm-list-bullet::after {
left: calc(#{$baseIndent}ch + 5ch);
}
}
&.sb-line-blockquote {
text-indent: calc(-1 * (#{$baseIndent}ch + 4ch));
padding-left: calc(#{$baseIndent}ch + 4ch);
}
.cm-list-bullet::after {
left: calc(#{$baseIndent}ch + #{$bulletIndent}ch + 2ch);
}
}
.sb-line-ul {
&.sb-line-li-1 {
@include lineOverflow(0);
}
&.sb-line-li-1.sb-line-li-2 {
@include lineOverflow(2);
}
&.sb-line-li-1.sb-line-li-2.sb-line-li-3 {
@include lineOverflow(4);
}
&.sb-line-li-1.sb-line-li-2.sb-line-li-3.sb-line-li-4 {
@include lineOverflow(6);
}
&.sb-line-li-1.sb-line-li-2.sb-line-li-3.sb-line-li-4.sb-line-li-5 {
@include lineOverflow(8);
}
}
.sb-line-ol {
&.sb-line-li-1 {
@include lineOverflow(1);
}
&.sb-line-li-1.sb-line-li-2 {
@include lineOverflow(4);
}
&.sb-line-li-1.sb-line-li-2.sb-line-li-3 {
@include lineOverflow(7);
}
&.sb-line-li-1.sb-line-li-2.sb-line-li-3.sb-line-li-4 {
@include lineOverflow(10);
}
&.sb-line-li-1.sb-line-li-2.sb-line-li-3.sb-line-li-4.sb-line-li-5 {
@include lineOverflow(13);
}
}
.sb-line-ol.sb-line-ul {
// &.sb-line-li-1 {
// @include lineOverflow(1);
// }
&.sb-line-li-1.sb-line-li-2 {
@include lineOverflow(3);
}
&.sb-line-li-1.sb-line-li-2.sb-line-li-3 {
@include lineOverflow(6);
}
&.sb-line-li-1.sb-line-li-2.sb-line-li-3.sb-line-li-4 {
@include lineOverflow(9);
}
&.sb-line-li-1.sb-line-li-2.sb-line-li-3.sb-line-li-4.sb-line-li-5 {
@include lineOverflow(12);
}
}
.sb-line-blockquote {
&.sb-line-li-1 {
@include lineOverflow(-1, 2);
}
&.sb-line-li-1.sb-line-li-2 {
@include lineOverflow(1, 2);
}
&.sb-line-li-1.sb-line-li-2.sb-line-li-3 {
@include lineOverflow(4);
}
&.sb-line-li-1.sb-line-li-2.sb-line-li-3.sb-line-li-4 {
@include lineOverflow(6);
}
&.sb-line-li-1.sb-line-li-2.sb-line-li-3.sb-line-li-4.sb-line-li-5 {
@include lineOverflow(8);
}
}
.sb-line-comment {
text-indent: -1 * 3ch;
padding-left: 3ch;
}
.cm-list-bullet {
position: relative;
visibility: hidden;
}
.cm-list-bullet::after {
visibility: visible;
position: absolute;
content: "\2022";
/* U+2022 BULLET */
}
.cm-task-checked,
.sb-line-task:has(.cm-task-checked) .sb-wiki-link {
text-decoration: line-through !important;
}
.cm-tooltip-autocomplete {
.cm-completionDetail {
font-style: normal;
display: block;
font-size: 80%;
margin-left: 5px;
}
.cm-completionLabel {
display: block;
margin-left: 5px;
}
.cm-completionIcon {
display: none;
}
}
.sb-header-inside.sb-line-h1 {
text-indent: -2ch;
}
.sb-header-inside.sb-line-h2 {
text-indent: -3ch;
}
.sb-header-inside.sb-line-h3 {
text-indent: -4ch;
}
.sb-header-inside.sb-line-h4 {
text-indent: -5ch;
}
.sb-header-inside.sb-line-h5 {
text-indent: -6ch;
}
.sb-header-inside.sb-line-h6 {
text-indent: -7ch;
}
.sb-checkbox > input[type="checkbox"] {
width: 3ch;
}
.sb-hashtag,
.hashtag {
border-radius: 6px;
padding: 0 3px;
margin: 0 1px 0 0;
font-size: 0.9em;
}
a.sb-hashtag {
text-decoration: none;
}
.sb-strikethrough {
text-decoration: line-through;
&.sb-meta {
text-decoration: none;
}
}
.sb-line-hr {
margin-top: 1em;
margin-bottom: -1em;
}
.sb-hr {
font-weight: bold;
}
.sb-naked-url {
cursor: pointer;
}
.sb-link:not(.sb-url) {
cursor: pointer;
}
.sb-link:not(.sb-meta, .sb-url) {
text-decoration: underline;
}
.sb-url:not(.sb-link) {
text-decoration: underline;
cursor: pointer;
}
.sb-wiki-link {
border-radius: 5px;
padding: 0 5px;
// white-space: nowrap;
text-decoration: none;
cursor: pointer;
}
.sb-lua-directive-inline {
display: inline;
padding: 2px;
}
.sb-lua-directive-block {
display: block;
margin: -1em 0;
}
.sb-widget-array {
display: flex;
flex-direction: column;
}
.sb-task-mark {
font-size: 91%;
}
.sb-task-state {
font-size: 91%;
}
.sb-task-deadline {
background-color: rgba(22, 22, 22, 0.07);
}
.sb-line-frontmatter-outside,
.sb-line-code-outside {
.sb-meta {
color: transparent;
}
color: transparent;
}
.sb-line-blockquote {
text-indent: -2ch;
}
.sb-blockquote-outside {
text-indent: -1ch;
min-height: 1em;
}
.sb-line-table-outside {
display: none;
}
.sb-line-tbl-header {
font-weight: bold;
}
.sb-line-tbl-header .meta {
font-weight: normal;
}
.sb-table-widget {
display: block;
font-weight: normal;
margin-bottom: -3rem;
overflow: auto;
}
table {
width: 100%;
border-spacing: 0;
}
thead tr {
font-weight: bold;
}
thead tr td {
// Primarily to make the column headers look reasonable with the button bar that may be put on top
padding: 11px 8px;
}
th,
td {
padding: 8px;
white-space: nowrap;
}
// Table alignment classes for justified tables
.sb-table-align-left {
text-align: left;
}
.sb-table-align-right {
text-align: right;
}
.sb-table-align-center {
text-align: center;
}
// dont apply background color twice for (fenced) code blocks
.sb-line-code .sb-code {
background-color: transparent;
}
.sb-line-code-outside .sb-code-info {
display: block;
float: right;
font-size: 90%;
padding-right: 7px;
}
.sb-code-copy-button {
float: right;
cursor: pointer;
margin: 0 3px;
}
.sb-code-copy-button > svg {
height: 1rem;
width: 1rem;
}
.sb-line-fenced-code .sb-code {
background-color: transparent;
}
.sb-line-fenced-code .sb-comment {
border-radius: 0;
font-style: inherit;
font-size: inherit;
line-height: inherit;
}
.sb-keyword {
font-weight: bold;
}
// Allow for cursor movement into a code widget fenced code block from bottom-up
.sb-fenced-code-hide {
background-color: transparent;
line-height: 0;
}
.sb-markdown-widget {
margin: 0 0 -4ch 0;
::selection {
background-color: var(--editor-selection-background-color) !important;
}
}
.sb-lua-top-widget,
.sb-lua-bottom-widget {
border: 1px solid var(--editor-widget-background-color);
border-radius: 5px;
white-space: normal;
position: relative;
min-height: 48px;
}
.sb-lua-top-widget {
margin: 0 0 10px 0;
}
.sb-lua-bottom-widget {
margin: 10px 0 0 0;
}
.sb-lua-top-widget h1,
.sb-lua-bottom-widget h1 {
margin: -10px -10px 10px -10px !important;
padding: 15px 10px !important;
background-color: var(--editor-widget-background-color);
font-size: 1.2em;
}
.sb-markdown-top-widget h1,
.sb-markdown-bottom-widget h1 {
margin: 0 0 5px 0;
padding: 10px !important;
background-color: var(--editor-widget-background-color);
font-size: 1.2em;
}
.sb-markdown-top-widget:has(*) {
margin-bottom: 10px;
}
.sb-markdown-bottom-widget {
margin-top: 10px;
}
.sb-lua-top-widget .content,
.sb-lua-bottom-widget .content {
max-height: 500px;
padding: 10px;
}
.sb-lua-bottom-widget p strong {
display: block;
padding: 10px 12px;
background-color: var(--editor-widget-background-color);
border: 1px solid var(--editor-widget-background-color);
border-radius: 8px 8px 0 0;
font-weight: 600;
}
.sb-lua-bottom-widget blockquote {
margin: 0 5px;
padding: 12px;
border: 1px solid var(--editor-widget-background-color);
border-radius: 8px;
background-color: var(--editor-widget-background-color);
color: var(--editor-text-color);
border-top: 1px solid var(--editor-widget-background-color);
}
.sb-markdown-top-widget:has(*) .content {
max-height: 500px;
}
@media screen and (max-height: 1000px) {
.sb-markdown-top-widget:has(*) .content {
max-height: 300px;
}
}
.sb-markdown-widget,
.sb-lua-directive-block,
.sb-lua-directive-inline,
.sb-markdown-top-widget:has(*),
.sb-markdown-bottom-widget:has(*) {
border: 1px solid var(--editor-widget-background-color);
border-radius: 5px;
white-space: normal;
position: relative;
min-height: 48px;
.content {
overflow-y: auto;
}
ul,
ol {
margin-top: 0;
margin-bottom: 0;
}
ul {
list-style: none;
// padding-left: 1ch;
}
ul li::before {
content: "\2022";
/* Add content: \2022 is the CSS Code/unicode for a bullet */
color: var(--editor-list-bullet-color);
display: inline-block;
/* Needed to add space between the bullet and the text */
width: 1em;
/* Also needed for space (tweak if needed) */
margin-left: -1em;
}
h1,
h2,
h3,
h4,
h5 {
margin: 0;
}
a.wiki-link {
border-radius: 5px;
padding: 0 5px;
color: var(--editor-wiki-link-page-color);
background-color: var(--editor-wiki-link-page-background-color);
text-decoration: none;
}
span.task-deadline {
background-color: rgba(22, 22, 22, 0.07);
}
tt {
background-color: var(--editor-code-background-color);
}
// Only show the button bar on hover on non-touch devices
&:hover .button-bar {
display: block;
}
// Always show button bar on touch devices
@media (hover: none) and (pointer: coarse) {
.button-bar {
display: block !important;
}
}
.button-bar {
position: absolute;
right: 0;
top: 0;
display: none;
background: var(--editor-widget-background-color);
padding-inline: 3px;
padding: 4px 0;
border-radius: 0 0 0 5px;
button {
border: none;
background: none;
cursor: pointer;
color: var(--root-color);
margin-right: -8px;
padding: 11px 8px;
}
button:last-of-type {
margin-right: 2px;
}
}
}
.sb-inline-content > div > .content > * {
max-width: 100%;
display: block;
}
.sb-inline-content {
margin: 0;
overflow: hidden;
}
.sb-fenced-code-iframe {
background-color: transparent;
iframe {
border: 0;
width: 100%;
max-width: 100%;
padding: 0;
margin: 0 0 -2ch 0;
border: 1px solid var(--editor-widget-background-color);
border-radius: 5px;
}
}
.sb-line-blockquote.sb-line-ul.sb-line-li > .sb-quote.sb-meta:first-child {
margin-left: -1ch;
}
.sb-admonition {
border-left-width: 4px !important;
border-left-style: solid;
padding-left: 5px;
}
.sb-admonition-type::before {
content: "";
mask: var(--admonition-icon) no-repeat;
-webkit-mask: var(--admonition-icon) no-repeat;
mask-size: cover;
-webkit-mask-size: cover;
/* used in (custom) admonition definitions */
--admonition-width: 1.1em;
width: 0em;
height: 1.1em;
display: inline-flex;
vertical-align: middle;
}
.sb-frontmatter-marker {
float: right;
font-size: 80%;
padding-right: 7px;
}
.cm-scroller {
// Give some breathing space at the bottom of the screen
padding-bottom: 20em;
}
}
div:not(.cm-focused).cm-fat-cursor {
outline: none !important;
}