国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 語言 > JavaScript > 正文

富文本編輯器vue2-editor實現全屏功能

2024-05-06 15:38:59
字體:
來源:轉載
供稿:網友

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實現全屏功能,希望對大家有所幫助,如果大家有任何疑問請給我留言,小編會及時回復大家的。在此也非常感謝大家對錯新站長站網站的支持!

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表

圖片精選

主站蜘蛛池模板: 萨迦县| 乌拉特后旗| 绥宁县| 于都县| 惠来县| 武宣县| 廉江市| 贵溪市| 建昌县| 建始县| 长泰县| 若羌县| 桑日县| 陆良县| 琼中| 民县| 铁力市| 湘乡市| 长岛县| 乐东| 宁国市| 沈阳市| 哈巴河县| 民和| 鄱阳县| 怀化市| 莫力| 沈丘县| 江安县| 旬邑县| 梁平县| 石台县| 莎车县| 青冈县| 武城县| 滦南县| 昂仁县| 普洱| 高安市| 山阳县| 神池县|