jodit 3.23.3 → 3.24.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 (175) hide show
  1. package/README.md +4 -4
  2. package/build/jodit.css +8 -3
  3. package/build/jodit.es2018.css +7 -2
  4. package/build/jodit.es2018.en.css +7 -2
  5. package/build/jodit.es2018.en.js +8384 -7869
  6. package/build/jodit.es2018.en.min.css +1 -1
  7. package/build/jodit.es2018.en.min.js +1 -1
  8. package/build/jodit.es2018.js +8384 -7869
  9. package/build/jodit.es2018.min.css +1 -1
  10. package/build/jodit.es2018.min.js +1 -1
  11. package/build/jodit.js +2954 -2414
  12. package/build/jodit.min.css +2 -2
  13. package/build/jodit.min.js +1 -1
  14. package/build/plugins/debug/debug.es2018.en.js +8 -8
  15. package/build/plugins/debug/debug.es2018.en.min.js +1 -1
  16. package/build/plugins/debug/debug.es2018.js +8 -8
  17. package/build/plugins/debug/debug.es2018.min.js +1 -1
  18. package/build/plugins/debug/debug.js +8 -8
  19. package/build/plugins/debug/debug.min.js +1 -1
  20. package/build/plugins/speech-recognize/speech-recognize.css +1 -1
  21. package/build/plugins/speech-recognize/speech-recognize.es2018.css +1 -1
  22. package/build/plugins/speech-recognize/speech-recognize.es2018.en.css +1 -1
  23. package/build/plugins/speech-recognize/speech-recognize.es2018.en.js +38 -38
  24. package/build/plugins/speech-recognize/speech-recognize.es2018.en.min.js +1 -1
  25. package/build/plugins/speech-recognize/speech-recognize.es2018.js +38 -38
  26. package/build/plugins/speech-recognize/speech-recognize.es2018.min.js +1 -1
  27. package/build/plugins/speech-recognize/speech-recognize.js +30 -30
  28. package/build/plugins/speech-recognize/speech-recognize.min.js +1 -1
  29. package/build/vdom.css +12 -1
  30. package/build/vdom.js +1445 -41
  31. package/package.json +23 -23
  32. package/src/core/constants.ts +10 -8
  33. package/src/core/dom/dom.test.js +25 -0
  34. package/src/core/dom/dom.ts +90 -41
  35. package/src/core/helpers/checker/has-browser-color-picker.ts +2 -2
  36. package/src/core/helpers/checker/index.ts +1 -0
  37. package/src/core/helpers/checker/is-boolean.ts +1 -1
  38. package/src/core/helpers/checker/is-marker.ts +20 -0
  39. package/src/core/helpers/normalize/normalize-css-value.ts +19 -0
  40. package/src/core/helpers/normalize/normalize-node.ts +2 -2
  41. package/src/core/helpers/size/position.test.js +198 -187
  42. package/src/core/helpers/utils/css.ts +7 -14
  43. package/src/core/plugin/plugin.ts +1 -1
  44. package/src/core/selection/interface.ts +24 -0
  45. package/src/core/selection/select.ts +69 -29
  46. package/src/core/selection/selection.test.js +5 -17
  47. package/src/core/selection/style/api/extract.ts +6 -7
  48. package/src/core/selection/style/api/finite-state-machine.ts +40 -35
  49. package/src/core/selection/style/api/get-suit-child.ts +3 -4
  50. package/src/core/selection/style/api/get-suit-parent.ts +3 -4
  51. package/src/core/selection/style/api/{element-has-same-style.ts → has-same-style.ts} +25 -6
  52. package/src/core/selection/style/api/index.ts +6 -6
  53. package/src/core/selection/style/api/is-inside-invisible-element.ts +1 -1
  54. package/src/core/selection/style/api/is-normal-node.ts +3 -3
  55. package/src/core/selection/style/api/is-same-attributes.ts +56 -0
  56. package/src/core/selection/style/api/is-suit-element.ts +22 -12
  57. package/src/core/selection/style/api/list/toggle-ordered-list.ts +100 -0
  58. package/src/core/selection/style/api/list/wrap-list.ts +71 -0
  59. package/src/core/selection/style/api/toggle-attributes.ts +251 -0
  60. package/src/core/selection/style/api/unwrap-children.ts +10 -8
  61. package/src/core/selection/style/api/wrap-unwrapped-text.ts +7 -8
  62. package/src/core/selection/style/api/{wrap-and-commit-style.ts → wrap.ts} +8 -11
  63. package/src/core/selection/style/apply-style.ts +32 -181
  64. package/src/core/selection/style/commit-style.ts +79 -4
  65. package/src/core/selection/style/style.test.js +457 -128
  66. package/src/core/selection/style/transactions.ts +256 -0
  67. package/src/core/ui/button/tooltip/tooltip.test.js +95 -76
  68. package/src/core/ui/popup/popup.test.js +158 -153
  69. package/src/{plugins/backspace/interface.d.ts → core/vdom/on-demand.ts} +7 -5
  70. package/src/core/vdom/render/index.ts +2 -4
  71. package/src/core/vdom/render/patcher.ts +14 -0
  72. package/src/core/vdom/v-dom-jodit.less +17 -0
  73. package/src/core/vdom/v-dom-jodit.ts +102 -3
  74. package/src/core/view/view.ts +2 -2
  75. package/src/index.ts +2 -0
  76. package/src/jodit.ts +5 -1
  77. package/src/langs/i18n.test.js +221 -216
  78. package/src/modules/dialog/dialog.less +9 -1
  79. package/src/modules/dialog/dialog.ts +25 -16
  80. package/src/modules/file-browser/data-provider.ts +44 -12
  81. package/src/modules/file-browser/file-browser.test.js +1019 -958
  82. package/src/modules/file-browser/file-browser.ts +0 -1
  83. package/src/modules/messages/messages.ts +3 -8
  84. package/src/plugins/backspace/backspace.test.js +2 -9
  85. package/src/plugins/backspace/backspace.ts +5 -0
  86. package/src/plugins/backspace/cases/check-join-neighbors.ts +7 -1
  87. package/src/plugins/backspace/cases/check-join-two-lists.ts +2 -1
  88. package/src/plugins/backspace/helpers.ts +9 -1
  89. package/src/plugins/backspace/interface.ts +31 -0
  90. package/src/plugins/clean-html/helpers/visitor/filters/fill-empty-paragraph.ts +2 -1
  91. package/src/plugins/color/color.test.js +122 -119
  92. package/src/plugins/enter/enter.test.js +18 -5
  93. package/src/plugins/enter/enter.ts +9 -5
  94. package/src/plugins/enter/interface.ts +41 -0
  95. package/src/plugins/font/config.ts +8 -8
  96. package/src/plugins/font/font.test.js +18 -23
  97. package/src/plugins/hotkeys/hotkeys.test.js +35 -47
  98. package/src/plugins/iframe/iframe.test.js +206 -195
  99. package/src/plugins/image/image.ts +1 -1
  100. package/src/plugins/image-properties/config.ts +22 -0
  101. package/src/plugins/image-properties/image-properties.test.js +174 -93
  102. package/src/plugins/image-properties/templates/position-tab.ts +22 -1
  103. package/src/plugins/indent/indent.test.js +2 -8
  104. package/src/plugins/link/link.test.js +19 -0
  105. package/src/plugins/link/link.ts +25 -15
  106. package/src/plugins/placeholder/placeholder.ts +8 -7
  107. package/src/plugins/size/size.test.js +239 -225
  108. package/src/plugins/tab/cases/on-tab-inside-li.ts +131 -22
  109. package/src/plugins/tab/tab.test.js +95 -11
  110. package/src/plugins/tab/tab.ts +22 -2
  111. package/src/plugins/wrap-nodes/config.ts +11 -0
  112. package/src/plugins/wrap-nodes/wrap-nodes.ts +0 -1
  113. package/src/types/events.d.ts +4 -0
  114. package/src/types/file-browser.d.ts +17 -10
  115. package/src/types/select.d.ts +6 -1
  116. package/src/types/style.d.ts +72 -5
  117. package/src/types/uploader.d.ts +14 -0
  118. package/src/types/view.d.ts +2 -2
  119. package/types/core/async/async.d.ts +1 -1
  120. package/types/core/constants.d.ts +3 -3
  121. package/types/core/dom/dom.d.ts +6 -3
  122. package/types/core/helpers/checker/index.d.ts +1 -0
  123. package/types/core/helpers/checker/is-boolean.d.ts +1 -1
  124. package/types/core/helpers/checker/is-marker.d.ts +10 -0
  125. package/types/core/helpers/html/safe-html.d.ts +1 -1
  126. package/types/core/helpers/normalize/normalize-css-value.d.ts +2 -0
  127. package/types/core/helpers/normalize/normalize-node.d.ts +1 -1
  128. package/types/core/helpers/utils/append-script.d.ts +1 -1
  129. package/types/core/selection/interface.d.ts +19 -0
  130. package/types/core/selection/select.d.ts +22 -5
  131. package/types/core/selection/style/api/finite-state-machine.d.ts +10 -9
  132. package/types/core/selection/style/api/get-suit-child.d.ts +2 -3
  133. package/types/core/selection/style/api/get-suit-parent.d.ts +2 -3
  134. package/types/core/selection/style/api/{element-has-same-style.d.ts → has-same-style.d.ts} +2 -2
  135. package/types/core/selection/style/api/index.d.ts +6 -6
  136. package/types/core/selection/style/api/is-same-attributes.d.ts +12 -0
  137. package/types/core/selection/style/api/is-suit-element.d.ts +4 -4
  138. package/types/core/selection/style/api/{toggle → list}/toggle-ordered-list.d.ts +2 -3
  139. package/types/core/selection/style/api/{wrap-ordered-list.d.ts → list/wrap-list.d.ts} +2 -3
  140. package/types/core/selection/style/api/toggle-attributes.d.ts +11 -0
  141. package/types/core/selection/style/api/unwrap-children.d.ts +2 -2
  142. package/types/core/selection/style/api/wrap-unwrapped-text.d.ts +2 -3
  143. package/types/core/selection/style/api/{wrap-and-commit-style.d.ts → wrap.d.ts} +2 -3
  144. package/types/core/selection/style/apply-style.d.ts +3 -3
  145. package/types/core/selection/style/commit-style.d.ts +6 -2
  146. package/types/core/selection/style/transactions.d.ts +29 -0
  147. package/types/core/ui/popup/popup.d.ts +1 -1
  148. package/types/core/view/view.d.ts +1 -1
  149. package/types/index.d.ts +2 -0
  150. package/types/modules/file-browser/builders/elements-map.d.ts +1 -1
  151. package/types/modules/file-browser/data-provider.d.ts +5 -0
  152. package/types/modules/messages/messages.d.ts +2 -1
  153. package/types/plugins/backspace/helpers.d.ts +5 -1
  154. package/types/plugins/backspace/interface.d.ts +21 -0
  155. package/types/plugins/enter/enter.d.ts +2 -0
  156. package/types/plugins/enter/interface.d.ts +32 -0
  157. package/types/plugins/image-properties/config.d.ts +19 -0
  158. package/types/plugins/link/link.d.ts +1 -1
  159. package/types/plugins/paste/interface.d.ts +2 -2
  160. package/types/plugins/tab/cases/on-tab-inside-li.d.ts +1 -1
  161. package/types/plugins/wrap-nodes/config.d.ts +10 -0
  162. package/types/types/events.d.ts +4 -0
  163. package/types/types/file-browser.d.ts +17 -10
  164. package/types/types/select.d.ts +6 -1
  165. package/types/types/storage.d.ts +1 -1
  166. package/types/types/style.d.ts +72 -5
  167. package/types/types/uploader.d.ts +14 -0
  168. package/types/types/view.d.ts +2 -2
  169. package/vdom.html +20 -0
  170. package/src/core/selection/style/api/toggle/toggle-css.ts +0 -136
  171. package/src/core/selection/style/api/toggle/toggle-ordered-list.ts +0 -54
  172. package/src/core/selection/style/api/toggle-commit-styles.ts +0 -35
  173. package/src/core/selection/style/api/wrap-ordered-list.ts +0 -42
  174. package/types/core/selection/style/api/toggle/toggle-css.d.ts +0 -12
  175. package/types/core/selection/style/api/toggle-commit-styles.d.ts +0 -13
