惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

T
The Blog of Author Tim Ferriss
S
Securelist
D
Docker
The Register - Security
The Register - Security
GbyAI
GbyAI
Recorded Future
Recorded Future
Engineering at Meta
Engineering at Meta
Stack Overflow Blog
Stack Overflow Blog
云风的 BLOG
云风的 BLOG
P
Proofpoint News Feed
罗磊的独立博客
博客园 - 【当耐特】
F
Full Disclosure
WordPress大学
WordPress大学
腾讯CDC
小众软件
小众软件
大猫的无限游戏
大猫的无限游戏
D
DataBreaches.Net
SecWiki News
SecWiki News
L
Lohrmann on Cybersecurity
I
InfoQ
MyScale Blog
MyScale Blog
量子位
Cyberwarzone
Cyberwarzone
博客园 - 三生石上(FineUI控件)
The Hacker News
The Hacker News
F
Fortinet All Blogs
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
Jina AI
Jina AI
博客园_首页
H
Help Net Security
K
Kaspersky official blog
酷 壳 – CoolShell
酷 壳 – CoolShell
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
www.infosecurity-magazine.com
www.infosecurity-magazine.com
Webroot Blog
Webroot Blog
Blog — PlanetScale
Blog — PlanetScale
V
Vulnerabilities – Threatpost
Y
Y Combinator Blog
The Cloudflare Blog
P
Proofpoint News Feed
V
Visual Studio Blog
C
Cyber Attacks, Cyber Crime and Cyber Security
T
Tailwind CSS Blog
爱范儿
爱范儿
P
Privacy International News Feed
Security Archives - TechRepublic
Security Archives - TechRepublic
The GitHub Blog
The GitHub Blog
C
Cybersecurity and Infrastructure Security Agency CISA
B
Blog RSS Feed

博客园 - 消失的风

使用Mist部署Contract到Rinkeby以太坊网络 基于以太坊的Token开发步骤 技术顾问认知(一) Angularjs-项目搭建 Augularjs-起步 appfuse:Excel导出 Appfuse:添加自定义页面组件 基于JQuery实现的文本框自动填充功能 Appfuse:权限控制 Appfuse:记录操作日志 Appfuse:扩展自己的GenericManager Appfuse:第一张表维护 Appfuse:起步 JAVA实现图片裁剪 Mybatis基于注解的方式访问数据库 敏捷开发与jira之研发管理模式 敏捷开发与jira之阶段工作项概述 敏捷开发与jira之燃烧图 敏捷开发与jira之流程
富文本编辑器vue2-editor实现全屏功能
消失的风 · 2019-05-26 · via 博客园 - 消失的风

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: 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;
  }

App.vue