没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
富文本编辑器富文本编辑器vue2-editor实现全屏功能实现全屏功能
主要介绍了富文本编辑器vue2-editor实现全屏功能,本文通过实例代码给大家介绍的非常详细,具有一定的参
考借鉴价值 ,需要的朋友可以参考下
vue2-editor非常不错,可惜并未带全屏功能,自己实现了一个,供大家参考。
实现思路:自定义模块。
1. 定义全屏模块定义全屏模块Fullscreen
/**
* 编辑器的全屏实现
*/
import noScroll from 'no-scroll'
export default class Fullscreen {
constructor (quill, options = {}) {
this.quill = quill
this.options = options
this.fullscreen = false
this.editorContainer = this.quill.container.parentNode.parentNode
}
handle () {
if (! this.fullscreen) {
this.fullscreen = true
this.editorContainer.className = 'ql-editor ql-blank editor-fullscreen'
noScroll.on()
}else{
this.fullscreen = false
this.editorContainer.className = 'ql-editor ql-blank'
noScroll.off()
}
}
}
Fullscreen.js
2. 通过编辑器的选项注册模块,我是放在了全局的Global.vue中,其他页面直接引用这个选项
const EDITOR_OPTIONS = {
modules: {
fullscreen: {},
toolbar: {
container: [
[{ header: [false, 1, 2, 3, 4, 5, 6] }],
["bold", "italic", "underline", "strike"], // toggled buttons
[
{ align: "" },
{ align: "center" },
{ align: "right" },
{ align: "justify" }
],
["blockquote", "code-block"],
[{ list: "ordered" }, { list: "bullet" }, { list: "check" }],
[{ indent: "-1" }, { indent: "+1" }], // outdent/indent
[{ color: [] }, { background: [] }], // dropdown with defaults from theme
["link", "image", "video"],
["clean"], // remove formatting button
['fullscreen']
],
handlers: {
fullscreen() {
this.quill.getModule('fullscreen').handle()
}
}
}
}
}
3. 在页面中引用
<vue-editor
useCustomImageHandler
@imageAdded="handleImageAdded"
v-model="entity.content"
:editorOptions="$global.EDITOR_OPTIONS"
class="editor">
</vue-editor>
资源评论
weixin_38576561
- 粉丝: 4
- 资源: 903
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功