@ozguraltan/strapi-content-input 1.0.6 → 1.0.8
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/admin/{ContentInputField-D6rlm6Te.mjs → ContentInputField-CKTOutN-.mjs} +416 -59
- package/dist/admin/{ContentInputField-BM2WS_KZ.js → ContentInputField-CLuL3TFr.js} +416 -59
- package/dist/admin/{index-BA2XyNVO.mjs → index-BIwC3VPC.mjs} +1 -1
- package/dist/admin/{index-IuCWhUHI.js → index-DV4pLrQl.js} +1 -1
- package/dist/admin/index.js +1 -1
- package/dist/admin/index.mjs +1 -1
- package/dist/admin/src/components/widgets/StrapiMediaPicker.d.ts +2 -0
- package/package.json +1 -1
|
@@ -2,7 +2,7 @@ import { jsx, jsxs, Fragment } from "react/jsx-runtime";
|
|
|
2
2
|
import React, { useState, useMemo, useRef, createContext, useContext, useEffect } from "react";
|
|
3
3
|
import { createPortal } from "react-dom";
|
|
4
4
|
import cloneDeep from "lodash/cloneDeep";
|
|
5
|
-
import { M as MaterialIcon } from "./index-
|
|
5
|
+
import { M as MaterialIcon } from "./index-BIwC3VPC.mjs";
|
|
6
6
|
import { useFetchClient } from "@strapi/strapi/admin";
|
|
7
7
|
const ROW_PRESETS = [
|
|
8
8
|
{
|
|
@@ -845,7 +845,8 @@ const translations = {
|
|
|
845
845
|
gridGallery: "Grid Gallery",
|
|
846
846
|
galleryDisplayType: "Gallery Display Type",
|
|
847
847
|
galleryImages: "Gallery Images",
|
|
848
|
-
addGalleryImage: "+ Add Image",
|
|
848
|
+
addGalleryImage: "+ Add Image(s)",
|
|
849
|
+
clearAllImages: "Clear All",
|
|
849
850
|
noGalleryImages: "No images added to this gallery yet.",
|
|
850
851
|
popupOnOnClick: "Open in Lightbox Popup on Click",
|
|
851
852
|
imageProcess: "Image Processing",
|
|
@@ -974,17 +975,37 @@ const translations = {
|
|
|
974
975
|
// Media Picker
|
|
975
976
|
selectImage: "Select Image",
|
|
976
977
|
selectMedia: "Select Media",
|
|
978
|
+
selectMultipleMedia: "Select Images",
|
|
977
979
|
removeImage: "Remove Image",
|
|
978
980
|
mediaUrlPlaceholder: "Image URL or choose from Media Library...",
|
|
979
981
|
mediaLibraryTitle: "Strapi Media Library",
|
|
980
982
|
filesCount: "files",
|
|
981
983
|
refresh: "Refresh",
|
|
982
984
|
uploading: "Uploading...",
|
|
983
|
-
uploadNewFile: "Upload New File",
|
|
985
|
+
uploadNewFile: "Upload New File(s)",
|
|
984
986
|
searchFilesPlaceholder: "Search by file name or extension...",
|
|
985
987
|
loadingMediaFiles: "Loading media files...",
|
|
986
988
|
noMediaFilesFound: "No matching files found in the media library. Use the Upload New File button above to upload from your computer.",
|
|
987
|
-
selectedBadge: "SELECTED"
|
|
989
|
+
selectedBadge: "SELECTED",
|
|
990
|
+
multiSelectHint: "Click multiple images to select them in order",
|
|
991
|
+
selectedCountLabel: "selected",
|
|
992
|
+
selectAllVisible: "Select All",
|
|
993
|
+
clearSelection: "Clear Selection",
|
|
994
|
+
addSelectedMedia: "Add Selected",
|
|
995
|
+
"media.selectImage": "Select Image",
|
|
996
|
+
"media.selectMedia": "Select Media",
|
|
997
|
+
"media.selectMultipleMedia": "Select Images",
|
|
998
|
+
"media.removeImage": "Remove Image",
|
|
999
|
+
"media.urlPlaceholder": "Image URL or choose from Media Library...",
|
|
1000
|
+
"media.libraryTitle": "Strapi Media Library",
|
|
1001
|
+
"media.filesCount": "files",
|
|
1002
|
+
"media.refresh": "Refresh",
|
|
1003
|
+
"media.uploading": "Uploading...",
|
|
1004
|
+
"media.uploadNew": "Upload New File(s)",
|
|
1005
|
+
"media.searchPlaceholder": "Search by file name or extension...",
|
|
1006
|
+
"media.loadingFiles": "Loading media files...",
|
|
1007
|
+
"media.noMatchingFiles": "No matching files found in the media library. Use the Upload New File button above to upload from your computer.",
|
|
1008
|
+
"media.selectedBadge": "SELECTED"
|
|
988
1009
|
},
|
|
989
1010
|
tr: {
|
|
990
1011
|
// Core entities & actions
|
|
@@ -1158,7 +1179,8 @@ const translations = {
|
|
|
1158
1179
|
gridGallery: "Grid (Izgara Galeri)",
|
|
1159
1180
|
galleryDisplayType: "Galeri Gösterim Tipi",
|
|
1160
1181
|
galleryImages: "Galeri Görselleri",
|
|
1161
|
-
addGalleryImage: "+ Görsel Ekle",
|
|
1182
|
+
addGalleryImage: "+ Görsel(ler) Ekle",
|
|
1183
|
+
clearAllImages: "Tümünü Temizle",
|
|
1162
1184
|
noGalleryImages: "Henüz galeriye görsel eklenmedi.",
|
|
1163
1185
|
popupOnOnClick: "Tıklandığında Pop-up (Lightbox) Olarak Büyüt",
|
|
1164
1186
|
imageProcess: "Görsel İşleme (Image Process)",
|
|
@@ -1287,17 +1309,37 @@ const translations = {
|
|
|
1287
1309
|
// Media Picker
|
|
1288
1310
|
selectImage: "Görsel Seç",
|
|
1289
1311
|
selectMedia: "Medya Seç",
|
|
1312
|
+
selectMultipleMedia: "Çoklu Görsel Seç",
|
|
1290
1313
|
removeImage: "Görseli Kaldır",
|
|
1291
1314
|
mediaUrlPlaceholder: "Görsel URL veya Medya Kütüphanesi...",
|
|
1292
1315
|
mediaLibraryTitle: "Strapi Medya Kütüphanesi",
|
|
1293
1316
|
filesCount: "dosya",
|
|
1294
1317
|
refresh: "Yenile",
|
|
1295
1318
|
uploading: "Yükleniyor...",
|
|
1296
|
-
uploadNewFile: "Yeni Dosya Yükle",
|
|
1319
|
+
uploadNewFile: "Yeni Dosya(lar) Yükle",
|
|
1297
1320
|
searchFilesPlaceholder: "Dosya adı veya uzantı ara...",
|
|
1298
1321
|
loadingMediaFiles: "Medya dosyaları yükleniyor...",
|
|
1299
1322
|
noMediaFilesFound: "Medya kütüphanesinde eşleşen dosya bulunamadı. Sağ üstteki Yeni Dosya Yükle butonuyla bilgisayarınızdan dosya yükleyebilirsiniz.",
|
|
1300
|
-
selectedBadge: "SEÇİLİ"
|
|
1323
|
+
selectedBadge: "SEÇİLİ",
|
|
1324
|
+
multiSelectHint: "Birden fazla görseli sırayla seçmek için üzerine tıklayın",
|
|
1325
|
+
selectedCountLabel: "seçildi",
|
|
1326
|
+
selectAllVisible: "Tümünü Seç",
|
|
1327
|
+
clearSelection: "Seçimi Temizle",
|
|
1328
|
+
addSelectedMedia: "Seçilenleri Ekle",
|
|
1329
|
+
"media.selectImage": "Görsel Seç",
|
|
1330
|
+
"media.selectMedia": "Medya Seç",
|
|
1331
|
+
"media.selectMultipleMedia": "Çoklu Görsel Seç",
|
|
1332
|
+
"media.removeImage": "Görseli Kaldır",
|
|
1333
|
+
"media.urlPlaceholder": "Görsel URL veya Medya Kütüphanesi...",
|
|
1334
|
+
"media.libraryTitle": "Strapi Medya Kütüphanesi",
|
|
1335
|
+
"media.filesCount": "dosya",
|
|
1336
|
+
"media.refresh": "Yenile",
|
|
1337
|
+
"media.uploading": "Yükleniyor...",
|
|
1338
|
+
"media.uploadNew": "Yeni Dosya(lar) Yükle",
|
|
1339
|
+
"media.searchPlaceholder": "Dosya adı veya uzantı ara...",
|
|
1340
|
+
"media.loadingFiles": "Medya dosyaları yükleniyor...",
|
|
1341
|
+
"media.noMatchingFiles": "Medya kütüphanesinde eşleşen dosya bulunamadı. Sağ üstteki Yeni Dosya Yükle butonuyla bilgisayarınızdan dosya yükleyebilirsiniz.",
|
|
1342
|
+
"media.selectedBadge": "SEÇİLİ"
|
|
1301
1343
|
}
|
|
1302
1344
|
};
|
|
1303
1345
|
function createTranslator(locale = "en") {
|
|
@@ -2889,6 +2931,7 @@ const VENodeToolbar = ({
|
|
|
2889
2931
|
onDragStart,
|
|
2890
2932
|
onDragEnd
|
|
2891
2933
|
}) => {
|
|
2934
|
+
const { t } = useEditorTranslator();
|
|
2892
2935
|
return /* @__PURE__ */ jsxs(
|
|
2893
2936
|
"div",
|
|
2894
2937
|
{
|
|
@@ -2898,7 +2941,7 @@ const VENodeToolbar = ({
|
|
|
2898
2941
|
onDragEnd,
|
|
2899
2942
|
onClick: (e) => e.stopPropagation(),
|
|
2900
2943
|
style: { cursor: onDragStart ? "grab" : "default" },
|
|
2901
|
-
title: "
|
|
2944
|
+
title: t("field.dragToReorderRow", "Drag to reorder"),
|
|
2902
2945
|
children: [
|
|
2903
2946
|
/* @__PURE__ */ jsxs(
|
|
2904
2947
|
"span",
|
|
@@ -2921,7 +2964,7 @@ const VENodeToolbar = ({
|
|
|
2921
2964
|
{
|
|
2922
2965
|
type: "button",
|
|
2923
2966
|
className: "ve-node-toolbar__btn",
|
|
2924
|
-
title: "
|
|
2967
|
+
title: `${t("contextMenu.moveUp", "Move Up")} (Alt+↑)`,
|
|
2925
2968
|
onClick: onMoveUp,
|
|
2926
2969
|
children: /* @__PURE__ */ jsx(MaterialIcon, { name: "arrow_upward", size: 13, color: "#fff" })
|
|
2927
2970
|
}
|
|
@@ -2931,7 +2974,7 @@ const VENodeToolbar = ({
|
|
|
2931
2974
|
{
|
|
2932
2975
|
type: "button",
|
|
2933
2976
|
className: "ve-node-toolbar__btn",
|
|
2934
|
-
title: "
|
|
2977
|
+
title: `${t("contextMenu.moveDown", "Move Down")} (Alt+↓)`,
|
|
2935
2978
|
onClick: onMoveDown,
|
|
2936
2979
|
children: /* @__PURE__ */ jsx(MaterialIcon, { name: "arrow_downward", size: 13, color: "#fff" })
|
|
2937
2980
|
}
|
|
@@ -2941,7 +2984,7 @@ const VENodeToolbar = ({
|
|
|
2941
2984
|
{
|
|
2942
2985
|
type: "button",
|
|
2943
2986
|
className: "ve-node-toolbar__btn",
|
|
2944
|
-
title: "
|
|
2987
|
+
title: t("common.settings", "Settings"),
|
|
2945
2988
|
onClick: onSettings,
|
|
2946
2989
|
children: /* @__PURE__ */ jsx(MaterialIcon, { name: "tune", size: 13, color: "#fff" })
|
|
2947
2990
|
}
|
|
@@ -2951,7 +2994,7 @@ const VENodeToolbar = ({
|
|
|
2951
2994
|
{
|
|
2952
2995
|
type: "button",
|
|
2953
2996
|
className: "ve-node-toolbar__btn",
|
|
2954
|
-
title: "
|
|
2997
|
+
title: `${t("common.duplicate", "Duplicate")} (Ctrl+D)`,
|
|
2955
2998
|
onClick: onDuplicate,
|
|
2956
2999
|
children: /* @__PURE__ */ jsx(MaterialIcon, { name: "content_copy", size: 13, color: "#fff" })
|
|
2957
3000
|
}
|
|
@@ -2961,7 +3004,7 @@ const VENodeToolbar = ({
|
|
|
2961
3004
|
{
|
|
2962
3005
|
type: "button",
|
|
2963
3006
|
className: "ve-node-toolbar__btn ve-node-toolbar__btn--danger",
|
|
2964
|
-
title: "
|
|
3007
|
+
title: `${t("common.delete", "Delete")} (Delete)`,
|
|
2965
3008
|
onClick: onDelete,
|
|
2966
3009
|
children: /* @__PURE__ */ jsx(MaterialIcon, { name: "delete_outline", size: 13, color: "#fff" })
|
|
2967
3010
|
}
|
|
@@ -10085,6 +10128,7 @@ const VELeftPanel = ({ width = 280 }) => {
|
|
|
10085
10128
|
type: "button",
|
|
10086
10129
|
draggable: true,
|
|
10087
10130
|
onDragStart: (e) => {
|
|
10131
|
+
e.stopPropagation();
|
|
10088
10132
|
const payload = {
|
|
10089
10133
|
type: "new-row-preset",
|
|
10090
10134
|
cols: preset.cols
|
|
@@ -10093,7 +10137,10 @@ const VELeftPanel = ({ width = 280 }) => {
|
|
|
10093
10137
|
e.dataTransfer.effectAllowed = "copy";
|
|
10094
10138
|
e.dataTransfer.setData("application/x-ci-dnd", JSON.stringify(payload));
|
|
10095
10139
|
},
|
|
10096
|
-
onDragEnd: () =>
|
|
10140
|
+
onDragEnd: (e) => {
|
|
10141
|
+
e.stopPropagation();
|
|
10142
|
+
editor.setDragItem(null);
|
|
10143
|
+
},
|
|
10097
10144
|
onClick: () => editor.addRowPreset(preset.cols),
|
|
10098
10145
|
title: `${presetLabel} (${t("leftPanel.clickOrDrag", "Click or drag onto canvas")})`,
|
|
10099
10146
|
style: {
|
|
@@ -10165,6 +10212,7 @@ const VELeftPanel = ({ width = 280 }) => {
|
|
|
10165
10212
|
type: "button",
|
|
10166
10213
|
draggable: true,
|
|
10167
10214
|
onDragStart: (e) => {
|
|
10215
|
+
e.stopPropagation();
|
|
10168
10216
|
const payload = {
|
|
10169
10217
|
type: "new-widget",
|
|
10170
10218
|
widgetId: w.id
|
|
@@ -10173,7 +10221,10 @@ const VELeftPanel = ({ width = 280 }) => {
|
|
|
10173
10221
|
e.dataTransfer.effectAllowed = "copy";
|
|
10174
10222
|
e.dataTransfer.setData("application/x-ci-dnd", JSON.stringify(payload));
|
|
10175
10223
|
},
|
|
10176
|
-
onDragEnd: () =>
|
|
10224
|
+
onDragEnd: (e) => {
|
|
10225
|
+
e.stopPropagation();
|
|
10226
|
+
editor.setDragItem(null);
|
|
10227
|
+
},
|
|
10177
10228
|
onClick: () => handleWidgetQuickAdd(w.id),
|
|
10178
10229
|
title: `${wDesc} (${t("leftPanel.clickOrDragBlock", "Click or drag into block")})`,
|
|
10179
10230
|
style: {
|
|
@@ -10246,10 +10297,13 @@ const VELeftPanel = ({ width = 280 }) => {
|
|
|
10246
10297
|
draggable: true,
|
|
10247
10298
|
onDragStart: (e) => {
|
|
10248
10299
|
e.stopPropagation();
|
|
10249
|
-
|
|
10300
|
+
const payload = { type: "row", rowIndex: rIdx };
|
|
10301
|
+
editor.setDragItem(payload);
|
|
10250
10302
|
e.dataTransfer.effectAllowed = "move";
|
|
10303
|
+
e.dataTransfer.setData("application/x-ci-dnd", JSON.stringify(payload));
|
|
10251
10304
|
},
|
|
10252
|
-
onDragEnd: () => {
|
|
10305
|
+
onDragEnd: (e) => {
|
|
10306
|
+
e.stopPropagation();
|
|
10253
10307
|
editor.setDragItem(null);
|
|
10254
10308
|
setLayerDropTarget(null);
|
|
10255
10309
|
},
|
|
@@ -10332,14 +10386,17 @@ const VELeftPanel = ({ width = 280 }) => {
|
|
|
10332
10386
|
draggable: true,
|
|
10333
10387
|
onDragStart: (e) => {
|
|
10334
10388
|
e.stopPropagation();
|
|
10335
|
-
|
|
10389
|
+
const payload = {
|
|
10336
10390
|
type: "block",
|
|
10337
10391
|
rowIndex: rIdx,
|
|
10338
10392
|
blockIndex: bIdx
|
|
10339
|
-
}
|
|
10393
|
+
};
|
|
10394
|
+
editor.setDragItem(payload);
|
|
10340
10395
|
e.dataTransfer.effectAllowed = "move";
|
|
10396
|
+
e.dataTransfer.setData("application/x-ci-dnd", JSON.stringify(payload));
|
|
10341
10397
|
},
|
|
10342
|
-
onDragEnd: () => {
|
|
10398
|
+
onDragEnd: (e) => {
|
|
10399
|
+
e.stopPropagation();
|
|
10343
10400
|
editor.setDragItem(null);
|
|
10344
10401
|
setLayerDropTarget(null);
|
|
10345
10402
|
},
|
|
@@ -10430,15 +10487,18 @@ const VELeftPanel = ({ width = 280 }) => {
|
|
|
10430
10487
|
draggable: true,
|
|
10431
10488
|
onDragStart: (e) => {
|
|
10432
10489
|
e.stopPropagation();
|
|
10433
|
-
|
|
10490
|
+
const payload = {
|
|
10434
10491
|
type: "widget",
|
|
10435
10492
|
rowIndex: rIdx,
|
|
10436
10493
|
blockIndex: bIdx,
|
|
10437
10494
|
widgetIndex: wIdx
|
|
10438
|
-
}
|
|
10495
|
+
};
|
|
10496
|
+
editor.setDragItem(payload);
|
|
10439
10497
|
e.dataTransfer.effectAllowed = "move";
|
|
10498
|
+
e.dataTransfer.setData("application/x-ci-dnd", JSON.stringify(payload));
|
|
10440
10499
|
},
|
|
10441
|
-
onDragEnd: () => {
|
|
10500
|
+
onDragEnd: (e) => {
|
|
10501
|
+
e.stopPropagation();
|
|
10442
10502
|
editor.setDragItem(null);
|
|
10443
10503
|
setLayerDropTarget(null);
|
|
10444
10504
|
},
|
|
@@ -10920,6 +10980,31 @@ const VECanvas = () => {
|
|
|
10920
10980
|
textAlign: "center"
|
|
10921
10981
|
},
|
|
10922
10982
|
onClick: (e) => e.stopPropagation(),
|
|
10983
|
+
onDragOver: (e) => {
|
|
10984
|
+
const d = editor.dragItem;
|
|
10985
|
+
if (!d || d.type !== "new-row-preset" && d.type !== "new-widget") return;
|
|
10986
|
+
e.preventDefault();
|
|
10987
|
+
e.stopPropagation();
|
|
10988
|
+
e.dataTransfer.dropEffect = "copy";
|
|
10989
|
+
},
|
|
10990
|
+
onDrop: (e) => {
|
|
10991
|
+
const d = editor.dragItem;
|
|
10992
|
+
if (!d) return;
|
|
10993
|
+
if (d.type === "new-row-preset") {
|
|
10994
|
+
e.preventDefault();
|
|
10995
|
+
e.stopPropagation();
|
|
10996
|
+
editor.setDragItem(null);
|
|
10997
|
+
editor.addRowPreset(d.cols);
|
|
10998
|
+
} else if (d.type === "new-widget") {
|
|
10999
|
+
e.preventDefault();
|
|
11000
|
+
e.stopPropagation();
|
|
11001
|
+
editor.setDragItem(null);
|
|
11002
|
+
editor.addRowPreset([[12, 12, 12, 12, 12]]);
|
|
11003
|
+
setTimeout(() => {
|
|
11004
|
+
editor.addWidget(0, 0, d.widgetId);
|
|
11005
|
+
}, 0);
|
|
11006
|
+
}
|
|
11007
|
+
},
|
|
10923
11008
|
children: [
|
|
10924
11009
|
/* @__PURE__ */ jsx(MaterialIcon, { name: "dashboard_customize", size: 38, color: "#2669a0" }),
|
|
10925
11010
|
/* @__PURE__ */ jsx(
|
|
@@ -11383,6 +11468,9 @@ const UnitInput = ({
|
|
|
11383
11468
|
)
|
|
11384
11469
|
] });
|
|
11385
11470
|
};
|
|
11471
|
+
function getFileKey(file) {
|
|
11472
|
+
return String(file?.id ?? file?.documentId ?? file?.url ?? file?.name ?? "");
|
|
11473
|
+
}
|
|
11386
11474
|
function mapStrapiFileToAsset(file) {
|
|
11387
11475
|
const srcset = file?.formats ? Object.values(file.formats).filter((f) => f && f.url && f.width).map((f) => `${f.url} ${f.width}w`).join(", ") : "";
|
|
11388
11476
|
return {
|
|
@@ -11400,12 +11488,15 @@ function mapStrapiFileToAsset(file) {
|
|
|
11400
11488
|
const StrapiMediaPicker = ({
|
|
11401
11489
|
value,
|
|
11402
11490
|
onChange,
|
|
11403
|
-
label
|
|
11491
|
+
label,
|
|
11492
|
+
multiple = false,
|
|
11493
|
+
onSelectMultiple
|
|
11404
11494
|
}) => {
|
|
11405
11495
|
const { t } = useEditorTranslator();
|
|
11406
11496
|
const { get, post } = useFetchClient();
|
|
11407
11497
|
const [modalOpen, setModalOpen] = useState(false);
|
|
11408
11498
|
const [files, setFiles] = useState([]);
|
|
11499
|
+
const [selectedFiles, setSelectedFiles] = useState([]);
|
|
11409
11500
|
const [loading, setLoading] = useState(false);
|
|
11410
11501
|
const [uploading, setUploading] = useState(false);
|
|
11411
11502
|
const [search, setSearch] = useState("");
|
|
@@ -11443,24 +11534,57 @@ const StrapiMediaPicker = ({
|
|
|
11443
11534
|
const handleOpenModal = (e) => {
|
|
11444
11535
|
e.preventDefault();
|
|
11445
11536
|
e.stopPropagation();
|
|
11537
|
+
setSelectedFiles([]);
|
|
11446
11538
|
setModalOpen(true);
|
|
11447
11539
|
loadLibrary().finally(() => setLoading(false));
|
|
11448
11540
|
};
|
|
11541
|
+
const toggleFileSelection = (file) => {
|
|
11542
|
+
const key = getFileKey(file);
|
|
11543
|
+
setSelectedFiles((prev) => {
|
|
11544
|
+
const exists = prev.some((f) => getFileKey(f) === key);
|
|
11545
|
+
if (exists) {
|
|
11546
|
+
return prev.filter((f) => getFileKey(f) !== key);
|
|
11547
|
+
}
|
|
11548
|
+
return [...prev, file];
|
|
11549
|
+
});
|
|
11550
|
+
};
|
|
11551
|
+
const handleConfirmMultiple = () => {
|
|
11552
|
+
if (selectedFiles.length === 0) return;
|
|
11553
|
+
const assets = selectedFiles.map(mapStrapiFileToAsset);
|
|
11554
|
+
if (onSelectMultiple) {
|
|
11555
|
+
onSelectMultiple(assets);
|
|
11556
|
+
} else {
|
|
11557
|
+
assets.forEach((asset) => onChange(asset));
|
|
11558
|
+
}
|
|
11559
|
+
setSelectedFiles([]);
|
|
11560
|
+
setModalOpen(false);
|
|
11561
|
+
};
|
|
11449
11562
|
const handleFileUpload = async (e) => {
|
|
11450
|
-
const
|
|
11451
|
-
if (!
|
|
11563
|
+
const inputFiles = e.target.files;
|
|
11564
|
+
if (!inputFiles || inputFiles.length === 0) return;
|
|
11452
11565
|
setUploading(true);
|
|
11453
11566
|
try {
|
|
11454
11567
|
const formData = new FormData();
|
|
11455
|
-
for (let i = 0; i <
|
|
11456
|
-
formData.append("files",
|
|
11568
|
+
for (let i = 0; i < inputFiles.length; i++) {
|
|
11569
|
+
formData.append("files", inputFiles[i]);
|
|
11457
11570
|
}
|
|
11458
11571
|
const res = await post("/upload", formData);
|
|
11459
11572
|
const uploadedList = Array.isArray(res?.data) ? res.data : Array.isArray(res?.data?.data) ? res.data.data : [];
|
|
11460
11573
|
await loadLibrary();
|
|
11461
11574
|
if (uploadedList.length > 0) {
|
|
11462
|
-
|
|
11463
|
-
|
|
11575
|
+
if (multiple) {
|
|
11576
|
+
const assets = uploadedList.map(mapStrapiFileToAsset);
|
|
11577
|
+
if (onSelectMultiple) {
|
|
11578
|
+
onSelectMultiple(assets);
|
|
11579
|
+
} else {
|
|
11580
|
+
assets.forEach((a) => onChange(a));
|
|
11581
|
+
}
|
|
11582
|
+
setSelectedFiles([]);
|
|
11583
|
+
setModalOpen(false);
|
|
11584
|
+
} else {
|
|
11585
|
+
onChange(mapStrapiFileToAsset(uploadedList[0]));
|
|
11586
|
+
setModalOpen(false);
|
|
11587
|
+
}
|
|
11464
11588
|
}
|
|
11465
11589
|
} catch {
|
|
11466
11590
|
} finally {
|
|
@@ -11472,7 +11596,25 @@ const StrapiMediaPicker = ({
|
|
|
11472
11596
|
const handleUrlApply = () => {
|
|
11473
11597
|
const trimmed = urlInput.trim();
|
|
11474
11598
|
if (!trimmed) {
|
|
11475
|
-
if (value) onChange(null);
|
|
11599
|
+
if (!multiple && value) onChange(null);
|
|
11600
|
+
return;
|
|
11601
|
+
}
|
|
11602
|
+
if (multiple) {
|
|
11603
|
+
const parts = trimmed.split(/[\n,]+/).map((s) => s.trim()).filter(Boolean);
|
|
11604
|
+
if (parts.length === 0) return;
|
|
11605
|
+
const assets = parts.map((u) => ({
|
|
11606
|
+
target_url: u,
|
|
11607
|
+
url: u,
|
|
11608
|
+
filename: u.split("/").pop() || "external-image",
|
|
11609
|
+
mime_type: "image/jpeg",
|
|
11610
|
+
caption: ""
|
|
11611
|
+
}));
|
|
11612
|
+
if (onSelectMultiple) {
|
|
11613
|
+
onSelectMultiple(assets);
|
|
11614
|
+
} else {
|
|
11615
|
+
assets.forEach((a) => onChange(a));
|
|
11616
|
+
}
|
|
11617
|
+
setUrlInput("");
|
|
11476
11618
|
return;
|
|
11477
11619
|
}
|
|
11478
11620
|
if (trimmed === (value?.target_url || value?.url || "")) return;
|
|
@@ -11616,8 +11758,8 @@ const StrapiMediaPicker = ({
|
|
|
11616
11758
|
whiteSpace: "nowrap"
|
|
11617
11759
|
},
|
|
11618
11760
|
children: [
|
|
11619
|
-
/* @__PURE__ */ jsx(MaterialIcon, { name: "image", size: 15, color: "#fff" }),
|
|
11620
|
-
t("media.selectMedia", "Select Media")
|
|
11761
|
+
/* @__PURE__ */ jsx(MaterialIcon, { name: multiple ? "collections" : "image", size: 15, color: "#fff" }),
|
|
11762
|
+
multiple ? t("media.selectMultipleMedia", "Select Images") : t("media.selectMedia", "Select Media")
|
|
11621
11763
|
]
|
|
11622
11764
|
}
|
|
11623
11765
|
)
|
|
@@ -11761,22 +11903,82 @@ const StrapiMediaPicker = ({
|
|
|
11761
11903
|
]
|
|
11762
11904
|
}
|
|
11763
11905
|
),
|
|
11764
|
-
/* @__PURE__ */
|
|
11765
|
-
"
|
|
11906
|
+
/* @__PURE__ */ jsxs(
|
|
11907
|
+
"div",
|
|
11766
11908
|
{
|
|
11767
|
-
type: "text",
|
|
11768
|
-
value: search,
|
|
11769
|
-
onChange: (e) => setSearch(e.target.value),
|
|
11770
|
-
placeholder: t("media.searchPlaceholder", "Search file name or extension..."),
|
|
11771
11909
|
style: {
|
|
11772
|
-
|
|
11773
|
-
|
|
11774
|
-
|
|
11775
|
-
|
|
11776
|
-
|
|
11777
|
-
}
|
|
11910
|
+
padding: "10px 18px",
|
|
11911
|
+
borderBottom: "1px solid #f1f5f9",
|
|
11912
|
+
display: "flex",
|
|
11913
|
+
alignItems: "center",
|
|
11914
|
+
gap: 8
|
|
11915
|
+
},
|
|
11916
|
+
children: [
|
|
11917
|
+
/* @__PURE__ */ jsx(
|
|
11918
|
+
"input",
|
|
11919
|
+
{
|
|
11920
|
+
type: "text",
|
|
11921
|
+
value: search,
|
|
11922
|
+
onChange: (e) => setSearch(e.target.value),
|
|
11923
|
+
placeholder: t("media.searchPlaceholder", "Search file name or extension..."),
|
|
11924
|
+
style: {
|
|
11925
|
+
flex: 1,
|
|
11926
|
+
padding: "7px 10px",
|
|
11927
|
+
fontSize: 12,
|
|
11928
|
+
border: "1px solid #cbd5e1",
|
|
11929
|
+
borderRadius: 5
|
|
11930
|
+
}
|
|
11931
|
+
}
|
|
11932
|
+
),
|
|
11933
|
+
multiple && filteredFiles.length > 0 && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
11934
|
+
/* @__PURE__ */ jsx(
|
|
11935
|
+
"button",
|
|
11936
|
+
{
|
|
11937
|
+
type: "button",
|
|
11938
|
+
onClick: () => {
|
|
11939
|
+
const existingKeys = new Set(selectedFiles.map(getFileKey));
|
|
11940
|
+
const additions = filteredFiles.filter(
|
|
11941
|
+
(f) => !existingKeys.has(getFileKey(f))
|
|
11942
|
+
);
|
|
11943
|
+
setSelectedFiles([...selectedFiles, ...additions]);
|
|
11944
|
+
},
|
|
11945
|
+
style: {
|
|
11946
|
+
padding: "6px 10px",
|
|
11947
|
+
fontSize: 11,
|
|
11948
|
+
fontWeight: 600,
|
|
11949
|
+
border: "1px solid #cbd5e1",
|
|
11950
|
+
borderRadius: 5,
|
|
11951
|
+
background: "#ffffff",
|
|
11952
|
+
color: "#334155",
|
|
11953
|
+
cursor: "pointer",
|
|
11954
|
+
whiteSpace: "nowrap"
|
|
11955
|
+
},
|
|
11956
|
+
children: t("selectAllVisible", "Select All")
|
|
11957
|
+
}
|
|
11958
|
+
),
|
|
11959
|
+
selectedFiles.length > 0 && /* @__PURE__ */ jsx(
|
|
11960
|
+
"button",
|
|
11961
|
+
{
|
|
11962
|
+
type: "button",
|
|
11963
|
+
onClick: () => setSelectedFiles([]),
|
|
11964
|
+
style: {
|
|
11965
|
+
padding: "6px 10px",
|
|
11966
|
+
fontSize: 11,
|
|
11967
|
+
fontWeight: 600,
|
|
11968
|
+
border: "1px solid #fecaca",
|
|
11969
|
+
borderRadius: 5,
|
|
11970
|
+
background: "#fef2f2",
|
|
11971
|
+
color: "#dc2626",
|
|
11972
|
+
cursor: "pointer",
|
|
11973
|
+
whiteSpace: "nowrap"
|
|
11974
|
+
},
|
|
11975
|
+
children: t("clearSelection", "Clear Selection")
|
|
11976
|
+
}
|
|
11977
|
+
)
|
|
11978
|
+
] })
|
|
11979
|
+
]
|
|
11778
11980
|
}
|
|
11779
|
-
)
|
|
11981
|
+
),
|
|
11780
11982
|
/* @__PURE__ */ jsx("div", { style: { padding: 18, overflowY: "auto", flex: 1 }, children: loading ? /* @__PURE__ */ jsx(
|
|
11781
11983
|
"div",
|
|
11782
11984
|
{
|
|
@@ -11801,14 +12003,36 @@ const StrapiMediaPicker = ({
|
|
|
11801
12003
|
gap: 12
|
|
11802
12004
|
},
|
|
11803
12005
|
children: filteredFiles.map((file) => {
|
|
11804
|
-
const
|
|
12006
|
+
const fileKey = getFileKey(file);
|
|
12007
|
+
const multiIndex = multiple ? selectedFiles.findIndex((f) => getFileKey(f) === fileKey) : -1;
|
|
12008
|
+
const isMultiSelected = multiIndex !== -1;
|
|
12009
|
+
const isCurrent = multiple ? isMultiSelected : Boolean(
|
|
12010
|
+
previewUrl && (file.url === previewUrl || file.name === value?.filename)
|
|
12011
|
+
);
|
|
11805
12012
|
const thumbSrc = file.formats?.thumbnail?.url || file.formats?.small?.url || file.url || "";
|
|
11806
12013
|
return /* @__PURE__ */ jsxs(
|
|
11807
12014
|
"div",
|
|
11808
12015
|
{
|
|
11809
12016
|
onClick: () => {
|
|
11810
|
-
|
|
11811
|
-
|
|
12017
|
+
if (multiple) {
|
|
12018
|
+
toggleFileSelection(file);
|
|
12019
|
+
} else {
|
|
12020
|
+
onChange(mapStrapiFileToAsset(file));
|
|
12021
|
+
setModalOpen(false);
|
|
12022
|
+
}
|
|
12023
|
+
},
|
|
12024
|
+
onDoubleClick: () => {
|
|
12025
|
+
if (multiple) {
|
|
12026
|
+
const asset = mapStrapiFileToAsset(file);
|
|
12027
|
+
const listToCommit = selectedFiles.length > 0 ? selectedFiles.map(mapStrapiFileToAsset) : [asset];
|
|
12028
|
+
if (onSelectMultiple) {
|
|
12029
|
+
onSelectMultiple(listToCommit);
|
|
12030
|
+
} else {
|
|
12031
|
+
listToCommit.forEach((a) => onChange(a));
|
|
12032
|
+
}
|
|
12033
|
+
setSelectedFiles([]);
|
|
12034
|
+
setModalOpen(false);
|
|
12035
|
+
}
|
|
11812
12036
|
},
|
|
11813
12037
|
style: {
|
|
11814
12038
|
border: isCurrent ? "2px solid #2669a0" : "1px solid #e2e8f0",
|
|
@@ -11816,7 +12040,8 @@ const StrapiMediaPicker = ({
|
|
|
11816
12040
|
overflow: "hidden",
|
|
11817
12041
|
cursor: "pointer",
|
|
11818
12042
|
background: isCurrent ? "#eff6ff" : "#fff",
|
|
11819
|
-
boxShadow: isCurrent ? "0 0 0 2px rgba(38, 105, 160, 0.16)" : "0 1px 3px rgba(0,0,0,0.04)"
|
|
12043
|
+
boxShadow: isCurrent ? "0 0 0 2px rgba(38, 105, 160, 0.16)" : "0 1px 3px rgba(0,0,0,0.04)",
|
|
12044
|
+
userSelect: "none"
|
|
11820
12045
|
},
|
|
11821
12046
|
children: [
|
|
11822
12047
|
/* @__PURE__ */ jsxs(
|
|
@@ -11839,7 +12064,30 @@ const StrapiMediaPicker = ({
|
|
|
11839
12064
|
style: { width: "100%", height: "100%", objectFit: "cover" }
|
|
11840
12065
|
}
|
|
11841
12066
|
) : /* @__PURE__ */ jsx(MaterialIcon, { name: "description", size: 30, color: "#64748b" }),
|
|
11842
|
-
|
|
12067
|
+
multiple ? /* @__PURE__ */ jsx(
|
|
12068
|
+
"span",
|
|
12069
|
+
{
|
|
12070
|
+
style: {
|
|
12071
|
+
position: "absolute",
|
|
12072
|
+
top: 6,
|
|
12073
|
+
left: 6,
|
|
12074
|
+
minWidth: 22,
|
|
12075
|
+
height: 22,
|
|
12076
|
+
padding: isMultiSelected ? "0 6px" : 0,
|
|
12077
|
+
borderRadius: 11,
|
|
12078
|
+
background: isMultiSelected ? "#2669a0" : "rgba(255, 255, 255, 0.88)",
|
|
12079
|
+
border: isMultiSelected ? "1.5px solid #ffffff" : "1.5px solid #94a3b8",
|
|
12080
|
+
color: "#ffffff",
|
|
12081
|
+
fontSize: 10,
|
|
12082
|
+
fontWeight: 700,
|
|
12083
|
+
display: "inline-flex",
|
|
12084
|
+
alignItems: "center",
|
|
12085
|
+
justifyContent: "center",
|
|
12086
|
+
boxShadow: "0 1px 3px rgba(0,0,0,0.2)"
|
|
12087
|
+
},
|
|
12088
|
+
children: isMultiSelected ? `✓ ${multiIndex + 1}` : ""
|
|
12089
|
+
}
|
|
12090
|
+
) : isCurrent && /* @__PURE__ */ jsx(
|
|
11843
12091
|
"span",
|
|
11844
12092
|
{
|
|
11845
12093
|
style: {
|
|
@@ -11901,11 +12149,84 @@ const StrapiMediaPicker = ({
|
|
|
11901
12149
|
] })
|
|
11902
12150
|
]
|
|
11903
12151
|
},
|
|
11904
|
-
|
|
12152
|
+
fileKey
|
|
11905
12153
|
);
|
|
11906
12154
|
})
|
|
11907
12155
|
}
|
|
11908
|
-
) })
|
|
12156
|
+
) }),
|
|
12157
|
+
multiple && /* @__PURE__ */ jsxs(
|
|
12158
|
+
"div",
|
|
12159
|
+
{
|
|
12160
|
+
style: {
|
|
12161
|
+
display: "flex",
|
|
12162
|
+
alignItems: "center",
|
|
12163
|
+
justifyContent: "space-between",
|
|
12164
|
+
padding: "12px 18px",
|
|
12165
|
+
borderTop: "1px solid #e2e8f0",
|
|
12166
|
+
background: "#f8fafc",
|
|
12167
|
+
gap: 12
|
|
12168
|
+
},
|
|
12169
|
+
children: [
|
|
12170
|
+
/* @__PURE__ */ jsx("div", { style: { fontSize: 12, color: "#475569", fontWeight: 500 }, children: selectedFiles.length > 0 ? /* @__PURE__ */ jsxs("span", { style: { color: "#0f172a", fontWeight: 700 }, children: [
|
|
12171
|
+
selectedFiles.length,
|
|
12172
|
+
" ",
|
|
12173
|
+
t("selectedCountLabel", "selected")
|
|
12174
|
+
] }) : /* @__PURE__ */ jsx("span", { children: t("multiSelectHint", "Click multiple images to select them in order") }) }),
|
|
12175
|
+
/* @__PURE__ */ jsxs("div", { style: { display: "flex", alignItems: "center", gap: 8 }, children: [
|
|
12176
|
+
/* @__PURE__ */ jsx(
|
|
12177
|
+
"button",
|
|
12178
|
+
{
|
|
12179
|
+
type: "button",
|
|
12180
|
+
onClick: () => {
|
|
12181
|
+
setSelectedFiles([]);
|
|
12182
|
+
setModalOpen(false);
|
|
12183
|
+
},
|
|
12184
|
+
style: {
|
|
12185
|
+
padding: "7px 14px",
|
|
12186
|
+
fontSize: 12,
|
|
12187
|
+
fontWeight: 600,
|
|
12188
|
+
border: "1px solid #cbd5e1",
|
|
12189
|
+
borderRadius: 5,
|
|
12190
|
+
background: "#ffffff",
|
|
12191
|
+
color: "#475569",
|
|
12192
|
+
cursor: "pointer"
|
|
12193
|
+
},
|
|
12194
|
+
children: t("cancel", "Cancel")
|
|
12195
|
+
}
|
|
12196
|
+
),
|
|
12197
|
+
/* @__PURE__ */ jsxs(
|
|
12198
|
+
"button",
|
|
12199
|
+
{
|
|
12200
|
+
type: "button",
|
|
12201
|
+
disabled: selectedFiles.length === 0,
|
|
12202
|
+
onClick: handleConfirmMultiple,
|
|
12203
|
+
style: {
|
|
12204
|
+
display: "inline-flex",
|
|
12205
|
+
alignItems: "center",
|
|
12206
|
+
gap: 6,
|
|
12207
|
+
padding: "7px 16px",
|
|
12208
|
+
fontSize: 12,
|
|
12209
|
+
fontWeight: 700,
|
|
12210
|
+
border: "none",
|
|
12211
|
+
borderRadius: 5,
|
|
12212
|
+
background: selectedFiles.length > 0 ? "#2669a0" : "#94a3b8",
|
|
12213
|
+
color: "#ffffff",
|
|
12214
|
+
cursor: selectedFiles.length > 0 ? "pointer" : "not-allowed"
|
|
12215
|
+
},
|
|
12216
|
+
children: [
|
|
12217
|
+
/* @__PURE__ */ jsx(MaterialIcon, { name: "check", size: 16, color: "#ffffff" }),
|
|
12218
|
+
/* @__PURE__ */ jsxs("span", { children: [
|
|
12219
|
+
t("addSelectedMedia", "Add Selected"),
|
|
12220
|
+
" ",
|
|
12221
|
+
selectedFiles.length > 0 ? `(${selectedFiles.length})` : ""
|
|
12222
|
+
] })
|
|
12223
|
+
]
|
|
12224
|
+
}
|
|
12225
|
+
)
|
|
12226
|
+
] })
|
|
12227
|
+
]
|
|
12228
|
+
}
|
|
12229
|
+
)
|
|
11909
12230
|
]
|
|
11910
12231
|
}
|
|
11911
12232
|
)
|
|
@@ -13002,18 +13323,54 @@ const WidgetEditor = ({ widget, onChange }) => {
|
|
|
13002
13323
|
{
|
|
13003
13324
|
label: t("addGalleryImage"),
|
|
13004
13325
|
value: null,
|
|
13326
|
+
multiple: true,
|
|
13005
13327
|
onChange: (asset) => {
|
|
13006
13328
|
if (asset) updateData([...images, asset]);
|
|
13329
|
+
},
|
|
13330
|
+
onSelectMultiple: (newAssets) => {
|
|
13331
|
+
if (newAssets && newAssets.length > 0) {
|
|
13332
|
+
updateData([...images, ...newAssets]);
|
|
13333
|
+
}
|
|
13007
13334
|
}
|
|
13008
13335
|
}
|
|
13009
13336
|
) }),
|
|
13010
13337
|
/* @__PURE__ */ jsxs("div", { children: [
|
|
13011
|
-
/* @__PURE__ */ jsxs(
|
|
13012
|
-
|
|
13013
|
-
|
|
13014
|
-
|
|
13015
|
-
|
|
13016
|
-
|
|
13338
|
+
/* @__PURE__ */ jsxs(
|
|
13339
|
+
"div",
|
|
13340
|
+
{
|
|
13341
|
+
style: {
|
|
13342
|
+
display: "flex",
|
|
13343
|
+
alignItems: "center",
|
|
13344
|
+
justifyContent: "space-between",
|
|
13345
|
+
marginBottom: 4
|
|
13346
|
+
},
|
|
13347
|
+
children: [
|
|
13348
|
+
/* @__PURE__ */ jsxs("label", { style: { ...labelStyle, marginBottom: 0 }, children: [
|
|
13349
|
+
t("galleryImages"),
|
|
13350
|
+
" (",
|
|
13351
|
+
images.length,
|
|
13352
|
+
")"
|
|
13353
|
+
] }),
|
|
13354
|
+
images.length > 1 && /* @__PURE__ */ jsx(
|
|
13355
|
+
"button",
|
|
13356
|
+
{
|
|
13357
|
+
type: "button",
|
|
13358
|
+
onClick: () => updateData([]),
|
|
13359
|
+
style: {
|
|
13360
|
+
border: "none",
|
|
13361
|
+
background: "transparent",
|
|
13362
|
+
color: "#dc2626",
|
|
13363
|
+
fontSize: 11,
|
|
13364
|
+
fontWeight: 600,
|
|
13365
|
+
cursor: "pointer",
|
|
13366
|
+
padding: "2px 4px"
|
|
13367
|
+
},
|
|
13368
|
+
children: t("clearAllImages")
|
|
13369
|
+
}
|
|
13370
|
+
)
|
|
13371
|
+
]
|
|
13372
|
+
}
|
|
13373
|
+
),
|
|
13017
13374
|
images.length === 0 ? /* @__PURE__ */ jsx(
|
|
13018
13375
|
"div",
|
|
13019
13376
|
{
|