修改富文本禁止粘贴

This commit is contained in:
范强强
2022-09-09 11:29:20 +08:00
parent e542b9bd1d
commit 9e31357847
@@ -234,6 +234,10 @@
placeholder: '',
theme: 'snow', // or 'bubble'
modules: {
clipboard: {
// 粘贴版,处理粘贴时候带图片
matchers: [[Node.ELEMENT_NODE, this.handleCustomMatcher]]
},
toolbar: {
container: toolbarOptions, // 工具栏
handlers: {
@@ -338,6 +342,18 @@
quilleditorBlur() {
this.$refs.ruleForm.validateField('content')
},
handleCustomMatcher(node, Delta) {
let ops = []
Delta.ops.forEach(op => {
if (op.insert && typeof op.insert === 'string') {// 如果粘贴了图片,这里会是一个对象,如果是字符串则可以添加
ops.push({
insert: op.insert
})
}
})
Delta.ops = ops
return Delta
},
getBase() {
getAction('/problemKnowledgeBase/problemKnowledgeBaseClassifyEO/list', {}).then((res) => {
if (res.success) {
@@ -445,7 +461,7 @@
let index1 = fileName.lastIndexOf('.')
let index2 = fileName.length
let fileSuffix = fileName.substring(index1, index2)
quill.insertEmbed(length, 'image', window._CONFIG['domianPreviewURL']+'/sys/common/download/'+file.response.result.id+fileSuffix)
quill.insertEmbed(length, 'image', window._CONFIG['domianPreviewURL'] + '/sys/common/download/' + file.response.result.id + fileSuffix)
quill.setSelection(length + 1)
this.quillUpdateImg = false
} else if (status === 'uploading') {