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,623 +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('Search plugin', function () {
|
|
7
|
-
const search = Jodit.plugins.get('search');
|
|
8
|
-
|
|
9
|
-
describe('Disable option', function () {
|
|
10
|
-
it('Should not init plugin', function () {
|
|
11
|
-
const editor = getJodit({
|
|
12
|
-
useSearch: false,
|
|
13
|
-
observer: {
|
|
14
|
-
timeout: 0
|
|
15
|
-
}
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
expect(editor.container.querySelector('.jodit-search')).is.null;
|
|
19
|
-
|
|
20
|
-
simulateEvent('keydown', 'f', editor.editor, function (options) {
|
|
21
|
-
options.ctrlKey = true;
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
expect(editor.container.querySelector('.jodit-search')).is.null;
|
|
25
|
-
});
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
describe('CTRL + F', function () {
|
|
29
|
-
it('Should show search form and query field must have focus', function () {
|
|
30
|
-
const editor = getJodit({
|
|
31
|
-
observer: {
|
|
32
|
-
timeout: 0
|
|
33
|
-
}
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
const search = editor.container.querySelector('.jodit-search');
|
|
37
|
-
|
|
38
|
-
expect(false).equals(
|
|
39
|
-
search.classList.contains('jodit-search_active')
|
|
40
|
-
);
|
|
41
|
-
|
|
42
|
-
simulateEvent('keydown', 'f', editor.editor, function (options) {
|
|
43
|
-
options.ctrlKey = true;
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
expect(true).equals(
|
|
47
|
-
search.classList.contains('jodit-search_active')
|
|
48
|
-
);
|
|
49
|
-
|
|
50
|
-
expect(true).equals(
|
|
51
|
-
editor.ownerDocument.activeElement ===
|
|
52
|
-
search.querySelector('[data-ref="query"]')
|
|
53
|
-
);
|
|
54
|
-
});
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
describe('CTRL + H', function () {
|
|
58
|
-
it('Should show search and replace form and query field must have focus', function () {
|
|
59
|
-
const editor = getJodit({
|
|
60
|
-
observer: {
|
|
61
|
-
timeout: 0
|
|
62
|
-
}
|
|
63
|
-
});
|
|
64
|
-
|
|
65
|
-
const search = editor.container.querySelector('.jodit-search');
|
|
66
|
-
expect(false).equals(
|
|
67
|
-
search.classList.contains('jodit-search_active')
|
|
68
|
-
);
|
|
69
|
-
|
|
70
|
-
simulateEvent('keydown', 'h', editor.editor, function (options) {
|
|
71
|
-
options.ctrlKey = true;
|
|
72
|
-
});
|
|
73
|
-
|
|
74
|
-
expect(true).equals(
|
|
75
|
-
search.classList.contains('jodit-search_active')
|
|
76
|
-
);
|
|
77
|
-
|
|
78
|
-
expect(true).equals(
|
|
79
|
-
search.classList.contains('jodit-search_replace')
|
|
80
|
-
);
|
|
81
|
-
|
|
82
|
-
expect(true).equals(
|
|
83
|
-
editor.ownerDocument.activeElement ===
|
|
84
|
-
search.querySelector('[data-ref="query"]')
|
|
85
|
-
);
|
|
86
|
-
});
|
|
87
|
-
|
|
88
|
-
describe('Press Replace button', function () {
|
|
89
|
-
it('Should replace value form query field to value from replace field in editor', function () {
|
|
90
|
-
const editor = getJodit({
|
|
91
|
-
observer: {
|
|
92
|
-
timeout: 0
|
|
93
|
-
}
|
|
94
|
-
});
|
|
95
|
-
|
|
96
|
-
editor.value = 'test test test';
|
|
97
|
-
|
|
98
|
-
const search = editor.container.querySelector('.jodit-search');
|
|
99
|
-
expect(false).equals(
|
|
100
|
-
search.classList.contains('jodit-search_active')
|
|
101
|
-
);
|
|
102
|
-
simulateEvent(
|
|
103
|
-
'keydown',
|
|
104
|
-
'h',
|
|
105
|
-
editor.editor,
|
|
106
|
-
function (options) {
|
|
107
|
-
options.ctrlKey = true;
|
|
108
|
-
}
|
|
109
|
-
);
|
|
110
|
-
|
|
111
|
-
expect(true).equals(
|
|
112
|
-
search.classList.contains('jodit-search_active')
|
|
113
|
-
);
|
|
114
|
-
|
|
115
|
-
expect(true).equals(
|
|
116
|
-
search.classList.contains('jodit-search_replace')
|
|
117
|
-
);
|
|
118
|
-
|
|
119
|
-
expect(true).equals(
|
|
120
|
-
editor.ownerDocument.activeElement ===
|
|
121
|
-
search.querySelector('[data-ref="query"]')
|
|
122
|
-
);
|
|
123
|
-
|
|
124
|
-
const query = search.querySelector('[data-ref="query"]');
|
|
125
|
-
const replace = search.querySelector('[data-ref="replace"]');
|
|
126
|
-
const replaceButton = search.querySelector(
|
|
127
|
-
'[data-ref="replace-btn"]'
|
|
128
|
-
);
|
|
129
|
-
|
|
130
|
-
query.value = 't';
|
|
131
|
-
replace.value = 'w';
|
|
132
|
-
|
|
133
|
-
simulateEvent('click', 0, replaceButton);
|
|
134
|
-
simulateEvent('click', 0, replaceButton);
|
|
135
|
-
simulateEvent('click', 0, replaceButton);
|
|
136
|
-
simulateEvent('click', 0, replaceButton);
|
|
137
|
-
|
|
138
|
-
expect(editor.value).equals('<p>wesw wesw test</p>');
|
|
139
|
-
});
|
|
140
|
-
});
|
|
141
|
-
});
|
|
142
|
-
|
|
143
|
-
describe('F3 after search', function () {
|
|
144
|
-
it('Should find a next match', function () {
|
|
145
|
-
const editor = getJodit({
|
|
146
|
-
observer: {
|
|
147
|
-
timeout: 0
|
|
148
|
-
}
|
|
149
|
-
});
|
|
150
|
-
|
|
151
|
-
editor.value = '<p>|test| test test</p>';
|
|
152
|
-
setCursorToChar(editor);
|
|
153
|
-
|
|
154
|
-
const search = editor.container.querySelector('.jodit-search');
|
|
155
|
-
expect(search.classList.contains('jodit-search_active')).is.false;
|
|
156
|
-
|
|
157
|
-
// press ctrl(cmd) + f
|
|
158
|
-
simulateEvent('keydown', 'f', editor.editor, function (options) {
|
|
159
|
-
options.ctrlKey = true;
|
|
160
|
-
});
|
|
161
|
-
|
|
162
|
-
expect(search.classList.contains('jodit-search_active')).is.true;
|
|
163
|
-
|
|
164
|
-
console.log(editor.ownerDocument.activeElement);
|
|
165
|
-
expect(
|
|
166
|
-
editor.ownerDocument.activeElement ===
|
|
167
|
-
search.querySelector('[data-ref="query"]')
|
|
168
|
-
).is.true;
|
|
169
|
-
|
|
170
|
-
editor.s.removeMarkers();
|
|
171
|
-
Jodit.modules.Helpers.normalizeNode(editor.editor.firstChild); // because Select module splits text node
|
|
172
|
-
|
|
173
|
-
editor.events.fire('searchNext');
|
|
174
|
-
|
|
175
|
-
simulateEvent('keydown', 'F3', editor.editor, function (options) {
|
|
176
|
-
options.shiftKey = false;
|
|
177
|
-
}); //
|
|
178
|
-
|
|
179
|
-
const sel = editor.s.sel;
|
|
180
|
-
|
|
181
|
-
expect(1).equals(sel.rangeCount);
|
|
182
|
-
range = sel.getRangeAt(0);
|
|
183
|
-
|
|
184
|
-
expect(editor.editor.firstChild.firstChild).equals(
|
|
185
|
-
range.startContainer
|
|
186
|
-
);
|
|
187
|
-
expect(5).equals(range.startOffset);
|
|
188
|
-
|
|
189
|
-
expect(editor.editor.firstChild.firstChild).equals(
|
|
190
|
-
range.endContainer
|
|
191
|
-
);
|
|
192
|
-
expect(9).equals(range.endOffset);
|
|
193
|
-
});
|
|
194
|
-
|
|
195
|
-
it('Should find the next match in a circle', function () {
|
|
196
|
-
const editor = getJodit({
|
|
197
|
-
disablePlugins: ['WrapTextNodes'],
|
|
198
|
-
|
|
199
|
-
observer: {
|
|
200
|
-
timeout: 0
|
|
201
|
-
}
|
|
202
|
-
});
|
|
203
|
-
|
|
204
|
-
editor.value = 'test test test';
|
|
205
|
-
|
|
206
|
-
let range = editor.s.createRange(true);
|
|
207
|
-
range.setStart(editor.editor.firstChild, 0);
|
|
208
|
-
range.setEnd(editor.editor.firstChild, 1);
|
|
209
|
-
|
|
210
|
-
const search = editor.container.querySelector('.jodit-search');
|
|
211
|
-
|
|
212
|
-
expect(search.classList.contains('jodit-search_active')).is.false;
|
|
213
|
-
|
|
214
|
-
// press ctrl(cmd) + f
|
|
215
|
-
simulateEvent('keydown', 'f', editor.editor, function (options) {
|
|
216
|
-
options.ctrlKey = true;
|
|
217
|
-
});
|
|
218
|
-
|
|
219
|
-
expect(search.classList.contains('jodit-search_active')).is.true;
|
|
220
|
-
expect(
|
|
221
|
-
editor.ownerDocument.activeElement ===
|
|
222
|
-
search.querySelector('[data-ref="query"]')
|
|
223
|
-
).is.true;
|
|
224
|
-
|
|
225
|
-
editor.s.removeMarkers();
|
|
226
|
-
Jodit.modules.Helpers.normalizeNode(editor.editor.firstChild); // because Select module splits text node
|
|
227
|
-
|
|
228
|
-
const sel = editor.s.sel;
|
|
229
|
-
|
|
230
|
-
editor.events.fire('searchNext');
|
|
231
|
-
[
|
|
232
|
-
[3, 4],
|
|
233
|
-
[5, 6],
|
|
234
|
-
[8, 9],
|
|
235
|
-
[10, 11],
|
|
236
|
-
[13, 14],
|
|
237
|
-
[0, 1],
|
|
238
|
-
[3, 4]
|
|
239
|
-
].forEach(function (pars) {
|
|
240
|
-
simulateEvent(
|
|
241
|
-
'keydown',
|
|
242
|
-
'F3',
|
|
243
|
-
editor.editor,
|
|
244
|
-
function (options) {
|
|
245
|
-
options.shiftKey = false;
|
|
246
|
-
}
|
|
247
|
-
); //
|
|
248
|
-
|
|
249
|
-
expect(1).equals(sel.rangeCount);
|
|
250
|
-
range = sel.getRangeAt(0);
|
|
251
|
-
|
|
252
|
-
expect(pars[0]).equals(range.startOffset);
|
|
253
|
-
expect(pars[1]).equals(range.endOffset);
|
|
254
|
-
});
|
|
255
|
-
});
|
|
256
|
-
|
|
257
|
-
describe('with SHIFT key', function () {
|
|
258
|
-
it('Should find a previous match', function () {
|
|
259
|
-
const editor = getJodit({
|
|
260
|
-
observer: {
|
|
261
|
-
timeout: 0
|
|
262
|
-
}
|
|
263
|
-
});
|
|
264
|
-
|
|
265
|
-
editor.value = 'test test test';
|
|
266
|
-
|
|
267
|
-
let range = editor.s.createRange(true);
|
|
268
|
-
range.setStart(editor.editor.firstChild.firstChild, 0);
|
|
269
|
-
range.setEnd(editor.editor.firstChild.firstChild, 4);
|
|
270
|
-
|
|
271
|
-
const search = editor.container.querySelector('.jodit-search');
|
|
272
|
-
|
|
273
|
-
expect(false).equals(
|
|
274
|
-
search.classList.contains('jodit-search_active')
|
|
275
|
-
);
|
|
276
|
-
|
|
277
|
-
// press ctrl(cmd) + f
|
|
278
|
-
simulateEvent(
|
|
279
|
-
'keydown',
|
|
280
|
-
'f',
|
|
281
|
-
editor.editor,
|
|
282
|
-
function (options) {
|
|
283
|
-
options.ctrlKey = true;
|
|
284
|
-
}
|
|
285
|
-
);
|
|
286
|
-
|
|
287
|
-
expect(true).equals(
|
|
288
|
-
search.classList.contains('jodit-search_active')
|
|
289
|
-
);
|
|
290
|
-
expect(true).equals(
|
|
291
|
-
editor.ownerDocument.activeElement ===
|
|
292
|
-
search.querySelector('[data-ref="query"]')
|
|
293
|
-
);
|
|
294
|
-
|
|
295
|
-
editor.s.removeMarkers();
|
|
296
|
-
Jodit.modules.Helpers.normalizeNode(editor.editor.firstChild); // because Select module splits text node
|
|
297
|
-
|
|
298
|
-
editor.events.fire('searchNext');
|
|
299
|
-
|
|
300
|
-
simulateEvent(
|
|
301
|
-
'keydown',
|
|
302
|
-
'F3',
|
|
303
|
-
editor.editor,
|
|
304
|
-
function (options) {
|
|
305
|
-
options.shiftKey = true;
|
|
306
|
-
}
|
|
307
|
-
); //
|
|
308
|
-
|
|
309
|
-
const sel = editor.s.sel;
|
|
310
|
-
|
|
311
|
-
expect(1).equals(sel.rangeCount);
|
|
312
|
-
range = sel.getRangeAt(0);
|
|
313
|
-
|
|
314
|
-
expect(editor.editor.firstChild.firstChild).equals(
|
|
315
|
-
range.startContainer
|
|
316
|
-
);
|
|
317
|
-
expect(10).equals(range.startOffset);
|
|
318
|
-
|
|
319
|
-
expect(editor.editor.firstChild.firstChild).equals(
|
|
320
|
-
range.endContainer
|
|
321
|
-
);
|
|
322
|
-
expect(14).equals(range.endOffset);
|
|
323
|
-
});
|
|
324
|
-
});
|
|
325
|
-
});
|
|
326
|
-
|
|
327
|
-
describe('Esc in query field', function () {
|
|
328
|
-
it('Should hide search form and restore selection', function () {
|
|
329
|
-
const editor = getJodit();
|
|
330
|
-
editor.value = '<p>text</p>';
|
|
331
|
-
|
|
332
|
-
const range = editor.s.createRange();
|
|
333
|
-
range.setStart(editor.editor.firstChild.firstChild, 1);
|
|
334
|
-
range.setEnd(editor.editor.firstChild.firstChild, 3);
|
|
335
|
-
const sel = editor.s.sel;
|
|
336
|
-
sel.removeAllRanges();
|
|
337
|
-
sel.addRange(range);
|
|
338
|
-
|
|
339
|
-
const search = editor.container.querySelector('.jodit-search');
|
|
340
|
-
expect(false).equals(
|
|
341
|
-
search.classList.contains('jodit-search_active')
|
|
342
|
-
);
|
|
343
|
-
simulateEvent('keydown', 'f', editor.editor, function (options) {
|
|
344
|
-
options.ctrlKey = true;
|
|
345
|
-
});
|
|
346
|
-
|
|
347
|
-
expect(true).equals(
|
|
348
|
-
search.classList.contains('jodit-search_active')
|
|
349
|
-
);
|
|
350
|
-
expect(true).equals(
|
|
351
|
-
editor.ownerDocument.activeElement ===
|
|
352
|
-
search.querySelector('[data-ref="query"]')
|
|
353
|
-
);
|
|
354
|
-
simulateEvent(
|
|
355
|
-
'keydown',
|
|
356
|
-
Jodit.KEY_ESC,
|
|
357
|
-
search.querySelector('[data-ref="query"]')
|
|
358
|
-
);
|
|
359
|
-
|
|
360
|
-
expect(false).equals(
|
|
361
|
-
search.classList.contains('jodit-search_active')
|
|
362
|
-
);
|
|
363
|
-
expect('ex').equals(sel.toString());
|
|
364
|
-
});
|
|
365
|
-
});
|
|
366
|
-
|
|
367
|
-
describe('Unit test compare string', function () {
|
|
368
|
-
describe('Get index of found string', function () {
|
|
369
|
-
it('Should find needle in haystack', function () {
|
|
370
|
-
const str = 'Mr John Smith washed window';
|
|
371
|
-
|
|
372
|
-
expect(11).equals(
|
|
373
|
-
search.getSomePartOfStringIndex('th was', str)
|
|
374
|
-
);
|
|
375
|
-
|
|
376
|
-
expect(11).equals(
|
|
377
|
-
search.getSomePartOfStringIndex('TH WAS', str)
|
|
378
|
-
);
|
|
379
|
-
|
|
380
|
-
expect(false).equals(
|
|
381
|
-
search.getSomePartOfStringIndex('TH WASNT', str)
|
|
382
|
-
);
|
|
383
|
-
});
|
|
384
|
-
|
|
385
|
-
it('Should find needle in haystack steb by step', function () {
|
|
386
|
-
expect(false).equals(
|
|
387
|
-
search.getSomePartOfStringIndex('th was', 'Mr')
|
|
388
|
-
);
|
|
389
|
-
expect(false).equals(
|
|
390
|
-
search.getSomePartOfStringIndex('th was', 'Mr John')
|
|
391
|
-
);
|
|
392
|
-
|
|
393
|
-
expect(11).equals(
|
|
394
|
-
search.getSomePartOfStringIndex('th was', 'Mr John Smith')
|
|
395
|
-
);
|
|
396
|
-
expect(11).equals(
|
|
397
|
-
search.getSomePartOfStringIndex(
|
|
398
|
-
'th was',
|
|
399
|
-
'Mr John Smith wa'
|
|
400
|
-
)
|
|
401
|
-
);
|
|
402
|
-
expect(false).equals(
|
|
403
|
-
search.getSomePartOfStringIndex('th was', 'Mr John Smith s')
|
|
404
|
-
);
|
|
405
|
-
|
|
406
|
-
expect(11).equals(
|
|
407
|
-
search.getSomePartOfStringIndex(
|
|
408
|
-
'th was',
|
|
409
|
-
'Mr John Smith washed'
|
|
410
|
-
)
|
|
411
|
-
);
|
|
412
|
-
expect(11).equals(
|
|
413
|
-
search.getSomePartOfStringIndex(
|
|
414
|
-
'th was',
|
|
415
|
-
'Mr John Smith washed window'
|
|
416
|
-
)
|
|
417
|
-
);
|
|
418
|
-
});
|
|
419
|
-
|
|
420
|
-
it('Should find needle in haystack steb by step in back direction', function () {
|
|
421
|
-
// const str = 'Mr John Smith washed window';
|
|
422
|
-
expect(false).equals(
|
|
423
|
-
search.getSomePartOfStringIndex('th was', 'window', false)
|
|
424
|
-
);
|
|
425
|
-
expect(0).equals(
|
|
426
|
-
search.getSomePartOfStringIndex(
|
|
427
|
-
'th was',
|
|
428
|
-
'washed window',
|
|
429
|
-
false
|
|
430
|
-
)
|
|
431
|
-
);
|
|
432
|
-
expect(0).equals(
|
|
433
|
-
search.getSomePartOfStringIndex(
|
|
434
|
-
'th was',
|
|
435
|
-
'h washed window',
|
|
436
|
-
false
|
|
437
|
-
)
|
|
438
|
-
);
|
|
439
|
-
expect(3).equals(
|
|
440
|
-
search.getSomePartOfStringIndex(
|
|
441
|
-
'th was',
|
|
442
|
-
'Smith washed window',
|
|
443
|
-
false
|
|
444
|
-
)
|
|
445
|
-
);
|
|
446
|
-
});
|
|
447
|
-
});
|
|
448
|
-
|
|
449
|
-
describe('Compare strings and return boolean', function () {
|
|
450
|
-
it('Should find needle in haystack', function () {
|
|
451
|
-
const str = 'Mr John Smith washed window';
|
|
452
|
-
expect(true).equals(search.findSomePartOfString('th was', str));
|
|
453
|
-
expect(true).equals(search.findSomePartOfString('TH WAS', str));
|
|
454
|
-
expect(true).equals(
|
|
455
|
-
search.findSomePartOfString('TH WAS', str)
|
|
456
|
-
);
|
|
457
|
-
expect(false).equals(
|
|
458
|
-
search.findSomePartOfString('TH WASNT', str)
|
|
459
|
-
);
|
|
460
|
-
});
|
|
461
|
-
|
|
462
|
-
it('Should find needle in haystack steb by step', function () {
|
|
463
|
-
//const str = 'Mr John Smith washed window';
|
|
464
|
-
expect(false).equals(
|
|
465
|
-
search.findSomePartOfString('th was', 'Mr')
|
|
466
|
-
);
|
|
467
|
-
expect(false).equals(
|
|
468
|
-
search.findSomePartOfString('th was', 'Mr John')
|
|
469
|
-
);
|
|
470
|
-
|
|
471
|
-
expect('th').equals(
|
|
472
|
-
search.findSomePartOfString('th was', 'Mr John Smith')
|
|
473
|
-
);
|
|
474
|
-
|
|
475
|
-
expect('th wa').equals(
|
|
476
|
-
search.findSomePartOfString('th was', 'Mr John Smith wa')
|
|
477
|
-
);
|
|
478
|
-
|
|
479
|
-
expect('th wa').equals(
|
|
480
|
-
search.findSomePartOfString('th was', 'Mr John Smith wa')
|
|
481
|
-
);
|
|
482
|
-
|
|
483
|
-
expect('th wa').equals(
|
|
484
|
-
search.findSomePartOfString('th was', 'Mr John Smith wa')
|
|
485
|
-
);
|
|
486
|
-
|
|
487
|
-
expect(false).equals(
|
|
488
|
-
search.findSomePartOfString('th was', 'Mr John Smith s')
|
|
489
|
-
);
|
|
490
|
-
|
|
491
|
-
expect(true).equals(
|
|
492
|
-
search.findSomePartOfString(
|
|
493
|
-
'th was',
|
|
494
|
-
'Mr John Smith washed'
|
|
495
|
-
)
|
|
496
|
-
);
|
|
497
|
-
|
|
498
|
-
expect(true).equals(
|
|
499
|
-
search.findSomePartOfString(
|
|
500
|
-
'th was',
|
|
501
|
-
'Mr John Smith washed'
|
|
502
|
-
)
|
|
503
|
-
);
|
|
504
|
-
|
|
505
|
-
expect(true).equals(
|
|
506
|
-
search.findSomePartOfString(
|
|
507
|
-
'th was',
|
|
508
|
-
'Mr John Smith washed window'
|
|
509
|
-
)
|
|
510
|
-
);
|
|
511
|
-
});
|
|
512
|
-
it('Should find needle in haystack steb by step in back direction', function () {
|
|
513
|
-
// const str = 'Mr John Smith washed window';
|
|
514
|
-
expect(false).equals(
|
|
515
|
-
search.findSomePartOfString('th was', 'window', false)
|
|
516
|
-
);
|
|
517
|
-
expect('was').equals(
|
|
518
|
-
search.findSomePartOfString(
|
|
519
|
-
'th was',
|
|
520
|
-
'washed window',
|
|
521
|
-
false
|
|
522
|
-
)
|
|
523
|
-
);
|
|
524
|
-
expect('h was').equals(
|
|
525
|
-
search.findSomePartOfString(
|
|
526
|
-
'th was',
|
|
527
|
-
'h washed window',
|
|
528
|
-
false
|
|
529
|
-
)
|
|
530
|
-
);
|
|
531
|
-
expect(true).equals(
|
|
532
|
-
search.findSomePartOfString(
|
|
533
|
-
'th was',
|
|
534
|
-
'Smith washed window',
|
|
535
|
-
false
|
|
536
|
-
)
|
|
537
|
-
);
|
|
538
|
-
});
|
|
539
|
-
});
|
|
540
|
-
|
|
541
|
-
describe('Haystack less needle', function () {
|
|
542
|
-
it('Should return false', function () {
|
|
543
|
-
expect(false).equals(
|
|
544
|
-
search.findSomePartOfString('th was', ' ', true)
|
|
545
|
-
);
|
|
546
|
-
expect(false).equals(
|
|
547
|
-
search.findSomePartOfString(
|
|
548
|
-
'Smith washed window',
|
|
549
|
-
'washed',
|
|
550
|
-
true
|
|
551
|
-
)
|
|
552
|
-
);
|
|
553
|
-
});
|
|
554
|
-
});
|
|
555
|
-
});
|
|
556
|
-
|
|
557
|
-
describe('Fire search event', function () {
|
|
558
|
-
it('Should select some elements which consists query string', function () {
|
|
559
|
-
const editor = getJodit({
|
|
560
|
-
observer: {
|
|
561
|
-
timeout: 0
|
|
562
|
-
}
|
|
563
|
-
});
|
|
564
|
-
editor.value =
|
|
565
|
-
'<p><span>Mr</span> <span>John</span> <span>Smith</span> <span>washed</span> <span>window</span></p>';
|
|
566
|
-
const sel = editor.s.sel;
|
|
567
|
-
sel.removeAllRanges();
|
|
568
|
-
|
|
569
|
-
editor.events.fire('search', 'th was');
|
|
570
|
-
expect(1).equals(sel.rangeCount);
|
|
571
|
-
const range = sel.getRangeAt(0);
|
|
572
|
-
|
|
573
|
-
expect(editor.editor.firstChild.childNodes[4].firstChild).equals(
|
|
574
|
-
range.startContainer
|
|
575
|
-
);
|
|
576
|
-
expect(3).equals(range.startOffset);
|
|
577
|
-
|
|
578
|
-
expect(editor.editor.firstChild.childNodes[6].firstChild).equals(
|
|
579
|
-
range.endContainer
|
|
580
|
-
);
|
|
581
|
-
expect(3).equals(range.startOffset);
|
|
582
|
-
});
|
|
583
|
-
});
|
|
584
|
-
|
|
585
|
-
describe('Find by toolbar button event', function () {
|
|
586
|
-
describe('Press Search button', function () {
|
|
587
|
-
it('Should open search dialog', function () {
|
|
588
|
-
const editor = getJodit({
|
|
589
|
-
observer: {
|
|
590
|
-
timeout: 0
|
|
591
|
-
}
|
|
592
|
-
});
|
|
593
|
-
|
|
594
|
-
clickButton('find', editor);
|
|
595
|
-
|
|
596
|
-
expect(
|
|
597
|
-
editor.container.querySelector(
|
|
598
|
-
'.jodit-search.jodit-search_active'
|
|
599
|
-
)
|
|
600
|
-
).is.not.null;
|
|
601
|
-
});
|
|
602
|
-
});
|
|
603
|
-
|
|
604
|
-
describe('Press Replace button', function () {
|
|
605
|
-
it('Should open search dialog', function () {
|
|
606
|
-
const editor = getJodit({
|
|
607
|
-
observer: {
|
|
608
|
-
timeout: 0
|
|
609
|
-
}
|
|
610
|
-
});
|
|
611
|
-
|
|
612
|
-
clickTrigger('find', editor);
|
|
613
|
-
clickButton('replace', getOpenedPopup(editor));
|
|
614
|
-
|
|
615
|
-
expect(
|
|
616
|
-
editor.container.querySelector(
|
|
617
|
-
'.jodit-search.jodit-search_active.jodit-search_replace'
|
|
618
|
-
)
|
|
619
|
-
).is.not.null;
|
|
620
|
-
});
|
|
621
|
-
});
|
|
622
|
-
});
|
|
623
|
-
});
|