jodit 3.8.1 → 3.8.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 (110) hide show
  1. package/.idea/codeStyles/Project.xml +68 -0
  2. package/.idea/codeStyles/codeStyleConfig.xml +5 -0
  3. package/.idea/dictionaries/v_chupurnov.xml +10 -0
  4. package/.idea/encodings.xml +4 -0
  5. package/.idea/inspectionProfiles/Project_Default.xml +118 -0
  6. package/.idea/jodit.iml +12 -0
  7. package/.idea/jsLibraryMappings.xml +6 -0
  8. package/.idea/markdown-navigator-enh.xml +29 -0
  9. package/.idea/markdown-navigator.xml +55 -0
  10. package/.idea/misc.xml +6 -0
  11. package/.idea/modules.xml +8 -0
  12. package/.idea/prettier.xml +6 -0
  13. package/.idea/vcs.xml +6 -0
  14. package/.idea/watcherTasks.xml +4 -0
  15. package/.idea/workspace.xml +1264 -0
  16. package/build/jodit.css +2 -2
  17. package/build/jodit.es2018.css +1 -1
  18. package/build/jodit.es2018.en.css +1 -1
  19. package/build/jodit.es2018.en.js +4 -4
  20. package/build/jodit.es2018.en.min.js +2 -2
  21. package/build/jodit.es2018.js +4 -4
  22. package/build/jodit.es2018.min.js +2 -2
  23. package/build/jodit.js +4 -4
  24. package/build/jodit.min.css +1 -1
  25. package/build/jodit.min.js +2 -2
  26. package/package.json +2 -2
  27. package/.travis.yml +0 -7
  28. package/bower.json +0 -33
  29. package/build.js +0 -39
  30. package/docker/Dockerfile +0 -11
  31. package/docker/README.md +0 -45
  32. package/docker/build +0 -3
  33. package/docker/install +0 -7
  34. package/docker/start +0 -3
  35. package/docker/test +0 -3
  36. package/docker/uninstall +0 -3
  37. package/examples/arabic.lang.html +0 -76
  38. package/examples/assets/app.css +0 -175
  39. package/examples/assets/app.js +0 -57
  40. package/examples/assets/download.jpg +0 -0
  41. package/examples/assets/icon.png +0 -0
  42. package/examples/assets/logo.png +0 -0
  43. package/examples/assets/prism.css +0 -200
  44. package/examples/assets/prism.js +0 -1254
  45. package/examples/color-picker.html +0 -139
  46. package/examples/custom-icons.html +0 -173
  47. package/examples/custom-toolbar.html +0 -80
  48. package/examples/example.default.html +0 -75
  49. package/examples/fullsize.html +0 -75
  50. package/examples/index.html +0 -176
  51. package/examples/inline-mode.html +0 -116
  52. package/examples/oneinstance.html +0 -125
  53. package/icons.html +0 -50
  54. package/karma.conf.js +0 -157
  55. package/make.js +0 -10
  56. package/server.js +0 -101
  57. package/test/bootstrap.js +0 -1167
  58. package/test/test.html +0 -102
  59. package/test/test.index.html +0 -11
  60. package/test/tests/acceptance/clipboardTest.js +0 -1234
  61. package/test/tests/acceptance/commandsTest.js +0 -647
  62. package/test/tests/acceptance/creatorTest.js +0 -103
  63. package/test/tests/acceptance/deleteBackSpaceTest.js +0 -1289
  64. package/test/tests/acceptance/dialogTest.js +0 -188
  65. package/test/tests/acceptance/editorTest.js +0 -855
  66. package/test/tests/acceptance/enterTest.js +0 -1088
  67. package/test/tests/acceptance/eventsTest.js +0 -1246
  68. package/test/tests/acceptance/filebrowserTest.js +0 -1309
  69. package/test/tests/acceptance/i18nTest.js +0 -81
  70. package/test/tests/acceptance/iframeTest.js +0 -306
  71. package/test/tests/acceptance/imageTest.js +0 -1649
  72. package/test/tests/acceptance/inlineModeTest.js +0 -826
  73. package/test/tests/acceptance/interfaceTest.js +0 -119
  74. package/test/tests/acceptance/mobileTest.js +0 -229
  75. package/test/tests/acceptance/plugins/classSpan.js +0 -220
  76. package/test/tests/acceptance/plugins/cleanHtml.js +0 -351
  77. package/test/tests/acceptance/plugins/color.js +0 -188
  78. package/test/tests/acceptance/plugins/dragAndDropElement.js +0 -172
  79. package/test/tests/acceptance/plugins/focus.js +0 -115
  80. package/test/tests/acceptance/plugins/font.js +0 -316
  81. package/test/tests/acceptance/plugins/image.js +0 -79
  82. package/test/tests/acceptance/plugins/indent.js +0 -179
  83. package/test/tests/acceptance/plugins/inline-popup.js +0 -578
  84. package/test/tests/acceptance/plugins/insert.js +0 -17
  85. package/test/tests/acceptance/plugins/limit.js +0 -164
  86. package/test/tests/acceptance/plugins/link.js +0 -1640
  87. package/test/tests/acceptance/plugins/orderedList.js +0 -290
  88. package/test/tests/acceptance/plugins/placeholder.js +0 -138
  89. package/test/tests/acceptance/plugins/resizer.js +0 -329
  90. package/test/tests/acceptance/plugins/search.js +0 -623
  91. package/test/tests/acceptance/plugins/size.js +0 -344
  92. package/test/tests/acceptance/plugins/source.js +0 -218
  93. package/test/tests/acceptance/plugins/stat.js +0 -120
  94. package/test/tests/acceptance/plugins/tooltip.js +0 -97
  95. package/test/tests/acceptance/plugins/wrapTextNodes.js +0 -105
  96. package/test/tests/acceptance/pluginsTest.js +0 -2219
  97. package/test/tests/acceptance/selectionTest.js +0 -862
  98. package/test/tests/acceptance/statesTest.js +0 -310
  99. package/test/tests/acceptance/tableTest.js +0 -1988
  100. package/test/tests/acceptance/toolbarTest.js +0 -1747
  101. package/test/tests/acceptance/undoredoTest.js +0 -217
  102. package/test/tests/acceptance/uploaderTest.js +0 -187
  103. package/test/tests/artio.jpg +0 -0
  104. package/test/tests/units/helpersTest.js +0 -771
  105. package/test/tests/units/modules/dom.js +0 -282
  106. package/test/tests/units/objectObserverTest.js +0 -533
  107. package/test/tests/units/popupTest.js +0 -211
  108. package/test/tests/units/positionTest.js +0 -238
  109. package/test/tests/units/styleTest.js +0 -1361
  110. package/webpack.config.js +0 -308
