feat: add new-tab links and removable media previews (1.7.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 11:48:44 +02:00
1 parent b8991ddd5c
commit 6d21c452bd
28 files changed
+496 -46

No files matched your search

+39
View File
@@ -305,6 +305,45 @@ test('free styles inherit from the wider device, reset individually and leave no
assert.deepEqual(history.document, fixture());
});
test('removing an inherited background upgrades the schema and can be reset or undone', () => {
const history = new EditorHistory(fixture());
history.change(doc => setStyle(doc, 's1', 'desktop', 'backgroundImage', 'a'.repeat(32)));
assert.equal(history.document.schemaVersion, 10);
history.change(doc => setStyle(doc, 's1', 'tablet', 'backgroundImage', 'none'));
const block = () => locate(history.document.blocks, 's1').block;
assert.equal(history.document.schemaVersion, 20);
assert.deepEqual(effectiveStyle(block(), 'mobile', 'backgroundImage'), { value: 'none', source: 'tablet' });
history.change(doc => setStyle(doc, 's1', 'tablet', 'backgroundImage', ''));
assert.deepEqual(effectiveStyle(block(), 'mobile', 'backgroundImage'), { value: 'a'.repeat(32), source: 'desktop' });
history.undo();
assert.equal(block().style.tablet.backgroundImage, 'none');
history.undo();
assert.equal(history.document.schemaVersion, 10);
});
test('replacing an image preserves its link, caption and layout and remains one undo step', () => {
const history = new EditorHistory(fixture());
const first = { id: 'a'.repeat(32), alt: 'First', variants: [{ src: '/media/a/192.webp', width: 192, height: 96 }] };
const second = { id: 'b'.repeat(32), alt: 'Second', variants: [{ src: '/media/b/480.webp', width: 480, height: 320 }] };
const galleryId = history.change(doc => insertMedia(doc, 's1', [first]));
const id = locate(history.document.blocks, galleryId).block.children[0].id;
history.change(doc => {
const block = locate(doc.blocks, id).block;
Object.assign(block.props, { href: '/kontakt', click: 'link', newTab: true, caption: 'Meine Bildunterschrift' });
setStyle(doc, id, 'desktop', 'width', '50%'); upgradeDocument(doc, 20);
});
const before = structuredClone(history.document);
history.change(doc => insertMedia(doc, id, [second]));
const replaced = locate(history.document.blocks, id).block;
assert.equal(replaced.props.mediaId, second.id);
assert.equal(replaced.props.width, 480); assert.equal(replaced.props.height, 320);
assert.equal(replaced.props.alt, 'Second'); assert.equal(replaced.props.href, '/kontakt');
assert.equal(replaced.props.click, 'link'); assert.equal(replaced.props.newTab, true);
assert.equal(replaced.props.caption, 'Meine Bildunterschrift');
assert.equal(replaced.style.desktop.width, '50%');
history.undo(); assert.deepEqual(history.document, before);
});
test('a row arrives with its columns, inside the selected container', () => {
const history = new EditorHistory(fixture());