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
@@ -0,0 +1,132 @@
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
+ /**
8
+ * [[include:plugins/tooltip/README.md]]
9
+ * @packageDocumentation
10
+ * @module plugins/tooltip
11
+ */
12
+
13
+ import './tooltip.less';
14
+
15
+ import type { IPoint, IViewBased } from 'jodit/types';
16
+ import { css, dataBind } from 'jodit/core/helpers';
17
+ import { getContainer } from 'jodit/core/global';
18
+ import { autobind } from 'jodit/core/decorators';
19
+ import { UIElement } from '../../element';
20
+
21
+ export class UITooltip extends UIElement {
22
+ private __isOpened = false;
23
+
24
+ className(): string {
25
+ return 'UITooltip';
26
+ }
27
+
28
+ protected constructor(view: IViewBased) {
29
+ super(view);
30
+ getContainer(view, UITooltip).appendChild(this.container);
31
+
32
+ let timeout = 0;
33
+
34
+ view.e
35
+ .off('.tooltip')
36
+ .on(
37
+ 'showTooltip.tooltip',
38
+ (getPoint: () => IPoint, content: string) => {
39
+ view.async.clearTimeout(timeout);
40
+ this.__open(getPoint, content);
41
+ }
42
+ )
43
+
44
+ .on('delayShowTooltip.tooltip', this.__delayOpen)
45
+
46
+ .on('escape.tooltip', this.__close)
47
+ .on(
48
+ 'hideTooltip.tooltip change.tooltip scroll.tooltip changePlace.tooltip hidePopup.tooltip closeAllPopups.tooltip',
49
+ () => {
50
+ this.j.async.clearTimeout(this.__delayShowTimeout);
51
+
52
+ timeout = view.async.setTimeout(
53
+ this.__close,
54
+ this.j.defaultTimeout
55
+ );
56
+ }
57
+ );
58
+ }
59
+
60
+ private __useCount: number = 1;
61
+
62
+ /**
63
+ * Creates only one instance of the tooltip for the container
64
+ */
65
+ static make(view: IViewBased): UITooltip {
66
+ let instance = dataBind<UITooltip>(view, 'ui-tooltip');
67
+ if (instance) {
68
+ instance.__useCount += 1;
69
+ return instance;
70
+ }
71
+ instance = new UITooltip(view);
72
+ dataBind<UITooltip>(view, 'ui-tooltip', instance);
73
+ return instance;
74
+ }
75
+
76
+ private __delayShowTimeout: number = 0;
77
+
78
+ @autobind
79
+ private __delayOpen(getPoint: () => IPoint, content: string): void {
80
+ const to = this.j.o.showTooltipDelay || this.j.defaultTimeout;
81
+
82
+ this.j.async.clearTimeout(this.__delayShowTimeout);
83
+
84
+ this.__delayShowTimeout = this.j.async.setTimeout(
85
+ () => this.__open(getPoint, content),
86
+ {
87
+ timeout: to,
88
+ label: 'tooltip'
89
+ }
90
+ );
91
+ }
92
+
93
+ private __open(getPoint: () => IPoint, content: string): void {
94
+ this.setMod('visible', true);
95
+ this.container.innerHTML = content;
96
+
97
+ this.__isOpened = true;
98
+ this.__setPosition(getPoint);
99
+ }
100
+
101
+ private __setPosition(getPoint: () => IPoint): void {
102
+ const point = getPoint();
103
+
104
+ css(this.container, {
105
+ left: point.x,
106
+ top: point.y
107
+ });
108
+ }
109
+
110
+ @autobind
111
+ private __close(): void {
112
+ this.j.async.clearTimeout(this.__delayShowTimeout);
113
+
114
+ if (this.__isOpened) {
115
+ this.__isOpened = false;
116
+ this.setMod('visible', false);
117
+
118
+ css(this.container, {
119
+ left: -5000
120
+ });
121
+ }
122
+ }
123
+
124
+ override destruct(): void {
125
+ this.__useCount--;
126
+ if (!this.__useCount) {
127
+ this.j?.e.off('.tooltip');
128
+ this.__close();
129
+ super.destruct();
130
+ }
131
+ }
132
+ }
@@ -12,15 +12,18 @@ import type {
12
12
  IDictionary,
13
13
  IUIElement,
14
14
  IViewBased,
15
- Nullable,
16
- ModType
15
+ Nullable
17
16
  } from 'jodit/types';
18
17
  import { Component, ViewComponent } from 'jodit/core/component';
