|
@@ -672,11 +672,74 @@ Vue.component('spaceEditor', {
|
|
|
}
|
|
}
|
|
|
return wrapper.innerHTML;
|
|
return wrapper.innerHTML;
|
|
|
},
|
|
},
|
|
|
|
|
+ restoreImageSourcesForSave: function (html) {
|
|
|
|
|
+ if (!html || html.indexOf("<img") === -1 || !this.editor) {
|
|
|
|
|
+ return html || "";
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ var wrapper = document.createElement("div");
|
|
|
|
|
+ wrapper.innerHTML = html;
|
|
|
|
|
+ var outputImages = wrapper.querySelectorAll("img");
|
|
|
|
|
+ if (!outputImages.length) {
|
|
|
|
|
+ return html;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ var getImageSrc = function (image) {
|
|
|
|
|
+ if (!image) {
|
|
|
|
|
+ return "";
|
|
|
|
|
+ }
|
|
|
|
|
+ var src = image.getAttribute("src") || image.src || "";
|
|
|
|
|
+ if (!src) {
|
|
|
|
|
+ var srcset = image.getAttribute("srcset") || "";
|
|
|
|
|
+ if (srcset) {
|
|
|
|
|
+ src = srcset.split(",")[0].trim().split(/\s+/)[0] || "";
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ return this.normalizeEditorMediaUrl(src);
|
|
|
|
|
+ }.bind(this);
|
|
|
|
|
+
|
|
|
|
|
+ var editorImages = [];
|
|
|
|
|
+ var editable = this.editor.ui && this.editor.ui.getEditableElement
|
|
|
|
|
+ ? this.editor.ui.getEditableElement()
|
|
|
|
|
+ : null;
|
|
|
|
|
+ if (editable) {
|
|
|
|
|
+ var domImages = editable.querySelectorAll("img");
|
|
|
|
|
+ for (var i = 0; i < domImages.length; i++) {
|
|
|
|
|
+ editorImages.push(getImageSrc(domImages[i]));
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ var modelImages = [];
|
|
|
|
|
+ if (this.editor.model && this.editor.model.document) {
|
|
|
|
|
+ var root = this.editor.model.document.getRoot();
|
|
|
|
|
+ var range = this.editor.model.createRangeIn(root);
|
|
|
|
|
+ var walker = range.getWalker({ ignoreElementEnd: true });
|
|
|
|
|
+ for (var step = walker.next(); !step.done; step = walker.next()) {
|
|
|
|
|
+ var item = step.value.item;
|
|
|
|
|
+ if (item.is && item.is("element") && (item.name === "imageBlock" || item.name === "imageInline")) {
|
|
|
|
|
+ modelImages.push(this.normalizeEditorMediaUrl(item.getAttribute("src") || ""));
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ for (var imageIndex = 0; imageIndex < outputImages.length; imageIndex++) {
|
|
|
|
|
+ if (outputImages[imageIndex].getAttribute("src")) {
|
|
|
|
|
+ continue;
|
|
|
|
|
+ }
|
|
|
|
|
+ var src = editorImages[imageIndex] || modelImages[imageIndex] || "";
|
|
|
|
|
+ if (src) {
|
|
|
|
|
+ outputImages[imageIndex].setAttribute("src", src);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return wrapper.innerHTML;
|
|
|
|
|
+ },
|
|
|
getEditorSaveHtml: function () {
|
|
getEditorSaveHtml: function () {
|
|
|
if (!this.editor) {
|
|
if (!this.editor) {
|
|
|
return this.htmlContent || "";
|
|
return this.htmlContent || "";
|
|
|
}
|
|
}
|
|
|
var html = this.editor.getData();
|
|
var html = this.editor.getData();
|
|
|
|
|
+ html = this.restoreImageSourcesForSave(html);
|
|
|
html = this.sanitizePdfHtmlForSave(html);
|
|
html = this.sanitizePdfHtmlForSave(html);
|
|
|
html = this.sanitizeVideoHtmlForSave(html);
|
|
html = this.sanitizeVideoHtmlForSave(html);
|
|
|
return html;
|
|
return html;
|