|
|
@@ -777,10 +777,46 @@ Vue.component('spaceEditor', {
|
|
|
}
|
|
|
var html = this.editor.getData();
|
|
|
html = this.restoreImageSourcesForSave(html);
|
|
|
+ html = this.normalizeAttachmentLinksForSave(html);
|
|
|
html = this.sanitizePdfHtmlForSave(html);
|
|
|
html = this.sanitizeVideoHtmlForSave(html);
|
|
|
return html;
|
|
|
},
|
|
|
+ normalizeAttachmentLinksForSave: function (html) {
|
|
|
+ if (!html || html.indexOf('/web/upload/') === -1) {
|
|
|
+ return html || "";
|
|
|
+ }
|
|
|
+
|
|
|
+ var wrapper = document.createElement('div');
|
|
|
+ wrapper.innerHTML = html;
|
|
|
+ var links = wrapper.querySelectorAll('a[href]');
|
|
|
+ for (var i = 0; i < links.length; i++) {
|
|
|
+ var link = links[i];
|
|
|
+ var href = this.normalizeLocalUploadUrl(link.getAttribute('href') || '');
|
|
|
+ if (!href || href.indexOf('/web/upload/') !== 0) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ var fileName = (link.textContent || '').replace(/\s+/g, ' ').trim();
|
|
|
+ if (!fileName) {
|
|
|
+ try {
|
|
|
+ fileName = decodeURIComponent(href.split('?')[0].split('#')[0].split('/').pop() || '附件');
|
|
|
+ } catch (error) {
|
|
|
+ fileName = href.split('?')[0].split('#')[0].split('/').pop() || '附件';
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ link.setAttribute('href', href);
|
|
|
+ link.setAttribute('download', fileName);
|
|
|
+ link.setAttribute('target', '_blank');
|
|
|
+ link.setAttribute('rel', 'noopener');
|
|
|
+ link.setAttribute('title', '下载附件:' + fileName);
|
|
|
+ link.classList.add('article-attachment');
|
|
|
+ link.style.color = '#1769ff';
|
|
|
+ link.style.textDecoration = 'underline';
|
|
|
+ }
|
|
|
+ return wrapper.innerHTML;
|
|
|
+ },
|
|
|
deferEmitEditorHtml: function () {
|
|
|
if (this._emitEditorHtmlTimer) {
|
|
|
window.clearTimeout(this._emitEditorHtmlTimer);
|