Skip to content

Build your personal knowledge base with Trilium Notes

feat(share): style headings like a read-only note in the app

Elian Doran18a59ff0f5a6
diff --git a/apps/client/src/index.ts b/apps/client/src/index.ts
index 559099e5cb..e6058adc25 100644
--- a/apps/client/src/index.ts
+++ b/apps/client/src/index.ts
@@ -3,6 +3,7 @@
// which loads ahead of the stylesheets `loadStylesheets()` appends.
import "@triliumnext/ckeditor5/src/theme/adaptive_colors.css";
import "@triliumnext/ckeditor5/src/theme/footnotes.css";
+import "@triliumnext/ckeditor5/src/theme/headings.css";
import "@triliumnext/ckeditor5/src/theme/reference_links.css";
import { createFontStylesheetLink } from "./services/font";
diff --git a/packages/ckeditor5/src/theme/headings.css b/packages/ckeditor5/src/theme/headings.css
new file mode 100644
index 0000000000..82f22ab957
--- /dev/null
+++ b/packages/ckeditor5/src/theme/headings.css
@@ -0,0 +1,48 @@
+/* The heading scale of Bootstrap 5, which the app also loads; the values must stay equal to its. */
+.ck-content :is(h1, h2, h3, h4, h5, h6) {
+ margin-top: 0;
+ margin-bottom: 0.5rem;
+ line-height: 1.2;
+}
+
+.ck-content h1 {
+ font-size: calc(1.375rem + 1.5vw);
+}
+
+.ck-content h2 {
+ font-size: calc(1.325rem + 0.9vw);
+}
+
+.ck-content h3 {
+ font-size: calc(1.3rem + 0.6vw);
+}
+
+.ck-content h4 {
+ font-size: calc(1.275rem + 0.3vw);
+}
+
+.ck-content h5 {
+ font-size: 1.25rem;
+}
+
+.ck-content h6 {
+ font-size: 1rem;
+}
+
+@media (min-width: 1200px) {
+ .ck-content h1 {
+ font-size: 2.5rem;
+ }
+
+ .ck-content h2 {
+ font-size: 2rem;
+ }
+
+ .ck-content h3 {
+ font-size: 1.75rem;
+ }
+
+ .ck-content h4 {
+ font-size: 1.5rem;
+ }
+}
diff --git a/packages/share-theme/src/content/content.css b/packages/share-theme/src/content/content.css
index 136012c9e7..39329f67cd 100644
--- a/packages/share-theme/src/content/content.css
+++ b/packages/share-theme/src/content/content.css
@@ -1,3 +1,4 @@
+@import "@triliumnext/ckeditor5/src/theme/headings.css";
@import "@triliumnext/ckeditor5/src/theme/reference_links.css";
:root {
@@ -7,9 +8,13 @@
--ck-content-line-height: inherit !important;
}
-#title {
+#content #title {
margin: 0;
padding-top: 10px;
+ font-size: 2em;
+ line-height: 1.2;
+ color: var(--text-heading);
+ border-bottom: 1px solid var(--background-highlight);
}
iframe.pdf-view {
@@ -52,15 +57,11 @@ iframe.pdf-view {
right: 0.5em;
}
-#content h1,
-#content h2,
-#content h3,
-#content h4,
-#content h5,
-#content h6 {
- color: var(--text-heading);
+/* The heading weight of the app's default theme (`theme-next/notes/text.css`) and its default
+ `headingStyle`, "underline" (`ReadOnlyText.css`). */
+.ck-content :is(h1, h2, h3, h4, h5, h6) {
+ font-weight: 300;
border-bottom: 1px solid var(--background-highlight);
- padding-bottom: 5px;
}
#content img {