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/types/config.d.ts CHANGED
@@ -11,6 +11,10 @@ import type { IExtraPlugin, IDictionary, IViewOptions, NodeFunction, Attributes,
11
11
  * Default Editor's Configuration
12
12
  */
13
13
  export declare class Config implements IViewOptions {
14
+ /**
15
+ * Timeout of all asynchronous methods
16
+ */
17
+ defaultTimeout: number;
14
18
  namespace: string;
15
19
  /**
16
20
  * Editor loads completely without plugins. Useful when debugging your own plugin.
@@ -100,11 +104,6 @@ export declare class Config implements IViewOptions {
100
104
  * if set true then the current mode is saved in a cookie , and is restored after a reload of the page
101
105
  */
102
106
  saveModeInStorage: boolean;
103
- /**
104
- * Options specifies whether the editor is to have its spelling and grammar checked or not
105
- * @see {@link http://www.w3schools.com/tags/att_global_spellcheck.asp}
106
- */
107
- spellcheck: boolean;
108
107
  /**
109
108
  * Class name that can be appended to the editor
110
109
  *
@@ -113,7 +112,7 @@ export declare class Config implements IViewOptions {
113
112
  *
114
113
  * @example
115
114
  * ```javascript
116
- * new Jodit('#editor', {
115
+ * Jodit.make('#editor', {
117
116
  * editorCssClass: 'some_my_class'
118
117
  * });
119
118
  * ```
@@ -131,7 +130,7 @@ export declare class Config implements IViewOptions {
131
130
  *
132
131
  * @example
133
132
  * ```javascript
134
- * new Jodit('#editor', {
133
+ * Jodit.make('#editor', {
135
134
  * style: {
136
135
  * font: '12px Arial'
137
136
  * }
@@ -144,7 +143,7 @@ export declare class Config implements IViewOptions {
144
143
  *
145
144
  * @example
146
145
  * ```javascript
147
- * var editor = new Jodit('#editor');
146
+ * var editor = Jodit.make('#editor');
148
147
  * document.getElementById('editor').addEventListener('change', function () {
149
148
  * console.log(this.value);
150
149
  * })
@@ -158,7 +157,7 @@ export declare class Config implements IViewOptions {
158
157
  * 'rtl' – Indicates a Right-To-Left text direction (like in Arabic).
159
158
  * @example
160
159
  * ```javascript
161
- * new Jodit('.editor', {
160
+ * Jodit.make('.editor', {
162
161
  * direction: 'rtl'
163
162
  * })
164
163
  * ```
@@ -174,7 +173,7 @@ export declare class Config implements IViewOptions {
174
173
  * <!-- include in you page lang file -->
175
174
  * <script src="jodit/lang/de.js"></script>
176
175
  * <script>
177
- * var editor = new Jodit('.editor', {
176
+ * var editor = Jodit.make('.editor', {
178
177
  * language: 'de'
179
178
  * });
180
179
  * </script>
@@ -187,7 +186,7 @@ export declare class Config implements IViewOptions {
187
186
  * @example
188
187
  * ```html
189
188
  * <script>
190
- * var editor = new Jodit('.editor', {
189
+ * var editor = Jodit.make('.editor', {
191
190
  * debugLanguage: true
192
191
  * });
193
192
  *
@@ -201,7 +200,7 @@ export declare class Config implements IViewOptions {
201
200
  *
202
201
  * @example
203
202
  * ```javascript
204
- * var editor = new Jodit('#editor', {
203
+ * var editor = Jodit.make('#editor', {
205
204
  * language: 'ru',
206
205
  * i18n: {
207
206
  * ru: {
@@ -254,7 +253,7 @@ export declare class Config implements IViewOptions {
254
253
  * Jodit.MODE_SOURCE syntax highlighting source editor
255
254
  * @example
256
255
  * ```javascript
257
- * var editor = new Jodit('#editor', {
256
+ * var editor = Jodit.make('#editor', {
258
257
  * defaultMode: Jodit.MODE_SPLIT
259
258
  * });
260
259
  * console.log(editor.getRealMode())
@@ -269,7 +268,7 @@ export declare class Config implements IViewOptions {
269
268
  * The colors in HEX representation to select a color for the background and for the text in colorpicker
270
269
  * @example
271
270
  * ```javascript
272
- * new Jodit('#editor', {
271
+ * Jodit.make('#editor', {
273
272
  * colors: ['#ff0000', '#00ff00', '#0000ff']
274
273
  * })
275
274
  * ```
@@ -279,7 +278,7 @@ export declare class Config implements IViewOptions {
279
278
  * The default tab color picker
280
279
  * @example
281
280
  * ```javascript
282
- * new Jodit('#editor2', {
281
+ * Jodit.make('#editor2', {
283
282
  * colorPickerDefaultTab: 'color'
284
283
  * })
285
284
  * ```
@@ -303,11 +302,11 @@ export declare class Config implements IViewOptions {
303
302
  * Do not init these plugins
304
303
  * @example
305
304
  * ```typescript
306
- * var editor = new Jodit('.editor', {
305
+ * var editor = Jodit.make('.editor', {
307
306
  * disablePlugins: 'table,iframe'
308
307
  * });
309
308
  * //or
310
- * var editor = new Jodit('.editor', {
309
+ * var editor = Jodit.make('.editor', {
311
310
  * disablePlugins: ['table', 'iframe']
312
311
  * });
313
312
  * ```
@@ -317,7 +316,7 @@ export declare class Config implements IViewOptions {
317
316
  * Init and download extra plugins
318
317
  * @example
319
318
  * ```typescript
320
- * var editor = new Jodit('.editor', {
319
+ * var editor = Jodit.make('.editor', {
321
320
  * extraPlugins: ['emoji']
322
321
  * });
323
322
  * ```
@@ -329,7 +328,7 @@ export declare class Config implements IViewOptions {
329
328
  */
330
329
  basePath?: string;
331
330
  /**
332
- * This buttons list will be added to option.buttons
331
+ * These buttons list will be added to option.buttons
333
332
  */
334
333
  extraButtons: Array<string | IControlType>;
335
334
  /**
@@ -371,6 +370,41 @@ export declare class Config implements IViewOptions {
371
370
  extraIcons: IDictionary<string>;
372
371
  /**
373
372
  * Default attributes for created inside editor elements
373
+ * @example
374
+ * ```js
375
+ * const editor2 = Jodit.make('#editor', {
376
+ * createAttributes: {
377
+ * div: {
378
+ * class: 'test'
379
+ * },
380
+ * ul: function (ul) {
381
+ * ul.classList.add('ui-test');
382
+ * }
383
+ * }
384
+ * });
385
+ *
386
+ * const div2 = editor2.createInside.div();
387
+ * expect(div2.className).equals('test');
388
+ *
389
+ * const ul = editor2.createInside.element('ul');
390
+ * expect(ul.className).equals('ui-test');
391
+ * ```
392
+ * Or JSX in React
393
+ * @example
394
+ * ```jsx
395
+ * import React, {useState, useRef} from 'react';
396
+ * import JoditEditor from "jodit-react";
397
+ *
398
+ * const config = {
399
+ * createAttributes: {
400
+ * div: {
401
+ * class: 'align-center'
402
+ * }
403
+ * }
404
+ * };
405
+ *
406
+ * <JoditEditor config={config}/>
407
+ * ```
374
408
  */
375
409
  createAttributes: IDictionary<Attributes | NodeFunction>;
376
410
  /**
@@ -390,7 +424,7 @@ export declare class Config implements IViewOptions {
390
424
  * Note - this is not the width of the device, the width of the editor
391
425
  * @example
392
426
  * ```javascript
393
- * new Jodit('#editor', {
427
+ * Jodit.make('#editor', {
394
428
  * buttons: ['bold', 'italic', 'source'],
395
429
  * buttonsMD: ['bold', 'italic'],
396
430
  * buttonsXS: ['bold', 'fullsize'],
@@ -398,32 +432,31 @@ export declare class Config implements IViewOptions {
398
432
  * ```
399
433
  * @example
400
434
  * ```javascript
401
- * new Jodit('#editor2', {
435
+ * Jodit.make('#editor2', {
402
436
  * buttons: [{
403
- * name: 'enty',
437
+ * name: 'empty',
404
438
  * icon: 'source',
405
- * exec: function () {
406
- * var dialog = new Jodit.modules.Dialog(this),
407
- * div = document.createElement('div'),
408
- * text = document.createElement('textarea');
409
- * div.textContent = this.val();
439
+ * exec: function (editor) {
440
+ * const dialog = new Jodit.modules.Dialog({}),
441
+ * text = editor.c.element('textarea');
442
+ *
410
443
  * dialog.setHeader('Source code');
411
444
  * dialog.setContent(text);
412
445
  * dialog.setSize(400, 300);
413
- * dom(text)
414
- * .css({
415
- * width: '100%',
416
- * height: '100%'
417
- * })
418
- * .val(div.innerHTML.replace(/<br>/g, '\n'));
419
- * dialog.{@link module:Dialog~open|open}();
446
+ *
447
+ * Jodit.modules.Helpers.css(elm, {
448
+ * width: '100%',
449
+ * height: '100%'
450
+ * })
451
+
452
+ * dialog.open();
420
453
  * }
421
454
  * }]
422
455
  * });
423
456
  * ```
424
457
  * @example
425
458
  * ```javascript
426
- * new Jodit('#editor2', {
459
+ * Jodit.make('#editor2', {
427
460
  * buttons: Jodit.defaultOptions.buttons.concat([{
428
461
  * name: 'listsss',
429
462
  * iconURL: 'stuf/dummy.png',
@@ -22,7 +22,7 @@ export declare class Async implements IAsync {
22
22
  *
23
23
  * @example
24
24
  * ```javascript
25
- * var jodit = new Jodit('.editor');
25
+ * var jodit = Jodit.make('.editor');
26
26
  * jodit.e.on('mousemove', jodit.async.debounce(() => {
27
27
  * // Do expensive things
28
28
  * }, 100));
@@ -35,7 +35,7 @@ export declare class Async implements IAsync {
35
35
  *
36
36
  * @example
37
37
  * ```javascript
38
- * var jodit = new Jodit('.editor');
38
+ * var jodit = Jodit.make('.editor');
39
39
  * jodit.e.on(document.body, 'scroll', jodit.async.throttle(function() {
40
40
  * // Do expensive things
41
41
  * }, 100));
@@ -49,11 +49,18 @@ export declare class Async implements IAsync {
49
49
  */
50
50
  promiseState(p: Promise<any>): Promise<'pending' | 'fulfilled' | 'rejected'>;
51
51
  private requestsIdle;
52
+ private requestsRaf;
52
53
  private requestIdleCallbackNative;
53
54
  private cancelIdleCallbackNative;
54
- requestIdleCallback(callback: IdleRequestCallback): number;
55
- requestIdlePromise(): RejectablePromise<number>;
55
+ requestIdleCallback(callback: IdleRequestCallback, options?: {
56
+ timeout: number;
57
+ }): number;
58
+ requestIdlePromise(options?: {
59
+ timeout: number;
60
+ }): RejectablePromise<number>;
56
61
  cancelIdleCallback(request: number): void;
62
+ requestAnimationFrame(callback: FrameRequestCallback): number;
63
+ cancelAnimationFrame(request: number): void;
57
64
  clear(): void;
58
65
  isDestructed: boolean;
59
66
  destruct(): any;
@@ -57,6 +57,7 @@ export declare const IS_IE: boolean;
57
57
  */
58
58
  export declare const TEXT_PLAIN: string;
59
59
  export declare const TEXT_HTML: string;
60
+ export declare const TEXT_RTF: string;
60
61
  export declare const MARKER_CLASS = "jodit-selection_marker";
61
62
  export declare const EMULATE_DBLCLICK_TIMEOUT = 300;
62
63
  /**
@@ -21,10 +21,8 @@ export declare class Dom {
21
21
  * Wrap all inline siblings
22
22
  */
23
23
  static wrapInline(current: Node, tag: Node | HTMLTagNames, editor: IJodit): HTMLElement;
24
- /**
25
- * Wrap node inside another node
26
- */
27
- static wrap<K extends HTMLTagNames>(current: Node, tag: K, create: ICreate): HTMLElementTagNameMap[K];
24
+ static wrap<K extends HTMLTagNames>(current: Node | Range, tag: HTMLElement, create: ICreate): HTMLElementTagNameMap[K];
25
+ static wrap<K extends HTMLTagNames>(current: Node | Range, tag: K, create: ICreate): HTMLElementTagNameMap[K];
28
26
  /**
29
27
  * Remove parent of node and insert this node instead that parent
30
28
  */
@@ -148,7 +146,7 @@ export declare class Dom {
148
146
  * Get not empty sibling
149
147
  */
150
148
  static findSibling(node: Node, left?: boolean, cond?: (n: Node) => boolean): Nullable<Node>;
151
- static sibling(node: Node, left: boolean): Nullable<Node>;
149
+ static sibling(node: Node, left?: boolean): Nullable<Node>;
152
150
  /**
153
151
  * It goes through all the elements in ascending order, and checks to see if they meet the predetermined condition
154
152
  */
@@ -7,3 +7,4 @@
7
7
  * @module dom
8
8
  */
9
9
  export * from './dom';
10
+ export * from './lazy-walker';
@@ -0,0 +1,37 @@
1
+ /*!
2
+ * Jodit Editor (https://xdsoft.net/jodit/)
3
+ * Released under MIT see LICENSE.txt in the project root for license information.
4
+ * Copyright (c) 2013-2022 Valeriy Chupurnov. All rights reserved. https://xdsoft.net
5
+ */
6
+ /**
7
+ * @module dom
8
+ */
9
+ import type { IAsync, IDestructible } from 'jodit/types';
10
+ import { Eventify } from 'jodit/core/event-emitter/eventify';
11
+ export declare class LazyWalker extends Eventify<{
12
+ visit: (node: Node) => boolean;
13
+ break: (reason?: string) => void;
14
+ end: (affect: boolean) => void;
15
+ }> implements IDestructible {
16
+ private readonly async;
17
+ private readonly options;
18
+ private workNodes;
19
+ setWork(root: Node): this;
20
+ private hadAffect;
21
+ private isWorked;
22
+ private isFinished;
23
+ constructor(async: IAsync, options?: {
24
+ readonly timeout?: number;
25
+ readonly whatToShow?: number;
26
+ readonly reverse?: boolean;
27
+ readonly timeoutChunkSize?: number;
28
+ });
29
+ private idleId;
30
+ private startIdleRequest;
31
+ break(reason?: string): void;
32
+ end(): void;
33
+ private stop;
34
+ destruct(): void;
35
+ private workPerform;
36
+ private visitNode;
37
+ }
@@ -0,0 +1,39 @@
1
+ /*!
2
+ * Jodit Editor (https://xdsoft.net/jodit/)
3
+ * Released under MIT see LICENSE.txt in the project root for license information.
4
+ * Copyright (c) 2013-2022 Valeriy Chupurnov. All rights reserved. https://xdsoft.net
5
+ */
6
+ /**
7
+ * @module event-emitter
8
+ */
9
+ import type { CanUndef } from 'jodit/types';
10
+ /**
11
+ * Class for adding event handling capability
12
+ *
13
+ * ```ts
14
+ * class SomeClass extends Eventify<{ start: (node: Node) => boolean; }> {
15
+ * constructor() {
16
+ * super();
17
+ * setTimeout(() => {
18
+ * if (this.emit('start', document.body)) {
19
+ * console.log('yes');
20
+ * };
21
+ * }, 100);
22
+ * }
23
+ * }
24
+ *
25
+ * const sm = new SomeClass();
26
+ * sm.on('start', (node) => {
27
+ * console.log(node);
28
+ * return true;
29
+ * })
30
+ * ```
31
+ */
32
+ export declare abstract class Eventify<MAP extends {
33
+ [key: string]: (...args: any[]) => any;
34
+ }, EVENT extends keyof MAP = keyof MAP> {
35
+ private map;
36
+ on(name: EVENT, func: MAP[EVENT]): this;
37
+ off(name: keyof MAP, func: MAP[EVENT]): this;
38
+ protected emit(name: EVENT, ...args: Parameters<MAP[EVENT]>): CanUndef<ReturnType<MAP[EVENT]>>;
39
+ }
@@ -7,5 +7,6 @@
7
7
  * @module event-emitter
8
8
  */
9
9
  export * from './event-emitter';
10
+ export * from './eventify';
10
11
  export * from './observable';
11
12
  export * from './store';
@@ -0,0 +1,10 @@
1
+ /*!
2
+ * Jodit Editor (https://xdsoft.net/jodit/)
3
+ * Released under MIT see LICENSE.txt in the project root for license information.
4
+ * Copyright (c) 2013-2022 Valeriy Chupurnov. All rights reserved. https://xdsoft.net
5
+ */
6
+ /**
7
+ * Finds the position of the substring in the string, if any, and returns the length of the found subsequence.
8
+ * Unlike `indexOf` ignores INVISIBLE_SPACE and may fail at `maxDistance` characters
9
+ */
10
+ export declare function fuzzySearchIndex(needle: string, haystack: string, offset?: number, maxDistance?: number): [number, number];
@@ -15,7 +15,7 @@ export declare const sprintf: (str: string, args?: (string | number)[] | undefin
15
15
  * Internationalization method. Uses Jodit.lang object
16
16
  * @example
17
17
  * ```javascript
18
- * var editor = new Jodit("#redactor", {
18
+ * var editor = Jodit.make("#redactor", {
19
19
  * language: 'ru'
20
20
  * });
21
21
  * console.log(editor.i18n('Cancel')) //Отмена;
@@ -7,8 +7,9 @@
7
7
  * @module helpers/string
8
8
  */
9
9
  export * from './camel-case';
10
- export * from './stringify';
10
+ export * from './fuzzy-search-index';
11
+ export * from './i18n';
11
12
  export * from './kebab-case';
13
+ export * from './stringify';
12
14
  export * from './trim';
13
15
  export * from './ucfirst';
14
- export * from './i18n';
@@ -24,7 +24,7 @@ export declare function attr(elm: Element, key: string): null | string;
24
24
  /**
25
25
  * Remove attribute
26
26
  */
27
- export declare function attr(elm: Element, key: string, value: null): null | string;
27
+ export declare function attr(elm: Element, key: string, value: null): void;
28
28
  /**
29
29
  * Set attribute
30
30
  */
@@ -188,7 +188,7 @@ export declare class Select implements ISelect {
188
188
  * Return current selected HTML
189
189
  * @example
190
190
  * ```javascript
191
- * const editor = new jodit();
191
+ * const editor = Jodit.make();
192
192
  * console.log(editor.s.html); // html
193
193
  * console.log(Jodit.modules.Helpers.stripTags(editor.s.html)); // plain text
194
194
  * ```
@@ -16,8 +16,8 @@ export declare class UIButton extends UIElement implements IUIButton {
16
16
  /**
17
17
  * Marker for buttons
18
18
  */
19
- isButton: true;
20
- state: IUIButtonState;
19
+ readonly isButton: true;
20
+ readonly state: IUIButtonState;
21
21
  /**
22
22
  * Set state
23
23
  */
@@ -43,7 +43,7 @@ export declare class UIButton extends UIElement implements IUIButton {
43
43
  protected onChangeActivated(): void;
44
44
  protected onChangeName(): void;
45
45
  protected onChangeTooltip(): void;
46
- onChangeTabIndex(): void;
46
+ protected onChangeTabIndex(): void;
47
47
  protected onChangeIcon(): void;
48
48
  /**
49
49
  * Set focus on element
@@ -57,7 +57,7 @@ export declare class UIButton extends UIElement implements IUIButton {
57
57
  protected createContainer(): HTMLElement;
58
58
  constructor(jodit: IViewBased, state?: IUIButtonStatePartial);
59
59
  destruct(): any;
60
- private actionHandlers;
60
+ private readonly actionHandlers;
61
61
  /**
62
62
  * Add action handler
63
63
  */
@@ -38,7 +38,7 @@ export declare abstract class View extends Component implements IViewBased, Mods
38
38
  readonly version: string;
39
39
  /**
40
40
  * Return default timeout period in milliseconds for some debounce or throttle functions.
41
- * By default return `{observer.timeout}` options
41
+ * By default, `{history.timeout}` options
42
42
  */
43
43
  get defaultTimeout(): number;
44
44
  readonly async: IAsync;
package/types/jodit.d.ts CHANGED
@@ -8,8 +8,9 @@
8
8
  * @packageDocumentation
9
9
  * @module jodit
10
10
  */
11
- import type { CustomCommand, IDictionary, IPluginSystem, IStatusBar, IWorkPlace, Modes, IFileBrowser, IJodit, IUploader, ICreate, IStorage, CanPromise, IObserver } from './types';
11
+ import type { CustomCommand, IDictionary, IPluginSystem, IStatusBar, IWorkPlace, Modes, IFileBrowser, IJodit, IUploader, ICreate, IStorage, CanPromise, IHistory } from './types';
12
12
  import { Config } from './config';
13
+ import * as constants from './core/constants';
13
14
  import { Plugin, Select } from './modules/';
14
15
  import { ViewWithToolbar } from './core/view/view-with-toolbar';
15
16
  /**
@@ -40,7 +41,7 @@ export declare class Jodit extends ViewWithToolbar implements IJodit {
40
41
  get text(): string;
41
42
  /**
42
43
  * Return default timeout period in milliseconds for some debounce or throttle functions.
43
- * By default return `{observer.timeout}` options
44
+ * By default, `{history.timeout}` options
44
45
  */
45
46
  get defaultTimeout(): number;
46
47
  /**
@@ -66,6 +67,7 @@ export declare class Jodit extends ViewWithToolbar implements IJodit {
66
67
  static readonly modules: IDictionary<Function>;
67
68
  static readonly ns: IDictionary<Function>;
68
69
  static readonly decorators: IDictionary<Function>;
70
+ static readonly constants: typeof constants;
69
71
  static readonly instances: IDictionary<IJodit>;
70
72
  static readonly lang: any;
71
73
  static readonly core: {
@@ -111,7 +113,11 @@ export declare class Jodit extends ViewWithToolbar implements IJodit {
111
113
  */
112
114
  get iframe(): HTMLIFrameElement | void;
113
115
  set iframe(iframe: HTMLIFrameElement | void);
114
- get observer(): IObserver;
116
+ get history(): IHistory;
117
+ /**
118
+ * @deprecated Instead use `Jodit.history`
119
+ */
120
+ get observer(): IHistory;
115
121
  /**
116
122
  * In iframe mode editor's window can be different by owner
117
123
  */
@@ -165,11 +171,16 @@ export declare class Jodit extends ViewWithToolbar implements IJodit {
165
171
  */
166
172
  getEditorValue(removeSelectionMarkers?: boolean, consumer?: string): string;
167
173
  private __callChangeCount;
174
+ synchronizeValues(): void;
168
175
  /**
169
176
  * Set editor html value and if set sync fill source element value
170
177
  * When method was called without arguments - it is simple way to synchronize editor to element
171
178
  */
172
179
  setEditorValue(value?: string): void;
180
+ /**
181
+ * If some plugin changes the DOM directly, then you need to update the content of the original element
182
+ */
183
+ protected updateElementValue(): void;
173
184
  /**
174
185
  * Return source element value
175
186
  */
@@ -184,7 +195,7 @@ export declare class Jodit extends ViewWithToolbar implements IJodit {
184
195
  *
185
196
  * @example
186
197
  * ```javascript
187
- * var jodit = new Jodit('#editor);
198
+ * var jodit = Jodit.make('#editor);
188
199
  *
189
200
  * jodit.setEditorValue('test test test');
190
201
  *
@@ -260,7 +271,7 @@ export declare class Jodit extends ViewWithToolbar implements IJodit {
260
271
  *
261
272
  * @example
262
273
  * ```javascript
263
- * var editor = new Jodit('#editor');
274
+ * var editor = Jodit.make('#editor');
264
275
  * console.log(editor.getRealMode());
265
276
  * ```
266
277
  */
@@ -274,7 +285,7 @@ export declare class Jodit extends ViewWithToolbar implements IJodit {
274
285
  *
275
286
  * @example
276
287
  * ```javascript
277
- * var editor = new Jodit('#editor');
288
+ * var editor = Jodit.make('#editor');
278
289
  * editor.toggleMode();
279
290
  * ```
280
291
  */
@@ -317,6 +328,8 @@ export declare class Jodit extends ViewWithToolbar implements IJodit {
317
328
  *
318
329
  * @param element - Selector or HTMLElement
319
330
  * @param options - Editor's options
331
+ *
332
+ * @deprecated - Instead use `Jodit.make`
320
333
  */
321
334
  constructor(element: HTMLElement | string, options?: object);
322
335
  currentPlace: IWorkPlace;
@@ -4,16 +4,16 @@
4
4
  * Copyright (c) 2013-2022 Valeriy Chupurnov. All rights reserved. https://xdsoft.net
5
5
  */
6
6
  /**
7
- * @module modules/observer
7
+ * @module modules/history
8
8
  */
9
9
  import type { SnapshotType } from 'jodit/types';
10
- import type { Observer } from './observer';
10
+ import type { History } from './history';
11
11
  export declare class Command {
12
12
  readonly oldValue: SnapshotType;
13
13
  readonly newValue: SnapshotType;
14
- readonly observer: Observer;
14
+ private readonly history;
15
15
  readonly tick: number;
16
16
  undo(): void;
17
17
  redo(): void;
18
- constructor(oldValue: SnapshotType, newValue: SnapshotType, observer: Observer, tick: number);
18
+ constructor(oldValue: SnapshotType, newValue: SnapshotType, history: History, tick: number);
19
19
  }