@@ -114,13 +114,13 @@ Config.prototype.controls.font = {
114
114
 
115
115
  list: {
116
116
  '': 'Default',
117
- 'Helvetica,sans-serif': 'Helvetica',
118
- 'Arial,Helvetica,sans-serif': 'Arial',
119
- 'Georgia,serif': 'Georgia',
120
- 'Impact,Charcoal,sans-serif': 'Impact',
121
- 'Tahoma,Geneva,sans-serif': 'Tahoma',
122
- 'Times New Roman,Times,serif': 'Times New Roman',
123
- 'Verdana,Geneva,sans-serif': 'Verdana'
117
+ 'helvetica,sans-serif': 'Helvetica',
118
+ 'arial,helvetica,sans-serif': 'Arial',
119
+ 'georgia,palatino,serif': 'Georgia',
120
+ 'impact,charcoal,sans-serif': 'Impact',
121
+ 'tahoma,geneva,sans-serif': 'Tahoma',
122
+ 'times new roman,times,serif': 'Times New Roman',
123
+ 'verdana,geneva,sans-serif': 'Verdana'
124
124
  },
125
125
 
126
126
  childTemplate: (editor, key: string, value: string) => {
@@ -132,7 +132,7 @@ Config.prototype.controls.font = {
132
132
  document.fonts.check(`16px ${key}`, value);
133
133
  } catch {}
134
134
 
135
- return `<span style="${
135
+ return `<span data-style="${key}" style="${
136
136
  isAvailable ? `font-family: ${key}!important;` : ''
137
137
  }">${value}</span>`;
138
138
  },
