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,1747 +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('Toolbar', function () {
7
- it('Should have buttons', function () {
8
- const editor = getJodit({
9
- toolbarAdaptive: true
10
- });
11
-
12
- expect(
13
- editor.toolbar.container.querySelectorAll('.jodit-toolbar-button')
14
- .length
15
- ).equals(37);
16
- });
17
-
18
- describe('Custom buttons', function () {
19
- it('should create normal button in toolbar', function () {
20
- const editor = getJodit({
21
- toolbarAdaptive: false,
22
- buttons: [
23
- 'image',
24
- {
25
- name: 'alert_some',
26
- iconURL:
27
- 'https://xdsoft.net/jodit/build/images/icons/045-copy.png',
28
- exec: function () {
29
- alert('test');
30
- }
31
- }
32
- ]
33
- });
34
-
35
- const btns = Array.from(
36
- editor.toolbar.container.querySelectorAll('[role="listitem"]')
37
- );
38
-
39
- expect(btns.length).equals(2);
40
-
41
- btns.forEach(function (btn) {
42
- const icon = btn.querySelector('.jodit-icon');
43
-
44
- expect(icon).is.not.null;
45
-
46
- const style = window.getComputedStyle(icon),
47
- height = parseInt(style.height),
48
- width = parseInt(style.width);
49
-
50
- expect(width).to.be.above(5);
51
- expect(height).to.be.above(5);
52
- });
53
- });
54
-
55
- describe('Use controls', function () {
56
- it('should create normal button in toolbar', function () {
57
- const editor = getJodit({
58
- toolbarAdaptive: false,
59
- controls: {
60
- alert_some: {
61
- name: 'alert_some',
62
- iconURL:
63
- 'https://xdsoft.net/jodit/build/images/icons/045-copy.png',
64
- exec: function () {
65
- editor.s.insertHTML(
66
- '<p><span>indigo</span></p>'
67
- );
68
- }
69
- }
70
- },
71
- buttons: ['image', 'alert_some']
72
- });
73
-
74
- expect(editor.toolbar.getButtonsNames().toString()).equals(
75
- 'image,alert_some'
76
- );
77
-
78
- clickButton('alert_some', editor);
79
-
80
- expect(editor.value).equals('<p><span>indigo</span></p>');
81
- });
82
- });
83
- });
84
-
85
- describe('Custom icons', function () {
86
- describe('By default for unknown icons', function () {
87
- it('should create button as text mode', function () {
88
- const editor = getJodit({
89
- toolbarAdaptive: false,
90
- buttons: ['rect']
91
- });
92
-
93
- expect(
94
- sortAttributes(getButton('rect', editor).innerHTML)
95
- ).equals(
96
- '<span class="jodit-toolbar-button__icon"></span><span class="jodit-toolbar-button__text">rect</span>'
97
- );
98
- });
99
- });
100
-
101
- describe('Use getIcon event', function () {
102
- it('should create buttons with custom icons', function () {
103
- const editor = getJodit({
104
- toolbarAdaptive: false,
105
- buttons: ['image', 'redo', 'about'],
106
- events: {
107
- getIcon: function (name, control, clearName) {
108
- var code = clearName;
109
-
110
- switch (clearName) {
111
- case 'redo':
112
- code = 'rotate-right';
113
- break;
114
- case 'about':
115
- code = 'question';
116
- break;
117
- }
118
-
119
- return (
120
- '<i style="font-size:14px" class="fa fa-' +
121
- code +
122
- ' fa-xs"></i>'
123
- );
124
- }
125
- }
126
- });
127
-
128
- expect(editor.toolbar.getButtonsNames().toString()).equals(
129
- 'image,redo,about'
130
- );
131
-
132
- expect(
133
- sortAttributes(getButton('image', editor).innerHTML)
134
- ).equals(
135
- '<span class="jodit-toolbar-button__icon">' +
136
- '<i class="fa fa-image fa-xs jodit-icon_image jodit-icon" style="font-size:14px"></i>' +
137
- '</span><span class="jodit-toolbar-button__text"></span>'
138
- );
139
-
140
- expect(
141
- sortAttributes(getButton('redo', editor).innerHTML)
142
- ).equals(
143
- '<span class="jodit-toolbar-button__icon">' +
144
- '<i class="fa fa-rotate-right fa-xs jodit-icon_redo jodit-icon" style="font-size:14px"></i>' +
145
- '</span><span class="jodit-toolbar-button__text"></span>'
146
- );
147
-
148
- expect(
149
- sortAttributes(getButton('about', editor).innerHTML)
150
- ).equals(
151
- '<span class="jodit-toolbar-button__icon">' +
152
- '<i class="fa fa-question fa-xs jodit-icon_about jodit-icon" style="font-size:14px"></i>' +
153
- '</span><span class="jodit-toolbar-button__text"></span>'
154
- );
155
- });
156
- });
157
-
158
- const rect =
159
- '<svg width="400" height="110"><rect width="300" height="100"/></svg>',
160
- rectResult =
161
- '<span class="jodit-toolbar-button__icon">' +
162
- '<svg class="jodit-icon_rect jodit-icon" height="110" width="400"><rect height="100" width="300"></rect></svg>' +
163
- '</span><span class="jodit-toolbar-button__text"></span>';
164
-
165
- describe('Use extraButtons options', function () {
166
- it('should create buttons with custom icons', function () {
167
- const editor = getJodit({
168
- toolbarAdaptive: false,
169
- buttons: [
170
- {
171
- name: 'rect'
172
- }
173
- ],
174
- extraIcons: {
175
- rect: rect
176
- }
177
- });
178
-
179
- expect(editor.toolbar.getButtonsNames().toString()).equals(
180
- 'rect'
181
- );
182
-
183
- expect(
184
- sortAttributes(getButton('rect', editor).innerHTML)
185
- ).equals(rectResult);
186
- });
187
- });
188
-
189
- describe('Use Icon module', function () {
190
- it('should create buttons with custom icons', function () {
191
- Jodit.modules.Icon.set('rect', rect);
192
- const editor = getJodit({
193
- toolbarAdaptive: false,
194
- buttons: [
195
- {
196
- name: 'rect'
197
- }
198
- ]
199
- });
200
-
201
- expect(
202
- sortAttributes(getButton('rect', editor).innerHTML)
203
- ).equals(rectResult);
204
- });
205
- });
206
-
207
- describe('Use svg in icon', function () {
208
- it('should create buttons with custom icons', function () {
209
- const editor = getJodit({
210
- toolbarAdaptive: false,
211
- buttons: [
212
- {
213
- name: 'rect',
214
- icon: rect
215
- }
216
- ]
217
- });
218
-
219
- expect(
220
- sortAttributes(getButton('rect', editor).innerHTML)
221
- ).equals(rectResult.replace('jodit-icon_rect ', ''));
222
- });
223
- });
224
- });
225
-
226
- describe('Set toolbar options to false', function () {
227
- it('Should hide toolbar', function () {
228
- const editor = getJodit({
229
- toolbar: false
230
- });
231
-
232
- expect(null).equals(
233
- editor.container.querySelector('.jodit_toolbar')
234
- );
235
- });
236
- });
237
-
238
- describe('Set toolbar options to css selector', function () {
239
- it('Should render toolbar in different container', function () {
240
- const div = appendTestDiv(),
241
- editor = getJodit(
242
- {
243
- toolbar: div
244
- },
245
- appendTestArea()
246
- );
247
-
248
- const toolbar = document.querySelector(
249
- '.jodit-toolbar-editor-collection'
250
- );
251
- const defaultContainer = editor.container.querySelector(
252
- '.jodit-toolbar__box'
253
- );
254
-
255
- expect(toolbar).is.not.null;
256
- expect(div).equals(toolbar.parentElement);
257
- expect(defaultContainer).does.not.equal(toolbar.parentElement);
258
- });
259
-
260
- describe('After enable Fullsize mode', function () {
261
- it('Should render toolbar in default container', function () {
262
- const div = appendTestDiv(),
263
- editor = Jodit.make(appendTestArea(), {
264
- toolbar: div
265
- });
266
-
267
- const toolbar = editor.toolbar.container;
268
- const defaultContainer = editor.defaultToolbarContainer;
269
-
270
- editor.toggleFullSize(true);
271
- expect(defaultContainer).equals(toolbar.parentElement);
272
-
273
- editor.toggleFullSize(false);
274
- expect(div).equals(toolbar.parentElement);
275
- });
276
- });
277
-
278
- describe('Change toolbar container dynamically', function () {
279
- it('Should render toolbar in different containers every call setPanel', function () {
280
- const div1 = appendTestDiv(),
281
- div2 = appendTestDiv(),
282
- div3 = appendTestDiv(),
283
- editor = getJodit();
284
-
285
- const toolbar = editor.toolbar.container;
286
- expect(toolbar).is.not.null;
287
-
288
- const defaultContainer = editor.toolbarContainer;
289
- expect(defaultContainer).is.not.null;
290
-
291
- expect(defaultContainer).equals(toolbar.parentElement);
292
-
293
- editor.setPanel(div1);
294
- expect(defaultContainer).not.equals(toolbar.parentElement);
295
- expect(div1).equals(toolbar.parentElement);
296
-
297
- editor.setPanel(div2);
298
- expect(div2).equals(toolbar.parentElement);
299
-
300
- editor.setPanel(div3);
301
- expect(div3).equals(toolbar.parentElement);
302
- });
303
- });
304
- });
305
-
306
- describe('Popups', function () {
307
- describe('Click on dots buttons in mobile size', function () {
308
- it('Should open popup with several buttons', function () {
309
- getBox().style.width = '300px';
310
- const editor = getJodit();
311
-
312
- clickButton('dots', editor);
313
-
314
- const popup = getOpenedPopup(editor);
315
-
316
- expect(popup).is.not.null;
317
-
318
- clickButton('video', popup);
319
-
320
- const popup2 = getOpenedPopup(editor);
321
- expect(popup2).is.not.null;
322
- getBox().style.width = 'auto';
323
- });
324
- });
325
-
326
- describe('Click on some link', function () {
327
- describe('in the left side of editor', function () {
328
- it('Should open inline popup with float by left editor side', function () {
329
- const editor = getJodit({});
330
-
331
- editor.value = 'asas <a href="#">test</a>';
332
-
333
- simulateEvent('click', editor.editor.querySelector('a'));
334
-
335
- const popup = getOpenedPopup(editor);
336
-
337
- expect(popup).is.not.null;
338
-
339
- const positionPopup = offset(popup);
340
- const positionContainer = offset(editor.container);
341
-
342
- expect(true).equals(
343
- positionPopup.left >= positionContainer.left
344
- );
345
- });
346
- });
347
- });
348
-
349
- describe('Click on some button with defined popup field', function () {
350
- it('Should open popup in toolbar', function () {
351
- const editor = getJodit({
352
- disablePlugins: 'mobile'
353
- });
354
-
355
- clickButton('video', editor);
356
-
357
- const popup = getOpenedPopup(editor);
358
-
359
- expect(popup).is.not.null;
360
- });
361
-
362
- describe('in the left side', function () {
363
- it('Should open popup in toolbar with float by left editor side', function () {
364
- const editor = getJodit({
365
- buttons: ['video'],
366
- disablePlugins: 'mobile'
367
- });
368
-
369
- clickButton('video', editor);
370
-
371
- const popup = getOpenedPopup(editor);
372
-
373
- expect(popup).is.not.null;
374
-
375
- const positionPopup = offset(popup);
376
- const positionContainer = offset(editor.container);
377
-
378
- expect(true).equals(
379
- positionPopup.left >= positionContainer.left
380
- );
381
- });
382
- });
383
-
384
- describe('in the right side', function () {
385
- it('Should open popup in toolbar with float by left editor side', function () {
386
- const editor = getJodit({
387
- width: 306,
388
- buttons: [
389
- 'video',
390
- 'video',
391
- 'video',
392
- 'video',
393
- 'video',
394
- 'video',
395
- 'video',
396
- 'video'
397
- ],
398
- disablePlugins: 'mobile'
399
- });
400
-
401
- clickButton('video', editor, 'button', true);
402
-
403
- const popup = getOpenedPopup(editor);
404
-
405
- expect(popup).is.not.null;
406
-
407
- const positionPopup = offset(popup);
408
- const positionContainer = offset(editor.container);
409
-
410
- expect(
411
- Math.abs(
412
- positionPopup.left +
413
- positionPopup.width -
414
- (positionContainer.left +
415
- positionContainer.width)
416
- ) < 10
417
- ).is.true;
418
- });
419
- });
420
- });
421
-
422
- getBox().style.width = 'auto';
423
-
424
- it('Open and close popup after clicking in another place', function () {
425
- const editor = getJodit({
426
- disablePlugins: 'mobile'
427
- });
428
-
429
- clickButton('video', editor);
430
-
431
- const popup = editor.ownerDocument.querySelector(
432
- '[role="popup"][data-editor_id="' + editor.id + '"]'
433
- );
434
- expect(popup).is.not.null;
435
-
436
- simulateEvent('mousedown', 0, window);
437
-
438
- expect(popup && popup.parentNode == null).is.true;
439
- });
440
-
441
- describe('Open list', function () {
442
- it('Should Open list in toolbar', function () {
443
- const editor = getJodit({
444
- toolbarAdaptive: false
445
- });
446
-
447
- clickTrigger('font', editor);
448
-
449
- const list = getOpenedPopup(editor);
450
-
451
- expect(
452
- list &&
453
- window.getComputedStyle(list).display === 'block' &&
454
- list.parentNode != null
455
- ).is.true;
456
- });
457
-
458
- describe('Change default list', function () {
459
- it('Should change default FONT list in toolbar', function () {
460
- const editor = getJodit({
461
- toolbarAdaptive: false,
462
- controls: {
463
- font: {
464
- list: {
465
- 'font-family: -apple-system,BlinkMacSystemFont,Segoe WPC,Segoe UI,HelveticaNeue-Light,Ubuntu,Droid Sans,sans-serif;':
466
- 'Custom',
467
- 'Helvetica,sans-serif': 'Helvetica',
468
- 'Arial,Helvetica,sans-serif': 'Arial',
469
- 'Georgia,serif': 'Georgia',
470
- 'Impact,Charcoal,sans-serif': 'Impact',
471
- 'Tahoma,Geneva,sans-serif': 'Tahoma',
472
- "'Times New Roman',Times,serif":
473
- 'Times New Roman',
474
- 'Verdana,Geneva,sans-serif': 'Verdana'
475
- }
476
- }
477
- }
478
- });
479
-
480
- clickTrigger('font', editor);
481
-
482
- const list = getOpenedPopup(editor);
483
-
484
- expect(
485
- list &&
486
- window.getComputedStyle(list).display === 'block' &&
487
- list.parentNode != null
488
- ).is.true;
489
-
490
- expect(list.textContent.match('Custom')).is.not.null;
491
- });
492
-
493
- it('Should change default FONT size list in toolbar', function () {
494
- const editor = getJodit({
495
- toolbarAdaptive: false,
496
- controls: {
497
- fontsize: {
498
- list: Jodit.atom('8,9,10'.split(','))
499
- }
500
- }
501
- });
502
-
503
- clickTrigger('fontsize', editor);
504
-
505
- const list = getOpenedPopup(editor);
506
-
507
- expect(list.getElementsByTagName('button').length).equals(
508
- 3
509
- );
510
- });
511
- });
512
- });
513
-
514
- it('Open and close list after clicking in another place', function () {
515
- const editor = getJodit();
516
-
517
- clickTrigger('fontsize', editor);
518
-
519
- const list = getOpenedPopup(editor);
520
-
521
- expect(list && window.getComputedStyle(list).display === 'block').is
522
- .true;
523
-
524
- simulateEvent('mousedown', 0, window);
525
-
526
- expect(list && list.parentNode == null).is.true;
527
- });
528
-
529
- it('Open format list set H1 for current cursor position. Restore selection after that', function () {
530
- const editor = getJodit();
531
-
532
- editor.value = 'text2text';
533
-
534
- const range = editor.s.createRange();
535
-
536
- range.setStart(editor.editor.firstChild.firstChild, 3);
537
- range.setEnd(editor.editor.firstChild.firstChild, 6);
538
- editor.s.selectRange(range);
539
-
540
- clickTrigger('paragraph', editor);
541
-
542
- const list = getOpenedPopup(editor);
543
-
544
- expect(window.getComputedStyle(list).display).equals('block');
545
-
546
- clickButton('h1', list);
547
-
548
- expect(editor.value).equals('<h1>text2text</h1>');
549
-
550
- simulateEvent('mousedown', 0, editor.editor);
551
-
552
- expect(list.parentNode).is.null;
553
-
554
- editor.s.insertNode(editor.createInside.text(' a '));
555
-
556
- expect(editor.value).equals('<h1>tex a ext</h1>');
557
- });
558
-
559
- it('Open video dialog and insert video by url from youtube.', function () {
560
- const editor = getJodit({
561
- disablePlugins: 'mobile'
562
- });
563
-
564
- editor.value = '';
565
-
566
- clickButton('video', editor);
567
-
568
- const popup = getOpenedPopup(editor);
569
-
570
- popup.querySelector('input[name=url]').value =
571
- 'sddhttps://www.youtube.com/watch?v=7CcEYRfxUOQ'; // try wrong url
572
-
573
- simulateEvent('submit', popup.querySelector('.jodit-ui-form'));
574
-
575
- expect(
576
- popup.querySelectorAll(
577
- '.jodit-ui-input.jodit-ui-input_has-error_true'
578
- ).length
579
- ).equals(1);
580
-
581
- popup.querySelector('input[name=url]').value =
582
- 'https://www.youtube.com/watch?v=7CcEYRfxUOQ';
583
-
584
- simulateEvent('submit', popup.querySelector('.jodit-ui-form'));
585
-
586
- expect(sortAttributes(editor.value)).equals(
587
- '<iframe allowfullscreen="" frameborder="0" height="345" src="https://www.youtube.com/embed/7CcEYRfxUOQ" width="400"></iframe>'
588
- );
589
-
590
- simulateEvent('mousedown', 0, editor.editor);
591
-
592
- expect(popup.parentNode).is.null;
593
- });
594
-
595
- it('Open align list and choose Right align.', function () {
596
- const editor = getJodit();
597
-
598
- editor.value = 'Test';
599
-
600
- clickTrigger('left', editor);
601
-
602
- const list = getOpenedPopup(editor);
603
-
604
- expect(window.getComputedStyle(list).display).equals('block');
605
-
606
- clickButton('right', list);
607
-
608
- expect(sortAttributes(editor.value)).equals(
609
- '<p style="text-align:right">Test</p>'
610
- );
611
-
612
- simulateEvent('mousedown', 0, editor.editor);
613
-
614
- expect(list.parentNode).is.null;
615
- });
616
-
617
- describe('Click inside the link', function () {
618
- it('Should open link popup', function () {
619
- const editor = getJodit({
620
- observer: {
621
- timeout: 0
622
- }
623
- });
624
-
625
- editor.value = 'test test <a href="#">test</a>';
626
-
627
- simulateEvent('click', editor.editor.querySelector('a'));
628
-
629
- const popup = getOpenedPopup(editor);
630
-
631
- expect(popup).is.not.null;
632
- });
633
-
634
- describe('Click on pencil', function () {
635
- it('Should open edit link popup', function () {
636
- const editor = getJodit({
637
- observer: {
638
- timeout: 0
639
- }
640
- });
641
-
642
- editor.value = 'test test <a href="#">test</a>';
643
-
644
- simulateEvent('click', editor.editor.querySelector('a'));
645
-
646
- const popup = getOpenedPopup(editor);
647
-
648
- expect(popup).is.not.null;
649
-
650
- const pencil = getButton('link', popup);
651
- expect(pencil).is.not.null;
652
-
653
- simulateEvent('click', pencil);
654
- const subpopup = getOpenedPopup(editor);
655
-
656
- expect(subpopup).is.not.null;
657
- expect(window.getComputedStyle(subpopup).display).equals(
658
- 'block'
659
- );
660
- expect(popup.parentNode.parentNode.parentNode).is.not.null;
661
- });
662
- });
663
- });
664
-
665
- describe('Create table', function () {
666
- describe('Mouse move', function () {
667
- it('Should highlight cells in table-creator', function () {
668
- const editor = getJodit();
669
- clickButton('table', editor);
670
-
671
- const list = getOpenedPopup(editor);
672
-
673
- expect(window.getComputedStyle(list).display).equals(
674
- 'block'
675
- );
676
-
677
- simulateEvent(
678
- 'mousemove',
679
- list.querySelectorAll('.jodit-form__container span')[14]
680
- );
681
-
682
- expect(
683
- list.querySelectorAll(
684
- '.jodit-form__container span.jodit_hovered'
685
- ).length
686
- ).equals(10);
687
- });
688
-
689
- describe('In iframe mode', function () {
690
- it('Should works same way', function () {
691
- const editor = getJodit({
692
- iframe: true
693
- });
694
-
695
- clickButton('table', editor);
696
-
697
- const list = getOpenedPopup(editor);
698
-
699
- expect(window.getComputedStyle(list).display).equals(
700
- 'block'
701
- );
702
-
703
- const divs = list.querySelectorAll(
704
- '.jodit-form__container span'
705
- );
706
-
707
- expect(divs.length).to.be.above(10);
708
-
709
- simulateEvent('mousemove', 0, divs[14]);
710
-
711
- expect(
712
- list.querySelectorAll(
713
- '.jodit-form__container span.jodit_hovered'
714
- ).length
715
- ).equals(10);
716
- });
717
- });
718
- });
719
- });
720
- });
721
-
722
- describe('Buttons', function () {
723
- describe('Buttons list', function () {
724
- it('Should allow get flat buttons list', function () {
725
- const editor = getJodit({
726
- buttons: [
727
- {
728
- group: 'source1',
729
- buttons: ['source', 'selectall']
730
- },
731
- {
732
- group: 'font-style1',
733
- buttons: ['bold', 'italic']
734
- },
735
- '\n',
736
- {
737
- group: 'history1',
738
- buttons: ['redo', 'undo']
739
- }
740
- ]
741
- });
742
- console.log(editor.toolbar.getButtonsNames());
743
-
744
- expect(editor.toolbar.getButtonsNames()).deep.eq([
745
- 'source',
746
- 'selectall',
747
- 'bold',
748
- 'italic',
749
- 'redo',
750
- 'undo'
751
- ]);
752
- });
753
- });
754
-
755
- describe('Text mode', function () {
756
- it('Should work i18n', function () {
757
- const editor = getJodit({
758
- textIcons: true,
759
- language: 'ru'
760
- }),
761
- editor2 = getJodit({
762
- textIcons: true,
763
- language: 'en'
764
- });
765
-
766
- const label1 = getButton('source', editor).textContent,
767
- label2 = getButton('source', editor2).textContent;
768
-
769
- expect(label1).does.not.equal(label2);
770
- });
771
-
772
- it('Should create buttons with text', function () {
773
- const editor = getJodit({
774
- textIcons: true
775
- });
776
-
777
- expect(getButton('source', editor)).is.not.null;
778
-
779
- expect(
780
- getButton('source', editor).querySelectorAll('svg').length
781
- ).equals(0);
782
- });
783
-
784
- it("Should add jodit_text_icons class to editor's container", function () {
785
- const editor = getJodit({
786
- textIcons: true
787
- });
788
-
789
- expect(
790
- getButton(
791
- 'source',
792
- editor
793
- ).parentElement.className.includes('text-icons_true')
794
- ).is.true;
795
- });
796
-
797
- it('Should set font-size more them 0', function () {
798
- const editor = getJodit({
799
- textIcons: true
800
- });
801
-
802
- expect(
803
- parseInt(
804
- editor.ownerWindow.getComputedStyle(
805
- getButton('source', editor)
806
- ).fontSize,
807
- 10
808
- )
809
- ).to.be.above(10);
810
- });
811
-
812
- describe('In tabs', function () {
813
- it('Should be also only text', function () {
814
- const editor = getJodit({
815
- textIcons: true
816
- });
817
-
818
- clickButton('image', editor);
819
-
820
- const popup = getOpenedPopup(editor);
821
-
822
- expect(popup).is.not.null;
823
-
824
- expect(popup.querySelectorAll('svg, img').length).equals(0);
825
- });
826
- });
827
-
828
- describe('In video popup', function () {
829
- it('Should be also only text', function () {
830
- const editor = getJodit({
831
- textIcons: true,
832
- toolbarAdaptive: false
833
- });
834
-
835
- clickButton('video', editor);
836
-
837
- const popup = getOpenedPopup(editor);
838
-
839
- expect(popup).is.not.null;
840
-
841
- expect(popup.querySelectorAll('svg, img').length).equals(0);
842
- });
843
- });
844
- });
845
-
846
- describe('Set empty Jodit.atom', function () {
847
- it('Should remove all buttons', function () {
848
- const editor = getJodit({
849
- buttons: []
850
- });
851
-
852
- expect(getButton('source', editor)).is.null;
853
- editor.destruct();
854
-
855
- const editor2 = getJodit({
856
- buttons: Jodit.atom([])
857
- });
858
-
859
- expect(getButton('source', editor2)).is.null;
860
- });
861
- });
862
-
863
- it('Remove default buttons functionality', function () {
864
- const editor = getJodit();
865
- expect(getButton('source', editor)).is.not.null;
866
- editor.destruct();
867
-
868
- const editor2 = getJodit({
869
- removeButtons: ['source']
870
- });
871
-
872
- expect(getButton('source', editor2)).is.null;
873
- });
874
-
875
- it('Add own button', function () {
876
- const editor = getJodit({
877
- disablePlugins: ['mobile'],
878
- buttons: Jodit.defaultOptions.buttons.concat([
879
- {
880
- name: 'insertDate',
881
- iconURL: 'http://xdsoft.net/jodit/images/logo.png',
882
- exec: function (editor) {
883
- editor.s.insertHTML(
884
- new Date('2016/03/16').toDateString()
885
- );
886
- }
887
- }
888
- ])
889
- });
890
-
891
- const button = getButton('insertDate', editor);
892
-
893
- expect(button).is.not.null;
894
-
895
- editor.value = '';
896
-
897
- simulateEvent('click', 0, button);
898
- expect(editor.value).equals('<p>Wed Mar 16 2016</p>');
899
- });
900
-
901
- it('When cursor inside STRONG tag, Bold button should be selected', function () {
902
- const editor = getJodit({
903
- observer: {
904
- timeout: 0 // disable delay
905
- }
906
- }),
907
- bold = getButton('bold', editor),
908
- italic = getButton('italic', editor);
909
-
910
- editor.value =
911
- '<strong>test</strong><em>test2</em><i>test3</i><b>test3</b>';
912
- editor.s.focus();
913
-
914
- const sel = editor.s.sel,
915
- range = editor.s.createRange();
916
-
917
- range.setStart(editor.editor.firstChild.firstChild.firstChild, 2);
918
- range.collapse(true);
919
- sel.removeAllRanges();
920
- sel.addRange(range);
921
-
922
- simulateEvent('mousedown', 0, editor.editor);
923
-
924
- expect(bold.getAttribute('aria-pressed')).equals('true');
925
-
926
- range.setStart(
927
- editor.editor.firstChild.firstChild.nextSibling.firstChild,
928
- 2
929
- );
930
- range.collapse(true);
931
- sel.removeAllRanges();
932
- sel.addRange(range);
933
-
934
- simulateEvent('mousedown', 0, editor.editor);
935
-
936
- expect(bold.getAttribute('aria-pressed')).equals('false');
937
-
938
- expect(italic.getAttribute('aria-pressed')).equals('true');
939
-
940
- range.setStart(
941
- editor.editor.firstChild.firstChild.nextSibling.nextSibling
942
- .firstChild,
943
- 2
944
- );
945
- range.collapse(true);
946
- sel.removeAllRanges();
947
- sel.addRange(range);
948
-
949
- simulateEvent('mousedown', 0, editor.editor);
950
-
951
- expect(bold.getAttribute('aria-pressed')).equals('false');
952
- expect(italic.getAttribute('aria-pressed')).equals('true');
953
-
954
- range.setStart(
955
- editor.editor.firstChild.firstChild.nextSibling.nextSibling
956
- .nextSibling.firstChild,
957
- 2
958
- );
959
- range.collapse(true);
960
- sel.removeAllRanges();
961
- sel.addRange(range);
962
-
963
- simulateEvent('mousedown', 0, editor.editor);
964
-
965
- expect(bold.getAttribute('aria-pressed')).equals('true');
966
- expect(italic.getAttribute('aria-pressed')).equals('false');
967
- });
968
-
969
- describe('Disable for mode', function () {
970
- it('Should disable buttons which can not be used in that mode', function () {
971
- const editor = getJodit({
972
- observer: {
973
- timeout: 0 // disable delay
974
- }
975
- });
976
-
977
- editor.value =
978
- '<strong>test</strong><em>test2</em><i>test3</i><b>test3</b>';
979
-
980
- editor.setMode(Jodit.MODE_SOURCE);
981
-
982
- expect(getButton('bold', editor).hasAttribute('disabled')).is
983
- .true;
984
- expect(getButton('source', editor).hasAttribute('disabled')).is
985
- .false;
986
-
987
- editor.setMode(Jodit.MODE_WYSIWYG);
988
-
989
- expect(getButton('bold', editor).hasAttribute('disabled')).is
990
- .false;
991
- expect(getButton('source', editor).hasAttribute('disabled')).is
992
- .false;
993
- });
994
-
995
- describe('For list', function () {
996
- describe('enable', function () {
997
- it('Should enable buttons which can be used in this mode', function () {
998
- const editor = getJodit({
999
- observer: {
1000
- timeout: 0 // disable delay
1001
- },
1002
- defaultMode: Jodit.MODE_SOURCE,
1003
- buttons: [
1004
- {
1005
- name: 'list_test',
1006
- mode: Jodit.MODE_SPLIT,
1007
- list: {
1008
- h1: 'insert Header 1',
1009
- h2: 'insert Header 2',
1010
- clear: 'Empty editor'
1011
- },
1012
- exec: function (editor) {
1013
- const key = this.args[0];
1014
-
1015
- if (key === 'clear') {
1016
- this.val('');
1017
- return;
1018
- }
1019
-
1020
- editor.s.insertHTML(
1021
- '&nbsp;{{test' + key + '}}&nbsp;'
1022
- );
1023
- },
1024
- childTemplate: function (key, value) {
1025
- return '<div>' + value + '</div>';
1026
- }
1027
- }
1028
- ]
1029
- });
1030
-
1031
- const btn = getButton('list_test', editor);
1032
- expect(btn).is.not.null;
1033
-
1034
- expect(btn.hasAttribute('disabled')).to.be.false;
1035
-
1036
- clickTrigger('list_test', editor);
1037
-
1038
- const list = getOpenedPopup(editor);
1039
- expect(list).is.not.null;
1040
-
1041
- expect(
1042
- list.querySelectorAll('.jodit_disabled').length
1043
- ).equals(0);
1044
- });
1045
- });
1046
-
1047
- describe('disable', function () {
1048
- it('Should disable buttons which can not be used in that mode', function () {
1049
- const editor = getJodit({
1050
- observer: {
1051
- timeout: 0 // disable delay
1052
- },
1053
- defaultMode: Jodit.MODE_SOURCE,
1054
- buttons: [
1055
- {
1056
- name: 'list_test',
1057
- mode: Jodit.MODE_WYSIWYG,
1058
- list: {
1059
- h1: 'insert Header 1',
1060
- h2: 'insert Header 2',
1061
- clear: 'Empty editor'
1062
- },
1063
- exec: function (editor) {
1064
- const key = this.args[0];
1065
-
1066
- if (key === 'clear') {
1067
- this.val('');
1068
- return;
1069
- }
1070
-
1071
- editor.s.insertHTML(
1072
- '&nbsp;{{test' + key + '}}&nbsp;'
1073
- );
1074
- },
1075
- childTemplate: function (key, value) {
1076
- return '<div>' + value + '</div>';
1077
- }
1078
- }
1079
- ]
1080
- });
1081
-
1082
- const btn = getButton('list_test', editor);
1083
- expect(btn).is.not.null;
1084
-
1085
- expect(btn.hasAttribute('disabled')).to.be.true;
1086
-
1087
- simulateEvent('mousedown', 0, btn);
1088
-
1089
- const list = btn.querySelector('.jodit_toolbar_list');
1090
- expect(list).is.null;
1091
- });
1092
- });
1093
- });
1094
- });
1095
-
1096
- describe('Set size', function () {
1097
- it('Should add modification to button', function () {
1098
- const editor = getJodit({
1099
- toolbarButtonSize: 'small'
1100
- });
1101
-
1102
- expect(
1103
- getButton(
1104
- 'source',
1105
- editor
1106
- ).parentElement.classList.contains(
1107
- 'jodit-toolbar-button_size_small'
1108
- )
1109
- ).is.true;
1110
- });
1111
-
1112
- describe('For list', function () {
1113
- describe('enable', function () {
1114
- it('Should enable buttons which can be used in this mode', function () {
1115
- const editor = getJodit({
1116
- observer: {
1117
- timeout: 0 // disable delay
1118
- },
1119
- defaultMode: Jodit.MODE_SOURCE,
1120
- buttons: [
1121
- {
1122
- name: 'list_test',
1123
- mode: Jodit.MODE_SPLIT,
1124
- list: {
1125
- h1: 'insert Header 1',
1126
- h2: 'insert Header 2',
1127
- clear: 'Empty editor'
1128
- },
1129
- exec: function (editor) {
1130
- const key = this.args[0];
1131
-
1132
- if (key === 'clear') {
1133
- this.val('');
1134
- return;
1135
- }
1136
-
1137
- editor.s.insertHTML(
1138
- '&nbsp;{{test' + key + '}}&nbsp;'
1139
- );
1140
- },
1141
- childTemplate: function (key, value) {
1142
- return '<div>' + value + '</div>';
1143
- }
1144
- }
1145
- ]
1146
- });
1147
-
1148
- const btn = getButton('list_test', editor);
1149
- expect(btn).is.not.null;
1150
-
1151
- expect(btn.hasAttribute('disabled')).to.be.false;
1152
-
1153
- clickTrigger('list_test', editor);
1154
-
1155
- const list = getOpenedPopup(editor);
1156
- expect(list).is.not.null;
1157
-
1158
- expect(
1159
- list.querySelectorAll('.jodit_disabled').length
1160
- ).equals(0);
1161
- });
1162
- });
1163
-
1164
- describe('disable', function () {
1165
- it('Should disable buttons which can not be used in that mode', function () {
1166
- const editor = getJodit({
1167
- observer: {
1168
- timeout: 0 // disable delay
1169
- },
1170
- defaultMode: Jodit.MODE_SOURCE,
1171
- buttons: [
1172
- {
1173
- name: 'list_test',
1174
- mode: Jodit.MODE_WYSIWYG,
1175
- list: {
1176
- h1: 'insert Header 1',
1177
- h2: 'insert Header 2',
1178
- clear: 'Empty editor'
1179
- },
1180
- exec: function (editor) {
1181
- const key = this.args[0];
1182
-
1183
- if (key === 'clear') {
1184
- this.val('');
1185
- return;
1186
- }
1187
-
1188
- editor.s.insertHTML(
1189
- '&nbsp;{{test' + key + '}}&nbsp;'
1190
- );
1191
- },
1192
- childTemplate: function (key, value) {
1193
- return '<div>' + value + '</div>';
1194
- }
1195
- }
1196
- ]
1197
- });
1198
-
1199
- const btn = getButton('list_test', editor);
1200
- expect(btn).is.not.null;
1201
-
1202
- expect(btn.hasAttribute('disabled')).to.be.true;
1203
-
1204
- simulateEvent('mousedown', 0, btn);
1205
-
1206
- const list = btn.querySelector('.jodit_toolbar_list');
1207
- expect(list).is.null;
1208
- });
1209
- });
1210
- });
1211
- });
1212
-
1213
- describe('Allow tab navigation', function () {
1214
- describe('Enable', function () {
1215
- it('Should set tabindex=0 for all buttons', function () {
1216
- const editor = getJodit({
1217
- allowTabNavigation: true
1218
- });
1219
-
1220
- expect(
1221
- getButton('source', editor).getAttribute('tabindex')
1222
- ).equals('0');
1223
- });
1224
- });
1225
-
1226
- describe('Disable', function () {
1227
- it('Should set tabindex=-1 for all buttons', function () {
1228
- const editor = getJodit({
1229
- allowTabNavigation: false // default
1230
- });
1231
-
1232
- expect(
1233
- getButton('source', editor).getAttribute('tabindex')
1234
- ).equals('-1');
1235
- });
1236
- });
1237
- });
1238
-
1239
- it('When cursor inside SPAN tag with style="font-weight: bold" or style="font-weight: 700", Bold button should be selected', function () {
1240
- const editor = getJodit({
1241
- observer: {
1242
- timeout: 0 // disable delay
1243
- }
1244
- }),
1245
- bold = getButton('bold', editor);
1246
-
1247
- editor.value = '<span style="font-weight: bold">test</span>';
1248
- editor.s.focus();
1249
-
1250
- const sel = editor.s.sel,
1251
- range = editor.s.createRange();
1252
- range.setStart(editor.editor.firstChild.firstChild.firstChild, 2);
1253
- range.collapse(true);
1254
- sel.removeAllRanges();
1255
- sel.addRange(range);
1256
-
1257
- simulateEvent('mousedown', 0, editor.editor);
1258
-
1259
- expect(bold.getAttribute('aria-pressed')).equals('true');
1260
- });
1261
-
1262
- describe('Check Redo Undo functionality', function () {
1263
- it('Should change disable in icon then then can not be executed', function () {
1264
- const area = appendTestArea();
1265
- area.value = 'top';
1266
- const editor = new Jodit(area, {
1267
- observer: {
1268
- timeout: 0 // disable delay
1269
- }
1270
- });
1271
-
1272
- editor.value = 'Test';
1273
-
1274
- expect(getButton('undo', editor).hasAttribute('disabled')).is
1275
- .false;
1276
- expect(getButton('redo', editor).hasAttribute('disabled')).is
1277
- .true;
1278
-
1279
- clickButton('undo', editor);
1280
-
1281
- expect(getButton('undo', editor).hasAttribute('disabled')).is
1282
- .true;
1283
- expect(getButton('redo', editor).hasAttribute('disabled')).is
1284
- .false;
1285
-
1286
- expect(editor.value).equals('<p>top</p>');
1287
- });
1288
- });
1289
-
1290
- it('Full size button', function () {
1291
- const editor = getJodit({
1292
- observer: {
1293
- timeout: 0 // disable delay
1294
- }
1295
- });
1296
-
1297
- clickButton('fullsize', editor);
1298
-
1299
- let node = editor.container.parentNode;
1300
-
1301
- while (node && node.nodeType !== Node.DOCUMENT_NODE) {
1302
- expect(
1303
- node.classList.contains('jodit_fullsize-box_true')
1304
- ).equals(true);
1305
- node = node.parentNode;
1306
- }
1307
- });
1308
-
1309
- describe('Extra buttons', function () {
1310
- describe('Options extraButtons', function () {
1311
- it('Should add extra buttons', function () {
1312
- const editor = getJodit({
1313
- extraButtons: [
1314
- {
1315
- name: 'adddate',
1316
- exec: function (editor) {
1317
- const a = editor.createInside.text('111');
1318
- editor.s.insertNode(a);
1319
- }
1320
- }
1321
- ]
1322
- });
1323
-
1324
- editor.value = '';
1325
-
1326
- expect(getButton('adddate', editor)).is.not.null;
1327
-
1328
- clickButton('adddate', editor);
1329
-
1330
- expect(editor.value).equals('<p>111</p>');
1331
- });
1332
-
1333
- describe('extraButtons always append in the end', function () {
1334
- it('Should add extra buttons on postion by buttons potions', function () {
1335
- const editor = getJodit({
1336
- buttons: [
1337
- 'indent',
1338
- 'outdent',
1339
- 'bold',
1340
- 'adddate',
1341
- 'dots'
1342
- ],
1343
- disablePlugins: 'mobile',
1344
- extraButtons: [
1345
- {
1346
- name: 'adddate',
1347
- exec: function (editor) {
1348
- const a =
1349
- editor.createInside.text('111');
1350
- editor.s.insertNode(a);
1351
- }
1352
- }
1353
- ]
1354
- });
1355
-
1356
- expect(
1357
- editor.toolbar.getButtonsNames().toString()
1358
- ).equals('indent,outdent,bold,adddate,dots,adddate');
1359
- });
1360
- });
1361
- });
1362
- });
1363
-
1364
- describe('Add button', function () {
1365
- it('Should create buttons in toolbar', function () {
1366
- const editor = getJodit({
1367
- buttons: ['indent', 'outdent', 'bold', 'customxxx'],
1368
- disablePlugins: 'mobile'
1369
- });
1370
-
1371
- expect(getButton('indent', editor)).is.not.null;
1372
- expect(getButton('outdent', editor)).is.not.null;
1373
- expect(getButton('bold', editor)).is.not.null;
1374
- expect(getButton('customxxx', editor)).is.not.null;
1375
- expect(getButton('source', editor)).is.null;
1376
- });
1377
- });
1378
-
1379
- describe('Button Bold', function () {
1380
- describe('In collapsed selection', function () {
1381
- it('Should reactivate Bold button after second click and move cursor out of Strong element', function () {
1382
- const editor = getJodit({
1383
- buttons: ['bold']
1384
- });
1385
-
1386
- editor.value = '<p>test</p>';
1387
- editor.s.setCursorAfter(
1388
- editor.editor.firstChild.firstChild
1389
- );
1390
-
1391
- clickButton('bold', editor);
1392
- editor.s.insertHTML('text');
1393
- clickButton('bold', editor);
1394
- editor.s.insertHTML('text');
1395
-
1396
- expect(editor.value).equals(
1397
- '<p>test<strong>text</strong>text</p>'
1398
- );
1399
- });
1400
- });
1401
-
1402
- describe('Not collapsed selection', function () {
1403
- it('Should reactivate Bold button after second click and move cursor out of Strong element', function () {
1404
- const editor = getJodit({
1405
- buttons: ['bold']
1406
- });
1407
-
1408
- editor.value = 'test test test';
1409
-
1410
- const range = editor.s.createRange();
1411
- range.setStart(editor.editor.firstChild.firstChild, 0);
1412
- range.setEnd(editor.editor.firstChild.firstChild, 4);
1413
-
1414
- editor.s.selectRange(range);
1415
-
1416
- clickButton('bold', editor);
1417
-
1418
- expect(editor.value).equals(
1419
- '<p><strong>test</strong> test test</p>'
1420
- );
1421
- });
1422
- });
1423
- });
1424
-
1425
- describe('Active button', function () {
1426
- it('Should not be activated then element has default style', function () {
1427
- const editor = getJodit({
1428
- observer: {
1429
- timeout: 0
1430
- }
1431
- });
1432
-
1433
- editor.value = '<p>test<strong>bold</strong></p>';
1434
- editor.s.focus();
1435
-
1436
- const p = editor.editor.firstChild;
1437
- editor.s.setCursorAfter(p.firstChild);
1438
-
1439
- simulateEvent('mousedown', 0, p);
1440
-
1441
- const bold = getButton('bold', editor);
1442
- const align = getButton('left', editor);
1443
-
1444
- expect(bold.getAttribute('aria-pressed')).equals('false');
1445
- expect(align.getAttribute('aria-pressed')).equals('false');
1446
-
1447
- editor.s.setCursorIn(p.querySelector('strong').firstChild);
1448
- simulateEvent('mousedown', 0, p);
1449
- // editor.s.insertHTML('ddd');
1450
- expect(bold.getAttribute('aria-pressed')).equals('true');
1451
- expect(align.getAttribute('aria-pressed')).equals('false');
1452
-
1453
- p.style.textAlign = 'right';
1454
- simulateEvent('mousedown', 0, p);
1455
- expect(bold.getAttribute('aria-pressed')).equals('true');
1456
- expect(align.getAttribute('aria-pressed')).equals('true');
1457
- });
1458
-
1459
- describe('In list', function () {
1460
- describe('Format block button', function () {
1461
- it('Should be activated then element has some tagname', function () {
1462
- const editor = getJodit({
1463
- observer: {
1464
- timeout: 0
1465
- }
1466
- });
1467
-
1468
- editor.value =
1469
- '<p>test</p><h1>test</h1><code>test</code>';
1470
- editor.s.focus();
1471
-
1472
- const p = editor.editor.firstChild;
1473
- const paragraph = getButton('paragraph', editor);
1474
-
1475
- expect(paragraph).is.not.null;
1476
-
1477
- editor.s.setCursorAfter(p.firstChild);
1478
- simulateEvent('mousedown', 0, p);
1479
- expect(paragraph.getAttribute('aria-pressed')).equals(
1480
- 'false'
1481
- );
1482
-
1483
- editor.s.setCursorIn(editor.editor.childNodes[1]);
1484
-
1485
- simulateEvent('mousedown', 0, p);
1486
- expect(paragraph.getAttribute('aria-pressed')).equals(
1487
- 'true'
1488
- );
1489
-
1490
- clickTrigger('paragraph', editor);
1491
-
1492
- const header =
1493
- getOpenedPopup(editor).querySelector('[class*=h1]');
1494
- expect(header.getAttribute('aria-pressed')).equals(
1495
- 'true'
1496
- );
1497
- });
1498
- });
1499
- });
1500
-
1501
- describe('Select text with several properties', function () {
1502
- it('Should select all buttons with conditions', function () {
1503
- const editor = getJodit({
1504
- observer: {
1505
- timeout: 0
1506
- }
1507
- });
1508
-
1509
- editor.value = '<em><strong><u>bold</u></strong></em>';
1510
- editor.s.focus();
1511
-
1512
- const range = editor.s.createRange();
1513
- range.setStartBefore(editor.editor.firstChild);
1514
- range.setEndAfter(editor.editor.firstChild);
1515
- editor.s.selectRange(range);
1516
-
1517
- const bold = getButton('bold', editor);
1518
-
1519
- const italic = getButton('italic', editor);
1520
-
1521
- const underline = getButton('underline', editor);
1522
-
1523
- expect(bold.getAttribute('aria-pressed')).equals('true');
1524
-
1525
- expect(italic.getAttribute('aria-pressed')).equals('true');
1526
-
1527
- expect(underline.getAttribute('aria-pressed')).equals(
1528
- 'true'
1529
- );
1530
- });
1531
- });
1532
- });
1533
-
1534
- describe('Disable button', function () {
1535
- describe('Cut and Copy', function () {
1536
- describe('Cut', function () {
1537
- it('Should be activated editor has some selected text', function () {
1538
- const editor = getJodit({
1539
- toolbarAdaptive: false,
1540
- observer: {
1541
- timeout: 0
1542
- }
1543
- });
1544
-
1545
- const cut = getButton('cut', editor);
1546
-
1547
- editor.value = '<p>test<strong>bold</strong></p>';
1548
- editor.s.focus();
1549
-
1550
- expect(cut.hasAttribute('disabled')).is.true;
1551
-
1552
- const p = editor.editor.firstChild;
1553
-
1554
- editor.s.select(p.firstChild);
1555
-
1556
- expect(cut.hasAttribute('disabled')).is.false;
1557
- });
1558
- });
1559
-
1560
- describe('Copy', function () {
1561
- it('Should be activated editor has some selected text', function () {
1562
- const editor = getJodit({
1563
- toolbarAdaptive: false,
1564
- observer: {
1565
- timeout: 0
1566
- }
1567
- });
1568
-
1569
- const copy = getButton('copy', editor);
1570
-
1571
- editor.value = '<p>test<strong>bold</strong></p>';
1572
- editor.s.focus();
1573
-
1574
- expect(copy.hasAttribute('disabled')).is.true;
1575
-
1576
- const p = editor.editor.firstChild;
1577
-
1578
- editor.s.select(p.firstChild);
1579
-
1580
- expect(copy.hasAttribute('disabled')).is.false;
1581
- });
1582
- });
1583
- });
1584
- });
1585
- });
1586
-
1587
- describe('Commands', function () {
1588
- it('Click on Source button should change current mode', function () {
1589
- const editor = getJodit();
1590
-
1591
- clickButton('source', editor);
1592
-
1593
- expect(editor.getMode()).equals(Jodit.MODE_SOURCE);
1594
- });
1595
-
1596
- it('Click on Bold button should wrap current selection in <strong>', function () {
1597
- const editor = getJodit();
1598
-
1599
- editor.value = 'Text to text';
1600
- editor.s.focus();
1601
-
1602
- const range = editor.s.createRange();
1603
- range.setStart(editor.editor.firstChild.firstChild, 3);
1604
- range.setEnd(editor.editor.firstChild.firstChild, 10);
1605
- editor.s.selectRange(range);
1606
-
1607
- clickButton('bold', editor);
1608
-
1609
- expect(editor.value).equals('<p>Tex<strong>t to te</strong>xt</p>');
1610
- });
1611
-
1612
- it('Click on Italic button when selection is collapsed should create new <em> element and set cursor into it', function () {
1613
- const editor = getJodit();
1614
-
1615
- editor.value = 'Text to text';
1616
- editor.s.focus();
1617
-
1618
- const range = editor.s.createRange();
1619
- range.setStart(editor.editor.firstChild.firstChild, 0);
1620
- range.collapse(true);
1621
- editor.s.selectRange(range);
1622
-
1623
- clickButton('italic', editor);
1624
-
1625
- editor.s.insertHTML('test');
1626
-
1627
- expect(editor.value).equals('<p><em>test</em>Text to text</p>');
1628
- });
1629
- });
1630
-
1631
- describe('In fileBrowser', function () {
1632
- describe('Hide buttons ', function () {
1633
- it('should hide toolbar buttons', function () {
1634
- const editor = getJodit({
1635
- filebrowser: {
1636
- buttons: Jodit.atom([
1637
- 'filebrowser.list',
1638
- 'filebrowser.tiles',
1639
- 'filebrowser.sort'
1640
- ]),
1641
- ajax: {
1642
- url: 'https://xdsoft.net/jodit/connector/index.php'
1643
- }
1644
- }
1645
- });
1646
-
1647
- clickButton('image', editor);
1648
-
1649
- const popup = getOpenedPopup(editor);
1650
-
1651
- expect(popup).is.not.null;
1652
-
1653
- simulateEvent('click', popup.querySelector('button'));
1654
- const dialog = getOpenedDialog(editor);
1655
-
1656
- expect(dialog).is.not.null;
1657
-
1658
- expect(3).equals(
1659
- dialog.querySelectorAll(
1660
- '.jodit-dialog__header .jodit-dialog__header-title button,' +
1661
- '.jodit-dialog__header .jodit-dialog__header-title select'
1662
- ).length
1663
- );
1664
- });
1665
- });
1666
- });
1667
-
1668
- describe('One toolbar for several editors', function () {
1669
- it('Should create one Jodit instance but with several edit places', function () {
1670
- const toolbarBox = appendTestDiv(),
1671
- firstEditPlace = appendTestDiv('firstEditPlace'),
1672
- secondEditPlace = appendTestDiv('secondEditPlace'),
1673
- thirdEditPlace = appendTestDiv('thirdEditPlace'),
1674
- editor = Jodit.make(firstEditPlace);
1675
-
1676
- editor.setPanel(toolbarBox);
1677
-
1678
- editor.value = 'first';
1679
-
1680
- editor.addPlace(secondEditPlace);
1681
- editor.value = 'second';
1682
-
1683
- editor.addPlace(thirdEditPlace);
1684
- editor.value = 'third';
1685
-
1686
- expect(Jodit.instances.firstEditPlace).equals(editor);
1687
- expect(Jodit.instances.secondEditPlace).equals(undefined);
1688
- expect(Jodit.instances.thirdEditPlace).equals(undefined);
1689
-
1690
- editor.destruct();
1691
-
1692
- expect(firstEditPlace.innerHTML).equals('<p>first</p>');
1693
- expect(secondEditPlace.innerHTML).equals('<p>second</p>');
1694
- expect(thirdEditPlace.innerHTML).equals('<p>third</p>');
1695
- });
1696
-
1697
- describe('For all instances you can set self options', function () {
1698
- it('Should change options for all instances', function () {
1699
- const toolbarBox = appendTestDiv(),
1700
- firstEditPlace = appendTestDiv('firstEditPlace'),
1701
- secondEditPlace = appendTestDiv('secondEditPlace'),
1702
- thirdEditPlace = appendTestDiv('thirdEditPlace'),
1703
- editor = Jodit.make(firstEditPlace, {
1704
- disablePlugins: ['WrapTextNodes']
1705
- });
1706
-
1707
- editor.setPanel(toolbarBox);
1708
-
1709
- editor.value = 'first';
1710
-
1711
- editor.addPlace(secondEditPlace, {
1712
- readonly: true,
1713
- showCharsCounter: false,
1714
- showWordsCounter: false,
1715
- showXPathInStatusbar: false
1716
- });
1717
-
1718
- editor.value = 'second';
1719
-
1720
- editor.addPlace(thirdEditPlace, {
1721
- readonly: false,
1722
- showCharsCounter: false,
1723
- showWordsCounter: false,
1724
- showXPathInStatusbar: false
1725
- });
1726
-
1727
- editor.value = 'third';
1728
-
1729
- const editPlaces =
1730
- editor.ownerDocument.querySelectorAll('.jodit-wysiwyg');
1731
- expect(editPlaces.length).equals(3);
1732
-
1733
- simulateEvent('focus', 0, editPlaces[0]);
1734
- expect(editor.options.readonly).is.false;
1735
- expect(editor.options.showCharsCounter).is.true;
1736
-
1737
- simulateEvent('focus', 0, editPlaces[1]);
1738
- expect(editor.options.readonly).is.true;
1739
- expect(editor.options.showCharsCounter).is.false;
1740
-
1741
- simulateEvent('focus', 0, editPlaces[2]);
1742
- expect(editor.options.readonly).is.false;
1743
- expect(editor.options.showCharsCounter).is.false;
1744
- });
1745
- });
1746
- });
1747
- });