@ckeditor/ckeditor5-typing 41.3.0-alpha.4 → 41.3.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/package.json +4 -5
- package/dist/content-index.css +0 -4
- package/dist/editor-index.css +0 -4
- package/dist/index.css +0 -4
- package/dist/types/augmentation.d.ts +0 -31
- package/dist/types/delete.d.ts +0 -36
- package/dist/types/deletecommand.d.ts +0 -87
- package/dist/types/deleteobserver.d.ts +0 -59
- package/dist/types/index.d.ts +0 -28
- package/dist/types/input.d.ts +0 -25
- package/dist/types/inserttextcommand.d.ts +0 -80
- package/dist/types/inserttextobserver.d.ts +0 -63
- package/dist/types/texttransformation.d.ts +0 -37
- package/dist/types/textwatcher.d.ts +0 -142
- package/dist/types/twostepcaretmovement.d.ts +0 -236
- package/dist/types/typing.d.ts +0 -27
- package/dist/types/typingconfig.d.ts +0 -208
- package/dist/types/utils/changebuffer.d.ts +0 -107
- package/dist/types/utils/findattributerange.d.ts +0 -37
- package/dist/types/utils/getlasttextline.d.ts +0 -53
- package/dist/types/utils/inlinehighlight.d.ts +0 -37
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ckeditor/ckeditor5-typing",
|
|
3
|
-
"version": "41.3.
|
|
3
|
+
"version": "41.3.1",
|
|
4
4
|
"description": "Typing feature for CKEditor 5.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ckeditor",
|
|
@@ -13,9 +13,9 @@
|
|
|
13
13
|
"type": "module",
|
|
14
14
|
"main": "src/index.js",
|
|
15
15
|
"dependencies": {
|
|
16
|
-
"@ckeditor/ckeditor5-core": "41.3.
|
|
17
|
-
"@ckeditor/ckeditor5-engine": "41.3.
|
|
18
|
-
"@ckeditor/ckeditor5-utils": "41.3.
|
|
16
|
+
"@ckeditor/ckeditor5-core": "41.3.1",
|
|
17
|
+
"@ckeditor/ckeditor5-engine": "41.3.1",
|
|
18
|
+
"@ckeditor/ckeditor5-utils": "41.3.1",
|
|
19
19
|
"lodash-es": "4.17.21"
|
|
20
20
|
},
|
|
21
21
|
"author": "CKSource (http://cksource.com/)",
|
|
@@ -28,7 +28,6 @@
|
|
|
28
28
|
"directory": "packages/ckeditor5-typing"
|
|
29
29
|
},
|
|
30
30
|
"files": [
|
|
31
|
-
"dist",
|
|
32
31
|
"lang",
|
|
33
32
|
"src/**/*.js",
|
|
34
33
|
"src/**/*.d.ts",
|
package/dist/content-index.css
DELETED
package/dist/editor-index.css
DELETED
package/dist/index.css
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
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
|
-
import type { Delete, DeleteCommand, Input, InsertTextCommand, TextTransformation, TwoStepCaretMovement, Typing, TypingConfig } from './index.js';
|
|
10
|
-
declare module '@ckeditor/ckeditor5-core' {
|
|
11
|
-
interface EditorConfig {
|
|
12
|
-
/**
|
|
13
|
-
* The configuration of the typing features. Used by the features from the `@ckeditor/ckeditor5-typing` package.
|
|
14
|
-
*
|
|
15
|
-
* Read more in {@link module:typing/typingconfig~TypingConfig}.
|
|
16
|
-
*/
|
|
17
|
-
typing?: TypingConfig;
|
|
18
|
-
}
|
|
19
|
-
interface CommandsMap {
|
|
20
|
-
deleteForward: DeleteCommand;
|
|
21
|
-
delete: DeleteCommand;
|
|
22
|
-
insertText: InsertTextCommand;
|
|
23
|
-
}
|
|
24
|
-
interface PluginsMap {
|
|
25
|
-
[Delete.pluginName]: Delete;
|
|
26
|
-
[Input.pluginName]: Input;
|
|
27
|
-
[TextTransformation.pluginName]: TextTransformation;
|
|
28
|
-
[TwoStepCaretMovement.pluginName]: TwoStepCaretMovement;
|
|
29
|
-
[Typing.pluginName]: Typing;
|
|
30
|
-
}
|
|
31
|
-
}
|
package/dist/types/delete.d.ts
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
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 typing/delete
|
|
11
|
-
*/
|
|
12
|
-
import { Plugin } from '@ckeditor/ckeditor5-core';
|
|
13
|
-
/**
|
|
14
|
-
* The delete and backspace feature. Handles keys such as <kbd>Delete</kbd> and <kbd>Backspace</kbd>, other
|
|
15
|
-
* keystrokes and user actions that result in deleting content in the editor.
|
|
16
|
-
*/
|
|
17
|
-
export default class Delete extends Plugin {
|
|
18
|
-
/**
|
|
19
|
-
* Whether pressing backspace should trigger undo action
|
|
20
|
-
*/
|
|
21
|
-
private _undoOnBackspace;
|
|
22
|
-
/**
|
|
23
|
-
* @inheritDoc
|
|
24
|
-
*/
|
|
25
|
-
static get pluginName(): "Delete";
|
|
26
|
-
/**
|
|
27
|
-
* @inheritDoc
|
|
28
|
-
*/
|
|
29
|
-
init(): void;
|
|
30
|
-
/**
|
|
31
|
-
* If the next user action after calling this method is pressing backspace, it would undo the last change.
|
|
32
|
-
*
|
|
33
|
-
* Requires {@link module:undo/undoediting~UndoEditing} plugin. If not loaded, does nothing.
|
|
34
|
-
*/
|
|
35
|
-
requestUndoOnBackspace(): void;
|
|
36
|
-
}
|
|
@@ -1,87 +0,0 @@
|
|
|
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 typing/deletecommand
|
|
11
|
-
*/
|
|
12
|
-
import { Command, type Editor } from '@ckeditor/ckeditor5-core';
|
|
13
|
-
import type { DocumentSelection, Selection } from '@ckeditor/ckeditor5-engine';
|
|
14
|
-
import ChangeBuffer from './utils/changebuffer.js';
|
|
15
|
-
/**
|
|
16
|
-
* The delete command. Used by the {@link module:typing/delete~Delete delete feature} to handle the <kbd>Delete</kbd> and
|
|
17
|
-
* <kbd>Backspace</kbd> keys.
|
|
18
|
-
*/
|
|
19
|
-
export default class DeleteCommand extends Command {
|
|
20
|
-
/**
|
|
21
|
-
* The directionality of the delete describing in what direction it should
|
|
22
|
-
* consume the content when the selection is collapsed.
|
|
23
|
-
*/
|
|
24
|
-
readonly direction: 'forward' | 'backward';
|
|
25
|
-
/**
|
|
26
|
-
* Delete's change buffer used to group subsequent changes into batches.
|
|
27
|
-
*/
|
|
28
|
-
private readonly _buffer;
|
|
29
|
-
/**
|
|
30
|
-
* Creates an instance of the command.
|
|
31
|
-
*
|
|
32
|
-
* @param direction The directionality of the delete describing in what direction it
|
|
33
|
-
* should consume the content when the selection is collapsed.
|
|
34
|
-
*/
|
|
35
|
-
constructor(editor: Editor, direction: 'forward' | 'backward');
|
|
36
|
-
/**
|
|
37
|
-
* The current change buffer.
|
|
38
|
-
*/
|
|
39
|
-
get buffer(): ChangeBuffer;
|
|
40
|
-
/**
|
|
41
|
-
* Executes the delete command. Depending on whether the selection is collapsed or not, deletes its content
|
|
42
|
-
* or a piece of content in the {@link #direction defined direction}.
|
|
43
|
-
*
|
|
44
|
-
* @fires execute
|
|
45
|
-
* @param options The command options.
|
|
46
|
-
* @param options.unit See {@link module:engine/model/utils/modifyselection~modifySelection}'s options.
|
|
47
|
-
* @param options.sequence A number describing which subsequent delete event it is without the key being released.
|
|
48
|
-
* See the {@link module:engine/view/document~Document#event:delete} event data.
|
|
49
|
-
* @param options.selection Selection to remove. If not set, current model selection will be used.
|
|
50
|
-
*/
|
|
51
|
-
execute(options?: {
|
|
52
|
-
unit?: 'character' | 'codePoint' | 'word';
|
|
53
|
-
sequence?: number;
|
|
54
|
-
selection?: Selection | DocumentSelection;
|
|
55
|
-
}): void;
|
|
56
|
-
/**
|
|
57
|
-
* If the user keeps <kbd>Backspace</kbd> or <kbd>Delete</kbd> key pressed, the content of the current
|
|
58
|
-
* editable will be cleared. However, this will not yet lead to resetting the remaining block to a paragraph
|
|
59
|
-
* (which happens e.g. when the user does <kbd>Ctrl</kbd> + <kbd>A</kbd>, <kbd>Backspace</kbd>).
|
|
60
|
-
*
|
|
61
|
-
* But, if the user pressed the key in an empty editable for the first time,
|
|
62
|
-
* we want to replace the entire content with a paragraph if:
|
|
63
|
-
*
|
|
64
|
-
* * the current limit element is empty,
|
|
65
|
-
* * the paragraph is allowed in the limit element,
|
|
66
|
-
* * the limit doesn't already have a paragraph inside.
|
|
67
|
-
*
|
|
68
|
-
* See https://github.com/ckeditor/ckeditor5-typing/issues/61.
|
|
69
|
-
*
|
|
70
|
-
* @param sequence A number describing which subsequent delete event it is without the key being released.
|
|
71
|
-
*/
|
|
72
|
-
private _shouldEntireContentBeReplacedWithParagraph;
|
|
73
|
-
/**
|
|
74
|
-
* The entire content is replaced with the paragraph. Selection is moved inside the paragraph.
|
|
75
|
-
*
|
|
76
|
-
* @param writer The model writer.
|
|
77
|
-
*/
|
|
78
|
-
private _replaceEntireContentWithParagraph;
|
|
79
|
-
/**
|
|
80
|
-
* Checks if the selection is inside an empty element that is the first child of the limit element
|
|
81
|
-
* and should be replaced with a paragraph.
|
|
82
|
-
*
|
|
83
|
-
* @param selection The selection.
|
|
84
|
-
* @param sequence A number describing which subsequent delete event it is without the key being released.
|
|
85
|
-
*/
|
|
86
|
-
private _shouldReplaceFirstBlockWithParagraph;
|
|
87
|
-
}
|
|
@@ -1,59 +0,0 @@
|
|
|
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
|
-
import { DomEventData, Observer, type BubblingEvent, type ViewDocumentSelection, type ViewSelection, type EditingView } from '@ckeditor/ckeditor5-engine';
|
|
10
|
-
/**
|
|
11
|
-
* Delete observer introduces the {@link module:engine/view/document~Document#event:delete} event.
|
|
12
|
-
*/
|
|
13
|
-
export default class DeleteObserver extends Observer {
|
|
14
|
-
/**
|
|
15
|
-
* @inheritDoc
|
|
16
|
-
*/
|
|
17
|
-
constructor(view: EditingView);
|
|
18
|
-
/**
|
|
19
|
-
* @inheritDoc
|
|
20
|
-
*/
|
|
21
|
-
observe(): void;
|
|
22
|
-
/**
|
|
23
|
-
* @inheritDoc
|
|
24
|
-
*/
|
|
25
|
-
stopObserving(): void;
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* Event fired when the user tries to delete content (e.g. presses <kbd>Delete</kbd> or <kbd>Backspace</kbd>).
|
|
29
|
-
*
|
|
30
|
-
* Note: This event is fired by the {@link module:typing/deleteobserver~DeleteObserver delete observer}
|
|
31
|
-
* (usually registered by the {@link module:typing/delete~Delete delete feature}).
|
|
32
|
-
*
|
|
33
|
-
* @eventName module:engine/view/document~Document#delete
|
|
34
|
-
* @param data The event data.
|
|
35
|
-
*/
|
|
36
|
-
export type ViewDocumentDeleteEvent = BubblingEvent<{
|
|
37
|
-
name: 'delete';
|
|
38
|
-
args: [data: DeleteEventData];
|
|
39
|
-
}>;
|
|
40
|
-
export interface DeleteEventData extends DomEventData<InputEvent> {
|
|
41
|
-
/**
|
|
42
|
-
* The direction in which the deletion should happen.
|
|
43
|
-
*/
|
|
44
|
-
direction: 'backward' | 'forward';
|
|
45
|
-
/**
|
|
46
|
-
* The "amount" of content that should be deleted.
|
|
47
|
-
*/
|
|
48
|
-
unit: 'selection' | 'codePoint' | 'character' | 'word';
|
|
49
|
-
/**
|
|
50
|
-
* A number describing which subsequent delete event it is without the key being released.
|
|
51
|
-
* If it's 2 or more it means that the key was pressed and hold.
|
|
52
|
-
*/
|
|
53
|
-
sequence: number;
|
|
54
|
-
/**
|
|
55
|
-
* View selection which content should be removed. If not set,
|
|
56
|
-
* current selection should be used.
|
|
57
|
-
*/
|
|
58
|
-
selectionToRemove?: ViewSelection | ViewDocumentSelection;
|
|
59
|
-
}
|
package/dist/types/index.d.ts
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
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 typing
|
|
11
|
-
*/
|
|
12
|
-
export { default as Typing } from './typing.js';
|
|
13
|
-
export { default as Input } from './input.js';
|
|
14
|
-
export { default as Delete } from './delete.js';
|
|
15
|
-
export { default as TextWatcher } from './textwatcher.js';
|
|
16
|
-
export { default as TwoStepCaretMovement } from './twostepcaretmovement.js';
|
|
17
|
-
export { default as TextTransformation } from './texttransformation.js';
|
|
18
|
-
export { default as inlineHighlight } from './utils/inlinehighlight.js';
|
|
19
|
-
export { default as findAttributeRange, findAttributeRangeBound } from './utils/findattributerange.js';
|
|
20
|
-
export { default as getLastTextLine, type LastTextLineData } from './utils/getlasttextline.js';
|
|
21
|
-
export { default as InsertTextCommand, type InsertTextCommandExecuteEvent } from './inserttextcommand.js';
|
|
22
|
-
export type { default as DeleteCommand } from './deletecommand.js';
|
|
23
|
-
export type { TypingConfig } from './typingconfig.js';
|
|
24
|
-
export type { ViewDocumentDeleteEvent } from './deleteobserver.js';
|
|
25
|
-
export type { ViewDocumentInsertTextEvent, InsertTextEventData } from './inserttextobserver.js';
|
|
26
|
-
export type { TextWatcherMatchedEvent } from './textwatcher.js';
|
|
27
|
-
export type { TextWatcherMatchedDataEvent } from './textwatcher.js';
|
|
28
|
-
import './augmentation.js';
|
package/dist/types/input.d.ts
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
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 typing/input
|
|
11
|
-
*/
|
|
12
|
-
import { Plugin } from '@ckeditor/ckeditor5-core';
|
|
13
|
-
/**
|
|
14
|
-
* Handles text input coming from the keyboard or other input methods.
|
|
15
|
-
*/
|
|
16
|
-
export default class Input extends Plugin {
|
|
17
|
-
/**
|
|
18
|
-
* @inheritDoc
|
|
19
|
-
*/
|
|
20
|
-
static get pluginName(): "Input";
|
|
21
|
-
/**
|
|
22
|
-
* @inheritDoc
|
|
23
|
-
*/
|
|
24
|
-
init(): void;
|
|
25
|
-
}
|
|
@@ -1,80 +0,0 @@
|
|
|
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 typing/inserttextcommand
|
|
11
|
-
*/
|
|
12
|
-
import { Command, type Editor } from '@ckeditor/ckeditor5-core';
|
|
13
|
-
import ChangeBuffer from './utils/changebuffer.js';
|
|
14
|
-
import type { DocumentSelection, Range, Selection } from '@ckeditor/ckeditor5-engine';
|
|
15
|
-
/**
|
|
16
|
-
* The insert text command. Used by the {@link module:typing/input~Input input feature} to handle typing.
|
|
17
|
-
*/
|
|
18
|
-
export default class InsertTextCommand extends Command {
|
|
19
|
-
/**
|
|
20
|
-
* Typing's change buffer used to group subsequent changes into batches.
|
|
21
|
-
*/
|
|
22
|
-
private readonly _buffer;
|
|
23
|
-
/**
|
|
24
|
-
* Creates an instance of the command.
|
|
25
|
-
*
|
|
26
|
-
* @param undoStepSize The maximum number of atomic changes
|
|
27
|
-
* which can be contained in one batch in the command buffer.
|
|
28
|
-
*/
|
|
29
|
-
constructor(editor: Editor, undoStepSize: number);
|
|
30
|
-
/**
|
|
31
|
-
* The current change buffer.
|
|
32
|
-
*/
|
|
33
|
-
get buffer(): ChangeBuffer;
|
|
34
|
-
/**
|
|
35
|
-
* @inheritDoc
|
|
36
|
-
*/
|
|
37
|
-
destroy(): void;
|
|
38
|
-
/**
|
|
39
|
-
* Executes the input command. It replaces the content within the given range with the given text.
|
|
40
|
-
* Replacing is a two step process, first the content within the range is removed and then the new text is inserted
|
|
41
|
-
* at the beginning of the range (which after the removal is a collapsed range).
|
|
42
|
-
*
|
|
43
|
-
* @fires execute
|
|
44
|
-
* @param options The command options.
|
|
45
|
-
*/
|
|
46
|
-
execute(options?: InsertTextCommandOptions): void;
|
|
47
|
-
}
|
|
48
|
-
/**
|
|
49
|
-
* Interface with parameters for executing InsertTextCommand.
|
|
50
|
-
*
|
|
51
|
-
* Both `range` and `selection` parameters are used for defining selection but should not be used together.
|
|
52
|
-
* If both are defined, only `selection` will be considered.
|
|
53
|
-
*/
|
|
54
|
-
export interface InsertTextCommandOptions {
|
|
55
|
-
/**
|
|
56
|
-
* The text to be inserted.
|
|
57
|
-
*/
|
|
58
|
-
text?: string;
|
|
59
|
-
/**
|
|
60
|
-
* The selection in which the text is inserted.
|
|
61
|
-
* Inserting a text into a selection deletes the current content within selection ranges. If the selection is not specified,
|
|
62
|
-
* the current selection in the model will be used instead.
|
|
63
|
-
*/
|
|
64
|
-
selection?: Selection | DocumentSelection;
|
|
65
|
-
/**
|
|
66
|
-
* The range in which the text is inserted. Defaults to the first range in the current selection.
|
|
67
|
-
*/
|
|
68
|
-
range?: Range;
|
|
69
|
-
/**
|
|
70
|
-
* The range where the selection should be placed after the insertion.
|
|
71
|
-
* If not specified, the selection will be placed right after the inserted text.
|
|
72
|
-
*/
|
|
73
|
-
resultRange?: Range;
|
|
74
|
-
}
|
|
75
|
-
export interface InsertTextCommandExecuteEvent {
|
|
76
|
-
name: 'execute';
|
|
77
|
-
args: [
|
|
78
|
-
data: [options: InsertTextCommandOptions]
|
|
79
|
-
];
|
|
80
|
-
}
|
|
@@ -1,63 +0,0 @@
|
|
|
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
|
-
import { DomEventData, Observer, FocusObserver, type EditingView, type ViewDocumentSelection, type ViewRange, type ViewSelection } from '@ckeditor/ckeditor5-engine';
|
|
10
|
-
/**
|
|
11
|
-
* Text insertion observer introduces the {@link module:engine/view/document~Document#event:insertText} event.
|
|
12
|
-
*/
|
|
13
|
-
export default class InsertTextObserver extends Observer {
|
|
14
|
-
/**
|
|
15
|
-
* Instance of the focus observer. Insert text observer calls
|
|
16
|
-
* {@link module:engine/view/observer/focusobserver~FocusObserver#flush} to mark the latest focus change as complete.
|
|
17
|
-
*/
|
|
18
|
-
readonly focusObserver: FocusObserver;
|
|
19
|
-
/**
|
|
20
|
-
* @inheritDoc
|
|
21
|
-
*/
|
|
22
|
-
constructor(view: EditingView);
|
|
23
|
-
/**
|
|
24
|
-
* @inheritDoc
|
|
25
|
-
*/
|
|
26
|
-
observe(): void;
|
|
27
|
-
/**
|
|
28
|
-
* @inheritDoc
|
|
29
|
-
*/
|
|
30
|
-
stopObserving(): void;
|
|
31
|
-
}
|
|
32
|
-
/**
|
|
33
|
-
* Event fired when the user types text, for instance presses <kbd>A</kbd> or <kbd>?</kbd> in the
|
|
34
|
-
* editing view document.
|
|
35
|
-
*
|
|
36
|
-
* **Note**: This event will **not** fire for keystrokes such as <kbd>Delete</kbd> or <kbd>Enter</kbd>.
|
|
37
|
-
* They have dedicated events, see {@link module:engine/view/document~Document#event:delete} and
|
|
38
|
-
* {@link module:engine/view/document~Document#event:enter} to learn more.
|
|
39
|
-
*
|
|
40
|
-
* **Note**: This event is fired by the {@link module:typing/inserttextobserver~InsertTextObserver input feature}.
|
|
41
|
-
*
|
|
42
|
-
* @eventName module:engine/view/document~Document#insertText
|
|
43
|
-
* @param data The event data.
|
|
44
|
-
*/
|
|
45
|
-
export type ViewDocumentInsertTextEvent = {
|
|
46
|
-
name: 'insertText';
|
|
47
|
-
args: [data: InsertTextEventData];
|
|
48
|
-
};
|
|
49
|
-
export interface InsertTextEventData extends DomEventData {
|
|
50
|
-
/**
|
|
51
|
-
* The text to be inserted.
|
|
52
|
-
*/
|
|
53
|
-
text: string;
|
|
54
|
-
/**
|
|
55
|
-
* The selection into which the text should be inserted.
|
|
56
|
-
* If not specified, the insertion should occur at the current view selection.
|
|
57
|
-
*/
|
|
58
|
-
selection: ViewSelection | ViewDocumentSelection;
|
|
59
|
-
/**
|
|
60
|
-
* The range that view selection should be set to after insertion.
|
|
61
|
-
*/
|
|
62
|
-
resultRange?: ViewRange;
|
|
63
|
-
}
|
|
@@ -1,37 +0,0 @@
|
|
|
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 typing/texttransformation
|
|
11
|
-
*/
|
|
12
|
-
import { Plugin, type Editor } from '@ckeditor/ckeditor5-core';
|
|
13
|
-
/**
|
|
14
|
-
* The text transformation plugin.
|
|
15
|
-
*/
|
|
16
|
-
export default class TextTransformation extends Plugin {
|
|
17
|
-
/**
|
|
18
|
-
* @inheritDoc
|
|
19
|
-
*/
|
|
20
|
-
static get requires(): readonly ["Delete", "Input"];
|
|
21
|
-
/**
|
|
22
|
-
* @inheritDoc
|
|
23
|
-
*/
|
|
24
|
-
static get pluginName(): "TextTransformation";
|
|
25
|
-
/**
|
|
26
|
-
* @inheritDoc
|
|
27
|
-
*/
|
|
28
|
-
constructor(editor: Editor);
|
|
29
|
-
/**
|
|
30
|
-
* @inheritDoc
|
|
31
|
-
*/
|
|
32
|
-
init(): void;
|
|
33
|
-
/**
|
|
34
|
-
* Create new TextWatcher listening to the editor for typing and selection events.
|
|
35
|
-
*/
|
|
36
|
-
private _enableTransformationWatchers;
|
|
37
|
-
}
|
|
@@ -1,142 +0,0 @@
|
|
|
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
|
-
import type { Batch, Model, Range } from '@ckeditor/ckeditor5-engine';
|
|
10
|
-
declare const TextWatcher_base: {
|
|
11
|
-
new (): import("@ckeditor/ckeditor5-utils").Observable;
|
|
12
|
-
prototype: import("@ckeditor/ckeditor5-utils").Observable;
|
|
13
|
-
};
|
|
14
|
-
/**
|
|
15
|
-
* The text watcher feature.
|
|
16
|
-
*
|
|
17
|
-
* Fires the {@link module:typing/textwatcher~TextWatcher#event:matched:data `matched:data`},
|
|
18
|
-
* {@link module:typing/textwatcher~TextWatcher#event:matched:selection `matched:selection`} and
|
|
19
|
-
* {@link module:typing/textwatcher~TextWatcher#event:unmatched `unmatched`} events on typing or selection changes.
|
|
20
|
-
*/
|
|
21
|
-
export default class TextWatcher extends TextWatcher_base {
|
|
22
|
-
/**
|
|
23
|
-
* The editor's model.
|
|
24
|
-
*/
|
|
25
|
-
readonly model: Model;
|
|
26
|
-
/**
|
|
27
|
-
* The function used to match the text.
|
|
28
|
-
*
|
|
29
|
-
* The test callback can return 3 values:
|
|
30
|
-
*
|
|
31
|
-
* * `false` if there is no match,
|
|
32
|
-
* * `true` if there is a match,
|
|
33
|
-
* * an object if there is a match and we want to pass some additional information to the {@link #event:matched:data} event.
|
|
34
|
-
*/
|
|
35
|
-
testCallback: (text: string) => unknown;
|
|
36
|
-
/**
|
|
37
|
-
* Whether there is a match currently.
|
|
38
|
-
*/
|
|
39
|
-
private _hasMatch;
|
|
40
|
-
/**
|
|
41
|
-
* Flag indicating whether the `TextWatcher` instance is enabled or disabled.
|
|
42
|
-
* A disabled TextWatcher will not evaluate text.
|
|
43
|
-
*
|
|
44
|
-
* To disable TextWatcher:
|
|
45
|
-
*
|
|
46
|
-
* ```ts
|
|
47
|
-
* const watcher = new TextWatcher( editor.model, testCallback );
|
|
48
|
-
*
|
|
49
|
-
* // After this a testCallback will not be called.
|
|
50
|
-
* watcher.isEnabled = false;
|
|
51
|
-
* ```
|
|
52
|
-
*/
|
|
53
|
-
isEnabled: boolean;
|
|
54
|
-
/**
|
|
55
|
-
* Creates a text watcher instance.
|
|
56
|
-
*
|
|
57
|
-
* @param testCallback See {@link module:typing/textwatcher~TextWatcher#testCallback}.
|
|
58
|
-
*/
|
|
59
|
-
constructor(model: Model, testCallback: (text: string) => unknown);
|
|
60
|
-
/**
|
|
61
|
-
* Flag indicating whether there is a match currently.
|
|
62
|
-
*/
|
|
63
|
-
get hasMatch(): boolean;
|
|
64
|
-
/**
|
|
65
|
-
* Starts listening to the editor for typing and selection events.
|
|
66
|
-
*/
|
|
67
|
-
private _startListening;
|
|
68
|
-
/**
|
|
69
|
-
* Checks the editor content for matched text.
|
|
70
|
-
*
|
|
71
|
-
* @fires matched:data
|
|
72
|
-
* @fires matched:selection
|
|
73
|
-
* @fires unmatched
|
|
74
|
-
*
|
|
75
|
-
* @param suffix A suffix used for generating the event name.
|
|
76
|
-
* @param data Data object for event.
|
|
77
|
-
*/
|
|
78
|
-
private _evaluateTextBeforeSelection;
|
|
79
|
-
}
|
|
80
|
-
export type TextWatcherMatchedEvent<TCallbackResult extends Record<string, unknown> = Record<string, unknown>> = {
|
|
81
|
-
name: 'matched' | 'matched:data' | 'matched:selection';
|
|
82
|
-
args: [
|
|
83
|
-
{
|
|
84
|
-
text: string;
|
|
85
|
-
range: Range;
|
|
86
|
-
batch?: Batch;
|
|
87
|
-
} & TCallbackResult
|
|
88
|
-
];
|
|
89
|
-
};
|
|
90
|
-
/**
|
|
91
|
-
* Fired whenever the text watcher found a match for data changes.
|
|
92
|
-
*
|
|
93
|
-
* @eventName ~TextWatcher#matched:data
|
|
94
|
-
* @param data Event data.
|
|
95
|
-
* @param data.testResult The additional data returned from the {@link module:typing/textwatcher~TextWatcher#testCallback}.
|
|
96
|
-
*/
|
|
97
|
-
export type TextWatcherMatchedDataEvent<TCallbackResult extends Record<string, unknown>> = {
|
|
98
|
-
name: 'matched:data';
|
|
99
|
-
args: [data: TextWatcherMatchedDataEventData & TCallbackResult];
|
|
100
|
-
};
|
|
101
|
-
export interface TextWatcherMatchedDataEventData {
|
|
102
|
-
/**
|
|
103
|
-
* The full text before selection to which the regexp was applied.
|
|
104
|
-
*/
|
|
105
|
-
text: string;
|
|
106
|
-
/**
|
|
107
|
-
* The range representing the position of the `data.text`.
|
|
108
|
-
*/
|
|
109
|
-
range: Range;
|
|
110
|
-
batch: Batch;
|
|
111
|
-
}
|
|
112
|
-
/**
|
|
113
|
-
* Fired whenever the text watcher found a match for selection changes.
|
|
114
|
-
*
|
|
115
|
-
* @eventName ~TextWatcher#matched:selection
|
|
116
|
-
* @param data Event data.
|
|
117
|
-
* @param data.testResult The additional data returned from the {@link module:typing/textwatcher~TextWatcher#testCallback}.
|
|
118
|
-
*/
|
|
119
|
-
export type TextWatcherMatchedSelectionEvent<TCallbackResult extends Record<string, unknown>> = {
|
|
120
|
-
name: 'matched:selection';
|
|
121
|
-
args: [data: TextWatcherMatchedSelectionEventData & TCallbackResult];
|
|
122
|
-
};
|
|
123
|
-
export interface TextWatcherMatchedSelectionEventData {
|
|
124
|
-
/**
|
|
125
|
-
* The full text before selection.
|
|
126
|
-
*/
|
|
127
|
-
text: string;
|
|
128
|
-
/**
|
|
129
|
-
* The range representing the position of the `data.text`.
|
|
130
|
-
*/
|
|
131
|
-
range: Range;
|
|
132
|
-
}
|
|
133
|
-
/**
|
|
134
|
-
* Fired whenever the text does not match anymore. Fired only when the text watcher found a match.
|
|
135
|
-
*
|
|
136
|
-
* @eventName ~TextWatcher#unmatched
|
|
137
|
-
*/
|
|
138
|
-
export type TextWatcherUnmatchedEvent = {
|
|
139
|
-
name: 'unmatched';
|
|
140
|
-
args: [];
|
|
141
|
-
};
|
|
142
|
-
export {};
|