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
client/text editor/content embed: tweak code embeds appearance
Adorian Doran048b049a78f0
diff --git a/apps/client/src/stylesheets/style.css b/apps/client/src/stylesheets/style.cssindex c3c7ceb742..d15a083b69 100644--- a/apps/client/src/stylesheets/style.css+++ b/apps/client/src/stylesheets/style.css@@ -1016,14 +1016,28 @@ body.mobile .modal-content-with-sidebar > .modal-main > .modal-header > .modal-t/* Includes in a series share flush edges, as link previews and collapsible blocks do. */.include-note + .include-note {- --_include-note-top-border-radius: 0;+ --_include-note-top-border-radius: 0px;}.include-note:has(+ .include-note) {- --_include-note-bottom-border-radius: 0;+ --_include-note-bottom-border-radius: 0px;margin-bottom: 3px;}+.include-note {+ /* The corners of the embed box that its content touches, as lengths for `calc()`. */+ --_include-note-content-top-radius: 0px;+ --_include-note-content-bottom-radius: var(--_include-note-bottom-border-radius, 8px);++ &[data-hide-title="true"]:not([data-box-size="tiny"], [data-box-size="expandable"]) {+ --_include-note-content-top-radius: var(--_include-note-top-border-radius, 8px);+ }++ &:has(> figcaption) {+ --_include-note-content-bottom-radius: 0px;+ }+}+/* CKEditor counts only non-UIElements as content (see `hasContent` in theengine), so a widget rendered entirely from UIElements — an include note, aMermaid diagram, etc. — looks "empty" to it. When such a widget is the first@@ -1335,6 +1349,35 @@ body.mobile .modal-content-with-sidebar > .modal-main > .modal-header > .modal-tmargin-bottom: 0;}+.include-note-content pre.code-embed-editor {+ padding: 0;+}++.include-note-content.type-code {+ --_code-embed-inset: 2px;+ padding: 0 var(--_code-embed-inset) var(--_code-embed-inset);+}++.include-note[data-hide-title="true"]:not([data-box-size="tiny"], [data-box-size="expandable"])+ .include-note-content.type-code {+ padding-top: var(--_code-embed-inset);+}++/* Outranks the `!important` margin and shadow that the themes give `.ck-content pre`. */+:root .include-note-content.type-code pre {+ margin: 0 !important;+ box-shadow: none !important;+ border-radius:+ max(0px, var(--_include-note-content-top-radius) - var(--_code-embed-inset))+ max(0px, var(--_include-note-content-top-radius) - var(--_code-embed-inset))+ max(0px, var(--_include-note-content-bottom-radius) - var(--_code-embed-inset))+ max(0px, var(--_include-note-content-bottom-radius) - var(--_code-embed-inset));++ &.code-embed-editor {+ overflow: hidden;+ }+}+/* Takes the wheel and the touch gestures for the page until the content has the focus. */.include-note-backdrop {position: absolute;diff --git a/apps/client/src/widgets/type_widgets/canvas/CanvasDrawing.css b/apps/client/src/widgets/type_widgets/canvas/CanvasDrawing.cssindex ed8f60c7d8..c7db7fb2c8 100644--- a/apps/client/src/widgets/type_widgets/canvas/CanvasDrawing.css+++ b/apps/client/src/widgets/type_widgets/canvas/CanvasDrawing.css@@ -132,18 +132,6 @@}.include-note {- /* The corners of the embed box that the drawing touches. */- --_canvas-drawing-top-radius: 0;- --_canvas-drawing-bottom-radius: var(--_include-note-bottom-border-radius, 8px);-- &[data-hide-title="true"]:not([data-box-size="tiny"], [data-box-size="expandable"]) {- --_canvas-drawing-top-radius: var(--_include-note-top-border-radius, 8px);- }-- &:has(> figcaption) {- --_canvas-drawing-bottom-radius: 0;- }-&[data-box-size="small"] .canvas-drawing {height: var(--include-note-height, 10em);}@@ -156,8 +144,10 @@/* Excalidraw hides its overflow, so its rounded container clips what it draws. */.include-note-content:not(:fullscreen) .canvas-drawing {&, .excalidraw-container, .canvas-drawing-view {- border-radius: var(--_canvas-drawing-top-radius) var(--_canvas-drawing-top-radius)- var(--_canvas-drawing-bottom-radius) var(--_canvas-drawing-bottom-radius);+ border-radius: var(--_include-note-content-top-radius)+ var(--_include-note-content-top-radius)+ var(--_include-note-content-bottom-radius)+ var(--_include-note-content-bottom-radius);}}diff --git a/apps/client/src/widgets/type_widgets/code/CodeEmbed.css b/apps/client/src/widgets/type_widgets/code/CodeEmbed.cssdeleted file mode 100644index 99b32c8a69..0000000000--- a/apps/client/src/widgets/type_widgets/code/CodeEmbed.css+++ /dev/null@@ -1,5 +0,0 @@-.include-note-content .code-embed-content {- pre.code-embed-editor {- padding: 0;- }-}diff --git a/apps/client/src/widgets/type_widgets/code/CodeEmbed.tsx b/apps/client/src/widgets/type_widgets/code/CodeEmbed.tsxindex 7050fbac70..dc4df951d0 100644--- a/apps/client/src/widgets/type_widgets/code/CodeEmbed.tsx+++ b/apps/client/src/widgets/type_widgets/code/CodeEmbed.tsx@@ -1,5 +1,3 @@-import "./CodeEmbed.css";-import type { ContentEmbedCodeView } from "@triliumnext/ckeditor5";import type VanillaCodeMirror from "@triliumnext/codemirror";import { createPortal, type RefObject } from "preact";diff --git a/apps/client/src/widgets/type_widgets/markdown/MarkdownEmbed.css b/apps/client/src/widgets/type_widgets/markdown/MarkdownEmbed.cssindex 10cfeb08a4..4684446a38 100644--- a/apps/client/src/widgets/type_widgets/markdown/MarkdownEmbed.css+++ b/apps/client/src/widgets/type_widgets/markdown/MarkdownEmbed.css@@ -39,22 +39,9 @@height: 100%;}-.include-note {- /* The corners of the embed box that the split editor touches. */- --_markdown-embed-top-radius: 0;- --_markdown-embed-bottom-radius: var(--_include-note-bottom-border-radius, 8px);-- &[data-hide-title="true"]:not([data-box-size="tiny"], [data-box-size="expandable"]) {- --_markdown-embed-top-radius: var(--_include-note-top-border-radius, 8px);- }-- &:has(> figcaption) {- --_markdown-embed-bottom-radius: 0;- }-}-.include-note-content:not(:fullscreen) .markdown-embed-content.with-source {- border-radius: var(--_markdown-embed-top-radius) var(--_markdown-embed-top-radius)- var(--_markdown-embed-bottom-radius) var(--_markdown-embed-bottom-radius);+ border-radius: var(--_include-note-content-top-radius) var(--_include-note-content-top-radius)+ var(--_include-note-content-bottom-radius)+ var(--_include-note-content-bottom-radius);overflow: hidden;}