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,771 +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 helpers', function () {
7
- describe('Normalizers', function () {
8
- describe('normalizeKeyAliases', function () {
9
- it('Should convert some hotkeys to normal', function () {
10
- const hotkeys = {
11
- 'cmd+ alt+s': 'alt+meta+s',
12
- 'cmd++': '++meta',
13
- 'ctrl+ alt+s': 'alt+control+s',
14
- ' command+s': 'meta+s',
15
- 'alt+s+ctrl': 'alt+control+s',
16
- 'shift+ctrl+cmd+D': 'control+d+meta+shift',
17
- 'meta+windows+win+ctrl+cmd': 'control+meta',
18
- 'cmd+ alt+ shift ': 'alt+meta+shift',
19
- 'return + esc ': 'enter+escape'
20
- };
21
-
22
- Object.keys(hotkeys).forEach(function (key) {
23
- expect(hotkeys[key]).equals(
24
- Jodit.modules.Helpers.normalizeKeyAliases(key)
25
- );
26
- });
27
- });
28
- });
29
-
30
- describe('normalizePath', function () {
31
- it('Should normalize slashes and join some parts', function () {
32
- const variants = {
33
- '/data/test/': ['/data/test/'],
34
- 'data/test/': ['data/test/'],
35
- 'data/test': ['data', 'test', ''],
36
- 'test/test/': ['test//test//'],
37
- 'https://xdsoft.net/jodit/connector/index.html': [
38
- 'https://xdsoft.net',
39
- 'jodit/connector/',
40
- '/index.html'
41
- ],
42
- 'https://xdsoft.net/jodit/connector/index2.html': [
43
- 'https://xdsoft.net\\jodit/connector/',
44
- '/index2.html'
45
- ]
46
- };
47
-
48
- Object.keys(variants).forEach(function (key) {
49
- expect(key).equals(
50
- Jodit.modules.Helpers.normalizePath.apply(
51
- null,
52
- variants[key]
53
- )
54
- );
55
- });
56
- });
57
- });
58
- });
59
-
60
- describe('Checkers', function () {
61
- describe('isVoid', function () {
62
- it('Should check value is undefned or null', function () {
63
- const values = [
64
- [1, false],
65
- [undefined, true],
66
- [null, true],
67
- ['0', false],
68
- [false, false]
69
- ];
70
-
71
- for (let i = 0; i < values.length; i += 1) {
72
- const value = values[i];
73
- expect(value[1]).equals(
74
- Jodit.modules.Helpers.isVoid(value[0])
75
- );
76
- }
77
- });
78
- });
79
-
80
- describe('isURL', function () {
81
- it('Should check value is URL', function () {
82
- const variants = {
83
- '12345678901234567890123': 0,
84
- 'http://j.mp': 1,
85
- 'http://xdan.ru': 1,
86
- ' http://xdan.ru ': 0,
87
- 'https://xdan.ru test': 0,
88
- 'https://xdan.ru?query=1': 1,
89
- 'https://xdan.ru?query': 1,
90
- 'https://xdan.ru:2333?query': 1,
91
- 'http://www.example.com/wpstyle/?p=364': 1,
92
- 'http://userid:password@example.com/': 1,
93
- 'http://userid@example.com:8080/': 1,
94
- 'http://⌘.ws': 1,
95
- 'https://томаты.рф': 1,
96
- 'http://foo.com/blah_(wikipedia)#cite-1': 1,
97
- 'http://foo.bar/?q=Test%20URL-encoded%20stuff': 1,
98
- 'http://a.b-c.de': 1,
99
- 'http://': 0,
100
- 'http://..': 1,
101
- 'http://../': 1,
102
- 'http://##/': 0,
103
- 'http:///a': 1,
104
- '//xdan.ru?query': 0,
105
- '//xdan.ru': 0,
106
- 'ftp://xdan.ru': 1,
107
- 'file://xdan.ru': 1,
108
- 'http://142.42.1.1/': 1,
109
- 'http://142.42.1.1:8080/': 1,
110
- 'httpss://xdan.ru': 0,
111
- 'http://www.google.com/url?sa=i&rct=j&q=&esrc=s&source=images&cd=&docid=nIv5rk2GyP3hXM&tbnid=isiOkMe3nCtexM:&ved=0CAUQjRw&url=http%3A%2F%2Fanimalcrossing.wikia.com%2Fwiki%2FLion&ei=ygZXU_2fGKbMsQTf4YLgAQ&bvm=bv.65177938,d.aWc&psig=AFQjCNEpBfKnal9kU7Zu4n7RnEt2nerN4g&ust=1398298682009707': 1,
112
- 'https://demosite.sharepoint.com/:v:/s/PCGKR005/ESMdCz-_rXtIrwSlDVW2mw0BQ8p9J1qtraaCe4VkVPsn_w?e=gEQORV': 1,
113
- 'https://demo.sharepoint.com/:v:/s/PCGKR005/ESMdCz-_rXtIrwSlDVW2mw0BQ8p9J1qtraaCe4VkVPsn_w?e=gEQORV': 1,
114
- '/index.php': 0
115
- };
116
-
117
- const values = Object.keys(variants);
118
-
119
- for (let i = 0; i < values.length; i += 1) {
120
- const key = values[i],
121
- result = Boolean(variants[key]);
122
-
123
- expect(result).equals(
124
- Jodit.modules.Helpers.isURL(key),
125
- `Is domain "${key}"`
126
- );
127
- }
128
- });
129
- });
130
-
131
- describe('isInt', function () {
132
- it('Should check value is int or not', function () {
133
- const values = [
134
- 'cmd+ alt+s',
135
- false,
136
- '+1',
137
- true,
138
- '-1',
139
- true,
140
- '-1dddd',
141
- false,
142
- '10',
143
- true,
144
- '10.1',
145
- false,
146
- '10e10',
147
- true,
148
- '10e10',
149
- true,
150
- 10,
151
- true,
152
- 11.33,
153
- false
154
- ];
155
-
156
- for (let i = 0; i < values.length; i += 2) {
157
- expect(values[i + 1]).equals(
158
- Jodit.modules.Helpers.isInt(values[i])
159
- );
160
- }
161
- });
162
- });
163
-
164
- describe('isNumeric', function () {
165
- it('Should check value is int or not', function () {
166
- const values = [
167
- 'cmd+ alt+s',
168
- false,
169
- '+1',
170
- true,
171
- '-1',
172
- true,
173
- '-1000.333',
174
- true,
175
- '-1dddd',
176
- false,
177
- 's1999999',
178
- false,
179
- ' -1 ',
180
- false,
181
- '10',
182
- true,
183
- '10.1',
184
- true,
185
- '12312310.1243234',
186
- true,
187
- '10e10',
188
- true,
189
- '10e10',
190
- true,
191
- 10,
192
- true,
193
- 11.33,
194
- true
195
- ];
196
-
197
- for (let i = 0; i < values.length; i += 2) {
198
- expect(values[i + 1]).equals(
199
- Jodit.modules.Helpers.isNumeric(values[i])
200
- );
201
- }
202
- });
203
- });
204
-
205
- describe('isNumber', function () {
206
- it('Should check value is a number', function () {
207
- const values = [
208
- 'cmd+ alt+s',
209
- false,
210
- false,
211
- false,
212
- 10,
213
- true,
214
- 11.33,
215
- true
216
- ];
217
-
218
- for (let i = 0; i < values.length; i += 2) {
219
- expect(values[i + 1]).equals(
220
- Jodit.modules.Helpers.isNumber(values[i])
221
- );
222
- }
223
- });
224
- });
225
- });
226
-
227
- describe('String', function () {
228
- describe('18n', function () {
229
- const i18n = Jodit.modules.Helpers.i18n;
230
-
231
- describe('Put defined sentence', function () {
232
- it('Should replace it on defined language', function () {
233
- const values = [
234
- 'Type something',
235
- 'Напишите что-либо',
236
- 'ru',
237
-
238
- 'rename',
239
- 'Переименовать',
240
- 'ru',
241
-
242
- 'Rename',
243
- 'Переименовать',
244
- 'ru',
245
-
246
- 'About Jodit',
247
- 'حول جوديت',
248
- 'ar',
249
-
250
- 'about Jodit',
251
- 'حول جوديت',
252
- 'ar',
253
-
254
- 'British people',
255
- 'British people',
256
- 'ar'
257
- ];
258
-
259
- for (let i = 0; i < values.length; i += 3) {
260
- expect(values[i + 1]).equals(
261
- i18n(
262
- values[i],
263
- [],
264
- {
265
- language: values[i + 2]
266
- },
267
- true
268
- )
269
- );
270
- }
271
- });
272
-
273
- describe('Put some information inside sentence', function () {
274
- it('Should put this information inside new sentence', function () {
275
- const values = [
276
- 'Chars: %d',
277
- 'Символов: 1',
278
- 'ru',
279
- [1],
280
- 'Select %s',
281
- 'Выделить: Test',
282
- 'ru',
283
- ['Test'],
284
- 'select %s',
285
- 'Выделить: Test',
286
- 'ru',
287
- ['Test'],
288
- 'Bla %d Bla %s',
289
- 'Bla 1 Bla boo',
290
- 'ru',
291
- [1, 'boo'],
292
- 'Bla %d Bla %s',
293
- 'Bla 1 Bla boo',
294
- 'ru1',
295
- [1, 'boo']
296
- ];
297
-
298
- for (let i = 0; i < values.length; i += 4) {
299
- expect(values[i + 1]).equals(
300
- i18n(
301
- values[i],
302
- values[i + 3],
303
- {
304
- language: values[i + 2]
305
- },
306
- true
307
- )
308
- );
309
- }
310
- });
311
- });
312
- });
313
-
314
- describe('Debug mode', function () {
315
- it('Should show debug brackets for undefined keys', function () {
316
- const values = [
317
- 'Type something',
318
- 'Напишите что-либо',
319
- 'ru',
320
-
321
- 'About Jodit',
322
- 'حول جوديت',
323
- 'ar',
324
-
325
- 'About Jodit',
326
- '{About Jodit}',
327
- 'ar1',
328
-
329
- 'British people',
330
- '{British people}',
331
- 'ar'
332
- ];
333
-
334
- for (let i = 0; i < values.length; i += 3) {
335
- expect(values[i + 1]).equals(
336
- i18n(
337
- values[i],
338
- [],
339
- {
340
- language: values[i + 2],
341
- debugLanguage: true
342
- },
343
- true
344
- )
345
- );
346
- }
347
- });
348
- });
349
-
350
- describe('Define i18n property inside input options', function () {
351
- it('Should use it', function () {
352
- const values = [
353
- 'Type something',
354
- 'Привет',
355
- 'ru',
356
- 'About Jodit',
357
- 'جوديت',
358
- 'ar',
359
- 'British people',
360
- 'Bond',
361
- 'ar'
362
- ];
363
-
364
- const opt = {
365
- ru: {
366
- 'Type something': 'Привет'
367
- },
368
- ar: {
369
- 'About Jodit': 'جوديت',
370
- 'British people': 'Bond'
371
- }
372
- };
373
-
374
- for (let i = 0; i < values.length; i += 3) {
375
- expect(values[i + 1]).equals(
376
- i18n(
377
- values[i],
378
- [],
379
- {
380
- language: values[i + 2],
381
- i18n: opt,
382
- debugLanguage: true
383
- },
384
- true
385
- )
386
- );
387
- }
388
- });
389
- });
390
- });
391
- });
392
-
393
- describe('HTML', function () {
394
- describe('stripTags', function () {
395
- describe('Put HTML text', function () {
396
- it('Should return only text', function () {
397
- const values = [
398
- ['<p>Type something<p>', 'Type something'],
399
- [
400
- '<p>Type <strong>something</strong><p>',
401
- 'Type something'
402
- ],
403
- [
404
- '<p>Type <strong>some<br>thing</strong><p>',
405
- 'Type some thing'
406
- ],
407
- [
408
- '<p>Type <strong>something</strong></p><p>Type <strong>something</strong></p>',
409
- 'Type something Type something'
410
- ]
411
- ];
412
-
413
- for (let i = 0; i < values.length; i += 1) {
414
- expect(values[i][1]).equals(
415
- Jodit.modules.Helpers.stripTags(
416
- values[i][0]
417
- ).replace(/\n/g, '')
418
- );
419
- }
420
- });
421
- });
422
- });
423
- });
424
-
425
- describe('Object', function () {
426
- describe('get', function () {
427
- it('Should get value from keyChain else return null', function () {
428
- const obj = {
429
- a1: 2,
430
- a: {
431
- b1: [
432
- {
433
- key: 5
434
- }
435
- ],
436
- b: {
437
- c: {
438
- d: {
439
- e: 1
440
- },
441
- e: false
442
- }
443
- }
444
- }
445
- };
446
-
447
- const values = [
448
- ['', null],
449
- [undefined, null],
450
- [null, null],
451
- ['a1', 2],
452
- ['a', obj.a],
453
- ['a2', null],
454
- ['a.b.c.d.e', 1],
455
- ['a.b.c.e', false],
456
- ['a.b.r.d.e', null],
457
- ['a.b1.0.key', 5],
458
- ['a.b1.0.key1', null]
459
- ];
460
-
461
- for (let i = 0; i < values.length; i += 1) {
462
- const value = values[i];
463
- expect(value[1]).equals(
464
- Jodit.modules.Helpers.get(value[0], obj)
465
- );
466
- }
467
- });
468
- });
469
-
470
- describe('set', function () {
471
- it('Should set value by keyChain', function () {
472
- let obj = {};
473
-
474
- const values = [
475
- ['', null, {}],
476
- [undefined, null, {}],
477
- [null, null, {}],
478
- ['a1', 2, { a1: 2 }],
479
- ['a', 1, { a1: 2, a: 1 }],
480
- ['a2', null, { a1: 2, a: 1, a2: null }],
481
- [
482
- 'a.b.c.d.e',
483
- 1,
484
- {
485
- a1: 2,
486
- a: {
487
- b: {
488
- c: {
489
- d: {
490
- e: 1
491
- }
492
- }
493
- }
494
- },
495
- a2: null
496
- }
497
- ],
498
- [
499
- 'a.b.c.d.e',
500
- 1,
501
- {
502
- a1: 2,
503
- a: {
504
- b: {
505
- c: {
506
- d: {
507
- e: 1
508
- }
509
- }
510
- }
511
- },
512
- a2: null
513
- }
514
- ],
515
- [
516
- 'a.b.c.e',
517
- false,
518
- {
519
- a1: 2,
520
- a: {
521
- b: {
522
- c: {
523
- e: false,
524
- d: {
525
- e: 1
526
- }
527
- }
528
- }
529
- },
530
- a2: null
531
- }
532
- ],
533
- [
534
- 'a.b1.0.key',
535
- 5,
536
- {
537
- a1: 2,
538
- a: {
539
- b1: [{ key: 5 }],
540
- b: {
541
- c: {
542
- e: false,
543
- d: {
544
- e: 1
545
- }
546
- }
547
- }
548
- },
549
- a2: null
550
- }
551
- ]
552
- ];
553
-
554
- for (let i = 0; i < values.length; i += 1) {
555
- const value = values[i];
556
- Jodit.modules.Helpers.set(value[0], value[1], obj);
557
- expect(obj).deep.eq(value[2]);
558
- }
559
- });
560
- });
561
- });
562
-
563
- describe('Utils', function () {
564
- describe('reset', function () {
565
- it('It should reset native browser method', function () {
566
- expect(typeof Jodit.modules.Helpers.reset('Array.from')).equals(
567
- 'function'
568
- );
569
-
570
- expect(Jodit.modules.Helpers.reset('Array.from') !== Array.from)
571
- .is.true;
572
-
573
- expect(
574
- Jodit.modules.Helpers.reset('Array.from')(
575
- new Set([1, 2, 3])
576
- )
577
- ).deep.equals([1, 2, 3]);
578
-
579
- expect(
580
- Jodit.modules.Helpers.reset('Array.from')('123')
581
- ).deep.equals(['1', '2', '3']);
582
- });
583
-
584
- it('should be cached', function () {
585
- expect(Jodit.modules.Helpers.reset('Array.from') !== Array.from)
586
- .is.true;
587
-
588
- expect(
589
- Jodit.modules.Helpers.reset('Array.from') ===
590
- Jodit.modules.Helpers.reset('Array.from')
591
- ).is.true;
592
- });
593
- });
594
-
595
- describe('getClassName', function () {
596
- const getClassName = Jodit.modules.Helpers.getClassName;
597
-
598
- it('Should return normal(not uglifyed) name for instance of class', function () {
599
- expect(getClassName(Jodit.modules.Popup.prototype)).equals(
600
- 'Popup'
601
- );
602
- expect(getClassName(Jodit.modules.UIButton.prototype)).equals(
603
- 'UIButton'
604
- );
605
- expect(
606
- getClassName(Jodit.modules.ToolbarButton.prototype)
607
- ).equals('ToolbarButton');
608
- });
609
- });
610
- });
611
-
612
- describe('Config prototype', function () {
613
- const ConfigProto = Jodit.modules.Helpers.ConfigProto;
614
-
615
- it('Should use object B as prototype for A', function () {
616
- const A = {
617
- a: 1,
618
-
619
- e: {
620
- f: {
621
- g: 5
622
- }
623
- }
624
- };
625
- const B = {
626
- a: 2,
627
- b: 3,
628
- e: {
629
- f: {
630
- g: 6,
631
- h: 7
632
- }
633
- }
634
- };
635
-
636
- const C = ConfigProto(A, B);
637
-
638
- expect(C).does.not.eq(A);
639
- expect(C.a).eq(1);
640
- expect(C.b).eq(3);
641
- expect(C.e.f.g).eq(5);
642
- expect(C.e.f.h).eq(7);
643
-
644
- B.e.f.h = 9;
645
- expect(C.e.f.h).eq(9);
646
- });
647
-
648
- describe('Several prototypes', function () {
649
- it('Should use all objects as prototype for A', function () {
650
- const A = {
651
- a: 1,
652
-
653
- e: {
654
- f: {
655
- g: 5
656
- }
657
- }
658
- };
659
-
660
- const B = {
661
- a: 2,
662
- b: 3,
663
- e: {
664
- f: {
665
- g: 6,
666
- k: 90
667
- }
668
- }
669
- };
670
-
671
- const C = {
672
- e: {
673
- f: {
674
- h: 7
675
- }
676
- }
677
- };
678
-
679
- const D = ConfigProto(A, ConfigProto(B, C));
680
-
681
- expect(D).does.not.eq(A);
682
- expect(D.a).eq(1);
683
- expect(D.b).eq(3);
684
- expect(D.e.f.g).eq(5);
685
- expect(D.e.f.h).eq(7);
686
- expect(D.e.f.k).eq(90);
687
-
688
- C.e.f.h = 9;
689
- expect(D.e.f.h).eq(9);
690
- });
691
- });
692
-
693
- describe('Atom values', function () {
694
- it('Should not merge', function () {
695
- const A = {
696
- a: Jodit.atom({
697
- b: {
698
- c: 1
699
- }
700
- })
701
- };
702
-
703
- const B = {
704
- a: {
705
- b: {
706
- c: 1,
707
- e: 5
708
- }
709
- }
710
- };
711
-
712
- const res = ConfigProto(A, B);
713
-
714
- expect(res.a.b.c).eq(1);
715
- expect(res.a.b.e).eq(undefined);
716
- });
717
- });
718
-
719
- describe('Arrays', function () {
720
- it('Should merge - not concat', function () {
721
- const A = {
722
- a: {
723
- b: [1, 2, 3, 4]
724
- }
725
- };
726
-
727
- const B = {
728
- a: {
729
- b: [5, 6, 7, 8, 9]
730
- }
731
- };
732
-
733
- const res = ConfigProto(A, B);
734
-
735
- expect(res.a.b).deep.eq([1, 2, 3, 4, 9]);
736
- });
737
-
738
- describe('Atom array', function () {
739
- it('Should be not merged', function () {
740
- const A = {
741
- a: { b: Jodit.atom([1, 2, 3, 4]) }
742
- };
743
-
744
- const B = {
745
- a: { b: [5, 6, 7, 8, 9] }
746
- };
747
-
748
- const res = ConfigProto(A, B);
749
-
750
- expect(res.a.b).deep.eq([1, 2, 3, 4]);
751
- });
752
-
753
- describe('On first level all arrays', function () {
754
- it('Should work as atomic', function () {
755
- const A = {
756
- a: [1, 2, 3, 4]
757
- };
758
-
759
- const B = {
760
- a: [5, 6, 7, 8, 9]
761
- };
762
-
763
- const res = ConfigProto(A, B);
764
-
765
- expect(res.a).deep.eq([1, 2, 3, 4]);
766
- });
767
- });
768
- });
769
- });
770
- });
771
- });