jodit-pro
Version:
PRO Version of Jodit Editor
292 lines (266 loc) • 14.7 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
*/
(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_define_property__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(82749);
/* harmony import */ var _swc_helpers_ts_decorate__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(31635);
/* harmony import */ var _config__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(64839);
/* harmony import */ var jodit_esm_core_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(82758);
/* harmony import */ var jodit_esm_core_decorators__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(65478);
/* harmony import */ var jodit_esm_core_dom_dom__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(2748);
/* harmony import */ var jodit_esm_core_helpers_utils__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(43555);
/* harmony import */ var jodit_esm_core_plugin__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(50911);
/* harmony import */ var jodit_esm_core_selection__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(59242);
/* harmony import */ var jodit_pro_jodit_pro__WEBPACK_IMPORTED_MODULE_9__ = __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/
*/
const apply = true;
class TodoList extends jodit_esm_core_plugin__WEBPACK_IMPORTED_MODULE_7__.Plugin {
afterInit(jodit) {
jodit.registerCommand('todoList', this.onCommand);
}
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;
}
__prependInputLabel(li) {
const { jodit } = this;
const { labelClassName, inputFactory } = this.j.o.todoList;
if (li.querySelector('label.' + labelClassName)) {
return;
}
const label = jodit.createInside.element('label', {
contenteditable: 'false',
class: labelClassName
});
const input = inputFactory(jodit);
label.appendChild(input);
jodit_esm_core_dom_dom__WEBPACK_IMPORTED_MODULE_5__.Dom.prepend(li, label);
}
__afterToggleList(mode, list) {
if (!apply) return;
if ((mode === jodit_esm_core_selection__WEBPACK_IMPORTED_MODULE_8__.CHANGE || mode === jodit_esm_core_selection__WEBPACK_IMPORTED_MODULE_8__.REPLACE) && this.__isOwnCommand) {
return this.__appendInputs(list);
}
if (mode === jodit_esm_core_selection__WEBPACK_IMPORTED_MODULE_8__.UNWRAP || mode === jodit_esm_core_selection__WEBPACK_IMPORTED_MODULE_8__.REPLACE || mode === jodit_esm_core_selection__WEBPACK_IMPORTED_MODULE_8__.CHANGE) {
return this.__removeInputs(list);
}
}
__appendInputs(list) {
list.querySelectorAll('li').forEach(this.__prependInputLabel);
}
__removeInputs(list) {
const { labelClassName } = this.j.o.todoList;
list.querySelectorAll('label.' + labelClassName).forEach(jodit_esm_core_dom_dom__WEBPACK_IMPORTED_MODULE_5__.Dom.safeRemove);
}
__beforeToggleOrderedList(mode, list, style) {
if (!apply) return;
const ukey = '__beforeToggleOrderedList';
if (mode !== jodit_esm_core_selection__WEBPACK_IMPORTED_MODULE_8__.REPLACE && (list.classList.contains(this.j.o.todoList.className) || style.isApplied(list, ukey)) && (style.element === 'ul' || style.element === 'ol') && style.options.attributes?.class !== this.j.o.todoList.className) {
const wrapper = jodit_esm_core_dom_dom__WEBPACK_IMPORTED_MODULE_5__.Dom.replace(list, style.element, this.jodit.createInside);
style.setApplied(wrapper, ukey);
this.__removeInputs(wrapper);
return wrapper;
}
}
__afterEnter() {
(0,jodit_esm_core_helpers_utils__WEBPACK_IMPORTED_MODULE_6__.$$)('ul.' + this.j.o.todoList.className + ' li', this.jodit.editor).forEach(this.__prependInputLabel);
}
__afterTab() {
(0,jodit_esm_core_helpers_utils__WEBPACK_IMPORTED_MODULE_6__.$$)('ul:not(.' + this.j.o.todoList.className + ') > li > label', this.jodit.editor).filter(this.isTodoLeafLabel).forEach(jodit_esm_core_dom_dom__WEBPACK_IMPORTED_MODULE_5__.Dom.safeRemove);
}
__changeSelection(e) {
const target = this.j.s.current();
if (this.isTodoLeafLabel(target)) {
e.preventDefault();
e.stopPropagation();
this.j.s.setCursorAfter(target);
}
}
__isEmptyListLeaf(li) {
return jodit_esm_core_dom_dom__WEBPACK_IMPORTED_MODULE_5__.Dom.isEmpty(li, (node)=>{
if (node.nodeName.toLowerCase() === 'input' && this.isTodoLeafLabel(node.parentElement)) {
return false;
}
return jodit_esm_core_constants__WEBPACK_IMPORTED_MODULE_3__.NO_EMPTY_TAGS.has(node.tagName.toLowerCase());
});
}
/**
* Remove checkbox before processing backspace
*/ __backSpaceBeforeCases(backspace, fake) {
if (backspace) {
const sibling = jodit_esm_core_dom_dom__WEBPACK_IMPORTED_MODULE_5__.Dom.findNotEmptySibling(fake, true);
this.isTodoLeafLabel(sibling) && jodit_esm_core_dom_dom__WEBPACK_IMPORTED_MODULE_5__.Dom.safeRemove(sibling);
}
}
__isInvisibleForCursor(elm) {
if (this.isTodoLeafLabel(elm)) {
return true;
}
}
/**
* Just normalize the list if all of a sudden the checkboxes
*/ __backSpaceAfterDelete() {
const { labelClassName } = this.j.o.todoList;
(0,jodit_esm_core_helpers_utils__WEBPACK_IMPORTED_MODULE_6__.$$)('label.' + labelClassName, this.jodit.editor).forEach((label)=>{
if (!label.closest('ul.' + this.j.o.todoList.className)) {
jodit_esm_core_dom_dom__WEBPACK_IMPORTED_MODULE_5__.Dom.safeRemove(label);
} else {
label.previousSibling && label.parentElement && jodit_esm_core_dom_dom__WEBPACK_IMPORTED_MODULE_5__.Dom.prepend(label.parentElement, label);
}
});
}
__afterWrapList(mode, wrapper) {
mode === jodit_esm_core_selection__WEBPACK_IMPORTED_MODULE_8__.WRAP && this.__appendInputs(wrapper);
}
__onClickInput(e) {
const input = e.target;
if (input && jodit_esm_core_dom_dom__WEBPACK_IMPORTED_MODULE_5__.Dom.isTag(input, 'input') && input.type === 'checkbox' && this.isTodoLeafLabel(input.parentElement)) {
(0,jodit_esm_core_helpers_utils__WEBPACK_IMPORTED_MODULE_6__.attr)(input, 'checked', input.checked ? 'checked' : null);
}
}
isTodoLeafLabel(node) {
const { labelClassName } = this.j.o.todoList;
return jodit_esm_core_dom_dom__WEBPACK_IMPORTED_MODULE_5__.Dom.isHTMLElement(node) && node.classList.contains(labelClassName);
}
beforeDestruct(jodit) {}
constructor(...args){
super(...args), (0,_swc_helpers_define_property__WEBPACK_IMPORTED_MODULE_0__._)(this, "buttons", [
{
name: 'todoList',
group: 'list'
}
]), (0,_swc_helpers_define_property__WEBPACK_IMPORTED_MODULE_0__._)(this, "__isOwnCommand", false);
}
}
(0,_swc_helpers_define_property__WEBPACK_IMPORTED_MODULE_0__._)(TodoList, "requires", [
'license'
]);
(0,_swc_helpers_ts_decorate__WEBPACK_IMPORTED_MODULE_1__.__decorate)([
jodit_esm_core_decorators__WEBPACK_IMPORTED_MODULE_4__.autobind
], TodoList.prototype, "onCommand", null);
(0,_swc_helpers_ts_decorate__WEBPACK_IMPORTED_MODULE_1__.__decorate)([
jodit_esm_core_decorators__WEBPACK_IMPORTED_MODULE_4__.autobind
], TodoList.prototype, "__prependInputLabel", null);
(0,_swc_helpers_ts_decorate__WEBPACK_IMPORTED_MODULE_1__.__decorate)([
(0,jodit_esm_core_decorators__WEBPACK_IMPORTED_MODULE_4__.watch)(':commitStyleAfterToggleList')
], TodoList.prototype, "__afterToggleList", null);
(0,_swc_helpers_ts_decorate__WEBPACK_IMPORTED_MODULE_1__.__decorate)([
(0,jodit_esm_core_decorators__WEBPACK_IMPORTED_MODULE_4__.watch)(':commitStyleBeforeUnwrapList')
], TodoList.prototype, "__beforeToggleOrderedList", null);
(0,_swc_helpers_ts_decorate__WEBPACK_IMPORTED_MODULE_1__.__decorate)([
(0,jodit_esm_core_decorators__WEBPACK_IMPORTED_MODULE_4__.watch)(':afterEnter')
], TodoList.prototype, "__afterEnter", null);
(0,_swc_helpers_ts_decorate__WEBPACK_IMPORTED_MODULE_1__.__decorate)([
(0,jodit_esm_core_decorators__WEBPACK_IMPORTED_MODULE_4__.watch)(':afterTab')
], TodoList.prototype, "__afterTab", null);
(0,_swc_helpers_ts_decorate__WEBPACK_IMPORTED_MODULE_1__.__decorate)([
(0,jodit_esm_core_decorators__WEBPACK_IMPORTED_MODULE_4__.watch)('j.ed:selectionchange'),
(0,jodit_esm_core_decorators__WEBPACK_IMPORTED_MODULE_4__.watch)(':afterEnter')
], TodoList.prototype, "__changeSelection", null);
(0,_swc_helpers_ts_decorate__WEBPACK_IMPORTED_MODULE_1__.__decorate)([
(0,jodit_esm_core_decorators__WEBPACK_IMPORTED_MODULE_4__.watch)(':enterIsEmptyListLeaf')
], TodoList.prototype, "__isEmptyListLeaf", null);
(0,_swc_helpers_ts_decorate__WEBPACK_IMPORTED_MODULE_1__.__decorate)([
(0,jodit_esm_core_decorators__WEBPACK_IMPORTED_MODULE_4__.watch)(':backSpaceBeforeCases')
], TodoList.prototype, "__backSpaceBeforeCases", null);
(0,_swc_helpers_ts_decorate__WEBPACK_IMPORTED_MODULE_1__.__decorate)([
(0,jodit_esm_core_decorators__WEBPACK_IMPORTED_MODULE_4__.watch)(':backSpaceIsMovedIgnore'),
(0,jodit_esm_core_decorators__WEBPACK_IMPORTED_MODULE_4__.watch)(':isInvisibleForCursor')
], TodoList.prototype, "__isInvisibleForCursor", null);
(0,_swc_helpers_ts_decorate__WEBPACK_IMPORTED_MODULE_1__.__decorate)([
(0,jodit_esm_core_decorators__WEBPACK_IMPORTED_MODULE_4__.watch)(':backSpaceAfterDelete')
], TodoList.prototype, "__backSpaceAfterDelete", null);
(0,_swc_helpers_ts_decorate__WEBPACK_IMPORTED_MODULE_1__.__decorate)([
jodit_esm_core_decorators__WEBPACK_IMPORTED_MODULE_4__.autobind
], TodoList.prototype, "__afterWrapList", null);
(0,_swc_helpers_ts_decorate__WEBPACK_IMPORTED_MODULE_1__.__decorate)([
(0,jodit_esm_core_decorators__WEBPACK_IMPORTED_MODULE_4__.watch)(':click')
], TodoList.prototype, "__onClickInput", null);
(0,_swc_helpers_ts_decorate__WEBPACK_IMPORTED_MODULE_1__.__decorate)([
jodit_esm_core_decorators__WEBPACK_IMPORTED_MODULE_4__.autobind
], TodoList.prototype, "isTodoLeafLabel", null);
jodit_pro_jodit_pro__WEBPACK_IMPORTED_MODULE_9__.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: (jodit)=>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 (e) {
const current = e.s.current();
return Boolean(current && jodit_esm_core_dom_dom__WEBPACK_IMPORTED_MODULE_2__.Dom.closest(current, (n)=>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__;
/******/ }
]);
});