Fassung 1.5.4: der Werkzeugkasten bekommt Bilder und eine Suche
Die Elementwahl war eine Liste aus Schriftzeichen - "▣" fuer Sektion, "☰" fuer Zeile. Jetzt traegt jeder der 34 Eintraege eine Strichzeichnung, die zeigt, was er baut: die Sektion ein gefuelltes Band, "Zeile, 3 Spalten" tatsaechlich drei Kaesten, das Bild einen Rahmen mit Bergzug. Zeichnungen statt Bilddateien. Flatsome liefert je Element ein PNG mit. Gezeichnet ist hier besser: library-previews.js ist ein paar hundert Byte statt eines Ordners voller Bitmaps, die Formen nehmen die Farbe der Flaeche an, auf der sie liegen - gesperrte Eintraege werden damit von selbst blass - und sie bleiben auf jedem Bildschirm scharf. Die Zeilenvorschau wird gerechnet: zwei, drei oder vier Kaesten aus derselben Funktion. Suche. Ein Feld ueber der Liste filtert ueber alle Gruppen, gesucht wird ueber Namen, internen Typ und Gruppennamen - wer "slider" eingibt, muss nicht wissen, dass er unter "Gruppen" steht. Gruppen ohne Treffer verschwinden, darunter steht wie viele von wie vielen uebrig sind. Dabei bemerkt: es gab zwei Suchfelder namens "Element suchen" auf einem Bildschirm, fuer eine Sprachausgabe nicht unterscheidbar. Sie heissen jetzt nach dem, was sie durchsuchen. Geprueft: der Browsertest zaehlt die Vorschaubilder gegen die Eintraege und sucht nach Name, Gruppenname und etwas Nichtvorhandenem. npm test 28/28, phpunit 452/452, npm run test:editor vollstaendig ohne axe-Verstoss. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
9726af9254
commit
7c3c8671a7
8 files changed
+176
-19
No files matched your search
+32
-7
@@ -1,8 +1,9 @@
|
||||
import { EditorHistory, labels, icons, blockLabel, blockIcon, isPluginBlock, setStyle, effectiveStyle, locate, clone, isContainer, canContain, insertBlock, insertBlockAt, insertionTarget, moveBlockTo, duplicateBlock, moveBlock, devices, effectiveDesign, setDesign, blockPath, insertPreset, insertRow, insertRowAt, setEffect, insertMedia, upgradeDocument, CATEGORIES, ROW_COLUMNS, whyNot, dropList } from './editor-model.js';
|
||||
import { EditorHistory, labels, blockLabel, blockIcon, isPluginBlock, setStyle, effectiveStyle, locate, clone, isContainer, canContain, insertBlock, insertBlockAt, insertionTarget, moveBlockTo, duplicateBlock, moveBlock, devices, effectiveDesign, setDesign, blockPath, insertPreset, insertRow, insertRowAt, setEffect, insertMedia, upgradeDocument, CATEGORIES, ROW_COLUMNS, whyNot, dropList } from './editor-model.js';
|
||||
import { openMedia } from './media.js';
|
||||
import { createDesignPanel } from './design-panel.js';
|
||||
import { createRichText } from './rich-text.js';
|
||||
import { createCanvasOverlay } from './canvas-overlay.js';
|
||||
import { preview, rowPreview } from './library-previews.js';
|
||||
|
||||
// Mirrors DocumentValidator::ICONS; the server rejects anything outside this list.
|
||||
const ICONS = ['app', 'web', 'design', 'network', 'hardware', 'shop', 'support', 'shield', 'clock', 'star', 'phone', 'mail', 'pin', 'check'];
|
||||
@@ -68,7 +69,7 @@ function controls() {
|
||||
updateLibrary();
|
||||
$('#presets').querySelectorAll('button').forEach(button => button.disabled = !ready || busy);
|
||||
$('#properties').querySelectorAll('input,textarea,select,button').forEach(input => input.disabled = busy);
|
||||
document.querySelectorAll('[data-panel],[data-viewport],#tree-search,#expand-all,#collapse-all').forEach(input => input.disabled = !ready || busy);
|
||||
document.querySelectorAll('[data-panel],[data-viewport],#tree-search,#library-search,#expand-all,#collapse-all').forEach(input => input.disabled = !ready || busy);
|
||||
$('[data-panel="design"]').disabled ||= !current;
|
||||
$('#select-page').disabled = !ready || busy;
|
||||
$('#open-media-library').disabled = !ready || busy;
|
||||
@@ -756,12 +757,18 @@ function buildLibrary() {
|
||||
button.type = 'button'; button.draggable = true;
|
||||
button.dataset.add = type;
|
||||
if (columns) button.dataset.row = String(columns);
|
||||
const glyph = document.createElement('span'); glyph.setAttribute('aria-hidden', 'true');
|
||||
glyph.textContent = columns ? '▥'.repeat(Math.min(columns, 4)) : icons[type];
|
||||
if (columns) glyph.className = 'library-row-glyph';
|
||||
const name = columns ? `${labels[type]}, ${columns} Spalten` : labels[type];
|
||||
// What is searched for: the name, the internal type and the group it sits in. Someone
|
||||
// looking for "slider" should not have to know it is filed under "Gruppen".
|
||||
button.dataset.search = `${name} ${type} ${category.name}`.toLocaleLowerCase('de');
|
||||
const picture = document.createElement('span');
|
||||
picture.className = 'library-preview';
|
||||
// Drawn, not written: the shapes come from this editor and carry no untrusted text.
|
||||
picture.innerHTML = columns ? rowPreview(columns) : preview(type);
|
||||
const text = document.createElement('span');
|
||||
text.textContent = columns ? `${labels[type]}, ${columns} Spalten` : labels[type];
|
||||
button.append(glyph, text);
|
||||
text.className = 'library-name';
|
||||
text.textContent = name;
|
||||
button.append(picture, text);
|
||||
list.append(button);
|
||||
}
|
||||
}
|
||||
@@ -789,6 +796,24 @@ function updateLibrary() {
|
||||
}
|
||||
}
|
||||
|
||||
/** Filters the toolbox. A group without a hit disappears, so the list does not keep its gaps. */
|
||||
function filterLibrary() {
|
||||
const term = $('#library-search').value.trim().toLocaleLowerCase('de');
|
||||
let hits = 0;
|
||||
for (const group of $('#library').querySelectorAll('.library-group')) {
|
||||
let visible = 0;
|
||||
for (const button of group.querySelectorAll('button')) {
|
||||
const hit = '' === term || (button.dataset.search ?? '').includes(term);
|
||||
button.hidden = !hit;
|
||||
if (hit) visible++;
|
||||
}
|
||||
group.hidden = 0 === visible;
|
||||
hits += visible;
|
||||
}
|
||||
$('#library-found').textContent = '' === term ? '' : (0 === hits ? 'Kein Element mit diesem Namen.' : `${hits} von ${$('#library').querySelectorAll('button').length}`);
|
||||
}
|
||||
$('#library-search').addEventListener('input', filterLibrary);
|
||||
|
||||
$('#library').addEventListener('click', event => {
|
||||
const button = event.target.closest('[data-add]');
|
||||
if (!button || button.disabled) return;
|
||||
|
||||
Reference in new issue
Block a user