UNPKG

jodit-pro

Version:

PRO Version of Jodit Editor

8 lines 5.98 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 */ !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 s in o)("object"==typeof exports?exports:e)[s]=o[s]}}(self,function(){return(self.webpackChunkjodit_pro=self.webpackChunkjodit_pro||[]).push([[502],{11373:function(e){e.exports='<svg stroke="black" stroke-linejoin="round" stroke-linecap="round" stroke-width="28" viewBox="0 0 256 256" xmlns="http://www.w3.org/2000/svg"> \x3c!-- <rect fill="none" height="256" width="256"/>--\x3e <line fill="none" x1="130" x2="241" y1="54" y2="54"/> <line fill="none" x1="130" x2="241" y1="128" y2="128"/> <line fill="none" x1="130" x2="241" y1="202" y2="202"/> <polyline fill="none" points="92 38 57.3 70 40 54"/> <polyline fill="none" points="92 112 57.3 144 40 128"/> <polyline fill="none" points="92 186 57.3 218 40 202"/> </svg>'},19374:function(e,t,o){"use strict";o.r(t),o.d(t,{TodoList:function(){return _}});var s=o(82749),i=o(31635);o(64839);var l=o(82758),n=o(65478),r=o(2748),a=o(43555),p=o(50911),c=o(59242),d=o(2692);class _ extends p.Plugin{afterInit(e){e.registerCommand("todoList",this.onCommand)}onCommand(){try{this.__isOwnCommand=!0,this.jodit.s.commitStyle({element:"ul",attributes:{class:this.j.o.todoList.className},hooks:{afterWrapList:this.__afterWrapList,afterToggleAttribute:this.__afterWrapList}})}finally{this.__isOwnCommand=!1}return!1}__prependInputLabel(e){let{jodit:t}=this,{labelClassName:o,inputFactory:s}=this.j.o.todoList;if(e.querySelector("label."+o))return;let i=t.createInside.element("label",{contenteditable:"false",class:o}),l=s(t);i.appendChild(l),r.Dom.prepend(e,i)}__afterToggleList(e,t){return(e===c.CHANGE||e===c.REPLACE)&&this.__isOwnCommand?this.__appendInputs(t):e===c.UNWRAP||e===c.REPLACE||e===c.CHANGE?this.__removeInputs(t):void 0}__appendInputs(e){e.querySelectorAll("li").forEach(this.__prependInputLabel)}__removeInputs(e){let{labelClassName:t}=this.j.o.todoList;e.querySelectorAll("label."+t).forEach(r.Dom.safeRemove)}__beforeToggleOrderedList(e,t,o){let s="__beforeToggleOrderedList";if(e!==c.REPLACE&&(t.classList.contains(this.j.o.todoList.className)||o.isApplied(t,s))&&("ul"===o.element||"ol"===o.element)&&o.options.attributes?.class!==this.j.o.todoList.className){let e=r.Dom.replace(t,o.element,this.jodit.createInside);return o.setApplied(e,s),this.__removeInputs(e),e}}__afterEnter(){(0,a.$$)("ul."+this.j.o.todoList.className+" li",this.jodit.editor).forEach(this.__prependInputLabel)}__afterTab(){(0,a.$$)("ul:not(."+this.j.o.todoList.className+") > li > label",this.jodit.editor).filter(this.isTodoLeafLabel).forEach(r.Dom.safeRemove)}__changeSelection(e){let t=this.j.s.current();this.isTodoLeafLabel(t)&&(e.preventDefault(),e.stopPropagation(),this.j.s.setCursorAfter(t))}__isEmptyListLeaf(e){return r.Dom.isEmpty(e,e=>!("input"===e.nodeName.toLowerCase()&&this.isTodoLeafLabel(e.parentElement))&&l.NO_EMPTY_TAGS.has(e.tagName.toLowerCase()))}__backSpaceBeforeCases(e,t){if(e){let e=r.Dom.findNotEmptySibling(t,!0);this.isTodoLeafLabel(e)&&r.Dom.safeRemove(e)}}__isInvisibleForCursor(e){if(this.isTodoLeafLabel(e))return!0}__backSpaceAfterDelete(){let{labelClassName:e}=this.j.o.todoList;(0,a.$$)("label."+e,this.jodit.editor).forEach(e=>{e.closest("ul."+this.j.o.todoList.className)?e.previousSibling&&e.parentElement&&r.Dom.prepend(e.parentElement,e):r.Dom.safeRemove(e)})}__afterWrapList(e,t){e===c.WRAP&&this.__appendInputs(t)}__onClickInput(e){let t=e.target;t&&r.Dom.isTag(t,"input")&&"checkbox"===t.type&&this.isTodoLeafLabel(t.parentElement)&&(0,a.attr)(t,"checked",t.checked?"checked":null)}isTodoLeafLabel(e){let{labelClassName:t}=this.j.o.todoList;return r.Dom.isHTMLElement(e)&&e.classList.contains(t)}beforeDestruct(e){}constructor(...e){super(...e),(0,s._)(this,"buttons",[{name:"todoList",group:"list"}]),(0,s._)(this,"__isOwnCommand",!1)}}(0,s._)(_,"requires",["license"]),(0,i.__decorate)([n.autobind],_.prototype,"onCommand",null),(0,i.__decorate)([n.autobind],_.prototype,"__prependInputLabel",null),(0,i.__decorate)([(0,n.watch)(":commitStyleAfterToggleList")],_.prototype,"__afterToggleList",null),(0,i.__decorate)([(0,n.watch)(":commitStyleBeforeUnwrapList")],_.prototype,"__beforeToggleOrderedList",null),(0,i.__decorate)([(0,n.watch)(":afterEnter")],_.prototype,"__afterEnter",null),(0,i.__decorate)([(0,n.watch)(":afterTab")],_.prototype,"__afterTab",null),(0,i.__decorate)([(0,n.watch)("j.ed:selectionchange"),(0,n.watch)(":afterEnter")],_.prototype,"__changeSelection",null),(0,i.__decorate)([(0,n.watch)(":enterIsEmptyListLeaf")],_.prototype,"__isEmptyListLeaf",null),(0,i.__decorate)([(0,n.watch)(":backSpaceBeforeCases")],_.prototype,"__backSpaceBeforeCases",null),(0,i.__decorate)([(0,n.watch)(":backSpaceIsMovedIgnore"),(0,n.watch)(":isInvisibleForCursor")],_.prototype,"__isInvisibleForCursor",null),(0,i.__decorate)([(0,n.watch)(":backSpaceAfterDelete")],_.prototype,"__backSpaceAfterDelete",null),(0,i.__decorate)([n.autobind],_.prototype,"__afterWrapList",null),(0,i.__decorate)([(0,n.watch)(":click")],_.prototype,"__onClickInput",null),(0,i.__decorate)([n.autobind],_.prototype,"isTodoLeafLabel",null),d.JoditPro.plugins.add("todo-list",_)},64839:function(e,t,o){"use strict";var s=o(11373),i=o.n(s),l=o(6441),n=o(2748),r=o(12153);l.Config.prototype.todoList={className:"todo-list",labelClassName:"todo-list__label",inputFactory:e=>e.createInside.element("input",{type:"checkbox",tabindex:-1})},l.Config.prototype.controls.todoList={tooltip:"To-do List",icon:"todo-list",command:"todolist",isActive(e){let t=e.s.current();return!!(t&&n.Dom.closest(t,e=>n.Dom.isElement(e)&&n.Dom.isTag(e,"ul")&&e.classList.contains("todo-list"),e.editor))}},r.Icon.set("todo-list",i())}},function(e){return e(e.s=19374)}])});