Explorar o código

完善正文附件下载链接属性

CKEditor 插入附件后会移除 download、target 等非默认链接属性,保存正文时统一为 /web/upload 文件链接补回 download、blue、target=_blank 和安全 rel 属性,并在编辑器内显示蓝色下划线。更新编辑器 CSS 和脚本缓存版本。\n\nValidation:\n- node --check WebRoot/apps/space/js/space.vue.subassembly.js\n- git diff --cached --check
非繁 hai 2 semanas
pai
achega
f791a4479b

+ 5 - 0
WebRoot/apps/space/css/space.editor.css

@@ -745,3 +745,8 @@ html.article-info-layer-page body {
 @font-face{font-family:'FangSong_GB2312';src:url('/main/ffkj-portal/fonts/FandolFang-Regular.otf') format('opentype');font-weight:400;font-style:normal;font-display:swap}
 @font-face{font-family:'仿宋_GB2312';src:url('/main/ffkj-portal/fonts/FandolFang-Regular.otf') format('opentype');font-weight:400;font-style:normal;font-display:swap}
 @font-face{font-family:'STFangsong';src:url('/main/ffkj-portal/fonts/FandolFang-Regular.otf') format('opentype');font-weight:400;font-style:normal;font-display:swap}
+.ck-content a.article-attachment,
+.ck-content a[href*="/web/upload/"] {
+  color: #1769ff;
+  text-decoration: underline;
+}

+ 36 - 0
WebRoot/apps/space/js/space.vue.subassembly.js

@@ -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);

+ 2 - 2
WebRoot/web/subassembly/app/pc/10021/10104/1002110104_run.jsp

@@ -12,13 +12,13 @@
  <link rel="stylesheet" type="text/css" href="/apps/space/css/SpaceIcon/iconfont.css"> 
  <link rel="stylesheet" type="text/css" href="/css/components.css"> 
  <link rel="stylesheet" href="/css/ckeditor.css"> 
- <link rel="stylesheet" href="/apps/space/css/space.editor.css?v=20261110-line-height">
+ <link rel="stylesheet" href="/apps/space/css/space.editor.css?v=20261110-attachments">
  <script>var space = { vars: {} };</script> 
  <script src="/js/jquery1.11.3.min.js" type="text/javascript" charset="utf-8"></script> 
  <script src="/apps/space/plug-in/element-resize-detector/element-resize-detector.min.js"></script> 
  <script src="/apps/space/plug-in/vue/vue.min.js" type="text/javascript" charset="utf-8"></script> 
  <script src="/apps/space/plug-in/element-ui@2.13.0/index.js" type="text/javascript" charset="utf-8"></script> 
- <script src="/js/space.vue.pc.subassembly.js?v=20261110-word-images-attachment"></script>
+ <script src="/js/space.vue.pc.subassembly.js?v=20261110-word-images-attachments-2"></script>
  <script src="/apps/space/plug-in/layui/dist/layui.all.js" type="text/javascript" charset="utf-8"></script> 
  <script src="/js/space.recycle.js" type="text/javascript" charset="utf-8"></script> 
  <script src="/js/space.display.js?v=20261110-title-submit-v2" type="text/javascript" charset="utf-8"></script>

+ 2 - 2
WebRoot/web/subassembly/app/pc/10021/10105/1002110105_run.jsp

@@ -12,13 +12,13 @@
  <link rel="stylesheet" type="text/css" href="/apps/space/css/SpaceIcon/iconfont.css"> 
  <link rel="stylesheet" type="text/css" href="/css/components.css"> 
  <link rel="stylesheet" href="/css/ckeditor.css"> 
- <link rel="stylesheet" href="/apps/space/css/space.editor.css?v=20261110-line-height">
+ <link rel="stylesheet" href="/apps/space/css/space.editor.css?v=20261110-attachments">
  <script>var space = { vars: {} };</script> 
  <script src="/js/jquery1.11.3.min.js" type="text/javascript" charset="utf-8"></script> 
  <script src="/apps/space/plug-in/element-resize-detector/element-resize-detector.min.js"></script> 
  <script src="/apps/space/plug-in/vue/vue.min.js" type="text/javascript" charset="utf-8"></script> 
  <script src="/apps/space/plug-in/element-ui@2.13.0/index.js" type="text/javascript" charset="utf-8"></script> 
- <script src="/js/space.vue.pc.subassembly.js?v=20261110-word-images-attachment"></script>
+ <script src="/js/space.vue.pc.subassembly.js?v=20261110-word-images-attachments-2"></script>
  <script src="/apps/space/plug-in/layui/dist/layui.all.js" type="text/javascript" charset="utf-8"></script> 
  <script src="/js/space.recycle.js" type="text/javascript" charset="utf-8"></script> 
  <script src="/js/space.display.js?v=20261110-title-submit-v2" type="text/javascript" charset="utf-8"></script>

+ 2 - 2
WebRoot/web/subassembly/app/pc/10021/10211/1002110211_run.jsp

@@ -12,13 +12,13 @@
  <link rel="stylesheet" type="text/css" href="/apps/space/css/SpaceIcon/iconfont.css"> 
  <link rel="stylesheet" type="text/css" href="/css/components.css"> 
  <link rel="stylesheet" href="/css/ckeditor.css"> 
-		<link rel="stylesheet" href="/apps/space/css/space.editor.css?v=20261110-line-height">
+		<link rel="stylesheet" href="/apps/space/css/space.editor.css?v=20261110-attachments">
  <script>var space = { vars: {} };</script> 
  <script src="/js/jquery1.11.3.min.js" type="text/javascript" charset="utf-8"></script> 
  <script src="/apps/space/plug-in/element-resize-detector/element-resize-detector.min.js"></script> 
  <script src="/apps/space/plug-in/vue/vue.min.js" type="text/javascript" charset="utf-8"></script> 
  <script src="/apps/space/plug-in/element-ui@2.13.0/index.js" type="text/javascript" charset="utf-8"></script> 
- <script src="/js/space.vue.pc.subassembly.js?v=20261110-word-images-attachment"></script>
+ <script src="/js/space.vue.pc.subassembly.js?v=20261110-word-images-attachments-2"></script>
  <script src="/apps/space/plug-in/layui/dist/layui.all.js" type="text/javascript" charset="utf-8"></script> 
  <script src="/js/space.recycle.js" type="text/javascript" charset="utf-8"></script> 
  <script src="/js/space.display.js?v=20261110-title-submit-v2" type="text/javascript" charset="utf-8"></script>