Quellcode durchsuchen

替换文章编辑器外层 Word 导入入口

将文章富文本外层工具条原“一键排版”按钮替换为“导入word文件”,复用 CKEditor 现有 wordUpload 按钮触发文件选择。

保留原 formatContent 方法不移除,避免影响历史调用;新增未加载完成时的现有消息提示。

Validation:

- node --check WebRoot/apps/space/js/space.vue.subassembly.js

- 本地工作台文章录入页无缓存刷新验证:外层按钮显示“导入word文件”,不再显示“一键排版”。
非繁 vor 4 Monaten
Ursprung
Commit
7c7bf9b20b
1 geänderte Dateien mit 27 neuen und 1 gelöschten Zeilen
  1. 27 1
      WebRoot/apps/space/js/space.vue.subassembly.js

+ 27 - 1
WebRoot/apps/space/js/space.vue.subassembly.js

@@ -1767,6 +1767,32 @@ Vue.component('spaceEditor', {
 			this.deferSyncEditorPlayableVideos();
 			space.message.success("正文已完成排版整理");
 		},
+		openWordImporter: function () {
+			if (!this.editor || !this.editor.ui || !this.editor.ui.view || !this.editor.ui.view.element) {
+				space.message.warning("编辑器尚未加载完成");
+				return;
+			}
+
+			var editorEl = this.editor.ui.view.element;
+			var wordButton = editorEl.querySelector('button[aria-label="导入word文件"]')
+				|| editorEl.querySelector('button[title="导入word文件"]');
+			if (!wordButton) {
+				var labels = editorEl.querySelectorAll(".ck-button__label");
+				for (var i = 0; i < labels.length; i++) {
+					if ((labels[i].textContent || "").trim() == "导入word文件") {
+						wordButton = labels[i].closest("button");
+						break;
+					}
+				}
+			}
+
+			if (!wordButton) {
+				space.message.warning("Word 导入功能尚未加载完成");
+				return;
+			}
+
+			wordButton.click();
+		},
 		insertHtml: function (html) {
 			if (!this.editor || space.utils.isNull(html)) {
 				return;
@@ -2520,7 +2546,7 @@ Vue.component('spaceEditor', {
 	template: `
 	<div class="space-editor-wrap">
 		<div class="space-editor-toolstrip" v-if="showEditorTools()">
-			<el-button class="space-editor-tool-btn" size="small" plain icon="el-icon-magic-stick" @click="formatContent">一键排版</el-button>
+			<el-button class="space-editor-tool-btn" size="small" plain icon="el-icon-document" @click="openWordImporter">导入word文件</el-button>
 			<el-button class="space-editor-tool-btn" size="small" plain icon="el-icon-video-camera" @click="openVideoPicker">上传视频</el-button>
 			<el-button class="space-editor-tool-btn" size="small" plain icon="el-icon-document" @click="openPdfPicker">上传PDF</el-button>
 			<span class="space-editor-tool-divider"></span>