Upload PDFs to the library, link them from any link target, show them in a viewer

PDFs go through the same upload field as images, are checked by their content and kept
unchanged in their own table. Every link field can pick one, and a page that links a PDF
opens it in a dialog with the browser's own viewer; touch devices and browsers without a
viewer get a new tab instead.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
kantarciandClaude Opus 5 committed 2026-09-22 07:56:29 +02:00
1 parent 04927b9563
commit e8a9dcdf5c
20 files changed
+667 -30

No files matched your search

+16
View File
@@ -360,6 +360,22 @@ try {
const previous = document.querySelector('#preview').contentDocument?.querySelector(`#${id}`)?.previousElementSibling;
return Boolean(previous?.classList.contains('button'));
}, headingId);
// Ein PDF als Linkziel: im Dialog hochladen, übernehmen, die Adresse steht im Feld.
await page.getByRole('button', { name: 'PDF aus Mediathek wählen', exact: true }).click();
const documentDialog = page.locator('dialog.document-dialog');
await documentDialog.waitFor();
await documentDialog.locator('#document-upload:enabled').waitFor({ state: 'attached' });
await documentDialog.locator('#document-upload').setInputFiles({ name: 'Preisliste.pdf', mimeType: 'application/pdf', buffer: Buffer.from('%PDF-1.4\n%%EOF\n') });
await documentDialog.locator('.document-card[aria-pressed="true"]').waitFor();
assert.equal(await documentDialog.locator('#document-error').isHidden(), true, 'the PDF upload reports no error');
const pdfAxe = await new AxeBuilder({ page }).include('dialog.document-dialog').withTags(['wcag2a', 'wcag2aa', 'wcag21a', 'wcag21aa']).analyze();
assert.deepEqual(pdfAxe.violations.map(v => v.id), [], 'the PDF dialog has no accessibility violations');
await documentDialog.getByRole('button', { name: 'PDF übernehmen', exact: true }).click();
await documentDialog.waitFor({ state: 'detached' });
assert.match(await page.locator('#property-href').inputValue(), /^\/media\/[a-f0-9]{32}\.pdf$/);
await page.waitForFunction(() => /^\/media\/[a-f0-9]{32}\.pdf$/.test(document.querySelector('#preview').contentDocument?.querySelector('a.button')?.getAttribute('href') ?? ''));
checks.push({ name: 'a PDF from the library as a link target', passed: true });
await page.getByRole('button', { name: 'Rückgängig', exact: true }).click();
await page.getByRole('button', { name: 'Rückgängig', exact: true }).click();
await page.waitForFunction(count => document.querySelectorAll('#structure [data-block-id]').length === count, beforeButtons);
checks.push({ name: 'canvas toolbar, insert points and drag from the toolbox', passed: true });