yks-element 1.0.324 → 1.0.792
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/README.md +74 -8
- package/lib/theme-chalk/buttons.css +1 -0
- package/lib/theme-chalk/common.css +1 -0
- package/lib/theme-chalk/dialogs.css +1 -0
- package/{packages/Topic/src/indefiniteChoice.vue → lib/theme-chalk/element-variables.css} +0 -0
- package/lib/theme-chalk/elements.css +1 -0
- package/lib/theme-chalk/enlarge.css +1 -0
- package/{packages/styles → lib/theme-chalk}/fonts/element-icons.ttf +0 -0
- package/{packages/styles → lib/theme-chalk}/fonts/element-icons.woff +0 -0
- package/{packages/styles → lib/theme-chalk}/fonts/iconfont.ttf +0 -0
- package/lib/theme-chalk/fonts/iconfont.woff +0 -0
- package/lib/theme-chalk/icons.css +1 -0
- package/lib/theme-chalk/index.css +1 -0
- package/lib/theme-chalk/multimedia.css +1 -0
- package/lib/theme-chalk/paginations.css +1 -0
- package/lib/theme-chalk/scrollbars.css +1 -0
- package/lib/theme-chalk/selects.css +1 -0
- package/lib/theme-chalk/tables.css +1 -0
- package/lib/theme-chalk/tinymce.css +1 -0
- package/lib/theme-chalk/uploadfile.css +1 -0
- package/lib/theme-chalk/video.css +1 -0
- package/{packages/Topic/src/matching.vue → lib/theme-chalk/videoPlayer.css} +0 -0
- package/lib/yks.js +1 -0
- package/package.json +42 -12
- package/lib/fonts/element-icons.535877f5.woff +0 -0
- package/lib/fonts/element-icons.732389de.ttf +0 -0
- package/lib/fonts/iconfont.19124b0d.ttf +0 -0
- package/lib/fonts/iconfont.3ae3dd4e.woff +0 -0
- package/lib/yks.css +0 -1
- package/packages/Button/index.js +0 -8
- package/packages/Button/src/index.vue +0 -78
- package/packages/Dialog/index.js +0 -8
- package/packages/Dialog/src/index.vue +0 -103
- package/packages/Multimedia/index.js +0 -8
- package/packages/Multimedia/src/index.vue +0 -179
- package/packages/Pagination/index.js +0 -8
- package/packages/Pagination/src/index.vue +0 -149
- package/packages/Scrollbar/index.js +0 -8
- package/packages/Scrollbar/src/index.vue +0 -27
- package/packages/Select/index.js +0 -8
- package/packages/Select/src/index.vue +0 -350
- package/packages/Select/src/option.vue +0 -29
- package/packages/Table/index.js +0 -8
- package/packages/Table/src/index.vue +0 -141
- package/packages/Tinymce/index.js +0 -8
- package/packages/Tinymce/src/config.js +0 -25
- package/packages/Tinymce/src/index.vue +0 -500
- package/packages/Topic/index.js +0 -23
- package/packages/Topic/src/attachment.vue +0 -123
- package/packages/Topic/src/audioFrequency.vue +0 -124
- package/packages/Topic/src/clozeFillInBlanks.vue +0 -264
- package/packages/Topic/src/compound.vue +0 -223
- package/packages/Topic/src/config.js +0 -132
- package/packages/Topic/src/fillInBlanks.vue +0 -269
- package/packages/Topic/src/judgment.vue +0 -138
- package/packages/Topic/src/multiple.vue +0 -190
- package/packages/Topic/src/pictureAnswer.vue +0 -124
- package/packages/Topic/src/shortAnswer.vue +0 -133
- package/packages/Topic/src/single.vue +0 -191
- package/packages/UploadFile/index.js +0 -8
- package/packages/UploadFile/src/index.vue +0 -390
- package/packages/Video/index.js +0 -8
- package/packages/Video/src/index.vue +0 -351
- package/packages/assets/mixins/topic.js +0 -137
- package/packages/assets/utils/index.js +0 -83
- package/packages/assets/utils/topic.js +0 -132
- package/packages/icon/default/icons.js +0 -182
- package/packages/icon/default/icons.min.js +0 -1
- package/packages/icon/default/index.js +0 -7
- package/packages/icon/ks-pdf.png +0 -0
- package/packages/icon/ks-ppt.png +0 -0
- package/packages/icon/ks-word.png +0 -0
- package/packages/icon/ks-xslx.png +0 -0
- package/packages/icon/music-bg.png +0 -0
- package/packages/icon/video-bg.png +0 -0
- package/packages/index.js +0 -223
- package/packages/option/index.js +0 -6
- package/packages/styles/_mixin.scss +0 -93
- package/packages/styles/_variables.scss +0 -40
- package/packages/styles/common.scss +0 -200
- package/packages/styles/element-ui.scss +0 -135
- package/packages/styles/element-variables.scss +0 -794
- package/packages/styles/fonts/iconfont.woff +0 -0
- package/packages/styles/icon.scss +0 -69
- package/packages/styles/index.scss +0 -11
- package/packages/styles/select.scss +0 -98
- package/packages/styles/table.scss +0 -45
- package/packages/styles/topic.scss +0 -26
|
@@ -1,500 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div
|
|
3
|
-
:class="{ fullscreen: fullscreen }"
|
|
4
|
-
class="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 '../../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
|
-
import YksUploadfile from '../../UploadFile/index'
|
|
82
|
-
import YksMultimedia from '../../Multimedia/index'
|
|
83
|
-
|
|
84
|
-
import { Loading } from 'element-ui'
|
|
85
|
-
|
|
86
|
-
export default {
|
|
87
|
-
name: 'YksTinymce',
|
|
88
|
-
components: {
|
|
89
|
-
TinymceEditor,
|
|
90
|
-
YksUploadfile,
|
|
91
|
-
YksMultimedia
|
|
92
|
-
},
|
|
93
|
-
props: {
|
|
94
|
-
value: {
|
|
95
|
-
required: true
|
|
96
|
-
},
|
|
97
|
-
/* 语言包 */
|
|
98
|
-
language: {
|
|
99
|
-
type: String,
|
|
100
|
-
default: 'zh_CN'
|
|
101
|
-
},
|
|
102
|
-
/* 扩展bar */
|
|
103
|
-
toolbar: {
|
|
104
|
-
type: [String, Array],
|
|
105
|
-
default: () => []
|
|
106
|
-
},
|
|
107
|
-
/* 字数限制 */
|
|
108
|
-
charLimit: {
|
|
109
|
-
type: Number,
|
|
110
|
-
default: 5000
|
|
111
|
-
},
|
|
112
|
-
/* 插件 */
|
|
113
|
-
plugins: {
|
|
114
|
-
type: [String, Array],
|
|
115
|
-
default: () => []
|
|
116
|
-
},
|
|
117
|
-
menubar: {
|
|
118
|
-
type: String,
|
|
119
|
-
default: 'file edit insert view format table'
|
|
120
|
-
},
|
|
121
|
-
height: {
|
|
122
|
-
type: String,
|
|
123
|
-
default: '660px'
|
|
124
|
-
},
|
|
125
|
-
width: {
|
|
126
|
-
type: String,
|
|
127
|
-
default: 'auto'
|
|
128
|
-
},
|
|
129
|
-
inline: {
|
|
130
|
-
type: Boolean,
|
|
131
|
-
default: false
|
|
132
|
-
},
|
|
133
|
-
/* 音视频数据 */
|
|
134
|
-
fileParams: {
|
|
135
|
-
type: Array,
|
|
136
|
-
default: () => []
|
|
137
|
-
},
|
|
138
|
-
/*
|
|
139
|
-
上传文件函数
|
|
140
|
-
抛出blobInfo函数
|
|
141
|
-
接收data src
|
|
142
|
-
*/
|
|
143
|
-
uploadFileToHwCloud: {
|
|
144
|
-
required: true,
|
|
145
|
-
type: Function
|
|
146
|
-
},
|
|
147
|
-
/*
|
|
148
|
-
上传音视频文件函数
|
|
149
|
-
抛出数组文件信息
|
|
150
|
-
接收data src
|
|
151
|
-
*/
|
|
152
|
-
uploadFileFunction: {
|
|
153
|
-
required: true,
|
|
154
|
-
type: Function
|
|
155
|
-
},
|
|
156
|
-
/* 扩展插件 */
|
|
157
|
-
externalPlugins: {
|
|
158
|
-
type: Object,
|
|
159
|
-
default: () => {
|
|
160
|
-
return {}
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
},
|
|
164
|
-
data() {
|
|
165
|
-
return {
|
|
166
|
-
hasChange: false,
|
|
167
|
-
hasInit: false,
|
|
168
|
-
fullscreen: false,
|
|
169
|
-
isComposition: false,
|
|
170
|
-
show: false,
|
|
171
|
-
fileData: {
|
|
172
|
-
fileType: '',
|
|
173
|
-
typeList: [],
|
|
174
|
-
fileSize: 0
|
|
175
|
-
},
|
|
176
|
-
limitNum: 0
|
|
177
|
-
}
|
|
178
|
-
},
|
|
179
|
-
computed: {
|
|
180
|
-
tinymceContent: {
|
|
181
|
-
get() {
|
|
182
|
-
return this.value
|
|
183
|
-
},
|
|
184
|
-
set(value) {
|
|
185
|
-
this.$emit('input', value)
|
|
186
|
-
}
|
|
187
|
-
},
|
|
188
|
-
containerWidth() {
|
|
189
|
-
const width = this.width
|
|
190
|
-
// Test matches `100`, `'100'`
|
|
191
|
-
if (/^[\d]+(\.[\d]+)?$/.test(width.toString())) {
|
|
192
|
-
return `${width}px`
|
|
193
|
-
}
|
|
194
|
-
return width
|
|
195
|
-
},
|
|
196
|
-
title() {
|
|
197
|
-
const params = {
|
|
198
|
-
recording: '音频录制',
|
|
199
|
-
video: '视频上传',
|
|
200
|
-
audio: '音频上传',
|
|
201
|
-
file: '文件上传'
|
|
202
|
-
}
|
|
203
|
-
return params[this.fileData.fileType]
|
|
204
|
-
},
|
|
205
|
-
mediaTypeList() {
|
|
206
|
-
return this.fileParams.map((v) => v.fileType)
|
|
207
|
-
},
|
|
208
|
-
initOptions() {
|
|
209
|
-
return {
|
|
210
|
-
selector: `#${this.tinymceId}`,
|
|
211
|
-
height: this.height,
|
|
212
|
-
charLimit: this.charLimit,
|
|
213
|
-
body_class: 'panel-body ',
|
|
214
|
-
object_resizing: false,
|
|
215
|
-
inline: this.inline,
|
|
216
|
-
toolbar: this.toolbar.length > 0 ? this.toolbar : toolbar,
|
|
217
|
-
menubar: this.menubar,
|
|
218
|
-
plugins: this.plugins.length > 0 ? this.plugins : plugins,
|
|
219
|
-
language: this.language,
|
|
220
|
-
language_url: `https://pub-static.yks365.net/assets/tinymce/langs/${this.language}.js`,
|
|
221
|
-
skin_url: 'https://pub-static.yks365.net/assets/tinymce/skins',
|
|
222
|
-
emoticons_database_url:
|
|
223
|
-
'https://pub-static.yks365.net/assets/tinymce/emojis.min.js',
|
|
224
|
-
end_container_on_empty_block: true,
|
|
225
|
-
powerpaste_word_import: 'clean',
|
|
226
|
-
code_dialog_height: 450,
|
|
227
|
-
code_dialog_width: 1000,
|
|
228
|
-
advlist_bullet_styles: 'square',
|
|
229
|
-
advlist_number_styles: 'default',
|
|
230
|
-
imagetools_cors_hosts: ['www.tinymce.com', 'codepen.io'],
|
|
231
|
-
default_link_target: '_blank',
|
|
232
|
-
link_title: false,
|
|
233
|
-
nonbreaking_force_tab: true,
|
|
234
|
-
branding: false,
|
|
235
|
-
convert_urls: false,
|
|
236
|
-
resize: false,
|
|
237
|
-
elementpath: false,
|
|
238
|
-
paste_as_text: false,
|
|
239
|
-
paste_data_image: true,
|
|
240
|
-
paste_data_images: true,
|
|
241
|
-
external_plugins: {
|
|
242
|
-
...this.externalPlugins,
|
|
243
|
-
powerpaste: `https://pub-static.yks365.net/assets/tinymce/powerpaste/plugin.min.js`,
|
|
244
|
-
'kityformula-editor': `https://pub-static.yks365.net/assets/tinymce/kityformula-editor/plugin.min.js`
|
|
245
|
-
},
|
|
246
|
-
images_upload_handler: async (blobInfo, success) => {
|
|
247
|
-
const loading = Loading.service({
|
|
248
|
-
lock: true,
|
|
249
|
-
text: '上传中...',
|
|
250
|
-
spinner: 'el-icon-loading',
|
|
251
|
-
background: 'rgba(0, 0, 0, 0.7)'
|
|
252
|
-
})
|
|
253
|
-
|
|
254
|
-
try {
|
|
255
|
-
const data = await this.uploadFileToHwCloud(blobInfo)
|
|
256
|
-
success(data)
|
|
257
|
-
} catch (error) {
|
|
258
|
-
console.log(error)
|
|
259
|
-
success('')
|
|
260
|
-
}
|
|
261
|
-
loading.close()
|
|
262
|
-
},
|
|
263
|
-
paste_preprocess: (e, args) => {
|
|
264
|
-
const tinymax = this.charLimit
|
|
265
|
-
const text = this.tinymceContent.replace(/(<([^>]+)>)/gi, '')
|
|
266
|
-
const contentOnBlur = args.content.replace(/(<([^>]+)>)/gi, '')
|
|
267
|
-
// 粘贴字数限制
|
|
268
|
-
if (tinymax - text.length < contentOnBlur.length) {
|
|
269
|
-
this.$message.error(`长度限制为${tinymax}个字符`)
|
|
270
|
-
this.limitNum++
|
|
271
|
-
if (tinymax > text.length) {
|
|
272
|
-
args.content = contentOnBlur.substr(0, tinymax - text.length)
|
|
273
|
-
} else {
|
|
274
|
-
args.content = ''
|
|
275
|
-
}
|
|
276
|
-
}
|
|
277
|
-
},
|
|
278
|
-
init_instance_callback: (editor) => {
|
|
279
|
-
if (this.value) {
|
|
280
|
-
editor.setContent(this.value)
|
|
281
|
-
}
|
|
282
|
-
this.hasInit = true
|
|
283
|
-
editor.on('NodeChange Change KeyUp SetContent', () => {
|
|
284
|
-
this.hasChange = true
|
|
285
|
-
this.$emit('input', editor.getContent())
|
|
286
|
-
})
|
|
287
|
-
},
|
|
288
|
-
setup: (editor) => {
|
|
289
|
-
editor.on('FullscreenStateChanged', (e) => {
|
|
290
|
-
this.fullscreen = e.state
|
|
291
|
-
})
|
|
292
|
-
editor.on('compositionstart', () => {
|
|
293
|
-
this.isComposition = false
|
|
294
|
-
})
|
|
295
|
-
editor.on('compositionend', () => {
|
|
296
|
-
this.isComposition = true
|
|
297
|
-
})
|
|
298
|
-
editor.on('input', (e) => {
|
|
299
|
-
this.wordLimit(e, editor)
|
|
300
|
-
})
|
|
301
|
-
|
|
302
|
-
editor.ui.registry.addButton('uploadRecording', {
|
|
303
|
-
text: uploadRecording,
|
|
304
|
-
onAction: () => {
|
|
305
|
-
if (this.mediaTypeList.includes('recording')) {
|
|
306
|
-
this.$message.warning('最多选择一种!')
|
|
307
|
-
return
|
|
308
|
-
}
|
|
309
|
-
this.show = true
|
|
310
|
-
this.fileData.fileType = 'recording'
|
|
311
|
-
this.fileData.typeList = []
|
|
312
|
-
this.fileData.fileSize = 600
|
|
313
|
-
}
|
|
314
|
-
})
|
|
315
|
-
|
|
316
|
-
editor.ui.registry.addButton('uploadVideo', {
|
|
317
|
-
text: uploadVideo,
|
|
318
|
-
onAction: () => {
|
|
319
|
-
if (this.mediaTypeList.includes('video')) {
|
|
320
|
-
this.$message.warning('最多选择一种!')
|
|
321
|
-
return
|
|
322
|
-
}
|
|
323
|
-
this.fileData.fileType = 'video'
|
|
324
|
-
this.fileData.typeList = ['mp4']
|
|
325
|
-
this.fileData.fileSize = 20
|
|
326
|
-
this.show = true
|
|
327
|
-
}
|
|
328
|
-
})
|
|
329
|
-
|
|
330
|
-
editor.ui.registry.addButton('uploadAudio', {
|
|
331
|
-
text: uploadAudio,
|
|
332
|
-
onAction: () => {
|
|
333
|
-
if (this.mediaTypeList.includes('audio')) {
|
|
334
|
-
this.$message.warning('最多选择一种!')
|
|
335
|
-
return
|
|
336
|
-
}
|
|
337
|
-
this.fileData.fileType = 'audio'
|
|
338
|
-
this.show = true
|
|
339
|
-
this.fileData.typeList = ['mp3']
|
|
340
|
-
this.fileData.fileSize = 20
|
|
341
|
-
}
|
|
342
|
-
})
|
|
343
|
-
|
|
344
|
-
editor.ui.registry.addButton('uploadFile', {
|
|
345
|
-
text: uploadFile,
|
|
346
|
-
onAction: () => {
|
|
347
|
-
if (this.mediaTypeList.includes('file')) {
|
|
348
|
-
this.$message.warning('最多选择一种!')
|
|
349
|
-
return
|
|
350
|
-
}
|
|
351
|
-
this.fileData.fileType = 'file'
|
|
352
|
-
this.fileData.typeList = ['pptx', 'docx', 'pdf', 'xlsx']
|
|
353
|
-
this.fileData.fileSize = 20
|
|
354
|
-
this.show = true
|
|
355
|
-
}
|
|
356
|
-
})
|
|
357
|
-
}
|
|
358
|
-
}
|
|
359
|
-
},
|
|
360
|
-
tinymceId() {
|
|
361
|
-
return 'vue-tinymce-' + Number(new Date()) + String((Math.random() * 1000).toFixed(0))
|
|
362
|
-
}
|
|
363
|
-
},
|
|
364
|
-
destroy() {
|
|
365
|
-
const tinymce = window.tinymce.get(this.tinymceId)
|
|
366
|
-
tinymce.destroy()
|
|
367
|
-
},
|
|
368
|
-
methods: {
|
|
369
|
-
handleCloseFile(row, index) {
|
|
370
|
-
this.$emit('delte', {
|
|
371
|
-
row: row,
|
|
372
|
-
index: index
|
|
373
|
-
})
|
|
374
|
-
},
|
|
375
|
-
handleFillInBlanks(value, id) {
|
|
376
|
-
const editor = this.$refs.tinymceEditor.editor
|
|
377
|
-
editor.editorManager.get(editor.id).focus()
|
|
378
|
-
tinymce.activeEditor.insertContent(
|
|
379
|
-
`<input type="text" class="fill-icon ${id}" disabled readonly value="${value}">`
|
|
380
|
-
)
|
|
381
|
-
},
|
|
382
|
-
deleFillItem(index) {
|
|
383
|
-
const el = this.$refs.tinymceEditor.editor
|
|
384
|
-
el.editorManager.get(el.id).focus()
|
|
385
|
-
const elList =
|
|
386
|
-
tinymce.activeEditor && tinymce.activeEditor.iframeElement
|
|
387
|
-
? tinymce.activeEditor.iframeElement.contentWindow &&
|
|
388
|
-
tinymce.activeEditor.iframeElement.contentWindow.document.getElementsByTagName(
|
|
389
|
-
'input'
|
|
390
|
-
)
|
|
391
|
-
: []
|
|
392
|
-
elList[index].remove()
|
|
393
|
-
for (let i = 0; i < elList.length; i++) {
|
|
394
|
-
elList[i].setAttribute('value', i + 1)
|
|
395
|
-
}
|
|
396
|
-
},
|
|
397
|
-
onSure(value) {
|
|
398
|
-
this.$emit('change', {
|
|
399
|
-
value: this.tinymceContent,
|
|
400
|
-
itemAttr: { type: this.fileData.fileType, content: value }
|
|
401
|
-
})
|
|
402
|
-
},
|
|
403
|
-
wordLimit(e, editor) {
|
|
404
|
-
const tinymax = editor.settings.charLimit
|
|
405
|
-
const text = e.target.innerText
|
|
406
|
-
const html = e.target.innerHTML
|
|
407
|
-
let last = ''
|
|
408
|
-
let lastIndex = ''
|
|
409
|
-
let startVal = ''
|
|
410
|
-
let endVal = ''
|
|
411
|
-
if (text.length === tinymax) {
|
|
412
|
-
this.tinymceContent = html
|
|
413
|
-
// 兼容输入法有可能会跳过最大值
|
|
414
|
-
} else if (!this.isComposition && text.length === tinymax + 1) {
|
|
415
|
-
last = text.substr(text.length - 1, 1)
|
|
416
|
-
lastIndex = html.lastIndexOf(last)
|
|
417
|
-
startVal = html.substring(0, lastIndex)
|
|
418
|
-
endVal = html.substring(lastIndex + 1, html.length)
|
|
419
|
-
this.tinymceContent = startVal + endVal
|
|
420
|
-
}
|
|
421
|
-
if (text.length > tinymax) {
|
|
422
|
-
e.target.innerHTML = this.tinymceContent
|
|
423
|
-
this.keepLastIndex()
|
|
424
|
-
editor.focus()
|
|
425
|
-
if (!this.limitNum) {
|
|
426
|
-
this.$message.error(`长度限制为${tinymax}个字符`)
|
|
427
|
-
this.limitNum++
|
|
428
|
-
}
|
|
429
|
-
} else {
|
|
430
|
-
this.limitNum = 0
|
|
431
|
-
}
|
|
432
|
-
},
|
|
433
|
-
keepLastIndex() {
|
|
434
|
-
const tinymce = window.tinymce.get(this.tinymceId)
|
|
435
|
-
const wind = tinymce.contentWindow
|
|
436
|
-
const obj = wind.document.getElementById('tinymce')
|
|
437
|
-
if (wind.getSelection) {
|
|
438
|
-
// ie11 10 9 ff safari
|
|
439
|
-
obj.focus() // 解决ff不获取焦点无法定位问题
|
|
440
|
-
const range = wind.getSelection() // 创建range
|
|
441
|
-
console.log(range)
|
|
442
|
-
range.selectAllChildren(obj) // range 选择obj下所有子内容
|
|
443
|
-
range.collapseToEnd() // 光标移至最后
|
|
444
|
-
} else if (document.selection) {
|
|
445
|
-
// ie10 9 8 7 6 5
|
|
446
|
-
const range = document.selection.createRange() // 创建选择对象
|
|
447
|
-
range.moveToElementText(obj) // range定位到obj
|
|
448
|
-
range.collapse(false) // 光标移至最后
|
|
449
|
-
range.select()
|
|
450
|
-
}
|
|
451
|
-
}
|
|
452
|
-
}
|
|
453
|
-
}
|
|
454
|
-
</script>
|
|
455
|
-
|
|
456
|
-
<style lang="scss" scoped>
|
|
457
|
-
.tinymce-container {
|
|
458
|
-
line-height: normal;
|
|
459
|
-
position: relative;
|
|
460
|
-
|
|
461
|
-
.mce-fullscreen {
|
|
462
|
-
z-index: 10000;
|
|
463
|
-
}
|
|
464
|
-
|
|
465
|
-
.editor-custom-btn-container {
|
|
466
|
-
position: absolute;
|
|
467
|
-
top: 6px;
|
|
468
|
-
right: 6px;
|
|
469
|
-
|
|
470
|
-
&.fullscreen {
|
|
471
|
-
position: fixed;
|
|
472
|
-
z-index: 10000;
|
|
473
|
-
}
|
|
474
|
-
}
|
|
475
|
-
|
|
476
|
-
.editor-upload-btn {
|
|
477
|
-
display: inline-block;
|
|
478
|
-
}
|
|
479
|
-
|
|
480
|
-
textarea {
|
|
481
|
-
visibility: hidden;
|
|
482
|
-
z-index: -1;
|
|
483
|
-
}
|
|
484
|
-
.ti-multimedia {
|
|
485
|
-
position: relative;
|
|
486
|
-
display: flex;
|
|
487
|
-
align-items: flex-start;
|
|
488
|
-
flex-wrap: wrap;
|
|
489
|
-
margin-top: 10px;
|
|
490
|
-
}
|
|
491
|
-
|
|
492
|
-
.tinymce-inline {
|
|
493
|
-
padding: 0 20px;
|
|
494
|
-
border: 1px solid #ccc;
|
|
495
|
-
}
|
|
496
|
-
.tox-statusbar__wordcount {
|
|
497
|
-
opacity: 0 !important;
|
|
498
|
-
}
|
|
499
|
-
}
|
|
500
|
-
</style>
|
package/packages/Topic/index.js
DELETED
|
@@ -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,123 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div class="single">
|
|
3
|
-
<div class="single-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="single-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="single-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 YksTinymce from '../../Tinymce/index'
|
|
52
|
-
import TopicMixins from '../../assets/mixins/topic'
|
|
53
|
-
import { stemItemType, shortItemType, analysisItemType } from './config'
|
|
54
|
-
|
|
55
|
-
export default {
|
|
56
|
-
name: 'YksAttachment',
|
|
57
|
-
components: { YksTinymce },
|
|
58
|
-
mixins: [TopicMixins],
|
|
59
|
-
methods: {
|
|
60
|
-
/**
|
|
61
|
-
* data 富文本数据
|
|
62
|
-
* field 对象名
|
|
63
|
-
* type 类型
|
|
64
|
-
*/
|
|
65
|
-
getTinymceEdit(data, type) {
|
|
66
|
-
switch (type) {
|
|
67
|
-
case 'stem':
|
|
68
|
-
data.itemAttr.type = stemItemType[data.itemAttr.type]
|
|
69
|
-
this.fromData.itemContent = data.value
|
|
70
|
-
if (data.itemAttr.type && data.itemAttr.content) {
|
|
71
|
-
this.fromData.stemAttrs.push(data.itemAttr)
|
|
72
|
-
}
|
|
73
|
-
break
|
|
74
|
-
case 'answer':
|
|
75
|
-
data.itemAttr.type = shortItemType[data.itemAttr.type]
|
|
76
|
-
this.fromData.answer = data.value
|
|
77
|
-
if (data.itemAttr.type && data.itemAttr.content) {
|
|
78
|
-
this.fromData.answerAttrs.push(data.itemAttr)
|
|
79
|
-
}
|
|
80
|
-
break
|
|
81
|
-
case 'analysis':
|
|
82
|
-
data.itemAttr.type = analysisItemType[data.itemAttr.type]
|
|
83
|
-
this.fromData.description = data.value
|
|
84
|
-
|
|
85
|
-
if (data.itemAttr.type && data.itemAttr.content) {
|
|
86
|
-
this.fromData.descriptionAttrs.push(data.itemAttr)
|
|
87
|
-
}
|
|
88
|
-
break
|
|
89
|
-
default:
|
|
90
|
-
break
|
|
91
|
-
}
|
|
92
|
-
this.$emit('change', this.fromData)
|
|
93
|
-
},
|
|
94
|
-
|
|
95
|
-
handleDelteAttrs(data, type, list, row = {}) {
|
|
96
|
-
const listAttrs = list
|
|
97
|
-
listAttrs.splice(data.index, 1)
|
|
98
|
-
switch (type) {
|
|
99
|
-
case 'stem':
|
|
100
|
-
this.fromData.stemAttrs = listAttrs
|
|
101
|
-
break
|
|
102
|
-
case 'answer':
|
|
103
|
-
this.fromData.answerAttrs = listAttrs
|
|
104
|
-
break
|
|
105
|
-
case 'analysis':
|
|
106
|
-
this.fromData.descriptionAttrs = listAttrs
|
|
107
|
-
break
|
|
108
|
-
default:
|
|
109
|
-
break
|
|
110
|
-
}
|
|
111
|
-
this.$emit('change', this.fromData)
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
</script>
|
|
116
|
-
|
|
117
|
-
<style lang="scss" scoped>
|
|
118
|
-
.single-stem__label {
|
|
119
|
-
margin: 30px 0;
|
|
120
|
-
font-size: 18px;
|
|
121
|
-
font-weight: 700;
|
|
122
|
-
}
|
|
123
|
-
</style>
|