UNPKG

jodit-pro

Version:

PRO Version of Jodit Editor

8 lines 6.64 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 i in o)("object"==typeof exports?exports:e)[i]=o[i]}}(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 y}});var i=o(80294),n=o(20616),a=o(67709),s=o(82749),l=o(18766),r=o(23078),c=o(31635);o(64839);var u=o(82758),p=o(65478),_=o(2748),d=o(43555),f=o(50911),m=o(59242),h=o(2692),y=function(e){function t(){var e;return(0,n._)(this,t),e=(0,i._)(this,t,arguments),(0,s._)(e,"buttons",[{name:"todoList",group:"list"}]),(0,s._)(e,"__isOwnCommand",!1),e}return(0,l._)(t,e),(0,a._)(t,[{key:"afterInit",value:function(e){e.registerCommand("todoList",this.onCommand)}},{key:"onCommand",value:function(){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}},{key:"__prependInputLabel",value:function(e){var t=this.jodit,o=this.j.o.todoList,i=o.labelClassName,n=o.inputFactory;if(!e.querySelector("label."+i)){var a=t.createInside.element("label",{contenteditable:"false",class:i}),s=n(t);a.appendChild(s),_.Dom.prepend(e,a)}}},{key:"__afterToggleList",value:function(e,t){return(e===m.CHANGE||e===m.REPLACE)&&this.__isOwnCommand?this.__appendInputs(t):e===m.UNWRAP||e===m.REPLACE||e===m.CHANGE?this.__removeInputs(t):void 0}},{key:"__appendInputs",value:function(e){e.querySelectorAll("li").forEach(this.__prependInputLabel)}},{key:"__removeInputs",value:function(e){var t=this.j.o.todoList.labelClassName;e.querySelectorAll("label."+t).forEach(_.Dom.safeRemove)}},{key:"__beforeToggleOrderedList",value:function(e,t,o){var i,n="__beforeToggleOrderedList";if(e!==m.REPLACE&&(t.classList.contains(this.j.o.todoList.className)||o.isApplied(t,n))&&("ul"===o.element||"ol"===o.element)&&(null==(i=o.options.attributes)?void 0:i.class)!==this.j.o.todoList.className){var a=_.Dom.replace(t,o.element,this.jodit.createInside);return o.setApplied(a,n),this.__removeInputs(a),a}}},{key:"__afterEnter",value:function(){(0,d.$$)("ul."+this.j.o.todoList.className+" li",this.jodit.editor).forEach(this.__prependInputLabel)}},{key:"__afterTab",value:function(){(0,d.$$)("ul:not(."+this.j.o.todoList.className+") > li > label",this.jodit.editor).filter(this.isTodoLeafLabel).forEach(_.Dom.safeRemove)}},{key:"__changeSelection",value:function(e){var t=this.j.s.current();this.isTodoLeafLabel(t)&&(e.preventDefault(),e.stopPropagation(),this.j.s.setCursorAfter(t))}},{key:"__isEmptyListLeaf",value:function(e){var t=this;return _.Dom.isEmpty(e,function(e){return!("input"===e.nodeName.toLowerCase()&&t.isTodoLeafLabel(e.parentElement))&&u.NO_EMPTY_TAGS.has(e.tagName.toLowerCase())})}},{key:"__backSpaceBeforeCases",value:function(e,t){if(e){var o=_.Dom.findNotEmptySibling(t,!0);this.isTodoLeafLabel(o)&&_.Dom.safeRemove(o)}}},{key:"__isInvisibleForCursor",value:function(e){if(this.isTodoLeafLabel(e))return!0}},{key:"__backSpaceAfterDelete",value:function(){var e=this,t=this.j.o.todoList.labelClassName;(0,d.$$)("label."+t,this.jodit.editor).forEach(function(t){t.closest("ul."+e.j.o.todoList.className)?t.previousSibling&&t.parentElement&&_.Dom.prepend(t.parentElement,t):_.Dom.safeRemove(t)})}},{key:"__afterWrapList",value:function(e,t){e===m.WRAP&&this.__appendInputs(t)}},{key:"__onClickInput",value:function(e){var t=e.target;t&&_.Dom.isTag(t,"input")&&"checkbox"===t.type&&this.isTodoLeafLabel(t.parentElement)&&(0,d.attr)(t,"checked",t.checked?"checked":null)}},{key:"isTodoLeafLabel",value:function(e){var t=this.j.o.todoList.labelClassName;return _.Dom.isHTMLElement(e)&&e.classList.contains(t)}},{key:"beforeDestruct",value:function(e){}}]),t}((0,r._)(f.Plugin));(0,s._)(y,"requires",["license"]),(0,c.__decorate)([p.autobind],y.prototype,"onCommand",null),(0,c.__decorate)([p.autobind],y.prototype,"__prependInputLabel",null),(0,c.__decorate)([(0,p.watch)(":commitStyleAfterToggleList")],y.prototype,"__afterToggleList",null),(0,c.__decorate)([(0,p.watch)(":commitStyleBeforeUnwrapList")],y.prototype,"__beforeToggleOrderedList",null),(0,c.__decorate)([(0,p.watch)(":afterEnter")],y.prototype,"__afterEnter",null),(0,c.__decorate)([(0,p.watch)(":afterTab")],y.prototype,"__afterTab",null),(0,c.__decorate)([(0,p.watch)("j.ed:selectionchange"),(0,p.watch)(":afterEnter")],y.prototype,"__changeSelection",null),(0,c.__decorate)([(0,p.watch)(":enterIsEmptyListLeaf")],y.prototype,"__isEmptyListLeaf",null),(0,c.__decorate)([(0,p.watch)(":backSpaceBeforeCases")],y.prototype,"__backSpaceBeforeCases",null),(0,c.__decorate)([(0,p.watch)(":backSpaceIsMovedIgnore"),(0,p.watch)(":isInvisibleForCursor")],y.prototype,"__isInvisibleForCursor",null),(0,c.__decorate)([(0,p.watch)(":backSpaceAfterDelete")],y.prototype,"__backSpaceAfterDelete",null),(0,c.__decorate)([p.autobind],y.prototype,"__afterWrapList",null),(0,c.__decorate)([(0,p.watch)(":click")],y.prototype,"__onClickInput",null),(0,c.__decorate)([p.autobind],y.prototype,"isTodoLeafLabel",null),h.JoditPro.plugins.add("todo-list",y)},64839:function(e,t,o){"use strict";var i=o(11373),n=o.n(i),a=o(6441),s=o(2748),l=o(12153);a.Config.prototype.todoList={className:"todo-list",labelClassName:"todo-list__label",inputFactory:function(e){return e.createInside.element("input",{type:"checkbox",tabindex:-1})}},a.Config.prototype.controls.todoList={tooltip:"To-do List",icon:"todo-list",command:"todolist",isActive:function(e){var t=e.s.current();return!!(t&&s.Dom.closest(t,function(e){return s.Dom.isElement(e)&&s.Dom.isTag(e,"ul")&&e.classList.contains("todo-list")},e.editor))}},l.Icon.set("todo-list",n())}},function(e){return e(e.s=19374)}])});