19
18
  import { Dom } from 'jodit/core/dom/dom';
20
19
  import { Elms, Mods } from 'jodit/core/traits';
21
20
  import { isString } from 'jodit/core/helpers/checker/is-string';
22
21
  import { Icon } from 'jodit/core/ui/icon';
22
+ import { derive } from 'jodit/core/decorators';
23
23
 
24
+ export interface UIElement extends Mods, Elms {}
25
+
26
+ @derive(Mods, Elms)
24
27
  export abstract class UIElement<T extends IViewBased = IViewBased>
25
28
  extends ViewComponent<T>
26
29
  implements IUIElement, Mods, Elms
@@ -112,31 +115,6 @@ export abstract class UIElement<T extends IViewBased = IViewBased>
112
115
 
113
116
  readonly mods: IDictionary<string | boolean | null> = {};
114
117
 
115
- /** @see [[Mods.setMod]] */
116
- setMod(
117
- name: string,
118
- value: ModType,
119
- container: HTMLElement = this.container
120
- ): this {
121
- Mods.setMod.call(this, name, value, container);
122
- return this;
123
- }
124
-
125
- /** @see [[Mods.getMod]] */
126
- getMod(name: string): ModType {
127
- return Mods.getMod.call(this, name);
128
- }
129
-
130
- /** @see [[Elms.getElm]]*/
131
- getElm(elementName: string): Nullable<HTMLElement> {
132
- return Elms.getElm.call(this, elementName);
133
- }
134
-
135
- /** @see [[Elms.getElms]]*/
136
- getElms(elementName: string): HTMLElement[] {
137
- return Elms.getElms.call(this, elementName);
138
- }
139
-
140
118
  /**
141
119
  * Update UI from state
142
120
  */
@@ -0,0 +1,44 @@
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
+ describe('Test group ui', () => {
8
+ const { UIGroup, UIButton } = Jodit.modules;
9
+ let editor;
10
+ beforeEach(() => {
11
+ editor = getJodit();
12
+ });
13
+
14
+ describe('UIGroup', () => {
15
+ describe('setMod', () => {
16
+ describe('syncMod === true', () => {
17
+ it('should set mod for all children', () => {
18
+ const group = new UIGroup(editor);
19
+ group.syncMod = true;
20
+ const button = new UIButton(editor);
21
+ const button2 = new UIButton(editor);
22
+ group.append(button);
23
+ group.append(button2);
24
+ group.setMod('test', 123);
25
+ expect(button.getMod('test')).eq(123);
26
+ expect(button2.getMod('test')).eq(123);
27
+ });
28
+ });
29
+
30
+ describe('syncMod === false', () => {
31
+ it('should not set mod for all children', () => {
32
+ const group = new UIGroup(editor);
33
+ const button = new UIButton(editor);
34
+ const button2 = new UIButton(editor);
35
+ group.append(button);
36
+ group.append(button2);
37
+ group.setMod('test', 123);
38
+ expect(button.getMod('test')).not.eq(123);
39
+ expect(button2.getMod('test')).not.eq(123);
40
+ });
41
+ });
42
+ });
43
+ });
44
+ });
@@ -16,7 +16,8 @@ import type {
16
16
  IUIButtonState,
17
17
  IUIElement,
18
18
  IUIGroup,
19
- IViewBased
19
+ IViewBased,
20
+ ModType
20
21
  } from 'jodit/types';
21
22
  import type { IDictionary } from 'jodit/types';
22
23
  import { UIElement } from '../element';
@@ -58,6 +59,7 @@ export class UIGroup<T extends IViewBased = IViewBased>
58
59
  if (isArray(elm)) {
59
60
  stack.push(...elm);
60
61
  } else if (Component.isInstanceOf<UIGroup>(elm, UIGroup)) {
62
+ // @ts-ignore
61
63
  stack.push(...elm.elements);
62
64
  } else {
63
65
  elm && result.push(elm);
@@ -108,12 +110,10 @@ export class UIGroup<T extends IViewBased = IViewBased>
108
110
  }
109
111
 
110
112
  /** @override */
