@ckeditor/ckeditor5-typing 48.2.0-alpha.7 → 48.3.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.
- package/dist/augmentation.d.ts +25 -25
- package/dist/delete.d.ts +29 -29
- package/dist/deletecommand.d.ts +78 -78
- package/dist/deleteobserver.d.ts +48 -48
- package/dist/index-content.css +1 -0
- package/dist/index-editor.css +1 -0
- package/dist/index.css +0 -2
- package/dist/index.d.ts +24 -24
- package/dist/index.js +1969 -2524
- package/dist/index.js.map +1 -1
- package/dist/input.d.ts +28 -28
- package/dist/inserttextcommand.d.ts +64 -66
- package/dist/inserttextobserver.d.ts +55 -55
- package/dist/texttransformation.d.ts +34 -34
- package/dist/textwatcher.d.ts +118 -119
- package/dist/twostepcaretmovement.d.ts +234 -234
- package/dist/typing.d.ts +22 -22
- package/dist/typingconfig.d.ts +193 -193
- package/dist/utils/changebuffer.d.ts +98 -98
- package/dist/utils/findattributerange.d.ts +27 -27
- package/dist/utils/getlasttextline.d.ts +42 -42
- package/dist/utils/inlinehighlight.d.ts +30 -30
- package/package.json +4 -4
- package/dist/index.css.map +0 -1
|
@@ -1,239 +1,239 @@
|
|
|
1
1
|
/**
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
* @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
|
+
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
|
|
4
|
+
*/
|
|
5
5
|
/**
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
import { Plugin, type Editor } from
|
|
9
|
-
import { type ViewDocumentDomEventData } from
|
|
6
|
+
* @module typing/twostepcaretmovement
|
|
7
|
+
*/
|
|
8
|
+
import { Plugin, type Editor } from "@ckeditor/ckeditor5-core";
|
|
9
|
+
import { type ViewDocumentDomEventData } from "@ckeditor/ckeditor5-engine";
|
|
10
10
|
/**
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
11
|
+
* This plugin enables the two-step caret (phantom) movement behavior for
|
|
12
|
+
* {@link module:typing/twostepcaretmovement~TwoStepCaretMovement#registerAttribute registered attributes}
|
|
13
|
+
* on arrow right (<kbd>→</kbd>) and left (<kbd>←</kbd>) key press.
|
|
14
|
+
*
|
|
15
|
+
* Thanks to this (phantom) caret movement the user is able to type before/after as well as at the
|
|
16
|
+
* beginning/end of an attribute.
|
|
17
|
+
*
|
|
18
|
+
* **Note:** This plugin support right–to–left (Arabic, Hebrew, etc.) content by mirroring its behavior
|
|
19
|
+
* but for the sake of simplicity examples showcase only left–to–right use–cases.
|
|
20
|
+
*
|
|
21
|
+
* # Forward movement
|
|
22
|
+
*
|
|
23
|
+
* ## "Entering" an attribute:
|
|
24
|
+
*
|
|
25
|
+
* When this plugin is enabled and registered for the `a` attribute and the selection is right before it
|
|
26
|
+
* (at the attribute boundary), pressing the right arrow key will not move the selection but update its
|
|
27
|
+
* attributes accordingly:
|
|
28
|
+
*
|
|
29
|
+
* * When enabled:
|
|
30
|
+
*
|
|
31
|
+
* ```xml
|
|
32
|
+
* foo{}<$text a="true">bar</$text>
|
|
33
|
+
* ```
|
|
34
|
+
*
|
|
35
|
+
* <kbd>→</kbd>
|
|
36
|
+
*
|
|
37
|
+
* ```xml
|
|
38
|
+
* foo<$text a="true">{}bar</$text>
|
|
39
|
+
* ```
|
|
40
|
+
*
|
|
41
|
+
* * When disabled:
|
|
42
|
+
*
|
|
43
|
+
* ```xml
|
|
44
|
+
* foo{}<$text a="true">bar</$text>
|
|
45
|
+
* ```
|
|
46
|
+
*
|
|
47
|
+
* <kbd>→</kbd>
|
|
48
|
+
*
|
|
49
|
+
* ```xml
|
|
50
|
+
* foo<$text a="true">b{}ar</$text>
|
|
51
|
+
* ```
|
|
52
|
+
*
|
|
53
|
+
*
|
|
54
|
+
* ## "Leaving" an attribute:
|
|
55
|
+
*
|
|
56
|
+
* * When enabled:
|
|
57
|
+
*
|
|
58
|
+
* ```xml
|
|
59
|
+
* <$text a="true">bar{}</$text>baz
|
|
60
|
+
* ```
|
|
61
|
+
*
|
|
62
|
+
* <kbd>→</kbd>
|
|
63
|
+
*
|
|
64
|
+
* ```xml
|
|
65
|
+
* <$text a="true">bar</$text>{}baz
|
|
66
|
+
* ```
|
|
67
|
+
*
|
|
68
|
+
* * When disabled:
|
|
69
|
+
*
|
|
70
|
+
* ```xml
|
|
71
|
+
* <$text a="true">bar{}</$text>baz
|
|
72
|
+
* ```
|
|
73
|
+
*
|
|
74
|
+
* <kbd>→</kbd>
|
|
75
|
+
*
|
|
76
|
+
* ```xml
|
|
77
|
+
* <$text a="true">bar</$text>b{}az
|
|
78
|
+
* ```
|
|
79
|
+
*
|
|
80
|
+
* # Backward movement
|
|
81
|
+
*
|
|
82
|
+
* * When enabled:
|
|
83
|
+
*
|
|
84
|
+
* ```xml
|
|
85
|
+
* <$text a="true">bar</$text>{}baz
|
|
86
|
+
* ```
|
|
87
|
+
*
|
|
88
|
+
* <kbd>←</kbd>
|
|
89
|
+
*
|
|
90
|
+
* ```xml
|
|
91
|
+
* <$text a="true">bar{}</$text>baz
|
|
92
|
+
* ```
|
|
93
|
+
*
|
|
94
|
+
* * When disabled:
|
|
95
|
+
*
|
|
96
|
+
* ```xml
|
|
97
|
+
* <$text a="true">bar</$text>{}baz
|
|
98
|
+
* ```
|
|
99
|
+
*
|
|
100
|
+
* <kbd>←</kbd>
|
|
101
|
+
*
|
|
102
|
+
* ```xml
|
|
103
|
+
* <$text a="true">ba{}r</$text>b{}az
|
|
104
|
+
* ```
|
|
105
|
+
*
|
|
106
|
+
* # Multiple attributes
|
|
107
|
+
*
|
|
108
|
+
* * When enabled and many attributes starts or ends at the same position:
|
|
109
|
+
*
|
|
110
|
+
* ```xml
|
|
111
|
+
* <$text a="true" b="true">bar</$text>{}baz
|
|
112
|
+
* ```
|
|
113
|
+
*
|
|
114
|
+
* <kbd>←</kbd>
|
|
115
|
+
*
|
|
116
|
+
* ```xml
|
|
117
|
+
* <$text a="true" b="true">bar{}</$text>baz
|
|
118
|
+
* ```
|
|
119
|
+
*
|
|
120
|
+
* * When enabled and one procedes another:
|
|
121
|
+
*
|
|
122
|
+
* ```xml
|
|
123
|
+
* <$text a="true">bar</$text><$text b="true">{}bar</$text>
|
|
124
|
+
* ```
|
|
125
|
+
*
|
|
126
|
+
* <kbd>←</kbd>
|
|
127
|
+
*
|
|
128
|
+
* ```xml
|
|
129
|
+
* <$text a="true">bar{}</$text><$text b="true">bar</$text>
|
|
130
|
+
* ```
|
|
131
|
+
*
|
|
132
|
+
*/
|
|
133
133
|
export declare class TwoStepCaretMovement extends Plugin {
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
134
|
+
/**
|
|
135
|
+
* A set of attributes to handle.
|
|
136
|
+
*/
|
|
137
|
+
private attributes;
|
|
138
|
+
/**
|
|
139
|
+
* The current UID of the overridden gravity, as returned by
|
|
140
|
+
* {@link module:engine/model/writer~ModelWriter#overrideSelectionGravity}.
|
|
141
|
+
*/
|
|
142
|
+
private _overrideUid;
|
|
143
|
+
/**
|
|
144
|
+
* A flag indicating that the automatic gravity restoration should not happen upon the next
|
|
145
|
+
* gravity restoration.
|
|
146
|
+
* {@link module:engine/model/selection~ModelSelection#event:change:range} event.
|
|
147
|
+
*/
|
|
148
|
+
private _isNextGravityRestorationSkipped;
|
|
149
|
+
/**
|
|
150
|
+
* @inheritDoc
|
|
151
|
+
*/
|
|
152
|
+
static get pluginName(): "TwoStepCaretMovement";
|
|
153
|
+
/**
|
|
154
|
+
* @inheritDoc
|
|
155
|
+
*/
|
|
156
|
+
static override get isOfficialPlugin(): true;
|
|
157
|
+
/**
|
|
158
|
+
* @inheritDoc
|
|
159
|
+
*/
|
|
160
|
+
constructor(editor: Editor);
|
|
161
|
+
/**
|
|
162
|
+
* @inheritDoc
|
|
163
|
+
*/
|
|
164
|
+
init(): void;
|
|
165
|
+
/**
|
|
166
|
+
* Registers a given attribute for the two-step caret movement.
|
|
167
|
+
*
|
|
168
|
+
* @param attribute Name of the attribute to handle.
|
|
169
|
+
*/
|
|
170
|
+
registerAttribute(attribute: string): void;
|
|
171
|
+
/**
|
|
172
|
+
* Updates the document selection and the view according to the two–step caret movement state
|
|
173
|
+
* when moving **forwards**. Executed upon `keypress` in the {@link module:engine/view/view~EditingView}.
|
|
174
|
+
*
|
|
175
|
+
* @internal
|
|
176
|
+
* @param eventData Data of the key press.
|
|
177
|
+
* @returns `true` when the handler prevented caret movement.
|
|
178
|
+
*/
|
|
179
|
+
_handleForwardMovement(eventData?: ViewDocumentDomEventData): boolean;
|
|
180
|
+
/**
|
|
181
|
+
* Updates the document selection and the view according to the two–step caret movement state
|
|
182
|
+
* when moving **backwards**. Executed upon `keypress` in the {@link module:engine/view/view~EditingView}.
|
|
183
|
+
*
|
|
184
|
+
* @internal
|
|
185
|
+
* @param eventData Data of the key press.
|
|
186
|
+
* @returns `true` when the handler prevented caret movement
|
|
187
|
+
*/
|
|
188
|
+
_handleBackwardMovement(eventData?: ViewDocumentDomEventData): boolean;
|
|
189
|
+
/**
|
|
190
|
+
* Starts listening to {@link module:engine/view/document~ViewDocument#event:mousedown} and
|
|
191
|
+
* {@link module:engine/view/document~ViewDocument#event:selectionChange} and puts the selection before/after a 2-step node
|
|
192
|
+
* if clicked at the beginning/ending of the 2-step node.
|
|
193
|
+
*
|
|
194
|
+
* The purpose of this action is to allow typing around the 2-step node directly after a click.
|
|
195
|
+
*
|
|
196
|
+
* See https://github.com/ckeditor/ckeditor5/issues/1016.
|
|
197
|
+
*/
|
|
198
|
+
private _enableClickingAfterNode;
|
|
199
|
+
/**
|
|
200
|
+
* Starts listening to {@link module:engine/model/model~Model#event:insertContent} and corrects the model
|
|
201
|
+
* selection attributes if the selection is at the end of a two-step node after inserting the content.
|
|
202
|
+
*
|
|
203
|
+
* The purpose of this action is to improve the overall UX because the user is no longer "trapped" by the
|
|
204
|
+
* two-step attribute of the selection, and they can type a "clean" (`linkHref`–less) text right away.
|
|
205
|
+
*
|
|
206
|
+
* See https://github.com/ckeditor/ckeditor5/issues/6053.
|
|
207
|
+
*/
|
|
208
|
+
private _enableInsertContentSelectionAttributesFixer;
|
|
209
|
+
/**
|
|
210
|
+
* Starts listening to {@link module:engine/model/model~Model#deleteContent} and checks whether
|
|
211
|
+
* removing a content right after the tow-step attribute.
|
|
212
|
+
*
|
|
213
|
+
* If so, the selection should not preserve the two-step attribute. However, if
|
|
214
|
+
* the {@link module:typing/twostepcaretmovement~TwoStepCaretMovement} plugin is active and
|
|
215
|
+
* the selection has the two-step attribute due to overridden gravity (at the end), the two-step attribute should stay untouched.
|
|
216
|
+
*
|
|
217
|
+
* The purpose of this action is to allow removing the link text and keep the selection outside the link.
|
|
218
|
+
*
|
|
219
|
+
* See https://github.com/ckeditor/ckeditor5/issues/7521.
|
|
220
|
+
*/
|
|
221
|
+
private _handleDeleteContentAfterNode;
|
|
222
|
+
/**
|
|
223
|
+
* `true` when the gravity is overridden for the plugin.
|
|
224
|
+
*/
|
|
225
|
+
private get _isGravityOverridden();
|
|
226
|
+
/**
|
|
227
|
+
* Overrides the gravity using the {@link module:engine/model/writer~ModelWriter model writer}
|
|
228
|
+
* and stores the information about this fact in the {@link #_overrideUid}.
|
|
229
|
+
*
|
|
230
|
+
* A shorthand for {@link module:engine/model/writer~ModelWriter#overrideSelectionGravity}.
|
|
231
|
+
*/
|
|
232
|
+
private _overrideGravity;
|
|
233
|
+
/**
|
|
234
|
+
* Restores the gravity using the {@link module:engine/model/writer~ModelWriter model writer}.
|
|
235
|
+
*
|
|
236
|
+
* A shorthand for {@link module:engine/model/writer~ModelWriter#restoreSelectionGravity}.
|
|
237
|
+
*/
|
|
238
|
+
private _restoreGravity;
|
|
239
239
|
}
|
package/dist/typing.d.ts
CHANGED
|
@@ -1,27 +1,27 @@
|
|
|
1
1
|
/**
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
* @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
|
+
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
|
|
4
|
+
*/
|
|
5
5
|
/**
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
import { Plugin } from
|
|
9
|
-
import { Input } from
|
|
10
|
-
import { Delete } from
|
|
6
|
+
* @module typing/typing
|
|
7
|
+
*/
|
|
8
|
+
import { Plugin, type PluginDependenciesOf } from "@ckeditor/ckeditor5-core";
|
|
9
|
+
import { Input } from "./input.js";
|
|
10
|
+
import { Delete } from "./delete.js";
|
|
11
11
|
/**
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
12
|
+
* The typing feature. It handles typing.
|
|
13
|
+
*
|
|
14
|
+
* This is a "glue" plugin which loads the {@link module:typing/input~Input} and {@link module:typing/delete~Delete}
|
|
15
|
+
* plugins.
|
|
16
|
+
*/
|
|
17
17
|
export declare class Typing extends Plugin {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
18
|
+
static get requires(): PluginDependenciesOf<[Input, Delete]>;
|
|
19
|
+
/**
|
|
20
|
+
* @inheritDoc
|
|
21
|
+
*/
|
|
22
|
+
static get pluginName(): "Typing";
|
|
23
|
+
/**
|
|
24
|
+
* @inheritDoc
|
|
25
|
+
*/
|
|
26
|
+
static override get isOfficialPlugin(): true;
|
|
27
27
|
}
|