commit 11113426022b0694dfc5e8977218b346f20dacdc
parent 8bcb30f2b35328a3086e0e66c3e2536a9e5b210d
Author: Eric Butler <ebutler@striven.com>
Date: Fri, 14 Nov 2025 17:14:29 -0500
Merge branch 'dev'
Diffstat:
2 files changed, 50 insertions(+), 7 deletions(-)
diff --git a/package.json b/package.json
@@ -1,7 +1,7 @@
{
"name": "@striven-erp/striven-editor",
"private": false,
- "version": "3.19.15",
+ "version": "3.19.16",
"description": "The editor used for the Striven ERP system.",
"main": "./dist",
"scripts": {
diff --git a/src/striveneditor.js b/src/striveneditor.js
@@ -33,6 +33,9 @@ import Pickr from '@simonwep/pickr/dist/pickr.es5.min';
// Formatting
import js_beautify from 'js-beautify';
+// Consts
+const MAX_FILES_UPLOAD = 25;
+
/* Represents an instance of the Striven Editor */
export default class StrivenEditor {
/**
@@ -120,6 +123,8 @@ export default class StrivenEditor {
// Allow File Upload
options.fileUpload !== false && (se.options.fileUpload = true);
+ options.maxFiles = options.maxFiles || MAX_FILES_UPLOAD;
+
// Configure Options with Minimal Enabled
if (options.toolbarOptions && options.minimal) {
// Get custom options from toolbarOptions
@@ -139,6 +144,7 @@ export default class StrivenEditor {
toolbarOptions: DEFAULTOPTIONS,
activeOptionColor: ACTIVEOPTIONCOLOR,
fontNames: FONTNAMES,
+ maxFiles: MAX_FILES_UPLOAD,
fileUpload: true,
canTab: false
};
@@ -927,7 +933,11 @@ export default class StrivenEditor {
if (e.clipboardData.files && e.clipboardData.files.length > 0 ) {
e.preventDefault();
- se.insertImages(e.clipboardData.files).finally(() => {
+ se.insertImages(e.clipboardData.files)
+ .catch((ex) => {
+ console.error(ex);
+ })
+ .finally(() => {
afterPaste();
});
@@ -1471,9 +1481,13 @@ export default class StrivenEditor {
const files = e.target.files;
// For each file, get the data url and insert the image
- se.insertImages(files).then(() => {
+ se.insertImages(files)
+ .then(() => {
// Clear the inputs
clearImageMenuInputs();
+ })
+ .catch((ex) => {
+ console.error(ex);
});
};
@@ -1507,9 +1521,13 @@ export default class StrivenEditor {
const files = e.dataTransfer.files;
// For each file, get the data url and insert the image
- se.insertImages(files).then(() => {
+ se.insertImages(files)
+ .then(() => {
// Clear the inputs
clearImageMenuInputs();
+ })
+ .catch((ex) => {
+ console.error(ex);
});
};
@@ -1783,7 +1801,15 @@ export default class StrivenEditor {
if (e.dataTransfer.types.includes('Files')) {
if (e.dataTransfer.files.length) {
- [...e.dataTransfer.files].forEach((file) => se.attachFile(file));
+ const files =[...e.dataTransfer.files];
+
+ // Ensure there are no more than the max files allowed
+ if (files.length + se.files.length > se.options.maxFiles) {
+ alert(`Only ${se.options.maxFiles} files are allowed to upload in one batch.`);
+ return;
+ }
+
+ files.forEach((file) => se.attachFile(file));
}
}
};
@@ -3300,7 +3326,15 @@ export default class StrivenEditor {
attachmentInput.style.display = 'none';
document.body.append(attachmentInput);
attachmentInput.onchange = (e) => {
- [...attachmentInput.files].forEach((file) => se.attachFile(file));
+ const files = [...attachmentInput.files]
+
+ // Ensure there are no more than the max files allowed
+ if (files.length + se.files.length > se.options.maxFiles) {
+ alert(`Only ${se.options.maxFiles} files are allowed to upload in one batch.`);
+ return;
+ }
+
+ files.forEach((file) => se.attachFile(file));
attachmentInput.remove();
};
attachmentInput.click();
@@ -3481,11 +3515,20 @@ export default class StrivenEditor {
* @returns
*/
insertImages(files) {
+
const se = this;
se.ensureSelectionInBody(se.body);
const currentRange = se.getRange();
- return new Promise((resolve) => {
+ return new Promise((resolve, reject) => {
+ // Check if files has more than 25 files
+ if (files.length > se.options.maxFiles) {
+ const errorMessage = `Only ${se.options.maxFiles} files are allowed to upload in one batch.`;
+ alert(errorMessage);
+ reject(errorMessage);
+ return;
+ }
+
// Add busy class to striven editor
se.editor.classList.add('se-image-uploading');
se._isImageUploading = true;