From c3ab2d09d59dc91c38e40bd250872655a7359043 Mon Sep 17 00:00:00 2001 From: Elian Doran Date: Sat, 11 Apr 2026 12:41:19 +0300 Subject: [PATCH] feat(ckeditor/include_note): add a new size for expandable items (closes #4134) --- apps/client/src/stylesheets/style.css | 37 +++++++++++++++++++ .../src/translations/en/translation.json | 1 + .../src/widgets/dialogs/include_note.tsx | 1 + .../text/CKEditorWithWatchdog.tsx | 2 +- .../src/widgets/type_widgets/text/utils.ts | 35 ++++++++++++++++-- packages/ckeditor5/src/plugins/includenote.ts | 3 +- 6 files changed, 74 insertions(+), 5 deletions(-) diff --git a/apps/client/src/stylesheets/style.css b/apps/client/src/stylesheets/style.css index 536db2d9b5..baff2d14dc 100644 --- a/apps/client/src/stylesheets/style.css +++ b/apps/client/src/stylesheets/style.css @@ -1230,6 +1230,43 @@ a.external:not(.no-arrow):after, a[href^="http://"]:not(.no-arrow):after, a[href width: 100%; } +/* Expandable include note styles */ +.include-note-title-row { + display: flex; + align-items: center; + gap: 5px; + cursor: pointer; +} + +.include-note-title-row .include-note-title { + margin: 0; +} + +.include-note-toggle { + background: none; + border: none; + padding: 2px; + cursor: pointer; + font-size: 1.2em; + color: var(--main-text-color); + transition: transform 0.2s ease; + display: flex; + align-items: center; + justify-content: center; +} + +.include-note-toggle:hover { + color: var(--main-link-color); +} + +.include-note-toggle.expanded { + transform: rotate(90deg); +} + +.include-note[data-box-size="expandable"] .include-note-content { + margin-top: 10px; +} + .alert { padding: 8px 14px; width: auto; diff --git a/apps/client/src/translations/en/translation.json b/apps/client/src/translations/en/translation.json index aefea90cb5..806134b62b 100644 --- a/apps/client/src/translations/en/translation.json +++ b/apps/client/src/translations/en/translation.json @@ -215,6 +215,7 @@ "box_size_small": "small (~ 10 lines)", "box_size_medium": "medium (~ 30 lines)", "box_size_full": "full (box shows complete text)", + "box_size_expandable": "expandable (collapsed by default)", "button_include": "Include note" }, "info": { diff --git a/apps/client/src/widgets/dialogs/include_note.tsx b/apps/client/src/widgets/dialogs/include_note.tsx index aabd64bab7..c8f818302d 100644 --- a/apps/client/src/widgets/dialogs/include_note.tsx +++ b/apps/client/src/widgets/dialogs/include_note.tsx @@ -63,6 +63,7 @@ export default function IncludeNoteDialog() { { label: t("include_note.box_size_small"), value: "small" }, { label: t("include_note.box_size_medium"), value: "medium" }, { label: t("include_note.box_size_full"), value: "full" }, + { label: t("include_note.box_size_expandable"), value: "expandable" }, ]} /> diff --git a/apps/client/src/widgets/type_widgets/text/CKEditorWithWatchdog.tsx b/apps/client/src/widgets/type_widgets/text/CKEditorWithWatchdog.tsx index 56b4d57060..dd4d9d02c9 100644 --- a/apps/client/src/widgets/type_widgets/text/CKEditorWithWatchdog.tsx +++ b/apps/client/src/widgets/type_widgets/text/CKEditorWithWatchdog.tsx @@ -7,7 +7,7 @@ import link from "../../../services/link"; import { useKeyboardShortcuts, useLegacyImperativeHandlers, useNoteContext, useSyncedRef, useTriliumOption } from "../../react/hooks"; import { buildConfig, BuildEditorOptions } from "./config"; -export type BoxSize = "small" | "medium" | "full"; +export type BoxSize = "small" | "medium" | "full" | "expandable"; export interface CKEditorApi { /** returns true if user selected some text, false if there's no selection */ diff --git a/apps/client/src/widgets/type_widgets/text/utils.ts b/apps/client/src/widgets/type_widgets/text/utils.ts index ad8a6df23d..b6a48e9ac3 100644 --- a/apps/client/src/widgets/type_widgets/text/utils.ts +++ b/apps/client/src/widgets/type_widgets/text/utils.ts @@ -8,15 +8,44 @@ export async function loadIncludedNote(noteId: string, $el: JQuery) const note = await froca.getNote(noteId); if (!note) return; + // Get the box size from the parent section element + const $section = $el.closest('section.include-note'); + const boxSize = $section.attr('data-box-size'); + const isExpandable = boxSize === 'expandable'; + const $wrapper = $('
'); const $link = await link.createLink(note.noteId, { showTooltip: false }); - $wrapper.empty().append($('

').append($link)); + if (isExpandable) { + // Create expandable structure with toggle + const $titleRow = $('
'); + const $toggle = $('