[update 89966] 富文本组件:去掉不能用的功能、解决火狐浏览器格式刷异常、解决显示错位
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
<template>
|
||||
<div>
|
||||
<script id="editor" type="text/plain" ></script>
|
||||
<div ref="editorBoxRef">
|
||||
<script :id="id" type="text/plain" ></script>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -35,11 +35,22 @@ export default {
|
||||
},
|
||||
getContentLength () {
|
||||
return this.editor.getContentLength()
|
||||
},
|
||||
// 解决火狐浏览器失去焦点后,下次获取焦点,会保留上次光标位置导致格式刷异常
|
||||
editorBlur (e) {
|
||||
// e.preventDefault()
|
||||
e.target.blur()
|
||||
this.$refs.editorBoxRef.querySelector('iframe').contentDocument.body.blur()
|
||||
setTimeout(() => {
|
||||
this.$refs.editorBoxRef.querySelector('iframe').contentDocument.body.blur()
|
||||
this.$refs.editorBoxRef.querySelector('iframe').contentDocument.body.focus()
|
||||
}, 100)
|
||||
}
|
||||
},
|
||||
props: {
|
||||
id: {
|
||||
type: String
|
||||
type: String,
|
||||
default: 'editor'
|
||||
},
|
||||
config: {
|
||||
type: Object
|
||||
@@ -74,27 +85,33 @@ export default {
|
||||
}
|
||||
UEDITOR_CONFIG.UEDITOR_HOME_URL = '../../../public/ueditor/'
|
||||
// 初始化UE
|
||||
this.editor = UE.delEditor('editor')
|
||||
this.editor = UE.getEditor('editor', this.config)
|
||||
this.editor = UE.delEditor(this.id)
|
||||
this.editor = UE.getEditor(this.id, this.config)
|
||||
const _this = this
|
||||
UE.getEditor('editor').addListener('blur', function (editor) {
|
||||
UE.getEditor(this.id).addListener('blur', function (editor) {
|
||||
_this.$emit('editor-onChange', _this.getUEContent())
|
||||
})
|
||||
UE.getEditor('editor').ready(function () {
|
||||
UE.getEditor(this.id).ready(() => {
|
||||
console.log('aaa', UE.getEditor(this.id))
|
||||
// 火狐浏览器格式刷会有问题,让页面失去焦点解决该问题
|
||||
UE.getEditor(this.id).body.addEventListener('blur', this.editorBlur)
|
||||
if (_this.fontfamily !== '') {
|
||||
UE.getEditor('editor').execCommand('fontfamily', _this.fontfamily)
|
||||
UE.getEditor(this.id).execCommand('fontfamily', _this.fontfamily)
|
||||
}
|
||||
if (_this.content !== '') {
|
||||
UE.getEditor('editor').setContent(_this.content)
|
||||
UE.getEditor(this.id).setContent(_this.content)
|
||||
}
|
||||
if (_this.fontsize !== '') {
|
||||
UE.getEditor('editor').execCommand('fontsize', _this.fontsize)
|
||||
UE.getEditor(this.id).execCommand('fontsize', _this.fontsize)
|
||||
}
|
||||
if (_this.bold) {
|
||||
UE.getEditor('editor').execCommand('bold')
|
||||
UE.getEditor(this.id).execCommand('bold')
|
||||
}
|
||||
})
|
||||
},
|
||||
beforeDestroy () {
|
||||
UE.getEditor(this.id).removeEventListener('blur', this.editorBlur)
|
||||
},
|
||||
destoryed () {
|
||||
this.editor.destory()
|
||||
}
|
||||
|
||||
@@ -69,10 +69,10 @@ export default {
|
||||
'unlink', // 取消链接
|
||||
// 'background', // 背景
|
||||
// 'simpleupload', // 单图上传
|
||||
'imagenone', // 默认
|
||||
'imageleft', // 左浮动
|
||||
'imageright', // 右浮动
|
||||
'imagecenter', // 居中
|
||||
// 'imagenone', // 默认
|
||||
// 'imageleft', // 左浮动
|
||||
// 'imageright', // 右浮动
|
||||
// 'imagecenter', // 居中
|
||||
'touppercase', // 字母大写
|
||||
'tolowercase', // 字母小写
|
||||
'emotion', // 表情
|
||||
@@ -81,8 +81,8 @@ export default {
|
||||
'insertunorderedlist', // 无序列表
|
||||
'insertorderedlist', // 有序列表
|
||||
'pagebreak', // 分页
|
||||
'insertframe', // 插入Iframe
|
||||
'charts', // 图表
|
||||
// 'insertframe', // 插入Iframe
|
||||
// 'charts', // 图表
|
||||
'edittip ', // 编辑提示
|
||||
'autotypeset', // 自动排版
|
||||
'drafts', // 从草稿箱加载
|
||||
|
||||
@@ -166,10 +166,10 @@ export default {
|
||||
'unlink', // 取消链接
|
||||
// 'background', // 背景
|
||||
// 'simpleupload', // 单图上传
|
||||
'imagenone', // 默认
|
||||
'imageleft', // 左浮动
|
||||
'imageright', // 右浮动
|
||||
'imagecenter', // 居中
|
||||
// 'imagenone', // 默认
|
||||
// 'imageleft', // 左浮动
|
||||
// 'imageright', // 右浮动
|
||||
// 'imagecenter', // 居中
|
||||
'touppercase', // 字母大写
|
||||
'tolowercase', // 字母小写
|
||||
'emotion', // 表情
|
||||
@@ -178,8 +178,8 @@ export default {
|
||||
'insertunorderedlist', // 无序列表
|
||||
'insertorderedlist', // 有序列表
|
||||
'pagebreak', // 分页
|
||||
'insertframe', // 插入Iframe
|
||||
'charts', // 图表
|
||||
// 'insertframe', // 插入Iframe
|
||||
// 'charts', // 图表
|
||||
'edittip ', // 编辑提示
|
||||
'autotypeset', // 自动排版
|
||||
'drafts', // 从草稿箱加载
|
||||
|
||||
Reference in New Issue
Block a user