UNPKG

jodit-pro

Version:

PRO Version of Jodit Editor

371 lines (340 loc) 18.5 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 webpackUniversalModuleDefinition(root, factory) { if(typeof exports === 'object' && typeof module === 'object') module.exports = factory(); else if(typeof define === 'function' && define.amd) define([], factory); else { var a = factory(); for(var i in a) (typeof exports === 'object' ? exports : root)[i] = a[i]; } })(self, function() { return (self["webpackChunkjodit_pro"] = self["webpackChunkjodit_pro"] || []).push([[502],{ /***/ 11373: /***/ (function(module) { module.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\"> <!-- <rect fill=\"none\" height=\"256\" width=\"256\"/>--> <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(__unused_webpack_module, __webpack_exports__, __webpack_require__) { "use strict"; __webpack_require__.r(__webpack_exports__); /* harmony export */ __webpack_require__.d(__webpack_exports__, { /* harmony export */ TodoList: function() { return /* binding */ TodoList; } /* harmony export */ }); /* harmony import */ var _swc_helpers_call_super__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(80294); /* harmony import */ var _swc_helpers_class_call_check__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(20616); /* harmony import */ var _swc_helpers_create_class__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(67709); /* harmony import */ var _swc_helpers_define_property__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(82749); /* harmony import */ var _swc_helpers_inherits__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(18766); /* harmony import */ var _swc_helpers_wrap_native_super__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(23078); /* harmony import */ var _swc_helpers_ts_decorate__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(31635); /* harmony import */ var _config__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(64839); /* harmony import */ var jodit_esm_core_constants__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(82758); /* harmony import */ var jodit_esm_core_decorators__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(65478); /* harmony import */ var jodit_esm_core_dom_dom__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(2748); /* harmony import */ var jodit_esm_core_helpers_utils__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(43555); /* harmony import */ var jodit_esm_core_plugin__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(50911); /* harmony import */ var jodit_esm_core_selection__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(59242); /* harmony import */ var jodit_pro_jodit_pro__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(2692); /*! * Jodit Editor PRO (https://xdsoft.net/jodit/) * See LICENSE.md in the project root for license information. * Copyright (c) 2013-2026 Valerii Chupurnov. All rights reserved. https://xdsoft.net/jodit/pro/ */ var apply = true; var TodoList = /*#__PURE__*/ function(Plugin) { "use strict"; (0,_swc_helpers_inherits__WEBPACK_IMPORTED_MODULE_4__._)(TodoList, Plugin); function TodoList() { (0,_swc_helpers_class_call_check__WEBPACK_IMPORTED_MODULE_1__._)(this, TodoList); var _this; _this = (0,_swc_helpers_call_super__WEBPACK_IMPORTED_MODULE_0__._)(this, TodoList, arguments), (0,_swc_helpers_define_property__WEBPACK_IMPORTED_MODULE_3__._)(_this, "buttons", [ { name: 'todoList', group: 'list' } ]), (0,_swc_helpers_define_property__WEBPACK_IMPORTED_MODULE_3__._)(_this, "__isOwnCommand", false); return _this; } (0,_swc_helpers_create_class__WEBPACK_IMPORTED_MODULE_2__._)(TodoList, [ { key: "afterInit", value: function afterInit(jodit) { jodit.registerCommand('todoList', this.onCommand); } }, { key: "onCommand", value: function onCommand() { try { this.__isOwnCommand = true; this.jodit.s.commitStyle({ element: 'ul', attributes: { class: this.j.o.todoList.className }, hooks: apply ? { afterWrapList: this.__afterWrapList, afterToggleAttribute: this.__afterWrapList } : {} }); } finally{ this.__isOwnCommand = false; } return false; } }, { key: "__prependInputLabel", value: function __prependInputLabel(li) { var jodit = this.jodit; var _this_j_o_todoList = this.j.o.todoList, labelClassName = _this_j_o_todoList.labelClassName, inputFactory = _this_j_o_todoList.inputFactory; if (li.querySelector('label.' + labelClassName)) { return; } var label = jodit.createInside.element('label', { contenteditable: 'false', class: labelClassName }); var input = inputFactory(jodit); label.appendChild(input); jodit_esm_core_dom_dom__WEBPACK_IMPORTED_MODULE_10__.Dom.prepend(li, label); } }, { key: "__afterToggleList", value: function __afterToggleList(mode, list) { if (!apply) return; if ((mode === jodit_esm_core_selection__WEBPACK_IMPORTED_MODULE_13__.CHANGE || mode === jodit_esm_core_selection__WEBPACK_IMPORTED_MODULE_13__.REPLACE) && this.__isOwnCommand) { return this.__appendInputs(list); } if (mode === jodit_esm_core_selection__WEBPACK_IMPORTED_MODULE_13__.UNWRAP || mode === jodit_esm_core_selection__WEBPACK_IMPORTED_MODULE_13__.REPLACE || mode === jodit_esm_core_selection__WEBPACK_IMPORTED_MODULE_13__.CHANGE) { return this.__removeInputs(list); } } }, { key: "__appendInputs", value: function __appendInputs(list) { list.querySelectorAll('li').forEach(this.__prependInputLabel); } }, { key: "__removeInputs", value: function __removeInputs(list) { var labelClassName = this.j.o.todoList.labelClassName; list.querySelectorAll('label.' + labelClassName).forEach(jodit_esm_core_dom_dom__WEBPACK_IMPORTED_MODULE_10__.Dom.safeRemove); } }, { key: "__beforeToggleOrderedList", value: function __beforeToggleOrderedList(mode, list, style) { var _style_options_attributes; if (!apply) return; var ukey = '__beforeToggleOrderedList'; if (mode !== jodit_esm_core_selection__WEBPACK_IMPORTED_MODULE_13__.REPLACE && (list.classList.contains(this.j.o.todoList.className) || style.isApplied(list, ukey)) && (style.element === 'ul' || style.element === 'ol') && ((_style_options_attributes = style.options.attributes) === null || _style_options_attributes === void 0 ? void 0 : _style_options_attributes.class) !== this.j.o.todoList.className) { var wrapper = jodit_esm_core_dom_dom__WEBPACK_IMPORTED_MODULE_10__.Dom.replace(list, style.element, this.jodit.createInside); style.setApplied(wrapper, ukey); this.__removeInputs(wrapper); return wrapper; } } }, { key: "__afterEnter", value: function __afterEnter() { (0,jodit_esm_core_helpers_utils__WEBPACK_IMPORTED_MODULE_11__.$$)('ul.' + this.j.o.todoList.className + ' li', this.jodit.editor).forEach(this.__prependInputLabel); } }, { key: "__afterTab", value: function __afterTab() { (0,jodit_esm_core_helpers_utils__WEBPACK_IMPORTED_MODULE_11__.$$)('ul:not(.' + this.j.o.todoList.className + ') > li > label', this.jodit.editor).filter(this.isTodoLeafLabel).forEach(jodit_esm_core_dom_dom__WEBPACK_IMPORTED_MODULE_10__.Dom.safeRemove); } }, { key: "__changeSelection", value: function __changeSelection(e) { var target = this.j.s.current(); if (this.isTodoLeafLabel(target)) { e.preventDefault(); e.stopPropagation(); this.j.s.setCursorAfter(target); } } }, { key: "__isEmptyListLeaf", value: function __isEmptyListLeaf(li) { var _this = this; return jodit_esm_core_dom_dom__WEBPACK_IMPORTED_MODULE_10__.Dom.isEmpty(li, function(node) { if (node.nodeName.toLowerCase() === 'input' && _this.isTodoLeafLabel(node.parentElement)) { return false; } return jodit_esm_core_constants__WEBPACK_IMPORTED_MODULE_8__.NO_EMPTY_TAGS.has(node.tagName.toLowerCase()); }); } }, { key: "__backSpaceBeforeCases", value: /** * Remove checkbox before processing backspace */ function __backSpaceBeforeCases(backspace, fake) { if (backspace) { var sibling = jodit_esm_core_dom_dom__WEBPACK_IMPORTED_MODULE_10__.Dom.findNotEmptySibling(fake, true); this.isTodoLeafLabel(sibling) && jodit_esm_core_dom_dom__WEBPACK_IMPORTED_MODULE_10__.Dom.safeRemove(sibling); } } }, { key: "__isInvisibleForCursor", value: function __isInvisibleForCursor(elm) { if (this.isTodoLeafLabel(elm)) { return true; } } }, { key: "__backSpaceAfterDelete", value: /** * Just normalize the list if all of a sudden the checkboxes */ function __backSpaceAfterDelete() { var _this = this; var labelClassName = this.j.o.todoList.labelClassName; (0,jodit_esm_core_helpers_utils__WEBPACK_IMPORTED_MODULE_11__.$$)('label.' + labelClassName, this.jodit.editor).forEach(function(label) { if (!label.closest('ul.' + _this.j.o.todoList.className)) { jodit_esm_core_dom_dom__WEBPACK_IMPORTED_MODULE_10__.Dom.safeRemove(label); } else { label.previousSibling && label.parentElement && jodit_esm_core_dom_dom__WEBPACK_IMPORTED_MODULE_10__.Dom.prepend(label.parentElement, label); } }); } }, { key: "__afterWrapList", value: function __afterWrapList(mode, wrapper) { mode === jodit_esm_core_selection__WEBPACK_IMPORTED_MODULE_13__.WRAP && this.__appendInputs(wrapper); } }, { key: "__onClickInput", value: function __onClickInput(e) { var input = e.target; if (input && jodit_esm_core_dom_dom__WEBPACK_IMPORTED_MODULE_10__.Dom.isTag(input, 'input') && input.type === 'checkbox' && this.isTodoLeafLabel(input.parentElement)) { (0,jodit_esm_core_helpers_utils__WEBPACK_IMPORTED_MODULE_11__.attr)(input, 'checked', input.checked ? 'checked' : null); } } }, { key: "isTodoLeafLabel", value: function isTodoLeafLabel(node) { var labelClassName = this.j.o.todoList.labelClassName; return jodit_esm_core_dom_dom__WEBPACK_IMPORTED_MODULE_10__.Dom.isHTMLElement(node) && node.classList.contains(labelClassName); } }, { key: "beforeDestruct", value: function beforeDestruct(jodit) {} } ]); return TodoList; }((0,_swc_helpers_wrap_native_super__WEBPACK_IMPORTED_MODULE_5__._)(jodit_esm_core_plugin__WEBPACK_IMPORTED_MODULE_12__.Plugin)); (0,_swc_helpers_define_property__WEBPACK_IMPORTED_MODULE_3__._)(TodoList, "requires", [ 'license' ]); (0,_swc_helpers_ts_decorate__WEBPACK_IMPORTED_MODULE_6__.__decorate)([ jodit_esm_core_decorators__WEBPACK_IMPORTED_MODULE_9__.autobind ], TodoList.prototype, "onCommand", null); (0,_swc_helpers_ts_decorate__WEBPACK_IMPORTED_MODULE_6__.__decorate)([ jodit_esm_core_decorators__WEBPACK_IMPORTED_MODULE_9__.autobind ], TodoList.prototype, "__prependInputLabel", null); (0,_swc_helpers_ts_decorate__WEBPACK_IMPORTED_MODULE_6__.__decorate)([ (0,jodit_esm_core_decorators__WEBPACK_IMPORTED_MODULE_9__.watch)(':commitStyleAfterToggleList') ], TodoList.prototype, "__afterToggleList", null); (0,_swc_helpers_ts_decorate__WEBPACK_IMPORTED_MODULE_6__.__decorate)([ (0,jodit_esm_core_decorators__WEBPACK_IMPORTED_MODULE_9__.watch)(':commitStyleBeforeUnwrapList') ], TodoList.prototype, "__beforeToggleOrderedList", null); (0,_swc_helpers_ts_decorate__WEBPACK_IMPORTED_MODULE_6__.__decorate)([ (0,jodit_esm_core_decorators__WEBPACK_IMPORTED_MODULE_9__.watch)(':afterEnter') ], TodoList.prototype, "__afterEnter", null); (0,_swc_helpers_ts_decorate__WEBPACK_IMPORTED_MODULE_6__.__decorate)([ (0,jodit_esm_core_decorators__WEBPACK_IMPORTED_MODULE_9__.watch)(':afterTab') ], TodoList.prototype, "__afterTab", null); (0,_swc_helpers_ts_decorate__WEBPACK_IMPORTED_MODULE_6__.__decorate)([ (0,jodit_esm_core_decorators__WEBPACK_IMPORTED_MODULE_9__.watch)('j.ed:selectionchange'), (0,jodit_esm_core_decorators__WEBPACK_IMPORTED_MODULE_9__.watch)(':afterEnter') ], TodoList.prototype, "__changeSelection", null); (0,_swc_helpers_ts_decorate__WEBPACK_IMPORTED_MODULE_6__.__decorate)([ (0,jodit_esm_core_decorators__WEBPACK_IMPORTED_MODULE_9__.watch)(':enterIsEmptyListLeaf') ], TodoList.prototype, "__isEmptyListLeaf", null); (0,_swc_helpers_ts_decorate__WEBPACK_IMPORTED_MODULE_6__.__decorate)([ (0,jodit_esm_core_decorators__WEBPACK_IMPORTED_MODULE_9__.watch)(':backSpaceBeforeCases') ], TodoList.prototype, "__backSpaceBeforeCases", null); (0,_swc_helpers_ts_decorate__WEBPACK_IMPORTED_MODULE_6__.__decorate)([ (0,jodit_esm_core_decorators__WEBPACK_IMPORTED_MODULE_9__.watch)(':backSpaceIsMovedIgnore'), (0,jodit_esm_core_decorators__WEBPACK_IMPORTED_MODULE_9__.watch)(':isInvisibleForCursor') ], TodoList.prototype, "__isInvisibleForCursor", null); (0,_swc_helpers_ts_decorate__WEBPACK_IMPORTED_MODULE_6__.__decorate)([ (0,jodit_esm_core_decorators__WEBPACK_IMPORTED_MODULE_9__.watch)(':backSpaceAfterDelete') ], TodoList.prototype, "__backSpaceAfterDelete", null); (0,_swc_helpers_ts_decorate__WEBPACK_IMPORTED_MODULE_6__.__decorate)([ jodit_esm_core_decorators__WEBPACK_IMPORTED_MODULE_9__.autobind ], TodoList.prototype, "__afterWrapList", null); (0,_swc_helpers_ts_decorate__WEBPACK_IMPORTED_MODULE_6__.__decorate)([ (0,jodit_esm_core_decorators__WEBPACK_IMPORTED_MODULE_9__.watch)(':click') ], TodoList.prototype, "__onClickInput", null); (0,_swc_helpers_ts_decorate__WEBPACK_IMPORTED_MODULE_6__.__decorate)([ jodit_esm_core_decorators__WEBPACK_IMPORTED_MODULE_9__.autobind ], TodoList.prototype, "isTodoLeafLabel", null); jodit_pro_jodit_pro__WEBPACK_IMPORTED_MODULE_14__.JoditPro.plugins.add('todo-list', TodoList); /***/ }), /***/ 64839: /***/ (function(__unused_webpack_module, __unused_webpack___webpack_exports__, __webpack_require__) { "use strict"; /* harmony import */ var _assets_todo_list_svg__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(11373); /* harmony import */ var _assets_todo_list_svg__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_assets_todo_list_svg__WEBPACK_IMPORTED_MODULE_0__); /* harmony import */ var jodit_esm_config__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(6441); /* harmony import */ var jodit_esm_core_dom_dom__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(2748); /* harmony import */ var jodit_esm_core_ui_icon__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(12153); /*! * Jodit Editor PRO (https://xdsoft.net/jodit/) * See LICENSE.md in the project root for license information. * Copyright (c) 2013-2026 Valerii Chupurnov. All rights reserved. https://xdsoft.net/jodit/pro/ */ jodit_esm_config__WEBPACK_IMPORTED_MODULE_1__.Config.prototype.todoList = { className: 'todo-list', labelClassName: 'todo-list__label', inputFactory: function inputFactory(jodit) { return jodit.createInside.element('input', { type: 'checkbox', tabindex: -1 }); } }; jodit_esm_config__WEBPACK_IMPORTED_MODULE_1__.Config.prototype.controls.todoList = { tooltip: 'To-do List', icon: 'todo-list', command: 'todolist', isActive: function isActive(e) { var current = e.s.current(); return Boolean(current && jodit_esm_core_dom_dom__WEBPACK_IMPORTED_MODULE_2__.Dom.closest(current, function(n) { return jodit_esm_core_dom_dom__WEBPACK_IMPORTED_MODULE_2__.Dom.isElement(n) && jodit_esm_core_dom_dom__WEBPACK_IMPORTED_MODULE_2__.Dom.isTag(n, 'ul') && n.classList.contains('todo-list'); }, e.editor)); } }; jodit_esm_core_ui_icon__WEBPACK_IMPORTED_MODULE_3__.Icon.set('todo-list', (_assets_todo_list_svg__WEBPACK_IMPORTED_MODULE_0___default())); /***/ }) }, /******/ function(__webpack_require__) { // webpackRuntimeModules /******/ var __webpack_exec__ = function(moduleId) { return __webpack_require__(__webpack_require__.s = moduleId); } /******/ var __webpack_exports__ = (__webpack_exec__(19374)); /******/ return __webpack_exports__; /******/ } ]); });