jodit 3.15.2 → 3.16.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 (260) hide show
  1. package/.idea/workspace.xml +301 -299
  2. package/CHANGELOG.MD +88 -7
  3. package/CONTRIBUTING.md +97 -0
  4. package/README.md +7 -7
  5. package/build/jodit.css +38 -32
  6. package/build/jodit.es2018.css +37 -31
  7. package/build/jodit.es2018.en.css +37 -31
  8. package/build/jodit.es2018.en.js +1981 -1393
  9. package/build/jodit.es2018.en.min.css +1 -1
  10. package/build/jodit.es2018.en.min.js +1 -1
  11. package/build/jodit.es2018.js +2053 -1447
  12. package/build/jodit.es2018.min.css +1 -1
  13. package/build/jodit.es2018.min.js +1 -1
  14. package/build/jodit.js +3475 -2625
  15. package/build/jodit.min.css +2 -2
  16. package/build/jodit.min.js +1 -1
  17. package/build/vdom.css +1 -1
  18. package/build/vdom.js +32 -20
  19. package/package.json +13 -13
  20. package/src/README.md +1 -1
  21. package/src/config.ts +69 -36
  22. package/src/core/async/async.ts +46 -24
  23. package/src/core/constants.ts +1 -0
  24. package/src/core/decorators/README.md +35 -0
  25. package/src/core/decorators/cache/cache.ts +1 -1
  26. package/src/core/decorators/debounce/debounce.ts +20 -9
  27. package/src/core/decorators/idle/README.md +14 -0
  28. package/src/core/decorators/idle/idle.ts +1 -1
  29. package/src/core/decorators/watch/watch.ts +8 -7
  30. package/src/core/dom/README.md +42 -0
  31. package/src/core/dom/dom.ts +37 -23
  32. package/src/core/dom/index.ts +1 -0
  33. package/src/core/dom/lazy-walker.ts +133 -0
  34. package/src/core/event-emitter/event-emitter.ts +8 -8
  35. package/src/core/event-emitter/eventify.ts +73 -0
  36. package/src/core/event-emitter/index.ts +1 -0
  37. package/src/core/helpers/html/apply-styles.ts +1 -1
  38. package/src/core/helpers/html/strip-tags.ts +3 -2
  39. package/src/core/helpers/string/fuzzy-search-index.ts +58 -0
  40. package/src/core/helpers/string/i18n.ts +1 -1
  41. package/src/core/helpers/string/index.ts +3 -2
  42. package/src/core/helpers/utils/append-script.ts +1 -1
  43. package/src/core/helpers/utils/css.ts +1 -1
  44. package/src/core/helpers/utils/selector.ts +1 -1
  45. package/src/core/helpers/utils/utils.ts +3 -3
  46. package/src/core/plugin/plugin-system.ts +14 -8
  47. package/src/core/request/ajax.ts +3 -3
  48. package/src/core/selection/select.ts +10 -10
  49. package/src/core/selection/style/api/toggle/toggle-css.ts +5 -2
  50. package/src/core/selection/style/api/wrap-unwrapped-text.ts +1 -1
  51. package/src/core/selection/style/apply-style.ts +4 -4
  52. package/src/core/storage/engines/local-storage-provider.ts +20 -19
  53. package/src/core/ui/button/button/button.ts +5 -5
  54. package/src/core/ui/element.ts +2 -2
  55. package/src/core/ui/form/inputs/input/input.ts +1 -1
  56. package/src/core/ui/form/inputs/select/select.ts +1 -1
  57. package/src/core/ui/group/list.ts +2 -2
  58. package/src/core/vdom/render/index.ts +12 -8
  59. package/src/core/vdom/v-dom-jodit.ts +1 -1
  60. package/src/core/view/view.ts +1 -1
  61. package/src/index.ts +3 -3
  62. package/src/jodit.ts +72 -55
  63. package/src/langs/README.md +1 -1
  64. package/src/langs/ar.js +2 -1
  65. package/src/langs/cs_cz.js +2 -1
  66. package/src/langs/de.js +2 -1
  67. package/src/langs/es.js +2 -1
  68. package/src/langs/fa.js +2 -1
  69. package/src/langs/fr.js +2 -1
  70. package/src/langs/he.js +2 -1
  71. package/src/langs/hu.js +2 -1
  72. package/src/langs/id.js +2 -1
  73. package/src/langs/index.ts +1 -1
  74. package/src/langs/it.js +2 -1
  75. package/src/langs/ja.js +2 -1
  76. package/src/langs/ko.js +2 -1
  77. package/src/langs/nl.js +2 -1
  78. package/src/langs/pl.js +2 -1
  79. package/src/langs/pt_br.js +2 -1
  80. package/src/langs/ru.js +2 -1
  81. package/src/langs/tr.js +2 -1
  82. package/src/langs/zh_cn.js +2 -1
  83. package/src/langs/zh_tw.js +2 -1
  84. package/src/modules/dialog/dialog.ts +6 -6
  85. package/src/modules/dialog/prompt.ts +1 -1
  86. package/src/modules/file-browser/README.md +2 -2
  87. package/src/modules/file-browser/builders/context-menu.ts +12 -13
  88. package/src/modules/file-browser/fetch/load-tree.ts +1 -1
  89. package/src/modules/file-browser/file-browser.ts +10 -7
  90. package/src/modules/history/README.md +5 -0
  91. package/src/modules/{observer → history}/command.ts +5 -5
  92. package/src/modules/{observer/observer.ts → history/history.ts} +97 -55
  93. package/src/modules/{observer → history}/snapshot.ts +3 -4
  94. package/src/modules/{observer → history}/stack.ts +4 -4
  95. package/src/modules/image-editor/image-editor.ts +8 -8
  96. package/src/modules/image-editor/templates/form.ts +2 -2
  97. package/src/modules/index.ts +3 -3
  98. package/src/modules/status-bar/status-bar.ts +4 -0
  99. package/src/modules/table/table.ts +2 -2
  100. package/src/modules/toolbar/button/button.ts +2 -2
  101. package/src/modules/toolbar/collection/collection.ts +1 -1
  102. package/src/modules/uploader/helpers/process-old-browser-drag.ts +1 -1
  103. package/src/modules/uploader/helpers/send-files.ts +1 -1
  104. package/src/modules/uploader/helpers/send.ts +1 -1
  105. package/src/modules/uploader/uploader.ts +3 -3
  106. package/src/modules/widget/color-picker/color-picker.ts +2 -3
  107. package/src/modules/widget/tabs/tabs.ts +17 -12
  108. package/src/plugins/add-new-line/add-new-line.ts +8 -8
  109. package/src/plugins/class-span/class-span.ts +1 -1
  110. package/src/plugins/clipboard/copy-format.ts +1 -1
  111. package/src/plugins/clipboard/drag-and-drop-element.ts +4 -2
  112. package/src/plugins/clipboard/paste/config.ts +19 -3
  113. package/src/plugins/clipboard/paste/helpers.ts +17 -50
  114. package/src/plugins/clipboard/paste/interface.ts +6 -0
  115. package/src/plugins/clipboard/paste/paste.ts +22 -8
  116. package/src/plugins/clipboard/paste-from-word/config.ts +17 -0
  117. package/src/plugins/clipboard/paste-from-word/paste-from-word.ts +15 -6
  118. package/src/plugins/clipboard/paste-storage/paste-storage.ts +6 -6
  119. package/src/plugins/color/color.ts +2 -2
  120. package/src/plugins/error-messages/error-messages.ts +2 -2
  121. package/src/plugins/fix/clean-html/README.md +26 -0
  122. package/src/plugins/fix/{clean-html.ts → clean-html/clean-html.ts} +59 -142
  123. package/src/plugins/fix/clean-html/config.ts +106 -0
  124. package/src/plugins/fix/index.ts +12 -0
  125. package/src/plugins/fix/wrap-nodes/README.md +27 -0
  126. package/src/plugins/fix/wrap-nodes/config.ts +24 -0
  127. package/src/plugins/fix/{wrap-text-nodes.ts → wrap-nodes/wrap-nodes.ts} +9 -4
  128. package/src/plugins/focus/focus.ts +1 -1
  129. package/src/plugins/format-block/format-block.ts +1 -1
  130. package/src/plugins/fullsize/fullsize.ts +4 -4
  131. package/src/plugins/iframe/iframe.ts +3 -3
  132. package/src/plugins/image/image-properties/image-properties.ts +12 -13
  133. package/src/plugins/indent/indent.ts +1 -1
  134. package/src/plugins/index.ts +2 -2
  135. package/src/plugins/inline-popup/config/items/a.ts +2 -2
  136. package/src/plugins/inline-popup/config/items/cells.ts +11 -11
  137. package/src/plugins/inline-popup/config/items/iframe.ts +1 -1
  138. package/src/plugins/inline-popup/config/items/img.ts +7 -7
  139. package/src/plugins/inline-popup/inline-popup.ts +5 -5
  140. package/src/plugins/keyboard/backspace/backspace.ts +1 -1
  141. package/src/plugins/keyboard/backspace/cases/check-join-neighbors.ts +1 -1
  142. package/src/plugins/keyboard/helpers.ts +1 -1
  143. package/src/plugins/keyboard/hotkeys.ts +1 -1
  144. package/src/plugins/limit/limit.ts +3 -3
  145. package/src/plugins/line-height/line-height.ts +1 -1
  146. package/src/plugins/link/link.ts +8 -8
  147. package/src/plugins/link/template.ts +2 -2
  148. package/src/plugins/media/file.ts +1 -1
  149. package/src/plugins/media/media.ts +1 -1
  150. package/src/plugins/media/video/config.ts +1 -1
  151. package/src/plugins/mobile/config.ts +1 -1
  152. package/src/plugins/mobile/mobile.ts +1 -1
  153. package/src/plugins/ordered-list/config.ts +61 -0
  154. package/src/plugins/ordered-list/ordered-list.ts +3 -153
  155. package/src/plugins/placeholder/placeholder.ts +3 -3
  156. package/src/plugins/print/helpers.ts +14 -7
  157. package/src/plugins/print/index.ts +1 -1
  158. package/src/plugins/print/{preview.less → preview/preview.less} +1 -1
  159. package/src/plugins/print/{preview.ts → preview/preview.ts} +9 -8
  160. package/src/plugins/print/print.ts +19 -10
  161. package/src/plugins/redo-undo/redo-undo.ts +3 -3
  162. package/src/plugins/resizer/resizer.ts +11 -11
  163. package/src/plugins/search/README.md +38 -0
  164. package/src/plugins/search/config.ts +82 -0
  165. package/src/plugins/search/helpers/index.ts +12 -0
  166. package/src/plugins/search/helpers/sentence-finder.ts +103 -0
  167. package/src/plugins/search/helpers/wrap-ranges-texts-in-tmp-span.ts +120 -0
  168. package/src/plugins/search/search.ts +269 -615
  169. package/src/plugins/search/ui/search.less +159 -0
  170. package/src/plugins/search/ui/search.ts +256 -0
  171. package/src/plugins/select/select.ts +1 -1
  172. package/src/plugins/size/config.ts +8 -8
  173. package/src/plugins/size/resize-handler.ts +3 -3
  174. package/src/plugins/size/size.ts +4 -4
  175. package/src/plugins/source/editor/engines/ace.ts +9 -9
  176. package/src/plugins/source/editor/engines/area.ts +3 -3
  177. package/src/plugins/source/source.ts +6 -6
  178. package/src/plugins/spellcheck/README.md +1 -0
  179. package/src/plugins/spellcheck/config.ts +34 -0
  180. package/src/plugins/spellcheck/spellcheck.svg +4 -0
  181. package/src/plugins/spellcheck/spellcheck.ts +48 -0
  182. package/src/plugins/sticky/sticky.ts +3 -3
  183. package/src/plugins/table/resize-cells.ts +11 -11
  184. package/src/plugins/table/select-cells.ts +2 -2
  185. package/src/plugins/tooltip/tooltip.ts +1 -1
  186. package/src/plugins/xpath/xpath.ts +8 -8
  187. package/src/polyfills.ts +5 -4
  188. package/src/styles/icons/README.md +2 -2
  189. package/src/types/async.d.ts +12 -2
  190. package/src/types/core.ts +1 -1
  191. package/src/types/events.d.ts +6 -2
  192. package/src/types/file-browser.d.ts +1 -2
  193. package/{types/types/observer.d.ts → src/types/history.d.ts} +11 -7
  194. package/src/types/index.d.ts +1 -1
  195. package/src/types/jodit.d.ts +12 -4
  196. package/src/types/toolbar.d.ts +5 -5
  197. package/src/types/types.d.ts +11 -4
  198. package/types/config.d.ts +68 -35
  199. package/types/core/async/async.d.ts +11 -4
  200. package/types/core/constants.d.ts +1 -0
  201. package/types/core/dom/dom.d.ts +3 -5
  202. package/types/core/dom/index.d.ts +1 -0
  203. package/types/core/dom/lazy-walker.d.ts +37 -0
  204. package/types/core/event-emitter/eventify.d.ts +39 -0
  205. package/types/core/event-emitter/index.d.ts +1 -0
  206. package/types/core/helpers/string/fuzzy-search-index.d.ts +10 -0
  207. package/types/core/helpers/string/i18n.d.ts +1 -1
  208. package/types/core/helpers/string/index.d.ts +3 -2
  209. package/types/core/helpers/utils/utils.d.ts +1 -1
  210. package/types/core/selection/select.d.ts +1 -1
  211. package/types/core/ui/button/button/button.d.ts +4 -4
  212. package/types/core/view/view.d.ts +1 -1
  213. package/types/jodit.d.ts +19 -6
  214. package/types/modules/{observer → history}/command.d.ts +4 -4
  215. package/types/modules/{observer/observer.d.ts → history/history.d.ts} +17 -9
  216. package/types/modules/{observer → history}/snapshot.d.ts +1 -1
  217. package/types/modules/{observer → history}/stack.d.ts +3 -3
  218. package/types/modules/image-editor/image-editor.d.ts +1 -1
  219. package/types/modules/index.d.ts +3 -3
  220. package/types/modules/toolbar/button/button.d.ts +2 -5
  221. package/types/modules/widget/tabs/tabs.d.ts +1 -1
  222. package/types/plugins/class-span/class-span.d.ts +1 -1
  223. package/types/plugins/clipboard/paste/config.d.ts +8 -0
  224. package/types/plugins/clipboard/paste/helpers.d.ts +2 -2
  225. package/types/plugins/clipboard/paste/interface.d.ts +5 -0
  226. package/types/plugins/clipboard/paste-from-word/config.d.ts +5 -0
  227. package/types/plugins/clipboard/paste-from-word/paste-from-word.d.ts +3 -2
  228. package/types/plugins/fix/clean-html/clean-html.d.ts +70 -0
  229. package/types/plugins/fix/{clean-html.d.ts → clean-html/config.d.ts} +2 -57
  230. package/types/plugins/fix/index.d.ts +10 -0
  231. package/types/plugins/fix/wrap-nodes/config.d.ts +16 -0
  232. package/types/plugins/fix/{wrap-text-nodes.d.ts → wrap-nodes/wrap-nodes.d.ts} +5 -2
  233. package/types/plugins/fullsize/fullsize.d.ts +2 -2
  234. package/types/plugins/index.d.ts +2 -2
  235. package/types/plugins/ordered-list/config.d.ts +6 -0
  236. package/types/plugins/ordered-list/ordered-list.d.ts +1 -1
  237. package/types/plugins/print/helpers.d.ts +2 -2
  238. package/types/plugins/print/index.d.ts +1 -1
  239. package/types/plugins/print/{preview.d.ts → preview/preview.d.ts} +1 -1
  240. package/types/plugins/search/config.d.ts +36 -0
  241. package/types/plugins/search/helpers/index.d.ts +10 -0
  242. package/types/plugins/search/helpers/sentence-finder.d.ts +21 -0
  243. package/types/plugins/search/helpers/wrap-ranges-texts-in-tmp-span.d.ts +14 -0
  244. package/types/plugins/search/search.d.ts +25 -39
  245. package/types/plugins/search/ui/search.d.ts +37 -0
  246. package/types/plugins/spellcheck/config.d.ts +15 -0
  247. package/types/plugins/spellcheck/spellcheck.d.ts +19 -0
  248. package/types/plugins/sticky/sticky.d.ts +2 -2
  249. package/types/types/async.d.ts +12 -2
  250. package/types/types/core.d.ts +1 -1
  251. package/types/types/core.ts +1 -1
  252. package/types/types/events.d.ts +6 -2
  253. package/types/types/file-browser.d.ts +1 -2
  254. package/{src/types/observer.d.ts → types/types/history.d.ts} +11 -7
  255. package/types/types/index.d.ts +1 -1
  256. package/types/types/jodit.d.ts +12 -4
  257. package/types/types/toolbar.d.ts +5 -5
  258. package/types/types/types.d.ts +11 -4
  259. package/src/modules/observer/README.md +0 -0
  260. package/src/plugins/search/search.less +0 -152
