askbot-dragon 1.4.73 → 1.4.75

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,6 +1,6 @@
1
1
  {
2
2
  "name": "askbot-dragon",
3
- "version": "1.4.73",
3
+ "version": "1.4.75",
4
4
  "scripts": {
5
5
  "serve": "vue-cli-service serve",
6
6
  "build": "vue-cli-service build",
@@ -8,7 +8,7 @@
8
8
  },
9
9
  "dependencies": {
10
10
  "@ckeditor/ckeditor5-ui": "^10.1.0",
11
- "@ckeditor/ckeditor5-vue": "^1.0.3",
11
+ "@ckeditor/ckeditor5-vue2": "^3.0.1",
12
12
  "ali-oss": "^6.2.1",
13
13
  "audio-loader": "^1.0.3",
14
14
  "ckeditor": "^4.12.1",
package/public/index.html CHANGED
@@ -12,7 +12,7 @@
12
12
  <!-- guoran图标 -->
13
13
  <link rel="stylesheet" href="//at.alicdn.com/t/c/font_2913049_qtm7orae3l.css"/>
14
14
  <script src="https://res.wx.qq.com/open/js/jweixin-1.2.0.js"></script>
15
- <script src="https://static.guoranbot.com/ckeditor5-build-classic/0.3.7/build/ckeditor.js"></script>
15
+ <script src="https://guoranopen-zjk.oss-cn-zhangjiakou.aliyuncs.com/ckeditor5-build-classic/0.4.2/build/ckeditor.js"></script>
16
16
 
17
17
  <!-- vue -->
18
18
  <!-- <script src="https://static.guoranbot.com/vue/2.6.11/dist/vue.min.js"></script>
Binary file
@@ -18,7 +18,7 @@
18
18
  {{ msg.content.text }}
19
19
  </template>
20
20
  </div>
21
- <div class="answer-kn-image-box">
21
+ <div v-if="msg.content.images && msg.content.images.length != 0" class="answer-kn-image-box">
22
22
  <img v-for="(imageItem, imageItemIndex) in msg.content.images" style='max-width: 230px;border-radius: 25px;margin-bottom: 15px' :src="imageItem.url" :key="imageItemIndex" alt="" @click="lookAttach(imageItem.url, imageItem, $event)">
23
23
  </div>
24
24
  </div>
@@ -921,6 +921,12 @@ export default {
921
921
  extraPlugins: [MyFileUpload,MyCustomUploadAdapterPlugin],
922
922
  toolbar: [
923
923
  'MyFileUpload'
924
+ ],
925
+ askPluginListener:[
926
+ {
927
+ event: 'UPLOAD',
928
+ process: this.desUploadImageAndFile,
929
+ }
924
930
  ]
925
931
  },
926
932
  },
@@ -2971,7 +2977,23 @@ export default {
2971
2977
  },
2972
2978
  attachDeleteFile(index,fieldId){
2973
2979
  this.extInfoFieldValue[fieldId].splice(index,1)
2974
- }
2980
+ },
2981
+ desUploadImageAndFile({type, param}) {
2982
+ if(param.type == 'pending') {
2983
+ this.attachmentList.push({
2984
+ url: '',
2985
+ name: param.name,
2986
+ id: param.uid
2987
+ })
2988
+ } else {
2989
+ this.attachmentList.forEach(item =>{
2990
+ if(item.id == param.uid) {
2991
+ item.url = param.url
2992
+ delete item.uid
2993
+ }
2994
+ })
2995
+ }
2996
+ },
2975
2997
  },
