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,862 +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
- describe('Selection Module Tests', function () {
7
- describe('Current method', function () {
8
- describe('Cursor outside the editor', function () {
9
- it('Should return false', function () {
10
- const editor = getJodit(),
11
- div = document.createElement('div');
12
-
13
- div.innerHTML = 'test';
14
- document.body.appendChild(div);
15
- editor.value = '<h1>test <span>test</span>sdfsdfds</h1>';
16
- const range = document.createRange();
17
- range.setStart(div.firstChild, 1);
18
- range.setEnd(div.firstChild, 2);
19
- const sel = window.getSelection();
20
- sel.removeAllRanges();
21
- sel.addRange(range);
22
-
23
- expect(editor.s.current()).is.null;
24
- document.body.removeChild(div);
25
- });
26
- });
27
-
28
- describe('Cursor in the left of some SPAN', function () {
29
- it('Should return text before this span', function () {
30
- const editor = getJodit();
31
- editor.value = '<h1>one<span>two</span>tree</h1>';
32
- const range = editor.s.createRange();
33
- range.setStart(editor.editor.firstChild, 1);
34
- range.collapse(true);
35
-
36
- editor.s.selectRange(range);
37
-
38
- expect(editor.s.current()).equals(
39
- editor.editor.firstChild.firstChild
40
- ); //one
41
- });
42
- });
43
- describe('Cursor inside the text node ', function () {
44
- it('Should return text', function () {
45
- const editor = getJodit();
46
- editor.value = '<h1>test</h1>';
47
- const range = editor.s.createRange();
48
- range.setStart(editor.editor.firstChild.firstChild, 1);
49
- range.collapse(true);
50
- editor.s.selectRange(range);
51
-
52
- expect(editor.s.current()).equals(
53
- editor.editor.firstChild.firstChild
54
- ); // test
55
- });
56
- });
57
- describe('Cursor after h1', function () {
58
- it('Should return text inside h1', function () {
59
- const editor = getJodit();
60
- editor.value = '<h1>test</h1>';
61
- const range = editor.s.createRange();
62
- range.setStart(editor.editor, 1);
63
- range.collapse(true);
64
- editor.s.selectRange(range);
65
-
66
- expect(editor.s.current()).equals(
67
- editor.editor.firstChild.firstChild
68
- ); // test
69
- });
70
-
71
- describe('With false argument', function () {
72
- it('Should return h1', function () {
73
- const editor = getJodit();
74
- editor.value = '<h1>test</h1>';
75
- const range = editor.s.createRange();
76
- range.setStart(editor.editor, 1);
77
- range.collapse(true);
78
- editor.s.selectRange(range);
79
-
80
- expect([
81
- editor.editor.firstChild,
82
- editor.editor.firstChild.firstChild
83
- ]).to.include(editor.s.current(false)); // h1
84
- });
85
- });
86
- });
87
- describe('Select img', function () {
88
- it('Should return this image', function () {
89
- const editor = getJodit();
90
- editor.value = '<h1>test <img src="#" alt=""> sdfsdfs</h1>';
91
- const range = editor.s.createRange();
92
- range.selectNode(editor.editor.querySelector('img'));
93
- editor.s.selectRange(range);
94
-
95
- expect(editor.s.current()).equals(
96
- editor.editor.querySelector('img')
97
- );
98
- });
99
- });
100
- });
101
-
102
- describe('cursorInTheEdge', function () {
103
- describe('Cursor in the text', function () {
104
- describe('cursorOnTheLeft and cursorOnTheRight', function () {
105
- describe('Cursor inside P but inside Li', function () {
106
- describe('Cursor in the end of text node', function () {
107
- it('Should work correct', function () {
108
- const editor = getJodit();
109
- editor.value = '<ul><li><p>test</p></li></ul>';
110
-
111
- const range = editor.s.createRange();
112
-
113
- range.setStartAfter(
114
- editor.editor.querySelector('p').firstChild
115
- );
116
- range.collapse(true);
117
- editor.s.selectRange(range);
118
-
119
- ['li', 'p'].forEach(function (tag) {
120
- expect(
121
- editor.s.cursorOnTheLeft(
122
- editor.editor.querySelector(tag)
123
- )
124
- ).is.false;
125
-
126
- expect(
127
- editor.s.cursorOnTheRight(
128
- editor.editor.querySelector(tag)
129
- )
130
- ).is.true;
131
- });
132
- });
133
- });
134
-
135
- describe('Cursor in the start of text node', function () {
136
- it('Should work correct', function () {
137
- const editor = getJodit();
138
- editor.value = '<ul><li><p>test</p></li></ul>';
139
-
140
- const range = editor.s.createRange();
141
-
142
- range.setStartBefore(
143
- editor.editor.querySelector('p').firstChild
144
- );
145
- range.collapse(true);
146
- editor.s.selectRange(range);
147
-
148
- ['li', 'p'].forEach(function (tag) {
149
- expect(
150
- editor.s.cursorOnTheLeft(
151
- editor.editor.querySelector(tag)
152
- )
153
- ).is.true;
154
-
155
- expect(
156
- editor.s.cursorOnTheRight(
157
- editor.editor.querySelector(tag)
158
- )
159
- ).is.false;
160
- });
161
- });
162
- });
163
- });
164
- });
165
-
166
- describe('Cursor in the end of text node but after this has BR', function () {
167
- it('Should return true', function () {
168
- const editor = getJodit();
169
- editor.value = '<p>test<br></p>';
170
-
171
- const range = editor.s.createRange();
172
-
173
- range.setStart(editor.editor.firstChild.firstChild, 4);
174
- range.collapse(true);
175
- editor.s.selectRange(range);
176
-
177
- expect(editor.s.cursorOnTheRight(editor.editor.firstChild))
178
- .is.true;
179
- });
180
- });
181
-
182
- describe('Cursor in the end of text node but after this has image', function () {
183
- it('Should return false', function () {
184
- const editor = getJodit();
185
- editor.value = '<p>test<img/></p>';
186
-
187
- const range = editor.s.createRange();
188
-
189
- range.setStart(editor.editor.firstChild.firstChild, 4);
190
- range.collapse(true);
191
- editor.s.selectRange(range);
192
-
193
- expect(editor.s.cursorOnTheRight(editor.editor.firstChild))
194
- .is.false;
195
- });
196
- });
197
-
198
- describe('Cursor in the middle of text node', function () {
199
- it('Should return false', function () {
200
- const editor = getJodit();
201
- editor.value = '<p>test</p>';
202
-
203
- const range = editor.s.createRange();
204
-
205
- range.setStart(editor.editor.firstChild.firstChild, 2);
206
- range.collapse(true);
207
- editor.s.selectRange(range);
208
-
209
- expect(editor.s.cursorOnTheRight(editor.editor.firstChild))
210
- .is.false;
211
- });
212
-
213
- describe('Cursor in the middle of text node but after cursor only invisible spaces', function () {
214
- it('Should return true', function () {
215
- const editor = getJodit();
216
- editor.value =
217
- '<p>test' +
218
- Jodit.INVISIBLE_SPACE +
219
- Jodit.INVISIBLE_SPACE +
220
- Jodit.INVISIBLE_SPACE +
221
- '</p>';
222
-
223
- const range = editor.s.createRange();
224
-
225
- range.setStart(editor.editor.firstChild.firstChild, 4);
226
- range.collapse(true);
227
- editor.s.selectRange(range);
228
-
229
- expect(
230
- editor.s.cursorOnTheRight(editor.editor.firstChild)
231
- ).is.true;
232
- });
233
- });
234
- describe('Cursor in the middle of text node but before cursor only invisible spaces', function () {
235
- it('Should return true', function () {
236
- const editor = getJodit();
237
- editor.value =
238
- '<p>' +
239
- Jodit.INVISIBLE_SPACE +
240
- Jodit.INVISIBLE_SPACE +
241
- Jodit.INVISIBLE_SPACE +
242
- 'test</p>';
243
-
244
- const range = editor.s.createRange();
245
-
246
- range.setStart(editor.editor.firstChild.firstChild, 3);
247
- range.collapse(true);
248
- editor.s.selectRange(range);
249
-
250
- expect(
251
- editor.s.cursorOnTheLeft(editor.editor.firstChild)
252
- ).is.true;
253
- });
254
- });
255
-
256
- describe('Cursor in the end of text node but after this has several not empty text nodes', function () {
257
- it('Should return false', function () {
258
- const editor = getJodit();
259
- editor.value = '<p>test</p>';
260
-
261
- const range = editor.s.createRange();
262
-
263
- range.setStart(editor.editor.firstChild.firstChild, 4);
264
- range.collapse(true);
265
- editor.s.selectRange(range);
266
- editor.s.insertNode(editor.createInside.text('a'));
267
-
268
- range.setStart(editor.editor.firstChild.firstChild, 4);
269
- range.collapse(true);
270
- editor.s.selectRange(range);
271
-
272
- expect(
273
- editor.s.cursorOnTheRight(editor.editor.firstChild)
274
- ).is.false;
275
- });
276
-
277
- describe('Cursor in the end of text node and after are only text nodes with invisible spaces', function () {
278
- it('Should return true', function () {
279
- const editor = getJodit();
280
- editor.value = '<p>test</p>';
281
-
282
- const range = editor.s.createRange();
283
-
284
- range.setStart(
285
- editor.editor.firstChild.firstChild,
286
- 4
287
- );
288
- range.collapse(true);
289
- editor.s.selectRange(range);
290
-
291
- editor.s.insertNode(
292
- editor.createInside.text(Jodit.INVISIBLE_SPACE)
293
- );
294
- editor.s.insertNode(
295
- editor.createInside.text(Jodit.INVISIBLE_SPACE)
296
- );
297
- editor.s.insertNode(
298
- editor.createInside.text(Jodit.INVISIBLE_SPACE)
299
- );
300
-
301
- range.setStart(
302
- editor.editor.firstChild.firstChild,
303
- 4
304
- );
305
- range.collapse(true);
306
- editor.s.selectRange(range);
307
-
308
- expect(
309
- editor.s.cursorOnTheRight(
310
- editor.editor.firstChild
311
- )
312
- ).is.true;
313
- });
314
- });
315
-
316
- describe('Inverse', function () {
317
- describe('Cursor in the start of text node but before this has several not empty text nodes', function () {
318
- it('Should return false', function () {
319
- const editor = getJodit();
320
- editor.value = '<p>test</p>';
321
-
322
- const range = editor.s.createRange();
323
-
324
- range.setStart(
325
- editor.editor.firstChild.firstChild,
326
- 0
327
- );
328
- range.collapse(true);
329
- editor.s.selectRange(range);
330
- editor.s.insertNode(
331
- editor.createInside.text('a')
332
- );
333
-
334
- range.setStart(
335
- editor.editor.firstChild.lastChild,
336
- 0
337
- );
338
- range.collapse(true);
339
- editor.s.selectRange(range);
340
-
341
- expect(
342
- editor.s.cursorOnTheLeft(
343
- editor.editor.firstChild
344
- )
345
- ).is.false;
346
- });
347
- describe('Cursor in the start of text node and before are only text nodes with invisible spaces', function () {
348
- it('Should return true', function () {
349
- const editor = getJodit();
350
- editor.value = '<p>test</p>';
351
-
352
- const range = editor.s.createRange();
353
-
354
- range.setStart(
355
- editor.editor.firstChild.firstChild,
356
- 0
357
- );
358
- range.collapse(true);
359
- editor.s.selectRange(range);
360
-
361
- editor.s.insertNode(
362
- editor.createInside.text(
363
- Jodit.INVISIBLE_SPACE
364
- )
365
- );
366
- editor.s.insertNode(
367
- editor.createInside.text(
368
- Jodit.INVISIBLE_SPACE
369
- )
370
- );
371
- editor.s.insertNode(
372
- editor.createInside.text(
373
- Jodit.INVISIBLE_SPACE
374
- )
375
- );
376
-
377
- range.setStart(
378
- editor.editor.firstChild.lastChild,
379
- 0
380
- );
381
- range.collapse(true);
382
- editor.s.selectRange(range);
383
-
384
- expect(
385
- editor.s.cursorOnTheLeft(
386
- editor.editor.firstChild
387
- )
388
- ).is.true;
389
- });
390
- });
391
- });
392
- });
393
- });
394
- });
395
- });
396
-
397
- describe('Cursor after element', function () {
398
- it('Should return null', function () {
399
- const editor = getJodit();
400
- editor.value = '<p>test</p>';
401
-
402
- const range = editor.s.createRange();
403
-
404
- range.setStartAfter(editor.editor.firstChild);
405
- range.collapse(true);
406
- editor.s.selectRange(range);
407
-
408
- expect(editor.s.cursorOnTheRight(editor.editor.firstChild)).is
409
- .null;
410
- });
411
- });
412
-
413
- describe('Cursor before element', function () {
414
- it('Should return null', function () {
415
- const editor = getJodit();
416
- editor.value = '<p>test</p>';
417
-
418
- const range = editor.s.createRange();
419
-
420
- range.setStartBefore(editor.editor.firstChild);
421
- range.collapse(true);
422
- editor.s.selectRange(range);
423
-
424
- expect(editor.s.cursorOnTheLeft(editor.editor.firstChild)).is
425
- .null;
426
- });
427
- });
428
-
429
- describe('Cursor in the start of element ', function () {
430
- it('Should return true', function () {
431
- const editor = getJodit();
432
- editor.value = '<p><span>test</span></p>';
433
-
434
- const range = editor.s.createRange();
435
-
436
- range.setStartBefore(editor.editor.firstChild.firstChild);
437
- range.collapse(true);
438
- editor.s.selectRange(range);
439
-
440
- expect(editor.s.cursorOnTheLeft(editor.editor.firstChild)).is
441
- .true;
442
- });
443
- });
444
-
445
- describe('Cursor in the end of element ', function () {
446
- it('Should return true', function () {
447
- const editor = getJodit();
448
- editor.value = '<p><span>test</span></p>';
449
-
450
- const range = editor.s.createRange();
451
-
452
- range.setStartAfter(editor.editor.firstChild.firstChild);
453
- range.collapse(true);
454
- editor.s.selectRange(range);
455
-
456
- expect(editor.s.cursorOnTheRight(editor.editor.firstChild)).is
457
- .true;
458
- });
459
- });
460
-
461
- describe('Cursor not in the end of element ', function () {
462
- it('Should return false', function () {
463
- const editor = getJodit();
464
- editor.value = '<p><span>test</span><span>stop</span></p>';
465
-
466
- const range = editor.s.createRange();
467
-
468
- range.setStartAfter(editor.editor.firstChild.firstChild);
469
- range.collapse(true);
470
- editor.s.selectRange(range);
471
-
472
- expect(editor.s.cursorOnTheRight(editor.editor.firstChild)).is
473
- .false;
474
- });
475
- });
476
-
477
- describe('Cursor not in the start of element ', function () {
478
- it('Should return false', function () {
479
- const editor = getJodit();
480
- editor.value = '<p><span>test</span><span>stop</span></p>';
481
-
482
- const range = editor.s.createRange();
483
-
484
- range.setStartAfter(editor.editor.firstChild.firstChild);
485
- range.collapse(true);
486
- editor.s.selectRange(range);
487
-
488
- expect(editor.s.cursorOnTheLeft(editor.editor.firstChild)).is
489
- .false;
490
- });
491
- });
492
-
493
- describe('If cursor in the end of P', function () {
494
- it('Should return true', function () {
495
- const editor = getJodit();
496
- editor.value = '<p>test</p>';
497
-
498
- const sel = editor.s.sel,
499
- range = editor.s.createRange();
500
-
501
- range.setStart(editor.editor.firstChild.firstChild, 4);
502
- range.collapse(true);
503
- sel.removeAllRanges();
504
- sel.addRange(range);
505
-
506
- expect(editor.s.cursorOnTheRight(editor.editor.firstChild)).is
507
- .true;
508
-
509
- range.setStart(editor.editor.firstChild.firstChild, 2);
510
- range.collapse(true);
511
- sel.removeAllRanges();
512
- sel.addRange(range);
513
-
514
- expect(editor.s.cursorOnTheRight(editor.editor.firstChild)).is
515
- .false;
516
- });
517
- });
518
-
519
- describe('If cursor in the end of SPAN in the end of P', function () {
520
- it('Should return true', function () {
521
- const editor = getJodit();
522
- editor.value = '<p>test<span>1</span></p>';
523
-
524
- const sel = editor.s.sel,
525
- range = editor.s.createRange();
526
-
527
- range.selectNodeContents(editor.editor.firstChild.lastChild);
528
- range.collapse(false);
529
- sel.removeAllRanges();
530
- sel.addRange(range);
531
-
532
- expect(
533
- editor.s.cursorInTheEdge(false, editor.editor.firstChild)
534
- ).is.true;
535
- });
536
- });
537
-
538
- describe('Curson in the end of span inside P and check cursorInTheEdge(true)', function () {
539
- it('Should return false', function () {
540
- const editor = getJodit();
541
- editor.value = '<p>Some <span>|text|</span></p>';
542
- setCursorToChar(editor);
543
-
544
- expect(editor.s.cursorInTheEdge(true, editor.editor.firstChild))
545
- .is.false;
546
- });
547
- });
548
- });
549
-
550
- describe('Change mode', function () {
551
- it('Should restore collapsed selection when user change mode - from WYSIWYG to TEXTAREA', function () {
552
- const editor = getJodit();
553
-
554
- editor.value = '<p>te|st</p>';
555
-
556
- setCursorToChar(editor);
557
-
558
- editor.setMode(Jodit.MODE_SOURCE);
559
-
560
- const mirror = editor.container.querySelector(
561
- 'textarea.jodit-source__mirror'
562
- );
563
-
564
- expect(mirror.value).equals('<p>test</p>');
565
- expect(mirror.selectionStart).equals(5);
566
- expect(mirror.selectionEnd).equals(5);
567
- });
568
-
569
- it('Should restore collapsed selection when user change mode - from WYSIWYG to TEXTAREA for long string', function (done) {
570
- unmockPromise();
571
-
572
- let timeout;
573
- const __done = function () {
574
- clearTimeout(timeout);
575
- done();
576
- };
577
-
578
- timeout = setTimeout(function () {
579
- expect(false).is.true;
580
- __done();
581
- }, 140100);
582
-
583
- Jodit.make(appendTestArea(), {
584
- defaultMode: Jodit.MODE_SOURCE,
585
- sourceEditor: 'ace',
586
- beautifyHTML: false,
587
- events: {
588
- sourceEditorReady: function (jodit) {
589
- jodit.setMode(Jodit.MODE_WYSIWYG);
590
- jodit.setEditorValue(
591
- ('<p>' + 'test '.repeat(50) + '</p>').repeat(1)
592
- );
593
-
594
- const sel = jodit.ew.getSelection(),
595
- range = jodit.ed.createRange();
596
-
597
- range.selectNodeContents(
598
- jodit.editor.querySelector('p')
599
- );
600
-
601
- range.collapse(false);
602
- sel.removeAllRanges();
603
- sel.addRange(range);
604
-
605
- jodit.s.insertHTML('hello');
606
-
607
- jodit.setMode(Jodit.MODE_SOURCE);
608
-
609
- const ace =
610
- jodit.__plugins.source.sourceEditor.instance;
611
-
612
- expect(ace).not.null;
613
-
614
- expect(ace.getSelectionRange().start.column).equals(
615
- 258
616
- );
617
-
618
- expect(ace.getSelectionRange().start.row).equals(0);
619
-
620
- ace.session.insert(ace.getCursorPosition(), ' world');
621
-
622
- expect(
623
- jodit.__plugins.source.sourceEditor.getValue()
624
- ).equals(
625
- '<p>' + 'test '.repeat(49) + 'test hello world</p>'
626
- );
627
-
628
- mockPromise();
629
- __done();
630
- }
631
- }
632
- });
633
- }).timeout(116000);
634
-
635
- it('Should restore collapsed selection when user change mode - from TEXTAREA to WYSIWYG', function () {
636
- const editor = getJodit({
637
- useAceEditor: false,
638
- defaultMode: Jodit.MODE_SOURCE
639
- });
640
- editor.value = '<p>test</p>';
641
-
642
- const mirror = editor.container.querySelector(
643
- 'textarea.jodit-source__mirror'
644
- );
645
- mirror.setSelectionRange(5, 5);
646
-
647
- editor.setMode(Jodit.MODE_WYSIWYG);
648
- editor.s.insertNode(editor.createInside.text(' a '));
649
-
650
- expect(editor.value).equals('<p>te a st</p>');
651
- });
652
-
653
- it('Should restore non collapsed selection when user change mode - from WYSIWYG to TEXTAREA', function () {
654
- const editor = getJodit({
655
- useAceEditor: false
656
- });
657
- editor.value = '<p>test</p>';
658
-
659
- const sel = editor.s.sel,
660
- range = editor.s.createRange();
661
-
662
- range.setStart(editor.editor.firstChild.firstChild, 1);
663
- range.setEnd(editor.editor.firstChild.firstChild, 3);
664
- sel.removeAllRanges();
665
- sel.addRange(range);
666
-
667
- editor.setMode(Jodit.MODE_SOURCE);
668
-
669
- const mirror = editor.container.querySelector(
670
- 'textarea.jodit-source__mirror'
671
- );
672
-
673
- expect(mirror.value).equals('<p>test</p>');
674
- expect(mirror.selectionStart).equals(4);
675
- expect(mirror.selectionEnd).equals(6);
676
- });
677
-
678
- describe('Problem', function () {
679
- it('Should restore non collapsed selection when user change mode - from TEXTAREA to WYSIWYG', function () {
680
- const editor = getJodit({
681
- useAceEditor: false,
682
- defaultMode: Jodit.MODE_SOURCE
683
- });
684
- editor.s.focus();
685
- editor.value = '<p>test</p>';
686
-
687
- const mirror = editor.container.querySelector(
688
- 'textarea.jodit-source__mirror'
689
- );
690
- mirror.setSelectionRange(2, 8);
691
-
692
- editor.setMode(Jodit.MODE_WYSIWYG);
693
-
694
- expect(editor.s.isCollapsed()).is.false;
695
-
696
- editor.s.insertNode(editor.createInside.text(' a '));
697
- expect(editor.value).equals('<p> a </p>');
698
- });
699
- });
700
-
701
- it('Should restore collapsed selection inside empty element - from TEXTAREA to WYSIWYG', function () {
702
- const editor = getJodit({
703
- useAceEditor: false,
704
- defaultMode: Jodit.MODE_SOURCE
705
- });
706
- editor.value = '<p><a>11</a></p>';
707
-
708
- const mirror = editor.container.querySelector(
709
- 'textarea.jodit-source__mirror'
710
- );
711
- mirror.setSelectionRange(7, 7);
712
-
713
- editor.setMode(Jodit.MODE_WYSIWYG);
714
- expect(editor.s.isCollapsed()).is.true;
715
- editor.s.insertNode(editor.createInside.text(' a '));
716
- expect(editor.value).equals('<p><a>1 a 1</a></p>');
717
- });
718
- });
719
-
720
- describe('Click on empty tag', function () {
721
- it('Should move cursore inside that', function () {
722
- const editor = getJodit();
723
- editor.value = '<p></p><p></p><p></p>';
724
- simulateEvent(
725
- 'mousedown',
726
- 0,
727
- editor.editor.getElementsByTagName('p')[1]
728
- );
729
- editor.s.insertHTML('test');
730
- expect('<p></p><p>test</p><p></p>').equals(editor.value);
731
- });
732
- });
733
-
734
- describe('Method setCursorIn', function () {
735
- describe('Call for not Node element', function () {
736
- it('Should throw exception', function () {
737
- const editor = getJodit();
738
- editor.value = '<p>1</p><p>2</p>';
739
- expect(function () {
740
- editor.s.setCursorIn(editor.editor.querySelector('strong'));
741
- }).to.throw();
742
- });
743
-
744
- describe('Call for inserted fragment', function () {
745
- it('Should not throw exception', function () {
746
- const editor = getJodit();
747
- editor.value = '<p>1<span>3</span>2</p>';
748
- editor.s.select(editor.editor.querySelector('span'));
749
- const fragment = editor.s.range.extractContents();
750
- editor.s.insertNode(fragment);
751
- });
752
- });
753
- });
754
-
755
- describe('Call for element what is not inside the current editor', function () {
756
- it('Should throw exception', function () {
757
- const editor = getJodit();
758
- expect(function () {
759
- editor.s.setCursorIn(document.body);
760
- }).to.throw();
761
- });
762
- });
763
-
764
- it('Should move cursor inside node in the end', function () {
765
- const editor = getJodit();
766
- editor.value = '<p>1</p><p>2</p>';
767
-
768
- editor.s.setCursorIn(editor.editor.lastChild);
769
- editor.s.insertHTML('test');
770
-
771
- expect(editor.value).equals('<p>1</p><p>2test</p>');
772
- });
773
-
774
- describe('With inStart = true', function () {
775
- it('Should move cursor inside node in the start', function () {
776
- const editor = getJodit();
777
- editor.value = '<p>1</p><p>2</p>';
778
-
779
- editor.s.setCursorIn(editor.editor.lastChild, true);
780
- editor.s.insertHTML('test');
781
-
782
- expect(editor.value).equals('<p>1</p><p>test2</p>');
783
- });
784
- });
785
- });
786
-
787
- describe('Method eachSelection', function () {
788
- it('Should call callback for each node in selection', function () {
789
- const editor = getJodit({
790
- disablePlugins: ['WrapTextNodes']
791
- });
792
- editor.value =
793
- '<p>1</p><p>2</p><strong><span>22</span></strong><p>4</p>stop';
794
- const range = editor.s.createRange();
795
- range.setStartBefore(editor.editor.firstChild);
796
- range.setEndAfter(editor.editor.lastChild);
797
- editor.s.selectRange(range);
798
-
799
- const nodesNames = [];
800
- editor.s.eachSelection(function (node) {
801
- nodesNames.push(node.nodeName);
802
- });
803
-
804
- expect(
805
- ['P', 'P', 'STRONG', 'P', '#text'].toString().toLowerCase()
806
- ).equals(nodesNames.toString().toLowerCase());
807
- });
808
-
809
- it('Should call callback for each node in selection range', function () {
810
- const editor = getJodit({ disablePlugins: ['WrapTextNodes'] });
811
- editor.value =
812
- '<p>1</p><p>2</p><strong><span>22</span></strong><p>4</p>stop';
813
- const range = editor.s.createRange();
814
- range.setStartBefore(editor.editor.firstChild.nextSibling);
815
- range.setEndAfter(editor.editor.lastChild.previousSibling);
816
- editor.s.selectRange(range);
817
-
818
- const nodesNames = [];
819
- editor.s.eachSelection(function (node) {
820
- nodesNames.push(node.nodeName);
821
- });
822
-
823
- expect(['p', 'strong', 'p'].toString().toLowerCase()).equals(
824
- nodesNames.toString().toLowerCase()
825
- );
826
- });
827
-
828
- it('Should not call callback for editor', function () {
829
- const editor = getJodit();
830
- editor.value = '';
831
-
832
- editor.s.setCursorIn(editor.editor);
833
-
834
- const nodesNames = [];
835
- editor.s.eachSelection(function (node) {
836
- nodesNames.push(node.nodeName);
837
- });
838
-
839
- expect(['#text'].toString().toLowerCase()).equals(
840
- nodesNames.toString().toLowerCase()
841
- );
842
- });
843
-
844
- it('Should call callback for current node if selection is collapsed', function () {
845
- const editor = getJodit();
846
- editor.value = '<p>1</p><p>2</p>';
847
-
848
- editor.s.setCursorIn(editor.editor.firstChild);
849
-
850
- const nodesNames = [];
851
- editor.s.eachSelection(function (node) {
852
- nodesNames.push(node.nodeName);
853
- });
854
-
855
- expect(['#text'].toString().toLowerCase()).equals(
856
- nodesNames.toString().toLowerCase()
857
- );
858
- });
859
-
860
- describe('If selected element is UL or LI or content in LI', function () {});
861
- });
862
- });