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,647 +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('Commands Jodit Editor Tests', function () {
7
- describe('Command "formatBlock"', function () {
8
- it('Try exec the command "formatBlock" for several elements', function () {
9
- const editor = getJodit();
10
- editor.value = '<p>test</p><p>test2</p>';
11
-
12
- const sel = editor.s.sel,
13
- range = editor.s.createRange();
14
-
15
- range.setStartBefore(editor.editor.firstChild);
16
- range.setEndAfter(editor.editor.lastChild);
17
- sel.removeAllRanges();
18
- sel.addRange(range);
19
-
20
- editor.execCommand('formatBlock', false, 'h1');
21
-
22
- expect(editor.value).equals('<h1>test</h1><h1>test2</h1>');
23
- });
24
-
25
- describe('Exec formatBlock for one inline element', function () {
26
- it('Should wrap this element and all nearest inline element in block', function () {
27
- const jodit = getJodit();
28
- jodit.value = 'stop <span>post</span> ice';
29
- const range = jodit.ed.createRange();
30
- range.setStart(jodit.editor.firstChild, 0);
31
- range.setEnd(jodit.editor.firstChild, 2);
32
- jodit.s.selectRange(range);
33
-
34
- jodit.execCommand('formatBlock', false, 'h1');
35
-
36
- expect(jodit.value).equals(
37
- '<h1>stop <span>post</span> ice</h1>'
38
- );
39
- });
40
- });
41
-
42
- describe('Exec formatBlock for STYLED block', function () {
43
- it('Should wrap this element and save previous styles', function () {
44
- const jodit = getJodit();
45
- jodit.value =
46
- '<p style="text-align: right">|stop <span>post</span> ice</p>';
47
- setCursorToChar(jodit);
48
-
49
- jodit.execCommand('formatBlock', false, 'h1');
50
-
51
- expect(jodit.value).equals(
52
- '<h1 style="text-align: right">stop <span>post</span> ice</h1>'
53
- );
54
- });
55
- });
56
-
57
- it('Try exec the command "formatBlock" in text node then selection is collapsed it should wrap it node in H1', function () {
58
- const editor = getJodit({
59
- disablePlugins: ['WrapTextNodes']
60
- });
61
- editor.value = 'test';
62
-
63
- const sel = editor.s.sel,
64
- range = editor.s.createRange();
65
-
66
- range.setStart(editor.editor.firstChild, 2);
67
-
68
- sel.removeAllRanges();
69
- sel.addRange(range);
70
-
71
- editor.execCommand('formatBlock', false, 'h1');
72
-
73
- editor.s.insertNode(editor.createInside.text(' a '));
74
-
75
- expect(editor.value).equals('<h1>te a st</h1>');
76
- });
77
-
78
- it('Try exec the command "formatBlock" in the end of text node then selection is collapsed it should wrap it node in H1', function () {
79
- const editor = getJodit({
80
- disablePlugins: ['WrapTextNodes']
81
- });
82
- editor.value = 'test';
83
-
84
- const sel = editor.s.sel,
85
- range = editor.s.createRange();
86
-
87
- range.setStart(editor.editor.firstChild, 4);
88
-
89
- sel.removeAllRanges();
90
- sel.addRange(range);
91
-
92
- editor.execCommand('formatBlock', false, 'h1');
93
-
94
- editor.s.insertNode(editor.createInside.text(' a '));
95
-
96
- expect(editor.value).equals('<h1>test a </h1>');
97
- });
98
-
99
- describe('Try exec the command "formatBlock" for several text nodes', function () {
100
- it('should wrap all these nodes inside tag', function () {
101
- const editor = getJodit();
102
- editor.value = '';
103
-
104
- editor.s.insertNode(editor.createInside.text('test'));
105
- editor.s.insertNode(editor.createInside.text(' test2'));
106
- editor.s.insertNode(editor.createInside.text(' test3'));
107
- editor.s.insertNode(
108
- editor.createInside.element('span', ' test4')
109
- );
110
-
111
- const range = editor.s.createRange(true);
112
-
113
- range.setStart(editor.editor.firstChild, 0);
114
- range.setEnd(editor.editor.lastChild, 0);
115
-
116
- editor.execCommand('formatBlock', false, 'h1');
117
-
118
- expect(editor.value).equals(
119
- '<h1>test test2 test3<span> test4</span></h1>'
120
- );
121
- });
122
- });
123
-
124
- describe('editor is empty', function () {
125
- it('Should create empty element and set cursor into it', function () {
126
- const editor = getJodit();
127
- editor.value = '';
128
- editor.s.focus();
129
-
130
- editor.execCommand('formatBlock', false, 'h1');
131
- editor.s.insertHTML('test');
132
-
133
- expect(editor.value).equals('<h1>test<br></h1>');
134
- });
135
- });
136
-
137
- describe('For UL>li elements', function () {
138
- describe('Select only LI', function () {
139
- it('Should replace all LI elements to P and unwrap it from UL', function () {
140
- const editor = getJodit();
141
- editor.value =
142
- '<ul>' +
143
- '<li>1</li>' +
144
- '<li>2</li>' +
145
- '<li>3</li>' +
146
- '</ul>';
147
-
148
- const range = editor.s.createRange();
149
- range.setStart(
150
- editor.editor.firstChild.firstChild.firstChild,
151
- 0
152
- );
153
- range.setEnd(
154
- editor.editor.firstChild.lastChild.firstChild,
155
- 1
156
- );
157
-
158
- editor.s.selectRange(range);
159
-
160
- editor.execCommand('formatBlock', false, 'h1');
161
-
162
- expect(editor.value).equals(
163
- '<ul>' +
164
- '<li><h1>1</h1></li>' +
165
- '<li><h1>2</h1></li>' +
166
- '<li><h1>3</h1></li>' +
167
- '</ul>'
168
- );
169
-
170
- editor.execCommand('formatBlock', false, 'h1');
171
-
172
- expect(editor.value).equals(
173
- '<ul>' +
174
- '<li>1</li>' +
175
- '<li>2</li>' +
176
- '<li>3</li>' +
177
- '</ul>'
178
- );
179
- });
180
- });
181
-
182
- describe('Select UL', function () {
183
- it('Should replace all LI elements to P and unwrap it from UL', function () {
184
- const editor = getJodit();
185
- editor.value =
186
- '<ul>' +
187
- '<li>1</li>' +
188
- '<li>2</li>' +
189
- '<li>3</li>' +
190
- '</ul>';
191
-
192
- const range = editor.s.createRange();
193
- range.selectNode(editor.editor.firstChild);
194
- editor.s.selectRange(range);
195
-
196
- editor.execCommand('formatBlock', false, 'h1');
197
- expect(editor.value).equals(
198
- '<ul>' +
199
- '<li><h1>1</h1></li>' +
200
- '<li><h1>2</h1></li>' +
201
- '<li><h1>3</h1></li>' +
202
- '</ul>'
203
- );
204
-
205
- editor.execCommand('formatBlock', false, 'h1');
206
- expect(editor.value).equals(
207
- '<ul>' +
208
- '<li>1</li>' +
209
- '<li>2</li>' +
210
- '<li>3</li>' +
211
- '</ul>'
212
- );
213
- });
214
- });
215
- });
216
- });
217
-
218
- describe('Sub/Supscript native', function () {
219
- describe('sub', function () {
220
- it('Should insert selection im SUB element', function () {
221
- const editor = getJodit();
222
- editor.value = '<p>test</p>';
223
- const range = editor.s.createRange();
224
- range.setStart(editor.editor.firstChild.firstChild, 2);
225
- range.setEnd(editor.editor.firstChild.firstChild, 4);
226
- editor.s.selectRange(range);
227
- editor.execCommand('subscript');
228
- expect(editor.value).equals('<p>te<sub>st</sub></p>');
229
- });
230
- });
231
-
232
- describe('sup', function () {
233
- it('Should insert selection im SUP element', function () {
234
- const editor = getJodit();
235
- editor.value = '<p>test</p>';
236
- const range = editor.s.createRange();
237
- range.setStart(editor.editor.firstChild.firstChild, 2);
238
- range.setEnd(editor.editor.firstChild.firstChild, 4);
239
- editor.s.selectRange(range);
240
- editor.execCommand('superscript');
241
- expect(editor.value).equals('<p>te<sup>st</sup></p>');
242
- });
243
- });
244
- });
245
-
246
- describe('After exec some command', function () {
247
- it('should restore selection to previous', function () {
248
- const editor = getJodit();
249
- editor.value = '<p>test</p>';
250
-
251
- const sel = editor.s.sel,
252
- range = editor.s.createRange();
253
-
254
- range.setStart(editor.editor.firstChild.firstChild, 2);
255
- range.setEnd(editor.editor.firstChild.firstChild, 3);
256
- //range.collapse(true);
257
- sel.removeAllRanges();
258
- sel.addRange(range);
259
-
260
- editor.execCommand('italic');
261
-
262
- editor.s.insertNode(editor.createInside.text('top'));
263
-
264
- expect(editor.value).equals('<p>tetopt</p>');
265
- });
266
- describe('in collapsed selection', function () {
267
- it('should place cursor inward', function () {
268
- const editor = getJodit();
269
- editor.value = '<p>test</p>';
270
-
271
- const sel = editor.s.sel,
272
- range = editor.s.createRange();
273
-
274
- range.setStart(editor.editor.firstChild.firstChild, 2);
275
- range.collapse(true);
276
-
277
- sel.removeAllRanges();
278
- sel.addRange(range);
279
-
280
- editor.execCommand('underline');
281
- editor.s.insertNode(editor.createInside.text('data'));
282
-
283
- expect(editor.value).equals('<p>te<u>data</u>st</p>');
284
- });
285
- });
286
- });
287
-
288
- describe('formatBlock', function () {
289
- it('Should wrap or replace container to specialize tag', function () {
290
- const editor = getJodit();
291
- editor.value = '<p>testy oprst <span>lets go</span></p>';
292
-
293
- const sel = editor.s.sel,
294
- range = editor.s.createRange();
295
-
296
- range.setStart(editor.editor.firstChild.firstChild, 5);
297
- range.collapse(true);
298
-
299
- sel.removeAllRanges();
300
- sel.addRange(range);
301
-
302
- editor.execCommand('formatBlock', false, 'h5');
303
-
304
- expect(editor.value).equals(
305
- '<h5>testy oprst <span>lets go</span></h5>'
306
- );
307
- });
308
-
309
- it('Should wrap text into H1 tag near Table, but table must be after this tag', function () {
310
- const editor = getJodit({
311
- disablePlugins: ['WrapTextNodes']
312
- });
313
- editor.value = 'test<table><tr><td>post</td></tr></table>';
314
-
315
- const sel = editor.s.sel,
316
- range = editor.s.createRange();
317
-
318
- range.setEnd(editor.editor.firstChild, 4);
319
- range.collapse(false);
320
-
321
- sel.removeAllRanges();
322
- sel.addRange(range);
323
-
324
- editor.execCommand('formatBlock', false, 'h1');
325
-
326
- expect(editor.value).equals(
327
- '<h1>test</h1><table><tbody><tr><td>post</td></tr></tbody></table>'
328
- );
329
- });
330
-
331
- describe('justifyLeft', function () {
332
- it('Should set align for element which was created using formatBlock', function () {
333
- const editor = getJodit({
334
- disablePlugins: ['WrapTextNodes']
335
- });
336
- editor.value = 'testy oprst <span>lets go</span>';
337
-
338
- const sel = editor.s.sel,
339
- range = editor.s.createRange();
340
-
341
- range.setStart(editor.editor.firstChild, 5);
342
- range.collapse(true);
343
-
344
- sel.removeAllRanges();
345
- sel.addRange(range);
346
-
347
- editor.execCommand('formatBlock', false, 'h5');
348
- editor.execCommand('justifyLeft');
349
- editor.execCommand('fontSize', false, 14);
350
-
351
- expect(editor.value).equals(
352
- '<h5 style="text-align: left;">testy<span style="font-size: 14px;"></span> oprst <span>lets go</span></h5>'
353
- );
354
- });
355
- });
356
-
357
- it('Insert H1 inside TD should crearte new H1 withow replacement', function () {
358
- const editor = getJodit();
359
- editor.value = '<table><tr><td>1</td></tr></table>';
360
-
361
- const range = editor.s.createRange(true);
362
-
363
- range.selectNodeContents(editor.editor.querySelector('td'));
364
-
365
- editor.execCommand('formatBlock', false, 'h1');
366
-
367
- expect(editor.value).equals(
368
- '<table><tbody><tr><td><h1>1</h1></td></tr></tbody></table>'
369
- );
370
- });
371
- });
372
-
373
- describe('Colors', function () {
374
- it('Set colour for all selection should create <span></span> tags inside all paragraps', function () {
375
- const editor = getJodit();
376
- editor.value = '<p>1</p><p>2</p><p>3</p>';
377
-
378
- const sel = editor.s.sel,
379
- range = editor.s.createRange();
380
-
381
- range.setStart(editor.editor.firstChild, 0);
382
- range.setEnd(editor.editor.lastChild, 1);
383
-
384
- sel.removeAllRanges();
385
- sel.addRange(range);
386
-
387
- editor.execCommand('foreColor', false, '#f00');
388
-
389
- expect(
390
- '<p><span style="color: rgb(255, 0, 0);">1</span></p><p><span style="color: rgb(255, 0, 0);">2</span></p><p><span style="color: rgb(255, 0, 0);">3</span></p>'
391
- ).equals(editor.value);
392
- });
393
-
394
- it('Set colour to collapsed position should create empty span and insert inward cursor', function () {
395
- const editor = getJodit({
396
- disablePlugins: ['WrapTextNodes']
397
- });
398
- editor.value = 'testy oprst <span>lets go</span>';
399
-
400
- const sel = editor.s.sel,
401
- range = editor.s.createRange();
402
-
403
- range.setStart(editor.editor.firstChild, 5);
404
- range.collapse(true);
405
-
406
- sel.removeAllRanges();
407
- sel.addRange(range);
408
-
409
- editor.execCommand('foreColor', false, '#f00');
410
-
411
- expect(editor.value).equals(
412
- 'testy<span style="color: rgb(255, 0, 0);"></span> oprst <span>lets go</span>'
413
- );
414
- });
415
- });
416
-
417
- describe('Align', function () {
418
- it('Justify to right', function () {
419
- const editor = getJodit();
420
- editor.value = '<p>test</p>';
421
-
422
- const sel = editor.s.sel,
423
- range = editor.s.createRange();
424
-
425
- range.setStart(editor.editor.firstChild.firstChild, 2);
426
- range.collapse(true);
427
-
428
- sel.removeAllRanges();
429
- sel.addRange(range);
430
-
431
- editor.execCommand('justifyright');
432
-
433
- expect(editor.value).equals(
434
- '<p style="text-align: right;">test</p>'
435
- );
436
- });
437
-
438
- it('Justify to center', function () {
439
- const editor = getJodit({
440
- disablePlugins: ['WrapTextNodes']
441
- });
442
- editor.value = 'test';
443
-
444
- const sel = editor.s.sel,
445
- range = editor.s.createRange();
446
-
447
- range.setStart(editor.editor.firstChild, 2);
448
- range.collapse(true);
449
-
450
- sel.removeAllRanges();
451
- sel.addRange(range);
452
-
453
- editor.execCommand('justifycenter');
454
-
455
- expect(editor.value).equals(
456
- '<p style="text-align: center;">test</p>'
457
- );
458
- });
459
-
460
- it('Justify to left', function () {
461
- const editor = getJodit({
462
- disablePlugins: ['WrapTextNodes']
463
- });
464
- editor.value = 'test some text <span>test</span><br><p>data</p>';
465
-
466
- const sel = editor.s.sel,
467
- range = editor.s.createRange();
468
-
469
- range.setStart(editor.editor.firstChild, 8);
470
- range.collapse(true);
471
-
472
- sel.removeAllRanges();
473
- sel.addRange(range);
474
-
475
- editor.execCommand('justifyleft');
476
-
477
- expect(editor.value).equals(
478
- '<p style="text-align: left;">test some text <span>test</span><br></p><p>data</p>'
479
- );
480
- });
481
-
482
- it('Justify to left in element of unordered list', function () {
483
- const editor = getJodit();
484
- editor.value = '<ul><li>test</li><li>data</li></ul>';
485
-
486
- const sel = editor.s.sel,
487
- range = editor.s.createRange();
488
-
489
- range.setStart(editor.editor.firstChild.firstChild.firstChild, 2);
490
- range.collapse(true);
491
-
492
- sel.removeAllRanges();
493
- sel.addRange(range);
494
-
495
- editor.execCommand('justifyleft');
496
-
497
- expect(editor.value).equals(
498
- '<ul><li style="text-align: left;">test</li><li>data</li></ul>'
499
- );
500
- });
501
-
502
- it('Justify to full', function () {
503
- const editor = getJodit();
504
- editor.value = '<h1>test some text <span>test</span></h1>';
505
-
506
- const sel = editor.s.sel,
507
- range = editor.s.createRange();
508
-
509
- range.setStart(editor.editor.firstChild.firstChild, 8);
510
- range.collapse(true);
511
-
512
- sel.removeAllRanges();
513
- sel.addRange(range);
514
-
515
- editor.execCommand('justifyfull');
516
-
517
- expect(editor.value).equals(
518
- '<h1 style="text-align: justify;">test some text <span>test</span></h1>'
519
- );
520
- });
521
-
522
- describe('Justify plain text with enter = br mode', function () {
523
- it('Should wrap this text in enterBlock element', function () {
524
- const editor = getJodit({
525
- enter: 'br'
526
- });
527
- editor.value = 'test';
528
-
529
- const sel = editor.s.sel,
530
- range = editor.s.createRange();
531
-
532
- range.setStart(editor.editor.firstChild, 0);
533
- range.setEnd(editor.editor.firstChild, 4);
534
-
535
- sel.removeAllRanges();
536
- sel.addRange(range);
537
-
538
- editor.execCommand('justifyleft');
539
-
540
- expect(editor.value).equals(
541
- '<p style="text-align: left;">test</p>'
542
- );
543
- });
544
- });
545
-
546
- describe('Table cells', function () {
547
- describe('Selected table cells', function () {
548
- it('Should apply align to all selected cells', function () {
549
- const editor = getJodit();
550
- editor.value =
551
- '<table><tbody><tr><td>1</td><td>2</td></tr></tbody></table>';
552
-
553
- const td = editor.editor.querySelector('td'),
554
- pos = Jodit.modules.Helpers.position(td);
555
-
556
- simulateEvent(
557
- ['mousedown', 'mouseup', 'click'],
558
- 0,
559
- td,
560
- e => {
561
- Object.assign(e, {
562
- clientX: pos.left,
563
- clientY: pos.top
564
- });
565
- }
566
- );
567
-
568
- editor.s.select(
569
- editor.editor.querySelector('td').firstChild
570
- );
571
-
572
- editor.execCommand('justifyright');
573
-
574
- expect(sortAttributes(editor.value)).equals(
575
- '<table><tbody><tr><td style="text-align:right">1</td><td>2</td></tr></tbody></table>'
576
- );
577
- });
578
-
579
- describe('After change obe cell - select all', function () {
580
- it('Should apply align to whole table and remove from cells', function () {
581
- const editor = getJodit();
582
- editor.value =
583
- '<table><tbody><tr><td>1</td><td>2</td></tr></tbody></table>';
584
-
585
- simulateEvent(
586
- 'mousedown',
587
- editor.editor.querySelector('td')
588
- );
589
-
590
- editor.s.select(
591
- editor.editor.querySelector('td').firstChild
592
- );
593
-
594
- editor.execCommand('justifyright');
595
-
596
- simulateEvent('click', editor.editor);
597
-
598
- editor.execCommand('selectall');
599
- editor.execCommand('justifyfull');
600
-
601
- expect(sortAttributes(editor.value)).equals(
602
- '<table style="text-align:justify"><tbody><tr><td>1</td><td>2</td></tr></tbody></table>'
603
- );
604
- });
605
- });
606
- });
607
- });
608
- });
609
-
610
- describe('Register sustom command', function () {
611
- it('Should register command and hotkeys for it', function () {
612
- const editor = getJodit({
613
- disablePlugins: ['WrapTextNodes']
614
- });
615
-
616
- editor.value = 'test test test';
617
- const range = editor.s.createRange();
618
- range.setStart(editor.editor.firstChild, 4);
619
- range.setEnd(editor.editor.firstChild, 8);
620
- editor.s.selectRange(range);
621
-
622
- editor.registerCommand('someCommand', function () {
623
- this.setEditorValue('stop');
624
- });
625
-
626
- expect('stop').does.not.equal(editor.value);
627
-
628
- editor.execCommand('someCommand');
629
- expect('stop').equals(editor.value);
630
-
631
- editor.registerCommand('someCommands', {
632
- hotkeys: 'ctrl+d',
633
- exec: function () {
634
- this.setEditorValue('even');
635
- }
636
- });
637
-
638
- expect('even').does.not.equal(editor.value);
639
- // ctrl+d
640
- simulateEvent('keydown', 68, editor.editor, function (data) {
641
- // data.shiftKey = true;
642
- data.ctrlKey = true;
643
- });
644
- expect('even').equals(editor.value);
645
- });
646
- });
647
- });