yks-element 1.0.4 → 1.0.5

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.
Files changed (190) hide show
  1. package/README.md +7 -3
  2. package/lib/theme-chalk/common.css +1 -1
  3. package/lib/theme-chalk/index.css +1 -1
  4. package/lib/theme-chalk/paginations.css +1 -1
  5. package/lib/theme-chalk/selects.css +1 -1
  6. package/lib/yks.js +1 -1
  7. package/package.json +1 -3
  8. package/lib/theme-chalk/topic.css +0 -1
  9. package/packages/Dialog/index.js +0 -8
  10. package/packages/Dialog/src/index.vue +0 -89
  11. package/packages/Multimedia/index.js +0 -8
  12. package/packages/Multimedia/src/index.vue +0 -136
  13. package/packages/Pagination/index.js +0 -8
  14. package/packages/Pagination/src/index.vue +0 -111
  15. package/packages/Scrollbar/index.js +0 -8
  16. package/packages/Scrollbar/src/index.vue +0 -20
  17. package/packages/Select/index.js +0 -8
  18. package/packages/Select/src/index.vue +0 -350
  19. package/packages/Select/src/option.vue +0 -29
  20. package/packages/Table/index.js +0 -8
  21. package/packages/Table/src/index.vue +0 -141
  22. package/packages/Tinymce/index.js +0 -8
  23. package/packages/Tinymce/src/config.js +0 -25
  24. package/packages/Tinymce/src/index.vue +0 -450
  25. package/packages/Topic/index.js +0 -23
  26. package/packages/Topic/src/attachment.vue +0 -114
  27. package/packages/Topic/src/audioFrequency.vue +0 -114
  28. package/packages/Topic/src/clozeFillInBlanks.vue +0 -237
  29. package/packages/Topic/src/compound.vue +0 -191
  30. package/packages/Topic/src/config.js +0 -132
  31. package/packages/Topic/src/fillInBlanks.vue +0 -242
  32. package/packages/Topic/src/indefiniteChoice.vue +0 -0
  33. package/packages/Topic/src/judgment.vue +0 -110
  34. package/packages/Topic/src/matching.vue +0 -0
  35. package/packages/Topic/src/multiple.vue +0 -163
  36. package/packages/Topic/src/pictureAnswer.vue +0 -113
  37. package/packages/Topic/src/shortAnswer.vue +0 -124
  38. package/packages/Topic/src/single.vue +0 -163
  39. package/packages/UploadFile/index.js +0 -8
  40. package/packages/UploadFile/src/index.vue +0 -358
  41. package/packages/Video/index.js +0 -8
  42. package/packages/Video/src/index.vue +0 -204
  43. package/packages/assets/mixins/topic.js +0 -137
  44. package/packages/assets/utils/index.js +0 -83
  45. package/packages/assets/utils/topic.js +0 -132
  46. package/packages/icon/default/icons.js +0 -182
  47. package/packages/icon/default/icons.min.js +0 -1
  48. package/packages/icon/default/index.js +0 -7
  49. package/packages/icon/ks-pdf.png +0 -0
  50. package/packages/icon/ks-ppt.png +0 -0
  51. package/packages/icon/ks-word.png +0 -0
  52. package/packages/icon/ks-xslx.png +0 -0
  53. package/packages/icon/music-bg.png +0 -0
  54. package/packages/icon/video-bg.png +0 -0
  55. package/packages/index.js +0 -221
  56. package/packages/option/index.js +0 -6
  57. package/packages/styles/_mixin.scss +0 -93
  58. package/packages/styles/_variables.scss +0 -40
  59. package/packages/styles/alert.scss +0 -147
  60. package/packages/styles/aside.scss +0 -7
  61. package/packages/styles/autocomplete.scss +0 -80
  62. package/packages/styles/avatar.scss +0 -51
  63. package/packages/styles/backtop.scss +0 -22
  64. package/packages/styles/badge.scss +0 -57
  65. package/packages/styles/base.scss +0 -2
  66. package/packages/styles/breadcrumb-item.scss +0 -0
  67. package/packages/styles/breadcrumb.scss +0 -55
  68. package/packages/styles/button-group.scss +0 -0
  69. package/packages/styles/button.scss +0 -262
  70. package/packages/styles/buttons.scss +0 -59
  71. package/packages/styles/calendar.scss +0 -79
  72. package/packages/styles/card.scss +0 -32
  73. package/packages/styles/carousel-item.scss +0 -50
  74. package/packages/styles/carousel.scss +0 -161
  75. package/packages/styles/cascader-panel.scss +0 -120
  76. package/packages/styles/cascader.scss +0 -182
  77. package/packages/styles/checkbox-button.scss +0 -0
  78. package/packages/styles/checkbox-group.scss +0 -0
  79. package/packages/styles/checkbox.scss +0 -359
  80. package/packages/styles/col.scss +0 -156
  81. package/packages/styles/collapse-item.scss +0 -0
  82. package/packages/styles/collapse.scss +0 -63
  83. package/packages/styles/color-picker.scss +0 -384
  84. package/packages/styles/common/popup.scss +0 -42
  85. package/packages/styles/common/transition.scss +0 -99
  86. package/packages/styles/common/var.scss +0 -1028
  87. package/packages/styles/common.scss +0 -204
  88. package/packages/styles/container.scss +0 -14
  89. package/packages/styles/date-picker/date-picker.scss +0 -97
  90. package/packages/styles/date-picker/date-range-picker.scss +0 -101
  91. package/packages/styles/date-picker/date-table.scss +0 -151
  92. package/packages/styles/date-picker/month-table.scss +0 -82
  93. package/packages/styles/date-picker/picker-panel.scss +0 -117
  94. package/packages/styles/date-picker/picker.scss +0 -197
  95. package/packages/styles/date-picker/time-picker.scss +0 -85
  96. package/packages/styles/date-picker/time-range-picker.scss +0 -31
  97. package/packages/styles/date-picker/time-spinner.scss +0 -110
  98. package/packages/styles/date-picker/year-table.scss +0 -51
  99. package/packages/styles/date-picker.scss +0 -12
  100. package/packages/styles/descriptions-item.scss +0 -42
  101. package/packages/styles/descriptions.scss +0 -111
  102. package/packages/styles/dialog.scss +0 -123
  103. package/packages/styles/display.scss +0 -12
  104. package/packages/styles/divider.scss +0 -47
  105. package/packages/styles/drawer.scss +0 -219
  106. package/packages/styles/dropdown-item.scss +0 -0
  107. package/packages/styles/dropdown-menu.scss +0 -0
  108. package/packages/styles/dropdown.scss +0 -182
  109. package/packages/styles/element-ui.scss +0 -135
  110. package/packages/styles/element-variables.scss +0 -794
  111. package/packages/styles/element.scss +0 -86
  112. package/packages/styles/empty.scss +0 -45
  113. package/packages/styles/fonts/element-icons.ttf +0 -0
  114. package/packages/styles/fonts/element-icons.woff +0 -0
  115. package/packages/styles/fonts/iconfont.ttf +0 -0
  116. package/packages/styles/fonts/iconfont.woff +0 -0
  117. package/packages/styles/footer.scss +0 -8
  118. package/packages/styles/form-item.scss +0 -0
  119. package/packages/styles/form.scss +0 -167
  120. package/packages/styles/header.scss +0 -8
  121. package/packages/styles/icon.scss +0 -1167
  122. package/packages/styles/icons.scss +0 -69
  123. package/packages/styles/image.scss +0 -179
  124. package/packages/styles/index.scss +0 -18
  125. package/packages/styles/infinite-scroll.scss +0 -0
  126. package/packages/styles/infiniteScroll.scss +0 -0
  127. package/packages/styles/input-number.scss +0 -180
  128. package/packages/styles/input.scss +0 -360
  129. package/packages/styles/link.scss +0 -81
  130. package/packages/styles/loading.scss +0 -96
  131. package/packages/styles/main.scss +0 -12
  132. package/packages/styles/menu-item-group.scss +0 -0
  133. package/packages/styles/menu-item.scss +0 -0
  134. package/packages/styles/menu.scss +0 -289
  135. package/packages/styles/message-box.scss +0 -226
  136. package/packages/styles/message.scss +0 -120
  137. package/packages/styles/mixins/_button.scss +0 -81
  138. package/packages/styles/mixins/config.scss +0 -4
  139. package/packages/styles/mixins/function.scss +0 -44
  140. package/packages/styles/mixins/mixins.scss +0 -190
  141. package/packages/styles/mixins/utils.scss +0 -39
  142. package/packages/styles/multimedia.scss +0 -58
  143. package/packages/styles/notification.scss +0 -99
  144. package/packages/styles/option-group.scss +0 -42
  145. package/packages/styles/option.scss +0 -36
  146. package/packages/styles/page-header.scss +0 -41
  147. package/packages/styles/pagination.scss +0 -295
  148. package/packages/styles/paginations.scss +0 -33
  149. package/packages/styles/popconfirm.scss +0 -16
  150. package/packages/styles/popover.scss +0 -40
  151. package/packages/styles/popper.scss +0 -101
  152. package/packages/styles/progress.scss +0 -141
  153. package/packages/styles/radio-button.scss +0 -113
  154. package/packages/styles/radio-group.scss +0 -9
  155. package/packages/styles/radio.scss +0 -199
  156. package/packages/styles/rate.scss +0 -49
  157. package/packages/styles/reset.scss +0 -79
  158. package/packages/styles/result.scss +0 -61
  159. package/packages/styles/row.scss +0 -43
  160. package/packages/styles/scrollbar.scss +0 -72
  161. package/packages/styles/scrollbars.scss +0 -5
  162. package/packages/styles/select-dropdown.scss +0 -62
  163. package/packages/styles/select.scss +0 -152
  164. package/packages/styles/selects.scss +0 -98
  165. package/packages/styles/skeleton-item.scss +0 -84
  166. package/packages/styles/skeleton.scss +0 -40
  167. package/packages/styles/slider.scss +0 -250
  168. package/packages/styles/spinner.scss +0 -44
  169. package/packages/styles/step.scss +0 -317
  170. package/packages/styles/steps.scss +0 -20
  171. package/packages/styles/submenu.scss +0 -0
  172. package/packages/styles/switch.scss +0 -116
  173. package/packages/styles/tab-pane.scss +0 -0
  174. package/packages/styles/table-column.scss +0 -97
  175. package/packages/styles/table.scss +0 -564
  176. package/packages/styles/tables.scss +0 -45
  177. package/packages/styles/tabs.scss +0 -602
  178. package/packages/styles/tag.scss +0 -163
  179. package/packages/styles/time-picker.scss +0 -8
  180. package/packages/styles/time-select.scss +0 -37
  181. package/packages/styles/timeline-item.scss +0 -86
  182. package/packages/styles/timeline.scss +0 -14
  183. package/packages/styles/tinymce.scss +0 -43
  184. package/packages/styles/tooltip.scss +0 -141
  185. package/packages/styles/topic.scss +0 -57
  186. package/packages/styles/transfer.scss +0 -227
  187. package/packages/styles/tree.scss +0 -123
  188. package/packages/styles/upload.scss +0 -603
  189. package/packages/styles/uploadfile.scss +0 -34
  190. package/packages/styles/video.scss +0 -98
