@dmitryvim/form-builder 0.1.25 → 0.1.27
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/form-builder.js +44 -32
- package/package.json +1 -1
package/dist/form-builder.js
CHANGED
|
@@ -1366,7 +1366,7 @@ function renderSelectElement(element, ctx, wrapper, pathKey) {
|
|
|
1366
1366
|
// Common file preview rendering function for readonly mode
|
|
1367
1367
|
function renderFilePreviewReadonly(resourceId, fileName) {
|
|
1368
1368
|
const meta = state.resourceIndex.get(resourceId);
|
|
1369
|
-
const actualFileName = fileName || meta?.name || "file";
|
|
1369
|
+
const actualFileName = fileName || meta?.name || resourceId.split("/").pop() || "file";
|
|
1370
1370
|
|
|
1371
1371
|
// Individual file result container
|
|
1372
1372
|
const fileResult = document.createElement("div");
|
|
@@ -1377,46 +1377,58 @@ function renderFilePreviewReadonly(resourceId, fileName) {
|
|
|
1377
1377
|
previewContainer.className =
|
|
1378
1378
|
"bg-gray-100 rounded-lg overflow-hidden cursor-pointer hover:opacity-90 transition-opacity";
|
|
1379
1379
|
|
|
1380
|
-
//
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1380
|
+
// Determine if this looks like an image file
|
|
1381
|
+
const isImage = meta?.type?.startsWith("image/") ||
|
|
1382
|
+
actualFileName.toLowerCase().match(/\.(jpg|jpeg|png|gif|webp)$/);
|
|
1383
|
+
|
|
1384
|
+
// Determine if this looks like a video file
|
|
1385
|
+
const isVideo = meta?.type?.startsWith("video/") ||
|
|
1386
|
+
actualFileName.toLowerCase().match(/\.(mp4|webm|avi|mov)$/);
|
|
1387
|
+
|
|
1388
|
+
if (isImage) {
|
|
1389
|
+
// Image preview - try getThumbnail first
|
|
1386
1390
|
if (state.config.getThumbnail) {
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
+
try {
|
|
1392
|
+
const thumbnailUrl = state.config.getThumbnail(resourceId);
|
|
1393
|
+
if (thumbnailUrl) {
|
|
1394
|
+
previewContainer.innerHTML = `<img src="${thumbnailUrl}" alt="${actualFileName}" class="w-full h-auto">`;
|
|
1395
|
+
} else {
|
|
1396
|
+
// Fallback to icon if getThumbnail returns null/undefined
|
|
1397
|
+
previewContainer.innerHTML = `<div class="aspect-video flex items-center justify-center text-gray-400"><div class="text-center"><div class="text-4xl mb-2">🖼️</div><div class="text-sm">${actualFileName}</div></div></div>`;
|
|
1398
|
+
}
|
|
1399
|
+
} catch (error) {
|
|
1400
|
+
console.warn("getThumbnail failed for", resourceId, error);
|
|
1391
1401
|
previewContainer.innerHTML = `<div class="aspect-video flex items-center justify-center text-gray-400"><div class="text-center"><div class="text-4xl mb-2">🖼️</div><div class="text-sm">${actualFileName}</div></div></div>`;
|
|
1392
1402
|
}
|
|
1393
1403
|
} else {
|
|
1394
1404
|
previewContainer.innerHTML = `<div class="aspect-video flex items-center justify-center text-gray-400"><div class="text-center"><div class="text-4xl mb-2">🖼️</div><div class="text-sm">${actualFileName}</div></div></div>`;
|
|
1395
1405
|
}
|
|
1396
|
-
} else if (
|
|
1397
|
-
|
|
1398
|
-
actualFileName.toLowerCase().match(/\.(mp4|webm|avi|mov)$/)
|
|
1399
|
-
) {
|
|
1400
|
-
// Video preview
|
|
1406
|
+
} else if (isVideo) {
|
|
1407
|
+
// Video preview - try getThumbnail for video URL
|
|
1401
1408
|
if (state.config.getThumbnail) {
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
<
|
|
1407
|
-
<
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
<div class="bg-
|
|
1412
|
-
<
|
|
1413
|
-
<
|
|
1414
|
-
|
|
1409
|
+
try {
|
|
1410
|
+
const videoUrl = state.config.getThumbnail(resourceId);
|
|
1411
|
+
if (videoUrl) {
|
|
1412
|
+
previewContainer.innerHTML = `
|
|
1413
|
+
<div class="relative group">
|
|
1414
|
+
<video class="w-full h-auto" controls preload="auto" muted>
|
|
1415
|
+
<source src="${videoUrl}" type="${meta?.type || "video/mp4"}">
|
|
1416
|
+
Ваш браузер не поддерживает видео.
|
|
1417
|
+
</video>
|
|
1418
|
+
<div class="absolute inset-0 bg-black bg-opacity-20 opacity-0 group-hover:opacity-100 transition-opacity flex items-center justify-center pointer-events-none">
|
|
1419
|
+
<div class="bg-white bg-opacity-90 rounded-full p-3">
|
|
1420
|
+
<svg class="w-8 h-8 text-gray-800" fill="currentColor" viewBox="0 0 24 24">
|
|
1421
|
+
<path d="M8 5v14l11-7z"/>
|
|
1422
|
+
</svg>
|
|
1423
|
+
</div>
|
|
1415
1424
|
</div>
|
|
1416
1425
|
</div>
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1426
|
+
`;
|
|
1427
|
+
} else {
|
|
1428
|
+
previewContainer.innerHTML = `<div class="aspect-video flex items-center justify-center text-gray-400"><div class="text-center"><div class="text-4xl mb-2">🎥</div><div class="text-sm">${actualFileName}</div></div></div>`;
|
|
1429
|
+
}
|
|
1430
|
+
} catch (error) {
|
|
1431
|
+
console.warn("getThumbnail failed for video", resourceId, error);
|
|
1420
1432
|
previewContainer.innerHTML = `<div class="aspect-video flex items-center justify-center text-gray-400"><div class="text-center"><div class="text-4xl mb-2">🎥</div><div class="text-sm">${actualFileName}</div></div></div>`;
|
|
1421
1433
|
}
|
|
1422
1434
|
} else {
|