jodit 4.18.0 → 4.18.2

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 (57) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/es2015/jodit.css +1 -1
  3. package/es2015/jodit.fat.min.js +3 -3
  4. package/es2015/jodit.js +38 -10
  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 +1 -1
  11. package/es2015/plugins/speech-recognize/speech-recognize.min.js +1 -1
  12. package/es2018/jodit.fat.min.js +3 -3
  13. package/es2018/jodit.min.js +8 -8
  14. package/es2018/plugins/debug/debug.min.js +1 -1
  15. package/es2018/plugins/speech-recognize/speech-recognize.min.js +1 -1
  16. package/es2021/jodit.css +1 -1
  17. package/es2021/jodit.fat.min.js +3 -3
  18. package/es2021/jodit.js +38 -10
  19. package/es2021/jodit.min.js +9 -9
  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 +1 -1
  25. package/es2021/plugins/speech-recognize/speech-recognize.min.js +1 -1
  26. package/es2021.en/jodit.css +1 -1
  27. package/es2021.en/jodit.fat.min.js +3 -3
  28. package/es2021.en/jodit.js +38 -10
  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 +1 -1
  35. package/es2021.en/plugins/speech-recognize/speech-recognize.min.js +1 -1
  36. package/es5/jodit.css +2 -2
  37. package/es5/jodit.fat.min.js +2 -2
  38. package/es5/jodit.js +40 -10
  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 +1 -1
  46. package/es5/plugins/speech-recognize/speech-recognize.min.js +1 -1
  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/core/constants.js +1 -1
  51. package/esm/plugins/clean-html/clean-html.d.ts +2 -1
  52. package/esm/plugins/clean-html/clean-html.js +24 -7
  53. package/esm/plugins/dtd/after-insert/remove-extra-br.js +6 -1
  54. package/esm/plugins/dtd/before-insert/check-block-nesting.js +16 -1
  55. package/esm/plugins/dtd/config.js +3 -0
  56. package/package.json +1 -1
  57. package/types/plugins/clean-html/clean-html.d.ts +2 -1
@@ -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.18.0
4
+ * Version: v4.18.2
5
5
  * Url: https://xdsoft.net/jodit/
6
6
  * License(s): MIT
7
7
  */
