@ckeditor/ckeditor5-find-and-replace 41.3.0 → 41.4.0-alpha.0

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.
Files changed (126) hide show
  1. package/build/find-and-replace.js +1 -1
  2. package/dist/index-content.css +4 -0
  3. package/dist/index-editor.css +32 -0
  4. package/dist/index.css +78 -0
  5. package/dist/index.css.map +1 -0
  6. package/dist/index.js +1380 -0
  7. package/dist/index.js.map +1 -0
  8. package/dist/translations/af.d.ts +8 -0
  9. package/dist/translations/af.js +5 -0
  10. package/dist/translations/ar.d.ts +8 -0
  11. package/dist/translations/ar.js +5 -0
  12. package/dist/translations/bg.d.ts +8 -0
  13. package/dist/translations/bg.js +5 -0
  14. package/dist/translations/bn.d.ts +8 -0
  15. package/dist/translations/bn.js +5 -0
  16. package/dist/translations/bs.d.ts +8 -0
  17. package/dist/translations/bs.js +5 -0
  18. package/dist/translations/ca.d.ts +8 -0
  19. package/dist/translations/ca.js +5 -0
  20. package/dist/translations/cs.d.ts +8 -0
  21. package/dist/translations/cs.js +5 -0
  22. package/dist/translations/da.d.ts +8 -0
  23. package/dist/translations/da.js +5 -0
  24. package/dist/translations/de.d.ts +8 -0
  25. package/dist/translations/de.js +5 -0
  26. package/dist/translations/el.d.ts +8 -0
  27. package/dist/translations/el.js +5 -0
  28. package/dist/translations/en-au.d.ts +8 -0
  29. package/dist/translations/en-au.js +5 -0
  30. package/dist/translations/en.d.ts +8 -0
  31. package/dist/translations/en.js +5 -0
  32. package/dist/translations/es-co.d.ts +8 -0
  33. package/dist/translations/es-co.js +5 -0
  34. package/dist/translations/es.d.ts +8 -0
  35. package/dist/translations/es.js +5 -0
  36. package/dist/translations/et.d.ts +8 -0
  37. package/dist/translations/et.js +5 -0
  38. package/dist/translations/fa.d.ts +8 -0
  39. package/dist/translations/fa.js +5 -0
  40. package/dist/translations/fi.d.ts +8 -0
  41. package/dist/translations/fi.js +5 -0
  42. package/dist/translations/fr.d.ts +8 -0
  43. package/dist/translations/fr.js +5 -0
  44. package/dist/translations/gl.d.ts +8 -0
  45. package/dist/translations/gl.js +5 -0
  46. package/dist/translations/he.d.ts +8 -0
  47. package/dist/translations/he.js +5 -0
  48. package/dist/translations/hi.d.ts +8 -0
  49. package/dist/translations/hi.js +5 -0
  50. package/dist/translations/hr.d.ts +8 -0
  51. package/dist/translations/hr.js +5 -0
  52. package/dist/translations/hu.d.ts +8 -0
  53. package/dist/translations/hu.js +5 -0
  54. package/dist/translations/id.d.ts +8 -0
  55. package/dist/translations/id.js +5 -0
  56. package/dist/translations/it.d.ts +8 -0
  57. package/dist/translations/it.js +5 -0
  58. package/dist/translations/ja.d.ts +8 -0
  59. package/dist/translations/ja.js +5 -0
  60. package/dist/translations/jv.d.ts +8 -0
  61. package/dist/translations/jv.js +5 -0
  62. package/dist/translations/ko.d.ts +8 -0
  63. package/dist/translations/ko.js +5 -0
  64. package/dist/translations/lt.d.ts +8 -0
  65. package/dist/translations/lt.js +5 -0
  66. package/dist/translations/lv.d.ts +8 -0
  67. package/dist/translations/lv.js +5 -0
  68. package/dist/translations/ms.d.ts +8 -0
  69. package/dist/translations/ms.js +5 -0
  70. package/dist/translations/nl.d.ts +8 -0
  71. package/dist/translations/nl.js +5 -0
  72. package/dist/translations/no.d.ts +8 -0
  73. package/dist/translations/no.js +5 -0
  74. package/dist/translations/pl.d.ts +8 -0
  75. package/dist/translations/pl.js +5 -0
  76. package/dist/translations/pt-br.d.ts +8 -0
  77. package/dist/translations/pt-br.js +5 -0
  78. package/dist/translations/pt.d.ts +8 -0
  79. package/dist/translations/pt.js +5 -0
  80. package/dist/translations/ro.d.ts +8 -0
  81. package/dist/translations/ro.js +5 -0
  82. package/dist/translations/ru.d.ts +8 -0
  83. package/dist/translations/ru.js +5 -0
  84. package/dist/translations/sk.d.ts +8 -0
  85. package/dist/translations/sk.js +5 -0
  86. package/dist/translations/sr-latn.d.ts +8 -0
  87. package/dist/translations/sr-latn.js +5 -0
  88. package/dist/translations/sr.d.ts +8 -0
  89. package/dist/translations/sr.js +5 -0
  90. package/dist/translations/sv.d.ts +8 -0
  91. package/dist/translations/sv.js +5 -0
  92. package/dist/translations/th.d.ts +8 -0
  93. package/dist/translations/th.js +5 -0
  94. package/dist/translations/tr.d.ts +8 -0
  95. package/dist/translations/tr.js +5 -0
  96. package/dist/translations/tt.d.ts +8 -0
  97. package/dist/translations/tt.js +5 -0
  98. package/dist/translations/ug.d.ts +8 -0
  99. package/dist/translations/ug.js +5 -0
  100. package/dist/translations/uk.d.ts +8 -0
  101. package/dist/translations/uk.js +5 -0
  102. package/dist/translations/ur.d.ts +8 -0
  103. package/dist/translations/ur.js +5 -0
  104. package/dist/translations/vi.d.ts +8 -0
  105. package/dist/translations/vi.js +5 -0
  106. package/dist/translations/zh-cn.d.ts +8 -0
  107. package/dist/translations/zh-cn.js +5 -0
  108. package/dist/translations/zh.d.ts +8 -0
  109. package/dist/translations/zh.js +5 -0
  110. package/dist/types/augmentation.d.ts +24 -0
  111. package/dist/types/findandreplace.d.ts +46 -0
  112. package/dist/types/findandreplaceconfig.d.ts +35 -0
  113. package/dist/types/findandreplaceediting.d.ts +67 -0
  114. package/dist/types/findandreplacestate.d.ts +99 -0
  115. package/dist/types/findandreplaceui.d.ts +83 -0
  116. package/dist/types/findandreplaceutils.d.ts +71 -0
  117. package/dist/types/findcommand.d.ts +52 -0
  118. package/dist/types/findnextcommand.d.ts +39 -0
  119. package/dist/types/findpreviouscommand.d.ts +23 -0
  120. package/dist/types/index.d.ts +22 -0
  121. package/dist/types/replaceallcommand.d.ts +39 -0
  122. package/dist/types/replacecommand.d.ts +26 -0
  123. package/dist/types/replacecommandbase.d.ts +35 -0
  124. package/dist/types/ui/findandreplaceformview.d.ts +313 -0
  125. package/package.json +4 -3
  126. package/src/index.d.ts +1 -1
