UNPKG

jodit-pro

Version:

PRO Version of Jodit Editor

10 lines 5.45 kB
/*! * 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(6441),i=o(22732),r=o(21537);let s=["tune.up","tune.remove","tune.down"],l=["tune.h1","tune.h2","tune.h3","\n","tune.h4","tune.h5","tune.h6","\n",...s];function c(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(t,o){var n;return(null==o||null==(n=o.target)?void 0:n.tagName.toLowerCase())===e},exec(t,o){if(o){t.selection.save();let n=i.Dom.replace(o,e,t.createInside);t.selection.restore(),t.e.fire("synchro"),t.e.fire("afterExecTune.tune",n)}return!0}}}function u(e){let t=e?"previousSibling":"nextSibling";return{icon:e?"angle-up":"angle-down",isDisabled(e,o){var n;return!(null==o||null==(n=o.target)?void 0:n[t])},exec(o,n){let s=null==n?void 0:n[t];return n&&s&&(o.selection.save(),(0,r.call)(e?i.Dom.before:i.Dom.after,s,n),o.selection.restore()),o.e.fire("synchro"),o.e.fire("afterExecTune.tune"),!0}}}n.Config.prototype.tuneBlock={popup:{p:s,table:s,img:s,blockquote:s,div:s,pre:["tune.editPre",...s],h1:l,h2:l,h3:l,h4:l,h5:l,h6:l}},n.Config.prototype.controls.tune={h1:c("h1"),h2:c("h2"),h3:c("h3"),h4:c("h4"),h5:c("h5"),h6:c("h6"),up:u(!0),down:u(!1),editPre:{icon:"pencil",exec(e,t){e.e.fire("editPreInPasteCode",t)}},remove:{icon:"bin",exec(e,t){i.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 u}});var n=o(82749),i=o(31635);o(8256);var r=o(40104),s=o(65478),l=o(50911),c=o(2692);class u extends l.Plugin{afterInit(e){this.tuner=new r.UITuner(e)}hideTuner(){this.tuner.hide()}onChangeSelection(){this.j.s.isCollapsed()||this.hideTuner()}onClickInBlock(e){this.j.s.isCollapsed()&&this.tuner.show()}beforeDestruct(e){this.tuner.destruct()}constructor(...e){super(...e),(0,n._)(this,"tuner",void 0)}}(0,n._)(u,"requires",["license"]),(0,i.__decorate)([(0,s.watch)(":outsideClick :keydown")],u.prototype,"hideTuner",null),(0,i.__decorate)([(0,s.watch)("j.ed:selectionchange"),(0,s.debounce)()],u.prototype,"onChangeSelection",null),(0,i.__decorate)([(0,s.watch)(":click")],u.prototype,"onClickInBlock",null),c.JoditPro.plugins.add("tune-block",u)},40104:function(e,t,o){o.d(t,{UITuner:function(){return h}});var n=o(82749),i=o(31635),r=o(65478),s=o(22732),l=o(21537),c=o(67510),u=o(21491);class h extends c.UIElement{className(){return"UITuner"}render(){return`<div> <div class='&__handle' title='~Click to tune~'/> </div>`}show(){let e=this.j.s.current();if(!e)return this.hide();let t=s.Dom.isBlock(e)?e:s.Dom.closest(e,e=>!!(e&&this.j.o.tuneBlock.popup[e.nodeName.toLowerCase()]),this.j.editor);if(!t||t===this.j.editor||!this.j.o.tuneBlock.popup[t.tagName.toLowerCase()])return this.hide();this.currentBlock=t,this.isShown=!0,this.closeToolbar(),this.calcPosition(),this.container.parentNode||this.j.workplace.append(this.container)}hide(){this.isShown&&(this.isShown=!1,s.Dom.safeRemove(this.container),this.closeToolbar())}onEditorScroll(){this.isShown&&this.calcPosition()}calcPosition(){let e=(0,l.css)(this.j.editor,"marginLeft"),t=(0,l.css)(this.j.editor,"paddingLeft"),o=(0,l.css)(this.j.editor,"marginTop"),n=this.currentBlock.offsetWidth-15+e+t,i=this.currentBlock.offsetTop-this.j.editor.scrollTop+o;(0,l.css)(this.container,{transform:`translate3d(${n}px, ${i}px, 0)`}),this.popup.isOpened&&this.popup.updatePosition()}onAfterExecTune(e){e&&(this.currentBlock=e),this.calcPosition(),this.openToolbar()}onClickPrevent(e){e.preventDefault(),e.stopPropagation()}onTargetClick(){this.toggleToolbar()}openToolbar(){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){let e=this.getElm("handle");(0,l.assert)(null!=e,"Handle element does not exist"),this.popup.open(()=>(0,l.position)(e))}}closeToolbar(){this.setMod("opened",!1),this.popup.close()}toggleToolbar(){this.getMod("opened")?this.closeToolbar():this.openToolbar()}constructor(...e){super(...e),(0,n._)(this,"isShown",!1),(0,n._)(this,"toolbar",(0,u.makeCollection)(this.j,this)),(0,n._)(this,"popup",new c.Popup(this.j,!1)),(0,n._)(this,"currentBlock",void 0)}}(0,i.__decorate)([(0,r.watch)(":hideTuner.tune")],h.prototype,"hide",null),(0,i.__decorate)([(0,r.watch)("j.editor:scroll"),(0,r.throttle)(10)],h.prototype,"onEditorScroll",null),(0,i.__decorate)([(0,r.watch)(":afterExecTune.tune"),(0,r.idle)()],h.prototype,"onAfterExecTune",null),(0,i.__decorate)([(0,r.watch)("container:click container:mousedown")],h.prototype,"onClickPrevent",null),(0,i.__decorate)([(0,r.watch)("handle:click")],h.prototype,"onTargetClick",null),(0,i.__decorate)([(0,r.watch)(":closeTuner.tune")],h.prototype,"closeToolbar",null),h=(0,i.__decorate)([r.component],h)}},function(e){return e(e.s=13152)}])});