@ckeditor/ckeditor5-typing 45.2.1 → 46.0.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/index.js +31 -29
- package/dist/index.js.map +1 -1
- package/package.json +5 -5
- package/src/delete.d.ts +1 -1
- package/src/delete.js +5 -5
- package/src/deletecommand.d.ts +6 -6
- package/src/deletecommand.js +4 -4
- package/src/deleteobserver.d.ts +7 -5
- package/src/deleteobserver.js +7 -5
- package/src/index.d.ts +16 -15
- package/src/index.js +13 -10
- package/src/input.d.ts +1 -1
- package/src/input.js +6 -6
- package/src/inserttextcommand.d.ts +7 -7
- package/src/inserttextcommand.js +4 -4
- package/src/inserttextobserver.d.ts +10 -10
- package/src/inserttextobserver.js +5 -5
- package/src/texttransformation.d.ts +1 -1
- package/src/texttransformation.js +2 -2
- package/src/textwatcher.d.ts +11 -11
- package/src/textwatcher.js +2 -2
- package/src/twostepcaretmovement.d.ts +14 -14
- package/src/twostepcaretmovement.js +12 -12
- package/src/typing.d.ts +3 -3
- package/src/typing.js +3 -3
- package/src/typingconfig.d.ts +4 -4
- package/src/utils/changebuffer.d.ts +2 -2
- package/src/utils/changebuffer.js +2 -2
- package/src/utils/findattributerange.d.ts +3 -3
- package/src/utils/findattributerange.js +1 -1
- package/src/utils/getlasttextline.d.ts +3 -3
- package/src/utils/getlasttextline.js +1 -1
- package/src/utils/inlinehighlight.d.ts +2 -2
- package/src/utils/inlinehighlight.js +3 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ckeditor/ckeditor5-typing",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "46.0.0-alpha.1",
|
|
4
4
|
"description": "Typing feature for CKEditor 5.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ckeditor",
|
|
@@ -13,10 +13,10 @@
|
|
|
13
13
|
"type": "module",
|
|
14
14
|
"main": "src/index.js",
|
|
15
15
|
"dependencies": {
|
|
16
|
-
"@ckeditor/ckeditor5-core": "
|
|
17
|
-
"@ckeditor/ckeditor5-engine": "
|
|
18
|
-
"@ckeditor/ckeditor5-utils": "
|
|
19
|
-
"es-toolkit": "1.
|
|
16
|
+
"@ckeditor/ckeditor5-core": "46.0.0-alpha.1",
|
|
17
|
+
"@ckeditor/ckeditor5-engine": "46.0.0-alpha.1",
|
|
18
|
+
"@ckeditor/ckeditor5-utils": "46.0.0-alpha.1",
|
|
19
|
+
"es-toolkit": "1.39.5"
|
|
20
20
|
},
|
|
21
21
|
"author": "CKSource (http://cksource.com/)",
|
|
22
22
|
"license": "SEE LICENSE IN LICENSE.md",
|
package/src/delete.d.ts
CHANGED
|
@@ -7,7 +7,7 @@ import { Plugin } from '@ckeditor/ckeditor5-core';
|
|
|
7
7
|
* The delete and backspace feature. Handles keys such as <kbd>Delete</kbd> and <kbd>Backspace</kbd>, other
|
|
8
8
|
* keystrokes and user actions that result in deleting content in the editor.
|
|
9
9
|
*/
|
|
10
|
-
export
|
|
10
|
+
export declare class Delete extends Plugin {
|
|
11
11
|
/**
|
|
12
12
|
* Whether pressing backspace should trigger undo action
|
|
13
13
|
*/
|
package/src/delete.js
CHANGED
|
@@ -5,16 +5,16 @@
|
|
|
5
5
|
/**
|
|
6
6
|
* @module typing/delete
|
|
7
7
|
*/
|
|
8
|
-
import { _tryFixingModelRange, BubblingEventInfo,
|
|
8
|
+
import { _tryFixingModelRange, BubblingEventInfo, ViewDocumentDomEventData } from '@ckeditor/ckeditor5-engine';
|
|
9
9
|
import { Plugin } from '@ckeditor/ckeditor5-core';
|
|
10
10
|
import { keyCodes } from '@ckeditor/ckeditor5-utils';
|
|
11
|
-
import DeleteCommand from './deletecommand.js';
|
|
12
|
-
import DeleteObserver from './deleteobserver.js';
|
|
11
|
+
import { DeleteCommand } from './deletecommand.js';
|
|
12
|
+
import { DeleteObserver } from './deleteobserver.js';
|
|
13
13
|
/**
|
|
14
14
|
* The delete and backspace feature. Handles keys such as <kbd>Delete</kbd> and <kbd>Backspace</kbd>, other
|
|
15
15
|
* keystrokes and user actions that result in deleting content in the editor.
|
|
16
16
|
*/
|
|
17
|
-
export
|
|
17
|
+
export class Delete extends Plugin {
|
|
18
18
|
/**
|
|
19
19
|
* Whether pressing backspace should trigger undo action
|
|
20
20
|
*/
|
|
@@ -92,7 +92,7 @@ export default class Delete extends Plugin {
|
|
|
92
92
|
direction: 'backward',
|
|
93
93
|
selectionToRemove: viewSelection
|
|
94
94
|
};
|
|
95
|
-
viewDocument.fire(eventInfo, new
|
|
95
|
+
viewDocument.fire(eventInfo, new ViewDocumentDomEventData(view, data.domEvent, deleteData));
|
|
96
96
|
}
|
|
97
97
|
});
|
|
98
98
|
if (this.editor.plugins.has('UndoEditing')) {
|
package/src/deletecommand.d.ts
CHANGED
|
@@ -6,13 +6,13 @@
|
|
|
6
6
|
* @module typing/deletecommand
|
|
7
7
|
*/
|
|
8
8
|
import { Command, type Editor } from '@ckeditor/ckeditor5-core';
|
|
9
|
-
import type {
|
|
10
|
-
import
|
|
9
|
+
import type { ModelDocumentSelection, ModelSelection } from '@ckeditor/ckeditor5-engine';
|
|
10
|
+
import { TypingChangeBuffer } from './utils/changebuffer.js';
|
|
11
11
|
/**
|
|
12
12
|
* The delete command. Used by the {@link module:typing/delete~Delete delete feature} to handle the <kbd>Delete</kbd> and
|
|
13
13
|
* <kbd>Backspace</kbd> keys.
|
|
14
14
|
*/
|
|
15
|
-
export
|
|
15
|
+
export declare class DeleteCommand extends Command {
|
|
16
16
|
/**
|
|
17
17
|
* The directionality of the delete describing in what direction it should
|
|
18
18
|
* consume the content when the selection is collapsed.
|
|
@@ -32,7 +32,7 @@ export default class DeleteCommand extends Command {
|
|
|
32
32
|
/**
|
|
33
33
|
* The current change buffer.
|
|
34
34
|
*/
|
|
35
|
-
get buffer():
|
|
35
|
+
get buffer(): TypingChangeBuffer;
|
|
36
36
|
/**
|
|
37
37
|
* Executes the delete command. Depending on whether the selection is collapsed or not, deletes its content
|
|
38
38
|
* or a piece of content in the {@link #direction defined direction}.
|
|
@@ -41,13 +41,13 @@ export default class DeleteCommand extends Command {
|
|
|
41
41
|
* @param options The command options.
|
|
42
42
|
* @param options.unit See {@link module:engine/model/utils/modifyselection~modifySelection}'s options.
|
|
43
43
|
* @param options.sequence A number describing which subsequent delete event it is without the key being released.
|
|
44
|
-
* See the {@link module:engine/view/document~
|
|
44
|
+
* See the {@link module:engine/view/document~ViewDocument#event:delete} event data.
|
|
45
45
|
* @param options.selection Selection to remove. If not set, current model selection will be used.
|
|
46
46
|
*/
|
|
47
47
|
execute(options?: {
|
|
48
48
|
unit?: 'character' | 'codePoint' | 'word';
|
|
49
49
|
sequence?: number;
|
|
50
|
-
selection?:
|
|
50
|
+
selection?: ModelSelection | ModelDocumentSelection;
|
|
51
51
|
}): void;
|
|
52
52
|
/**
|
|
53
53
|
* If the user keeps <kbd>Backspace</kbd> or <kbd>Delete</kbd> key pressed, the content of the current
|
package/src/deletecommand.js
CHANGED
|
@@ -7,13 +7,13 @@
|
|
|
7
7
|
*/
|
|
8
8
|
import { Command } from '@ckeditor/ckeditor5-core';
|
|
9
9
|
import { count } from '@ckeditor/ckeditor5-utils';
|
|
10
|
-
import
|
|
10
|
+
import { TypingChangeBuffer } from './utils/changebuffer.js';
|
|
11
11
|
// @if CK_DEBUG_TYPING // const { _buildLogMessage } = require( '@ckeditor/ckeditor5-engine/src/dev-utils/utils.js' );
|
|
12
12
|
/**
|
|
13
13
|
* The delete command. Used by the {@link module:typing/delete~Delete delete feature} to handle the <kbd>Delete</kbd> and
|
|
14
14
|
* <kbd>Backspace</kbd> keys.
|
|
15
15
|
*/
|
|
16
|
-
export
|
|
16
|
+
export class DeleteCommand extends Command {
|
|
17
17
|
/**
|
|
18
18
|
* The directionality of the delete describing in what direction it should
|
|
19
19
|
* consume the content when the selection is collapsed.
|
|
@@ -32,7 +32,7 @@ export default class DeleteCommand extends Command {
|
|
|
32
32
|
constructor(editor, direction) {
|
|
33
33
|
super(editor);
|
|
34
34
|
this.direction = direction;
|
|
35
|
-
this._buffer = new
|
|
35
|
+
this._buffer = new TypingChangeBuffer(editor.model, editor.config.get('typing.undoStep'));
|
|
36
36
|
// Since this command may execute on different selectable than selection, it should be checked directly in execute block.
|
|
37
37
|
this._isEnabledBasedOnSelection = false;
|
|
38
38
|
}
|
|
@@ -50,7 +50,7 @@ export default class DeleteCommand extends Command {
|
|
|
50
50
|
* @param options The command options.
|
|
51
51
|
* @param options.unit See {@link module:engine/model/utils/modifyselection~modifySelection}'s options.
|
|
52
52
|
* @param options.sequence A number describing which subsequent delete event it is without the key being released.
|
|
53
|
-
* See the {@link module:engine/view/document~
|
|
53
|
+
* See the {@link module:engine/view/document~ViewDocument#event:delete} event data.
|
|
54
54
|
* @param options.selection Selection to remove. If not set, current model selection will be used.
|
|
55
55
|
*/
|
|
56
56
|
execute(options = {}) {
|
package/src/deleteobserver.d.ts
CHANGED
|
@@ -2,11 +2,13 @@
|
|
|
2
2
|
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
3
|
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
|
|
4
4
|
*/
|
|
5
|
-
import {
|
|
5
|
+
import { ViewDocumentDomEventData, Observer, type BubblingEvent, type ViewDocumentSelection, type ViewSelection, type EditingView } from '@ckeditor/ckeditor5-engine';
|
|
6
6
|
/**
|
|
7
|
-
* Delete observer introduces the {@link module:engine/view/document~
|
|
7
|
+
* Delete observer introduces the {@link module:engine/view/document~ViewDocument#event:delete} event.
|
|
8
|
+
*
|
|
9
|
+
* @internal
|
|
8
10
|
*/
|
|
9
|
-
export
|
|
11
|
+
export declare class DeleteObserver extends Observer {
|
|
10
12
|
/**
|
|
11
13
|
* @inheritDoc
|
|
12
14
|
*/
|
|
@@ -26,14 +28,14 @@ export default class DeleteObserver extends Observer {
|
|
|
26
28
|
* Note: This event is fired by the {@link module:typing/deleteobserver~DeleteObserver delete observer}
|
|
27
29
|
* (usually registered by the {@link module:typing/delete~Delete delete feature}).
|
|
28
30
|
*
|
|
29
|
-
* @eventName module:engine/view/document~
|
|
31
|
+
* @eventName module:engine/view/document~ViewDocument#delete
|
|
30
32
|
* @param data The event data.
|
|
31
33
|
*/
|
|
32
34
|
export type ViewDocumentDeleteEvent = BubblingEvent<{
|
|
33
35
|
name: 'delete';
|
|
34
36
|
args: [data: DeleteEventData];
|
|
35
37
|
}>;
|
|
36
|
-
export interface DeleteEventData extends
|
|
38
|
+
export interface DeleteEventData extends ViewDocumentDomEventData<InputEvent> {
|
|
37
39
|
/**
|
|
38
40
|
* The direction in which the deletion should happen.
|
|
39
41
|
*/
|
package/src/deleteobserver.js
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* @module typing/deleteobserver
|
|
7
7
|
*/
|
|
8
8
|
import { env, keyCodes, isInsideCombinedSymbol, isInsideEmojiSequence, isInsideSurrogatePair } from '@ckeditor/ckeditor5-utils';
|
|
9
|
-
import { BubblingEventInfo,
|
|
9
|
+
import { BubblingEventInfo, ViewDocumentDomEventData, Observer } from '@ckeditor/ckeditor5-engine';
|
|
10
10
|
const DELETE_CHARACTER = 'character';
|
|
11
11
|
const DELETE_WORD = 'word';
|
|
12
12
|
const DELETE_CODE_POINT = 'codePoint';
|
|
@@ -93,9 +93,11 @@ const DELETE_EVENT_TYPES = {
|
|
|
93
93
|
}
|
|
94
94
|
};
|
|
95
95
|
/**
|
|
96
|
-
* Delete observer introduces the {@link module:engine/view/document~
|
|
96
|
+
* Delete observer introduces the {@link module:engine/view/document~ViewDocument#event:delete} event.
|
|
97
|
+
*
|
|
98
|
+
* @internal
|
|
97
99
|
*/
|
|
98
|
-
export
|
|
100
|
+
export class DeleteObserver extends Observer {
|
|
99
101
|
/**
|
|
100
102
|
* @inheritDoc
|
|
101
103
|
*/
|
|
@@ -146,7 +148,7 @@ export default class DeleteObserver extends Observer {
|
|
|
146
148
|
}
|
|
147
149
|
}
|
|
148
150
|
const eventInfo = new BubblingEventInfo(document, 'delete', targetRanges[0]);
|
|
149
|
-
document.fire(eventInfo, new
|
|
151
|
+
document.fire(eventInfo, new ViewDocumentDomEventData(view, domEvent, deleteData));
|
|
150
152
|
// Stop the beforeinput event if `delete` event was stopped.
|
|
151
153
|
// https://github.com/ckeditor/ckeditor5/issues/753
|
|
152
154
|
if (eventInfo.stop.called) {
|
|
@@ -195,7 +197,7 @@ function enableChromeWorkaround(observer) {
|
|
|
195
197
|
direction: getDeleteDirection(keyCode),
|
|
196
198
|
selectionToRemove: selection
|
|
197
199
|
};
|
|
198
|
-
document.fire(eventInfo, new
|
|
200
|
+
document.fire(eventInfo, new ViewDocumentDomEventData(view, domEvent, deleteData));
|
|
199
201
|
}
|
|
200
202
|
});
|
|
201
203
|
document.on('beforeinput', (evt, { inputType }) => {
|
package/src/index.d.ts
CHANGED
|
@@ -5,21 +5,22 @@
|
|
|
5
5
|
/**
|
|
6
6
|
* @module typing
|
|
7
7
|
*/
|
|
8
|
-
export {
|
|
9
|
-
export {
|
|
10
|
-
export {
|
|
11
|
-
export {
|
|
12
|
-
export {
|
|
13
|
-
export {
|
|
8
|
+
export { Typing } from './typing.js';
|
|
9
|
+
export { Input } from './input.js';
|
|
10
|
+
export { Delete } from './delete.js';
|
|
11
|
+
export { TextWatcher } from './textwatcher.js';
|
|
12
|
+
export { TwoStepCaretMovement } from './twostepcaretmovement.js';
|
|
13
|
+
export { TextTransformation } from './texttransformation.js';
|
|
14
14
|
export type { TextTransformationConfig } from './typingconfig.js';
|
|
15
|
-
export {
|
|
16
|
-
export {
|
|
17
|
-
export {
|
|
18
|
-
export {
|
|
19
|
-
export type
|
|
20
|
-
export
|
|
15
|
+
export { inlineHighlight } from './utils/inlinehighlight.js';
|
|
16
|
+
export { findAttributeRange, findAttributeRangeBound } from './utils/findattributerange.js';
|
|
17
|
+
export { getLastTextLine, type LastTextLineData } from './utils/getlasttextline.js';
|
|
18
|
+
export { TypingChangeBuffer } from './utils/changebuffer.js';
|
|
19
|
+
export { InsertTextCommand, type InsertTextCommandExecuteEvent, type InsertTextCommandOptions } from './inserttextcommand.js';
|
|
20
|
+
export { DeleteCommand } from './deletecommand.js';
|
|
21
|
+
export { DeleteObserver as _DeleteObserver, type DeleteEventData } from './deleteobserver.js';
|
|
22
|
+
export type { TypingConfig, TextTypingTransformationDescription } from './typingconfig.js';
|
|
21
23
|
export type { ViewDocumentDeleteEvent } from './deleteobserver.js';
|
|
22
|
-
export type { ViewDocumentInsertTextEvent, InsertTextEventData } from './inserttextobserver.js';
|
|
23
|
-
export type { TextWatcherMatchedEvent } from './textwatcher.js';
|
|
24
|
-
export type { TextWatcherMatchedDataEvent } from './textwatcher.js';
|
|
24
|
+
export type { ViewDocumentInsertTextEvent, InsertTextEventData, InsertTextObserver } from './inserttextobserver.js';
|
|
25
|
+
export type { TextWatcherMatchedEvent, TextWatcherMatchedDataEvent, TextWatcherMatchedTypingDataEventData, TextWatcherMatchedTypingSelectionEvent, TextWatcherMatchedTypingSelectionEventData, TextWatcherUnmatchedTypingEvent } from './textwatcher.js';
|
|
25
26
|
import './augmentation.js';
|
package/src/index.js
CHANGED
|
@@ -5,14 +5,17 @@
|
|
|
5
5
|
/**
|
|
6
6
|
* @module typing
|
|
7
7
|
*/
|
|
8
|
-
export {
|
|
9
|
-
export {
|
|
10
|
-
export {
|
|
11
|
-
export {
|
|
12
|
-
export {
|
|
13
|
-
export {
|
|
14
|
-
export {
|
|
15
|
-
export {
|
|
16
|
-
export {
|
|
17
|
-
export {
|
|
8
|
+
export { Typing } from './typing.js';
|
|
9
|
+
export { Input } from './input.js';
|
|
10
|
+
export { Delete } from './delete.js';
|
|
11
|
+
export { TextWatcher } from './textwatcher.js';
|
|
12
|
+
export { TwoStepCaretMovement } from './twostepcaretmovement.js';
|
|
13
|
+
export { TextTransformation } from './texttransformation.js';
|
|
14
|
+
export { inlineHighlight } from './utils/inlinehighlight.js';
|
|
15
|
+
export { findAttributeRange, findAttributeRangeBound } from './utils/findattributerange.js';
|
|
16
|
+
export { getLastTextLine } from './utils/getlasttextline.js';
|
|
17
|
+
export { TypingChangeBuffer } from './utils/changebuffer.js';
|
|
18
|
+
export { InsertTextCommand } from './inserttextcommand.js';
|
|
19
|
+
export { DeleteCommand } from './deletecommand.js';
|
|
20
|
+
export { DeleteObserver as _DeleteObserver } from './deleteobserver.js';
|
|
18
21
|
import './augmentation.js';
|
package/src/input.d.ts
CHANGED
|
@@ -9,7 +9,7 @@ import { Plugin } from '@ckeditor/ckeditor5-core';
|
|
|
9
9
|
/**
|
|
10
10
|
* Handles text input coming from the keyboard or other input methods.
|
|
11
11
|
*/
|
|
12
|
-
export
|
|
12
|
+
export declare class Input extends Plugin {
|
|
13
13
|
/**
|
|
14
14
|
* The queue of `insertText` command executions that are waiting for the DOM to get updated after beforeinput event.
|
|
15
15
|
*/
|
package/src/input.js
CHANGED
|
@@ -7,15 +7,15 @@
|
|
|
7
7
|
*/
|
|
8
8
|
import { Plugin } from '@ckeditor/ckeditor5-core';
|
|
9
9
|
import { env } from '@ckeditor/ckeditor5-utils';
|
|
10
|
-
import InsertTextCommand from './inserttextcommand.js';
|
|
11
|
-
import InsertTextObserver from './inserttextobserver.js';
|
|
12
|
-
import {
|
|
10
|
+
import { InsertTextCommand } from './inserttextcommand.js';
|
|
11
|
+
import { InsertTextObserver } from './inserttextobserver.js';
|
|
12
|
+
import { ModelLiveRange, _tryFixingModelRange } from '@ckeditor/ckeditor5-engine';
|
|
13
13
|
import { debounce } from 'es-toolkit/compat';
|
|
14
14
|
// @if CK_DEBUG_TYPING // const { _debouncedLine, _buildLogMessage } = require( '@ckeditor/ckeditor5-engine/src/dev-utils/utils.js' );
|
|
15
15
|
/**
|
|
16
16
|
* Handles text input coming from the keyboard or other input methods.
|
|
17
17
|
*/
|
|
18
|
-
export
|
|
18
|
+
export class Input extends Plugin {
|
|
19
19
|
/**
|
|
20
20
|
* The queue of `insertText` command executions that are waiting for the DOM to get updated after beforeinput event.
|
|
21
21
|
*/
|
|
@@ -332,7 +332,7 @@ class TypingQueue {
|
|
|
332
332
|
if (commandData.selection) {
|
|
333
333
|
commandLiveData.selectionRanges = [];
|
|
334
334
|
for (const range of commandData.selection.getRanges()) {
|
|
335
|
-
commandLiveData.selectionRanges.push(
|
|
335
|
+
commandLiveData.selectionRanges.push(ModelLiveRange.fromRange(range));
|
|
336
336
|
// Keep reference to the model element for later mutation checks.
|
|
337
337
|
this._affectedElements.add(range.start.parent);
|
|
338
338
|
}
|
|
@@ -453,7 +453,7 @@ function deleteSelectionContent(model, insertTextCommand) {
|
|
|
453
453
|
buffer.unlock();
|
|
454
454
|
}
|
|
455
455
|
/**
|
|
456
|
-
* Detaches a
|
|
456
|
+
* Detaches a ModelLiveRange and returns the static range from it.
|
|
457
457
|
*/
|
|
458
458
|
function detachLiveRange(liveRange) {
|
|
459
459
|
const range = liveRange.toRange();
|
|
@@ -6,12 +6,12 @@
|
|
|
6
6
|
* @module typing/inserttextcommand
|
|
7
7
|
*/
|
|
8
8
|
import { Command, type Editor } from '@ckeditor/ckeditor5-core';
|
|
9
|
-
import
|
|
10
|
-
import type {
|
|
9
|
+
import { TypingChangeBuffer } from './utils/changebuffer.js';
|
|
10
|
+
import type { ModelDocumentSelection, ModelRange, ModelSelection } from '@ckeditor/ckeditor5-engine';
|
|
11
11
|
/**
|
|
12
12
|
* The insert text command. Used by the {@link module:typing/input~Input input feature} to handle typing.
|
|
13
13
|
*/
|
|
14
|
-
export
|
|
14
|
+
export declare class InsertTextCommand extends Command {
|
|
15
15
|
/**
|
|
16
16
|
* Typing's change buffer used to group subsequent changes into batches.
|
|
17
17
|
*/
|
|
@@ -26,7 +26,7 @@ export default class InsertTextCommand extends Command {
|
|
|
26
26
|
/**
|
|
27
27
|
* The current change buffer.
|
|
28
28
|
*/
|
|
29
|
-
get buffer():
|
|
29
|
+
get buffer(): TypingChangeBuffer;
|
|
30
30
|
/**
|
|
31
31
|
* @inheritDoc
|
|
32
32
|
*/
|
|
@@ -57,16 +57,16 @@ export interface InsertTextCommandOptions {
|
|
|
57
57
|
* Inserting a text into a selection deletes the current content within selection ranges. If the selection is not specified,
|
|
58
58
|
* the current selection in the model will be used instead.
|
|
59
59
|
*/
|
|
60
|
-
selection?:
|
|
60
|
+
selection?: ModelSelection | ModelDocumentSelection;
|
|
61
61
|
/**
|
|
62
62
|
* The range in which the text is inserted. Defaults to the first range in the current selection.
|
|
63
63
|
*/
|
|
64
|
-
range?:
|
|
64
|
+
range?: ModelRange;
|
|
65
65
|
/**
|
|
66
66
|
* The range where the selection should be placed after the insertion.
|
|
67
67
|
* If not specified, the selection will be placed right after the inserted text.
|
|
68
68
|
*/
|
|
69
|
-
resultRange?:
|
|
69
|
+
resultRange?: ModelRange;
|
|
70
70
|
}
|
|
71
71
|
export interface InsertTextCommandExecuteEvent {
|
|
72
72
|
name: 'execute';
|
package/src/inserttextcommand.js
CHANGED
|
@@ -6,11 +6,11 @@
|
|
|
6
6
|
* @module typing/inserttextcommand
|
|
7
7
|
*/
|
|
8
8
|
import { Command } from '@ckeditor/ckeditor5-core';
|
|
9
|
-
import
|
|
9
|
+
import { TypingChangeBuffer } from './utils/changebuffer.js';
|
|
10
10
|
/**
|
|
11
11
|
* The insert text command. Used by the {@link module:typing/input~Input input feature} to handle typing.
|
|
12
12
|
*/
|
|
13
|
-
export
|
|
13
|
+
export class InsertTextCommand extends Command {
|
|
14
14
|
/**
|
|
15
15
|
* Typing's change buffer used to group subsequent changes into batches.
|
|
16
16
|
*/
|
|
@@ -23,7 +23,7 @@ export default class InsertTextCommand extends Command {
|
|
|
23
23
|
*/
|
|
24
24
|
constructor(editor, undoStepSize) {
|
|
25
25
|
super(editor);
|
|
26
|
-
this._buffer = new
|
|
26
|
+
this._buffer = new TypingChangeBuffer(editor.model, undoStepSize);
|
|
27
27
|
// Since this command may execute on different selectable than selection, it should be checked directly in execute block.
|
|
28
28
|
this._isEnabledBasedOnSelection = false;
|
|
29
29
|
}
|
|
@@ -68,7 +68,7 @@ export default class InsertTextCommand extends Command {
|
|
|
68
68
|
model.enqueueChange(this._buffer.batch, writer => {
|
|
69
69
|
this._buffer.lock();
|
|
70
70
|
// Store selection attributes before deleting old content to preserve formatting and link.
|
|
71
|
-
// This unifies the behavior between
|
|
71
|
+
// This unifies the behavior between ModelDocumentSelection and Selection provided as input option.
|
|
72
72
|
const selectionAttributes = Array.from(doc.selection.getAttributes());
|
|
73
73
|
model.deleteContent(selection);
|
|
74
74
|
if (text) {
|
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
3
|
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
|
|
4
4
|
*/
|
|
5
|
-
import {
|
|
5
|
+
import { ViewDocumentDomEventData, Observer, FocusObserver, type EditingView, type ViewDocumentSelection, type ViewSelection } from '@ckeditor/ckeditor5-engine';
|
|
6
6
|
/**
|
|
7
|
-
* Text insertion observer introduces the {@link module:engine/view/document~
|
|
7
|
+
* Text insertion observer introduces the {@link module:engine/view/document~ViewDocument#event:insertText} event.
|
|
8
8
|
*/
|
|
9
|
-
export
|
|
9
|
+
export declare class InsertTextObserver extends Observer {
|
|
10
10
|
/**
|
|
11
11
|
* Instance of the focus observer. Insert text observer calls
|
|
12
12
|
* {@link module:engine/view/observer/focusobserver~FocusObserver#flush} to mark the latest focus change as complete.
|
|
@@ -30,19 +30,19 @@ export default class InsertTextObserver extends Observer {
|
|
|
30
30
|
* editing view document.
|
|
31
31
|
*
|
|
32
32
|
* **Note**: This event will **not** fire for keystrokes such as <kbd>Delete</kbd> or <kbd>Enter</kbd>.
|
|
33
|
-
* They have dedicated events, see {@link module:engine/view/document~
|
|
34
|
-
* {@link module:engine/view/document~
|
|
33
|
+
* They have dedicated events, see {@link module:engine/view/document~ViewDocument#event:delete} and
|
|
34
|
+
* {@link module:engine/view/document~ViewDocument#event:enter} to learn more.
|
|
35
35
|
*
|
|
36
36
|
* **Note**: This event is fired by the {@link module:typing/inserttextobserver~InsertTextObserver input feature}.
|
|
37
37
|
*
|
|
38
|
-
* @eventName module:engine/view/document~
|
|
38
|
+
* @eventName module:engine/view/document~ViewDocument#insertText
|
|
39
39
|
* @param data The event data.
|
|
40
40
|
*/
|
|
41
41
|
export type ViewDocumentInsertTextEvent = {
|
|
42
42
|
name: 'insertText';
|
|
43
43
|
args: [data: InsertTextEventData];
|
|
44
44
|
};
|
|
45
|
-
export interface InsertTextEventData extends
|
|
45
|
+
export interface InsertTextEventData extends ViewDocumentDomEventData {
|
|
46
46
|
/**
|
|
47
47
|
* The text to be inserted.
|
|
48
48
|
*/
|
|
@@ -56,9 +56,9 @@ export interface InsertTextEventData extends DomEventData {
|
|
|
56
56
|
* A flag indicating that event was fired during composition.
|
|
57
57
|
*
|
|
58
58
|
* Corresponds to the
|
|
59
|
-
* {@link module:engine/view/document~
|
|
60
|
-
* {@link module:engine/view/document~
|
|
61
|
-
* and {@link module:engine/view/document~
|
|
59
|
+
* {@link module:engine/view/document~ViewDocument#event:compositionstart},
|
|
60
|
+
* {@link module:engine/view/document~ViewDocument#event:compositionupdate},
|
|
61
|
+
* and {@link module:engine/view/document~ViewDocument#event:compositionend } trio.
|
|
62
62
|
*/
|
|
63
63
|
isComposing?: boolean;
|
|
64
64
|
}
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* @module typing/inserttextobserver
|
|
7
7
|
*/
|
|
8
8
|
import { env, EventInfo } from '@ckeditor/ckeditor5-utils';
|
|
9
|
-
import {
|
|
9
|
+
import { ViewDocumentDomEventData, Observer, FocusObserver } from '@ckeditor/ckeditor5-engine';
|
|
10
10
|
// @if CK_DEBUG_TYPING // const { _buildLogMessage } = require( '@ckeditor/ckeditor5-engine/src/dev-utils/utils.js' );
|
|
11
11
|
const TYPING_INPUT_TYPES = [
|
|
12
12
|
// For collapsed range:
|
|
@@ -25,9 +25,9 @@ const TYPING_INPUT_TYPES_ANDROID = [
|
|
|
25
25
|
'insertCompositionText'
|
|
26
26
|
];
|
|
27
27
|
/**
|
|
28
|
-
* Text insertion observer introduces the {@link module:engine/view/document~
|
|
28
|
+
* Text insertion observer introduces the {@link module:engine/view/document~ViewDocument#event:insertText} event.
|
|
29
29
|
*/
|
|
30
|
-
export
|
|
30
|
+
export class InsertTextObserver extends Observer {
|
|
31
31
|
/**
|
|
32
32
|
* Instance of the focus observer. Insert text observer calls
|
|
33
33
|
* {@link module:engine/view/observer/focusobserver~FocusObserver#flush} to mark the latest focus change as complete.
|
|
@@ -56,7 +56,7 @@ export default class InsertTextObserver extends Observer {
|
|
|
56
56
|
// so the selection is in the focused element).
|
|
57
57
|
this.focusObserver.flush();
|
|
58
58
|
const eventInfo = new EventInfo(viewDocument, 'insertText');
|
|
59
|
-
viewDocument.fire(eventInfo, new
|
|
59
|
+
viewDocument.fire(eventInfo, new ViewDocumentDomEventData(view, domEvent, {
|
|
60
60
|
text,
|
|
61
61
|
selection: view.createSelection(targetRanges),
|
|
62
62
|
isComposing
|
|
@@ -94,7 +94,7 @@ export default class InsertTextObserver extends Observer {
|
|
|
94
94
|
// 2. The last moment before it's locked is the `compositionstart` event.
|
|
95
95
|
// 3. The `SelectionObserver` is listening for `compositionstart` event and immediately converts
|
|
96
96
|
// the selection. Handle this at the low priority so after the rendering is blocked.
|
|
97
|
-
viewDocument.fire('insertText', new
|
|
97
|
+
viewDocument.fire('insertText', new ViewDocumentDomEventData(view, domEvent, {
|
|
98
98
|
text: data,
|
|
99
99
|
isComposing: true
|
|
100
100
|
}));
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* @module typing/texttransformation
|
|
7
7
|
*/
|
|
8
8
|
import { Plugin } from '@ckeditor/ckeditor5-core';
|
|
9
|
-
import TextWatcher from './textwatcher.js';
|
|
9
|
+
import { TextWatcher } from './textwatcher.js';
|
|
10
10
|
import { escapeRegExp } from 'es-toolkit/compat';
|
|
11
11
|
// All named transformations.
|
|
12
12
|
const TRANSFORMATIONS = {
|
|
@@ -61,7 +61,7 @@ const DEFAULT_TRANSFORMATIONS = [
|
|
|
61
61
|
/**
|
|
62
62
|
* The text transformation plugin.
|
|
63
63
|
*/
|
|
64
|
-
export
|
|
64
|
+
export class TextTransformation extends Plugin {
|
|
65
65
|
/**
|
|
66
66
|
* @inheritDoc
|
|
67
67
|
*/
|
package/src/textwatcher.d.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
3
|
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
|
|
4
4
|
*/
|
|
5
|
-
import type { Batch, Model,
|
|
5
|
+
import type { Batch, Model, ModelRange } from '@ckeditor/ckeditor5-engine';
|
|
6
6
|
declare const TextWatcher_base: {
|
|
7
7
|
new (): import("@ckeditor/ckeditor5-utils").Observable;
|
|
8
8
|
prototype: import("@ckeditor/ckeditor5-utils").Observable;
|
|
@@ -14,7 +14,7 @@ declare const TextWatcher_base: {
|
|
|
14
14
|
* {@link module:typing/textwatcher~TextWatcher#event:matched:selection `matched:selection`} and
|
|
15
15
|
* {@link module:typing/textwatcher~TextWatcher#event:unmatched `unmatched`} events on typing or selection changes.
|
|
16
16
|
*/
|
|
17
|
-
export
|
|
17
|
+
export declare class TextWatcher extends /* #__PURE__ */ TextWatcher_base {
|
|
18
18
|
/**
|
|
19
19
|
* The editor's model.
|
|
20
20
|
*/
|
|
@@ -78,7 +78,7 @@ export type TextWatcherMatchedEvent<TCallbackResult extends Record<string, unkno
|
|
|
78
78
|
args: [
|
|
79
79
|
{
|
|
80
80
|
text: string;
|
|
81
|
-
range:
|
|
81
|
+
range: ModelRange;
|
|
82
82
|
batch?: Batch;
|
|
83
83
|
} & TCallbackResult
|
|
84
84
|
];
|
|
@@ -92,9 +92,9 @@ export type TextWatcherMatchedEvent<TCallbackResult extends Record<string, unkno
|
|
|
92
92
|
*/
|
|
93
93
|
export type TextWatcherMatchedDataEvent<TCallbackResult extends Record<string, unknown>> = {
|
|
94
94
|
name: 'matched:data';
|
|
95
|
-
args: [data:
|
|
95
|
+
args: [data: TextWatcherMatchedTypingDataEventData & TCallbackResult];
|
|
96
96
|
};
|
|
97
|
-
export interface
|
|
97
|
+
export interface TextWatcherMatchedTypingDataEventData {
|
|
98
98
|
/**
|
|
99
99
|
* The full text before selection to which the regexp was applied.
|
|
100
100
|
*/
|
|
@@ -102,7 +102,7 @@ export interface TextWatcherMatchedDataEventData {
|
|
|
102
102
|
/**
|
|
103
103
|
* The range representing the position of the `data.text`.
|
|
104
104
|
*/
|
|
105
|
-
range:
|
|
105
|
+
range: ModelRange;
|
|
106
106
|
batch: Batch;
|
|
107
107
|
}
|
|
108
108
|
/**
|
|
@@ -112,11 +112,11 @@ export interface TextWatcherMatchedDataEventData {
|
|
|
112
112
|
* @param data Event data.
|
|
113
113
|
* @param data.testResult The additional data returned from the {@link module:typing/textwatcher~TextWatcher#testCallback}.
|
|
114
114
|
*/
|
|
115
|
-
export type
|
|
115
|
+
export type TextWatcherMatchedTypingSelectionEvent<TCallbackResult extends Record<string, unknown>> = {
|
|
116
116
|
name: 'matched:selection';
|
|
117
|
-
args: [data:
|
|
117
|
+
args: [data: TextWatcherMatchedTypingSelectionEventData & TCallbackResult];
|
|
118
118
|
};
|
|
119
|
-
export interface
|
|
119
|
+
export interface TextWatcherMatchedTypingSelectionEventData {
|
|
120
120
|
/**
|
|
121
121
|
* The full text before selection.
|
|
122
122
|
*/
|
|
@@ -124,14 +124,14 @@ export interface TextWatcherMatchedSelectionEventData {
|
|
|
124
124
|
/**
|
|
125
125
|
* The range representing the position of the `data.text`.
|
|
126
126
|
*/
|
|
127
|
-
range:
|
|
127
|
+
range: ModelRange;
|
|
128
128
|
}
|
|
129
129
|
/**
|
|
130
130
|
* Fired whenever the text does not match anymore. Fired only when the text watcher found a match.
|
|
131
131
|
*
|
|
132
132
|
* @eventName ~TextWatcher#unmatched
|
|
133
133
|
*/
|
|
134
|
-
export type
|
|
134
|
+
export type TextWatcherUnmatchedTypingEvent = {
|
|
135
135
|
name: 'unmatched';
|
|
136
136
|
args: [];
|
|
137
137
|
};
|
package/src/textwatcher.js
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* @module typing/textwatcher
|
|
7
7
|
*/
|
|
8
8
|
import { ObservableMixin } from '@ckeditor/ckeditor5-utils';
|
|
9
|
-
import getLastTextLine from './utils/getlasttextline.js';
|
|
9
|
+
import { getLastTextLine } from './utils/getlasttextline.js';
|
|
10
10
|
/**
|
|
11
11
|
* The text watcher feature.
|
|
12
12
|
*
|
|
@@ -14,7 +14,7 @@ import getLastTextLine from './utils/getlasttextline.js';
|
|
|
14
14
|
* {@link module:typing/textwatcher~TextWatcher#event:matched:selection `matched:selection`} and
|
|
15
15
|
* {@link module:typing/textwatcher~TextWatcher#event:unmatched `unmatched`} events on typing or selection changes.
|
|
16
16
|
*/
|
|
17
|
-
export
|
|
17
|
+
export class TextWatcher extends /* #__PURE__ */ ObservableMixin() {
|
|
18
18
|
/**
|
|
19
19
|
* The editor's model.
|
|
20
20
|
*/
|