askbot-dragon 1.4.74 → 1.4.76

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.74",
3
+ "version": "1.4.76",
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
@@ -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,56 @@ 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
+ .ck-widget:hover {
3115
+ outline-color:#366aff;
3116
+ .ck-widget__type-around {
3117
+ display: none;
3118
+ }
3119
+ }
3120
+ .ask-component-img-box {
3121
+ width: auto;
3122
+ height: auto;
3123
+ display: inline-block;
3124
+ }
3125
+ .ask-component-placeholder-span[type=upload] {
3126
+ background-color: rgba(0, 89, 255, 0.2);
3127
+ display: inline-block;
3128
+ padding: 2px 5px;
3129
+ border-radius: 3px;
3130
+ padding-left: 20px;
3131
+ position: relative;
3132
+ }
3133
+ .ask-component-placeholder-span[type=upload]::after {
3134
+ content: '';
3135
+ background-image: url('../assets/image/building.png');
3136
+ background-size: 100%;
3137
+ width: 15px;
3138
+ height: 15px;
3139
+ position: absolute;
3140
+ top: 5px;
3141
+ left: 2px;
3142
+ color: #366AFF;
3143
+ animation: rotate 1.5s linear infinite;
3144
+ }
3145
+ @keyframes rotate {
3146
+ from {
3147
+ transform: rotate(0deg);
3148
+ }
3149
+ to {
3150
+ transform: rotate(360deg);
3151
+ }
3152
+ }
3153
+
3087
3154
  }
3155
+
3088
3156
  .cascader-class{
3089
3157
  padding: 10px 16px;
3090
3158
  }
@@ -1,6 +1,7 @@
1
+ /* eslint-disable */
1
2
  import {multipartUpload, ossFileUrl} from "./AliyunIssUtil";
2
-
3
- const ossConfig={
3
+ import { v4 as uuidv4 } from "uuid";
4
+ const ossConfig = {
4
5
  region: "oss-cn-zhangjiakou",
5
6
  //云账号AccessKey有所有API访问权限,建议遵循阿里云安全最佳实践,创建并使用STS方式来进行API访问
6
7
  accessKeyId: "LTAI4G3QtdEdwkEbihBngAsK",
@@ -18,22 +19,30 @@ class MyUploadAdapter {
18
19
  // 启动上载过程
19
20
  upload() {
20
21
  return this.loader.file
21
- .then( file => new Promise( ( ) => {
22
- /* this._initRequest();
22
+ .then( file => new Promise(() => {
23
+ /* this._initRequest();
23
24
  this._initListeners( resolve, reject, file );
24
25
  this._sendRequest( file );*/
25
26
  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
- },
27
+ let uid = uuidv4()
28
+ command.execute({
29
+ tag: "section",
30
+ options: {
31
+ className: 'self-p-section',
32
+ data: 'self-p-section'
33
+ },
34
+ });
35
+ command.execute({
36
+ tag: "span-editable",
37
+ options: {
38
+ name: file.name + '正在上传...',
39
+ data: uid,
40
+ editable:false,
41
+ type:'upload'
42
+ }
34
43
  })
35
44
  this.uploadFile(file)
36
- } ) );
45
+ }));
37
46
  }
38
47
 
39
48
  // 中止上载过程
@@ -54,19 +63,28 @@ class MyUploadAdapter {
54
63
  );
