jodit 3.19.4 → 3.20.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 (217) hide show
  1. package/build/jodit.css +45 -42
  2. package/build/jodit.es2018.css +38 -36
  3. package/build/jodit.es2018.en.css +38 -36
  4. package/build/jodit.es2018.en.js +22562 -25637
  5. package/build/jodit.es2018.en.min.css +1 -1
  6. package/build/jodit.es2018.en.min.js +1 -1
  7. package/build/jodit.es2018.js +23105 -26181
  8. package/build/jodit.es2018.min.css +1 -1
  9. package/build/jodit.es2018.min.js +1 -1
  10. package/build/jodit.js +797 -386
  11. package/build/jodit.min.css +2 -2
  12. package/build/jodit.min.js +1 -1
  13. package/build/plugins/debug/debug.es2018.en.js +97 -0
  14. package/build/plugins/debug/debug.es2018.en.min.js +1 -0
  15. package/build/plugins/debug/debug.es2018.js +97 -0
  16. package/build/plugins/debug/debug.es2018.min.js +1 -0
  17. package/build/plugins/debug/debug.js +96 -0
  18. package/build/plugins/debug/debug.min.js +1 -0
  19. package/build/plugins/speech-recognize/speech-recognize.css +1 -1
  20. package/build/plugins/speech-recognize/speech-recognize.es2018.css +1 -1
  21. package/build/plugins/speech-recognize/speech-recognize.es2018.en.css +1 -1
  22. package/build/plugins/speech-recognize/speech-recognize.es2018.en.js +331 -398
  23. package/build/plugins/speech-recognize/speech-recognize.es2018.en.min.js +1 -1
  24. package/build/plugins/speech-recognize/speech-recognize.es2018.js +331 -398
  25. package/build/plugins/speech-recognize/speech-recognize.es2018.min.js +1 -1
  26. package/build/plugins/speech-recognize/speech-recognize.js +1 -1
  27. package/build/vdom.css +1 -1
  28. package/build/vdom.js +1 -1
  29. package/index.html +2 -2
  30. package/package.json +9 -4
  31. package/src/config.ts +4 -2
  32. package/src/core/constants.ts +7 -7
  33. package/src/core/decorators/derive/README.md +71 -0
  34. package/src/core/decorators/derive/derive.ts +48 -0
  35. package/src/core/decorators/index.ts +1 -0
  36. package/src/core/decorators/spy/spy.ts +5 -0
  37. package/src/core/dom/dom.test.js +0 -1
  38. package/src/core/dom/dom.ts +28 -13
  39. package/src/core/event-emitter/observable.ts +3 -3
  40. package/src/core/helpers/helpers.test.js +0 -170
  41. package/src/core/plugin/plugin-system.ts +20 -0
  42. package/src/core/selection/select.ts +27 -9
  43. package/src/core/selection/style/api/toggle/toggle-ordered-list.ts +5 -1
  44. package/src/core/selection/style/api/wrap-ordered-list.ts +5 -1
  45. package/src/core/selection/style/api/wrap-unwrapped-text.ts +1 -1
  46. package/src/core/selection/style/style.test.js +1 -1
  47. package/src/core/{view/panel.ts → traits/dlgs.ts} +17 -9
  48. package/src/core/traits/elms.ts +4 -8
  49. package/src/core/traits/index.ts +1 -0
  50. package/src/core/traits/mods.ts +17 -10
  51. package/src/core/ui/button/index.ts +1 -0
  52. package/src/{plugins → core/ui/button}/tooltip/README.md +0 -0
  53. package/src/{plugins → core/ui/button}/tooltip/tooltip.less +4 -4
  54. package/src/{plugins → core/ui/button}/tooltip/tooltip.test.js +3 -2
  55. package/src/core/ui/button/tooltip/tooltip.ts +132 -0
  56. package/src/core/ui/element.ts +5 -27
  57. package/src/core/ui/group/group.test.js +44 -0
  58. package/src/core/ui/group/group.ts +4 -4
  59. package/src/core/view/view-with-toolbar.ts +2 -2
  60. package/src/core/view/view.ts +11 -33
  61. package/src/jodit.ts +20 -8
  62. package/src/langs/ar.js +1 -1
  63. package/src/langs/cs_cz.js +1 -1
  64. package/src/langs/de.js +1 -1
  65. package/src/langs/es.js +1 -1
  66. package/src/langs/fa.js +1 -1
  67. package/src/langs/fr.js +1 -1
  68. package/src/langs/he.js +1 -1
  69. package/src/langs/hu.js +1 -1
  70. package/src/langs/i18n.test.js +170 -0
  71. package/src/langs/id.js +1 -1
  72. package/src/langs/it.js +1 -1
  73. package/src/langs/ja.js +1 -1
  74. package/src/langs/ko.js +1 -1
  75. package/src/langs/nl.js +1 -1
  76. package/src/langs/pl.js +1 -1
  77. package/src/langs/pt_br.js +1 -1
  78. package/src/langs/ru.js +1 -1
  79. package/src/langs/tr.js +1 -1
  80. package/src/langs/zh_cn.js +1 -1
  81. package/src/langs/zh_tw.js +1 -1
  82. package/src/modules/dialog/dialog.less +2 -0
  83. package/src/modules/dialog/dialog.ts +27 -50
  84. package/src/modules/file-browser/README.md +10 -10
  85. package/src/modules/file-browser/__image_snapshots__/file-browser-test-screenshot-js-filebrowser-screenshot-testing-open-filebrowser-works-1-snap.png +0 -0
  86. package/src/modules/file-browser/builders/context-menu.ts +1 -1
  87. package/src/modules/file-browser/file-browser.test.js +26 -13
  88. package/src/modules/file-browser/file-browser.test.screenshot.js +23 -0
  89. package/src/modules/file-browser/file-browser.ts +9 -5
  90. package/src/modules/history/snapshot.ts +12 -3
  91. package/src/modules/image-editor/__image_snapshots__/image-editor-test-screenshot-js-image-editor-screenshot-testing-open-image-editor-works-1-snap.png +0 -0
  92. package/src/modules/image-editor/image-editor.test.screenshot.js +25 -0
  93. package/src/modules/image-editor/image-editor.ts +7 -6
  94. package/src/modules/status-bar/status-bar.ts +5 -16
  95. package/src/modules/table/table.test.js +2 -1
  96. package/src/modules/toolbar/collection/collection.ts +6 -1
  97. package/src/modules/uploader/README.md +1 -1
  98. package/src/modules/uploader/config.ts +1 -1
  99. package/src/modules/uploader/uploader.test.js +96 -46
  100. package/src/plugins/about/about.ts +1 -1
  101. package/src/plugins/add-new-line/add-new-line.ts +5 -4
  102. package/src/plugins/backspace/backspace.test.js +33 -39
  103. package/src/plugins/backspace/backspace.ts +10 -4
  104. package/src/plugins/backspace/cases/check-remove-char.ts +36 -14
  105. package/src/plugins/backspace/cases/check-remove-unbreakable-element.ts +8 -0
  106. package/src/plugins/backspace/config.ts +1 -1
  107. package/src/plugins/backspace/interface.d.ts +1 -1
  108. package/src/plugins/clean-html/clean-html.test.js +240 -164
  109. package/src/plugins/clean-html/config.ts +10 -2
  110. package/src/plugins/clean-html/helpers/remove-format/remove-format-for-collapsed-selection.ts +3 -2
  111. package/src/plugins/clean-html/helpers/remove-format/remove-format-for-selection.ts +2 -2
  112. package/src/plugins/clean-html/helpers/visitor/filters/index.ts +1 -0
  113. package/src/plugins/clean-html/helpers/visitor/filters/remove-empty-text-node.ts +35 -0
  114. package/src/plugins/clean-html/helpers/visitor/filters/remove-inv-text-nodes.ts +2 -6
  115. package/src/plugins/clean-html/helpers/visitor/visit-node-walker.ts +5 -0
  116. package/src/plugins/debug/debug.ts +68 -0
  117. package/src/plugins/drag-and-drop/drag-and-drop.ts +0 -1
  118. package/src/plugins/drag-and-drop-element/drag-and-drop-element.test.js +37 -34
  119. package/src/plugins/dtd/README.md +52 -0
  120. package/{types/plugins/tooltip/tooltip.d.ts → src/plugins/dtd/after-insert/index.ts} +5 -4
  121. package/src/plugins/dtd/after-insert/remove-extra-br.ts +39 -0
  122. package/src/plugins/dtd/before-insert/check-block-nesting.ts +40 -0
  123. package/src/plugins/dtd/before-insert/index.ts +12 -0
  124. package/src/plugins/dtd/config.ts +67 -0
  125. package/src/plugins/dtd/dtd.test.js +128 -0
  126. package/src/plugins/dtd/dtd.ts +48 -0
  127. package/src/plugins/enter/enter.test.js +89 -193
  128. package/src/plugins/enter/enter.ts +14 -11
  129. package/src/plugins/enter/helpers/check-br.ts +11 -1
  130. package/src/plugins/enter/helpers/index.ts +1 -0
  131. package/src/plugins/enter/helpers/move-cursor-out-from-specal-tags.ts +32 -0
  132. package/src/plugins/enter/helpers/split-fragment.ts +1 -0
  133. package/src/plugins/fullsize/config.ts +1 -1
  134. package/src/plugins/fullsize/fullsize.test.js +77 -12
  135. package/src/plugins/fullsize/fullsize.ts +12 -1
  136. package/src/plugins/iframe/config.ts +1 -1
  137. package/src/plugins/image-properties/README.md +7 -0
  138. package/src/plugins/image-properties/image-properties.ts +1 -1
  139. package/src/plugins/index.ts +1 -1
  140. package/src/plugins/limit/limit.test.js +27 -0
  141. package/src/plugins/limit/limit.ts +4 -2
  142. package/src/plugins/line-height/line-height.svg +1 -1
  143. package/src/plugins/link/README.md +5 -0
  144. package/src/plugins/link/link.test.js +11 -12
  145. package/src/plugins/link/link.ts +1 -1
  146. package/src/plugins/mobile/mobile.ts +1 -1
  147. package/src/plugins/ordered-list/ordered-list.test.js +3 -14
  148. package/src/plugins/paste/config.ts +0 -7
  149. package/src/plugins/paste/paste.test.js +3 -3
  150. package/src/plugins/paste-storage/paste-storage.ts +1 -1
  151. package/src/plugins/preview/preview.ts +1 -1
  152. package/src/plugins/search/search.ts +1 -1
  153. package/src/plugins/select/config.ts +1 -1
  154. package/src/plugins/spellcheck/config.ts +1 -1
  155. package/src/plugins/symbols/symbols.test.js +5 -4
  156. package/src/plugins/table/config.ts +4 -17
  157. package/src/plugins/table/table.test.js +2 -2
  158. package/src/plugins/wrap-nodes/wrap-nodes.test.js +34 -5
  159. package/src/plugins/wrap-nodes/wrap-nodes.ts +59 -16
  160. package/src/styles/variables.less +1 -1
  161. package/src/types/ajax.d.ts +2 -2
  162. package/src/types/file-browser.d.ts +4 -2
  163. package/src/types/jodit.d.ts +3 -2
  164. package/src/types/plugin.d.ts +1 -0
  165. package/src/types/toolbar.d.ts +12 -6
  166. package/src/types/traits.d.ts +30 -1
  167. package/src/types/types.d.ts +1 -0
  168. package/src/types/view.d.ts +9 -34
  169. package/src/typings.d.ts +1 -0
  170. package/types/config.d.ts +3 -2
  171. package/types/core/constants.d.ts +7 -7
  172. package/types/core/decorators/derive/derive.d.ts +6 -0
  173. package/types/core/decorators/index.d.ts +1 -0
  174. package/types/core/dom/dom.d.ts +5 -4
  175. package/types/core/plugin/plugin-system.d.ts +4 -0
  176. package/types/core/traits/dlgs.d.ts +15 -0
  177. package/types/core/traits/elms.d.ts +2 -4
  178. package/types/core/traits/index.d.ts +1 -0
  179. package/types/core/traits/mods.d.ts +5 -8
  180. package/types/core/ui/button/index.d.ts +1 -0
  181. package/types/core/ui/button/tooltip/tooltip.d.ts +29 -0
  182. package/types/core/ui/element.d.ts +3 -9
  183. package/types/core/ui/group/group.d.ts +2 -2
  184. package/types/core/view/view-with-toolbar.d.ts +2 -2
  185. package/types/core/view/view.d.ts +5 -10
  186. package/types/jodit.d.ts +7 -4
  187. package/types/modules/dialog/dialog.d.ts +8 -10
  188. package/types/modules/file-browser/file-browser.d.ts +5 -2
  189. package/types/modules/history/snapshot.d.ts +3 -2
  190. package/types/modules/image-editor/image-editor.d.ts +4 -4
  191. package/types/modules/status-bar/status-bar.d.ts +3 -4
  192. package/types/modules/toolbar/collection/collection.d.ts +1 -0
  193. package/types/plugins/clean-html/config.d.ts +7 -1
  194. package/types/plugins/clean-html/helpers/visitor/filters/index.d.ts +1 -0
  195. package/types/plugins/clean-html/helpers/visitor/filters/remove-empty-text-node.d.ts +13 -0
  196. package/types/plugins/dtd/after-insert/index.d.ts +10 -0
  197. package/types/plugins/dtd/after-insert/remove-extra-br.d.ts +16 -0
  198. package/types/plugins/dtd/before-insert/check-block-nesting.d.ts +16 -0
  199. package/types/plugins/dtd/before-insert/index.d.ts +10 -0
  200. package/types/plugins/dtd/config.d.ts +27 -0
  201. package/types/plugins/dtd/dtd.d.ts +6 -0
  202. package/types/plugins/enter/helpers/index.d.ts +1 -0
  203. package/types/plugins/enter/helpers/move-cursor-out-from-specal-tags.d.ts +13 -0
  204. package/types/plugins/iframe/config.d.ts +1 -1
  205. package/types/plugins/index.d.ts +1 -1
  206. package/types/plugins/paste/config.d.ts +0 -4
  207. package/types/plugins/spellcheck/config.d.ts +1 -1
  208. package/types/types/ajax.d.ts +2 -2
  209. package/types/types/file-browser.d.ts +4 -2
  210. package/types/types/jodit.d.ts +3 -2
  211. package/types/types/plugin.d.ts +1 -0
  212. package/types/types/toolbar.d.ts +12 -6
  213. package/types/types/traits.d.ts +30 -1
  214. package/types/types/types.d.ts +1 -0
  215. package/types/types/view.d.ts +9 -34
  216. package/src/plugins/tooltip/tooltip.ts +0 -114
  217. package/types/core/view/panel.d.ts +0 -13
