@uurtech/jdf 0.2.1 → 0.2.2
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/dist/jdfjs.cjs +3 -3
- package/dist/jdfjs.cjs.map +1 -1
- package/dist/jdfjs.css +3 -0
- package/dist/jdfjs.js +3 -3
- package/dist/jdfjs.js.map +1 -1
- package/package.json +1 -1
- package/src/jdfjs.css +3 -0
- package/src/renderers/element.ts +10 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uurtech/jdf",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.2",
|
|
4
4
|
"description": "Render JDF (JSON Document Format) documents in the browser. Drop-in replacement for embedding PDFs — point at a .jdf file and it appears on the page, fully styled, searchable, with a clickable TOC.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Ugur Kazdal <ugur@uurtech.com>",
|
package/src/jdfjs.css
CHANGED
|
@@ -360,3 +360,6 @@ select.jdfjs-form-control {
|
|
|
360
360
|
.jdfjs-dark .jdfjs-form-control:disabled {
|
|
361
361
|
background: #1f2937;
|
|
362
362
|
}
|
|
363
|
+
|
|
364
|
+
/* Unknown element type — same visible fallback as the desktop reader, never a silent drop. */
|
|
365
|
+
.jdfjs-unknown { font-size: 10px; color: #9ca3af; font-family: ui-monospace, Menlo, monospace; }
|
package/src/renderers/element.ts
CHANGED
|
@@ -47,8 +47,15 @@ export function renderElement(el: Element, ctx: RenderContext): HTMLElement | nu
|
|
|
47
47
|
case "checkbox": inner = renderFormCheckbox(el, ctx); break;
|
|
48
48
|
case "select": inner = renderFormSelect(el, ctx); break;
|
|
49
49
|
case "signature": inner = renderFormSignature(el, ctx); break;
|
|
50
|
+
default: {
|
|
51
|
+
// Same visible fallback as the desktop reader — an element must never vanish silently.
|
|
52
|
+
inner = document.createElement("div");
|
|
53
|
+
inner.className = "jdfjs-unknown";
|
|
54
|
+
inner.textContent = `[unknown: ${(el as any).type}]`;
|
|
55
|
+
}
|
|
50
56
|
}
|
|
51
57
|
if (!inner) return null;
|
|
58
|
+
wrap.dataset.jdfType = String((el as any).type);
|
|
52
59
|
wrap.appendChild(inner);
|
|
53
60
|
return wrap;
|
|
54
61
|
}
|
|
@@ -234,7 +241,9 @@ function renderImage(el: ImageElement, ctx: RenderContext): HTMLElement {
|
|
|
234
241
|
wrap.style.height = "100%";
|
|
235
242
|
const img = document.createElement("img");
|
|
236
243
|
img.src = imageSrc(el, ctx.resources);
|
|
237
|
-
|
|
244
|
+
// A caption written by `jdf describe` doubles as accessible text and hover title, so the text RAG indexes is the text the reader sees.
|
|
245
|
+
img.alt = el.alt || el.caption || "";
|
|
246
|
+
if (el.caption) img.title = el.caption;
|
|
238
247
|
img.style.display = "block";
|
|
239
248
|
img.style.width = "100%";
|
|
240
249
|
img.style.height = "100%";
|