55
64
  res.then(resp=>{
56
65
  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
- // }
66
+ let root = this.editor.model.document.getRoot()
67
+ let children = root.getChildren()
68
+ for(let child of children){
69
+ for (let index = 0; index < child._children._nodes.length; index++) {
70
+ if(child._children._nodes[index].name == 'askComponentPlaceholderContainer'){
71
+ if(child._children._nodes[index]._children._nodes[0]) {
72
+ let attrs = child._children._nodes[index]._children._nodes[0]._attrs
73
+ if(attrs) {
74
+ let attrsList = [...attrs.keys()]
75
+ for (let j = 0; j < attrsList.length; j++) {
76
+ if(attrsList[j] == 'data') {
77
+ // this.editor.uploadImg = this.editor.uploadImg.filter(id =>{return id != attrs.get(attrsList[j])})
78
+ this.editor.model.change(writer => {
79
+ writer.remove(child._children._nodes[index].parent);
80
+ });
81
+ }
82
+ }
83
+ }
84
+ }
85
+ }
86
+ }
87
+ }
70
88
  let command = this.editor.commands.get("insertAskComponent");
71
89
  command.execute({
72
90
  tag: "img",
@@ -76,9 +94,9 @@ class MyUploadAdapter {
76
94
  src: imgInfo.url
77
95
  },
78
96
  });
79
- // resolve({
80
- // default:imgInfo.url
81
- // })
97
+ this.editor.execute('insertParagraph', {
98
+ position: this.editor.model.document.selection.focus
99
+ })
82
100
  })
83
101
  }
84
102
  // 使用传递给构造函数的URL初始化XMLHttpRequest对象.
@@ -145,6 +163,7 @@ class MyUploadAdapter {
145
163
  function MyCustomUploadAdapterPlugin( editor ) {
146
164
  editor.plugins.get( 'FileRepository' ).createUploadAdapter = ( loader ) => {
147
165
  // 在这里将URL配置为后端上载脚本
166
+ console.log(loader,'loader');
148
167
  return new MyUploadAdapter( loader,editor );
149
168
  }
150
169
  }
@@ -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,99 @@ 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
+ this.editor.execute('insertParagraph', {
82
+ position: this.editor.model.document.selection.focus
83
+ })
84
+ })
85
+ }
86
+ FileUploadCallback({filed, uid, beforeButtonInsert}) {
87
+ beforeButtonInsert.process({
88
+ type: "UPLOAD",
89
+ param:{
90
+ uid:uid,
91
+ type:'pending',
92
+ name:filed.name
93
+ }
94
+ });
95
+ this.upload(filed).then(res =>{
96
+ beforeButtonInsert.process({
97
+ type: "UPLOAD",
98
+ param:{
99
+ uid: uid,
100
+ name:filed.name,
101
+ type:'success',
102
+ url: res.default
103
+ }
104
+ })
105
+ })
106
+ }
107
+ delChildrenNode(type) {
108
+ let root = this.editor.model.document.getRoot()
109
+ let children = root.getChildren()
110
+ for(let child of children){
111
+ console.log(child._children._nodes,'child._children._nodes');
112
+ for (let index = 0; index < child._children._nodes.length; index++) {
113
+ if(child._children._nodes[index].name == 'askComponentPlaceholderContainer'){
114
+ if(child._children._nodes[index]._children._nodes[0]) {
115
+ let attrs = child._children._nodes[index]._children._nodes[0]._attrs
116
+ if(attrs) {
117
+ let attrsList = [...attrs.keys()]
118
+ for (let j = 0; j < attrsList.length; j++) {
119
+ if(attrsList[j] == 'data') {
120
+ if(type == 'file') {
121
+ this.editor.uploadImg = this.editor.uploadImg.filter(id =>{return id != attrs.get(attrsList[j]).id })
122
+ } else {
123
+ this.editor.uploadImg = this.editor.uploadImg.filter(id =>{return id != attrs.get(attrsList[j]) })
124
+ }
125
+ }
126
+ }
127
+ }
128
+ this.editor.model.change(writer => {
129
+ writer.remove(child._children._nodes[index]._children._nodes[0]);
130
+ });
131
+ }
82
132
  }
83
-
84
133
  }
85
134
  }
86
135
  }
87
-
88
136
  forEachFiles(files){
89
137
  for (let index = 0; index < files.length; index++) {
90
138
  const filed = files[index];
@@ -99,7 +147,6 @@ export default class FileCommand extends Command {
99
147
  editable:false,
100
148
  type:'MyFile'
101
149
  },
102
- // src: res.default
103
150
  })
104
151
  })
105
152
  }
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