From a98721c01679acf24aaecd9added2a828a8da061 Mon Sep 17 00:00:00 2001 From: Elian Doran Date: Sat, 11 Apr 2026 12:43:34 +0300 Subject: [PATCH] fix(ckeditor/include_note): changing expandability doesn't refresh --- .../src/widgets/type_widgets/text/utils.ts | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/apps/client/src/widgets/type_widgets/text/utils.ts b/apps/client/src/widgets/type_widgets/text/utils.ts index b6a48e9ac3..a3e0f382ba 100644 --- a/apps/client/src/widgets/type_widgets/text/utils.ts +++ b/apps/client/src/widgets/type_widgets/text/utils.ts @@ -48,6 +48,37 @@ export async function loadIncludedNote(noteId: string, $el: JQuery) } $el.empty().append($wrapper); + + // Watch for box-size attribute changes and re-render + setupBoxSizeObserver($section[0], noteId, $el); +} + +// Track observers to avoid duplicates +const boxSizeObservers = new WeakMap(); + +function setupBoxSizeObserver(section: Element, noteId: string, $el: JQuery) { + // Clean up existing observer if any + const existingObserver = boxSizeObservers.get(section); + if (existingObserver) { + existingObserver.disconnect(); + } + + const observer = new MutationObserver((mutations) => { + for (const mutation of mutations) { + if (mutation.type === 'attributes' && mutation.attributeName === 'data-box-size') { + // Re-render the included note with the new box size + loadIncludedNote(noteId, $el); + break; + } + } + }); + + observer.observe(section, { + attributes: true, + attributeFilter: ['data-box-size'] + }); + + boxSizeObservers.set(section, observer); } export function refreshIncludedNote(container: HTMLDivElement, noteId: string) {