2976
2998
  watch:{
2977
2999
  formFieldValus:{
@@ -2984,7 +3006,7 @@ export default {
2984
3006
  handler(val){
2985
3007
  let newVal = ''
2986
3008
  newVal = val.replace(/ style=".*?"/g, '');
2987
- newVal = this.getAttach(newVal)
3009
+ // newVal = this.getAttach(newVal)
2988
3010
  if (this.currentEditor){
2989
3011
  if (this.workOrderDestail){
2990
3012
  this.$nextTick(() =>{
@@ -3081,10 +3103,50 @@ export default {
3081
3103
  /deep/.ck-editor__editable{
3082
3104
  img{
3083
3105
  height: 140px;
3084
- width: 80%;
3106
+ // width: 80%;
3085
3107
  object-fit: contain;
3086
3108
  }
3109
+ .ck-widget_selected {
3110
+ .ck-widget__type-around {
3111
+ display: none;
3112
+ }
3113
+ }
3114
+ .ask-component-img-box {
3115
+ width: auto;
3116
+ height: auto;
3117
+ display: inline-block;
3118
+ }
3119
+ .ask-component-placeholder-span[type=upload] {
3120
+ background-color: rgba(0, 89, 255, 0.2);
3121
+ display: inline-block;
3122
+ padding: 2px 5px;
3123
+ border-radius: 3px;
3124
+ padding-left: 20px;
3125
+ position: relative;
3126
+ }
3127
+ .ask-component-placeholder-span[type=upload]::after {
3128
+ content: '';
3129
+ background-image: url('../assets/image/building.png');
3130
+ background-size: 100%;
3131
+ width: 15px;
3132
+ height: 15px;
3133
+ position: absolute;
3134
+ top: 5px;
3135
+ left: 2px;
3136
+ color: #366AFF;
3137
+ animation: rotate 1.5s linear infinite;
3138
+ }
3139
+ @keyframes rotate {
3140
+ from {
3141
+ transform: rotate(0deg);
3142
+ }
3143
+ to {
3144
+ transform: rotate(360deg);
3145
+ }
3146
+ }
3147
+
3087
3148
  }
3149
+
3088
3150
  .cascader-class{
3089
3151
  padding: 10px 16px;
3090
3152
  }
@@ -1,5 +1,5 @@
1
1
  import {multipartUpload, ossFileUrl} from "./AliyunIssUtil";
2
-
2
+ import { v4 as uuidv4 } from "uuid";
3
3
  const ossConfig={
4
4
  region: "oss-cn-zhangjiakou",
5
5
  //云账号AccessKey有所有API访问权限,建议遵循阿里云安全最佳实践,创建并使用STS方式来进行API访问
@@ -19,21 +19,29 @@ class MyUploadAdapter {
19
19
  upload() {
20
20
  return this.loader.file
21
21
  .then( file => new Promise( ( ) => {
22
- /* this._initRequest();
22
+ /* this._initRequest();
23
23
  this._initListeners( resolve, reject, file );
24
24
  this._sendRequest( file );*/
25
25
  let command = this.editor.commands.get("insertAskComponent");
26
- command.execute({
27
- tag: "span-editable",
28
- options: {
29
- name: file.name + '正在上传...',
30
- data: 0,
31
- editable:false,
32
- type:'upload'
33
- },
26
+ let uid = uuidv4()
27
+ command.execute({
28
+ tag: "section",
29
+ options: {
30
+ className: 'self-p-section',
31
+ data: 'self-p-section'
32
+ },
33
+ });
34
+ command.execute({
35
+ tag: "span-editable",
36
+ options: {
37
+ name: file.name + '正在上传...',
38
+ data: uid,
39
+ editable:false,
40
+ type:'upload'
41
+ },
34
42
  })
35
43
  this.uploadFile(file)
36
- } ) );
44
+ }));
37
45
  }
38
46
 
39
47
  // 中止上载过程
@@ -54,19 +62,28 @@ class MyUploadAdapter {
54
62
  );
55
63
  res.then(resp=>{
56
64
  imgInfo.url = ossFileUrl(ossConfig, resp.name)
57
- // let root = this.editor.model.document.getRoot()
58
- // let children = root.getChildren()
59
- // for(let child of children){
60
- // for (let index = 0; index < child._children._nodes.length; index++) {
61
- // if(child._children._nodes[index].name == 'askComponentPlaceholderContainer'){
62
- // if(child._children._nodes[index]._children._nodes[0]) {
63
- // this.editor.model.change(writer => {
64
- // writer.remove(child._children._nodes[index]._children._nodes[0]);
65
- // });
66
- // }
67
- // }
68
- // }
69
- // }
65
+ let root = this.editor.model.document.getRoot()
66
+ let children = root.getChildren()
67
+ for(let child of children){
68
+ for (let index = 0; index < child._children._nodes.length; index++) {
69
+ if(child._children._nodes[index].name == 'askComponentPlaceholderContainer'){
70
+ if(child._children._nodes[index]._children._nodes[0]) {
71
+ let attrs = child._children._nodes[index]._children._nodes[0]._attrs
72
+ if(attrs) {
73
+ let attrsList = [...attrs.keys()]
74
+ for (let j = 0; j < attrsList.length; j++) {
75
+ if(attrsList[j] == 'data') {
76
+ // this.editor.uploadImg = this.editor.uploadImg.filter(id =>{return id != attrs.get(attrsList[j])})
77
+ this.editor.model.change(writer => {
78
+ writer.remove(child._children._nodes[index].parent);
79
+ });
80
+ }
81
+ }
82
+ }
83
+ }
84
+ }
85
+ }
86
+ }
70
87
  let command = this.editor.commands.get("insertAskComponent");
71
88
  command.execute({
72
89
  tag: "img",
@@ -76,9 +93,6 @@ class MyUploadAdapter {
76
93
  src: imgInfo.url
77
94
  },
78
95
  });
79
- // resolve({
80
- // default:imgInfo.url
81
- // })
82
96
  })
83
97
  }
84
98
  // 使用传递给构造函数的URL初始化XMLHttpRequest对象.
@@ -1,6 +1,7 @@
1
1
  import Command from "@ckeditor/ckeditor5-core/src/command";
2
2
  import { multipartUpload, ossFileUrl } from "../AliyunIssUtil";
3
3
  import { v4 as uuidv4 } from "uuid";
4
+
4
5
  const ossConfig = {
5
6
  region: "oss-cn-zhangjiakou",
6
7
  //云账号AccessKey有所有API访问权限,建议遵循阿里云安全最佳实践,创建并使用STS方式来进行API访问
@@ -10,6 +11,14 @@ const ossConfig = {
10
11
  bucket: "guoranopen-zjk",
11
12
  }
12
13
 
14
+ function findListener(askPluginListeners, type) {
15
+ for (let i = 0, len = askPluginListeners.length; i < len; i++) {
16
+ if (askPluginListeners[i].event === type) {
17
+ return askPluginListeners[i];
18
+ }
19
+ }
20
+ }
21
+
13
22
  export default class FileCommand extends Command {
14
23
  refresh() {
15
24
  this.isEnabled = true;
@@ -18,8 +27,8 @@ export default class FileCommand extends Command {
18
27
  if (file){
19
28
  this.forEachFiles(file.file)
20
29
  return
21
- }
22
- let inputObj = document.createElement('input')
30
+ }
31
+ var inputObj = document.createElement('input')
23
32
  inputObj.setAttribute('id', '_ef');
24
33
  inputObj.setAttribute('type', 'file');
25
34
  inputObj.setAttribute('accept','*')
@@ -31,60 +40,96 @@ export default class FileCommand extends Command {
31
40
  let files = inputObj.files;
32
41
  for (let index = 0; index < files.length; index++) {
33
42
  const filed = files[index];
34
- let command = this.editor.commands.get("insertAskComponent");
43
+ let uid = uuidv4()
44
+ let command = this.editor.commands.get("insertAskComponent");
45
+ const listeners = this.editor.config.get('askPluginListener');
46
+ let beforeButtonInsert = findListener(listeners, "UPLOAD");
35
47
  if(filed.type.includes('image')) {
36
- command.execute({
37
- tag: "span-editable",
38
- options: {
39
- name: filed.name + '正在上传...',
40
- data: index,
41
- editable:false,
42
- type:'upload'
43
- },
44
- })
45
- this.upload(filed).then(res =>{
46
- command.execute({
47
- tag: "img",
48
- options: {
49
- width:'100%',
50
- alt: filed.name + index,
51
- src: res.default
52
- },
53
- });
54
- })
48
+ if(this.editor.uploadImg) {
49
+ this.editor.uploadImg.push(uid)
50
+ } else {
51
+ this.editor.uploadImg = []
52
+ this.editor.uploadImg.push(uid)
53
+ }
54
+ this.ImgUploadCallback({ command, filed, uid, index, beforeButtonInsert})
55
55
  } else {
56
- let uid = uuidv4()
57
- command.execute({
58
- tag: "span-editable",
59
- options: {
60
- name: filed.name,
61
- data: uid,
62
- editable:false,
63
- type:'FileUpload'
64
- },
65
- })
66
- this.upload(filed).then(res =>{
67
- // 需要回调通知父组件 上传成功
68
- let data = JSON.stringify({
69
- id: uid,
70
- default:res.default
71
- })
72
- command.execute({
73
- tag: "span-editable",
74
- options: {
75
- name: filed.name,
76
- data: data ,
77
- editable:false,
78
- type:'MyFile'
79
- },
80
- })
81
- })
56
+ this.FileUploadCallback({ command, filed, uid ,beforeButtonInsert})
57
+ }
58
+ }
59
+ }
60
+ }
61
+ ImgUploadCallback({command, filed, uid, index}){
62
+ command.execute({
63
+ tag: "span-editable",
64
+ options: {
65
+ name: filed.name + '正在上传...',
66
+ data: uid,
67
+ editable:false,
68
+ type:'upload'
69
+ },
70
+ })
71
+ this.upload(filed).then(res =>{
72
+ this.delChildrenNode('image')
73
+ command.execute({
74
+ tag: "img",
75
+ options: {
76
+ width:'100%',
77
+ alt: filed.name + index,
78
+ src: res.default
79
+ },
80
+ });
81
+ })
82
+ }
83
+ FileUploadCallback({filed, uid, beforeButtonInsert}) {
84
+ beforeButtonInsert.process({
85
+ type: "UPLOAD",
86
+ param:{
87
+ uid:uid,
88
+ type:'pending',
89
+ name:filed.name
90
+ }
91
+ });
92
+ this.upload(filed).then(res =>{
93
+ beforeButtonInsert.process({
94
+ type: "UPLOAD",
95
+ param:{
96
+ uid: uid,
97
+ name:filed.name,
98
+ type:'success',
99
+ url: res.default
100
+ }
101
+ })
102
+ })
103
+ }
104
+ delChildrenNode(type) {
105
+ let root = this.editor.model.document.getRoot()
106
+ let children = root.getChildren()
107
+ for(let child of children){
108
+ console.log(child._children._nodes,'child._children._nodes');
109
+ for (let index = 0; index < child._children._nodes.length; index++) {
110
+ if(child._children._nodes[index].name == 'askComponentPlaceholderContainer'){
111
+ if(child._children._nodes[index]._children._nodes[0]) {
112
+ let attrs = child._children._nodes[index]._children._nodes[0]._attrs
113
+ if(attrs) {
114
+ let attrsList = [...attrs.keys()]
115
+ for (let j = 0; j < attrsList.length; j++) {
116
+ if(attrsList[j] == 'data') {
117
+ if(type == 'file') {
118
+ this.editor.uploadImg = this.editor.uploadImg.filter(id =>{return id != attrs.get(attrsList[j]).id })
119
+ } else {
120
+ this.editor.uploadImg = this.editor.uploadImg.filter(id =>{return id != attrs.get(attrsList[j]) })
121
+ }
122
+ }
123
+ }
124
+ }
125
+ this.editor.model.change(writer => {
126
+ writer.remove(child._children._nodes[index]._children._nodes[0]);
127
+ });
128
+ }
82
129
  }
83
-
84
130
  }
85
131
  }
86
132
  }
87
-
88
133
  forEachFiles(files){
89
134
  for (let index = 0; index < files.length; index++) {
90
135
  const filed = files[index];
@@ -99,7 +144,6 @@ export default class FileCommand extends Command {
99
144
  editable:false,
100
145
  type:'MyFile'
101
146
  },
102
- // src: res.default
103
147
  })
104
148
  })
105
149
  }
package/src/main.js CHANGED
@@ -10,9 +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-vue';
14
-
13
+ import CKEditor from '@ckeditor/ckeditor5-vue2';
15
14
  Vue.use(CKEditor);
15
+
16
16
  /*import VConsole from 'vconsole'
17
17
  const vConsole = new VConsole();
18
18
  Vue.use(vConsole);*/
package/vue.config.js CHANGED
@@ -49,7 +49,7 @@ module.exports = {
49
49
  // 不去 node_modules 中找,而是去找 全局变量 ELEMENT
50
50
  // 'element-ui': 'ELEMENT',
51
51
  // 'vant': 'Vant',
52
- 'ckeditor': 'CKEDITOR',
52
+ 'ckeditor': 'ClassicEditor',
53
53
  },
54
54
  },
55
55