jodit-pro
Version:
PRO Version of Jodit Editor
8 lines • 6.24 kB
JavaScript
/*!
* jodit-pro - PRO Version of Jodit Editor
* Author: Chupurnov Valerii <chupurnov@gmail.com>
* Version: v4.9.27
* Url: https://xdsoft.net/jodit/pro/
* License(s): SEE LICENSE IN LICENSE.md
*/
"use strict";!function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var o=t();for(var n in o)("object"==typeof exports?exports:e)[n]=o[n]}}(self,function(){return(self.webpackChunkjodit_pro=self.webpackChunkjodit_pro||[]).push([[576],{8256:function(e,t,o){var n=o(94899),i=o(6441),r=o(22732),c=o(21537),u=["tune.up","tune.remove","tune.down"],s=["tune.h1","tune.h2","tune.h3","\n","tune.h4","tune.h5","tune.h6","\n"].concat((0,n._)(u));function l(e){return{icon:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 50 50"><text dominant-baseline="text-before-edge" style="font: 45px sans-serif" x="0" y="0">'+e.toUpperCase()+"</text></svg>",isActive:function(t,o){var n;return(null==o||null==(n=o.target)?void 0:n.tagName.toLowerCase())===e},exec:function(t,o){if(o){t.selection.save();var n=r.Dom.replace(o,e,t.createInside);t.selection.restore(),t.e.fire("synchro"),t.e.fire("afterExecTune.tune",n)}return!0}}}function a(e){var t=e?"previousSibling":"nextSibling";return{icon:e?"angle-up":"angle-down",isDisabled:function(e,o){var n;return!(null==o||null==(n=o.target)?void 0:n[t])},exec:function(o,n){var i=null==n?void 0:n[t];return n&&i&&(o.selection.save(),(0,c.call)(e?r.Dom.before:r.Dom.after,i,n),o.selection.restore()),o.e.fire("synchro"),o.e.fire("afterExecTune.tune"),!0}}}i.Config.prototype.tuneBlock={popup:{p:u,table:u,img:u,blockquote:u,div:u,pre:["tune.editPre"].concat((0,n._)(u)),h1:s,h2:s,h3:s,h4:s,h5:s,h6:s}},i.Config.prototype.controls.tune={h1:l("h1"),h2:l("h2"),h3:l("h3"),h4:l("h4"),h5:l("h5"),h6:l("h6"),up:a(!0),down:a(!1),editPre:{icon:"pencil",exec:function(e,t){e.e.fire("editPreInPasteCode",t)}},remove:{icon:"bin",exec:function(e,t){r.Dom.safeRemove(t),e.e.fire("synchro"),e.e.fire("closeTuner.tune"),e.e.fire("hideTuner.tune")}}}},13152:function(e,t,o){o.r(t),o.d(t,{tuneBlock:function(){return f}});var n=o(80294),i=o(20616),r=o(67709),c=o(82749),u=o(18766),s=o(23078),l=o(31635);o(8256);var a=o(40104),h=o(65478),p=o(50911),d=o(2692),f=function(e){function t(){var e;return(0,i._)(this,t),e=(0,n._)(this,t,arguments),(0,c._)(e,"tuner",void 0),e}return(0,u._)(t,e),(0,r._)(t,[{key:"afterInit",value:function(e){this.tuner=new a.UITuner(e)}},{key:"hideTuner",value:function(){this.tuner.hide()}},{key:"onChangeSelection",value:function(){this.j.s.isCollapsed()||this.hideTuner()}},{key:"onClickInBlock",value:function(e){this.j.s.isCollapsed()&&this.tuner.show()}},{key:"beforeDestruct",value:function(e){this.tuner.destruct()}}]),t}((0,s._)(p.Plugin));(0,c._)(f,"requires",["license"]),(0,l.__decorate)([(0,h.watch)(":outsideClick :keydown")],f.prototype,"hideTuner",null),(0,l.__decorate)([(0,h.watch)("j.ed:selectionchange"),(0,h.debounce)()],f.prototype,"onChangeSelection",null),(0,l.__decorate)([(0,h.watch)(":click")],f.prototype,"onClickInBlock",null),d.JoditPro.plugins.add("tune-block",f)},40104:function(e,t,o){o.d(t,{UITuner:function(){return f}});var n=o(80294),i=o(20616),r=o(67709),c=o(82749),u=o(18766),s=o(31635),l=o(65478),a=o(22732),h=o(21537),p=o(67510),d=o(21491),f=function(e){function t(){var e;return(0,i._)(this,t),e=(0,n._)(this,t,arguments),(0,c._)(e,"isShown",!1),(0,c._)(e,"toolbar",(0,d.makeCollection)(e.j,e)),(0,c._)(e,"popup",new p.Popup(e.j,!1)),(0,c._)(e,"currentBlock",void 0),e}return(0,u._)(t,e),(0,r._)(t,[{key:"className",value:function(){return"UITuner"}},{key:"render",value:function(){return"<div>\n <div class='&__handle' title='~Click to tune~'/>\n </div>"}},{key:"show",value:function(){var e=this,t=this.j.s.current();if(!t)return this.hide();var o=a.Dom.isBlock(t)?t:a.Dom.closest(t,function(t){return!!(t&&e.j.o.tuneBlock.popup[t.nodeName.toLowerCase()])},this.j.editor);if(!o||o===this.j.editor||!this.j.o.tuneBlock.popup[o.tagName.toLowerCase()])return this.hide();this.currentBlock=o,this.isShown=!0,this.closeToolbar(),this.calcPosition(),this.container.parentNode||this.j.workplace.append(this.container)}},{key:"hide",value:function(){this.isShown&&(this.isShown=!1,a.Dom.safeRemove(this.container),this.closeToolbar())}},{key:"onEditorScroll",value:function(){this.isShown&&this.calcPosition()}},{key:"calcPosition",value:function(){var e=(0,h.css)(this.j.editor,"marginLeft"),t=(0,h.css)(this.j.editor,"paddingLeft"),o=(0,h.css)(this.j.editor,"marginTop"),n=this.currentBlock.offsetWidth-15+e+t,i=this.currentBlock.offsetTop-this.j.editor.scrollTop+o;(0,h.css)(this.container,{transform:"translate3d(".concat(n,"px, ").concat(i,"px, 0)")}),this.popup.isOpened&&this.popup.updatePosition()}},{key:"onAfterExecTune",value:function(e){e&&(this.currentBlock=e),this.calcPosition(),this.openToolbar()}},{key:"onClickPrevent",value:function(e){e.preventDefault(),e.stopPropagation()}},{key:"onTargetClick",value:function(){this.toggleToolbar()}},{key:"openToolbar",value:function(){if(this.setMod("opened",!0),this.toolbar.build(this.j.o.tuneBlock.popup[this.currentBlock.tagName.toLowerCase()],this.currentBlock),this.popup.setContent(this.toolbar.container),!this.popup.isOpened){var e=this.getElm("handle");(0,h.assert)(null!=e,"Handle element does not exist"),this.popup.open(function(){return(0,h.position)(e)})}}},{key:"closeToolbar",value:function(){this.setMod("opened",!1),this.popup.close()}},{key:"toggleToolbar",value:function(){this.getMod("opened")?this.closeToolbar():this.openToolbar()}}]),t}(p.UIElement);(0,s.__decorate)([(0,l.watch)(":hideTuner.tune")],f.prototype,"hide",null),(0,s.__decorate)([(0,l.watch)("j.editor:scroll"),(0,l.throttle)(10)],f.prototype,"onEditorScroll",null),(0,s.__decorate)([(0,l.watch)(":afterExecTune.tune"),(0,l.idle)()],f.prototype,"onAfterExecTune",null),(0,s.__decorate)([(0,l.watch)("container:click container:mousedown")],f.prototype,"onClickPrevent",null),(0,s.__decorate)([(0,l.watch)("handle:click")],f.prototype,"onTargetClick",null),(0,s.__decorate)([(0,l.watch)(":closeTuner.tune")],f.prototype,"closeToolbar",null),f=(0,s.__decorate)([l.component],f)}},function(e){return e(e.s=13152)}])});