@ckeditor/ckeditor5-typing 40.0.0 → 40.2.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.
package/src/index.d.ts CHANGED
@@ -1,24 +1,24 @@
1
- /**
2
- * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
3
- * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
- */
5
- /**
6
- * @module typing
7
- */
8
- export { default as Typing } from './typing';
9
- export { default as Input } from './input';
10
- export { default as Delete } from './delete';
11
- export { default as TextWatcher } from './textwatcher';
12
- export { default as TwoStepCaretMovement } from './twostepcaretmovement';
13
- export { default as TextTransformation } from './texttransformation';
14
- export { default as inlineHighlight } from './utils/inlinehighlight';
15
- export { default as findAttributeRange, findAttributeRangeBound } from './utils/findattributerange';
16
- export { default as getLastTextLine, type LastTextLineData } from './utils/getlasttextline';
17
- export { default as InsertTextCommand, type InsertTextCommandExecuteEvent } from './inserttextcommand';
18
- export type { default as DeleteCommand } from './deletecommand';
19
- export type { TypingConfig } from './typingconfig';
20
- export type { ViewDocumentDeleteEvent } from './deleteobserver';
21
- export type { ViewDocumentInsertTextEvent, InsertTextEventData } from './inserttextobserver';
22
- export type { TextWatcherMatchedEvent } from './textwatcher';
23
- export type { TextWatcherMatchedDataEvent } from './textwatcher';
24
- import './augmentation';
1
+ /**
2
+ * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
3
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
+ */
5
+ /**
6
+ * @module typing
7
+ */
8
+ export { default as Typing } from './typing';
9
+ export { default as Input } from './input';
10
+ export { default as Delete } from './delete';
11
+ export { default as TextWatcher } from './textwatcher';
12
+ export { default as TwoStepCaretMovement } from './twostepcaretmovement';
13
+ export { default as TextTransformation } from './texttransformation';
14
+ export { default as inlineHighlight } from './utils/inlinehighlight';
15
+ export { default as findAttributeRange, findAttributeRangeBound } from './utils/findattributerange';
16
+ export { default as getLastTextLine, type LastTextLineData } from './utils/getlasttextline';
17
+ export { default as InsertTextCommand, type InsertTextCommandExecuteEvent } from './inserttextcommand';
18
+ export type { default as DeleteCommand } from './deletecommand';
19
+ export type { TypingConfig } from './typingconfig';
20
+ export type { ViewDocumentDeleteEvent } from './deleteobserver';
21
+ export type { ViewDocumentInsertTextEvent, InsertTextEventData } from './inserttextobserver';
22
+ export type { TextWatcherMatchedEvent } from './textwatcher';
23
+ export type { TextWatcherMatchedDataEvent } from './textwatcher';
24
+ import './augmentation';
package/src/index.js CHANGED
@@ -1,18 +1,18 @@
1
- /**
2
- * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
3
- * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
- */
5
- /**
6
- * @module typing
7
- */
8
- export { default as Typing } from './typing';
9
- export { default as Input } from './input';
10
- export { default as Delete } from './delete';
11
- export { default as TextWatcher } from './textwatcher';
12
- export { default as TwoStepCaretMovement } from './twostepcaretmovement';
13
- export { default as TextTransformation } from './texttransformation';
14
- export { default as inlineHighlight } from './utils/inlinehighlight';
15
- export { default as findAttributeRange, findAttributeRangeBound } from './utils/findattributerange';
16
- export { default as getLastTextLine } from './utils/getlasttextline';
17
- export { default as InsertTextCommand } from './inserttextcommand';
18
- import './augmentation';
1
+ /**
2
+ * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
3
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
+ */
5
+ /**
6
+ * @module typing
7
+ */
8
+ export { default as Typing } from './typing';
9
+ export { default as Input } from './input';
10
+ export { default as Delete } from './delete';
11
+ export { default as TextWatcher } from './textwatcher';
12
+ export { default as TwoStepCaretMovement } from './twostepcaretmovement';
13
+ export { default as TextTransformation } from './texttransformation';
14
+ export { default as inlineHighlight } from './utils/inlinehighlight';
15
+ export { default as findAttributeRange, findAttributeRangeBound } from './utils/findattributerange';
16
+ export { default as getLastTextLine } from './utils/getlasttextline';
17
+ export { default as InsertTextCommand } from './inserttextcommand';
18
+ import './augmentation';
package/src/input.d.ts CHANGED
@@ -1,21 +1,21 @@
1
- /**
2
- * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
3
- * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
- */
5
- /**
6
- * @module typing/input
7
- */
8
- import { Plugin } from '@ckeditor/ckeditor5-core';
9
- /**
10
- * Handles text input coming from the keyboard or other input methods.
11
- */
12
- export default class Input extends Plugin {
13
- /**
14
- * @inheritDoc
15
- */
16
- static get pluginName(): "Input";
17
- /**
18
- * @inheritDoc
19
- */
20
- init(): void;
21
- }
1
+ /**
2
+ * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
3
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
+ */
5
+ /**
6
+ * @module typing/input
7
+ */
8
+ import { Plugin } from '@ckeditor/ckeditor5-core';
9
+ /**
10
+ * Handles text input coming from the keyboard or other input methods.
11
+ */
12
+ export default class Input extends Plugin {
13
+ /**
14
+ * @inheritDoc
15
+ */
16
+ static get pluginName(): "Input";
17
+ /**
18
+ * @inheritDoc
19
+ */
20
+ init(): void;
21
+ }
package/src/input.js CHANGED
@@ -1,141 +1,141 @@
1
- /**
2
- * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
3
- * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
- */
5
- /**
6
- * @module typing/input
7
- */
8
- import { Plugin } from '@ckeditor/ckeditor5-core';
9
- import { env } from '@ckeditor/ckeditor5-utils';
10
- import InsertTextCommand from './inserttextcommand';
11
- import InsertTextObserver from './inserttextobserver';
12
- /**
13
- * Handles text input coming from the keyboard or other input methods.
14
- */
15
- export default class Input extends Plugin {
16
- /**
17
- * @inheritDoc
18
- */
19
- static get pluginName() {
20
- return 'Input';
21
- }
22
- /**
23
- * @inheritDoc
24
- */
25
- init() {
26
- const editor = this.editor;
27
- const model = editor.model;
28
- const view = editor.editing.view;
29
- const modelSelection = model.document.selection;
30
- view.addObserver(InsertTextObserver);
31
- // TODO The above default configuration value should be defined using editor.config.define() once it's fixed.
32
- const insertTextCommand = new InsertTextCommand(editor, editor.config.get('typing.undoStep') || 20);
33
- // Register `insertText` command and add `input` command as an alias for backward compatibility.
34
- editor.commands.add('insertText', insertTextCommand);
35
- editor.commands.add('input', insertTextCommand);
36
- this.listenTo(view.document, 'insertText', (evt, data) => {
37
- // Rendering is disabled while composing so prevent events that will be rendered by the engine
38
- // and should not be applied by the browser.
39
- if (!view.document.isComposing) {
40
- data.preventDefault();
41
- }
42
- const { text, selection: viewSelection, resultRange: viewResultRange } = data;
43
- // If view selection was specified, translate it to model selection.
44
- const modelRanges = Array.from(viewSelection.getRanges()).map(viewRange => {
45
- return editor.editing.mapper.toModelRange(viewRange);
46
- });
47
- let insertText = text;
48
- // Typing in English on Android is firing composition events for the whole typed word.
49
- // We need to check the target range text to only apply the difference.
50
- if (env.isAndroid) {
51
- const selectedText = Array.from(modelRanges[0].getItems()).reduce((rangeText, node) => {
52
- return rangeText + (node.is('$textProxy') ? node.data : '');
53
- }, '');
54
- if (selectedText) {
55
- if (selectedText.length <= insertText.length) {
56
- if (insertText.startsWith(selectedText)) {
57
- insertText = insertText.substring(selectedText.length);
58
- modelRanges[0].start = modelRanges[0].start.getShiftedBy(selectedText.length);
59
- }
60
- }
61
- else {
62
- if (selectedText.startsWith(insertText)) {
63
- // TODO this should be mapped as delete?
64
- modelRanges[0].start = modelRanges[0].start.getShiftedBy(insertText.length);
65
- insertText = '';
66
- }
67
- }
68
- }
69
- }
70
- const insertTextCommandData = {
71
- text: insertText,
72
- selection: model.createSelection(modelRanges)
73
- };
74
- // @if CK_DEBUG_TYPING // if ( ( window as any ).logCKETyping ) {
75
- // @if CK_DEBUG_TYPING // console.log( '%c[Input]%c Execute insertText:',
76
- // @if CK_DEBUG_TYPING // 'font-weight: bold; color: green;', '',
77
- // @if CK_DEBUG_TYPING // insertText,
78
- // @if CK_DEBUG_TYPING // `[${ modelRanges[ 0 ].start.path }]-[${ modelRanges[ 0 ].end.path }]`
79
- // @if CK_DEBUG_TYPING // );
80
- // @if CK_DEBUG_TYPING // }
81
- if (viewResultRange) {
82
- insertTextCommandData.resultRange = editor.editing.mapper.toModelRange(viewResultRange);
83
- }
84
- editor.execute('insertText', insertTextCommandData);
85
- view.scrollToTheSelection();
86
- });
87
- if (env.isAndroid) {
88
- // On Android with English keyboard, the composition starts just by putting caret
89
- // at the word end or by selecting a table column. This is not a real composition started.
90
- // Trigger delete content on first composition key pressed.
91
- this.listenTo(view.document, 'keydown', (evt, data) => {
92
- if (modelSelection.isCollapsed || data.keyCode != 229 || !view.document.isComposing) {
93
- return;
94
- }
95
- // @if CK_DEBUG_TYPING // if ( ( window as any ).logCKETyping ) {
96
- // @if CK_DEBUG_TYPING // const firstPositionPath = modelSelection.getFirstPosition()!.path;
97
- // @if CK_DEBUG_TYPING // const lastPositionPath = modelSelection.getLastPosition()!.path;
98
- // @if CK_DEBUG_TYPING // console.log( '%c[Input]%c KeyDown 229 -> model.deleteContent()',
99
- // @if CK_DEBUG_TYPING // 'font-weight: bold; color: green;', '',
100
- // @if CK_DEBUG_TYPING // `[${ firstPositionPath }]-[${ lastPositionPath }]`
101
- // @if CK_DEBUG_TYPING // );
102
- // @if CK_DEBUG_TYPING // }
103
- deleteSelectionContent(model, insertTextCommand);
104
- });
105
- }
106
- else {
107
- // Note: The priority must precede the CompositionObserver handler to call it before
108
- // the renderer is blocked, because we want to render this change.
109
- this.listenTo(view.document, 'compositionstart', () => {
110
- if (modelSelection.isCollapsed) {
111
- return;
112
- }
113
- // @if CK_DEBUG_TYPING // if ( ( window as any ).logCKETyping ) {
114
- // @if CK_DEBUG_TYPING // const firstPositionPath = modelSelection.getFirstPosition()!.path;
115
- // @if CK_DEBUG_TYPING // const lastPositionPath = modelSelection.getLastPosition()!.path;
116
- // @if CK_DEBUG_TYPING // console.log( '%c[Input]%c Composition start -> model.deleteContent()',
117
- // @if CK_DEBUG_TYPING // 'font-weight: bold; color: green;', '',
118
- // @if CK_DEBUG_TYPING // `[${ firstPositionPath }]-[${ lastPositionPath }]`
119
- // @if CK_DEBUG_TYPING // );
120
- // @if CK_DEBUG_TYPING // }
121
- deleteSelectionContent(model, insertTextCommand);
122
- });
123
- }
124
- }
125
- }
126
- function deleteSelectionContent(model, insertTextCommand) {
127
- // By relying on the state of the input command we allow disabling the entire input easily
128
- // by just disabling the input command. We could’ve used here the delete command but that
129
- // would mean requiring the delete feature which would block loading one without the other.
130
- // We could also check the editor.isReadOnly property, but that wouldn't allow to block
131
- // the input without blocking other features.
132
- if (!insertTextCommand.isEnabled) {
133
- return;
134
- }
135
- const buffer = insertTextCommand.buffer;
136
- buffer.lock();
137
- model.enqueueChange(buffer.batch, () => {
138
- model.deleteContent(model.document.selection);
139
- });
140
- buffer.unlock();
141
- }
1
+ /**
2
+ * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
3
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
+ */
5
+ /**
6
+ * @module typing/input
7
+ */
8
+ import { Plugin } from '@ckeditor/ckeditor5-core';
9
+ import { env } from '@ckeditor/ckeditor5-utils';
10
+ import InsertTextCommand from './inserttextcommand';
11
+ import InsertTextObserver from './inserttextobserver';
12
+ /**
13
+ * Handles text input coming from the keyboard or other input methods.
14
+ */
15
+ export default class Input extends Plugin {
16
+ /**
17
+ * @inheritDoc
18
+ */
19
+ static get pluginName() {
20
+ return 'Input';
21
+ }
22
+ /**
23
+ * @inheritDoc
24
+ */
25
+ init() {
26
+ const editor = this.editor;
27
+ const model = editor.model;
28
+ const view = editor.editing.view;
29
+ const modelSelection = model.document.selection;
30
+ view.addObserver(InsertTextObserver);
31
+ // TODO The above default configuration value should be defined using editor.config.define() once it's fixed.
32
+ const insertTextCommand = new InsertTextCommand(editor, editor.config.get('typing.undoStep') || 20);
33
+ // Register `insertText` command and add `input` command as an alias for backward compatibility.
34
+ editor.commands.add('insertText', insertTextCommand);
35
+ editor.commands.add('input', insertTextCommand);
36
+ this.listenTo(view.document, 'insertText', (evt, data) => {
37
+ // Rendering is disabled while composing so prevent events that will be rendered by the engine
38
+ // and should not be applied by the browser.
39
+ if (!view.document.isComposing) {
40
+ data.preventDefault();
41
+ }
42
+ const { text, selection: viewSelection, resultRange: viewResultRange } = data;
43
+ // If view selection was specified, translate it to model selection.
44
+ const modelRanges = Array.from(viewSelection.getRanges()).map(viewRange => {
45
+ return editor.editing.mapper.toModelRange(viewRange);
46
+ });
47
+ let insertText = text;
48
+ // Typing in English on Android is firing composition events for the whole typed word.
49
+ // We need to check the target range text to only apply the difference.
50
+ if (env.isAndroid) {
51
+ const selectedText = Array.from(modelRanges[0].getItems()).reduce((rangeText, node) => {
52
+ return rangeText + (node.is('$textProxy') ? node.data : '');
53
+ }, '');
54
+ if (selectedText) {
55
+ if (selectedText.length <= insertText.length) {
56
+ if (insertText.startsWith(selectedText)) {
57
+ insertText = insertText.substring(selectedText.length);
58
+ modelRanges[0].start = modelRanges[0].start.getShiftedBy(selectedText.length);
59
+ }
60
+ }
61
+ else {
62
+ if (selectedText.startsWith(insertText)) {
63
+ // TODO this should be mapped as delete?
64
+ modelRanges[0].start = modelRanges[0].start.getShiftedBy(insertText.length);
65
+ insertText = '';
66
+ }
67
+ }
68
+ }
69
+ }
70
+ const insertTextCommandData = {
71
+ text: insertText,
72
+ selection: model.createSelection(modelRanges)
73
+ };
74
+ // @if CK_DEBUG_TYPING // if ( ( window as any ).logCKETyping ) {
75
+ // @if CK_DEBUG_TYPING // console.log( '%c[Input]%c Execute insertText:',
76
+ // @if CK_DEBUG_TYPING // 'font-weight: bold; color: green;', '',
77
+ // @if CK_DEBUG_TYPING // insertText,
78
+ // @if CK_DEBUG_TYPING // `[${ modelRanges[ 0 ].start.path }]-[${ modelRanges[ 0 ].end.path }]`
79
+ // @if CK_DEBUG_TYPING // );
80
+ // @if CK_DEBUG_TYPING // }
81
+ if (viewResultRange) {
82
+ insertTextCommandData.resultRange = editor.editing.mapper.toModelRange(viewResultRange);
83
+ }
84
+ editor.execute('insertText', insertTextCommandData);
85
+ view.scrollToTheSelection();
86
+ });
87
+ if (env.isAndroid) {
88
+ // On Android with English keyboard, the composition starts just by putting caret
89
+ // at the word end or by selecting a table column. This is not a real composition started.
90
+ // Trigger delete content on first composition key pressed.
91
+ this.listenTo(view.document, 'keydown', (evt, data) => {
92
+ if (modelSelection.isCollapsed || data.keyCode != 229 || !view.document.isComposing) {
93
+ return;
94
+ }
95
+ // @if CK_DEBUG_TYPING // if ( ( window as any ).logCKETyping ) {
96
+ // @if CK_DEBUG_TYPING // const firstPositionPath = modelSelection.getFirstPosition()!.path;
97
+ // @if CK_DEBUG_TYPING // const lastPositionPath = modelSelection.getLastPosition()!.path;
98
+ // @if CK_DEBUG_TYPING // console.log( '%c[Input]%c KeyDown 229 -> model.deleteContent()',
99
+ // @if CK_DEBUG_TYPING // 'font-weight: bold; color: green;', '',
100
+ // @if CK_DEBUG_TYPING // `[${ firstPositionPath }]-[${ lastPositionPath }]`
101
+ // @if CK_DEBUG_TYPING // );
102
+ // @if CK_DEBUG_TYPING // }
103
+ deleteSelectionContent(model, insertTextCommand);
104
+ });
105
+ }
106
+ else {
107
+ // Note: The priority must precede the CompositionObserver handler to call it before
108
+ // the renderer is blocked, because we want to render this change.
109
+ this.listenTo(view.document, 'compositionstart', () => {
110
+ if (modelSelection.isCollapsed) {
111
+ return;
112
+ }
113
+ // @if CK_DEBUG_TYPING // if ( ( window as any ).logCKETyping ) {
114
+ // @if CK_DEBUG_TYPING // const firstPositionPath = modelSelection.getFirstPosition()!.path;
115
+ // @if CK_DEBUG_TYPING // const lastPositionPath = modelSelection.getLastPosition()!.path;
116
+ // @if CK_DEBUG_TYPING // console.log( '%c[Input]%c Composition start -> model.deleteContent()',
117
+ // @if CK_DEBUG_TYPING // 'font-weight: bold; color: green;', '',
118
+ // @if CK_DEBUG_TYPING // `[${ firstPositionPath }]-[${ lastPositionPath }]`
119
+ // @if CK_DEBUG_TYPING // );
120
+ // @if CK_DEBUG_TYPING // }
121
+ deleteSelectionContent(model, insertTextCommand);
122
+ });
123
+ }
124
+ }
125
+ }
126
+ function deleteSelectionContent(model, insertTextCommand) {
127
+ // By relying on the state of the input command we allow disabling the entire input easily
128
+ // by just disabling the input command. We could’ve used here the delete command but that
129
+ // would mean requiring the delete feature which would block loading one without the other.
130
+ // We could also check the editor.isReadOnly property, but that wouldn't allow to block
131
+ // the input without blocking other features.
132
+ if (!insertTextCommand.isEnabled) {
133
+ return;
134
+ }
135
+ const buffer = insertTextCommand.buffer;
136
+ buffer.lock();
137
+ model.enqueueChange(buffer.batch, () => {
138
+ model.deleteContent(model.document.selection);
139
+ });
140
+ buffer.unlock();
141
+ }
@@ -1,76 +1,76 @@
1
- /**
2
- * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
3
- * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
- */
5
- /**
6
- * @module typing/inserttextcommand
7
- */
8
- import { Command, type Editor } from '@ckeditor/ckeditor5-core';
9
- import ChangeBuffer from './utils/changebuffer';
10
- import type { DocumentSelection, Range, Selection } from '@ckeditor/ckeditor5-engine';
11
- /**
12
- * The insert text command. Used by the {@link module:typing/input~Input input feature} to handle typing.
13
- */
14
- export default class InsertTextCommand extends Command {
15
- /**
16
- * Typing's change buffer used to group subsequent changes into batches.
17
- */
18
- private readonly _buffer;
19
- /**
20
- * Creates an instance of the command.
21
- *
22
- * @param undoStepSize The maximum number of atomic changes
23
- * which can be contained in one batch in the command buffer.
24
- */
25
- constructor(editor: Editor, undoStepSize: number);
26
- /**
27
- * The current change buffer.
28
- */
29
- get buffer(): ChangeBuffer;
30
- /**
31
- * @inheritDoc
32
- */
33
- destroy(): void;
34
- /**
35
- * Executes the input command. It replaces the content within the given range with the given text.
36
- * Replacing is a two step process, first the content within the range is removed and then the new text is inserted
37
- * at the beginning of the range (which after the removal is a collapsed range).
38
- *
39
- * @fires execute
40
- * @param options The command options.
41
- */
42
- execute(options?: InsertTextCommandOptions): void;
43
- }
44
- /**
45
- * Interface with parameters for executing InsertTextCommand.
46
- *
47
- * Both `range` and `selection` parameters are used for defining selection but should not be used together.
48
- * If both are defined, only `selection` will be considered.
49
- */
50
- export interface InsertTextCommandOptions {
51
- /**
52
- * The text to be inserted.
53
- */
54
- text?: string;
55
- /**
56
- * The selection in which the text is inserted.
57
- * Inserting a text into a selection deletes the current content within selection ranges. If the selection is not specified,
58
- * the current selection in the model will be used instead.
59
- */
60
- selection?: Selection | DocumentSelection;
61
- /**
62
- * The range in which the text is inserted. Defaults to the first range in the current selection.
63
- */
64
- range?: Range;
65
- /**
66
- * The range where the selection should be placed after the insertion.
67
- * If not specified, the selection will be placed right after the inserted text.
68
- */
69
- resultRange?: Range;
70
- }
71
- export interface InsertTextCommandExecuteEvent {
72
- name: 'execute';
73
- args: [
74
- data: [options: InsertTextCommandOptions]
75
- ];
76
- }
1
+ /**
2
+ * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
3
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
+ */
5
+ /**
6
+ * @module typing/inserttextcommand
7
+ */
8
+ import { Command, type Editor } from '@ckeditor/ckeditor5-core';
9
+ import ChangeBuffer from './utils/changebuffer';
10
+ import type { DocumentSelection, Range, Selection } from '@ckeditor/ckeditor5-engine';
11
+ /**
12
+ * The insert text command. Used by the {@link module:typing/input~Input input feature} to handle typing.
13
+ */
14
+ export default class InsertTextCommand extends Command {
15
+ /**
16
+ * Typing's change buffer used to group subsequent changes into batches.
17
+ */
18
+ private readonly _buffer;
19
+ /**
20
+ * Creates an instance of the command.
21
+ *
22
+ * @param undoStepSize The maximum number of atomic changes
23
+ * which can be contained in one batch in the command buffer.
24
+ */
25
+ constructor(editor: Editor, undoStepSize: number);
26
+ /**
27
+ * The current change buffer.
28
+ */
29
+ get buffer(): ChangeBuffer;
30
+ /**
31
+ * @inheritDoc
32
+ */
33
+ destroy(): void;
34
+ /**
35
+ * Executes the input command. It replaces the content within the given range with the given text.
36
+ * Replacing is a two step process, first the content within the range is removed and then the new text is inserted
37
+ * at the beginning of the range (which after the removal is a collapsed range).
38
+ *
39
+ * @fires execute
40
+ * @param options The command options.
41
+ */
42
+ execute(options?: InsertTextCommandOptions): void;
43
+ }
44
+ /**
45
+ * Interface with parameters for executing InsertTextCommand.
46
+ *
47
+ * Both `range` and `selection` parameters are used for defining selection but should not be used together.
48
+ * If both are defined, only `selection` will be considered.
49
+ */
50
+ export interface InsertTextCommandOptions {
51
+ /**
52
+ * The text to be inserted.
53
+ */
54
+ text?: string;
55
+ /**
56
+ * The selection in which the text is inserted.
57
+ * Inserting a text into a selection deletes the current content within selection ranges. If the selection is not specified,
58
+ * the current selection in the model will be used instead.
59
+ */
60
+ selection?: Selection | DocumentSelection;
61
+ /**
62
+ * The range in which the text is inserted. Defaults to the first range in the current selection.
63
+ */
64
+ range?: Range;
65
+ /**
66
+ * The range where the selection should be placed after the insertion.
67
+ * If not specified, the selection will be placed right after the inserted text.
68
+ */
69
+ resultRange?: Range;
70
+ }
71
+ export interface InsertTextCommandExecuteEvent {
72
+ name: 'execute';
73
+ args: [
74
+ data: [options: InsertTextCommandOptions]
75
+ ];
76
+ }