This commit is contained in:
parent
ef5f977f8a
commit
d7871736c8
10 changed files with 566 additions and 8 deletions
|
|
@ -241,6 +241,11 @@ function normalizeCalculatorValue(value) {
|
|||
return Number.isFinite(parsed) ? parsed : 0;
|
||||
}
|
||||
|
||||
function labelFromFileName(name) {
|
||||
if (!name || name === "image.png") return "";
|
||||
return name.replace(/\.[^.]+$/, "").trim();
|
||||
}
|
||||
|
||||
function normalizeCalculatorData(data) {
|
||||
const entries = (data?.entries || [])
|
||||
.map((entry) => ({
|
||||
|
|
@ -313,7 +318,11 @@ function compactModuleDataForStorage(type, value) {
|
|||
if (type === "screenshots") {
|
||||
const shots = (Array.isArray(value?.shots) ? value.shots : [])
|
||||
.filter((shot) => shot?.dataUrl)
|
||||
.map((shot) => ({ id: shot.id || uid("shot"), dataUrl: shot.dataUrl }));
|
||||
.map((shot) => {
|
||||
const compact = { id: shot.id || uid("shot"), dataUrl: shot.dataUrl };
|
||||
if (shot.label) compact.label = shot.label;
|
||||
return compact;
|
||||
});
|
||||
return shots.length ? { shots } : null;
|
||||
}
|
||||
if (type === "imageAnnotation") {
|
||||
|
|
@ -798,7 +807,10 @@ function App() {
|
|||
if (!imageFiles.length) return false;
|
||||
const data = store.getModuleData(toolboxId, moduleId, { shots: [] });
|
||||
for (const file of imageFiles) {
|
||||
data.shots.unshift({ id: uid("shot"), dataUrl: await compressImage(file) });
|
||||
const shot = { id: uid("shot"), dataUrl: await compressImage(file) };
|
||||
const label = labelFromFileName(file.name);
|
||||
if (label) shot.label = label;
|
||||
data.shots.unshift(shot);
|
||||
}
|
||||
return store.updateModuleData(toolboxId, moduleId, data);
|
||||
}
|
||||
|
|
@ -1812,10 +1824,13 @@ function ScreenshotViewer({ shot, onClose }) {
|
|||
<div className="screenshot-viewer-backdrop" onClick={onClose} />
|
||||
<section ref={viewerRef} className="screenshot-viewer" role="dialog" aria-modal="true" aria-label="Screenshot">
|
||||
<header>
|
||||
{!canAnnotate && !hasMarkers && (
|
||||
<button className="screenshot-viewer-button" onClick={() => openImageInNewTab(shot.dataUrl)} aria-label="Ouvrir l'image en taille réelle" title="Taille réelle"><Icon name="zoom" /></button>
|
||||
)}
|
||||
<button className="screenshot-viewer-button" onClick={onClose} aria-label="Fermer" title="Fermer"><Icon name="close" /></button>
|
||||
{shot.label && <strong className="screenshot-viewer-title">{shot.label}</strong>}
|
||||
<div className="screenshot-viewer-actions">
|
||||
{!canAnnotate && !hasMarkers && (
|
||||
<button className="screenshot-viewer-button" onClick={() => openImageInNewTab(shot.dataUrl)} aria-label="Ouvrir l'image en taille réelle" title="Taille réelle"><Icon name="zoom" /></button>
|
||||
)}
|
||||
<button className="screenshot-viewer-button" onClick={onClose} aria-label="Fermer" title="Fermer"><Icon name="close" /></button>
|
||||
</div>
|
||||
</header>
|
||||
<div className={`screenshot-viewer-body ${canAnnotate ? "has-annotation-side" : ""}`}>
|
||||
<div
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue