askbot-dragon 1.6.19-beta → 1.6.21-beta

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,15 +1,20 @@
1
1
  {
2
2
  "name": "askbot-dragon",
3
- "version": "1.6.19-beta",
3
+ "version": "1.6.21-beta",
4
4
  "scripts": {
5
5
  "serve": "vue-cli-service serve",
6
6
  "build": "vue-cli-service build",
7
7
  "lint": "vue-cli-service lint"
8
8
  },
9
9
  "dependencies": {
10
+ "@ckeditor/ckeditor5-ui": "^10.1.0",
11
+ "@ckeditor/ckeditor5-vue2": "^3.0.1",
10
12
  "ali-oss": "^6.2.1",
11
13
  "audio-loader": "^1.0.3",
14
+ "ckeditor": "^4.12.1",
12
15
  "core-js": "^3.6.5",
16
+ "element-ui": "^2.15.14",
17
+ "esdk-obs-browserjs": "^3.23.5",
13
18
  "install": "^0.13.0",
14
19
  "jquery": "^3.5.1",
15
20
  "lodash": "^4.17.21",
@@ -27,7 +32,6 @@
27
32
  "@vue/cli-plugin-eslint": "~4.5.0",
28
33
  "@vue/cli-service": "~4.5.0",
29
34
  "babel-eslint": "^10.1.0",
30
- "element-ui": "^2.15.10",
31
35
  "eslint": "^6.7.2",
32
36
  "eslint-plugin-vue": "^6.2.2",
33
37
  "less": "^3.12.2",
package/public/index.html CHANGED
@@ -23,11 +23,13 @@
23
23
  });
24
24
  }
25
25
  </script>
26
+ <script src="https://askbot-uat.obs.cn-east-3.myhuaweicloud.com/npm-static/ckeditor5-build-classic/0.4.4/ckeditor.js"></script>
26
27
  <!-- 项目图标 -->
27
28
  <link rel="stylesheet" href="//at.alicdn.com/t/font_1566110_3hu6pyd938i.css"/>
28
29
  <!-- guoran图标 -->
29
30
  <link rel="stylesheet" href="//at.alicdn.com/t/c/font_2913049_qtm7orae3l.css"/>
30
31
  <script src="https://res.wx.qq.com/open/js/jweixin-1.2.0.js"></script>
32
+ <!-- <script src="https://static.guoranbot.com/ckeditor5-build-classic/0.3.7/build/ckeditor.js"></script> -->
31
33
 
32
34
  <!-- vue -->
33
35
  <!-- <script src="https://static.guoranbot.com/vue/2.6.11/dist/vue.min.js"></script>
@@ -46,12 +48,12 @@
46
48
  <script src="https://cdnjs.cloudflare.com/ajax/libs/pdf.js/3.5.141/pdf.worker.min.js" integrity="sha512-6UHd2tcWIvg5hIYHXb3lnNO61tWfriGen6KddwGYTSUUazWGYESTHDDxJFEQkCy1cSL//yXKc1gcL+51/DTLFQ==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
47
49
  <script src="https://cdnjs.cloudflare.com/ajax/libs/pdf.js/3.5.141/pdf_viewer.min.js" integrity="sha512-tYEGuMBQkCfSlBKJ3dNgS06wbb/MNE6nO2poZ1Y5brix8NajGcDcfEvuL38wJDOTkq0j5ojASNmrzv/8/wgGHQ==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
48
50
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/pdf.js/3.5.141/pdf_viewer.min.css" integrity="sha512-Jf9DLkegLgARLR151csVkPvcVt4cOUhslrSZwiTAe9mqFL/BbYRDmxCOioCtbHifEgjsBFbrVhOMQ3mYPDLrqQ==" crossorigin="anonymous" referrerpolicy="no-referrer" /> -->
49
-
50
-
51
- <script src="https://guoranopen-zjk.oss-cn-zhangjiakou.aliyuncs.com/cdn-common/pdfJS2.1.266/pdf.min.js" referrerpolicy="no-referrer"></script>
52
- <script src="https://guoranopen-zjk.oss-cn-zhangjiakou.aliyuncs.com/cdn-common/pdfJS2.1.266/pdf.worker.min.js" referrerpolicy="no-referrer"></script>
53
- <script src="https://guoranopen-zjk.oss-cn-zhangjiakou.aliyuncs.com/cdn-common/pdfJS2.1.266/pdf_viewer.js" referrerpolicy="no-referrer"></script>
54
- <link rel="stylesheet" href="https://guoranopen-zjk.oss-cn-zhangjiakou.aliyuncs.com/cdn-common/pdfJS2.1.266/pdf_viewer_01.css" referrerpolicy="no-referrer" />
51
+
52
+
53
+ <script src="https://askbot-uat.obs.cn-east-3.myhuaweicloud.com/npm-static/pdfJS2.1.266/pdf.min.js" referrerpolicy="no-referrer"></script>
54
+ <script src="https://askbot-uat.obs.cn-east-3.myhuaweicloud.com/npm-static/pdfJS2.1.266/pdf.worker.min.js" referrerpolicy="no-referrer"></script>
55
+ <script src="https://askbot-uat.obs.cn-east-3.myhuaweicloud.com/npm-static/pdfJS2.1.266/pdf_viewer.js" referrerpolicy="no-referrer"></script>
56
+ <link rel="stylesheet" href="https://askbot-uat.obs.cn-east-3.myhuaweicloud.com/npm-static/pdfJS2.1.266/pdf_viewer_01.css" referrerpolicy="no-referrer" />
55
57
  <!-- hammer.js -->
56
58
  <!-- <script src="https://cdnjs.cloudflare.com/ajax/libs/hammer.js/2.0.8/hammer.min.js" integrity="sha512-UXumZrZNiOwnTcZSHLOfcTs0aos2MzBWHXOHOuB0J/R44QB0dwY5JgfbvljXcklVf65Gc4El6RjZ+lnwd2az2g==" crossorigin="anonymous" referrerpolicy="no-referrer"></script> -->
57
59
  <style>
