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