@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.
@@ -6,7 +6,7 @@
6
6
  * @module typing/twostepcaretmovement
7
7
  */
8
8
  import { Plugin, type Editor } from '@ckeditor/ckeditor5-core';
9
- import { type DomEventData } from '@ckeditor/ckeditor5-engine';
9
+ import { type ViewDocumentDomEventData } from '@ckeditor/ckeditor5-engine';
10
10
  /**
11
11
  * This plugin enables the two-step caret (phantom) movement behavior for
12
12
  * {@link module:typing/twostepcaretmovement~TwoStepCaretMovement#registerAttribute registered attributes}
@@ -130,20 +130,20 @@ import { type DomEventData } from '@ckeditor/ckeditor5-engine';
130
130
  * ```
131
131
  *
132
132
  */
133
- export default class TwoStepCaretMovement extends Plugin {
133
+ export declare class TwoStepCaretMovement extends Plugin {
134
134
  /**
135
135
  * A set of attributes to handle.
136
136
  */
137
137
  private attributes;
138
138
  /**
139
139
  * The current UID of the overridden gravity, as returned by
140
- * {@link module:engine/model/writer~Writer#overrideSelectionGravity}.
140
+ * {@link module:engine/model/writer~ModelWriter#overrideSelectionGravity}.
141
141
  */
142
142
  private _overrideUid;
143
143
  /**
144
144
  * A flag indicating that the automatic gravity restoration should not happen upon the next
145
145
  * gravity restoration.
146
- * {@link module:engine/model/selection~Selection#event:change:range} event.
146
+ * {@link module:engine/model/selection~ModelSelection#event:change:range} event.
147
147
  */
148
148
  private _isNextGravityRestorationSkipped;
149
149
  /**
@@ -170,25 +170,25 @@ export default class TwoStepCaretMovement extends Plugin {
170
170
  registerAttribute(attribute: string): void;
171
171
  /**
172
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~View}.
173
+ * when moving **forwards**. Executed upon `keypress` in the {@link module:engine/view/view~EditingView}.
174
174
  *
175
175
  * @internal
176
176
  * @param eventData Data of the key press.
177
177
  * @returns `true` when the handler prevented caret movement.
178
178
  */
179
- _handleForwardMovement(eventData?: DomEventData): boolean;
179
+ _handleForwardMovement(eventData?: ViewDocumentDomEventData): boolean;
180
180
  /**
181
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~View}.
182
+ * when moving **backwards**. Executed upon `keypress` in the {@link module:engine/view/view~EditingView}.
183
183
  *
184
184
  * @internal
185
185
  * @param eventData Data of the key press.
186
186
  * @returns `true` when the handler prevented caret movement
187
187
  */
188
- _handleBackwardMovement(eventData?: DomEventData): boolean;
188
+ _handleBackwardMovement(eventData?: ViewDocumentDomEventData): boolean;
189
189
  /**
190
- * Starts listening to {@link module:engine/view/document~Document#event:mousedown} and
191
- * {@link module:engine/view/document~Document#event:selectionChange} and puts the selection before/after a 2-step node
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
192
  * if clicked at the beginning/ending of the 2-step node.
193
193
  *
194
194
  * The purpose of this action is to allow typing around the 2-step node directly after a click.
@@ -224,16 +224,16 @@ export default class TwoStepCaretMovement extends Plugin {
224
224
  */
225
225
  private get _isGravityOverridden();
226
226
  /**
227
- * Overrides the gravity using the {@link module:engine/model/writer~Writer model writer}
227
+ * Overrides the gravity using the {@link module:engine/model/writer~ModelWriter model writer}
228
228
  * and stores the information about this fact in the {@link #_overrideUid}.
229
229
  *
230
- * A shorthand for {@link module:engine/model/writer~Writer#overrideSelectionGravity}.
230
+ * A shorthand for {@link module:engine/model/writer~ModelWriter#overrideSelectionGravity}.
231
231
  */
232
232
  private _overrideGravity;
233
233
  /**
234
- * Restores the gravity using the {@link module:engine/model/writer~Writer model writer}.
234
+ * Restores the gravity using the {@link module:engine/model/writer~ModelWriter model writer}.
235
235
  *
236
- * A shorthand for {@link module:engine/model/writer~Writer#restoreSelectionGravity}.
236
+ * A shorthand for {@link module:engine/model/writer~ModelWriter#restoreSelectionGravity}.
237
237
  */
238
238
  private _restoreGravity;
239
239
  }
@@ -131,20 +131,20 @@ import { MouseObserver, TouchObserver } from '@ckeditor/ckeditor5-engine';
131
131
  * ```
132
132
  *
133
133
  */
134
- export default class TwoStepCaretMovement extends Plugin {
134
+ export class TwoStepCaretMovement extends Plugin {
135
135
  /**
136
136
  * A set of attributes to handle.
137
137
  */
138
138
  attributes;
139
139
  /**
140
140
  * The current UID of the overridden gravity, as returned by
141
- * {@link module:engine/model/writer~Writer#overrideSelectionGravity}.
141
+ * {@link module:engine/model/writer~ModelWriter#overrideSelectionGravity}.
142
142
  */
143
143
  _overrideUid;
144
144
  /**
145
145
  * A flag indicating that the automatic gravity restoration should not happen upon the next
146
146
  * gravity restoration.
147
- * {@link module:engine/model/selection~Selection#event:change:range} event.
147
+ * {@link module:engine/model/selection~ModelSelection#event:change:range} event.
148
148
  */
149
149
  _isNextGravityRestorationSkipped = false;
150
150
  /**
@@ -246,7 +246,7 @@ export default class TwoStepCaretMovement extends Plugin {
246
246
  }
247
247
  /**
248
248
  * Updates the document selection and the view according to the two–step caret movement state
249
- * when moving **forwards**. Executed upon `keypress` in the {@link module:engine/view/view~View}.
249
+ * when moving **forwards**. Executed upon `keypress` in the {@link module:engine/view/view~EditingView}.
250
250
  *
251
251
  * @internal
252
252
  * @param eventData Data of the key press.
@@ -308,7 +308,7 @@ export default class TwoStepCaretMovement extends Plugin {
308
308
  }
309
309
  /**
310
310
  * Updates the document selection and the view according to the two–step caret movement state
311
- * when moving **backwards**. Executed upon `keypress` in the {@link module:engine/view/view~View}.
311
+ * when moving **backwards**. Executed upon `keypress` in the {@link module:engine/view/view~EditingView}.
312
312
  *
313
313
  * @internal
314
314
  * @param eventData Data of the key press.
@@ -411,8 +411,8 @@ export default class TwoStepCaretMovement extends Plugin {
411
411
  return false;
412
412
  }
413
413
  /**
414
- * Starts listening to {@link module:engine/view/document~Document#event:mousedown} and
415
- * {@link module:engine/view/document~Document#event:selectionChange} and puts the selection before/after a 2-step node
414
+ * Starts listening to {@link module:engine/view/document~ViewDocument#event:mousedown} and
415
+ * {@link module:engine/view/document~ViewDocument#event:selectionChange} and puts the selection before/after a 2-step node
416
416
  * if clicked at the beginning/ending of the 2-step node.
417
417
  *
418
418
  * The purpose of this action is to allow typing around the 2-step node directly after a click.
@@ -562,10 +562,10 @@ export default class TwoStepCaretMovement extends Plugin {
562
562
  return !!this._overrideUid;
563
563
  }
564
564
  /**
565
- * Overrides the gravity using the {@link module:engine/model/writer~Writer model writer}
565
+ * Overrides the gravity using the {@link module:engine/model/writer~ModelWriter model writer}
566
566
  * and stores the information about this fact in the {@link #_overrideUid}.
567
567
  *
568
- * A shorthand for {@link module:engine/model/writer~Writer#overrideSelectionGravity}.
568
+ * A shorthand for {@link module:engine/model/writer~ModelWriter#overrideSelectionGravity}.
569
569
  */
570
570
  _overrideGravity() {
571
571
  this._overrideUid = this.editor.model.change(writer => {
@@ -573,9 +573,9 @@ export default class TwoStepCaretMovement extends Plugin {
573
573
  });
574
574
  }
575
575
  /**
576
- * Restores the gravity using the {@link module:engine/model/writer~Writer model writer}.
576
+ * Restores the gravity using the {@link module:engine/model/writer~ModelWriter model writer}.
577
577
  *
578
- * A shorthand for {@link module:engine/model/writer~Writer#restoreSelectionGravity}.
578
+ * A shorthand for {@link module:engine/model/writer~ModelWriter#restoreSelectionGravity}.
579
579
  */
580
580
  _restoreGravity() {
581
581
  this.editor.model.change(writer => {
@@ -598,7 +598,7 @@ function hasAnyAttribute(selection, attributes) {
598
598
  /**
599
599
  * Applies the given attributes to the current selection using using the
600
600
  * values from the node before the current position. Uses
601
- * the {@link module:engine/model/writer~Writer model writer}.
601
+ * the {@link module:engine/model/writer~ModelWriter model writer}.
602
602
  */
603
603
  function setSelectionAttributesFromTheNodeBefore(model, attributes, position) {
604
604
  const nodeBefore = position.nodeBefore;
package/src/typing.d.ts CHANGED
@@ -6,15 +6,15 @@
6
6
  * @module typing/typing
7
7
  */
8
8
  import { Plugin } from '@ckeditor/ckeditor5-core';
9
- import Input from './input.js';
10
- import Delete from './delete.js';
9
+ import { Input } from './input.js';
10
+ import { Delete } from './delete.js';
11
11
  /**
12
12
  * The typing feature. It handles typing.
13
13
  *
14
14
  * This is a "glue" plugin which loads the {@link module:typing/input~Input} and {@link module:typing/delete~Delete}
15
15
  * plugins.
16
16
  */
17
- export default class Typing extends Plugin {
17
+ export declare class Typing extends Plugin {
18
18
  static get requires(): readonly [typeof Input, typeof Delete];
19
19
  /**
20
20
  * @inheritDoc
package/src/typing.js CHANGED
@@ -6,15 +6,15 @@
6
6
  * @module typing/typing
7
7
  */
8
8
  import { Plugin } from '@ckeditor/ckeditor5-core';
9
- import Input from './input.js';
10
- import Delete from './delete.js';
9
+ import { Input } from './input.js';
10
+ import { Delete } from './delete.js';
11
11
  /**
12
12
  * The typing feature. It handles typing.
13
13
  *
14
14
  * This is a "glue" plugin which loads the {@link module:typing/input~Input} and {@link module:typing/delete~Delete}
15
15
  * plugins.
16
16
  */
17
- export default class Typing extends Plugin {
17
+ export class Typing extends Plugin {
18
18
  static get requires() {
19
19
  return [Input, Delete];
20
20
  }
@@ -117,7 +117,7 @@ export interface TextTransformationConfig {
117
117
  * ({@link module:typing/typingconfig~TextTransformationConfig#extra `transformations.extra`},
118
118
  * {@link module:typing/typingconfig~TextTransformationConfig#remove `transformations.remove`}) to fine-tune the default list.
119
119
  */
120
- include: Array<TextTransformationDescription | string>;
120
+ include: Array<TextTypingTransformationDescription | string>;
121
121
  /**
122
122
  * Additional text transformations that are added to the transformations defined in
123
123
  * {@link module:typing/typingconfig~TextTransformationConfig#include `transformations.include`}.
@@ -130,7 +130,7 @@ export interface TextTransformationConfig {
130
130
  * };
131
131
  * ```
132
132
  */
133
- extra?: Array<TextTransformationDescription | string>;
133
+ extra?: Array<TextTypingTransformationDescription | string>;
134
134
  /**
135
135
  * The text transformation names that are removed from transformations defined in
136
136
  * {@link module:typing/typingconfig~TextTransformationConfig#include `transformations.include`} or
@@ -145,7 +145,7 @@ export interface TextTransformationConfig {
145
145
  * }
146
146
  * ```
147
147
  */
148
- remove?: Array<TextTransformationDescription | string>;
148
+ remove?: Array<TextTypingTransformationDescription | string>;
149
149
  }