@@ -0,0 +1,63 @@
1
+ // 创建ObsClient实例
2
+ import ObsClient from 'esdk-obs-browserjs';
3
+ const obsClient = new ObsClient({
4
+ access_key_id: "EE4MAFWH4YLQSQF7NNIP",
5
+ secret_access_key: "Dq9giqqwZoX77dqSIzhA1Yhhe9tarA3LRBGBF4eO",
6
+ server : 'https://obs.cn-east-3.myhuaweicloud.com',
7
+ timeout : 1000
8
+ });
9
+ let mainId = sessionStorage.getItem('_mainId') ? sessionStorage.getItem('_mainId') : "";
10
+ let IDX = 256, HEX = [], SIZE = 256, BUFFER;
11
+ while (IDX--) HEX[IDX] = (IDX + 256).toString(16).substring(1);
12
+ function uid(len) {
13
+ let i = 0, tmp = (len || 11);
14
+ if (!BUFFER || ((IDX + tmp) > SIZE * 2)) {
15
+ for (BUFFER = '', IDX = 0; i < SIZE; i++) {
16
+ BUFFER += HEX[Math.random() * 256 | 0];
17
+ }
18
+ }
19
+
20
+ return BUFFER.substring(IDX, IDX++ + tmp);
21
+ }
22
+
23
+ function dataFormat(fmt, date = new Date()) {
24
+ const o = {
25
+ "M+": date.getMonth() + 1, //月份
26
+ "d+": date.getDate(), //日
27
+ "h+": date.getHours(), //小时
28
+ "m+": date.getMinutes(), //分
29
+ "s+": date.getSeconds(), //秒
30
+ "q+": Math.floor((date.getMonth() + 3) / 3), //季度
31
+ "S": date.getMilliseconds() //毫秒
32
+ };
33
+ if (/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (date.getFullYear() + "").substr(4 - RegExp.$1.length));
34
+ for (const k in o)
35
+ if (new RegExp("(" + k + ")").test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length === 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
36
+ return fmt;
37
+ }
38
+ async function putObject(file,callback){
39
+ let fileUrl = ''
40
+ let objName = (process.env.VUE_APP_ENV === 'development' ? 'dev_' : 'pro_') + file.name;
41
+ let fileName = "front-oss/" + mainId + '/' + dataFormat("yyyy/MM/dd/hh/mm/") + uid(32) + "/" + objName;
42
+ await obsClient.putObject({
43
+ Bucket: 'askbot-uat',
44
+ Key : fileName,
45
+ SourceFile : file,
46
+ ACL : obsClient.enums.AclPublicRead,
47
+ ProgressCallback: callback
48
+ }).then(function(result) {
49
+ if(result.CommonMsg.Status < 300){
50
+ console.log('Create object:' + JSON.stringify(result) + ' successfully!\n',process.env.VUE_APP_ENV);
51
+ let domain = process.env.VUE_APP_ENV ==='development' ? 'https://askbot-uat.obs.cn-east-3.myhuaweicloud.com/' : ''
52
+ fileUrl = {
53
+ url: domain + fileName,
54
+ name:file.name
55
+ }
56
+ }
57
+ });
58
+ return fileUrl
59
+ }
60
+
61
+ export {
62
+ putObject
63
+ }
@@ -69,6 +69,9 @@
69
69
  </div>
70
70
  </div>
71
71
  </div>
72
+ <div class="ad-loadmore" v-if="loadMoreFlag" @click="lazyLoadKnowledegList">
73
+ 查看更多
74
+ </div>
72
75
  </div>
73
76
  <previewPdf ref="previewPdf" :url="previewHref" :sourceFileType="sourceFileType" officePreviewType="pdf"></previewPdf>
74
77
  </div>
@@ -154,28 +157,29 @@ export default {
154
157
  MP3: "audio",
155
158
  yqhtml: "yqhtml",
156
159
  feishuhtml:"feishuhtml"
157
- }
160
+ },
161
+ allKnowledgeList:[],
162
+ loadMoreFlag:false
158
163
  }
159
164
  },
160
165
  props: ['msg','isAskLightning', 'isMessageRecord',"isApp"],
161
166
  beforeMounted() {
162
-
163
167
  },
164
168
  watch:{
165
- msg:{
166
- handler(n){
167
- console.log(n,'answerDocknowledge');
168
- n.content.list.forEach(element => {
169
- console.log(this.imageObj[element.format],1111);
170
- element.src = 'https://static.guoranbot.com/cdn-office-website/askbot_doc/' + this.imageObj[element.format] + '.png';
171
- if ((element.format === "txt" || element.format === "html") && element.source === "WECHAT") {
172
- element.src = 'https://static.guoranbot.com/cdn-office-website/askbot_doc/wechat.png';
173
- }
174
- });
175
- },
176
- deep:true,
177
- immediate:true
178
- }
169
+ msg:{
170
+ handler(n){
171
+ console.log(n,'answerDocknowledge');
172
+ n.content.list.forEach(element => {
173
+ console.log(this.imageObj[element.format],1111);
174
+ element.src = 'https://static.guoranbot.com/cdn-office-website/askbot_doc/' + this.imageObj[element.format] + '.png';
175
+ if ((element.format === "txt" || element.format === "html") && element.source === "WECHAT") {
176
+ element.src = 'https://static.guoranbot.com/cdn-office-website/askbot_doc/wechat.png';
177
+ }
178
+ });
179
+ },
180
+ deep:true,
181
+ immediate:true
182
+ }
179
183
  },
180
184
  created() {
181
185
  var system = {};
@@ -196,7 +200,17 @@ export default {
196
200
  // });
197
201
  },
198
202
  mounted() {
199
-
203
+ console.log(this.msg.content,'this.msg.content');
204
+ // if(this.msg.content.type == 1) {
205
+
206
+ // }
207
+ if(this.msg.content.list && this.msg.content.list.length > 0) {
208
+ this.loadMoreFlag = true
209
+ this.allKnowledgeList = JSON.parse(JSON.stringify(this.msg.content.list))
210
+ // console.log(this.allKnowledgeList.length, 'this.allKnowledgeList');
211
+ this.msg.content.list = []
212
+ this.lazyLoadKnowledegList()
213
+ }
200
214
  },
201
215
  methods: {
202
216
  //预览图片
@@ -298,6 +312,21 @@ export default {
298
312
  // return res.data
299
313
  })
300
314
  // return imgurl
315
+ },
316
+ lazyLoadKnowledegList() {
317
+ if(this.allKnowledgeList.length !== 0) {
318
+ let arr = this.allKnowledgeList.splice(0, 5)
319
+ if(arr.length < 5) {
320
+ this.loadMoreFlag = false
321
+ this.msg.content.list = [...this.msg.content.list, ...arr]
322
+ return
323
+ }
324
+ if(this.allKnowledgeList.length == 0) {
325
+ this.loadMoreFlag = false
326
+ }
327
+ this.msg.content.list = [...this.msg.content.list, ...arr]
328
+ return
329
+ }
301
330
  }
302
331
  }
303
332
  }
@@ -511,6 +540,18 @@ export default {
511
540
  }
512
541
  }
513
542
  }
543
+ .ad-loadmore {
544
+ width: 100%;
545
+ height: 40px;
546
+ display: flex;
547
+ align-items: center;
548
+ justify-content: center;
549
+ // background: #FFFFFF;
550
+ color: #366AFF;
551
+ font-size: 14px;
552
+ margin-top: 8px;
553
+ cursor: pointer;
554
+ }
514
555
  }
515
556
  }
516
557
  </style>
@@ -12,15 +12,15 @@
12
12
  <loading-process :dataNote="dataNote" :finished="finished"></loading-process>
13
13
  </div>
14
14
  </div> -->
15
- <MyEditor></MyEditor>
15
+
16
16
  <!-- <form-template
17
17
  :formList="formList2"
18
18
  @submitClick="submitClick"
19
19
  ></form-template> -->
20
- <form-template
20
+ <!-- <form-template
21
21
  :formList="formList"
22
22
  @submitClick="submitClick"
23
- ></form-template>
23
+ ></form-template> -->
24
24
  <!-- <form-template
25
25
  :formList="formList3"
26
26
  @submitClick="submitClick"
@@ -77,11 +77,11 @@
77
77
  </template>
78
78
  <script>
79
79
  import TextMessage from '@/components/message/TextMessage'
80
- import FormTemplate from "@/components/formTemplate";
80
+ // import FormTemplate from "@/components/formTemplate";
81
81
 
82
82
  /*import FormTemplate from "@/components/formTemplate";
83
83
  import TextMessage from "@/components/message/TextMessage";*/
84
- import MyEditor from '@/components/MyEditor'
84
+
85
85
  // import FormTemplate from '@/components/formTemplate'
86
86
  import AnswerRadio from './answerRadio'
87
87
  // import TicketMessage from './message/TicketMessage'