@@ -0,0 +1,83 @@
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
+ * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
7
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
8
+ */
9
+ /**
10
+ * @module find-and-replace/findandreplaceui
11
+ */
12
+ import { type Editor, Plugin } from 'ckeditor5/src/core.js';
13
+ import { Dialog, type ViewWithCssTransitionDisabler } from 'ckeditor5/src/ui.js';
14
+ import FindAndReplaceFormView from './ui/findandreplaceformview.js';
15
+ /**
16
+ * The default find and replace UI.
17
+ *
18
+ * It registers the `'findAndReplace'` UI button in the editor's {@link module:ui/componentfactory~ComponentFactory component factory}.
19
+ * that uses the {@link module:find-and-replace/findandreplace~FindAndReplace FindAndReplace} plugin API.
20
+ */
21
+ export default class FindAndReplaceUI extends Plugin {
22
+ /**
23
+ * @inheritDoc
24
+ */
25
+ static get requires(): readonly [typeof Dialog];
26
+ /**
27
+ * @inheritDoc
28
+ */
29
+ static get pluginName(): "FindAndReplaceUI";
30
+ /**
31
+ * A reference to the find and replace form view.
32
+ */
33
+ formView: FindAndReplaceFormView & ViewWithCssTransitionDisabler | null;
34
+ /**
35
+ * @inheritDoc
36
+ */
37
+ constructor(editor: Editor);
38
+ /**
39
+ * @inheritDoc
40
+ */
41
+ init(): void;
42
+ /**
43
+ * Creates a dropdown containing the find and replace form.
44
+ */
45
+ private _createDropdown;
46
+ /**
47
+ * Creates a button that opens a dialog with the find and replace form.
48
+ */
49
+ private _createDialogButtonForToolbar;
50
+ /**
51
+ * Creates a button for for menu bar that will show find and replace dialog.
52
+ */
53
+ private _createDialogButtonForMenuBar;
54
+ /**
55
+ * Creates a button for find and replace command to use either in toolbar or in menu bar.
56
+ */
57
+ private _createButton;
58
+ /**
59
+ * Shows the find and replace dialog.
60
+ */
61
+ private _showDialog;
62
+ /**
63
+ * Sets up the form view for the find and replace.
64
+ *
65
+ * @param formView A related form view.
66
+ */
67
+ private _createFormView;
68
+ /**
69
+ * Clears the find and replace form and focuses the search text field.
70
+ */
71
+ private _setupFormView;
72
+ }
73
+ /**
74
+ * Fired when the UI was reset and the search results marked in the editing root should be invalidated,
75
+ * for instance, because the user changed the searched phrase (or options) but didn't hit
76
+ * the "Find" button yet.
77
+ *
78
+ * @eventName ~FindAndReplaceUI#searchReseted
79
+ */
80
+ export type SearchResetedEvent = {
81
+ name: 'searchReseted';
82
+ args: [];
83
+ };
@@ -0,0 +1,71 @@
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
+ * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
7
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
8
+ */
9
+ /**
10
+ * @module find-and-replace/findandreplaceutils
11
+ */
12
+ import type { Item, Model, Range } from 'ckeditor5/src/engine.js';
13
+ import { Plugin } from 'ckeditor5/src/core.js';
14
+ import { Collection } from 'ckeditor5/src/utils.js';
15
+ import type { ResultType } from './findandreplace.js';
16
+ /**
17
+ * A set of helpers related to find and replace.
18
+ */
19
+ export default class FindAndReplaceUtils extends Plugin {
20
+ /**
21
+ * @inheritDoc
22
+ */
23
+ static get pluginName(): "FindAndReplaceUtils";
24
+ /**
25
+ * Executes findCallback and updates search results list.
26
+ *
27
+ * @param range The model range to scan for matches.
28
+ * @param model The model.
29
+ * @param findCallback The callback that should return `true` if provided text matches the search term.
30
+ * @param startResults An optional collection of find matches that the function should
31
+ * start with. This would be a collection returned by a previous `updateFindResultFromRange()` call.
32
+ * @returns A collection of objects describing find match.
33
+ *
34
+ * An example structure:
35
+ *
36
+ * ```js
37
+ * {
38
+ * id: resultId,
39
+ * label: foundItem.label,
40
+ * marker
41
+ * }
42
+ * ```
43
+ */
44
+ updateFindResultFromRange(range: Range, model: Model, findCallback: ({ item, text }: {
45
+ item: Item;
46
+ text: string;
47
+ }) => Array<ResultType>, startResults: Collection<ResultType> | null): Collection<ResultType>;
48
+ /**
49
+ * Returns text representation of a range. The returned text length should be the same as range length.
50
+ * In order to achieve this, this function will replace inline elements (text-line) as new line character ("\n").
51
+ *
52
+ * @param range The model range.
53
+ * @returns The text content of the provided range.
54
+ */
55
+ rangeToText(range: Range): string;
56
+ /**
57
+ * Creates a text matching callback for a specified search term and matching options.
58
+ *
59
+ * @param searchTerm The search term.
60
+ * @param options Matching options.
61
+ * - options.matchCase=false If set to `true` letter casing will be ignored.
62
+ * - options.wholeWords=false If set to `true` only whole words that match `callbackOrText` will be matched.
63
+ */
64
+ findByTextCallback(searchTerm: string, options: {
65
+ matchCase?: boolean;
66
+ wholeWords?: boolean;
67
+ }): ({ item, text }: {
68
+ item: Item;
69
+ text: string;
70
+ }) => Array<ResultType>;
71
+ }
@@ -0,0 +1,52 @@
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
+ * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
7
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
8
+ */
9
+ /**
10
+ * @module find-and-replace/findcommand
11
+ */
12
+ import { Command, type Editor } from 'ckeditor5/src/core.js';
13
+ import type { Collection } from 'ckeditor5/src/utils.js';
14
+ import type { default as FindAndReplaceState, FindCallback } from './findandreplacestate.js';
15
+ import type { ResultType } from './findandreplace.js';
16
+ /**
17
+ * The find command. It is used by the {@link module:find-and-replace/findandreplace~FindAndReplace find and replace feature}.
18
+ */
19
+ export default class FindCommand extends Command {
20
+ /**
21
+ * The find and replace state object used for command operations.
22
+ */
23
+ private _state;
24
+ /**
25
+ * Creates a new `FindCommand` instance.
26
+ *
27
+ * @param editor The editor on which this command will be used.
28
+ * @param state An object to hold plugin state.
29
+ */
30
+ constructor(editor: Editor, state: FindAndReplaceState);
31
+ /**
32
+ * Executes the command.
33
+ *
34
+ * @param callbackOrText
35
+ * @param options Options object.
36
+ * @param options.matchCase If set to `true`, the letter case will be matched.
37
+ * @param options.wholeWords If set to `true`, only whole words that match `callbackOrText` will be matched.
38
+ *
39
+ * @fires execute
40
+ */
41
+ execute(callbackOrText: string | FindCallback, { matchCase, wholeWords }?: FindAttributes): {
42
+ results: Collection<ResultType>;
43
+ findCallback: FindCallback;
44
+ };
45
+ }
46
+ /**
47
+ * The options object for the find command.
48
+ */
49
+ export type FindAttributes = {
50
+ matchCase?: boolean;
51
+ wholeWords?: boolean;
52
+ };
@@ -0,0 +1,39 @@
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
+ * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
7
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
8
+ */
9
+ /**
10
+ * @module find-and-replace/findnextcommand
11
+ */
12
+ import { Command, type Editor } from 'ckeditor5/src/core.js';
13
+ import type FindAndReplaceState from './findandreplacestate.js';
14
+ /**
15
+ * The find next command. Moves the highlight to the next search result.
16
+ *
17
+ * It is used by the {@link module:find-and-replace/findandreplace~FindAndReplace find and replace feature}.
18
+ */
19
+ export default class FindNextCommand extends Command {
20
+ /**
21
+ * The find and replace state object used for command operations.
22
+ */
23
+ protected _state: FindAndReplaceState;
24
+ /**
25
+ * Creates a new `FindNextCommand` instance.
26
+ *
27
+ * @param editor The editor on which this command will be used.
28
+ * @param state An object to hold plugin state.
29
+ */
30
+ constructor(editor: Editor, state: FindAndReplaceState);
31
+ /**
32
+ * @inheritDoc
33
+ */
34
+ refresh(): void;
35
+ /**
36
+ * @inheritDoc
37
+ */
38
+ execute(): void;
39
+ }
@@ -0,0 +1,23 @@
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
+ * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
7
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
8
+ */
9
+ /**
10
+ * @module find-and-replace/findpreviouscommand
11
+ */
12
+ import FindNextCommand from './findnextcommand.js';
13
+ /**
14
+ * The find previous command. Moves the highlight to the previous search result.
15
+ *
16
+ * It is used by the {@link module:find-and-replace/findandreplace~FindAndReplace find and replace feature}.
17
+ */
18
+ export default class FindPreviousCommand extends FindNextCommand {
19
+ /**
20
+ * @inheritDoc
21
+ */
22
+ execute(): void;
23
+ }
@@ -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
+ * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
7
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
8
+ */
9
+ /**
10
+ * @module find-and-replace
11
+ */
12
+ export { default as FindAndReplace } from './findandreplace.js';
13
+ export { default as FindAndReplaceEditing } from './findandreplaceediting.js';
14
+ export { default as FindAndReplaceUI } from './findandreplaceui.js';
15
+ export { default as FindAndReplaceUtils } from './findandreplaceutils.js';
16
+ export { default as FindCommand } from './findcommand.js';
17
+ export { default as FindNextCommand } from './findnextcommand.js';
18
+ export { default as FindPreviousCommand } from './findpreviouscommand.js';
19
+ export { default as ReplaceCommand } from './replacecommand.js';
20
+ export { default as ReplaceAllCommand } from './replaceallcommand.js';
21
+ export type { FindAndReplaceConfig } from './findandreplaceconfig.js';
22
+ import './augmentation.js';
@@ -0,0 +1,39 @@
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
+ * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
7
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
8
+ */
9
+ /**
10
+ * @module find-and-replace/replaceallcommand
11
+ */
12
+ import { Collection } from 'ckeditor5/src/utils.js';
13
+ import type { ResultType } from './findandreplace.js';
14
+ import { ReplaceCommandBase } from './replacecommandbase.js';
15
+ /**
16
+ * The replace all command. It is used by the {@link module:find-and-replace/findandreplace~FindAndReplace find and replace feature}.
17
+ */
18
+ export default class ReplaceAllCommand extends ReplaceCommandBase {
19
+ /**
20
+ * Replaces all the occurrences of `textToReplace` with a given `newText` string.
21
+ *
22
+ * ```ts
23
+ * replaceAllCommand.execute( 'replaceAll', 'new text replacement', 'text to replace' );
24
+ * ```
25
+ *
26
+ * Alternatively you can call it from editor instance:
27
+ *
28
+ * ```ts
29
+ * editor.execute( 'replaceAll', 'new text', 'old text' );
30
+ * ```
31
+ *
32
+ * @param newText Text that will be inserted to the editor for each match.
33
+ * @param textToReplace Text to be replaced or a collection of matches
34
+ * as returned by the find command.
35
+ *
36
+ * @fires module:core/command~Command#event:execute
37
+ */
38
+ execute(newText: string, textToReplace: string | Collection<ResultType>): void;
39
+ }
@@ -0,0 +1,26 @@
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
+ * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
7
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
8
+ */
9
+ /**
10
+ * @module find-and-replace/replacecommand
11
+ */
12
+ import type { ResultType } from './findandreplace.js';
13
+ import { ReplaceCommandBase } from './replacecommandbase.js';
14
+ /**
15
+ * The replace command. It is used by the {@link module:find-and-replace/findandreplace~FindAndReplace find and replace feature}.
16
+ */
17
+ export default class ReplaceCommand extends ReplaceCommandBase {
18
+ /**
19
+ * Replace a given find result by a string or a callback.
20
+ *
21
+ * @param result A single result from the find command.
22
+ *
23
+ * @fires execute
24
+ */
25
+ execute(replacementText: string, result: ResultType): void;
26
+ }
@@ -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
+ * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
7
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
8
+ */
9
+ /**
10
+ * @module find-and-replace/replacecommandbase
11
+ */
12
+ import { Command, type Editor } from 'ckeditor5/src/core.js';
13
+ import type { ResultType } from './findandreplace.js';
14
+ import type FindAndReplaceState from './findandreplacestate.js';
15
+ export declare abstract class ReplaceCommandBase extends Command {
16
+ /**
17
+ * The find and replace state object used for command operations.
18
+ */
19
+ protected _state: FindAndReplaceState;
20
+ /**
21
+ * Creates a new `ReplaceCommand` instance.
22
+ *
23
+ * @param editor 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
+ abstract execute(...args: Array<unknown>): void;
28
+ /**
29
+ * Common logic for both `replace` commands.
30
+ * Replace a given find result by a string or a callback.
31
+ *
32
+ * @param result A single result from the find command.
33
+ */
34
+ protected _replace(replacementText: string, result: ResultType): void;
35
+ }