111
- override setMod(name: string, value: string | boolean | null): this {
113
+ override afterSetMod(name: string, value: ModType): void {
112
114
  if (this.syncMod) {
113
115
  this.elements.forEach(elm => elm.setMod(name, value));
114
116
  }
115
-
116
- return super.setMod(name, value);
117
117
  }
118
118
 
119
119
  /**
@@ -29,7 +29,7 @@ import { autobind } from 'jodit/core/decorators';
29
29
 
30
30
  export abstract class ViewWithToolbar extends View implements IViewWithToolbar {
31
31
  TOOLBAR!: IToolbarCollection;
32
- toolbar: this['TOOLBAR'] = makeCollection(this);
32
+ readonly toolbar: this['TOOLBAR'] = makeCollection(this);
33
33
 
34
34
  private defaultToolbarContainer: HTMLElement =
35
35
  this.c.div('jodit-toolbar__box');
@@ -154,7 +154,7 @@ export abstract class ViewWithToolbar extends View implements IViewWithToolbar {
154
154
  }
155
155
  }
156
156
 
157
- override isJodit: boolean = false;
157
+ override readonly isJodit: boolean = false;
158
158
 
159
159
  /** @override **/
160
160
  protected constructor(
@@ -39,38 +39,21 @@ import {
39
39
  Create,
40
40
  Dom,
41
41
  ViewComponent
42
- } from '../../modules';
43
- import { modules } from '../global';
44
- import { hook } from 'jodit/core/decorators';
45
- import { Elms, Mods } from '../traits';
46
- import { EventEmitter } from '../event-emitter';
42
+ } from 'jodit/modules';
43
+ import { modules } from 'jodit/core/global';
44
+ import { hook, derive } from 'jodit/core/decorators';
45
+ import { Elms, Mods } from 'jodit/core/traits';
46
+ import { EventEmitter } from 'jodit/core/event-emitter';
47
47
 
48
+ export interface View extends Mods, Elms {}
49
+
50
+ @derive(Mods, Elms)
48
51
  export abstract class View extends Component implements IViewBased, Mods, Elms {
49
52
  readonly isView = true as const;
53
+ parent: Nullable<IViewBased> = null;
50
54
 
51
55
  readonly mods: IDictionary<string | boolean | null> = {};
52
56
 
53
- /** @see [[Mods.setMod]] */
54
- setMod(...[name, value]: Parameters<typeof Mods.setMod>): this {
55
- Mods.setMod.call(this, name, value);
56
- return this;
57
- }
58
-
59
- /** @see [[Mods.getMod]] */
60
- getMod(name: string): string | boolean | null {
61
- return Mods.getMod.call(this, name);
62
- }
63
-
64
- /** @see [[Elms.getElm]]*/
65
- getElm(elementName: string): Nullable<HTMLElement> {
66
- return Elms.getElm.call(this, elementName);
67
- }
68
-
69
- /** @see [[Elms.getElms]]*/
70
- getElms(elementName: string): HTMLElement[] {
71
- return Elms.getElms.call(this, elementName);
72
- }
73
-
74
57
  /**
75
58
  * ID attribute for source element, id add `{id}_editor` it's editor's id
76
59
  */
@@ -174,10 +157,7 @@ export abstract class View extends Component implements IViewBased, Mods, Elms {
174
157
  }
175
158
 
176
159
  this.__isFullSize = isFullSize;
177
-
178
- if (this.events) {
179
- this.e.fire('toggleFullSize', isFullSize);
180
- }
160
+ this.e.fire('toggleFullSize', isFullSize);
181
161
  }
182
162
 
183
163
  private __whoLocked: string | false = '';
@@ -276,9 +256,7 @@ export abstract class View extends Component implements IViewBased, Mods, Elms {
276
256
  this.events = new EventEmitter(this.od);
277
257
  this.create = new Create(this.od);
278
258
 
279
- this.container = this.c.div();
280
- this.container.classList.add('jodit');
281
-
259
+ this.container = this.c.div(`jodit ${this.componentName}`);
282
260
  this.progressbar = new ProgressBar(this);
283
261
  }
284
262
 
package/src/jodit.ts CHANGED
@@ -40,7 +40,8 @@ import {
40
40
  Plugin,
41
41
  Select,
42
42
  StatusBar,
43
- STATUSES
43
+ STATUSES,
44
+ ViewWithToolbar
44
45
  } from './modules/';
45
46
 
46
47
  import {
@@ -65,11 +66,10 @@ import {
65
66
 
66
67
  import { Storage } from './core/storage/';
67
68
 
68
- import { Panel } from './core/view/panel';
69
-
70
69
  import { lang } from 'jodit/core/constants';
71
- import { instances, pluginSystem, modules } from './core/global';
72
- import { autobind, cache, throttle, watch } from './core/decorators';
70
+ import { instances, pluginSystem, modules, eventEmitter } from './core/global';
71
+ import { autobind, cache, throttle, watch, derive } from './core/decorators';
72
+ import { Dlgs } from 'jodit/core/traits';
73
73
 
74
74
  const __defaultStyleDisplayKey = 'data-jodit-default-style-display';
75
75
  const __defaultClassesKey = 'data-jodit-default-classes';
@@ -77,7 +77,10 @@ const __defaultClassesKey = 'data-jodit-default-classes';
77
77
  /**
78
78
  * Class Jodit. Main class
79
79
  */
80
- export class Jodit extends Panel implements IJodit {
80
+ export interface Jodit extends Dlgs {}
81
+
82
+ @derive(Dlgs)
83
+ export class Jodit extends ViewWithToolbar implements IJodit, Dlgs {
81
84
  /** @override */
82
85
  override className(): string {
83
86
  return 'Jodit';
@@ -104,6 +107,12 @@ export class Jodit extends Panel implements IJodit {
104
107
  });
105
108
  }
106
109
 
110
+ static get ready(): Promise<IJodit> {
111
+ return new Promise(resolve => {
112
+ eventEmitter.on('oditready', resolve);
113
+ });
114
+ }
115
+
107
116
  /**
108
117
  * Define if object is Jodit
109
118
  */
@@ -744,7 +753,7 @@ export class Jodit extends Panel implements IJodit {
744
753
  * Execute command editor
745
754
  *
746
755
  * @param command - command. It supports all the
747
- * {@link https://developer.mozilla.org/ru/docs/Web/API/Document/execCommand#commands} and a number of its own
756
+ * @see https://developer.mozilla.org/ru/docs/Web/API/Document/execCommand#commands and a number of its own
748
757
  * for example applyStyleProperty. Comand fontSize receives the second parameter px,
749
758
  * formatBlock and can take several options
750
759
  * @example
@@ -763,7 +772,10 @@ export class Jodit extends Panel implements IJodit {
763
772
  this.s.focus();
764
773
  }
765
774
 
766
- if (this.o.readonly && command !== 'selectall') {
775
+ if (
776
+ this.o.readonly &&
777
+ !this.o.allowCommandsInReadOnly.includes(command)
778
+ ) {
767
779
  return;
768
780
  }
769
781
 
package/src/langs/ar.js CHANGED
@@ -17,7 +17,7 @@ module.exports = {
17
17
  'حقوق الطبع والنشر © XDSoft.net - Chupurnov Valeriy. كل الحقوق محفوظة.',
18
18
  Anchor: 'مِرْساة',
19
19
  'Open in new tab': 'فتح في نافذة جديدة',
20
- 'Open editor in fullsize': 'فتح المحرر في الحجم الكامل',
20
+ 'Open in fullsize': 'فتح المحرر في الحجم الكامل',
21
21
  'Clear Formatting': 'مسح التنسيق',
22
22
  'Fill color or set the text color': 'ملء اللون أو تعيين لون النص',
23
23
  Redo: 'إعادة',
@@ -18,7 +18,7 @@ module.exports = {
18
18
  'Copyright © XDSoft.net - Chupurnov Valeriy. Všechna práva vyhrazena.',
19
19
  Anchor: 'Anchor',
20
20
  'Open in new tab': 'Otevřít v nové záložce',
21
- 'Open editor in fullsize': 'Otevřít v celoobrazovkovém režimu',
21
+ 'Open in fullsize': 'Otevřít v celoobrazovkovém režimu',
22
22
  'Clear Formatting': 'Vyčistit formátování',
23
23
  'Fill color or set the text color': 'Barva výplně a písma',
24
24
  Redo: 'Vpřed',
package/src/langs/de.js CHANGED
@@ -19,7 +19,7 @@ module.exports = {
19
19
  'Copyright © XDSoft.net - Chupurnov Valeriy. Alle Rechte vorbehalten.',
20
20
  Anchor: 'Anker',
21
21
  'Open in new tab': 'In neuer Registerkarte öffnen',
22
- 'Open editor in fullsize': 'Editor in voller Größe öffnen',
22
+ 'Open in fullsize': 'Editor in voller Größe öffnen',
23
23
  'Clear Formatting': 'Formatierung löschen',
24
24
  'Fill color or set the text color': 'Füllfarbe oder Textfarbe ändern',
25
25
  Redo: 'Wiederholen',
package/src/langs/es.js CHANGED
@@ -18,7 +18,7 @@ module.exports = {
18
18
  'Copyright © XDSoft.net - Chupurnov Valeriy. Todos los derechos reservados.',
19
19
  Anchor: 'Anclar',
20
20
  'Open in new tab': 'Abrir en nueva pestaña',
21
- 'Open editor in fullsize': 'Abrir editor en pantalla completa',
21
+ 'Open in fullsize': 'Abrir editor en pantalla completa',
22
22
  'Clear Formatting': 'Limpiar formato',
23
23
  'Fill color or set the text color': 'Color de relleno o de letra',
24
24
  Redo: 'Rehacer',
package/src/langs/fa.js CHANGED
@@ -18,7 +18,7 @@ module.exports = {
18
18
  'Copyright © XDSoft.net - Chupurnov Valeriy. Alle Rechte vorbehalten.',
19
19
  Anchor: 'لینک',
20
20
  'Open in new tab': 'بازکردن در تب جدید',
21
- 'Open editor in fullsize': 'تمام صفحه کردن ویرایشگر',
21
+ 'Open in fullsize': 'تمام صفحه کردن ویرایشگر',
22
22
  'Clear Formatting': 'پاک کردن قالب ها',
23
23
  'Fill color or set the text color':
24
24
  'رنگ را پر کنید یا رنگ متن را تنظیم کنید',
package/src/langs/fr.js CHANGED
@@ -17,7 +17,7 @@ module.exports = {
17
17
  'Copyright © XDSoft.net - Chupurnov Valeriy. Tous droits réservés.',
18
18
  Anchor: 'Ancre',
19
19
  'Open in new tab': 'Ouvrir dans un nouvel onglet',
20
- 'Open editor in fullsize': "Ouvrir l'éditeur en pleine page",
20
+ 'Open in fullsize': "Ouvrir l'éditeur en pleine page",
21
21
  'Clear Formatting': 'Supprimer le formattage',
22
22
  'Fill color or set the text color':
23
23
  'Modifier la couleur du fond ou du texte',
package/src/langs/he.js CHANGED
@@ -18,7 +18,7 @@ module.exports = {
18
18
  'Copyright © XDSoft.net - Chupurnov Valeriy. All rights reserved.',
19
19
  Anchor: 'מקום עיגון',
20
20
  'Open in new tab': 'פתח בכרטיסיה חדשה',
21
- 'Open editor in fullsize': 'פתח את העורך בחלון חדש',
21
+ 'Open in fullsize': 'פתח את העורך בחלון חדש',
22
22
  'Clear Formatting': 'נקה עיצוב',
23
23
  'Fill color or set the text color': 'שנה צבע טקסט או רקע',
24
24
  Redo: 'בצע שוב',
package/src/langs/hu.js CHANGED
@@ -19,7 +19,7 @@ module.exports = {
19
19
  'Copyright © XDSoft.net - Chupurnov Valeriy. Minden jog fenntartva.',
20
20
  Anchor: 'Horgony',
21
21
  'Open in new tab': 'Megnyitás új lapon',
22
- 'Open editor in fullsize': 'Megnyitás teljes méretben',
22
+ 'Open in fullsize': 'Megnyitás teljes méretben',
23
23
  'Clear Formatting': 'Formázás törlése',
24
24
  'Fill color or set the text color': 'Háttér/szöveg szín',
25
25
  Redo: 'Újra',
@@ -4,6 +4,176 @@
4
4
  * Copyright (c) 2013-2022 Valeriy Chupurnov. All rights reserved. https://xdsoft.net
5
5
  */
6
6
  describe('Test i18n functionality', function () {
7
+ describe('Helper 18n', function () {
8
+ const i18n = Jodit.modules.Helpers.i18n;
9
+
10
+ describe('Put defined sentence', function () {
11
+ it('Should replace it on defined language', function () {
12
+ const values = [
13
+ 'Type something',
14
+ 'Напишите что-либо',
15
+ 'ru',
16
+
17
+ 'rename',
18
+ 'Переименовать',
19
+ 'ru',
20
+
21
+ 'Rename',
22
+ 'Переименовать',
23
+ 'ru',
24
+
25
+ 'About Jodit',
26
+ 'حول جوديت',
27
+ 'ar',
28
+
29
+ 'about Jodit',
30
+ 'حول جوديت',
31
+ 'ar',
32
+
33
+ 'British people',
34
+ 'British people',
35
+ 'ar'
36
+ ];
37
+
38
+ for (let i = 0; i < values.length; i += 3) {
39
+ expect(values[i + 1]).equals(
40
+ i18n(
41
+ values[i],
42
+ [],
43
+ {
44
+ language: values[i + 2]
45
+ },
46
+ true
47
+ )
48
+ );
49
+ }
50
+ });
51
+
52
+ describe('Put some information inside sentence', function () {
53
+ it('Should put this information inside new sentence', function () {
54
+ const values = [
55
+ 'Chars: %d',
56
+ 'Символов: 1',
57
+ 'ru',
58
+ [1],
59
+ 'Select %s',
60
+ 'Выделить: Test',
61
+ 'ru',
62
+ ['Test'],
63
+ 'select %s',
64
+ 'Выделить: Test',
65
+ 'ru',
66
+ ['Test'],
67
+ 'Bla %d Bla %s',
68
+ 'Bla 1 Bla boo',
69
+ 'ru',
70
+ [1, 'boo'],
71
+ 'Bla %d Bla %s',
72
+ 'Bla 1 Bla boo',
73
+ 'ru1',
74
+ [1, 'boo']
75
+ ];
76
+
77
+ for (let i = 0; i < values.length; i += 4) {
78
+ expect(values[i + 1]).equals(
79
+ i18n(
80
+ values[i],
81
+ values[i + 3],
82
+ {
83
+ language: values[i + 2]
84
+ },
85
+ true
86
+ )
87
+ );
88
+ }
89
+ });
90
+ });
91
+ });
92
+
93
+ const values = [
94
+ 'Type something',
95
+ 'Напишите что-либо',
96
+ 'ru',
97
+
98
+ 'About Jodit',
99
+ 'حول جوديت',
100
+ 'ar',
101
+
102
+ 'About Jodit',
103
+ '{About Jodit}',
104
+ 'ar1',
105
+
106
+ 'British people',
107
+ '{British people}',
108
+ 'ar'
109
+ ];
110
+
111
+ for (let i = 0; i < values.length; i += 3) {
112
+ const [source, result, language] = [
113
+ values[i],
114
+ values[i + 1],
115
+ values[i + 2]
116
+ ];
117
+
118
+ describe(`Debug mode for ${language}`, function () {
119
+ it(`Should show debug brackets for undefined keys for source ${source}`, function () {
120
+ expect(result).equals(
121
+ i18n(
122
+ source,
123
+ [],
124
+ {
125
+ language,
126
+ debugLanguage: true
127
+ },
128
+ true
129
+ )
130
+ );
131
+ });
132
+ });
133
+ }
134
+
135
+ describe('Define i18n property inside input options', function () {
136
+ it('Should use it', function () {
137
+ const values = [
138
+ 'Type something',
139
+ 'Привет',
140
+ 'ru',
141
+ 'About Jodit',
142
+ 'جوديت',
143
+ 'ar',
144
+ 'British people',
145
+ 'Bond',
146
+ 'ar'
147
+ ];
148
+
149
+ const opt = {
150
+ ru: {
151
+ 'Type something': 'Привет'
152
+ },
153
+ ar: {
154
+ 'About Jodit': 'جوديت',
155
+ 'British people': 'Bond'
156
+ }
157
+ };
158
+
159
+ for (let i = 0; i < values.length; i += 3) {
160
+ expect(values[i + 1]).equals(
161
+ i18n(
162
+ values[i],
163
+ [],
164
+ {
165
+ language: values[i + 2],
166
+ i18n: opt,
167
+ debugLanguage: true
168
+ },
169
+ true
170
+ )
171
+ );
172
+ }
173
+ });
174
+ });
175
+ });
176
+
7
177
  describe('Test has keys in all functionality', function () {
8
178
  const filter = [
9
179
  'customxxx',
package/src/langs/id.js CHANGED
@@ -18,7 +18,7 @@ module.exports = {
18
18
  'Hak Cipta © XDSoft.net - Chupurnov Valeriy. Hak cipta dilindungi undang-undang.',
19
19
  Anchor: 'Tautan',
20
20
  'Open in new tab': 'Buka di tab baru',
21
- 'Open editor in fullsize': 'Buka editor dalam ukuran penuh',
21
+ 'Open in fullsize': 'Buka editor dalam ukuran penuh',
22
22
  'Clear Formatting': 'Hapus Pemformatan',
23
23
  'Fill color or set the text color': 'Isi warna atau atur warna teks',
24
24
  Redo: 'Ulangi',