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,1309 +0,0 @@
1
- /*!
2
- * Jodit Editor (https://xdsoft.net/jodit/)
3
- * Released under MIT see LICENSE.txt in the project root for license information.
4
- * Copyright (c) 2013-2021 Valeriy Chupurnov. All rights reserved. https://xdsoft.net
5
- */
6
-
7
- describe('Jodit FileBrowser Tests', function () {
8
- describe('Constructor/Destructor', function () {
9
- describe('Without Jodit', function () {
10
- it('Should create dialog and load files', function () {
11
- const filebrowser = new Jodit.modules.FileBrowser({
12
- ajax: {
13
- url: 'https://xdsoft.net/jodit/connector/index.php'
14
- }
15
- });
16
-
17
- filebrowser.open(function () {});
18
-
19
- expect(
20
- document.querySelectorAll('.jodit-dialog').length
21
- ).equals(1);
22
-
23
- filebrowser.close();
24
-
25
- expect(
26
- document.querySelectorAll('.jodit-dialog').length
27
- ).equals(0);
28
-
29
- filebrowser.destruct();
30
- });
31
- });
32
-
33
- it('Should create dialog and load files', function () {
34
- const editor = getJodit({
35
- filebrowser: {
36
- ajax: {
37
- url: 'https://xdsoft.net/jodit/connector/index.php'
38
- }
39
- }
40
- });
41
-
42
- const filebrowser = new Jodit.modules.FileBrowser(
43
- editor.o.filebrowser
44
- );
45
- filebrowser.open(function () {});
46
-
47
- expect(
48
- editor.ownerDocument.querySelectorAll('.jodit-dialog').length
49
- ).equals(1);
50
-
51
- filebrowser.destruct();
52
- });
53
-
54
- it('Should add filebrowser icon in image buttons popup', function () {
55
- const editor = getJodit({
56
- filebrowser: {
57
- ajax: {
58
- url: 'https://xdsoft.net/jodit/connector/index.php'
59
- }
60
- }
61
- });
62
-
63
- clickButton('image', editor);
64
-
65
- expect(
66
- getOpenedPopup(editor)
67
- .querySelector('[aria-pressed="true"]')
68
- .innerText.trim()
69
- ).equals('Browse');
70
- });
71
-
72
- it('Should add uploader icon in image buttons popup', function () {
73
- const editor = getJodit({
74
- uploader: {
75
- url: 'https://xdsoft.net/jodit/connector/index.php?action=upload'
76
- },
77
- filebrowser: {
78
- ajax: {
79
- url: 'https://xdsoft.net/jodit/connector/index.php'
80
- }
81
- }
82
- });
83
-
84
- clickButton('image', editor);
85
-
86
- expect(
87
- getOpenedPopup(editor)
88
- .querySelector('[aria-pressed="true"]')
89
- .innerText.trim()
90
- ).equals('Upload');
91
- });
92
-
93
- describe('Without folders panel', function () {
94
- it('Should create dialog and load files', function (done) {
95
- const editor = getJodit({
96
- filebrowser: {
97
- ajax: {
98
- url: 'https://xdsoft.net/jodit/connector/index.php'
99
- },
100
- showFoldersPanel: false
101
- }
102
- });
103
-
104
- const filebrowser = editor.filebrowser;
105
-
106
- filebrowser
107
- .open(function () {})
108
- .then(function () {
109
- const files = filebrowser.browser.querySelector(
110
- '.jodit-filebrowser__files'
111
- );
112
-
113
- expect(files).is.not.null;
114
-
115
- expect(
116
- files.querySelector(
117
- '.jodit-filebrowser__files-item img[data-src="https://xdsoft.net/jodit/files/images.jpg"]'
118
- )
119
- ).is.not.null;
120
-
121
- done();
122
- })
123
- .catch(function (e) {
124
- throw e;
125
- });
126
- });
127
- });
128
- });
129
-
130
- describe('Change Ajax options', function () {
131
- describe('Use GET method instead POST', function () {
132
- it('Should add params into url instead body', function (done) {
133
- const filebrowser = new Jodit.modules.FileBrowser({
134
- ajax: {
135
- url: 'https://xdsoft.net/jodit/connector/index.php',
136
- method: 'GET'
137
- }
138
- });
139
-
140
- filebrowser
141
- .open(function () {})
142
- .then(function () {
143
- Jodit.modules.Ajax.log.forEach(function (req) {
144
- expect(req.url).to.be.match(/\?action/);
145
- });
146
-
147
- filebrowser.destruct();
148
- done();
149
- })
150
- .catch(function (e) {
151
- throw e;
152
- });
153
- });
154
- });
155
-
156
- describe('Use POST method', function () {
157
- it('Should add params only into body', function (done) {
158
- const filebrowser = new Jodit.modules.FileBrowser({
159
- ajax: {
160
- url: 'https://xdsoft.net/jodit/connector/index.php',
161
- method: 'POST'
162
- }
163
- });
164
-
165
- filebrowser
166
- .open(function () {})
167
- .then(function () {
168
- Jodit.modules.Ajax.log.forEach(function (req) {
169
- expect(req.url).equals(
170
- 'https://xdsoft.net/jodit/connector/index.php'
171
- );
172
- });
173
-
174
- filebrowser.destruct();
175
- done();
176
- })
177
- .catch(function (e) {
178
- throw e;
179
- });
180
- });
181
- });
182
- });
183
-
184
- describe('Toolbar', function () {
185
- describe('Without Jodit', function () {
186
- it('Should create filebrowser and show standart toolbar', function (done) {
187
- const filebrowser = new Jodit.modules.FileBrowser({
188
- ajax: {
189
- url: 'https://xdsoft.net/jodit/connector/index.php'
190
- }
191
- });
192
-
193
- filebrowser
194
- .open(function () {})
195
- .then(function () {
196
- expect(
197
- filebrowser.dialog.dialogbox_header.querySelectorAll(
198
- '.jodit-toolbar-button,.jodit-toolbar-content'
199
- ).length
200
- ).equals(9);
201
-
202
- filebrowser.close();
203
- filebrowser.destruct();
204
-
205
- done();
206
- })
207
- .catch(function (e) {
208
- throw e;
209
- });
210
- });
211
- });
212
- describe('Disable buttons', function () {
213
- describe('Edit button', function () {
214
- it('Should be disable while not selected some image', function (done) {
215
- const filebrowser = new Jodit.modules.FileBrowser({
216
- ajax: {
217
- url: 'https://xdsoft.net/jodit/connector/index.php'
218
- }
219
- });
220
-
221
- filebrowser
222
- .open(function () {})
223
- .then(function () {
224
- const edit = getButton(
225
- 'edit',
226
- filebrowser.dialog.dialogbox_header
227
- );
228
- expect(edit).is.not.null;
229
- expect(edit.hasAttribute('disabled')).is.true;
230
-
231
- simulateEvent(
232
- 'click',
233
- filebrowser.browser.querySelector(
234
- '.jodit-filebrowser__files-item[data-is-file="0"]'
235
- )
236
- );
237
-
238
- expect(edit.hasAttribute('disabled')).is.false;
239
-
240
- filebrowser.close();
241
- filebrowser.destruct();
242
-
243
- done();
244
- })
245
- .catch(function (e) {
246
- throw e;
247
- });
248
- });
249
-
250
- it('Should be disabled if selected more then 1 image or some file', function (done) {
251
- const filebrowser = new Jodit.modules.FileBrowser({
252
- ajax: {
253
- url: 'https://xdsoft.net/jodit/connector/index.php'
254
- }
255
- });
256
-
257
- filebrowser
258
- .open(function () {})
259
- .then(function () {
260
- const edit = getButton(
261
- 'edit',
262
- filebrowser.dialog.dialogbox_header
263
- );
264
-
265
- expect(edit.hasAttribute('disabled')).is.true;
266
-
267
- simulateEvent(
268
- 'click',
269
- 0,
270
- filebrowser.browser.querySelectorAll(
271
- '.jodit-filebrowser__files-item[data-is-file="0"]'
272
- )[0]
273
- );
274
-
275
- expect(edit.hasAttribute('disabled')).is.false;
276
-
277
- simulateEvent(
278
- 'click',
279
- 0,
280
- filebrowser.browser.querySelectorAll(
281
- '.jodit-filebrowser__files-item[data-is-file="0"]'
282
- )[1],
283
- function (data) {
284
- data[
285
- !navigator.userAgent.indexOf('Mac OS X')
286
- ? 'ctrlKey'
287
- : 'metaKey'
288
- ] = true;
289
- }
290
- );
291
-
292
- expect(edit.hasAttribute('disabled')).is.true;
293
-
294
- filebrowser.close();
295
- filebrowser.destruct();
296
-
297
- done();
298
- })
299
- .catch(function (e) {
300
- throw e;
301
- });
302
- });
303
-
304
- describe('Allow all buttons if permission handle is not set', function () {
305
- describe('If deny remove action', function () {
306
- it('Should not use permission hash and canI method', function (done) {
307
- defaultPermissions.permissions.allowFileRemove = false;
308
-
309
- const filebrowser = new Jodit.modules.FileBrowser({
310
- ajax: {
311
- url: 'https://xdsoft.net/jodit/connector/index.php'
312
- }
313
- });
314
-
315
- filebrowser
316
- .open(function () {})
317
- .then(function () {
318
- const remove = getButton(
319
- 'remove',
320
- filebrowser.dialog
321
- );
322
- expect(remove).is.not.null;
323
- expect(
324
- remove.hasAttribute('disabled')
325
- ).is.true;
326
-
327
- simulateEvent(
328
- 'click',
329
- 0,
330
- filebrowser.browser.querySelector(
331
- '.jodit-filebrowser__files-item[data-is-file="0"]'
332
- )
333
- );
334
-
335
- expect(
336
- remove.hasAttribute('disabled')
337
- ).is.true;
338
-
339
- filebrowser.close();
340
- filebrowser.destruct();
341
-
342
- done();
343
- })
344
- .catch(function (e) {
345
- throw e;
346
- });
347
- });
348
- });
349
-
350
- describe('If not set permission api option', function () {
351
- it('Should not use permission hash and canI method', function (done) {
352
- defaultPermissions.permissions.allowFileRemove = false;
353
-
354
- const filebrowser = new Jodit.modules.FileBrowser({
355
- ajax: {
356
- url: 'https://xdsoft.net/jodit/connector/index.php'
357
- },
358
- permissions: null
359
- });
360
-
361
- filebrowser
362
- .open(function () {})
363
- .then(function () {
364
- const remove = getButton(
365
- 'remove',
366
- filebrowser.dialog
367
- );
368
- expect(remove).is.not.null;
369
-
370
- expect(
371
- remove.hasAttribute('disabled')
372
- ).is.true;
373
-
374
- simulateEvent(
375
- 'click',
376
- 0,
377
- filebrowser.browser.querySelector(
378
- '.jodit-filebrowser__files-item[data-is-file="0"]'
379
- )
380
- );
381
-
382
- expect(
383
- remove.hasAttribute('disabled')
384
- ).is.false;
385
-
386
- filebrowser.close();
387
- filebrowser.destruct();
388
-
389
- done();
390
- })
391
- .catch(function (e) {
392
- throw e;
393
- });
394
- });
395
- });
396
- });
397
- });
398
- });
399
-
400
- describe('View', function () {
401
- it('Should show filebrowser in default view', function (done) {
402
- const filebrowser = new Jodit.modules.FileBrowser({
403
- view: 'tiles',
404
- ajax: {
405
- url: 'https://xdsoft.net/jodit/connector/index.php'
406
- }
407
- });
408
-
409
- filebrowser
410
- .open(function () {})
411
- .then(function () {
412
- const tiles = getButton('tiles', filebrowser.dialog);
413
- const list = getButton('list', filebrowser.dialog);
414
-
415
- const files = filebrowser.browser.querySelector(
416
- '.jodit-filebrowser__files'
417
- );
418
-
419
- expect(files).is.not.null;
420
- expect(
421
- files.classList.contains(
422
- 'jodit-filebrowser__files_view_tiles'
423
- )
424
- ).is.true;
425
-
426
- expect(tiles.component.state.activated).is.true;
427
- expect(list.component.state.activated).is.false;
428
-
429
- filebrowser.close();
430
- filebrowser.destruct();
431
-
432
- done();
433
- })
434
- .catch(function (e) {
435
- throw e;
436
- });
437
- });
438
-
439
- describe('Change view', function () {
440
- it('Should change filebrowser view', function (done) {
441
- const filebrowser = new Jodit.modules.FileBrowser({
442
- view: 'tiles',
443
- ajax: {
444
- url: 'https://xdsoft.net/jodit/connector/index.php'
445
- }
446
- });
447
-
448
- filebrowser
449
- .open(function () {})
450
- .then(function () {
451
- const tiles = getButton(
452
- 'tiles',
453
- filebrowser.dialog
454
- );
455
- const list = getButton('list', filebrowser.dialog);
456
-
457
- const files = filebrowser.browser.querySelector(
458
- '.jodit-filebrowser__files'
459
- );
460
- expect(files).is.not.null;
461
- expect(
462
- files.classList.contains(
463
- 'jodit-filebrowser__files_view_tiles'
464
- )
465
- ).is.true;
466
-
467
- expect(tiles.component.state.activated).is.true;
468
- expect(list.component.state.activated).is.false;
469
-
470
- simulateEvent('click', 0, list);
471
-
472
- expect(
473
- files.classList.contains(
474
- 'jodit-filebrowser__files_view_tiles'
475
- )
476
- ).is.false;
477
- expect(
478
- files.classList.contains(
479
- 'jodit-filebrowser__files_view_list'
480
- )
481
- ).is.true;
482
- expect(tiles.component.state.activated).is.false;
483
- expect(list.component.state.activated).is.true;
484
-
485
- filebrowser.close();
486
- filebrowser.destruct();
487
-
488
- done();
489
- })
490
- .catch(function (e) {
491
- throw e;
492
- });
493
- });
494
- });
495
- });
496
-
497
- describe('Filter', function () {
498
- it('Should show only filtered items', function (done) {
499
- const filebrowser = new Jodit.modules.FileBrowser({
500
- ajax: {
501
- url: 'https://xdsoft.net/jodit/connector/index.php'
502
- }
503
- });
504
-
505
- filebrowser
506
- .open(function () {})
507
- .then(async function () {
508
- const filter =
509
- filebrowser.dialog.dialogbox_header.querySelector(
510
- '.jodit-toolbar-content_filter'
511
- );
512
- const input = filter.querySelector('input');
513
- const files = filebrowser.browser.querySelector(
514
- '.jodit-filebrowser__files'
515
- );
516
-
517
- expect(files).is.not.null;
518
- expect(filter).is.not.null;
519
- expect(input).is.not.null;
520
-
521
- const count = files.querySelectorAll(
522
- '.jodit-filebrowser__files-item'
523
- ).length;
524
-
525
- input.value = 'i';
526
- simulateEvent('keydown', input);
527
-
528
- await filebrowser.async.requestIdlePromise();
529
-
530
- expect(
531
- files.querySelectorAll(
532
- '.jodit-filebrowser__files-item'
533
- ).length
534
- ).does.not.equal(count);
535
-
536
- input.value = '';
537
- simulateEvent('keydown', input);
538
-
539
- await filebrowser.async.requestIdlePromise();
540
-
541
- expect(
542
- files.querySelectorAll(
543
- '.jodit-filebrowser__files-item'
544
- ).length
545
- ).equals(count);
546
-
547
- filebrowser.close();
548
- filebrowser.destruct();
549
-
550
- done();
551
- })
552
- .catch(function (e) {
553
- throw e;
554
- });
555
- });
556
- });
557
-
558
- describe('Sort', function () {
559
- it('Should sort elements by filter select', function (done) {
560
- const filebrowser = new Jodit.modules.FileBrowser({
561
- ajax: {
562
- url: 'https://xdsoft.net/jodit/connector/index.php'
563
- }
564
- });
565
-
566
- filebrowser
567
- .open(function () {})
568
- .then(async function () {
569
- const sort =
570
- filebrowser.dialog.dialogbox_header.querySelector(
571
- '.jodit-toolbar-content_sort'
572
- );
573
- const select = sort.querySelector('select');
574
- const files = filebrowser.browser.querySelector(
575
- '.jodit-filebrowser__files'
576
- );
577
-
578
- expect(files).is.not.null;
579
- expect(sort).is.not.null;
580
- expect(select).is.not.null;
581
-
582
- const pars = {
583
- 'changed-asc': [
584
- 'images.jpg',
585
- '1966051_524428741092238_1051008806888563137_o.jpg',
586
- 'ibanez-s520-443140.jpg',
587
- 'test.txt'
588
- ],
589
- 'changed-desc': [
590
- 'test.txt',
591
- 'ibanez-s520-443140.jpg',
592
- '1966051_524428741092238_1051008806888563137_o.jpg',
593
- 'images.jpg'
594
- ],
595
- 'name-asc': [
596
- '1966051_524428741092238_1051008806888563137_o.jpg',
597
- 'ibanez-s520-443140.jpg',
598
- 'images.jpg',
599
- 'test.txt'
600
- ],
601
- 'name-desc': [
602
- 'test.txt',
603
- 'images.jpg',
604
- 'ibanez-s520-443140.jpg',
605
- '1966051_524428741092238_1051008806888563137_o.jpg'
606
- ],
607
- 'size-asc': [
608
- 'images.jpg',
609
- 'test.txt',
610
- 'ibanez-s520-443140.jpg',
611
- '1966051_524428741092238_1051008806888563137_o.jpg'
612
- ],
613
- 'size-desc': [
614
- '1966051_524428741092238_1051008806888563137_o.jpg',
615
- 'ibanez-s520-443140.jpg',
616
- 'test.txt',
617
- 'images.jpg'
618
- ]
619
- };
620
-
621
- for (const key in pars) {
622
- select.value = key;
623
-
624
- simulateEvent('change', 0, select);
625
-
626
- await filebrowser.async.requestIdlePromise();
627
-
628
- const items = files.querySelectorAll(
629
- '.jodit-filebrowser__files-item'
630
- );
631
-
632
- expect(
633
- Array.from(items)
634
- .map(function (item) {
635
- return item.querySelector(
636
- '.jodit-filebrowser__files-item-info-filename'
637
- ).textContent;
638
- })
639
- .join(',')
640
- ).equals(pars[key].join(','));
641
- }
642
-
643
- filebrowser.close();
644
- filebrowser.destruct();
645
-
646
- done();
647
- })
648
- .catch(function (e) {
649
- throw e;
650
- });
651
- });
652
- });
653
-
654
- describe('Select button', function () {
655
- it('Should fire first callback in open method', function (done) {
656
- const filebrowser = new Jodit.modules.FileBrowser({
657
- filebrowser: {
658
- saveStateInStorage: false
659
- },
660
- ajax: {
661
- url: 'https://xdsoft.net/jodit/connector/index.php'
662
- }
663
- });
664
-
665
- filebrowser
666
- .open(function (data) {
667
- expect(data !== undefined).is.true;
668
- expect(data.files !== undefined).is.true;
669
- expect(data.files.length).equals(1);
670
- expect(data.files[0]).equals(
671
- 'https://xdsoft.net/jodit/files/test.txt'
672
- );
673
- })
674
- .then(function () {
675
- const select = getButton('select', filebrowser.dialog);
676
- const files = filebrowser.browser.querySelector(
677
- '.jodit-filebrowser__files'
678
- );
679
-
680
- expect(files).is.not.null;
681
- expect(select).is.not.null;
682
-
683
- expect(select.hasAttribute('disabled')).is.true;
684
-
685
- simulateEvent(
686
- 'click',
687
- 0,
688
- filebrowser.browser.querySelector(
689
- '.jodit-filebrowser__files-item'
690
- )
691
- );
692
-
693
- expect(select.hasAttribute('disabled')).is.false;
694
-
695
- simulateEvent('click', 0, select);
696
-
697
- filebrowser.close();
698
- filebrowser.destruct();
699
-
700
- done();
701
- })
702
- .catch(function (e) {
703
- throw e;
704
- });
705
- });
706
- });
707
- });
708
-
709
- describe('Test drag and drop', function () {
710
- describe('Drag and drop image from filebrowser', function () {
711
- it('Should create IMG element in editor', function (done) {
712
- const editor = getJodit({
713
- filebrowser: {
714
- ajax: {
715
- url: 'https://xdsoft.net/jodit/connector/index.php'
716
- }
717
- }
718
- });
719
-
720
- const filebrowser = editor.filebrowser;
721
-
722
- filebrowser
723
- .open(function () {})
724
- .then(function () {
725
- const files = filebrowser.browser.querySelector(
726
- '.jodit-filebrowser__files'
727
- );
728
-
729
- expect(files).is.not.null;
730
-
731
- simulateEvent(
732
- 'dragstart',
733
- files.querySelector(
734
- '.jodit-filebrowser__files-item img[data-src="https://xdsoft.net/jodit/files/images.jpg"]'
735
- )
736
- );
737
-
738
- simulateEvent('dragover', window, function (data) {
739
- data.clientX = 50;
740
- data.clientY = 20 + offset(editor.editor).top;
741
- });
742
-
743
- simulateEvent('drop', editor.editor, function (data) {
744
- Object.defineProperty(data, 'dataTransfer', {
745
- value: {
746
- files: []
747
- }
748
- });
749
- });
750
-
751
- expect(editor.value).equals(
752
- '<p><img src="https://xdsoft.net/jodit/files/images.jpg"></p>'
753
- );
754
-
755
- simulateEvent('drop', window);
756
-
757
- filebrowser.destruct();
758
-
759
- done();
760
- })
761
- .catch(function (e) {
762
- throw e;
763
- });
764
- });
765
- });
766
-
767
- describe('Drag and drop File from filebrowser', function () {
768
- it('Should create A element in editor', function (done) {
769
- const editor = getJodit({
770
- filebrowser: {
771
- ajax: {
772
- url: 'https://xdsoft.net/jodit/connector/index.php'
773
- }
774
- }
775
- });
776
-
777
- const filebrowser = editor.filebrowser;
778
-
779
- filebrowser
780
- .open(function () {})
781
- .then(function () {
782
- const files = filebrowser.browser.querySelector(
783
- '.jodit-filebrowser__files'
784
- );
785
-
786
- expect(files).is.not.null;
787
-
788
- simulateEvent(
789
- 'dragstart',
790
- files.querySelector(
791
- '.jodit-filebrowser__files-item[data-is-file="1"] img'
792
- )
793
- );
794
-
795
- simulateEvent('dragover', window, function (data) {
796
- data.clientX = 50;
797
- data.clientY = 20 + offset(editor.editor).top;
798
- });
799
-
800
- simulateEvent('drop', editor.editor, function (data) {
801
- Object.defineProperty(data, 'dataTransfer', {
802
- value: {
803
- files: []
804
- }
805
- });
806
- });
807
-
808
- expect(editor.value).equals(
809
- '<p><a href="https://xdsoft.net/jodit/files/test.txt">https://xdsoft.net/jodit/files/test.txt</a></p>'
810
- );
811
- simulateEvent('drop', window);
812
-
813
- filebrowser.destruct();
814
- done();
815
- })
816
- .catch(function (e) {
817
- throw e;
818
- });
819
- });
820
- });
821
- });
822
-
823
- describe('DblClick', function () {
824
- describe('DblClick on image from filebrowser', function () {
825
- it('Should insert IMG element in editor in the selected before place', function (done) {
826
- const editor = getJodit({
827
- filebrowser: {
828
- ajax: {
829
- url: 'https://xdsoft.net/jodit/connector/index.php'
830
- }
831
- }
832
- });
833
-
834
- editor.value =
835
- '<p>Some text</p><p>Another text</p><p>Another some text</p>';
836
-
837
- const range = editor.s.createRange();
838
- range.setStart(
839
- editor.editor.querySelectorAll('p')[1].firstChild,
840
- 7
841
- );
842
-
843
- range.collapse(true);
844
- editor.s.selectRange(range);
845
-
846
- const filebrowser = editor.filebrowser;
847
-
848
- filebrowser
849
- .open()
850
- .then(function () {
851
- const files = filebrowser.browser.querySelector(
852
- '.jodit-filebrowser__files'
853
- );
854
-
855
- expect(files).is.not.null;
856
-
857
- simulateEvent(
858
- ['click', 'dblclick'],
859
- 0,
860
- files.querySelector(
861
- 'a[data-is-file="0"].jodit-filebrowser__files-item'
862
- )
863
- );
864
-
865
- expect(editor.value).equals(
866
- '<p>Some text</p><p>Another<img src="https://xdsoft.net/jodit/files/ibanez-s520-443140.jpg" style="width: 300px;"> text</p><p>Another some text</p>'
867
- );
868
-
869
- filebrowser.destruct();
870
- done();
871
- })
872
- .catch(function (e) {
873
- throw e;
874
- });
875
- });
876
- });
877
-
878
- describe('DblClick on File from filebrowser', function () {
879
- it('Should insert A element in editor in the selected before place', function (done) {
880
- const editor = getJodit({
881
- filebrowser: {
882
- ajax: {
883
- url: 'https://xdsoft.net/jodit/connector/index.php'
884
- }
885
- }
886
- });
887
-
888
- editor.value =
889
- '<p>Some text</p><p>Another text</p><p>Another some text</p>';
890
- const range = editor.s.createRange();
891
- range.setStart(
892
- editor.editor.querySelectorAll('p')[1].firstChild,
893
- 7
894
- );
895
- range.collapse(true);
896
- editor.s.selectRange(range);
897
-
898
- const filebrowser = editor.filebrowser;
899
-
900
- filebrowser
901
- .open()
902
- .then(function () {
903
- const files = filebrowser.browser.querySelector(
904
- '.jodit-filebrowser__files'
905
- );
906
-
907
- expect(files).is.not.null;
908
-
909
- simulateEvent(
910
- ['click', 'dblclick'],
911
- 0,
912
- files.querySelector(
913
- 'a[data-is-file="1"].jodit-filebrowser__files-item'
914
- )
915
- );
916
-
917
- expect(editor.value).equals(
918
- '<p>Some text</p><p>Another<a href="https://xdsoft.net/jodit/files/test.txt" title="https://xdsoft.net/jodit/files/test.txt">https://xdsoft.net/jodit/files/test.txt</a> text</p><p>Another some text</p>'
919
- );
920
-
921
- filebrowser.destruct();
922
- done();
923
- })
924
- .catch(function (e) {
925
- throw e;
926
- });
927
- });
928
- });
929
- });
930
-
931
- describe('Uploader', function () {
932
- describe('Drag and drop', function () {
933
- describe('Image', function () {
934
- it('Should create IMG element', function (done) {
935
- const editor = getJodit({
936
- uploader: {
937
- url: 'https://xdsoft.net/jodit/connector/index.php?action=fileUpload'
938
- },
939
- filebrowser: {
940
- ajax: {
941
- url: 'https://xdsoft.net/jodit/connector/index.php'
942
- }
943
- }
944
- });
945
-
946
- editor.value = '';
947
-
948
- editor.events.on('filesWereUploaded', function () {
949
- expect(sortAttributes(editor.value)).equals(
950
- '<p><img src="https://xdsoft.net/jodit/files/test.png" style="width:300px"></p>'
951
- );
952
- done();
953
- });
954
-
955
- simulateEvent('drop', 0, editor.editor, function (data) {
956
- Object.defineProperty(data, 'dataTransfer', {
957
- value: {
958
- files: [{ name: 'test.png', type: 'image/png' }]
959
- }
960
- });
961
- });
962
- });
963
- });
964
-
965
- describe('File', function () {
966
- it('Should create A element', function (done) {
967
- const editor = getJodit({
968
- uploader: {
969
- url: 'https://xdsoft.net/jodit/connector/index.php?action=fileUpload'
970
- },
971
- filebrowser: {
972
- ajax: {
973
- url: 'https://xdsoft.net/jodit/connector/index.php'
974
- }
975
- }
976
- });
977
-
978
- editor.value = '';
979
-
980
- editor.events.on('filesWereUploaded', function () {
981
- expect(editor.value).equals(
982
- '<p><a href="https://xdsoft.net/jodit/files/test.txt">https://xdsoft.net/jodit/files/test.txt</a></p>'
983
- );
984
- done();
985
- });
986
-
987
- simulateEvent('drop', 0, editor.editor, function (data) {
988
- Object.defineProperty(data, 'dataTransfer', {
989
- value: {
990
- files: [
991
- { name: 'test.txt', type: 'plain/text' }
992
- ]
993
- }
994
- });
995
- });
996
- });
997
- });
998
- });
999
- });
1000
-
1001
- describe('Rename', function () {
1002
- describe('Folder', function () {
1003
- it('Should create button inside every folder of list', function (done) {
1004
- const editor = getJodit({
1005
- filebrowser: {
1006
- ajax: {
1007
- url: 'https://xdsoft.net/jodit/connector/index.php'
1008
- }
1009
- }
1010
- });
1011
-
1012
- const filebrowser = editor.filebrowser;
1013
-
1014
- filebrowser
1015
- .open(function () {})
1016
- .then(async function () {
1017
- const tree = filebrowser.browser.querySelector(
1018
- '.jodit-filebrowser__tree'
1019
- );
1020
-
1021
- expect(tree).is.not.null;
1022
-
1023
- const item = tree.querySelectorAll(
1024
- '.jodit-filebrowser__tree-item'
1025
- )[1];
1026
-
1027
- expect(item).is.not.null;
1028
-
1029
- const trigger = getButton('rename', item);
1030
-
1031
- expect(trigger).is.not.null;
1032
-
1033
- expect(trigger.parentElement.textContent.trim()).equals(
1034
- 'ceicom'
1035
- );
1036
- simulateEvent('click', trigger);
1037
-
1038
- const dialog = getOpenedDialog(editor);
1039
- expect(dialog).is.not.null;
1040
- expect(dialog).does.not.equal(filebrowser.dialog);
1041
-
1042
- expect(dialog.querySelector('input').value).equals(
1043
- 'ceicom'
1044
- );
1045
-
1046
- dialog.querySelector('input').value = 'ceicom1';
1047
- clickButton('ok', dialog);
1048
-
1049
- await filebrowser.async.requestIdlePromise();
1050
-
1051
- const item2 = tree.querySelectorAll(
1052
- '.jodit-filebrowser__tree-item'
1053
- )[1];
1054
- expect(item2.textContent.trim()).equals('ceicom1');
1055
-
1056
- filebrowser.destruct();
1057
-
1058
- done();
1059
- })
1060
- .catch(function (e) {
1061
- throw e;
1062
- });
1063
- });
1064
- });
1065
- });
1066
-
1067
- describe('Remove', function () {
1068
- describe('Folder', function () {
1069
- it('Should create button inside every folder of list', function (done) {
1070
- const editor = getJodit({
1071
- filebrowser: {
1072
- ajax: {
1073
- url: 'https://xdsoft.net/jodit/connector/index.php'
1074
- }
1075
- }
1076
- });
1077
-
1078
- const filebrowser = editor.filebrowser;
1079
-
1080
- filebrowser
1081
- .open(function () {})
1082
- .then(function () {
1083
- const tree = filebrowser.browser.querySelector(
1084
- '.jodit-filebrowser__tree'
1085
- );
1086
-
1087
- expect(tree).is.not.null;
1088
-
1089
- const item = tree.querySelectorAll(
1090
- '.jodit-filebrowser__tree-item'
1091
- )[1];
1092
-
1093
- expect(item).is.not.null;
1094
-
1095
- const trigger = getButton('remove', item);
1096
-
1097
- expect(trigger).is.not.null;
1098
-
1099
- simulateEvent('click', trigger);
1100
-
1101
- const dialog = getOpenedDialog(editor);
1102
- expect(dialog).is.not.null;
1103
- expect(dialog).does.not.equal(filebrowser.dialog);
1104
-
1105
- clickButton('ok', dialog);
1106
-
1107
- filebrowser.destruct();
1108
-
1109
- done();
1110
- })
1111
- .catch(function (e) {
1112
- throw e;
1113
- });
1114
- });
1115
- });
1116
- });
1117
-
1118
- describe('Create', function () {
1119
- describe('Folder', function () {
1120
- it('Should create button below folders list', function (done) {
1121
- const editor = getJodit({
1122
- filebrowser: {
1123
- ajax: {
1124
- url: 'https://xdsoft.net/jodit/connector/index.php'
1125
- }
1126
- }
1127
- });
1128
-
1129
- const filebrowser = editor.filebrowser;
1130
-
1131
- filebrowser
1132
- .open(function () {})
1133
- .then(function () {
1134
- const addfolder = getButton('plus', filebrowser.tree);
1135
-
1136
- expect(addfolder).is.not.null;
1137
- filebrowser.destruct();
1138
-
1139
- done();
1140
- })
1141
- .catch(function (e) {
1142
- throw e;
1143
- });
1144
- });
1145
-
1146
- describe('Create new folder', function () {
1147
- it('Should create new folder', function (done) {
1148
- const editor = getJodit({
1149
- filebrowser: {
1150
- ajax: {
1151
- url: 'https://xdsoft.net/jodit/connector/index.php'
1152
- }
1153
- }
1154
- });
1155
-
1156
- const filebrowser = editor.filebrowser;
1157
-
1158
- filebrowser
1159
- .open(function () {})
1160
- .then(async function () {
1161
- const addfolder = getButton(
1162
- 'plus',
1163
- filebrowser.tree
1164
- );
1165
-
1166
- expect(addfolder).is.not.null;
1167
-
1168
- simulateEvent('click', addfolder);
1169
-
1170
- const dialog = getOpenedDialog(editor);
1171
-
1172
- expect(dialog).is.not.null;
1173
- dialog.querySelector('input').value = 'free';
1174
- clickButton('ok', dialog);
1175
- await filebrowser.async.requestIdlePromise();
1176
-
1177
- const tree = filebrowser.browser.querySelector(
1178
- '.jodit-filebrowser__tree'
1179
- );
1180
-
1181
- const item = tree.querySelectorAll(
1182
- '.jodit-filebrowser__tree-item'
1183
- )[1];
1184
- expect(item.textContent.trim()).equals('free');
1185
-
1186
- filebrowser.destruct();
1187
-
1188
- done();
1189
- })
1190
- .catch(function (e) {
1191
- throw e;
1192
- });
1193
- });
1194
- });
1195
- });
1196
- });
1197
-
1198
- describe('Context menu', function () {
1199
- describe('Right click on image', function () {
1200
- it('Should open context menu', function (done) {
1201
- const editor = getJodit({
1202
- filebrowser: {
1203
- ajax: {
1204
- url: 'https://xdsoft.net/jodit/connector/index.php'
1205
- }
1206
- }
1207
- });
1208
-
1209
- const filebrowser = editor.filebrowser;
1210
-
1211
- filebrowser
1212
- .open(function () {})
1213
- .then(function () {
1214
- const files = filebrowser.browser.querySelector(
1215
- '.jodit-filebrowser__files'
1216
- );
1217
-
1218
- expect(files).is.not.null;
1219
-
1220
- const item = files.querySelector(
1221
- '.jodit-filebrowser__files-item[data-is-file="1"]'
1222
- ),
1223
- pos = Jodit.modules.Helpers.position(item);
1224
-
1225
- simulateEvent('contextmenu', 0, item, function (o) {
1226
- Object.assign(o, {
1227
- clientX: pos.left + 10,
1228
- clientY: pos.top + 10
1229
- });
1230
- });
1231
-
1232
- const context = getOpenedPopup(filebrowser);
1233
-
1234
- expect(context).is.not.null;
1235
- filebrowser.destruct();
1236
-
1237
- done();
1238
- })
1239
- .catch(function (e) {
1240
- throw e;
1241
- });
1242
- });
1243
-
1244
- describe('Click on preview', function () {
1245
- it('Should open preview dialog', function (done) {
1246
- unmockPromise();
1247
-
1248
- const editor = getJodit({
1249
- filebrowser: {
1250
- ajax: {
1251
- url: 'https://xdsoft.net/jodit/connector/index.php'
1252
- }
1253
- }
1254
- });
1255
-
1256
- const filebrowser = editor.filebrowser;
1257
-
1258
- filebrowser
1259
- .open()
1260
- .then(function () {
1261
- const files = filebrowser.browser.querySelector(
1262
- '.jodit-filebrowser__files'
1263
- );
1264
-
1265
- expect(files).is.not.null;
1266
-
1267
- const item = files.querySelector(
1268
- '.jodit-filebrowser__files-item[data-is-file="0"]'
1269
- ),
1270
- pos = Jodit.modules.Helpers.position(item);
1271
-
1272
- simulateEvent('contextmenu', 0, item, function (o) {
1273
- Object.assign(o, {
1274
- clientX: pos.left + 10,
1275
- clientY: pos.top + 10
1276
- });
1277
- });
1278
-
1279
- const context = getOpenedPopup(filebrowser);
1280
-
1281
- expect(context).is.not.null;
1282
-
1283
- filebrowser.events.on(
1284
- 'previewOpenedAndLoaded',
1285
- function () {
1286
- const dialog = getOpenedDialog(filebrowser);
1287
-
1288
- expect(dialog).is.not.null;
1289
- const previewsButtons =
1290
- dialog.querySelectorAll(
1291
- ' .jodit-filebrowser_preview .jodit-filebrowser_preview_navigation.jodit-filebrowser_preview_navigation-prev, ' +
1292
- ' .jodit-filebrowser_preview .jodit-filebrowser_preview_navigation.jodit-filebrowser_preview_navigation-next'
1293
- );
1294
-
1295
- expect(previewsButtons.length).equals(2);
1296
- done();
1297
- }
1298
- );
1299
-
1300
- clickButton('eye', context);
1301
- })
1302
- .catch(function (e) {
1303
- throw e;
1304
- });
1305
- });
1306
- });
1307
- });
1308
- });
1309
- });