Browse Source

知识库支持使用command+s(Mac)或ctrl+s(PC)保存

kuaifan 5 years ago
parent
commit
0aa1edc6b8

+ 1 - 1
package.json

@@ -1,6 +1,6 @@
 {
 {
     "name": "wookteam",
     "name": "wookteam",
-    "version": "1.5.9",
+    "version": "1.5.10",
     "description": "WookTeam是一款轻量级的开源在线团队协作工具,提供各类文档工具、在线思维导图、在线流程图、项目管理、任务分发、即时IM,知识库管理等工具。",
     "description": "WookTeam是一款轻量级的开源在线团队协作工具,提供各类文档工具、在线思维导图、在线流程图、项目管理、任务分发、即时IM,知识库管理等工具。",
     "scripts": {
     "scripts": {
         "ide-helper": "php artisan ide-helper:generate",
         "ide-helper": "php artisan ide-helper:generate",

+ 4 - 1
resources/assets/js/main/components/TEditor.vue

@@ -137,7 +137,7 @@
                         'advlist autolink lists link image charmap print preview hr anchor pagebreak imagetools',
                         'advlist autolink lists link image charmap print preview hr anchor pagebreak imagetools',
                         'searchreplace visualblocks visualchars code',
                         'searchreplace visualblocks visualchars code',
                         'insertdatetime media nonbreaking save table contextmenu directionality',
                         'insertdatetime media nonbreaking save table contextmenu directionality',
-                        'emoticons paste textcolor colorpicker imagetools codesample'
+                        'emoticons paste textcolor colorpicker imagetools codesample save'
                     ];
                     ];
                 }
                 }
             },
             },
@@ -227,6 +227,9 @@
                     language: "zh_CN",
                     language: "zh_CN",
                     toolbar: this.toolbar,
                     toolbar: this.toolbar,
                     plugins: this.plugins,
                     plugins: this.plugins,
