commit 539578270f8b508f2d0b003c8a55ea06203dd725
parent fdadbf6e3275944b630d8b61ee5dfc32a65d9b31
Author: Eric Butler <ebutler@striven.com>
Date: Thu, 27 Feb 2025 17:43:15 -0500
version update
Diffstat:
2 files changed, 17 insertions(+), 6 deletions(-)
diff --git a/package.json b/package.json
@@ -1,7 +1,7 @@
{
"name": "@striven-erp/striven-editor",
"private": false,
- "version": "3.19.5",
+ "version": "3.19.6",
"description": "The editor used for the Striven ERP system.",
"main": "./dist",
"scripts": {
diff --git a/src/striveneditor.js b/src/striveneditor.js
@@ -390,8 +390,9 @@ export default class StrivenEditor {
se.toolbarOptionsGroup.classList.add('se-toolbar-options');
- toolbar.onclick = () => {
+ toolbar.onclick = (ev) => {
se.body.focus();
+ ev.stopPropagation();
};
// Append Font Options
@@ -2435,17 +2436,15 @@ export default class StrivenEditor {
imageMenuLinkTabButton.click();
imageMenuUploadTabButton.setAttribute('disabled', 'disabled');
imageMenuUploadTabButton.style.cursor = 'not-allowed';
- // Change the text of the insert image button to Update Image
+ // Change the text of the insert image button to Update Image
imageInsertButton.textContent = 'Update Image';
// Set cursor to indicate disabled
-
} else {
imageMenuUploadTabButton.click();
imageMenuUploadTabButton.removeAttribute('disabled');
imageMenuUploadTabButton.style.cursor = 'pointer';
// Rename insert image button
imageInsertButton.textContent = 'Insert Image';
-
}
// Clear the input fields
@@ -3427,6 +3426,8 @@ export default class StrivenEditor {
*/
insertImage(file) {
const se = this;
+ se.body.focus();
+ se.setRange();
return new Promise((resolveImageInsert) => {
const bodyWidth = se.body.offsetWidth;
@@ -3442,8 +3443,12 @@ export default class StrivenEditor {
<svg width="25%" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><title>cloud-upload-outline</title><path d="M6.5 20Q4.22 20 2.61 18.43 1 16.85 1 14.58 1 12.63 2.17 11.1 3.35 9.57 5.25 9.15 5.88 6.85 7.75 5.43 9.63 4 12 4 14.93 4 16.96 6.04 19 8.07 19 11 20.73 11.2 21.86 12.5 23 13.78 23 15.5 23 17.38 21.69 18.69 20.38 20 18.5 20H13Q12.18 20 11.59 19.41 11 18.83 11 18V12.85L9.4 14.4L8 13L12 9L16 13L14.6 14.4L13 12.85V18H18.5Q19.55 18 20.27 17.27 21 16.55 21 15.5 21 14.45 20.27 13.73 19.55 13 18.5 13H17V11Q17 8.93 15.54 7.46 14.08 6 12 6 9.93 6 8.46 7.46 7 8.93 7 11H6.5Q5.05 11 4.03 12.03 3 13.05 3 14.5 3 15.95 4.03 17 5.05 18 6.5 18H9V20M12 13Z" /></svg>
</div>`
);
- // Replace the temporary image with the uploaded image
+
const tempImg = document.getElementById(randomString);
+ if (!tempImg){
+ console.error("Failed to insert image into the DOM. Make sure the editor body is focused and try again.");
+ return;
+ }
getImageDataURL(file)
.then((imgDataUrl) => {
@@ -3458,6 +3463,7 @@ export default class StrivenEditor {
//upload image if imageUrl is provided
se.getImage(imgDataUrl)
.then((imageUrl) => {
+ // Replace the temporary image with the uploaded image
tempImg.outerHTML = `<img id="${randomString}" src="${imageUrl}" width="${newWidth}px" alt=""/>`;
se._isImageUploading = false;
setTimeout(function () {
@@ -3465,10 +3471,12 @@ export default class StrivenEditor {
}, 100);
})
.catch((err) => {
+ // Replace the temporary image with the uploaded image
tempImg.outerHTML = imgTag;
se._isImageUploading = false;
});
} else {
+ // Replace the temporary image with the uploaded image
tempImg.outerHTML = imgTag;
se._isImageUploading = false;
setTimeout(function () {
@@ -3480,17 +3488,20 @@ export default class StrivenEditor {
})
.catch((err) => {
console.error(err);
+ // Replace the temporary image with the uploaded image
tempImg.remove();
se._isImageUploading = false;
});
})
.catch((err) => {
console.error(err);
+ // Replace the temporary image with the uploaded image
tempImg.remove();
se._isImageUploading = false;
});
}).catch((err) => {
console.error(err);
+ // Replace the temporary image with the uploaded image
tempImg.remove();
se._isImageUploading = false;
});