Skip to content

Build your personal knowledge base with Trilium Notes

text editor/formatting toolbar: make the Mermaid template dropdown scrollable, refactor

Adorian Doran01d1d37db73c
diff --git a/apps/client/src/stylesheets/theme-next/notes/text.css b/apps/client/src/stylesheets/theme-next/notes/text.css
index d1a4b8da57..d0941e3c61 100644
--- a/apps/client/src/stylesheets/theme-next/notes/text.css
+++ b/apps/client/src/stylesheets/theme-next/notes/text.css
@@ -371,8 +371,11 @@ div.ck.ck-collapsible {
color: var(--accent);
}
-/* Code dropdown */
+/* Scrollable dropdown panel. Applies to our reusable `.ck-tn-dropdown`
+ (footnotes, mermaid; set via `dropdownView.class`) and to CKEditor's own code
+ block language dropdown, whose 250px default we bump up to 400px. */
+.ck.ck-dropdown.ck-tn-dropdown .ck-dropdown__panel,
.ck.ck-dropdown.ck-code-block-dropdown .ck-dropdown__panel,
.ck.ck-toolbar-container.codeblock-language-list .ck.ck-dropdown__panel {
--_panel-height: 400px;
@@ -381,6 +384,7 @@ div.ck.ck-collapsible {
max-height: var(--_panel-height);
}
+.ck-tn-dropdown .ck-dropdown__panel .ck-list,
.ck-code-block-dropdown .ck-dropdown__panel .ck-list,
.ck.ck-toolbar-container.codeblock-language-list .ck.ck-dropdown__panel .ck-list {
overflow: auto;
diff --git a/packages/ckeditor5-footnotes/src/footnote-ui.ts b/packages/ckeditor5-footnotes/src/footnote-ui.ts
index 719eb69013..c2e365cba0 100644
--- a/packages/ckeditor5-footnotes/src/footnote-ui.ts
+++ b/packages/ckeditor5-footnotes/src/footnote-ui.ts
@@ -44,7 +44,7 @@ export default class FootnoteUI extends Plugin {
editor.editing.view.focus();
} );
- dropdownView.class = 'ck-code-block-dropdown';
+ dropdownView.class = 'ck-tn-dropdown';
dropdownView.bind( 'isEnabled' ).to( command );
dropdownView.on(
'change:isOpen',
diff --git a/packages/ckeditor5-mermaid/src/mermaidui.ts b/packages/ckeditor5-mermaid/src/mermaidui.ts
index 7b11892733..20b26d4284 100644
--- a/packages/ckeditor5-mermaid/src/mermaidui.ts
+++ b/packages/ckeditor5-mermaid/src/mermaidui.ts
@@ -84,8 +84,11 @@ export default class MermaidUI extends Plugin {
splitButtonView.on( 'execute', () => this._insertDiagram() );
// Dropdown: insert a diagram pre-filled with the picked template.
+ // Reuse the shared scrollable dropdown style so the long list of
+ // templates doesn't overflow the viewport.
// `createDropdown` already binds the split button's `isEnabled` to the
// dropdown, so binding the dropdown alone disables both parts.
+ dropdownView.class = 'ck-tn-dropdown';
addListToDropdown( dropdownView, this._getSampleDropdownItems( samples ) );
dropdownView.bind( 'isEnabled' ).to( command, 'isEnabled' );
dropdownView.on( 'execute', evt => {