@@ -119,7 +119,7 @@ export default {
119
119
  // LoadingProcess,
120
120
  // MsgLoading,
121
121
  // ActionSatisfaction,
122
- AssociationIntention,
122
+ AssociationIntention,
123
123
  /* VoiceComponent,*/
124
124
  TicketMessage,
125
125
  // AsserDeatils,
@@ -130,12 +130,11 @@ export default {
130
130
  // VoiceCompontent,
131
131
  AiGuide,
132
132
  AnswerVoice,
133
- FormTemplate,
133
+ // FormTemplate,
134
134
  // FormTemplate,
135
135
  // FileType,
136
136
  // ChatContent,
137
137
  AnswerDocknowledge,
138
- MyEditor
139
138
  },
140
139
  props: {
141
140
  messages: Array
@@ -26,7 +26,7 @@
26
26
  </div>
27
27
  </template>
28
28
  <script>
29
- import {ossConfig,uploadImageByBase64} from "../assets/js/AliyunlssUtil";
29
+ import { putObject } from "../assets/js/obsBrowser";
30
30
 
31
31
  export default {
32
32
  name: "ask_video",
@@ -86,7 +86,10 @@
86
86
  console.debug('img.src',output)
87
87
  let base64 = canvas.toDataURL("image/png")
88
88
  let blob = that.dataURLtoFile(base64,'name')
89
- let promise = uploadImageByBase64(ossConfig,blob);
89
+ // let promise = uploadImageByBase64(ossConfig,blob);
90
+ const file = new File([blob], 'name', { type: 'text/plain', lastModified: Date.now() });
91
+ console.debug('file',file)
92
+ let promise = putObject(file);
90
93
  promise.then((res)=>{
91
94
  console.debug("upload base64 reslut",res);
92
95
  if (res&&res.url){
@@ -63,20 +63,13 @@
63
63
  v-if="item.formField.type==='TEXTAREA'&& item.fieldId!=='workorder_description'"
64
64
  ></el-input>
65
65
  <div v-else-if="item.fieldId === 'workorder_description'">
66
- <!-- <ckeditor
66
+ <ckeditor
67
67
  :editor="ckeditor.editor"
68
68
  v-model="item.value"
69
69
  :config="{...ckeditor.editorConfig,placeholder:item.formField.extInfo && item.formField.extInfo.placeholder?item.formField.extInfo.placeholder:'请输入'}"
70
70
  @ready="(editor)=>currentEditor=editor"
71
71
  @focus="(zh,editor)=>currentEditor=editor"
72
- ></ckeditor> -->
73
- <MyEditor
74
- v-model="item.value"
75
- :placeholder="item.formField.extInfo && item.formField.extInfo.placeholder?item.formField.extInfo.placeholder:'请输入'"
76
- @fileUploadCallback="desUploadImageAndFile"
77
- :havToolbar="mainId !== '8b9bd566e3e64156ab764b19defc9d48' && mainId !== '0b73521f96e4486aaf6be42932bd7b07'">
78
- </MyEditor>
79
- <!-- @input="(value) =>{item.value = value}" -->
72
+ ></ckeditor>
80
73
  <file-list-view :attachmentList="attachmentList" @attachDeleteAttch="attachDeleteAttch"></file-list-view>
81
74
  </div>
82
75
  <el-date-picker
@@ -352,20 +345,13 @@
352
345
  <i class="el-icon-warning-outline"></i>
353
346
  </span>
354
347
  </div>
355
- <!-- <ckeditor
348
+ <ckeditor
356
349
  :editor="ckeditor.editor"
357
350
  v-model="item.value"
358
351
  @ready="(editor)=>currentEditor=editor"
359
352
  @focus="(zh,editor)=>currentEditor=editor"
360
353
  :config="{...ckeditor.editorConfig,placeholder:item.formField.extInfo && item.formField.extInfo.placeholder?item.formField.extInfo.placeholder:'请输入'}"
361
- ></ckeditor> -->
362
- <MyEditor
363
- v-model="item.value"
364
- :placeholder="item.formField.extInfo && item.formField.extInfo.placeholder?item.formField.extInfo.placeholder:'请输入'"
365
- @fileUploadCallback="desUploadImageAndFile"
366
- :havToolbar="mainId !== '8b9bd566e3e64156ab764b19defc9d48' && mainId !== '0b73521f96e4486aaf6be42932bd7b07' "
367
- >
368
- </MyEditor>
354
+ ></ckeditor>
369
355
  <file-list-view :attachmentList="attachmentList" @attachDeleteAttch="attachDeleteAttch"></file-list-view>
370
356
  </div>
371
357
  </div>
@@ -861,14 +847,20 @@
861
847
  <script>
862
848
  /* eslint-disable */
863
849
  import { forMatTime } from "./utils/format_date";
850
+
864
851
  let that
865
852
  import {multipartUpload,ossFileUrl} from "./utils/AliyunIssUtil";
866
- import MyEditor from './MyEditor'
853
+ import {MyCustomUploadAdapterPlugin} from "./utils/ckeditor";
854
+ // import MyimageUpload from './utils/ckeditorImageUpload/plugin-image'
855
+ import MyFileUpload from './utils/ckeditorfileUpload/plugin_file'
856
+ import CKEDITOR from 'ckeditor'
857
+
867
858
  import myPopup from "./myPopup.vue";
868
859
  import Tree from '../components/tree'
869
860
  import selectPopup from '../components/popup'
870
861
  import fileListView from './fielListView.vue'
871
862
  import { uniqueData } from './utils/math_utils'
863
+ import { putObject } from "../assets/js/obsBrowser";
872
864
  export default {
873
865
  name: "formTemplate",
874
866
  data() {
@@ -953,6 +945,21 @@ export default {
953
945
  },
954
946
  hideUploadEdit:false,
955
947
  limitNum:1,
948
+ ckeditor: {
949
+ editor: CKEDITOR.ClassicEditor,
950
+ editorConfig: {
951
+ extraPlugins: [MyFileUpload,MyCustomUploadAdapterPlugin],
952
+ toolbar: [
953
+ 'MyFileUpload'
954
+ ],
955
+ askPluginListener:[
956
+ {
957
+ event: 'UPLOAD',
958
+ process: this.desUploadImageAndFile,
959
+ }
960
+ ]
961
+ },
962
+ },
956
963
  refShowPicker:false,
957
964
  refTemplateList:{},
958
965
  refList:{},
@@ -1194,8 +1201,7 @@ export default {
1194
1201
  myPopup,
1195
1202
  Tree,
1196
1203
  selectPopup,
1197
- fileListView,
1198
- MyEditor
1204
+ fileListView
1199
1205
  },
1200
1206
  mounted() {
1201
1207
 
@@ -1214,10 +1220,9 @@ export default {
1214
1220
  // }
1215
1221
  // })
1216
1222
  // }
1217
- // if (this.mainId == '8b9bd566e3e64156ab764b19defc9d48' || this.mainId == '0b73521f96e4486aaf6be42932bd7b07'){
1218
- // this.ckeditor.editorConfig.toolbar = []
1219
-
1220
- // }
1223
+ if (this.mainId == '8b9bd566e3e64156ab764b19defc9d48' || this.mainId == '0b73521f96e4486aaf6be42932bd7b07'){
1224
+ this.ckeditor.editorConfig.toolbar = []
1225
+ }
1221
1226
  if (this.mainId == '90df4764122240de939331d372546c28'){
1222
1227
  this.isBaiLi = true;
1223
1228
  }
@@ -1645,21 +1650,24 @@ export default {
1645
1650
  status:'',
1646
1651
  url:''
1647
1652
  }
1648
- let res = multipartUpload(
1649
- this.ossConfig,
1650
- file,
1651
- null,
1652
- imageInfo
1653
- );
1654
- res.then((res) => {
1653
+ // let res = multipartUpload(
1654
+ // this.ossConfig,
1655
+ // file,
1656
+ // null,
1657
+ // imageInfo
1658
+ // );
1659
+ let resp = putObject(file);
1660
+ resp.then((res) => {
1655
1661
  console.log("upload result:", res);
1656
1662
  // let filePath = res.name;
1657
- imageData.urls.push({
1663
+ let obj = {
1658
1664
  name:file.name,
1659
- url:ossFileUrl(this.ossConfig, res.name),
1665
+ url:res.url,
1660
1666
  status:'success'
1661
- })
1662
- imageInfo.url = ossFileUrl(this.ossConfig, res.name)
1667
+ }
1668
+ imageData.urls.push(obj)
1669
+ // imageInfo.url = ossFileUrl(this.ossConfig, res.name)
1670
+ imageInfo.url = res.url;
1663
1671
  imageInfo.status='success'
1664
1672
  imageInfo.name=file.name
1665
1673
  for (let j=0;j<this.extInfoFieldValue[this.filedId].length;j++){
@@ -2571,13 +2579,14 @@ export default {
2571
2579
  progress: 0,
2572
2580
  },
2573
2581
  };*/
2574
- let res = multipartUpload(
2575
- this.ossConfig,
2576
- file,
2577
- null,
2578
- imgInfo
2579
- );
2580
- res.then((res) => {
2582
+ // let res = multipartUpload(
2583
+ // this.ossConfig,
2584
+ // file,
2585
+ // null,
2586
+ // imgInfo
2587
+ // );
2588
+ let ress = putObject(file)
2589
+ ress.then((res) => {
2581
2590
  console.debug("upload result:", res);
2582
2591
  // let filePath = res.name;
2583
2592
  /* imageData.content.progress = 1;
@@ -2585,7 +2594,7 @@ export default {
2585
2594
  ossFileUrl(this.ossConfig, res.name)
2586
2595
  );
2587
2596
  console.log('imageData',imageData)*/
2588
- imgInfo.url = ossFileUrl(this.ossConfig, res.name)
2597
+ imgInfo.url = res.url
2589
2598
  imgInfo.status='success'
2590
2599
  if (data.file){
2591
2600
  imgInfo.name = data.file.name
@@ -1,6 +1,7 @@
1
1
  /* eslint-disable */
2
2
  import {multipartUpload, ossFileUrl} from "./AliyunIssUtil";
3
3
  import { v4 as uuidv4 } from "uuid";
4
+ import { putObject } from "../../assets/js/obsBrowser";
4
5
  const ossConfig = {
5
6
  region: "oss-cn-zhangjiakou",
6
7
  //云账号AccessKey有所有API访问权限,建议遵循阿里云安全最佳实践,创建并使用STS方式来进行API访问
@@ -55,14 +56,16 @@ class MyUploadAdapter {
55
56
  let imgInfo = {
56
57
  url:'',
57
58
  }
58
- let res = multipartUpload(
59
- ossConfig,
60
- file,
61
- null,
62
- imgInfo
63
- );
59
+ // let res = multipartUpload(
60
+ // ossConfig,
61
+ // file,
62
+ // null,
63
+ // imgInfo
64
+ // );
65
+ let res = putObject(file);
64
66
  res.then(resp=>{
65
- imgInfo.url = ossFileUrl(ossConfig, resp.name)
67
+ // imgInfo.url = ossFileUrl(ossConfig, resp.name)
68
+ imgInfo.url = resp.url;
66
69
  let root = this.editor.model.document.getRoot()
67
70
  let children = root.getChildren()
68
71
  for(let child of children){
@@ -0,0 +1,112 @@
1
+ import Command from "@ckeditor/ckeditor5-core/src/command";
2
+ import { multipartUpload, ossFileUrl } from "../AliyunIssUtil";
3
+ import { putObject } from "../../../assets/js/obsBrowser";
4
+ const ossConfig = {
5
+ region: "oss-cn-zhangjiakou",
6
+ //云账号AccessKey有所有API访问权限,建议遵循阿里云安全最佳实践,创建并使用STS方式来进行API访问
7
+ accessKeyId: "LTAI4G3QtdEdwkEbihBngAsK",
8
+ accessKeySecret: "OwgdVfc5PeCkIgqIdug660xmiSPchn",
9
+ // stsToken: '<Your securityToken(STS)>',
10
+ bucket: "guoranopen-zjk",
11
+ }
12
+ export default class ImageCommand extends Command {
13
+ refresh() {
14
+ this.isEnabled = true;
15
+ }
16
+ execute(file) {
17
+ if (file){
18
+ this.forEachFiles(file.file)
19
+ return
20
+ }
21
+ var inputObj = document.createElement('input')
22
+ inputObj.setAttribute('id', '_ef');
23
+ inputObj.setAttribute('type', 'file');
24
+ inputObj.setAttribute('accept','image/jpeg,image/png,image/gif,image/bmp,image/webp,image/tiff')
25
+ inputObj.setAttribute("style", 'visibility:hidden');
26
+ document.body.appendChild(inputObj);
27
+ inputObj.click();
28
+ inputObj.onchange = () => {
29
+ // 循环上传文件
30
+ let files = inputObj.files;
31
+ for (let index = 0; index < files.length; index++) {
32
+ const filed = files[index];
33
+ let command = this.editor.commands.get("insertAskComponent");
34
+ command.execute({
35
+ tag: "span-editable",
36
+ options: {
37
+ name: filed.name + '正在上传...',
38
+ data: index,
39
+ editable:false,
40
+ type:'upload'
41
+ },
42
+ })
43
+ this.upload(filed).then(res =>{
44
+ // let command = this.editor.commands.get("insertAskComponent");
45
+ command.execute({
46
+ tag: "img",
47
+ options: {
48
+ width:'100%',
49
+ alt: filed.name + index,
50
+ src: res.default
51
+ },
52
+ });
53
+ })
54
+ }
55
+ }
56
+ }
57
+ forEachFiles(files){
58
+ for (let index = 0; index < files.length; index++) {
59
+ const filed = files[index];
60
+ let command = this.editor.commands.get("insertAskComponent");
61
+ command.execute({
62
+ tag: "span-editable",
63
+ options: {
64
+ name: filed.name + '正在上传...',
65
+ data: index,
66
+ editable: false,
67
+ type: 'upload'
68
+ },
69
+ })
70
+ this.upload(filed).then(res => {
71
+ // let command = this.editor.commands.get("insertAskComponent");
72
+ command.execute({
73
+ tag: "img",
74
+ options: {
75
+ width: '100%',
76
+ alt: filed.name + index,
77
+ src: res.default
78
+ },
79
+ });
80
+ })
81
+ }
82
+ }
83
+ upload(file) {
84
+ return new Promise((resolve) => {
85
+ /* this._initRequest();
86
+ this._initListeners( resolve, reject, file );
87
+ this._sendRequest( file );*/
88
+ this.uploadFile(file, resolve)
89
+ })
90
+ }
91
+ uploadFile(file, resolve) {
92
+ let imgInfo = {
93
+ url: '',
94
+ }
95
+ // let res = multipartUpload(
96
+ // ossConfig,
97
+ // file,
98
+ // null,
99
+ // imgInfo
100
+ // );
101
+ let res = putObject(file)
102
+ console.log(res,'resprespresp');
103
+ res.then(resp => {
104
+ imgInfo.url = resp.url;
105
+ console.log(resp,'resprespresp');
106
+ console.log(imgInfo)
107
+ resolve({
108
+ default: imgInfo.url
109
+ })
110
+ })
111
+ }
112
+ }
@@ -0,0 +1,12 @@
1
+ import Plugin from "@ckeditor/ckeditor5-core/src/plugin";
2
+ import ImageCommand from "./command";
3
+ export default class MyimageUpload extends Plugin {
4
+ static get pluginName() {
5
+ return "imageUpload";
6
+ }
7
+ init() {
8
+ const editor = this.editor;
9
+ // 注册一个 BoldCommand 命令
10
+ editor.commands.add('imageUpload', new ImageCommand(editor));
11
+ }
12
+ }
@@ -0,0 +1,12 @@
1
+ import Plugin from '@ckeditor/ckeditor5-core/src/plugin';
2
+ import ToolbarUI from './toolbar-ui'
3
+ import ImageUpload from './editing'
4
+
5
+ export default class MyimageUpload extends Plugin {
6
+ static get requires() {
7
+ return [ImageUpload, ToolbarUI];
8
+ }
9
+ static get pluginName() {
10
+ return 'MyimageUpload';
11
+ }
12
+ }
@@ -0,0 +1,41 @@
1
+ /* eslint-disable */
2
+ import Plugin from "@ckeditor/ckeditor5-core/src/plugin";
3
+ import ButtonView from "@ckeditor/ckeditor5-ui/src/button/buttonview";
4
+ // import aoteman from "@ckeditor/ckeditor5-basic-styles/theme/icons/bold.svg";
5
+
6
+ // console.log(aoteman.replace('/',''));
7
+ export default class BoldToolbarUI extends Plugin {
8
+ init() {
9
+ this._createToolbarButton();
10
+ }
11
+
12
+ _createToolbarButton() {
13
+ const editor = this.editor;
14
+ const command = editor.commands.get('imageUpload');
15
+ editor.ui.componentFactory.add('MyimageUpload', (locale) => {
16
+ const view = new ButtonView(locale);
17
+ view.set({
18
+ label: '上传图片',
19
+ tooltip: true,
20
+ withText: true, // 在按钮上展示 label
21
+ // icon:`<svg version="1.1" id="图层_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
22
+ // viewBox="0 0 200 200" style="enable-background:new 0 0 200 200;" xml:space="preserve">
23
+ // <path d="M182,4.2H18c-9.9,0-18,8-18,18l0,0v156c0.2,9.7,8.3,17.5,18,17.5h164c9.7,0,17.8-7.8,18-17.5v-156C200,12.3,192,4.2,182,4.2
24
+ // z M152.5,101.2c-3.1-2.3-7.5-2.3-10.6,0l-31.1,26.1L67.9,58.5c-3.4-3.7-8.9-3.9-12.6-0.6c-0.2,0.2-0.3,0.3-0.6,0.6L18,99.3V22.2h164
25
+ // v91.3L152.5,101.2z" fill="#333333"/>
26
+ // <path d="M145.8,38.3c-14,0-25.3,11.3-25.3,25.3s11.3,25.3,25.3,25.3s25.3-11.3,25.3-25.3l0,0C171.1,49.6,159.7,38.3,145.8,38.3z
27
+ // M145.8,70.3c-4,0-7.3-3.2-7.3-7.3s3.2-7.3,7.3-7.3s7.3,3.2,7.3,7.3c0.2,4-2.8,7.4-6.8,7.6c-0.1,0-0.3,0-0.4,0V70.3z" fill="#333333"/>
28
+ // </svg>`,
29
+ class:'icon'
30
+ });
31
+
32
+ // console.log(Template);
33
+ // 将按钮的状态关联到命令对应值上
34
+ view.bind("isOn", "isEnabled").to(command, "value", "isEnabled");
35
+ // 点击按钮时触发相应命令
36
+ this.listenTo(view, "execute", () => editor.execute('imageUpload'));
37
+ return view;
38
+
39
+ })
40
+ }
41
+ }
@@ -0,0 +1,175 @@
1
+ import Command from "@ckeditor/ckeditor5-core/src/command";
2
+ import { v4 as uuidv4 } from "uuid";
3
+ import { putObject } from "../../../assets/js/obsBrowser";
4
+
5
+ function findListener(askPluginListeners, type) {
6
+ for (let i = 0, len = askPluginListeners.length; i < len; i++) {
7
+ if (askPluginListeners[i].event === type) {
8
+ return askPluginListeners[i];
9
+ }
10
+ }
11
+ }
12
+
13
+ export default class FileCommand extends Command {
14
+ refresh() {
15
+ this.isEnabled = true;
16
+ }
17
+ execute(file) {
18
+ if (file){
19
+ this.forEachFiles(file.file)
20
+ return
21
+ }
22
+ var inputObj = document.createElement('input')
23
+ inputObj.setAttribute('id', '_ef');
24
+ inputObj.setAttribute('type', 'file');
25
+ inputObj.setAttribute('accept','*')
26
+ inputObj.setAttribute('multiple', true)
27
+ inputObj.setAttribute("style", 'visibility:hidden');
28
+ document.body.appendChild(inputObj);
29
+ inputObj.click();
30
+ inputObj.onchange = () => {
31
+ // 循环上传文件
32
+ let files = inputObj.files;
33
+ for (let index = 0; index < files.length; index++) {
34
+ const filed = files[index];
35
+ let uid = uuidv4()
36
+ let command = this.editor.commands.get("insertAskComponent");
37
+ const listeners = this.editor.config.get('askPluginListener');
38
+ let beforeButtonInsert = findListener(listeners, "UPLOAD");
39
+ if(filed.type.includes('image')) {
40
+ if(this.editor.uploadImg) {
41
+ this.editor.uploadImg.push(uid)
42
+ } else {
43
+ this.editor.uploadImg = []
44
+ this.editor.uploadImg.push(uid)
45
+ }
46
+ this.ImgUploadCallback({ command, filed, uid, index, beforeButtonInsert})
47
+ } else {
48
+ this.FileUploadCallback({ command, filed, uid ,beforeButtonInsert})
49
+ }
50
+ }
51
+ }
52
+ }
53
+ ImgUploadCallback({command, filed, uid, index}){
54
+ command.execute({
55
+ tag: "span-editable",
56
+ options: {
57
+ name: filed.name + '正在上传...',
58
+ data: uid,
59
+ editable:false,
60
+ type:'upload'
61
+ },
62
+ })
63
+ this.upload(filed).then(res =>{
64
+ this.delChildrenNode('image')
65
+ command.execute({
66
+ tag: "img",
67
+ options: {
68
+ width:'100%',
69
+ alt: filed.name + index,
70
+ src: res.default
71
+ },
72
+ });
73
+ this.editor.execute('insertParagraph', {
74
+ position: this.editor.model.document.selection.focus
75
+ })
76
+ })
77
+ }
78
+ FileUploadCallback({filed, uid, beforeButtonInsert}) {
79
+ beforeButtonInsert.process({
80
+ type: "UPLOAD",
81
+ param:{
82
+ uid:uid,
83
+ type:'pending',
84
+ name:filed.name
85
+ }
86
+ });
87
+ this.upload(filed).then(res =>{
88
+ beforeButtonInsert.process({
89
+ type: "UPLOAD",
90
+ param:{
91
+ uid: uid,
92
+ name:filed.name,
93
+ type:'success',
94
+ url: res.default
95
+ }
96
+ })
97
+ })
98
+ }
99
+ delChildrenNode(type) {
100
+ let root = this.editor.model.document.getRoot()
101
+ let children = root.getChildren()
102
+ for(let child of children){
103
+ console.log(child._children._nodes,'child._children._nodes');
104
+ for (let index = 0; index < child._children._nodes.length; index++) {
105
+ if(child._children._nodes[index].name == 'askComponentPlaceholderContainer'){
106
+ if(child._children._nodes[index]._children._nodes[0]) {
107
+ let attrs = child._children._nodes[index]._children._nodes[0]._attrs
108
+ if(attrs) {
109
+ let attrsList = [...attrs.keys()]
110
+ for (let j = 0; j < attrsList.length; j++) {
111
+ if(attrsList[j] == 'data') {
112
+ if(type == 'file') {
113
+ this.editor.uploadImg = this.editor.uploadImg.filter(id =>{return id != attrs.get(attrsList[j]).id })
114
+ } else {
115
+ this.editor.uploadImg = this.editor.uploadImg.filter(id =>{return id != attrs.get(attrsList[j]) })
116
+ }
117
+ }
118
+ }
119
+ }
120
+ this.editor.model.change(writer => {
121
+ writer.remove(child._children._nodes[index]._children._nodes[0]);
122
+ });
123
+ }
124
+ }
125
+ }
126
+ }
127
+ }
128
+ forEachFiles(files){
129
+ for (let index = 0; index < files.length; index++) {
130
+ const filed = files[index];
131
+ this.upload(filed).then(res =>{
132
+ // 需要回调通知父组件 上传成功
133
+ let command = this.editor.commands.get("insertAskComponent");
134
+ command.execute({
135
+ tag: "span-editable",
136
+ options: {
137
+ name: filed.name,
138
+ data: res.default,
139
+ editable:false,
140
+ type:'MyFile'
141
+ },
142
+ })
143
+ })
144
+ }
145
+ }
146
+
147
+ upload(file) {
148
+ return new Promise((resolve) => {
149
+ /* this._initRequest();
150
+ this._initListeners( resolve, reject, file );
151
+ this._sendRequest( file );*/
152
+ this.uploadFile(file, resolve)
153
+ })
154
+ }
155
+ uploadFile(file, resolve) {
156
+ let imgInfo = {
157
+ url: '',
158
+ }
159
+ // let res = multipartUpload(
160
+ // ossConfig,
161
+ // file,
162
+ // null,
163
+ // imgInfo
164
+ // );
165
+ let res = putObject(file);
166
+ res.then(resp => {
167
+ // imgInfo.url = ossFileUrl(ossConfig, resp.name)
168
+ imgInfo.url = resp.url;
169
+ resolve({
170
+ name: resp.name,
171
+ default: imgInfo.url
172
+ })
173
+ })
174
+ }
175
+ }
@@ -0,0 +1,12 @@
1
+ import Plugin from "@ckeditor/ckeditor5-core/src/plugin";
2
+ import FileCommand from "./common";
3
+ export default class MyFileUpload extends Plugin {
4
+ static get pluginName() {
5
+ return "fileUpload";
6
+ }
7
+ init() {
8
+ const editor = this.editor;
9
+ // 注册一个 BoldCommand 命令
10
+ editor.commands.add('fileUpload', new FileCommand(editor));
11
+ }
12
+ }
@@ -0,0 +1,12 @@
1
+ import Plugin from '@ckeditor/ckeditor5-core/src/plugin';
2
+ import ToolbarUI from './toolbar_ui'
3
+ import FieldUpload from './editing'
4
+
5
+ export default class MyFileUpload extends Plugin {
6
+ static get requires() {
7
+ return [FieldUpload, ToolbarUI];
8
+ }
9
+ static get pluginName() {
10
+ return 'MyFileUpload';
11
+ }
12
+ }
@@ -0,0 +1,35 @@
1
+ import Plugin from "@ckeditor/ckeditor5-core/src/plugin";
2
+ import ButtonView from "@ckeditor/ckeditor5-ui/src/button/buttonview";
3
+ // import aoteman from "@ckeditor/ckeditor5-basic-styles/theme/icons/bold.svg";
4
+ // import aoteman from '../../assets/image/2.jpg'
5
+
6
+ // console.log(aoteman.replace('/',''));
7
+ export default class BoldToolbarUI extends Plugin {
8
+ init() {
9
+ this._createToolbarButton();
10
+ }
11
+
12
+ _createToolbarButton() {
13
+ const editor = this.editor;
14
+ const command = editor.commands.get('fileUpload');
15
+ editor.ui.componentFactory.add('MyFileUpload', (locale) => {
16
+ const view = new ButtonView(locale);
17
+ view.set({
18
+ label: '上传图片或附件',
19
+ tooltip: true,
20
+ withText: true, // 在按钮上展示 label
21
+ // icon:`<svg t="1674962541538" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="30473" width="14" height="14"><path d="M81.92 432.64L0 732.672V156.672C0 126.976 24.064 102.4 54.272 102.4h256c14.336 0 27.648 5.632 38.4 15.872l110.08 110.08c2.048 2.048 4.608 3.072 7.68 3.072h385.024c29.696 0 54.272 24.064 54.272 54.272v75.776H176.128c-44.544 0-82.944 28.672-94.208 71.168z m931.328-7.168c-9.728-13.824-26.112-20.992-43.008-20.992H175.616c-24.064 0-45.568 16.384-51.712 39.936L12.288 852.992c-7.68 28.672 8.704 58.368 37.888 66.048 4.608 1.024 9.216 2.048 14.336 2.048h794.112c24.064 0 45.568-16.384 51.712-39.936l111.616-409.088c4.608-16.384 1.024-33.28-8.704-46.592z" p-id="30474"></path></svg>`,
22
+ // icon:'<svg t="1674984294045" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" style="width: 20px !important;height: 18px !important;" p-id="30878" ><path d="M94.72 444.928L14.848 737.792V175.616C14.848 146.432 38.4 122.88 67.584 122.88H317.44c13.824 0 27.136 5.632 37.376 15.36l107.52 107.52c2.048 2.048 4.608 3.072 7.68 3.072h375.808c29.184 0 52.736 23.552 52.736 52.736v73.728h-711.68c-43.52 0-80.896 28.16-92.16 69.632zM1003.52 437.76c-9.728-13.312-25.6-20.48-41.984-20.48H186.368c-23.552 0-44.544 15.872-50.688 38.912L26.624 855.04c-7.68 28.16 8.704 56.832 36.864 64.512 4.608 1.024 9.216 2.048 13.824 2.048h775.168c23.552 0 44.544-15.872 50.688-38.912l109.056-399.36c4.608-15.872 1.024-32.768-8.704-45.568z" p-id="30879"></path></svg>',
23
+ icon:`<svg t="1703581982515" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="74840" width="200" height="200"><path d="M566.839921 866.857572V983.050833c0 22.522042-7.677969 33.271198-29.688146 37.877979-18.427125 4.094917-37.366115 3.583052-55.281375-2.047458-17.403396-5.63051-24.057636-15.867802-24.057636-33.271198v-410.003534c0-7.166104-1.535594-9.213563-9.213562-9.213562-80.36274 0.511865-330.152658 0-410.515399 0-19.450854 0-29.688146-7.166104-34.294927-26.105094-5.118646-19.450854-5.118646-39.925438 0.511865-58.864427 5.118646-16.891531 15.355938-23.545771 32.759333-23.545771h412.562857c7.166104 0 8.189833-1.535594 8.189833-8.189834V41.219994c0-25.081365 7.166104-34.806792 32.247469-38.901708 18.93899-3.583052 38.389844-3.583052 56.305105 4.094917 13.820344 5.63051 20.474583 15.867802 20.474583 30.711875v412.562856c0 6.65424 1.535594 8.189833 8.189833 8.189834h406.932346c23.545771 0 33.783063 7.677969 38.901709 30.711875 4.094917 18.427125 4.094917 37.366115-2.047458 55.281375-5.118646 16.379667-15.355938 23.033906-32.247469 23.033907h-410.515398c-7.166104 0-10.237292 1.023729-9.725428 9.725427 0.511865 40.437302 0.511865 249.789918 0.511865 290.22722z" p-id="74841"></path></svg>`
24
+ });
25
+
26
+ // console.log(Template);
27
+ // 将按钮的状态关联到命令对应值上
28
+ view.bind("isOn", "isEnabled").to(command, "value", "isEnabled");
29
+ // 点击按钮时触发相应命令
30
+ this.listenTo(view, "execute", () => editor.execute('fileUpload'));
31
+ return view;
32
+
33
+ })
34
+ }
35
+ }
package/src/main.js CHANGED
@@ -10,6 +10,9 @@ import 'video.js/dist/video-js.css'
10
10
  import Vant from 'vant';
11
11
  import 'vant/lib/index.css';
12
12
 
13
+ import CKEditor from '@ckeditor/ckeditor5-vue2';
14
+ Vue.use(CKEditor);
15
+
13
16
  /*import VConsole from 'vconsole'
14
17
  const vConsole = new VConsole();
15
18
  Vue.use(vConsole);*/
package/vue.config.js CHANGED
@@ -49,6 +49,7 @@ module.exports = {
49
49
  // 不去 node_modules 中找,而是去找 全局变量 ELEMENT
50
50
  // 'element-ui': 'ELEMENT',
51
51
  // 'vant': 'Vant',
52
+ 'ckeditor': 'ClassicEditor',
52
53
  },
53
54
  },
54
55
 
@@ -1,345 +0,0 @@
1
- <template>
2
- <div class="my_editor">
3
- <div class="editor_head" v-if="havToolbar">
4
- <button class="button" @click="handleUpdate">
5
- <svg
6
- t="1703581982515"
7
- class="icon"
8
- viewBox="0 0 1024 1024"
9
- version="1.1"
10
- xmlns="http://www.w3.org/2000/svg"
11
- p-id="74840"
12
- width="200"
13
- height="200"
14
- >
15
- <path
16
- d="M566.839921 866.857572V983.050833c0 22.522042-7.677969 33.271198-29.688146 37.877979-18.427125 4.094917-37.366115 3.583052-55.281375-2.047458-17.403396-5.63051-24.057636-15.867802-24.057636-33.271198v-410.003534c0-7.166104-1.535594-9.213563-9.213562-9.213562-80.36274 0.511865-330.152658 0-410.515399 0-19.450854 0-29.688146-7.166104-34.294927-26.105094-5.118646-19.450854-5.118646-39.925438 0.511865-58.864427 5.118646-16.891531 15.355938-23.545771 32.759333-23.545771h412.562857c7.166104 0 8.189833-1.535594 8.189833-8.189834V41.219994c0-25.081365 7.166104-34.806792 32.247469-38.901708 18.93899-3.583052 38.389844-3.583052 56.305105 4.094917 13.820344 5.63051 20.474583 15.867802 20.474583 30.711875v412.562856c0 6.65424 1.535594 8.189833 8.189833 8.189834h406.932346c23.545771 0 33.783063 7.677969 38.901709 30.711875 4.094917 18.427125 4.094917 37.366115-2.047458 55.281375-5.118646 16.379667-15.355938 23.033906-32.247469 23.033907h-410.515398c-7.166104 0-10.237292 1.023729-9.725428 9.725427 0.511865 40.437302 0.511865 249.789918 0.511865 290.22722z"
17
- p-id="74841"
18
- />
19
- </svg>
20
- 上传图片或附件
21
- </button>
22
- </div>
23
- <div
24
- class="editor_content"
25
- id="my_editor_content"
26
- v-html="text"
27
- contenteditable
28
- ref="editorContent"
29
- @focus="ischecked = true"
30
- @blur="blurFn"
31
- @input="changeInput"
32
- :data-placeholder="placeholder"
33
- ></div>
34
- </div>
35
- </template>
36
-
37
- <script>
38
- import { v4 as uuidv4 } from "uuid";
39
- import { multipartUpload, ossFileUrl } from "./utils/AliyunIssUtil";
40
-
41
- export default {
42
- props: ["value", "placeholder", "havToolbar"],
43
- data () {
44
- return {
45
- ossConfig: {
46
- region: "oss-cn-zhangjiakou",
47
- //云账号AccessKey有所有API访问权限,建议遵循阿里云安全最佳实践,创建并使用STS方式来进行API访问
48
- accessKeyId: "LTAI4G3QtdEdwkEbihBngAsK",
49
- accessKeySecret: "OwgdVfc5PeCkIgqIdug660xmiSPchn",
50
- // stsToken: '<Your securityToken(STS)>',
51
- bucket: "guoranopen-zjk",
52
- },
53
- ischecked: false,
54
- text: ''
55
- }
56
- },
57
- watch: {
58
- value () {
59
- // 解决光标跳动BUG
60
- if (!this.ischecked) {
61
- this.text = this.value
62
- }
63
- }
64
- },
65
- methods: {
66
- blurFn (e) {
67
- this.ischecked = false
68
- this.text = this.value
69
- e.view.blur()
70
- },
71
- changeInput (e) {
72
- this.$emit("input", e.target.innerHTML)
73
- },
74
- handleUpdate () {
75
- let inputObj = document.createElement('input')
76
- inputObj.setAttribute('id', '_ef');
77
- inputObj.setAttribute('type', 'file');
78
- inputObj.setAttribute('accept', '*')
79
- inputObj.setAttribute('multiple', true)
80
- inputObj.setAttribute("style", 'visibility:hidden');
81
- document.body.appendChild(inputObj);
82
- inputObj.click();
83
- inputObj.onchange = () => {
84
- // 循环上传文件
85
- let files = inputObj.files;
86
- for (let index = 0; index < files.length; index++) {
87
- const file = files[index];
88
- let uid = uuidv4()
89
- // let command = this.editor.commands.get("insertAskComponent");
90
- // const listeners = this.editor.config.get('askPluginListener');
91
- // let beforeButtonInsert = findListener(listeners, "UPLOAD");
92
- if (file.type.includes('image')) {
93
- // if (this.editor.uploadImg) {
94
- // this.editor.uploadImg.push(uid)
95
- // } else {
96
- // this.editor.uploadImg = []
97
- // this.editor.uploadImg.push(uid)
98
- // }
99
- this.imgUploadCallback(file, uid, index)
100
- } else {
101
- this.fileUploadCallback(file, uid)
102
- }
103
- }
104
- }
105
- },
106
- appenNode (type, uid, value) {
107
- let node = document.createElement(type)
108
- node.setAttribute("uid", uid)
109
- if (type == 'img') {
110
- node.setAttribute("src", value)
111
- node.setAttribute("class", 'image')
112
- setTimeout(() => {
113
- this.appenNode('div', '', '')
114
- })
115
- }
116
- if (type == 'div' && uid) {
117
- node.innerText = value
118
- node.setAttribute("class", 'loading')
119
- setTimeout(() => {
120
- this.appenNode('div', '', '')
121
- })
122
- }
123
- if (type == 'div' && !uid) {
124
- node.setAttribute("class", 'wrap')
125
- }
126
- this.$refs.editorContent.appendChild(node)
127
- },
128
- deleteNode (uid) {
129
- console.log(uid);
130
- try {
131
- let node = document.querySelector("[uid=" + uid + ']')
132
- if (node) {
133
- this.$refs.editorContent.removeChild(node)
134
- }
135
- } catch {
136
- console.error("未找到该节点");
137
- }
138
- },
139
- imgUploadCallback (file, uid, index) {
140
- console.log(file, uid, index);
141
- this.appenNode("div", "div" + index + uid, file.name + "正在上传,请稍后...")
142
- this.upload(file).then(res => {
143
- this.appenNode('img', "img" + index + uid, res.default)
144
- this.deleteNode("div" + index + uid)
145
- })
146
- },
147
- upload (file) {
148
- return new Promise((resolve) => {
149
- this.uploadFile(file, resolve)
150
- })
151
- },
152
- uploadFile (file, resolve) {
153
- let imgInfo = {
154
- url: '',
155
- }
156
- let res = multipartUpload(
157
- this.ossConfig,
158
- file,
159
- null,
160
- imgInfo
161
- );
162
- res.then(resp => {
163
- imgInfo.url = ossFileUrl(this.ossConfig, resp.name)
164
- resolve({
165
- name: resp.name,
166
- default: imgInfo.url
167
- })
168
- })
169
- },
170
- fileUploadCallback (file, uid) {
171
- this.$emit("fileUploadCallback", {
172
- param: {
173
- uid: uid,
174
- type: 'pending',
175
- name: file.name
176
- }
177
- })
178
- this.upload(file).then(res => {
179
- this.$emit("fileUploadCallback", {
180
- param: {
181
- uid: uid,
182
- name: file.name,
183
- type: 'success',
184
- url: res.default
185
- }
186
- })
187
- })
188
- },
189
-
190
- },
191
- mounted () {
192
- this.$nextTick(() => {
193
- let myEditorContent = this.$refs.editorContent
194
- console.log(myEditorContent, 'myEditorContent');
195
- myEditorContent.addEventListener("paste", (e) => {
196
- let { files } = e.clipboardData
197
- console.log(files, e.clipboardData, 'filesfilesfilesfiles');
198
- if (files.length > 0) {
199
- for (let index = 0; index < files.length; index++) {
200
- let uid = uuidv4()
201
- if (files[index].type.indexOf('image') != -1) {
202
- this.imgUploadCallback(files[index], uid, index)
203
- e.preventDefault();
204
- } else {
205
- this.fileUploadCallback(files[index], uid)
206
- e.preventDefault();
207
- }
208
- }
209
- }
210
- })
211
- myEditorContent.addEventListener("dragenter", function () {
212
- });
213
- myEditorContent.addEventListener("dragover", function (e) {
214
- e.preventDefault();
215
- });
216
- myEditorContent.addEventListener("drop", (e) => {
217
- e.preventDefault();
218
- let files = e.dataTransfer.files; // 这个就相当于文件上传组件
219
- if (files.length > 0) {
220
- for (let index = 0; index < files.length; index++) {
221
- let uid = uuidv4()
222
- if (files[index].type.indexOf('image') != -1) {
223
- this.imgUploadCallback(files[index], uid, index)
224
- e.preventDefault();
225
- } else {
226
- this.fileUploadCallback(files[index], uid)
227
- e.preventDefault();
228
- }
229
- }
230
- }
231
- }, false);
232
- })
233
-
234
- }
235
- }
236
- </script>
237
-
238
- <style lang="less" scoped>
239
- .my_editor {
240
- width: 100%;
241
- border: 1px solid #e0e6f7;
242
- border-radius: 9px !important;
243
- background: #ffffff;
244
- /deep/.editor_content {
245
- border-bottom-left-radius: 9px !important;
246
- border-bottom-right-radius: 9px !important;
247
- padding: 10px;
248
- box-sizing: border-box;
249
- min-height: 150px !important;
250
- font-size: 14px !important;
251
- outline: none;
252
- div {
253
- margin-bottom: 8px;
254
- white-space: pre-wrap;
255
- }
256
- .image {
257
- height: 140px;
258
- object-fit: contain;
259
- }
260
- // .image{
261
- // outline: 3px solid #366aff;
262
- // }
263
- .loading {
264
- background: rgba(0, 89, 255, 0.2);
265
- display: inline-block;
266
- padding: 2px 5px;
267
- border-radius: 3px;
268
- padding-left: 20px;
269
- position: relative;
270
- font-size: 12px;
271
- -webkit-user-modify: read-only;
272
- -moz-user-modify: read-only;
273
- }
274
- .loading::after {
275
- content: '';
276
- background-image: url(../assets/image/building.png);
277
- background-size: 100%;
278
- width: 15px;
279
- height: 15px;
280
- position: absolute;
281
- top: 3px;
282
- left: 2px;
283
- color: #366aff;
284
- -webkit-animation: rotate 1.5s linear infinite;
285
- animation: rotate 1.5s linear infinite;
286
- }
287
- .wrap {
288
- height: 1px;
289
- width: 100%;
290
- }
291
- }
292
- .editor_content:focus {
293
- box-shadow: 2px 2px 3px rgba(0, 0, 0, 0.1) inset, 0, 0;
294
- }
295
- .editor_content:empty::before {
296
- content: attr(data-placeholder);
297
- color: #b3b3b3;
298
- font-size: 14px;
299
- }
300
- .editor_head {
301
- display: flex;
302
- align-items: center;
303
- width: 100%;
304
- height: 38px;
305
- padding: 0 10px;
306
- padding-left: 3px;
307
- box-sizing: border-box;
308
- color: #366aff;
309
- font-size: 14px;
310
- border-bottom: 1px solid #e0e6f7;
311
-
312
- .button {
313
- padding: 5px 8px;
314
- background: #ffffff;
315
- border: none;
316
- border-radius: 2px;
317
- svg {
318
- fill: #366aff;
319
- width: 12px !important;
320
- height: 12px !important;
321
- }
322
- }
323
- .button:focus {
324
- // box-shadow: var(--ck-focus-outer-shadow),0 0;
325
- outline: none;
326
- background: #f0f0f0;
327
- transition: box-shadow 0.2s ease-in-out, border 0.2s ease-in-ou;
328
- }
329
- .button:active {
330
- border: 1px solid #366aff;
331
- }
332
- }
333
- }
334
- @keyframes rotate {
335
- 0% {
336
- -webkit-transform: rotate(0deg);
337
- transform: rotate(0deg);
338
- }
339
-
340
- 100% {
341
- -webkit-transform: rotate(360deg);
342
- transform: rotate(360deg);
343
- }
344
- }
345
- </style>