diff --git a/CHANGES.md b/CHANGES.md
index 7fbef9e3..ca0e2aae 100644
--- a/CHANGES.md
+++ b/CHANGES.md
@@ -1,5 +1,9 @@
# Changes
+Version 4.17.6 (release 2026-07-07)
+
+- fix: file preview not showing for S3 instances
+
Version 4.17.5 (release 2026-07-02)
- fix(ci): add Node.js 24.x to test matrix
diff --git a/package-lock.json b/package-lock.json
index 8aef85a7..64aedbaa 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "react-invenio-forms",
- "version": "4.17.5",
+ "version": "4.17.6",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "react-invenio-forms",
- "version": "4.17.5",
+ "version": "4.17.6",
"license": "MIT",
"devDependencies": {
"@babel/cli": "^7.5.0",
@@ -6957,9 +6957,9 @@
"license": "MIT"
},
"node_modules/baseline-browser-mapping": {
- "version": "2.10.40",
- "resolved": "https://registry.npmjs.org/baseline-browser-mapping/-/baseline-browser-mapping-2.10.40.tgz",
- "integrity": "sha512-BSSLZ9/Cjjv7Gtj5B68ZzXcXUg8iOf3fme+FCuh8rC/Go+Kmh8cox7M3A8dolou16s64QjLPOSdngh7GxXvkSw==",
+ "version": "2.10.42",
+ "resolved": "https://registry.npmjs.org/baseline-browser-mapping/-/baseline-browser-mapping-2.10.42.tgz",
+ "integrity": "sha512-c/jurFrDLyui7o1J86yLkRu4LMsTYcBohveus7/I2Hzdn9KIP2bdJPTue/lR1KH46enoPbD77GKeSYNdyPoD3Q==",
"dev": true,
"license": "Apache-2.0",
"bin": {
@@ -7155,9 +7155,9 @@
"license": "BSD-2-Clause"
},
"node_modules/browserslist": {
- "version": "4.28.4",
- "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.28.4.tgz",
- "integrity": "sha512-MTc8i/x9jBQd1iMw2CFGS+rwMa07eYjLR0CCTLDACl9xhxy+nIs3KeML/biicXtk9JrZ6dnnTatmc7ErPXIxqw==",
+ "version": "4.28.5",
+ "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.28.5.tgz",
+ "integrity": "sha512-Cu2E6QejHWzuDMTkuwgpABFgDfZrXLQq5V13YOACZx4mFAG4IwGTbTfHPMr4WtxlHoXSM8FIuRwYYCz5XiabaQ==",
"dev": true,
"funding": [
{
@@ -7175,10 +7175,10 @@
],
"license": "MIT",
"dependencies": {
- "baseline-browser-mapping": "^2.10.38",
- "caniuse-lite": "^1.0.30001799",
- "electron-to-chromium": "^1.5.376",
- "node-releases": "^2.0.48",
+ "baseline-browser-mapping": "^2.10.42",
+ "caniuse-lite": "^1.0.30001800",
+ "electron-to-chromium": "^1.5.387",
+ "node-releases": "^2.0.50",
"update-browserslist-db": "^1.2.3"
},
"bin": {
@@ -7336,9 +7336,9 @@
}
},
"node_modules/caniuse-lite": {
- "version": "1.0.30001800",
- "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001800.tgz",
- "integrity": "sha512-MMHtuAz9Ys840zAY5F4k6fV5GaivZ9sPk+nz0mY+GYVzRBnYkN0mpqkSR92oWRQ19yQWo4HvBV/FnC16AJX8MA==",
+ "version": "1.0.30001803",
+ "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001803.tgz",
+ "integrity": "sha512-g/uHREV2ZpK9qMalCsWaxmA6ol+DX8GYhuf3T40RKoP+oL7vhRJh8LNt73PCjpnR6l14FzfPrB5Yux4PKm2meg==",
"dev": true,
"funding": [
{
@@ -8982,9 +8982,9 @@
}
},
"node_modules/electron-to-chromium": {
- "version": "1.5.384",
- "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.384.tgz",
- "integrity": "sha512-g6KAKY1vkYsADvSPWvdJsuYT0ixdcu6lUtD9P/wJKGBEDlZVXh2AX42j1mPqqaQPDluWjara9ziQ7xqAeXCt5A==",
+ "version": "1.5.388",
+ "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.388.tgz",
+ "integrity": "sha512-Pl/aJaqOOxYxda3vcx1IKSJimwYXHDkEnGn0F+kG2EE68dDtx2uCinaS+Vih8Z91B9t8CSAbiF/HKyWcnXjhzw==",
"dev": true,
"license": "ISC"
},
@@ -9043,9 +9043,9 @@
}
},
"node_modules/enhanced-resolve": {
- "version": "5.24.1",
- "resolved": "https://registry.npmjs.org/enhanced-resolve/-/enhanced-resolve-5.24.1.tgz",
- "integrity": "sha512-7DdUaTjmNwMcH2gLr1qycesKII3BK4RLy/mdAb7x10Lq7bR4aNKHt1BR1ZALSv0rPM/hF5wYF0PhGop/rJm8vw==",
+ "version": "5.24.2",
+ "resolved": "https://registry.npmjs.org/enhanced-resolve/-/enhanced-resolve-5.24.2.tgz",
+ "integrity": "sha512-rpsZEGT1jFuve6QlpyRp9ckQ+kN61hvF9BzCPyMdaKTm8UJce96KBn3sorXOFXlzjPrs3Vc4T1NsSroZ3PxlFw==",
"dev": true,
"license": "MIT",
"dependencies": {
@@ -9697,9 +9697,9 @@
}
},
"node_modules/eslint-module-utils": {
- "version": "2.13.0",
- "resolved": "https://registry.npmjs.org/eslint-module-utils/-/eslint-module-utils-2.13.0.tgz",
- "integrity": "sha512-bLohSkT6469rRs8czj0tLTD8vaeIS/whvPRJVjDr7IuoTT1k5DYDERlNycjDj/HkOlvQdYurmfZ/g3fG5bgeLQ==",
+ "version": "2.14.0",
+ "resolved": "https://registry.npmjs.org/eslint-module-utils/-/eslint-module-utils-2.14.0.tgz",
+ "integrity": "sha512-W2WCRZ9Dqntd+2u8jJcVMV2PKulc6RdLgUUoh/yQr3uB6lo/ZOeGx11sv60/8S4QFFKNslAlWhr9u0Ef7ZW6Ig==",
"dev": true,
"license": "MIT",
"dependencies": {
@@ -22690,9 +22690,9 @@
}
},
"node_modules/tinyglobby/node_modules/picomatch": {
- "version": "4.0.4",
- "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.4.tgz",
- "integrity": "sha512-QP88BAKvMam/3NxH6vj2o21R6MjxZUAd6nlwAS/pnGvN9IVLocLHxGYIzFhg6fUQ+5th6P4dv4eW9jX3DSIj7A==",
+ "version": "4.0.5",
+ "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.5.tgz",
+ "integrity": "sha512-RvwwcruNjI1ncT5xRakeyS9Lf8lcItv34KD+aif+VH9kduAyfYBipGh12274xtenIPZ119/R9BdTBa8gAwSh0A==",
"dev": true,
"license": "MIT",
"engines": {
@@ -23428,9 +23428,9 @@
}
},
"node_modules/webpack": {
- "version": "5.108.3",
- "resolved": "https://registry.npmjs.org/webpack/-/webpack-5.108.3.tgz",
- "integrity": "sha512-hOpaCHmQVVY66IVTjofnH14IgSdmod2aquSGHGuYig/OIdWge01Hk2Wt988DZcwXumFUT4+FvJY5N+ikl8o/ww==",
+ "version": "5.108.4",
+ "resolved": "https://registry.npmjs.org/webpack/-/webpack-5.108.4.tgz",
+ "integrity": "sha512-yur8LyJoeiWh47dErD+Ok7vlbmDsJ3UbbRPAoxbGJ54WpE2y5yVo5G/inUzujnYgw3tPmBRdn+G7PoxXaYC33w==",
"dev": true,
"license": "MIT",
"dependencies": {
@@ -23651,9 +23651,9 @@
}
},
"node_modules/webpack-sources": {
- "version": "3.5.0",
- "resolved": "https://registry.npmjs.org/webpack-sources/-/webpack-sources-3.5.0.tgz",
- "integrity": "sha512-HPuy+uuoTCaaoEoI1LQ3JN9+vrPBvEesnnX1jADHy728cHSMlq4wUc4afYqahq2B1mhQVZxCXOkNTnXltr+2vQ==",
+ "version": "3.5.1",
+ "resolved": "https://registry.npmjs.org/webpack-sources/-/webpack-sources-3.5.1.tgz",
+ "integrity": "sha512-jyuiGJdtvY434z5bUZrjz67v76/ePNvFZTp9Mdz29IlH4+GPsgyGjiv0fKI+M7BdkU6ADjulUcKAd3tUK3WlEw==",
"dev": true,
"license": "MIT",
"engines": {
diff --git a/package.json b/package.json
index 6fee3d16..acac88b2 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "react-invenio-forms",
- "version": "4.17.5",
+ "version": "4.17.6",
"description": "Reusable React components for forms and other in Invenio",
"main": "dist/cjs/index.js",
"browser": "dist/cjs/index.js",
diff --git a/src/lib/forms/RichEditor.js b/src/lib/forms/RichEditor.js
index ea3c34b7..fa8d32d4 100644
--- a/src/lib/forms/RichEditor.js
+++ b/src/lib/forms/RichEditor.js
@@ -1,7 +1,7 @@
/*
* SPDX-FileCopyrightText: 2022-2026 CERN.
* SPDX-FileCopyrightText: 2020 Northwestern University.
- * SPDX-FileCopyrightText: 2024 KTH Royal Institute of Technology.
+ * SPDX-FileCopyrightText: 2024-2026 KTH Royal Institute of Technology.
* SPDX-License-Identifier: MIT
*/
import React, { Component } from "react";
@@ -133,6 +133,22 @@ export class RichEditor extends Component {
}
};
+ insertUploadedFile = (location, info = {}) => {
+ if (!this.editorRef.current) {
+ return;
+ }
+ if (info.alt) {
+ this.editorRef.current.insertContent(`
`);
+ } else {
+ const text = info.text || location;
+ this.editorRef.current.insertContent(`${text}`);
+ }
+ };
+
+ getPickerFileType = (file) => {
+ return file?.type?.startsWith("image/") ? "image" : "file";
+ };
+
/**
* This function is called when a a user clicks on the upload icons
* in the Link and Image popup dialogs.
@@ -161,6 +177,7 @@ export class RichEditor extends Component {
input.onchange = (event) => {
const file = event.target.files[0];
+ const selectedFileType = this.getPickerFileType(file);
const filename = file.name;
if (this.editorRef.current) {
@@ -188,9 +205,9 @@ export class RichEditor extends Component {
}
const locationRelative = new URL(json.data.links.download_html).pathname;
- if (meta.filetype === "file") {
+ if (selectedFileType === "file") {
callback(locationRelative, { text: json.data.metadata.original_filename });
- } else if (meta.filetype === "image") {
+ } else if (selectedFileType === "image") {
callback(locationRelative, {
alt: `Description of ${json.data.metadata.original_filename}`,
});
@@ -218,7 +235,7 @@ export class RichEditor extends Component {
* or on the attach files button next to the files list.
*/
onAttachFiles = () => {
- this.filePickerCallback(() => {}, "", "file");
+ this.filePickerCallback(this.insertUploadedFile, "", { filetype: "file" });
};
mapToEditorLinkList = (files) => {