UNPKG

froala-editor

Version:

The next generation Javascript WYSIWYG HTML rich text editor made by devs for devs. High performance and modern design make it easy to use for developers and loved by users.

7 lines (6 loc) 3.79 kB
/*! * froala_editor v5.0.1 (https://www.froala.com/wysiwyg-editor) * License https://froala.com/wysiwyg-editor/terms/ * Copyright 2014-2026 Froala Labs */ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(require("froala-editor")):"function"==typeof define&&define.amd?define(["froala-editor"],t):t(("undefined"!=typeof globalThis?globalThis:e||self).FroalaEditor)}(this,function(e){"use strict";e.PLUGINS.fullscreen=function(s){var t,n,o,r,i,l=s.$;function a(){if(s.helpers.isIOS()&&s.core.hasFocus())s.$el.blur(),setTimeout(c,250);else{t=s.helpers.scrollTop(),s.opts.iframe&&s.markdown&&s.markdown.isEnabled()&&(s.$box=s.$oel),s.$box.toggleClass("fr-fullscreen"),l("body").first().toggleClass("fr-fullscreen"),s.helpers.isMobile()&&(s.opts.toolbarBottom?s.$tb[0].removeAttribute("style"):(s.$tb.data("parent",s.$tb.parent()),s.$box.prepend(s.$tb),s.$tb.data("sticky-dummy")&&s.$tb.after(s.$tb.data("sticky-dummy")))),o=s.opts.height,r=s.opts.heightMax,i=s.opts.zIndex,s.opts.height=s.o_win.innerHeight-(s.opts.toolbarInline?0:s.$tb.outerHeight()+(s.$second_tb?s.$second_tb.outerHeight():0)),s.opts.zIndex=2147483641,s.opts.heightMax=null,s.size.refresh(),s.opts.toolbarInline&&s.toolbar.showInline();for(var e=s.$box.parent();!e.first().is("body");)e.addClass("fr-fullscreen-wrapper"),e=e.parent();s.opts.toolbarContainer&&s.$box.prepend(s.$tb),s.events.trigger("charCounter.update"),s.events.trigger("codeView.update"),s.$win.trigger("scroll")}}function f(){if(s.helpers.isIOS()&&s.core.hasFocus())s.$el.blur(),setTimeout(c,250);else{s.$box.toggleClass("fr-fullscreen"),l("body").first().toggleClass("fr-fullscreen"),s.$tb.data("parent")&&s.$tb.data("parent").prepend(s.$tb),s.$tb.data("sticky-dummy")&&s.$tb.after(s.$tb.data("sticky-dummy")),s.opts.height=o,s.opts.heightMax=r,s.opts.zIndex=i,s.size.refresh(),s.o_win.scroll(0,t),s.opts.toolbarInline&&s.toolbar.showInline(),s.events.trigger("charCounter.update"),s.opts.toolbarSticky&&s.opts.toolbarStickyOffset&&(s.opts.toolbarBottom?s.$tb.css("bottom",s.opts.toolbarStickyOffset).data("bottom",s.opts.toolbarStickyOffset):s.$tb.css("top",s.opts.toolbarStickyOffset).data("top",s.opts.toolbarStickyOffset));for(var e=s.$box.parent();!e.first().is("body");)e.removeClass("fr-fullscreen-wrapper"),e=e.parent();s.opts.toolbarContainer&&l(s.opts.toolbarContainer).append(s.$tb),l(s.o_win).trigger("scroll"),s.events.trigger("codeView.update")}}function c(){(n()?f:a)(),d(s.$tb.find('.fr-command[data-cmd="fullscreen"]'));var e=s.$tb.find('.fr-command[data-cmd="moreText"]'),t=s.$tb.find('.fr-command[data-cmd="moreParagraph"]'),o=s.$tb.find('.fr-command[data-cmd="moreRich"]'),r=s.$tb.find('.fr-command[data-cmd="moreMisc"]');e.length&&s.refresh.moreText(e),t.length&&s.refresh.moreParagraph(t),o.length&&s.refresh.moreRich(o),r.length&&s.refresh.moreMisc(r)}function d(e){var t=n();e.toggleClass("fr-active",t).attr("aria-pressed",t),e.find("> *").not(".fr-sr-only").replaceWith(t?s.icon.create("fullscreenCompress"):s.icon.create("fullscreen"))}return{_init:function(){if(!s.$wp)return!1;s.events.$on(l(s.o_win),"resize",function(){n()&&(f(),a())}),s.events.on("toolbar.hide",function(){if(n()&&s.helpers.isMobile())return!1}),s.events.on("position.refresh",function(){if(s.helpers.isIOS())return!n()}),s.events.on("destroy",function(){n()&&f()},!0)},toggle:c,refresh:d,isActive:n=function n(){return s.$box.hasClass("fr-fullscreen")}}},e.RegisterCommand("fullscreen",{title:"Fullscreen",undo:!1,focus:!1,accessibilityFocus:!0,forcedRefresh:!0,toggle:!0,callback:function(){this.fullscreen.toggle()},refresh:function(e){this.fullscreen.refresh(e)},plugin:"fullscreen"}),e.DefineIcon("fullscreen",{NAME:"expand",SVG_KEY:"fullscreen"}),e.DefineIcon("fullscreenCompress",{NAME:"compress",SVG_KEY:"exitFullscreen"})});