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
style(mind-map): let a node's memo read as the pane it fills
Elian Doran3fa435463a97
diff --git a/apps/client/src/translations/en/translation.json b/apps/client/src/translations/en/translation.jsonindex b262001f49..426f2f999b 100644--- a/apps/client/src/translations/en/translation.json+++ b/apps/client/src/translations/en/translation.json@@ -3554,6 +3554,7 @@"links-differ": "The selected nodes don't carry the same link.","tab-format": "Format","memo": "Memo",+ "memo-placeholder": "Write a memo...","memos-differ": "The selected nodes carry different memos, so this one can only be read.","tags": "Tags","tags-placeholder": "Type a tag and press Enter",diff --git a/apps/client/src/widgets/type_widgets/mind_map/NodeMemo.css b/apps/client/src/widgets/type_widgets/mind_map/NodeMemo.cssindex 529b4e6f38..eece8e2363 100644--- a/apps/client/src/widgets/type_widgets/mind_map/NodeMemo.css+++ b/apps/client/src/widgets/type_widgets/mind_map/NodeMemo.css@@ -1,23 +1,41 @@/*- * The memo is a field like the others around it, framed and scrolling once what is written outgrows- * the room the panel has: the editor inside it brings neither.+ * The memo is the whole of its tab rather than a field within one, so it wears none of a field's+ * chrome: no frame, no fill and no focus ring of its own. The panel is the surface and the memo is+ * simply what is written on it — a frame here would only draw a box inside a box.+ *+ * The `!important`s override CKEditor's own styling of an inline editable, which lands at the same+ * specificity as this rule from a stylesheet whose load order against this one is not settled.*/.mind-map-node-panel .mind-map-node-memo {- max-height: 160px;overflow: auto;- padding: 4px 8px;- border: 1px solid var(--main-border-color);- border-radius: 6px;- background: var(--input-background-color);+ /* The room the fields of the other tab are given (see NodePanel.css), so that what is read in+ either tab stands the same distance from the edge of the panel. It is the memo's own padding+ rather than the tab's, so that the memo fills the tab edge to edge and what is written scrolls+ within it — a scrollbar riding the panel's edge rather than an inset frame's. */+ padding: 15px !important;+ border: none !important;+ border-radius: 0 !important;+ box-shadow: none !important;+ background: transparent;+ color: inherit;- &:focus-within {- outline: 2px solid var(--input-focus-outline-color);+ /* CKEditor adds `.ck-content` to the very element it took over, which is this one. */+ &.ck-content {+ outline: none;++ /* What is written begins and ends at the padding rather than a blank line inside it: the+ memo is the pane, and a pane does not indent itself from its own edge. */+ > :first-child {+ margin-top: 0;+ }++ > :last-child {+ margin-bottom: 0;+ }}- /* The editor is the field's own surface; a frame of its own would draw a second one within it. */- .ck.ck-editor__editable {- border: none;- box-shadow: none;- background: transparent;+ /* Dimmed as every other hint CKEditor writes into an empty editor is (see style.css). */+ .ck-placeholder::before {+ opacity: .5;}}diff --git a/apps/client/src/widgets/type_widgets/mind_map/NodeMemo.tsx b/apps/client/src/widgets/type_widgets/mind_map/NodeMemo.tsxindex a435dfd0a3..5fef04131f 100644--- a/apps/client/src/widgets/type_widgets/mind_map/NodeMemo.tsx+++ b/apps/client/src/widgets/type_widgets/mind_map/NodeMemo.tsx@@ -4,6 +4,7 @@ import { AttributeEditor, CHAT_INPUT_PLUGINS, type CKTextEditor, type EditorConfimport type { NodeObj } from "mind-elixir";import { useEffect, useLayoutEffect, useRef } from "preact/hooks";+import { t } from "../../../services/i18n";import { escapeHtml } from "../../../services/utils";import CKEditor, { type CKEditorApi } from "../../react/CKEditor";@@ -79,7 +80,7 @@ export default function NodeMemo({ selectionKey, memo, readOnly, onCommit }: {apiRef={apiRef}className="mind-map-node-memo"editor={AttributeEditor}- config={MEMO_EDITOR_CONFIG}+ config={buildMemoEditorConfig()}currentValue={html}onChange={(html) => (typed.current = { key: currentKey.current, html: html ?? "" })}onInitialized={(editor) => {@@ -98,14 +99,21 @@ export default function NodeMemo({ selectionKey, memo, readOnly, onCommit }: {);}-/** Kept still, so that the editor is not configured anew every time the panel renders. */-const MEMO_EDITOR_CONFIG: EditorConfig = {- // The markdown autoformatting the chat box has — quotes, code, lists, links — and no toolbar.- extraPlugins: CHAT_INPUT_PLUGINS,- toolbar: { items: [] },- licenseKey: "GPL",- language: "en"-};+/**+ * Built where it is used rather than kept still beside the module: the hint is a translated string,+ * and the catalogue is not yet loaded when this module is. Nothing is spent on rebuilding it — an+ * editor is raised from the configuration it is handed as it mounts, and never reconfigured.+ */+function buildMemoEditorConfig(): EditorConfig {+ return {+ // The markdown autoformatting the chat box has — quotes, code, lists, links — and no toolbar.+ extraPlugins: CHAT_INPUT_PLUGINS,+ toolbar: { items: [] },+ placeholder: t("mind-map.memo-placeholder"),+ licenseKey: "GPL",+ language: "en"+ };+}/** Held while the selection disagrees, there being no one memo to write over the others. */const MEMO_READ_ONLY_LOCK = "mind-map-node-memo";diff --git a/apps/client/src/widgets/type_widgets/mind_map/NodePanel.css b/apps/client/src/widgets/type_widgets/mind_map/NodePanel.cssindex 77fdd69304..990d6cb374 100644--- a/apps/client/src/widgets/type_widgets/mind_map/NodePanel.css+++ b/apps/client/src/widgets/type_widgets/mind_map/NodePanel.css@@ -63,14 +63,18 @@visibility: hidden;}-/* The memo is the whole of its tab, so it fills the height the panel took from the fields. */+/*+ * The memo is the whole of its tab, so it fills the height the panel took from the fields — and the+ * width edge to edge, the tab keeping none of the padding for itself. What insets the writing is+ * the memo's own padding (see NodeMemo.css), so that the two read as one surface rather than as a+ * sheet laid on a tab.+ */.mind-map-node-panel .mind-map-node-panel-memo-body {display: flex;- padding: 8px;+ padding: 0;.mind-map-node-memo {flex: 1;- max-height: none;}}