Files
plainleaf/client/styles/editor.scss
T

885 lines
18 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;
// Vertical breathing room above/below the heading without indenting
// the heading text away from the body column.
padding: 2px 0;
}
}
.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;
}
.sb-external-gutter .cm-gutterElement {
padding: 0 3px;
}
.sb-external-delete-marker {
display: block;
margin: 0 auto;
width: 4px;
height: 4px;
border-radius: 50%;
background-color: var(--editor-external-caret-color);
}
.sb-external-edit {
background-color: var(--editor-external-edit-color);
transition: background-color 3s ease-out 1s;
}
.sb-external-caret {
position: relative;
border-left: 2px solid var(--editor-external-caret-color);
margin-left: -1px;
animation: sb-external-caret-blink 1s steps(1) infinite;
&::after {
content: attr(data-source);
position: absolute;
top: -1.1em;
left: -2px;
font-size: 0.65em;
line-height: 1.3;
padding: 0 4px;
border-radius: 3px;
background-color: var(--editor-external-caret-color);
color: var(--ui-accent-contrast-color);
white-space: nowrap;
pointer-events: none;
}
}
@keyframes sb-external-caret-blink {
50% {
border-left-color: transparent;
}
}
.cm-foldPlaceholder {
background-color: transparent;
border: 0;
}
.cm-frontmatterFoldPlaceholder {
box-sizing: border-box;
cursor: pointer;
display: inline-flex;
align-items: baseline;
gap: 3px;
padding: 2px 7px !important;
user-select: none;
width: 100%;
}
.cm-frontmatterFoldStatus {
color: var(--subtle-color);
font-size: 0.85em;
margin-left: 0.4em;
opacity: 0.75;
}
.sb-line-comment {
text-indent: -1 * 3ch;
padding-left: 3ch;
}
.cm-list-bullet {
color: var(--editor-list-bullet-color, inherit);
white-space: nowrap; // Prevent bullet from being a line-wrap opportunity (fixes #1829)
}
.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;
}
}
.cm-tooltip.cm-completionInfo:has(.sb-completion-documentation) {
max-width: min(48rem, 70vw);
padding: 0;
white-space: normal;
}
.sb-completion-documentation {
box-sizing: border-box;
max-height: min(32rem, 70vh);
overflow-y: auto;
padding: 0.75rem 1rem;
>h3:first-child {
display: none;
}
}
// Hanging-indent for the leading `#`-markers in cursor-in mode
.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;
}
// On narrow viewports (≤ default editor-width), the gutter to the left of
// `.cm-content` is gone, so the hanging `#`-markers would slide off-screen.
// Render them inline instead — the heading text shifts right by `Nch + 1`
// but stays fully visible. CSS variables can't be used in media queries,
// so this threshold tracks the default `--editor-width` (800px).
@media (max-width: 800px) {
.sb-header-inside.sb-line-h1,
.sb-header-inside.sb-line-h2,
.sb-header-inside.sb-line-h3,
.sb-header-inside.sb-line-h4,
.sb-header-inside.sb-line-h5,
.sb-header-inside.sb-line-h6 {
text-indent: 0;
}
}
.sb-checkbox {
display: inline-block;
text-align: center;
width: 3ch;
// Stop the inherited negative text-indent on list-item lines from
// dragging the inner <input> out of the checkbox's own box.
text-indent: 0;
line-height: 1;
}
// Replace the native <input type=checkbox> with a CSS-drawn box. Safari
// renders the native control at a fixed ~13px regardless of CSS `width`,
// leaving a wide visual gap between the glyph and the task text inside
// the 3ch column. A custom box fills the column predictably across
// engines and renders the same on Chrome, Firefox, and Safari. The rule
// matches both the editor's `.sb-checkbox` widget and any checkbox
// produced by `renderMarkdownToHtml` (query/table/html/footnote widgets),
// so rendered task lists look identical to source-mode tasks.
input[type="checkbox"] {
appearance: none;
-webkit-appearance: none;
display: inline-block;
box-sizing: border-box;
width: 1.3em;
height: 1.3em;
margin: 0;
padding: 0;
border: 1.5px solid currentColor;
border-radius: 3px;
background: transparent;
cursor: pointer;
position: relative;
vertical-align: middle;
}
input[type="checkbox"]:checked::after {
content: "";
position: absolute;
left: 28%;
top: 8%;
width: 32%;
height: 64%;
border: solid currentColor;
border-width: 0 1.5px 1.5px 0;
transform: rotate(45deg);
}
.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;
// Horizontal-only chip gutter that doesn't take layout width or add
// vertical box height: 5px of padding on each side is cancelled by
// -5px margin, so the background extends visually around the text but
// adjacent inline content isn't pushed away.
padding: 0 5px;
margin: 0 -5px;
// white-space: nowrap;
text-decoration: none;
cursor: pointer;
}
.sb-lua-directive-inline {
display: inline;
padding: 2px;
}
.sb-lua-directive-block {
display: block;
}
.sb-loading-widget {
display: inline-flex;
align-items: center;
gap: 0.4em;
color: var(--top-loading-color, #888);
opacity: 0.7;
vertical-align: middle;
}
.sb-loading-widget-block {
display: flex;
padding: 0.2em 0;
}
.sb-loading-spinner {
display: inline-block;
width: 0.9em;
height: 0.9em;
border: 2px solid currentColor;
border-top-color: transparent;
border-radius: 50%;
animation: sb-loading-spin 0.8s linear infinite;
box-sizing: border-box;
}
@keyframes sb-loading-spin {
to {
transform: rotate(360deg);
}
}
.sb-widget-array {
display: flex;
flex-direction: column;
}
.sb-task-dropdown {
cursor: pointer;
opacity: 0.4;
user-select: none;
&:hover {
opacity: 1;
}
}
.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: inline-block;
vertical-align: top;
width: 100%;
font-weight: normal;
overflow: auto;
}
.sb-html-widget {
font-weight: normal;
}
.sb-html-widget-inline {
display: inline;
}
div.sb-html-widget {
display: block;
}
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;
}
// HTML comments (inline + block, incl. baked-section `<!--#lua … -->`
// markers) render slightly smaller, reinforcing the subtle comment styling.
.sb-comment {
font-size: 0.9em;
}
// Comments inside fenced code keep the code block's sizing (more specific,
// so it overrides the general rule above).
.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-lua-wrapper {
::selection {
background-color: var(--editor-selection-background-color) !important;
}
}
// For block directives only: the widget root is a `<span>` wrapping a
// `display: block` div, and inline-around-block adds a line-box
// descent (~one line-height) below the block — invisible to
// CodeMirror's height map (offsetHeight) but visible to layout, so
// the height map and the real position of following lines drift
// apart. `inline-block` + `vertical-align: top` removes the descent;
// `width: 100%` keeps the wrapper editor-width so wide block content
// (tables) gets its own scrollbar instead of expanding past the
// editor. Inline directives (`${10 + 2}`) must stay inline.
.sb-lua-wrapper:has(.sb-lua-directive-block) {
display: inline-block;
vertical-align: top;
width: 100%;
}
.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;
// Vertical padding chosen so the rendered h1 strip has the same total
// height as the hover-revealed `.button-bar` overlay sitting on top of it
padding: 16px 10px !important;
background-color: var(--editor-widget-background-color);
font-size: 1.2em;
line-height: 1;
}
.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;
}
// Hanging-indent for task items so wrapped task text aligns with the
// first-line text (after the checkbox) instead of falling back under
// the bullet column.
li>.sb-task {
display: inline-block;
width: 100%;
box-sizing: border-box;
padding-left: 1.7em;
text-indent: -1.7em;
vertical-align: top;
}
h1,
h2,
h3,
h4,
h5 {
margin: 0;
}
a.wiki-link {
border-radius: 5px;
padding: 0 5px;
margin: 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);
}
button:not(.sb-button):not(.sb-button-primary):not(.sb-button-danger):not(.sb-button-icon) {
font-family: var(--editor-font);
font-size: inherit;
white-space: nowrap;
}
// 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-lua-directive-inline:has(> button) {
border: none;
border-radius: 0;
}
.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-comment-widget {
padding: 2px 0;
}
.sb-comment-card {
border: 1px solid var(--editor-directive-background-color);
border-radius: 6px;
padding: 4px 10px;
font-size: 0.9em;
.sb-comment-quote {
color: var(--editor-code-comment-color);
font-style: italic;
border-left: 2px solid var(--editor-code-comment-color);
padding-left: 8px;
margin-bottom: 2px;
}
.sb-comment-addressee {
font-weight: 600;
}
.sb-comment-sig {
color: var(--editor-code-comment-color);
font-size: 0.9em;
}
.sb-comment-actions button {
font-size: 0.85em;
margin-right: 6px;
}
}
.sb-frontmatter-marker {
cursor: pointer;
float: right;
font-size: 80%;
opacity: 0.8;
padding-right: 7px;
user-select: none;
}
.sb-frontmatter-marker:hover,
.sb-frontmatter-marker:focus-visible {
opacity: 1;
}
.cm-scroller {
// Give some breathing space at the bottom of the screen
padding-bottom: 20em;
}
}
#sb-editor>.cm-editor>.cm-scroller {
scrollbar-gutter: stable;
}
div:not(.cm-focused).cm-fat-cursor {
outline: none !important;
}