vue2-editor非常不錯(cuò),可惜并未帶全屏功能,自己實(shí)現(xiàn)了一個(gè),供大家參考。
在云龍等地區(qū),都構(gòu)建了全面的區(qū)域性戰(zhàn)略布局,加強(qiáng)發(fā)展的系統(tǒng)性、市場(chǎng)前瞻性、產(chǎn)品創(chuàng)新能力,以專注、極致的服務(wù)理念,為客戶提供成都網(wǎng)站制作、做網(wǎng)站 網(wǎng)站設(shè)計(jì)制作按需規(guī)劃網(wǎng)站,公司網(wǎng)站建設(shè),企業(yè)網(wǎng)站建設(shè),高端網(wǎng)站設(shè)計(jì),成都全網(wǎng)營(yíng)銷,外貿(mào)營(yíng)銷網(wǎng)站建設(shè),云龍網(wǎng)站建設(shè)費(fèi)用合理。
實(shí)現(xiàn)思路:自定義模塊。
1. 定義全屏模塊Fullscreen
/** * 編輯器的全屏實(shí)現(xiàn) */ 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. 通過編輯器的選項(xiàng)注冊(cè)模塊,我是放在了全局的Global.vue中,其他頁面直接引用這個(gè)選項(xiàng)
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. 在頁面中引用
import {VueEditor, Quill} from "vue2-editor" import Fullscreen from '../Fullscreen' Quill.register('modules/fullscreen', Fullscreen)
4. 最后在全局樣式中加入全屏的樣式,我這個(gè)樣式中控制了編輯器的高度,默認(rèn)是自適應(yīng)高度的。
.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; }
總結(jié)
以上所述是小編給大家介紹的富文本編輯器vue2-editor實(shí)現(xiàn)全屏功能,希望對(duì)大家有所幫助,如果大家有任何疑問請(qǐng)給我留言,小編會(huì)及時(shí)回復(fù)大家的。在此也非常感謝大家對(duì)創(chuàng)新互聯(lián)網(wǎng)站的支持!