Skip to content

Build your personal knowledge base with Trilium Notes

text editor/collapsible: update the behavior of the toolbar button

Adorian Doran2f72edede8b6
diff --git a/packages/ckeditor5-collapsible/src/collapsiblecommand.ts b/packages/ckeditor5-collapsible/src/collapsiblecommand.ts
index 752e39b5b1..e21d230668 100644
--- a/packages/ckeditor5-collapsible/src/collapsiblecommand.ts
+++ b/packages/ckeditor5-collapsible/src/collapsiblecommand.ts
@@ -12,9 +12,11 @@ export default class CollapsibleCommand extends Command {
declare public value: boolean;
public override refresh(): void {
- const selection = this.editor.model.document.selection;
- const block = selection.getFirstPosition()?.findAncestor("details");
- this.value = !!block;
+ // This command is a pure insert, not a toggle — running it again inside an
+ // existing collapsible would create a nested one (and re-running to "remove"
+ // would lose formatting). Keep `value` false so the toolbar button never
+ // shows as active.
+ this.value = false;
this.isEnabled = this._checkEnabled();
}
diff --git a/packages/ckeditor5-collapsible/src/collapsibleui.ts b/packages/ckeditor5-collapsible/src/collapsibleui.ts
index 858c52cfd3..edee22509c 100644
--- a/packages/ckeditor5-collapsible/src/collapsibleui.ts
+++ b/packages/ckeditor5-collapsible/src/collapsibleui.ts
@@ -18,11 +18,9 @@ export default class CollapsibleUI extends Plugin {
button.set({
label: t("Collapsible block"),
icon: collapsibleIcon,
- tooltip: true,
- isToggleable: true
+ tooltip: true
});
- button.bind("isOn").to(command, "value");
button.bind("isEnabled").to(command, "isEnabled");
this.listenTo(button, "execute", () => {