jodit 4.12.2 → 4.12.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (62) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/es2015/jodit.css +1 -1
  3. package/es2015/jodit.fat.min.js +4 -4
  4. package/es2015/jodit.js +69 -11
  5. package/es2015/jodit.min.js +3 -3
  6. package/es2015/plugins/debug/debug.css +1 -1
  7. package/es2015/plugins/debug/debug.js +1 -1
  8. package/es2015/plugins/debug/debug.min.js +1 -1
  9. package/es2015/plugins/speech-recognize/speech-recognize.css +1 -1
  10. package/es2015/plugins/speech-recognize/speech-recognize.js +50 -8
  11. package/es2015/plugins/speech-recognize/speech-recognize.min.js +2 -2
  12. package/es2018/jodit.fat.min.js +4 -4
  13. package/es2018/jodit.min.js +24 -24
  14. package/es2018/plugins/debug/debug.min.js +1 -1
  15. package/es2018/plugins/speech-recognize/speech-recognize.min.js +2 -2
  16. package/es2021/jodit.css +1 -1
  17. package/es2021/jodit.fat.min.js +4 -4
  18. package/es2021/jodit.js +69 -11
  19. package/es2021/jodit.min.js +3 -3
  20. package/es2021/plugins/debug/debug.css +1 -1
  21. package/es2021/plugins/debug/debug.js +1 -1
  22. package/es2021/plugins/debug/debug.min.js +1 -1
  23. package/es2021/plugins/speech-recognize/speech-recognize.css +1 -1
  24. package/es2021/plugins/speech-recognize/speech-recognize.js +50 -8
  25. package/es2021/plugins/speech-recognize/speech-recognize.min.js +2 -2
  26. package/es2021.en/jodit.css +1 -1
  27. package/es2021.en/jodit.fat.min.js +4 -4
  28. package/es2021.en/jodit.js +69 -11
  29. package/es2021.en/jodit.min.js +3 -3
  30. package/es2021.en/plugins/debug/debug.css +1 -1
  31. package/es2021.en/plugins/debug/debug.js +1 -1
  32. package/es2021.en/plugins/debug/debug.min.js +1 -1
  33. package/es2021.en/plugins/speech-recognize/speech-recognize.css +1 -1
  34. package/es2021.en/plugins/speech-recognize/speech-recognize.js +50 -8
  35. package/es2021.en/plugins/speech-recognize/speech-recognize.min.js +2 -2
  36. package/es5/jodit.css +2 -2
  37. package/es5/jodit.fat.min.js +2 -2
  38. package/es5/jodit.js +72 -11
  39. package/es5/jodit.min.css +2 -2
  40. package/es5/jodit.min.js +2 -2
  41. package/es5/plugins/debug/debug.css +1 -1
  42. package/es5/plugins/debug/debug.js +1 -1
  43. package/es5/plugins/debug/debug.min.js +1 -1
  44. package/es5/plugins/speech-recognize/speech-recognize.css +1 -1
  45. package/es5/plugins/speech-recognize/speech-recognize.js +51 -9
  46. package/es5/plugins/speech-recognize/speech-recognize.min.js +2 -2
  47. package/es5/polyfills.fat.min.js +1 -1
  48. package/es5/polyfills.js +1 -1
  49. package/es5/polyfills.min.js +1 -1
  50. package/esm/config.d.ts +48 -4
  51. package/esm/config.js +28 -3
  52. package/esm/core/constants.js +1 -1
  53. package/esm/core/ui/icon.d.ts +10 -0
  54. package/esm/core/ui/icon.js +17 -1
  55. package/esm/plugins/speech-recognize/config.js +4 -1
  56. package/esm/plugins/speech-recognize/helpers/recognize-manager.js +3 -2
  57. package/esm/plugins/speech-recognize/helpers/sound.d.ts +8 -1
  58. package/esm/plugins/speech-recognize/helpers/sound.js +45 -8
  59. package/package.json +1 -1
  60. package/types/config.d.ts +48 -4
  61. package/types/core/ui/icon.d.ts +10 -0
  62. package/types/plugins/speech-recognize/helpers/sound.d.ts +8 -1
package/es2015/jodit.js CHANGED
@@ -1,7 +1,7 @@
1
1
  /*!
2
2
  * jodit - Jodit is an awesome and useful wysiwyg editor with filebrowser
3
3
  * Author: Chupurnov <chupurnov@gmail.com> (https://xdsoft.net/jodit/)
4
- * Version: v4.12.2
4
+ * Version: v4.12.4
5
5
  * Url: https://xdsoft.net/jodit/
6
6
  * License(s): MIT
7
7
  */
