@ckeditor/ckeditor5-find-and-replace 41.2.0 → 41.3.0-alpha.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/dist/content-index.css +4 -0
- package/dist/editor-index.css +20 -0
- package/dist/index.css +38 -0
- package/dist/index.css.map +1 -0
- package/dist/index.js +1493 -0
- package/dist/index.js.map +1 -0
- package/dist/types/augmentation.d.ts +20 -0
- package/dist/types/findandreplace.d.ts +42 -0
- package/dist/types/findandreplaceconfig.d.ts +31 -0
- package/dist/types/findandreplaceediting.d.ts +63 -0
- package/dist/types/findandreplacestate.d.ts +95 -0
- package/dist/types/findandreplaceui.d.ts +67 -0
- package/dist/types/findandreplaceutils.d.ts +67 -0
- package/dist/types/findcommand.d.ts +48 -0
- package/dist/types/findnextcommand.d.ts +35 -0
- package/dist/types/findpreviouscommand.d.ts +19 -0
- package/dist/types/index.d.ts +18 -0
- package/dist/types/replaceallcommand.d.ts +35 -0
- package/dist/types/replacecommand.d.ts +22 -0
- package/dist/types/replacecommandbase.d.ts +31 -0
- package/dist/types/ui/findandreplaceformview.d.ts +309 -0
- package/package.json +4 -3
- package/src/index.d.ts +1 -1
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright (c) 2003-2024, 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
|
+
import type { FindAndReplace, FindAndReplaceEditing, FindAndReplaceUI, FindAndReplaceUtils, FindCommand, FindNextCommand, FindPreviousCommand, ReplaceAllCommand, ReplaceCommand } from './index.js';
|
|
6
|
+
declare module '@ckeditor/ckeditor5-core' {
|
|
7
|
+
interface PluginsMap {
|
|
8
|
+
[FindAndReplace.pluginName]: FindAndReplace;
|
|
9
|
+
[FindAndReplaceEditing.pluginName]: FindAndReplaceEditing;
|
|
10
|
+
[FindAndReplaceUI.pluginName]: FindAndReplaceUI;
|
|
11
|
+
[FindAndReplaceUtils.pluginName]: FindAndReplaceUtils;
|
|
12
|
+
}
|
|
13
|
+
interface CommandsMap {
|
|
14
|
+
find: FindCommand;
|
|
15
|
+
findNext: FindNextCommand;
|
|
16
|
+
findPrevious: FindPreviousCommand;
|
|
17
|
+
replace: ReplaceCommand;
|
|
18
|
+
replaceAll: ReplaceAllCommand;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright (c) 2003-2024, 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/findandreplace
|
|
7
|
+
*/
|
|
8
|
+
import { Plugin } from 'ckeditor5/src/core.js';
|
|
9
|
+
import FindAndReplaceUI from './findandreplaceui.js';
|
|
10
|
+
import FindAndReplaceEditing from './findandreplaceediting.js';
|
|
11
|
+
import type { Marker } from 'ckeditor5/src/engine.js';
|
|
12
|
+
export type ResultType = {
|
|
13
|
+
id?: string;
|
|
14
|
+
label?: string;
|
|
15
|
+
start?: number;
|
|
16
|
+
end?: number;
|
|
17
|
+
marker?: Marker;
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* The find and replace plugin.
|
|
21
|
+
*
|
|
22
|
+
* For a detailed overview, check the {@glink features/find-and-replace Find and replace feature documentation}.
|
|
23
|
+
*
|
|
24
|
+
* This is a "glue" plugin which loads the following plugins:
|
|
25
|
+
*
|
|
26
|
+
* * The {@link module:find-and-replace/findandreplaceediting~FindAndReplaceEditing find and replace editing feature},
|
|
27
|
+
* * The {@link module:find-and-replace/findandreplaceui~FindAndReplaceUI find and replace UI feature}
|
|
28
|
+
*/
|
|
29
|
+
export default class FindAndReplace extends Plugin {
|
|
30
|
+
/**
|
|
31
|
+
* @inheritDoc
|
|
32
|
+
*/
|
|
33
|
+
static get requires(): readonly [typeof FindAndReplaceEditing, typeof FindAndReplaceUI];
|
|
34
|
+
/**
|
|
35
|
+
* @inheritDoc
|
|
36
|
+
*/
|
|
37
|
+
static get pluginName(): "FindAndReplace";
|
|
38
|
+
/**
|
|
39
|
+
* @inheritDoc
|
|
40
|
+
*/
|
|
41
|
+
init(): void;
|
|
42
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright (c) 2003-2024, 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/findandreplaceconfig
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* The configuration of the find and replace feature.
|
|
10
|
+
* The option is used by the {@link module:find-and-replace/findandreplace~FindAndReplace} feature.
|
|
11
|
+
*
|
|
12
|
+
* ```ts
|
|
13
|
+
* ClassicEditor
|
|
14
|
+
* .create( {
|
|
15
|
+
* findAndReplace: ... // Find and replace feature config.
|
|
16
|
+
* } )
|
|
17
|
+
* .then( ... )
|
|
18
|
+
* .catch( ... );
|
|
19
|
+
* ```
|
|
20
|
+
*
|
|
21
|
+
* See {@link module:core/editor/editorconfig~EditorConfig all editor options}.
|
|
22
|
+
*/
|
|
23
|
+
export interface FindAndReplaceConfig {
|
|
24
|
+
/**
|
|
25
|
+
* The type of the find and replace UI opened by the `'findAndReplace'` button registered in the
|
|
26
|
+
* editor's {@link module:ui/componentfactory~ComponentFactory component factory}
|
|
27
|
+
*
|
|
28
|
+
* The default value is `'dialog'`.
|
|
29
|
+
*/
|
|
30
|
+
uiType?: 'dialog' | 'dropdown';
|
|
31
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright (c) 2003-2024, 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/findandreplaceediting
|
|
7
|
+
*/
|
|
8
|
+
import { Plugin } from 'ckeditor5/src/core.js';
|
|
9
|
+
import { type Collection } from 'ckeditor5/src/utils.js';
|
|
10
|
+
import { type FindAttributes } from './findcommand.js';
|
|
11
|
+
import FindAndReplaceState, { type FindCallback } from './findandreplacestate.js';
|
|
12
|
+
import FindAndReplaceUtils from './findandreplaceutils.js';
|
|
13
|
+
import type { ResultType } from './findandreplace.js';
|
|
14
|
+
import '../theme/findandreplace.css';
|
|
15
|
+
/**
|
|
16
|
+
* Implements the editing part for find and replace plugin. For example conversion, commands etc.
|
|
17
|
+
*/
|
|
18
|
+
export default class FindAndReplaceEditing extends Plugin {
|
|
19
|
+
/**
|
|
20
|
+
* @inheritDoc
|
|
21
|
+
*/
|
|
22
|
+
static get requires(): readonly [typeof FindAndReplaceUtils];
|
|
23
|
+
/**
|
|
24
|
+
* @inheritDoc
|
|
25
|
+
*/
|
|
26
|
+
static get pluginName(): "FindAndReplaceEditing";
|
|
27
|
+
/**
|
|
28
|
+
* An object storing the find and replace state within a given editor instance.
|
|
29
|
+
*/
|
|
30
|
+
state?: FindAndReplaceState;
|
|
31
|
+
/**
|
|
32
|
+
* A flag that indicates that the user has started a search and the editor is listening for changes
|
|
33
|
+
* to the text on which it will perform an automatic search. Among other things, the mode is activated
|
|
34
|
+
* when the user first clicks 'Find' button and then later deactivated when the modal or search dropdown is closed.
|
|
35
|
+
*
|
|
36
|
+
* @internal
|
|
37
|
+
*/
|
|
38
|
+
_isSearchActive: boolean;
|
|
39
|
+
/**
|
|
40
|
+
* @inheritDoc
|
|
41
|
+
*/
|
|
42
|
+
init(): void;
|
|
43
|
+
/**
|
|
44
|
+
* Initiate a search.
|
|
45
|
+
*/
|
|
46
|
+
find(callbackOrText: string | FindCallback, findAttributes?: FindAttributes): Collection<ResultType>;
|
|
47
|
+
/**
|
|
48
|
+
* Stops active results from updating, and clears out the results.
|
|
49
|
+
*/
|
|
50
|
+
stop(): void;
|
|
51
|
+
/**
|
|
52
|
+
* Sets up the commands.
|
|
53
|
+
*/
|
|
54
|
+
private _defineCommands;
|
|
55
|
+
/**
|
|
56
|
+
* Sets up the marker downcast converters for search results highlighting.
|
|
57
|
+
*/
|
|
58
|
+
private _defineConverters;
|
|
59
|
+
/**
|
|
60
|
+
* Reacts to document changes in order to update search list.
|
|
61
|
+
*/
|
|
62
|
+
private _onDocumentChange;
|
|
63
|
+
}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright (c) 2003-2024, 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/findandreplacestate
|
|
7
|
+
*/
|
|
8
|
+
import type { Model, Item } from 'ckeditor5/src/engine.js';
|
|
9
|
+
import { Collection } from 'ckeditor5/src/utils.js';
|
|
10
|
+
import type { ResultType } from './findandreplace.js';
|
|
11
|
+
declare const FindAndReplaceState_base: {
|
|
12
|
+
new (): import("ckeditor5/src/utils.js").Observable;
|
|
13
|
+
prototype: import("ckeditor5/src/utils.js").Observable;
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* The object storing find and replace plugin state for a given editor instance.
|
|
17
|
+
*/
|
|
18
|
+
export default class FindAndReplaceState extends FindAndReplaceState_base {
|
|
19
|
+
/**
|
|
20
|
+
* A collection of find matches.
|
|
21
|
+
*
|
|
22
|
+
* @observable
|
|
23
|
+
*/
|
|
24
|
+
results: Collection<ResultType>;
|
|
25
|
+
/**
|
|
26
|
+
* Currently highlighted search result in {@link #results matched results}.
|
|
27
|
+
*
|
|
28
|
+
* @readonly
|
|
29
|
+
* @observable
|
|
30
|
+
*/
|
|
31
|
+
highlightedResult: ResultType | null;
|
|
32
|
+
/**
|
|
33
|
+
* Currently highlighted search result offset in {@link #results matched results}.
|
|
34
|
+
*
|
|
35
|
+
* @readonly
|
|
36
|
+
* @observable
|
|
37
|
+
*/
|
|
38
|
+
highlightedOffset: number;
|
|
39
|
+
/**
|
|
40
|
+
* Searched text value.
|
|
41
|
+
*
|
|
42
|
+
* @readonly
|
|
43
|
+
* @observable
|
|
44
|
+
*/
|
|
45
|
+
searchText: string;
|
|
46
|
+
/**
|
|
47
|
+
* The most recent search callback used by the feature to find matches.
|
|
48
|
+
* It is used to re-run the search when user modifies the editor content.
|
|
49
|
+
*
|
|
50
|
+
* @readonly
|
|
51
|
+
* @observable
|
|
52
|
+
*/
|
|
53
|
+
lastSearchCallback: FindCallback | null;
|
|
54
|
+
/**
|
|
55
|
+
* Replace text value.
|
|
56
|
+
*
|
|
57
|
+
* @readonly
|
|
58
|
+
* @observable
|
|
59
|
+
*/
|
|
60
|
+
replaceText: string;
|
|
61
|
+
/**
|
|
62
|
+
* Indicates whether the matchCase checkbox has been checked.
|
|
63
|
+
*
|
|
64
|
+
* @readonly
|
|
65
|
+
* @observable
|
|
66
|
+
*/
|
|
67
|
+
matchCase: boolean;
|
|
68
|
+
/**
|
|
69
|
+
* Indicates whether the matchWholeWords checkbox has been checked.
|
|
70
|
+
*
|
|
71
|
+
* @readonly
|
|
72
|
+
* @observable
|
|
73
|
+
*/
|
|
74
|
+
matchWholeWords: boolean;
|
|
75
|
+
/**
|
|
76
|
+
* Creates an instance of the state.
|
|
77
|
+
*/
|
|
78
|
+
constructor(model: Model);
|
|
79
|
+
/**
|
|
80
|
+
* Cleans the state up and removes markers from the model.
|
|
81
|
+
*/
|
|
82
|
+
clear(model: Model): void;
|
|
83
|
+
/**
|
|
84
|
+
* Refreshes the highlight result offset based on it's index within the result list.
|
|
85
|
+
*/
|
|
86
|
+
refreshHighlightOffset(): void;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* The callback function used to find matches in the document.
|
|
90
|
+
*/
|
|
91
|
+
export type FindCallback = (({ item, text }: {
|
|
92
|
+
item: Item;
|
|
93
|
+
text: string;
|
|
94
|
+
}) => Array<ResultType>);
|
|
95
|
+
export {};
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright (c) 2003-2024, 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/findandreplaceui
|
|
7
|
+
*/
|
|
8
|
+
import { type Editor, Plugin } from 'ckeditor5/src/core.js';
|
|
9
|
+
import { Dialog, type ViewWithCssTransitionDisabler } from 'ckeditor5/src/ui.js';
|
|
10
|
+
import FindAndReplaceFormView from './ui/findandreplaceformview.js';
|
|
11
|
+
/**
|
|
12
|
+
* The default find and replace UI.
|
|
13
|
+
*
|
|
14
|
+
* It registers the `'findAndReplace'` UI button in the editor's {@link module:ui/componentfactory~ComponentFactory component factory}.
|
|
15
|
+
* that uses the {@link module:find-and-replace/findandreplace~FindAndReplace FindAndReplace} plugin API.
|
|
16
|
+
*/
|
|
17
|
+
export default class FindAndReplaceUI extends Plugin {
|
|
18
|
+
/**
|
|
19
|
+
* @inheritDoc
|
|
20
|
+
*/
|
|
21
|
+
static get requires(): readonly [typeof Dialog];
|
|
22
|
+
/**
|
|
23
|
+
* @inheritDoc
|
|
24
|
+
*/
|
|
25
|
+
static get pluginName(): "FindAndReplaceUI";
|
|
26
|
+
/**
|
|
27
|
+
* A reference to the find and replace form view.
|
|
28
|
+
*/
|
|
29
|
+
formView: FindAndReplaceFormView & ViewWithCssTransitionDisabler | null;
|
|
30
|
+
/**
|
|
31
|
+
* @inheritDoc
|
|
32
|
+
*/
|
|
33
|
+
constructor(editor: Editor);
|
|
34
|
+
/**
|
|
35
|
+
* @inheritDoc
|
|
36
|
+
*/
|
|
37
|
+
init(): void;
|
|
38
|
+
/**
|
|
39
|
+
* Creates a dropdown containing the find and replace form.
|
|
40
|
+
*/
|
|
41
|
+
private _createDropdown;
|
|
42
|
+
/**
|
|
43
|
+
* Creates a button that opens a dialog with the find and replace form.
|
|
44
|
+
*/
|
|
45
|
+
private _createDialogButton;
|
|
46
|
+
/**
|
|
47
|
+
* Sets up the form view for the find and replace.
|
|
48
|
+
*
|
|
49
|
+
* @param formView A related form view.
|
|
50
|
+
*/
|
|
51
|
+
private _createFormView;
|
|
52
|
+
/**
|
|
53
|
+
* Clears the find and replace form and focuses the search text field.
|
|
54
|
+
*/
|
|
55
|
+
private _setupFormView;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Fired when the UI was reset and the search results marked in the editing root should be invalidated,
|
|
59
|
+
* for instance, because the user changed the searched phrase (or options) but didn't hit
|
|
60
|
+
* the "Find" button yet.
|
|
61
|
+
*
|
|
62
|
+
* @eventName ~FindAndReplaceUI#searchReseted
|
|
63
|
+
*/
|
|
64
|
+
export type SearchResetedEvent = {
|
|
65
|
+
name: 'searchReseted';
|
|
66
|
+
args: [];
|
|
67
|
+
};
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright (c) 2003-2024, 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/findandreplaceutils
|
|
7
|
+
*/
|
|
8
|
+
import type { Item, Model, Range } from 'ckeditor5/src/engine.js';
|
|
9
|
+
import { Plugin } from 'ckeditor5/src/core.js';
|
|
10
|
+
import { Collection } from 'ckeditor5/src/utils.js';
|
|
11
|
+
import type { ResultType } from './findandreplace.js';
|
|
12
|
+
/**
|
|
13
|
+
* A set of helpers related to find and replace.
|
|
14
|
+
*/
|
|
15
|
+
export default class FindAndReplaceUtils extends Plugin {
|
|
16
|
+
/**
|
|
17
|
+
* @inheritDoc
|
|
18
|
+
*/
|
|
19
|
+
static get pluginName(): "FindAndReplaceUtils";
|
|
20
|
+
/**
|
|
21
|
+
* Executes findCallback and updates search results list.
|
|
22
|
+
*
|
|
23
|
+
* @param range The model range to scan for matches.
|
|
24
|
+
* @param model The model.
|
|
25
|
+
* @param findCallback The callback that should return `true` if provided text matches the search term.
|
|
26
|
+
* @param startResults An optional collection of find matches that the function should
|
|
27
|
+
* start with. This would be a collection returned by a previous `updateFindResultFromRange()` call.
|
|
28
|
+
* @returns A collection of objects describing find match.
|
|
29
|
+
*
|
|
30
|
+
* An example structure:
|
|
31
|
+
*
|
|
32
|
+
* ```js
|
|
33
|
+
* {
|
|
34
|
+
* id: resultId,
|
|
35
|
+
* label: foundItem.label,
|
|
36
|
+
* marker
|
|
37
|
+
* }
|
|
38
|
+
* ```
|
|
39
|
+
*/
|
|
40
|
+
updateFindResultFromRange(range: Range, model: Model, findCallback: ({ item, text }: {
|
|
41
|
+
item: Item;
|
|
42
|
+
text: string;
|
|
43
|
+
}) => Array<ResultType>, startResults: Collection<ResultType> | null): Collection<ResultType>;
|
|
44
|
+
/**
|
|
45
|
+
* Returns text representation of a range. The returned text length should be the same as range length.
|
|
46
|
+
* In order to achieve this, this function will replace inline elements (text-line) as new line character ("\n").
|
|
47
|
+
*
|
|
48
|
+
* @param range The model range.
|
|
49
|
+
* @returns The text content of the provided range.
|
|
50
|
+
*/
|
|
51
|
+
rangeToText(range: Range): string;
|
|
52
|
+
/**
|
|
53
|
+
* Creates a text matching callback for a specified search term and matching options.
|
|
54
|
+
*
|
|
55
|
+
* @param searchTerm The search term.
|
|
56
|
+
* @param options Matching options.
|
|
57
|
+
* - options.matchCase=false If set to `true` letter casing will be ignored.
|
|
58
|
+
* - options.wholeWords=false If set to `true` only whole words that match `callbackOrText` will be matched.
|
|
59
|
+
*/
|
|
60
|
+
findByTextCallback(searchTerm: string, options: {
|
|
61
|
+
matchCase?: boolean;
|
|
62
|
+
wholeWords?: boolean;
|
|
63
|
+
}): ({ item, text }: {
|
|
64
|
+
item: Item;
|
|
65
|
+
text: string;
|
|
66
|
+
}) => Array<ResultType>;
|
|
67
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright (c) 2003-2024, 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/findcommand
|
|
7
|
+
*/
|
|
8
|
+
import { Command, type Editor } from 'ckeditor5/src/core.js';
|
|
9
|
+
import type { Collection } from 'ckeditor5/src/utils.js';
|
|
10
|
+
import type { default as FindAndReplaceState, FindCallback } from './findandreplacestate.js';
|
|
11
|
+
import type { ResultType } from './findandreplace.js';
|
|
12
|
+
/**
|
|
13
|
+
* The find command. It is used by the {@link module:find-and-replace/findandreplace~FindAndReplace find and replace feature}.
|
|
14
|
+
*/
|
|
15
|
+
export default class FindCommand extends Command {
|
|
16
|
+
/**
|
|
17
|
+
* The find and replace state object used for command operations.
|
|
18
|
+
*/
|
|
19
|
+
private _state;
|
|
20
|
+
/**
|
|
21
|
+
* Creates a new `FindCommand` instance.
|
|
22
|
+
*
|
|
23
|
+
* @param editor The editor on which this command will be used.
|
|
24
|
+
* @param state An object to hold plugin state.
|
|
25
|
+
*/
|
|
26
|
+
constructor(editor: Editor, state: FindAndReplaceState);
|
|
27
|
+
/**
|
|
28
|
+
* Executes the command.
|
|
29
|
+
*
|
|
30
|
+
* @param callbackOrText
|
|
31
|
+
* @param options Options object.
|
|
32
|
+
* @param options.matchCase If set to `true`, the letter case will be matched.
|
|
33
|
+
* @param options.wholeWords If set to `true`, only whole words that match `callbackOrText` will be matched.
|
|
34
|
+
*
|
|
35
|
+
* @fires execute
|
|
36
|
+
*/
|
|
37
|
+
execute(callbackOrText: string | FindCallback, { matchCase, wholeWords }?: FindAttributes): {
|
|
38
|
+
results: Collection<ResultType>;
|
|
39
|
+
findCallback: FindCallback;
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* The options object for the find command.
|
|
44
|
+
*/
|
|
45
|
+
export type FindAttributes = {
|
|
46
|
+
matchCase?: boolean;
|
|
47
|
+
wholeWords?: boolean;
|
|
48
|
+
};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright (c) 2003-2024, 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/findnextcommand
|
|
7
|
+
*/
|
|
8
|
+
import { Command, type Editor } from 'ckeditor5/src/core.js';
|
|
9
|
+
import type FindAndReplaceState from './findandreplacestate.js';
|
|
10
|
+
/**
|
|
11
|
+
* The find next command. Moves the highlight to the next search result.
|
|
12
|
+
*
|
|
13
|
+
* It is used by the {@link module:find-and-replace/findandreplace~FindAndReplace find and replace feature}.
|
|
14
|
+
*/
|
|
15
|
+
export default class FindNextCommand extends Command {
|
|
16
|
+
/**
|
|
17
|
+
* The find and replace state object used for command operations.
|
|
18
|
+
*/
|
|
19
|
+
protected _state: FindAndReplaceState;
|
|
20
|
+
/**
|
|
21
|
+
* Creates a new `FindNextCommand` instance.
|
|
22
|
+
*
|
|
23
|
+
* @param editor The editor on which this command will be used.
|
|
24
|
+
* @param state An object to hold plugin state.
|
|
25
|
+
*/
|
|
26
|
+
constructor(editor: Editor, state: FindAndReplaceState);
|
|
27
|
+
/**
|
|
28
|
+
* @inheritDoc
|
|
29
|
+
*/
|
|
30
|
+
refresh(): void;
|
|
31
|
+
/**
|
|
32
|
+
* @inheritDoc
|
|
33
|
+
*/
|
|
34
|
+
execute(): void;
|
|
35
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright (c) 2003-2024, 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/findpreviouscommand
|
|
7
|
+
*/
|
|
8
|
+
import FindNextCommand from './findnextcommand.js';
|
|
9
|
+
/**
|
|
10
|
+
* The find previous command. Moves the highlight to the previous search result.
|
|
11
|
+
*
|
|
12
|
+
* It is used by the {@link module:find-and-replace/findandreplace~FindAndReplace find and replace feature}.
|
|
13
|
+
*/
|
|
14
|
+
export default class FindPreviousCommand extends FindNextCommand {
|
|
15
|
+
/**
|
|
16
|
+
* @inheritDoc
|
|
17
|
+
*/
|
|
18
|
+
execute(): void;
|
|
19
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright (c) 2003-2024, 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
|
|
7
|
+
*/
|
|
8
|
+
export { default as FindAndReplace } from './findandreplace.js';
|
|
9
|
+
export { default as FindAndReplaceEditing } from './findandreplaceediting.js';
|
|
10
|
+
export { default as FindAndReplaceUI } from './findandreplaceui.js';
|
|
11
|
+
export { default as FindAndReplaceUtils } from './findandreplaceutils.js';
|
|
12
|
+
export { default as FindCommand } from './findcommand.js';
|
|
13
|
+
export { default as FindNextCommand } from './findnextcommand.js';
|
|
14
|
+
export { default as FindPreviousCommand } from './findpreviouscommand.js';
|
|
15
|
+
export { default as ReplaceCommand } from './replacecommand.js';
|
|
16
|
+
export { default as ReplaceAllCommand } from './replaceallcommand.js';
|
|
17
|
+
export type { FindAndReplaceConfig } from './findandreplaceconfig.js';
|
|
18
|
+
import './augmentation.js';
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright (c) 2003-2024, 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/replaceallcommand
|
|
7
|
+
*/
|
|
8
|
+
import { Collection } from 'ckeditor5/src/utils.js';
|
|
9
|
+
import type { ResultType } from './findandreplace.js';
|
|
10
|
+
import { ReplaceCommandBase } from './replacecommandbase.js';
|
|
11
|
+
/**
|
|
12
|
+
* The replace all command. It is used by the {@link module:find-and-replace/findandreplace~FindAndReplace find and replace feature}.
|
|
13
|
+
*/
|
|
14
|
+
export default class ReplaceAllCommand extends ReplaceCommandBase {
|
|
15
|
+
/**
|
|
16
|
+
* Replaces all the occurrences of `textToReplace` with a given `newText` string.
|
|
17
|
+
*
|
|
18
|
+
* ```ts
|
|
19
|
+
* replaceAllCommand.execute( 'replaceAll', 'new text replacement', 'text to replace' );
|
|
20
|
+
* ```
|
|
21
|
+
*
|
|
22
|
+
* Alternatively you can call it from editor instance:
|
|
23
|
+
*
|
|
24
|
+
* ```ts
|
|
25
|
+
* editor.execute( 'replaceAll', 'new text', 'old text' );
|
|
26
|
+
* ```
|
|
27
|
+
*
|
|
28
|
+
* @param newText Text that will be inserted to the editor for each match.
|
|
29
|
+
* @param textToReplace Text to be replaced or a collection of matches
|
|
30
|
+
* as returned by the find command.
|
|
31
|
+
*
|
|
32
|
+
* @fires module:core/command~Command#event:execute
|
|
33
|
+
*/
|
|
34
|
+
execute(newText: string, textToReplace: string | Collection<ResultType>): void;
|
|
35
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright (c) 2003-2024, 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/replacecommand
|
|
7
|
+
*/
|
|
8
|
+
import type { ResultType } from './findandreplace.js';
|
|
9
|
+
import { ReplaceCommandBase } from './replacecommandbase.js';
|
|
10
|
+
/**
|
|
11
|
+
* The replace command. It is used by the {@link module:find-and-replace/findandreplace~FindAndReplace find and replace feature}.
|
|
12
|
+
*/
|
|
13
|
+
export default class ReplaceCommand extends ReplaceCommandBase {
|
|
14
|
+
/**
|
|
15
|
+
* Replace a given find result by a string or a callback.
|
|
16
|
+
*
|
|
17
|
+
* @param result A single result from the find command.
|
|
18
|
+
*
|
|
19
|
+
* @fires execute
|
|
20
|
+
*/
|
|
21
|
+
execute(replacementText: string, result: ResultType): void;
|
|
22
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright (c) 2003-2024, 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, type Editor } from 'ckeditor5/src/core.js';
|
|
9
|
+
import type { ResultType } from './findandreplace.js';
|
|
10
|
+
import type FindAndReplaceState from './findandreplacestate.js';
|
|
11
|
+
export declare abstract class ReplaceCommandBase extends Command {
|
|
12
|
+
/**
|
|
13
|
+
* The find and replace state object used for command operations.
|
|
14
|
+
*/
|
|
15
|
+
protected _state: FindAndReplaceState;
|
|
16
|
+
/**
|
|
17
|
+
* Creates a new `ReplaceCommand` instance.
|
|
18
|
+
*
|
|
19
|
+
* @param editor Editor on which this command will be used.
|
|
20
|
+
* @param state An object to hold plugin state.
|
|
21
|
+
*/
|
|
22
|
+
constructor(editor: Editor, state: FindAndReplaceState);
|
|
23
|
+
abstract execute(...args: Array<unknown>): void;
|
|
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
|
+
protected _replace(replacementText: string, result: ResultType): void;
|
|
31
|
+
}
|