@rjsf/core 5.16.0 → 5.17.0
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/core.umd.js +46 -15
- package/dist/index.esm.js +51 -18
- package/dist/index.esm.js.map +3 -3
- package/dist/index.js +46 -15
- package/dist/index.js.map +2 -2
- package/lib/components/fields/MultiSchemaField.js +33 -6
- package/lib/components/fields/MultiSchemaField.js.map +1 -1
- package/lib/components/widgets/FileWidget.js +26 -12
- package/lib/components/widgets/FileWidget.js.map +1 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/package.json +12 -12
- package/src/components/fields/MultiSchemaField.tsx +34 -6
- package/src/components/widgets/FileWidget.tsx +25 -11
|
@@ -69,10 +69,15 @@ function FileInfoPreview<T = any, S extends StrictRJSFSchema = RJSFSchema, F ext
|
|
|
69
69
|
return null;
|
|
70
70
|
}
|
|
71
71
|
|
|
72
|
-
|
|
72
|
+
// If type is JPEG or PNG then show image preview.
|
|
73
|
+
// Originally, any type of image was supported, but this was changed into a whitelist
|
|
74
|
+
// since SVGs and animated GIFs are also images, which are generally considered a security risk.
|
|
75
|
+
if (['image/jpeg', 'image/png'].includes(type)) {
|
|
73
76
|
return <img src={dataURL} style={{ maxWidth: '100%' }} className='file-preview' />;
|
|
74
77
|
}
|
|
75
78
|
|
|
79
|
+
// otherwise, let users download file
|
|
80
|
+
|
|
76
81
|
return (
|
|
77
82
|
<>
|
|
78
83
|
{' '}
|
|
@@ -121,17 +126,26 @@ function FilesInfo<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends F
|
|
|
121
126
|
}
|
|
122
127
|
|
|
123
128
|
function extractFileInfo(dataURLs: string[]): FileInfoType[] {
|
|
124
|
-
return dataURLs
|
|
125
|
-
|
|
126
|
-
|
|
129
|
+
return dataURLs.reduce((acc, dataURL) => {
|
|
130
|
+
if (!dataURL) {
|
|
131
|
+
return acc;
|
|
132
|
+
}
|
|
133
|
+
try {
|
|
127
134
|
const { blob, name } = dataURItoBlob(dataURL);
|
|
128
|
-
return
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
+
return [
|
|
136
|
+
...acc,
|
|
137
|
+
{
|
|
138
|
+
dataURL,
|
|
139
|
+
name: name,
|
|
140
|
+
size: blob.size,
|
|
141
|
+
type: blob.type,
|
|
142
|
+
},
|
|
143
|
+
];
|
|
144
|
+
} catch (e) {
|
|
145
|
+
// Invalid dataURI, so just ignore it.
|
|
146
|
+
return acc;
|
|
147
|
+
}
|
|
148
|
+
}, [] as FileInfoType[]);
|
|
135
149
|
}
|
|
136
150
|
|
|
137
151
|
/**
|