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,1988 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* Jodit Editor (https://xdsoft.net/jodit/)
|
|
3
|
-
* Released under MIT see LICENSE.txt in the project root for license information.
|
|
4
|
-
* Copyright (c) 2013-2021 Valeriy Chupurnov. All rights reserved. https://xdsoft.net
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
describe('Tables Jodit Editor Tests', function () {
|
|
8
|
-
describe('Methods', function () {
|
|
9
|
-
it('After init container must has one element .jodit-table-resizer', function () {
|
|
10
|
-
const editor = getJodit();
|
|
11
|
-
expect(editor.editor.querySelector('.jodit-table-resizer')).equals(
|
|
12
|
-
null
|
|
13
|
-
);
|
|
14
|
-
|
|
15
|
-
const table1 = editor.createInside.fromHTML(
|
|
16
|
-
'<table><tr><td>1</td></tr></table>'
|
|
17
|
-
);
|
|
18
|
-
editor.s.insertNode(table1);
|
|
19
|
-
simulateEvent(
|
|
20
|
-
'mousemove',
|
|
21
|
-
0,
|
|
22
|
-
table1.querySelector('td'),
|
|
23
|
-
function (opt) {
|
|
24
|
-
opt.offsetX = 3;
|
|
25
|
-
}
|
|
26
|
-
);
|
|
27
|
-
|
|
28
|
-
const table2 = editor.createInside.fromHTML(
|
|
29
|
-
'<table><tr><td>2</td></tr></table>'
|
|
30
|
-
);
|
|
31
|
-
editor.s.insertNode(table2);
|
|
32
|
-
simulateEvent(
|
|
33
|
-
'mousemove',
|
|
34
|
-
0,
|
|
35
|
-
table2.querySelector('td'),
|
|
36
|
-
function (opt) {
|
|
37
|
-
opt.offsetX = 3;
|
|
38
|
-
}
|
|
39
|
-
);
|
|
40
|
-
|
|
41
|
-
expect(
|
|
42
|
-
editor.container.querySelectorAll('.jodit-table-resizer').length
|
|
43
|
-
).equals(1);
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
it('Process wrong table', function () {
|
|
47
|
-
const editor = getJodit();
|
|
48
|
-
editor.value =
|
|
49
|
-
'<table>' +
|
|
50
|
-
'<tr>' +
|
|
51
|
-
'<td>1</td>' +
|
|
52
|
-
'<td>2</td>' +
|
|
53
|
-
'<td rowspan="2">3</td>' +
|
|
54
|
-
'</tr>' +
|
|
55
|
-
'<tr><td>4</td></tr>' +
|
|
56
|
-
'</table>';
|
|
57
|
-
|
|
58
|
-
selectCells(editor, [0, 1]);
|
|
59
|
-
|
|
60
|
-
Jodit.modules.Table.mergeSelected(editor.editor.firstChild, editor);
|
|
61
|
-
|
|
62
|
-
simulateEvent(
|
|
63
|
-
'mousemove',
|
|
64
|
-
0,
|
|
65
|
-
editor.editor.querySelector('td'),
|
|
66
|
-
function (opt) {
|
|
67
|
-
opt.offsetX = 3;
|
|
68
|
-
}
|
|
69
|
-
);
|
|
70
|
-
|
|
71
|
-
expect(
|
|
72
|
-
editor.container.querySelectorAll('.jodit-table-resizer').length
|
|
73
|
-
).equals(1);
|
|
74
|
-
});
|
|
75
|
-
|
|
76
|
-
it('Method getRowsCount should return TR count', function () {
|
|
77
|
-
const editor = getJodit();
|
|
78
|
-
|
|
79
|
-
editor.value =
|
|
80
|
-
'<table>' +
|
|
81
|
-
[1, 2, 3, 4]
|
|
82
|
-
.map(function () {
|
|
83
|
-
return '<tr>' + '<td>1</td>' + '<td>2</td>' + '</tr>';
|
|
84
|
-
})
|
|
85
|
-
.join('') +
|
|
86
|
-
'</table>';
|
|
87
|
-
|
|
88
|
-
// const table = new Jodit.modules.Table(editor);
|
|
89
|
-
expect(
|
|
90
|
-
Jodit.modules.Table.getRowsCount(editor.editor.firstChild)
|
|
91
|
-
).equals(4);
|
|
92
|
-
});
|
|
93
|
-
|
|
94
|
-
it('Method getColumnsCount should return maximum of TH or TD in one row in table', function () {
|
|
95
|
-
const editor = getJodit();
|
|
96
|
-
|
|
97
|
-
editor.value =
|
|
98
|
-
'<table>' +
|
|
99
|
-
'<tr><td>1</td><td>2</td><td>3</td></tr>' +
|
|
100
|
-
'<tr><td>1</td><td>2</td><td>3</td></tr>' +
|
|
101
|
-
'<tr><td colspan="2">12</td><td>3</td></tr>' +
|
|
102
|
-
'<tr><td colspan="3">123</td></tr>' +
|
|
103
|
-
'<tr><td colspan="3">123</td><td>4</td></tr>' + // 4 cells - wrong table but will suit
|
|
104
|
-
'</table>';
|
|
105
|
-
|
|
106
|
-
expect(
|
|
107
|
-
Jodit.modules.Table.getColumnsCount(editor.editor.firstChild)
|
|
108
|
-
).equals(4);
|
|
109
|
-
});
|
|
110
|
-
|
|
111
|
-
describe('appendRow', function () {
|
|
112
|
-
it('should append one row in the end of table', function () {
|
|
113
|
-
const editor = getJodit();
|
|
114
|
-
|
|
115
|
-
editor.value =
|
|
116
|
-
'<table>' +
|
|
117
|
-
'<tr><td>1</td><td>2</td><td>3</td></tr>' +
|
|
118
|
-
'</table>';
|
|
119
|
-
|
|
120
|
-
Jodit.modules.Table.appendRow(
|
|
121
|
-
editor.editor.firstChild,
|
|
122
|
-
false,
|
|
123
|
-
true,
|
|
124
|
-
editor.createInside
|
|
125
|
-
);
|
|
126
|
-
|
|
127
|
-
expect(editor.value).equals(
|
|
128
|
-
'<table><tbody><tr><td>1</td><td>2</td><td>3</td></tr><tr><td></td><td></td><td></td></tr></tbody></table>'
|
|
129
|
-
);
|
|
130
|
-
});
|
|
131
|
-
|
|
132
|
-
describe('with second argument', function () {
|
|
133
|
-
it('should append one row after row', function () {
|
|
134
|
-
const editor = getJodit();
|
|
135
|
-
|
|
136
|
-
editor.value =
|
|
137
|
-
'<table>' +
|
|
138
|
-
'<tr><td>1</td><td>2</td><td>3</td></tr>' +
|
|
139
|
-
'<tr><td>2</td><td>3</td><td>4</td></tr>' +
|
|
140
|
-
'</table>';
|
|
141
|
-
|
|
142
|
-
Jodit.modules.Table.appendRow(
|
|
143
|
-
editor.editor.firstChild,
|
|
144
|
-
editor.editor.firstChild.querySelector('tr'),
|
|
145
|
-
true,
|
|
146
|
-
editor.createInside
|
|
147
|
-
);
|
|
148
|
-
|
|
149
|
-
expect(editor.value).equals(
|
|
150
|
-
'<table><tbody>' +
|
|
151
|
-
'<tr><td>1</td><td>2</td><td>3</td></tr>' +
|
|
152
|
-
'<tr><td></td><td></td><td></td></tr>' +
|
|
153
|
-
'<tr><td>2</td><td>3</td><td>4</td></tr>' +
|
|
154
|
-
'</tbody></table>'
|
|
155
|
-
);
|
|
156
|
-
});
|
|
157
|
-
|
|
158
|
-
describe('Set rowspan', function () {
|
|
159
|
-
it('should append one row after row and recalculate all rowspan', function () {
|
|
160
|
-
const editor = getJodit();
|
|
161
|
-
|
|
162
|
-
editor.value =
|
|
163
|
-
'<table>' +
|
|
164
|
-
'<tr><td rowspan="2">1</td><td>2</td><td>3</td></tr>' +
|
|
165
|
-
'<tr><td>3</td><td>4</td></tr>' +
|
|
166
|
-
'</table>';
|
|
167
|
-
|
|
168
|
-
Jodit.modules.Table.appendRow(
|
|
169
|
-
editor.editor.firstChild,
|
|
170
|
-
editor.editor.firstChild.querySelector('tr'),
|
|
171
|
-
true,
|
|
172
|
-
editor.createInside
|
|
173
|
-
);
|
|
174
|
-
|
|
175
|
-
expect(editor.value).equals(
|
|
176
|
-
'<table><tbody>' +
|
|
177
|
-
'<tr><td>1</td><td>2</td><td>3</td></tr>' +
|
|
178
|
-
'<tr><td rowspan="2"></td><td></td><td></td></tr>' +
|
|
179
|
-
'<tr><td>3</td><td>4</td></tr>' +
|
|
180
|
-
'</tbody></table>'
|
|
181
|
-
);
|
|
182
|
-
});
|
|
183
|
-
});
|
|
184
|
-
|
|
185
|
-
describe('with styled row', function () {
|
|
186
|
-
it('should append one row after this row and copy matching styles', function () {
|
|
187
|
-
const editor = getJodit();
|
|
188
|
-
|
|
189
|
-
editor.value =
|
|
190
|
-
'<table>' +
|
|
191
|
-
'<tr><td style="color: red">1</td><td class="blue">2</td><td>3</td></tr>' +
|
|
192
|
-
'<tr><td>2</td><td>3</td><td>4</td></tr>' +
|
|
193
|
-
'</table>';
|
|
194
|
-
|
|
195
|
-
Jodit.modules.Table.appendRow(
|
|
196
|
-
editor.editor.firstChild,
|
|
197
|
-
editor.editor.firstChild.querySelector('tr'),
|
|
198
|
-
true,
|
|
199
|
-
editor.createInside
|
|
200
|
-
);
|
|
201
|
-
|
|
202
|
-
expect(sortAttributes(editor.value)).equals(
|
|
203
|
-
'<table><tbody>' +
|
|
204
|
-
'<tr><td style="color:red">1</td><td class="blue">2</td><td>3</td></tr>' +
|
|
205
|
-
'<tr><td style="color:red"></td><td class="blue"></td><td></td></tr>' +
|
|
206
|
-
'<tr><td>2</td><td>3</td><td>4</td></tr></tbody></table>'
|
|
207
|
-
);
|
|
208
|
-
});
|
|
209
|
-
});
|
|
210
|
-
});
|
|
211
|
-
|
|
212
|
-
describe('with second=TR and third=false arguments ', function () {
|
|
213
|
-
it('should append and one row before row', function () {
|
|
214
|
-
const editor = getJodit();
|
|
215
|
-
|
|
216
|
-
editor.value =
|
|
217
|
-
'<table>' +
|
|
218
|
-
'<tr><td>1</td><td>2</td><td>3</td></tr>' +
|
|
219
|
-
'<tr><td>2</td><td>3</td><td>4</td></tr>' +
|
|
220
|
-
'</table>';
|
|
221
|
-
|
|
222
|
-
Jodit.modules.Table.appendRow(
|
|
223
|
-
editor.editor.firstChild,
|
|
224
|
-
editor.editor.firstChild.querySelector('tr'),
|
|
225
|
-
false,
|
|
226
|
-
editor.createInside
|
|
227
|
-
);
|
|
228
|
-
|
|
229
|
-
expect(editor.value).equals(
|
|
230
|
-
'<table><tbody><tr><td></td><td></td><td></td></tr><tr><td>1</td><td>2</td><td>3</td></tr><tr><td>2</td><td>3</td><td>4</td></tr></tbody></table>'
|
|
231
|
-
);
|
|
232
|
-
});
|
|
233
|
-
});
|
|
234
|
-
});
|
|
235
|
-
|
|
236
|
-
it('Method appendColumn should append column in the end', function () {
|
|
237
|
-
const editor = getJodit();
|
|
238
|
-
|
|
239
|
-
editor.value =
|
|
240
|
-
'<table>' +
|
|
241
|
-
'<tr><td>1</td><td>2</td></tr>' +
|
|
242
|
-
'<tr><td colspan="2">3</td></tr>' +
|
|
243
|
-
'</table>';
|
|
244
|
-
|
|
245
|
-
Jodit.modules.Table.appendColumn(
|
|
246
|
-
editor.editor.firstChild,
|
|
247
|
-
-1,
|
|
248
|
-
true,
|
|
249
|
-
editor.createInside
|
|
250
|
-
);
|
|
251
|
-
|
|
252
|
-
expect(editor.value.toLowerCase()).equals(
|
|
253
|
-
'<table>' +
|
|
254
|
-
'<tbody>' +
|
|
255
|
-
'<tr><td>1</td><td>2</td><td></td></tr>' +
|
|
256
|
-
'<tr><td colspan="2">3</td><td></td></tr>' +
|
|
257
|
-
'</tbody>' +
|
|
258
|
-
'</table>'
|
|
259
|
-
);
|
|
260
|
-
});
|
|
261
|
-
|
|
262
|
-
it('Method appendColumn with second argument should append column after that column', function () {
|
|
263
|
-
const editor = getJodit();
|
|
264
|
-
|
|
265
|
-
editor.value =
|
|
266
|
-
'<table>' +
|
|
267
|
-
'<tr><td>1</td><td>2</td></tr>' +
|
|
268
|
-
'<tr><td colspan="2">3</td></tr>' +
|
|
269
|
-
'</table>';
|
|
270
|
-
|
|
271
|
-
Jodit.modules.Table.appendColumn(
|
|
272
|
-
editor.editor.firstChild,
|
|
273
|
-
0,
|
|
274
|
-
true,
|
|
275
|
-
editor.createInside
|
|
276
|
-
);
|
|
277
|
-
|
|
278
|
-
expect(editor.value.toLowerCase()).equals(
|
|
279
|
-
'<table>' +
|
|
280
|
-
'<tbody>' +
|
|
281
|
-
'<tr><td>1</td><td></td><td>2</td></tr>' +
|
|
282
|
-
'<tr><td colspan="3">3</td></tr>' +
|
|
283
|
-
'</tbody>' +
|
|
284
|
-
'</table>'
|
|
285
|
-
);
|
|
286
|
-
});
|
|
287
|
-
|
|
288
|
-
it('Method appendColumn with second argument and third = false should append column before that column', function () {
|
|
289
|
-
const editor = getJodit();
|
|
290
|
-
|
|
291
|
-
editor.value =
|
|
292
|
-
'<table>' +
|
|
293
|
-
'<tr><td>1</td><td>2</td></tr>' +
|
|
294
|
-
'<tr><td colspan="2">3</td></tr>' +
|
|
295
|
-
'</table>';
|
|
296
|
-
|
|
297
|
-
Jodit.modules.Table.appendColumn(
|
|
298
|
-
editor.editor.firstChild,
|
|
299
|
-
1,
|
|
300
|
-
false,
|
|
301
|
-
editor.createInside
|
|
302
|
-
);
|
|
303
|
-
|
|
304
|
-
expect(editor.value.toLowerCase()).equals(
|
|
305
|
-
'<table>' +
|
|
306
|
-
'<tbody>' +
|
|
307
|
-
'<tr><td>1</td><td></td><td>2</td></tr>' +
|
|
308
|
-
'<tr><td colspan="3">3</td></tr>' +
|
|
309
|
-
'</tbody>' +
|
|
310
|
-
'</table>'
|
|
311
|
-
);
|
|
312
|
-
});
|
|
313
|
-
|
|
314
|
-
it('Remove row should delete TR from table', function () {
|
|
315
|
-
const editor = getJodit();
|
|
316
|
-
|
|
317
|
-
editor.value =
|
|
318
|
-
'<table>' +
|
|
319
|
-
'<tr><td>1</td><td>2</td><td>3</td></tr>' +
|
|
320
|
-
'<tr><td rowspan="2">4</td><td>5</td><td>6</td></tr>' +
|
|
321
|
-
'<tr><td>7</td><td>8</td></tr>' +
|
|
322
|
-
'</table>';
|
|
323
|
-
|
|
324
|
-
simulateEvent(
|
|
325
|
-
'mousedown',
|
|
326
|
-
Jodit.KEY_TAB,
|
|
327
|
-
editor.editor.querySelectorAll('td')[4]
|
|
328
|
-
);
|
|
329
|
-
|
|
330
|
-
Jodit.modules.Table.removeRow(editor.editor.firstChild, 1);
|
|
331
|
-
|
|
332
|
-
expect(editor.value.toLowerCase()).equals(
|
|
333
|
-
'<table>' +
|
|
334
|
-
'<tbody>' +
|
|
335
|
-
'<tr><td>1</td><td>2</td><td>3</td></tr>' +
|
|
336
|
-
'<tr><td>4</td><td>7</td><td>8</td></tr>' +
|
|
337
|
-
'</tbody>' +
|
|
338
|
-
'</table>'
|
|
339
|
-
);
|
|
340
|
-
});
|
|
341
|
-
|
|
342
|
-
describe('Method merge selected cells', function () {
|
|
343
|
-
it('Simple should merge all selected cells into one ', function () {
|
|
344
|
-
const editor = getJodit();
|
|
345
|
-
|
|
346
|
-
editor.value =
|
|
347
|
-
'<table>' +
|
|
348
|
-
'<tr><td>1</td><td>2</td></tr>' +
|
|
349
|
-
'<tr><td>3</td><td>4</td></tr>' +
|
|
350
|
-
'<tr><td>5</td><td>6</td></tr>' +
|
|
351
|
-
'</table>';
|
|
352
|
-
|
|
353
|
-
selectCells(editor, [0, 1, 2, 3]);
|
|
354
|
-
// const table = new Jodit.modules.Table(editor);
|
|
355
|
-
Jodit.modules.Table.mergeSelected(
|
|
356
|
-
editor.editor.firstChild,
|
|
357
|
-
editor
|
|
358
|
-
);
|
|
359
|
-
|
|
360
|
-
expect(sortAttributes(editor.editor.innerHTML)).equals(
|
|
361
|
-
'<table>' +
|
|
362
|
-
'<tbody>' +
|
|
363
|
-
'<tr>' +
|
|
364
|
-
'<td colspan="2">1<br>2<br>3<br>4</td>' +
|
|
365
|
-
'</tr>' +
|
|
366
|
-
'<tr>' +
|
|
367
|
-
'<td>5</td>' +
|
|
368
|
-
'<td>6</td>' +
|
|
369
|
-
'</tr>' +
|
|
370
|
-
'</tbody>' +
|
|
371
|
-
'</table>'
|
|
372
|
-
);
|
|
373
|
-
|
|
374
|
-
expect(
|
|
375
|
-
editor.getInstance('Table', editor.o).selected.size
|
|
376
|
-
).equals(1);
|
|
377
|
-
});
|
|
378
|
-
|
|
379
|
-
it('With colspan and rowspan into one ', function () {
|
|
380
|
-
const editor = getJodit();
|
|
381
|
-
|
|
382
|
-
editor.value =
|
|
383
|
-
'<table>' +
|
|
384
|
-
'<tr><td colspan="2">1</td></tr>' +
|
|
385
|
-
'<tr><td>3</td><td>4</td></tr>' +
|
|
386
|
-
'<tr><td rowspan="2">5</td><td>6</td></tr>' +
|
|
387
|
-
'<tr><td>7</td></tr>' +
|
|
388
|
-
'<tr><td>8</td><td>9</td></tr>' +
|
|
389
|
-
'</table>';
|
|
390
|
-
|
|
391
|
-
selectCells(editor, [0, 1, 2, 3, 4, 5]);
|
|
392
|
-
Jodit.modules.Table.mergeSelected(
|
|
393
|
-
editor.editor.firstChild,
|
|
394
|
-
editor
|
|
395
|
-
);
|
|
396
|
-
|
|
397
|
-
expect(sortAttributes(editor.value)).equals(
|
|
398
|
-
'<table>' +
|
|
399
|
-
'<tbody>' +
|
|
400
|
-
'<tr>' +
|
|
401
|
-
'<td colspan="2">' +
|
|
402
|
-
'1<br>3<br>4<br>5<br>6<br>7' +
|
|
403
|
-
'</td>' +
|
|
404
|
-
'</tr>' +
|
|
405
|
-
'<tr>' +
|
|
406
|
-
'<td>8</td>' +
|
|
407
|
-
'<td>9</td>' +
|
|
408
|
-
'</tr>' +
|
|
409
|
-
'</tbody>' +
|
|
410
|
-
'</table>'
|
|
411
|
-
);
|
|
412
|
-
|
|
413
|
-
expect(
|
|
414
|
-
editor.getInstance('Table', editor.o).selected.size
|
|
415
|
-
).equals(1);
|
|
416
|
-
});
|
|
417
|
-
|
|
418
|
-
it('A few cells with colspan and rowspan', function () {
|
|
419
|
-
const editor = getJodit();
|
|
420
|
-
|
|
421
|
-
editor.value =
|
|
422
|
-
'<table style="width: 100%;">' +
|
|
423
|
-
'<tbody>' +
|
|
424
|
-
'<tr><td colspan="3">0,0<br>0,1<br>0,2<br></td><td>0,3</td></tr>' +
|
|
425
|
-
'<tr><td rowspan="3">1,0<br>2,0<br>3,0<br></td><td>1,1</td><td>1,2</td><td>1,3</td></tr>' +
|
|
426
|
-
'<tr><td>2,1</td><td>2,2</td><td>2,3</td></tr>' +
|
|
427
|
-
'<tr><td>3,1</td><td>3,2</td><td>3,3</td></tr>' +
|
|
428
|
-
'</tbody></table>';
|
|
429
|
-
|
|
430
|
-
selectCells(editor, [0, 2, 3, 4, 6, 7, 9, 10]);
|
|
431
|
-
|
|
432
|
-
Jodit.modules.Table.mergeSelected(
|
|
433
|
-
editor.editor.firstChild,
|
|
434
|
-
editor
|
|
435
|
-
);
|
|
436
|
-
|
|
437
|
-
expect(sortAttributes(editor.value)).equals(
|
|
438
|
-
'<table style="width:100%">' +
|
|
439
|
-
'<tbody>' +
|
|
440
|
-
'<tr>' +
|
|
441
|
-
'<td rowspan="4">' +
|
|
442
|
-
'0,0<br>0,1<br>0,2<br><br>' +
|
|
443
|
-
'1,0<br>2,0<br>3,0<br><br>' +
|
|
444
|
-
'1,1<br>' +
|
|
445
|
-
'1,2<br>' +
|
|
446
|
-
'2,1<br>' +
|
|
447
|
-
'2,2<br>' +
|
|
448
|
-
'3,1<br>' +
|
|
449
|
-
'3,2' +
|
|
450
|
-
'</td>' +
|
|
451
|
-
'<td>0,3</td>' +
|
|
452
|
-
'</tr>' +
|
|
453
|
-
'<tr>' +
|
|
454
|
-
'<td>1,3</td>' +
|
|
455
|
-
'</tr>' +
|
|
456
|
-
'<tr>' +
|
|
457
|
-
'<td>2,3</td>' +
|
|
458
|
-
'</tr>' +
|
|
459
|
-
'<tr>' +
|
|
460
|
-
'<td>3,3</td>' +
|
|
461
|
-
'</tr>' +
|
|
462
|
-
'</tbody>' +
|
|
463
|
-
'</table>'
|
|
464
|
-
);
|
|
465
|
-
});
|
|
466
|
-
|
|
467
|
-
it('Merge cells in center', function () {
|
|
468
|
-
const editor = getJodit();
|
|
469
|
-
|
|
470
|
-
editor.value =
|
|
471
|
-
'<table style="width: 100%;">' +
|
|
472
|
-
'<tbody>' +
|
|
473
|
-
'<tr>' +
|
|
474
|
-
'<td colspan="3" class="">0,0<br>0,1<br>0,2<br></td>' +
|
|
475
|
-
'<td>0,3</td>' +
|
|
476
|
-
'</tr>' +
|
|
477
|
-
'<tr>' +
|
|
478
|
-
'<td rowspan="3" class="">1,0<br>2,0<br>3,0<br></td>' +
|
|
479
|
-
'<td>1,1</td>' +
|
|
480
|
-
'<td>1,2</td>' +
|
|
481
|
-
'<td>1,3</td>' +
|
|
482
|
-
'</tr>' +
|
|
483
|
-
'<tr>' +
|
|
484
|
-
'<td>2,1</td>' +
|
|
485
|
-
'<td>2,2</td>' +
|
|
486
|
-
'<td>2,3</td>' +
|
|
487
|
-
'</tr>' +
|
|
488
|
-
'<tr>' +
|
|
489
|
-
'<td class="">3,1</td>' +
|
|
490
|
-
'<td class="">3,2</td>' +
|
|
491
|
-
'<td>3,3</td>' +
|
|
492
|
-
'</tr>' +
|
|
493
|
-
'</tbody>' +
|
|
494
|
-
'</table>';
|
|
495
|
-
|
|
496
|
-
selectCells(editor, [3, 4, 5, 6, 7, 8]);
|
|
497
|
-
|
|
498
|
-
// const table = new Jodit.modules.Table(editor);
|
|
499
|
-
Jodit.modules.Table.mergeSelected(
|
|
500
|
-
editor.editor.firstChild,
|
|
501
|
-
editor
|
|
502
|
-
);
|
|
503
|
-
|
|
504
|
-
expect(sortAttributes(editor.editor.innerHTML)).equals(
|
|
505
|
-
'<table style="width:100%">' +
|
|
506
|
-
'<tbody>' +
|
|
507
|
-
'<tr>' +
|
|
508
|
-
'<td colspan="3">0,0<br>0,1<br>0,2<br></td><td>0,3</td>' +
|
|
509
|
-
'</tr>' +
|
|
510
|
-
'<tr>' +
|
|
511
|
-
'<td rowspan="2">1,0<br>2,0<br>3,0<br></td>' +
|
|
512
|
-
'<td colspan="3">1,1<br>1,2<br>1,3<br>2,1<br>2,2<br>2,3</td>' +
|
|
513
|
-
'</tr>' +
|
|
514
|
-
'<tr>' +
|
|
515
|
-
'<td>3,1</td><td>3,2</td><td>3,3</td>' +
|
|
516
|
-
'</tr>' +
|
|
517
|
-
'</tbody>' +
|
|
518
|
-
'</table>'
|
|
519
|
-
);
|
|
520
|
-
});
|
|
521
|
-
|
|
522
|
-
it('Normalize merged cells', function () {
|
|
523
|
-
const editor = getJodit();
|
|
524
|
-
|
|
525
|
-
editor.value =
|
|
526
|
-
'<table>' +
|
|
527
|
-
'<tbody>' +
|
|
528
|
-
'<tr>' +
|
|
529
|
-
'<td colspan="3" rowspan="4">1</td>' +
|
|
530
|
-
'<td rowspan="4">2</td>' +
|
|
531
|
-
'</tr>' +
|
|
532
|
-
'<tr></tr>' +
|
|
533
|
-
'<tr></tr>' +
|
|
534
|
-
'<tr></tr>' +
|
|
535
|
-
'</tbody>' +
|
|
536
|
-
'</table>';
|
|
537
|
-
|
|
538
|
-
selectCells(editor, [0, 1]);
|
|
539
|
-
|
|
540
|
-
Jodit.modules.Table.mergeSelected(
|
|
541
|
-
editor.editor.firstChild,
|
|
542
|
-
editor
|
|
543
|
-
);
|
|
544
|
-
|
|
545
|
-
expect(sortAttributes(editor.editor.innerHTML)).equals(
|
|
546
|
-
'<table>' +
|
|
547
|
-
'<tbody>' +
|
|
548
|
-
'<tr>' +
|
|
549
|
-
'<td>1<br>2</td>' +
|
|
550
|
-
'</tr>' +
|
|
551
|
-
'</tbody>' +
|
|
552
|
-
'</table>'
|
|
553
|
-
);
|
|
554
|
-
});
|
|
555
|
-
});
|
|
556
|
-
|
|
557
|
-
describe('Split selected cells', function () {
|
|
558
|
-
it('Split cell by Horizontal', function () {
|
|
559
|
-
const editor = getJodit();
|
|
560
|
-
|
|
561
|
-
editor.value =
|
|
562
|
-
'<table>' +
|
|
563
|
-
'<tbody>' +
|
|
564
|
-
'<tr><td>0,0</td></tr>' +
|
|
565
|
-
'<tr><td>1,0</td></tr>' +
|
|
566
|
-
'</tbody>' +
|
|
567
|
-
'</table>';
|
|
568
|
-
|
|
569
|
-
selectCells(editor, [0]);
|
|
570
|
-
|
|
571
|
-
Jodit.modules.Table.splitHorizontal(
|
|
572
|
-
editor.editor.firstChild,
|
|
573
|
-
editor
|
|
574
|
-
);
|
|
575
|
-
|
|
576
|
-
expect(sortAttributes(editor.editor.innerHTML)).equals(
|
|
577
|
-
'<table>' +
|
|
578
|
-
'<tbody>' +
|
|
579
|
-
'<tr><td>0,0</td></tr>' +
|
|
580
|
-
'<tr><td><br></td></tr>' +
|
|
581
|
-
'<tr><td>1,0</td></tr>' +
|
|
582
|
-
'</tbody>' +
|
|
583
|
-
'</table>'
|
|
584
|
-
);
|
|
585
|
-
});
|
|
586
|
-
|
|
587
|
-
it('Split cell with rowspan by horizontal', function () {
|
|
588
|
-
const editor = getJodit();
|
|
589
|
-
|
|
590
|
-
editor.value =
|
|
591
|
-
'<table>' +
|
|
592
|
-
'<tbody>' +
|
|
593
|
-
'<tr><td>0,0</td><td>0,1</td><td>0,2</td></tr>' +
|
|
594
|
-
'<tr>' +
|
|
595
|
-
'<td rowspan="2">1,0</td>' +
|
|
596
|
-
'<td>1,1</td>' +
|
|
597
|
-
'<td rowspan="2">1,2</td>' +
|
|
598
|
-
'</tr>' +
|
|
599
|
-
'<tr><td><br></td></tr>' +
|
|
600
|
-
'<tr><td>2,0</td><td>2,1</td><td>2,2</td></tr>' +
|
|
601
|
-
'</tbody>' +
|
|
602
|
-
'</table>';
|
|
603
|
-
|
|
604
|
-
selectCells(editor, [3]);
|
|
605
|
-
|
|
606
|
-
// const table = new Jodit.modules.Table(editor);
|
|
607
|
-
Jodit.modules.Table.splitHorizontal(
|
|
608
|
-
editor.editor.firstChild,
|
|
609
|
-
editor
|
|
610
|
-
);
|
|
611
|
-
|
|
612
|
-
expect(sortAttributes(editor.editor.innerHTML)).equals(
|
|
613
|
-
'<table>' +
|
|
614
|
-
'<tbody>' +
|
|
615
|
-
'<tr><td>0,0</td><td>0,1</td><td>0,2</td></tr>' +
|
|
616
|
-
'<tr>' +
|
|
617
|
-
'<td>1,0</td>' +
|
|
618
|
-
'<td>1,1</td>' +
|
|
619
|
-
'<td rowspan="2">1,2</td>' +
|
|
620
|
-
'</tr>' +
|
|
621
|
-
'<tr><td><br></td><td><br></td></tr>' +
|
|
622
|
-
'<tr><td>2,0</td><td>2,1</td><td>2,2</td></tr>' +
|
|
623
|
-
'</tbody>' +
|
|
624
|
-
'</table>'
|
|
625
|
-
);
|
|
626
|
-
});
|
|
627
|
-
|
|
628
|
-
it('Split cell with rowspan by horizontal 2', function () {
|
|
629
|
-
const editor = getJodit();
|
|
630
|
-
|
|
631
|
-
editor.value =
|
|
632
|
-
'<table>' +
|
|
633
|
-
'<tbody>' +
|
|
634
|
-
'<tr><td>0,0</td><td>0,1</td><td>0,2</td></tr>' +
|
|
635
|
-
'<tr>' +
|
|
636
|
-
'<td rowspan="2">1,0</td>' +
|
|
637
|
-
'<td rowspan="2">1,1</td>' +
|
|
638
|
-
'<td>1,2</td>' +
|
|
639
|
-
'</tr>' +
|
|
640
|
-
'<tr><td><br></td></tr>' +
|
|
641
|
-
'<tr><td>2,0</td><td>2,1</td><td>2,2</td></tr>' +
|
|
642
|
-
'</tbody>' +
|
|
643
|
-
'</table>';
|
|
644
|
-
|
|
645
|
-
selectCells(editor, [4]);
|
|
646
|
-
|
|
647
|
-
Jodit.modules.Table.splitHorizontal(
|
|
648
|
-
editor.editor.firstChild,
|
|
649
|
-
editor
|
|
650
|
-
);
|
|
651
|
-
|
|
652
|
-
expect(sortAttributes(editor.value)).equals(
|
|
653
|
-
'<table>' +
|
|
654
|
-
'<tbody>' +
|
|
655
|
-
'<tr><td>0,0</td><td>0,1</td><td>0,2</td></tr>' +
|
|
656
|
-
'<tr>' +
|
|
657
|
-
'<td rowspan="2">1,0</td>' +
|
|
658
|
-
'<td>1,1</td>' +
|
|
659
|
-
'<td>1,2</td>' +
|
|
660
|
-
'</tr>' +
|
|
661
|
-
'<tr><td><br></td><td><br></td></tr>' +
|
|
662
|
-
'<tr><td>2,0</td><td>2,1</td><td>2,2</td></tr>' +
|
|
663
|
-
'</tbody>' +
|
|
664
|
-
'</table>'
|
|
665
|
-
);
|
|
666
|
-
});
|
|
667
|
-
|
|
668
|
-
it('Split cell by vertical', function () {
|
|
669
|
-
const editor = getJodit();
|
|
670
|
-
|
|
671
|
-
editor.value =
|
|
672
|
-
'<table style="width: 300px;">' +
|
|
673
|
-
'<tbody>' +
|
|
674
|
-
'<tr><td style="width:100px">0,0</td><td>0,1</td></tr>' +
|
|
675
|
-
'<tr><td>1,0</td><td>1,1</td></tr>' +
|
|
676
|
-
'</tbody>' +
|
|
677
|
-
'</table>';
|
|
678
|
-
|
|
679
|
-
selectCells(editor, [0]);
|
|
680
|
-
|
|
681
|
-
Jodit.modules.Table.splitVertical(
|
|
682
|
-
editor.editor.firstChild,
|
|
683
|
-
editor
|
|
684
|
-
);
|
|
685
|
-
|
|
686
|
-
expect(sortAttributes(editor.value)).equals(
|
|
687
|
-
'<table style="width:300px">' +
|
|
688
|
-
'<tbody>' +
|
|
689
|
-
'<tr><td style="width:16.66%">0,0</td><td style="width:16.66%"><br></td><td>0,1</td></tr>' +
|
|
690
|
-
'<tr><td colspan="2">1,0</td><td>1,1</td></tr>' +
|
|
691
|
-
'</tbody>' +
|
|
692
|
-
'</table>'
|
|
693
|
-
);
|
|
694
|
-
});
|
|
695
|
-
});
|
|
696
|
-
});
|
|
697
|
-
|
|
698
|
-
describe('Work with tables', function () {
|
|
699
|
-
it('Create table and insert into cell some text', function () {
|
|
700
|
-
const editor = getJodit();
|
|
701
|
-
editor.ownerWindow.focus();
|
|
702
|
-
editor.value = '';
|
|
703
|
-
|
|
704
|
-
const table = editor.createInside.element('table'),
|
|
705
|
-
tr = editor.createInside.element('tr'),
|
|
706
|
-
td = editor.createInside.element('td'),
|
|
707
|
-
td2 = editor.createInside.element('td');
|
|
708
|
-
|
|
709
|
-
tr.appendChild(td);
|
|
710
|
-
tr.appendChild(td2);
|
|
711
|
-
table.appendChild(tr);
|
|
712
|
-
|
|
713
|
-
editor.s.focus();
|
|
714
|
-
editor.s.insertNode(table, false);
|
|
715
|
-
editor.s.setCursorIn(table, false); // set cursor in last cell
|
|
716
|
-
editor.s.insertNode(editor.createInside.text('ok'));
|
|
717
|
-
|
|
718
|
-
expect(editor.value).equals(
|
|
719
|
-
'<table><tr><td></td><td>ok</td></tr></table>'
|
|
720
|
-
);
|
|
721
|
-
});
|
|
722
|
-
|
|
723
|
-
it('After insert table like html without tbody, it should be appear', function () {
|
|
724
|
-
const editor = getJodit();
|
|
725
|
-
|
|
726
|
-
editor.value =
|
|
727
|
-
'<table>' +
|
|
728
|
-
'<tr>' +
|
|
729
|
-
'<td>1</td>' +
|
|
730
|
-
'<td>2</td>' +
|
|
731
|
-
'</tr>' +
|
|
732
|
-
'</table>';
|
|
733
|
-
|
|
734
|
-
expect(editor.value).equals(
|
|
735
|
-
'<table><tbody><tr><td>1</td><td>2</td></tr></tbody></table>'
|
|
736
|
-
);
|
|
737
|
-
});
|
|
738
|
-
|
|
739
|
-
it('After press Tab button cursor should be in next cell in table', function () {
|
|
740
|
-
const editor = getJodit();
|
|
741
|
-
|
|
742
|
-
editor.value =
|
|
743
|
-
'<table>' +
|
|
744
|
-
'<tr>' +
|
|
745
|
-
'<td>1</td>' +
|
|
746
|
-
'<td>2</td>' +
|
|
747
|
-
'</tr>' +
|
|
748
|
-
'</table>';
|
|
749
|
-
|
|
750
|
-
editor.s.setCursorIn(editor.editor.querySelector('td'));
|
|
751
|
-
|
|
752
|
-
simulateEvent('keydown', Jodit.KEY_TAB, editor.editor);
|
|
753
|
-
|
|
754
|
-
editor.s.insertNode(editor.createInside.text('test'), false);
|
|
755
|
-
|
|
756
|
-
expect(editor.value.replace('<br>', '')).equals(
|
|
757
|
-
'<table><tbody><tr><td>1</td><td>test</td></tr></tbody></table>'
|
|
758
|
-
);
|
|
759
|
-
});
|
|
760
|
-
|
|
761
|
-
it('After press Tab + Shift buttons cursor should be in next cell in table', function () {
|
|
762
|
-
const editor = getJodit();
|
|
763
|
-
|
|
764
|
-
editor.value =
|
|
765
|
-
'<table>' +
|
|
766
|
-
'<tr>' +
|
|
767
|
-
'<td>1</td>' +
|
|
768
|
-
'<td>2</td>' +
|
|
769
|
-
'</tr>' +
|
|
770
|
-
'</table>';
|
|
771
|
-
|
|
772
|
-
editor.s.setCursorIn(editor.editor.querySelector('td').nextSibling);
|
|
773
|
-
|
|
774
|
-
simulateEvent(
|
|
775
|
-
'keydown',
|
|
776
|
-
Jodit.KEY_TAB,
|
|
777
|
-
editor.editor,
|
|
778
|
-
function (evnt) {
|
|
779
|
-
evnt.shiftKey = true;
|
|
780
|
-
}
|
|
781
|
-
);
|
|
782
|
-
|
|
783
|
-
editor.s.insertNode(editor.createInside.text('test'), false);
|
|
784
|
-
|
|
785
|
-
expect(editor.value.replace('<br>', '')).equals(
|
|
786
|
-
'<table><tbody><tr><td>test</td><td>2</td></tr></tbody></table>'
|
|
787
|
-
);
|
|
788
|
-
});
|
|
789
|
-
|
|
790
|
-
it('After press Right arrow not in the end of cell it should do nothing', function () {
|
|
791
|
-
const editor = getJodit();
|
|
792
|
-
|
|
793
|
-
editor.value =
|
|
794
|
-
'<table>' +
|
|
795
|
-
'<tr>' +
|
|
796
|
-
'<td>1</td>' +
|
|
797
|
-
'<td>2</td>' +
|
|
798
|
-
'</tr>' +
|
|
799
|
-
'</table>';
|
|
800
|
-
|
|
801
|
-
editor.s.setCursorIn(editor.editor.querySelector('td'), true); // set cursor before 1
|
|
802
|
-
|
|
803
|
-
simulateEvent('keydown', Jodit.KEY_RIGHT, editor.editor); // not work but in real cursor move after 1
|
|
804
|
-
|
|
805
|
-
editor.s.insertNode(editor.createInside.text('test'), false);
|
|
806
|
-
|
|
807
|
-
expect(editor.value).equals(
|
|
808
|
-
'<table><tbody><tr><td>test1</td><td>2</td></tr></tbody></table>'
|
|
809
|
-
);
|
|
810
|
-
});
|
|
811
|
-
|
|
812
|
-
it('After press Left arrow in the start of cell it should work like tab + shift', function () {
|
|
813
|
-
const editor = getJodit();
|
|
814
|
-
|
|
815
|
-
editor.value =
|
|
816
|
-
'<table>' +
|
|
817
|
-
'<tr>' +
|
|
818
|
-
'<td>1</td>' +
|
|
819
|
-
'<td>2</td>' +
|
|
820
|
-
'</tr>' +
|
|
821
|
-
'</table>';
|
|
822
|
-
|
|
823
|
-
editor.s.setCursorIn(
|
|
824
|
-
editor.editor.querySelector('td').nextSibling,
|
|
825
|
-
true
|
|
826
|
-
); // set cursor before 1
|
|
827
|
-
|
|
828
|
-
simulateEvent('keydown', Jodit.KEY_LEFT, editor.editor); // not work but in real cursor move after 1
|
|
829
|
-
|
|
830
|
-
editor.s.insertNode(editor.createInside.text('test'), false);
|
|
831
|
-
|
|
832
|
-
expect(editor.value).equals(
|
|
833
|
-
'<table><tbody>' +
|
|
834
|
-
'<tr>' +
|
|
835
|
-
'<td>1test</td>' +
|
|
836
|
-
'<td>2</td>' +
|
|
837
|
-
'</tr>' +
|
|
838
|
-
'</tbody></table>'
|
|
839
|
-
);
|
|
840
|
-
});
|
|
841
|
-
|
|
842
|
-
it("After press Top arrow in the first cell's line cursor should move into top cell", function () {
|
|
843
|
-
const editor = getJodit();
|
|
844
|
-
|
|
845
|
-
editor.value =
|
|
846
|
-
'<table>' +
|
|
847
|
-
'<tr>' +
|
|
848
|
-
'<td>1</td>' +
|
|
849
|
-
'<td>2</td>' +
|
|
850
|
-
'</tr>' +
|
|
851
|
-
'<tr>' +
|
|
852
|
-
'<td>3</td>' +
|
|
853
|
-
'<td>4<br>5<br>6</td>' +
|
|
854
|
-
'</tr>' +
|
|
855
|
-
'</table>';
|
|
856
|
-
|
|
857
|
-
editor.s.setCursorAfter(
|
|
858
|
-
editor.editor.querySelectorAll('td')[3].firstChild
|
|
859
|
-
); // set cursor after 4
|
|
860
|
-
|
|
861
|
-
simulateEvent('keydown', Jodit.KEY_UP, editor.editor);
|
|
862
|
-
|
|
863
|
-
editor.s.insertNode(editor.createInside.text('test'), false);
|
|
864
|
-
|
|
865
|
-
expect(editor.value).equals(
|
|
866
|
-
'<table><tbody>' +
|
|
867
|
-
'<tr>' +
|
|
868
|
-
'<td>1</td>' +
|
|
869
|
-
'<td>2test</td></tr>' +
|
|
870
|
-
'<tr>' +
|
|
871
|
-
'<td>3</td>' +
|
|
872
|
-
'<td>' +
|
|
873
|
-
'4<br>' +
|
|
874
|
-
'5<br>' +
|
|
875
|
-
'6' +
|
|
876
|
-
'</td>' +
|
|
877
|
-
'</tr>' +
|
|
878
|
-
'</tbody></table>'
|
|
879
|
-
);
|
|
880
|
-
});
|
|
881
|
-
|
|
882
|
-
it("After press Bottom arrow in the first cell's line cursor should move into bottom cell", function () {
|
|
883
|
-
const editor = getJodit();
|
|
884
|
-
|
|
885
|
-
editor.value =
|
|
886
|
-
'<table>' +
|
|
887
|
-
'<tr>' +
|
|
888
|
-
'<td>1</td>' +
|
|
889
|
-
'<td>2<br>3</td>' +
|
|
890
|
-
'</tr>' +
|
|
891
|
-
'<tr>' +
|
|
892
|
-
'<td>4</td>' +
|
|
893
|
-
'<td>5</td>' +
|
|
894
|
-
'</tr>' +
|
|
895
|
-
'</table>';
|
|
896
|
-
|
|
897
|
-
editor.s.setCursorAfter(
|
|
898
|
-
editor.editor.querySelectorAll('td')[1].lastChild
|
|
899
|
-
); // set cursor after 3
|
|
900
|
-
|
|
901
|
-
simulateEvent('keydown', Jodit.KEY_DOWN, editor.editor);
|
|
902
|
-
|
|
903
|
-
editor.s.insertNode(editor.createInside.text('test'), false);
|
|
904
|
-
|
|
905
|
-
expect(editor.value).equals(
|
|
906
|
-
'<table><tbody>' +
|
|
907
|
-
'<tr>' +
|
|
908
|
-
'<td>1</td>' +
|
|
909
|
-
'<td>2<br>3</td>' +
|
|
910
|
-
'</tr>' +
|
|
911
|
-
'<tr>' +
|
|
912
|
-
'<td>4</td>' +
|
|
913
|
-
'<td>test5</td>' +
|
|
914
|
-
'</tr>' +
|
|
915
|
-
'</tbody></table>'
|
|
916
|
-
);
|
|
917
|
-
});
|
|
918
|
-
|
|
919
|
-
it("After press Tab in last table's cell in table should add new row and move into first cell form it", function () {
|
|
920
|
-
const editor = getJodit();
|
|
921
|
-
|
|
922
|
-
editor.value =
|
|
923
|
-
'<table>' +
|
|
924
|
-
'<tr>' +
|
|
925
|
-
'<td>1</td>' +
|
|
926
|
-
'<td>2</td>' +
|
|
927
|
-
'</tr>' +
|
|
928
|
-
'</table>';
|
|
929
|
-
|
|
930
|
-
editor.s.setCursorAfter(
|
|
931
|
-
editor.editor.querySelectorAll('td')[1].lastChild
|
|
932
|
-
); // set cursor after 2
|
|
933
|
-
|
|
934
|
-
simulateEvent('keydown', Jodit.KEY_TAB, editor.editor);
|
|
935
|
-
|
|
936
|
-
editor.s.insertNode(editor.createInside.text('test'), false);
|
|
937
|
-
|
|
938
|
-
expect(editor.value).equals(
|
|
939
|
-
'<table><tbody>' +
|
|
940
|
-
'<tr>' +
|
|
941
|
-
'<td>1</td>' +
|
|
942
|
-
'<td>2</td>' +
|
|
943
|
-
'</tr>' +
|
|
944
|
-
'<tr>' +
|
|
945
|
-
'<td>test<br></td>' +
|
|
946
|
-
'<td></td>' +
|
|
947
|
-
'</tr>' +
|
|
948
|
-
'</tbody></table>'
|
|
949
|
-
);
|
|
950
|
-
});
|
|
951
|
-
|
|
952
|
-
describe('Remove row', function () {
|
|
953
|
-
it('Remove simple row without rowspan should simple remove row', function () {
|
|
954
|
-
const editor = getJodit();
|
|
955
|
-
|
|
956
|
-
editor.value =
|
|
957
|
-
'<table>' +
|
|
958
|
-
'<tr><td>1</td><td>2</td></tr>' +
|
|
959
|
-
'<tr><td>3</td><td>4</td></tr>' +
|
|
960
|
-
'</table>';
|
|
961
|
-
|
|
962
|
-
Jodit.modules.Table.removeRow(editor.editor.firstChild, 0);
|
|
963
|
-
|
|
964
|
-
expect(editor.value.toLowerCase()).equals(
|
|
965
|
-
'<table>' +
|
|
966
|
-
'<tbody>' +
|
|
967
|
-
'<tr><td>3</td><td>4</td></tr>' +
|
|
968
|
-
'</tbody>' +
|
|
969
|
-
'</table>'
|
|
970
|
-
);
|
|
971
|
-
});
|
|
972
|
-
it('Remove row which not consists td, because of in previous row was cell with rowspan should simple remove row and decrement rowspan', function () {
|
|
973
|
-
const editor = getJodit();
|
|
974
|
-
|
|
975
|
-
editor.value =
|
|
976
|
-
'<table>' +
|
|
977
|
-
'<tr><td rowspan="2">1</td><td>2</td></tr>' +
|
|
978
|
-
'<tr><td>3</td></tr>' +
|
|
979
|
-
'</table>';
|
|
980
|
-
|
|
981
|
-
// const table = new Jodit.modules.Table(editor);
|
|
982
|
-
Jodit.modules.Table.removeRow(editor.editor.firstChild, 1);
|
|
983
|
-
|
|
984
|
-
expect(editor.value.toLowerCase()).equals(
|
|
985
|
-
'<table>' +
|
|
986
|
-
'<tbody>' +
|
|
987
|
-
'<tr><td>1</td><td>2</td></tr>' +
|
|
988
|
-
'</tbody>' +
|
|
989
|
-
'</table>'
|
|
990
|
-
);
|
|
991
|
-
});
|
|
992
|
-
it('Remove row which not consists td, because of in previous row was cell with rowspan and colspan should simple remove row and decrement rowspan once time', function () {
|
|
993
|
-
const editor = getJodit();
|
|
994
|
-
|
|
995
|
-
editor.value =
|
|
996
|
-
'<table>' +
|
|
997
|
-
'<tr><td rowspan="3" colspan="2">1</td><td>2</td></tr>' +
|
|
998
|
-
'<tr><td>3</td></tr>' +
|
|
999
|
-
'<tr><td>4</td></tr>' +
|
|
1000
|
-
'<tr><td>5</td><td>6</td><td>7</td></tr>' +
|
|
1001
|
-
'</table>';
|
|
1002
|
-
|
|
1003
|
-
// const table = new Jodit.modules.Table(editor);
|
|
1004
|
-
Jodit.modules.Table.removeRow(editor.editor.firstChild, 1);
|
|
1005
|
-
|
|
1006
|
-
expect(editor.value.toLowerCase()).equals(
|
|
1007
|
-
'<table>' +
|
|
1008
|
-
'<tbody>' +
|
|
1009
|
-
'<tr><td rowspan="2" colspan="2">1</td><td>2</td></tr>' +
|
|
1010
|
-
'<tr><td>4</td></tr>' +
|
|
1011
|
-
'<tr><td>5</td><td>6</td><td>7</td></tr>' +
|
|
1012
|
-
'</tbody>' +
|
|
1013
|
-
'</table>'
|
|
1014
|
-
);
|
|
1015
|
-
});
|
|
1016
|
-
it('Remove row which consists td with rowspan should simple remove row and decrement rowspan and move that cell into next row', function () {
|
|
1017
|
-
const editor = getJodit();
|
|
1018
|
-
|
|
1019
|
-
editor.value =
|
|
1020
|
-
'<table>' +
|
|
1021
|
-
'<tr><td rowspan="2">1</td><td>2</td></tr>' +
|
|
1022
|
-
'<tr><td>3</td></tr>' +
|
|
1023
|
-
'</table>';
|
|
1024
|
-
|
|
1025
|
-
// const table = new Jodit.modules.Table(editor);
|
|
1026
|
-
Jodit.modules.Table.removeRow(editor.editor.firstChild, 0);
|
|
1027
|
-
|
|
1028
|
-
expect(editor.value.toLowerCase()).equals(
|
|
1029
|
-
'<table>' +
|
|
1030
|
-
'<tbody>' +
|
|
1031
|
-
'<tr><td>1</td><td>3</td></tr>' +
|
|
1032
|
-
'</tbody>' +
|
|
1033
|
-
'</table>'
|
|
1034
|
-
);
|
|
1035
|
-
});
|
|
1036
|
-
it('Remove row which consists td with rowspan and colspan should simple remove row and decrement rowspan and move that cell into next row', function () {
|
|
1037
|
-
const editor = getJodit();
|
|
1038
|
-
|
|
1039
|
-
editor.value =
|
|
1040
|
-
'<table>' +
|
|
1041
|
-
'<tr><td rowspan="2" colspan="2">1</td><td>2</td></tr>' +
|
|
1042
|
-
'<tr><td>3</td></tr>' +
|
|
1043
|
-
'<tr><td>4</td><td>5</td><td>6</td></tr>' +
|
|
1044
|
-
'</table>';
|
|
1045
|
-
|
|
1046
|
-
// const table = new Jodit.modules.Table(editor);
|
|
1047
|
-
Jodit.modules.Table.removeRow(editor.editor.firstChild, 0);
|
|
1048
|
-
|
|
1049
|
-
expect(editor.value.toLowerCase()).equals(
|
|
1050
|
-
'<table>' +
|
|
1051
|
-
'<tbody>' +
|
|
1052
|
-
'<tr><td colspan="2">1</td><td>3</td></tr>' +
|
|
1053
|
-
'<tr><td>4</td><td>5</td><td>6</td></tr>' +
|
|
1054
|
-
'</tbody>' +
|
|
1055
|
-
'</table>'
|
|
1056
|
-
);
|
|
1057
|
-
});
|
|
1058
|
-
it('Remove row which consists last td with rowspan and colspan should simple remove row and decrement rowspan and move that cell into next row in last position', function () {
|
|
1059
|
-
const editor = getJodit();
|
|
1060
|
-
|
|
1061
|
-
editor.value =
|
|
1062
|
-
'<table>' +
|
|
1063
|
-
'<tr><td>1</td><td>2</td><td>3</td></tr>' +
|
|
1064
|
-
'<tr><td>4</td><td colspan="2" rowspan="2">5</td></tr>' +
|
|
1065
|
-
'<tr><td>6</td></tr>' +
|
|
1066
|
-
'</table>';
|
|
1067
|
-
|
|
1068
|
-
// const table = new Jodit.modules.Table(editor);
|
|
1069
|
-
Jodit.modules.Table.removeRow(editor.editor.firstChild, 1);
|
|
1070
|
-
|
|
1071
|
-
expect(editor.value.toLowerCase()).equals(
|
|
1072
|
-
'<table>' +
|
|
1073
|
-
'<tbody>' +
|
|
1074
|
-
'<tr><td>1</td><td>2</td><td>3</td></tr>' +
|
|
1075
|
-
'<tr><td>6</td><td colspan="2">5</td></tr>' +
|
|
1076
|
-
'</tbody>' +
|
|
1077
|
-
'</table>'
|
|
1078
|
-
);
|
|
1079
|
-
});
|
|
1080
|
-
});
|
|
1081
|
-
|
|
1082
|
-
describe('Remove column', function () {
|
|
1083
|
-
it('Remove simple column without colspan should simple remove all cells in column', function () {
|
|
1084
|
-
const editor = getJodit();
|
|
1085
|
-
|
|
1086
|
-
editor.value =
|
|
1087
|
-
'<table>' +
|
|
1088
|
-
'<tr><td>1</td><td>2</td></tr>' +
|
|
1089
|
-
'<tr><td>3</td><td>4</td></tr>' +
|
|
1090
|
-
'<tr><td>5</td><td>6</td></tr>' +
|
|
1091
|
-
'</table>';
|
|
1092
|
-
|
|
1093
|
-
// const table = new Jodit.modules.Table(editor);
|
|
1094
|
-
Jodit.modules.Table.removeColumn(editor.editor.firstChild, 0);
|
|
1095
|
-
|
|
1096
|
-
expect(editor.value.toLowerCase()).equals(
|
|
1097
|
-
'<table>' +
|
|
1098
|
-
'<tbody>' +
|
|
1099
|
-
'<tr><td>2</td></tr>' +
|
|
1100
|
-
'<tr><td>4</td></tr>' +
|
|
1101
|
-
'<tr><td>6</td></tr>' +
|
|
1102
|
-
'</tbody>' +
|
|
1103
|
-
'</table>'
|
|
1104
|
-
);
|
|
1105
|
-
});
|
|
1106
|
-
it('Remove column which consists td with colspan should remove all cells in column but that td should decrement colspan', function () {
|
|
1107
|
-
const editor = getJodit();
|
|
1108
|
-
|
|
1109
|
-
editor.value =
|
|
1110
|
-
'<table>' +
|
|
1111
|
-
'<tr><td>1</td><td>2</td></tr>' +
|
|
1112
|
-
'<tr><td colspan="2">3</td></tr>' +
|
|
1113
|
-
'<tr><td>4</td><td>5</td></tr>' +
|
|
1114
|
-
'</table>';
|
|
1115
|
-
|
|
1116
|
-
// const table = new Jodit.modules.Table(editor);
|
|
1117
|
-
Jodit.modules.Table.removeColumn(editor.editor.firstChild, 0);
|
|
1118
|
-
|
|
1119
|
-
expect(editor.value.toLowerCase()).equals(
|
|
1120
|
-
'<table>' +
|
|
1121
|
-
'<tbody>' +
|
|
1122
|
-
'<tr><td>2</td></tr>' +
|
|
1123
|
-
'<tr><td>3</td></tr>' +
|
|
1124
|
-
'<tr><td>5</td></tr>' +
|
|
1125
|
-
'</tbody>' +
|
|
1126
|
-
'</table>'
|
|
1127
|
-
);
|
|
1128
|
-
});
|
|
1129
|
-
it('Remove column which not consists td with colspan should remove all cells in column but that td should decrement colspan too', function () {
|
|
1130
|
-
const editor = getJodit();
|
|
1131
|
-
|
|
1132
|
-
editor.value =
|
|
1133
|
-
'<table>' +
|
|
1134
|
-
'<tr><td>1</td><td>2</td></tr>' +
|
|
1135
|
-
'<tr><td colspan="2">3</td></tr>' +
|
|
1136
|
-
'<tr><td>4</td><td>5</td></tr>' +
|
|
1137
|
-
'</table>';
|
|
1138
|
-
|
|
1139
|
-
// const table = new Jodit.modules.Table(editor);
|
|
1140
|
-
Jodit.modules.Table.removeColumn(editor.editor.firstChild, 1);
|
|
1141
|
-
|
|
1142
|
-
expect(editor.value.toLowerCase()).equals(
|
|
1143
|
-
'<table>' +
|
|
1144
|
-
'<tbody>' +
|
|
1145
|
-
'<tr><td>1</td></tr>' +
|
|
1146
|
-
'<tr><td>3</td></tr>' +
|
|
1147
|
-
'<tr><td>4</td></tr>' +
|
|
1148
|
-
'</tbody>' +
|
|
1149
|
-
'</table>'
|
|
1150
|
-
);
|
|
1151
|
-
});
|
|
1152
|
-
|
|
1153
|
-
it('Remove column part of that td (colspan and rowspan) in another column should remove all cells in column but that td should decrement colspan once time', function () {
|
|
1154
|
-
const editor = getJodit();
|
|
1155
|
-
|
|
1156
|
-
editor.value =
|
|
1157
|
-
'<table>' +
|
|
1158
|
-
'<tr><td>1</td><td>2</td><td>3</td><td>4</td></tr>' +
|
|
1159
|
-
'<tr><td>5</td><td colspan="3" rowspan="2">6</td></tr>' +
|
|
1160
|
-
'<tr><td>7</td></tr>' +
|
|
1161
|
-
'</table>';
|
|
1162
|
-
|
|
1163
|
-
// const table = new Jodit.modules.Table(editor);
|
|
1164
|
-
Jodit.modules.Table.removeColumn(editor.editor.firstChild, 3);
|
|
1165
|
-
|
|
1166
|
-
let result = editor.value.toLowerCase();
|
|
1167
|
-
|
|
1168
|
-
// in ie colspan and rowspan change places but it is not so important
|
|
1169
|
-
result = result.replace('rowspan', 'colspan');
|
|
1170
|
-
|
|
1171
|
-
expect(result).equals(
|
|
1172
|
-
'<table>' +
|
|
1173
|
-
'<tbody>' +
|
|
1174
|
-
'<tr><td>1</td><td>2</td><td>3</td></tr>' +
|
|
1175
|
-
'<tr><td>5</td><td colspan="2" colspan="2">6</td></tr>' +
|
|
1176
|
-
'<tr><td>7</td></tr>' +
|
|
1177
|
-
'</tbody>' +
|
|
1178
|
-
'</table>'
|
|
1179
|
-
);
|
|
1180
|
-
});
|
|
1181
|
-
});
|
|
1182
|
-
|
|
1183
|
-
describe('Select cells', function () {
|
|
1184
|
-
it('When we press mouse button over cell and move mouse to another cell, it should select all cells in bound', function (done) {
|
|
1185
|
-
const editor = getJodit();
|
|
1186
|
-
|
|
1187
|
-
editor.value = `<table>
|
|
1188
|
-
<tbody>
|
|
1189
|
-
<tr><td>1</td><td>2</td></tr>
|
|
1190
|
-
<tr><td>3</td><td>4</td></tr>
|
|
1191
|
-
<tr><td>5</td><td>6</td></tr>
|
|
1192
|
-
</tbody>
|
|
1193
|
-
</table>`;
|
|
1194
|
-
|
|
1195
|
-
let td = editor.editor.querySelector('td');
|
|
1196
|
-
|
|
1197
|
-
simulateEvent('mousedown', td);
|
|
1198
|
-
|
|
1199
|
-
td = editor.editor.querySelectorAll('td')[3];
|
|
1200
|
-
|
|
1201
|
-
simulateEvent(['mousemove', 'mouseup', 'click'], td);
|
|
1202
|
-
|
|
1203
|
-
editor.async.requestIdleCallback(() => {
|
|
1204
|
-
expect(
|
|
1205
|
-
editor.getInstance('Table', editor.o).selected.size
|
|
1206
|
-
).equals(4);
|
|
1207
|
-
done();
|
|
1208
|
-
});
|
|
1209
|
-
});
|
|
1210
|
-
|
|
1211
|
-
describe('Set custom selected border color', function () {
|
|
1212
|
-
it('Should add css rule in document for selected css', function () {
|
|
1213
|
-
const editor = getJodit({
|
|
1214
|
-
table: {
|
|
1215
|
-
selectionCellStyle:
|
|
1216
|
-
'border: 1px double red !important;'
|
|
1217
|
-
}
|
|
1218
|
-
});
|
|
1219
|
-
|
|
1220
|
-
editor.value =
|
|
1221
|
-
'<table>' +
|
|
1222
|
-
'<tr><td>1</td><td>2</td></tr>' +
|
|
1223
|
-
'<tr><td>3</td><td>4</td></tr>' +
|
|
1224
|
-
'<tr><td>5</td><td>6</td></tr>' +
|
|
1225
|
-
'</table>';
|
|
1226
|
-
|
|
1227
|
-
let td = editor.editor.querySelector('td');
|
|
1228
|
-
|
|
1229
|
-
simulateEvent('mousedown', td);
|
|
1230
|
-
|
|
1231
|
-
td = editor.editor.querySelectorAll('td')[3];
|
|
1232
|
-
|
|
1233
|
-
simulateEvent(['mousemove', 'mouseup', 'click'], td);
|
|
1234
|
-
|
|
1235
|
-
expect(
|
|
1236
|
-
Jodit.modules.Helpers.normalizeColor(
|
|
1237
|
-
editor.ew.getComputedStyle(td).borderBottomColor
|
|
1238
|
-
)
|
|
1239
|
-
).equals('#FF0000');
|
|
1240
|
-
});
|
|
1241
|
-
|
|
1242
|
-
describe('For iframe mode', function () {
|
|
1243
|
-
it('Should add css rule in editor document for selected css', function () {
|
|
1244
|
-
const editor = getJodit({
|
|
1245
|
-
iframe: true,
|
|
1246
|
-
table: {
|
|
1247
|
-
selectionCellStyle:
|
|
1248
|
-
'border: 1px double red !important;'
|
|
1249
|
-
}
|
|
1250
|
-
});
|
|
1251
|
-
|
|
1252
|
-
editor.value =
|
|
1253
|
-
'<table>' +
|
|
1254
|
-
'<tr><td>1</td><td>2</td></tr>' +
|
|
1255
|
-
'<tr><td>3</td><td>4</td></tr>' +
|
|
1256
|
-
'<tr><td>5</td><td>6</td></tr>' +
|
|
1257
|
-
'</table>';
|
|
1258
|
-
|
|
1259
|
-
let td = editor.editor.querySelector('td');
|
|
1260
|
-
|
|
1261
|
-
simulateEvent('mousedown', td);
|
|
1262
|
-
|
|
1263
|
-
td = editor.editor.querySelectorAll('td')[3];
|
|
1264
|
-
|
|
1265
|
-
simulateEvent(['mousemove', 'mouseup', 'click'], td);
|
|
1266
|
-
|
|
1267
|
-
expect(
|
|
1268
|
-
Jodit.modules.Helpers.normalizeColor(
|
|
1269
|
-
editor.ew.getComputedStyle(td).borderBottomColor
|
|
1270
|
-
)
|
|
1271
|
-
).equals('#FF0000');
|
|
1272
|
-
});
|
|
1273
|
-
});
|
|
1274
|
-
});
|
|
1275
|
-
|
|
1276
|
-
describe('When we press mouse button over cell in subtable and move mouse to another cell', function () {
|
|
1277
|
-
it('should select all cells in bound in that table', function () {
|
|
1278
|
-
const editor = getJodit();
|
|
1279
|
-
|
|
1280
|
-
editor.value =
|
|
1281
|
-
'<table>' +
|
|
1282
|
-
'<tr><td>1</td><td>2</td></tr>' +
|
|
1283
|
-
'<tr>' +
|
|
1284
|
-
'<td>3</td>' +
|
|
1285
|
-
'<td class="test">' +
|
|
1286
|
-
'<table>' +
|
|
1287
|
-
'<tr><td>1</td><td>2</td></tr>' +
|
|
1288
|
-
'<tr><td>3</td><td>4</td></tr>' +
|
|
1289
|
-
'<tr><td>5</td><td>6</td></tr>' +
|
|
1290
|
-
'</table>' +
|
|
1291
|
-
'</td>' +
|
|
1292
|
-
'</tr>' +
|
|
1293
|
-
'<tr><td>5</td><td>6</td></tr>' +
|
|
1294
|
-
'</table>';
|
|
1295
|
-
|
|
1296
|
-
let td = editor.editor
|
|
1297
|
-
.querySelector('.test')
|
|
1298
|
-
.querySelector('td'),
|
|
1299
|
-
pos = Jodit.modules.Helpers.position(td);
|
|
1300
|
-
simulateEvent('mousedown', 0, td, e => {
|
|
1301
|
-
Object.assign(e, {
|
|
1302
|
-
clientX: pos.left,
|
|
1303
|
-
clientY: pos.top
|
|
1304
|
-
});
|
|
1305
|
-
});
|
|
1306
|
-
|
|
1307
|
-
td = editor.editor
|
|
1308
|
-
.querySelector('.test')
|
|
1309
|
-
.querySelectorAll('td')[3];
|
|
1310
|
-
pos = Jodit.modules.Helpers.position(td);
|
|
1311
|
-
|
|
1312
|
-
simulateEvent(['mousemove', 'mouseup', 'click'], td);
|
|
1313
|
-
|
|
1314
|
-
expect(
|
|
1315
|
-
editor.getInstance('Table', editor.o).selected.size
|
|
1316
|
-
).equals(4);
|
|
1317
|
-
});
|
|
1318
|
-
});
|
|
1319
|
-
|
|
1320
|
-
it('When we press mouse button over cell and move mouse to another cell, it should select all cells in bound even if between be colspan and rowspan', function () {
|
|
1321
|
-
const editor = getJodit();
|
|
1322
|
-
|
|
1323
|
-
editor.value =
|
|
1324
|
-
'<table style="width: 100%;">' +
|
|
1325
|
-
'<tbody>' +
|
|
1326
|
-
'<tr><td colspan="3">0,0<br>0,1<br>0,2<br></td><td>0,3</td></tr>' +
|
|
1327
|
-
'<tr><td rowspan="3">1,0<br>2,0<br>3,0<br></td><td>1,1</td><td>1,2</td><td>1,3</td></tr>' +
|
|
1328
|
-
'<tr><td>2,1</td><td>2,2</td><td>2,3</td></tr>' +
|
|
1329
|
-
'<tr><td>3,1</td><td>3,2</td><td>3,3</td></tr>' +
|
|
1330
|
-
'</tbody>' +
|
|
1331
|
-
'</table>';
|
|
1332
|
-
|
|
1333
|
-
editor.editor.scrollIntoView();
|
|
1334
|
-
|
|
1335
|
-
let td = editor.editor.querySelector('td');
|
|
1336
|
-
|
|
1337
|
-
simulateEvent('mousedown', td);
|
|
1338
|
-
|
|
1339
|
-
td = editor.editor.querySelectorAll('td')[7];
|
|
1340
|
-
simulateEvent(['mousemove', 'mouseup', 'click'], td);
|
|
1341
|
-
|
|
1342
|
-
expect(
|
|
1343
|
-
editor.getInstance('Table', editor.o).selected.size
|
|
1344
|
-
).equals(8);
|
|
1345
|
-
});
|
|
1346
|
-
});
|
|
1347
|
-
|
|
1348
|
-
describe('Resize column', function () {
|
|
1349
|
-
describe('Move mouse over edge of cell', function () {
|
|
1350
|
-
before(function () {
|
|
1351
|
-
const brs = [];
|
|
1352
|
-
for (let i = 0; i < 100; i += 1) {
|
|
1353
|
-
brs.push(document.createElement('br'));
|
|
1354
|
-
brs[brs.length - 1].classList.add('test');
|
|
1355
|
-
document.body.appendChild(brs[brs.length - 1]);
|
|
1356
|
-
}
|
|
1357
|
-
});
|
|
1358
|
-
|
|
1359
|
-
describe('Normal scroll', function () {
|
|
1360
|
-
it("should show element's resizer", function (done) {
|
|
1361
|
-
const editor = getJodit();
|
|
1362
|
-
window.scrollTo(
|
|
1363
|
-
0,
|
|
1364
|
-
Jodit.modules.Helpers.offset(
|
|
1365
|
-
editor.container,
|
|
1366
|
-
editor,
|
|
1367
|
-
editor.ownerDocument
|
|
1368
|
-
).top + 50
|
|
1369
|
-
);
|
|
1370
|
-
|
|
1371
|
-
editor.value =
|
|
1372
|
-
'<table>' +
|
|
1373
|
-
'<tr><td>1</td><td>2</td></tr>' +
|
|
1374
|
-
'</table><p>3</p>';
|
|
1375
|
-
|
|
1376
|
-
const box = Jodit.modules.Helpers.offset(
|
|
1377
|
-
editor.editor.querySelectorAll('td')[1],
|
|
1378
|
-
editor,
|
|
1379
|
-
editor.ed
|
|
1380
|
-
);
|
|
1381
|
-
|
|
1382
|
-
const tablebox = Jodit.modules.Helpers.offset(
|
|
1383
|
-
editor.editor.querySelector('table'),
|
|
1384
|
-
editor,
|
|
1385
|
-
editor.ed
|
|
1386
|
-
);
|
|
1387
|
-
|
|
1388
|
-
simulateEvent(
|
|
1389
|
-
'mousemove',
|
|
1390
|
-
1,
|
|
1391
|
-
editor.editor.getElementsByTagName('td')[1],
|
|
1392
|
-
function (options) {
|
|
1393
|
-
options.offsetX = 3;
|
|
1394
|
-
}
|
|
1395
|
-
);
|
|
1396
|
-
|
|
1397
|
-
const resizer = editor.container.querySelector(
|
|
1398
|
-
'.jodit-table-resizer'
|
|
1399
|
-
);
|
|
1400
|
-
expect(resizer).is.not.null;
|
|
1401
|
-
|
|
1402
|
-
const resizerBox = Jodit.modules.Helpers.offset(
|
|
1403
|
-
resizer,
|
|
1404
|
-
editor,
|
|
1405
|
-
editor.ownerDocument
|
|
1406
|
-
);
|
|
1407
|
-
|
|
1408
|
-
expect(Math.abs(resizerBox.left - box.left) < 10).is
|
|
1409
|
-
.true;
|
|
1410
|
-
|
|
1411
|
-
expect(Math.abs(resizerBox.top - tablebox.top) < 10).is
|
|
1412
|
-
.true;
|
|
1413
|
-
|
|
1414
|
-
simulateEvent(
|
|
1415
|
-
'mouseleave',
|
|
1416
|
-
1,
|
|
1417
|
-
editor.editor.querySelector('table'),
|
|
1418
|
-
function (options) {
|
|
1419
|
-
options.relatedTarget =
|
|
1420
|
-
editor.editor.querySelector('p');
|
|
1421
|
-
}
|
|
1422
|
-
);
|
|
1423
|
-
simulateEvent(
|
|
1424
|
-
'mousemove',
|
|
1425
|
-
1,
|
|
1426
|
-
editor.editor.querySelector('p')
|
|
1427
|
-
);
|
|
1428
|
-
|
|
1429
|
-
expect(resizer.parentNode).is.null;
|
|
1430
|
-
|
|
1431
|
-
done();
|
|
1432
|
-
});
|
|
1433
|
-
});
|
|
1434
|
-
|
|
1435
|
-
after(function () {
|
|
1436
|
-
[].slice
|
|
1437
|
-
.call(document.querySelectorAll('br.test'))
|
|
1438
|
-
.forEach(function (br) {
|
|
1439
|
-
br.parentNode && br.parentNode.removeChild(br);
|
|
1440
|
-
});
|
|
1441
|
-
});
|
|
1442
|
-
});
|
|
1443
|
-
|
|
1444
|
-
it('When move mouse over left edge of cell and press mouse button and move cursor to right in 500 pixels - resizer should be nearby next edge', function (done) {
|
|
1445
|
-
const editor = getJodit();
|
|
1446
|
-
|
|
1447
|
-
editor.value =
|
|
1448
|
-
'<table style="width: 100px; border-collapse: separate;" cellspacing="0">' +
|
|
1449
|
-
'<tr><td>1</td><td>2</td><td>3</td><td>4</td><td>5</td></tr>' +
|
|
1450
|
-
'</table>';
|
|
1451
|
-
|
|
1452
|
-
editor.editor.scrollIntoView();
|
|
1453
|
-
|
|
1454
|
-
const td = editor.editor.querySelectorAll('td')[1],
|
|
1455
|
-
box = td.getBoundingClientRect();
|
|
1456
|
-
|
|
1457
|
-
simulateEvent('mousemove', td, function (options) {
|
|
1458
|
-
options.clientX = box.left;
|
|
1459
|
-
options.offsetX = 0;
|
|
1460
|
-
options.pageX = 0;
|
|
1461
|
-
options.pageY = 0;
|
|
1462
|
-
});
|
|
1463
|
-
|
|
1464
|
-
simulateEvent(
|
|
1465
|
-
'mousedown',
|
|
1466
|
-
editor.container.querySelector('.jodit-table-resizer'),
|
|
1467
|
-
function (options) {
|
|
1468
|
-
options.clientX = box.left;
|
|
1469
|
-
options.pageX = 0;
|
|
1470
|
-
options.pageY = 0;
|
|
1471
|
-
}
|
|
1472
|
-
);
|
|
1473
|
-
|
|
1474
|
-
simulateEvent('mousemove', editor.ew, function (options) {
|
|
1475
|
-
options.clientX = box.left + 500; // can move only on 5 pixels
|
|
1476
|
-
options.pageX = 0;
|
|
1477
|
-
options.pageY = 0;
|
|
1478
|
-
});
|
|
1479
|
-
|
|
1480
|
-
expect(
|
|
1481
|
-
parseInt(
|
|
1482
|
-
editor.container.querySelector('.jodit-table-resizer')
|
|
1483
|
-
.style.left,
|
|
1484
|
-
10
|
|
1485
|
-
) < 55
|
|
1486
|
-
).is.true;
|
|
1487
|
-
|
|
1488
|
-
done();
|
|
1489
|
-
});
|
|
1490
|
-
|
|
1491
|
-
describe('When move mouse over left edge of cell and press mouse button and move cursor to right in 5 pixels', function () {
|
|
1492
|
-
it('should decrease the width of the right column and the width of the left column should increase', function (done) {
|
|
1493
|
-
const editor = getJodit();
|
|
1494
|
-
|
|
1495
|
-
editor.value =
|
|
1496
|
-
'<table style="width: 100px; border-collapse: separate;" cellspacing="0">' +
|
|
1497
|
-
'<tr><td>1</td><td>2</td><td>3</td><td>4</td></tr>' +
|
|
1498
|
-
'</table>';
|
|
1499
|
-
|
|
1500
|
-
const td = editor.editor.querySelectorAll('td')[1],
|
|
1501
|
-
box = td.getBoundingClientRect();
|
|
1502
|
-
|
|
1503
|
-
simulateEvent('mousemove', 1, td, function (options) {
|
|
1504
|
-
options.clientX = box.left;
|
|
1505
|
-
options.offsetX = 0;
|
|
1506
|
-
options.pageX = 0;
|
|
1507
|
-
options.pageY = 0;
|
|
1508
|
-
});
|
|
1509
|
-
|
|
1510
|
-
simulateEvent(
|
|
1511
|
-
'mousedown',
|
|
1512
|
-
1,
|
|
1513
|
-
editor.container.querySelector('.jodit-table-resizer'),
|
|
1514
|
-
function (options) {
|
|
1515
|
-
options.clientX = box.left;
|
|
1516
|
-
options.pageX = 0;
|
|
1517
|
-
options.pageY = 0;
|
|
1518
|
-
}
|
|
1519
|
-
);
|
|
1520
|
-
|
|
1521
|
-
simulateEvent(
|
|
1522
|
-
'mousemove',
|
|
1523
|
-
1,
|
|
1524
|
-
editor.ew,
|
|
1525
|
-
function (options) {
|
|
1526
|
-
options.clientX = box.left + 5; // move on 5 pixels
|
|
1527
|
-
options.pageX = 0;
|
|
1528
|
-
options.pageY = 0;
|
|
1529
|
-
}
|
|
1530
|
-
);
|
|
1531
|
-
simulateEvent('mouseup', 1, window, function (options) {
|
|
1532
|
-
options.clientX = box.left + 5; // move on 5 pixels
|
|
1533
|
-
options.pageX = 0;
|
|
1534
|
-
options.pageY = 0;
|
|
1535
|
-
});
|
|
1536
|
-
|
|
1537
|
-
expect(editor.editor.innerHTML.toLowerCase()).equals(
|
|
1538
|
-
'<table style="width: 100px; border-collapse: separate;" cellspacing="0"><tbody>' +
|
|
1539
|
-
'<tr>' +
|
|
1540
|
-
'<td style="width: 30%;">1</td>' +
|
|
1541
|
-
'<td style="width: 20%;">2</td>' +
|
|
1542
|
-
'<td>3</td>' +
|
|
1543
|
-
'<td>4</td>' +
|
|
1544
|
-
'</tr>' +
|
|
1545
|
-
'</tbody></table>'
|
|
1546
|
-
);
|
|
1547
|
-
done();
|
|
1548
|
-
});
|
|
1549
|
-
|
|
1550
|
-
describe('After resize', function () {
|
|
1551
|
-
it('it should restore selection', function (done) {
|
|
1552
|
-
const editor = getJodit();
|
|
1553
|
-
|
|
1554
|
-
editor.value =
|
|
1555
|
-
'<p>test</p><table style="width: 100px; border-collapse: separate;" cellspacing="0">' +
|
|
1556
|
-
'<tr><td>1</td><td>2</td><td>3</td><td>4</td></tr>' +
|
|
1557
|
-
'</table>';
|
|
1558
|
-
|
|
1559
|
-
const td = editor.editor.querySelectorAll('td')[1],
|
|
1560
|
-
box = td.getBoundingClientRect();
|
|
1561
|
-
|
|
1562
|
-
editor.s.setCursorIn(editor.editor.firstChild);
|
|
1563
|
-
|
|
1564
|
-
simulateEvent('mousemove', 1, td, function (options) {
|
|
1565
|
-
options.clientX = box.left;
|
|
1566
|
-
options.offsetX = 0;
|
|
1567
|
-
options.pageX = 0;
|
|
1568
|
-
options.pageY = 0;
|
|
1569
|
-
});
|
|
1570
|
-
|
|
1571
|
-
simulateEvent(
|
|
1572
|
-
'mousedown',
|
|
1573
|
-
1,
|
|
1574
|
-
editor.container.querySelector(
|
|
1575
|
-
'.jodit-table-resizer'
|
|
1576
|
-
),
|
|
1577
|
-
function (options) {
|
|
1578
|
-
options.clientX = box.left;
|
|
1579
|
-
options.pageX = 0;
|
|
1580
|
-
options.pageY = 0;
|
|
1581
|
-
}
|
|
1582
|
-
);
|
|
1583
|
-
|
|
1584
|
-
simulateEvent(
|
|
1585
|
-
'mousemove',
|
|
1586
|
-
1,
|
|
1587
|
-
editor.ew,
|
|
1588
|
-
function (options) {
|
|
1589
|
-
options.clientX = box.left + 5; // move on 5 pixels
|
|
1590
|
-
options.pageX = 0;
|
|
1591
|
-
options.pageY = 0;
|
|
1592
|
-
}
|
|
1593
|
-
);
|
|
1594
|
-
simulateEvent(
|
|
1595
|
-
'mouseup',
|
|
1596
|
-
1,
|
|
1597
|
-
editor.ownerWindow,
|
|
1598
|
-
function (options) {
|
|
1599
|
-
options.clientX = box.left + 5; // move on 5 pixels
|
|
1600
|
-
options.pageX = 0;
|
|
1601
|
-
options.pageY = 0;
|
|
1602
|
-
}
|
|
1603
|
-
);
|
|
1604
|
-
|
|
1605
|
-
editor.s.insertHTML('stop');
|
|
1606
|
-
|
|
1607
|
-
expect(sortAttributes(editor.value)).equals(
|
|
1608
|
-
'<p>teststop</p>' +
|
|
1609
|
-
'<table cellspacing="0" style="border-collapse:separate;width:100px">' +
|
|
1610
|
-
'<tbody>' +
|
|
1611
|
-
'<tr>' +
|
|
1612
|
-
'<td style="width:30%">1</td>' +
|
|
1613
|
-
'<td style="width:20%">2</td>' +
|
|
1614
|
-
'<td>3</td>' +
|
|
1615
|
-
'<td>4</td>' +
|
|
1616
|
-
'</tr>' +
|
|
1617
|
-
'</tbody>' +
|
|
1618
|
-
'</table>'
|
|
1619
|
-
);
|
|
1620
|
-
|
|
1621
|
-
done();
|
|
1622
|
-
});
|
|
1623
|
-
});
|
|
1624
|
-
|
|
1625
|
-
describe('For RTL direction', function () {
|
|
1626
|
-
it('should decrease the width of the left column and the width of the right column should increase', function (done) {
|
|
1627
|
-
const editor = getJodit({
|
|
1628
|
-
direction: 'rtl'
|
|
1629
|
-
});
|
|
1630
|
-
|
|
1631
|
-
editor.value =
|
|
1632
|
-
'<table style="width: 100px; border-collapse: separate;" cellspacing="0">' +
|
|
1633
|
-
'<tr><td>1</td><td>2</td><td>3</td><td>4</td></tr>' +
|
|
1634
|
-
'</table>';
|
|
1635
|
-
|
|
1636
|
-
const td = editor.editor.querySelectorAll('td')[1],
|
|
1637
|
-
box = td.getBoundingClientRect();
|
|
1638
|
-
|
|
1639
|
-
simulateEvent('mousemove', 1, td, function (options) {
|
|
1640
|
-
options.clientX = box.left;
|
|
1641
|
-
options.offsetX = 0;
|
|
1642
|
-
options.pageX = 0;
|
|
1643
|
-
options.pageY = 0;
|
|
1644
|
-
});
|
|
1645
|
-
|
|
1646
|
-
simulateEvent(
|
|
1647
|
-
'mousedown',
|
|
1648
|
-
1,
|
|
1649
|
-
editor.container.querySelector(
|
|
1650
|
-
'.jodit-table-resizer'
|
|
1651
|
-
),
|
|
1652
|
-
function (options) {
|
|
1653
|
-
options.clientX = box.left;
|
|
1654
|
-
options.pageX = 0;
|
|
1655
|
-
options.pageY = 0;
|
|
1656
|
-
}
|
|
1657
|
-
);
|
|
1658
|
-
|
|
1659
|
-
simulateEvent(
|
|
1660
|
-
'mousemove',
|
|
1661
|
-
1,
|
|
1662
|
-
editor.ew,
|
|
1663
|
-
function (options) {
|
|
1664
|
-
options.clientX = box.left + 5; // move on 5 pixels
|
|
1665
|
-
options.pageX = 0;
|
|
1666
|
-
options.pageY = 0;
|
|
1667
|
-
}
|
|
1668
|
-
);
|
|
1669
|
-
|
|
1670
|
-
simulateEvent(
|
|
1671
|
-
'mouseup',
|
|
1672
|
-
1,
|
|
1673
|
-
editor.ownerWindow,
|
|
1674
|
-
function (options) {
|
|
1675
|
-
options.clientX = box.left + 5; // move on 5 pixels
|
|
1676
|
-
options.pageX = 0;
|
|
1677
|
-
options.pageY = 0;
|
|
1678
|
-
}
|
|
1679
|
-
);
|
|
1680
|
-
|
|
1681
|
-
expect(editor.editor.innerHTML.toLowerCase()).equals(
|
|
1682
|
-
'<table style="width: 100px; border-collapse: separate;" cellspacing="0"><tbody>' +
|
|
1683
|
-
'<tr>' +
|
|
1684
|
-
'<td>1</td>' +
|
|
1685
|
-
'<td style="width: 20%;">2</td>' +
|
|
1686
|
-
'<td style="width: 30%;">3</td>' +
|
|
1687
|
-
'<td>4</td>' +
|
|
1688
|
-
'</tr>' +
|
|
1689
|
-
'</tbody></table>'
|
|
1690
|
-
);
|
|
1691
|
-
|
|
1692
|
-
done();
|
|
1693
|
-
});
|
|
1694
|
-
|
|
1695
|
-
describe('After resize', function () {
|
|
1696
|
-
it('it should restore selection', function (done) {
|
|
1697
|
-
const editor = getJodit({
|
|
1698
|
-
direction: 'rtl'
|
|
1699
|
-
});
|
|
1700
|
-
|
|
1701
|
-
editor.value =
|
|
1702
|
-
'<p>test</p><table style="width: 100px; border-collapse: separate;" cellspacing="0">' +
|
|
1703
|
-
'<tr><td>1</td><td>2</td><td>3</td><td>4</td></tr>' +
|
|
1704
|
-
'</table>';
|
|
1705
|
-
|
|
1706
|
-
const td = editor.editor.querySelectorAll('td')[1],
|
|
1707
|
-
box = td.getBoundingClientRect();
|
|
1708
|
-
|
|
1709
|
-
editor.s.setCursorIn(editor.editor.firstChild);
|
|
1710
|
-
|
|
1711
|
-
simulateEvent(
|
|
1712
|
-
'mousemove',
|
|
1713
|
-
1,
|
|
1714
|
-
td,
|
|
1715
|
-
function (options) {
|
|
1716
|
-
options.clientX = box.left;
|
|
1717
|
-
options.offsetX = 0;
|
|
1718
|
-
options.pageX = 0;
|
|
1719
|
-
options.pageY = 0;
|
|
1720
|
-
}
|
|
1721
|
-
);
|
|
1722
|
-
|
|
1723
|
-
simulateEvent(
|
|
1724
|
-
'mousedown',
|
|
1725
|
-
1,
|
|
1726
|
-
editor.container.querySelector(
|
|
1727
|
-
'.jodit-table-resizer'
|
|
1728
|
-
),
|
|
1729
|
-
function (options) {
|
|
1730
|
-
options.clientX = box.left;
|
|
1731
|
-
options.pageX = 0;
|
|
1732
|
-
options.pageY = 0;
|
|
1733
|
-
}
|
|
1734
|
-
);
|
|
1735
|
-
|
|
1736
|
-
simulateEvent(
|
|
1737
|
-
'mousemove',
|
|
1738
|
-
1,
|
|
1739
|
-
editor.ew,
|
|
1740
|
-
function (options) {
|
|
1741
|
-
options.clientX = box.left + 5; // move on 5 pixels
|
|
1742
|
-
options.pageX = 0;
|
|
1743
|
-
options.pageY = 0;
|
|
1744
|
-
}
|
|
1745
|
-
);
|
|
1746
|
-
|
|
1747
|
-
simulateEvent(
|
|
1748
|
-
'mouseup',
|
|
1749
|
-
1,
|
|
1750
|
-
editor.ownerWindow,
|
|
1751
|
-
function (options) {
|
|
1752
|
-
options.clientX = box.left + 5; // move on 5 pixels
|
|
1753
|
-
options.pageX = 0;
|
|
1754
|
-
options.pageY = 0;
|
|
1755
|
-
}
|
|
1756
|
-
);
|
|
1757
|
-
|
|
1758
|
-
editor.s.insertHTML('stop');
|
|
1759
|
-
|
|
1760
|
-
expect(sortAttributes(editor.value)).equals(
|
|
1761
|
-
'<p>teststop</p>' +
|
|
1762
|
-
'<table cellspacing="0" style="border-collapse:separate;width:100px">' +
|
|
1763
|
-
'<tbody>' +
|
|
1764
|
-
'<tr>' +
|
|
1765
|
-
'<td>1</td>' +
|
|
1766
|
-
'<td style="width:20%">2</td>' +
|
|
1767
|
-
'<td style="width:30%">3</td>' +
|
|
1768
|
-
'<td>4</td>' +
|
|
1769
|
-
'</tr>' +
|
|
1770
|
-
'</tbody>' +
|
|
1771
|
-
'</table>'
|
|
1772
|
-
);
|
|
1773
|
-
|
|
1774
|
-
done();
|
|
1775
|
-
});
|
|
1776
|
-
});
|
|
1777
|
-
});
|
|
1778
|
-
});
|
|
1779
|
-
|
|
1780
|
-
it('When move mouse over right edge of last cell and press mouse button and move cursor to right in 50 pixels - the width of the whole table should increase', function () {
|
|
1781
|
-
const editor = getJodit();
|
|
1782
|
-
|
|
1783
|
-
getBox().style.width = '202px';
|
|
1784
|
-
|
|
1785
|
-
editor.value =
|
|
1786
|
-
'<table style="width: 100px; border-collapse: separate;" cellspacing="0">' +
|
|
1787
|
-
'<tr><td>1</td><td>2</td><td>3</td><td>5</td></tr>' +
|
|
1788
|
-
'</table>';
|
|
1789
|
-
const td = editor.editor.querySelectorAll('td')[3],
|
|
1790
|
-
box = td.getBoundingClientRect();
|
|
1791
|
-
|
|
1792
|
-
simulateEvent('mousemove', 1, td, function (options) {
|
|
1793
|
-
options.clientX = box.left + box.width;
|
|
1794
|
-
options.offsetX = box.width;
|
|
1795
|
-
});
|
|
1796
|
-
|
|
1797
|
-
simulateEvent(
|
|
1798
|
-
'mousedown',
|
|
1799
|
-
1,
|
|
1800
|
-
editor.container.querySelector('.jodit-table-resizer'),
|
|
1801
|
-
function (options) {
|
|
1802
|
-
options.clientX = box.left + box.width;
|
|
1803
|
-
}
|
|
1804
|
-
);
|
|
1805
|
-
|
|
1806
|
-
simulateEvent('mousemove', 1, window, function (options) {
|
|
1807
|
-
options.clientX = box.left + box.width + 50;
|
|
1808
|
-
});
|
|
1809
|
-
simulateEvent('mouseup', 1, window, function (options) {
|
|
1810
|
-
options.clientX = box.left + box.width + 50;
|
|
1811
|
-
});
|
|
1812
|
-
|
|
1813
|
-
expect(
|
|
1814
|
-
sortAttributes(editor.editor.innerHTML.toLowerCase())
|
|
1815
|
-
).equals(
|
|
1816
|
-
'<table cellspacing="0" style="border-collapse:separate;width:81.52%"><tbody>' +
|
|
1817
|
-
'<tr>' +
|
|
1818
|
-
'<td>1</td>' +
|
|
1819
|
-
'<td>2</td>' +
|
|
1820
|
-
'<td>3</td>' +
|
|
1821
|
-
'<td>5</td>' +
|
|
1822
|
-
'</tr>' +
|
|
1823
|
-
'</tbody></table>'
|
|
1824
|
-
);
|
|
1825
|
-
});
|
|
1826
|
-
|
|
1827
|
-
describe('When move mouse over left edge of first cell', function () {
|
|
1828
|
-
describe('press mouse button and move cursor to left in 50 pixels', function () {
|
|
1829
|
-
it('should increase the width of the whole table', function () {
|
|
1830
|
-
const editor = getJodit();
|
|
1831
|
-
|
|
1832
|
-
getBox().style.width = '202px';
|
|
1833
|
-
|
|
1834
|
-
editor.value =
|
|
1835
|
-
'<table style="width: 100px">' +
|
|
1836
|
-
'<tr><td>1</td><td>2</td><td>3</td><td>4</td></tr>' +
|
|
1837
|
-
'</table>';
|
|
1838
|
-
|
|
1839
|
-
const td = editor.editor.querySelectorAll('td')[0],
|
|
1840
|
-
box = td.getBoundingClientRect();
|
|
1841
|
-
|
|
1842
|
-
simulateEvent('mousemove', 1, td, function (options) {
|
|
1843
|
-
options.clientX = box.left;
|
|
1844
|
-
options.offsetX = 0;
|
|
1845
|
-
});
|
|
1846
|
-
|
|
1847
|
-
simulateEvent(
|
|
1848
|
-
'mousedown',
|
|
1849
|
-
1,
|
|
1850
|
-
editor.container.querySelector(
|
|
1851
|
-
'.jodit-table-resizer'
|
|
1852
|
-
),
|
|
1853
|
-
function (options) {
|
|
1854
|
-
options.clientX = box.left;
|
|
1855
|
-
}
|
|
1856
|
-
);
|
|
1857
|
-
|
|
1858
|
-
simulateEvent(
|
|
1859
|
-
'mousemove',
|
|
1860
|
-
1,
|
|
1861
|
-
window,
|
|
1862
|
-
function (options) {
|
|
1863
|
-
options.clientX = box.left + 50;
|
|
1864
|
-
}
|
|
1865
|
-
);
|
|
1866
|
-
simulateEvent('mouseup', 1, window, function (options) {
|
|
1867
|
-
options.clientX = box.left + 50;
|
|
1868
|
-
});
|
|
1869
|
-
|
|
1870
|
-
expect(
|
|
1871
|
-
sortAttributes(
|
|
1872
|
-
editor.editor.innerHTML.toLowerCase()
|
|
1873
|
-
)
|
|
1874
|
-
).equals(
|
|
1875
|
-
'<table style="margin-left:27.17%;width:27.17%">' +
|
|
1876
|
-
'<tbody>' +
|
|
1877
|
-
'<tr>' +
|
|
1878
|
-
'<td>1</td>' +
|
|
1879
|
-
'<td>2</td>' +
|
|
1880
|
-
'<td>3</td>' +
|
|
1881
|
-
'<td>4</td>' +
|
|
1882
|
-
'</tr>' +
|
|
1883
|
-
'</tbody>' +
|
|
1884
|
-
'</table>'
|
|
1885
|
-
);
|
|
1886
|
-
});
|
|
1887
|
-
});
|
|
1888
|
-
|
|
1889
|
-
describe('press mouse button and do not move cursor after', function () {
|
|
1890
|
-
it("should not change any cell's width", function () {
|
|
1891
|
-
const editor = getJodit();
|
|
1892
|
-
|
|
1893
|
-
getBox().style.width = '202px';
|
|
1894
|
-
|
|
1895
|
-
const initital =
|
|
1896
|
-
'<table style="width:100px"><tbody>' +
|
|
1897
|
-
'<tr><td>1</td><td>2</td><td>3</td><td>4</td></tr>' +
|
|
1898
|
-
'</tbody></table>';
|
|
1899
|
-
|
|
1900
|
-
editor.value = initital;
|
|
1901
|
-
|
|
1902
|
-
const td = editor.editor.querySelectorAll('td')[0],
|
|
1903
|
-
box = td.getBoundingClientRect();
|
|
1904
|
-
|
|
1905
|
-
simulateEvent('mousemove', td, function (options) {
|
|
1906
|
-
options.clientX = box.left;
|
|
1907
|
-
options.offsetX = 0;
|
|
1908
|
-
});
|
|
1909
|
-
|
|
1910
|
-
simulateEvent(
|
|
1911
|
-
'mousedown',
|
|
1912
|
-
editor.container.querySelector(
|
|
1913
|
-
'.jodit-table-resizer'
|
|
1914
|
-
),
|
|
1915
|
-
function (options) {
|
|
1916
|
-
options.clientX = box.left;
|
|
1917
|
-
}
|
|
1918
|
-
);
|
|
1919
|
-
|
|
1920
|
-
simulateEvent('mouseup', window, function (options) {
|
|
1921
|
-
options.clientX = box.left;
|
|
1922
|
-
});
|
|
1923
|
-
|
|
1924
|
-
expect(sortAttributes(editor.value)).equals(initital);
|
|
1925
|
-
});
|
|
1926
|
-
});
|
|
1927
|
-
});
|
|
1928
|
-
});
|
|
1929
|
-
|
|
1930
|
-
describe('Resize table', function () {
|
|
1931
|
-
describe('Image in cell', function () {
|
|
1932
|
-
describe('Mouse down on the Image', function () {
|
|
1933
|
-
it('should show resizer for this image', function () {
|
|
1934
|
-
const area = document.createElement('textarea');
|
|
1935
|
-
area.setAttribute(
|
|
1936
|
-
'id',
|
|
1937
|
-
'should_show_resizer_for_this_image'
|
|
1938
|
-
);
|
|
1939
|
-
document.body.appendChild(area);
|
|
1940
|
-
const editor = new Jodit(area);
|
|
1941
|
-
|
|
1942
|
-
editor.value =
|
|
1943
|
-
'<table>' +
|
|
1944
|
-
'<tr>' +
|
|
1945
|
-
'<td>1</td>' +
|
|
1946
|
-
'<td>2</td>' +
|
|
1947
|
-
'<td>3</td>' +
|
|
1948
|
-
'<td>4</td>' +
|
|
1949
|
-
'<td>5</td>' +
|
|
1950
|
-
'<td>6</td>' +
|
|
1951
|
-
'<td>7</td>' +
|
|
1952
|
-
'<td><img style="width:30px" src="tests/artio.jpg"></td>' +
|
|
1953
|
-
'</tr>' +
|
|
1954
|
-
'</table>';
|
|
1955
|
-
|
|
1956
|
-
simulateEvent(
|
|
1957
|
-
'click',
|
|
1958
|
-
1,
|
|
1959
|
-
editor.editor.querySelector('img')
|
|
1960
|
-
);
|
|
1961
|
-
|
|
1962
|
-
const resizer = editor.ownerDocument.querySelector(
|
|
1963
|
-
'.jodit-resizer[data-editor_id=should_show_resizer_for_this_image]'
|
|
1964
|
-
);
|
|
1965
|
-
|
|
1966
|
-
expect(resizer).is.not.null;
|
|
1967
|
-
|
|
1968
|
-
const positionResizer = offset(resizer);
|
|
1969
|
-
const positionImg = offset(
|
|
1970
|
-
editor.editor.querySelector('img')
|
|
1971
|
-
);
|
|
1972
|
-
|
|
1973
|
-
expect(
|
|
1974
|
-
Math.abs(positionResizer.left - positionImg.left) <
|
|
1975
|
-
10
|
|
1976
|
-
).is.true;
|
|
1977
|
-
|
|
1978
|
-
expect(
|
|
1979
|
-
Math.abs(positionResizer.top - positionImg.top) < 10
|
|
1980
|
-
).is.true;
|
|
1981
|
-
|
|
1982
|
-
document.body.removeChild(area);
|
|
1983
|
-
});
|
|
1984
|
-
});
|
|
1985
|
-
});
|
|
1986
|
-
});
|
|
1987
|
-
});
|
|
1988
|
-
});
|