@@ -1,1088 +0,0 @@
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-2021 Valeriy Chupurnov. All rights reserved. https://xdsoft.net
5
- */
6
-
7
- describe('Enter behavior Jodit Editor Tests', function () {
8
- describe('Enter key', function () {
9
- describe('Enter BR', function () {
10
- it('Should simple insert BR element', function () {
11
- const editor = getJodit({
12
- enter: 'br'
13
- });
14
-
15
- editor.value = 'test';
16
- editor.s.setCursorAfter(editor.editor.firstChild);
17
- simulateEvent('keydown', Jodit.KEY_ENTER, editor.editor);
18
- expect(editor.value).equals('test<br>');
19
- editor.s.insertHTML('stop');
20
- expect(editor.value).equals('test<br>stop');
21
- });
22
- });
23
-
24
- describe('If Enter was pressed in not wrapped text in the end, it text ', function () {
25
- it('should be wrap in paragraph and cursor should be in next new paragraph', function () {
26
- const editor = getJodit();
27
- editor.value = 'Some text';
28
-
29
- const sel = editor.s.sel,
30
- range = editor.s.createRange();
31
-
32
- range.setStart(editor.editor.firstChild.firstChild, 9);
33
- range.collapse(true);
34
- sel.removeAllRanges();
35
- sel.addRange(range);
36
-
37
- simulateEvent('keydown', Jodit.KEY_ENTER, editor.editor);
38
-
39
- editor.s.insertNode(editor.createInside.text(' a '));
40
-
41
- expect(editor.value).equals('<p>Some text</p><p> a <br></p>');
42
- });
43
-
44
- describe('Inside BODY for iframe and editHTMLDocumentMode', function () {
45
- it('should work like in usual case', function () {
46
- const editor = getJodit({
47
- editHTMLDocumentMode: true,
48
- iframe: true,
49
- iframeStyle: '',
50
- iframeCSSLinks: Jodit.atom([])
51
- });
52
-
53
- editor.value = 'Some text';
54
-
55
- const sel = editor.s.sel,
56
- range = editor.s.createRange();
57
-
58
- range.setStart(editor.editor.firstChild.firstChild, 9);
59
- range.collapse(true);
60
- sel.removeAllRanges();
61
- sel.addRange(range);
62
-
63
- simulateEvent('keydown', Jodit.KEY_ENTER, editor.editor);
64
-
65
- editor.s.insertNode(editor.createInside.text(' a '));
66
-
67
- expect(sortAttributes(editor.value)).equals(
68
- '<!DOCTYPE html><html lang="en" style="overflow-y:hidden">' +
69
- '<head><title>Jodit Editor</title></head>' +
70
- '<body spellcheck="true" ><p>Some text</p><p> a <br></p></body>' +
71
- '</html>'
72
- );
73
- });
74
- });
75
- });
76
-
77
- describe('If Enter was pressed in the end of SPAN inside P', function () {
78
- it('should simple create P>SPAN and move cursor inside this', function () {
79
- const editor = getJodit();
80
- editor.value =
81
- '<p>Some <span style="color: red">text</span></p>';
82
-
83
- const sel = editor.s.sel,
84
- range = editor.s.createRange();
85
-
86
- range.selectNodeContents(editor.editor.firstChild.lastChild);
87
- range.collapse(false);
88
- sel.removeAllRanges();
89
- sel.addRange(range);
90
-
91
- simulateEvent('keydown', Jodit.KEY_ENTER, editor.editor);
92
-
93
- editor.s.insertNode(editor.createInside.text(' a '));
94
-
95
- expect(editor.value).equals(
96
- '<p>Some <span style="color: red">text</span></p><p><span style="color: red"> a <br></span></p>'
97
- );
98
- });
99
- });
100
-
101
- describe('If Enter was pressed in the end of STRONG inside P', function () {
102
- it('should simple create P>STRONG and move cursor inside this', function () {
103
- const editor = getJodit();
104
- editor.value = '<p>Some <strong>text</strong></p>';
105
-
106
- const sel = editor.s.sel,
107
- range = editor.s.createRange();
108
-
109
- range.selectNodeContents(editor.editor.firstChild.lastChild);
110
- range.collapse(false);
111
- sel.removeAllRanges();
112
- sel.addRange(range);
113
-
114
- simulateEvent('keydown', Jodit.KEY_ENTER, editor.editor);
115
-
116
- editor.s.insertNode(editor.createInside.text(' a '));
117
-
118
- expect(editor.value).equals(
119
- '<p>Some <strong>text</strong></p><p><strong> a <br></strong></p>'
120
- );
121
- });
122
- });
123
-
124
- describe('If Enter was pressed inside text without wrapper and near were some another elements', function () {
125
- it('should split that wrapper', function () {
126
- const editor = getJodit();
127
- editor.value =
128
- 'as<span style="color: rgb(147, 101, 184);">da</span>s';
129
-
130
- const range = editor.s.createRange();
131
-
132
- // set focus in the span
133
- range.setStart(
134
- editor.editor.firstChild.firstChild.nextSibling.firstChild,
135
- 1
136
- );
137
- range.collapse(true);
138
- editor.s.selectRange(range);
139
-
140
- simulateEvent('keydown', Jodit.KEY_ENTER, editor.editor);
141
-
142
- editor.s.insertNode(editor.createInside.text(' a '));
143
-
144
- expect(editor.value).equals(
145
- '<p>as<span style="color: rgb(147, 101, 184);">d</span></p><p><span style="color: rgb(147, 101, 184);"> a a</span>s</p>'
146
- );
147
- });
148
- });
149
-
150
- describe('If Enter was pressed inside H1-6 that', function () {
151
- it('should be spliced on two', function () {
152
- const editor = getJodit();
153
- editor.value = '<h1>Some text</h1>';
154
-
155
- const sel = editor.s.sel,
156
- range = editor.s.createRange();
157
-
158
- range.setStart(editor.editor.firstChild.firstChild, 5);
159
- range.collapse(true);
160
- sel.removeAllRanges();
161
- sel.addRange(range);
162
-
163
- simulateEvent('keydown', Jodit.KEY_ENTER, editor.editor);
164
-
165
- editor.s.insertNode(editor.createInside.text(' a '));
166
-
167
- expect(editor.value).equals('<h1>Some </h1><h1> a text</h1>');
168
- });
169
- });
170
-
171
- describe('If Enter was pressed inside H1-6 cursor ', function () {
172
- it('should be move in new paragraph below', function () {
173
- const editor = getJodit();
174
- editor.value = '<h1>Some text</h1>';
175
-
176
- const sel = editor.s.sel,
177
- range = editor.s.createRange();
178
-
179
- range.setStart(editor.editor.firstChild.firstChild, 9);
180
- range.collapse(true);
181
- sel.removeAllRanges();
182
- sel.addRange(range);
183
-
184
- simulateEvent('keydown', Jodit.KEY_ENTER, editor.editor);
185
-
186
- editor.s.insertNode(editor.createInside.text(' a '));
187
-
188
- expect(editor.value).equals('<h1>Some text</h1><p> a <br></p>');
189
- });
190
- });
191
-
192
- describe('If Enter was pressed', function () {
193
- describe('Prevent plugin work', function () {
194
- it('Should prevent plugin work', function () {
195
- const editor = getJodit({
196
- enter: 'BR',
197
- events: {
198
- beforeEnter: function () {
199
- return false;
200
- }
201
- }
202
- });
203
- editor.value = 'test';
204
- editor.s.setCursorAfter(editor.editor.firstChild);
205
- simulateEvent('keydown', Jodit.KEY_ENTER, editor.editor);
206
- expect(editor.value).equals('test');
207
- editor.s.insertHTML('stop');
208
- expect(editor.value).equals('teststop');
209
- });
210
- });
211
-
212
- describe('in not wrapped text in the start', function () {
213
- it('should wrap this text in paragraph and cursor should be in that, and before should be empty new paragraph', function () {
214
- const editor = getJodit();
215
- editor.value = 'Some text';
216
-
217
- const sel = editor.s.sel,
218
- range = editor.s.createRange();
219
-
220
- range.setStart(editor.editor.firstChild, 0);
221
- range.collapse(true);
222
- sel.removeAllRanges();
223
- sel.addRange(range);
224
-
225
- simulateEvent('keydown', Jodit.KEY_ENTER, editor.editor);
226
-
227
- editor.s.insertNode(editor.createInside.text(' a '));
228
-
229
- expect(editor.value).equals(
230
- '<p><br></p><p> a Some text</p>'
231
- );
232
- });
233
- });
234
- });
235
-
236
- describe('If Enter was pressed inside empty editor', function () {
237
- it('should be added 2 paragraph and cursor must be in second', function () {
238
- const editor = getJodit();
239
-
240
- editor.value = ''; // empty
241
- editor.s.focus();
242
-
243
- simulateEvent('keydown', Jodit.KEY_ENTER, editor.editor);
244
-
245
- editor.s.insertNode(editor.createInside.text(' a '));
246
-
247
- expect(editor.value).equals('<p><br></p><p> a <br></p>');
248
- });
249
- });
250
-
251
- describe('If Enter was pressed in no wrapped text, it text ', function () {
252
- it('should be wrap in paragraph and spliced on two parts', function () {
253
- const editor = getJodit();
254
- editor.value = 'Some text';
255
-
256
- const sel = editor.s.sel,
257
- range = editor.s.createRange();
258
-
259
- range.setStart(editor.editor.firstChild.firstChild, 5);
260
- range.collapse(true);
261
- sel.removeAllRanges();
262
- sel.addRange(range);
263
-
264
- simulateEvent('keydown', Jodit.KEY_ENTER, editor.editor);
265
-
266
- editor.s.insertNode(editor.createInside.text(' a '));
267
-
268
- expect(editor.value).equals('<p>Some </p><p> a text</p>');
269
- });
270
- });
271
-
272
- describe('Content editor after pressing the Enter key', function () {
273
- it('Should contain the specified tag settings', function () {
274
- const editor = getJodit();
275
- simulateEvent('keydown', Jodit.KEY_ENTER, editor.editor);
276
- simulateEvent('keydown', Jodit.KEY_ENTER, editor.editor);
277
- simulateEvent('keydown', Jodit.KEY_ENTER, editor.editor);
278
- expect(editor.value).equals(
279
- '<p><br></p><p><br></p><p><br></p><p><br></p>'
280
- );
281
- });
282
-
283
- describe('after this', function () {
284
- it('Should contain the specified tag settings and after this cursor must be inside that tag', function () {
285
- const editor = getJodit();
286
- editor.value = '';
287
- editor.s.focus();
288
-
289
- simulateEvent('keydown', Jodit.KEY_ENTER, editor.editor);
290
- editor.s.insertNode(editor.createInside.text('test'));
291
-
292
- simulateEvent('keydown', Jodit.KEY_ENTER, editor.editor);
293
- editor.s.insertNode(editor.createInside.text('test2'));
294
-
295
- simulateEvent('keydown', Jodit.KEY_ENTER, editor.editor);
296
- editor.s.insertNode(editor.createInside.text('test3'));
297
-
298
- expect(editor.value).equals(
299
- '<p><br></p><p>test</p><p>test2</p><p>test3<br></p>'
300
- );
301
- });
302
- });
303
- });
304
-
305
- describe('Enter pressed inside P element', function () {
306
- describe('In the middle of element', function () {
307
- it('Should split paragraph', function () {
308
- const editor = getJodit();
309
-
310
- const p = editor.ed.createElement('p'),
311
- node = editor.createInside.text('Split paragraph');
312
-
313
- p.appendChild(node);
314
-
315
- editor.s.insertNode(p);
316
-
317
- const range = editor.s.createRange();
318
-
319
- range.setStart(node, 6);
320
- editor.s.sel.removeAllRanges();
321
- editor.s.sel.addRange(range);
322
-
323
- simulateEvent('keydown', Jodit.KEY_ENTER, editor.editor);
324
-
325
- editor.s.insertNode(editor.createInside.text('a '));
326
-
327
- expect(editor.value).equals(
328
- '<p>Split </p><p>a paragraph</p>'
329
- );
330
- });
331
- it('Should create new paragraph with same styles like as original', function () {
332
- const editor = getJodit();
333
-
334
- const p = editor.ed.createElement('p'),
335
- node = editor.createInside.text('Split paragraph');
336
-
337
- p.appendChild(node);
338
- p.style.textAlign = 'right';
339
- p.style.color = '#ff0000';
340
-
341
- editor.s.insertNode(p);
342
-
343
- const range = editor.s.createRange();
344
-
345
- range.setStart(node, 6);
346
- editor.s.sel.removeAllRanges();
347
- editor.s.sel.addRange(range);
348
-
349
- simulateEvent('keydown', Jodit.KEY_ENTER, editor.editor);
350
-
351
- editor.s.insertNode(editor.createInside.text('a '));
352
-
353
- expect(sortAttributes(editor.value)).equals(
354
- '<p style="color:#FF0000;text-align:right">Split </p><p style="color:#FF0000;text-align:right">a paragraph</p>'
355
- );
356
- });
357
- });
358
- describe('Enter pressed inside P element in the edge', function () {
359
- describe('If cursor in the right edge of paragraph after enter', function () {
360
- it('should move cursor in another new paragraph', function () {
361
- const editor = getJodit();
362
-
363
- const p = editor.ed.createElement('p'),
364
- p2 = editor.ed.createElement('p');
365
-
366
- p.innerHTML = 'Split paragraph';
367
- p2.innerHTML = 'Test';
368
- editor.s.insertNode(p);
369
- editor.s.insertNode(p2);
370
-
371
- // set cursor in end of element
372
- editor.s.setCursorIn(p, false);
373
-
374
- simulateEvent(
375
- 'keydown',
376
- Jodit.KEY_ENTER,
377
- editor.editor
378
- );
379
-
380
- editor.s.insertNode(editor.createInside.text('a '));
381
-
382
- expect(editor.value).equals(
383
- '<p>Split paragraph</p><p>a <br></p><p>Test</p>'
384
- );
385
- });
386
- });
387
- describe('If cursor in the left edge of paragraph after enter', function () {
388
- it('should move cursor in another new paragraph before old place', function () {
389
- const editor = getJodit();
390
-
391
- const p = editor.ed.createElement('p'),
392
- p2 = editor.ed.createElement('p');
393
-
394
- p.innerHTML = 'Split paragraph';
395
- p2.innerHTML = 'Test';
396
- editor.s.insertNode(p);
397
- editor.s.insertNode(p2);
398
-
399
- const range = editor.s.createRange();
400
-
401
- // set cursor in start of element
402
- range.setStart(p.firstChild, 0);
403
- range.collapse(true);
404
- editor.s.sel.removeAllRanges();
405
- editor.s.sel.addRange(range);
406
-
407
- simulateEvent(
408
- 'keydown',
409
- Jodit.KEY_ENTER,
410
- editor.editor
411
- );
412
-
413
- editor.s.insertNode(editor.createInside.text('a '));
414
-
415
- expect(editor.value).equals(
416
- '<p><br></p><p>a Split paragraph</p><p>Test</p>'
417
- );
418
- });
419
- });
420
- describe('Copys styles', function () {
421
- it('should move cursor in new paragraph an copy all styles from old', function () {
422
- const editor = getJodit();
423
-
424
- const p = editor.ed.createElement('p'),
425
- p2 = editor.ed.createElement('p');
426
-
427
- p.style.color = '#ff0000';
428
- p.style.textAlign = 'right';
429
-
430
- p.innerHTML = 'Split paragraph';
431
- p2.innerHTML = 'Test';
432
- editor.s.insertNode(p);
433
- editor.s.insertNode(p2);
434
-
435
- // set cursor in end of element
436
- editor.s.setCursorIn(p, false);
437
-
438
- simulateEvent(
439
- 'keydown',
440
- Jodit.KEY_ENTER,
441
- editor.editor
442
- );
443
-
444
- editor.s.insertNode(editor.createInside.text('a '));
445
-
446
- expect(sortAttributes(editor.value)).to.be.equal(
447
- '<p style="color:#FF0000;text-align:right">Split paragraph</p><p style="color:#FF0000;text-align:right">a <br></p><p>Test</p>'
448
- );
449
- });
450
- });
451
- });
452
- });
453
-
454
- describe('with table', function () {
455
- it('If cursor in TD tag', function () {
456
- const editor = getJodit();
457
-
458
- editor.value = '<table><tr><td>text</td></tr></table>';
459
-
460
- const range = editor.s.createRange();
461
-
462
- // set cursor in start of element
463
- range.selectNodeContents(editor.editor.querySelector('td'));
464
- range.collapse(true);
465
- editor.s.selectRange(range);
466
-
467
- editor.s.insertNode(editor.createInside.text('split '));
468
-
469
- expect(editor.value).equals(
470
- '<table><tbody><tr><td>split text</td></tr></tbody></table>'
471
- );
472
-
473
- simulateEvent('keydown', Jodit.KEY_ENTER, editor.editor);
474
-
475
- expect(editor.value).equals(
476
- '<table><tbody><tr><td>split <br>text</td></tr></tbody></table>'
477
- );
478
-
479
- editor.s.insertNode(editor.createInside.text(' test '));
480
-
481
- expect(editor.value).equals(
482
- '<table><tbody><tr><td>split <br> test text</td></tr></tbody></table>'
483
- );
484
-
485
- simulateEvent('keydown', Jodit.KEY_ENTER, editor.editor);
486
-
487
- expect(editor.value).equals(
488
- '<table><tbody><tr><td>split <br> test <br>text</td></tr></tbody></table>'
489
- );
490
-
491
- editor.s.insertNode(editor.createInside.text(' stop '));
492
-
493
- expect(editor.value).equals(
494
- '<table><tbody><tr><td>split <br> test <br> stop text</td></tr></tbody></table>'
495
- );
496
- });
497
-
498
- it('If cursor in right side of table', function () {
499
- const editor = getJodit();
500
-
501
- editor.value = '<table><tr><td>test</td></tr></table>';
502
-
503
- const range = editor.s.createRange();
504
-
505
- // set cursor in start of element
506
- range.setEndAfter(editor.editor.querySelector('table'));
507
- range.collapse(false);
508
- editor.s.selectRange(range);
509
-
510
- simulateEvent('keydown', Jodit.KEY_ENTER, editor.editor);
511
-
512
- editor.s.insertNode(editor.createInside.text('text'), false);
513
-
514
- expect(editor.value).equals(
515
- '<table><tbody><tr><td>test</td></tr></tbody></table><p>text<br></p>'
516
- );
517
- });
518
- });
519
-
520
- describe('with SHIFT button', function () {
521
- it('should insert <br> tag and move cursor after it.', function () {
522
- const editor = getJodit();
523
-
524
- editor.value = 'test';
525
-
526
- const range = editor.s.createRange();
527
-
528
- // set cursor in start of element
529
- range.setStart(editor.editor.firstChild.firstChild, 2);
530
- range.collapse(true);
531
- editor.s.sel.removeAllRanges();
532
- editor.s.sel.addRange(range);
533
-
534
- simulateEvent(
535
- 'keydown',
536
- Jodit.KEY_ENTER,
537
- editor.editor,
538
- function (options) {
539
- options.shiftKey = true;
540
- }
541
- );
542
-
543
- editor.s.insertNode(editor.createInside.text('split '));
544
-
545
- expect(editor.value).equals('<p>te<br>split st</p>');
546
-
547
- simulateEvent(
548
- 'keydown',
549
- Jodit.KEY_ENTER,
550
- editor.editor,
551
- function (options) {
552
- options.shiftKey = true;
553
- }
554
- );
555
-
556
- expect(editor.value).equals('<p>te<br>split <br>st</p>');
557
- });
558
- });
559
-
560
- describe('In PRE or BLOCKQUOTE tag', function () {
561
- it('Should add <br> element', function () {
562
- const editor = getJodit();
563
-
564
- editor.value = '<pre>test</pre>';
565
-
566
- editor.s.setCursorIn(editor.editor.querySelector('pre'), false);
567
- simulateEvent('keydown', Jodit.KEY_ENTER, editor.editor);
568
- editor.s.insertNode(editor.createInside.text('split'));
569
-
570
- expect(sortAttributes(editor.value)).equals(
571
- '<pre>test<br>split</pre>'
572
- );
573
- });
574
-
575
- describe('with SHIFT button', function () {
576
- describe('In the end', function () {
577
- it('should add new P element after PRE', function () {
578
- const editor = getJodit();
579
-
580
- editor.value = '<pre>test</pre>';
581
-
582
- editor.s
583
- .createRange(true)
584
- .setStart(editor.editor.firstChild.firstChild, 4);
585
-
586
- simulateEvent(
587
- 'keydown',
588
- Jodit.KEY_ENTER,
589
- editor.editor,
590
- function (options) {
591
- options.shiftKey = true;
592
- }
593
- );
594
-
595
- editor.s.insertNode(editor.createInside.text('split '));
596
-
597
- expect(editor.value).equals(
598
- '<pre>test</pre><p>split <br></p>'
599
- );
600
- });
601
- });
602
-
603
- describe('In the start', function () {
604
- it('should add new P element before blockquote', function () {
605
- const editor = getJodit();
606
-
607
- editor.value = '<blockquote>test</blockquote>';
608
-
609
- editor.s
610
- .createRange(true)
611
- .setStart(editor.editor.firstChild.firstChild, 0);
612
-
613
- simulateEvent(
614
- 'keydown',
615
- Jodit.KEY_ENTER,
616
- editor.editor,
617
- function (options) {
618
- options.shiftKey = true;
619
- }
620
- );
621
-
622
- editor.s.insertNode(editor.createInside.text('split '));
623
-
624
- expect(editor.value).equals(
625
- '<p><br></p><blockquote>split test</blockquote>'
626
- );
627
- });
628
- });
629
-
630
- describe('In the middle', function () {
631
- it('should split PRE element', function () {
632
- const editor = getJodit();
633
-
634
- editor.value = '<pre>test</pre>';
635
-
636
- editor.s
637
- .createRange(true)
638
- .setStart(editor.editor.firstChild.firstChild, 2);
639
-
640
- simulateEvent(
641
- 'keydown',
642
- Jodit.KEY_ENTER,
643
- editor.editor,
644
- function (options) {
645
- options.shiftKey = true;
646
- }
647
- );
648
-
649
- editor.s.insertNode(editor.createInside.text('split '));
650
-
651
- expect(editor.value).equals(
652
- '<pre>te</pre><pre>split st</pre>'
653
- );
654
- });
655
- });
656
- });
657
- });
658
-
659
- describe('Inside UL tag', function () {
660
- describe('enter mode = br', function () {
661
- describe('Inside LI tag in the end', function () {
662
- it('Should work like usual and add new LI element', function () {
663
- const editor = getJodit({
664
- enter: 'BR'
665
- });
666
-
667
- editor.value = '<ul><li>test</li></ul>';
668
-
669
- editor.s.setCursorAfter(
670
- editor.editor.querySelector('ul>li').firstChild
671
- );
672
- simulateEvent(
673
- 'keydown',
674
- Jodit.KEY_ENTER,
675
- editor.editor
676
- );
677
- editor.s.insertNode(editor.createInside.text('split'));
678
-
679
- expect(
680
- '<ul>' +
681
- '<li>test</li>' +
682
- '<li>split<br></li>' +
683
- '</ul>'
684
- ).equals(sortAttributes(editor.value));
685
- });
686
- });
687
-
688
- describe('Inside empty LI tag', function () {
689
- it('Should work like usual and add insert new br after UL', function () {
690
- const editor = getJodit({
691
- enter: 'BR'
692
- });
693
-
694
- editor.value = '<ul><li>test</li><li> </li></ul>';
695
-
696
- editor.s.setCursorAfter(
697
- editor.editor.querySelectorAll('ul>li')[1]
698
- .firstChild
699
- );
700
- simulateEvent(
701
- 'keydown',
702
- Jodit.KEY_ENTER,
703
- editor.editor
704
- );
705
- editor.s.insertNode(editor.createInside.text('split'));
706
-
707
- expect(
708
- '<ul>' + '<li>test</li>' + '</ul>split<br>'
709
- ).equals(sortAttributes(editor.value));
710
- });
711
- });
712
- });
713
-
714
- describe('In LI tag inside table cell', function () {
715
- it('Should work like usual', function () {
716
- const editor = getJodit();
717
-
718
- editor.value =
719
- '<table>' +
720
- '<tbody>' +
721
- '<tr>' +
722
- '<td>' +
723
- '<ul><li>test</li></ul>' +
724
- '</td>' +
725
- '</tr>' +
726
- '</tbody>' +
727
- '</table>';
728
-
729
- editor.s.setCursorIn(
730
- editor.editor.querySelector('ul>li'),
731
- false
732
- );
733
- simulateEvent('keydown', Jodit.KEY_ENTER, editor.editor);
734
- editor.s.insertNode(editor.createInside.text('split'));
735
-
736
- expect(
737
- '<table>' +
738
- '<tbody>' +
739
- '<tr>' +
740
- '<td>' +
741
- '<ul>' +
742
- '<li>test</li>' +
743
- '<li>split<br></li>' +
744
- '</ul>' +
745
- '</td>' +
746
- '</tr>' +
747
- '</tbody>' +
748
- '</table>'
749
- ).equals(sortAttributes(editor.value));
750
- });
751
- });
752
-
753
- describe('In last LI tag', function () {
754
- describe('In tag was only one Image element but cursor was before it', function () {
755
- it('Should not add new P element and move image there', function () {
756
- const editor = getJodit();
757
-
758
- editor.value =
759
- '<ul>' +
760
- '<li>1</li>' +
761
- '<li>2</li>' +
762
- '<li><img style="width:30px" src="tests/artio.jpg"></li>' +
763
- '</ul>';
764
-
765
- editor.s.setCursorBefore(
766
- editor.editor.firstChild.lastChild.firstChild
767
- );
768
- simulateEvent(
769
- 'keydown',
770
- Jodit.KEY_ENTER,
771
- editor.editor
772
- );
773
- editor.s.insertNode(editor.createInside.text('split '));
774
-
775
- expect(
776
- '<ul>' +
777
- '<li>1</li>' +
778
- '<li>2</li>' +
779
- '<li><br></li>' +
780
- '<li>split <img src="tests/artio.jpg" style="width:30px"></li>' +
781
- '</ul>'
782
- ).equals(sortAttributes(editor.value));
783
- });
784
- });
785
- });
786
-
787
- describe('If Enter was pressed inside first empty LI and it was alone LI in UL', function () {
788
- it('should be remove LI and UL and cursor must b inside new P', function () {
789
- const editor = getJodit();
790
- editor.value = '<ul><li> </li></ul>';
791
-
792
- const sel = editor.s.sel,
793
- range = editor.s.createRange();
794
-
795
- range.setStart(editor.editor.firstChild.firstChild, 0);
796
- range.collapse(true);
797
- sel.removeAllRanges();
798
- sel.addRange(range);
799
-
800
- simulateEvent('keydown', Jodit.KEY_ENTER, editor.editor);
801
-
802
- editor.s.insertNode(editor.createInside.text(' a '));
803
-
804
- expect(editor.value).equals('<p> a <br></p>');
805
- });
806
- });
807
-
808
- describe('If Enter was pressed inside empty LI', function () {
809
- it('should be removed and cursor must be after UL|OL', function () {
810
- const editor = getJodit();
811
- editor.value = '<ul><li>Some text</li><li> </li></ul>';
812
-
813
- const range = editor.s.createRange(true);
814
-
815
- range.setStart(
816
- editor.editor.firstChild.lastChild.firstChild,
817
- 1
818
- );
819
- range.collapse(true);
820
-
821
- simulateEvent('keydown', Jodit.KEY_ENTER, editor.editor);
822
-
823
- editor.s.insertNode(editor.createInside.text(' a '));
824
-
825
- expect(editor.value).equals(
826
- '<ul><li>Some text</li></ul><p> a <br></p>'
827
- );
828
- });
829
- });
830
-
831
- describe('If Enter was pressed inside empty middle LI', function () {
832
- it('should split parent UL, remove LI, insert new P in the middle of two new Ul and insert cursor inside this', function () {
833
- const editor = getJodit();
834
- editor.value =
835
- '<ul><li>Test</li><li> </li><li>Some text</li></ul>';
836
-
837
- const sel = editor.s.sel,
838
- range = editor.s.createRange();
839
-
840
- range.setStart(editor.editor.firstChild.childNodes[1], 0);
841
- range.collapse(true);
842
- sel.removeAllRanges();
843
- sel.addRange(range);
844
-
845
- simulateEvent('keydown', Jodit.KEY_ENTER, editor.editor);
846
-
847
- editor.s.insertNode(editor.createInside.text(' a '));
848
-
849
- expect(editor.value).equals(
850
- '<ul><li>Test</li></ul><p> a <br></p><ul><li>Some text</li></ul>'
851
- );
852
- });
853
- });
854
-
855
- describe('Inside not empty LI', function () {
856
- describe('In the middle of LI', function () {
857
- it('should split LI on two parts', function () {
858
- const editor = getJodit();
859
- editor.value =
860
- '<ul>\n' +
861
- '\t<li>first</li>\n' +
862
- '\t<li>second</li>\n' +
863
- '\t<li>third</li>\n' +
864
- '</ul>';
865
-
866
- const range = editor.s.createRange(true);
867
-
868
- range.setStart(
869
- editor.editor.querySelectorAll('li')[1].firstChild,
870
- 3
871
- );
872
- range.collapse(true);
873
-
874
- simulateEvent(
875
- 'keydown',
876
- Jodit.KEY_ENTER,
877
- editor.editor
878
- );
879
-
880
- editor.s.insertNode(editor.createInside.text(' a '));
881
-
882
- expect(editor.value).equals(
883
- '<ul>\n' +
884
- '\t<li>first</li>\n' +
885
- '\t<li>sec</li>' +
886
- '<li> a ond</li>\n' +
887
- '\t<li>third</li>\n' +
888
- '</ul>'
889
- );
890
- });
891
-
892
- describe('With Shift', function () {
893
- it('should only add new BR', function () {
894
- const editor = getJodit();
895
- editor.value =
896
- '<ul>\n' +
897
- '\t<li>first</li>\n' +
898
- '\t<li>second</li>\n' +
899
- '\t<li>third</li>\n' +
900
- '</ul>';
901
-
902
- const range = editor.s.createRange(true);
903
-
904
- range.setStart(
905
- editor.editor.querySelectorAll('li')[1]
906
- .firstChild,
907
- 3
908
- );
909
- range.collapse(true);
910
-
911
- simulateEvent(
912
- 'keydown',
913
- Jodit.KEY_ENTER,
914
- editor.editor,
915
- function (options) {
916
- options.shiftKey = true;
917
- }
918
- );
919
-
920
- editor.s.insertNode(
921
- editor.createInside.text(' a ')
922
- );
923
-
924
- expect(editor.value).equals(
925
- '<ul>\n' +
926
- '\t<li>first</li>\n' +
927
- '\t<li>sec<br> a ond</li>\n' +
928
- '\t<li>third</li>\n' +
929
- '</ul>'
930
- );
931
- });
932
- });
933
- });
934
- });
935
-
936
- describe('If Enter was pressed inside start of first(not empty) LI', function () {
937
- it('should add empty LI and cursor should not move', function () {
938
- const editor = getJodit();
939
- editor.value = '<ul><li>Some text</li></ul>';
940
-
941
- const sel = editor.s.sel,
942
- range = editor.s.createRange();
943
-
944
- range.setStart(
945
- editor.editor.firstChild.firstChild.firstChild,
946
- 0
947
- );
948
- range.collapse(true);
949
- sel.removeAllRanges();
950
- sel.addRange(range);
951
-
952
- simulateEvent('keydown', Jodit.KEY_ENTER, editor.editor);
953
-
954
- editor.s.insertNode(editor.createInside.text(' a '));
955
-
956
- expect(editor.value).equals(
957
- '<ul><li><br></li><li> a Some text</li></ul>'
958
- );
959
- });
960
- });
961
-
962
- describe('If Enter was pressed inside start of first empty LI', function () {
963
- it('should remove this LI, and insert new P element before parent UL, cursor should move to inside it', function () {
964
- const editor = getJodit();
965
- editor.value = '<ul><li> </li><li>Some text</li></ul>';
966
-
967
- const sel = editor.s.sel,
968
- range = editor.s.createRange();
969
-
970
- range.setStart(editor.editor.firstChild.firstChild, 0);
971
- range.collapse(true);
972
- sel.removeAllRanges();
973
- sel.addRange(range);
974
-
975
- simulateEvent('keydown', Jodit.KEY_ENTER, editor.editor);
976
-
977
- editor.s.insertNode(editor.createInside.text(' a '));
978
-
979
- expect(editor.value).equals(
980
- '<p> a <br></p><ul><li>Some text</li></ul>'
981
- );
982
- });
983
- });
984
-
985
- describe('Enter was pressed inside P inside LI', function () {
986
- it('should add new LI with P and set cursor inside it', function () {
987
- const editor = getJodit();
988
- editor.value =
989
- '<ul>' +
990
- '<li><p>Line_1</p></li>' +
991
- '<li><p>Line_2</p></li>' +
992
- '</ul>';
993
-
994
- const range = editor.s.createRange();
995
-
996
- range.setEndAfter(
997
- editor.editor.querySelector('p').firstChild
998
- );
999
- range.collapse(false);
1000
- editor.s.selectRange(range);
1001
-
1002
- simulateEvent('keydown', Jodit.KEY_ENTER, editor.editor);
1003
-
1004
- editor.s.insertNode(editor.createInside.text(' a '));
1005
-
1006
- expect(editor.value).equals(
1007
- '<ul>' +
1008
- '<li><p>Line_1</p></li>' +
1009
- '<li><p> a <br></p></li>' +
1010
- '<li><p>Line_2</p></li>' +
1011
- '</ul>'
1012
- );
1013
- });
1014
- });
1015
- });
1016
-
1017
- describe('Use BR instead P', function () {
1018
- describe('Enter 3 times', function () {
1019
- it('should create 3 BR elements and set cursor after these', function () {
1020
- const editor = getJodit({
1021
- enter: Jodit.BR
1022
- });
1023
- editor.value = 'Some text';
1024
-
1025
- const sel = editor.s.sel,
1026
- range = editor.s.createRange();
1027
-
1028
- range.setStart(editor.editor.firstChild, 9);
1029
- range.collapse(true);
1030
- sel.removeAllRanges();
1031
- sel.addRange(range);
1032
-
1033
- simulateEvent('keydown', Jodit.KEY_ENTER, editor.editor);
1034
- simulateEvent('keydown', Jodit.KEY_ENTER, editor.editor);
1035
- simulateEvent('keydown', Jodit.KEY_ENTER, editor.editor);
1036
-
1037
- editor.s.insertNode(editor.createInside.text(' a '));
1038
-
1039
- expect(editor.value).equals('Some text<br><br><br> a ');
1040
- });
1041
- });
1042
- });
1043
-
1044
- describe('Press Enter inside SPAN with some color', function () {
1045
- it('Should add new P(with SPAN with same style) element after this span and this SPAN should wrap in P', function () {
1046
- const editor = getJodit();
1047
-
1048
- editor.value = '<span style="color:red">test</span>';
1049
-
1050
- editor.s.setCursorIn(
1051
- editor.editor.querySelector('span'),
1052
- false
1053
- );
1054
- simulateEvent('keydown', Jodit.KEY_ENTER, editor.editor);
1055
-
1056
- editor.s.insertNode(editor.createInside.text('test'));
1057
-
1058
- expect(sortAttributes(editor.value)).equals(
1059
- '<p><span style="color:red">test</span></p><p><span style="color:red">test<br></span></p>'
1060
- );
1061
- });
1062
-
1063
- describe('Enter two times', function () {
1064
- it('Should add 2 P', function () {
1065
- const editor = getJodit();
1066
-
1067
- editor.value = '<p><span style="color:red">test</span></p>';
1068
-
1069
- editor.s.setCursorIn(
1070
- editor.editor.querySelector('span'),
1071
- false
1072
- );
1073
-
1074
- simulateEvent('keydown', Jodit.KEY_ENTER, editor.editor);
1075
- simulateEvent('keydown', Jodit.KEY_ENTER, editor.editor);
1076
-
1077
- editor.s.insertNode(editor.createInside.text('test'));
1078
-
1079
- expect(sortAttributes(editor.value)).equals(
1080
- '<p><span style="color:red">test</span></p>' +
1081
- '<p><span style="color:red"><br></span></p>' +
1082
- '<p><span style="color:red">test<br></span></p>'
1083
- );
1084
- });
1085
- });
1086
- });
1087
- });
1088
- });