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,1361 +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 Style module', function () {
|
|
7
|
-
let editor;
|
|
8
|
-
|
|
9
|
-
const Style = Jodit.ns.CommitStyle;
|
|
10
|
-
|
|
11
|
-
beforeEach(function () {
|
|
12
|
-
editor = getJodit();
|
|
13
|
-
editor.value = '<p>test</p>';
|
|
14
|
-
editor.execCommand('selectall');
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
describe('Base apply', () => {
|
|
18
|
-
[
|
|
19
|
-
[
|
|
20
|
-
'<ul><li>|1</li><li>2</li><li>3|</li></ul>',
|
|
21
|
-
{ element: 'h1' },
|
|
22
|
-
'<ul><li><h1>|1</h1></li><li><h1>2</h1></li><li><h1>3|</h1></li></ul>'
|
|
23
|
-
],
|
|
24
|
-
[
|
|
25
|
-
'<ul><li><h1>|1</h1></li><li><h1>2</h1></li><li><h1>3|</h1></li></ul>',
|
|
26
|
-
{ element: 'h1' },
|
|
27
|
-
'<ul><li>|1</li><li>2</li><li>3|</li></ul>'
|
|
28
|
-
],
|
|
29
|
-
[
|
|
30
|
-
'<p>test|<u>test</u>|test</p>',
|
|
31
|
-
{ style: { color: '#FFF000' } },
|
|
32
|
-
'<p>test|<u style="color:#FFF000">test</u>|test</p>'
|
|
33
|
-
],
|
|
34
|
-
[
|
|
35
|
-
'<p><u>|test|</u></p>',
|
|
36
|
-
{ style: { color: '#FFF000' } },
|
|
37
|
-
'<p><u style="color:#FFF000">|test|</u></p>'
|
|
38
|
-
],
|
|
39
|
-
[
|
|
40
|
-
'<p>|<u>test</u>|</p>',
|
|
41
|
-
{ style: { color: '#FFF000' } },
|
|
42
|
-
'<p>|<u style="color:#FFF000">test</u>|</p>'
|
|
43
|
-
],
|
|
44
|
-
[
|
|
45
|
-
'<p><u>|tes|t</u></p>',
|
|
46
|
-
{ style: { color: '#FFF000' } },
|
|
47
|
-
'<p><u>|<span style="color:#FFF000">tes</span>|t</u></p>'
|
|
48
|
-
],
|
|
49
|
-
[
|
|
50
|
-
'<p><strong>|test|</strong></p>',
|
|
51
|
-
{ style: { color: '#FFF000' } },
|
|
52
|
-
'<p><strong style="color:#FFF000">|test|</strong></p>'
|
|
53
|
-
],
|
|
54
|
-
[
|
|
55
|
-
'<p>|test|</p>',
|
|
56
|
-
{ element: 'strong' },
|
|
57
|
-
'<p>|<strong>test</strong>|</p>'
|
|
58
|
-
],
|
|
59
|
-
[
|
|
60
|
-
'<p>test|</p>',
|
|
61
|
-
{ element: 'strong' },
|
|
62
|
-
'<p>test<strong>|</strong></p>'
|
|
63
|
-
],
|
|
64
|
-
[
|
|
65
|
-
'<p><strong>|test|</strong></p>',
|
|
66
|
-
{ element: 'strong' },
|
|
67
|
-
'<p>|test|</p>'
|
|
68
|
-
],
|
|
69
|
-
[
|
|
70
|
-
'<p><strong>te|s|t</strong></p>',
|
|
71
|
-
{ element: 'strong' },
|
|
72
|
-
'<p><strong>te</strong>|s|<strong>t</strong></p>'
|
|
73
|
-
],
|
|
74
|
-
[
|
|
75
|
-
'<p>te|s|t</p>',
|
|
76
|
-
{
|
|
77
|
-
style: {
|
|
78
|
-
color: '#fff'
|
|
79
|
-
}
|
|
80
|
-
},
|
|
81
|
-
'<p>te|<span style="color:#FFFFFF">s</span>|t</p>'
|
|
82
|
-
],
|
|
83
|
-
[
|
|
84
|
-
'<p>te|st</p>',
|
|
85
|
-
{
|
|
86
|
-
style: {
|
|
87
|
-
color: '#fff'
|
|
88
|
-
}
|
|
89
|
-
},
|
|
90
|
-
'<p>te<span style="color:#FFFFFF">|</span>st</p>'
|
|
91
|
-
],
|
|
92
|
-
[
|
|
93
|
-
'<p>|test|</p>',
|
|
94
|
-
{
|
|
95
|
-
style: {
|
|
96
|
-
color: 'red',
|
|
97
|
-
backgroundColor: 'yellow'
|
|
98
|
-
}
|
|
99
|
-
},
|
|
100
|
-
'<p>|<span style="background-color:yellow;color:red">test</span>|</p>'
|
|
101
|
-
]
|
|
102
|
-
].forEach(([input, opt, output]) => {
|
|
103
|
-
describe(`For selection ${input} apply style ${JSON.stringify(
|
|
104
|
-
opt
|
|
105
|
-
)}`, () => {
|
|
106
|
-
it(`Should get ${output}`, function () {
|
|
107
|
-
editor.value = input;
|
|
108
|
-
setCursorToChar(editor);
|
|
109
|
-
|
|
110
|
-
const style = new Style(opt);
|
|
111
|
-
|
|
112
|
-
style.apply(editor);
|
|
113
|
-
replaceCursorToChar(editor);
|
|
114
|
-
|
|
115
|
-
expect(sortAttributes(editor.value)).equals(output);
|
|
116
|
-
});
|
|
117
|
-
});
|
|
118
|
-
});
|
|
119
|
-
});
|
|
120
|
-
|
|
121
|
-
describe('Apply style', function () {
|
|
122
|
-
describe('For STYLE element', function () {
|
|
123
|
-
it('Should not apply styles to STYLE element', function () {
|
|
124
|
-
editor.value =
|
|
125
|
-
'<p>test</p><style>.a {color: red}</style><p>stop</p>';
|
|
126
|
-
editor.execCommand('selectall');
|
|
127
|
-
|
|
128
|
-
const style = new Style({
|
|
129
|
-
style: {
|
|
130
|
-
fontFamily: 'Helvetica,sans-serif'
|
|
131
|
-
}
|
|
132
|
-
});
|
|
133
|
-
|
|
134
|
-
style.apply(editor);
|
|
135
|
-
|
|
136
|
-
expect(sortAttributes(editor.value)).equals(
|
|
137
|
-
'<p><span style="font-family:Helvetica,sans-serif">test</span></p>' +
|
|
138
|
-
'<style>.a {color: red}</style>' +
|
|
139
|
-
'<p><span style="font-family:Helvetica,sans-serif">stop</span></p>'
|
|
140
|
-
);
|
|
141
|
-
});
|
|
142
|
-
});
|
|
143
|
-
|
|
144
|
-
describe('For all content', function () {
|
|
145
|
-
it('Should apply style to all elements', function () {
|
|
146
|
-
editor.value = '<p><br></p><p>test</p>';
|
|
147
|
-
editor.execCommand('selectall');
|
|
148
|
-
|
|
149
|
-
const style = new Style({
|
|
150
|
-
style: {
|
|
151
|
-
color: 'yellow'
|
|
152
|
-
}
|
|
153
|
-
});
|
|
154
|
-
|
|
155
|
-
style.apply(editor);
|
|
156
|
-
|
|
157
|
-
expect(sortAttributes(editor.value)).equals(
|
|
158
|
-
'<p><span style="color:yellow"><br></span></p>' +
|
|
159
|
-
'<p><span style="color:yellow">test</span></p>'
|
|
160
|
-
);
|
|
161
|
-
});
|
|
162
|
-
|
|
163
|
-
describe('Select all content by edges', function () {
|
|
164
|
-
it('Should apply style to all elements', function () {
|
|
165
|
-
editor.value = '<p><br></p><p>test</p>';
|
|
166
|
-
const range = editor.s.createRange(true);
|
|
167
|
-
|
|
168
|
-
range.setStart(editor.editor.firstChild, 0);
|
|
169
|
-
range.setEnd(editor.editor.lastChild.firstChild, 4);
|
|
170
|
-
editor.s.selectRange(range);
|
|
171
|
-
|
|
172
|
-
const style = new Style({
|
|
173
|
-
style: {
|
|
174
|
-
color: 'yellow'
|
|
175
|
-
}
|
|
176
|
-
});
|
|
177
|
-
|
|
178
|
-
style.apply(editor);
|
|
179
|
-
|
|
180
|
-
expect(sortAttributes(editor.value)).equals(
|
|
181
|
-
'<p><span style="color:yellow"><br></span></p>' +
|
|
182
|
-
'<p><span style="color:yellow">test</span></p>'
|
|
183
|
-
);
|
|
184
|
-
});
|
|
185
|
-
});
|
|
186
|
-
});
|
|
187
|
-
|
|
188
|
-
describe('Two times', function () {
|
|
189
|
-
it('Should do nothing', function () {
|
|
190
|
-
const style = function () {
|
|
191
|
-
return new Style({
|
|
192
|
-
style: {
|
|
193
|
-
color: '#FF0000'
|
|
194
|
-
}
|
|
195
|
-
});
|
|
196
|
-
};
|
|
197
|
-
|
|
198
|
-
style().apply(editor);
|
|
199
|
-
|
|
200
|
-
expect(sortAttributes(editor.value)).equals(
|
|
201
|
-
'<p><span style="color:#FF0000">test</span></p>'
|
|
202
|
-
);
|
|
203
|
-
|
|
204
|
-
style().apply(editor);
|
|
205
|
-
|
|
206
|
-
expect(sortAttributes(editor.value)).equals('<p>test</p>');
|
|
207
|
-
});
|
|
208
|
-
});
|
|
209
|
-
|
|
210
|
-
describe('For collapsed selection', function () {
|
|
211
|
-
it('Should create SPAN element with this style', function () {
|
|
212
|
-
editor.s.setCursorAfter(editor.editor.firstChild.firstChild);
|
|
213
|
-
|
|
214
|
-
const style = new Style({
|
|
215
|
-
style: {
|
|
216
|
-
fontSize: 12
|
|
217
|
-
}
|
|
218
|
-
});
|
|
219
|
-
|
|
220
|
-
style.apply(editor);
|
|
221
|
-
|
|
222
|
-
editor.s.insertHTML('stop');
|
|
223
|
-
|
|
224
|
-
expect(sortAttributes(editor.value)).equals(
|
|
225
|
-
'<p>test<span style="font-size:12px">stop</span></p>'
|
|
226
|
-
);
|
|
227
|
-
});
|
|
228
|
-
|
|
229
|
-
describe('Double times', function () {
|
|
230
|
-
it('Should create new SPAN inside first', function () {
|
|
231
|
-
editor.s.setCursorAfter(
|
|
232
|
-
editor.editor.firstChild.firstChild
|
|
233
|
-
);
|
|
234
|
-
|
|
235
|
-
const style = new Style({
|
|
236
|
-
style: {
|
|
237
|
-
fontSize: 12
|
|
238
|
-
}
|
|
239
|
-
});
|
|
240
|
-
|
|
241
|
-
style.apply(editor);
|
|
242
|
-
|
|
243
|
-
editor.s.insertHTML('stop');
|
|
244
|
-
|
|
245
|
-
const style2 = new Style({
|
|
246
|
-
style: {
|
|
247
|
-
color: '#ff00ff'
|
|
248
|
-
}
|
|
249
|
-
});
|
|
250
|
-
|
|
251
|
-
style2.apply(editor);
|
|
252
|
-
|
|
253
|
-
editor.s.insertHTML('elem');
|
|
254
|
-
|
|
255
|
-
expect(sortAttributes(editor.value)).equals(
|
|
256
|
-
'<p>test<span style="font-size:12px">stop<span style="color:#FF00FF">elem</span></span></p>'
|
|
257
|
-
);
|
|
258
|
-
});
|
|
259
|
-
|
|
260
|
-
describe('With same style', function () {
|
|
261
|
-
it('Should break first SPAN', function () {
|
|
262
|
-
editor.value = '<p>test|</p>';
|
|
263
|
-
setCursorToChar(editor);
|
|
264
|
-
|
|
265
|
-
const style = new Style({
|
|
266
|
-
style: {
|
|
267
|
-
fontSize: 12
|
|
268
|
-
}
|
|
269
|
-
});
|
|
270
|
-
|
|
271
|
-
style.apply(editor);
|
|
272
|
-
|
|
273
|
-
editor.s.insertHTML('stop');
|
|
274
|
-
|
|
275
|
-
expect(sortAttributes(editor.value)).equals(
|
|
276
|
-
'<p>test<span style="font-size:12px">stop</span></p>'
|
|
277
|
-
);
|
|
278
|
-
|
|
279
|
-
style.apply(editor);
|
|
280
|
-
|
|
281
|
-
editor.s.insertHTML('elem');
|
|
282
|
-
|
|
283
|
-
replaceCursorToChar(editor);
|
|
284
|
-
|
|
285
|
-
expect(sortAttributes(editor.value)).equals(
|
|
286
|
-
'<p>test<span style="font-size:12px">stop</span>elem|</p>'
|
|
287
|
-
);
|
|
288
|
-
});
|
|
289
|
-
|
|
290
|
-
describe('Without editing', function () {
|
|
291
|
-
it('Should unwap empty SPAN', function () {
|
|
292
|
-
editor.value = '<p>test|</p>';
|
|
293
|
-
setCursorToChar(editor);
|
|
294
|
-
|
|
295
|
-
const style = new Style({
|
|
296
|
-
style: {
|
|
297
|
-
fontSize: 12
|
|
298
|
-
}
|
|
299
|
-
});
|
|
300
|
-
|
|
301
|
-
style.apply(editor);
|
|
302
|
-
style.apply(editor);
|
|
303
|
-
|
|
304
|
-
editor.s.insertHTML('elem');
|
|
305
|
-
|
|
306
|
-
expect(sortAttributes(editor.value)).equals(
|
|
307
|
-
'<p>testelem</p>'
|
|
308
|
-
);
|
|
309
|
-
});
|
|
310
|
-
});
|
|
311
|
-
});
|
|
312
|
-
|
|
313
|
-
describe('Apply different styles', function () {
|
|
314
|
-
it('Should combine all of it', function () {
|
|
315
|
-
editor.value = '<p>test|</p>';
|
|
316
|
-
setCursorToChar(editor);
|
|
317
|
-
|
|
318
|
-
const style = new Style({
|
|
319
|
-
style: {
|
|
320
|
-
backgroundColor: 'yellow'
|
|
321
|
-
}
|
|
322
|
-
});
|
|
323
|
-
|
|
324
|
-
style.apply(editor);
|
|
325
|
-
|
|
326
|
-
const style2 = new Style({
|
|
327
|
-
style: {
|
|
328
|
-
fontSize: '12px'
|
|
329
|
-
}
|
|
330
|
-
});
|
|
331
|
-
|
|
332
|
-
style2.apply(editor);
|
|
333
|
-
|
|
334
|
-
editor.s.insertHTML('stop');
|
|
335
|
-
|
|
336
|
-
expect(sortAttributes(editor.value)).equals(
|
|
337
|
-
'<p>test<span style="background-color:yellow;font-size:12px">stop</span></p>'
|
|
338
|
-
);
|
|
339
|
-
});
|
|
340
|
-
});
|
|
341
|
-
});
|
|
342
|
-
});
|
|
343
|
-
|
|
344
|
-
describe('Apply different styles', function () {
|
|
345
|
-
it('Should combine all of it', function () {
|
|
346
|
-
const style = new Style({
|
|
347
|
-
style: {
|
|
348
|
-
backgroundColor: 'yellow'
|
|
349
|
-
}
|
|
350
|
-
});
|
|
351
|
-
|
|
352
|
-
style.apply(editor);
|
|
353
|
-
|
|
354
|
-
const style2 = new Style({
|
|
355
|
-
style: {
|
|
356
|
-
fontSize: '12px'
|
|
357
|
-
}
|
|
358
|
-
});
|
|
359
|
-
|
|
360
|
-
style2.apply(editor);
|
|
361
|
-
|
|
362
|
-
expect(sortAttributes(editor.value)).equals(
|
|
363
|
-
'<p><span style="background-color:yellow;font-size:12px">test</span></p>'
|
|
364
|
-
);
|
|
365
|
-
});
|
|
366
|
-
});
|
|
367
|
-
|
|
368
|
-
describe('For text inside some SPAN', function () {
|
|
369
|
-
describe('Select SPAN', function () {
|
|
370
|
-
it('Should apply style to this SPAN', function () {
|
|
371
|
-
editor.value = '<span>test</span>';
|
|
372
|
-
editor.s.select(editor.editor.firstChild.firstChild);
|
|
373
|
-
|
|
374
|
-
const style = new Style({
|
|
375
|
-
style: {
|
|
376
|
-
fontSize: 11
|
|
377
|
-
}
|
|
378
|
-
});
|
|
379
|
-
|
|
380
|
-
style.apply(editor);
|
|
381
|
-
|
|
382
|
-
expect(sortAttributes(editor.value)).equals(
|
|
383
|
-
'<p><span style="font-size:11px">test</span></p>'
|
|
384
|
-
);
|
|
385
|
-
});
|
|
386
|
-
});
|
|
387
|
-
|
|
388
|
-
describe('Select SPAN content', function () {
|
|
389
|
-
it('Should apply style to this SPAN', function () {
|
|
390
|
-
editor.value = '<span>test</span>';
|
|
391
|
-
editor.s.select(editor.editor.firstChild.firstChild);
|
|
392
|
-
|
|
393
|
-
const style = new Style({
|
|
394
|
-
style: {
|
|
395
|
-
fontSize: 11
|
|
396
|
-
}
|
|
397
|
-
});
|
|
398
|
-
|
|
399
|
-
style.apply(editor);
|
|
400
|
-
|
|
401
|
-
expect(sortAttributes(editor.value)).equals(
|
|
402
|
-
'<p><span style="font-size:11px">test</span></p>'
|
|
403
|
-
);
|
|
404
|
-
});
|
|
405
|
-
});
|
|
406
|
-
});
|
|
407
|
-
});
|
|
408
|
-
|
|
409
|
-
describe('Apply element', function () {
|
|
410
|
-
it('Should wrap selection in element', function () {
|
|
411
|
-
const style = new Style({
|
|
412
|
-
element: 'h1'
|
|
413
|
-
});
|
|
414
|
-
|
|
415
|
-
style.apply(editor);
|
|
416
|
-
|
|
417
|
-
expect(sortAttributes(editor.value)).equals('<h1>test</h1>');
|
|
418
|
-
});
|
|
419
|
-
|
|
420
|
-
describe('Block or inline element', function () {
|
|
421
|
-
describe('Block element', function () {
|
|
422
|
-
it('Should wrap whole text for selection part', function () {
|
|
423
|
-
const range = editor.s.createRange();
|
|
424
|
-
range.setStart(editor.editor.firstChild.firstChild, 2);
|
|
425
|
-
range.setEndAfter(editor.editor.firstChild.firstChild);
|
|
426
|
-
editor.s.selectRange(range);
|
|
427
|
-
|
|
428
|
-
const style = new Style({
|
|
429
|
-
element: 'h1'
|
|
430
|
-
});
|
|
431
|
-
|
|
432
|
-
style.apply(editor);
|
|
433
|
-
|
|
434
|
-
expect(sortAttributes(editor.value)).equals(
|
|
435
|
-
'<h1>test</h1>'
|
|
436
|
-
);
|
|
437
|
-
});
|
|
438
|
-
|
|
439
|
-
describe('Selected part inside inline element', function () {
|
|
440
|
-
it('Should wrap whole text with this part', function () {
|
|
441
|
-
editor.value = 'test<strong>stop</strong>left';
|
|
442
|
-
const range = editor.s.createRange();
|
|
443
|
-
range.setStart(
|
|
444
|
-
editor.editor.querySelector('strong').firstChild,
|
|
445
|
-
2
|
|
446
|
-
);
|
|
447
|
-
range.setEnd(
|
|
448
|
-
editor.editor.querySelector('strong').firstChild,
|
|
449
|
-
3
|
|
450
|
-
);
|
|
451
|
-
editor.s.selectRange(range);
|
|
452
|
-
|
|
453
|
-
const style = new Style({
|
|
454
|
-
element: 'h1'
|
|
455
|
-
});
|
|
456
|
-
|
|
457
|
-
style.apply(editor);
|
|
458
|
-
|
|
459
|
-
expect(sortAttributes(editor.value)).equals(
|
|
460
|
-
'<h1>test<strong>stop</strong>left</h1>'
|
|
461
|
-
);
|
|
462
|
-
});
|
|
463
|
-
});
|
|
464
|
-
|
|
465
|
-
describe('In empty editor', function () {
|
|
466
|
-
it('Should insert this new block element with BR', function () {
|
|
467
|
-
editor.value = '';
|
|
468
|
-
|
|
469
|
-
const style = new Style({
|
|
470
|
-
element: 'h1'
|
|
471
|
-
});
|
|
472
|
-
|
|
473
|
-
style.apply(editor);
|
|
474
|
-
|
|
475
|
-
expect(sortAttributes(editor.value)).equals(
|
|
476
|
-
'<h1><br></h1>'
|
|
477
|
-
);
|
|
478
|
-
|
|
479
|
-
editor.s.insertHTML('test');
|
|
480
|
-
|
|
481
|
-
expect(sortAttributes(editor.value)).equals(
|
|
482
|
-
'<h1>test<br></h1>'
|
|
483
|
-
);
|
|
484
|
-
});
|
|
485
|
-
});
|
|
486
|
-
});
|
|
487
|
-
|
|
488
|
-
describe('inline element', function () {
|
|
489
|
-
it('Should wrap only selection part', function () {
|
|
490
|
-
const range = editor.s.createRange();
|
|
491
|
-
range.setStart(editor.editor.firstChild.firstChild, 2);
|
|
492
|
-
range.setEndAfter(editor.editor.firstChild.firstChild);
|
|
493
|
-
editor.s.selectRange(range);
|
|
494
|
-
|
|
495
|
-
const style = new Style({
|
|
496
|
-
element: 'strong'
|
|
497
|
-
});
|
|
498
|
-
|
|
499
|
-
style.apply(editor);
|
|
500
|
-
|
|
501
|
-
expect(sortAttributes(editor.value)).equals(
|
|
502
|
-
'<p>te<strong>st</strong></p>'
|
|
503
|
-
);
|
|
504
|
-
});
|
|
505
|
-
});
|
|
506
|
-
});
|
|
507
|
-
|
|
508
|
-
describe('For collapsed selection', function () {
|
|
509
|
-
describe('Block element', function () {
|
|
510
|
-
it('Should wrap whole text in element', function () {
|
|
511
|
-
editor.s.setCursorAfter(
|
|
512
|
-
editor.editor.firstChild.firstChild
|
|
513
|
-
);
|
|
514
|
-
|
|
515
|
-
const style = new Style({
|
|
516
|
-
element: 'h1'
|
|
517
|
-
});
|
|
518
|
-
|
|
519
|
-
style.apply(editor);
|
|
520
|
-
|
|
521
|
-
expect(sortAttributes(editor.value)).equals(
|
|
522
|
-
'<h1>test</h1>'
|
|
523
|
-
);
|
|
524
|
-
});
|
|
525
|
-
|
|
526
|
-
describe('Double time', function () {
|
|
527
|
-
it('Should unwrap element', function () {
|
|
528
|
-
editor.value = '<h1>test</h1>';
|
|
529
|
-
|
|
530
|
-
editor.s.setCursorAfter(
|
|
531
|
-
editor.editor.firstChild.firstChild
|
|
532
|
-
);
|
|
533
|
-
|
|
534
|
-
const style = new Style({
|
|
535
|
-
element: 'h1'
|
|
536
|
-
});
|
|
537
|
-
|
|
538
|
-
style.apply(editor);
|
|
539
|
-
|
|
540
|
-
expect(sortAttributes(editor.value)).equals('test');
|
|
541
|
-
});
|
|
542
|
-
});
|
|
543
|
-
|
|
544
|
-
describe('Selected Block element', function () {
|
|
545
|
-
it('Should replace this element to new style', function () {
|
|
546
|
-
editor.value = '<p>test</p>';
|
|
547
|
-
|
|
548
|
-
editor.s.setCursorAfter(
|
|
549
|
-
editor.editor.firstChild.firstChild
|
|
550
|
-
);
|
|
551
|
-
|
|
552
|
-
const style = new Style({
|
|
553
|
-
element: 'h1'
|
|
554
|
-
});
|
|
555
|
-
|
|
556
|
-
style.apply(editor);
|
|
557
|
-
|
|
558
|
-
expect(sortAttributes(editor.value)).equals(
|
|
559
|
-
'<h1>test</h1>'
|
|
560
|
-
);
|
|
561
|
-
});
|
|
562
|
-
});
|
|
563
|
-
});
|
|
564
|
-
});
|
|
565
|
-
|
|
566
|
-
describe('For suitable element', function () {
|
|
567
|
-
it('Should replace it to new element', function () {
|
|
568
|
-
editor.value = '<h2>test</h2>';
|
|
569
|
-
editor.execCommand('selectall');
|
|
570
|
-
|
|
571
|
-
const style = new Style({
|
|
572
|
-
element: 'h1'
|
|
573
|
-
});
|
|
574
|
-
|
|
575
|
-
style.apply(editor);
|
|
576
|
-
|
|
577
|
-
expect(sortAttributes(editor.value)).equals('<h1>test</h1>');
|
|
578
|
-
});
|
|
579
|
-
|
|
580
|
-
describe('With style', function () {
|
|
581
|
-
it('Should wrap contents again', function () {
|
|
582
|
-
editor.value = '<strong>test</strong>';
|
|
583
|
-
const range = editor.s.createRange();
|
|
584
|
-
|
|
585
|
-
range.setStart(
|
|
586
|
-
editor.editor.firstChild.firstChild.firstChild,
|
|
587
|
-
0
|
|
588
|
-
);
|
|
589
|
-
range.setEnd(
|
|
590
|
-
editor.editor.firstChild.firstChild.firstChild,
|
|
591
|
-
4
|
|
592
|
-
);
|
|
593
|
-
editor.s.selectRange(range);
|
|
594
|
-
|
|
595
|
-
const style = new Style({
|
|
596
|
-
element: 'em',
|
|
597
|
-
style: {
|
|
598
|
-
fontStyle: 'italic'
|
|
599
|
-
}
|
|
600
|
-
});
|
|
601
|
-
|
|
602
|
-
style.apply(editor);
|
|
603
|
-
|
|
604
|
-
expect(sortAttributes(editor.value)).equals(
|
|
605
|
-
'<p><strong><em>test</em></strong></p>'
|
|
606
|
-
);
|
|
607
|
-
});
|
|
608
|
-
|
|
609
|
-
describe('For collapsed selection', function () {
|
|
610
|
-
it('Should add several tags', function () {
|
|
611
|
-
editor.s.setCursorAfter(
|
|
612
|
-
editor.editor.firstChild.firstChild
|
|
613
|
-
);
|
|
614
|
-
|
|
615
|
-
const strong = new Style({
|
|
616
|
-
element: 'strong',
|
|
617
|
-
style: {
|
|
618
|
-
fontWeight: 700
|
|
619
|
-
}
|
|
620
|
-
});
|
|
621
|
-
|
|
622
|
-
strong.apply(editor);
|
|
623
|
-
|
|
624
|
-
editor.s.insertHTML('stop');
|
|
625
|
-
|
|
626
|
-
expect(sortAttributes(editor.value)).equals(
|
|
627
|
-
'<p>test<strong>stop</strong></p>'
|
|
628
|
-
);
|
|
629
|
-
|
|
630
|
-
const em = new Style({
|
|
631
|
-
element: 'em',
|
|
632
|
-
style: {
|
|
633
|
-
fontStyle: 'italic'
|
|
634
|
-
}
|
|
635
|
-
});
|
|
636
|
-
|
|
637
|
-
em.apply(editor);
|
|
638
|
-
|
|
639
|
-
editor.s.insertHTML('last');
|
|
640
|
-
|
|
641
|
-
expect(sortAttributes(editor.value)).equals(
|
|
642
|
-
'<p>test<strong>stop<em>last</em></strong></p>'
|
|
643
|
-
);
|
|
644
|
-
});
|
|
645
|
-
|
|
646
|
-
describe('Double times', function () {
|
|
647
|
-
it('Should create new SPAN inside first', function () {
|
|
648
|
-
editor.s.setCursorAfter(
|
|
649
|
-
editor.editor.firstChild.firstChild
|
|
650
|
-
);
|
|
651
|
-
|
|
652
|
-
const style = new Style({
|
|
653
|
-
style: {
|
|
654
|
-
fontSize: 12
|
|
655
|
-
}
|
|
656
|
-
});
|
|
657
|
-
|
|
658
|
-
style.apply(editor);
|
|
659
|
-
|
|
660
|
-
editor.s.insertHTML('stop');
|
|
661
|
-
|
|
662
|
-
const style2 = new Style({
|
|
663
|
-
style: {
|
|
664
|
-
color: '#ff00ff'
|
|
665
|
-
}
|
|
666
|
-
});
|
|
667
|
-
|
|
668
|
-
style2.apply(editor);
|
|
669
|
-
|
|
670
|
-
editor.s.insertHTML('elem');
|
|
671
|
-
|
|
672
|
-
expect(sortAttributes(editor.value)).equals(
|
|
673
|
-
'<p>test<span style="font-size:12px">stop<span style="color:#FF00FF">elem</span></span></p>'
|
|
674
|
-
);
|
|
675
|
-
});
|
|
676
|
-
|
|
677
|
-
describe('With same style', function () {
|
|
678
|
-
it('Should break first SPAN', function () {
|
|
679
|
-
editor.s.setCursorAfter(
|
|
680
|
-
editor.editor.firstChild.firstChild
|
|
681
|
-
);
|
|
682
|
-
|
|
683
|
-
const style = new Style({
|
|
684
|
-
style: {
|
|
685
|
-
fontSize: 12
|
|
686
|
-
}
|
|
687
|
-
});
|
|
688
|
-
|
|
689
|
-
style.apply(editor);
|
|
690
|
-
|
|
691
|
-
editor.s.insertHTML('stop');
|
|
692
|
-
|
|
693
|
-
style.apply(editor);
|
|
694
|
-
|
|
695
|
-
editor.s.insertHTML('elem');
|
|
696
|
-
|
|
697
|
-
expect(sortAttributes(editor.value)).equals(
|
|
698
|
-
'<p>test<span style="font-size:12px">stop</span>elem</p>'
|
|
699
|
-
);
|
|
700
|
-
});
|
|
701
|
-
});
|
|
702
|
-
});
|
|
703
|
-
});
|
|
704
|
-
});
|
|
705
|
-
|
|
706
|
-
describe('For several block elements', function () {
|
|
707
|
-
it('Should replace all these element to new', function () {
|
|
708
|
-
editor.value = '<p>test</p>\n<p>test2</p>';
|
|
709
|
-
|
|
710
|
-
const range = editor.s.createRange();
|
|
711
|
-
range.setStartBefore(editor.editor.firstChild);
|
|
712
|
-
range.setEndAfter(editor.editor.lastChild);
|
|
713
|
-
editor.s.selectRange(range);
|
|
714
|
-
|
|
715
|
-
const style = new Style({
|
|
716
|
-
element: 'h5'
|
|
717
|
-
});
|
|
718
|
-
|
|
719
|
-
style.apply(editor);
|
|
720
|
-
|
|
721
|
-
expect(sortAttributes(editor.value)).equals(
|
|
722
|
-
'<h5>test</h5>\n<h5>test2</h5>'
|
|
723
|
-
);
|
|
724
|
-
});
|
|
725
|
-
});
|
|
726
|
-
});
|
|
727
|
-
|
|
728
|
-
describe('For same element', function () {
|
|
729
|
-
it('Should unwrap selection', function () {
|
|
730
|
-
editor.value = '<h1>test</h1>';
|
|
731
|
-
editor.execCommand('selectall');
|
|
732
|
-
|
|
733
|
-
const style = new Style({
|
|
734
|
-
element: 'h1'
|
|
735
|
-
});
|
|
736
|
-
|
|
737
|
-
style.apply(editor);
|
|
738
|
-
|
|
739
|
-
expect(sortAttributes(editor.value)).equals('test');
|
|
740
|
-
});
|
|
741
|
-
});
|
|
742
|
-
|
|
743
|
-
describe('For part of same element', function () {
|
|
744
|
-
it('Should unwrap selection', function () {
|
|
745
|
-
editor.value = '<strong>test</strong> some';
|
|
746
|
-
|
|
747
|
-
const range = editor.s.createRange();
|
|
748
|
-
range.setStart(
|
|
749
|
-
editor.editor.firstChild.firstChild.firstChild,
|
|
750
|
-
2
|
|
751
|
-
);
|
|
752
|
-
range.setEnd(editor.editor.firstChild.lastChild, 3);
|
|
753
|
-
editor.s.selectRange(range);
|
|
754
|
-
|
|
755
|
-
const style = new Style({
|
|
756
|
-
element: 'strong',
|
|
757
|
-
style: {
|
|
758
|
-
fontWeight: 700
|
|
759
|
-
}
|
|
760
|
-
});
|
|
761
|
-
|
|
762
|
-
style.apply(editor);
|
|
763
|
-
|
|
764
|
-
expect(sortAttributes(editor.value)).equals(
|
|
765
|
-
'<p><strong>te</strong>st some</p>'
|
|
766
|
-
);
|
|
767
|
-
});
|
|
768
|
-
});
|
|
769
|
-
|
|
770
|
-
describe('Apply UL/OL', function () {
|
|
771
|
-
describe('UL', function () {
|
|
772
|
-
it('Should create LI inside new element', function () {
|
|
773
|
-
const style = new Style({
|
|
774
|
-
element: 'ul'
|
|
775
|
-
});
|
|
776
|
-
|
|
777
|
-
style.apply(editor);
|
|
778
|
-
|
|
779
|
-
expect(sortAttributes(editor.value)).equals(
|
|
780
|
-
'<ul><li>test</li></ul>'
|
|
781
|
-
);
|
|
782
|
-
});
|
|
783
|
-
});
|
|
784
|
-
|
|
785
|
-
describe('OL', function () {
|
|
786
|
-
it('Should create LI inside new element', function () {
|
|
787
|
-
const style = new Style({
|
|
788
|
-
element: 'ol'
|
|
789
|
-
});
|
|
790
|
-
|
|
791
|
-
style.apply(editor);
|
|
792
|
-
|
|
793
|
-
expect(sortAttributes(editor.value)).equals(
|
|
794
|
-
'<ol><li>test</li></ol>'
|
|
795
|
-
);
|
|
796
|
-
});
|
|
797
|
-
});
|
|
798
|
-
});
|
|
799
|
-
|
|
800
|
-
describe('Apply H1 inside LI', function () {
|
|
801
|
-
it('Should create H1 inside LI', function () {
|
|
802
|
-
editor.value =
|
|
803
|
-
'<ul>' +
|
|
804
|
-
'<li>1</li>' +
|
|
805
|
-
'<li>2</li>' +
|
|
806
|
-
'<li>3</li>' +
|
|
807
|
-
'</ul> test';
|
|
808
|
-
|
|
809
|
-
const range = editor.s.createRange();
|
|
810
|
-
range.setStart(
|
|
811
|
-
editor.editor.firstChild.firstChild.firstChild,
|
|
812
|
-
0
|
|
813
|
-
);
|
|
814
|
-
range.setEnd(editor.editor.firstChild.lastChild.firstChild, 1);
|
|
815
|
-
editor.s.selectRange(range);
|
|
816
|
-
|
|
817
|
-
const style = new Style({
|
|
818
|
-
element: 'h1'
|
|
819
|
-
});
|
|
820
|
-
|
|
821
|
-
style.apply(editor);
|
|
822
|
-
|
|
823
|
-
expect(editor.value).equals(
|
|
824
|
-
'<ul>' +
|
|
825
|
-
'<li><h1>1</h1></li>' +
|
|
826
|
-
'<li><h1>2</h1></li>' +
|
|
827
|
-
'<li><h1>3</h1></li>' +
|
|
828
|
-
'</ul><p> test</p>'
|
|
829
|
-
);
|
|
830
|
-
});
|
|
831
|
-
|
|
832
|
-
describe('Apply H1 for whole UL', function () {
|
|
833
|
-
it('Should create H1 inside every LI inside UL', function () {
|
|
834
|
-
editor.value =
|
|
835
|
-
'<ul>' +
|
|
836
|
-
'<li>1</li>' +
|
|
837
|
-
'<li>2</li>' +
|
|
838
|
-
'<li>3</li>' +
|
|
839
|
-
'</ul>';
|
|
840
|
-
|
|
841
|
-
const range = editor.s.createRange();
|
|
842
|
-
range.selectNodeContents(editor.editor);
|
|
843
|
-
editor.s.selectRange(range);
|
|
844
|
-
|
|
845
|
-
const style = new Style({
|
|
846
|
-
element: 'h1'
|
|
847
|
-
});
|
|
848
|
-
|
|
849
|
-
style.apply(editor);
|
|
850
|
-
|
|
851
|
-
expect(editor.value).equals(
|
|
852
|
-
'<ul>' +
|
|
853
|
-
'<li><h1>1</h1></li>' +
|
|
854
|
-
'<li><h1>2</h1></li>' +
|
|
855
|
-
'<li><h1>3</h1></li>' +
|
|
856
|
-
'</ul>'
|
|
857
|
-
);
|
|
858
|
-
});
|
|
859
|
-
|
|
860
|
-
describe('Apply H1 for whole UL with text', function () {
|
|
861
|
-
it('Should create H1 inside every LI inside UL and wrap text', function () {
|
|
862
|
-
editor.value =
|
|
863
|
-
'<ul>' +
|
|
864
|
-
'<li>1</li>' +
|
|
865
|
-
'<li>2</li>' +
|
|
866
|
-
'<li>3</li>' +
|
|
867
|
-
'</ul> test';
|
|
868
|
-
|
|
869
|
-
const range = editor.s.createRange();
|
|
870
|
-
range.selectNodeContents(editor.editor);
|
|
871
|
-
editor.s.selectRange(range);
|
|
872
|
-
|
|
873
|
-
const style = new Style({
|
|
874
|
-
element: 'h1'
|
|
875
|
-
});
|
|
876
|
-
|
|
877
|
-
style.apply(editor);
|
|
878
|
-
|
|
879
|
-
expect(editor.value).equals(
|
|
880
|
-
'<ul>' +
|
|
881
|
-
'<li><h1>1</h1></li>' +
|
|
882
|
-
'<li><h1>2</h1></li>' +
|
|
883
|
-
'<li><h1>3</h1></li>' +
|
|
884
|
-
'</ul><h1> test</h1>'
|
|
885
|
-
);
|
|
886
|
-
});
|
|
887
|
-
});
|
|
888
|
-
});
|
|
889
|
-
});
|
|
890
|
-
});
|
|
891
|
-
|
|
892
|
-
describe('Combine style or element', function () {
|
|
893
|
-
describe('For Styled element with style equaled STRONG', function () {
|
|
894
|
-
describe('Apply STRONG', function () {
|
|
895
|
-
it('Should unwrap this element', function () {
|
|
896
|
-
editor.value = '<span style="font-weight:700">test</span>';
|
|
897
|
-
editor.execCommand('selectall');
|
|
898
|
-
|
|
899
|
-
const style = new Style({
|
|
900
|
-
element: 'strong',
|
|
901
|
-
style: {
|
|
902
|
-
fontWeight: 700
|
|
903
|
-
}
|
|
904
|
-
});
|
|
905
|
-
|
|
906
|
-
style.apply(editor);
|
|
907
|
-
|
|
908
|
-
expect(sortAttributes(editor.value)).equals('<p>test</p>');
|
|
909
|
-
});
|
|
910
|
-
});
|
|
911
|
-
});
|
|
912
|
-
|
|
913
|
-
describe('For Styled element with style contains STRONG', function () {
|
|
914
|
-
describe('Apply STRONG', function () {
|
|
915
|
-
it('Should remove STRONG from element', function () {
|
|
916
|
-
editor.value =
|
|
917
|
-
'<span style="font-weight:700;font-size:24px;">test</span>';
|
|
918
|
-
editor.execCommand('selectall');
|
|
919
|
-
|
|
920
|
-
const style = new Style({
|
|
921
|
-
element: 'strong',
|
|
922
|
-
style: {
|
|
923
|
-
fontWeight: 700
|
|
924
|
-
}
|
|
925
|
-
});
|
|
926
|
-
|
|
927
|
-
style.apply(editor);
|
|
928
|
-
|
|
929
|
-
expect(sortAttributes(editor.value)).equals(
|
|
930
|
-
'<p><span style="font-size:24px">test</span></p>'
|
|
931
|
-
);
|
|
932
|
-
});
|
|
933
|
-
});
|
|
934
|
-
});
|
|
935
|
-
});
|
|
936
|
-
});
|
|
937
|
-
|
|
938
|
-
describe('Test Selection.applyStyle method', function () {
|
|
939
|
-
describe('Bold command', function () {
|
|
940
|
-
describe('For box with style="font-weight:bold"', function () {
|
|
941
|
-
it('should wrap selected text in STRONG element without questions', function () {
|
|
942
|
-
const editor = getJodit(),
|
|
943
|
-
style = document.createElement('style');
|
|
944
|
-
|
|
945
|
-
editor.value = '<p>test</p>';
|
|
946
|
-
style.innerHTML = 'p {font-weight: bold !important};';
|
|
947
|
-
document.body.appendChild(style);
|
|
948
|
-
|
|
949
|
-
const sel = editor.s.sel,
|
|
950
|
-
range = editor.s.createRange();
|
|
951
|
-
|
|
952
|
-
range.setStart(editor.editor.firstChild.firstChild, 0);
|
|
953
|
-
range.setEnd(editor.editor.firstChild.firstChild, 4);
|
|
954
|
-
sel.removeAllRanges();
|
|
955
|
-
sel.addRange(range);
|
|
956
|
-
|
|
957
|
-
editor.execCommand('bold');
|
|
958
|
-
|
|
959
|
-
style.parentNode.removeChild(style);
|
|
960
|
-
expect(editor.value).equals('<p><strong>test</strong></p>');
|
|
961
|
-
});
|
|
962
|
-
});
|
|
963
|
-
|
|
964
|
-
it('Should insert a few chars and again exec bold. Bold mode should be switch off', function () {
|
|
965
|
-
const editor = getJodit();
|
|
966
|
-
editor.value = 'test';
|
|
967
|
-
|
|
968
|
-
const range = editor.s.createRange(true);
|
|
969
|
-
|
|
970
|
-
range.selectNodeContents(editor.editor.firstChild);
|
|
971
|
-
range.collapse(false);
|
|
972
|
-
|
|
973
|
-
editor.execCommand('bold');
|
|
974
|
-
|
|
975
|
-
editor.s.insertNode(editor.createInside.text('abc'));
|
|
976
|
-
|
|
977
|
-
editor.execCommand('bold');
|
|
978
|
-
|
|
979
|
-
editor.s.insertNode(editor.createInside.text('def'));
|
|
980
|
-
|
|
981
|
-
expect(editor.value).equals('<p>test<strong>abc</strong>def</p>');
|
|
982
|
-
});
|
|
983
|
-
|
|
984
|
-
describe('for some text', function () {
|
|
985
|
-
it('should wrap this text in STRONG element', function () {
|
|
986
|
-
const editor = getJodit();
|
|
987
|
-
editor.value = 'test';
|
|
988
|
-
|
|
989
|
-
const sel = editor.s.sel,
|
|
990
|
-
range = editor.s.createRange();
|
|
991
|
-
|
|
992
|
-
range.selectNodeContents(editor.editor.firstChild);
|
|
993
|
-
sel.removeAllRanges();
|
|
994
|
-
sel.addRange(range);
|
|
995
|
-
|
|
996
|
-
editor.execCommand('bold');
|
|
997
|
-
|
|
998
|
-
expect(editor.value).equals('<p><strong>test</strong></p>');
|
|
999
|
-
});
|
|
1000
|
-
|
|
1001
|
-
describe('inside STRONG element ', function () {
|
|
1002
|
-
it('from start of this element, should unwrap this text', function () {
|
|
1003
|
-
const editor = getJodit();
|
|
1004
|
-
editor.value = '<strong>test</strong>';
|
|
1005
|
-
|
|
1006
|
-
const range = editor.s.createRange();
|
|
1007
|
-
|
|
1008
|
-
range.setStart(
|
|
1009
|
-
editor.editor.firstChild.firstChild.firstChild,
|
|
1010
|
-
0
|
|
1011
|
-
);
|
|
1012
|
-
range.setEnd(
|
|
1013
|
-
editor.editor.firstChild.firstChild.firstChild,
|
|
1014
|
-
2
|
|
1015
|
-
);
|
|
1016
|
-
|
|
1017
|
-
editor.s.selectRange(range);
|
|
1018
|
-
|
|
1019
|
-
editor.execCommand('bold');
|
|
1020
|
-
|
|
1021
|
-
expect(editor.value).equals('<p>te<strong>st</strong></p>');
|
|
1022
|
-
});
|
|
1023
|
-
|
|
1024
|
-
it('near end of this element, should unwrap this text', function () {
|
|
1025
|
-
const editor = getJodit();
|
|
1026
|
-
editor.value = '<strong>test</strong>';
|
|
1027
|
-
|
|
1028
|
-
const range = editor.s.createRange();
|
|
1029
|
-
|
|
1030
|
-
range.setStart(
|
|
1031
|
-
editor.editor.firstChild.firstChild.firstChild,
|
|
1032
|
-
2
|
|
1033
|
-
);
|
|
1034
|
-
range.setEnd(
|
|
1035
|
-
editor.editor.firstChild.firstChild.firstChild,
|
|
1036
|
-
4
|
|
1037
|
-
);
|
|
1038
|
-
|
|
1039
|
-
editor.s.selectRange(range);
|
|
1040
|
-
|
|
1041
|
-
editor.execCommand('bold');
|
|
1042
|
-
|
|
1043
|
-
expect(editor.value).equals('<p><strong>te</strong>st</p>');
|
|
1044
|
-
});
|
|
1045
|
-
|
|
1046
|
-
it('in the middle of this element, should unwrap this text', function () {
|
|
1047
|
-
const editor = getJodit();
|
|
1048
|
-
editor.value = '<strong>test</strong>';
|
|
1049
|
-
|
|
1050
|
-
const range = editor.s.createRange();
|
|
1051
|
-
|
|
1052
|
-
range.setStart(
|
|
1053
|
-
editor.editor.firstChild.firstChild.firstChild,
|
|
1054
|
-
1
|
|
1055
|
-
);
|
|
1056
|
-
range.setEnd(
|
|
1057
|
-
editor.editor.firstChild.firstChild.firstChild,
|
|
1058
|
-
3
|
|
1059
|
-
);
|
|
1060
|
-
editor.s.selectRange(range);
|
|
1061
|
-
|
|
1062
|
-
editor.execCommand('bold');
|
|
1063
|
-
|
|
1064
|
-
expect(editor.value).equals(
|
|
1065
|
-
'<p><strong>t</strong>es<strong>t</strong></p>'
|
|
1066
|
-
);
|
|
1067
|
-
});
|
|
1068
|
-
|
|
1069
|
-
it('should unwrap this part and after exec "bold" again it should create 3 STRONG elements', function () {
|
|
1070
|
-
const editor = getJodit();
|
|
1071
|
-
editor.value = '<strong>1 2 3</strong>';
|
|
1072
|
-
|
|
1073
|
-
const range = editor.s.createRange();
|
|
1074
|
-
|
|
1075
|
-
range.setStart(
|
|
1076
|
-
editor.editor.firstChild.firstChild.firstChild,
|
|
1077
|
-
1
|
|
1078
|
-
);
|
|
1079
|
-
range.setEnd(
|
|
1080
|
-
editor.editor.firstChild.firstChild.firstChild,
|
|
1081
|
-
4
|
|
1082
|
-
);
|
|
1083
|
-
editor.s.selectRange(range);
|
|
1084
|
-
|
|
1085
|
-
editor.execCommand('bold');
|
|
1086
|
-
editor.execCommand('bold');
|
|
1087
|
-
|
|
1088
|
-
expect(editor.value).equals(
|
|
1089
|
-
'<p><strong>1</strong><strong> 2 </strong><strong>3</strong></p>'
|
|
1090
|
-
);
|
|
1091
|
-
});
|
|
1092
|
-
|
|
1093
|
-
describe('For collapsed selection', function () {
|
|
1094
|
-
it('should split this element and set cursor between two parts', function () {
|
|
1095
|
-
const editor = getJodit();
|
|
1096
|
-
editor.value = '<strong>test</strong>';
|
|
1097
|
-
|
|
1098
|
-
const range = editor.s.createRange();
|
|
1099
|
-
|
|
1100
|
-
range.setStart(
|
|
1101
|
-
editor.editor.firstChild.firstChild.firstChild,
|
|
1102
|
-
2
|
|
1103
|
-
);
|
|
1104
|
-
range.collapse(true);
|
|
1105
|
-
editor.s.selectRange(range);
|
|
1106
|
-
|
|
1107
|
-
editor.execCommand('bold');
|
|
1108
|
-
editor.s.insertHTML('stop');
|
|
1109
|
-
|
|
1110
|
-
expect(editor.value).equals(
|
|
1111
|
-
'<p><strong>te</strong>stop<strong>st</strong></p>'
|
|
1112
|
-
);
|
|
1113
|
-
});
|
|
1114
|
-
});
|
|
1115
|
-
});
|
|
1116
|
-
|
|
1117
|
-
it('that contains a few STRONG elements, should unwrap all of these', function () {
|
|
1118
|
-
const editor = getJodit();
|
|
1119
|
-
editor.value =
|
|
1120
|
-
'<strong>test</strong> test <strong>test</strong>';
|
|
1121
|
-
|
|
1122
|
-
const range = editor.s.createRange();
|
|
1123
|
-
|
|
1124
|
-
range.setStart(
|
|
1125
|
-
editor.editor.firstChild.firstChild.firstChild,
|
|
1126
|
-
0
|
|
1127
|
-
);
|
|
1128
|
-
range.setEnd(editor.editor.firstChild.lastChild.firstChild, 4);
|
|
1129
|
-
editor.s.selectRange(range);
|
|
1130
|
-
|
|
1131
|
-
editor.execCommand('bold');
|
|
1132
|
-
|
|
1133
|
-
expect(editor.value).equals('<p>test test test</p>');
|
|
1134
|
-
});
|
|
1135
|
-
});
|
|
1136
|
-
|
|
1137
|
-
describe('Try exec the command "bold"', function () {
|
|
1138
|
-
it('Should wrap selected text in STRONG element', function () {
|
|
1139
|
-
const editor = getJodit();
|
|
1140
|
-
editor.value = '<p>test</p>';
|
|
1141
|
-
|
|
1142
|
-
const sel = editor.s.sel,
|
|
1143
|
-
range = editor.s.createRange();
|
|
1144
|
-
|
|
1145
|
-
range.selectNodeContents(editor.editor.firstChild);
|
|
1146
|
-
sel.removeAllRanges();
|
|
1147
|
-
sel.addRange(range);
|
|
1148
|
-
|
|
1149
|
-
editor.execCommand('bold');
|
|
1150
|
-
|
|
1151
|
-
expect(editor.value).equals('<p><strong>test</strong></p>');
|
|
1152
|
-
});
|
|
1153
|
-
describe('Try exec the command "bold" twice', function () {
|
|
1154
|
-
it('Should unwrap strong elements', function () {
|
|
1155
|
-
const editor = getJodit();
|
|
1156
|
-
editor.value = '<p>test</p>';
|
|
1157
|
-
|
|
1158
|
-
const sel = editor.s.sel,
|
|
1159
|
-
range = editor.s.createRange();
|
|
1160
|
-
|
|
1161
|
-
range.selectNodeContents(editor.editor.firstChild);
|
|
1162
|
-
sel.removeAllRanges();
|
|
1163
|
-
sel.addRange(range);
|
|
1164
|
-
|
|
1165
|
-
editor.execCommand('bold');
|
|
1166
|
-
editor.execCommand('bold');
|
|
1167
|
-
|
|
1168
|
-
expect(editor.value).equals('<p>test</p>');
|
|
1169
|
-
});
|
|
1170
|
-
});
|
|
1171
|
-
});
|
|
1172
|
-
|
|
1173
|
-
describe('Try exec the command "bold" for font-weight: 700 Element', function () {
|
|
1174
|
-
it('should ubnwrap selected srtong element', function () {
|
|
1175
|
-
const editor = getJodit();
|
|
1176
|
-
editor.value = '<span style="font-weight: 700">test</span>';
|
|
1177
|
-
|
|
1178
|
-
const range = editor.s.createRange();
|
|
1179
|
-
|
|
1180
|
-
range.selectNodeContents(editor.editor.firstChild);
|
|
1181
|
-
editor.s.selectRange(range);
|
|
1182
|
-
|
|
1183
|
-
editor.execCommand('bold');
|
|
1184
|
-
|
|
1185
|
-
expect(editor.value).equals('<p>test</p>');
|
|
1186
|
-
});
|
|
1187
|
-
});
|
|
1188
|
-
|
|
1189
|
-
describe('Exec bold for collapsed range and move cursor in another place', function () {
|
|
1190
|
-
it('Should remove STRONG element', function () {
|
|
1191
|
-
const editor = getJodit({
|
|
1192
|
-
cleanHTML: {
|
|
1193
|
-
timeout: 0
|
|
1194
|
-
}
|
|
1195
|
-
});
|
|
1196
|
-
|
|
1197
|
-
editor.value = 'testtest';
|
|
1198
|
-
|
|
1199
|
-
const range = editor.s.createRange();
|
|
1200
|
-
range.setStart(editor.editor.firstChild.firstChild, 4);
|
|
1201
|
-
range.collapse(true);
|
|
1202
|
-
editor.s.selectRange(range);
|
|
1203
|
-
|
|
1204
|
-
editor.execCommand('bold');
|
|
1205
|
-
expect(editor.value).equals('<p>test<strong></strong>test</p>');
|
|
1206
|
-
|
|
1207
|
-
range.setStart(editor.editor.firstChild.lastChild, 2);
|
|
1208
|
-
range.collapse(true);
|
|
1209
|
-
editor.s.selectRange(range);
|
|
1210
|
-
simulateEvent('mousedown', 0, editor.editor);
|
|
1211
|
-
|
|
1212
|
-
expect(editor.value).equals('<p>testtest</p>');
|
|
1213
|
-
});
|
|
1214
|
-
});
|
|
1215
|
-
|
|
1216
|
-
describe('Exec bold command for SPAN with font-size', function () {
|
|
1217
|
-
it('Should leave both font-size and font-weight rules', function () {
|
|
1218
|
-
const editor = getJodit();
|
|
1219
|
-
editor.value = '<span style="font-size: 36px;">asdasd</span>';
|
|
1220
|
-
|
|
1221
|
-
const range = editor.s.createRange();
|
|
1222
|
-
|
|
1223
|
-
range.setStart(
|
|
1224
|
-
editor.editor.firstChild.firstChild.firstChild,
|
|
1225
|
-
0
|
|
1226
|
-
);
|
|
1227
|
-
range.setEnd(editor.editor.firstChild.firstChild.firstChild, 6);
|
|
1228
|
-
|
|
1229
|
-
editor.s.selectRange(range);
|
|
1230
|
-
|
|
1231
|
-
editor.execCommand('bold');
|
|
1232
|
-
|
|
1233
|
-
expect(sortAttributes(editor.value)).equals(
|
|
1234
|
-
sortAttributes(
|
|
1235
|
-
'<p><span style="font-size: 36px;"><strong>asdasd</strong></span></p>'
|
|
1236
|
-
)
|
|
1237
|
-
);
|
|
1238
|
-
});
|
|
1239
|
-
});
|
|
1240
|
-
});
|
|
1241
|
-
|
|
1242
|
-
describe('Fonts', function () {
|
|
1243
|
-
describe('Set font size', function () {
|
|
1244
|
-
it('should create attribute style="font-size:value"', function () {
|
|
1245
|
-
const editor = getJodit();
|
|
1246
|
-
editor.value = '<p> testy oprst <span>lets go</span></p>';
|
|
1247
|
-
|
|
1248
|
-
const sel = editor.s.sel,
|
|
1249
|
-
range = editor.s.createRange();
|
|
1250
|
-
|
|
1251
|
-
range.selectNode(editor.editor.querySelector('span'));
|
|
1252
|
-
|
|
1253
|
-
sel.removeAllRanges();
|
|
1254
|
-
sel.addRange(range);
|
|
1255
|
-
|
|
1256
|
-
editor.execCommand('fontSize', false, 12);
|
|
1257
|
-
|
|
1258
|
-
expect(editor.value).equals(
|
|
1259
|
-
'<p> testy oprst <span style="font-size: 12px;">lets go</span></p>'
|
|
1260
|
-
);
|
|
1261
|
-
|
|
1262
|
-
editor.execCommand('fontSize', false, '12%');
|
|
1263
|
-
expect(editor.value).equals(
|
|
1264
|
-
'<p> testy oprst <span style="font-size: 12%;">lets go</span></p>'
|
|
1265
|
-
);
|
|
1266
|
-
});
|
|
1267
|
-
|
|
1268
|
-
describe('For box with style="font-size:12px"', function () {
|
|
1269
|
-
it('should wrap selected text in SPAN with style="font-size:12px" element without questions', function () {
|
|
1270
|
-
const editor = getJodit();
|
|
1271
|
-
editor.value = 'test';
|
|
1272
|
-
|
|
1273
|
-
const sel = editor.s.sel,
|
|
1274
|
-
range = editor.s.createRange();
|
|
1275
|
-
|
|
1276
|
-
range.selectNodeContents(
|
|
1277
|
-
editor.editor.firstChild.firstChild
|
|
1278
|
-
);
|
|
1279
|
-
sel.removeAllRanges();
|
|
1280
|
-
sel.addRange(range);
|
|
1281
|
-
|
|
1282
|
-
editor.editor.style.fontSize = '12px';
|
|
1283
|
-
|
|
1284
|
-
editor.execCommand('fontSize', false, 12);
|
|
1285
|
-
|
|
1286
|
-
expect(editor.value).equals(
|
|
1287
|
-
'<p><span style="font-size: 12px;">test</span></p>'
|
|
1288
|
-
);
|
|
1289
|
-
});
|
|
1290
|
-
});
|
|
1291
|
-
});
|
|
1292
|
-
|
|
1293
|
-
describe('Set font family', function () {
|
|
1294
|
-
describe('For box with style="font-name:Arial"', function () {
|
|
1295
|
-
it('should wrap selected text in SPAN with style="font-family:Arial" element without questions', function () {
|
|
1296
|
-
const editor = getJodit();
|
|
1297
|
-
editor.value = '<p>test</p>';
|
|
1298
|
-
|
|
1299
|
-
const sel = editor.s.sel,
|
|
1300
|
-
range = editor.s.createRange();
|
|
1301
|
-
|
|
1302
|
-
range.setStart(editor.editor.firstChild.firstChild, 2);
|
|
1303
|
-
range.setEnd(editor.editor.firstChild.firstChild, 4);
|
|
1304
|
-
|
|
1305
|
-
sel.removeAllRanges();
|
|
1306
|
-
sel.addRange(range);
|
|
1307
|
-
|
|
1308
|
-
editor.editor.style.fontFamily = 'Arial';
|
|
1309
|
-
|
|
1310
|
-
editor.execCommand('fontName', false, 'Arial');
|
|
1311
|
-
|
|
1312
|
-
expect(editor.value).equals(
|
|
1313
|
-
'<p>te<span style="font-family: Arial;">st</span></p>'
|
|
1314
|
-
);
|
|
1315
|
-
});
|
|
1316
|
-
});
|
|
1317
|
-
it('should create attribute style="font-family:value"', function () {
|
|
1318
|
-
const editor = getJodit();
|
|
1319
|
-
editor.value = '<p>test</p>';
|
|
1320
|
-
|
|
1321
|
-
const sel = editor.s.sel,
|
|
1322
|
-
range = editor.s.createRange();
|
|
1323
|
-
|
|
1324
|
-
range.setStart(editor.editor.firstChild.firstChild, 2);
|
|
1325
|
-
range.setEnd(editor.editor.firstChild.firstChild, 4);
|
|
1326
|
-
|
|
1327
|
-
sel.removeAllRanges();
|
|
1328
|
-
sel.addRange(range);
|
|
1329
|
-
|
|
1330
|
-
editor.execCommand('fontName', false, 'Arial');
|
|
1331
|
-
|
|
1332
|
-
expect(editor.value).equals(
|
|
1333
|
-
'<p>te<span style="font-family: Arial;">st</span></p>'
|
|
1334
|
-
);
|
|
1335
|
-
});
|
|
1336
|
-
});
|
|
1337
|
-
|
|
1338
|
-
describe('Set font size and family', function () {
|
|
1339
|
-
it('should create attribute style="font-family:value;font-size:value"', function () {
|
|
1340
|
-
const editor = getJodit();
|
|
1341
|
-
editor.value = '<p>test</p>';
|
|
1342
|
-
|
|
1343
|
-
const sel = editor.s.sel,
|
|
1344
|
-
range = editor.s.createRange();
|
|
1345
|
-
|
|
1346
|
-
range.setStart(editor.editor.firstChild.firstChild, 2);
|
|
1347
|
-
range.setEnd(editor.editor.firstChild.firstChild, 4);
|
|
1348
|
-
|
|
1349
|
-
sel.removeAllRanges();
|
|
1350
|
-
sel.addRange(range);
|
|
1351
|
-
|
|
1352
|
-
editor.execCommand('fontName', false, 'Arial');
|
|
1353
|
-
editor.execCommand('fontSize', false, 12);
|
|
1354
|
-
|
|
1355
|
-
expect(sortAttributes(editor.value)).equals(
|
|
1356
|
-
'<p>te<span style="font-family:Arial;font-size:12px">st</span></p>'
|
|
1357
|
-
);
|
|
1358
|
-
});
|
|
1359
|
-
});
|
|
1360
|
-
});
|
|
1361
|
-
});
|