@ckeditor/ckeditor5-find-and-replace 38.0.1 → 38.1.1
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/build/find-and-replace.js +1 -1
- package/build/find-and-replace.js.map +1 -0
- package/package.json +3 -31
- package/src/augmentation.d.ts +20 -20
- package/src/augmentation.js +5 -5
- package/src/findandreplace.d.ts +42 -42
- package/src/findandreplace.js +84 -84
- package/src/findandreplaceediting.d.ts +63 -63
- package/src/findandreplaceediting.js +201 -202
- package/src/findandreplacestate.d.ts +69 -69
- package/src/findandreplacestate.js +60 -60
- package/src/findandreplaceui.d.ts +55 -55
- package/src/findandreplaceui.js +132 -132
- package/src/findandreplaceutils.d.ts +67 -67
- package/src/findandreplaceutils.js +143 -143
- package/src/findcommand.d.ts +51 -51
- package/src/findcommand.js +63 -63
- package/src/findnextcommand.d.ts +35 -35
- package/src/findnextcommand.js +47 -47
- package/src/findpreviouscommand.d.ts +19 -19
- package/src/findpreviouscommand.js +25 -25
- package/src/index.d.ts +17 -17
- package/src/index.js +17 -17
- package/src/replaceallcommand.d.ts +35 -35
- package/src/replaceallcommand.js +47 -47
- package/src/replacecommand.d.ts +22 -22
- package/src/replacecommand.js +20 -20
- package/src/replacecommandbase.d.ts +31 -31
- package/src/replacecommandbase.js +56 -56
- package/src/ui/findandreplaceformview.d.ts +288 -288
- package/src/ui/findandreplaceformview.js +453 -453
|
@@ -1,56 +1,56 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
|
-
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
4
|
-
*/
|
|
5
|
-
/**
|
|
6
|
-
* @module find-and-replace/replacecommandbase
|
|
7
|
-
*/
|
|
8
|
-
import { Command } from 'ckeditor5/src/core';
|
|
9
|
-
export class ReplaceCommandBase extends Command {
|
|
10
|
-
/**
|
|
11
|
-
* Creates a new `ReplaceCommand` instance.
|
|
12
|
-
*
|
|
13
|
-
* @param editor Editor on which this command will be used.
|
|
14
|
-
* @param state An object to hold plugin state.
|
|
15
|
-
*/
|
|
16
|
-
constructor(editor, state) {
|
|
17
|
-
super(editor);
|
|
18
|
-
// The replace command is always enabled.
|
|
19
|
-
this.isEnabled = true;
|
|
20
|
-
this._state = state;
|
|
21
|
-
// Since this command executes on particular result independent of selection, it should be checked directly in execute block.
|
|
22
|
-
this._isEnabledBasedOnSelection = false;
|
|
23
|
-
}
|
|
24
|
-
/**
|
|
25
|
-
* Common logic for both `replace` commands.
|
|
26
|
-
* Replace a given find result by a string or a callback.
|
|
27
|
-
*
|
|
28
|
-
* @param result A single result from the find command.
|
|
29
|
-
*/
|
|
30
|
-
_replace(replacementText, result) {
|
|
31
|
-
const { model } = this.editor;
|
|
32
|
-
const range = result.marker.getRange();
|
|
33
|
-
// Don't replace a result that is in non-editable place.
|
|
34
|
-
if (!model.canEditAt(range)) {
|
|
35
|
-
return;
|
|
36
|
-
}
|
|
37
|
-
model.change(writer => {
|
|
38
|
-
// Don't replace a result (marker) that found its way into the $graveyard (e.g. removed by collaborators).
|
|
39
|
-
if (range.root.rootName === '$graveyard') {
|
|
40
|
-
this._state.results.remove(result);
|
|
41
|
-
return;
|
|
42
|
-
}
|
|
43
|
-
let textAttributes = {};
|
|
44
|
-
for (const item of range.getItems()) {
|
|
45
|
-
if (item.is('$text') || item.is('$textProxy')) {
|
|
46
|
-
textAttributes = item.getAttributes();
|
|
47
|
-
break;
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
model.insertContent(writer.createText(replacementText, textAttributes), range);
|
|
51
|
-
if (this._state.results.has(result)) {
|
|
52
|
-
this._state.results.remove(result);
|
|
53
|
-
}
|
|
54
|
-
});
|
|
55
|
-
}
|
|
56
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
|
+
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* @module find-and-replace/replacecommandbase
|
|
7
|
+
*/
|
|
8
|
+
import { Command } from 'ckeditor5/src/core';
|
|
9
|
+
export class ReplaceCommandBase extends Command {
|
|
10
|
+
/**
|
|
11
|
+
* Creates a new `ReplaceCommand` instance.
|
|
12
|
+
*
|
|
13
|
+
* @param editor Editor on which this command will be used.
|
|
14
|
+
* @param state An object to hold plugin state.
|
|
15
|
+
*/
|
|
16
|
+
constructor(editor, state) {
|
|
17
|
+
super(editor);
|
|
18
|
+
// The replace command is always enabled.
|
|
19
|
+
this.isEnabled = true;
|
|
20
|
+
this._state = state;
|
|
21
|
+
// Since this command executes on particular result independent of selection, it should be checked directly in execute block.
|
|
22
|
+
this._isEnabledBasedOnSelection = false;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Common logic for both `replace` commands.
|
|
26
|
+
* Replace a given find result by a string or a callback.
|
|
27
|
+
*
|
|
28
|
+
* @param result A single result from the find command.
|
|
29
|
+
*/
|
|
30
|
+
_replace(replacementText, result) {
|
|
31
|
+
const { model } = this.editor;
|
|
32
|
+
const range = result.marker.getRange();
|
|
33
|
+
// Don't replace a result that is in non-editable place.
|
|
34
|
+
if (!model.canEditAt(range)) {
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
model.change(writer => {
|
|
38
|
+
// Don't replace a result (marker) that found its way into the $graveyard (e.g. removed by collaborators).
|
|
39
|
+
if (range.root.rootName === '$graveyard') {
|
|
40
|
+
this._state.results.remove(result);
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
let textAttributes = {};
|
|
44
|
+
for (const item of range.getItems()) {
|
|
45
|
+
if (item.is('$text') || item.is('$textProxy')) {
|
|
46
|
+
textAttributes = item.getAttributes();
|
|
47
|
+
break;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
model.insertContent(writer.createText(replacementText, textAttributes), range);
|
|
51
|
+
if (this._state.results.has(result)) {
|
|
52
|
+
this._state.results.remove(result);
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
}
|