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()
}
}
}
}
}

Global.vue

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:;
left:;
width: 100%;
height: 100%;
z-index:;
.ql-editor{
height: 100%;
}
.fullscreen-editor {
border-radius:;
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;
}

App.vue

富文本编辑器vue2-editor实现全屏功能的更多相关文章

  1. 给Django后台富文本编辑器添加上传文件的功能

    使用富文本编辑器上传的文件是要放到服务器上的,所以这是一个request.既然是一个request,就需要urls.py进行转发请求views.py进行处理.views.py处理完了返回一个文件所在的 ...

  2. vue 富文本编辑器 项目实战用法

    1.挑个富文本编辑器 首先针对自己项目的类型,确定自己要用啥编辑器. 1.1 wangeditor 如果一般类似博客这种项目不需要花里胡哨的,功能也不要求贼多的,推荐一下wangeditor(点击跳转 ...

  3. 富文本编辑器 - wangEditor 上传图片

    效果: . 项目结构图: wangEditor-upload-img.html代码: <html> <head> <title>wangEditor-图片上传< ...

  4. wangEditor-基于javascript和css开发的 Web富文本编辑器, 轻量、简洁、易用、开源免费(2)

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  5. JS编写自己的富文本编辑器

    富文本编辑器,网上有很多功能齐全种类丰富的如百度的Ueditor,简单适用型的如WangEditor等等.在经过一番挑选后,我发现都不适用现在的项目,然后决定自己造轮子玩玩.富文本编辑器中主要涉及到J ...

  6. 富文本编辑器防止xss注入javascript版

    富文本编辑器:ueditor 其实富文本编辑器已经有防止xss注入功能,但是你服务端程序在接收的时候在做一次转义,否则有可能然后前端验证直接提交数据导致被xss攻击. 为了节省后端程序开销则在前端 显 ...

  7. 百度富文本编辑器UEditor安装配置全过程

    网站开发时富文本编辑器是必不可少的,他可以让用户自行编辑内容的样式然后上传到后台!下面我们来介绍如何安装使用百度富文本编辑器 一.下载并且设置百度富文本编辑器的样式     你可以去百度UEditor ...

  8. (转)淘淘商城系列——KindEditor富文本编辑器的使用

    http://blog.csdn.net/yerenyuan_pku/article/details/72809794 通过上文的学习,我们知道了怎样解决KindEditor富文本编辑器上传图片时的浏 ...

  9. (转)学习淘淘商城第二十二课(KindEditor富文本编辑器的使用)

    http://blog.csdn.net/u012453843/article/details/70184155 上节课我们一起学习了怎样解决KindEditor富文本编辑器上传图片的浏览器兼容性问题 ...

随机推荐

  1. Ubuntu 16.04 同时使用python3.5

    Python 3.x版本使用pip3,它会把你想下载的包放到usr/local/lib/python3.5/dist-packages/下,而非usr/local/lib/python2.7/dist ...

  2. vue 计算属性与侦听器

    侦听器:顾名思义,就是用来监听数据变化用的.侦听器在vue实例中,定义变量watch来使用.监听新值newVal和旧值oldVal,具体使用方法如下: <!DOCTYPE html> &l ...

  3. PyOpenGL下GlutBitmapCharacter的替代

    虽然pyinstaller支持pyopengl,但是调用GLUT之后,在其它电脑上面运行就会出现错误,索性按照之前C#上面的办法,把字体数据和函数用python重写 fontData.py #! /u ...

  4. notpad++快捷键

    Notpad++快捷键 Notepad++选中行操作 快捷键 使用技巧 作者: Rememberautumn 分类: 其他 发布时间: 2014-09-04 14:18 阅读: 60,106  微信小 ...

  5. iptables apache2

    Apache2 iptables 安装指令:sudo apt-get install apache2 2.产生的启动和停止文件是:/etc/init.d/apache2 3.启动:sudo apach ...

  6. HDU 6068 Classic Quotation KMP+DP

    Classic Quotation Problem Description When online chatting, we can save what somebody said to form h ...

  7. 使用Apache Ant合并多个jar

    Apache Ant下载地址 下载解压后进入bin目录,并在此目录打开cmd 在cmd中运行ant,运行结果为: Buildfile: build.xml does not exist! Build ...

  8. JAVA变量存储

    1.java变量存储域 java变量的存储区域主要放在以下几个地方: (1)寄存器:可以说是最快的存储区,在C/C++中可以声明寄存器变量,但是在java中不能声明寄存器变量,只是编译器在编译时确定. ...

  9. map数据的分组,list数据排序 数据筛选

    sfit0144 (李四) 2015-01-10 18:00:251Sfit0734 (Sfit0734) 2015-01-10 18:00:38go homesfit0144 (李四) 2015-0 ...

  10. redis02---对于key的操作命令

    Redis对于key的操作命令 del key1 key2 ... Keyn 作用: 删除1个或多个键 返回值: 不存在的key忽略掉,返回真正删除的key的数量 rename key newkey ...