@@ -27,18 +27,19 @@ describe('Font test', function () {
27
27
  simulateEvent('mousedown', editor.editor);
28
28
 
29
29
  Array.from(openFontNameList()).map(function (font) {
30
- simulateEvent('click', 0, font);
30
+ simulateEvent('click', font);
31
31
 
32
32
  const fontFamily = font
33
33
  .querySelector('span[style]')
34
- .getAttribute('style')
34
+ .getAttribute('data-style')
35
35
  .replace(/"/g, "'");
36
36
 
37
37
  expect(sortAttributes(editor.value)).equals(
38
38
  sortAttributes(
39
- '<p><span style="' +
40
- fontFamily.replace('!important', '') +
41
- '">test</span></p>'
39
+ `<p><span style="font-family:${fontFamily.replace(
40
+ '!important',
41
+ ''
42
+ )}">test</span></p>`
42
43
  )
43
44
  );
44
45
  });
@@ -99,12 +100,12 @@ describe('Font test', function () {
99
100
  clickTrigger('font', editor);
100
101
  const list2 = getOpenedPopup(editor);
101
102
 
102
- clickButton('Impact_Charcoal_sans_serif', list2);
103
+ clickButton('impact_charcoal_sans_serif', list2);
103
104
  editor.s.insertHTML('stop');
104
105
 
105
106
  expect(sortAttributes(editor.value)).equals(
106
107
  '<p><span style="font-size:10px">test' +
107
- '<span style="font-family:Impact,Charcoal,sans-serif">stop</span></span></p>'
108
+ '<span style="font-family:impact,charcoal,sans-serif">stop</span></span></p>'
108
109
  );
109
110
  });
110
111
  });
@@ -153,9 +154,7 @@ describe('Font test', function () {
153
154
  clickButton('8', popup);
154
155
 
155
156
  expect(sortAttributes(editor.value)).equals(
156
- '<p>tex<span style="font-size:8' +
157
- point +
158
- '">t2t</span>ext</p>'
157
+ `<p>tex<span style="font-size:8${point}">t2t</span>ext</p>`
159
158
  );
160
159
 
161
160
  const range2 = editor.s.createRange(true);
@@ -169,11 +168,7 @@ describe('Font test', function () {
169
168
  expect(popup2).is.null;
170
169
 
171
170
  expect(editor.value).equals(
172
- '<p>tex<span style="font-size: 8' +
173
- point +
174
- ';">t2t</span>ext</p><p><span style="font-size: 8' +
175
- point +
176
- ';"></span></p>'
171
+ `<p>tex<span style="font-size: 8${point};">t2t</span>ext</p><p><span style="font-size: 8${point};"></span></p>`
177
172
  );
178
173
  });
179
174
  });
@@ -212,10 +207,10 @@ describe('Font test', function () {
212
207
 
213
208
  expect(popup).is.not.null;
214
209
 
215
- clickButton('Impact_Charcoal_sans_serif', popup);
210
+ clickButton('impact_charcoal_sans_serif', popup);
216
211
 
217
212
  expect(editor.value).equals(
218
- '<p>tex<span style="font-family: Impact, Charcoal, sans-serif;">t2t</span>ext</p>'
213
+ '<p>tex<span style="font-family: impact, charcoal, sans-serif;">t2t</span>ext</p>'
219
214
  );
220
215
 
221
216
  const range2 = editor.s.createRange(true);
@@ -229,7 +224,7 @@ describe('Font test', function () {
229
224
  expect(popup2).is.null;
230
225
 
231
226
  expect(editor.value).equals(
232
- '<p>tex<span style="font-family: Impact, Charcoal, sans-serif;">t2t</span>ext</p><p><span style="font-family: Impact, Charcoal, sans-serif;"></span></p>'
227
+ '<p>tex<span style="font-family: impact, charcoal, sans-serif;">t2t</span>ext</p><p><span style="font-family: impact, charcoal, sans-serif;"></span></p>'
233
228
  );
234
229
  });
235
230
  });
@@ -257,13 +252,13 @@ describe('Font test', function () {
257
252
  expect(font).is.not.null;
258
253
 
259
254
  editor.s.setCursorAfter(p.firstChild);
260
- simulateEvent('mousedown', 0, p);
255
+ simulateEvent('mousedown', p);
261
256
 
262
257
  expect(font.getAttribute('aria-pressed')).equals('false');
263
258
 
264
259
  editor.s.setCursorIn(p.lastChild);
265
260
 
266
- simulateEvent('mousedown', 0, p);
261
+ simulateEvent('mousedown', p);
267
262
 
268
263
  clickTrigger('fontsize', editor);
269
264
 
@@ -285,7 +280,7 @@ describe('Font test', function () {
285
280
  });
286
281
 
287
282
  editor.value =
288
- '<p>test<span style="font-family: Georgia, serif;">bold</span></p>';
283
+ '<p>test<span style="font-family: georgia,palatino,serif;">bold</span></p>';
289
284
  editor.s.focus();
290
285
 
291
286
  const p = editor.editor.firstChild;
@@ -294,7 +289,7 @@ describe('Font test', function () {
294
289
  expect(font).is.not.null;
295
290
 
296
291
  editor.s.setCursorAfter(p.firstChild);
297
- simulateEvent('mousedown', 0, p);
292
+ simulateEvent('mousedown', p);
298
293
  expect(font.getAttribute('aria-pressed')).equals('false');
299
294
 
300
295
  editor.s.setCursorIn(p.lastChild);
@@ -306,7 +301,7 @@ describe('Font test', function () {
306
301
  const popup = getOpenedPopup(editor);
307
302
 
308
303
  const fontGeorgia = popup.querySelector(
309
- '[class*=Georgia_serif]'
304
+ '[class*=georgia_palatino]'
310
305
  );
311
306
 
312
307
  expect(fontGeorgia).does.not.equal(font);
@@ -7,19 +7,15 @@
7
7
  describe('Hotkeys', function () {
8
8
  describe('Override default shortcuts for some commands', function () {
9
9
  it('Should work default shortcuts for another commands', function () {
10
- const area = appendTestArea(),
11
- editor = new Jodit(area, {
12
- commandToHotkeys: {
13
- bold: 'ctrl+shift+b',
14
- italic: ['ctrl+i', 'ctrl+shift+i']
15
- }
16
- });
17
-
18
- editor.value = 'test test test';
10
+ const editor = getJodit({
11
+ commandToHotkeys: {
12
+ bold: 'ctrl+shift+b',
13
+ italic: ['ctrl+i', 'ctrl+shift+i']
14
+ }
15
+ });
19
16
 
20
- const range = editor.s.createRange(true);
21
- range.setStart(editor.editor.firstChild.firstChild, 4);
22
- range.setEnd(editor.editor.firstChild.firstChild, 8);
17
+ editor.value = '<p>test| tes|t test</p>';
18
+ setCursorToChar(editor);
23
19
 
24
20
  // standart ctrl+u
25
21
  simulateEvent('keydown', 85, editor.editor, function (data) {
@@ -29,21 +25,18 @@ describe('Hotkeys', function () {
29
25
 
30
26
  expect(editor.value).equals('<p>test<u> tes</u>t test</p>');
31
27
  });
32
- describe('Replace ctrl+b to ctrl+shift+b for bold command', function () {
33
- it('Should not execute bold on ctrl+b', function () {
34
- const area = appendTestArea(),
35
- editor = new Jodit(area, {
36
- commandToHotkeys: {
37
- bold: 'ctrl+shift+b',
38
- italic: ['ctrl+i', 'ctrl+shift+i']
39
- }
40
- });
41
28
 
42
- editor.value = 'test test test';
29
+ describe('Replace ctrl+b to ctrl+alt+b for bold command', function () {
30
+ it('Should not execute bold on ctrl+b', function () {
31
+ const editor = getJodit({
32
+ commandToHotkeys: {
33
+ bold: 'ctrl+alt+b',
34
+ italic: ['ctrl+i', 'ctrl+shift+i']
35
+ }
36
+ });
43
37
 
44
- const range = editor.s.createRange(true);
45
- range.setStart(editor.editor.firstChild.firstChild, 4);
46
- range.setEnd(editor.editor.firstChild.firstChild, 8);
38
+ editor.value = '<p>test| tes|t test</p>';
39
+ setCursorToChar(editor);
47
40
 
48
41
  // standart ctrl+b
49
42
  simulateEvent('keydown', 66, editor.editor, function (data) {
@@ -54,7 +47,7 @@ describe('Hotkeys', function () {
54
47
  expect(editor.value).equals('<p>test test test</p>'); // should not sork
55
48
 
56
49
  simulateEvent('keydown', 66, editor.editor, function (data) {
57
- data.shiftKey = true;
50
+ data.altKey = true;
58
51
  data.ctrlKey = true;
59
52
  });
60
53
 
@@ -63,23 +56,19 @@ describe('Hotkeys', function () {
63
56
  );
64
57
  });
65
58
 
66
- it('Should execute bold on ctrl+shift+b', function () {
67
- const area = appendTestArea(),
68
- editor = new Jodit(area, {
69
- commandToHotkeys: {
70
- bold: 'ctrl+shift+b',
71
- italic: ['ctrl+i', 'ctrl+shift+i']
72
- }
73
- });
74
-
75
- editor.value = 'test test test';
59
+ it('Should execute bold on ctrl+alt+b', function () {
60
+ const editor = getJodit({
61
+ commandToHotkeys: {
62
+ bold: 'ctrl+alt+b',
63
+ italic: ['ctrl+i', 'ctrl+shift+i']
64
+ }
65
+ });
76
66
 
77
- const range = editor.s.createRange(true);
78
- range.setStart(editor.editor.firstChild.firstChild, 4);
79
- range.setEnd(editor.editor.firstChild.firstChild, 8);
67
+ editor.value = '<p>test| tes|t test</p>';
68
+ setCursorToChar(editor);
80
69
 
81
70
  simulateEvent('keydown', 66, editor.editor, function (data) {
82
- data.shiftKey = true;
71
+ data.altKey = true;
83
72
  data.ctrlKey = true;
84
73
  });
85
74
 
@@ -106,13 +95,12 @@ describe('Hotkeys', function () {
106
95
 
107
96
  describe('Add ctrl+shift+i to default ctrl+i shortcut for italic command', function () {
108
97
  it('Should work with each of shortcuts', function () {
109
- const area = appendTestArea(),
110
- editor = new Jodit(area, {
111
- commandToHotkeys: {
112
- bold: 'ctrl+shift+b',
113
- italic: ['ctrl+i', 'ctrl+shift+i']
114
- }
115
- });
98
+ const editor = getJodit({
99
+ commandToHotkeys: {
100
+ bold: 'ctrl+shift+b',
101
+ italic: ['ctrl+i', 'ctrl+shift+i']
102
+ }
103
+ });
116
104
 
117
105
  editor.value = '<p>test| tes|t test</p>';
118
106
  setCursorToChar(editor);