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,2219 +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('Test plugins', function () {
7
- getBox().style.width = 'auto';
8
-
9
- describe('Copy format plugin', function () {
10
- it('Should copy fontWeight from element and paste it in new selection', function () {
11
- getBox().style.width = 'auto';
12
- const editor = getJodit();
13
-
14
- editor.value = '<div>text <strong>test</strong> post</div>';
15
- editor.s.focus();
16
- editor.s.setCursorIn(editor.editor.querySelector('strong'));
17
-
18
- expect(getButton('copyformat', editor)).is.not.null;
19
-
20
- expect(
21
- getButton('copyformat', editor).getAttribute('aria-pressed')
22
- ).equals('false');
23
-
24
- simulateEvent('click', 0, getButton('copyformat', editor));
25
-
26
- expect(
27
- getButton('copyformat', editor).getAttribute('aria-pressed')
28
- ).equals('true');
29
-
30
- const range = editor.s.createRange();
31
-
32
- range.selectNode(editor.editor.firstChild.lastChild);
33
- editor.s.selectRange(range);
34
-
35
- simulateEvent('mouseup', 0, editor.editor);
36
-
37
- expect(editor.value.replace('700', 'bold')).equals(
38
- '<div>text <strong>test</strong><span style="font-weight: bold;"> post</span></div>'
39
- );
40
- });
41
-
42
- it('Should copy fontSize from element and paste it in new selection', function () {
43
- getBox().style.width = 'auto';
44
- const editor = getJodit();
45
-
46
- editor.value =
47
- '<div>text <span style="font-size: 11px;">test</span> post</div>';
48
- editor.s.focus();
49
- editor.s.setCursorIn(editor.editor.querySelector('span'));
50
-
51
- expect(getButton('copyformat', editor)).is.not.null;
52
- expect(
53
- getButton('copyformat', editor).getAttribute('aria-pressed')
54
- ).equals('false');
55
-
56
- clickButton('copyformat', editor);
57
-
58
- expect(
59
- getButton('copyformat', editor).getAttribute('aria-pressed')
60
- ).equals('true');
61
-
62
- const range = editor.s.createRange(true);
63
- range.selectNode(editor.editor.firstChild.lastChild);
64
-
65
- simulateEvent('mouseup', 0, editor.editor);
66
-
67
- expect(editor.value).equals(
68
- '<div>text <span style="font-size: 11px;">test</span><span style="font-size: 11px;"> post</span></div>'
69
- );
70
- });
71
-
72
- describe('Test', function () {
73
- it('Should copy fontSize and color from element and paste it in new selection', function () {
74
- getBox().style.width = 'auto';
75
- const editor = getJodit();
76
-
77
- editor.value =
78
- '<div>text <span style="font-size: 11px;color: rgb(255, 0, 0);">test</span> post</div>';
79
- editor.s.focus();
80
-
81
- editor.s.setCursorIn(editor.editor.querySelector('span'));
82
-
83
- expect(
84
- getButton('copyformat', editor).getAttribute('aria-pressed')
85
- ).equals('false');
86
-
87
- clickButton('copyformat', editor);
88
-
89
- expect(
90
- getButton('copyformat', editor).getAttribute('aria-pressed')
91
- ).equals('true');
92
-
93
- const range = editor.s.createRange(true);
94
-
95
- range.selectNode(editor.editor.firstChild.lastChild);
96
-
97
- simulateEvent('mouseup', 0, editor.editor);
98
-
99
- expect(sortAttributes(editor.value)).equals(
100
- '<div>text <span style="color:#FF0000;font-size:11px">test</span><span style="color:#FF0000;font-size:11px"> post</span></div>'
101
- );
102
- });
103
- });
104
-
105
- it('Should toggle active state after double click', function () {
106
- getBox().style.width = 'auto';
107
-
108
- const editor = getJodit();
109
-
110
- editor.value =
111
- 'text <span style="font-size: 11px;color: rgb(255, 0, 0);">test</span> post';
112
- editor.s.focus();
113
-
114
- editor.s.setCursorIn(editor.editor.querySelector('span'));
115
-
116
- expect(
117
- getButton('copyformat', editor).getAttribute('aria-pressed')
118
- ).equals('false');
119
-
120
- clickButton('copyformat', editor);
121
-
122
- expect(
123
- getButton('copyformat', editor).getAttribute('aria-pressed')
124
- ).equals('true');
125
-
126
- clickButton('copyformat', editor);
127
-
128
- expect(
129
- getButton('copyformat', editor).getAttribute('aria-pressed')
130
- ).equals('false');
131
-
132
- const sel = editor.s.sel,
133
- range = editor.s.createRange();
134
-
135
- range.selectNode(editor.editor.firstChild.lastChild);
136
- sel.removeAllRanges();
137
- sel.addRange(range);
138
-
139
- simulateEvent('mouseup', 0, editor.editor);
140
-
141
- expect(sortAttributes(editor.value)).equals(
142
- '<p>text <span style="color:#FF0000;font-size:11px">test</span> post</p>'
143
- );
144
- });
145
-
146
- describe('For image', function () {
147
- it('Should copy format from one image to another', function () {
148
- getBox().style.width = 'auto';
149
-
150
- const editor = getJodit(),
151
- html =
152
- '<p><img src="tests/artio.jpg" ' +
153
- 'style="height: 100px;width: 100px; margin: 20px; border-image: none; border:1px solid #CCCCCC; border-radius: 50%;"> test ' +
154
- '<img style="height: 100px;width: 100px;" src="tests/artio.jpg"></p>';
155
-
156
- editor.value = html;
157
- editor.s.focus();
158
-
159
- expect(sortAttributes(editor.value)).equals(
160
- sortAttributes(html)
161
- );
162
-
163
- simulateEvent(
164
- 'mousedown',
165
- 0,
166
- editor.editor.querySelector('img')
167
- );
168
-
169
- clickButton('copyformat', editor);
170
-
171
- simulateEvent(
172
- 'mousedown',
173
- 0,
174
- editor.editor.querySelectorAll('img')[1]
175
- );
176
- simulateEvent(
177
- 'mouseup',
178
- 0,
179
- editor.editor.querySelectorAll('img')[1]
180
- );
181
-
182
- expect(sortAttributes(editor.value)).equals(
183
- sortAttributes(
184
- '<p><img src="tests/artio.jpg" ' +
185
- 'style="border-image:none;border-radius:50%;border:1px solid #CCCCCC;height:100px;margin:20px;width:100px"> test ' +
186
- '<img src="tests/artio.jpg" ' +
187
- 'style="border-image:none;border-color:#CCCCCC;border-radius:50%;border-style:solid;border-width:1px;height:100px;margin:20px;width:100px"></p>'
188
- )
189
- );
190
- });
191
- });
192
-
193
- describe('Set cursor inside em[style=background] > strong elements', function () {
194
- it('Should copy fontWeight from strong element, copy italic and background style from em and paste it in new selection', function () {
195
- getBox().style.width = 'auto';
196
- const editor = getJodit();
197
-
198
- editor.value =
199
- '<div>text <em style="background-color: #ff0000"><strong>test</strong></em> post</div>';
200
- editor.s.focus();
201
-
202
- editor.s.setCursorIn(editor.editor.querySelector('strong'));
203
- expect(
204
- getButton('copyformat', editor).getAttribute('aria-pressed')
205
- ).equals('false');
206
-
207
- clickButton('copyformat', editor);
208
-
209
- expect(
210
- getButton('copyformat', editor).getAttribute('aria-pressed')
211
- ).equals('true');
212
-
213
- const range = editor.s.createRange(true);
214
-
215
- range.selectNode(editor.editor.firstChild.lastChild);
216
-
217
- simulateEvent('mouseup', 0, editor.editor);
218
-
219
- expect(
220
- sortAttributes(
221
- editor
222
- .getEditorValue()
223
- .replace(/700/g, 'bold')
224
- .replace(/rgb\(255, 0, 0\)/g, '#ff0000')
225
- )
226
- ).equals(
227
- '<div>text <em style="background-color:#ff0000"><strong>test</strong></em><span style="background-color:#ff0000;font-style:italic;font-weight:bold"> post</span></div>'
228
- );
229
- });
230
- });
231
- });
232
-
233
- describe('Add new Line plugin', function () {
234
- it('Should not add new line element in container before first use', function () {
235
- const editor = getJodit();
236
- expect(
237
- editor.container.querySelectorAll('.jodit-add-new-line').length
238
- ).equals(0);
239
- });
240
-
241
- const moveCursorUnder = function (editor, elm) {
242
- simulateEvent('mousemove', 0, editor.editor, function (e) {
243
- const pos = Jodit.modules.Helpers.position(elm, editor);
244
-
245
- e.clientX = pos.left + 5;
246
- e.clientY = pos.top + 5;
247
- });
248
- };
249
-
250
- it('Should show .jodit-add-new-line after user move mouse under Table,Ifrmae or IMG ', function () {
251
- const editor = getJodit();
252
- editor.value =
253
- '<table>' +
254
- '<tbody>' +
255
- '<tr><td>1</td></tr>' +
256
- '<tr><td>2</td></tr>' +
257
- '<tr><td>3</td></tr>' +
258
- '<tr><td>4</td></tr>' +
259
- '</tbody>' +
260
- '</table>';
261
-
262
- window.scrollTo(
263
- 0,
264
- Jodit.modules.Helpers.offset(
265
- editor.editor,
266
- editor,
267
- editor.ownerDocument
268
- ).top
269
- ); // elementFromPoint works only with visible part of view
270
-
271
- moveCursorUnder(editor, editor.editor.firstChild);
272
-
273
- const newline = editor.container.querySelector(
274
- '.jodit-add-new-line'
275
- );
276
-
277
- expect(newline).not.is.null;
278
- expect(editor.ownerWindow.getComputedStyle(newline).display).equals(
279
- 'block'
280
- );
281
- });
282
-
283
- it('Should add new paragraph after user clicked on newline ', function () {
284
- const editor = getJodit();
285
- editor.value =
286
- '<table><tbody>' +
287
- '<tr><td>2</td></tr>' +
288
- '<tr><td>2</td></tr>' +
289
- '<tr><td>3</td></tr>' +
290
- '<tr><td>4</td></tr>' +
291
- '</tbody></table>';
292
-
293
- window.scrollTo(
294
- 0,
295
- Jodit.modules.Helpers.offset(
296
- editor.editor,
297
- editor,
298
- editor.ownerDocument
299
- ).top
300
- ); // elementFromPoint works only with visible part of view
301
-
302
- moveCursorUnder(editor, editor.editor.firstChild);
303
-
304
- const newline = editor.container.querySelector(
305
- '.jodit-add-new-line'
306
- );
307
-
308
- expect(newline).not.is.null;
309
- expect(editor.ownerWindow.getComputedStyle(newline).display).equals(
310
- 'block'
311
- );
312
-
313
- simulateEvent('mousedown', 0, newline.querySelector('span'));
314
- expect(editor.getElementValue()).equals(
315
- '<p></p><table><tbody>' +
316
- '<tr><td>2</td></tr>' +
317
- '<tr><td>2</td></tr>' +
318
- '<tr><td>3</td></tr>' +
319
- '<tr><td>4</td></tr>' +
320
- '</tbody></table>'
321
- );
322
- });
323
-
324
- it('Should add new paragraph after user clicked on newline below table', function () {
325
- const editor = getJodit();
326
- editor.value =
327
- '<table><tbody>' +
328
- '<tr><td>3</td></tr>' +
329
- '<tr><td>2</td></tr>' +
330
- '</tbody></table>';
331
-
332
- window.scrollTo(
333
- 0,
334
- Jodit.modules.Helpers.offset(
335
- editor.editor,
336
- editor,
337
- editor.ownerDocument
338
- ).top
339
- ); // elementFromPoint works only with visible part of view
340
-
341
- simulateEvent('mousemove', 0, editor.editor, function (data) {
342
- const pos = Jodit.modules.Helpers.position(
343
- editor.editor.firstChild,
344
- editor
345
- );
346
-
347
- data.clientX = pos.left + 5;
348
- data.clientY = pos.top + (pos.height - 5);
349
- });
350
-
351
- const newline = editor.container.querySelector(
352
- '.jodit-add-new-line'
353
- );
354
-
355
- expect(newline).not.is.null;
356
- expect(editor.ownerWindow.getComputedStyle(newline).display).equals(
357
- 'block'
358
- );
359
-
360
- simulateEvent('mousedown', 0, newline.querySelector('span'));
361
- expect(editor.getElementValue()).equals(
362
- '<table><tbody>' +
363
- '<tr><td>3</td></tr>' +
364
- '<tr><td>2</td></tr>' +
365
- '</tbody></table><p></p>'
366
- );
367
- });
368
-
369
- it('Should add new paragraph after user clicked on newline below table in IFRAME mode', function () {
370
- const editor = getJodit({
371
- ifarme: true
372
- });
373
- editor.value =
374
- '<table><tbody>' +
375
- '<tr><td>3</td></tr>' +
376
- '<tr><td>2</td></tr>' +
377
- '</tbody></table>';
378
-
379
- window.scrollTo(
380
- 0,
381
- Jodit.modules.Helpers.offset(
382
- editor.editor,
383
- editor,
384
- editor.ownerDocument
385
- ).top
386
- ); // elementFromPoint works only with visible part of view
387
-
388
- simulateEvent('mousemove', 0, editor.editor, function (data) {
389
- const pos = Jodit.modules.Helpers.position(
390
- editor.editor.firstChild,
391
- editor
392
- );
393
-
394
- data.clientX = pos.left + 5;
395
- data.clientY = pos.top + (pos.height - 5);
396
- });
397
-
398
- const newline = editor.container.querySelector(
399
- '.jodit-add-new-line'
400
- );
401
-
402
- expect(newline).not.is.null;
403
- expect(editor.ownerWindow.getComputedStyle(newline).display).equals(
404
- 'block'
405
- );
406
-
407
- simulateEvent('mousedown', 0, newline.querySelector('span'));
408
- expect(editor.getElementValue()).equals(
409
- '<table><tbody>' +
410
- '<tr><td>3</td></tr>' +
411
- '<tr><td>2</td></tr>' +
412
- '</tbody></table><p></p>'
413
- );
414
- });
415
-
416
- describe('Insert line on top of IMG element that was inside P element', function () {
417
- it('Should insert new P before parent P element', function () {
418
- const editor = getJodit();
419
- editor.value =
420
- '<p><img src="tests/artio.jpg" style="width: 100px; height: 100px;" alt=""></p>';
421
-
422
- window.scrollTo(
423
- 0,
424
- Jodit.modules.Helpers.offset(
425
- editor.editor,
426
- editor,
427
- editor.ownerDocument
428
- ).top
429
- ); // elementFromPoint works only with visible part of view
430
-
431
- const img = editor.editor.querySelector('img');
432
- expect(null).does.not.equal(img);
433
-
434
- moveCursorUnder(editor, img);
435
-
436
- const newline = editor.container.querySelector(
437
- '.jodit-add-new-line'
438
- );
439
-
440
- expect(null).does.not.equal(newline);
441
- expect(
442
- editor.ownerWindow.getComputedStyle(newline).display
443
- ).equals('block');
444
- simulateEvent('mousedown', 0, newline.querySelector('span'));
445
-
446
- editor.s.insertHTML('stop');
447
-
448
- expect(
449
- '<p>stop</p><p><img alt="" src="tests/artio.jpg" style="height:100px;width:100px"></p>'
450
- ).equals(sortAttributes(editor.value));
451
- });
452
- });
453
- });
454
-
455
- describe('Edit image tests', function () {
456
- describe('Image editor', function () {
457
- describe('Crop mode', function () {
458
- describe('Enable ratio', function () {
459
- it('Should deny crop image without ratio', function (done) {
460
- const area = appendTestArea();
461
- const editor = new Jodit(area, {
462
- observer: {
463
- timeout: 0
464
- },
465
- uploader: {
466
- url: 'https://xdsoft.net/jodit/connector/index.php?action=upload'
467
- },
468
- filebrowser: {
469
- ajax: {
470
- url: 'https://xdsoft.net/jodit/connector/index.php'
471
- }
472
- },
473
- disablePlugins: 'mobile'
474
- });
475
-
476
- editor.value =
477
- '<img alt="" src="https://xdsoft.net/jodit/files/th.jpg">';
478
-
479
- simulateEvent(
480
- 'dblclick',
481
- editor.editor.querySelector('img')
482
- );
483
-
484
- const dialog = getOpenedDialog(editor);
485
-
486
- expect(dialog).is.not.null;
487
- expect(
488
- dialog.querySelectorAll('[data-ref="editImage"]')
489
- .length
490
- ).equals(1);
491
-
492
- editor.filebrowser.events.on(
493
- 'afterImageEditor',
494
- function () {
495
- const imageEditor = getOpenedDialog(editor);
496
-
497
- expect(imageEditor).is.not.null;
498
-
499
- expect(
500
- imageEditor.querySelectorAll(
501
- '[data-area=crop]'
502
- ).length
503
- ).equals(1);
504
- expect(
505
- imageEditor.querySelectorAll(
506
- '[data-area=crop].jodit-image-editor_active'
507
- ).length
508
- ).equals(0);
509
-
510
- simulateEvent(
511
- 'click',
512
- 0,
513
- imageEditor.querySelector(
514
- '[data-area=crop] > div'
515
- )
516
- );
517
-
518
- expect(
519
- imageEditor.querySelectorAll(
520
- '[data-area=crop].jodit-image-editor_active'
521
- ).length
522
- ).equals(1);
523
-
524
- const cropper = imageEditor.querySelector(
525
- '.jodit-image-editor__croper'
526
- );
527
-
528
- expect(cropper).not.is.null;
529
-
530
- const oldRatio =
531
- cropper.offsetWidth / cropper.offsetHeight;
532
- simulateEvent(
533
- 'mousedown',
534
- 0,
535
- cropper.querySelector('.jodit_bottomright'),
536
- function (e) {
537
- const pos =
538
- Jodit.modules.Helpers.offset(
539
- cropper,
540
- editor,
541
- editor.ownerDocument
542
- );
543
- e.clientX = pos.left + pos.width;
544
- e.clientY = pos.top + pos.height;
545
- }
546
- );
547
-
548
- simulateEvent(
549
- 'mousemove',
550
- 0,
551
- editor.ownerWindow,
552
- function (e) {
553
- const pos =
554
- Jodit.modules.Helpers.offset(
555
- cropper,
556
- editor,
557
- editor.ownerDocument
558
- );
559
- e.clientX = pos.left + pos.width - 50;
560
- e.clientY = pos.top + pos.height - 150;
561
- }
562
- );
563
-
564
- simulateEvent(
565
- 'mouseup',
566
- 0,
567
- editor.ownerWindow,
568
- function (e) {
569
- const pos =
570
- Jodit.modules.Helpers.offset(
571
- cropper,
572
- editor,
573
- editor.ownerDocument
574
- );
575
- e.clientX = pos.left + pos.width - 50;
576
- e.clientY = pos.top + pos.height - 150;
577
- }
578
- );
579
-
580
- expect(
581
- Math.abs(
582
- cropper.offsetWidth /
583
- cropper.offsetHeight -
584
- oldRatio
585
- ) < 0.02
586
- ).is.true;
587
-
588
- done();
589
- }
590
- );
591
-
592
- simulateEvent(
593
- 'click',
594
- 0,
595
- dialog.querySelector('[data-ref="editImage"]')
596
- );
597
- }).timeout(7000);
598
- });
599
-
600
- describe('Disable ratio', function () {
601
- it('Should allow crop image without ratio', function (done) {
602
- const area = appendTestArea();
603
-
604
- const editor = new Jodit(area, {
605
- observer: {
606
- timeout: 0
607
- },
608
- uploader: {
609
- url: 'https://xdsoft.net/jodit/connector/index.php?action=upload'
610
- },
611
- filebrowser: {
612
- ajax: {
613
- url: 'https://xdsoft.net/jodit/connector/index.php'
614
- }
615
- }
616
- });
617
-
618
- editor.value =
619
- '<img alt="" src="https://xdsoft.net/jodit/files/th.jpg">';
620
-
621
- simulateEvent(
622
- 'dblclick',
623
- editor.editor.querySelector('img')
624
- );
625
-
626
- const dialog = getOpenedDialog(editor);
627
-
628
- expect(dialog).is.not.null;
629
- expect(
630
- dialog.querySelectorAll('[data-ref="editImage"]')
631
- .length
632
- ).equals(1);
633
-
634
- editor.filebrowser.events.on(
635
- 'afterImageEditor',
636
- function () {
637
- const imageEditor = getOpenedDialog(editor);
638
-
639
- expect(imageEditor).is.not.null;
640
-
641
- expect(
642
- imageEditor.querySelectorAll(
643
- '[data-area=crop]'
644
- ).length
645
- ).equals(1);
646
-
647
- expect(
648
- imageEditor.querySelectorAll(
649
- '[data-area=crop].jodit-image-editor_active'
650
- ).length
651
- ).equals(0);
652
-
653
- simulateEvent(
654
- 'click',
655
- imageEditor.querySelector(
656
- '[data-area=crop] > div'
657
- )
658
- );
659
-
660
- expect(
661
- imageEditor.querySelectorAll(
662
- '[data-area=crop].jodit-image-editor_active'
663
- ).length
664
- ).equals(1);
665
-
666
- const cropper = imageEditor.querySelector(
667
- '.jodit-image-editor__croper'
668
- );
669
-
670
- expect(cropper).not.is.null;
671
-
672
- const oldRatio =
673
- cropper.offsetWidth / cropper.offsetHeight;
674
-
675
- const disableRatioBtn = imageEditor
676
- .querySelector(
677
- '[data-area=crop].jodit-image-editor_active'
678
- )
679
- .querySelector('.jodi-switcher input');
680
-
681
- expect(disableRatioBtn).not.is.null;
682
- disableRatioBtn.checked = false;
683
- simulateEvent('change', disableRatioBtn);
684
-
685
- simulateEvent(
686
- 'mousedown',
687
- cropper.querySelector('.jodit_bottomright'),
688
- function (e) {
689
- const pos =
690
- Jodit.modules.Helpers.offset(
691
- cropper,
692
- editor,
693
- editor.ownerDocument
694
- );
695
- e.clientX = pos.left + pos.width;
696
- e.clientY = pos.top + pos.height;
697
- }
698
- );
699
-
700
- simulateEvent(
701
- 'mousemove',
702
- editor.ownerWindow,
703
- function (e) {
704
- const pos =
705
- Jodit.modules.Helpers.offset(
706
- cropper,
707
- editor,
708
- editor.ownerDocument
709
- );
710
- e.clientX = pos.left + pos.width - 50;
711
- e.clientY = pos.top + pos.height - 150;
712
- }
713
- );
714
-
715
- simulateEvent(
716
- 'mouseup',
717
- editor.ownerWindow,
718
- function (e) {
719
- const pos =
720
- Jodit.modules.Helpers.offset(
721
- cropper,
722
- editor,
723
- editor.ownerDocument
724
- );
725
- e.clientX = pos.left + pos.width - 50;
726
- e.clientY = pos.top + pos.height - 150;
727
- }
728
- );
729
-
730
- expect(
731
- Math.abs(
732
- cropper.offsetWidth /
733
- cropper.offsetHeight -
734
- oldRatio
735
- ) > 1
736
- ).is.true;
737
-
738
- done();
739
- }
740
- );
741
-
742
- simulateEvent(
743
- 'click',
744
- 0,
745
- dialog.querySelector('[data-ref="editImage"]')
746
- );
747
- }).timeout(7000);
748
- });
749
- });
750
-
751
- describe('Resize mode', function () {
752
- describe('Enable ratio', function () {
753
- it('Should deny resize image without ratio', function (done) {
754
- const area = appendTestArea();
755
- const editor = new Jodit(area, {
756
- observer: {
757
- timeout: 0
758
- },
759
- uploader: {
760
- url: 'https://xdsoft.net/jodit/connector/index.php?action=upload'
761
- },
762
- filebrowser: {
763
- ajax: {
764
- url: 'https://xdsoft.net/jodit/connector/index.php'
765
- }
766
- }
767
- });
768
-
769
- editor.value = '<img src="tests/artio.jpg">';
770
-
771
- simulateEvent(
772
- 'dblclick',
773
- 0,
774
- editor.editor.querySelector('img')
775
- );
776
-
777
- const dialog = getOpenedDialog(editor);
778
-
779
- editor.filebrowser.events.on(
780
- 'afterImageEditor',
781
- function () {
782
- const imageEditor = getOpenedDialog(editor);
783
- expect(imageEditor).is.not.null;
784
-
785
- expect(
786
- imageEditor.querySelectorAll(
787
- '[data-area=resize]'
788
- ).length
789
- ).equals(1);
790
- expect(
791
- imageEditor.querySelectorAll(
792
- '[data-area=resize].jodit-image-editor_active'
793
- ).length
794
- ).equals(1); // default mode
795
-
796
- simulateEvent(
797
- 'click',
798
- 0,
799
- imageEditor.querySelector(
800
- '[data-area=resize] > div'
801
- )
802
- );
803
-
804
- expect(
805
- imageEditor.querySelectorAll(
806
- '[data-area=resize].jodit-image-editor_active'
807
- ).length
808
- ).equals(1);
809
-
810
- const resizer = imageEditor.querySelector(
811
- '.jodit-image-editor__resizer'
812
- );
813
-
814
- expect(resizer).not.is.null;
815
-
816
- const oldRatio =
817
- resizer.offsetWidth / resizer.offsetHeight;
818
-
819
- simulateEvent(
820
- 'mousedown',
821
- 0,
822
- resizer.querySelector('.jodit_bottomright'),
823
- function (e) {
824
- const pos =
825
- Jodit.modules.Helpers.offset(
826
- resizer,
827
- editor,
828
- editor.ownerDocument
829
- );
830
- e.clientX = pos.left + pos.width;
831
- e.clientY = pos.top + pos.height;
832
- }
833
- );
834
-
835
- simulateEvent(
836
- 'mousemove',
837
- 0,
838
- editor.ownerWindow,
839
- function (e) {
840
- const pos =
841
- Jodit.modules.Helpers.offset(
842
- resizer,
843
- editor,
844
- editor.ownerDocument
845
- );
846
- e.clientX = pos.left + pos.width - 250;
847
- e.clientY = pos.top + pos.height - 150;
848
- }
849
- );
850
-
851
- simulateEvent(
852
- 'mouseup',
853
- 0,
854
- editor.ownerWindow,
855
- function (e) {
856
- const pos =
857
- Jodit.modules.Helpers.offset(
858
- resizer,
859
- editor,
860
- editor.ownerDocument
861
- );
862
- e.clientX = pos.left + pos.width - 250;
863
- e.clientY = pos.top + pos.height - 150;
864
- }
865
- );
866
-
867
- expect(
868
- Math.abs(
869
- resizer.offsetWidth /
870
- resizer.offsetHeight -
871
- oldRatio
872
- ) < 0.05
873
- ).is.true;
874
-
875
- done();
876
- }
877
- );
878
-
879
- simulateEvent(
880
- 'click',
881
- 0,
882
- dialog.querySelector('[data-ref="editImage"]')
883
- );
884
- }).timeout(7000);
885
- });
886
-
887
- describe('Disable ratio', function () {
888
- it('Should allow resize image without ratio', function (done) {
889
- const area = appendTestArea();
890
- const editor = new Jodit(area, {
891
- observer: {
892
- timeout: 0
893
- },
894
- uploader: {
895
- url: 'https://xdsoft.net/jodit/connector/index.php?action=upload'
896
- },
897
- filebrowser: {
898
- ajax: {
899
- url: 'https://xdsoft.net/jodit/connector/index.php'
900
- }
901
- }
902
- });
903
- editor.value = '<img src="tests/artio.jpg">';
904
-
905
- simulateEvent(
906
- 'dblclick',
907
- editor.editor.querySelector('img')
908
- );
909
-
910
- const dialog = getOpenedDialog(editor);
911
-
912
- editor.filebrowser.events.on(
913
- 'afterImageEditor',
914
- function () {
915
- const imageEditor = getOpenedDialog(editor);
916
- expect(imageEditor).is.not.null;
917
-
918
- expect(
919
- imageEditor.querySelectorAll(
920
- '[data-area=resize]'
921
- ).length
922
- ).equals(1);
923
- expect(
924
- imageEditor.querySelectorAll(
925
- '[data-area=resize].jodit-image-editor_active'
926
- ).length
927
- ).equals(1); // default mode
928
-
929
- simulateEvent(
930
- 'click',
931
- 0,
932
- imageEditor.querySelector(
933
- '[data-area=resize] > div'
934
- )
935
- );
936
-
937
- expect(
938
- imageEditor.querySelectorAll(
939
- '[data-area=resize].jodit-image-editor_active'
940
- ).length
941
- ).equals(1);
942
-
943
- const disableRatioBtn = imageEditor
944
- .querySelector(
945
- '[data-area=resize].jodit-image-editor_active'
946
- )
947
- .querySelector('.jodi-switcher input');
948
-
949
- expect(disableRatioBtn).not.is.null;
950
- disableRatioBtn.checked = false;
951
- simulateEvent('change', disableRatioBtn);
952
-
953
- const resizer = imageEditor.querySelector(
954
- '.jodit-image-editor__resizer'
955
- );
956
-
957
- expect(resizer).not.is.null;
958
-
959
- const oldRatio =
960
- resizer.offsetWidth / resizer.offsetHeight;
961
-
962
- simulateEvent(
963
- 'mousedown',
964
- resizer.querySelector('.jodit_bottomright'),
965
- function (e) {
966
- const pos =
967
- Jodit.modules.Helpers.offset(
968
- resizer,
969
- editor,
970
- editor.ownerDocument
971
- );
972
- e.clientX = pos.left + pos.width;
973
- e.clientY = pos.top + pos.height;
974
- }
975
- );
976
-
977
- simulateEvent(
978
- 'mousemove',
979
- editor.ownerWindow,
980
- function (e) {
981
- const pos =
982
- Jodit.modules.Helpers.offset(
983
- resizer,
984
- editor,
985
- editor.ownerDocument
986
- );
987
-
988
- e.clientX = pos.left + pos.width - 50;
989
- e.clientY = pos.top + pos.height - 150;
990
- }
991
- );
992
-
993
- simulateEvent(
994
- 'mouseup',
995
- editor.ownerWindow,
996
- function (e) {
997
- const pos =
998
- Jodit.modules.Helpers.offset(
999
- resizer,
1000
- editor,
1001
- editor.ownerDocument
1002
- );
1003
- e.clientX = pos.left + pos.width - 50;
1004
- e.clientY = pos.top + pos.height - 150;
1005
- }
1006
- );
1007
-
1008
- expect(
1009
- Math.abs(
1010
- resizer.offsetWidth /
1011
- resizer.offsetHeight -
1012
- oldRatio
1013
- ) > 1
1014
- ).is.true;
1015
-
1016
- done();
1017
- }
1018
- );
1019
-
1020
- simulateEvent(
1021
- 'click',
1022
- 0,
1023
- dialog.querySelector('[data-ref="editImage"]')
1024
- );
1025
- }).timeout(7000);
1026
- });
1027
- });
1028
- });
1029
- });
1030
-
1031
- describe('Indent plugin', function () {
1032
- it('Should set active outdent button if current container has marginLeft', function () {
1033
- const area = appendTestArea();
1034
- const editor = new Jodit(area, {
1035
- toolbarAdaptive: false,
1036
- buttons: 'indent,outdent'
1037
- });
1038
-
1039
- editor.value = '<p>text</p>';
1040
- editor.s.setCursorIn(editor.editor.firstChild.firstChild);
1041
-
1042
- simulateEvent('mousedown', 0, editor.editor.firstChild);
1043
-
1044
- expect(getButton('outdent', editor).hasAttribute('disabled')).is
1045
- .true;
1046
-
1047
- editor.editor.firstChild.style.marginLeft = '100px';
1048
- simulateEvent('mousedown', 0, editor.editor.firstChild);
1049
- expect(getButton('outdent', editor).hasAttribute('disabled')).is
1050
- .false;
1051
- });
1052
-
1053
- describe('Press Indent button', function () {
1054
- it('Should increase indent for current blocks', function () {
1055
- const area = appendTestArea();
1056
- const editor = new Jodit(area, {
1057
- toolbarAdaptive: false,
1058
- buttons: 'indent,outdent',
1059
- indentMargin: 5
1060
- });
1061
-
1062
- editor.value = '<h1>test</h1><p>text</p><p>text</p>';
1063
-
1064
- const range = editor.s.createRange();
1065
-
1066
- range.setStartBefore(editor.editor.firstChild);
1067
- range.setEndAfter(editor.editor.firstChild.nextSibling);
1068
- editor.s.selectRange(range);
1069
-
1070
- clickButton('indent', editor);
1071
- clickButton('indent', editor);
1072
- clickButton('indent', editor);
1073
-
1074
- expect(
1075
- '<h1 style="margin-left: 15px;">test</h1><p style="margin-left: 15px;">text</p><p>text</p>'
1076
- ).equals(editor.value);
1077
-
1078
- clickButton('outdent', editor);
1079
- clickButton('outdent', editor);
1080
- clickButton('outdent', editor);
1081
-
1082
- expect('<h1>test</h1><p>text</p><p>text</p>').equals(
1083
- editor.value
1084
- );
1085
- });
1086
- });
1087
-
1088
- describe('Run indent command for inline elements', function () {
1089
- it('should wrap elements in block and change margin for it', function () {
1090
- const area = appendTestArea();
1091
- const editor = new Jodit(area);
1092
- editor.value = '<p>a<br>b<br>c<br></p>';
1093
- editor.s.setCursorAfter(editor.editor.firstChild.lastChild);
1094
- editor.execCommand('indent');
1095
- expect(sortAttributes(editor.value)).equals(
1096
- '<p style="margin-left:10px">a<br>b<br>c<br></p>'
1097
- );
1098
- });
1099
- });
1100
- });
1101
-
1102
- describe('Symbols plugin', function () {
1103
- it('Should create symbol button in toolbar and after click open dialog with symbols', function () {
1104
- const area = appendTestArea();
1105
- const editor = new Jodit(area, {
1106
- toolbarAdaptive: false,
1107
- buttons: 'symbol'
1108
- });
1109
- editor.value = 'test';
1110
-
1111
- const btn = getButton('symbol', editor);
1112
- expect(null).does.not.equal(btn);
1113
-
1114
- simulateEvent('click', 0, btn);
1115
- const dialog = getOpenedDialog(editor);
1116
- expect(null).does.not.equal(dialog);
1117
- });
1118
-
1119
- describe('Symbols dialog', function () {
1120
- it('Should have focus on first element after open', function () {
1121
- const area = appendTestArea();
1122
- const editor = new Jodit(area, {
1123
- toolbarAdaptive: false,
1124
- buttons: 'symbol'
1125
- });
1126
- editor.value = 'test';
1127
-
1128
- const btn = getButton('symbol', editor);
1129
- expect(null).does.not.equal(btn);
1130
-
1131
- simulateEvent('click', 0, btn);
1132
- const dialog = getOpenedDialog(editor);
1133
- expect(null).does.not.equal(dialog);
1134
-
1135
- expect(dialog.querySelector('a')).equals(
1136
- editor.ownerDocument.activeElement
1137
- );
1138
- });
1139
-
1140
- describe('Press key left', function () {
1141
- it('Should select previous element', function () {
1142
- const area = appendTestArea();
1143
- const editor = new Jodit(area, {
1144
- toolbarAdaptive: false,
1145
- buttons: 'symbol'
1146
- });
1147
- editor.value = 'test';
1148
-
1149
- const btn = getButton('symbol', editor);
1150
-
1151
- simulateEvent('click', 0, btn);
1152
- const dialog = getOpenedDialog(editor);
1153
-
1154
- expect(null).does.not.equal(dialog);
1155
-
1156
- const currentActive = dialog.getElementsByTagName('a')[10];
1157
-
1158
- simulateEvent(
1159
- 'keydown',
1160
- Jodit.KEY_LEFT,
1161
- currentActive,
1162
- function (data) {
1163
- data.target = currentActive;
1164
- }
1165
- );
1166
-
1167
- expect(editor.ownerDocument.activeElement).equals(
1168
- dialog.getElementsByTagName('a')[9]
1169
- );
1170
- });
1171
- });
1172
-
1173
- describe('Press key right', function () {
1174
- it('Should select next element', function () {
1175
- const area = appendTestArea();
1176
- const editor = new Jodit(area, {
1177
- toolbarAdaptive: false,
1178
- buttons: 'symbol'
1179
- });
1180
- editor.value = 'test';
1181
-
1182
- const btn = getButton('symbol', editor);
1183
-
1184
- simulateEvent('click', 0, btn);
1185
- const dialog = getOpenedDialog(editor);
1186
-
1187
- expect(null).does.not.equal(dialog);
1188
-
1189
- const currentActive = dialog.getElementsByTagName('a')[10];
1190
-
1191
- simulateEvent(
1192
- 'keydown',
1193
- Jodit.KEY_RIGHT,
1194
- currentActive,
1195
- function (data) {
1196
- data.target = currentActive;
1197
- }
1198
- );
1199
-
1200
- expect(editor.ownerDocument.activeElement).equals(
1201
- dialog.getElementsByTagName('a')[11]
1202
- );
1203
- });
1204
- });
1205
- describe('Press key top', function () {
1206
- it('Should select element above', function () {
1207
- const area = appendTestArea();
1208
-
1209
- const editor = new Jodit(area, {
1210
- toolbarAdaptive: false,
1211
- buttons: 'symbol'
1212
- });
1213
-
1214
- editor.value = 'test';
1215
-
1216
- const btn = getButton('symbol', editor);
1217
-
1218
- simulateEvent('click', 0, btn);
1219
- const dialog = getOpenedDialog(editor);
1220
-
1221
- expect(null).does.not.equal(dialog);
1222
-
1223
- let currentActive = dialog.getElementsByTagName('a')[30];
1224
-
1225
- simulateEvent(
1226
- 'keydown',
1227
- Jodit.KEY_UP,
1228
- currentActive,
1229
- function (data) {
1230
- data.target = currentActive;
1231
- }
1232
- );
1233
-
1234
- expect(editor.ownerDocument.activeElement).equals(
1235
- dialog.getElementsByTagName('a')[13]
1236
- );
1237
-
1238
- currentActive = dialog.getElementsByTagName('a')[10];
1239
-
1240
- simulateEvent(
1241
- 'keydown',
1242
- Jodit.KEY_UP,
1243
- currentActive,
1244
- function (data) {
1245
- data.target = currentActive;
1246
- }
1247
- );
1248
-
1249
- expect(editor.ownerDocument.activeElement).equals(
1250
- dialog.getElementsByTagName('a')[197]
1251
- );
1252
- });
1253
- });
1254
-
1255
- describe('Press key bottom', function () {
1256
- it('Should select element below', function () {
1257
- const area = appendTestArea();
1258
- const editor = new Jodit(area, {
1259
- toolbarAdaptive: false,
1260
- buttons: 'symbol'
1261
- });
1262
- editor.value = 'test';
1263
-
1264
- const btn = getButton('symbol', editor);
1265
-
1266
- simulateEvent('click', 0, btn);
1267
- const dialog = getOpenedDialog(editor);
1268
-
1269
- expect(null).does.not.equal(dialog);
1270
-
1271
- let currentActive = dialog.getElementsByTagName('a')[30];
1272
-
1273
- simulateEvent(
1274
- 'keydown',
1275
- Jodit.KEY_DOWN,
1276
- currentActive,
1277
- function (data) {
1278
- data.target = currentActive;
1279
- }
1280
- );
1281
-
1282
- expect(editor.ownerDocument.activeElement).equals(
1283
- dialog.getElementsByTagName('a')[47]
1284
- );
1285
-
1286
- currentActive = dialog.getElementsByTagName('a')[200];
1287
-
1288
- simulateEvent(
1289
- 'keydown',
1290
- Jodit.KEY_DOWN,
1291
- currentActive,
1292
- function (data) {
1293
- data.target = currentActive;
1294
- }
1295
- );
1296
-
1297
- expect(editor.ownerDocument.activeElement).equals(
1298
- dialog.getElementsByTagName('a')[13]
1299
- );
1300
- });
1301
- });
1302
-
1303
- describe('Press Enter or mousdown on element', function () {
1304
- it('Should insert character', function () {
1305
- const area = appendTestArea();
1306
- const editor = new Jodit(area, {
1307
- toolbarAdaptive: false,
1308
- buttons: 'symbol'
1309
- });
1310
-
1311
- editor.value = '';
1312
-
1313
- const btn = getButton('symbol', editor);
1314
-
1315
- simulateEvent('click', 0, btn);
1316
- let dialog = getOpenedDialog(editor);
1317
-
1318
- expect(dialog).is.not.null;
1319
-
1320
- const currentActive = dialog.getElementsByTagName('a')[5];
1321
-
1322
- simulateEvent('keydown', Jodit.KEY_ENTER, currentActive);
1323
-
1324
- expect(editor.value).equals('<p>&amp;</p>');
1325
-
1326
- simulateEvent('click', 0, btn);
1327
- dialog = getOpenedDialog(editor);
1328
-
1329
- expect(dialog).is.not.null;
1330
-
1331
- const currentActive2 =
1332
- dialog.getElementsByTagName('a')[125];
1333
-
1334
- simulateEvent('mousedown', 0, currentActive2);
1335
-
1336
- expect(editor.value).equals('<p>&amp;½</p>');
1337
- });
1338
- });
1339
- });
1340
-
1341
- describe('Symbols popup', function () {
1342
- it('Should create popup this symbols', function () {
1343
- const area = appendTestArea();
1344
- const editor = new Jodit(area, {
1345
- toolbarAdaptive: false,
1346
- buttons: 'symbol',
1347
- usePopupForSpecialCharacters: true
1348
- });
1349
-
1350
- editor.value = 'test';
1351
-
1352
- const range = editor.s.createRange(true);
1353
- range.setStart(editor.editor.firstChild, 0);
1354
- range.collapse(true);
1355
-
1356
- const btn = getButton('symbol', editor);
1357
-
1358
- simulateEvent('click', 0, btn);
1359
- const dialog = getOpenedDialog(editor);
1360
-
1361
- expect(null).equals(dialog);
1362
-
1363
- const popup = getOpenedPopup(editor);
1364
- expect(null).does.not.equal(popup);
1365
-
1366
- const currentActive = popup.getElementsByTagName('a')[125];
1367
-
1368
- simulateEvent('mousedown', 0, currentActive);
1369
-
1370
- expect(editor.value).equals('<p>½test</p>');
1371
- expect(popup.parentNode).is.null;
1372
- });
1373
- });
1374
- });
1375
-
1376
- describe('Hotkeys', function () {
1377
- describe('Override default shortcuts for some commands', function () {
1378
- it('Should work default shortcuts for another commands', function () {
1379
- const area = appendTestArea(),
1380
- editor = new Jodit(area, {
1381
- commandToHotkeys: {
1382
- bold: 'ctrl+shift+b',
1383
- italic: ['ctrl+i', 'ctrl+shift+i']
1384
- }
1385
- });
1386
-
1387
- editor.value = 'test test test';
1388
-
1389
- const range = editor.s.createRange(true);
1390
- range.setStart(editor.editor.firstChild.firstChild, 4);
1391
- range.setEnd(editor.editor.firstChild.firstChild, 8);
1392
-
1393
- // standart ctrl+u
1394
- simulateEvent('keydown', 85, editor.editor, function (data) {
1395
- // data.shiftKey = true;
1396
- data.ctrlKey = true;
1397
- });
1398
-
1399
- expect(editor.value).equals('<p>test<u> tes</u>t test</p>');
1400
- });
1401
- describe('Replace ctrl+b to ctrl+shift+b for bold command', function () {
1402
- it('Should not execute bold on ctrl+b', function () {
1403
- const area = appendTestArea(),
1404
- editor = new Jodit(area, {
1405
- commandToHotkeys: {
1406
- bold: 'ctrl+shift+b',
1407
- italic: ['ctrl+i', 'ctrl+shift+i']
1408
- }
1409
- });
1410
-
1411
- editor.value = 'test test test';
1412
-
1413
- const range = editor.s.createRange(true);
1414
- range.setStart(editor.editor.firstChild.firstChild, 4);
1415
- range.setEnd(editor.editor.firstChild.firstChild, 8);
1416
-
1417
- // standart ctrl+b
1418
- simulateEvent(
1419
- 'keydown',
1420
- 66,
1421
- editor.editor,
1422
- function (data) {
1423
- // data.shiftKey = true;
1424
- data.ctrlKey = true;
1425
- }
1426
- );
1427
-
1428
- expect(editor.value).equals('<p>test test test</p>'); // should not sork
1429
-
1430
- simulateEvent(
1431
- 'keydown',
1432
- 66,
1433
- editor.editor,
1434
- function (data) {
1435
- data.shiftKey = true;
1436
- data.ctrlKey = true;
1437
- }
1438
- );
1439
-
1440
- expect(editor.value).equals(
1441
- '<p>test<strong> tes</strong>t test</p>'
1442
- );
1443
- });
1444
-
1445
- it('Should execute bold on ctrl+shift+b', function () {
1446
- const area = appendTestArea(),
1447
- editor = new Jodit(area, {
1448
- commandToHotkeys: {
1449
- bold: 'ctrl+shift+b',
1450
- italic: ['ctrl+i', 'ctrl+shift+i']
1451
- }
1452
- });
1453
-
1454
- editor.value = 'test test test';
1455
-
1456
- const range = editor.s.createRange(true);
1457
- range.setStart(editor.editor.firstChild.firstChild, 4);
1458
- range.setEnd(editor.editor.firstChild.firstChild, 8);
1459
-
1460
- simulateEvent(
1461
- 'keydown',
1462
- 66,
1463
- editor.editor,
1464
- function (data) {
1465
- data.shiftKey = true;
1466
- data.ctrlKey = true;
1467
- }
1468
- );
1469
-
1470
- expect(editor.value).equals(
1471
- '<p>test<strong> tes</strong>t test</p>'
1472
- );
1473
- });
1474
- });
1475
-
1476
- describe('Add ctrl+shift+i to default ctrl+i shortcut for italic command', function () {
1477
- it('Should work with each of shortcuts', function () {
1478
- const area = appendTestArea(),
1479
- editor = new Jodit(area, {
1480
- commandToHotkeys: {
1481
- bold: 'ctrl+shift+b',
1482
- italic: ['ctrl+i', 'ctrl+shift+i']
1483
- }
1484
- });
1485
-
1486
- editor.value = '<p>test| tes|t test</p>';
1487
- setCursorToChar(editor);
1488
-
1489
- // standart ctrl+i
1490
- simulateEvent(
1491
- 'keydown',
1492
- 'i',
1493
- editor.editor,
1494
- function (data) {
1495
- // data.shiftKey = true;
1496
- data.ctrlKey = true;
1497
- }
1498
- );
1499
-
1500
- expect(editor.value).equals(
1501
- '<p>test<em> tes</em>t test</p>'
1502
- );
1503
-
1504
- editor.value = '<p>test| tes|t test</p>';
1505
- setCursorToChar(editor);
1506
-
1507
- // standart ctrl+shift+i
1508
- simulateEvent(
1509
- 'keydown',
1510
- 'i',
1511
- editor.editor,
1512
- function (data) {
1513
- data.shiftKey = true;
1514
- data.ctrlKey = true;
1515
- }
1516
- );
1517
-
1518
- expect(editor.value).equals(
1519
- '<p>test<em> tes</em>t test</p>'
1520
- );
1521
-
1522
- // standart ctrl+shift+7
1523
- simulateEvent(
1524
- 'keydown',
1525
- '7',
1526
- editor.editor,
1527
- function (data) {
1528
- data.shiftKey = true;
1529
- data.ctrlKey = true;
1530
- }
1531
- );
1532
-
1533
- expect(editor.value.replace('<br>', '')).equals(
1534
- '<ol><li>test<em> tes</em>t test</li></ol>'
1535
- );
1536
- });
1537
- });
1538
- });
1539
- });
1540
-
1541
- describe('Sticky plugin', function () {
1542
- describe('Without scrolling', function () {
1543
- it('Should not have `jodit_sticky` class and toolbar must be in normal state', function () {
1544
- const area = appendTestArea(),
1545
- editor = new Jodit(area);
1546
-
1547
- editor.value = '<p>stop</p>'.repeat(100);
1548
- expect(false).equals(
1549
- editor.container.classList.contains('jodit_sticky')
1550
- );
1551
- });
1552
- });
1553
-
1554
- describe('Create editor in page with long text', function () {
1555
- describe('and scroll page to bottom', function () {
1556
- it('Should add to editor class `jodit_sticky` and toolbar must be always on the top', function () {
1557
- const editor = getJodit();
1558
-
1559
- editor.value = '<p>stop</p>'.repeat(100);
1560
-
1561
- const offset = Jodit.modules.Helpers.offset(
1562
- editor.container,
1563
- editor,
1564
- editor.ownerDocument
1565
- );
1566
-
1567
- window.scroll(0, offset.top + offset.height / 2); // scroll page to bottom
1568
-
1569
- simulateEvent('scroll', 0, window);
1570
-
1571
- expect(true).equals(
1572
- editor.container.classList.contains('jodit_sticky')
1573
- );
1574
-
1575
- expect(0).equals(
1576
- editor.toolbar.container.getBoundingClientRect().top
1577
- );
1578
- });
1579
-
1580
- describe('On mobile devices - with toolbarDisableStickyForMobile = true', function () {
1581
- it('Should not add to editor class `jodit_sticky`', function () {
1582
- getBox().style.width = '370px'; // IPhone 7
1583
-
1584
- const area = appendTestArea(),
1585
- editor = new Jodit(area);
1586
-
1587
- editor.value = '<p>stop</p>'.repeat(100);
1588
- const offset = Jodit.modules.Helpers.offset(
1589
- editor.container,
1590
- editor,
1591
- editor.ownerDocument
1592
- );
1593
-
1594
- window.scroll(0, offset.top + offset.height / 2); // scroll page to bottom
1595
- simulateEvent('scroll', 0, window);
1596
-
1597
- expect(false).equals(
1598
- editor.container.classList.contains('jodit_sticky')
1599
- );
1600
- expect(0).does.not.equal(
1601
- editor.toolbar.container.getBoundingClientRect().top
1602
- );
1603
- getBox().style.width = 'auto'; // IPhone 7
1604
- });
1605
- });
1606
-
1607
- describe('In iframe mode', function () {
1608
- it('Should work some way', function () {
1609
- const editor = getJodit({
1610
- iframe: true
1611
- });
1612
-
1613
- editor.value = '<p>stop</p>'.repeat(100);
1614
- const offset = Jodit.modules.Helpers.offset(
1615
- editor.container,
1616
- editor,
1617
- editor.ownerDocument
1618
- );
1619
-
1620
- window.scroll(0, offset.top + offset.height / 2); // scroll page to bottom
1621
- simulateEvent('scroll', 0, window);
1622
-
1623
- expect(true).equals(
1624
- editor.container.classList.contains('jodit_sticky')
1625
- );
1626
- expect(0).equals(
1627
- editor.toolbar.container.getBoundingClientRect().top
1628
- );
1629
- });
1630
- });
1631
-
1632
- describe('add offset for toolbar', function () {
1633
- it('Should add offset for sticky toolbar', function () {
1634
- const area = appendTestArea(),
1635
- editor = new Jodit(area, {
1636
- toolbarStickyOffset: 100
1637
- });
1638
-
1639
- editor.value = '<p>stop</p>'.repeat(100);
1640
- const offset = Jodit.modules.Helpers.offset(
1641
- editor.container,
1642
- editor,
1643
- editor.ownerDocument
1644
- );
1645
-
1646
- window.scroll(0, offset.top + offset.height / 2); // scroll page to bottom
1647
- simulateEvent('scroll', 0, window);
1648
-
1649
- expect(true).equals(
1650
- editor.container.classList.contains('jodit_sticky')
1651
- );
1652
- expect(100).equals(
1653
- editor.toolbar.container.getBoundingClientRect().top
1654
- );
1655
- });
1656
- });
1657
-
1658
- describe('with toolbarSticky false', function () {
1659
- it('Should do nothing with toolbar', function () {
1660
- const area = appendTestArea(),
1661
- editor = new Jodit(area, {
1662
- toolbarStickyOffset: 100,
1663
- toolbarSticky: false
1664
- });
1665
-
1666
- editor.value = '<p>stop</p>'.repeat(100);
1667
- const offset = Jodit.modules.Helpers.offset(
1668
- editor.container,
1669
- editor,
1670
- editor.ownerDocument
1671
- );
1672
-
1673
- window.scroll(0, offset.top + offset.height / 2); // scroll page to bottom
1674
- simulateEvent('scroll', 0, window);
1675
-
1676
- expect(false).equals(
1677
- editor.container.classList.contains('jodit_sticky')
1678
- );
1679
- expect(100).does.not.equal(
1680
- editor.toolbar.container.getBoundingClientRect().top
1681
- );
1682
- expect(0).does.not.equal(
1683
- editor.toolbar.container.getBoundingClientRect().top
1684
- );
1685
- });
1686
- });
1687
- });
1688
-
1689
- describe('and scroll page to the top', function () {
1690
- it('Should remove class `jodit_sticky` from editor and toolbar must have normal position', function () {
1691
- fillBoxBr(100);
1692
-
1693
- const area = appendTestArea(),
1694
- editor = new Jodit(area),
1695
- brs = [0, 0, 0, 0, 0, 0, 0, 0, 0].map(function () {
1696
- return editor.ownerDocument.createElement('br');
1697
- });
1698
-
1699
- brs.forEach(function (br) {
1700
- editor.container.parentNode.insertBefore(
1701
- br,
1702
- editor.container
1703
- );
1704
- });
1705
-
1706
- editor.value = '<p>stop</p>'.repeat(100);
1707
- const offset = Jodit.modules.Helpers.offset(
1708
- editor.container,
1709
- editor,
1710
- editor.ownerDocument
1711
- );
1712
-
1713
- window.scroll(0, offset.top - 200); // scroll page above editor
1714
- simulateEvent('scroll', 0, window);
1715
-
1716
- expect(false).equals(
1717
- editor.container.classList.contains('jodit_sticky')
1718
- );
1719
-
1720
- expect(5).to.be.above(
1721
- Math.abs(
1722
- 200 -
1723
- Jodit.modules.Helpers.position(
1724
- editor.toolbar.container
1725
- ).top
1726
- )
1727
- );
1728
-
1729
- brs.forEach(function (br) {
1730
- br.parentNode.removeChild(br);
1731
- });
1732
- });
1733
- });
1734
- });
1735
- });
1736
-
1737
- describe('Size plugin', function () {
1738
- describe('In iframe mode after change mode', function () {
1739
- it('Should set min-height to iframe', function () {
1740
- const editor = getJodit({
1741
- iframe: true,
1742
- minHeight: 300
1743
- });
1744
-
1745
- editor.value = '';
1746
-
1747
- editor.toggleMode();
1748
- editor.toggleMode();
1749
-
1750
- expect(editor.editor.offsetHeight).to.be.above(180);
1751
- });
1752
- });
1753
-
1754
- describe('Set height', function () {
1755
- it('Should set container height', function () {
1756
- const editor = getJodit({
1757
- height: 222
1758
- });
1759
-
1760
- expect(editor.container.offsetHeight).equals(222);
1761
- });
1762
- });
1763
- });
1764
-
1765
- describe('Fullsize plugin', function () {
1766
- describe('Toggle fullsize', function () {
1767
- it('Should resize all boxes to first state', function () {
1768
- const editor = getJodit({
1769
- observer: {
1770
- timeout: 0
1771
- }
1772
- });
1773
- const chacksizes = ['container', 'workplace', 'editor'];
1774
- const sizes = chacksizes.map(function (key) {
1775
- return editor[key].offsetHeight;
1776
- }),
1777
- equal = function (a, b) {
1778
- return Math.abs(a - b) <= 2;
1779
- };
1780
-
1781
- editor.toggleFullSize(true);
1782
- chacksizes.map(function (key, index) {
1783
- expect(
1784
- equal(editor[key].offsetHeight, sizes[index])
1785
- ).is.false;
1786
- });
1787
-
1788
- editor.toggleFullSize(false);
1789
-
1790
- chacksizes.map(function (key, index) {
1791
- expect(
1792
- equal(editor[key].offsetHeight, sizes[index])
1793
- ).is.true;
1794
- });
1795
- });
1796
- });
1797
- });
1798
-
1799
- describe('Path plugin', function () {
1800
- describe('After init', function () {
1801
- describe('With showXPathInStatusbar=true', function () {
1802
- it('Should show status bar', function () {
1803
- const editor = getJodit({
1804
- language: 'en',
1805
- showXPathInStatusbar: true,
1806
- showCharsCounter: false,
1807
- showWordsCounter: false,
1808
- observer: {
1809
- timeout: 0
1810
- }
1811
- });
1812
-
1813
- editor.value = '<p>Simple text</p>';
1814
-
1815
- const statusbar =
1816
- editor.container.querySelector('.jodit-status-bar');
1817
-
1818
- expect(
1819
- editor.ownerWindow.getComputedStyle(statusbar).display
1820
- ).equals('flex');
1821
- });
1822
-
1823
- it('Should show path to selection element', function () {
1824
- const editor = getJodit({
1825
- language: 'en',
1826
- showXPathInStatusbar: true,
1827
- observer: {
1828
- timeout: 0
1829
- }
1830
- });
1831
-
1832
- editor.value = '<p>Simple text <a href="#">sss</a></p>';
1833
- editor.s.setCursorIn(editor.editor.querySelector('a'));
1834
-
1835
- const statusbar = editor.container.querySelector(
1836
- '.jodit-status-bar .jodit-xpath'
1837
- );
1838
-
1839
- expect(statusbar).is.not.null;
1840
- expect(statusbar.firstChild.textContent.trim()).equals('');
1841
- expect(statusbar.childNodes[1].textContent).equals('p');
1842
- expect(statusbar.childNodes[2].textContent).equals('a');
1843
- });
1844
-
1845
- describe('After change selection', function () {
1846
- it('Should change path to selection element', function () {
1847
- const editor = getJodit({
1848
- language: 'en',
1849
- showXPathInStatusbar: true,
1850
- observer: {
1851
- timeout: 0
1852
- }
1853
- });
1854
-
1855
- editor.value =
1856
- '<p>Simple text <a href="#">sss</a><span>s</span></p>';
1857
- editor.s.setCursorIn(editor.editor.querySelector('a'));
1858
-
1859
- const statusbar = editor.container.querySelector(
1860
- '.jodit-status-bar .jodit-xpath'
1861
- );
1862
-
1863
- expect(statusbar).is.not.null;
1864
- expect(statusbar.firstChild.innerText).equals('');
1865
- expect(statusbar.childNodes[1].textContent).equals('p');
1866
- expect(statusbar.childNodes[2].textContent).equals('a');
1867
-
1868
- editor.s.setCursorIn(
1869
- editor.editor.querySelector('span')
1870
- );
1871
-
1872
- expect(statusbar.firstChild.innerText).equals('');
1873
- expect(statusbar.childNodes[1].textContent).equals('p');
1874
- expect(statusbar.childNodes[2].textContent).equals(
1875
- 'span'
1876
- );
1877
- });
1878
- });
1879
-
1880
- describe('After click on element of path', function () {
1881
- it('Should select this element', function () {
1882
- const editor = getJodit({
1883
- language: 'en',
1884
- showXPathInStatusbar: true,
1885
- observer: {
1886
- timeout: 0
1887
- }
1888
- });
1889
-
1890
- editor.value =
1891
- '<p>Simple text <a href="#">sss</a><span>s</span></p>';
1892
- editor.s.setCursorIn(editor.editor.querySelector('a'));
1893
-
1894
- const statusbar = editor.container.querySelector(
1895
- '.jodit-status-bar .jodit-xpath'
1896
- );
1897
-
1898
- expect(statusbar).is.not.null;
1899
- expect(statusbar.firstChild.innerText).equals('');
1900
- expect(statusbar.childNodes[1].textContent).equals('p');
1901
- expect(statusbar.childNodes[2].textContent).equals('a');
1902
-
1903
- simulateEvent(
1904
- 'click',
1905
- 0,
1906
- statusbar.childNodes[2].firstChild
1907
- ); // click on A
1908
-
1909
- expect(
1910
- Jodit.modules.Helpers.trim(editor.s.sel.toString())
1911
- ).equals('sss');
1912
- expect(statusbar.childNodes[2].textContent).equals('a');
1913
-
1914
- simulateEvent(
1915
- 'click',
1916
- 0,
1917
- statusbar.childNodes[1].firstChild
1918
- ); // click on P
1919
-
1920
- expect(
1921
- Jodit.modules.Helpers.trim(editor.s.sel.toString())
1922
- ).equals('Simple text ssss');
1923
- expect(statusbar.childNodes.length).equals(3);
1924
- });
1925
- });
1926
-
1927
- describe('Context menu on element of path', function () {
1928
- it('Should open context menu', function () {
1929
- const editor = getJodit({
1930
- language: 'en',
1931
- showXPathInStatusbar: true,
1932
- observer: {
1933
- timeout: 0
1934
- }
1935
- });
1936
-
1937
- editor.value =
1938
- '<p>Simple text <a href="#">sss</a><span>s</span></p>';
1939
-
1940
- editor.s.setCursorIn(editor.editor.querySelector('a'));
1941
-
1942
- const statusbar = editor.container.querySelector(
1943
- '.jodit-status-bar .jodit-xpath'
1944
- );
1945
-
1946
- expect(statusbar).is.not.null;
1947
- expect(statusbar.firstChild.innerText).equals('');
1948
- expect(statusbar.childNodes[1].textContent).equals('p');
1949
- expect(statusbar.childNodes[2].textContent).equals('a');
1950
-
1951
- const elm = statusbar.childNodes[2].querySelector('a'),
1952
- pos = Jodit.modules.Helpers.position(elm);
1953
-
1954
- simulateEvent('contextmenu', 0, elm, function (o) {
1955
- Object.assign(o, {
1956
- clientX: pos.left + 10,
1957
- clientY: pos.top + 10
1958
- });
1959
- });
1960
-
1961
- const context = getOpenedPopup(editor);
1962
-
1963
- expect(context).is.not.null;
1964
- expect(
1965
- editor.ownerWindow.getComputedStyle(context).display
1966
- ).equals('block');
1967
-
1968
- simulateEvent(
1969
- 'click',
1970
- 0,
1971
- context.querySelector('button')
1972
- );
1973
- expect(editor.value).equals(
1974
- '<p>Simple text <span>s</span></p>'
1975
- );
1976
-
1977
- expect(context.parentNode).is.null;
1978
- });
1979
- });
1980
- });
1981
- });
1982
- });
1983
-
1984
- describe('Paste storage', function () {
1985
- describe('Empty list', function () {
1986
- it('Sholud not show dialog', function () {
1987
- const editor = getJodit();
1988
-
1989
- simulateEvent('keydown', 'v', editor.editor, function (data) {
1990
- data.ctrlKey = true;
1991
- data.shiftKey = true;
1992
- });
1993
-
1994
- const dialog = getOpenedDialog(editor);
1995
- expect(dialog).is.null;
1996
- });
1997
- });
1998
-
1999
- describe('After copy elements', function () {
2000
- it('Sholud show dialog with pasted list', function () {
2001
- const editor = getJodit({
2002
- observer: {
2003
- timeout: 0
2004
- }
2005
- });
2006
-
2007
- editor.s.focus();
2008
- editor.value = 'abcde';
2009
- const range = editor.ownerDocument.createRange();
2010
-
2011
- range.setStart(editor.editor.firstChild, 0);
2012
- range.setEnd(editor.editor.firstChild, 1);
2013
- editor.s.selectRange(range);
2014
-
2015
- simulateEvent('copy', 0, editor.editor, function (data) {
2016
- Object.defineProperty(data, 'clipboardData', {
2017
- value: {
2018
- getData: function () {},
2019
- setData: function () {}
2020
- }
2021
- });
2022
- });
2023
-
2024
- range.setStart(editor.editor.firstChild.firstChild, 1);
2025
- range.setEnd(editor.editor.firstChild.firstChild, 2);
2026
- editor.s.selectRange(range);
2027
-
2028
- simulateEvent('copy', 0, editor.editor, function (data) {
2029
- Object.defineProperty(data, 'clipboardData', {
2030
- value: {
2031
- getData: function () {},
2032
- setData: function () {}
2033
- }
2034
- });
2035
- });
2036
-
2037
- simulateEvent('keydown', 'v', editor.editor, function (data) {
2038
- data.ctrlKey = true;
2039
- data.shiftKey = true;
2040
- });
2041
-
2042
- const dialog = getOpenedDialog(editor);
2043
- expect(dialog).is.not.null;
2044
- });
2045
-
2046
- describe('After click on some of elements', function () {
2047
- it('Sholud select this', function () {
2048
- const editor = getJodit();
2049
-
2050
- editor.value = 'abcde';
2051
- const range = editor.ownerDocument.createRange();
2052
-
2053
- range.setStart(editor.editor.firstChild.firstChild, 0);
2054
- range.setEnd(editor.editor.firstChild.firstChild, 1);
2055
- editor.s.selectRange(range);
2056
-
2057
- simulateEvent('copy', 0, editor.editor, function (data) {
2058
- Object.defineProperty(data, 'clipboardData', {
2059
- value: {
2060
- getData: function () {},
2061
- setData: function () {}
2062
- }
2063
- });
2064
- });
2065
-
2066
- range.setStart(editor.editor.firstChild.firstChild, 1);
2067
- range.setEnd(editor.editor.firstChild.firstChild, 2);
2068
- editor.s.selectRange(range);
2069
-
2070
- simulateEvent('copy', 0, editor.editor, function (data) {
2071
- Object.defineProperty(data, 'clipboardData', {
2072
- value: {
2073
- getData: function () {},
2074
- setData: function () {}
2075
- }
2076
- });
2077
- });
2078
-
2079
- simulateEvent(
2080
- 'keydown',
2081
- 'v',
2082
- editor.editor,
2083
- function (data) {
2084
- data.ctrlKey = true;
2085
- data.shiftKey = true;
2086
- }
2087
- );
2088
-
2089
- const dialog = getOpenedDialog(editor);
2090
- expect(dialog).is.not.null;
2091
-
2092
- simulateEvent(
2093
- 'click',
2094
- 0,
2095
- dialog.querySelectorAll('.jodit-paste-storage a')[1]
2096
- );
2097
-
2098
- expect(
2099
- dialog
2100
- .querySelectorAll('.jodit-paste-storage a')[1]
2101
- .classList.contains('jodit_active')
2102
- ).is.true;
2103
-
2104
- simulateEvent(
2105
- 'dblclick',
2106
- 0,
2107
- dialog.querySelectorAll('.jodit-paste-storage a')[1]
2108
- );
2109
-
2110
- expect(dialog.parentNode).is.null;
2111
-
2112
- expect(editor.value).equals('<p>aacde</p>');
2113
- });
2114
- });
2115
-
2116
- describe('Press key up/down/enter', function () {
2117
- it('Sholud select next/previos element of list and insert selected value after Enter', function () {
2118
- const editor = getJodit();
2119
-
2120
- editor.value = 'abcde';
2121
- const range = editor.ownerDocument.createRange();
2122
-
2123
- range.setStart(editor.editor.firstChild.firstChild, 0);
2124
- range.setEnd(editor.editor.firstChild.firstChild, 1);
2125
- editor.s.selectRange(range);
2126
-
2127
- simulateEvent('copy', 0, editor.editor, function (data) {
2128
- Object.defineProperty(data, 'clipboardData', {
2129
- value: {
2130
- getData: function () {},
2131
- setData: function () {}
2132
- }
2133
- });
2134
- });
2135
-
2136
- range.setStart(editor.editor.firstChild.firstChild, 1);
2137
- range.setEnd(editor.editor.firstChild.firstChild, 2);
2138
- editor.s.selectRange(range);
2139
-
2140
- simulateEvent('copy', 0, editor.editor, function (data) {
2141
- Object.defineProperty(data, 'clipboardData', {
2142
- value: {
2143
- getData: function () {},
2144
- setData: function () {}
2145
- }
2146
- });
2147
- });
2148
-
2149
- simulateEvent(
2150
- 'keydown',
2151
- 'v',
2152
- editor.editor,
2153
- function (data) {
2154
- data.ctrlKey = true;
2155
- data.shiftKey = true;
2156
- }
2157
- );
2158
-
2159
- const dialog = getOpenedDialog(editor);
2160
- expect(dialog).is.not.null;
2161
-
2162
- simulateEvent(
2163
- 'click',
2164
- 0,
2165
- dialog.querySelectorAll('.jodit-paste-storage a')[0]
2166
- );
2167
- expect(
2168
- dialog
2169
- .querySelectorAll('.jodit-paste-storage a')[0]
2170
- .classList.contains('jodit_active')
2171
- ).is.true;
2172
-
2173
- simulateEvent(
2174
- 'keydown',
2175
- Jodit.KEY_UP,
2176
- dialog.querySelectorAll('.jodit-paste-storage a')[0]
2177
- );
2178
- expect(
2179
- dialog
2180
- .querySelectorAll('.jodit-paste-storage a')[1]
2181
- .classList.contains('jodit_active')
2182
- ).is.true;
2183
-
2184
- simulateEvent(
2185
- 'keydown',
2186
- Jodit.KEY_UP,
2187
- dialog.querySelectorAll('.jodit-paste-storage a')[1]
2188
- );
2189
- expect(
2190
- dialog
2191
- .querySelectorAll('.jodit-paste-storage a')[0]
2192
- .classList.contains('jodit_active')
2193
- ).is.true;
2194
-
2195
- simulateEvent(
2196
- 'keydown',
2197
- Jodit.KEY_DOWN,
2198
- dialog.querySelectorAll('.jodit-paste-storage a')[0]
2199
- );
2200
- expect(
2201
- dialog
2202
- .querySelectorAll('.jodit-paste-storage a')[1]
2203
- .classList.contains('jodit_active')
2204
- ).is.true;
2205
-
2206
- simulateEvent(
2207
- 'keydown',
2208
- Jodit.KEY_ENTER,
2209
- dialog.querySelectorAll('.jodit-paste-storage a')[0]
2210
- );
2211
-
2212
- expect(dialog.parentNode).is.null;
2213
-
2214
- expect(editor.value).equals('<p>aacde</p>');
2215
- });
2216
- });
2217
- });
2218
- });
2219
- });