UNPKG

@opentiny/fluent-editor

Version:

A rich text editor based on Quill 2.0, which extends rich modules and formats on the basis of Quill. It's powerful and out-of-the-box.

61 lines (60 loc) 2.36 kB
"use strict"; Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" }); const index = require("../config/index.cjs.js"); const icons = require("../ui/icons.cjs.js"); const scrollLock = require("../utils/scroll-lock.cjs.js"); let exitEscHandlerBindToolbar; let resizeHandlerBindToolbar; let cleanLock; let originScrollTop = 0; function exitEscHandler(toolbar, e) { if (e.code === "Escape") { exitFullscreen(toolbar); } } function updateToolbarHeight(toolbar) { const toolbarRect = toolbar.container.getBoundingClientRect(); toolbar.quill.container.style.setProperty(`--${index.namespace}-top`, `${toolbarRect.height}px`); } function intoFullscreen(toolbar) { toolbar.quill.isFullscreen = true; originScrollTop = document.documentElement.scrollTop; toolbar.container.classList.add("fullscreen"); toolbar.quill.container.classList.add("fullscreen"); cleanLock = scrollLock.lockScroll(); resizeHandlerBindToolbar(); const [, btn] = toolbar.controls.find((item) => item[0] === "fullscreen"); btn.innerHTML = icons.ICONS_CONFIG["fullscreen-exit"]; window.addEventListener("resize", resizeHandlerBindToolbar); document.addEventListener("keydown", exitEscHandlerBindToolbar); const toolbarTipModule = toolbar.quill.getModule("toolbar-tip"); if (toolbarTipModule) { toolbarTipModule.hideAllTips(); } } function exitFullscreen(toolbar) { toolbar.quill.isFullscreen = false; toolbar.container.classList.remove("fullscreen"); toolbar.quill.container.classList.remove("fullscreen"); cleanLock(); document.documentElement.scrollTop = originScrollTop; const [, btn] = toolbar.controls.find((item) => item[0] === "fullscreen"); btn.innerHTML = icons.ICONS_CONFIG.fullscreen; window.removeEventListener("resize", resizeHandlerBindToolbar); document.removeEventListener("keydown", exitEscHandlerBindToolbar); const toolbarTipModule = toolbar.quill.getModule("toolbar-tip"); if (toolbarTipModule) { toolbarTipModule.hideAllTips(); } } function fullscreenHandler() { if (this.quill.isFullscreen) { exitFullscreen(this); } else { exitEscHandlerBindToolbar = exitEscHandler.bind(void 0, this); resizeHandlerBindToolbar = updateToolbarHeight.bind(void 0, this); intoFullscreen(this); } } exports.fullscreenHandler = fullscreenHandler; //# sourceMappingURL=fullscreen.cjs.js.map