@@ -29,10 +29,18 @@ class wrapNodes extends Plugin {
29
29
  return;
30
30
  }
31
31
 
32
- jodit.e.on(
33
- 'afterInit.wtn postProcessSetEditorValue.wtn',
34
- this.postProcessSetEditorValue
35
- );
32
+ jodit.e
33
+ .on(
34
+ 'drop.wtn focus.wtn keydown.wtn mousedown.wtn',
35
+ this.preprocessInput,
36
+ {
37
+ top: true
38
+ }
39
+ )
40
+ .on(
41
+ 'afterInit.wtn postProcessSetEditorValue.wtn',
42
+ this.postProcessSetEditorValue
43
+ );
36
44
  }
37
45
 
38
46
  /** @override **/
@@ -55,7 +63,7 @@ class wrapNodes extends Plugin {
55
63
  isChanged: boolean = false;
56
64
 
57
65
  while (child) {
58
- this.checkAloneListLeaf(child, jodit);
66
+ child = this.checkAloneListLeaf(child, jodit);
59
67
 
60
68
  if (this.isSuitableStart(child)) {
61
69
  if (!isChanged) {
@@ -74,6 +82,7 @@ class wrapNodes extends Plugin {
74
82
  }
75
83
 
76
84
  box.normalize();
85
+ child = box;
77
86
  }
78
87
 
79
88
  child = child && child.nextSibling;
@@ -88,17 +97,33 @@ class wrapNodes extends Plugin {
88
97
  }
89
98
  }
90
99
 
91
- private checkAloneListLeaf(
92
- child: Node | Element | HTMLLIElement,
93
- jodit: IJodit
94
- ): void {
95
- if (
96
- Dom.isElement(child) &&
97
- Dom.isTag(child, 'li') &&
98
- !Dom.isTag(child.parentElement, ['ul', 'ol'])
99
- ) {
100
- Dom.wrap(child, 'ul', jodit.createInside);
101
- }
100
+ private checkAloneListLeaf(child: Node, jodit: IJodit): Node {
101
+ // debugger
102
+ let result = child;
103
+ let next: Nullable<Node> = child;
104
+
105
+ do {
106
+ if (
107
+ Dom.isElement(next) &&
108
+ Dom.isTag(next, 'li') &&
109
+ !Dom.isTag(next.parentElement, ['ul', 'ol'])
110
+ ) {
111
+ const nextChild: Nullable<Node> = Dom.findNotEmptySibling(
112
+ next,
113
+ false
114
+ );
115
+ if (Dom.isTag(result, 'ul')) {
116
+ result.appendChild(next);
117
+ } else {
118
+ result = Dom.wrap(next, 'ul', jodit.createInside);
119
+ }
120
+ next = nextChild;
121
+ } else {
122
+ break;
123
+ }
124
+ } while (next);
125
+
126
+ return result;
102
127
  }
103
128
 
104
129
  /**
@@ -120,6 +145,24 @@ class wrapNodes extends Plugin {
120
145
  private isNotClosed = (n: Nullable<Node>): n is Element =>
121
146
  Dom.isElement(n) &&
122
147
  !(Dom.isBlock(n) || Dom.isTag(n, this.j.o.wrapNodes.exclude));
148
+
149
+ /**
150
+ * Process input without parent box
151
+ */
152
+ @autobind
153
+ private preprocessInput(): void {
154
+ const { jodit } = this;
155
+
156
+ if (!jodit.isEditorMode() || jodit.editor.firstChild) {
157
+ return;
158
+ }
159
+
160
+ const box = jodit.createInside.element(jodit.o.enter);
161
+ const br = jodit.createInside.element('br');
162
+ Dom.append(box, br);
163
+ Dom.append(jodit.editor, box);
164
+ jodit.s.setCursorBefore(br);
165
+ }
123
166
  }
124
167
 
125
168
  pluginSystem.add('wrapNodes', wrapNodes);
@@ -80,10 +80,10 @@
80
80
  //z-index
81
81
  --z-index-full-size: 100000;
82
82
  --z-index-popup: 10000001;
83
- --z-index-tooltip: 10000002;
84
83
  --z-index-dialog-overlay: 20000003;
85
84
  --z-index-dialog: 20000004;
86
85
  --z-index-context-menu: 30000005;
86
+ --z-index-tooltip: 30000006;
87
87
 
88
88
  --icon-loader-size: 48px;
89
89
 
@@ -82,8 +82,8 @@ export interface AjaxOptions {
82
82
 
83
83
  /**
84
84
  * An object (or a function which returns an object) of additional header key/value pairs to send along
85
- * with requests using the XMLHttpRequest transport. Uses in {@link FileBrowser|FileBrowser}
86
- * and {@link Uploader|Uploader}
85
+ * with requests using the XMLHttpRequest transport. Uses in [[FileBrowser]]
86
+ * and [[Uploader]]
87
87
  */
88
88
  headers?:
89
89
  | IDictionary<string>
@@ -17,10 +17,11 @@ import type {
17
17
  Nullable
18
18
  } from './types';
19
19
  import type { IUploader, IUploaderOptions } from './uploader';
20
- import type { IPanel, IViewOptions } from './view';
20
+ import type { IViewOptions, IViewWithToolbar } from './view';
21
21
  import type { IUIGroup } from './ui';
22
22
  import type { IObservable } from './events';
23
23
  import type { IAjax } from './ajax';
24
+ import type { IDlgs } from './traits';
24
25
 
25
26
  /**
26
27
  * The module creates a web browser dialog box. In a Web browser ,you can select an image, remove, drag it. Upload new
@@ -252,7 +253,8 @@ export interface IFileBrowserDataProvider extends IDestructible {
252
253
  // TODO - Remove extending
253
254
  export interface IFileBrowser<
254
255
  T extends IFileBrowserOptions = IFileBrowserOptions
255
- > extends IPanel<T> {
256
+ > extends IViewWithToolbar<T>,
257
+ IDlgs {
256
258
  readonly dataProvider: IFileBrowserDataProvider;
257
259
  readonly state: IFileBrowserState & IObservable;
258
260
 
@@ -8,12 +8,13 @@
8
8
  * @module types
9
9
  */
10
10
 
11
- import { IViewOptions, IPanel } from './view';
11
+ import { IViewOptions, IViewWithToolbar } from './view';
12
12
  import type { Config } from 'jodit/config';
13
13
  import type {
14
14
  CustomCommand,
15
15
  ICreate,
16
16
  IDestructible,
17
+ IDlgs,
17
18
  IHistory,
18
19
  IStatusBar,
19
20
  Modes
@@ -34,7 +35,7 @@ interface IWorkPlace {
34
35
  options: IViewOptions;
35
36
  }
36
37
 
37
- interface IJodit extends IPanel {
38
+ interface IJodit extends IViewWithToolbar, IDlgs {
38
39
  isJodit: true;
39
40
 
40
41
  options: Config;
@@ -54,6 +54,7 @@ export interface IExtraPlugin {
54
54
 
55
55
  export interface IPluginSystem {
56
56
  add(name: string, plugin: any): void;
57
+ wait(name: string): Promise<void>;
57
58
  get(name: string): PluginType | void;
58
59
  remove(name: string): void;
59
60
  init(jodit: IJodit): CanPromise<void>;
@@ -17,7 +17,8 @@ import type {
17
17
  IViewBased,
18
18
  IJodit,
19
19
  IMods,
20
- IBound
20
+ IBound,
21
+ IContainer
21
22
  } from './';
22
23
  import type { IFileBrowser } from './file-browser';
23
24
 
@@ -113,7 +114,7 @@ interface IControlType<
113
114
 
114
115
  /**
115
116
  * Drop-down list. A hash or array. You must specify the command which will be submitted for the hash key
116
- * (or array value) (see .[[Jodit.execCommand]] or define 'exec' function. See example
117
+ * (or array value) (see .[[IJodit.execCommand]] or define 'exec' function. See example
117
118
  * @example
118
119
  * ```javascript
119
120
  * Jodit.make('#editor2', {
@@ -146,8 +147,8 @@ interface IControlType<
146
147
 
147
148
  /**
148
149
  * The command executes when the button is pressed. Allowed all
149
- * {@link https://developer.mozilla.org/ru/docs/Web/API/Document/execCommand#commands}
150
- * and several specific [[Jodit.execCommand]]
150
+ * @see https://developer.mozilla.org/ru/docs/Web/API/Document/execCommand#commands
151
+ * and several specific [[IJodit.execCommand]]
151
152
  */
152
153
  command?: string;
153
154
  tagRegExp?: RegExp;
@@ -209,7 +210,12 @@ interface IControlType<
209
210
  * The method which will be called for each element of button.list
210
211
  */
211
212
  template?: (jodit: T, key: string, value: string) => string;
212
- childTemplate?: (jodit: T, key: string, value: string, button: IToolbarButton) => string;
213
+ childTemplate?: (
214
+ jodit: T,
215
+ key: string,
216
+ value: string,
217
+ button: IToolbarButton
218
+ ) => string;
213
219
 
214
220
  /**
215
221
  * After click on the button it will show popup element which consist value that this function returned
@@ -311,7 +317,7 @@ interface IToolbarCollection extends IUIList {
311
317
  showInline(bound?: IBound): void;
312
318
  }
313
319
 
314
- export interface IStatusBar extends IComponent, IMods {
320
+ export interface IStatusBar extends IContainer, IComponent, IMods {
315
321
  show(): void;
316
322
  hide(): void;
317
323
  isShown: boolean;
@@ -9,6 +9,7 @@
9
9
  */
10
10
 
11
11
  import type { IDictionary, Nullable } from 'jodit/types';
12
+ import type { IComponent, IContainer, IDialog, IDialogOptions } from 'jodit/types';
12
13
 
13
14
  export type ModType = string | boolean | null;
14
15
 
@@ -16,7 +17,9 @@ export interface IMods {
16
17
  /**
17
18
  * Set/remove modification (null - remove)
18
19
  */
19
- setMod(name: string, value: ModType): this;
20
+ setMod<T extends IComponent & IContainer & IMods>(this: T, name: string, value: ModType): T;
21
+ afterSetMod(name: string, value: ModType): void;
22
+
20
23
  getMod(name: string): ModType;
21
24
  mods: IDictionary<ModType>;
22
25
  }
@@ -25,3 +28,29 @@ export interface IElms {
25
28
  getElm(elementName: string): Nullable<HTMLElement>;
26
29
  getElms(elementName: string): HTMLElement[];
27
30
  }
31
+
32
+
33
+ export interface IDlgs {
34
+ dlg(options?: IDialogOptions): IDialog;
35
+
36
+ confirm(
37
+ msg: string,
38
+ title: string | ((yes: boolean) => void) | undefined,
39
+ callback?: (yes: boolean) => void | false
40
+ ): IDialog;
41
+
42
+ prompt(
43
+ msg: string,
44
+ title: string | (() => false | void) | undefined,
45
+ callback: (value: string) => false | void,
46
+ placeholder?: string,
47
+ defaultValue?: string
48
+ ): IDialog;
49
+
50
+ alert(
51
+ msg: string | HTMLElement,
52
+ title?: string | (() => void | false),
53
+ callback?: string | ((dialog: IDialog) => void | false),
54
+ className?: string
55
+ ): IDialog;
56
+ }
@@ -273,6 +273,7 @@ declare global {
273
273
  jodit: HTMLDivElement;
274
274
  svg: HTMLElement;
275
275
  path: HTMLElement;
276
+ font: HTMLElement;
276
277
  'jodit-media': HTMLElement;
277
278
  }
278
279
  }
@@ -23,8 +23,7 @@ import type { IStorage } from './storage';
23
23
  import type { IUIButtonState } from './ui';
24
24
  import type { IEventEmitter } from './events';
25
25
  import type { IPluginButton } from './plugin';
26
- import type { Mods, Elms } from '../core/traits'; //TODO remove export
27
- import type { IDialog, IDialogOptions } from './dialog';
26
+ import type { IElms, IMods } from './traits';
28
27
 
29
28
  interface ILanguageOptions {
30
29
  language?: string;
@@ -90,16 +89,17 @@ interface IViewOptions extends ILanguageOptions, IToolbarOptions {
90
89
  interface IViewBased<T = IViewOptions>
91
90
  extends IContainer,
92
91
  IComponent,
93
- Mods,
94
- Elms {
92
+ IMods,
93
+ IElms {
95
94
  readonly isView: true;
95
+ readonly parent: Nullable<IViewBased>;
96
96
 
97
97
  /**
98
98
  * ID attribute for source element, id add \{id\}_editor it's editor's id
99
99
  */
100
100
  readonly id: string;
101
101
 
102
- basePath: string;
102
+ readonly basePath: string;
103
103
 
104
104
  readonly isLocked: boolean;
105
105
  isLockedNotBy(name: string): boolean;
@@ -112,7 +112,7 @@ interface IViewBased<T = IViewOptions>
112
112
  readonly buffer: IStorage;
113
113
  readonly storage: IStorage;
114
114
 
115
- progressbar: IProgressBar;
115
+ readonly progressbar: IProgressBar;
116
116
 
117
117
  readonly events: IEventEmitter;
118
118
  readonly e: this['events'];
@@ -125,11 +125,11 @@ interface IViewBased<T = IViewOptions>
125
125
  // alias
126
126
  readonly o: this['options'];
127
127
 
128
- i18n: (text: string, ...params: Array<string | number>) => string;
128
+ i18n(text: string, ...params: Array<string | number>): string;
129
129
 
130
- defaultTimeout: number;
130
+ readonly defaultTimeout: number;
131
131
 
132
- getVersion: () => string;
132
+ getVersion(): string;
133
133
 
134
134
  readonly components: Set<IComponent>;
135
135
  getInstance<T extends IComponent>(moduleName: string, options?: object): T;
@@ -146,28 +146,3 @@ interface IViewWithToolbar<T = IViewOptions> extends IViewBased<T> {
146
146
 
147
147
  setPanel(element: HTMLElement | string): void;
148
148
  }
149
-
150
- interface IPanel<T = IViewOptions> extends IViewWithToolbar<T> {
151
- dialog(options?: IDialogOptions): IDialog;
152
-
153
- confirm(
154
- msg: string,
155
- title: string | ((yes: boolean) => void) | undefined,
156
- callback?: (yes: boolean) => void | false
157
- ): IDialog;
158
-
159
- prompt(
160
- msg: string,
161
- title: string | (() => false | void) | undefined,
162
- callback: (value: string) => false | void,
163
- placeholder?: string,
164
- defaultValue?: string
165
- ): IDialog;
166
-
167
- alert(
168
- msg: string | HTMLElement,
169
- title?: string | (() => void | false),
170
- callback?: string | ((dialog: IDialog) => void | false),
171
- className?: string
172
- ): IDialog;
173
- }
package/src/typings.d.ts CHANGED
@@ -6,6 +6,7 @@
6
6
 
7
7
  /**
8
8
  * @module types
9
+ * @internal
9
10
  */
10
11
 
11
12
  declare module '*.svg' {
package/types/config.d.ts CHANGED
@@ -117,6 +117,7 @@ export declare class Config implements IViewOptions {
117
117
  */
118
118
  disabled: boolean;
119
119
  activeButtonsInReadOnly: string[];
120
+ allowCommandsInReadOnly: string[];
120
121
  /**
121
122
  * Size of icons in the toolbar (can be "small", "middle", "large")
122
123
  *
@@ -153,8 +154,8 @@ export declare class Config implements IViewOptions {
153
154
  /**
154
155
  * Class name that can be appended to the editor
155
156
  *
156
- * @see {@link Jodit.defaultOptions.iframeCSSLinks|iframeCSSLinks}
157
- * @see {@link Jodit.defaultOptions.iframeStyle|iframeStyle}
157
+ * @see [[Config.iframeCSSLinks]]
158
+ * @see [[Config.iframeStyle]]
158
159
  *
159
160
  * @example
160
161
  * ```javascript
@@ -46,7 +46,7 @@ export declare const MODE_WYSIWYG = 1;
46
46
  export declare const MODE_SOURCE = 2;
47
47
  /**
48
48
  * Source code editor and HTML editor both like
49
- * {@link http://getuikit.com/docs/htmleditor.html|this}
49
+ * @see http://getuikit.com/docs/htmleditor.html|this
50
50
  */
51
51
  export declare const MODE_SPLIT = 3;
52
52
  /**
@@ -75,33 +75,33 @@ export declare const EMULATE_DBLCLICK_TIMEOUT = 300;
75
75
  export declare const INSERT_AS_HTML = "insert_as_html";
76
76
  /**
77
77
  * Same as [[INSERT_AS_HTML]], but content will be stripped of extra styles and empty tags
78
- * ```
78
+ * ```html
79
79
  * <h1 style="color:red">test</h1>
80
80
  * ```
81
81
  * Will be inserted into the document as
82
- * ```
82
+ * ```html
83
83
  * <h1>test</h1>
84
84
  * ```
85
85
  */
86
86
  export declare const INSERT_CLEAR_HTML = "insert_clear_html";
87
87
  /**
88
88
  * The contents of the clipboard will be pasted into the document as plain text, i.e. all tags will be displayed as text.
89
- * ```
89
+ * ```html
90
90
  * <h1>test</h1>
91
91
  * ```
92
92
  * Will be inserted into the document as
93
- * ```
93
+ * ```html
94
94
  * &gt;&lt;h1&gt;test&lt;/h1&gt;
95
95
  * ```
96
96
  */
97
97
  export declare const INSERT_AS_TEXT = "insert_as_text";
98
98
  /**
99
99
  * All tags will be stripped:
100
- * ```
100
+ * ```html
101
101
  * <h1>test</h1>
102
102
  * ```
103
103
  * Will be inserted into the document as
104
- * ```
104
+ * ```html
105
105
  * test
106
106
  * ```
107
107
  */
@@ -0,0 +1,6 @@
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
+ export declare function derive(...traits: Function[]): (target: Function) => void;
@@ -17,4 +17,5 @@ export * from './nonenumerable/nonenumerable';
17
17
  export * from './persistent/persistent';
18
18
  export * from './wait/wait';
19
19
  export * from './watch/watch';
20
+ export * from './derive/derive';
20
21
  export { default as autobind } from 'autobind-decorator';
@@ -44,7 +44,7 @@ export declare class Dom {
44
44
  * // Replace the first <span> element to the < p >
45
45
  * ```
46
46
  */
47
- static replace(elm: HTMLElement, newTagName: HTMLTagNames | HTMLElement | string, create: ICreate, withAttributes?: boolean, notMoveContent?: boolean): HTMLElement;
47
+ static replace<T extends Node>(elm: Node, newTagName: HTMLTagNames | Node | string, create: ICreate, withAttributes?: boolean, notMoveContent?: boolean): T;
48
48
  /**
49
49
  * Checks whether the Node text and blank (in this case it may contain invisible auxiliary characters ,
50
50
  * it is also empty )
@@ -152,7 +152,7 @@ export declare class Dom {
152
152
  /**
153
153
  * Returns the nearest non-empty sibling
154
154
  */
155
- static findNotEmptySibling(node: Node, backspace: boolean): Nullable<Node>;
155
+ static findNotEmptySibling(node: Node, left: boolean): Nullable<Node>;
156
156
  /**
157
157
  * Returns the nearest non-empty neighbor
158
158
  */
@@ -205,6 +205,7 @@ export declare class Dom {
205
205
  * Safe remove element from DOM
206
206
  */
207
207
  static safeRemove(...nodes: unknown[]): void;
208
+ static safeInsertNode(range: Range, node: Node): void;
208
209
  /**
209
210
  * Hide element
210
211
  */
@@ -216,8 +217,8 @@ export declare class Dom {
216
217
  /**
217
218
  * Check if element is some tag
218
219
  */
219
- static isTag<K extends keyof HTMLElementTagNameMap>(node: Node | null | undefined | false | EventTarget, tagName: K): node is HTMLElementTagNameMap[K];
220
- static isTag<K extends keyof HTMLElementTagNameMap>(node: Node | null | undefined | false | EventTarget, tagNames: K[]): node is HTMLElementTagNameMap[K];
220
+ static isTag<K extends HTMLTagNames>(node: Node | null | undefined | false | EventTarget, tagName: K): node is HTMLElementTagNameMap[K];
221
+ static isTag<K extends HTMLTagNames>(node: Node | null | undefined | false | EventTarget, tagNames: K[]): node is HTMLElementTagNameMap[K];
221
222
  /**
222
223
  * Marks an item as temporary
223
224
  */
@@ -39,6 +39,10 @@ export declare class PluginSystem implements IPluginSystem {
39
39
  * Public method for async init all plugins
40
40
  */
41
41
  init(jodit: IJodit): CanPromise<void>;
42
+ /**
43
+ * Returns the promise to wait for the plugin to load.
44
+ */
45
+ wait(name: string): Promise<void>;
42
46
  /**
43
47
  * Plugin type has disabled requires
44
48
  */
@@ -0,0 +1,15 @@
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 traits
8
+ */
9
+ import type { IDialog, IDialogOptions, IViewBased, IDlgs } from 'jodit/types';
10
+ export declare abstract class Dlgs implements IDlgs {
11
+ dlg(this: IViewBased & IDlgs, options?: IDialogOptions): IDialog;
12
+ confirm(this: IViewBased & IDlgs, msg: string, title: string | ((yes: boolean) => void) | undefined, callback?: (yes: boolean) => void | false): IDialog;
13
+ prompt(this: IViewBased & IDlgs, msg: string, title: string | (() => false | void) | undefined, callback: (value: string) => false | void, placeholder?: string, defaultValue?: string): IDialog;
14
+ alert(this: IViewBased & IDlgs, msg: string | HTMLElement, title?: string | (() => void | false), callback?: string | ((dialog: IDialog) => void | false), className?: string): IDialog;
15
+ }
@@ -8,14 +8,12 @@
8
8
  */
9
9
  import type { IComponent, IContainer, IElms, Nullable } from 'jodit/types';
10
10
  export declare abstract class Elms implements IElms {
11
- abstract getElm(elementName: string): Nullable<HTMLElement>;
12
- abstract getElms(elementName: string): HTMLElement[];
13
11
  /**
14
12
  * Return element with BEM class name
15
13
  */
16
- static getElm(this: IComponent & IContainer, elementName: string): Nullable<HTMLElement>;
14
+ getElm<T extends IComponent & IContainer & IElms>(this: T, elementName: string): Nullable<HTMLElement>;
17
15
  /**
18
16
  * Return elements with BEM class name
19
17
  */
20
- static getElms(this: IComponent & IContainer, elementName: string): HTMLElement[];
18
+ getElms<T extends IComponent & IContainer & IElms>(this: T, elementName: string): HTMLElement[];
21
19
  }
@@ -8,3 +8,4 @@
8
8
  */
9
9
  export * from './elms';
10
10
  export * from './mods';
11
+ export * from './dlgs';
@@ -6,21 +6,18 @@
6
6
  /**
7
7
  * @module traits
8
8
  */
9
- import type { IComponent, IContainer, IMods, ModType } from 'jodit/types';
9
+ import type { IContainer, IDictionary, IMods, IComponent, ModType } from 'jodit/types';
10
10
  export declare abstract class Mods implements IMods {
11
- abstract mods: IMods['mods'];
12
- abstract readonly componentName: string;
13
- abstract container: HTMLElement;
14
- abstract setMod(name: string, value: ModType): this;
15
- abstract getMod(name: string): ModType;
11
+ abstract mods: IDictionary;
12
+ afterSetMod(name: string, value: ModType): void;
16
13
  /**
17
14
  * Set/remove BEM class modification
18
15
  *
19
16
  * @param value - if null, mod will be removed
20
17
  */
21
- static setMod<T extends IComponent & IContainer & Mods>(this: T, name: string, value: ModType, container?: HTMLElement): void;
18
+ setMod<T extends IComponent & IContainer & IMods>(this: T, name: string, value: ModType, container?: HTMLElement): T;
22
19
  /**
23
20
  * Get BEM class modification value
24
21
  */
25
- static getMod(this: IComponent & IContainer & Mods, name: string): ModType;
22
+ getMod(this: IMods, name: string): ModType;
26
23
  }
@@ -10,3 +10,4 @@
10
10
  */
11
11
  export * from './button/button';
12
12
  export * from './group/group';
13
+ export * from './tooltip/tooltip';
@@ -0,0 +1,29 @@
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
+ * [[include:plugins/tooltip/README.md]]
8
+ * @packageDocumentation
9
+ * @module plugins/tooltip
10
+ */
11
+ import './tooltip.less';
12
+ import type { IViewBased } from 'jodit/types';
13
+ import { UIElement } from '../../element';
14
+ export declare class UITooltip extends UIElement {
15
+ private __isOpened;
16
+ className(): string;
17
+ protected constructor(view: IViewBased);
18
+ private __useCount;
19
+ /**
20
+ * Creates only one instance of the tooltip for the container
21
+ */
22
+ static make(view: IViewBased): UITooltip;
23
+ private __delayShowTimeout;
24
+ private __delayOpen;
25
+ private __open;
26
+ private __setPosition;
27
+ private __close;
28
+ destruct(): void;
29
+ }
@@ -6,9 +6,11 @@
6
6
  /**
7
7
  * @module ui
8
8
  */
9
- import type { IDictionary, IUIElement, IViewBased, Nullable, ModType } from 'jodit/types';
9
+ import type { IDictionary, IUIElement, IViewBased, Nullable } from 'jodit/types';
10
10
  import { ViewComponent } from 'jodit/core/component';
11
11
  import { Elms, Mods } from 'jodit/core/traits';
12
+ export interface UIElement extends Mods, Elms {
13
+ }
12
14
  export declare abstract class UIElement<T extends IViewBased = IViewBased> extends ViewComponent<T> implements IUIElement, Mods, Elms {
13
15
  container: HTMLElement;
14
16
  name: string;
@@ -28,14 +30,6 @@ export declare abstract class UIElement<T extends IViewBased = IViewBased> exten
28
30
  */
29
31
  static closestElement(node: Node, type: Function): Nullable<IUIElement>;
30
32
  readonly mods: IDictionary<string | boolean | null>;
31
- /** @see [[Mods.setMod]] */
32
- setMod(name: string, value: ModType, container?: HTMLElement): this;
33
- /** @see [[Mods.getMod]] */
34
- getMod(name: string): ModType;
35
- /** @see [[Elms.getElm]]*/
36
- getElm(elementName: string): Nullable<HTMLElement>;
37
- /** @see [[Elms.getElms]]*/
38
- getElms(elementName: string): HTMLElement[];
39
33
  /**
40
34
  * Update UI from state
41
35
  */