富文本编辑器vue2-editor实现全屏功能
2019-05-26 18:02
1811 查看
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>
import {VueEditor, Quill} from "vue2-editor" import Fullscreen from '../Fullscreen' Quill.register('modules/fullscreen', Fullscreen)
4. 最后在全局样式中加入全屏的样式,我这个样式中控制了编辑器的高度,默认是自适应高度的。
.editor .ql-editor{ height: 300px; } .editor-fullscreen{ background: white; margin: 0 !important; position: fixed; top: 0; left: 0; width: 100%; height: 100%; z-index: 100000; .ql-editor{ height: 100%; } .fullscreen-editor { border-radius: 0; border: none; } .ql-container { height: calc(100vh - 3rem - 24px) !important; margin: 0 auto; overflow-y: auto; } } .ql-fullscreen{ background:url('./assets/images/fullscreen.svg') no-repeat center!important; }
总结
以上所述是小编给大家介绍的富文本编辑器vue2-editor实现全屏功能,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对脚本之家网站的支持!
您可能感兴趣的文章:
相关文章推荐
- 富文本编辑器,CKEditor与 CKFinder 整合并实现文件上传功能
- Android实现全屏截图或长截屏功能
- iOS 实现全屏右滑返回功能解析!
- Vue中使用Froala Editor时,外部方法调用html.insert()插入内容到光标最后停留位置功能实现
- Vue 中使用vue2-highcharts实现top功能
- FLEX入门实例--------FLEX全屏功能实现及右键菜单
- Socket的TCP、UDP通讯(实现功能:文字发送,窗口震动,大文件传输,语音发送,语音通话、直接发送全屏截图)
- 用keyword实现Editor.GetSelection的退出功能
- Vue中使用Froala Editor时,外部方法调用html.insert()插入内容到光标最后停留位置功能实现
- vue2 mint-ui loadmore实现下拉刷新,上拉更多功能
- vue2实现简单的商品加入购物车和结算功能(前端数据保存方向)
- UINavigationController实现全屏滑动返回功能
- editormd实现Markdown编辑器写文章功能
- Vue中使用Froala Editor时,外部方法调用html.insert()插入内容到光标最后停留位置功能实现
- Android Rich Editor - 安卓富文本编辑器 - 纯Java实现
- mfc实现播放器功能,双击全屏,再双击还原
- python qt4 实现秒表,有背景音乐,全屏等功能
- Android中实现全屏、无标题栏的功能
- 基于Vue2实现的仿手机QQ单页面应用功能(接入聊天机器人 )
- c# 更改最大化按钮功能实现最大化时遮盖任务栏,点击Esc取消全屏