+                    save_onsavecallback: (e) => {
+                        this.$emit('editorSave', e);
+                    },
                     paste_data_images: true,
                     paste_data_images: true,
                     menu: {
                     menu: {
                         view: {
                         view: {

+ 4 - 0
resources/assets/js/main/components/docs/flow/index.vue

@@ -82,6 +82,10 @@
                         this.$emit('input', data.params.xml);
                         this.$emit('input', data.params.xml);
                         break
                         break
 
 
+                    case 'save':
+                        this.$emit('saveData');
+                        break
+
                     case 'imageContent':
                     case 'imageContent':
                         let pdf = new JSPDF({
                         let pdf = new JSPDF({
                             format: [data.params.width, data.params.height]
                             format: [data.params.width, data.params.height]

+ 21 - 4
resources/assets/js/main/pages/docs/edit.vue

@@ -71,11 +71,11 @@
             <div class="docs-body">
             <div class="docs-body">
                 <template v-if="docDetail.type=='document'">
                 <template v-if="docDetail.type=='document'">
                     <MDEditor v-if="docContent.type=='md'" class="body-text" v-model="docContent.content" height="100%"></MDEditor>
                     <MDEditor v-if="docContent.type=='md'" class="body-text" v-model="docContent.content" height="100%"></MDEditor>
-                    <TEditor v-else class="body-text" v-model="docContent.content" height="100%"></TEditor>
+                    <TEditor v-else class="body-text" v-model="docContent.content" height="100%" @editorSave="handleClick('saveBefore')"></TEditor>
                 </template>
                 </template>
-                <minder v-else-if="docDetail.type=='mind'" ref="myMind" class="body-mind" v-model="docContent"></minder>
+                <minder v-else-if="docDetail.type=='mind'" ref="myMind" class="body-mind" v-model="docContent" @saveData="handleClick('saveBefore')"></minder>
                 <sheet v-else-if="docDetail.type=='sheet'" ref="mySheet" class="body-sheet" v-model="docContent.content"></sheet>
                 <sheet v-else-if="docDetail.type=='sheet'" ref="mySheet" class="body-sheet" v-model="docContent.content"></sheet>
-                <flow v-else-if="docDetail.type=='flow'" ref="myFlow" class="body-flow" v-model="docContent.content"></flow>
+                <flow v-else-if="docDetail.type=='flow'" ref="myFlow" class="body-flow" v-model="docContent.content" @saveData="handleClick('saveBefore')"></flow>
             </div>
             </div>
         </div>
         </div>
 
 
@@ -501,6 +501,7 @@
             //
             //
             this.refreshSid();
             this.refreshSid();
             this.synergy(true);
             this.synergy(true);
+            document.addEventListener("keydown", this.keySave);
         },
         },
         deactivated() {
         deactivated() {
             if (this.isLock && this.docDetail.lockname == this.userInfo.username) {
             if (this.isLock && this.docDetail.lockname == this.userInfo.username) {
@@ -514,6 +515,7 @@
             }
             }
             //
             //
             this.synergy(false);
             this.synergy(false);
+            document.removeEventListener("keydown", this.keySave);
             this.docDrawerShow = false;
             this.docDrawerShow = false;
             if ($A.getToken() === false) {
             if ($A.getToken() === false) {
                 this.sid = 0;
                 this.sid = 0;
@@ -534,7 +536,7 @@
                     this.sid = To.params.sid;
                     this.sid = To.params.sid;
                 }
                 }
             },
             },
-            
+
             docDrawerTab(act) {
             docDrawerTab(act) {
                 switch (act) {
                 switch (act) {
                     case "menu":
                     case "menu":
@@ -617,6 +619,13 @@
             }
             }
         },
         },
         methods: {
         methods: {
+            keySave(e) {
+                if ((e.ctrlKey || e.metaKey) && e.keyCode === 83) {
+                    this.handleClick('saveBefore');
+                    e.preventDefault();
+                }
+            },
+
             goBackDirect() {
             goBackDirect() {
                 this.bakContent = $A.jsonStringify(this.docContent);
                 this.bakContent = $A.jsonStringify(this.docContent);
                 this.goBack({name:'docs'});
                 this.goBack({name:'docs'});
@@ -767,6 +776,14 @@
                         });
                         });
                         break;
                         break;
 
 
+                    case "saveBefore":
+                        if (!this.equalContent && this.loadIng == 0) {
+                            this.handleClick('save');
+                        } else {
+                            this.$Message.warning(this.$L('没有任何修改!'));
+                        }
+                        return;
+
                     case "save":
                     case "save":
                         this.bakContent = $A.jsonStringify(this.docContent);
                         this.bakContent = $A.jsonStringify(this.docContent);
                         $A.apiAjax({
                         $A.apiAjax({

+ 10 - 1
resources/assets/statics/public/js/grapheditor/index.html

@@ -54,11 +54,20 @@
             this.actions.get('export').setEnabled(false);
             this.actions.get('export').setEnabled(false);
             this.actions.get('open').setEnabled(false);
             this.actions.get('open').setEnabled(false);
             this.actions.get('import').setEnabled(false);
             this.actions.get('import').setEnabled(false);
-            this.actions.get('save').setEnabled(false);
+            this.actions.get('save').setEnabled(true);
             this.actions.get('saveAs').setEnabled(false);
             this.actions.get('saveAs').setEnabled(false);
             this.actions.get('export').setEnabled(false);
             this.actions.get('export').setEnabled(false);
         };
         };
 
 
+        EditorUi.prototype.saveFile = function () {
+            window.parent.postMessage({
+                act: 'save',
+                params: {
+
+                }
+            }, '*');
+        };
+
         EditorUi.prototype.menubarHeight = 0;
         EditorUi.prototype.menubarHeight = 0;
         EditorUi.prototype.footerHeight = 0;
         EditorUi.prototype.footerHeight = 0;
 
 

+ 4 - 0
resources/lang/en/general.js

@@ -512,4 +512,8 @@ export default {
     "全部任务": "All tasks",
     "全部任务": "All tasks",
     "我负责的任务": "I am responsible for the task",
     "我负责的任务": "I am responsible for the task",
     "使用我上次抄送的人": "Use the person I cc'd last time",
     "使用我上次抄送的人": "Use the person I cc'd last time",
+    "没有任何修改!": "No changes!",
+    "分享文档": "Share documents",
+    "历史版本": "Historic version",
+    "浏览文档": "View the document",
 }
 }