Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
feat(text): keep the heading of the section being read in view
Elian Dorana1f58c684afc
diff --git a/apps/client/src/widgets/type_widgets/Doc.css b/apps/client/src/widgets/type_widgets/Doc.cssindex 0c48a95b9b..a2eb623d6e 100644--- a/apps/client/src/widgets/type_widgets/Doc.css+++ b/apps/client/src/widgets/type_widgets/Doc.css@@ -18,21 +18,3 @@background-color: var(--accented-background-color);border: 1px solid var(--main-border-color);}--.note-detail-doc-content.contextual-help {- padding-bottom: 0;-}--.note-detail-doc-content.contextual-help h2,-.note-detail-doc-content.contextual-help h3,-.note-detail-doc-content.contextual-help h4,-.note-detail-doc-content.contextual-help h5,-.note-detail-doc-content.contextual-help h6 {- font-size: 1.25rem;- background-color: var(--main-background-color);- position: sticky;- top: 0;- z-index: 50;- margin: 0;- padding-bottom: 0.25em;-}\ No newline at end of filediff --git a/apps/client/src/widgets/type_widgets/Doc.tsx b/apps/client/src/widgets/type_widgets/Doc.tsxindex 93929c7bab..92596e38f4 100644--- a/apps/client/src/widgets/type_widgets/Doc.tsx+++ b/apps/client/src/widgets/type_widgets/Doc.tsx@@ -8,7 +8,7 @@ import { useTriliumEvent } from "../react/hooks";import { refToJQuerySelector } from "../react/react_utils";import { TypeWidgetProps } from "./type_widget";-export default function Doc({ note, viewScope, ntxId }: TypeWidgetProps) {+export default function Doc({ note, ntxId }: TypeWidgetProps) {const initialized = useRef<Promise<void> | null>(null);const containerRef = useRef<HTMLDivElement>(null);@@ -31,7 +31,7 @@ export default function Doc({ note, viewScope, ntxId }: TypeWidgetProps) {return (<divref={containerRef}- className={`note-detail-doc-content ck-content ${viewScope?.viewMode === "contextual-help" ? "contextual-help" : ""}`}+ className="note-detail-doc-content ck-content"/>);}diff --git a/apps/client/src/widgets/type_widgets/text/ReadOnlyText.css b/apps/client/src/widgets/type_widgets/text/ReadOnlyText.cssindex b866e1c831..5efd357546 100644--- a/apps/client/src/widgets/type_widgets/text/ReadOnlyText.css+++ b/apps/client/src/widgets/type_widgets/text/ReadOnlyText.css@@ -7,6 +7,21 @@h5 { font-size: 1.1em; }h6 { font-size: 1.0em; }+ /* Keep the heading of the section being read in view. Every level pins to the same edge, so a+ deeper heading slides over its parent and exactly one is ever shown. The space above a+ heading has to be padding rather than margin: sticky positions the margin box, so a margin+ would pin the heading that far down and leave the gap transparent for the text to run+ through. */+ :is(h1, h2, h3, h4, h5, h6) {+ position: sticky;+ top: 0;+ z-index: 50;+ background-color: var(--main-background-color);+ margin-top: 0;+ padding-top: 0.83em;+ padding-bottom: 0.15em;+ }+.mermaid-diagram,.mermaid-diagram svg,img {@@ -15,6 +30,12 @@}}+/* Dialogs (e.g. the quick-edit popup) paint their content area with the modal background, so a+ pinned heading has to match it there instead of the main background. */+.modal .note-detail-readonly-text-content :is(h1, h2, h3, h4, h5, h6) {+ background-color: var(--modal-background-color);+}+/* Top-level (not scoped to the note view) so a swallowed mermaid failure isvisible in the chat panel too, where the container lacks the note class. */.mermaid-diagram.mermaid-error {