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.
- package/.idea/codeStyles/Project.xml +68 -0
- package/.idea/codeStyles/codeStyleConfig.xml +5 -0
- package/.idea/dictionaries/v_chupurnov.xml +10 -0
- package/.idea/encodings.xml +4 -0
- package/.idea/inspectionProfiles/Project_Default.xml +118 -0
- package/.idea/jodit.iml +12 -0
- package/.idea/jsLibraryMappings.xml +6 -0
- package/.idea/markdown-navigator-enh.xml +29 -0
- package/.idea/markdown-navigator.xml +55 -0
- package/.idea/misc.xml +6 -0
- package/.idea/modules.xml +8 -0
- package/.idea/prettier.xml +6 -0
- package/.idea/vcs.xml +6 -0
- package/.idea/watcherTasks.xml +4 -0
- package/.idea/workspace.xml +1264 -0
- package/build/jodit.css +2 -2
- package/build/jodit.es2018.css +1 -1
- package/build/jodit.es2018.en.css +1 -1
- package/build/jodit.es2018.en.js +4 -4
- package/build/jodit.es2018.en.min.js +2 -2
- package/build/jodit.es2018.js +4 -4
- package/build/jodit.es2018.min.js +2 -2
- package/build/jodit.js +4 -4
- package/build/jodit.min.css +1 -1
- package/build/jodit.min.js +2 -2
- package/package.json +2 -2
- package/.travis.yml +0 -7
- package/bower.json +0 -33
- package/build.js +0 -39
- package/docker/Dockerfile +0 -11
- package/docker/README.md +0 -45
- package/docker/build +0 -3
- package/docker/install +0 -7
- package/docker/start +0 -3
- package/docker/test +0 -3
- package/docker/uninstall +0 -3
- package/examples/arabic.lang.html +0 -76
- package/examples/assets/app.css +0 -175
- package/examples/assets/app.js +0 -57
- package/examples/assets/download.jpg +0 -0
- package/examples/assets/icon.png +0 -0
- package/examples/assets/logo.png +0 -0
- package/examples/assets/prism.css +0 -200
- package/examples/assets/prism.js +0 -1254
- package/examples/color-picker.html +0 -139
- package/examples/custom-icons.html +0 -173
- package/examples/custom-toolbar.html +0 -80
- package/examples/example.default.html +0 -75
- package/examples/fullsize.html +0 -75
- package/examples/index.html +0 -176
- package/examples/inline-mode.html +0 -116
- package/examples/oneinstance.html +0 -125
- package/icons.html +0 -50
- package/karma.conf.js +0 -157
- package/make.js +0 -10
- package/server.js +0 -101
- package/test/bootstrap.js +0 -1167
- package/test/test.html +0 -102
- package/test/test.index.html +0 -11
- package/test/tests/acceptance/clipboardTest.js +0 -1234
- package/test/tests/acceptance/commandsTest.js +0 -647
- package/test/tests/acceptance/creatorTest.js +0 -103
- package/test/tests/acceptance/deleteBackSpaceTest.js +0 -1289
- package/test/tests/acceptance/dialogTest.js +0 -188
- package/test/tests/acceptance/editorTest.js +0 -855
- package/test/tests/acceptance/enterTest.js +0 -1088
- package/test/tests/acceptance/eventsTest.js +0 -1246
- package/test/tests/acceptance/filebrowserTest.js +0 -1309
- package/test/tests/acceptance/i18nTest.js +0 -81
- package/test/tests/acceptance/iframeTest.js +0 -306
- package/test/tests/acceptance/imageTest.js +0 -1649
- package/test/tests/acceptance/inlineModeTest.js +0 -826
- package/test/tests/acceptance/interfaceTest.js +0 -119
- package/test/tests/acceptance/mobileTest.js +0 -229
- package/test/tests/acceptance/plugins/classSpan.js +0 -220
- package/test/tests/acceptance/plugins/cleanHtml.js +0 -351
- package/test/tests/acceptance/plugins/color.js +0 -188
- package/test/tests/acceptance/plugins/dragAndDropElement.js +0 -172
- package/test/tests/acceptance/plugins/focus.js +0 -115
- package/test/tests/acceptance/plugins/font.js +0 -316
- package/test/tests/acceptance/plugins/image.js +0 -79
- package/test/tests/acceptance/plugins/indent.js +0 -179
- package/test/tests/acceptance/plugins/inline-popup.js +0 -578
- package/test/tests/acceptance/plugins/insert.js +0 -17
- package/test/tests/acceptance/plugins/limit.js +0 -164
- package/test/tests/acceptance/plugins/link.js +0 -1640
- package/test/tests/acceptance/plugins/orderedList.js +0 -290
- package/test/tests/acceptance/plugins/placeholder.js +0 -138
- package/test/tests/acceptance/plugins/resizer.js +0 -329
- package/test/tests/acceptance/plugins/search.js +0 -623
- package/test/tests/acceptance/plugins/size.js +0 -344
- package/test/tests/acceptance/plugins/source.js +0 -218
- package/test/tests/acceptance/plugins/stat.js +0 -120
- package/test/tests/acceptance/plugins/tooltip.js +0 -97
- package/test/tests/acceptance/plugins/wrapTextNodes.js +0 -105
- package/test/tests/acceptance/pluginsTest.js +0 -2219
- package/test/tests/acceptance/selectionTest.js +0 -862
- package/test/tests/acceptance/statesTest.js +0 -310
- package/test/tests/acceptance/tableTest.js +0 -1988
- package/test/tests/acceptance/toolbarTest.js +0 -1747
- package/test/tests/acceptance/undoredoTest.js +0 -217
- package/test/tests/acceptance/uploaderTest.js +0 -187
- package/test/tests/artio.jpg +0 -0
- package/test/tests/units/helpersTest.js +0 -771
- package/test/tests/units/modules/dom.js +0 -282
- package/test/tests/units/objectObserverTest.js +0 -533
- package/test/tests/units/popupTest.js +0 -211
- package/test/tests/units/positionTest.js +0 -238
- package/test/tests/units/styleTest.js +0 -1361
- package/webpack.config.js +0 -308
|
@@ -1,855 +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('Jodit Editor Tests', function () {
|
|
7
|
-
describe('Constructor', function () {
|
|
8
|
-
it('Constructor Jodit must be in global scope', function () {
|
|
9
|
-
expect(window.Jodit).is.a('function');
|
|
10
|
-
});
|
|
11
|
-
|
|
12
|
-
it('Constructor default should not be in global scope', function () {
|
|
13
|
-
expect(window.default).is.not.a('function');
|
|
14
|
-
expect(window.default).does.not.equal(window.Jodit);
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
describe('First argument', function () {
|
|
18
|
-
describe('String #id', function () {
|
|
19
|
-
it('Should be valid selector', function () {
|
|
20
|
-
const area = appendTestArea('editor');
|
|
21
|
-
|
|
22
|
-
const editor = new Jodit('#editor');
|
|
23
|
-
expect(editor.element).equals(area);
|
|
24
|
-
editor.destruct();
|
|
25
|
-
});
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
describe('Undefined,null,false,bad seelctor,function,number, text node', function () {
|
|
29
|
-
it('Should be not valid selector', function () {
|
|
30
|
-
expect(function () {
|
|
31
|
-
// eslint-disable-next-line no-new
|
|
32
|
-
new Jodit(0);
|
|
33
|
-
}).to.throw(Error);
|
|
34
|
-
|
|
35
|
-
expect(function () {
|
|
36
|
-
// eslint-disable-next-line no-new
|
|
37
|
-
new Jodit();
|
|
38
|
-
}).to.throw(Error);
|
|
39
|
-
|
|
40
|
-
expect(function () {
|
|
41
|
-
// eslint-disable-next-line no-new
|
|
42
|
-
new Jodit(null);
|
|
43
|
-
}).to.throw(Error);
|
|
44
|
-
|
|
45
|
-
expect(function () {
|
|
46
|
-
// eslint-disable-next-line no-new
|
|
47
|
-
new Jodit(false);
|
|
48
|
-
}).to.throw(Error);
|
|
49
|
-
|
|
50
|
-
expect(function () {
|
|
51
|
-
// eslint-disable-next-line no-new
|
|
52
|
-
new Jodit('.salomon');
|
|
53
|
-
}).to.throw(Error);
|
|
54
|
-
|
|
55
|
-
expect(function () {
|
|
56
|
-
// eslint-disable-next-line no-new
|
|
57
|
-
new Jodit('>asdsad.salomon');
|
|
58
|
-
}).to.throw(Error);
|
|
59
|
-
|
|
60
|
-
expect(function () {
|
|
61
|
-
// eslint-disable-next-line no-new
|
|
62
|
-
new Jodit(function () {});
|
|
63
|
-
}).to.throw(Error);
|
|
64
|
-
|
|
65
|
-
expect(function () {
|
|
66
|
-
// eslint-disable-next-line no-new
|
|
67
|
-
new Jodit(233);
|
|
68
|
-
}).to.throw(Error);
|
|
69
|
-
|
|
70
|
-
const elm = document.createTextNode('stop');
|
|
71
|
-
expect(function () {
|
|
72
|
-
// eslint-disable-next-line no-new
|
|
73
|
-
new Jodit(elm);
|
|
74
|
-
}).to.throw(Error);
|
|
75
|
-
});
|
|
76
|
-
});
|
|
77
|
-
|
|
78
|
-
describe('HTMLTextAreaElement', function () {
|
|
79
|
-
it('Should be instance of HTMLElement', function () {
|
|
80
|
-
const area = appendTestArea('editor2');
|
|
81
|
-
|
|
82
|
-
const editor2 = getJodit(undefined, area);
|
|
83
|
-
expect(editor2.element).equals(area);
|
|
84
|
-
editor2.destruct();
|
|
85
|
-
});
|
|
86
|
-
});
|
|
87
|
-
|
|
88
|
-
describe('HTMLDivElement', function () {
|
|
89
|
-
it('Should be instance of HTMLElement', function () {
|
|
90
|
-
const div = document.createElement('div');
|
|
91
|
-
div.innerHTML = '<h1>Test</h1>';
|
|
92
|
-
document.body.appendChild(div);
|
|
93
|
-
const editor3 = getJodit(undefined, div);
|
|
94
|
-
|
|
95
|
-
expect(editor3.element).equals(div);
|
|
96
|
-
expect('<h1>Test</h1>').equals(editor3.getEditorValue());
|
|
97
|
-
|
|
98
|
-
editor3.destruct();
|
|
99
|
-
document.body.removeChild(div);
|
|
100
|
-
});
|
|
101
|
-
});
|
|
102
|
-
|
|
103
|
-
describe('Found element', function () {
|
|
104
|
-
it('Should be instance of HTMLElement', function () {
|
|
105
|
-
const div = document.createElement('div');
|
|
106
|
-
div.innerHTML = '<h1>Test</h1>';
|
|
107
|
-
div.setAttribute('id', 'test2222');
|
|
108
|
-
document.body.appendChild(div);
|
|
109
|
-
|
|
110
|
-
const found = document.getElementById('test2222');
|
|
111
|
-
|
|
112
|
-
const editor3 = getJodit(undefined, found);
|
|
113
|
-
|
|
114
|
-
expect(editor3.element).equals(found);
|
|
115
|
-
expect('<h1>Test</h1>').equals(editor3.getEditorValue());
|
|
116
|
-
editor3.destruct();
|
|
117
|
-
|
|
118
|
-
document.body.removeChild(div);
|
|
119
|
-
});
|
|
120
|
-
});
|
|
121
|
-
});
|
|
122
|
-
|
|
123
|
-
it('Editor should replace and hide source textarea', function () {
|
|
124
|
-
const area = appendTestArea();
|
|
125
|
-
|
|
126
|
-
const editor = getJodit(undefined, area);
|
|
127
|
-
expect(area.style.display).equals('none');
|
|
128
|
-
|
|
129
|
-
if (!editor.options.iframe) {
|
|
130
|
-
expect(editor.editor).equals(
|
|
131
|
-
document.querySelector('.jodit-wysiwyg')
|
|
132
|
-
);
|
|
133
|
-
} else {
|
|
134
|
-
expect(editor.editor).equals(editor.ed.body);
|
|
135
|
-
}
|
|
136
|
-
});
|
|
137
|
-
|
|
138
|
-
describe('Source textarea', () => {
|
|
139
|
-
it('should have component properties with Jodit instance', function () {
|
|
140
|
-
const area = appendTestArea();
|
|
141
|
-
|
|
142
|
-
const editor = getJodit(undefined, area);
|
|
143
|
-
expect(area.component).equals(editor);
|
|
144
|
-
});
|
|
145
|
-
|
|
146
|
-
describe('After destruct', () => {
|
|
147
|
-
it('should not have component properties with Jodit instance', function () {
|
|
148
|
-
const area = appendTestArea();
|
|
149
|
-
|
|
150
|
-
const editor = getJodit(undefined, area);
|
|
151
|
-
editor.destruct();
|
|
152
|
-
expect(area.component).is.null;
|
|
153
|
-
});
|
|
154
|
-
});
|
|
155
|
-
});
|
|
156
|
-
|
|
157
|
-
describe('Options', function () {
|
|
158
|
-
it('Options should be inherited from the default values', function () {
|
|
159
|
-
const editor = getJodit({
|
|
160
|
-
zIndex: 1986
|
|
161
|
-
});
|
|
162
|
-
|
|
163
|
-
expect(editor.options.zIndex).equals(1986);
|
|
164
|
-
expect(editor.options.spellcheck).is.true;
|
|
165
|
-
});
|
|
166
|
-
|
|
167
|
-
describe('Set nested array', function () {
|
|
168
|
-
it('Should create editor with merged default array and set array', function () {
|
|
169
|
-
Jodit.defaultOptions.someArray = {
|
|
170
|
-
data: [1, 2, 3, 4]
|
|
171
|
-
};
|
|
172
|
-
const editor = getJodit({
|
|
173
|
-
someArray: {
|
|
174
|
-
data: [5, 6, 7]
|
|
175
|
-
}
|
|
176
|
-
});
|
|
177
|
-
|
|
178
|
-
expect(editor.options.someArray.data.toString()).equals(
|
|
179
|
-
'5,6,7,4'
|
|
180
|
-
);
|
|
181
|
-
});
|
|
182
|
-
|
|
183
|
-
describe('Set nested array like Jodit.atom', function () {
|
|
184
|
-
it('Should create editor with set array', function () {
|
|
185
|
-
Jodit.defaultOptions.someArray = {
|
|
186
|
-
data: [1, 2, 3, 4]
|
|
187
|
-
};
|
|
188
|
-
|
|
189
|
-
const editor = getJodit({
|
|
190
|
-
someArray: {
|
|
191
|
-
data: Jodit.atom([5, 6, 7])
|
|
192
|
-
}
|
|
193
|
-
});
|
|
194
|
-
|
|
195
|
-
expect(editor.options.someArray.data.toString()).equals(
|
|
196
|
-
'5,6,7'
|
|
197
|
-
);
|
|
198
|
-
});
|
|
199
|
-
});
|
|
200
|
-
});
|
|
201
|
-
|
|
202
|
-
describe('Set nested object', function () {
|
|
203
|
-
it('Should create editor with merged default object and set object', function () {
|
|
204
|
-
Jodit.defaultOptions.someObject = {
|
|
205
|
-
data: {
|
|
206
|
-
left: 10,
|
|
207
|
-
right: 20
|
|
208
|
-
}
|
|
209
|
-
};
|
|
210
|
-
|
|
211
|
-
const editor = getJodit({
|
|
212
|
-
someObject: {
|
|
213
|
-
data: {
|
|
214
|
-
top: 10,
|
|
215
|
-
right: 10
|
|
216
|
-
}
|
|
217
|
-
}
|
|
218
|
-
});
|
|
219
|
-
|
|
220
|
-
expect(
|
|
221
|
-
JSON.stringify(flatten(editor.options.someObject.data))
|
|
222
|
-
).equals('{"top":10,"right":10,"left":10}');
|
|
223
|
-
});
|
|
224
|
-
|
|
225
|
-
describe('Set nested object like Jodit.atom', function () {
|
|
226
|
-
it('Should create editor with set object', function () {
|
|
227
|
-
Jodit.defaultOptions.someObject = {
|
|
228
|
-
data: {
|
|
229
|
-
left: 10,
|
|
230
|
-
right: 20
|
|
231
|
-
}
|
|
232
|
-
};
|
|
233
|
-
|
|
234
|
-
const editor = getJodit({
|
|
235
|
-
someObject: {
|
|
236
|
-
data: Jodit.atom({
|
|
237
|
-
top: 10,
|
|
238
|
-
right: 10
|
|
239
|
-
})
|
|
240
|
-
}
|
|
241
|
-
});
|
|
242
|
-
|
|
243
|
-
expect(
|
|
244
|
-
JSON.stringify(editor.options.someObject.data)
|
|
245
|
-
).equals('{"top":10,"right":10}');
|
|
246
|
-
});
|
|
247
|
-
});
|
|
248
|
-
});
|
|
249
|
-
|
|
250
|
-
describe('Statusbar', function () {
|
|
251
|
-
describe('Hide', function () {
|
|
252
|
-
it('should not show statusbar', function () {
|
|
253
|
-
const editor = getJodit({
|
|
254
|
-
statusbar: false
|
|
255
|
-
});
|
|
256
|
-
|
|
257
|
-
expect(
|
|
258
|
-
editor.container
|
|
259
|
-
.querySelector('.jodit-status-bar')
|
|
260
|
-
.classList.contains('jodit_hidden')
|
|
261
|
-
).is.true;
|
|
262
|
-
|
|
263
|
-
expect(editor.statusbar.isShown).is.false;
|
|
264
|
-
});
|
|
265
|
-
|
|
266
|
-
describe('Show programmatically', function () {
|
|
267
|
-
it('should show statusbar', function () {
|
|
268
|
-
const editor = getJodit({
|
|
269
|
-
statusbar: false
|
|
270
|
-
});
|
|
271
|
-
|
|
272
|
-
expect(
|
|
273
|
-
editor.container
|
|
274
|
-
.querySelector('.jodit-status-bar')
|
|
275
|
-
.classList.contains('jodit_hidden')
|
|
276
|
-
).is.true;
|
|
277
|
-
expect(editor.statusbar.isShown).is.false;
|
|
278
|
-
|
|
279
|
-
editor.statusbar.show();
|
|
280
|
-
|
|
281
|
-
expect(
|
|
282
|
-
editor.container
|
|
283
|
-
.querySelector('.jodit-status-bar')
|
|
284
|
-
.classList.contains('jodit_hidden')
|
|
285
|
-
).is.false;
|
|
286
|
-
expect(editor.statusbar.isShown).is.true;
|
|
287
|
-
});
|
|
288
|
-
});
|
|
289
|
-
});
|
|
290
|
-
|
|
291
|
-
describe('Show', function () {
|
|
292
|
-
it('should show statusbar', function () {
|
|
293
|
-
const editor = getJodit();
|
|
294
|
-
|
|
295
|
-
expect(
|
|
296
|
-
editor.container
|
|
297
|
-
.querySelector('.jodit-status-bar')
|
|
298
|
-
.classList.contains('jodit_hidden')
|
|
299
|
-
).is.false;
|
|
300
|
-
expect(editor.statusbar.isShown).is.true;
|
|
301
|
-
});
|
|
302
|
-
});
|
|
303
|
-
});
|
|
304
|
-
});
|
|
305
|
-
|
|
306
|
-
describe('Set font for editor', function () {
|
|
307
|
-
it('Should set the font-family of the editor by option', function () {
|
|
308
|
-
const editor = getJodit({
|
|
309
|
-
style: {
|
|
310
|
-
fontFamily: 'Arial'
|
|
311
|
-
}
|
|
312
|
-
});
|
|
313
|
-
|
|
314
|
-
editor.value = '<some>test</some>';
|
|
315
|
-
|
|
316
|
-
const style = window.getComputedStyle(editor.editor.firstChild);
|
|
317
|
-
|
|
318
|
-
expect(style.fontFamily).equals('Arial');
|
|
319
|
-
});
|
|
320
|
-
});
|
|
321
|
-
|
|
322
|
-
describe('Check preset', function () {
|
|
323
|
-
it('Should set option by preset', function () {
|
|
324
|
-
const editor2 = getJodit();
|
|
325
|
-
|
|
326
|
-
expect(editor2.options.inline).is.false;
|
|
327
|
-
expect(editor2.options.toolbar).is.true;
|
|
328
|
-
expect(editor2.options.readonly).is.false;
|
|
329
|
-
|
|
330
|
-
const editor = getJodit({
|
|
331
|
-
preset: 'inline'
|
|
332
|
-
});
|
|
333
|
-
expect(editor.options.inline).is.true;
|
|
334
|
-
expect(editor.options.toolbar).is.false;
|
|
335
|
-
|
|
336
|
-
Jodit.defaultOptions.presets.custom = { readonly: true };
|
|
337
|
-
const editor3 = getJodit({
|
|
338
|
-
preset: 'custom'
|
|
339
|
-
});
|
|
340
|
-
expect(editor3.options.readonly).is.true;
|
|
341
|
-
|
|
342
|
-
const editor4 = getJodit({
|
|
343
|
-
preset: 'inline',
|
|
344
|
-
inline: false
|
|
345
|
-
});
|
|
346
|
-
expect(editor4.options.inline).is.false;
|
|
347
|
-
expect(editor4.options.toolbar).is.false;
|
|
348
|
-
});
|
|
349
|
-
});
|
|
350
|
-
});
|
|
351
|
-
|
|
352
|
-
describe('Editors stack', function () {
|
|
353
|
-
it('Jodit.instances should contain all instances of Jodit', function () {
|
|
354
|
-
const editor = getJodit(
|
|
355
|
-
undefined,
|
|
356
|
-
appendTestArea('textarea_editor')
|
|
357
|
-
);
|
|
358
|
-
expect(Jodit.instances.textarea_editor).equals(editor);
|
|
359
|
-
});
|
|
360
|
-
|
|
361
|
-
it('Jodit.instances should not contain editor after destruct', function () {
|
|
362
|
-
const editor = getJodit(
|
|
363
|
-
undefined,
|
|
364
|
-
appendTestArea('textarea_editor')
|
|
365
|
-
);
|
|
366
|
-
editor.destruct();
|
|
367
|
-
expect(Jodit.instances.textarea_editor).to.be.an('undefined');
|
|
368
|
-
});
|
|
369
|
-
});
|
|
370
|
-
|
|
371
|
-
describe('Destructor', function () {
|
|
372
|
-
it('After call "destruct" method, should return source textarea and remove Editor\'s stuf', function () {
|
|
373
|
-
const area = appendTestArea();
|
|
374
|
-
area.style.display = 'block';
|
|
375
|
-
|
|
376
|
-
const editor = getJodit(undefined, area);
|
|
377
|
-
expect(area.style.display).equals('none');
|
|
378
|
-
expect(editor.container.parentNode).equals(area.parentNode);
|
|
379
|
-
editor.destruct();
|
|
380
|
-
|
|
381
|
-
expect(area.style.display).equals('block');
|
|
382
|
-
expect(editor.editor).equals(undefined);
|
|
383
|
-
});
|
|
384
|
-
|
|
385
|
-
it('After call "destruct" method, should return source textarea and remove all Editor\'s stuf', function () {
|
|
386
|
-
const box = document.createElement('div'),
|
|
387
|
-
area = document.createElement('textarea');
|
|
388
|
-
|
|
389
|
-
box.appendChild(area);
|
|
390
|
-
document.body.appendChild(box);
|
|
391
|
-
|
|
392
|
-
const editor = getJodit(undefined, area);
|
|
393
|
-
editor.destruct();
|
|
394
|
-
|
|
395
|
-
expect(box.innerHTML).equals('<textarea></textarea>');
|
|
396
|
-
box.parentNode.removeChild(box);
|
|
397
|
-
});
|
|
398
|
-
});
|
|
399
|
-
|
|
400
|
-
describe('Set/Get', function () {
|
|
401
|
-
describe('Set value', function () {
|
|
402
|
-
it('Set element value', function () {
|
|
403
|
-
const area = appendTestArea();
|
|
404
|
-
const editor = getJodit(undefined, area);
|
|
405
|
-
editor.setElementValue('<p>Test</p>');
|
|
406
|
-
expect(area.value).equals('<p>Test</p>');
|
|
407
|
-
});
|
|
408
|
-
|
|
409
|
-
it('Set value by magic property', function () {
|
|
410
|
-
const area = appendTestArea();
|
|
411
|
-
const editor = getJodit(undefined, area);
|
|
412
|
-
editor.value = 'Test';
|
|
413
|
-
|
|
414
|
-
expect(area.value).equals('<p>Test</p>');
|
|
415
|
-
expect(editor.value).equals('<p>Test</p>');
|
|
416
|
-
});
|
|
417
|
-
});
|
|
418
|
-
|
|
419
|
-
it('Set wrong element value', function () {
|
|
420
|
-
const area = appendTestArea(),
|
|
421
|
-
editor = getJodit(undefined, area);
|
|
422
|
-
|
|
423
|
-
expect(function () {
|
|
424
|
-
editor.setElementValue(document.createTextNode('Test'));
|
|
425
|
-
}).to.throw(/value must be/);
|
|
426
|
-
});
|
|
427
|
-
|
|
428
|
-
it('Set editor value', function () {
|
|
429
|
-
const editor = getJodit();
|
|
430
|
-
|
|
431
|
-
editor.value = '<div>Test</div>';
|
|
432
|
-
expect(editor.editor.innerHTML).equals('<div>Test</div>');
|
|
433
|
-
});
|
|
434
|
-
|
|
435
|
-
it('Set no string editor value', function () {
|
|
436
|
-
const editor = getJodit();
|
|
437
|
-
|
|
438
|
-
expect(function () {
|
|
439
|
-
editor.value = document.createElement('div');
|
|
440
|
-
}).to.throw(/value must be/);
|
|
441
|
-
});
|
|
442
|
-
|
|
443
|
-
it('Set wrong editor value', function () {
|
|
444
|
-
const editor = getJodit();
|
|
445
|
-
|
|
446
|
-
editor.value = '<div>Test<div>';
|
|
447
|
-
expect(editor.editor.innerHTML).equals(
|
|
448
|
-
'<div>Test<div></div></div>'
|
|
449
|
-
);
|
|
450
|
-
});
|
|
451
|
-
|
|
452
|
-
describe('Synchronization', function () {
|
|
453
|
-
it('Check synchronization between element and editor', function () {
|
|
454
|
-
const editor = getJodit();
|
|
455
|
-
editor.value = '<div>Test<div>';
|
|
456
|
-
|
|
457
|
-
const range = editor.s.createRange(true);
|
|
458
|
-
|
|
459
|
-
range.selectNodeContents(editor.editor.firstChild);
|
|
460
|
-
range.collapse(false);
|
|
461
|
-
|
|
462
|
-
expect(editor.getElementValue()).equals(
|
|
463
|
-
'<div>Test<div></div></div>'
|
|
464
|
-
);
|
|
465
|
-
});
|
|
466
|
-
|
|
467
|
-
it('Check synchronization between editor and element', function () {
|
|
468
|
-
const area = appendTestArea();
|
|
469
|
-
const editor = getJodit(undefined, area);
|
|
470
|
-
area.value = '<div>Test</div>';
|
|
471
|
-
editor.setElementValue();
|
|
472
|
-
expect(editor.value).equals('<div>Test</div>');
|
|
473
|
-
});
|
|
474
|
-
|
|
475
|
-
it('Check synchronization between editor and element with wrong html', function () {
|
|
476
|
-
const editor = getJodit();
|
|
477
|
-
editor.setElementValue('<div>Test</div>');
|
|
478
|
-
expect(editor.value).equals(editor.getElementValue());
|
|
479
|
-
});
|
|
480
|
-
|
|
481
|
-
it('Check synchronization between editor and element when was pressed button', function () {
|
|
482
|
-
const editor = getJodit();
|
|
483
|
-
editor.setElementValue('<div>Test</div>');
|
|
484
|
-
expect(editor.value).equals(editor.getElementValue());
|
|
485
|
-
|
|
486
|
-
const range = editor.s.createRange(true);
|
|
487
|
-
|
|
488
|
-
range.selectNodeContents(editor.editor.firstChild);
|
|
489
|
-
range.collapse(false);
|
|
490
|
-
|
|
491
|
-
simulateEvent('keydown', Jodit.KEY_ENTER, editor.editor);
|
|
492
|
-
expect(editor.value).equals(editor.getElementValue());
|
|
493
|
-
});
|
|
494
|
-
});
|
|
495
|
-
|
|
496
|
-
describe('Save selection stuf', function () {
|
|
497
|
-
describe('Set false in getEditorValue method', function () {
|
|
498
|
-
it('Should return HTML with selections markers', function () {
|
|
499
|
-
const editor = getJodit();
|
|
500
|
-
editor.value = 'test';
|
|
501
|
-
editor.s.setCursorAfter(editor.editor.firstChild);
|
|
502
|
-
editor.s.save(); // add selection markers
|
|
503
|
-
expect(
|
|
504
|
-
/<span[^>]+id="jodit-selection_marker_[^>]+><\/span>/.test(
|
|
505
|
-
editor.getEditorValue(false)
|
|
506
|
-
)
|
|
507
|
-
).is.true;
|
|
508
|
-
expect(
|
|
509
|
-
/<span[^>]+id="jodit-selection_marker_[^>]+><\/span>/.test(
|
|
510
|
-
editor.getEditorValue(true)
|
|
511
|
-
)
|
|
512
|
-
).is.false;
|
|
513
|
-
});
|
|
514
|
-
});
|
|
515
|
-
});
|
|
516
|
-
|
|
517
|
-
describe('Change returning value', function () {
|
|
518
|
-
describe('Event "beforeGetValueFromEditor"', function () {
|
|
519
|
-
it('Should restore > to normal value in Liquid expressions', function () {
|
|
520
|
-
const editor = getJodit();
|
|
521
|
-
editor.value = 'test {% if a > b %} stop {% if a < b %}';
|
|
522
|
-
expect(editor.value).equals(
|
|
523
|
-
'<p>test {% if a > b %} stop {% if a < b %}</p>'
|
|
524
|
-
);
|
|
525
|
-
|
|
526
|
-
editor.events.on('beforeGetValueFromEditor', function () {
|
|
527
|
-
return editor
|
|
528
|
-
.getNativeEditorValue()
|
|
529
|
-
.replace(/{%[^}]+%}/g, function (match) {
|
|
530
|
-
return match
|
|
531
|
-
.replace(/>/g, '>')
|
|
532
|
-
.replace(/</g, '<');
|
|
533
|
-
});
|
|
534
|
-
});
|
|
535
|
-
|
|
536
|
-
expect(editor.value).equals(
|
|
537
|
-
'<p>test {% if a > b %} stop {% if a < b %}</p>'
|
|
538
|
-
);
|
|
539
|
-
});
|
|
540
|
-
});
|
|
541
|
-
|
|
542
|
-
describe('Event "beforeSetValueToEditor"', function () {
|
|
543
|
-
it('Should be fired before set editor value', function () {
|
|
544
|
-
const editor = getJodit();
|
|
545
|
-
editor.value = 'test';
|
|
546
|
-
expect(editor.value).equals('<p>test</p>');
|
|
547
|
-
|
|
548
|
-
editor.events.on(
|
|
549
|
-
'beforeSetValueToEditor',
|
|
550
|
-
function (old_value) {
|
|
551
|
-
return old_value + ' stop';
|
|
552
|
-
}
|
|
553
|
-
);
|
|
554
|
-
|
|
555
|
-
editor.value = 'test';
|
|
556
|
-
|
|
557
|
-
expect(editor.value).equals('<p>test stop</p>');
|
|
558
|
-
|
|
559
|
-
editor.events.on('beforeSetValueToEditor', function () {
|
|
560
|
-
return false;
|
|
561
|
-
});
|
|
562
|
-
|
|
563
|
-
editor.value = 'uuups';
|
|
564
|
-
|
|
565
|
-
expect(editor.value).equals('<p>test stop</p>');
|
|
566
|
-
});
|
|
567
|
-
});
|
|
568
|
-
});
|
|
569
|
-
|
|
570
|
-
describe('Check Cache decorator', function () {
|
|
571
|
-
describe('Get filebrowser and uploader property from editor', function () {
|
|
572
|
-
describe('FileBrowser', function () {
|
|
573
|
-
it('should create instance of Filebrowser only one time and in lazy mode', function () {
|
|
574
|
-
const editor = getJodit();
|
|
575
|
-
|
|
576
|
-
editor.components.forEach(function (cmp) {
|
|
577
|
-
expect(
|
|
578
|
-
cmp instanceof Jodit.modules.FileBrowser
|
|
579
|
-
).is.false;
|
|
580
|
-
});
|
|
581
|
-
|
|
582
|
-
const filebrowser = editor.filebrowser;
|
|
583
|
-
expect(filebrowser instanceof Jodit.modules.FileBrowser)
|
|
584
|
-
.is.true;
|
|
585
|
-
|
|
586
|
-
let instanceCount = 0;
|
|
587
|
-
|
|
588
|
-
editor.components.forEach(function (cmp) {
|
|
589
|
-
if (cmp instanceof Jodit.modules.FileBrowser) {
|
|
590
|
-
instanceCount += 1;
|
|
591
|
-
expect(filebrowser === cmp).is.true;
|
|
592
|
-
}
|
|
593
|
-
});
|
|
594
|
-
|
|
595
|
-
expect(instanceCount).equals(1);
|
|
596
|
-
|
|
597
|
-
const filebrowser2 = editor.filebrowser;
|
|
598
|
-
editor.components.forEach(function (cmp) {
|
|
599
|
-
if (cmp instanceof Jodit.modules.FileBrowser) {
|
|
600
|
-
instanceCount += 1;
|
|
601
|
-
expect(filebrowser === cmp).is.true;
|
|
602
|
-
}
|
|
603
|
-
});
|
|
604
|
-
|
|
605
|
-
expect(instanceCount).equals(2);
|
|
606
|
-
expect(filebrowser2 === filebrowser).is.true;
|
|
607
|
-
});
|
|
608
|
-
});
|
|
609
|
-
|
|
610
|
-
describe('Uploader', function () {
|
|
611
|
-
it('should create instance of Uploader only one time and in lazy mode', function () {
|
|
612
|
-
const editor = getJodit();
|
|
613
|
-
editor.components.forEach(function (cmp) {
|
|
614
|
-
expect(
|
|
615
|
-
cmp instanceof Jodit.modules.Uploader
|
|
616
|
-
).is.false;
|
|
617
|
-
});
|
|
618
|
-
|
|
619
|
-
const uploader = editor.uploader;
|
|
620
|
-
expect(uploader instanceof Jodit.modules.Uploader).is
|
|
621
|
-
.true;
|
|
622
|
-
|
|
623
|
-
let instanceCount = 0;
|
|
624
|
-
|
|
625
|
-
editor.components.forEach(function (cmp) {
|
|
626
|
-
if (cmp instanceof Jodit.modules.Uploader) {
|
|
627
|
-
instanceCount += 1;
|
|
628
|
-
expect(uploader === cmp).is.true;
|
|
629
|
-
}
|
|
630
|
-
});
|
|
631
|
-
|
|
632
|
-
expect(instanceCount).equals(1);
|
|
633
|
-
|
|
634
|
-
const uploader2 = editor.uploader;
|
|
635
|
-
|
|
636
|
-
editor.components.forEach(function (cmp) {
|
|
637
|
-
if (cmp instanceof Jodit.modules.Uploader) {
|
|
638
|
-
instanceCount += 1;
|
|
639
|
-
expect(uploader === cmp).is.true;
|
|
640
|
-
}
|
|
641
|
-
});
|
|
642
|
-
|
|
643
|
-
expect(instanceCount).equals(2);
|
|
644
|
-
expect(uploader2 === uploader).is.true;
|
|
645
|
-
});
|
|
646
|
-
});
|
|
647
|
-
});
|
|
648
|
-
});
|
|
649
|
-
});
|
|
650
|
-
|
|
651
|
-
describe('Selection module', function () {
|
|
652
|
-
it('Current selection element should be inside editor', function () {
|
|
653
|
-
const editor = getJodit(),
|
|
654
|
-
div = document.createElement('div');
|
|
655
|
-
|
|
656
|
-
document.body.appendChild(div);
|
|
657
|
-
div.innerHTML = 'jingl';
|
|
658
|
-
|
|
659
|
-
const sel = window.getSelection(),
|
|
660
|
-
range = document.createRange();
|
|
661
|
-
|
|
662
|
-
range.selectNodeContents(div);
|
|
663
|
-
range.collapse(false);
|
|
664
|
-
sel.removeAllRanges();
|
|
665
|
-
sel.addRange(range);
|
|
666
|
-
|
|
667
|
-
expect(editor.s.current()).is.null;
|
|
668
|
-
div.parentNode.removeChild(div);
|
|
669
|
-
});
|
|
670
|
-
|
|
671
|
-
it('Current selection element', function () {
|
|
672
|
-
const editor = getJodit(),
|
|
673
|
-
div = editor.ed.createElement('div'),
|
|
674
|
-
text = editor.createInside.text('jingl');
|
|
675
|
-
|
|
676
|
-
editor.value = '';
|
|
677
|
-
div.appendChild(text);
|
|
678
|
-
editor.s.insertNode(div);
|
|
679
|
-
editor.s.setCursorIn(text);
|
|
680
|
-
|
|
681
|
-
expect(editor.s.current()).equals(text);
|
|
682
|
-
});
|
|
683
|
-
|
|
684
|
-
it('Insert simple text node in editor', function () {
|
|
685
|
-
const area = appendTestArea();
|
|
686
|
-
const editor = new Jodit(area);
|
|
687
|
-
editor.s.insertNode(editor.createInside.text('Test'));
|
|
688
|
-
expect(editor.value).equals('<p>Test</p>');
|
|
689
|
-
editor.destruct();
|
|
690
|
-
});
|
|
691
|
-
|
|
692
|
-
it('Insert 3 divs', function () {
|
|
693
|
-
const editor = getJodit();
|
|
694
|
-
|
|
695
|
-
function insert(digit) {
|
|
696
|
-
const div = editor.ed.createElement('div');
|
|
697
|
-
|
|
698
|
-
div.innerHTML = digit;
|
|
699
|
-
editor.s.insertNode(div);
|
|
700
|
-
}
|
|
701
|
-
|
|
702
|
-
insert(1);
|
|
703
|
-
insert(2);
|
|
704
|
-
insert(3);
|
|
705
|
-
|
|
706
|
-
expect(editor.value).equals('<div>1</div><div>2</div><div>3</div>');
|
|
707
|
-
editor.destruct();
|
|
708
|
-
});
|
|
709
|
-
|
|
710
|
-
it('Insert wrong data', function () {
|
|
711
|
-
const editor = getJodit();
|
|
712
|
-
|
|
713
|
-
expect(function () {
|
|
714
|
-
editor.s.insertNode();
|
|
715
|
-
}).to.throw(/node must be/);
|
|
716
|
-
|
|
717
|
-
expect(function () {
|
|
718
|
-
editor.s.insertNode('Text');
|
|
719
|
-
}).to.throw(/node must be/);
|
|
720
|
-
|
|
721
|
-
expect(function () {
|
|
722
|
-
editor.s.insertNode(null);
|
|
723
|
-
}).to.throw(/node must be/);
|
|
724
|
-
|
|
725
|
-
editor.destruct();
|
|
726
|
-
});
|
|
727
|
-
|
|
728
|
-
it('Select all and delete. Check plugin "backspace"', function () {
|
|
729
|
-
const editor = getJodit();
|
|
730
|
-
editor.value = '<p>asdasd</p><p>asdasd</p><p>asd</p>';
|
|
731
|
-
editor.execCommand('selectall');
|
|
732
|
-
editor.execCommand('delete');
|
|
733
|
-
expect(editor.value).equals('');
|
|
734
|
-
editor.destruct();
|
|
735
|
-
});
|
|
736
|
-
|
|
737
|
-
describe('Editor after focus and after blur', function () {
|
|
738
|
-
it('Should change editorIsActive field', function () {
|
|
739
|
-
const input = document.createElement('input'),
|
|
740
|
-
p = document.createElement('p'),
|
|
741
|
-
editor = getJodit();
|
|
742
|
-
|
|
743
|
-
editor.s.focus({
|
|
744
|
-
preventScroll: false
|
|
745
|
-
});
|
|
746
|
-
|
|
747
|
-
input.type = 'input';
|
|
748
|
-
document.body.appendChild(input);
|
|
749
|
-
|
|
750
|
-
p.textContent = 'Hi';
|
|
751
|
-
document.body.appendChild(p);
|
|
752
|
-
|
|
753
|
-
editor.value = '<p>Hello world</p>';
|
|
754
|
-
editor.s.focus();
|
|
755
|
-
editor.s.setCursorAfter(editor.editor.firstChild);
|
|
756
|
-
|
|
757
|
-
expect(editor.editorIsActive).is.true;
|
|
758
|
-
|
|
759
|
-
input.focus();
|
|
760
|
-
simulateEvent('blur', editor.editor);
|
|
761
|
-
expect(editor.editorIsActive).is.false;
|
|
762
|
-
document.body.removeChild(input);
|
|
763
|
-
|
|
764
|
-
editor.s.focus();
|
|
765
|
-
simulateEvent('focus', editor.editor);
|
|
766
|
-
editor.s.setCursorAfter(editor.editor.firstChild);
|
|
767
|
-
expect(editor.editorIsActive).is.true;
|
|
768
|
-
|
|
769
|
-
const range = editor.s.createRange(true);
|
|
770
|
-
|
|
771
|
-
range.selectNodeContents(p);
|
|
772
|
-
|
|
773
|
-
simulateEvent('blur', editor.editor);
|
|
774
|
-
expect(editor.editorIsActive).is.false;
|
|
775
|
-
document.body.removeChild(p);
|
|
776
|
-
});
|
|
777
|
-
});
|
|
778
|
-
|
|
779
|
-
describe('Cursor position', function () {
|
|
780
|
-
it('Should set cursor after node', function () {
|
|
781
|
-
const editor = getJodit({
|
|
782
|
-
cleanHTML: {
|
|
783
|
-
removeEmptyElements: false
|
|
784
|
-
}
|
|
785
|
-
});
|
|
786
|
-
|
|
787
|
-
editor.value = '<p></p>';
|
|
788
|
-
editor.s.setCursorIn(editor.editor.firstChild);
|
|
789
|
-
|
|
790
|
-
const spans = [
|
|
791
|
-
editor.ed.createElement('span'),
|
|
792
|
-
editor.ed.createElement('span'),
|
|
793
|
-
editor.ed.createElement('span')
|
|
794
|
-
];
|
|
795
|
-
|
|
796
|
-
editor.s.insertNode(spans[0]);
|
|
797
|
-
editor.s.insertNode(spans[1]);
|
|
798
|
-
editor.s.insertNode(spans[2]);
|
|
799
|
-
|
|
800
|
-
editor.s.setCursorAfter(spans[1]);
|
|
801
|
-
editor.s.insertNode(editor.ed.createElement('i'));
|
|
802
|
-
|
|
803
|
-
expect(editor.value).equals(
|
|
804
|
-
'<p><span></span><span></span><i></i><span></span></p>'
|
|
805
|
-
);
|
|
806
|
-
});
|
|
807
|
-
|
|
808
|
-
it('Set cursor in non placed element', function () {
|
|
809
|
-
const editor = getJodit();
|
|
810
|
-
|
|
811
|
-
expect(function () {
|
|
812
|
-
const div = editor.ed.createElement('div');
|
|
813
|
-
editor.s.setCursorIn(div);
|
|
814
|
-
}).to.Throw(/in editor/);
|
|
815
|
-
});
|
|
816
|
-
});
|
|
817
|
-
});
|
|
818
|
-
|
|
819
|
-
describe('Readiness', () => {
|
|
820
|
-
describe('Method waitForReady', () => {
|
|
821
|
-
describe('Sync init', () => {
|
|
822
|
-
it('Should return resolved promise', done => {
|
|
823
|
-
const jodit = getJodit();
|
|
824
|
-
|
|
825
|
-
expect(jodit.isReady).is.true;
|
|
826
|
-
|
|
827
|
-
jodit.waitForReady().then(j => {
|
|
828
|
-
expect(jodit).eq(j);
|
|
829
|
-
expect(jodit.isReady).is.true;
|
|
830
|
-
done();
|
|
831
|
-
});
|
|
832
|
-
});
|
|
833
|
-
});
|
|
834
|
-
|
|
835
|
-
describe('Async init', () => {
|
|
836
|
-
it('Should return resolved promise', done => {
|
|
837
|
-
unmockPromise();
|
|
838
|
-
const jodit = getJodit({
|
|
839
|
-
events: {
|
|
840
|
-
createEditor: () => delay(100)
|
|
841
|
-
}
|
|
842
|
-
});
|
|
843
|
-
|
|
844
|
-
expect(jodit.isReady).is.false;
|
|
845
|
-
|
|
846
|
-
jodit.waitForReady().then(j => {
|
|
847
|
-
expect(jodit).eq(j);
|
|
848
|
-
expect(jodit.isReady).is.true;
|
|
849
|
-
done();
|
|
850
|
-
});
|
|
851
|
-
});
|
|
852
|
-
});
|
|
853
|
-
});
|
|
854
|
-
});
|
|
855
|
-
});
|