fix: expose accordion contents and add clear insert actions (1.8.3)
CMS quality / php (8.2) (push) Canceled after 0s
CMS quality / php (8.4) (push) Canceled after 0s
CMS quality / browser (push) Canceled after 0s
CMS quality / mysql (push) Canceled after 0s

This commit is contained in:
kantarci committed 2026-09-14 12:53:16 +02:00
1 parent a108e7d143
commit a3029966cb
12 files changed
+257 -18

No files matched your search

+19 -8
View File
@@ -5,22 +5,28 @@ export function decorateContainers(preview, content) {
const visit = (blocks, parent = null) => {
blocks.forEach((block, index) => {
const node = preview.getElementById(block.id);
if (node && ['section', 'row', 'column'].includes(block.type)) {
// Editing must expose the body without changing the visitor's saved open/closed state.
if (node && block.type === 'accordionitem') node.open = true;
if (node && ['section', 'row', 'column', 'accordion', 'accordionitem'].includes(block.type)) {
const label = block.type === 'column' && parent?.type === 'row'
? `Spalte ${index + 1} von ${blocks.length}` : blockLabel(block);
? `Spalte ${index + 1} von ${blocks.length}` : block.type === 'accordionitem'
? `Eintrag „${block.props?.title || 'Ohne Titel'}“` : blockLabel(block);
node.classList.add('editor-container');
node.dataset.editorLabel = label;
if (!block.children?.length) {
node.classList.add('editor-empty-container');
const host = block.type === 'section' ? node.querySelector(':scope > .section-inner') : node;
if (!block.children?.length || ['accordion', 'accordionitem'].includes(block.type)) {
const compact = Boolean(block.children?.length);
if (!compact) node.classList.add('editor-empty-container');
const host = block.type === 'section' ? node.querySelector(':scope > .section-inner')
: block.type === 'accordionitem' ? node.querySelector(':scope > .accordion-body') : node;
if (!host) return;
const empty = preview.createElement('div');
empty.className = 'editor-empty';
empty.className = compact ? 'editor-empty editor-add-content' : 'editor-empty';
const name = preview.createElement('span');
name.className = 'editor-empty-name'; name.textContent = label;
const hint = preview.createElement('span');
hint.className = 'editor-empty-hint';
hint.textContent = block.type === 'row' ? 'Spalte hierher ziehen oder hinzufügen' : 'Element hierher ziehen oder hinzufügen';
hint.textContent = block.type === 'row' ? 'Spalte hierher ziehen oder hinzufügen'
: block.type === 'accordion' ? 'Eintrag hinzufügen und darin Inhalte gestalten' : 'Element hierher ziehen oder hinzufügen';
const actions = preview.createElement('div'); actions.className = 'editor-empty-actions';
const add = (text, attribute, value, accessibleName) => {
const button = preview.createElement('button');
@@ -31,10 +37,15 @@ export function decorateContainers(preview, content) {
actions.append(button);
};
add(block.type === 'row' ? '+ Spalte hinzufügen' : '+ Inhalt hinzufügen', 'data-editor-insert', '', `${label}: ${block.type === 'row' ? 'Spalte' : 'Inhalt'} hinzufügen`);
if (block.type === 'accordion') {
actions.replaceChildren();
add('+ Eintrag hinzufügen', 'data-editor-add-entry', '', 'Akkordeon: Eintrag hinzufügen');
}
if (block.type === 'section') {
for (const count of [1, 2, 3, 4]) add(`${count} ${count === 1 ? 'Spalte' : 'Spalten'}`, 'data-editor-row', String(count), `${count} ${count === 1 ? 'Spalte' : 'Spalten'} in dieser Sektion anlegen`);
}
empty.append(name, hint, actions);
if (!compact) empty.append(name, hint);
empty.append(actions);
host.append(empty);
}
}