jodit-pro
Version:
PRO Version of Jodit Editor
12 lines • 5.36 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(6441),i=o(22732),r=o(21537);let s=["tune.up","tune.remove","tune.down"],c=["tune.h1","tune.h2","tune.h3",`
`,"tune.h4","tune.h5","tune.h6",`
`,...s];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:(t,o)=>o?.target?.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 h(e){let t=e?"previousSibling":"nextSibling";return{icon:e?"angle-up":"angle-down",isDisabled:(e,o)=>!o?.target?.[t],exec(o,n){let s=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:c,h2:c,h3:c,h4:c,h5:c,h6:c}},n.Config.prototype.controls.tune={h1:l("h1"),h2:l("h2"),h3:l("h3"),h4:l("h4"),h5:l("h5"),h6:l("h6"),up:h(!0),down:h(!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 h}});var n=o(82749),i=o(31635);o(8256);var r=o(40104),s=o(65478),c=o(50911),l=o(2692);class h extends c.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._)(h,"requires",["license"]),(0,i.__decorate)([(0,s.watch)(":outsideClick :keydown")],h.prototype,"hideTuner",null),(0,i.__decorate)([(0,s.watch)("j.ed:selectionchange"),(0,s.debounce)()],h.prototype,"onChangeSelection",null),(0,i.__decorate)([(0,s.watch)(":click")],h.prototype,"onClickInBlock",null),l.JoditPro.plugins.add("tune-block",h)},40104:function(e,t,o){o.d(t,{UITuner:function(){return u}});var n=o(82749),i=o(31635),r=o(65478),s=o(22732),c=o(21537),l=o(67510),h=o(21491);class u extends l.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,c.css)(this.j.editor,"marginLeft"),t=(0,c.css)(this.j.editor,"paddingLeft"),o=(0,c.css)(this.j.editor,"marginTop"),n=this.currentBlock.offsetWidth-15+e+t,i=this.currentBlock.offsetTop-this.j.editor.scrollTop+o;(0,c.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,c.assert)(null!=e,"Handle element does not exist"),this.popup.open(()=>(0,c.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,h.makeCollection)(this.j,this)),(0,n._)(this,"popup",new l.Popup(this.j,!1)),(0,n._)(this,"currentBlock",void 0)}}(0,i.__decorate)([(0,r.watch)(":hideTuner.tune")],u.prototype,"hide",null),(0,i.__decorate)([(0,r.watch)("j.editor:scroll"),(0,r.throttle)(10)],u.prototype,"onEditorScroll",null),(0,i.__decorate)([(0,r.watch)(":afterExecTune.tune"),(0,r.idle)()],u.prototype,"onAfterExecTune",null),(0,i.__decorate)([(0,r.watch)("container:click container:mousedown")],u.prototype,"onClickPrevent",null),(0,i.__decorate)([(0,r.watch)("handle:click")],u.prototype,"onTargetClick",null),(0,i.__decorate)([(0,r.watch)(":closeTuner.tune")],u.prototype,"closeToolbar",null),u=(0,i.__decorate)([r.component],u)}},function(e){return e(e.s=13152)}])});