package/src/jodit.ts CHANGED
@@ -27,16 +27,16 @@ import type {
27
27
  IFileBrowserCallBackData,
28
28
  IStorage,
29
29
  CanPromise,
30
- IObserver
30
+ IHistory
31
31
  } from './types';
32
32
 
33
33
  import { Config } from './config';
34
- import * as consts from './core/constants';
34
+ import * as constants from './core/constants';
35
35
 
36
36
  import {
37
37
  Create,
38
38
  Dom,
39
- Observer,
39
+ History,
40
40
  Plugin,
41
41
  Select,
42
42
  StatusBar,
@@ -59,7 +59,8 @@ import {
59
59
  markAsAtomic,
60
60
  ConfigProto,
61
61
  kebabCase,
62
- isJoditObject
62
+ isJoditObject,
63
+ isNumber
63
64
  } from './core/helpers/';
64
65
 
65
66
  import { Storage } from './core/storage/';
@@ -67,7 +68,7 @@ import { Storage } from './core/storage/';
67
68
  import { ViewWithToolbar } from './core/view/view-with-toolbar';
68
69
 
69
70
  import { instances, pluginSystem, modules, lang } from './core/global';
70
- import { autobind, cache } from './core/decorators';
71
+ import { autobind, cache, throttle, watch } from './core/decorators';
71
72
 
72
73
  const __defaultStyleDisplayKey = 'data-jodit-default-style-display';
73
74
  const __defaultClassesKey = 'data-jodit-default-classes';
@@ -77,7 +78,7 @@ const __defaultClassesKey = 'data-jodit-default-classes';
77
78
  */
78
79
  export class Jodit extends ViewWithToolbar implements IJodit {
79
80
  /** @override */
80
- className(): string {
81
+ override className(): string {
81
82
  return 'Jodit';
82
83
  }
83
84
 
@@ -123,12 +124,12 @@ export class Jodit extends ViewWithToolbar implements IJodit {
123
124
 
124
125
  /**
125
126
  * Return default timeout period in milliseconds for some debounce or throttle functions.
126
- * By default return `{observer.timeout}` options
127
+ * By default, `{history.timeout}` options
127
128
  */
128
129
  override get defaultTimeout(): number {
129
- return this.options && this.o.observer
130
- ? this.o.observer.timeout
131
- : Config.defaultOptions.observer.timeout;
130
+ return isNumber(this.o.defaultTimeout)
131
+ ? this.o.defaultTimeout
132
+ : Config.defaultOptions.defaultTimeout;
132
133
  }
133
134
 
134
135
  /**
@@ -173,6 +174,7 @@ export class Jodit extends ViewWithToolbar implements IJodit {
173
174
  static readonly ns: IDictionary<Function> = modules;
174
175
 
175
176
  static readonly decorators: IDictionary<Function> = {};
177
+ static readonly constants: typeof constants = constants;
176
178
  static readonly instances: IDictionary<IJodit> = instances;
177
179
 
178
180
  static readonly lang: any = lang;
@@ -266,8 +268,15 @@ export class Jodit extends ViewWithToolbar implements IJodit {
266
268
  this.setPlaceField('iframe', iframe);
267
269
  }
268
270
 
269
- get observer(): IObserver {
270
- return this.currentPlace.observer;
271
+ get history(): IHistory {
272
+ return this.currentPlace.history;
273
+ }
274
+
275
+ /**
276
+ * @deprecated Instead use `Jodit.history`
277
+ */
278
+ get observer(): IHistory {
279
+ return this.history;
271
280
  }
272
281
 
273
282
  /**
@@ -369,7 +378,7 @@ export class Jodit extends ViewWithToolbar implements IJodit {
369
378
  return jodit.getInstance<IFileBrowser>('FileBrowser', options);
370
379
  }
371
380
 
372
- private __mode: Modes = consts.MODE_WYSIWYG;
381
+ private __mode: Modes = constants.MODE_WYSIWYG;
373
382
 
374
383
  /**
375
384
  * Editor's mode
@@ -425,6 +434,7 @@ export class Jodit extends ViewWithToolbar implements IJodit {
425
434
 
426
435
  set value(html: string) {
427
436
  this.setEditorValue(html);
437
+ this.history.processChanges();
428
438
  }
429
439
 
430
440
  /**
@@ -439,7 +449,7 @@ export class Jodit extends ViewWithToolbar implements IJodit {
439
449
  * If returned not undefined getEditorValue will return this value
440
450
  * @example
441
451
  * ```javascript
442
- * var editor = new Jodit("#redactor");
452
+ * var editor = Jodit.make("#redactor");
443
453
  * editor.e.on('beforeGetValueFromEditor', function () {
444
454
  * return editor.editor.innerHTML.replace(/a/g, 'b');
445
455
  * });
@@ -454,7 +464,7 @@ export class Jodit extends ViewWithToolbar implements IJodit {
454
464
  }
455
465
 
456
466
  value = this.getNativeEditorValue().replace(
457
- consts.INVISIBLE_SPACE_REG_EXP(),
467
+ constants.INVISIBLE_SPACE_REG_EXP(),
458
468
  ''
459
469
  );
460
470
 
@@ -475,7 +485,7 @@ export class Jodit extends ViewWithToolbar implements IJodit {
475
485
  *
476
486
  * @example
477
487
  * ```javascript
478
- * var editor = new Jodit("#redactor");
488
+ * var editor = Jodit.make("#redactor");
479
489
  * editor.e.on('afterGetValueFromEditor', function (new_value) {
480
490
  * new_value.value = new_value.value.replace('a', 'b');
481
491
  * });
@@ -490,6 +500,11 @@ export class Jodit extends ViewWithToolbar implements IJodit {
490
500
 
491
501
  private __callChangeCount = 0;
492
502
 
503
+ @throttle()
504
+ synchronizeValues(): void {
505
+ this.setEditorValue();
506
+ }
507
+
493
508
  /**
494
509
  * Set editor html value and if set sync fill source element value
495
510
  * When method was called without arguments - it is simple way to synchronize editor to element
@@ -499,7 +514,7 @@ export class Jodit extends ViewWithToolbar implements IJodit {
499
514
  * Triggered before getEditorValue set value to wysiwyg.
500
515
  * @example
501
516
  * ```javascript
502
- * var editor = new Jodit("#redactor");
517
+ * var editor = Jodit.make("#redactor");
503
518
  * editor.e.on('beforeSetValueToEditor', function (old_value) {
504
519
  * return old_value.value.replace('a', 'b');
505
520
  * });
@@ -545,21 +560,29 @@ export class Jodit extends ViewWithToolbar implements IJodit {
545
560
  if (
546
561
  !this.isSilentChange &&
547
562
  old_value !== new_value &&
548
- this.__callChangeCount < consts.SAFE_COUNT_CHANGE_CALL
563
+ this.__callChangeCount < constants.SAFE_COUNT_CHANGE_CALL
549
564
  ) {
550
565
  this.setElementValue(new_value);
551
566
  this.__callChangeCount += 1;
552
567
 
553
568
  try {
554
- this.observer.upTick();
569
+ this.history.upTick();
555
570
  this.e.fire('change', new_value, old_value);
556
- this.e.fire(this.observer, 'change', new_value, old_value);
571
+ this.e.fire(this.history, 'change', new_value, old_value);
557
572
  } finally {
558
573
  this.__callChangeCount = 0;
559
574
  }
560
575
  }
561
576
  }
562
577
 
578
+ /**
579
+ * If some plugin changes the DOM directly, then you need to update the content of the original element
580
+ */
581
+ @watch(':internalChange')
582
+ protected updateElementValue(): void {
583
+ this.setElementValue(this.getEditorValue());
584
+ }
585
+
563
586
  /**
564
587
  * Return source element value
565
588
  */
@@ -600,7 +623,7 @@ export class Jodit extends ViewWithToolbar implements IJodit {
600
623
  *
601
624
  * @example
602
625
  * ```javascript
603
- * var jodit = new Jodit('#editor);
626
+ * var jodit = Jodit.make('#editor);
604
627
  *
605
628
  * jodit.setEditorValue('test test test');
606
629
  *
@@ -865,7 +888,7 @@ export class Jodit extends ViewWithToolbar implements IJodit {
865
888
  }
866
889
 
867
890
  isEditorMode(): boolean {
868
- return this.getRealMode() === consts.MODE_WYSIWYG;
891
+ return this.getRealMode() === constants.MODE_WYSIWYG;
869
892
  }
870
893
 
871
894
  /**
@@ -875,12 +898,12 @@ export class Jodit extends ViewWithToolbar implements IJodit {
875
898
  *
876
899
  * @example
877
900
  * ```javascript
878
- * var editor = new Jodit('#editor');
901
+ * var editor = Jodit.make('#editor');
879
902
  * console.log(editor.getRealMode());
880
903
  * ```
881
904
  */
882
905
  getRealMode(): Modes {
883
- if (this.getMode() !== consts.MODE_SPLIT) {
906
+ if (this.getMode() !== constants.MODE_SPLIT) {
884
907
  return this.getMode();
885
908
  }
886
909
 
@@ -892,10 +915,10 @@ export class Jodit extends ViewWithToolbar implements IJodit {
892
915
  Dom.isOrContains(this.editor, active) ||
893
916
  Dom.isOrContains(this.toolbar.container, active))
894
917
  ) {
895
- return consts.MODE_WYSIWYG;
918
+ return constants.MODE_WYSIWYG;
896
919
  }
897
920
 
898
- return consts.MODE_SOURCE;
921
+ return constants.MODE_SOURCE;
899
922
  }
900
923
 
901
924
  /**
@@ -918,7 +941,7 @@ export class Jodit extends ViewWithToolbar implements IJodit {
918
941
  * @param data - PlainObject `{mode: {string}}` In handler you can change data.mode
919
942
  * @example
920
943
  * ```javascript
921
- * var editor = new Jodit("#redactor");
944
+ * var editor = Jodit.make("#redactor");
922
945
  * editor.e.on('beforeSetMode', function (data) {
923
946
  * data.mode = Jodit.MODE_SOURCE; // not respond to the mode change. Always make the source code mode
924
947
  * });
@@ -929,12 +952,12 @@ export class Jodit extends ViewWithToolbar implements IJodit {
929
952
  }
930
953
 
931
954
  this.__mode = [
932
- consts.MODE_SOURCE,
933
- consts.MODE_WYSIWYG,
934
- consts.MODE_SPLIT
955
+ constants.MODE_SOURCE,
956
+ constants.MODE_WYSIWYG,
957
+ constants.MODE_SPLIT
935
958
  ].includes(data.mode)
936
959
  ? data.mode
937
- : consts.MODE_WYSIWYG;
960
+ : constants.MODE_WYSIWYG;
938
961
 
939
962
  if (this.o.saveModeInStorage) {
940
963
  this.storage.set('jodit_default_mode', this.mode);
@@ -950,7 +973,7 @@ export class Jodit extends ViewWithToolbar implements IJodit {
950
973
  * Triggered after setMode executed
951
974
  * @example
952
975
  * ```javascript
953
- * var editor = new Jodit("#redactor");
976
+ * var editor = Jodit.make("#redactor");
954
977
  * editor.e.on('afterSetMode', function () {
955
978
  * editor.setEditorValue(''); // clear editor's value after change mode
956
979
  * });
@@ -966,7 +989,7 @@ export class Jodit extends ViewWithToolbar implements IJodit {
966
989
  *
967
990
  * @example
968
991
  * ```javascript
969
- * var editor = new Jodit('#editor');
992
+ * var editor = Jodit.make('#editor');
970
993
  * editor.toggleMode();
971
994
  * ```
972
995
  */
@@ -975,14 +998,14 @@ export class Jodit extends ViewWithToolbar implements IJodit {
975
998
 
976
999
  if (
977
1000
  [
978
- consts.MODE_SOURCE,
979
- consts.MODE_WYSIWYG,
980
- this.o.useSplitMode ? consts.MODE_SPLIT : 9
1001
+ constants.MODE_SOURCE,
1002
+ constants.MODE_WYSIWYG,
1003
+ this.o.useSplitMode ? constants.MODE_SPLIT : 9
981
1004
  ].includes(mode + 1)
982
1005
  ) {
983
1006
  mode += 1;
984
1007
  } else {
985
- mode = consts.MODE_WYSIWYG;
1008
+ mode = constants.MODE_WYSIWYG;
986
1009
  }
987
1010
 
988
1011
  this.setMode(mode);
@@ -1078,6 +1101,8 @@ export class Jodit extends ViewWithToolbar implements IJodit {
1078
1101
  *
1079
1102
  * @param element - Selector or HTMLElement
1080
1103
  * @param options - Editor's options
1104
+ *
1105
+ * @deprecated - Instead use `Jodit.make`
1081
1106
  */
1082
1107
  constructor(element: HTMLElement | string, options?: object) {
1083
1108
  super(options as IViewOptions, true);
@@ -1138,7 +1163,7 @@ export class Jodit extends ViewWithToolbar implements IJodit {
1138
1163
 
1139
1164
  instances[this.id] = this;
1140
1165
 
1141
- const init = () => {
1166
+ const init = (): void => {
1142
1167
  if (this.e) {
1143
1168
  this.e.fire('afterInit', this);
1144
1169
  }
@@ -1276,7 +1301,7 @@ export class Jodit extends ViewWithToolbar implements IJodit {
1276
1301
  Config.defaultOptions
1277
1302
  ) as IWorkPlace['options'])
1278
1303
  : this.options,
1279
- observer: new Observer(this),
1304
+ history: new History(this),
1280
1305
  editorWindow: this.ow
1281
1306
  };
1282
1307
 
@@ -1291,7 +1316,7 @@ export class Jodit extends ViewWithToolbar implements IJodit {
1291
1316
 
1292
1317
  const opt = this.options;
1293
1318
 
1294
- const init = () => {
1319
+ const init = (): void => {
1295
1320
  if (
1296
1321
  opt.enableDragAndDropFileToEditor &&
1297
1322
  opt.uploader &&
@@ -1325,7 +1350,7 @@ export class Jodit extends ViewWithToolbar implements IJodit {
1325
1350
  }
1326
1351
 
1327
1352
  if (!this.isEditorMode()) {
1328
- this.setMode(consts.MODE_WYSIWYG);
1353
+ this.setMode(constants.MODE_WYSIWYG);
1329
1354
  }
1330
1355
 
1331
1356
  this.currentPlace = place;
@@ -1458,15 +1483,9 @@ export class Jodit extends ViewWithToolbar implements IJodit {
1458
1483
  * Attach some native event listeners
1459
1484
  */
1460
1485
  @autobind
1461
- private prepareWYSIWYGEditor() {
1486
+ private prepareWYSIWYGEditor(): void {
1462
1487
  const { editor } = this;
1463
1488
 
1464
- if (this.o.spellcheck) {
1465
- this.editor.setAttribute('spellcheck', 'true');
1466
- } else {
1467
- this.editor.setAttribute('spellcheck', 'false');
1468
- }
1469
-
1470
1489
  // direction
1471
1490
  if (this.o.direction) {
1472
1491
  const direction =
@@ -1485,9 +1504,7 @@ export class Jodit extends ViewWithToolbar implements IJodit {
1485
1504
  this.setCurrentPlace(place);
1486
1505
  }
1487
1506
  })
1488
- .on(editor, 'compositionend', () => {
1489
- this.setEditorValue();
1490
- })
1507
+ .on(editor, 'compositionend', this.synchronizeValues)
1491
1508
  .on(
1492
1509
  editor,
1493
1510
  'selectionchange selectionstart keydown keyup input keypress dblclick mousedown mouseup ' +
@@ -1510,7 +1527,7 @@ export class Jodit extends ViewWithToolbar implements IJodit {
1510
1527
  return false;
1511
1528
  }
1512
1529
 
1513
- this.setEditorValue();
1530
+ this.synchronizeValues();
1514
1531
  }
1515
1532
  }
1516
1533
  );
@@ -1553,7 +1570,7 @@ export class Jodit extends ViewWithToolbar implements IJodit {
1553
1570
  element,
1554
1571
  iframe,
1555
1572
  editor,
1556
- observer
1573
+ history
1557
1574
  }) => {
1558
1575
  if (element !== container) {
1559
1576
  if (element.hasAttribute(__defaultStyleDisplayKey)) {
@@ -1578,7 +1595,7 @@ export class Jodit extends ViewWithToolbar implements IJodit {
1578
1595
  element.removeAttribute('style');
1579
1596
  }
1580
1597
 
1581
- !statusbar.isInDestruct && statusbar.destruct();
1598
+ statusbar.destruct();
1582
1599
 
1583
1600
  this.e.off(container);
1584
1601
  this.e.off(element);
@@ -1604,7 +1621,7 @@ export class Jodit extends ViewWithToolbar implements IJodit {
1604
1621
  element.innerHTML = buffer;
1605
1622
  }
1606
1623
 
1607
- !observer.isInDestruct && observer.destruct();
1624
+ history.destruct();
1608
1625
  }
1609
1626
  );
1610
1627
 
@@ -75,7 +75,7 @@ Jodit.make('#editor', {
75
75
  To use internationalization in your own plugin, use the method [[Jodit.i18n]]
76
76
 
77
77
  ```js
78
- const editor = new Jodit('#redactor', {
78
+ const editor = Jodit.make('#redactor', {
79
79
  language: 'ru'
80
80
  });
81
81
  console.log(editor.i18n('Type something')); //'Введите что-либо тут...'
package/src/langs/ar.js CHANGED
@@ -222,5 +222,6 @@ module.exports = {
222
222
  'Word Paste Detected': 'كلمة لصق الكشف عن',
223
223
  Clean: 'نظيفة',
224
224
  'Insert className': 'أدخل اسم الفصل',
225
- 'Line height': 'ارتفاع الخط'
225
+ 'Line height': 'ارتفاع الخط',
226
+ Spellchecking: 'التدقيق الإملائي'
226
227
  };
@@ -224,5 +224,6 @@ module.exports = {
224
224
  'Find Previous': 'Najít Předchozí',
225
225
  'Find Next': 'Najít Další',
226
226
  'Insert className': 'Vložte název třídy',
227
- 'Line height': 'Výška čáry'
227
+ 'Line height': 'Výška čáry',
228
+ Spellchecking: 'Kontrola pravopisu'
228
229
  };
package/src/langs/de.js CHANGED
@@ -229,5 +229,6 @@ module.exports = {
229
229
  'Find Previous': 'Suche vorherige',
230
230
  'Find Next': 'Weitersuchen',
231
231
  'Insert className': 'className (CSS) einfügen',
232
- 'Line height': 'Zeilenhöhe'
232
+ 'Line height': 'Zeilenhöhe',
233
+ Spellchecking: 'Rechtschreibprüfung'
233
234
  };
package/src/langs/es.js CHANGED
@@ -228,5 +228,6 @@ module.exports = {
228
228
  'Find Previous': 'Buscar Anterior',
229
229
  'Find Next': 'Buscar Siguiente',
230
230
  'Insert className': 'Insertar nombre de clase',
231
- 'Line height': 'Altura de la línea'
231
+ 'Line height': 'Altura de la línea',
232
+ Spellchecking: 'Corrección ortográfica'
232
233
  };
package/src/langs/fa.js CHANGED
@@ -224,5 +224,6 @@ module.exports = {
224
224
  'Find Previous': 'پیدا کردن قبلی',
225
225
  'Find Next': 'پیدا کردن بعدی',
226
226
  'Insert className': 'Insertar nombre de clase',
227
- 'Line height': 'ارتفاع خط'
227
+ 'Line height': 'ارتفاع خط',
228
+ Spellchecking: 'غلطیابی املایی'
228
229
  };
package/src/langs/fr.js CHANGED
@@ -219,5 +219,6 @@ module.exports = {
219
219
  'Find Previous': 'Trouvez Précédente',
220
220
  'Find Next': 'Suivant',
221
221
  'Insert className': 'Insérer un nom de classe',
222
- 'Line height': 'Hauteur de ligne'
222
+ 'Line height': 'Hauteur de ligne',
223
+ Spellchecking: 'Vérification Orthographique'
223
224
  };
package/src/langs/he.js CHANGED
@@ -223,5 +223,6 @@ module.exports = {
223
223
  'Find Previous': 'מצא את הקודם',
224
224
  'Find Next': 'חפש את הבא',
225
225
  'Insert className': 'הכנס את שם הכיתה',
226
- 'Line height': 'גובה שורה'
226
+ 'Line height': 'גובה שורה',
227
+ Spellchecking: 'בדיקת איות'
227
228
  };
package/src/langs/hu.js CHANGED
@@ -225,5 +225,6 @@ module.exports = {
225
225
  'Find Previous': 'Megtalálja Előző',
226
226
  'Find Next': 'Következő Keresése',
227
227
  'Insert className': 'Helyezze be az osztály nevét',
228
- 'Line height': 'Vonal magassága'
228
+ 'Line height': 'Vonal magassága',
229
+ Spellchecking: 'Helyesírás-ellenőrzés'
229
230
  };
package/src/langs/id.js CHANGED
@@ -224,5 +224,6 @@ module.exports = {
224
224
  'Find Previous': 'Menemukan Sebelumnya',
225
225
  'Find Next': 'Menemukan Berikutnya',
226
226
  'Insert className': 'Masukkan nama kelas',
227
- 'Line height': 'Tinggi baris'
227
+ 'Line height': 'Tinggi baris',
228
+ Spellchecking: 'Spellchecking'
228
229
  };
@@ -63,7 +63,7 @@ if (!process.env.EXCLUDE_LANGS) {
63
63
  }
64
64
 
65
65
  /* Unpack array to hash */
66
- const get = (value: IDictionary) => value.default || value,
66
+ const get = (value: IDictionary): IDictionary => value.default || value,
67
67
  hashLang: IDictionary = {};
68
68
 
69
69
  if (isArray(get(en))) {
package/src/langs/it.js CHANGED
@@ -224,5 +224,6 @@ module.exports = {
224
224
  'Find Previous': 'Trova Precedente',
225
225
  'Find Next': 'Trova Successivo',
226
226
  'Insert className': 'Inserisci il nome della classe',
227
- 'Line height': 'Altezza linea'
227
+ 'Line height': 'Altezza linea',
228
+ Spellchecking: 'Controllo ortografico'
228
229
  };
package/src/langs/ja.js CHANGED
@@ -227,5 +227,6 @@ module.exports = {
227
227
  'Upper Alpha': '英大文字',
228
228
  'Upper Roman': 'ローマ数字大文字',
229
229
  'Insert className': 'クラス名を挿入',
230
- 'Line height': 'ラインの高さ'
230
+ 'Line height': 'ラインの高さ',
231
+ Spellchecking: 'スペルチェック'
231
232
  };
package/src/langs/ko.js CHANGED
@@ -222,5 +222,6 @@ module.exports = {
222
222
  'Find Previous': '이전 찾기',
223
223
  'Find Next': '다음 찾기',
224
224
  'Insert className': 'className 입력',
225
- 'Line height': '선 높이'
225
+ 'Line height': '선 높이',
226
+ Spellchecking: '맞춤법 검사'
226
227
  };
package/src/langs/nl.js CHANGED
@@ -225,5 +225,6 @@ module.exports = {
225
225
  'Find Previous': 'Vorige Zoeken',
226
226
  'Find Next': 'Volgende Zoeken',
227
227
  'Insert className': 'Voeg de klassenaam in',
228
- 'Line height': 'Lijnhoogte'
228
+ 'Line height': 'Lijnhoogte',
229
+ Spellchecking: 'Spellingcontrole'
229
230
  };
package/src/langs/pl.js CHANGED
@@ -225,5 +225,6 @@ module.exports = {
225
225
  'Find Previous': 'Znaleźć Poprzednie',
226
226
  'Find Next': 'Znajdź Dalej',
227
227
  'Insert className': 'Wstaw nazwę zajęć',
228
- 'Line height': 'Wysokość linii'
228
+ 'Line height': 'Wysokość linii',
229
+ Spellchecking: 'Sprawdzanie pisowni'
229
230
  };
@@ -228,5 +228,6 @@ module.exports = {
228
228
  'Find Previous': 'Encontrar Anteriores',
229
229
  'Find Next': 'Localizar Próxima',
230
230
  'Insert className': 'Insira o nome da classe',
231
- 'Line height': 'Altura da linha'
231
+ 'Line height': 'Altura da linha',
232
+ Spellchecking: 'Verificação ortográfica'
232
233
  };
package/src/langs/ru.js CHANGED
@@ -223,5 +223,6 @@ module.exports = {
223
223
  'Find Previous': 'Найти Предыдущие',
224
224
  'Find Next': 'Найти Далее',
225
225
  'Insert className': 'Вставить название класса',
226
- 'Line height': 'Высота линии'
226
+ 'Line height': 'Высота линии',
227
+ Spellchecking: 'Проверка орфографии'
227
228
  };
package/src/langs/tr.js CHANGED
@@ -223,5 +223,6 @@ module.exports = {
223
223
  'Find Previous': 'Öncekini Bul',
224
224
  'Find Next': 'Sonrakini Bul',
225
225
  'Insert className': 'Sınıf adı girin',
226
- 'Line height': 'Çizgi yüksekliği'
226
+ 'Line height': 'Çizgi yüksekliği',
227
+ Spellchecking: 'Yazım denetimi'
227
228
  };
@@ -223,5 +223,6 @@ module.exports = {
223
223
  'Find Previous': '查找上一个',
224
224
  'Find Next': '查找下一个',
225
225
  'Insert className': '插入班级名称',
226
- 'Line height': '线高'
226
+ 'Line height': '线高',
227
+ Spellchecking: '拼写检查'
227
228
  };
@@ -221,5 +221,6 @@ module.exports = {
221
221
  'Find Previous': 'ค้นหาก่อนหน้านี้',
222
222
  'Find Next': 'ค้นหาถัดไป',
223
223
  'Insert className': 'ใส่ชื่อคลาส',
224
- 'Line height': 'ความสูงเส้น'
224
+ 'Line height': 'ความสูงเส้น',
225
+ Spellchecking: 'สะกดคำ'
225
226
  };
@@ -111,15 +111,15 @@ export class Dialog extends ViewWithToolbar implements IDialog {
111
111
  private startY: number = 0;
112
112
  private startPoint = { x: 0, y: 0, w: 0, h: 0 };
113
113
 
114
- private lockSelect = () => {
114
+ private lockSelect = (): void => {
115
115
  this.setMod('moved', true);
116
116
  };
117
117
 
118
- private unlockSelect = () => {
118
+ private unlockSelect = (): void => {
119
119
  this.setMod('moved', false);
120
120
  };
121
121
 
122
- private setElements(root: HTMLElement, elements: Content) {
122
+ private setElements(root: HTMLElement, elements: Content): void {
123
123
  const elements_list: HTMLElement[] = [];
124
124
 
125
125
  asArray<ContentItem | ContentItem[] | IContainer>(elements).forEach(
@@ -215,7 +215,7 @@ export class Dialog extends ViewWithToolbar implements IDialog {
215
215
  }
216
216
 
217
217
  @autobind
218
- private onMouseMove(e: MouseEvent) {
218
+ private onMouseMove(e: MouseEvent): void {
219
219
  if (this.draggable && this.o.draggable) {
220
220
  this.setPosition(
221
221
  this.startPoint.x + e.clientX - this.startX,
@@ -276,7 +276,7 @@ export class Dialog extends ViewWithToolbar implements IDialog {
276
276
  }
277
277
  }
278
278
 
279
- private onResize = () => {
279
+ private onResize = (): void => {
280
280
  if (
281
281
  this.options &&
282
282
  this.o.resizable &&
@@ -290,7 +290,7 @@ export class Dialog extends ViewWithToolbar implements IDialog {
290
290
  };
291
291
 
292
292
  @autobind
293
- private onResizerMouseDown(e: MouseEvent) {
293
+ private onResizerMouseDown(e: MouseEvent): void {
294
294
  this.resizable = true;
295
295
  this.startX = e.clientX;
296
296
  this.startY = e.clientY;
@@ -64,7 +64,7 @@ export const Prompt = (
64
64
 
65
65
  cancelButton.onAction(dialog.close);
66
66
 
67
- const onclick = () => {
67
+ const onclick = (): void => {
68
68
  if (
69
69
  !callback ||
70
70
  !isFunction(callback) ||
@@ -141,7 +141,7 @@ Jodit.make('#editor', {
141
141
  Example:
142
142
 
143
143
  ```javascript
144
- var editor = new Jodit('#editor', {
144
+ var editor = Jodit.make('#editor', {
145
145
  filebrowser: {
146
146
  buttons: [
147
147
  'filebrowser.upload',
@@ -330,7 +330,7 @@ Jodit.make('#editor2', {
330
330
  Example:
331
331
 
332
332
  ```javascript
333
- var editor = new Jodit('#jodit', {
333
+ var editor = Jodit.make('#jodit', {
334
334
  uploader: {
335
335
  url: 'connector/upload.php',
336
336
  baseurl: 'images/'