@@ -1,450 +0,0 @@
1
- <template>
2
- <div
3
- :class="{ 'yks-fullscreen': fullscreen }"
4
- class="yks-tinymce-container"
5
- :style="{ width: containerWidth }"
6
- >
7
- <TinymceEditor
8
- :id="tinymceId"
9
- ref="tinymceEditor"
10
- :key="tinymceId"
11
- v-model="tinymceContent"
12
- :init="initOptions"
13
- :class="{ 'tinymce-inline': inline }"
14
- />
15
- <div v-if="fileParams.length !== 0" class="ti-multimedia">
16
- <div
17
- v-for="(values, index) in fileParams"
18
- :key="`fileParams${index}${Math.random()}`"
19
- class="media-file"
20
- >
21
- <yks-multimedia
22
- :data="values"
23
- visibleDel
24
- @delete="handleCloseFile(values, index)"
25
- ></yks-multimedia>
26
- </div>
27
- </div>
28
- <yks-uploadfile
29
- :show.sync="show"
30
- :fileData="fileData"
31
- :title="title"
32
- :uploadFileFunction="uploadFileFunction"
33
- @sure="onSure"
34
- ></yks-uploadfile>
35
- </div>
36
- </template>
37
-
38
- <script>
39
- // Docs: https://armour.github.io/vue-typescript-admin-docs/features/components/rich-editor.html#tinymce
40
- import 'tinymce/tinymce'
41
- import 'tinymce/themes/silver' // Import themes
42
- import 'tinymce/themes/mobile'
43
- import 'tinymce/plugins/advlist' // Any plugins you want to use has to be imported
44
- import 'tinymce/plugins/anchor'
45
- import 'tinymce/plugins/autolink'
46
- import 'tinymce/plugins/autosave'
47
- import 'tinymce/plugins/charmap'
48
- import 'tinymce/plugins/code'
49
- import 'tinymce/plugins/codesample'
50
- import 'tinymce/plugins/directionality'
51
- import 'tinymce/plugins/emoticons'
52
- import 'tinymce/plugins/fullscreen'
53
- import 'tinymce/plugins/hr'
54
- import 'tinymce/plugins/image'
55
- import 'tinymce/plugins/imagetools'
56
- import 'tinymce/plugins/insertdatetime'
57
- import 'tinymce/plugins/link'
58
- import 'tinymce/plugins/lists'
59
- import 'tinymce/plugins/media'
60
- import 'tinymce/plugins/nonbreaking'
61
- import 'tinymce/plugins/noneditable'
62
- import 'tinymce/plugins/pagebreak'
63
- import 'tinymce/plugins/paste'
64
- import 'tinymce/plugins/preview'
65
- import 'tinymce/plugins/print'
66
- import 'tinymce/plugins/save'
67
- import 'tinymce/plugins/searchreplace'
68
- import 'tinymce/plugins/spellchecker'
69
- import 'tinymce/plugins/tabfocus'
70
- import 'tinymce/plugins/table'
71
- import 'tinymce/plugins/template'
72
- import 'tinymce/plugins/textpattern'
73
- import 'tinymce/plugins/visualblocks'
74
- import 'tinymce/plugins/visualchars'
75
- import 'tinymce/plugins/wordcount'
76
- import 'yks/icon/default'
77
- import TinymceEditor from '@tinymce/tinymce-vue' // TinyMCE vue wrapper
78
- // eslint-disable-next-line no-duplicate-imports
79
- import tinymce from 'tinymce/tinymce'
80
- import { uploadAudio, uploadVideo, uploadFile, uploadRecording, plugins, toolbar } from './config'
81
-
82
- import { Loading } from 'element-ui'
83
-
84
- export default {
85
- name: 'YksTinymce',
86
- components: {
87
- TinymceEditor
88
- },
89
- props: {
90
- value: {
91
- required: true
92
- },
93
- /* 语言包 */
94
- language: {
95
- type: String,
96
- default: 'zh_CN'
97
- },
98
- /* 扩展bar */
99
- toolbar: {
100
- type: [String, Array],
101
- default: () => []
102
- },
103
- /* 字数限制 */
104
- charLimit: {
105
- type: Number,
106
- default: 5000
107
- },
108
- /* 插件 */
109
- plugins: {
110
- type: [String, Array],
111
- default: () => []
112
- },
113
- menubar: {
114
- type: String,
115
- default: 'file edit insert view format table'
116
- },
117
- height: {
118
- type: String,
119
- default: '660px'
120
- },
121
- width: {
122
- type: String,
123
- default: 'auto'
124
- },
125
- inline: {
126
- type: Boolean,
127
- default: false
128
- },
129
- /* 音视频数据 */
130
- fileParams: {
131
- type: Array,
132
- default: () => []
133
- },
134
- /*
135
- 上传文件函数
136
- 抛出blobInfo函数
137
- 接收data src
138
- */
139
- uploadFileToHwCloud: {
140
- required: true,
141
- type: Function
142
- },
143
- /*
144
- 上传音视频文件函数
145
- 抛出数组文件信息
146
- 接收data src
147
- */
148
- uploadFileFunction: {
149
- required: true,
150
- type: Function
151
- },
152
- /* 扩展插件 */
153
- externalPlugins: {
154
- type: Object,
155
- default: () => {
156
- return {}
157
- }
158
- }
159
- },
160
- data() {
161
- return {
162
- hasChange: false,
163
- hasInit: false,
164
- fullscreen: false,
165
- isComposition: false,
166
- show: false,
167
- fileData: {
168
- fileType: '',
169
- typeList: [],
170
- fileSize: 0
171
- },
172
- limitNum: 0
173
- }
174
- },
175
- computed: {
176
- tinymceContent: {
177
- get() {
178
- return this.value
179
- },
180
- set(value) {
181
- this.$emit('input', value)
182
- }
183
- },
184
- containerWidth() {
185
- const width = this.width
186
- // Test matches `100`, `'100'`
187
- if (/^[\d]+(\.[\d]+)?$/.test(width.toString())) {
188
- return `${width}px`
189
- }
190
- return width
191
- },
192
- title() {
193
- const params = {
194
- recording: '音频录制',
195
- video: '视频上传',
196
- audio: '音频上传',
197
- file: '文件上传'
198
- }
199
- return params[this.fileData.fileType]
200
- },
201
- mediaTypeList() {
202
- return this.fileParams.map((v) => v.fileType)
203
- },
204
- initOptions() {
205
- return {
206
- selector: `#${this.tinymceId}`,
207
- height: this.height,
208
- charLimit: this.charLimit,
209
- body_class: 'panel-body ',
210
- object_resizing: false,
211
- inline: this.inline,
212
- toolbar: this.toolbar.length > 0 ? this.toolbar : toolbar,
213
- menubar: this.menubar,
214
- plugins: this.plugins.length > 0 ? this.plugins : plugins,
215
- language: this.language,
216
- language_url: `https://pub-static.yks365.net/assets/tinymce/langs/${this.language}.js`,
217
- skin_url: 'https://pub-static.yks365.net/assets/tinymce/skins',
218
- emoticons_database_url:
219
- 'https://pub-static.yks365.net/assets/tinymce/emojis.min.js',
220
- end_container_on_empty_block: true,
221
- powerpaste_word_import: 'clean',
222
- code_dialog_height: 450,
223
- code_dialog_width: 1000,
224
- advlist_bullet_styles: 'square',
225
- advlist_number_styles: 'default',
226
- imagetools_cors_hosts: ['www.tinymce.com', 'codepen.io'],
227
- default_link_target: '_blank',
228
- link_title: false,
229
- nonbreaking_force_tab: true,
230
- branding: false,
231
- convert_urls: false,
232
- resize: false,
233
- elementpath: false,
234
- paste_as_text: false,
235
- paste_data_image: true,
236
- paste_data_images: true,
237
- external_plugins: {
238
- ...this.externalPlugins,
239
- powerpaste: `https://pub-static.yks365.net/assets/tinymce/powerpaste/plugin.min.js`,
240
- 'kityformula-editor': `https://pub-static.yks365.net/assets/tinymce/kityformula-editor/plugin.min.js`
241
- },
242
- images_upload_handler: async (blobInfo, success) => {
243
- const loading = Loading.service({
244
- lock: true,
245
- text: '上传中...',
246
- spinner: 'el-icon-loading',
247
- background: 'rgba(0, 0, 0, 0.7)'
248
- })
249
-
250
- try {
251
- const data = await this.uploadFileToHwCloud(blobInfo)
252
- success(data)
253
- } catch (error) {
254
- console.log(error)
255
- success('')
256
- }
257
- loading.close()
258
- },
259
- paste_preprocess: (e, args) => {
260
- const tinymax = this.charLimit
261
- const text = this.tinymceContent.replace(/(<([^>]+)>)/gi, '')
262
- const contentOnBlur = args.content.replace(/(<([^>]+)>)/gi, '')
263
- // 粘贴字数限制
264
- if (tinymax - text.length < contentOnBlur.length) {
265
- this.$message.error(`长度限制为${tinymax}个字符`)
266
- this.limitNum++
267
- if (tinymax > text.length) {
268
- args.content = contentOnBlur.substr(0, tinymax - text.length)
269
- } else {
270
- args.content = ''
271
- }
272
- }
273
- },
274
- init_instance_callback: (editor) => {
275
- if (this.value) {
276
- editor.setContent(this.value)
277
- }
278
- this.hasInit = true
279
- editor.on('NodeChange Change KeyUp SetContent', () => {
280
- this.hasChange = true
281
- this.$emit('input', editor.getContent())
282
- })
283
- },
284
- setup: (editor) => {
285
- editor.on('FullscreenStateChanged', (e) => {
286
- this.fullscreen = e.state
287
- })
288
- editor.on('compositionstart', () => {
289
- this.isComposition = false
290
- })
291
- editor.on('compositionend', () => {
292
- this.isComposition = true
293
- })
294
- editor.on('input', (e) => {
295
- this.wordLimit(e, editor)
296
- })
297
-
298
- editor.ui.registry.addButton('uploadRecording', {
299
- text: uploadRecording,
300
- onAction: () => {
301
- if (this.mediaTypeList.includes('recording')) {
302
- this.$message.warning('最多选择一种!')
303
- return
304
- }
305
- this.show = true
306
- this.fileData.fileType = 'recording'
307
- this.fileData.typeList = []
308
- this.fileData.fileSize = 600
309
- }
310
- })
311
-
312
- editor.ui.registry.addButton('uploadVideo', {
313
- text: uploadVideo,
314
- onAction: () => {
315
- if (this.mediaTypeList.includes('video')) {
316
- this.$message.warning('最多选择一种!')
317
- return
318
- }
319
- this.fileData.fileType = 'video'
320
- this.fileData.typeList = ['mp4']
321
- this.fileData.fileSize = 20
322
- this.show = true
323
- }
324
- })
325
-
326
- editor.ui.registry.addButton('uploadAudio', {
327
- text: uploadAudio,
328
- onAction: () => {
329
- if (this.mediaTypeList.includes('audio')) {
330
- this.$message.warning('最多选择一种!')
331
- return
332
- }
333
- this.fileData.fileType = 'audio'
334
- this.show = true
335
- this.fileData.typeList = ['mp3']
336
- this.fileData.fileSize = 20
337
- }
338
- })
339
-
340
- editor.ui.registry.addButton('uploadFile', {
341
- text: uploadFile,
342
- onAction: () => {
343
- if (this.mediaTypeList.includes('file')) {
344
- this.$message.warning('最多选择一种!')
345
- return
346
- }
347
- this.fileData.fileType = 'file'
348
- this.fileData.typeList = ['pptx', 'docx', 'pdf', 'xlsx']
349
- this.fileData.fileSize = 20
350
- this.show = true
351
- }
352
- })
353
- }
354
- }
355
- },
356
- tinymceId() {
357
- return 'vue-tinymce-' + Number(new Date()) + String((Math.random() * 1000).toFixed(0))
358
- }
359
- },
360
- destroy() {
361
- const tinymce = window.tinymce.get(this.tinymceId)
362
- tinymce.destroy()
363
- },
364
- methods: {
365
- handleCloseFile(row, index) {
366
- this.$emit('delte', {
367
- row: row,
368
- index: index
369
- })
370
- },
371
- handleFillInBlanks(value, id) {
372
- const editor = this.$refs.tinymceEditor.editor
373
- editor.editorManager.get(editor.id).focus()
374
- tinymce.activeEditor.insertContent(
375
- `<input type="text" class="fill-icon ${id}" disabled readonly value="${value}">`
376
- )
377
- },
378
- deleFillItem(index) {
379
- const el = this.$refs.tinymceEditor.editor
380
- el.editorManager.get(el.id).focus()
381
- const elList =
382
- tinymce.activeEditor && tinymce.activeEditor.iframeElement
383
- ? tinymce.activeEditor.iframeElement.contentWindow &&
384
- tinymce.activeEditor.iframeElement.contentWindow.document.getElementsByTagName(
385
- 'input'
386
- )
387
- : []
388
- elList[index].remove()
389
- for (let i = 0; i < elList.length; i++) {
390
- elList[i].setAttribute('value', i + 1)
391
- }
392
- },
393
- onSure(value) {
394
- this.$emit('change', {
395
- value: this.tinymceContent,
396
- itemAttr: { type: this.fileData.fileType, content: value }
397
- })
398
- },
399
- wordLimit(e, editor) {
400
- const tinymax = editor.settings.charLimit
401
- const text = e.target.innerText
402
- const html = e.target.innerHTML
403
- let last = ''
404
- let lastIndex = ''
405
- let startVal = ''
406
- let endVal = ''
407
- if (text.length === tinymax) {
408
- this.tinymceContent = html
409
- // 兼容输入法有可能会跳过最大值
410
- } else if (!this.isComposition && text.length === tinymax + 1) {
411
- last = text.substr(text.length - 1, 1)
412
- lastIndex = html.lastIndexOf(last)
413
- startVal = html.substring(0, lastIndex)
414
- endVal = html.substring(lastIndex + 1, html.length)
415
- this.tinymceContent = startVal + endVal
416
- }
417
- if (text.length > tinymax) {
418
- e.target.innerHTML = this.tinymceContent
419
- this.keepLastIndex()
420
- editor.focus()
421
- if (!this.limitNum) {
422
- this.$message.error(`长度限制为${tinymax}个字符`)
423
- this.limitNum++
424
- }
425
- } else {
426
- this.limitNum = 0
427
- }
428
- },
429
- keepLastIndex() {
430
- const tinymce = window.tinymce.get(this.tinymceId)
431
- const wind = tinymce.contentWindow
432
- const obj = wind.document.getElementById('tinymce')
433
- if (wind.getSelection) {
434
- // ie11 10 9 ff safari
435
- obj.focus() // 解决ff不获取焦点无法定位问题
436
- const range = wind.getSelection() // 创建range
437
- console.log(range)
438
- range.selectAllChildren(obj) // range 选择obj下所有子内容
439
- range.collapseToEnd() // 光标移至最后
440
- } else if (document.selection) {
441
- // ie10 9 8 7 6 5
442
- const range = document.selection.createRange() // 创建选择对象
443
- range.moveToElementText(obj) // range定位到obj
444
- range.collapse(false) // 光标移至最后
445
- range.select()
446
- }
447
- }
448
- }
449
- }
450
- </script>
@@ -1,23 +0,0 @@
1
- import Single from './src/single'
2
- import Multiple from './src/multiple'
3
- import Judgment from './src/judgment'
4
- import FillInBlanks from './src/fillInBlanks'
5
- import ShortAnswer from './src/shortAnswer'
6
- import PictureAnswer from './src/pictureAnswer'
7
- import Compound from './src/compound'
8
- import AudioFrequency from './src/audioFrequency'
9
- import Attachment from './src/attachment'
10
-
11
- const components = [
12
- Single,
13
- Multiple,
14
- Judgment,
15
- FillInBlanks,
16
- ShortAnswer,
17
- PictureAnswer,
18
- Compound,
19
- AudioFrequency,
20
- Attachment
21
- ]
22
-
23
- export default components
@@ -1,114 +0,0 @@
1
- <template>
2
- <div>
3
- <div class="topic-stem__label required__label">题干</div>
4
- <yks-tinymce
5
- key="itemContent"
6
- v-model="fromData.itemContent"
7
- :toolbar="toolbar"
8
- :plugins="plugins"
9
- :charLimit="topicDataExtent.itemContentLength || 20000"
10
- :fileParams="getFileTypes('stem', fromData.stemAttrs)"
11
- :uploadFileToHwCloud="uploadFileToHwCloud"
12
- :uploadFileFunction="uploadFileFunction"
13
- menubar=""
14
- height="200px"
15
- @change="($event) => getTinymceEdit($event, 'stem')"
16
- @delte="($event) => handleDelteAttrs($event, 'stem', fromData.stemAttrs)"
17
- />
18
- <div class="topic-stem__label required__label">标准答案</div>
19
- <yks-tinymce
20
- key="answer"
21
- v-model="fromData.answer"
22
- :toolbar="toolbar"
23
- :plugins="plugins"
24
- :charLimit="topicDataExtent.answerLength || 5000"
25
- :fileParams="getFileTypes('answer', fromData.answerAttrs)"
26
- :uploadFileToHwCloud="uploadFileToHwCloud"
27
- :uploadFileFunction="uploadFileFunction"
28
- menubar=""
29
- height="200px"
30
- @change="($event) => getTinymceEdit($event, 'answer')"
31
- @delte="($event) => handleDelteAttrs($event, 'answer', fromData.answerAttrs)"
32
- />
33
- <div class="topic-stem__label">答案解析</div>
34
- <yks-tinymce
35
- key="description"
36
- v-model="fromData.description"
37
- :toolbar="toolbar"
38
- :plugins="plugins"
39
- :charLimit="topicDataExtent.descriptionLength || 20000"
40
- :fileParams="getFileTypes('analysis', fromData.descriptionAttrs)"
41
- :uploadFileToHwCloud="uploadFileToHwCloud"
42
- :uploadFileFunction="uploadFileFunction"
43
- menubar=""
44
- height="200px"
45
- @change="($event) => getTinymceEdit($event, 'analysis')"
46
- @delte="($event) => handleDelteAttrs($event, 'analysis', fromData.descriptionAttrs)"
47
- />
48
- </div>
49
- </template>
50
- <script>
51
- import TopicMixins from 'yks/assets/mixins/topic'
52
- import { stemItemType, shortItemType, analysisItemType } from './config'
53
-
54
- export default {
55
- name: 'YksAttachment',
56
- mixins: [TopicMixins],
57
- methods: {
58
- /**
59
- * data 富文本数据
60
- * field 对象名
61
- * type 类型
62
- */
63
- getTinymceEdit(data, type) {
64
- switch (type) {
65
- case 'stem':
66
- data.itemAttr.type = stemItemType[data.itemAttr.type]
67
- this.fromData.itemContent = data.value
68
- if (data.itemAttr.type && data.itemAttr.content) {
69
- this.fromData.stemAttrs.push(data.itemAttr)
70
- }
71
- break
72
- case 'answer':
73
- data.itemAttr.type = shortItemType[data.itemAttr.type]
74
- this.fromData.answer = data.value
75
- if (data.itemAttr.type && data.itemAttr.content) {
76
- this.fromData.answerAttrs.push(data.itemAttr)
77
- }
78
- break
79
- case 'analysis':
80
- data.itemAttr.type = analysisItemType[data.itemAttr.type]
81
- this.fromData.description = data.value
82
-
83
- if (data.itemAttr.type && data.itemAttr.content) {
84
- this.fromData.descriptionAttrs.push(data.itemAttr)
85
- }
86
- break
87
- default:
88
- break
89
- }
90
- this.$emit('change', this.fromData)
91
- },
92
-
93
- handleDelteAttrs(data, type, list, row = {}) {
94
- const listAttrs = list
95
- listAttrs.splice(data.index, 1)
96
- switch (type) {
97
- case 'stem':
98
- this.fromData.stemAttrs = listAttrs
99
- break
100
- case 'answer':
101
- this.fromData.answerAttrs = listAttrs
102
- break
103
- case 'analysis':
104
- this.fromData.descriptionAttrs = listAttrs
105
- break
106
- default:
107
- break
108
- }
109
- this.$emit('change', this.fromData)
110
- }
111
- }
112
- }
113
- </script>
114
-