Skip to content

Build your personal knowledge base with Trilium Notes

feat(text): wrap code blocks in table cells

Elian Doran76413ff30ab7
diff --git a/apps/client/src/stylesheets/theme-next/notes/text.css b/apps/client/src/stylesheets/theme-next/notes/text.css
index 18f8bf7cef..d2823ad64e 100644
--- a/apps/client/src/stylesheets/theme-next/notes/text.css
+++ b/apps/client/src/stylesheets/theme-next/notes/text.css
@@ -849,6 +849,15 @@ html .note-detail-editable-text > :not(figure, .include-note, hr):first-child {
white-space: pre;
}
+:root .ck-content td pre {
+ --padding-size: 0.5em;
+}
+
+:root .ck-content td pre code {
+ white-space: pre-wrap;
+ overflow-wrap: break-word;
+}
+
.code-sample-wrapper .hljs {
transition: background-color linear 100ms;
}
diff --git a/packages/share-theme/src/content/content.css b/packages/share-theme/src/content/content.css
index 752a7f5468..22f1501843 100644
--- a/packages/share-theme/src/content/content.css
+++ b/packages/share-theme/src/content/content.css
@@ -54,10 +54,16 @@ iframe.pdf-view {
:root .ck-content pre code {
display: block;
- padding: 1em;
+ padding: var(--code-block-padding, 1em);
overflow: auto;
}
+:root .ck-content td pre {
+ --code-block-padding: 0.5em;
+ white-space: pre-wrap;
+ overflow-wrap: break-word;
+}
+
.ck-content pre:has(> .copy-button) {
position: relative;
@@ -68,8 +74,8 @@ iframe.pdf-view {
.ck-content pre > .copy-button {
position: absolute;
- top: 0.5em;
- inset-inline-end: 0.5em;
+ top: calc(var(--code-block-padding, 1em) / 2);
+ inset-inline-end: calc(var(--code-block-padding, 1em) / 2);
display: flex;
align-items: center;
justify-content: center;