Explorateur : vue Galerie, panneau Détails et tri
Troisième vue de l'explorateur : il couvre toute la zone de travail, dossiers en cartes et schémas en grandes tuiles (miniature 640 px, nom complet, date relative et dernier auteur, taille, versions, partages, compteurs d'éléments, tags). Le panneau Détails (bouton ⓘ ou menu) affiche création, dimensions, fond, cadres, dernières versions et liens de partage. Ouvrir un schéma referme la galerie ; ☰ ou Échap y ramène. Tri par nom, date de modification ou taille dans toutes les vues. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01PbFY8ZmoErQdPvgvAN3MBU
This commit is contained in:
1 parent
ef76967aa2
commit
99b088acf6
9 files changed
+1187
-106
No files matched your search
+18
-9
@@ -15,7 +15,7 @@ import type {
|
|||||||
} from "@excalidraw/excalidraw/types";
|
} from "@excalidraw/excalidraw/types";
|
||||||
import type { OrderedExcalidrawElement } from "@excalidraw/excalidraw/element/types";
|
import type { OrderedExcalidrawElement } from "@excalidraw/excalidraw/element/types";
|
||||||
import { api, ApiError, basename, displayPath, stripExt, type Settings } from "./api";
|
import { api, ApiError, basename, displayPath, stripExt, type Settings } from "./api";
|
||||||
import { Explorer } from "./Explorer";
|
import { Explorer, initialView, type View } from "./Explorer";
|
||||||
import { CloseIcon, HistoryIcon, MenuIcon, MoonIcon, PinIcon, SaveIcon, SettingsIcon, ShareIcon, SunIcon, UpdateIcon } from "./icons";
|
import { CloseIcon, HistoryIcon, MenuIcon, MoonIcon, PinIcon, SaveIcon, SettingsIcon, ShareIcon, SunIcon, UpdateIcon } from "./icons";
|
||||||
import { ShareDialog } from "./ShareDialog";
|
import { ShareDialog } from "./ShareDialog";
|
||||||
import { HistoryDialog } from "./HistoryDialog";
|
import { HistoryDialog } from "./HistoryDialog";
|
||||||
@@ -97,8 +97,11 @@ export default function App() {
|
|||||||
const [scene, setScene] = useState<Scene | null>(null);
|
const [scene, setScene] = useState<Scene | null>(null);
|
||||||
const [saveState, setSaveState] = useState<SaveState>("saved");
|
const [saveState, setSaveState] = useState<SaveState>("saved");
|
||||||
const [pinned, setPinned] = useState(initialPinned);
|
const [pinned, setPinned] = useState(initialPinned);
|
||||||
// Non épinglé : ouvert d'office tant qu'aucun schéma n'est demandé.
|
// Vue Galerie : l'explorateur couvre toute la zone de travail, comme un panneau
|
||||||
const [drawerOpen, setDrawerOpen] = useState(() => !isMobile() && (pinned || !pathFromHash()));
|
// flottant (il se referme à l'ouverture d'un schéma).
|
||||||
|
const [gallery, setGallery] = useState(() => initialView() === "gallery");
|
||||||
|
// Non épinglé ou Galerie : ouvert d'office tant qu'aucun schéma n'est demandé.
|
||||||
|
const [drawerOpen, setDrawerOpen] = useState(() => !isMobile() && ((pinned && !gallery) || !pathFromHash()));
|
||||||
const [instant, setInstant] = useState(false); // bascule sans animation de la grille
|
const [instant, setInstant] = useState(false); // bascule sans animation de la grille
|
||||||
const [refreshKey, setRefreshKey] = useState(0);
|
const [refreshKey, setRefreshKey] = useState(0);
|
||||||
const [loadError, setLoadError] = useState<string | null>(null);
|
const [loadError, setLoadError] = useState<string | null>(null);
|
||||||
@@ -126,6 +129,8 @@ export default function App() {
|
|||||||
const openRef = useRef<(path: string, opts?: { skipFlush?: boolean }) => Promise<void>>(async () => {});
|
const openRef = useRef<(path: string, opts?: { skipFlush?: boolean }) => Promise<void>>(async () => {});
|
||||||
const pinnedRef = useRef(pinned);
|
const pinnedRef = useRef(pinned);
|
||||||
pinnedRef.current = pinned;
|
pinnedRef.current = pinned;
|
||||||
|
const galleryRef = useRef(gallery);
|
||||||
|
galleryRef.current = gallery;
|
||||||
const peek = useRef<"hover" | "click" | null>(null); // comment le panneau non épinglé a été ouvert
|
const peek = useRef<"hover" | "click" | null>(null); // comment le panneau non épinglé a été ouvert
|
||||||
const peekTimer = useRef<number>(undefined);
|
const peekTimer = useRef<number>(undefined);
|
||||||
const scrollShift = useRef(0); // décalage du canevas à compenser après une bascule épinglé/non épinglé
|
const scrollShift = useRef(0); // décalage du canevas à compenser après une bascule épinglé/non épinglé
|
||||||
@@ -240,7 +245,7 @@ export default function App() {
|
|||||||
setSaveState("saved");
|
setSaveState("saved");
|
||||||
if (location.hash !== `#/${path}`) history.replaceState(null, "", `#/${encodeURI(path)}`);
|
if (location.hash !== `#/${path}`) history.replaceState(null, "", `#/${encodeURI(path)}`);
|
||||||
store("lastScene", path);
|
store("lastScene", path);
|
||||||
if (isMobile() || !pinnedRef.current) setDrawerOpen(false);
|
if (isMobile() || !pinnedRef.current || galleryRef.current) setDrawerOpen(false);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
setLoadError(`Impossible d'ouvrir « ${path} » : ${e instanceof Error ? e.message : e}`);
|
setLoadError(`Impossible d'ouvrir « ${path} » : ${e instanceof Error ? e.message : e}`);
|
||||||
}
|
}
|
||||||
@@ -254,8 +259,8 @@ export default function App() {
|
|||||||
excalidraw.current = null;
|
excalidraw.current = null;
|
||||||
setScene(null);
|
setScene(null);
|
||||||
history.replaceState(null, "", location.pathname);
|
history.replaceState(null, "", location.pathname);
|
||||||
// Non épinglé : l'explorateur revient pour choisir le schéma suivant.
|
// Non épinglé ou Galerie : l'explorateur revient pour choisir le schéma suivant.
|
||||||
if (!pinnedRef.current && !isMobile()) {
|
if ((!pinnedRef.current || galleryRef.current) && !isMobile()) {
|
||||||
peek.current = "click";
|
peek.current = "click";
|
||||||
setDrawerOpen(true);
|
setDrawerOpen(true);
|
||||||
}
|
}
|
||||||
@@ -431,7 +436,10 @@ export default function App() {
|
|||||||
return () => cancelAnimationFrame(id);
|
return () => cancelAnimationFrame(id);
|
||||||
}, [pinned, instant]);
|
}, [pinned, instant]);
|
||||||
|
|
||||||
const floating = !pinned && drawerOpen;
|
// Panneau par-dessus le schéma : non épinglé, ou Galerie quand un schéma est ouvert.
|
||||||
|
const floating = drawerOpen && (!pinned || (gallery && !!scene));
|
||||||
|
|
||||||
|
const onViewChange = useCallback((v: View) => setGallery(v === "gallery"), []);
|
||||||
|
|
||||||
const peekOpen = () => {
|
const peekOpen = () => {
|
||||||
clearTimeout(peekTimer.current);
|
clearTimeout(peekTimer.current);
|
||||||
@@ -517,7 +525,7 @@ export default function App() {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
className={`app ${drawerOpen ? "drawer-open" : ""} ${pinned ? "pinned" : "unpinned"} ${resizing ? "resizing" : ""} ${instant ? "instant" : ""} ${scene ? "has-scene" : ""}`}
|
className={`app ${drawerOpen ? "drawer-open" : ""} ${pinned ? "pinned" : "unpinned"} ${gallery ? "gallery" : ""} ${resizing ? "resizing" : ""} ${instant ? "instant" : ""} ${scene ? "has-scene" : ""}`}
|
||||||
style={{ "--drawer-w": `${drawerWidth}px` } as CSSProperties}
|
style={{ "--drawer-w": `${drawerWidth}px` } as CSSProperties}
|
||||||
>
|
>
|
||||||
<header className="topbar">
|
<header className="topbar">
|
||||||
@@ -626,6 +634,7 @@ export default function App() {
|
|||||||
onDeleted={onDeleted}
|
onDeleted={onDeleted}
|
||||||
onHistory={showHistory}
|
onHistory={showHistory}
|
||||||
onShare={setShareFor}
|
onShare={setShareFor}
|
||||||
|
onViewChange={onViewChange}
|
||||||
toolbarEnd={
|
toolbarEnd={
|
||||||
<button
|
<button
|
||||||
className={`icon-btn pin-btn ${pinned ? "on" : ""}`}
|
className={`icon-btn pin-btn ${pinned ? "on" : ""}`}
|
||||||
@@ -652,7 +661,7 @@ export default function App() {
|
|||||||
onReset={() => setDrawerWidth(clampDrawer(DRAWER_DEFAULT))}
|
onReset={() => setDrawerWidth(clampDrawer(DRAWER_DEFAULT))}
|
||||||
/>
|
/>
|
||||||
<div className="backdrop" onClick={() => setDrawerOpen(false)} />
|
<div className="backdrop" onClick={() => setDrawerOpen(false)} />
|
||||||
{!pinned && !drawerOpen && (
|
{!pinned && !drawerOpen && !gallery && (
|
||||||
<div className="peek-edge" aria-hidden onMouseEnter={peekOpen} onMouseLeave={peekCancel} />
|
<div className="peek-edge" aria-hidden onMouseEnter={peekOpen} onMouseLeave={peekCancel} />
|
||||||
)}
|
)}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,201 @@
|
|||||||
|
import { useEffect, useState } from "react";
|
||||||
|
import { api, dirname, displayPath, stripExt, type Hit, type Share, type Version } from "./api";
|
||||||
|
import { fmtDate, fmtRelative, fmtSize, plural, who } from "./format";
|
||||||
|
import { CloseIcon, FolderIcon, HistoryIcon, ShareIcon, StarFilledIcon, StarIcon } from "./icons";
|
||||||
|
import { Thumb } from "./Thumb";
|
||||||
|
import { expectedThumb } from "./thumbs";
|
||||||
|
|
||||||
|
interface Props {
|
||||||
|
entry: Hit;
|
||||||
|
onOpen: (path: string) => void;
|
||||||
|
onLocate: (dir: string) => void;
|
||||||
|
onHistory: (path: string) => void;
|
||||||
|
onShare: (path: string) => void;
|
||||||
|
onFavorite: (e: Hit) => void;
|
||||||
|
onTag: (tag: string) => void;
|
||||||
|
onClose: () => void;
|
||||||
|
}
|
||||||
|
|
||||||
|
const LAST_VERSIONS = 5;
|
||||||
|
|
||||||
|
/** Panneau Détails de la vue Galerie : métadonnées complètes d'un schéma. */
|
||||||
|
export function DetailsPanel({ entry: e, onOpen, onLocate, onHistory, onShare, onFavorite, onTag, onClose }: Props) {
|
||||||
|
const [versions, setVersions] = useState<Version[] | null>(null);
|
||||||
|
const [shares, setShares] = useState<Share[] | null>(null);
|
||||||
|
const d = e.details ?? {};
|
||||||
|
|
||||||
|
// Versions et liens : relus quand le schéma change (modTime) ou qu'on en change.
|
||||||
|
useEffect(() => {
|
||||||
|
let live = true;
|
||||||
|
setVersions(null);
|
||||||
|
setShares(null);
|
||||||
|
api.history(e.path).then((v) => live && setVersions(v), () => live && setVersions([]));
|
||||||
|
api.shares(e.path).then((s) => live && setShares(s), () => live && setShares([]));
|
||||||
|
return () => {
|
||||||
|
live = false;
|
||||||
|
};
|
||||||
|
}, [e.path, e.modTime]);
|
||||||
|
|
||||||
|
const content = [
|
||||||
|
d.elements ? plural(d.elements, "élément") : "vide",
|
||||||
|
d.texts ? plural(d.texts, "texte") : "",
|
||||||
|
d.arrows ? plural(d.arrows, "flèche") : "",
|
||||||
|
d.images ? plural(d.images, "image") : "",
|
||||||
|
d.frames ? plural(d.frames, "cadre") : "",
|
||||||
|
].filter(Boolean);
|
||||||
|
const location = displayPath(dirname(e.path)) || "Racine";
|
||||||
|
|
||||||
|
return (
|
||||||
|
<aside className="details-panel" aria-label="Détails du schéma">
|
||||||
|
<div className="details-head">
|
||||||
|
<h3 title={e.name}>{stripExt(e.name)}</h3>
|
||||||
|
<button className="icon-btn" onClick={onClose} aria-label="Fermer les détails" title="Fermer (Échap)">
|
||||||
|
<CloseIcon />
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
<button className="details-shot" onClick={() => onOpen(e.path)} title="Ouvrir le schéma">
|
||||||
|
<Thumb path={e.path} version={e.modTime} minSize={expectedThumb(d.width, d.height)} />
|
||||||
|
</button>
|
||||||
|
<button className="details-where" onClick={() => onLocate(dirname(e.path))} title="Ouvrir l'emplacement">
|
||||||
|
<FolderIcon size={14} />
|
||||||
|
{location}
|
||||||
|
</button>
|
||||||
|
<div className="details-actions">
|
||||||
|
<button className="primary" onClick={() => onOpen(e.path)}>
|
||||||
|
Ouvrir
|
||||||
|
</button>
|
||||||
|
<button onClick={() => onShare(e.path)}>
|
||||||
|
<ShareIcon />
|
||||||
|
Partager
|
||||||
|
</button>
|
||||||
|
<button onClick={() => onHistory(e.path)}>
|
||||||
|
<HistoryIcon />
|
||||||
|
Historique
|
||||||
|
</button>
|
||||||
|
<button
|
||||||
|
className="square"
|
||||||
|
onClick={() => onFavorite(e)}
|
||||||
|
title={e.favorite ? "Retirer des favoris" : "Ajouter aux favoris"}
|
||||||
|
aria-label={e.favorite ? "Retirer des favoris" : "Ajouter aux favoris"}
|
||||||
|
aria-pressed={!!e.favorite}
|
||||||
|
>
|
||||||
|
{e.favorite ? <StarFilledIcon /> : <StarIcon />}
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<dl>
|
||||||
|
<dt>Modifié</dt>
|
||||||
|
<dd>
|
||||||
|
{fmtDate(e.modTime)} <span className="muted">({fmtRelative(e.modTime)})</span>
|
||||||
|
{who(e.editedBy) && <span className="muted"> par {e.editedBy}</span>}
|
||||||
|
</dd>
|
||||||
|
{d.created && (
|
||||||
|
<>
|
||||||
|
<dt>Créé</dt>
|
||||||
|
<dd>
|
||||||
|
{fmtDate(d.created)}
|
||||||
|
{who(d.createdBy) ? (
|
||||||
|
<span className="muted"> par {d.createdBy}</span>
|
||||||
|
) : (
|
||||||
|
<span className="muted" title="Date de la plus ancienne version conservée">
|
||||||
|
{" "}
|
||||||
|
(plus ancienne version)
|
||||||
|
</span>
|
||||||
|
)}
|
||||||
|
</dd>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
<dt>Taille</dt>
|
||||||
|
<dd>{fmtSize(e.size)}</dd>
|
||||||
|
<dt>Contenu</dt>
|
||||||
|
<dd>{content.join(", ")}</dd>
|
||||||
|
{!!d.width && !!d.height && (
|
||||||
|
<>
|
||||||
|
<dt>Dimensions</dt>
|
||||||
|
<dd>
|
||||||
|
{d.width.toLocaleString()} × {d.height.toLocaleString()} px
|
||||||
|
</dd>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
{d.background && (
|
||||||
|
<>
|
||||||
|
<dt>Fond</dt>
|
||||||
|
<dd className="swatch-line">
|
||||||
|
<span className="swatch" style={{ background: d.background }} />
|
||||||
|
{d.background}
|
||||||
|
</dd>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
{!!e.tags?.length && (
|
||||||
|
<>
|
||||||
|
<dt>Tags</dt>
|
||||||
|
<dd className="tags">
|
||||||
|
{e.tags.map((t) => (
|
||||||
|
<button key={t} className="chip" onClick={() => onTag(t)} title={`Filtrer sur « ${t} »`}>
|
||||||
|
{t}
|
||||||
|
</button>
|
||||||
|
))}
|
||||||
|
</dd>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
</dl>
|
||||||
|
|
||||||
|
{!!d.frameNames?.length && (
|
||||||
|
<section>
|
||||||
|
<h4>Cadres</h4>
|
||||||
|
<ul>
|
||||||
|
{d.frameNames.map((f, i) => (
|
||||||
|
<li key={i}>{f}</li>
|
||||||
|
))}
|
||||||
|
{(d.frames ?? 0) > d.frameNames.length && (
|
||||||
|
<li className="muted">et {d.frames! - d.frameNames.length} autres</li>
|
||||||
|
)}
|
||||||
|
</ul>
|
||||||
|
</section>
|
||||||
|
)}
|
||||||
|
|
||||||
|
<section>
|
||||||
|
<h4>Versions{versions && versions.length > 0 ? ` (${versions.length})` : ""}</h4>
|
||||||
|
{versions === null ? (
|
||||||
|
<p className="muted">Chargement…</p>
|
||||||
|
) : versions.length === 0 ? (
|
||||||
|
<p className="muted">Aucune version enregistrée</p>
|
||||||
|
) : (
|
||||||
|
<ul>
|
||||||
|
{versions.slice(0, LAST_VERSIONS).map((v) => (
|
||||||
|
<li key={v.id}>
|
||||||
|
<span>{fmtDate(v.time)}</span>
|
||||||
|
<span className="muted">{fmtSize(v.size)}</span>
|
||||||
|
</li>
|
||||||
|
))}
|
||||||
|
{versions.length > LAST_VERSIONS && (
|
||||||
|
<li>
|
||||||
|
<button className="link" onClick={() => onHistory(e.path)}>
|
||||||
|
Tout l'historique…
|
||||||
|
</button>
|
||||||
|
</li>
|
||||||
|
)}
|
||||||
|
</ul>
|
||||||
|
)}
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<section>
|
||||||
|
<h4>Partages actifs{shares && shares.length > 0 ? ` (${shares.length})` : ""}</h4>
|
||||||
|
{shares === null ? (
|
||||||
|
<p className="muted">Chargement…</p>
|
||||||
|
) : shares.length === 0 ? (
|
||||||
|
<p className="muted">Aucun lien de partage</p>
|
||||||
|
) : (
|
||||||
|
<ul>
|
||||||
|
{shares.map((s) => (
|
||||||
|
<li key={s.id}>
|
||||||
|
<span title={api.shareUrl(s.token)}>Créé le {fmtDate(s.created)}</span>
|
||||||
|
<span className="muted">{s.expires ? `expire le ${fmtDate(s.expires)}` : "sans expiration"}</span>
|
||||||
|
</li>
|
||||||
|
))}
|
||||||
|
</ul>
|
||||||
|
)}
|
||||||
|
</section>
|
||||||
|
</aside>
|
||||||
|
);
|
||||||
|
}
|
||||||
+349
-87
@@ -19,6 +19,8 @@ import {
|
|||||||
type TagCount,
|
type TagCount,
|
||||||
} from "./api";
|
} from "./api";
|
||||||
import {
|
import {
|
||||||
|
ArrowIcon,
|
||||||
|
ClockIcon,
|
||||||
CloseIcon,
|
CloseIcon,
|
||||||
DeselectIcon,
|
DeselectIcon,
|
||||||
CopyIcon,
|
CopyIcon,
|
||||||
@@ -30,18 +32,26 @@ import {
|
|||||||
FolderIcon,
|
FolderIcon,
|
||||||
FolderPlusIcon,
|
FolderPlusIcon,
|
||||||
FolderUploadIcon,
|
FolderUploadIcon,
|
||||||
|
FrameIcon,
|
||||||
|
GalleryIcon,
|
||||||
GridIcon,
|
GridIcon,
|
||||||
HistoryIcon,
|
HistoryIcon,
|
||||||
|
InfoIcon,
|
||||||
ListIcon,
|
ListIcon,
|
||||||
MoveIcon,
|
MoveIcon,
|
||||||
|
PhotoIcon,
|
||||||
RefreshIcon,
|
RefreshIcon,
|
||||||
RestoreIcon,
|
RestoreIcon,
|
||||||
SearchIcon,
|
SearchIcon,
|
||||||
SelectAllIcon,
|
SelectAllIcon,
|
||||||
|
ShapesIcon,
|
||||||
ShareIcon,
|
ShareIcon,
|
||||||
|
SizeIcon,
|
||||||
|
SortIcon,
|
||||||
StarFilledIcon,
|
StarFilledIcon,
|
||||||
StarIcon,
|
StarIcon,
|
||||||
TagIcon,
|
TagIcon,
|
||||||
|
TextIcon,
|
||||||
TrashFullIcon,
|
TrashFullIcon,
|
||||||
TrashIcon,
|
TrashIcon,
|
||||||
UpIcon,
|
UpIcon,
|
||||||
@@ -49,12 +59,15 @@ import {
|
|||||||
UserIcon,
|
UserIcon,
|
||||||
} from "./icons";
|
} from "./icons";
|
||||||
import { ActionMenu } from "./ActionMenu";
|
import { ActionMenu } from "./ActionMenu";
|
||||||
|
import { DetailsPanel } from "./DetailsPanel";
|
||||||
|
import { fmtDate, fmtRelative, fmtSize, plural, who } from "./format";
|
||||||
import { FolderGlyph } from "./folderIcons";
|
import { FolderGlyph } from "./folderIcons";
|
||||||
import { IconDialog } from "./IconDialog";
|
import { IconDialog } from "./IconDialog";
|
||||||
import { collectDrop, collectFiles, hasFiles, type Collected } from "./importer";
|
import { collectDrop, collectFiles, hasFiles, type Collected } from "./importer";
|
||||||
import { MoveDialog } from "./MoveDialog";
|
import { MoveDialog } from "./MoveDialog";
|
||||||
import { TagsDialog } from "./TagsDialog";
|
import { TagsDialog } from "./TagsDialog";
|
||||||
import { Thumb } from "./Thumb";
|
import { Thumb } from "./Thumb";
|
||||||
|
import { expectedThumb } from "./thumbs";
|
||||||
|
|
||||||
export const EMPTY_SCENE = JSON.stringify({
|
export const EMPTY_SCENE = JSON.stringify({
|
||||||
type: "excalidraw",
|
type: "excalidraw",
|
||||||
@@ -81,38 +94,64 @@ interface Props {
|
|||||||
onShare: (path: string) => void;
|
onShare: (path: string) => void;
|
||||||
/** Contenu ajouté au bout de la barre de recherche (bouton d'épinglage du panneau). */
|
/** Contenu ajouté au bout de la barre de recherche (bouton d'épinglage du panneau). */
|
||||||
toolbarEnd?: ReactNode;
|
toolbarEnd?: ReactNode;
|
||||||
|
/** Changement de vue : la Galerie occupe toute la zone de travail (App). */
|
||||||
|
onViewChange?: (view: View) => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
type View = "list" | "grid";
|
/** Vignettes, liste, ou Galerie (grandes tuiles avec métadonnées, pleine largeur). */
|
||||||
|
export type View = "list" | "grid" | "gallery";
|
||||||
|
|
||||||
const fmtDate = (iso: string) =>
|
/** Tri de l'affichage : nom (ordre du serveur), date de modification ou taille. */
|
||||||
new Date(iso).toLocaleString(undefined, { dateStyle: "short", timeStyle: "short" });
|
type Sort = "name" | "modified" | "size";
|
||||||
|
|
||||||
const fmtSize = (n: number) =>
|
|
||||||
n < 1024 ? `${n} o` : n < 1 << 20 ? `${(n / 1024).toFixed(1)} Ko` : `${(n / (1 << 20)).toFixed(1)} Mo`;
|
|
||||||
|
|
||||||
const plural = (n: number, word: string) => `${n} ${word}${n > 1 ? "s" : ""}`;
|
|
||||||
|
|
||||||
const DND_TYPE = "application/x-excalidraw-paths";
|
const DND_TYPE = "application/x-excalidraw-paths";
|
||||||
|
|
||||||
const initialView = (): View => {
|
const stored = <T extends string>(key: string, allowed: readonly T[], fallback: T): T => {
|
||||||
try {
|
try {
|
||||||
return localStorage.getItem("explorerView") === "list" ? "list" : "grid";
|
const v = localStorage.getItem(key) as T | null;
|
||||||
|
return v && allowed.includes(v) ? v : fallback;
|
||||||
} catch {
|
} catch {
|
||||||
return "grid";
|
return fallback;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const initialView = () => stored<View>("explorerView", ["list", "grid", "gallery"], "grid");
|
||||||
|
const initialSort = () => stored<Sort>("explorerSort", ["name", "modified", "size"], "name");
|
||||||
|
|
||||||
|
/** Rang d'affichage : dossiers virtuels, puis dossiers, puis schémas. */
|
||||||
|
const rank = (e: Entry) => (e.special ? 0 : e.isDir ? 1 : 2);
|
||||||
|
|
||||||
|
const sortEntries = <T extends Entry>(list: T[], sort: Sort): T[] => {
|
||||||
|
if (sort === "name") return list; // ordre du serveur (nom ; pertinence pour une recherche)
|
||||||
|
const by =
|
||||||
|
sort === "modified"
|
||||||
|
? (a: T, b: T) => Date.parse(b.modTime) - Date.parse(a.modTime)
|
||||||
|
: (a: T, b: T) => (a.isDir ? 0 : b.size - a.size);
|
||||||
|
return [...list].sort((a, b) => rank(a) - rank(b) || (a.special ? 0 : by(a, b)));
|
||||||
|
};
|
||||||
|
|
||||||
/** Un élément peut-il être déplacé dans targetDir ? (pas sur place, pas dans lui-même) */
|
/** Un élément peut-il être déplacé dans targetDir ? (pas sur place, pas dans lui-même) */
|
||||||
const canMoveInto = (path: string, targetDir: string) =>
|
const canMoveInto = (path: string, targetDir: string) =>
|
||||||
dirname(path) !== targetDir && targetDir !== path && !targetDir.startsWith(path + "/");
|
dirname(path) !== targetDir && targetDir !== path && !targetDir.startsWith(path + "/");
|
||||||
|
|
||||||
export function Explorer({ current, refreshKey, onOpen, onMoved, onDeleted, onHistory, onShare, toolbarEnd }: Props) {
|
export function Explorer({
|
||||||
|
current,
|
||||||
|
refreshKey,
|
||||||
|
onOpen,
|
||||||
|
onMoved,
|
||||||
|
onDeleted,
|
||||||
|
onHistory,
|
||||||
|
onShare,
|
||||||
|
toolbarEnd,
|
||||||
|
onViewChange,
|
||||||
|
}: Props) {
|
||||||
const [dir, setDir] = useState(() => (current ? dirname(current) : ""));
|
const [dir, setDir] = useState(() => (current ? dirname(current) : ""));
|
||||||
const [entries, setEntries] = useState<Entry[]>([]);
|
const [entries, setEntries] = useState<Entry[]>([]);
|
||||||
const [query, setQuery] = useState("");
|
const [query, setQuery] = useState("");
|
||||||
const [results, setResults] = useState<Hit[] | null>(null);
|
const [results, setResults] = useState<Hit[] | null>(null);
|
||||||
const [view, setView] = useState<View>(initialView);
|
const [view, setView] = useState<View>(initialView);
|
||||||
|
const [sort, setSort] = useState<Sort>(initialSort);
|
||||||
|
const [inspect, setInspect] = useState<string | null>(null); // schéma du panneau Détails (Galerie)
|
||||||
const [selected, setSelected] = useState<Set<string>>(new Set());
|
const [selected, setSelected] = useState<Set<string>>(new Set());
|
||||||
const [anchor, setAnchor] = useState<string | null>(null); // origine d'une sélection Maj+clic
|
const [anchor, setAnchor] = useState<string | null>(null); // origine d'une sélection Maj+clic
|
||||||
const [menu, setMenu] = useState<{ entry: Hit; anchor: HTMLElement } | null>(null); // menu « … » ouvert
|
const [menu, setMenu] = useState<{ entry: Hit; anchor: HTMLElement } | null>(null); // menu « … » ouvert
|
||||||
@@ -132,6 +171,8 @@ export function Explorer({ current, refreshKey, onOpen, onMoved, onDeleted, onHi
|
|||||||
const stay = useRef<string | null>(null); // schéma ouvert depuis Favoris : on reste dans Favoris
|
const stay = useRef<string | null>(null); // schéma ouvert depuis Favoris : on reste dans Favoris
|
||||||
|
|
||||||
const list = results ?? entries;
|
const list = results ?? entries;
|
||||||
|
const shown = sortEntries(list, sort);
|
||||||
|
const gallery = view === "gallery";
|
||||||
const filter = { tag: tagFilter };
|
const filter = { tag: tagFilter };
|
||||||
const filtering = query.trim() !== "" || tagFilter !== null;
|
const filtering = query.trim() !== "" || tagFilter !== null;
|
||||||
// Dossier Favoris : des liens vers les originaux, ni création ni déplacement.
|
// Dossier Favoris : des liens vers les originaux, ni création ni déplacement.
|
||||||
@@ -143,6 +184,7 @@ export function Explorer({ current, refreshKey, onOpen, onMoved, onDeleted, onHi
|
|||||||
const closeMenu = useCallback(() => setMenu(null), []);
|
const closeMenu = useCallback(() => setMenu(null), []);
|
||||||
// La liste change de forme : le bouton « … » d'origine disparaît.
|
// La liste change de forme : le bouton « … » d'origine disparaît.
|
||||||
useEffect(closeMenu, [view, dir, results, closeMenu]);
|
useEffect(closeMenu, [view, dir, results, closeMenu]);
|
||||||
|
useEffect(() => setInspect(null), [dir, results === null, view]);
|
||||||
|
|
||||||
const guard = useCallback(async (fn: () => Promise<unknown>) => {
|
const guard = useCallback(async (fn: () => Promise<unknown>) => {
|
||||||
setError(null);
|
setError(null);
|
||||||
@@ -156,7 +198,7 @@ export function Explorer({ current, refreshKey, onOpen, onMoved, onDeleted, onHi
|
|||||||
const refresh = useCallback(
|
const refresh = useCallback(
|
||||||
() =>
|
() =>
|
||||||
guard(async () => {
|
guard(async () => {
|
||||||
const [next, tagList] = await Promise.all([api.list(dir), api.tags()]);
|
const [next, tagList] = await Promise.all([api.list(dir, gallery), api.tags()]);
|
||||||
setEntries(next);
|
setEntries(next);
|
||||||
setTags(tagList);
|
setTags(tagList);
|
||||||
// Tag filtré qui n'existe plus : filtre retiré.
|
// Tag filtré qui n'existe plus : filtre retiré.
|
||||||
@@ -169,7 +211,7 @@ export function Explorer({ current, refreshKey, onOpen, onMoved, onDeleted, onHi
|
|||||||
return new Set([...s].filter((p) => still.has(p)));
|
return new Set([...s].filter((p) => still.has(p)));
|
||||||
});
|
});
|
||||||
}),
|
}),
|
||||||
[dir, guard],
|
[dir, gallery, guard],
|
||||||
);
|
);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@@ -194,15 +236,15 @@ export function Explorer({ current, refreshKey, onOpen, onMoved, onDeleted, onHi
|
|||||||
setResults(null);
|
setResults(null);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const t = setTimeout(() => guard(async () => setResults(await api.search(query, filter))), 250);
|
const t = setTimeout(() => guard(async () => setResults(await api.search(query, filter, gallery))), 250);
|
||||||
return () => clearTimeout(t);
|
return () => clearTimeout(t);
|
||||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
}, [query, tagFilter, guard, refreshKey]);
|
}, [query, tagFilter, guard, refreshKey, gallery]);
|
||||||
|
|
||||||
/** Recharge le dossier et, si une recherche est affichée, ses résultats. */
|
/** Recharge le dossier et, si une recherche est affichée, ses résultats. */
|
||||||
const reload = async () => {
|
const reload = async () => {
|
||||||
await refresh();
|
await refresh();
|
||||||
if (filtering) setResults(await api.search(query, filter));
|
if (filtering) setResults(await api.search(query, filter, gallery));
|
||||||
};
|
};
|
||||||
|
|
||||||
// Délai de purge, affiché dans la poubelle (réglé dans les paramètres).
|
// Délai de purge, affiché dans la poubelle (réglé dans les paramètres).
|
||||||
@@ -220,7 +262,16 @@ export function Explorer({ current, refreshKey, onOpen, onMoved, onDeleted, onHi
|
|||||||
} catch {
|
} catch {
|
||||||
/* stockage indisponible */
|
/* stockage indisponible */
|
||||||
}
|
}
|
||||||
}, [view]);
|
onViewChange?.(view);
|
||||||
|
}, [view, onViewChange]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
try {
|
||||||
|
localStorage.setItem("explorerSort", sort);
|
||||||
|
} catch {
|
||||||
|
/* stockage indisponible */
|
||||||
|
}
|
||||||
|
}, [sort]);
|
||||||
|
|
||||||
// --- Sélection -----------------------------------------------------------
|
// --- Sélection -----------------------------------------------------------
|
||||||
|
|
||||||
@@ -247,7 +298,7 @@ export function Explorer({ current, refreshKey, onOpen, onMoved, onDeleted, onHi
|
|||||||
setSelected((s) => new Set([...s, ...paths.slice(lo, hi + 1)]));
|
setSelected((s) => new Set([...s, ...paths.slice(lo, hi + 1)]));
|
||||||
};
|
};
|
||||||
|
|
||||||
const selectable = list.filter((e) => !e.special);
|
const selectable = shown.filter((e) => !e.special);
|
||||||
const selectAll = () => setSelected(new Set(selectable.map((e) => e.path)));
|
const selectAll = () => setSelected(new Set(selectable.map((e) => e.path)));
|
||||||
|
|
||||||
const onItemClick = (ev: MouseEvent, e: Entry) => {
|
const onItemClick = (ev: MouseEvent, e: Entry) => {
|
||||||
@@ -269,7 +320,10 @@ export function Explorer({ current, refreshKey, onOpen, onMoved, onDeleted, onHi
|
|||||||
|
|
||||||
const onKeyDown = (ev: KeyboardEvent) => {
|
const onKeyDown = (ev: KeyboardEvent) => {
|
||||||
if ((ev.target as HTMLElement).tagName === "INPUT") return;
|
if ((ev.target as HTMLElement).tagName === "INPUT") return;
|
||||||
if (ev.key === "Escape" && selected.size > 0) {
|
if (ev.key === "Escape" && inspect) {
|
||||||
|
ev.preventDefault();
|
||||||
|
setInspect(null);
|
||||||
|
} else if (ev.key === "Escape" && selected.size > 0) {
|
||||||
ev.preventDefault();
|
ev.preventDefault();
|
||||||
clearSelection();
|
clearSelection();
|
||||||
} else if ((ev.ctrlKey || ev.metaKey) && ev.key.toLowerCase() === "a") {
|
} else if ((ev.ctrlKey || ev.metaKey) && ev.key.toLowerCase() === "a") {
|
||||||
@@ -548,7 +602,7 @@ export function Explorer({ current, refreshKey, onOpen, onMoved, onDeleted, onHi
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
const big = view === "grid" ? 40 : 20;
|
const big = view === "grid" ? 40 : gallery ? 28 : 20;
|
||||||
const icon = (e: Entry) =>
|
const icon = (e: Entry) =>
|
||||||
e.special ? (
|
e.special ? (
|
||||||
<span className={`icon special ${e.special} ${e.count ? "full" : ""}`} aria-hidden>
|
<span className={`icon special ${e.special} ${e.count ? "full" : ""}`} aria-hidden>
|
||||||
@@ -583,6 +637,7 @@ export function Explorer({ current, refreshKey, onOpen, onMoved, onDeleted, onHi
|
|||||||
// Dans Favoris : actions sur l'original, retrait du lien à la place de la suppression.
|
// Dans Favoris : actions sur l'original, retrait du lien à la place de la suppression.
|
||||||
const favActions = (e: Entry) => (
|
const favActions = (e: Entry) => (
|
||||||
<>
|
<>
|
||||||
|
{detailsAction(e)}
|
||||||
{!e.broken && (
|
{!e.broken && (
|
||||||
<>
|
<>
|
||||||
<button role="menuitem" onClick={() => setDir(dirname(e.path))}>
|
<button role="menuitem" onClick={() => setDir(dirname(e.path))}>
|
||||||
@@ -631,8 +686,19 @@ export function Explorer({ current, refreshKey, onOpen, onMoved, onDeleted, onHi
|
|||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const detailsAction = (e: Entry) =>
|
||||||
|
gallery &&
|
||||||
|
!e.isDir &&
|
||||||
|
!e.broken && (
|
||||||
|
<button role="menuitem" onClick={() => setInspect(e.path)}>
|
||||||
|
<InfoIcon />
|
||||||
|
Détails
|
||||||
|
</button>
|
||||||
|
);
|
||||||
|
|
||||||
const actions = (e: Entry) => (
|
const actions = (e: Entry) => (
|
||||||
<>
|
<>
|
||||||
|
{detailsAction(e)}
|
||||||
<button role="menuitem" onClick={() => rename(e)}>
|
<button role="menuitem" onClick={() => rename(e)}>
|
||||||
<EditIcon />
|
<EditIcon />
|
||||||
Renommer
|
Renommer
|
||||||
@@ -690,30 +756,23 @@ export function Explorer({ current, refreshKey, onOpen, onMoved, onDeleted, onHi
|
|||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
|
||||||
const item = (e: Hit) => {
|
const itemClass = (e: Hit) =>
|
||||||
const isSel = selected.has(e.path);
|
[
|
||||||
const cls = [
|
|
||||||
"item",
|
"item",
|
||||||
e.isDir ? "dir" : "file",
|
e.isDir ? "dir" : "file",
|
||||||
e.path === current ? "active" : "",
|
e.path === current ? "active" : "",
|
||||||
isSel ? "selected" : "",
|
selected.has(e.path) ? "selected" : "",
|
||||||
e.special ? "special" : "",
|
e.special ? "special" : "",
|
||||||
e.broken ? "broken" : "",
|
e.broken ? "broken" : "",
|
||||||
dropTarget === e.path ? "drop" : "",
|
dropTarget === e.path ? "drop" : "",
|
||||||
].join(" ");
|
].join(" ");
|
||||||
return (
|
|
||||||
<li key={e.path} className={cls}>
|
const checkbox = (e: Hit) =>
|
||||||
<div
|
!e.special && (
|
||||||
className="row"
|
|
||||||
draggable={!e.special && !locked}
|
|
||||||
onDragStart={(ev) => onDragStart(ev, e)}
|
|
||||||
{...(e.isDir ? dropProps(e.path) : {})}
|
|
||||||
>
|
|
||||||
{!e.special && (
|
|
||||||
<input
|
<input
|
||||||
type="checkbox"
|
type="checkbox"
|
||||||
className="check"
|
className="check"
|
||||||
checked={isSel}
|
checked={selected.has(e.path)}
|
||||||
aria-label={`Sélectionner ${e.name}`}
|
aria-label={`Sélectionner ${e.name}`}
|
||||||
onClick={(ev) => {
|
onClick={(ev) => {
|
||||||
ev.stopPropagation();
|
ev.stopPropagation();
|
||||||
@@ -724,7 +783,59 @@ export function Explorer({ current, refreshKey, onOpen, onMoved, onDeleted, onHi
|
|||||||
}}
|
}}
|
||||||
onChange={() => toggle(e.path)}
|
onChange={() => toggle(e.path)}
|
||||||
/>
|
/>
|
||||||
)}
|
);
|
||||||
|
|
||||||
|
const moreButton = (e: Hit) =>
|
||||||
|
!e.special && (
|
||||||
|
<button
|
||||||
|
className={`icon-btn more ${menu?.entry.path === e.path ? "open" : ""}`}
|
||||||
|
aria-label="Actions"
|
||||||
|
aria-haspopup="menu"
|
||||||
|
aria-expanded={menu?.entry.path === e.path}
|
||||||
|
title="Actions"
|
||||||
|
onClick={(ev) => {
|
||||||
|
const anchor = ev.currentTarget;
|
||||||
|
setMenu((m) => (m?.entry.path === e.path ? null : { entry: e, anchor }));
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<DotsIcon />
|
||||||
|
</button>
|
||||||
|
);
|
||||||
|
|
||||||
|
const tagChips = (e: Hit) =>
|
||||||
|
!!e.tags?.length && (
|
||||||
|
<span className="tags">
|
||||||
|
{e.tags.map((t) => (
|
||||||
|
<button
|
||||||
|
key={t}
|
||||||
|
className={`chip ${t === tagFilter ? "on" : ""}`}
|
||||||
|
title={`Filtrer sur « ${t} »`}
|
||||||
|
onClick={() => setTagFilter(t === tagFilter ? null : t)}
|
||||||
|
>
|
||||||
|
{t}
|
||||||
|
</button>
|
||||||
|
))}
|
||||||
|
</span>
|
||||||
|
);
|
||||||
|
|
||||||
|
/** Galerie : contenu d'un dossier sous son nom. */
|
||||||
|
const dirSummary = (e: Hit) => {
|
||||||
|
const d = e.details;
|
||||||
|
if (!d) return null;
|
||||||
|
const parts = [d.files ? plural(d.files, "schéma") : "", d.dirs ? plural(d.dirs, "dossier") : ""].filter(Boolean);
|
||||||
|
return <small className="muted dir-meta">{parts.length ? parts.join(" · ") : "vide"}</small>;
|
||||||
|
};
|
||||||
|
|
||||||
|
const item = (e: Hit) => {
|
||||||
|
return (
|
||||||
|
<li key={e.path} className={itemClass(e)}>
|
||||||
|
<div
|
||||||
|
className="row"
|
||||||
|
draggable={!e.special && !locked}
|
||||||
|
onDragStart={(ev) => onDragStart(ev, e)}
|
||||||
|
{...(e.isDir ? dropProps(e.path) : {})}
|
||||||
|
>
|
||||||
|
{checkbox(e)}
|
||||||
<button
|
<button
|
||||||
className="name"
|
className="name"
|
||||||
onClick={(ev) => onItemClick(ev, e)}
|
onClick={(ev) => onItemClick(ev, e)}
|
||||||
@@ -751,46 +862,154 @@ export function Explorer({ current, refreshKey, onOpen, onMoved, onDeleted, onHi
|
|||||||
{e.special === "poubelle" && !!e.count && <small className="badge">{e.count}</small>}
|
{e.special === "poubelle" && !!e.count && <small className="badge">{e.count}</small>}
|
||||||
{(results || (favView && !e.broken)) && <small className="muted where"> {where(e.path)}</small>}
|
{(results || (favView && !e.broken)) && <small className="muted where"> {where(e.path)}</small>}
|
||||||
{trashView && <small className="muted where"> {e.origin ? where(e.origin) : ""}</small>}
|
{trashView && <small className="muted where"> {e.origin ? where(e.origin) : ""}</small>}
|
||||||
|
{gallery && e.isDir && !trashView && dirSummary(e)}
|
||||||
{e.snippet && <small className="snippet">{e.snippet}</small>}
|
{e.snippet && <small className="snippet">{e.snippet}</small>}
|
||||||
</span>
|
</span>
|
||||||
</button>
|
</button>
|
||||||
{!!e.tags?.length && (
|
{tagChips(e)}
|
||||||
<span className="tags">
|
{(!e.isDir || trashView) && view !== "grid" && <span className="meta muted">{fmtDate(e.modTime)}</span>}
|
||||||
{e.tags.map((t) => (
|
{moreButton(e)}
|
||||||
<button
|
</div>
|
||||||
key={t}
|
</li>
|
||||||
className={`chip ${t === tagFilter ? "on" : ""}`}
|
);
|
||||||
title={`Filtrer sur « ${t} »`}
|
};
|
||||||
onClick={() => setTagFilter(t === tagFilter ? null : t)}
|
|
||||||
>
|
/** Galerie : tuile d'un schéma, grande miniature et métadonnées. */
|
||||||
{t}
|
const tile = (e: Hit) => {
|
||||||
|
const d = e.details ?? {};
|
||||||
|
const by = who(e.editedBy);
|
||||||
|
return (
|
||||||
|
<li key={e.path} className={`${itemClass(e)} tile ${inspect === e.path ? "inspected" : ""}`}>
|
||||||
|
<div className="row" draggable={!locked} onDragStart={(ev) => onDragStart(ev, e)}>
|
||||||
|
{checkbox(e)}
|
||||||
|
<button className="name" onClick={(ev) => onItemClick(ev, e)} title={displayPath(e.path)}>
|
||||||
|
{e.broken ? (
|
||||||
|
<span className="icon folder" aria-hidden>
|
||||||
|
<StarIcon size={40} />
|
||||||
|
</span>
|
||||||
|
) : (
|
||||||
|
<Thumb path={e.path} version={e.modTime} minSize={expectedThumb(d.width, d.height)} />
|
||||||
|
)}
|
||||||
|
<span className="label">{stripExt(e.name)}</span>
|
||||||
</button>
|
</button>
|
||||||
))}
|
{e.favorite && (
|
||||||
|
<span className="fav-badge" title="Favori">
|
||||||
|
<StarFilledIcon size={16} />
|
||||||
</span>
|
</span>
|
||||||
)}
|
)}
|
||||||
{(!e.isDir || trashView) && view === "list" && <span className="meta muted">{fmtDate(e.modTime)}</span>}
|
<span className="tile-tools">
|
||||||
{!e.special && (
|
{!e.broken && (
|
||||||
<button
|
<button
|
||||||
className={`icon-btn more ${menu?.entry.path === e.path ? "open" : ""}`}
|
className={`icon-btn ${inspect === e.path ? "on" : ""}`}
|
||||||
aria-label="Actions"
|
aria-label="Détails"
|
||||||
aria-haspopup="menu"
|
title="Détails"
|
||||||
aria-expanded={menu?.entry.path === e.path}
|
onClick={() => setInspect(inspect === e.path ? null : e.path)}
|
||||||
title="Actions"
|
|
||||||
onClick={(ev) => {
|
|
||||||
const anchor = ev.currentTarget;
|
|
||||||
setMenu((m) => (m?.entry.path === e.path ? null : { entry: e, anchor }));
|
|
||||||
}}
|
|
||||||
>
|
>
|
||||||
<DotsIcon />
|
<InfoIcon />
|
||||||
</button>
|
</button>
|
||||||
)}
|
)}
|
||||||
|
{moreButton(e)}
|
||||||
|
</span>
|
||||||
|
{!e.broken && (
|
||||||
|
<div className="tile-meta">
|
||||||
|
{(results || favView) && <small className="muted where">{where(e.path)}</small>}
|
||||||
|
<span className="facts">
|
||||||
|
<span title={`Modifié le ${fmtDate(e.modTime)}${by ? ` par ${by}` : ""}`}>
|
||||||
|
<ClockIcon size={14} />
|
||||||
|
{fmtRelative(e.modTime)}
|
||||||
|
{by && <span className="by"> · {by}</span>}
|
||||||
|
</span>
|
||||||
|
</span>
|
||||||
|
<span className="facts">
|
||||||
|
<span title="Taille du fichier">
|
||||||
|
<SizeIcon size={14} />
|
||||||
|
{fmtSize(e.size)}
|
||||||
|
</span>
|
||||||
|
{!!d.versions && (
|
||||||
|
<span title="Versions dans l'historique">
|
||||||
|
<HistoryIcon size={14} />
|
||||||
|
{plural(d.versions, "version")}
|
||||||
|
</span>
|
||||||
|
)}
|
||||||
|
{!!d.shares && (
|
||||||
|
<span className="ok" title="Liens de partage actifs">
|
||||||
|
<ShareIcon size={14} />
|
||||||
|
{plural(d.shares, "partage")}
|
||||||
|
</span>
|
||||||
|
)}
|
||||||
|
</span>
|
||||||
|
<span className="facts">
|
||||||
|
<span title="Éléments">
|
||||||
|
<ShapesIcon size={14} />
|
||||||
|
{d.elements ? plural(d.elements, "élément") : "vide"}
|
||||||
|
</span>
|
||||||
|
{!!d.texts && (
|
||||||
|
<span title="Textes">
|
||||||
|
<TextIcon size={14} />
|
||||||
|
{plural(d.texts, "texte")}
|
||||||
|
</span>
|
||||||
|
)}
|
||||||
|
{!!d.arrows && (
|
||||||
|
<span title="Flèches">
|
||||||
|
<ArrowIcon size={14} />
|
||||||
|
{plural(d.arrows, "flèche")}
|
||||||
|
</span>
|
||||||
|
)}
|
||||||
|
{!!d.images && (
|
||||||
|
<span title="Images">
|
||||||
|
<PhotoIcon size={14} />
|
||||||
|
{plural(d.images, "image")}
|
||||||
|
</span>
|
||||||
|
)}
|
||||||
|
{!!d.frames && (
|
||||||
|
<span title={d.frameNames?.length ? `Cadres : ${d.frameNames.join(", ")}` : "Cadres"}>
|
||||||
|
<FrameIcon size={14} />
|
||||||
|
{plural(d.frames, "cadre")}
|
||||||
|
</span>
|
||||||
|
)}
|
||||||
|
</span>
|
||||||
|
{tagChips(e)}
|
||||||
|
{e.snippet && <small className="snippet">{e.snippet}</small>}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
</li>
|
</li>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const upItem = !results && dir && (
|
||||||
|
<li className={`item dir up ${dropTarget === dirname(dir) ? "drop" : ""}`}>
|
||||||
|
<div className="row" {...dropProps(dirname(dir))}>
|
||||||
|
<button className="name" onClick={() => setDir(dirname(dir))}>
|
||||||
|
<span className="icon" aria-hidden>
|
||||||
|
<UpIcon size={view === "grid" ? 32 : 20} />
|
||||||
|
</span>
|
||||||
|
<span className="label">..</span>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</li>
|
||||||
|
);
|
||||||
|
|
||||||
|
const emptyText = results
|
||||||
|
? "Aucun résultat"
|
||||||
|
: favView
|
||||||
|
? "Aucun favori : étoile ou glisser-déposer un schéma ici"
|
||||||
|
: trashView
|
||||||
|
? "La poubelle est vide"
|
||||||
|
: "Dossier vide";
|
||||||
|
|
||||||
|
// Galerie : dossiers en cartes compactes, schémas en grandes tuiles.
|
||||||
|
const galleryDirs = shown.filter((e) => e.isDir || trashView);
|
||||||
|
const galleryFiles = trashView ? [] : shown.filter((e) => !e.isDir);
|
||||||
|
const inspected = gallery && inspect ? (shown.find((e) => e.path === inspect && !e.isDir) ?? null) : null;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={`explorer ${fileDrag ? "file-drag" : ""}`} onKeyDown={onKeyDown} {...zoneProps}>
|
<div
|
||||||
|
className={`explorer ${gallery ? "gallery" : ""} ${fileDrag ? "file-drag" : ""}`}
|
||||||
|
onKeyDown={onKeyDown}
|
||||||
|
{...zoneProps}
|
||||||
|
>
|
||||||
|
<div className="head">
|
||||||
<div className="toolbar">
|
<div className="toolbar">
|
||||||
<button className="ex-btn" onClick={newDrawing} title="Nouveau schéma" disabled={locked}>
|
<button className="ex-btn" onClick={newDrawing} title="Nouveau schéma" disabled={locked}>
|
||||||
<FilePlusIcon />
|
<FilePlusIcon />
|
||||||
@@ -871,11 +1090,21 @@ export function Explorer({ current, refreshKey, onOpen, onMoved, onDeleted, onHi
|
|||||||
>
|
>
|
||||||
<ListIcon />
|
<ListIcon />
|
||||||
</button>
|
</button>
|
||||||
|
<button
|
||||||
|
className={`icon-btn ${gallery ? "on" : ""}`}
|
||||||
|
onClick={() => setView("gallery")}
|
||||||
|
title="Galerie : grandes tuiles et détails, sur toute la largeur"
|
||||||
|
aria-label="Galerie"
|
||||||
|
aria-pressed={gallery}
|
||||||
|
>
|
||||||
|
<GalleryIcon />
|
||||||
|
</button>
|
||||||
</div>
|
</div>
|
||||||
<button className="icon-btn" onClick={refresh} title="Rafraîchir" aria-label="Rafraîchir">
|
<button className="icon-btn" onClick={refresh} title="Rafraîchir" aria-label="Rafraîchir">
|
||||||
<RefreshIcon />
|
<RefreshIcon />
|
||||||
</button>
|
</button>
|
||||||
{toolbarEnd}
|
{!gallery && toolbarEnd}
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="filters" role="group" aria-label="Filtres">
|
<div className="filters" role="group" aria-label="Filtres">
|
||||||
@@ -893,7 +1122,10 @@ export function Explorer({ current, refreshKey, onOpen, onMoved, onDeleted, onHi
|
|||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{!results && (
|
<div className="listbar">
|
||||||
|
{results ? (
|
||||||
|
<span className="muted count">{plural(results.length, "résultat")}</span>
|
||||||
|
) : (
|
||||||
<nav className="crumbs">
|
<nav className="crumbs">
|
||||||
<button className={dropTarget === "" ? "drop" : ""} onClick={() => setDir("")} {...dropProps("")}>
|
<button className={dropTarget === "" ? "drop" : ""} onClick={() => setDir("")} {...dropProps("")}>
|
||||||
Racine
|
Racine
|
||||||
@@ -911,6 +1143,15 @@ export function Explorer({ current, refreshKey, onOpen, onMoved, onDeleted, onHi
|
|||||||
})}
|
})}
|
||||||
</nav>
|
</nav>
|
||||||
)}
|
)}
|
||||||
|
<label className="sort" title="Trier">
|
||||||
|
<SortIcon />
|
||||||
|
<select value={sort} onChange={(ev) => setSort(ev.target.value as Sort)} aria-label="Trier par">
|
||||||
|
<option value="name">Nom</option>
|
||||||
|
<option value="modified">Modifié</option>
|
||||||
|
<option value="size">Taille</option>
|
||||||
|
</select>
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
|
||||||
{trashView && (
|
{trashView && (
|
||||||
<div className="trashbar">
|
<div className="trashbar">
|
||||||
@@ -999,32 +1240,53 @@ export function Explorer({ current, refreshKey, onOpen, onMoved, onDeleted, onHi
|
|||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
<ul className={`entries ${view} ${selected.size > 0 ? "selecting" : ""}`}>
|
{gallery ? (
|
||||||
{!results && dir && (
|
<div className="gallery-body">
|
||||||
<li className={`item dir up ${dropTarget === dirname(dir) ? "drop" : ""}`}>
|
<div className={`gallery-scroll ${selected.size > 0 ? "selecting" : ""}`}>
|
||||||
<div className="row" {...dropProps(dirname(dir))}>
|
{(upItem || galleryDirs.length > 0) && (
|
||||||
<button className="name" onClick={() => setDir(dirname(dir))}>
|
<>
|
||||||
<span className="icon" aria-hidden>
|
{galleryFiles.length > 0 && !trashView && <h4 className="gallery-heading">Dossiers</h4>}
|
||||||
<UpIcon size={view === "grid" ? 32 : 20} />
|
<ul className="entries gallery-dirs">
|
||||||
</span>
|
{upItem}
|
||||||
<span className="label">..</span>
|
{galleryDirs.map(item)}
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
</li>
|
|
||||||
)}
|
|
||||||
{list.map(item)}
|
|
||||||
{list.length === 0 && (
|
|
||||||
<li className="muted empty">
|
|
||||||
{results
|
|
||||||
? "Aucun résultat"
|
|
||||||
: favView
|
|
||||||
? "Aucun favori : étoile ou glisser-déposer un schéma ici"
|
|
||||||
: trashView
|
|
||||||
? "La poubelle est vide"
|
|
||||||
: "Dossier vide"}
|
|
||||||
</li>
|
|
||||||
)}
|
|
||||||
</ul>
|
</ul>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
{galleryFiles.length > 0 && (
|
||||||
|
<>
|
||||||
|
{(upItem || galleryDirs.length > 0) && <h4 className="gallery-heading">Schémas</h4>}
|
||||||
|
<ul className="entries gallery-tiles">{galleryFiles.map(tile)}</ul>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
{list.length === 0 && <p className="muted empty">{emptyText}</p>}
|
||||||
|
</div>
|
||||||
|
{inspected && (
|
||||||
|
<DetailsPanel
|
||||||
|
entry={inspected}
|
||||||
|
onOpen={(p) => {
|
||||||
|
if (favView && p !== current) stay.current = p;
|
||||||
|
onOpen(p);
|
||||||
|
}}
|
||||||
|
onLocate={(d) => {
|
||||||
|
setQuery("");
|
||||||
|
setTagFilter(null);
|
||||||
|
setDir(d);
|
||||||
|
}}
|
||||||
|
onHistory={onHistory}
|
||||||
|
onShare={onShare}
|
||||||
|
onFavorite={(e) => toggleFavorite([e])}
|
||||||
|
onTag={(t) => setTagFilter(t)}
|
||||||
|
onClose={() => setInspect(null)}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
) : (
|
||||||
|
<ul className={`entries ${view} ${selected.size > 0 ? "selecting" : ""}`}>
|
||||||
|
{upItem}
|
||||||
|
{shown.map(item)}
|
||||||
|
{list.length === 0 && <li className="muted empty">{emptyText}</li>}
|
||||||
|
</ul>
|
||||||
|
)}
|
||||||
|
|
||||||
{fileDrag && (
|
{fileDrag && (
|
||||||
<div className="drop-hint" aria-hidden>
|
<div className="drop-hint" aria-hidden>
|
||||||
|
|||||||
+13
-5
@@ -1,4 +1,5 @@
|
|||||||
import { useEffect, useRef, useState } from "react";
|
import { useEffect, useRef, useState } from "react";
|
||||||
|
import type { SyntheticEvent } from "react";
|
||||||
import { api } from "./api";
|
import { api } from "./api";
|
||||||
import { ensureThumb, knownThumb } from "./thumbs";
|
import { ensureThumb, knownThumb } from "./thumbs";
|
||||||
|
|
||||||
@@ -7,9 +8,10 @@ type State = "idle" | "server" | "generating" | "retry" | "empty" | "error";
|
|||||||
/**
|
/**
|
||||||
* Miniature d'un schéma, chargée quand elle devient visible. Si le serveur
|
* Miniature d'un schéma, chargée quand elle devient visible. Si le serveur
|
||||||
* n'en a pas (ou qu'elle est périmée), elle est générée dans le navigateur
|
* n'en a pas (ou qu'elle est périmée), elle est générée dans le navigateur
|
||||||
* puis envoyée au serveur pour les visites suivantes.
|
* puis envoyée au serveur pour les visites suivantes. minSize : une miniature
|
||||||
|
* du serveur plus petite (rendue à une ancienne taille) est régénérée.
|
||||||
*/
|
*/
|
||||||
export function Thumb({ path, version }: { path: string; version: string }) {
|
export function Thumb({ path, version, minSize }: { path: string; version: string; minSize?: number }) {
|
||||||
const ref = useRef<HTMLSpanElement>(null);
|
const ref = useRef<HTMLSpanElement>(null);
|
||||||
const [visible, setVisible] = useState(false);
|
const [visible, setVisible] = useState(false);
|
||||||
const [state, setState] = useState<State>("idle");
|
const [state, setState] = useState<State>("idle");
|
||||||
@@ -39,12 +41,18 @@ export function Thumb({ path, version }: { path: string; version: string }) {
|
|||||||
if (visible && state === "idle") setState("server");
|
if (visible && state === "idle") setState("server");
|
||||||
}, [visible, state]);
|
}, [visible, state]);
|
||||||
|
|
||||||
const onError = () => {
|
const regenerate = () => {
|
||||||
if (state !== "server") return setState("error");
|
|
||||||
setState("generating");
|
setState("generating");
|
||||||
ensureThumb(path, version).then((r) => setState(r === "ok" ? "retry" : r));
|
ensureThumb(path, version).then((r) => setState(r === "ok" ? "retry" : r));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const onError = () => (state === "server" ? regenerate() : setState("error"));
|
||||||
|
|
||||||
|
const onLoad = (ev: SyntheticEvent<HTMLImageElement>) => {
|
||||||
|
const img = ev.currentTarget;
|
||||||
|
if (minSize && state === "server" && Math.max(img.naturalWidth, img.naturalHeight) < minSize) regenerate();
|
||||||
|
};
|
||||||
|
|
||||||
const src =
|
const src =
|
||||||
state === "server"
|
state === "server"
|
||||||
? api.thumbUrl(path, version)
|
? api.thumbUrl(path, version)
|
||||||
@@ -55,7 +63,7 @@ export function Thumb({ path, version }: { path: string; version: string }) {
|
|||||||
return (
|
return (
|
||||||
<span ref={ref} className={`thumb ${state}`} aria-hidden>
|
<span ref={ref} className={`thumb ${state}`} aria-hidden>
|
||||||
{src ? (
|
{src ? (
|
||||||
<img src={src} alt="" loading="lazy" decoding="async" draggable={false} onError={onError} />
|
<img src={src} alt="" loading="lazy" decoding="async" draggable={false} onError={onError} onLoad={onLoad} />
|
||||||
) : (
|
) : (
|
||||||
<span className="ph">{state === "empty" ? "∅" : state === "error" ? "📄" : ""}</span>
|
<span className="ph">{state === "empty" ? "∅" : state === "error" ? "📄" : ""}</span>
|
||||||
)}
|
)}
|
||||||
|
|||||||
+34
-4
@@ -22,6 +22,33 @@ export interface Entry {
|
|||||||
link?: string;
|
link?: string;
|
||||||
/** Favori dont l'original a disparu (chemin .favoris/<lien>, à retirer). */
|
/** Favori dont l'original a disparu (chemin .favoris/<lien>, à retirer). */
|
||||||
broken?: boolean;
|
broken?: boolean;
|
||||||
|
/** Schéma : dernier utilisateur à l'avoir enregistré ("local" hors authentification). */
|
||||||
|
editedBy?: string;
|
||||||
|
/** Vue Galerie : détails demandés à la liste ou à la recherche (details=1). */
|
||||||
|
details?: Details;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Détails d'une entrée (internal/storage/details.go) ; compteurs absents = 0. */
|
||||||
|
export interface Details {
|
||||||
|
elements?: number;
|
||||||
|
texts?: number;
|
||||||
|
images?: number;
|
||||||
|
arrows?: number;
|
||||||
|
frames?: number;
|
||||||
|
frameNames?: string[];
|
||||||
|
/** Emprise des éléments, en px du canevas. */
|
||||||
|
width?: number;
|
||||||
|
height?: number;
|
||||||
|
background?: string;
|
||||||
|
versions?: number;
|
||||||
|
/** Liens de partage actifs. */
|
||||||
|
shares?: number;
|
||||||
|
/** Création, ou plus ancienne version connue si l'auteur n'est pas connu. */
|
||||||
|
created?: string;
|
||||||
|
createdBy?: string;
|
||||||
|
/** Dossier : sous-dossiers et schémas. */
|
||||||
|
dirs?: number;
|
||||||
|
files?: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface TagCount {
|
export interface TagCount {
|
||||||
@@ -142,12 +169,15 @@ export const api = {
|
|||||||
|
|
||||||
me: async (): Promise<Me> => (await request("/api/me")).json(),
|
me: async (): Promise<Me> => (await request("/api/me")).json(),
|
||||||
|
|
||||||
list: async (dir: string): Promise<Entry[]> =>
|
/** details : détails des entrées pour la vue Galerie. */
|
||||||
(await request(`/api/list?path=${q(dir)}`)).json(),
|
list: async (dir: string, details = false): Promise<Entry[]> =>
|
||||||
|
(await request(`/api/list?path=${q(dir)}${details ? "&details=1" : ""}`)).json(),
|
||||||
|
|
||||||
search: async (text: string, f: SearchFilter = {}): Promise<Hit[]> =>
|
search: async (text: string, f: SearchFilter = {}, details = false): Promise<Hit[]> =>
|
||||||
(
|
(
|
||||||
await request(`/api/search?q=${q(text)}${f.tag ? `&tag=${q(f.tag)}` : ""}${f.fav ? "&fav=true" : ""}`)
|
await request(
|
||||||
|
`/api/search?q=${q(text)}${f.tag ? `&tag=${q(f.tag)}` : ""}${f.fav ? "&fav=true" : ""}${details ? "&details=1" : ""}`,
|
||||||
|
)
|
||||||
).json(),
|
).json(),
|
||||||
|
|
||||||
tags: async (): Promise<TagCount[]> => (await request("/api/tags")).json(),
|
tags: async (): Promise<TagCount[]> => (await request("/api/tags")).json(),
|
||||||
|
|||||||
@@ -0,0 +1,24 @@
|
|||||||
|
// Mise en forme des dates, tailles et auteurs (explorateur, panneau Détails).
|
||||||
|
|
||||||
|
export const fmtDate = (iso: string) =>
|
||||||
|
new Date(iso).toLocaleString(undefined, { dateStyle: "short", timeStyle: "short" });
|
||||||
|
|
||||||
|
export const fmtSize = (n: number) =>
|
||||||
|
n < 1024 ? `${n} o` : n < 1 << 20 ? `${(n / 1024).toFixed(1)} Ko` : `${(n / (1 << 20)).toFixed(1)} Mo`;
|
||||||
|
|
||||||
|
export const plural = (n: number, word: string) => `${n} ${word}${n > 1 ? "s" : ""}`;
|
||||||
|
|
||||||
|
const relative = new Intl.RelativeTimeFormat("fr", { numeric: "auto" });
|
||||||
|
|
||||||
|
/** « à l'instant », « il y a 5 minutes », « hier »… puis la date au-delà d'un mois. */
|
||||||
|
export const fmtRelative = (iso: string) => {
|
||||||
|
const s = (Date.now() - new Date(iso).getTime()) / 1000;
|
||||||
|
if (s < 60) return "à l'instant";
|
||||||
|
if (s < 3600) return relative.format(-Math.round(s / 60), "minute");
|
||||||
|
if (s < 86400) return relative.format(-Math.round(s / 3600), "hour");
|
||||||
|
if (s < 30 * 86400) return relative.format(-Math.round(s / 86400), "day");
|
||||||
|
return new Date(iso).toLocaleDateString(undefined, { dateStyle: "medium" });
|
||||||
|
};
|
||||||
|
|
||||||
|
/** Auteur affichable : rien pour l'utilisateur unique sans authentification. */
|
||||||
|
export const who = (id?: string) => (id && id !== "local" ? id : "");
|
||||||
@@ -237,3 +237,61 @@ export const LogoutIcon = icon(
|
|||||||
<path d="M9 12h12l-3-3M18 15l3-3" />
|
<path d="M9 12h12l-3-3M18 15l3-3" />
|
||||||
</>,
|
</>,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// Vue Galerie et ses métadonnées.
|
||||||
|
export const GalleryIcon = icon(
|
||||||
|
<>
|
||||||
|
<rect x="3" y="4" width="8" height="7" rx="1.5" />
|
||||||
|
<rect x="13" y="4" width="8" height="7" rx="1.5" />
|
||||||
|
<path d="M3 15h8M3 19h5M13 15h8M13 19h5" />
|
||||||
|
</>,
|
||||||
|
);
|
||||||
|
|
||||||
|
export const ClockIcon = icon(
|
||||||
|
<>
|
||||||
|
<circle cx="12" cy="12" r="9" />
|
||||||
|
<path d="M12 7v5l3 3" />
|
||||||
|
</>,
|
||||||
|
);
|
||||||
|
|
||||||
|
export const ShapesIcon = icon(
|
||||||
|
<>
|
||||||
|
<rect x="3" y="3" width="8" height="8" rx="1" />
|
||||||
|
<circle cx="17" cy="17" r="4" />
|
||||||
|
<path d="M17 3l4 7h-8z" />
|
||||||
|
</>,
|
||||||
|
);
|
||||||
|
|
||||||
|
export const TextIcon = icon(<path d="M6 4h12M12 4v16M9 20h6" />);
|
||||||
|
|
||||||
|
export const PhotoIcon = icon(
|
||||||
|
<>
|
||||||
|
<rect x="3" y="4" width="18" height="16" rx="2" />
|
||||||
|
<circle cx="9" cy="10" r="1.5" />
|
||||||
|
<path d="M21 16l-5-5-8 9" />
|
||||||
|
</>,
|
||||||
|
);
|
||||||
|
|
||||||
|
export const FrameIcon = icon(<path d="M4 7h16M4 17h16M7 4v16M17 4v16" />);
|
||||||
|
|
||||||
|
export const ArrowIcon = icon(<path d="M5 19 19 5M10 5h9v9" />);
|
||||||
|
|
||||||
|
export const SizeIcon = icon(
|
||||||
|
<>
|
||||||
|
<path d="M6 4h10l4 4v10a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2z" />
|
||||||
|
<path d="M8 4v5h7V4M8 20v-6h8v6" />
|
||||||
|
</>,
|
||||||
|
);
|
||||||
|
|
||||||
|
export const SortIcon = icon(<path d="M4 6h9M4 12h7M4 18h5M17 4v16M14 17l3 3 3-3" />);
|
||||||
|
|
||||||
|
export const InfoIcon = icon(
|
||||||
|
<>
|
||||||
|
<circle cx="12" cy="12" r="9" />
|
||||||
|
<path d="M12 8v.01M11 12h1v4h1" />
|
||||||
|
</>,
|
||||||
|
);
|
||||||
|
|
||||||
|
export const LinkIcon = icon(
|
||||||
|
<path d="M9 15l6-6M11 6l.46-.54a5 5 0 0 1 7.07 7.07l-.53.47M13 18l-.4.53a5 5 0 0 1-7.07-7.07L6 11" />,
|
||||||
|
);
|
||||||
@@ -1660,3 +1660,483 @@ button.chip.on,
|
|||||||
max-width: 260px;
|
max-width: 260px;
|
||||||
white-space: pre-line;
|
white-space: pre-line;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* --- Barre de liste : fil d'Ariane (ou nombre de résultats) et tri ---------- */
|
||||||
|
|
||||||
|
.head {
|
||||||
|
display: contents; /* panneau latéral : barre d'outils et recherche l'une sous l'autre */
|
||||||
|
}
|
||||||
|
.listbar {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 6px;
|
||||||
|
min-height: 24px;
|
||||||
|
}
|
||||||
|
.listbar .crumbs {
|
||||||
|
flex: 1;
|
||||||
|
min-width: 0;
|
||||||
|
}
|
||||||
|
.listbar .count {
|
||||||
|
flex: 1;
|
||||||
|
font-size: 13px;
|
||||||
|
padding-left: 6px;
|
||||||
|
}
|
||||||
|
.sort {
|
||||||
|
display: inline-flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 2px;
|
||||||
|
flex: none;
|
||||||
|
color: var(--muted);
|
||||||
|
}
|
||||||
|
.sort select {
|
||||||
|
height: 26px;
|
||||||
|
padding: 0 4px;
|
||||||
|
border: 1px solid transparent;
|
||||||
|
border-radius: var(--ex-radius-md);
|
||||||
|
background: transparent;
|
||||||
|
color: var(--ex-on-surface);
|
||||||
|
font: 12px var(--ex-font);
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
.sort select:hover,
|
||||||
|
.sort select:focus-visible {
|
||||||
|
border-color: var(--border);
|
||||||
|
background: var(--ex-surface-low);
|
||||||
|
outline: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* --- Vue Galerie : l'explorateur couvre toute la zone de travail ------------ */
|
||||||
|
|
||||||
|
.app.gallery.drawer-open .drawer {
|
||||||
|
position: fixed;
|
||||||
|
z-index: 20;
|
||||||
|
inset: var(--topbar-h) 0 0 0;
|
||||||
|
width: auto;
|
||||||
|
transform: none;
|
||||||
|
visibility: visible;
|
||||||
|
border-right: none;
|
||||||
|
box-shadow: none;
|
||||||
|
}
|
||||||
|
.app.gallery .splitter,
|
||||||
|
.app.gallery.drawer-open .backdrop {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
.explorer.gallery {
|
||||||
|
width: 100%;
|
||||||
|
padding: 14px 20px 0;
|
||||||
|
gap: 10px;
|
||||||
|
}
|
||||||
|
.explorer.gallery .head {
|
||||||
|
display: flex;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
align-items: center;
|
||||||
|
gap: 8px;
|
||||||
|
}
|
||||||
|
.explorer.gallery .searchbar {
|
||||||
|
flex: 1;
|
||||||
|
min-width: min(100%, 320px);
|
||||||
|
}
|
||||||
|
.explorer.gallery .search {
|
||||||
|
max-width: 640px;
|
||||||
|
}
|
||||||
|
.explorer.gallery .crumbs,
|
||||||
|
.explorer.gallery .crumbs button {
|
||||||
|
font-size: 14px;
|
||||||
|
}
|
||||||
|
.gallery-body {
|
||||||
|
flex: 1;
|
||||||
|
min-height: 0;
|
||||||
|
display: flex;
|
||||||
|
margin: 0 -20px;
|
||||||
|
border-top: 1px solid var(--border);
|
||||||
|
}
|
||||||
|
.gallery-scroll {
|
||||||
|
flex: 1;
|
||||||
|
min-width: 0;
|
||||||
|
overflow-y: auto;
|
||||||
|
padding: 4px 20px 24px;
|
||||||
|
}
|
||||||
|
.gallery-scroll > .empty {
|
||||||
|
padding: 12px 0;
|
||||||
|
}
|
||||||
|
.gallery-heading {
|
||||||
|
margin: 14px 0 8px;
|
||||||
|
font-size: 11.5px;
|
||||||
|
font-weight: 600;
|
||||||
|
letter-spacing: 0.06em;
|
||||||
|
text-transform: uppercase;
|
||||||
|
color: var(--muted);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Dossiers : cartes compactes. */
|
||||||
|
.entries.gallery-dirs {
|
||||||
|
flex: none;
|
||||||
|
overflow: visible;
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
|
||||||
|
gap: 8px;
|
||||||
|
padding-top: 10px;
|
||||||
|
}
|
||||||
|
.entries.gallery-dirs .row {
|
||||||
|
position: relative;
|
||||||
|
height: 100%;
|
||||||
|
border: 1px solid var(--border);
|
||||||
|
border-radius: 0.625rem;
|
||||||
|
background: var(--ex-surface-lowest);
|
||||||
|
}
|
||||||
|
.entries.gallery-dirs .row:hover {
|
||||||
|
border-color: var(--ex-primary);
|
||||||
|
background: var(--ex-surface-lowest);
|
||||||
|
}
|
||||||
|
.entries.gallery-dirs .name {
|
||||||
|
padding: 8px 6px 8px 8px;
|
||||||
|
gap: 10px;
|
||||||
|
}
|
||||||
|
.entries.gallery-dirs .icon {
|
||||||
|
width: 40px;
|
||||||
|
height: 40px;
|
||||||
|
border-radius: var(--ex-radius-lg);
|
||||||
|
background: var(--ex-surface-mid);
|
||||||
|
}
|
||||||
|
.entries.gallery-dirs .label {
|
||||||
|
font-size: 13.5px;
|
||||||
|
font-weight: 600;
|
||||||
|
}
|
||||||
|
.entries.gallery-dirs .label small {
|
||||||
|
display: block;
|
||||||
|
font-weight: 400;
|
||||||
|
font-size: 12px;
|
||||||
|
overflow: hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
}
|
||||||
|
.entries.gallery-dirs .check {
|
||||||
|
position: absolute;
|
||||||
|
top: 6px;
|
||||||
|
left: 4px;
|
||||||
|
z-index: 1;
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
.entries.gallery-dirs .row .tags {
|
||||||
|
display: none; /* les tags d'un dossier restent visibles en liste */
|
||||||
|
}
|
||||||
|
.entries.gallery-dirs .row .meta {
|
||||||
|
padding-right: 4px;
|
||||||
|
}
|
||||||
|
.entries.gallery-dirs .more {
|
||||||
|
opacity: 0;
|
||||||
|
}
|
||||||
|
.entries.gallery-dirs .item:hover .more,
|
||||||
|
.entries.gallery-dirs .more.open,
|
||||||
|
.entries.gallery-dirs .more:focus-visible {
|
||||||
|
opacity: 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Schémas : grandes tuiles avec miniature et métadonnées. */
|
||||||
|
.entries.gallery-tiles {
|
||||||
|
flex: none;
|
||||||
|
overflow: visible;
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
|
||||||
|
gap: 14px;
|
||||||
|
padding-top: 10px;
|
||||||
|
}
|
||||||
|
.tile > .row {
|
||||||
|
position: relative;
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: stretch;
|
||||||
|
gap: 0;
|
||||||
|
height: 100%;
|
||||||
|
overflow: hidden;
|
||||||
|
border: 1px solid var(--border);
|
||||||
|
border-radius: 0.75rem;
|
||||||
|
background: var(--ex-surface-lowest);
|
||||||
|
transition:
|
||||||
|
border-color 0.1s,
|
||||||
|
box-shadow 0.1s;
|
||||||
|
}
|
||||||
|
.tile > .row:hover {
|
||||||
|
border-color: var(--ex-primary);
|
||||||
|
background: var(--ex-surface-lowest);
|
||||||
|
box-shadow: var(--ex-shadow-island);
|
||||||
|
}
|
||||||
|
.tile.inspected > .row {
|
||||||
|
border-color: var(--ex-primary);
|
||||||
|
outline: 2px solid var(--ex-primary);
|
||||||
|
outline-offset: -2px;
|
||||||
|
}
|
||||||
|
.tile .name {
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: stretch;
|
||||||
|
gap: 0;
|
||||||
|
padding: 0;
|
||||||
|
border-radius: 0;
|
||||||
|
}
|
||||||
|
.tile .thumb,
|
||||||
|
.tile .icon {
|
||||||
|
width: 100%;
|
||||||
|
height: auto;
|
||||||
|
aspect-ratio: 16 / 10;
|
||||||
|
border: none;
|
||||||
|
border-bottom: 1px solid var(--border);
|
||||||
|
border-radius: 0;
|
||||||
|
}
|
||||||
|
.tile .label {
|
||||||
|
padding: 10px 12px 4px;
|
||||||
|
white-space: normal;
|
||||||
|
overflow-wrap: anywhere;
|
||||||
|
font-size: 14.5px;
|
||||||
|
font-weight: 600;
|
||||||
|
line-height: 1.25;
|
||||||
|
display: -webkit-box;
|
||||||
|
-webkit-line-clamp: 2;
|
||||||
|
-webkit-box-orient: vertical;
|
||||||
|
}
|
||||||
|
.tile .check {
|
||||||
|
position: absolute;
|
||||||
|
top: 8px;
|
||||||
|
left: 6px;
|
||||||
|
z-index: 1;
|
||||||
|
width: 18px;
|
||||||
|
height: 18px;
|
||||||
|
}
|
||||||
|
.tile .fav-badge {
|
||||||
|
position: absolute;
|
||||||
|
top: 8px;
|
||||||
|
left: 30px;
|
||||||
|
z-index: 1;
|
||||||
|
display: inline-flex;
|
||||||
|
color: #f59f00;
|
||||||
|
filter: drop-shadow(0 0 2px var(--ex-surface-lowest));
|
||||||
|
}
|
||||||
|
.tile .tile-tools {
|
||||||
|
position: absolute;
|
||||||
|
top: 6px;
|
||||||
|
right: 6px;
|
||||||
|
z-index: 1;
|
||||||
|
display: flex;
|
||||||
|
gap: 2px;
|
||||||
|
padding: 2px;
|
||||||
|
border-radius: var(--ex-radius-lg);
|
||||||
|
background: color-mix(in srgb, var(--ex-surface-lowest) 85%, transparent);
|
||||||
|
opacity: 0;
|
||||||
|
transition: opacity 0.1s;
|
||||||
|
}
|
||||||
|
.tile:hover .tile-tools,
|
||||||
|
.tile.inspected .tile-tools,
|
||||||
|
.tile .tile-tools:focus-within,
|
||||||
|
.tile .more.open {
|
||||||
|
opacity: 1;
|
||||||
|
}
|
||||||
|
.tile .tile-tools:has(.more.open) {
|
||||||
|
opacity: 1;
|
||||||
|
}
|
||||||
|
@media (hover: none) {
|
||||||
|
.tile .tile-tools {
|
||||||
|
opacity: 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.tile-meta {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 5px;
|
||||||
|
padding: 2px 12px 12px;
|
||||||
|
font-size: 12px;
|
||||||
|
color: var(--muted);
|
||||||
|
}
|
||||||
|
.tile-meta .where {
|
||||||
|
overflow: hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
.tile-meta .facts {
|
||||||
|
display: flex;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
gap: 3px 12px;
|
||||||
|
}
|
||||||
|
.tile-meta .facts > span {
|
||||||
|
display: inline-flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 4px;
|
||||||
|
min-width: 0;
|
||||||
|
}
|
||||||
|
.tile-meta .facts .by {
|
||||||
|
overflow: hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
.tile-meta .ok {
|
||||||
|
color: var(--ok);
|
||||||
|
}
|
||||||
|
.tile-meta .tags {
|
||||||
|
display: flex;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
gap: 4px;
|
||||||
|
margin-top: 2px;
|
||||||
|
}
|
||||||
|
.tile-meta .snippet {
|
||||||
|
display: block;
|
||||||
|
overflow: hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
white-space: nowrap;
|
||||||
|
color: var(--ex-on-primary-container);
|
||||||
|
opacity: 0.8;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Panneau Détails, à droite des tuiles. */
|
||||||
|
.details-panel {
|
||||||
|
flex: none;
|
||||||
|
width: 340px;
|
||||||
|
overflow-y: auto;
|
||||||
|
padding: 14px 16px 24px;
|
||||||
|
border-left: 1px solid var(--border);
|
||||||
|
background: var(--panel);
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 10px;
|
||||||
|
font-size: 13px;
|
||||||
|
}
|
||||||
|
.details-head {
|
||||||
|
display: flex;
|
||||||
|
align-items: flex-start;
|
||||||
|
gap: 6px;
|
||||||
|
}
|
||||||
|
.details-head h3 {
|
||||||
|
flex: 1;
|
||||||
|
margin: 4px 0 0;
|
||||||
|
font-size: 16px;
|
||||||
|
line-height: 1.3;
|
||||||
|
overflow-wrap: anywhere;
|
||||||
|
}
|
||||||
|
.details-shot {
|
||||||
|
display: block;
|
||||||
|
height: auto;
|
||||||
|
padding: 0;
|
||||||
|
overflow: hidden;
|
||||||
|
border: 1px solid var(--border);
|
||||||
|
border-radius: 0.625rem;
|
||||||
|
background: var(--thumb-bg);
|
||||||
|
box-shadow: none;
|
||||||
|
}
|
||||||
|
.details-shot .thumb {
|
||||||
|
width: 100%;
|
||||||
|
height: auto;
|
||||||
|
aspect-ratio: 16 / 10;
|
||||||
|
border: none;
|
||||||
|
border-radius: 0;
|
||||||
|
}
|
||||||
|
.details-where {
|
||||||
|
align-self: flex-start;
|
||||||
|
height: auto;
|
||||||
|
padding: 2px 4px;
|
||||||
|
gap: 4px;
|
||||||
|
background: transparent;
|
||||||
|
box-shadow: none;
|
||||||
|
color: var(--muted);
|
||||||
|
font-size: 12.5px;
|
||||||
|
letter-spacing: normal;
|
||||||
|
white-space: normal;
|
||||||
|
text-align: left;
|
||||||
|
}
|
||||||
|
.details-actions {
|
||||||
|
display: flex;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
gap: 6px;
|
||||||
|
}
|
||||||
|
.details-panel dl {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: auto 1fr;
|
||||||
|
gap: 6px 12px;
|
||||||
|
margin: 4px 0;
|
||||||
|
}
|
||||||
|
.details-panel dt {
|
||||||
|
color: var(--muted);
|
||||||
|
}
|
||||||
|
.details-panel dd {
|
||||||
|
margin: 0;
|
||||||
|
min-width: 0;
|
||||||
|
overflow-wrap: anywhere;
|
||||||
|
}
|
||||||
|
.details-panel dd.tags {
|
||||||
|
display: flex;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
gap: 4px;
|
||||||
|
}
|
||||||
|
.swatch-line {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 6px;
|
||||||
|
}
|
||||||
|
.swatch {
|
||||||
|
width: 14px;
|
||||||
|
height: 14px;
|
||||||
|
border-radius: 3px;
|
||||||
|
border: 1px solid var(--ex-outline-variant);
|
||||||
|
}
|
||||||
|
.details-panel h4 {
|
||||||
|
margin: 6px 0 4px;
|
||||||
|
font-size: 11.5px;
|
||||||
|
font-weight: 600;
|
||||||
|
letter-spacing: 0.06em;
|
||||||
|
text-transform: uppercase;
|
||||||
|
color: var(--muted);
|
||||||
|
}
|
||||||
|
.details-panel section p {
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
.details-panel ul {
|
||||||
|
list-style: none;
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
|
.details-panel li {
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
gap: 8px;
|
||||||
|
padding: 5px 0;
|
||||||
|
border-bottom: 1px solid var(--border);
|
||||||
|
}
|
||||||
|
.details-panel li:last-child {
|
||||||
|
border-bottom: none;
|
||||||
|
}
|
||||||
|
.details-panel button.link {
|
||||||
|
height: auto;
|
||||||
|
padding: 0;
|
||||||
|
background: transparent;
|
||||||
|
box-shadow: none;
|
||||||
|
color: var(--accent);
|
||||||
|
font-size: 13px;
|
||||||
|
letter-spacing: normal;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (max-width: 768px) {
|
||||||
|
.app.gallery.drawer-open .drawer {
|
||||||
|
width: auto;
|
||||||
|
}
|
||||||
|
.explorer.gallery {
|
||||||
|
padding: 10px 12px 0;
|
||||||
|
}
|
||||||
|
.explorer.gallery .toolbar .ex-btn span {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
.gallery-body {
|
||||||
|
margin: 0 -12px;
|
||||||
|
}
|
||||||
|
.gallery-scroll {
|
||||||
|
padding: 4px 12px 16px;
|
||||||
|
}
|
||||||
|
.entries.gallery-dirs {
|
||||||
|
grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
|
||||||
|
}
|
||||||
|
.entries.gallery-tiles {
|
||||||
|
grid-template-columns: 1fr;
|
||||||
|
}
|
||||||
|
/* Détails : feuille plein écran au-dessus des tuiles. */
|
||||||
|
.details-panel {
|
||||||
|
position: fixed;
|
||||||
|
z-index: 30;
|
||||||
|
inset: var(--topbar-h) 0 0 0;
|
||||||
|
width: auto;
|
||||||
|
border-left: none;
|
||||||
|
padding-bottom: max(24px, env(safe-area-inset-bottom));
|
||||||
|
}
|
||||||
|
}
|
||||||
+10
-1
@@ -6,7 +6,8 @@ import type { AppState, BinaryFiles } from "@excalidraw/excalidraw/types";
|
|||||||
import type { ExcalidrawElement } from "@excalidraw/excalidraw/element/types";
|
import type { ExcalidrawElement } from "@excalidraw/excalidraw/element/types";
|
||||||
import { api } from "./api";
|
import { api } from "./api";
|
||||||
|
|
||||||
const THUMB_PX = 320;
|
// Assez grand pour les tuiles de la vue Galerie (affichées jusqu'à ~420 px de large).
|
||||||
|
export const THUMB_PX = 640;
|
||||||
|
|
||||||
/** Rend la miniature d'une scène ; null si la scène est vide. */
|
/** Rend la miniature d'une scène ; null si la scène est vide. */
|
||||||
export async function renderThumb(
|
export async function renderThumb(
|
||||||
@@ -101,3 +102,11 @@ export function ensureThumb(path: string, version: string): Promise<ThumbResult>
|
|||||||
}
|
}
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Taille minimale attendue (plus grand côté, px) d'une miniature à jour pour une
|
||||||
|
* scène dont l'emprise est w × h : Excalidraw n'agrandit pas les petites scènes.
|
||||||
|
* Une miniature plus petite date d'une ancienne taille de rendu (320 px).
|
||||||
|
*/
|
||||||
|
export const expectedThumb = (w?: number, h?: number) =>
|
||||||
|
w && h ? Math.floor(Math.min(THUMB_PX, Math.max(w, h)) * 0.9) : undefined;
|
||||||
Reference in new issue
Block a user