@@ -1824,7 +1824,7 @@ __webpack_require__.r(__webpack_exports__);
1824
1824
  * ```
1825
1825
  * @packageDocumentation
1826
1826
  * @module constants
1827
- */ const APP_VERSION = "4.18.0";
1827
+ */ const APP_VERSION = "4.18.2";
1828
1828
  // prettier-ignore
1829
1829
  const ES = "es2021";
1830
1830
  const IS_ES_MODERN = true;
@@ -28913,7 +28913,11 @@ jodit_core_ui_icon__WEBPACK_IMPORTED_MODULE_5__.Icon.set('class-span', (_class_s
28913
28913
  * Clean HTML after removeFormat and insertHorizontalRule command
28914
28914
  */ const TRAILING_BR_BLOCKS = 'p, div, li, td, th, h1, h2, h3, h4, h5, h6, blockquote';
28915
28915
  class cleanHtml extends jodit_core_plugin_plugin__WEBPACK_IMPORTED_MODULE_7__.Plugin {
28916
- /** @override */ afterInit(jodit) {}
28916
+ /** @override */ afterInit() {
28917
+ // The walker's own `:afterInit` watcher is bound on that very event,
28918
+ // so without this the first pass waited for the first key or click
28919
+ this.onChangeCleanHTML();
28920
+ }
28917
28921
  get isEditMode() {
28918
28922
  return !(this.j.isInDestruct || !this.j.isEditorMode() || this.j.getReadOnly());
28919
28923
  }
@@ -29051,10 +29055,11 @@ class cleanHtml extends jodit_core_plugin_plugin__WEBPACK_IMPORTED_MODULE_7__.Pl
29051
29055
  ;(0,jodit_core_helpers_html_safe_html__WEBPACK_IMPORTED_MODULE_6__.safeHTML)(sandBox, this.j.o.cleanHTML);
29052
29056
  }
29053
29057
  /** @override */ beforeDestruct() {
29058
+ this.j.e.off('safeHTML', this.onSafeHTML).off('beforeSetNativeEditorValue', this.onBeforeSetNativeEditorValue).off('afterSetNativeEditorValue', this.onAfterSetNativeEditorValue);
29054
29059
  this.walker.destruct();
29055
29060
  }
29056
- constructor(...args){
29057
- super(...args), /** @override */ (0,_swc_helpers_define_property__WEBPACK_IMPORTED_MODULE_0__._)(this, "buttons", [
29061
+ constructor(jodit){
29062
+ super(jodit), /** @override */ (0,_swc_helpers_define_property__WEBPACK_IMPORTED_MODULE_0__._)(this, "buttons", [
29058
29063
  {
29059
29064
  name: 'eraser',
29060
29065
  group: 'font-style'
@@ -29062,6 +29067,12 @@ class cleanHtml extends jodit_core_plugin_plugin__WEBPACK_IMPORTED_MODULE_7__.Pl
29062
29067
  ]), (0,_swc_helpers_define_property__WEBPACK_IMPORTED_MODULE_0__._)(this, "currentSelectionNode", null), (0,_swc_helpers_define_property__WEBPACK_IMPORTED_MODULE_0__._)(this, "walker", new jodit_core_dom_lazy_walker__WEBPACK_IMPORTED_MODULE_4__.LazyWalker(this.j.async, {
29063
29068
  timeout: this.j.o.cleanHTML.timeout
29064
29069
  }));
29070
+ // `@watch` binds once the plugin is ready, which is after the initial
29071
+ // value has already gone into the editor. The handlers that keep
29072
+ // markup out of the live tree have to be there from the start, or
29073
+ // event handlers in a textarea's content run before anything
29074
+ // sanitises them.
29075
+ jodit.e.on('safeHTML', this.onSafeHTML).on('beforeSetNativeEditorValue', this.onBeforeSetNativeEditorValue).on('afterSetNativeEditorValue', this.onAfterSetNativeEditorValue);
29065
29076
  }
29066
29077
  }
29067
29078
  ;(0,_swc_helpers_ts_decorate__WEBPACK_IMPORTED_MODULE_1__.__decorate)([
@@ -29080,16 +29091,16 @@ class cleanHtml extends jodit_core_plugin_plugin__WEBPACK_IMPORTED_MODULE_7__.Pl
29080
29091
  (0,jodit_core_decorators__WEBPACK_IMPORTED_MODULE_2__.watch)(':beforeCommand')
29081
29092
  ], cleanHtml.prototype, "beforeCommand", null);
29082
29093
  (0,_swc_helpers_ts_decorate__WEBPACK_IMPORTED_MODULE_1__.__decorate)([
29083
- (0,jodit_core_decorators__WEBPACK_IMPORTED_MODULE_2__.watch)(':afterSetNativeEditorValue')
29094
+ jodit_core_decorators__WEBPACK_IMPORTED_MODULE_2__.autobind
29084
29095
  ], cleanHtml.prototype, "onAfterSetNativeEditorValue", null);
29085
29096
  (0,_swc_helpers_ts_decorate__WEBPACK_IMPORTED_MODULE_1__.__decorate)([
29086
- (0,jodit_core_decorators__WEBPACK_IMPORTED_MODULE_2__.watch)(':beforeSetNativeEditorValue')
29097
+ jodit_core_decorators__WEBPACK_IMPORTED_MODULE_2__.autobind
29087
29098
  ], cleanHtml.prototype, "onBeforeSetNativeEditorValue", null);
29088
29099
  (0,_swc_helpers_ts_decorate__WEBPACK_IMPORTED_MODULE_1__.__decorate)([
29089
29100
  (0,jodit_core_decorators__WEBPACK_IMPORTED_MODULE_2__.watch)(':afterGetValueFromEditor')
29090
29101
  ], cleanHtml.prototype, "onAfterGetValueFromEditor", null);
29091
29102
  (0,_swc_helpers_ts_decorate__WEBPACK_IMPORTED_MODULE_1__.__decorate)([
29092
- (0,jodit_core_decorators__WEBPACK_IMPORTED_MODULE_2__.watch)(':safeHTML')
29103
+ jodit_core_decorators__WEBPACK_IMPORTED_MODULE_2__.autobind
29093
29104
  ], cleanHtml.prototype, "onSafeHTML", null);
29094
29105
  jodit_core_global__WEBPACK_IMPORTED_MODULE_5__.pluginSystem.add('cleanHtml', cleanHtml);
29095
29106
 
@@ -31312,7 +31323,12 @@ const brBoxes = new Set([
31312
31323
  if (jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_0__.Dom.findNotEmptySibling(br, false)) {
31313
31324
  return;
31314
31325
  }
31315
- jodit.s.setCursorBefore(br);
31326
+ // After a block is inserted the caret is already at the end of its
31327
+ // text; moving it before the `<br>` would put it on a line of its own
31328
+ // below the block (#1315)
31329
+ if (!jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_0__.Dom.isOrContains(node, jodit.s.range.startContainer)) {
31330
+ jodit.s.setCursorBefore(br);
31331
+ }
31316
31332
  jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_0__.Dom.safeRemove(br);
31317
31333
  }
31318
31334
  }
@@ -31349,13 +31365,22 @@ const brBoxes = new Set([
31349
31365
  let current = jodit.s.current()?.parentElement ?? null;
31350
31366
  while(current && current !== jodit.editor){
31351
31367
  if (jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_0__.Dom.isBlock(current)) {
31352
- if (jodit.o.dtd.blockLimits[current.nodeName.toLowerCase()]) {
31368
+ // In DIV mode the caret's own empty block is a line, like
31369
+ // `<p><br></p>`, not a container to insert into (#1315)
31370
+ const isEmptyLine = !parent && jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_0__.Dom.isTag(current, jodit.o.enter) && jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_0__.Dom.isEmpty(current);
31371
+ if (jodit.o.dtd.blockLimits[current.nodeName.toLowerCase()] && !isEmptyLine) {
31353
31372
  break;
31354
31373
  }
31355
31374
  parent = current;
31356
31375
  }
31357
31376
  current = current.parentElement;
31358
31377
  }
31378
+ // A list that is all of the inserted content adds its items to the
31379
+ // list of the item it goes into, as the browsers' own paste does
31380
+ if (jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_0__.Dom.isLeaf(current) && jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_0__.Dom.isList(node) && jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_0__.Dom.isFragment(node.parentNode) && !jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_0__.Dom.findNotEmptySibling(node, false)) {
31381
+ jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_0__.Dom.unwrap(node);
31382
+ parent = current;
31383
+ }
31359
31384
  if (parent) {
31360
31385
  jodit.s.setCursorAfter(parent);
31361
31386
  if (jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_0__.Dom.isEmpty(parent)) {
@@ -31410,10 +31435,12 @@ jodit_config__WEBPACK_IMPORTED_MODULE_0__.Config.prototype.dtd = {
31410
31435
  audio: 1,
31411
31436
  body: 1,
31412
31437
  caption: 1,
31438
+ dd: 1,
31413
31439
  details: 1,
31414
31440
  dir: 1,
31415
31441
  div: 1,
31416
31442
  dl: 1,
31443
+ dt: 1,
31417
31444
  fieldset: 1,
31418
31445
  figcaption: 1,
31419
31446
  figure: 1,
@@ -31421,6 +31448,7 @@ jodit_config__WEBPACK_IMPORTED_MODULE_0__.Config.prototype.dtd = {
31421
31448
  form: 1,
31422
31449
  header: 1,
31423
31450
  hgroup: 1,
31451
+ li: 1,
31424
31452
  main: 1,
31425
31453
  menu: 1,
31426
31454
  nav: 1,