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,1640 +0,0 @@
1
- /*!
2
- * Jodit Editor (https://xdsoft.net/jodit/)
3
- * Released under MIT see LICENSE.txt in the project root for license information.
4
- * Copyright (c) 2013-2021 Valeriy Chupurnov. All rights reserved. https://xdsoft.net
5
- */
6
-
7
- describe('Link plugin', function () {
8
- describe('Insert link', function () {
9
- describe('Insert simple link', function () {
10
- it('Should insert as simple link', function () {
11
- const editor = getJodit();
12
-
13
- simulatePaste(
14
- editor.editor,
15
- 'https://www.youtube.com',
16
- 'text/plain'
17
- );
18
-
19
- expect(editor.value).equal(
20
- '<p><a href="https://www.youtube.com">https://www.youtube.com</a></p>'
21
- );
22
- });
23
-
24
- describe('Disable', function () {
25
- describe('Disable any convert', function () {
26
- it('Should not change source link', function () {
27
- const editor = getJodit({
28
- link: {
29
- processPastedLink: false
30
- }
31
- });
32
-
33
- simulatePaste(editor.editor, 'https://www.youtube.com');
34
- expect(editor.value).equal(
35
- '<p>https://www.youtube.com</p>'
36
- );
37
- });
38
- });
39
- });
40
- });
41
-
42
- describe('Insert youtube link', function () {
43
- [
44
- [
45
- 'https://www.youtube.com/watch?v=Cy1qd16VDhM&ab_channel=КонстантинСёмин',
46
- 'https://www.youtube.com/embed/Cy1qd16VDhM'
47
- ],
48
- [
49
- 'https://www.youtube.com/watch?v=8Qn_spdM5Zg',
50
- 'https://www.youtube.com/embed/8Qn_spdM5Zg'
51
- ]
52
- ].forEach(function (lnk) {
53
- describe('Insert link ' + lnk[0], function () {
54
- it(
55
- 'Should insert iframe with video ' + lnk[1],
56
- function () {
57
- const editor = getJodit();
58
-
59
- simulatePaste(editor.editor, lnk[0]);
60
-
61
- expect(sortAttributes(editor.value)).equal(
62
- sortAttributes(
63
- '<iframe width="400" height="345" src="' +
64
- lnk[1] +
65
- '" frameborder="0" allowfullscreen=""></iframe>'
66
- )
67
- );
68
- }
69
- );
70
- });
71
- });
72
-
73
- describe('Disable', function () {
74
- describe('Disable any convert', function () {
75
- it('Should not change source link', function () {
76
- const editor = getJodit({
77
- link: {
78
- processPastedLink: false,
79
- processVideoLink: false
80
- }
81
- });
82
-
83
- simulatePaste(
84
- editor.editor,
85
- 'https://www.youtube.com/watch?v=8Qn_spdM5Zg'
86
- );
87
- expect(editor.value).equal(
88
- '<p>https://www.youtube.com/watch?v=8Qn_spdM5Zg</p>'
89
- );
90
- });
91
- });
92
-
93
- describe('Disable video convert', function () {
94
- it('Should insert video link as simple link', function () {
95
- const editor = getJodit({
96
- link: {
97
- processVideoLink: false
98
- }
99
- });
100
-
101
- simulatePaste(
102
- editor.editor,
103
- 'https://www.youtube.com/watch?v=8Qn_spdM5Zg'
104
- );
105
- expect(editor.value).equal(
106
- '<p><a href="https://www.youtube.com/watch?v=8Qn_spdM5Zg">https://www.youtube.com/watch?v=8Qn_spdM5Zg</a></p>'
107
- );
108
- });
109
- });
110
- });
111
- });
112
- });
113
-
114
- describe('Toolbar link', function () {
115
- describe('Click link button', function () {
116
- describe('Edit exists link', function () {
117
- describe('Content input was not changed', function () {
118
- it('Should save link content', function () {
119
- const editor = getJodit();
120
-
121
- editor.value =
122
- '<p>test <a href="#somelink">link <strong>strong</strong></a> open</p>';
123
-
124
- const range = editor.s.createRange();
125
- range.setStart(
126
- editor.editor.querySelector('a').firstChild,
127
- 4
128
- );
129
- range.collapse(true);
130
- editor.s.selectRange(range);
131
-
132
- simulateEvent(
133
- 'click',
134
- editor.editor.querySelector('a')
135
- );
136
-
137
- const inlinePopup = getOpenedPopup(editor);
138
- expect(inlinePopup).is.not.null;
139
-
140
- clickButton('link', inlinePopup);
141
-
142
- const popup = getOpenedPopup(editor);
143
- expect(popup).is.not.null;
144
-
145
- const content = popup.querySelector(
146
- '[ref=content_input]'
147
- );
148
- expect(content).is.not.null;
149
- expect(content.value).equals('link strong');
150
-
151
- const url = popup.querySelector('[ref=url_input]');
152
- expect(url).is.not.null;
153
- expect(url.value).equals('#somelink');
154
-
155
- url.value = 'https://xdan.ru';
156
-
157
- simulateEvent('submit', 0, popup.querySelector('form'));
158
-
159
- expect(editor.value).equals(
160
- '<p>test <a href="https://xdan.ru">link <strong>strong</strong></a> open</p>'
161
- );
162
- });
163
-
164
- describe('For relative link', function () {
165
- it('Should work same way', function () {
166
- const editor = getJodit();
167
-
168
- editor.value =
169
- '<p>test <a href="#somelink">|link <strong>strong</strong></a> open</p>';
170
-
171
- setCursorToChar(editor);
172
-
173
- simulateEvent(
174
- 'click',
175
- editor.editor.querySelector('a')
176
- );
177
-
178
- const inlinePopup = getOpenedPopup(editor);
179
- clickButton('link', inlinePopup);
180
-
181
- const popup = getOpenedPopup(editor);
182
-
183
- const url = popup.querySelector('[ref=url_input]');
184
- expect(url.value).equals('#somelink');
185
-
186
- url.value = '/jodit/docs/';
187
-
188
- simulateEvent(
189
- 'submit',
190
- popup.querySelector('form')
191
- );
192
-
193
- expect(editor.value).equals(
194
- '<p>test <a href="/jodit/docs/">link <strong>strong</strong></a> open</p>'
195
- );
196
- });
197
- });
198
- });
199
-
200
- describe('Content input was changed', function () {
201
- it('Should replace link content', function () {
202
- const editor = getJodit();
203
-
204
- editor.value =
205
- '<p>test <a href="#somelink">link <strong>strong</strong></a> open</p>';
206
-
207
- const range = editor.s.createRange();
208
- range.setStart(
209
- editor.editor.querySelector('a').firstChild,
210
- 4
211
- );
212
- range.collapse(true);
213
- editor.s.selectRange(range);
214
-
215
- simulateEvent(
216
- 'click',
217
- editor.editor.querySelector('a')
218
- );
219
-
220
- const inlinePopup = getOpenedPopup(editor);
221
-
222
- clickButton('link', inlinePopup);
223
-
224
- const popup = getOpenedPopup(editor);
225
-
226
- const content = popup.querySelector(
227
- '[ref=content_input]'
228
- );
229
-
230
- content.value = 'some text';
231
-
232
- simulateEvent('submit', 0, popup.querySelector('form'));
233
-
234
- expect(editor.value).equals(
235
- '<p>test <a href="#somelink">some text</a> open</p>'
236
- );
237
- });
238
-
239
- describe('Content stay clear', function () {
240
- it('Should replace link content to url', function () {
241
- const editor = getJodit();
242
-
243
- editor.value =
244
- '<p>test <a href="#somelink">link <strong>strong</strong></a> open</p>';
245
-
246
- const range = editor.s.createRange();
247
- range.setStart(
248
- editor.editor.querySelector('a').firstChild,
249
- 4
250
- );
251
- range.collapse(true);
252
- editor.s.selectRange(range);
253
-
254
- simulateEvent(
255
- 'click',
256
- editor.editor.querySelector('a')
257
- );
258
-
259
- const inlinePopup = getOpenedPopup(editor);
260
-
261
- clickButton('link', inlinePopup);
262
-
263
- const popup = getOpenedPopup(editor);
264
-
265
- const content = popup.querySelector(
266
- '[ref=content_input]'
267
- );
268
-
269
- content.value = '';
270
-
271
- simulateEvent(
272
- 'submit',
273
- 0,
274
- popup.querySelector('form')
275
- );
276
-
277
- expect(editor.value).equals(
278
- '<p>test <a href="#somelink">#somelink</a> open</p>'
279
- );
280
- });
281
- });
282
- });
283
-
284
- describe('Select some text inside link', function () {
285
- describe('Content input was not changed', function () {
286
- it("Should open edit popup with full link's content", function () {
287
- const editor = getJodit();
288
-
289
- editor.value =
290
- '<p>test <a href="#somelink">link <strong>strong</strong></a> open</p>';
291
-
292
- const range = editor.s.createRange();
293
- range.setStart(
294
- editor.editor.querySelector('a').firstChild,
295
- 2
296
- );
297
- range.setEnd(
298
- editor.editor.querySelector('a').firstChild,
299
- 4
300
- );
301
- editor.s.selectRange(range);
302
-
303
- simulateEvent(
304
- 'click',
305
- editor.editor.querySelector('a')
306
- );
307
-
308
- const inlinePopup = getOpenedPopup(editor);
309
-
310
- clickButton('link', inlinePopup);
311
-
312
- const popup = getOpenedPopup(editor);
313
-
314
- const content = popup.querySelector(
315
- '[ref=content_input]'
316
- );
317
-
318
- expect(content.value).equals('link strong');
319
-
320
- const url = popup.querySelector('[ref=url_input]');
321
- expect(url).is.not.null;
322
- expect(url.value).equals('#somelink');
323
-
324
- url.value = 'https://xdan.ru';
325
-
326
- simulateEvent(
327
- 'submit',
328
- 0,
329
- popup.querySelector('form')
330
- );
331
-
332
- expect(editor.value).equals(
333
- '<p>test <a href="https://xdan.ru">link <strong>strong</strong></a> open</p>'
334
- );
335
- });
336
- });
337
-
338
- describe('Content input was changed', function () {
339
- it("Should open edit popup with full link's content and after submit should replace full link's content", function () {
340
- const editor = getJodit();
341
-
342
- editor.value =
343
- '<p>test <a href="#somelink">link <strong>strong</strong></a> open</p>';
344
-
345
- const range = editor.s.createRange();
346
- range.setStart(
347
- editor.editor.querySelector('a').firstChild,
348
- 2
349
- );
350
- range.setEnd(
351
- editor.editor.querySelector('a').firstChild,
352
- 4
353
- );
354
- editor.s.selectRange(range);
355
-
356
- simulateEvent(
357
- 'click',
358
- editor.editor.querySelector('a')
359
- );
360
-
361
- const inlinePopup = getOpenedPopup(editor);
362
-
363
- clickButton('link', inlinePopup);
364
-
365
- const popup = getOpenedPopup(editor);
366
-
367
- const content = popup.querySelector(
368
- '[ref=content_input]'
369
- );
370
-
371
- expect(content.value).equals('link strong');
372
-
373
- content.value = 'https://xdan.ru';
374
-
375
- simulateEvent(
376
- 'submit',
377
- 0,
378
- popup.querySelector('form')
379
- );
380
-
381
- expect(editor.value).equals(
382
- '<p>test <a href="#somelink">https://xdan.ru</a> open</p>'
383
- );
384
- });
385
- });
386
- });
387
- });
388
-
389
- describe('In dialog', function () {
390
- describe('Edit exists link', function () {
391
- describe('Content input was not changed', function () {
392
- it('Should save link content', function () {
393
- const editor = getJodit();
394
-
395
- editor.value =
396
- '<p>test <a href="#somelink">link| <strong>strong</strong></a> open</p>';
397
-
398
- setCursorToChar(editor);
399
-
400
- simulateEvent(
401
- 'keydown',
402
- 'k',
403
- editor.editor,
404
- function (opt) {
405
- opt.ctrlKey = true;
406
- }
407
- );
408
-
409
- const dialog = getOpenedDialog(editor);
410
- expect(dialog).is.not.null;
411
-
412
- const content = dialog.querySelector(
413
- '[ref=content_input]'
414
- );
415
- expect(content).is.not.null;
416
- expect(content.value).equals('link strong');
417
-
418
- const url = dialog.querySelector('[ref=url_input]');
419
- expect(url).is.not.null;
420
- expect(url.value).equals('#somelink');
421
-
422
- url.value = 'https://xdan.ru';
423
-
424
- simulateEvent(
425
- 'submit',
426
- 0,
427
- dialog.querySelector('form')
428
- );
429
-
430
- expect(editor.value).equals(
431
- '<p>test <a href="https://xdan.ru">link <strong>strong</strong></a> open</p>'
432
- );
433
- });
434
- });
435
- });
436
- });
437
-
438
- describe('Open LINK insert dialog and insert new link', function () {
439
- it('Should insert new link', function () {
440
- let popup_opened = 0;
441
-
442
- const editor = getJodit({
443
- events: {
444
- beforeLinkOpenPopup: function () {
445
- popup_opened += 1;
446
- },
447
- afterLinkOpenPopup: function () {
448
- popup_opened += 1;
449
- }
450
- },
451
- observer: {
452
- timeout: 0
453
- }
454
- });
455
-
456
- editor.value = '';
457
-
458
- clickButton('link', editor);
459
-
460
- const list = getOpenedPopup(editor);
461
-
462
- expect(popup_opened).equals(2);
463
- expect(
464
- editor.ownerWindow.getComputedStyle(list).display
465
- ).equals('block');
466
-
467
- expect(
468
- list.querySelector('[ref="unlink"]').style.display
469
- ).equals('none');
470
-
471
- const url = list.querySelector('[ref=url_input]');
472
- expect(url).is.not.null;
473
-
474
- url.focus();
475
- url.value = ''; // try wrong url
476
- list.querySelector('[ref=content_input]').value = '123';
477
-
478
- simulateEvent('submit', list.querySelector('form'));
479
-
480
- expect(
481
- Boolean(url.closest('.jodit-ui-input_has-error_true'))
482
- ).is.true;
483
-
484
- url.focus();
485
- url.value = 'tests/artio.jpg';
486
- simulateEvent('submit', 0, list.querySelector('form'));
487
-
488
- expect(sortAttributes(editor.value)).equals(
489
- '<p><a href="tests/artio.jpg">123</a></p>'
490
- );
491
-
492
- simulateEvent('mousedown', 0, editor.editor);
493
-
494
- expect(list.parentNode).is.null;
495
- });
496
-
497
- it('Should fire change event', function () {
498
- let change = 0;
499
-
500
- const editor = getJodit({
501
- events: {
502
- change: function () {
503
- change += 1;
504
- }
505
- }
506
- });
507
-
508
- editor.value = '';
509
-
510
- clickButton('link', editor);
511
-
512
- const list = getOpenedPopup(editor);
513
- const url = list.querySelector('input[ref=url_input]');
514
- url.value = 'tests/artio.jpg';
515
- simulateEvent('submit', 0, list.querySelector('form'));
516
-
517
- expect(sortAttributes(editor.value)).equals(
518
- '<p><a href="tests/artio.jpg">tests/artio.jpg</a></p>'
519
- );
520
-
521
- expect(change).equals(1);
522
- });
523
-
524
- describe('Set custom popup template', function () {
525
- it('Should show this template inside popup', function () {
526
- const tpl =
527
- '<form class="form_url"><input ref="url_input" type="url"><button>save</button></form>';
528
-
529
- const editor = getJodit({
530
- link: {
531
- formTemplate: function () {
532
- return tpl;
533
- }
534
- }
535
- });
536
-
537
- editor.value = '123';
538
- editor.s.select(editor.editor.firstChild);
539
-
540
- clickButton('link', editor);
541
-
542
- const popup = getOpenedPopup(editor);
543
-
544
- expect(
545
- sortAttributes(
546
- popup.querySelector('form').outerHTML
547
- )
548
- ).equals(tpl);
549
-
550
- const url = popup.querySelector('[ref=url_input]');
551
- expect(url).is.not.null;
552
-
553
- url.focus();
554
- url.value = 'tests/artio.jpg';
555
-
556
- simulateEvent('submit', 0, popup.querySelector('form'));
557
-
558
- expect(sortAttributes(editor.value)).equals(
559
- '<p><a href="tests/artio.jpg">123</a></p>'
560
- );
561
- });
562
-
563
- describe('Use data-ref instead ref', function () {
564
- it('Should show this template inside popup', function () {
565
- const tpl =
566
- '<form class="form_url"><input data-ref="url_input" type="url"><button>save</button></form>';
567
-
568
- const editor = getJodit({
569
- link: {
570
- formTemplate: function () {
571
- return tpl;
572
- }
573
- }
574
- });
575
-
576
- editor.value = '123';
577
- editor.s.select(editor.editor.firstChild);
578
-
579
- clickButton('link', editor);
580
-
581
- const popup = getOpenedPopup(editor);
582
-
583
- expect(
584
- sortAttributes(
585
- popup.querySelector('form').outerHTML
586
- )
587
- ).equals(tpl);
588
-
589
- const url = popup.querySelector(
590
- '[data-ref=url_input]'
591
- );
592
- expect(url).is.not.null;
593
-
594
- url.focus();
595
- url.value = 'tests/artio.jpg';
596
-
597
- simulateEvent(
598
- 'submit',
599
- 0,
600
- popup.querySelector('form')
601
- );
602
-
603
- expect(sortAttributes(editor.value)).equals(
604
- '<p><a href="tests/artio.jpg">123</a></p>'
605
- );
606
- });
607
- });
608
-
609
- describe('Add class name in form', function () {
610
- it('Should show form with this class', function () {
611
- const editor = getJodit({
612
- link: {
613
- formClassName: 'bootstrap_form'
614
- }
615
- });
616
-
617
- clickButton('link', editor);
618
-
619
- const form =
620
- getOpenedPopup(editor).querySelector('form');
621
-
622
- expect(form).is.not.null;
623
- expect(form.classList.contains('bootstrap_form')).is
624
- .true;
625
- });
626
- });
627
- });
628
-
629
- describe('On selected content', function () {
630
- describe('Selected text', function () {
631
- it('Should wrap selected text in link', function () {
632
- const editor = getJodit({
633
- toolbarAdaptive: false
634
- });
635
-
636
- editor.value =
637
- 'test <span style="color: #ccc;">select </span> stop';
638
-
639
- const range = editor.s.createRange();
640
-
641
- range.setStart(
642
- editor.editor.querySelector('span').firstChild,
643
- 0
644
- );
645
- range.setEnd(
646
- editor.editor.querySelector('span').firstChild,
647
- 6
648
- );
649
-
650
- editor.s.selectRange(range);
651
-
652
- clickButton('link', editor);
653
-
654
- const popup = getOpenedPopup(editor);
655
- expect(popup).is.not.null;
656
-
657
- expect(
658
- editor.ownerWindow.getComputedStyle(popup)
659
- .display
660
- ).equals('block');
661
-
662
- expect(
663
- popup.querySelector('[ref="unlink"]').style
664
- .display
665
- ).equals('none');
666
-
667
- const url = popup.querySelector('[ref=url_input]');
668
- expect(url).is.not.null;
669
-
670
- const text = popup.querySelector(
671
- '[ref=content_input]'
672
- );
673
- expect(text).is.not.null;
674
-
675
- expect(text.value).equals('select');
676
-
677
- url.focus();
678
- url.value = 'tests/artio.jpg';
679
- simulateEvent(
680
- 'submit',
681
- 0,
682
- popup.querySelector('form')
683
- );
684
-
685
- expect(sortAttributes(editor.value)).equals(
686
- '<p>test <span style="color:#ccc"><a href="tests/artio.jpg">select</a> </span> stop</p>'
687
- );
688
-
689
- simulateEvent('mousedown', 0, editor.editor);
690
-
691
- expect(popup.parentNode).is.null;
692
- });
693
- });
694
-
695
- describe('Selected image', function () {
696
- describe('On open popup', function () {
697
- it('Should hide text input', function () {
698
- const editor = getJodit({
699
- toolbarAdaptive: false,
700
- observer: {
701
- timeout: 0
702
- }
703
- });
704
-
705
- editor.value =
706
- 'test <img style="width: 100px;height: 100px" src="https://xdsoft.net/jodit/build/images/artio.jpg" alt=""> stop';
707
-
708
- editor.s.select(
709
- editor.editor.querySelector('img')
710
- );
711
-
712
- clickButton('link', editor);
713
-
714
- const popup = getOpenedPopup(editor);
715
-
716
- const text = popup.querySelector(
717
- '[ref=content_input_box]'
718
- );
719
-
720
- expect(
721
- editor.ownerWindow.getComputedStyle(text)
722
- .display
723
- ).equals('none');
724
- });
725
- });
726
-
727
- it('Should wrap selected image in link', function () {
728
- const editor = getJodit({
729
- toolbarAdaptive: false,
730
- observer: {
731
- timeout: 0
732
- }
733
- });
734
-
735
- editor.value =
736
- 'test <img style="width: 100px;height: 100px" src="https://xdsoft.net/jodit/build/images/artio.jpg" alt=""> stop';
737
-
738
- editor.s.select(editor.editor.querySelector('img'));
739
-
740
- clickButton('link', editor);
741
-
742
- const popup = getOpenedPopup(editor);
743
- expect(popup).is.not.null;
744
- expect(
745
- editor.ownerWindow.getComputedStyle(popup)
746
- .display
747
- ).equals('block');
748
-
749
- const url = popup.querySelector('[ref=url_input]');
750
- const text = popup.querySelector(
751
- '[ref=content_input]'
752
- );
753
-
754
- expect(text.value).equals('');
755
-
756
- url.focus();
757
- url.value = 'tests/artio.jpg';
758
-
759
- simulateEvent(
760
- 'submit',
761
- 0,
762
- popup.querySelector('form')
763
- );
764
-
765
- expect(sortAttributes(editor.value)).equals(
766
- '<p>test <a href="tests/artio.jpg"><img alt="" src="https://xdsoft.net/jodit/build/images/artio.jpg" style="height:100px;width:100px"></a> stop</p>'
767
- );
768
-
769
- simulateEvent('mousedown', 0, editor.editor);
770
-
771
- expect(popup.parentNode).is.null;
772
- });
773
- });
774
- });
775
-
776
- it('Should restore source text after user clicked on Unlink button', function () {
777
- const editor = getJodit({
778
- observer: {
779
- timeout: 0
780
- }
781
- });
782
-
783
- editor.value =
784
- '<a target="_blank" rel="nofollow" href="#test">test</a>';
785
-
786
- const sel = editor.s.sel,
787
- range = editor.s.createRange();
788
-
789
- range.selectNode(editor.editor.firstChild);
790
- sel.removeAllRanges();
791
- sel.addRange(range);
792
-
793
- clickButton('link', editor);
794
-
795
- const popup = getOpenedPopup(editor);
796
-
797
- expect(popup.querySelector('input[name=url]').value).equals(
798
- '#test'
799
- );
800
-
801
- expect(popup.querySelector('input[name=target]').checked).is
802
- .true;
803
-
804
- expect(popup.querySelector('input[name=nofollow]').checked)
805
- .is.true;
806
-
807
- expect(
808
- popup.querySelector('[ref="unlink"]').style.display
809
- ).does.not.equal('none');
810
-
811
- expect(
812
- popup.querySelector('[ref=insert]').innerHTML
813
- ).equals(editor.i18n('Update'));
814
-
815
- simulateEvent(
816
- 'click',
817
- 0,
818
- popup.querySelector('[ref=unlink]')
819
- );
820
-
821
- expect(sortAttributes(editor.value)).equals('<p>test</p>');
822
- });
823
- });
824
-
825
- describe('Was selected part of text', function () {
826
- it('Should show dialog form with this text', function () {
827
- const editor = getJodit();
828
-
829
- editor.value = '<p>one green bottle hanging under wall</p>';
830
- const range = editor.s.createRange();
831
- range.setStart(editor.editor.firstChild.firstChild, 10);
832
- range.setEnd(editor.editor.firstChild.firstChild, 16);
833
- editor.s.selectRange(range);
834
-
835
- clickButton('link', editor);
836
-
837
- const popup = getOpenedPopup(editor);
838
-
839
- const textInput = popup.querySelector(
840
- 'input[ref=content_input]'
841
- );
842
- expect(textInput).is.not.null;
843
-
844
- expect(textInput.value).equals('bottle');
845
- });
846
- });
847
-
848
- describe('Was selected part of html', function () {
849
- it('Should show dialog form with selection text content from this HTML', function () {
850
- const editor = getJodit();
851
-
852
- editor.value =
853
- '<p>one green <strong>bottle hanging</strong> under wall</p>' +
854
- '<p>two green <em>bottles hanging</em> under wall</p>';
855
-
856
- const range = editor.s.createRange();
857
- range.setStart(editor.editor.firstChild.firstChild, 4);
858
- range.setEnd(editor.editor.lastChild.lastChild, 6);
859
- editor.s.selectRange(range);
860
-
861
- clickButton('link', editor);
862
-
863
- const popup = getOpenedPopup(editor);
864
-
865
- const textInput = popup.querySelector(
866
- 'input[ref=content_input]'
867
- );
868
- expect(textInput).is.not.null;
869
-
870
- expect(textInput.value).equals(
871
- 'green bottle hanging under wall two green bottles hanging under'
872
- );
873
- });
874
-
875
- describe('Was selected image', function () {
876
- describe('Image was inside the Table', function () {
877
- describe('Edit with contect menu', function () {
878
- it('Should wrap selected image inside the link', function () {
879
- const editor = getJodit({
880
- popup: {
881
- img: ['link', 'unlink']
882
- }
883
- });
884
-
885
- editor.value =
886
- '<p>test</p>' +
887
- '<table>' +
888
- '<tbody>' +
889
- '<tr>' +
890
- '<td><img src="https://xdsoft.net/jodit/build/images/artio.jpg" alt="test"></td>' +
891
- '</tr>' +
892
- '</tbody>' +
893
- '</table>';
894
-
895
- editor.s.select(
896
- editor.editor.querySelector('img')
897
- );
898
-
899
- simulateEvent(
900
- 'click',
901
- editor.editor.querySelector('img')
902
- );
903
-
904
- const inline = getOpenedPopup(editor);
905
-
906
- clickButton('link', inline);
907
-
908
- const popup = getOpenedPopup(editor);
909
-
910
- const textInput = popup.querySelector(
911
- 'input[ref=content_input]'
912
- );
913
-
914
- expect(
915
- textInput.closest('.jodit-ui-block').style
916
- .display
917
- ).equals('none');
918
-
919
- expect(textInput.value).equals('');
920
-
921
- const urlInput = popup.querySelector(
922
- 'input[ref=url_input]'
923
- );
924
-
925
- expect(urlInput).is.not.null;
926
- urlInput.focus();
927
- urlInput.value = './shapiro';
928
- urlInput.select();
929
-
930
- simulateEvent(
931
- 'submit',
932
- popup.querySelector('form')
933
- );
934
-
935
- expect(sortAttributes(editor.value)).equals(
936
- '<p>test</p>' +
937
- '<table>' +
938
- '<tbody>' +
939
- '<tr>' +
940
- '<td><a href="./shapiro"><img alt="test" src="https://xdsoft.net/jodit/build/images/artio.jpg"></a></td>' +
941
- '</tr>' +
942
- '</tbody>' +
943
- '</table>'
944
- );
945
- });
946
- });
947
- });
948
-
949
- describe('Image had not anchor parent', function () {
950
- it('Should show dialog without content input and after submit wrap this image', function () {
951
- const editor = getJodit();
952
-
953
- editor.value =
954
- '<p>one green <img src="https://xdsoft.net/jodit/build/images/artio.jpg" alt="test"> under wall</p>';
955
-
956
- editor.s.select(editor.editor.querySelector('img'));
957
-
958
- clickButton('link', editor);
959
-
960
- const popup = getOpenedPopup(editor);
961
-
962
- const textInput = popup.querySelector(
963
- 'input[ref=content_input]'
964
- );
965
-
966
- expect(
967
- textInput.closest('.jodit-ui-block').style
968
- .display
969
- ).equals('none');
970
-
971
- expect(textInput.value).equals('');
972
-
973
- const urlInput = popup.querySelector(
974
- 'input[ref=url_input]'
975
- );
976
-
977
- expect(urlInput).is.not.null;
978
- urlInput.focus();
979
- urlInput.value = 'https://xdsoft.net';
980
- urlInput.select();
981
-
982
- simulateEvent(
983
- 'submit',
984
- popup.querySelector('form')
985
- );
986
-
987
- expect(sortAttributes(editor.value)).equals(
988
- '<p>one green <a href="https://xdsoft.net"><img alt="test" src="https://xdsoft.net/jodit/build/images/artio.jpg"></a> under wall</p>'
989
- );
990
- });
991
- });
992
-
993
- describe('Image had anchor parent', function () {
994
- it('Should show dialog without content input and after submit wrap this image', function () {
995
- const editor = getJodit();
996
-
997
- editor.value =
998
- '<p>one green <a href="https://xdan.ru"><img src="https://xdsoft.net/jodit/build/images/artio.jpg" alt="test"></a> under wall</p>';
999
-
1000
- editor.s.focus({ preventScroll: false });
1001
- editor.s.select(editor.editor.querySelector('img'));
1002
-
1003
- clickButton('link', editor);
1004
-
1005
- const popup = getOpenedPopup(editor);
1006
-
1007
- const textInput = popup.querySelector(
1008
- 'input[ref=content_input]'
1009
- );
1010
-
1011
- expect(
1012
- textInput.closest('.jodit-ui-block').style
1013
- .display
1014
- ).equals('none');
1015
-
1016
- expect(textInput.value).equals('');
1017
-
1018
- const urlInput = popup.querySelector(
1019
- 'input[ref=url_input]'
1020
- );
1021
-
1022
- expect(urlInput).is.not.null;
1023
- expect(urlInput.value).equals('https://xdan.ru');
1024
-
1025
- urlInput.focus();
1026
- urlInput.value = 'https://xdsoft.net';
1027
- urlInput.select();
1028
-
1029
- simulateEvent(
1030
- 'submit',
1031
- popup.querySelector('form')
1032
- );
1033
-
1034
- expect(sortAttributes(editor.value)).equals(
1035
- '<p>one green <a href="https://xdsoft.net"><img alt="test" src="https://xdsoft.net/jodit/build/images/artio.jpg"></a> under wall</p>'
1036
- );
1037
- });
1038
- });
1039
- });
1040
-
1041
- describe('After submit this part', function () {
1042
- it('should be wrapped inside anchor', function () {
1043
- const editor = getJodit();
1044
-
1045
- editor.value =
1046
- '<p>one green <strong>bottle hanging</strong> under wall</p>' +
1047
- '<p>two green <em>bottles hanging</em> under wall</p>';
1048
-
1049
- const range = editor.s.createRange();
1050
- range.setStart(editor.editor.firstChild.firstChild, 4);
1051
- range.setEnd(editor.editor.lastChild.lastChild, 6);
1052
- editor.s.selectRange(range);
1053
-
1054
- clickButton('link', editor);
1055
-
1056
- const popup = getOpenedPopup(editor);
1057
-
1058
- const form = popup.querySelector('.jodit-ui-form');
1059
- expect(form).is.not.null;
1060
-
1061
- const input = form.querySelector(
1062
- 'input[ref=url_input]'
1063
- );
1064
-
1065
- expect(input).is.not.null;
1066
-
1067
- input.value = 'https://xdsoft.net/jodit/';
1068
-
1069
- simulateEvent('submit', 0, form);
1070
-
1071
- expect(editor.value).equals(
1072
- '<p>one <a href="https://xdsoft.net/jodit/">green <strong>bottle hanging</strong> under wall</a></p>' +
1073
- '<p><a href="https://xdsoft.net/jodit/">two green <em>bottles hanging</em> under</a> wall</p>'
1074
- );
1075
- });
1076
- });
1077
- });
1078
- });
1079
- });
1080
-
1081
- describe('Link with class name (modeClassName=input/default)', function () {
1082
- describe('Add class name on link', function () {
1083
- it('Should insert new link with a class name', function () {
1084
- const editor = getJodit();
1085
-
1086
- editor.value =
1087
- '<p>one green <strong>bottle hanging</strong> under wall</p>' +
1088
- '<p>two green <em>bottles hanging</em> under wall</p>';
1089
-
1090
- const range = editor.s.createRange();
1091
- range.setStart(editor.editor.firstChild.firstChild, 4);
1092
- range.setEnd(editor.editor.lastChild.lastChild, 6);
1093
- editor.s.selectRange(range);
1094
-
1095
- clickButton('link', editor);
1096
-
1097
- const popup = getOpenedPopup(editor);
1098
-
1099
- const form = popup.querySelector('.jodit-ui-form');
1100
- expect(form).is.not.null;
1101
-
1102
- const input = form.querySelector('input[ref=url_input]');
1103
-
1104
- expect(input).is.not.null;
1105
-
1106
- input.value = 'https://xdsoft.net/jodit/';
1107
-
1108
- const className_input = form.querySelector(
1109
- 'input[ref=className_input]'
1110
- );
1111
-
1112
- expect(className_input).is.not.null;
1113
-
1114
- className_input.value = 'test';
1115
-
1116
- simulateEvent('submit', 0, form);
1117
-
1118
- expect(editor.value).equals(
1119
- '<p>one <a href="https://xdsoft.net/jodit/" class="test">green <strong>bottle hanging</strong> under wall</a></p>' +
1120
- '<p><a href="https://xdsoft.net/jodit/" class="test">two green <em>bottles hanging</em> under</a> wall</p>'
1121
- );
1122
- });
1123
- });
1124
-
1125
- describe('Vérify class name on link', function () {
1126
- it('Should have link with a class name', function () {
1127
- const editor = getJodit();
1128
-
1129
- editor.value =
1130
- '<p>one <a href="https://xdsoft.net/jodit/" class="test">green <strong>bottle hanging</strong> under wall</a></p>' +
1131
- '<p><a href="https://xdsoft.net/jodit/" class="test">two green <em>bottles hanging</em> under</a> wall</p>';
1132
-
1133
- const range = editor.s.createRange();
1134
- range.setStart(editor.editor.querySelector('a').firstChild, 4);
1135
- range.collapse(true);
1136
- editor.s.selectRange(range);
1137
-
1138
- clickButton('link', editor);
1139
-
1140
- const popup = getOpenedPopup(editor);
1141
-
1142
- const form = popup.querySelector('.jodit-ui-form');
1143
- expect(form).is.not.null;
1144
-
1145
- const className_input = form.querySelector(
1146
- 'input[ref=className_input]'
1147
- );
1148
-
1149
- expect(className_input).is.not.null;
1150
- expect(className_input.value).equals('test');
1151
- });
1152
- });
1153
-
1154
- describe('Modify class name on link', function () {
1155
- it('Should modify link with a new class name', function () {
1156
- const editor = getJodit();
1157
-
1158
- editor.value =
1159
- '<p>one <a href="https://xdsoft.net/jodit/" class="test">green <strong>bottle hanging</strong> under wall</a></p>' +
1160
- '<p><a href="https://xdsoft.net/jodit/" class="test">two green <em>bottles hanging</em> under</a> wall</p>';
1161
-
1162
- const range = editor.s.createRange();
1163
- range.setStart(editor.editor.querySelector('a').firstChild, 4);
1164
- range.collapse(true);
1165
- editor.s.selectRange(range);
1166
-
1167
- clickButton('link', editor);
1168
-
1169
- const popup = getOpenedPopup(editor);
1170
-
1171
- const form = popup.querySelector('.jodit-ui-form');
1172
- expect(form).is.not.null;
1173
-
1174
- const className_input = form.querySelector(
1175
- 'input[ref=className_input]'
1176
- );
1177
-
1178
- expect(className_input).is.not.null;
1179
-
1180
- className_input.value = 'test2';
1181
-
1182
- simulateEvent('submit', 0, form);
1183
-
1184
- expect(editor.value).equals(
1185
- '<p>one <a href="https://xdsoft.net/jodit/" class="test2">green <strong>bottle hanging</strong> under wall</a></p>' +
1186
- '<p><a href="https://xdsoft.net/jodit/" class="test">two green <em>bottles hanging</em> under</a> wall</p>'
1187
- );
1188
- });
1189
- });
1190
-
1191
- describe('Delete class name on link', function () {
1192
- it('Should modify link witout class name', function () {
1193
- const editor = getJodit();
1194
-
1195
- editor.value =
1196
- '<p>one <a href="https://xdsoft.net/jodit/" class="test">green <strong>bottle hanging</strong> under wall</a></p>' +
1197
- '<p><a href="https://xdsoft.net/jodit/" class="test">two green <em>bottles hanging</em> under</a> wall</p>';
1198
-
1199
- const range = editor.s.createRange();
1200
- range.setStart(editor.editor.querySelector('a').firstChild, 4);
1201
- range.collapse(true);
1202
- editor.s.selectRange(range);
1203
-
1204
- clickButton('link', editor);
1205
-
1206
- const popup = getOpenedPopup(editor);
1207
-
1208
- const form = popup.querySelector('.jodit-ui-form');
1209
- expect(form).is.not.null;
1210
-
1211
- const className_input = form.querySelector(
1212
- 'input[ref=className_input]'
1213
- );
1214
-
1215
- expect(className_input).is.not.null;
1216
-
1217
- className_input.value = '';
1218
-
1219
- simulateEvent('submit', 0, form);
1220
-
1221
- expect(editor.value).equals(
1222
- '<p>one <a href="https://xdsoft.net/jodit/">green <strong>bottle hanging</strong> under wall</a></p>' +
1223
- '<p><a href="https://xdsoft.net/jodit/" class="test">two green <em>bottles hanging</em> under</a> wall</p>'
1224
- );
1225
- });
1226
- });
1227
- });
1228
-
1229
- describe('Link with class name (modeClassName=select)', function () {
1230
- describe('Add class name on link', function () {
1231
- it('Should insert new link with a class name', function () {
1232
- const editor = getJodit({
1233
- link: {
1234
- modeClassName: 'select',
1235
- selectOptionsClassName: [
1236
- { value: '', text: '' },
1237
- { value: 'val1', text: 'text1' },
1238
- { value: 'val2', text: 'text2' },
1239
- { value: 'val3', text: 'text3' }
1240
- ]
1241
- }
1242
- });
1243
-
1244
- editor.value =
1245
- '<p>one green <strong>bottle hanging</strong> under wall</p>' +
1246
- '<p>two green <em>bottles hanging</em> under wall</p>';
1247
-
1248
- const range = editor.s.createRange();
1249
- range.setStart(editor.editor.firstChild.firstChild, 4);
1250
- range.setEnd(editor.editor.lastChild.lastChild, 6);
1251
- editor.s.selectRange(range);
1252
-
1253
- clickButton('link', editor);
1254
-
1255
- const popup = getOpenedPopup(editor);
1256
-
1257
- const form = popup.querySelector('.jodit-ui-form');
1258
- expect(form).is.not.null;
1259
-
1260
- const input = form.querySelector('input[ref=url_input]');
1261
-
1262
- expect(input).is.not.null;
1263
-
1264
- input.value = 'https://xdsoft.net/jodit/';
1265
-
1266
- const className_select = form.querySelector(
1267
- 'select[ref=className_select]'
1268
- );
1269
-
1270
- expect(className_select).is.not.null;
1271
-
1272
- for (let i = 0; i < className_select.options.length; i++) {
1273
- let option = className_select.options.item(i);
1274
- option.selected = option.value === 'val1';
1275
- }
1276
-
1277
- simulateEvent('submit', 0, form);
1278
-
1279
- expect(editor.value).equals(
1280
- '<p>one <a href="https://xdsoft.net/jodit/" class="val1">green <strong>bottle hanging</strong> under wall</a></p>' +
1281
- '<p><a href="https://xdsoft.net/jodit/" class="val1">two green <em>bottles hanging</em> under</a> wall</p>'
1282
- );
1283
- });
1284
- });
1285
-
1286
- describe('Vérify class name on link', function () {
1287
- it('Should have link with a class name', function () {
1288
- const editor = getJodit({
1289
- link: {
1290
- modeClassName: 'select',
1291
- selectOptionsClassName: [
1292
- { value: '', text: '' },
1293
- { value: 'val1', text: 'text1' },
1294
- { value: 'val2', text: 'text2' },
1295
- { value: 'val3', text: 'text3' }
1296
- ]
1297
- }
1298
- });
1299
-
1300
- editor.value =
1301
- '<p>one <a href="https://xdsoft.net/jodit/" class="val1">green <strong>bottle hanging</strong> under wall</a></p>' +
1302
- '<p><a href="https://xdsoft.net/jodit/" class="val1">two green <em>bottles hanging</em> under</a> wall</p>';
1303
-
1304
- const range = editor.s.createRange();
1305
- range.setStart(editor.editor.querySelector('a').firstChild, 4);
1306
- range.collapse(true);
1307
- editor.s.selectRange(range);
1308
-
1309
- clickButton('link', editor);
1310
-
1311
- const popup = getOpenedPopup(editor);
1312
-
1313
- const form = popup.querySelector('.jodit-ui-form');
1314
- expect(form).is.not.null;
1315
-
1316
- const className_select = form.querySelector(
1317
- 'select[ref=className_select]'
1318
- );
1319
-
1320
- expect(className_select).is.not.null;
1321
-
1322
- for (let i = 0; i < className_select.options.length; i++) {
1323
- let option = className_select.options.item(i);
1324
- expect(option.selected).equals(option.value === 'val1');
1325
- }
1326
- });
1327
- });
1328
-
1329
- describe('Modify class name on link', function () {
1330
- it('Should modify link with a new class name', function () {
1331
- const editor = getJodit({
1332
- link: {
1333
- modeClassName: 'select',
1334
- selectOptionsClassName: [
1335
- { value: '', text: '' },
1336
- { value: 'val1', text: 'text1' },
1337
- { value: 'val2', text: 'text2' },
1338
- { value: 'val3', text: 'text3' }
1339
- ]
1340
- }
1341
- });
1342
-
1343
- editor.value =
1344
- '<p>one <a href="https://xdsoft.net/jodit/" class="val1">green <strong>bottle hanging</strong> under wall</a></p>' +
1345
- '<p><a href="https://xdsoft.net/jodit/" class="val1">two green <em>bottles hanging</em> under</a> wall</p>';
1346
-
1347
- const range = editor.s.createRange();
1348
- range.setStart(editor.editor.querySelector('a').firstChild, 4);
1349
- range.collapse(true);
1350
- editor.s.selectRange(range);
1351
-
1352
- clickButton('link', editor);
1353
-
1354
- const popup = getOpenedPopup(editor);
1355
-
1356
- const form = popup.querySelector('.jodit-ui-form');
1357
- expect(form).is.not.null;
1358
-
1359
- const className_select = form.querySelector(
1360
- 'select[ref=className_select]'
1361
- );
1362
-
1363
- expect(className_select).is.not.null;
1364
-
1365
- for (let i = 0; i < className_select.options.length; i++) {
1366
- let option = className_select.options.item(i);
1367
- option.selected = option.value === 'val2' ? true : false;
1368
- }
1369
-
1370
- simulateEvent('submit', 0, form);
1371
-
1372
- expect(editor.value).equals(
1373
- '<p>one <a href="https://xdsoft.net/jodit/" class="val2">green <strong>bottle hanging</strong> under wall</a></p>' +
1374
- '<p><a href="https://xdsoft.net/jodit/" class="val1">two green <em>bottles hanging</em> under</a> wall</p>'
1375
- );
1376
- });
1377
- });
1378
-
1379
- describe('Delete class name on link', function () {
1380
- it('Should modify link witout class name', function () {
1381
- const editor = getJodit({
1382
- link: {
1383
- modeClassName: 'select',
1384
- selectOptionsClassName: [
1385
- { value: '', text: '' },
1386
- { value: 'val1', text: 'text1' },
1387
- { value: 'val2', text: 'text2' },
1388
- { value: 'val3', text: 'text3' }
1389
- ]
1390
- }
1391
- });
1392
-
1393
- editor.value =
1394
- '<p>one <a href="https://xdsoft.net/jodit/" class="val1">green <strong>bottle hanging</strong> under wall</a></p>' +
1395
- '<p><a href="https://xdsoft.net/jodit/" class="val1">two green <em>bottles hanging</em> under</a> wall</p>';
1396
-
1397
- const range = editor.s.createRange();
1398
- range.setStart(editor.editor.querySelector('a').firstChild, 4);
1399
- range.collapse(true);
1400
- editor.s.selectRange(range);
1401
-
1402
- clickButton('link', editor);
1403
-
1404
- const popup = getOpenedPopup(editor);
1405
-
1406
- const form = popup.querySelector('.jodit-ui-form');
1407
- expect(form).is.not.null;
1408
-
1409
- const className_select = form.querySelector(
1410
- 'select[ref=className_select]'
1411
- );
1412
-
1413
- expect(className_select).is.not.null;
1414
-
1415
- for (let i = 0; i < className_select.options.length; i++) {
1416
- let option = className_select.options.item(i);
1417
- option.selected = false;
1418
- }
1419
-
1420
- simulateEvent('submit', 0, form);
1421
-
1422
- expect(editor.value).equals(
1423
- '<p>one <a href="https://xdsoft.net/jodit/">green <strong>bottle hanging</strong> under wall</a></p>' +
1424
- '<p><a href="https://xdsoft.net/jodit/" class="val1">two green <em>bottles hanging</em> under</a> wall</p>'
1425
- );
1426
- });
1427
- });
1428
- });
1429
-
1430
- describe('Link with class name (modeClassName="select", selectMultipleClassName=true)', function () {
1431
- describe('Add class name on link', function () {
1432
- it('Should insert new link with a class name', function () {
1433
- const editor = getJodit({
1434
- link: {
1435
- modeClassName: 'select',
1436
- selectMultipleClassName: true,
1437
- selectOptionsClassName: [
1438
- { value: '', text: '' },
1439
- { value: 'val1', text: 'text1' },
1440
- { value: 'val2', text: 'text2' },
1441
- { value: 'val3', text: 'text3' }
1442
- ]
1443
- }
1444
- });
1445
-
1446
- editor.value =
1447
- '<p>one green <strong>bottle hanging</strong> under wall</p>' +
1448
- '<p>two green <em>bottles hanging</em> under wall</p>';
1449
-
1450
- const range = editor.s.createRange();
1451
- range.setStart(editor.editor.firstChild.firstChild, 4);
1452
- range.setEnd(editor.editor.lastChild.lastChild, 6);
1453
- editor.s.selectRange(range);
1454
-
1455
- clickButton('link', editor);
1456
-
1457
- const popup = getOpenedPopup(editor);
1458
-
1459
- const form = popup.querySelector('.jodit-ui-form');
1460
- expect(form).is.not.null;
1461
-
1462
- const input = form.querySelector('input[ref=url_input]');
1463
-
1464
- expect(input).is.not.null;
1465
-
1466
- input.value = 'https://xdsoft.net/jodit/';
1467
-
1468
- const className_select = form.querySelector(
1469
- 'select[ref=className_select]'
1470
- );
1471
-
1472
- expect(className_select).is.not.null;
1473
-
1474
- for (let i = 0; i < className_select.options.length; i++) {
1475
- let option = className_select.options.item(i);
1476
- option.selected =
1477
- option.value === 'val1' || option.value === 'val3';
1478
- }
1479
-
1480
- simulateEvent('submit', 0, form);
1481
-
1482
- expect(editor.value).equals(
1483
- '<p>one <a href="https://xdsoft.net/jodit/" class="val1 val3">green <strong>bottle hanging</strong> under wall</a></p>' +
1484
- '<p><a href="https://xdsoft.net/jodit/" class="val1 val3">two green <em>bottles hanging</em> under</a> wall</p>'
1485
- );
1486
- });
1487
- });
1488
-
1489
- describe('Vérify class name on link', function () {
1490
- it('Should have link with a class name', function () {
1491
- const editor = getJodit({
1492
- link: {
1493
- modeClassName: 'select',
1494
- selectMultipleClassName: true,
1495
- selectOptionsClassName: [
1496
- { value: '', text: '' },
1497
- { value: 'val1', text: 'text1' },
1498
- { value: 'val2', text: 'text2' },
1499
- { value: 'val3', text: 'text3' }
1500
- ]
1501
- }
1502
- });
1503
-
1504
- editor.value =
1505
- '<p>one <a href="https://xdsoft.net/jodit/" class="val1 val3">green <strong>bottle hanging</strong> under wall</a></p>' +
1506
- '<p><a href="https://xdsoft.net/jodit/" class="val1 val3">two green <em>bottles hanging</em> under</a> wall</p>';
1507
-
1508
- const range = editor.s.createRange();
1509
- range.setStart(editor.editor.querySelector('a').firstChild, 4);
1510
- range.collapse(true);
1511
- editor.s.selectRange(range);
1512
-
1513
- clickButton('link', editor);
1514
-
1515
- const popup = getOpenedPopup(editor);
1516
-
1517
- const form = popup.querySelector('.jodit-ui-form');
1518
- expect(form).is.not.null;
1519
-
1520
- const className_select = form.querySelector(
1521
- 'select[ref=className_select]'
1522
- );
1523
-
1524
- expect(className_select).is.not.null;
1525
-
1526
- for (let i = 0; i < className_select.options.length; i++) {
1527
- let option = className_select.options.item(i);
1528
- expect(option.selected).equals(
1529
- option.value === 'val1' || option.value === 'val3'
1530
- );
1531
- }
1532
- });
1533
- });
1534
-
1535
- describe('Modify class name on link', function () {
1536
- it('Should modify link with a new class name', function () {
1537
- const editor = getJodit({
1538
- link: {
1539
- modeClassName: 'select',
1540
- selectMultipleClassName: true,
1541
- selectOptionsClassName: [
1542
- { value: '', text: '' },
1543
- { value: 'val1', text: 'text1' },
1544
- { value: 'val2', text: 'text2' },
1545
- { value: 'val3', text: 'text3' }
1546
- ]
1547
- }
1548
- });
1549
-
1550
- editor.value =
1551
- '<p>one <a href="https://xdsoft.net/jodit/" class="val1 val3">green <strong>bottle hanging</strong> under wall</a></p>' +
1552
- '<p><a href="https://xdsoft.net/jodit/" class="val1 val3">two green <em>bottles hanging</em> under</a> wall</p>';
1553
-
1554
- const range = editor.s.createRange();
1555
- range.setStart(editor.editor.querySelector('a').firstChild, 4);
1556
- range.collapse(true);
1557
- editor.s.selectRange(range);
1558
-
1559
- clickButton('link', editor);
1560
-
1561
- const popup = getOpenedPopup(editor);
1562
-
1563
- const form = popup.querySelector('.jodit-ui-form');
1564
- expect(form).is.not.null;
1565
-
1566
- const className_select = form.querySelector(
1567
- 'select[ref=className_select]'
1568
- );
1569
-
1570
- expect(className_select).is.not.null;
1571
-
1572
- for (let i = 0; i < className_select.options.length; i++) {
1573
- let option = className_select.options.item(i);
1574
- option.selected =
1575
- option.value === 'val1' || option.value === 'val2'
1576
- ? true
1577
- : false;
1578
- }
1579
-
1580
- simulateEvent('submit', 0, form);
1581
-
1582
- expect(editor.value).equals(
1583
- '<p>one <a href="https://xdsoft.net/jodit/" class="val1 val2">green <strong>bottle hanging</strong> under wall</a></p>' +
1584
- '<p><a href="https://xdsoft.net/jodit/" class="val1 val3">two green <em>bottles hanging</em> under</a> wall</p>'
1585
- );
1586
- });
1587
- });
1588
-
1589
- describe('Delete class name on link', function () {
1590
- it('Should modify link witout class name', function () {
1591
- const editor = getJodit({
1592
- link: {
1593
- modeClassName: 'select',
1594
- selectMultipleClassName: true,
1595
- selectOptionsClassName: [
1596
- { value: '', text: '' },
1597
- { value: 'val1', text: 'text1' },
1598
- { value: 'val2', text: 'text2' },
1599
- { value: 'val3', text: 'text3' }
1600
- ]
1601
- }
1602
- });
1603
-
1604
- editor.value =
1605
- '<p>one <a href="https://xdsoft.net/jodit/" class="val1 val3">green <strong>bottle hanging</strong> under wall</a></p>' +
1606
- '<p><a href="https://xdsoft.net/jodit/" class="val1 val3">two green <em>bottles hanging</em> under</a> wall</p>';
1607
-
1608
- const range = editor.s.createRange();
1609
- range.setStart(editor.editor.querySelector('a').firstChild, 4);
1610
- range.collapse(true);
1611
- editor.s.selectRange(range);
1612
-
1613
- clickButton('link', editor);
1614
-
1615
- const popup = getOpenedPopup(editor);
1616
-
1617
- const form = popup.querySelector('.jodit-ui-form');
1618
- expect(form).is.not.null;
1619
-
1620
- const className_select = form.querySelector(
1621
- 'select[ref=className_select]'
1622
- );
1623
-
1624
- expect(className_select).is.not.null;
1625
-
1626
- for (let i = 0; i < className_select.options.length; i++) {
1627
- let option = className_select.options.item(i);
1628
- option.selected = false;
1629
- }
1630
-
1631
- simulateEvent('submit', 0, form);
1632
-
1633
- expect(editor.value).equals(
1634
- '<p>one <a href="https://xdsoft.net/jodit/">green <strong>bottle hanging</strong> under wall</a></p>' +
1635
- '<p><a href="https://xdsoft.net/jodit/" class="val1 val3">two green <em>bottles hanging</em> under</a> wall</p>'
1636
- );
1637
- });
1638
- });
1639
- });
1640
- });