150
150
  /**
151
151
  * The text transformation definition object. It describes what should be replaced with what.
@@ -192,7 +192,7 @@ export interface TextTransformationConfig {
192
192
  * }
193
193
  * ```
194
194
  */
195
- export interface TextTransformationDescription {
195
+ export interface TextTypingTransformationDescription {
196
196
  /**
197
197
  * The string or regular expression to transform.
198
198
  */
@@ -13,7 +13,7 @@ import type { Model, Batch } from '@ckeditor/ckeditor5-engine';
13
13
  * Batches represent single undo steps, hence changes added to one single batch are undone together.
14
14
  *
15
15
  * The buffer has a configurable limit of atomic changes that it can accommodate. After the limit was
16
- * exceeded (see {@link ~ChangeBuffer#input}), a new batch is created in {@link ~ChangeBuffer#batch}.
16
+ * exceeded (see {@link ~TypingChangeBuffer#input}), a new batch is created in {@link ~TypingChangeBuffer#batch}.
17
17
  *
18
18
  * To use the change buffer you need to let it know about the number of changes that were added to the batch:
19
19
  *
@@ -25,7 +25,7 @@ import type { Model, Batch } from '@ckeditor/ckeditor5-engine';
25
25
  * buffer.input( insertedCharacters.length );
26
26
  * ```
27
27
  */
28
- export default class ChangeBuffer {
28
+ export declare class TypingChangeBuffer {
29
29
  /**
30
30
  * The model instance.
31
31
  */
@@ -9,7 +9,7 @@
9
9
  * Batches represent single undo steps, hence changes added to one single batch are undone together.
10
10
  *
11
11
  * The buffer has a configurable limit of atomic changes that it can accommodate. After the limit was
12
- * exceeded (see {@link ~ChangeBuffer#input}), a new batch is created in {@link ~ChangeBuffer#batch}.
12
+ * exceeded (see {@link ~TypingChangeBuffer#input}), a new batch is created in {@link ~TypingChangeBuffer#batch}.
13
13
  *
14
14
  * To use the change buffer you need to let it know about the number of changes that were added to the batch:
15
15
  *
@@ -21,7 +21,7 @@
21
21
  * buffer.input( insertedCharacters.length );
22
22
  * ```
23
23
  */
24
- export default class ChangeBuffer {
24
+ export class TypingChangeBuffer {
25
25
  /**
26
26
  * The model instance.
27
27
  */
@@ -5,7 +5,7 @@
5
5
  /**
6
6
  * @module typing/utils/findattributerange
7
7
  */
8
- import type { Position, Model, Range } from '@ckeditor/ckeditor5-engine';
8
+ import type { ModelPosition, Model, ModelRange } from '@ckeditor/ckeditor5-engine';
9
9
  /**
10
10
  * Returns a model range that covers all consecutive nodes with the same `attributeName` and its `value`
11
11
  * that intersect the given `position`.
@@ -19,7 +19,7 @@ import type { Position, Model, Range } from '@ckeditor/ckeditor5-engine';
19
19
  * @param model The model instance.
20
20
  * @returns The link range.
21
21
  */
22
- export default function findAttributeRange(position: Position, attributeName: string, value: unknown, model: Model): Range;
22
+ export declare function findAttributeRange(position: ModelPosition, attributeName: string, value: unknown, model: Model): ModelRange;
23
23
  /**
24
24
  * Walks forward or backward (depends on the `lookBack` flag), node by node, as long as they have the same attribute value
25
25
  * and returns a position just before or after (depends on the `lookBack` flag) the last matched node.
@@ -30,4 +30,4 @@ export default function findAttributeRange(position: Position, attributeName: st
30
30
  * @param lookBack Whether the walk direction is forward (`false`) or backward (`true`).
31
31
  * @returns The position just before the last matched node.
32
32
  */
33
- export declare function findAttributeRangeBound(position: Position, attributeName: string, value: unknown, lookBack: boolean, model: Model): Position;
33
+ export declare function findAttributeRangeBound(position: ModelPosition, attributeName: string, value: unknown, lookBack: boolean, model: Model): ModelPosition;
@@ -15,7 +15,7 @@
15
15
  * @param model The model instance.
16
16
  * @returns The link range.
17
17
  */
18
- export default function findAttributeRange(position, attributeName, value, model) {
18
+ export function findAttributeRange(position, attributeName, value, model) {
19
19
  return model.createRange(findAttributeRangeBound(position, attributeName, value, true, model), findAttributeRangeBound(position, attributeName, value, false, model));
20
20
  }
21
21
  /**
@@ -5,7 +5,7 @@
5
5
  /**
6
6
  * @module typing/utils/getlasttextline
7
7
  */
8
- import type { Model, Range } from '@ckeditor/ckeditor5-engine';
8
+ import type { Model, ModelRange } from '@ckeditor/ckeditor5-engine';
9
9
  /**
10
10
  * Returns the last text line from the given range.
11
11
  *
@@ -33,7 +33,7 @@ import type { Model, Range } from '@ckeditor/ckeditor5-engine';
33
33
  * <paragraph>Foo<softBreak></softBreak>bar<softBreak></softBreak>baz<paragraph>
34
34
  * ```
35
35
  */
36
- export default function getLastTextLine(range: Range, model: Model): LastTextLineData;
36
+ export declare function getLastTextLine(range: ModelRange, model: Model): LastTextLineData;
37
37
  /**
38
38
  * The value returned by {@link module:typing/utils/getlasttextline~getLastTextLine}.
39
39
  */
@@ -45,5 +45,5 @@ export type LastTextLineData = {
45
45
  /**
46
46
  * The range set on the text nodes in the last text line.
47
47
  */
48
- range: Range;
48
+ range: ModelRange;
49
49
  };
@@ -29,7 +29,7 @@
29
29
  * <paragraph>Foo<softBreak></softBreak>bar<softBreak></softBreak>baz<paragraph>
30
30
  * ```
31
31
  */
32
- export default function getLastTextLine(range, model) {
32
+ export function getLastTextLine(range, model) {
33
33
  let start = range.start;
34
34
  const text = Array.from(range.getWalker({ ignoreElementEnd: false })).reduce((rangeText, { item }) => {
35
35
  // Trim text to a last occurrence of an inline element and update range start.
@@ -18,7 +18,7 @@ import type { Editor } from '@ckeditor/ckeditor5-core';
18
18
  * Usage:
19
19
  *
20
20
  * ```ts
21
- * import inlineHighlight from '@ckeditor/ckeditor5-typing/src/utils/inlinehighlight';
21
+ * import { inlineHighlight } from '@ckeditor/ckeditor5-typing/src/utils/inlinehighlight';
22
22
  *
23
23
  * // Make `ck-link_selected` class be applied on an `a` element
24
24
  * // whenever the corresponding `linkHref` attribute element is selected.
@@ -30,4 +30,4 @@ import type { Editor } from '@ckeditor/ckeditor5-core';
30
30
  * @param tagName The tagName of a view item.
31
31
  * @param className The class name to apply in the view.
32
32
  */
33
- export default function inlineHighlight(editor: Editor, attributeName: string, tagName: string, className: string): void;
33
+ export declare function inlineHighlight(editor: Editor, attributeName: string, tagName: string, className: string): void;
@@ -5,7 +5,7 @@
5
5
  /**
6
6
  * @module typing/utils/inlinehighlight
7
7
  */
8
- import findAttributeRange from './findattributerange.js';
8
+ import { findAttributeRange } from './findattributerange.js';
9
9
  /**
10
10
  * Adds a visual highlight style to an attribute element in which the selection is anchored.
11
11
  * Together with two-step caret movement, they indicate that the user is typing inside the element.
@@ -21,7 +21,7 @@ import findAttributeRange from './findattributerange.js';
21
21
  * Usage:
22
22
  *
23
23
  * ```ts
24
- * import inlineHighlight from '@ckeditor/ckeditor5-typing/src/utils/inlinehighlight';
24
+ * import { inlineHighlight } from '@ckeditor/ckeditor5-typing/src/utils/inlinehighlight';
25
25
  *
26
26
  * // Make `ck-link_selected` class be applied on an `a` element
27
27
  * // whenever the corresponding `linkHref` attribute element is selected.
@@ -33,7 +33,7 @@ import findAttributeRange from './findattributerange.js';
33
33
  * @param tagName The tagName of a view item.
34
34
  * @param className The class name to apply in the view.
35
35
  */
36
- export default function inlineHighlight(editor, attributeName, tagName, className) {
36
+ export function inlineHighlight(editor, attributeName, tagName, className) {
37
37
  const view = editor.editing.view;
38
38
  const highlightedElements = new Set();
39
39
  // Adding the class.