UNPKG

jodit-pro

Version:

PRO Version of Jodit Editor

532 lines (486 loc) 21.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([[850],{ /***/ 5440: /***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { "use strict"; /* harmony export */ __webpack_require__.d(__webpack_exports__, { /* harmony export */ buildStylePopup: function() { return /* binding */ buildStylePopup; } /* harmony export */ }); /* harmony import */ var _helpers_apply_style__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(31105); /* harmony import */ var _helpers_classify_definitions__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(8060); /* harmony import */ var _helpers_detect_active_style__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(69341); /*! * 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 CLASS_NAME = 'jodit-style-popup'; function buildStylePopup(editor, definitions, close) { var groups = (0,_helpers_classify_definitions__WEBPACK_IMPORTED_MODULE_1__.classifyDefinitions)(definitions); var active = (0,_helpers_detect_active_style__WEBPACK_IMPORTED_MODULE_2__.detectActiveStyle)(editor, definitions); var container = editor.c.div(CLASS_NAME); var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined; try { for(var _iterator = groups[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){ var group = _step.value; var title = editor.c.div("".concat(CLASS_NAME, "__group-title")); title.textContent = editor.i18n(group.title); container.appendChild(title); var grid = editor.c.div("".concat(CLASS_NAME, "__grid")); var _iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = undefined; try { var _loop = function() { var def = _step1.value; var card = editor.c.element('button'); card.type = 'button'; var isActive = active === def; card.className = "".concat(CLASS_NAME, "__card") + (isActive ? " ".concat(CLASS_NAME, "__card_active_true") : ''); var preview = editor.c.div("".concat(CLASS_NAME, "__card-preview")); var previewEl = editor.c.element(def.element); var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined; try { for(var _iterator = def.classes[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){ var cls = _step.value; previewEl.classList.add(cls); } } catch (err) { _didIteratorError = true; _iteratorError = err; } finally{ try { if (!_iteratorNormalCompletion && _iterator.return != null) { _iterator.return(); } } finally{ if (_didIteratorError) { throw _iteratorError; } } } previewEl.textContent = def.name; preview.appendChild(previewEl); card.appendChild(preview); var label = editor.c.div("".concat(CLASS_NAME, "__card-label")); label.textContent = def.name; card.appendChild(label); editor.e.on(card, 'click', function() { editor.s.focus(); (0,_helpers_apply_style__WEBPACK_IMPORTED_MODULE_0__.applyStyle)(editor, def, definitions); editor.synchronizeValues(); close(); }); grid.appendChild(card); }; for(var _iterator1 = group.definitions[Symbol.iterator](), _step1; !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = true)_loop(); } catch (err) { _didIteratorError1 = true; _iteratorError1 = err; } finally{ try { if (!_iteratorNormalCompletion1 && _iterator1.return != null) { _iterator1.return(); } } finally{ if (_didIteratorError1) { throw _iteratorError1; } } } container.appendChild(grid); } } catch (err) { _didIteratorError = true; _iteratorError = err; } finally{ try { if (!_iteratorNormalCompletion && _iterator.return != null) { _iterator.return(); } } finally{ if (_didIteratorError) { throw _iteratorError; } } } return container; } /***/ }), /***/ 8060: /***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { "use strict"; /* harmony export */ __webpack_require__.d(__webpack_exports__, { /* harmony export */ classifyDefinitions: function() { return /* binding */ classifyDefinitions; } /* harmony export */ }); /* harmony import */ var jodit_esm_core_constants__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(82758); /*! * 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/ */ function classifyDefinitions(definitions) { var block = []; var inline = []; var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined; try { for(var _iterator = definitions[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){ var def = _step.value; if (jodit_esm_core_constants__WEBPACK_IMPORTED_MODULE_0__.IS_BLOCK.test(def.element)) { block.push(def); } else { inline.push(def); } } } catch (err) { _didIteratorError = true; _iteratorError = err; } finally{ try { if (!_iteratorNormalCompletion && _iterator.return != null) { _iterator.return(); } } finally{ if (_didIteratorError) { throw _iteratorError; } } } var groups = []; if (block.length) { groups.push({ title: 'Block styles', definitions: block }); } if (inline.length) { groups.push({ title: 'Text styles', definitions: inline }); } return groups; } /***/ }), /***/ 28609: /***/ (function(__unused_webpack_module, __unused_webpack___webpack_exports__, __webpack_require__) { "use strict"; /* harmony import */ var _helpers_detect_active_style__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(69341); /* harmony import */ var _ui_style_popup__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(5440); /* harmony import */ var _icon_svg__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(78955); /* harmony import */ var _icon_svg__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_icon_svg__WEBPACK_IMPORTED_MODULE_2__); /* harmony import */ var jodit_esm_config__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(6441); /*! * 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_3__.Config.prototype.customStyles = { definitions: [] }; jodit_esm_config__WEBPACK_IMPORTED_MODULE_3__.Config.prototype.controls.style = { tooltip: 'Styles', icon: (_icon_svg__WEBPACK_IMPORTED_MODULE_2___default()), isDisabled: function isDisabled(editor) { return !editor.o.customStyles.definitions.length; }, isActive: function isActive(editor) { var definitions = editor.o.customStyles.definitions; if (!definitions.length) { return false; } return (0,_helpers_detect_active_style__WEBPACK_IMPORTED_MODULE_0__.detectActiveStyle)(editor, definitions) != null; }, update: function update(editor, button) { var _button_control; var definitions = editor.o.customStyles.definitions; if (!definitions.length) { return; } var active = (0,_helpers_detect_active_style__WEBPACK_IMPORTED_MODULE_0__.detectActiveStyle)(editor, definitions); var isSelect = ((_button_control = button.control) === null || _button_control === void 0 ? void 0 : _button_control.component) === 'select'; if (editor.o.textIcons || isSelect) { if (active) { button.state.text = active.name; } else { button.state.text = isSelect ? editor.i18n('Styles') : ''; } } }, exec: function exec() { return false; }, popup: function popup(editor, _current, close) { var definitions = editor.o.customStyles.definitions; if (!definitions.length) { return false; } if (!editor.s.current()) { editor.s.focus(); } editor.s.save(); var popup = (0,_ui_style_popup__WEBPACK_IMPORTED_MODULE_1__.buildStylePopup)(editor, definitions, function() { editor.s.restore(); close(); }); editor.e.one('beforePopupClose', function() { editor.s.restore(); }); return popup; } }; /***/ }), /***/ 31105: /***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { "use strict"; /* harmony export */ __webpack_require__.d(__webpack_exports__, { /* harmony export */ applyStyle: function() { return /* binding */ applyStyle; } /* harmony export */ }); /* harmony import */ var _detect_active_style__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(69341); /* harmony import */ var jodit_esm_core_constants__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(82758); /* harmony import */ var jodit_esm_core_dom_dom__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(2748); /*! * 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/ */ function findTarget(editor, def) { var current = editor.s.current(); if (!current) { return null; } if (jodit_esm_core_constants__WEBPACK_IMPORTED_MODULE_1__.IS_BLOCK.test(def.element)) { return jodit_esm_core_dom_dom__WEBPACK_IMPORTED_MODULE_2__.Dom.closest(current, jodit_esm_core_dom_dom__WEBPACK_IMPORTED_MODULE_2__.Dom.isBlock, editor.editor); } var node = jodit_esm_core_dom_dom__WEBPACK_IMPORTED_MODULE_2__.Dom.isElement(current) ? current : current.parentNode; while(node && node !== editor.editor){ if (jodit_esm_core_dom_dom__WEBPACK_IMPORTED_MODULE_2__.Dom.isElement(node) && node.nodeName.toLowerCase() === def.element) { return node; } node = node.parentNode; } return null; } function removeClassesFromElement(el, classes) { var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined; try { for(var _iterator = classes[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){ var cls = _step.value; el.classList.remove(cls); } } catch (err) { _didIteratorError = true; _iteratorError = err; } finally{ try { if (!_iteratorNormalCompletion && _iterator.return != null) { _iterator.return(); } } finally{ if (_didIteratorError) { throw _iteratorError; } } } if (el.className === '') { el.removeAttribute('class'); } } function cleanupExtraClasses(editor, def) { if (def.classes.length <= 1) { return; } var current = editor.s.current(); if (!current) { return; } if (jodit_esm_core_constants__WEBPACK_IMPORTED_MODULE_1__.IS_BLOCK.test(def.element)) { var block = jodit_esm_core_dom_dom__WEBPACK_IMPORTED_MODULE_2__.Dom.closest(current, jodit_esm_core_dom_dom__WEBPACK_IMPORTED_MODULE_2__.Dom.isBlock, editor.editor); if (block) { removeClassesFromElement(block, def.classes.slice(1)); } } else { var target = findTarget(editor, def); if (target) { removeClassesFromElement(target, def.classes.slice(1)); if (target.nodeName.toLowerCase() === 'span' && !target.attributes.length) { jodit_esm_core_dom_dom__WEBPACK_IMPORTED_MODULE_2__.Dom.unwrap(target); } } } } function addExtraClasses(editor, def) { if (def.classes.length <= 1) { return; } var target = findTarget(editor, def); if (!target) { return; } for(var i = 1; i < def.classes.length; i++){ target.classList.add(def.classes[i]); } } function applyStyle(editor, def, definitions) { var active = (0,_detect_active_style__WEBPACK_IMPORTED_MODULE_0__.detectActiveStyle)(editor, definitions); if (active) { editor.s.commitStyle({ element: active.element, attributes: { class: active.classes[0] } }); cleanupExtraClasses(editor, active); if (active === def) { return; } } editor.s.commitStyle({ element: def.element, attributes: { class: def.classes[0] } }); addExtraClasses(editor, def); } /***/ }), /***/ 69341: /***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { "use strict"; /* harmony export */ __webpack_require__.d(__webpack_exports__, { /* harmony export */ detectActiveStyle: function() { return /* binding */ detectActiveStyle; } /* harmony export */ }); /* harmony import */ var jodit_esm_core_constants__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(82758); /* harmony import */ var jodit_esm_core_dom_dom__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(2748); /*! * 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/ */ function elementMatchesDefinition(el, def) { if (el.nodeName.toLowerCase() !== def.element) { return false; } return def.classes.every(function(cls) { return el.classList.contains(cls); }); } function detectActiveStyle(editor, definitions) { var current = editor.s.current(); if (!current) { return null; } var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined; try { for(var _iterator = definitions[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){ var def = _step.value; if (jodit_esm_core_constants__WEBPACK_IMPORTED_MODULE_0__.IS_BLOCK.test(def.element)) { var block = jodit_esm_core_dom_dom__WEBPACK_IMPORTED_MODULE_1__.Dom.closest(current, jodit_esm_core_dom_dom__WEBPACK_IMPORTED_MODULE_1__.Dom.isBlock, editor.editor); if (block && elementMatchesDefinition(block, def)) { return def; } } else { var node = jodit_esm_core_dom_dom__WEBPACK_IMPORTED_MODULE_1__.Dom.isElement(current) ? current : current.parentNode; while(node && node !== editor.editor){ if (jodit_esm_core_dom_dom__WEBPACK_IMPORTED_MODULE_1__.Dom.isElement(node) && elementMatchesDefinition(node, def)) { return def; } node = node.parentNode; } } } } catch (err) { _didIteratorError = true; _iteratorError = err; } finally{ try { if (!_iteratorNormalCompletion && _iterator.return != null) { _iterator.return(); } } finally{ if (_didIteratorError) { throw _iteratorError; } } } return null; } /***/ }), /***/ 75554: /***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { "use strict"; __webpack_require__.r(__webpack_exports__); /* harmony export */ __webpack_require__.d(__webpack_exports__, { /* harmony export */ style: function() { return /* binding */ style; } /* 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 _config__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(28609); /* harmony import */ var jodit_esm_core_plugin__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(50911); /* harmony import */ var jodit_pro_jodit_pro__WEBPACK_IMPORTED_MODULE_8__ = __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 style = /*#__PURE__*/ function(Plugin) { "use strict"; (0,_swc_helpers_inherits__WEBPACK_IMPORTED_MODULE_4__._)(style, Plugin); function style() { (0,_swc_helpers_class_call_check__WEBPACK_IMPORTED_MODULE_1__._)(this, style); var _this; _this = (0,_swc_helpers_call_super__WEBPACK_IMPORTED_MODULE_0__._)(this, style, arguments), /** @override */ (0,_swc_helpers_define_property__WEBPACK_IMPORTED_MODULE_3__._)(_this, "buttons", [ { name: 'style', group: 'font' } ]); return _this; } (0,_swc_helpers_create_class__WEBPACK_IMPORTED_MODULE_2__._)(style, [ { key: "afterInit", value: /** @override */ function afterInit(_jodit) {} }, { key: "beforeDestruct", value: /** @override */ function beforeDestruct(_jodit) {} } ]); return style; }((0,_swc_helpers_wrap_native_super__WEBPACK_IMPORTED_MODULE_5__._)(jodit_esm_core_plugin__WEBPACK_IMPORTED_MODULE_7__.Plugin)); /** @override */ (0,_swc_helpers_define_property__WEBPACK_IMPORTED_MODULE_3__._)(style, "requires", [ 'license' ]); jodit_pro_jodit_pro__WEBPACK_IMPORTED_MODULE_8__.JoditPro.plugins.add('style', style); /***/ }), /***/ 78955: /***/ (function(module) { module.exports = "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\" width=\"24\" height=\"24\" stroke=\"currentColor\" stroke-width=\"1.5\"> <rect x=\"2\" y=\"3.5\" width=\"9\" height=\"9\" rx=\"1.5\" fill=\"none\"/> <rect x=\"2\" y=\"14.5\" width=\"9\" height=\"9\" rx=\"1.5\" fill=\"none\"/> <rect x=\"13\" y=\"14.5\" width=\"9\" height=\"9\" rx=\"1.5\" fill=\"none\"/> <rect x=\"13\" y=\"3.5\" width=\"9\" height=\"9\" rx=\"1.5\" fill=\"currentColor\" transform=\"rotate(45 17.5 8)\"/> </svg>" /***/ }) }, /******/ function(__webpack_require__) { // webpackRuntimeModules /******/ var __webpack_exec__ = function(moduleId) { return __webpack_require__(__webpack_require__.s = moduleId); } /******/ var __webpack_exports__ = (__webpack_exec__(75554)); /******/ return __webpack_exports__; /******/ } ]); });