@@ -717,17 +717,61 @@ let ConfigPrototype = {};
717
717
  * ```
718
718
  */ (0,_swc_helpers_define_property__WEBPACK_IMPORTED_MODULE_0__._)(this, "disablePlugins", []);
719
719
  /**
720
- * Init and download extra plugins
720
+ * Init and download extra plugins that are **not** already bundled/registered.
721
+ *
722
+ * For every name in this list that is not found in the plugin registry, Jodit
723
+ * loads it **at runtime over the network** from:
724
+ *
725
+ * ```text
726
+ * <basePath>plugins/<name>/<name>(.min).js
727
+ * ```
728
+ *
729
+ * (see {@link Config.basePath} and {@link Config.minified}). If the plugin is
730
+ * already registered — e.g. you imported it statically, or you use a bundle
731
+ * that ships it (such as the `jodit-pro` / `jodit-pro-react` "all plugins"
732
+ * build) — it is **skipped** and no request is made; in that case you don't
733
+ * need `extraPlugins` at all, just add the plugin's button.
721
734
  *
722
735
  * ```typescript
723
- * var editor = Jodit.make('.editor', {
736
+ * // Dynamic loading: fetches <basePath>plugins/emoji/emoji.js
737
+ * const editor = Jodit.make('.editor', {
724
738
  * extraPlugins: ['emoji']
725
739
  * });
726
740
  * ```
727
- * It will try load %SCRIPT_PATH%/plugins/emoji/emoji.js and after load will try init it
741
+ *
742
+ * You can also pass an explicit URL to bypass the `basePath` convention:
743
+ *
744
+ * ```typescript
745
+ * const editor = Jodit.make('.editor', {
746
+ * extraPlugins: [{ name: 'emoji', url: 'https://cdn.example.com/emoji.js' }]
747
+ * });
748
+ * ```
749
+ *
750
+ * Note: if you see a request to a malformed URL (e.g. `.../src/main.tsx?t=...plugins/emoji/emoji.js`),
751
+ * it means `basePath` was auto-detected incorrectly under your bundler — set
752
+ * {@link Config.basePath} explicitly. See the Plugin System docs for details.
728
753
  */ (0,_swc_helpers_define_property__WEBPACK_IMPORTED_MODULE_0__._)(this, "extraPlugins", []);
729
754
  /**
730
- * Base path for download extra plugins
755
+ * Base path used to build the URL for dynamically loaded {@link Config.extraPlugins}
756
+ * (and their styles): `<basePath>plugins/<name>/<name>(.min).js`.
757
+ *
758
+ * When not set, Jodit auto-detects it from `document.currentScript`, then the
759
+ * last `<script src>` on the page, then `location.href`. That detection works
760
+ * for classic `<script>` includes, but **fails under ESM bundlers / dev
761
+ * servers** (Vite, Webpack dev, etc.) where there is no script tag for the
762
+ * bundle — it falls back to the entry module URL (e.g. `main.tsx`) and produces
763
+ * a broken plugin URL.
764
+ *
765
+ * Fix: host the plugin files at a public location and point `basePath` there
766
+ * (note the trailing slash):
767
+ *
768
+ * ```typescript
769
+ * const editor = Jodit.make('.editor', {
770
+ * basePath: 'https://your-site.com/jodit-assets/',
771
+ * extraPlugins: ['emoji']
772
+ * // → loads https://your-site.com/jodit-assets/plugins/emoji/emoji.js
773
+ * });
774
+ * ```
731
775
  */ (0,_swc_helpers_define_property__WEBPACK_IMPORTED_MODULE_0__._)(this, "basePath", void 0);
732
776
  /**
733
777
  * Additional buttons appended to the {@link Config.buttons} list
@@ -1764,7 +1808,7 @@ __webpack_require__.r(__webpack_exports__);
1764
1808
  * ```
1765
1809
  * @packageDocumentation
1766
1810
  * @module constants
1767
- */ const APP_VERSION = "4.12.2";
1811
+ */ const APP_VERSION = "4.12.4";
1768
1812
  // prettier-ignore
1769
1813
  const ES = "es2015";
1770
1814
  const IS_ES_MODERN = true;
@@ -15515,8 +15559,9 @@ UISpacer = (0,_swc_helpers_ts_decorate__WEBPACK_IMPORTED_MODULE_0__.__decorate)(
15515
15559
  /* harmony export */ });
15516
15560
  /* harmony import */ var _swc_helpers_define_property__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(25045);
15517
15561
  /* harmony import */ var jodit_core_constants__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(81937);
15518
- /* harmony import */ var jodit_core_helpers__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(65946);
15519
- /* harmony import */ var jodit_core_helpers_utils_css__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(80991);
15562
+ /* harmony import */ var jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(23211);
15563
+ /* harmony import */ var jodit_core_helpers__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(65946);
15564
+ /* harmony import */ var jodit_core_helpers_utils_css__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(80991);
15520
15565
  /*!
15521
15566
  * Jodit Editor (https://xdsoft.net/jodit/)
15522
15567
  * Released under MIT see LICENSE.txt in the project root for license information.
@@ -15527,12 +15572,13 @@ UISpacer = (0,_swc_helpers_ts_decorate__WEBPACK_IMPORTED_MODULE_0__.__decorate)(
15527
15572
 
15528
15573
 
15529
15574
 
15575
+
15530
15576
  class Icon {
15531
15577
  static getIcon(name) {
15532
15578
  if (/<svg/i.test(name)) {
15533
15579
  return name;
15534
15580
  }
15535
- const icon = Icon.icons[name] || Icon.icons[name.replace(/-/g, '_')] || Icon.icons[name.replace(/_/g, '-')] || Icon.icons[(0,jodit_core_helpers__WEBPACK_IMPORTED_MODULE_2__.camelCase)(name)] || Icon.icons[(0,jodit_core_helpers__WEBPACK_IMPORTED_MODULE_2__.kebabCase)(name)] || Icon.icons[name.toLowerCase()];
15581
+ const icon = Icon.icons[name] || Icon.icons[name.replace(/-/g, '_')] || Icon.icons[name.replace(/_/g, '-')] || Icon.icons[(0,jodit_core_helpers__WEBPACK_IMPORTED_MODULE_3__.camelCase)(name)] || Icon.icons[(0,jodit_core_helpers__WEBPACK_IMPORTED_MODULE_3__.kebabCase)(name)] || Icon.icons[name.toLowerCase()];
15536
15582
  if (!jodit_core_constants__WEBPACK_IMPORTED_MODULE_1__.IS_PROD && !icon) {
15537
15583
  console.warn(`Icon "${name}" not found`);
15538
15584
  }
@@ -15575,12 +15621,12 @@ class Icon {
15575
15621
  }
15576
15622
  if (iconURL) {
15577
15623
  iconElement = jodit.c.span();
15578
- (0,jodit_core_helpers_utils_css__WEBPACK_IMPORTED_MODULE_3__.css)(iconElement, 'backgroundImage', 'url(' + iconURL.replace('{basePath}', (jodit === null || jodit === void 0 ? void 0 : jodit.basePath) || '') + ')');
15624
+ (0,jodit_core_helpers_utils_css__WEBPACK_IMPORTED_MODULE_4__.css)(iconElement, 'backgroundImage', 'url(' + iconURL.replace('{basePath}', (jodit === null || jodit === void 0 ? void 0 : jodit.basePath) || '') + ')');
15579
15625
  } else {
15580
15626
  var _jodit_o_extraIcons;
15581
15627
  const svg = iconFromEvent || Icon.get(name, '') || ((_jodit_o_extraIcons = jodit.o.extraIcons) === null || _jodit_o_extraIcons === void 0 ? void 0 : _jodit_o_extraIcons[name]);
15582
15628
  if (svg) {
15583
- iconElement = jodit.c.fromHTML(svg.trim());
15629
+ iconElement = Icon.toIconElement(jodit, svg.trim());
15584
15630
  if (!/^<svg/i.test(name)) {
15585
15631
  iconElement.classList.add('jodit-icon_' + clearName);
15586
15632
  }
@@ -15596,6 +15642,18 @@ class Icon {
15596
15642
  }
15597
15643
  return iconElement;
15598
15644
  }
15645
+ /**
15646
+ * Turn a raw icon string into an element with a `classList`.
15647
+ *
15648
+ * A plain-text icon (e.g. an emoji/text glyph) makes `fromHTML` return a
15649
+ * Text node, which has no `classList`; wrap it in a span so classes/styles
15650
+ * can be applied and `makeIcon` never crashes on `iconElement.classList`.
15651
+ * Note: SVG icons are `SVGElement` (not `HTMLElement`) but are still Element
15652
+ * nodes with a `classList`, so we check `isElement`, not `isHTMLElement`.
15653
+ */ static toIconElement(jodit, svg) {
15654
+ const node = jodit.c.fromHTML(svg);
15655
+ return jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_2__.Dom.isElement(node) ? node : jodit.c.span('jodit-icon_text', node);
15656
+ }
15599
15657
  }
15600
15658
  (0,_swc_helpers_define_property__WEBPACK_IMPORTED_MODULE_0__._)(Icon, "icons", {});
15601
15659
  (0,_swc_helpers_define_property__WEBPACK_IMPORTED_MODULE_0__._)(Icon, "__cache", new Map());