|
@@ -916,7 +916,7 @@ export default {
|
|
|
|
|
|
// Update the content and notify parent component
|
|
|
this.$nextTick(() => {
|
|
|
- this.updateContentWithNewImage(uploadedUrl);
|
|
|
+ this.updateContentWithNewImage(imgElement, uploadedUrl);
|
|
|
});
|
|
|
}
|
|
|
} catch (error) {
|
|
@@ -924,14 +924,26 @@ export default {
|
|
|
}
|
|
|
},
|
|
|
|
|
|
- updateContentWithNewImage(newImageUrl) {
|
|
|
- // Get the latest DOM content
|
|
|
- const latestContent = this.$refs.richEditor.innerHTML;
|
|
|
+ updateContentWithNewImage(imgElement, newImageUrl) {
|
|
|
+ // Get the rich-editor div
|
|
|
+ const richEditor = this.$refs.richEditor;
|
|
|
|
|
|
- // Update this.content with the latest DOM content
|
|
|
- this.content = latestContent;
|
|
|
+ // Create a new Image element with the new URL
|
|
|
+ const newImg = document.createElement("img");
|
|
|
+ newImg.src = newImageUrl;
|
|
|
+
|
|
|
+ // Copy attributes from the old image to the new one
|
|
|
+ for (let attr of imgElement.attributes) {
|
|
|
+ if (attr.name !== "src") {
|
|
|
+ newImg.setAttribute(attr.name, attr.value);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // Replace the old image with the new one
|
|
|
+ imgElement.parentNode.replaceChild(newImg, imgElement);
|
|
|
|
|
|
- console.log("Updated content:", this.content);
|
|
|
+ // Update this.content with the latest DOM content
|
|
|
+ this.content = richEditor.innerHTML;
|
|
|
|
|
|
// Update the com object
|
|
|
this.com.content = this.content;
|