diff --git a/CHANGELOG.rst b/CHANGELOG.rst index a46652b5..107507b7 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -12,6 +12,10 @@ Next version - Fixed a bug where a plugin with multiple fieldsets wouldn't collapse completely. - Added Django 5.1 to the CI. +- Introduced sections. Content editor inlines can now define a ``sections`` + attribute; recommended values include 0 (the default), 1 (open one section) + and -1 (close one section). Those sections are collapsed and moved as one + unit during editing. 7.0 (2024-05-31) diff --git a/content_editor/static/content_editor/content_editor.js b/content_editor/static/content_editor/content_editor.js index ab58b86e..db2a4f9e 100644 --- a/content_editor/static/content_editor/content_editor.js +++ b/content_editor/static/content_editor/content_editor.js @@ -243,6 +243,10 @@ inline.addEventListener("drop", (e) => { if (window.__fs_dragging) { e.preventDefault() + for (let inline of qsa(".order-machine .inline-related.selected")) { + selectSection(inline) + } + const inline = e.target.closest(".inline-related") const toMove = qsa(".order-machine .inline-related.selected").map( (inline) => [inline, +inline.style.order], @@ -733,6 +737,16 @@ } } + function selectSection(inline) { + const children = childrenMap && childrenMap.get(inline) + if (children) { + for (let child of children) { + child.classList.add("selected") + selectSection(child) + } + } + } + // Initialize tabs and currentRegion. ;(() => { const tabContainer = $(".tabs.regions")