@seclai/react 0.0.18 → 0.0.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +23 -15
- package/dist/index.d.ts +40 -19
- package/dist/index.js +240 -88
- package/dist/styles.css +99 -10
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -253,28 +253,40 @@ import { MediaGallery, MediaPreview, MediaSkeleton, MediaViewer } from "@seclai/
|
|
|
253
253
|
/>
|
|
254
254
|
```
|
|
255
255
|
|
|
256
|
-
- **`MediaPreview`** shows one attachment
|
|
257
|
-
-
|
|
256
|
+
- **`MediaPreview`** shows one attachment as a card, chosen by its mime type (ignoring case and parameters such as `; codecs=…`). Every card has a download link, an optional number badge and an `actions` slot:
|
|
257
|
+
- **Images** (`image/*`, SVG included) sit in a fixed-ratio frame, so the layout doesn't jump while they load.
|
|
258
|
+
- **Audio** (`audio/*`) plays in the browser's own `<audio controls>`, under the file's name.
|
|
259
|
+
- **Video** (`video/*`) plays in the browser's own `<video controls playsinline>`, in a frame like an image's.
|
|
260
|
+
- **PDFs** (`application/pdf`) show in the browser's PDF viewer, in an `<object>`. Browsers without one, including most mobile browsers, show a download link in its place.
|
|
261
|
+
- **Anything else**, HTML included, is a download link.
|
|
262
|
+
|
|
263
|
+
Audio and video load only their metadata until played (`preload="metadata"`). A file that fails to load says so in its card, and keeps its download link.
|
|
264
|
+
- **`MediaGallery`** lays out a run's images, audio, video and PDFs as cards, numbered in the attachments' order so the numbers match the agent's numbered list. Images open a full-size viewer. "Download all" saves every card's file when there's more than one, one at a time, because browsers block a burst of simultaneous downloads. Other files follow the cards as download links.
|
|
258
265
|
- **`MediaSkeleton`** is a placeholder card for an image that's still being generated. It pulses, unless the user prefers reduced motion.
|
|
259
|
-
- **`MediaViewer`** is the gallery's full-size viewer, a modal `<dialog>` with previous and next (also on the arrow keys) and a download button. Escape, the close button or a click on the backdrop closes it, and focus goes back to where it was. It's controlled: pass the `index` to show, or `null` when closed.
|
|
260
|
-
- **`attachmentFileName(attachment, number?)`** is the filename the components save a file as: its own name, or else `image
|
|
266
|
+
- **`MediaViewer`** is the gallery's full-size image viewer, a modal `<dialog>` with previous and next (also on the arrow keys) and a download button. Escape, the close button or a click on the backdrop closes it, and focus goes back to where it was. It's controlled: pass the `index` to show, or `null` when closed. Pass `numbers` to name each image by its card number rather than its position. Video and PDFs don't open in it: video has its own full-screen control, and a PDF its browser viewer.
|
|
267
|
+
- **`attachmentFileName(attachment, number?)`** is the filename the components save a file as: its own name, or else its kind and number (`image-2.png`, `audio-3.mp3`, `video-1.mp4`, `pdf-4.pdf`, `file-5.zip`), or its id without a number, with an extension from the mime type.
|
|
261
268
|
|
|
262
269
|
| `MediaPreview` prop | |
|
|
263
270
|
|---|---|
|
|
264
271
|
| `attachment` | Required. The file to show |
|
|
265
|
-
| `aspectRatio` |
|
|
266
|
-
| `number` | A badge on the
|
|
272
|
+
| `aspectRatio` | An image or video frame's ratio, as a number (`16 / 9`) or a string (`"16 / 9"`). Without it the frame takes the file's own ratio once it loads, and `--seclai-media-aspect-ratio` (square) until then. Audio and PDF cards don't use it |
|
|
273
|
+
| `number` | A badge on the card, matching the agent's numbered list. Also names an unnamed file, such as `image-<number>` or `audio-<number>`, for download and for screen readers ("Audio 2") |
|
|
267
274
|
| `actions` | App-specific buttons after the download link: a node, or a function of the attachment |
|
|
268
|
-
| `onOpen` | Makes
|
|
275
|
+
| `onOpen` | Makes an image a button, for opening a viewer. Other files ignore it |
|
|
269
276
|
|
|
270
277
|
| `MediaGallery` prop | |
|
|
271
278
|
|---|---|
|
|
272
279
|
| `attachments` | Required. A run's attachments |
|
|
273
|
-
| `aspectRatio` | Every card's ratio. Without it each
|
|
274
|
-
| `pending` | How many skeleton cards to show after the
|
|
275
|
-
| `actions` | `(attachment, number) => ReactNode`, for each
|
|
280
|
+
| `aspectRatio` | Every image and video card's ratio. Without it each takes its file's own ratio |
|
|
281
|
+
| `pending` | How many skeleton cards to show after the cards, numbered on from them |
|
|
282
|
+
| `actions` | `(attachment, number) => ReactNode`, for each card |
|
|
276
283
|
|
|
277
|
-
The stylesheet adds these variables for media: `--seclai-media-aspect-ratio` (a frame's ratio before its image loads, `1 / 1`), `--seclai-media-fit` (`object-fit` in the frame, `scale-down`, so small images keep their natural size), `--seclai-media-min-width` (a gallery column's minimum width, `220px`)
|
|
284
|
+
The stylesheet adds these variables for media: `--seclai-media-aspect-ratio` (a frame's ratio before its image or video loads, `1 / 1`), `--seclai-media-fit` (`object-fit` in the frame, `scale-down`, so small images keep their natural size), `--seclai-media-min-width` (a gallery column's minimum width, `220px`), `--seclai-media-max-width` (a card's width outside a gallery, `480px`) and `--seclai-media-pdf-aspect-ratio` (a PDF's frame, `3 / 4`). Each kind of card has a class: `.seclai-media-image`, `.seclai-media-audio`, `.seclai-media-video` and `.seclai-media-pdf`, all with `.seclai-media-card`. The viewer is dark in both colour schemes.
|
|
285
|
+
|
|
286
|
+
### Audio, video and PDFs
|
|
287
|
+
|
|
288
|
+
- **Seeking doesn't work yet, and Safari may not play video.** The previews stream through the `download` handler, and the Seclai API doesn't answer HTTP `Range` requests for run attachments yet ([seclai/seclai#2556](https://github.com/seclai/seclai/issues/2556)), nor can `@seclai/sdk` send them ([seclai/seclai-javascript#21](https://github.com/seclai/seclai-javascript/issues/21)). So audio and video play from the start but can't skip ahead, and Safari, which wants `206 Partial Content` for video, may refuse to play it at all. The download link still works. The handler will forward `Range` once both land.
|
|
289
|
+
- **Your Content Security Policy** must let the page load media and objects from the handler's URL: if you set `media-src` or `object-src` (or `default-src`), they need `'self'`, or wherever you mount the handler. `object-src 'none'`, a common recommendation, stops PDFs from showing, as do `frame-ancestors 'none'` and `X-Frame-Options: DENY` on the handler's responses (`SAMEORIGIN` is fine). The handler's own `sandbox` policy on the files it serves doesn't stop `<audio>` and `<video>` from playing them: a response's policy only applies when it's opened as a page.
|
|
278
290
|
|
|
279
291
|
### Saving files
|
|
280
292
|
|
|
@@ -430,10 +442,6 @@ The stylesheet styles Markdown with the same `--seclai-*` variables, in light an
|
|
|
430
442
|
|
|
431
443
|
Two more variables: `--seclai-code-font` (the monospace font for code) and `--seclai-code-surface` (the background of code blocks and inline code).
|
|
432
444
|
|
|
433
|
-
## Placeholders
|
|
434
|
-
|
|
435
|
-
`MediaPreview` is exported so the API is in place, but it's minimal until it's ported from the main Seclai app: it shows image cards (see [Media](#media)) and a download link for everything else. Audio, video and PDF previews are still to come.
|
|
436
|
-
|
|
437
445
|
## License
|
|
438
446
|
|
|
439
447
|
MIT
|
package/dist/index.d.ts
CHANGED
|
@@ -351,42 +351,56 @@ type MediaAspectRatio = number | string;
|
|
|
351
351
|
interface MediaPreviewProps {
|
|
352
352
|
attachment: AgentAttachment;
|
|
353
353
|
/**
|
|
354
|
-
* The image frame's aspect ratio. Without it the frame takes the
|
|
355
|
-
* ratio once it loads, and `--seclai-media-aspect-ratio` (square
|
|
356
|
-
* until then.
|
|
354
|
+
* The image or video frame's aspect ratio. Without it the frame takes the
|
|
355
|
+
* file's own ratio once it loads, and `--seclai-media-aspect-ratio` (square
|
|
356
|
+
* by default) until then. Audio and PDF cards don't use it.
|
|
357
357
|
*/
|
|
358
358
|
aspectRatio?: MediaAspectRatio;
|
|
359
|
-
/** A badge on the
|
|
359
|
+
/** A badge on the card, matching the agent's numbered list ("1.", "2."). */
|
|
360
360
|
number?: number;
|
|
361
361
|
/** App-specific buttons, shown after the download link. A function gets the attachment. */
|
|
362
362
|
actions?: ReactNode | ((attachment: AgentAttachment) => ReactNode);
|
|
363
|
-
/** Makes
|
|
363
|
+
/** Makes an image a button, for opening a full-size viewer. Other files ignore it. */
|
|
364
364
|
onOpen?(): void;
|
|
365
365
|
}
|
|
366
366
|
/**
|
|
367
|
-
* Shows a file from a run
|
|
368
|
-
*
|
|
369
|
-
*
|
|
367
|
+
* Shows a file from a run, by its mime type (ignoring case and parameters):
|
|
368
|
+
*
|
|
369
|
+
* - an image in a fixed-ratio frame, which can open a full-size viewer;
|
|
370
|
+
* - audio with the browser's own controls;
|
|
371
|
+
* - video with the browser's own controls, in a frame like an image's;
|
|
372
|
+
* - a PDF in the browser's PDF viewer, or a download link where there isn't one;
|
|
373
|
+
* - anything else as a download link.
|
|
374
|
+
*
|
|
375
|
+
* Every card has a download link, an optional number badge and an `actions`
|
|
376
|
+
* slot. A file that fails to load says so, and keeps its download link.
|
|
370
377
|
*/
|
|
371
378
|
declare function MediaPreview({ attachment, aspectRatio, number, actions, onOpen }: MediaPreviewProps): react.JSX.Element;
|
|
372
379
|
|
|
373
380
|
interface MediaGalleryProps {
|
|
374
|
-
/**
|
|
381
|
+
/**
|
|
382
|
+
* A run's attachments. Images, audio, video and PDFs become cards, numbered in
|
|
383
|
+
* this order; other files follow as download links.
|
|
384
|
+
*/
|
|
375
385
|
attachments: AgentAttachment[];
|
|
376
|
-
/**
|
|
386
|
+
/**
|
|
387
|
+
* Every image and video card's aspect ratio. Without it each takes its file's
|
|
388
|
+
* own ratio. Audio and PDF cards keep their own shape.
|
|
389
|
+
*/
|
|
377
390
|
aspectRatio?: MediaAspectRatio;
|
|
378
391
|
/**
|
|
379
|
-
* Skeleton cards to show after the
|
|
380
|
-
* They're numbered on from the last
|
|
392
|
+
* Skeleton cards to show after the cards, for images still being generated.
|
|
393
|
+
* They're numbered on from the last card.
|
|
381
394
|
*/
|
|
382
395
|
pending?: number;
|
|
383
396
|
/** App-specific buttons for each card. Gets the attachment and its 1-based number. */
|
|
384
397
|
actions?(attachment: AgentAttachment, number: number): ReactNode;
|
|
385
398
|
}
|
|
386
399
|
/**
|
|
387
|
-
* Lays out a run's images
|
|
388
|
-
*
|
|
389
|
-
*
|
|
400
|
+
* Lays out a run's images, audio, video and PDFs as numbered cards, in the
|
|
401
|
+
* attachments' order, so the numbers match the agent's numbered list. Images
|
|
402
|
+
* open a full-size viewer. "Download all" saves every card's file when there's
|
|
403
|
+
* more than one. Other files follow the cards as download links.
|
|
390
404
|
*/
|
|
391
405
|
declare function MediaGallery({ attachments, aspectRatio, pending, actions, }: MediaGalleryProps): react.JSX.Element;
|
|
392
406
|
|
|
@@ -406,8 +420,14 @@ interface MediaSkeletonProps {
|
|
|
406
420
|
declare function MediaSkeleton({ aspectRatio, number, label }: MediaSkeletonProps): react.JSX.Element;
|
|
407
421
|
|
|
408
422
|
interface MediaViewerProps {
|
|
409
|
-
/** The images to page through, in order. Image `i` is numbered `i + 1
|
|
423
|
+
/** The images to page through, in order. Image `i` is numbered `i + 1`, unless `numbers` says otherwise. */
|
|
410
424
|
attachments: AgentAttachment[];
|
|
425
|
+
/**
|
|
426
|
+
* Each image's number, as on its card, for its name and filename. A gallery
|
|
427
|
+
* with audio, video or PDF cards between its images passes these, so image 3
|
|
428
|
+
* isn't called "Image 2" because it's the second image.
|
|
429
|
+
*/
|
|
430
|
+
numbers?: readonly number[];
|
|
411
431
|
/** The image showing, or `null` when the viewer is closed. */
|
|
412
432
|
index: number | null;
|
|
413
433
|
/** Called with the new index when the user goes to the previous or next image. */
|
|
@@ -421,11 +441,12 @@ interface MediaViewerProps {
|
|
|
421
441
|
* show, and `null` to close it. Focus moves into the viewer when it opens and
|
|
422
442
|
* back to where it was when it closes.
|
|
423
443
|
*/
|
|
424
|
-
declare function MediaViewer({ attachments, index, onIndexChange, onClose }: MediaViewerProps): react.JSX.Element;
|
|
444
|
+
declare function MediaViewer({ attachments, numbers, index, onIndexChange, onClose }: MediaViewerProps): react.JSX.Element;
|
|
425
445
|
|
|
426
446
|
/**
|
|
427
|
-
* The filename to save an attachment as: its own name, or else
|
|
428
|
-
* (
|
|
447
|
+
* The filename to save an attachment as: its own name, or else its kind and
|
|
448
|
+
* number (`image-2`, `audio-3`, `video-1`, `pdf-4`, or `file-5` for anything
|
|
449
|
+
* else), or its id without a number, with an extension from its mime type.
|
|
429
450
|
*/
|
|
430
451
|
declare function attachmentFileName(attachment: AgentAttachment, number?: number): string;
|
|
431
452
|
/**
|
package/dist/index.js
CHANGED
|
@@ -33,15 +33,15 @@ function createEndpoints({
|
|
|
33
33
|
agentId
|
|
34
34
|
} = {}) {
|
|
35
35
|
const trimmed = basePath.replace(/\/+$/, "");
|
|
36
|
-
const
|
|
36
|
+
const base = agentId ? `${trimmed}/${encodeURIComponent(agentId)}` : trimmed;
|
|
37
37
|
return {
|
|
38
|
-
attachmentReferences: `${
|
|
39
|
-
upload: `${
|
|
40
|
-
run: `${
|
|
38
|
+
attachmentReferences: `${base}/attachment-references`,
|
|
39
|
+
upload: `${base}/upload`,
|
|
40
|
+
run: `${base}/run`,
|
|
41
41
|
download(runId, attachmentId, name) {
|
|
42
42
|
const params = new URLSearchParams({ runId, attachmentId });
|
|
43
43
|
if (name) params.set("name", name);
|
|
44
|
-
return `${
|
|
44
|
+
return `${base}/download?${params}`;
|
|
45
45
|
}
|
|
46
46
|
};
|
|
47
47
|
}
|
|
@@ -70,10 +70,10 @@ function withQuery(url, params) {
|
|
|
70
70
|
const query = new URLSearchParams(params).toString();
|
|
71
71
|
if (!query) return url;
|
|
72
72
|
const hashAt = url.indexOf("#");
|
|
73
|
-
const
|
|
73
|
+
const base = hashAt < 0 ? url : url.slice(0, hashAt);
|
|
74
74
|
const hash = hashAt < 0 ? "" : url.slice(hashAt);
|
|
75
|
-
const separator = !
|
|
76
|
-
return `${
|
|
75
|
+
const separator = !base.includes("?") ? "?" : base.endsWith("?") || base.endsWith("&") ? "" : "&";
|
|
76
|
+
return `${base}${separator}${query}${hash}`;
|
|
77
77
|
}
|
|
78
78
|
|
|
79
79
|
// src/attachments.ts
|
|
@@ -190,7 +190,7 @@ function splitPoints(tree, source, rawHtml = true) {
|
|
|
190
190
|
// src/markdown/extensions.tsx
|
|
191
191
|
import { createContext, useContext } from "react";
|
|
192
192
|
import { jsx } from "react/jsx-runtime";
|
|
193
|
-
var ExtensionsContext = createContext([]);
|
|
193
|
+
var ExtensionsContext = /* @__PURE__ */ createContext([]);
|
|
194
194
|
function SeclaiMarkdownProvider({ extensions, children }) {
|
|
195
195
|
return /* @__PURE__ */ jsx(ExtensionsContext.Provider, { value: extensions, children });
|
|
196
196
|
}
|
|
@@ -342,25 +342,26 @@ var svgAttributes = {
|
|
|
342
342
|
feComposite: ["in", "in2", "operator", "k1", "k2", "k3", "k4", "result"]
|
|
343
343
|
};
|
|
344
344
|
var DROPPED = /* @__PURE__ */ new Set(["accessKey", "tabIndex"]);
|
|
345
|
-
var
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
345
|
+
var sanitizeSchema = /* @__PURE__ */ (() => {
|
|
346
|
+
const base = defaultSchema.attributes ?? {};
|
|
347
|
+
return {
|
|
348
|
+
...defaultSchema,
|
|
349
|
+
tagNames: [...defaultSchema.tagNames ?? [], ...SVG_TAGS],
|
|
350
|
+
attributes: {
|
|
351
|
+
...base,
|
|
352
|
+
"*": (base["*"] ?? []).filter((attribute) => typeof attribute !== "string" || !DROPPED.has(attribute)),
|
|
353
|
+
...Object.fromEntries(SVG_TAGS.map((tag) => [tag, [...SVG_COMMON, ...svgAttributes[tag] ?? []]]))
|
|
354
|
+
},
|
|
355
|
+
protocols: {
|
|
356
|
+
...defaultSchema.protocols,
|
|
357
|
+
href: ["http", "https", "mailto"],
|
|
358
|
+
src: ["http", "https"]
|
|
359
|
+
},
|
|
360
|
+
// Dropped with their content. Other disallowed elements, such as `form`, are
|
|
361
|
+
// unwrapped and their content kept.
|
|
362
|
+
strip: ["script", "style", "foreignObject", "iframe", "noscript", "template"]
|
|
363
|
+
};
|
|
364
|
+
})();
|
|
364
365
|
var isElement = (node) => node.type === "element";
|
|
365
366
|
function walk(node, visit, inSvg = false) {
|
|
366
367
|
for (const child of node.children) {
|
|
@@ -372,6 +373,7 @@ function walk(node, visit, inSvg = false) {
|
|
|
372
373
|
}
|
|
373
374
|
var URL_REFERENCE = /url\(\s*(['"]?)([^)'"]*)\1\s*\)/gi;
|
|
374
375
|
function rehypeSafeReferences() {
|
|
376
|
+
const prefix = defaultSchema.clobberPrefix ?? "user-content-";
|
|
375
377
|
return (tree) => {
|
|
376
378
|
walk(tree, (element, _parent, inSvg) => {
|
|
377
379
|
const { properties } = element;
|
|
@@ -380,7 +382,7 @@ function rehypeSafeReferences() {
|
|
|
380
382
|
if (typeof value !== "string") continue;
|
|
381
383
|
if (key === "href" || key === "xLinkHref") {
|
|
382
384
|
if (value.startsWith("#")) {
|
|
383
|
-
properties[key] = `#${
|
|
385
|
+
properties[key] = `#${prefix}${value.slice(1)}`;
|
|
384
386
|
} else if (inSvg && element.tagName !== "a") {
|
|
385
387
|
delete properties[key];
|
|
386
388
|
}
|
|
@@ -390,7 +392,7 @@ function rehypeSafeReferences() {
|
|
|
390
392
|
let external2 = false;
|
|
391
393
|
const rewritten = value.replace(URL_REFERENCE, (_, _quote, target) => {
|
|
392
394
|
if (!target.startsWith("#")) external2 = true;
|
|
393
|
-
return `url(#${
|
|
395
|
+
return `url(#${prefix}${target.slice(1)})`;
|
|
394
396
|
});
|
|
395
397
|
if (external2 || /url\(/i.test(rewritten.replace(URL_REFERENCE, ""))) delete properties[key];
|
|
396
398
|
else properties[key] = rewritten;
|
|
@@ -486,7 +488,7 @@ function pipelineFor(extensions) {
|
|
|
486
488
|
function remarkOnTree(onTree) {
|
|
487
489
|
return (tree, file) => onTree(tree, String(file.value));
|
|
488
490
|
}
|
|
489
|
-
var Block = memo(
|
|
491
|
+
var Block = /* @__PURE__ */ memo(
|
|
490
492
|
function Block2({ text, pipeline, onTree }) {
|
|
491
493
|
return /* @__PURE__ */ jsx2(
|
|
492
494
|
Markdown,
|
|
@@ -531,7 +533,7 @@ var Splitter = class {
|
|
|
531
533
|
return { starts, onTree };
|
|
532
534
|
}
|
|
533
535
|
};
|
|
534
|
-
var MarkdownContent = memo(function MarkdownContent2({
|
|
536
|
+
var MarkdownContent = /* @__PURE__ */ memo(function MarkdownContent2({
|
|
535
537
|
content,
|
|
536
538
|
streaming = false,
|
|
537
539
|
extensions
|
|
@@ -561,9 +563,6 @@ var MarkdownContent = memo(function MarkdownContent2({
|
|
|
561
563
|
// src/media/MediaGallery.tsx
|
|
562
564
|
import { useEffect as useEffect4, useRef as useRef3, useState as useState4 } from "react";
|
|
563
565
|
|
|
564
|
-
// src/placeholders/MediaPreview.tsx
|
|
565
|
-
import { useEffect as useEffect2, useRef, useState as useState3 } from "react";
|
|
566
|
-
|
|
567
566
|
// src/media/files.ts
|
|
568
567
|
var EXTENSIONS = {
|
|
569
568
|
"image/jpeg": "jpg",
|
|
@@ -576,11 +575,22 @@ var EXTENSIONS = {
|
|
|
576
575
|
"text/markdown": "md",
|
|
577
576
|
"application/octet-stream": "bin"
|
|
578
577
|
};
|
|
578
|
+
function baseMime(mime) {
|
|
579
|
+
return mime.split(";")[0].trim().toLowerCase();
|
|
580
|
+
}
|
|
579
581
|
function isImage(attachment) {
|
|
580
|
-
return attachment.mime
|
|
582
|
+
return baseMime(attachment.mime).startsWith("image/");
|
|
583
|
+
}
|
|
584
|
+
function mediaKind(attachment) {
|
|
585
|
+
const type = baseMime(attachment.mime);
|
|
586
|
+
if (type.startsWith("image/")) return "image";
|
|
587
|
+
if (type.startsWith("audio/")) return "audio";
|
|
588
|
+
if (type.startsWith("video/")) return "video";
|
|
589
|
+
if (type === "application/pdf") return "pdf";
|
|
590
|
+
return null;
|
|
581
591
|
}
|
|
582
592
|
function extensionForMime(mime) {
|
|
583
|
-
const type = mime
|
|
593
|
+
const type = baseMime(mime);
|
|
584
594
|
const known = EXTENSIONS[type];
|
|
585
595
|
if (known) return known;
|
|
586
596
|
const subtype = type.split("/")[1] ?? "";
|
|
@@ -589,8 +599,8 @@ function extensionForMime(mime) {
|
|
|
589
599
|
}
|
|
590
600
|
function attachmentFileName(attachment, number) {
|
|
591
601
|
if (attachment.name) return attachment.name;
|
|
592
|
-
const
|
|
593
|
-
return `${
|
|
602
|
+
const base = number != null ? `${mediaKind(attachment) ?? "file"}-${number}` : attachment.id;
|
|
603
|
+
return `${base}.${extensionForMime(attachment.mime)}`;
|
|
594
604
|
}
|
|
595
605
|
var SAFE_PROTOCOLS = /* @__PURE__ */ new Set(["http:", "https:", "blob:"]);
|
|
596
606
|
function isSafeUrl(url) {
|
|
@@ -646,7 +656,8 @@ function wait(ms, signal) {
|
|
|
646
656
|
});
|
|
647
657
|
}
|
|
648
658
|
|
|
649
|
-
// src/
|
|
659
|
+
// src/media/MediaPreview.tsx
|
|
660
|
+
import { useEffect as useEffect2, useRef, useState as useState3 } from "react";
|
|
650
661
|
import { Fragment as Fragment2, jsx as jsx3, jsxs } from "react/jsx-runtime";
|
|
651
662
|
function hasContent(node) {
|
|
652
663
|
return node != null && node !== false && node !== "";
|
|
@@ -654,35 +665,66 @@ function hasContent(node) {
|
|
|
654
665
|
function aspectRatioStyle(ratio) {
|
|
655
666
|
return ratio == null ? void 0 : { aspectRatio: String(ratio) };
|
|
656
667
|
}
|
|
657
|
-
|
|
658
|
-
|
|
668
|
+
var KIND_LABELS = {
|
|
669
|
+
image: "Image",
|
|
670
|
+
audio: "Audio",
|
|
671
|
+
video: "Video",
|
|
672
|
+
pdf: "PDF"
|
|
673
|
+
};
|
|
674
|
+
function kindLabel(attachment) {
|
|
675
|
+
const kind = mediaKind(attachment);
|
|
676
|
+
return kind ? KIND_LABELS[kind] : "File";
|
|
677
|
+
}
|
|
678
|
+
function mediaLabel(attachment, number) {
|
|
679
|
+
if (attachment.name) return attachment.name;
|
|
680
|
+
const kind = kindLabel(attachment);
|
|
681
|
+
return number != null ? `${kind} ${number}` : kind;
|
|
659
682
|
}
|
|
660
683
|
function MediaPreview({ attachment, aspectRatio, number, actions, onOpen }) {
|
|
661
684
|
const filename = attachmentFileName(attachment, number);
|
|
662
685
|
const extra = typeof actions === "function" ? actions(attachment) : actions;
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
686
|
+
const card = { attachment, number, filename, extra };
|
|
687
|
+
switch (mediaKind(attachment)) {
|
|
688
|
+
case "image":
|
|
689
|
+
return /* @__PURE__ */ jsx3(ImageCard, { ...card, aspectRatio, onOpen });
|
|
690
|
+
case "video":
|
|
691
|
+
return /* @__PURE__ */ jsx3(VideoCard, { ...card, aspectRatio });
|
|
692
|
+
case "audio":
|
|
693
|
+
return /* @__PURE__ */ jsx3(AudioCard, { ...card });
|
|
694
|
+
case "pdf":
|
|
695
|
+
return /* @__PURE__ */ jsx3(PdfCard, { ...card });
|
|
696
|
+
default:
|
|
697
|
+
return /* @__PURE__ */ jsx3("figure", { className: "seclai-media", children: /* @__PURE__ */ jsxs("figcaption", { children: [
|
|
698
|
+
/* @__PURE__ */ jsx3("a", { href: attachment.url, download: filename, children: attachment.name || filename }),
|
|
699
|
+
hasContent(extra) && /* @__PURE__ */ jsx3("span", { className: "seclai-media-actions", children: extra })
|
|
700
|
+
] }) });
|
|
668
701
|
}
|
|
669
|
-
return /* @__PURE__ */ jsx3(
|
|
670
|
-
ImageCard,
|
|
671
|
-
{
|
|
672
|
-
attachment,
|
|
673
|
-
aspectRatio,
|
|
674
|
-
number,
|
|
675
|
-
filename,
|
|
676
|
-
extra,
|
|
677
|
-
onOpen
|
|
678
|
-
}
|
|
679
|
-
);
|
|
680
702
|
}
|
|
681
|
-
function
|
|
703
|
+
function Badge({ number }) {
|
|
704
|
+
return number != null ? /* @__PURE__ */ jsx3("span", { className: "seclai-media-badge", children: number }) : null;
|
|
705
|
+
}
|
|
706
|
+
function CardBar({ attachment, number, filename, extra }) {
|
|
707
|
+
return /* @__PURE__ */ jsxs("figcaption", { className: "seclai-media-bar", children: [
|
|
708
|
+
/* @__PURE__ */ jsx3("a", { href: attachment.url, download: filename, "aria-label": `Download ${mediaLabel(attachment, number)}`, children: "Download" }),
|
|
709
|
+
hasContent(extra) && /* @__PURE__ */ jsx3("span", { className: "seclai-media-actions", children: extra })
|
|
710
|
+
] });
|
|
711
|
+
}
|
|
712
|
+
function CardHead({ attachment, number }) {
|
|
713
|
+
return /* @__PURE__ */ jsxs("div", { className: "seclai-media-head", children: [
|
|
714
|
+
/* @__PURE__ */ jsx3(Badge, { number }),
|
|
715
|
+
/* @__PURE__ */ jsx3("span", { className: "seclai-media-title", children: attachment.name || kindLabel(attachment) })
|
|
716
|
+
] });
|
|
717
|
+
}
|
|
718
|
+
function ImageCard({
|
|
719
|
+
aspectRatio,
|
|
720
|
+
onOpen,
|
|
721
|
+
...card
|
|
722
|
+
}) {
|
|
723
|
+
const { attachment, number } = card;
|
|
682
724
|
const img = useRef(null);
|
|
683
725
|
const [natural, setNatural] = useState3(null);
|
|
684
726
|
const [failed, setFailed] = useState3(false);
|
|
685
|
-
const label =
|
|
727
|
+
const label = mediaLabel(attachment, number);
|
|
686
728
|
function measure() {
|
|
687
729
|
const el = img.current;
|
|
688
730
|
if (el && el.naturalWidth > 0 && el.naturalHeight > 0) {
|
|
@@ -711,10 +753,10 @@ function ImageCard({ attachment, aspectRatio, number, filename, extra, onOpen })
|
|
|
711
753
|
onError: () => setFailed(true)
|
|
712
754
|
}
|
|
713
755
|
),
|
|
714
|
-
|
|
756
|
+
/* @__PURE__ */ jsx3(Badge, { number })
|
|
715
757
|
] });
|
|
716
758
|
const frameStyle = aspectRatioStyle(aspectRatio ?? natural ?? void 0);
|
|
717
|
-
return /* @__PURE__ */ jsxs("figure", { className: "seclai-media seclai-media-image", children: [
|
|
759
|
+
return /* @__PURE__ */ jsxs("figure", { className: "seclai-media seclai-media-card seclai-media-image", children: [
|
|
718
760
|
onOpen ? /* @__PURE__ */ jsx3(
|
|
719
761
|
"button",
|
|
720
762
|
{
|
|
@@ -727,10 +769,108 @@ function ImageCard({ attachment, aspectRatio, number, filename, extra, onOpen })
|
|
|
727
769
|
children: frameContent
|
|
728
770
|
}
|
|
729
771
|
) : /* @__PURE__ */ jsx3("div", { className: "seclai-media-frame", style: frameStyle, children: frameContent }),
|
|
730
|
-
/* @__PURE__ */
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
772
|
+
/* @__PURE__ */ jsx3(CardBar, { ...card })
|
|
773
|
+
] });
|
|
774
|
+
}
|
|
775
|
+
function VideoCard({ aspectRatio, ...card }) {
|
|
776
|
+
const { attachment, number } = card;
|
|
777
|
+
const video = useRef(null);
|
|
778
|
+
const [natural, setNatural] = useState3(null);
|
|
779
|
+
const [failed, setFailed] = useState3(false);
|
|
780
|
+
function measure() {
|
|
781
|
+
const el = video.current;
|
|
782
|
+
if (el && el.videoWidth > 0 && el.videoHeight > 0) {
|
|
783
|
+
setNatural(`${el.videoWidth} / ${el.videoHeight}`);
|
|
784
|
+
}
|
|
785
|
+
}
|
|
786
|
+
useEffect2(() => {
|
|
787
|
+
setNatural(null);
|
|
788
|
+
setFailed(false);
|
|
789
|
+
const el = video.current;
|
|
790
|
+
if (el?.error) setFailed(true);
|
|
791
|
+
else if (el && el.readyState >= HTMLMediaElement.HAVE_METADATA) measure();
|
|
792
|
+
}, [attachment.url]);
|
|
793
|
+
return /* @__PURE__ */ jsxs("figure", { className: "seclai-media seclai-media-card seclai-media-video", children: [
|
|
794
|
+
/* @__PURE__ */ jsxs("div", { className: "seclai-media-frame", style: aspectRatioStyle(aspectRatio ?? natural ?? void 0), children: [
|
|
795
|
+
failed ? /* @__PURE__ */ jsx3("span", { className: "seclai-media-error", children: "Couldn't load the video." }) : /* @__PURE__ */ jsx3(
|
|
796
|
+
"video",
|
|
797
|
+
{
|
|
798
|
+
ref: video,
|
|
799
|
+
src: attachment.url,
|
|
800
|
+
controls: true,
|
|
801
|
+
preload: "metadata",
|
|
802
|
+
playsInline: true,
|
|
803
|
+
"aria-label": mediaLabel(attachment, number),
|
|
804
|
+
onLoadedMetadata: measure,
|
|
805
|
+
onError: () => setFailed(true)
|
|
806
|
+
}
|
|
807
|
+
),
|
|
808
|
+
/* @__PURE__ */ jsx3(Badge, { number })
|
|
809
|
+
] }),
|
|
810
|
+
/* @__PURE__ */ jsx3(CardBar, { ...card })
|
|
811
|
+
] });
|
|
812
|
+
}
|
|
813
|
+
function AudioCard(card) {
|
|
814
|
+
const { attachment, number } = card;
|
|
815
|
+
const audio = useRef(null);
|
|
816
|
+
const [failed, setFailed] = useState3(false);
|
|
817
|
+
useEffect2(() => {
|
|
818
|
+
setFailed(audio.current?.error != null);
|
|
819
|
+
}, [attachment.url]);
|
|
820
|
+
return /* @__PURE__ */ jsxs("figure", { className: "seclai-media seclai-media-card seclai-media-audio", children: [
|
|
821
|
+
/* @__PURE__ */ jsx3(CardHead, { attachment, number }),
|
|
822
|
+
/* @__PURE__ */ jsx3("div", { className: "seclai-media-body", children: failed ? /* @__PURE__ */ jsx3("span", { className: "seclai-media-error", children: "Couldn't load the audio." }) : /* @__PURE__ */ jsx3(
|
|
823
|
+
"audio",
|
|
824
|
+
{
|
|
825
|
+
ref: audio,
|
|
826
|
+
src: attachment.url,
|
|
827
|
+
controls: true,
|
|
828
|
+
preload: "metadata",
|
|
829
|
+
"aria-label": mediaLabel(attachment, number),
|
|
830
|
+
onError: () => setFailed(true)
|
|
831
|
+
}
|
|
832
|
+
) }),
|
|
833
|
+
/* @__PURE__ */ jsx3(CardBar, { ...card })
|
|
834
|
+
] });
|
|
835
|
+
}
|
|
836
|
+
function PdfCard(card) {
|
|
837
|
+
const { attachment, number, filename } = card;
|
|
838
|
+
const object = useRef(null);
|
|
839
|
+
const [failed, setFailed] = useState3(false);
|
|
840
|
+
const label = mediaLabel(attachment, number);
|
|
841
|
+
useEffect2(() => setFailed(false), [attachment.url]);
|
|
842
|
+
useEffect2(() => {
|
|
843
|
+
const el = object.current;
|
|
844
|
+
if (!el) return;
|
|
845
|
+
const fail = () => setFailed(true);
|
|
846
|
+
el.addEventListener("error", fail);
|
|
847
|
+
return () => el.removeEventListener("error", fail);
|
|
848
|
+
}, [attachment.url, failed]);
|
|
849
|
+
return /* @__PURE__ */ jsxs("figure", { className: "seclai-media seclai-media-card seclai-media-pdf", children: [
|
|
850
|
+
/* @__PURE__ */ jsx3(CardHead, { attachment, number }),
|
|
851
|
+
/* @__PURE__ */ jsx3("div", { className: "seclai-media-frame", children: failed ? /* @__PURE__ */ jsx3("span", { className: "seclai-media-error", children: "Couldn't load the PDF." }) : (
|
|
852
|
+
// Keyed on the URL: browsers don't reliably reload an <object> whose
|
|
853
|
+
// data changes.
|
|
854
|
+
/* @__PURE__ */ jsx3(
|
|
855
|
+
"object",
|
|
856
|
+
{
|
|
857
|
+
ref: object,
|
|
858
|
+
type: "application/pdf",
|
|
859
|
+
data: attachment.url,
|
|
860
|
+
"aria-label": label,
|
|
861
|
+
children: /* @__PURE__ */ jsxs("span", { className: "seclai-media-fallback", children: [
|
|
862
|
+
"This browser can't show the PDF here.",
|
|
863
|
+
" ",
|
|
864
|
+
/* @__PURE__ */ jsxs("a", { href: attachment.url, download: filename, children: [
|
|
865
|
+
"Download ",
|
|
866
|
+
label
|
|
867
|
+
] })
|
|
868
|
+
] })
|
|
869
|
+
},
|
|
870
|
+
attachment.url
|
|
871
|
+
)
|
|
872
|
+
) }),
|
|
873
|
+
/* @__PURE__ */ jsx3(CardBar, { ...card })
|
|
734
874
|
] });
|
|
735
875
|
}
|
|
736
876
|
|
|
@@ -738,7 +878,7 @@ function ImageCard({ attachment, aspectRatio, number, filename, extra, onOpen })
|
|
|
738
878
|
import { jsx as jsx4, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
739
879
|
function MediaSkeleton({ aspectRatio, number, label }) {
|
|
740
880
|
const name = label ?? (number != null ? `Image ${number} is being generated` : "Image is being generated");
|
|
741
|
-
return /* @__PURE__ */ jsxs2("div", { className: "seclai-media seclai-media-image seclai-media-skeleton", role: "img", "aria-label": name, children: [
|
|
881
|
+
return /* @__PURE__ */ jsxs2("div", { className: "seclai-media seclai-media-card seclai-media-image seclai-media-skeleton", role: "img", "aria-label": name, children: [
|
|
742
882
|
/* @__PURE__ */ jsx4("div", { className: "seclai-media-frame", style: aspectRatioStyle(aspectRatio), children: number != null && /* @__PURE__ */ jsx4("span", { className: "seclai-media-badge", children: number }) }),
|
|
743
883
|
/* @__PURE__ */ jsx4("div", { className: "seclai-media-bar", children: /* @__PURE__ */ jsx4("span", { className: "seclai-media-skeleton-line" }) })
|
|
744
884
|
] });
|
|
@@ -747,7 +887,7 @@ function MediaSkeleton({ aspectRatio, number, label }) {
|
|
|
747
887
|
// src/media/MediaViewer.tsx
|
|
748
888
|
import { useEffect as useEffect3, useId, useRef as useRef2 } from "react";
|
|
749
889
|
import { Fragment as Fragment3, jsx as jsx5, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
750
|
-
function MediaViewer({ attachments, index, onIndexChange, onClose }) {
|
|
890
|
+
function MediaViewer({ attachments, numbers, index, onIndexChange, onClose }) {
|
|
751
891
|
const dialog = useRef2(null);
|
|
752
892
|
const closeButton = useRef2(null);
|
|
753
893
|
const returnFocus = useRef2(null);
|
|
@@ -805,8 +945,9 @@ function MediaViewer({ attachments, index, onIndexChange, onClose }) {
|
|
|
805
945
|
function onClick(event) {
|
|
806
946
|
if (event.target === event.currentTarget) onClose();
|
|
807
947
|
}
|
|
808
|
-
const
|
|
809
|
-
const
|
|
948
|
+
const position = index != null ? index + 1 : 0;
|
|
949
|
+
const number = index != null ? numbers?.[index] ?? position : 0;
|
|
950
|
+
const label = current ? mediaLabel(current, number) : "";
|
|
810
951
|
return /* @__PURE__ */ jsx5(
|
|
811
952
|
"dialog",
|
|
812
953
|
{
|
|
@@ -823,7 +964,7 @@ function MediaViewer({ attachments, index, onIndexChange, onClose }) {
|
|
|
823
964
|
/* @__PURE__ */ jsxs3("p", { className: "seclai-viewer-title", id: titleId, children: [
|
|
824
965
|
label,
|
|
825
966
|
attachments.length > 1 && /* @__PURE__ */ jsxs3("span", { className: "seclai-viewer-count", children: [
|
|
826
|
-
|
|
967
|
+
position,
|
|
827
968
|
" of ",
|
|
828
969
|
attachments.length
|
|
829
970
|
] })
|
|
@@ -866,8 +1007,15 @@ function MediaGallery({
|
|
|
866
1007
|
pending = 0,
|
|
867
1008
|
actions
|
|
868
1009
|
}) {
|
|
869
|
-
const
|
|
870
|
-
const files = attachments.filter((attachment) =>
|
|
1010
|
+
const cards = attachments.filter((attachment) => mediaKind(attachment) != null);
|
|
1011
|
+
const files = attachments.filter((attachment) => mediaKind(attachment) == null);
|
|
1012
|
+
const images = [];
|
|
1013
|
+
const imageNumbers = [];
|
|
1014
|
+
const viewerIndexes = cards.map((card, i) => {
|
|
1015
|
+
if (!isImage(card)) return null;
|
|
1016
|
+
imageNumbers.push(i + 1);
|
|
1017
|
+
return images.push(card) - 1;
|
|
1018
|
+
});
|
|
871
1019
|
const [viewing, setViewing] = useState4(null);
|
|
872
1020
|
const [downloading, setDownloading] = useState4(false);
|
|
873
1021
|
const abort = useRef3(null);
|
|
@@ -880,7 +1028,7 @@ function MediaGallery({
|
|
|
880
1028
|
setDownloading(true);
|
|
881
1029
|
try {
|
|
882
1030
|
await saveFiles(
|
|
883
|
-
|
|
1031
|
+
cards.map((card, i) => ({ source: card.url, filename: attachmentFileName(card, i + 1) })),
|
|
884
1032
|
{ delayMs: DOWNLOAD_ALL_DELAY_MS, signal: controller.signal }
|
|
885
1033
|
);
|
|
886
1034
|
} finally {
|
|
@@ -889,27 +1037,30 @@ function MediaGallery({
|
|
|
889
1037
|
}
|
|
890
1038
|
const skeletons = Math.max(0, Math.floor(pending));
|
|
891
1039
|
return /* @__PURE__ */ jsxs4("div", { className: "seclai-gallery", children: [
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
{
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
1040
|
+
cards.length + skeletons > 0 && /* @__PURE__ */ jsxs4("ul", { className: "seclai-gallery-grid", children: [
|
|
1041
|
+
cards.map((card, i) => {
|
|
1042
|
+
const image = viewerIndexes[i];
|
|
1043
|
+
return /* @__PURE__ */ jsx6("li", { children: /* @__PURE__ */ jsx6(
|
|
1044
|
+
MediaPreview,
|
|
1045
|
+
{
|
|
1046
|
+
attachment: card,
|
|
1047
|
+
aspectRatio,
|
|
1048
|
+
number: i + 1,
|
|
1049
|
+
actions: actions?.(card, i + 1),
|
|
1050
|
+
onOpen: image != null ? () => setViewing(image) : void 0
|
|
1051
|
+
}
|
|
1052
|
+
) }, card.id);
|
|
1053
|
+
}),
|
|
1054
|
+
Array.from({ length: skeletons }, (_, i) => /* @__PURE__ */ jsx6("li", { children: /* @__PURE__ */ jsx6(MediaSkeleton, { aspectRatio, number: cards.length + i + 1 }) }, `pending-${i}`))
|
|
904
1055
|
] }),
|
|
905
|
-
|
|
1056
|
+
cards.length > 1 && /* @__PURE__ */ jsx6("div", { className: "seclai-gallery-actions", children: /* @__PURE__ */ jsx6(
|
|
906
1057
|
"button",
|
|
907
1058
|
{
|
|
908
1059
|
type: "button",
|
|
909
1060
|
className: "seclai-button",
|
|
910
1061
|
"aria-disabled": downloading,
|
|
911
1062
|
onClick: downloadAll,
|
|
912
|
-
children: downloading ? "Downloading\u2026" : `Download all ${
|
|
1063
|
+
children: downloading ? "Downloading\u2026" : `Download all ${cards.length}`
|
|
913
1064
|
}
|
|
914
1065
|
) }),
|
|
915
1066
|
files.map((file) => /* @__PURE__ */ jsx6(MediaPreview, { attachment: file }, file.id)),
|
|
@@ -917,6 +1068,7 @@ function MediaGallery({
|
|
|
917
1068
|
MediaViewer,
|
|
918
1069
|
{
|
|
919
1070
|
attachments: images,
|
|
1071
|
+
numbers: imageNumbers,
|
|
920
1072
|
index: viewing,
|
|
921
1073
|
onIndexChange: setViewing,
|
|
922
1074
|
onClose: () => setViewing(null)
|
package/dist/styles.css
CHANGED
|
@@ -686,23 +686,25 @@ div.seclai-markdown-math {
|
|
|
686
686
|
}
|
|
687
687
|
|
|
688
688
|
/*
|
|
689
|
-
*
|
|
690
|
-
*
|
|
691
|
-
* --seclai-media-
|
|
692
|
-
* --seclai-media-
|
|
693
|
-
* --seclai-media-
|
|
689
|
+
* Media cards (image, video, audio and PDF), galleries, skeletons and the
|
|
690
|
+
* viewer. Also themable with:
|
|
691
|
+
* --seclai-media-aspect-ratio a frame's ratio before its image or video loads (1 / 1)
|
|
692
|
+
* --seclai-media-fit object-fit for the image in its frame (scale-down)
|
|
693
|
+
* --seclai-media-min-width a gallery column's minimum width (220px)
|
|
694
|
+
* --seclai-media-max-width a card's width outside a gallery (480px)
|
|
695
|
+
* --seclai-media-pdf-aspect-ratio a PDF frame's ratio (3 / 4)
|
|
694
696
|
*/
|
|
695
697
|
.seclai-gallery,
|
|
696
698
|
.seclai-gallery *,
|
|
697
|
-
.seclai-media-
|
|
698
|
-
.seclai-media-
|
|
699
|
+
.seclai-media-card,
|
|
700
|
+
.seclai-media-card *,
|
|
699
701
|
.seclai-viewer,
|
|
700
702
|
.seclai-viewer * {
|
|
701
703
|
box-sizing: border-box;
|
|
702
704
|
}
|
|
703
705
|
|
|
704
706
|
.seclai-gallery :focus-visible,
|
|
705
|
-
.seclai-media-
|
|
707
|
+
.seclai-media-card :focus-visible,
|
|
706
708
|
.seclai-viewer :focus-visible {
|
|
707
709
|
outline: 2px solid var(--seclai-focus);
|
|
708
710
|
outline-offset: 2px;
|
|
@@ -724,7 +726,7 @@ div.seclai-markdown-math {
|
|
|
724
726
|
}
|
|
725
727
|
}
|
|
726
728
|
|
|
727
|
-
.seclai-media-
|
|
729
|
+
.seclai-media-card {
|
|
728
730
|
width: 100%;
|
|
729
731
|
max-width: var(--seclai-media-max-width, 480px);
|
|
730
732
|
gap: 0;
|
|
@@ -774,6 +776,78 @@ button.seclai-media-frame:focus-visible {
|
|
|
774
776
|
}
|
|
775
777
|
}
|
|
776
778
|
|
|
779
|
+
.seclai-media-frame > video,
|
|
780
|
+
.seclai-media-frame > object {
|
|
781
|
+
display: block;
|
|
782
|
+
width: 100%;
|
|
783
|
+
height: 100%;
|
|
784
|
+
border: 0;
|
|
785
|
+
}
|
|
786
|
+
|
|
787
|
+
/* Black bars, as in any video player, rather than the frame's tint. */
|
|
788
|
+
.seclai-media-frame:has(> video) {
|
|
789
|
+
background: #000000;
|
|
790
|
+
}
|
|
791
|
+
|
|
792
|
+
.seclai-media-frame > video {
|
|
793
|
+
object-fit: contain;
|
|
794
|
+
}
|
|
795
|
+
|
|
796
|
+
/* Inset, as on an image's button: the frame fills the card and clips anything outside it. */
|
|
797
|
+
.seclai-media-frame > video:focus-visible,
|
|
798
|
+
.seclai-media-frame > object:focus-visible {
|
|
799
|
+
outline-offset: -2px;
|
|
800
|
+
}
|
|
801
|
+
|
|
802
|
+
.seclai-media-pdf .seclai-media-frame {
|
|
803
|
+
aspect-ratio: var(--seclai-media-pdf-aspect-ratio, 3 / 4);
|
|
804
|
+
}
|
|
805
|
+
|
|
806
|
+
/* Shown in place of the PDF by browsers without a PDF viewer. */
|
|
807
|
+
.seclai-media-fallback {
|
|
808
|
+
display: flex;
|
|
809
|
+
flex-direction: column;
|
|
810
|
+
align-items: center;
|
|
811
|
+
justify-content: center;
|
|
812
|
+
gap: 8px;
|
|
813
|
+
height: 100%;
|
|
814
|
+
padding: 12px;
|
|
815
|
+
color: var(--seclai-muted);
|
|
816
|
+
text-align: center;
|
|
817
|
+
}
|
|
818
|
+
|
|
819
|
+
/* Audio and PDF cards name the file above it, with the badge. */
|
|
820
|
+
.seclai-media-head {
|
|
821
|
+
display: flex;
|
|
822
|
+
align-items: center;
|
|
823
|
+
gap: 8px;
|
|
824
|
+
min-width: 0;
|
|
825
|
+
padding: 8px 12px;
|
|
826
|
+
border-bottom: 1px solid var(--seclai-border);
|
|
827
|
+
}
|
|
828
|
+
|
|
829
|
+
.seclai-media-title {
|
|
830
|
+
overflow: hidden;
|
|
831
|
+
font-weight: 600;
|
|
832
|
+
text-overflow: ellipsis;
|
|
833
|
+
white-space: nowrap;
|
|
834
|
+
}
|
|
835
|
+
|
|
836
|
+
.seclai-media-body {
|
|
837
|
+
padding: 8px 12px 0;
|
|
838
|
+
}
|
|
839
|
+
|
|
840
|
+
.seclai-media-audio audio {
|
|
841
|
+
display: block;
|
|
842
|
+
width: 100%;
|
|
843
|
+
}
|
|
844
|
+
|
|
845
|
+
.seclai-media-audio .seclai-media-error {
|
|
846
|
+
position: static;
|
|
847
|
+
justify-content: flex-start;
|
|
848
|
+
padding: 0;
|
|
849
|
+
}
|
|
850
|
+
|
|
777
851
|
/*
|
|
778
852
|
* A number badge, on an image and on the matching item of a numbered list in
|
|
779
853
|
* the agent's text. Fixed colours: the badge sits on the image, not on the page.
|
|
@@ -799,6 +873,16 @@ button.seclai-media-frame:focus-visible {
|
|
|
799
873
|
position: absolute;
|
|
800
874
|
top: 8px;
|
|
801
875
|
inset-inline-start: 8px;
|
|
876
|
+
/* Clicks go through to the video under it. */
|
|
877
|
+
pointer-events: none;
|
|
878
|
+
}
|
|
879
|
+
|
|
880
|
+
/* On the page rather than on a picture, so it inverts in a dark colour scheme, like a list number's. */
|
|
881
|
+
.seclai-media-head .seclai-media-badge {
|
|
882
|
+
position: static;
|
|
883
|
+
flex: none;
|
|
884
|
+
color: light-dark(#ffffff, #000000);
|
|
885
|
+
background: light-dark(rgb(0 0 0 / 0.72), rgb(255 255 255 / 0.85));
|
|
802
886
|
}
|
|
803
887
|
|
|
804
888
|
/* On the page, the same badge inverts in a dark colour scheme, so it still stands out. */
|
|
@@ -882,11 +966,16 @@ button.seclai-media-frame:focus-visible {
|
|
|
882
966
|
min-width: 0;
|
|
883
967
|
}
|
|
884
968
|
|
|
885
|
-
.seclai-gallery-grid .seclai-media-
|
|
969
|
+
.seclai-gallery-grid .seclai-media-card {
|
|
886
970
|
max-width: none;
|
|
887
971
|
height: 100%;
|
|
888
972
|
}
|
|
889
973
|
|
|
974
|
+
/* In a row of taller cards, an audio card's player sits at the top and its bar at the bottom. */
|
|
975
|
+
.seclai-gallery-grid .seclai-media-audio .seclai-media-body {
|
|
976
|
+
flex: 1;
|
|
977
|
+
}
|
|
978
|
+
|
|
890
979
|
.seclai-gallery-actions {
|
|
891
980
|
display: flex;
|
|
892
981
|
flex-wrap: wrap;
|