@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 CHANGED
@@ -4,7 +4,7 @@
4
4
  */
5
5
  import { Command, Plugin } from '@ckeditor/ckeditor5-core/dist/index.js';
6
6
  import { env, EventInfo, count, isInsideSurrogatePair, isInsideCombinedSymbol, isInsideEmojiSequence, keyCodes, ObservableMixin } from '@ckeditor/ckeditor5-utils/dist/index.js';
7
- import { Observer, FocusObserver, DomEventData, _tryFixingModelRange, LiveRange, BubblingEventInfo, MouseObserver, TouchObserver } from '@ckeditor/ckeditor5-engine/dist/index.js';
7
+ import { Observer, FocusObserver, ViewDocumentDomEventData, _tryFixingModelRange, ModelLiveRange, BubblingEventInfo, MouseObserver, TouchObserver } from '@ckeditor/ckeditor5-engine/dist/index.js';
8
8
  import { debounce, escapeRegExp } from 'es-toolkit/compat';
9
9
 
10
10
  /**
@@ -19,7 +19,7 @@ import { debounce, escapeRegExp } from 'es-toolkit/compat';
19
19
  * Batches represent single undo steps, hence changes added to one single batch are undone together.
20
20
  *
21
21
  * The buffer has a configurable limit of atomic changes that it can accommodate. After the limit was
22
- * exceeded (see {@link ~ChangeBuffer#input}), a new batch is created in {@link ~ChangeBuffer#batch}.
22
+ * exceeded (see {@link ~TypingChangeBuffer#input}), a new batch is created in {@link ~TypingChangeBuffer#batch}.
23
23
  *
24
24
  * To use the change buffer you need to let it know about the number of changes that were added to the batch:
25
25
  *
@@ -30,7 +30,7 @@ import { debounce, escapeRegExp } from 'es-toolkit/compat';
30
30
  * buffer.batch.insert( pos, insertedCharacters );
31
31
  * buffer.input( insertedCharacters.length );
32
32
  * ```
33
- */ class ChangeBuffer {
33
+ */ class TypingChangeBuffer {
34
34
  /**
35
35
  * The model instance.
36
36
  */ model;
@@ -155,7 +155,7 @@ import { debounce, escapeRegExp } from 'es-toolkit/compat';
155
155
  * which can be contained in one batch in the command buffer.
156
156
  */ constructor(editor, undoStepSize){
157
157
  super(editor);
158
- this._buffer = new ChangeBuffer(editor.model, undoStepSize);
158
+ this._buffer = new TypingChangeBuffer(editor.model, undoStepSize);
159
159
  // Since this command may execute on different selectable than selection, it should be checked directly in execute block.
160
160
  this._isEnabledBasedOnSelection = false;
161
161
  }
@@ -196,7 +196,7 @@ import { debounce, escapeRegExp } from 'es-toolkit/compat';
196
196
  model.enqueueChange(this._buffer.batch, (writer)=>{
197
197
  this._buffer.lock();
198
198
  // Store selection attributes before deleting old content to preserve formatting and link.
199
- // This unifies the behavior between DocumentSelection and Selection provided as input option.
199
+ // This unifies the behavior between ModelDocumentSelection and Selection provided as input option.
200
200
  const selectionAttributes = Array.from(doc.selection.getAttributes());
201
201
  model.deleteContent(selection);
202
202
  if (text) {
@@ -231,7 +231,7 @@ const TYPING_INPUT_TYPES_ANDROID = [
231
231
  'insertCompositionText'
232
232
  ];
233
233
  /**
234
- * Text insertion observer introduces the {@link module:engine/view/document~Document#event:insertText} event.
234
+ * Text insertion observer introduces the {@link module:engine/view/document~ViewDocument#event:insertText} event.
235
235
  */ class InsertTextObserver extends Observer {
236
236
  /**
237
237
  * Instance of the focus observer. Insert text observer calls
@@ -259,7 +259,7 @@ const TYPING_INPUT_TYPES_ANDROID = [
259
259
  // so the selection is in the focused element).
260
260
  this.focusObserver.flush();
261
261
  const eventInfo = new EventInfo(viewDocument, 'insertText');
262
- viewDocument.fire(eventInfo, new DomEventData(view, domEvent, {
262
+ viewDocument.fire(eventInfo, new ViewDocumentDomEventData(view, domEvent, {
263
263
  text,
264
264
  selection: view.createSelection(targetRanges),
265
265
  isComposing
@@ -297,7 +297,7 @@ const TYPING_INPUT_TYPES_ANDROID = [
297
297
  // 2. The last moment before it's locked is the `compositionstart` event.
298
298
  // 3. The `SelectionObserver` is listening for `compositionstart` event and immediately converts
299
299
  // the selection. Handle this at the low priority so after the rendering is blocked.
300
- viewDocument.fire('insertText', new DomEventData(view, domEvent, {
300
+ viewDocument.fire('insertText', new ViewDocumentDomEventData(view, domEvent, {
301
301
  text: data,
302
302
  isComposing: true
303
303
  }));
@@ -627,7 +627,7 @@ const TYPING_INPUT_TYPES_ANDROID = [
627
627
  if (commandData.selection) {
628
628
  commandLiveData.selectionRanges = [];
629
629
  for (const range of commandData.selection.getRanges()){
630
- commandLiveData.selectionRanges.push(LiveRange.fromRange(range));
630
+ commandLiveData.selectionRanges.push(ModelLiveRange.fromRange(range));
631
631
  // Keep reference to the model element for later mutation checks.
632
632
  this._affectedElements.add(range.start.parent);
633
633
  }
@@ -740,7 +740,7 @@ const TYPING_INPUT_TYPES_ANDROID = [
740
740
  buffer.unlock();
741
741
  }
742
742
  /**
743
- * Detaches a LiveRange and returns the static range from it.
743
+ * Detaches a ModelLiveRange and returns the static range from it.
744
744
  */ function detachLiveRange(liveRange) {
745
745
  const range = liveRange.toRange();
746
746
  liveRange.detach();
@@ -779,7 +779,7 @@ const TYPING_INPUT_TYPES_ANDROID = [
779
779
  */ constructor(editor, direction){
780
780
  super(editor);
781
781
  this.direction = direction;
782
- this._buffer = new ChangeBuffer(editor.model, editor.config.get('typing.undoStep'));
782
+ this._buffer = new TypingChangeBuffer(editor.model, editor.config.get('typing.undoStep'));
783
783
  // Since this command may execute on different selectable than selection, it should be checked directly in execute block.
784
784
  this._isEnabledBasedOnSelection = false;
785
785
  }
@@ -796,7 +796,7 @@ const TYPING_INPUT_TYPES_ANDROID = [
796
796
  * @param options The command options.
797
797
  * @param options.unit See {@link module:engine/model/utils/modifyselection~modifySelection}'s options.
798
798
  * @param options.sequence A number describing which subsequent delete event it is without the key being released.
799
- * See the {@link module:engine/view/document~Document#event:delete} event data.
799
+ * See the {@link module:engine/view/document~ViewDocument#event:delete} event data.
800
800
  * @param options.selection Selection to remove. If not set, current model selection will be used.
801
801
  */ execute(options = {}) {
802
802
  const model = this.editor.model;
@@ -1045,7 +1045,9 @@ const DELETE_EVENT_TYPES = {
1045
1045
  }
1046
1046
  };
1047
1047
  /**
1048
- * Delete observer introduces the {@link module:engine/view/document~Document#event:delete} event.
1048
+ * Delete observer introduces the {@link module:engine/view/document~ViewDocument#event:delete} event.
1049
+ *
1050
+ * @internal
1049
1051
  */ class DeleteObserver extends Observer {
1050
1052
  /**
1051
1053
  * @inheritDoc
@@ -1096,7 +1098,7 @@ const DELETE_EVENT_TYPES = {
1096
1098
  }
1097
1099
  }
1098
1100
  const eventInfo = new BubblingEventInfo(document, 'delete', targetRanges[0]);
1099
- document.fire(eventInfo, new DomEventData(view, domEvent, deleteData));
1101
+ document.fire(eventInfo, new ViewDocumentDomEventData(view, domEvent, deleteData));
1100
1102
  // Stop the beforeinput event if `delete` event was stopped.
1101
1103
  // https://github.com/ckeditor/ckeditor5/issues/753
1102
1104
  if (eventInfo.stop.called) {
@@ -1138,7 +1140,7 @@ const DELETE_EVENT_TYPES = {
1138
1140
  direction: getDeleteDirection(keyCode),
1139
1141
  selectionToRemove: selection
1140
1142
  };
1141
- document.fire(eventInfo, new DomEventData(view, domEvent, deleteData));
1143
+ document.fire(eventInfo, new ViewDocumentDomEventData(view, domEvent, deleteData));
1142
1144
  }
1143
1145
  });
1144
1146
  document.on('beforeinput', (evt, { inputType })=>{
@@ -1274,7 +1276,7 @@ const DELETE_EVENT_TYPES = {
1274
1276
  direction: 'backward',
1275
1277
  selectionToRemove: viewSelection
1276
1278
  };
1277
- viewDocument.fire(eventInfo, new DomEventData(view, data.domEvent, deleteData));
1279
+ viewDocument.fire(eventInfo, new ViewDocumentDomEventData(view, data.domEvent, deleteData));
1278
1280
  }
1279
1281
  });
1280
1282
  if (this.editor.plugins.has('UndoEditing')) {
@@ -1616,12 +1618,12 @@ const DELETE_EVENT_TYPES = {
1616
1618
  */ attributes;
1617
1619
  /**
1618
1620
  * The current UID of the overridden gravity, as returned by
1619
- * {@link module:engine/model/writer~Writer#overrideSelectionGravity}.
1621
+ * {@link module:engine/model/writer~ModelWriter#overrideSelectionGravity}.
1620
1622
  */ _overrideUid;
1621
1623
  /**
1622
1624
  * A flag indicating that the automatic gravity restoration should not happen upon the next
1623
1625
  * gravity restoration.
1624
- * {@link module:engine/model/selection~Selection#event:change:range} event.
1626
+ * {@link module:engine/model/selection~ModelSelection#event:change:range} event.
1625
1627
  */ _isNextGravityRestorationSkipped = false;
1626
1628
  /**
1627
1629
  * @inheritDoc
@@ -1719,7 +1721,7 @@ const DELETE_EVENT_TYPES = {
1719
1721
  }
1720
1722
  /**
1721
1723
  * Updates the document selection and the view according to the two–step caret movement state
1722
- * when moving **forwards**. Executed upon `keypress` in the {@link module:engine/view/view~View}.
1724
+ * when moving **forwards**. Executed upon `keypress` in the {@link module:engine/view/view~EditingView}.
1723
1725
  *
1724
1726
  * @internal
1725
1727
  * @param eventData Data of the key press.
@@ -1778,7 +1780,7 @@ const DELETE_EVENT_TYPES = {
1778
1780
  }
1779
1781
  /**
1780
1782
  * Updates the document selection and the view according to the two–step caret movement state
1781
- * when moving **backwards**. Executed upon `keypress` in the {@link module:engine/view/view~View}.
1783
+ * when moving **backwards**. Executed upon `keypress` in the {@link module:engine/view/view~EditingView}.
1782
1784
  *
1783
1785
  * @internal
1784
1786
  * @param eventData Data of the key press.
@@ -1875,8 +1877,8 @@ const DELETE_EVENT_TYPES = {
1875
1877
  return false;
1876
1878
  }
1877
1879
  /**
1878
- * Starts listening to {@link module:engine/view/document~Document#event:mousedown} and
1879
- * {@link module:engine/view/document~Document#event:selectionChange} and puts the selection before/after a 2-step node
1880
+ * Starts listening to {@link module:engine/view/document~ViewDocument#event:mousedown} and
1881
+ * {@link module:engine/view/document~ViewDocument#event:selectionChange} and puts the selection before/after a 2-step node
1880
1882
  * if clicked at the beginning/ending of the 2-step node.
1881
1883
  *
1882
1884
  * The purpose of this action is to allow typing around the 2-step node directly after a click.
@@ -2024,19 +2026,19 @@ const DELETE_EVENT_TYPES = {
2024
2026
  return !!this._overrideUid;
2025
2027
  }
2026
2028
  /**
2027
- * Overrides the gravity using the {@link module:engine/model/writer~Writer model writer}
2029
+ * Overrides the gravity using the {@link module:engine/model/writer~ModelWriter model writer}
2028
2030
  * and stores the information about this fact in the {@link #_overrideUid}.
2029
2031
  *
2030
- * A shorthand for {@link module:engine/model/writer~Writer#overrideSelectionGravity}.
2032
+ * A shorthand for {@link module:engine/model/writer~ModelWriter#overrideSelectionGravity}.
2031
2033
  */ _overrideGravity() {
2032
2034
  this._overrideUid = this.editor.model.change((writer)=>{
2033
2035
  return writer.overrideSelectionGravity();
2034
2036
  });
2035
2037
  }
2036
2038
  /**
2037
- * Restores the gravity using the {@link module:engine/model/writer~Writer model writer}.
2039
+ * Restores the gravity using the {@link module:engine/model/writer~ModelWriter model writer}.
2038
2040
  *
2039
- * A shorthand for {@link module:engine/model/writer~Writer#restoreSelectionGravity}.
2041
+ * A shorthand for {@link module:engine/model/writer~ModelWriter#restoreSelectionGravity}.
2040
2042
  */ _restoreGravity() {
2041
2043
  this.editor.model.change((writer)=>{
2042
2044
  writer.restoreSelectionGravity(this._overrideUid);
@@ -2057,7 +2059,7 @@ const DELETE_EVENT_TYPES = {
2057
2059
  /**
2058
2060
  * Applies the given attributes to the current selection using using the
2059
2061
  * values from the node before the current position. Uses
2060
- * the {@link module:engine/model/writer~Writer model writer}.
2062
+ * the {@link module:engine/model/writer~ModelWriter model writer}.
2061
2063
  */ function setSelectionAttributesFromTheNodeBefore(model, attributes, position) {
2062
2064
  const nodeBefore = position.nodeBefore;
2063
2065
  model.change((writer)=>{
@@ -2527,7 +2529,7 @@ const DEFAULT_TRANSFORMATIONS = [
2527
2529
  * Usage:
2528
2530
  *
2529
2531
  * ```ts
2530
- * import inlineHighlight from '@ckeditor/ckeditor5-typing/src/utils/inlinehighlight';
2532
+ * import { inlineHighlight } from '@ckeditor/ckeditor5-typing/src/utils/inlinehighlight';
2531
2533
  *
2532
2534
  * // Make `ck-link_selected` class be applied on an `a` element
2533
2535
  * // whenever the corresponding `linkHref` attribute element is selected.
@@ -2586,5 +2588,5 @@ const DEFAULT_TRANSFORMATIONS = [
2586
2588
  });
2587
2589
  }
2588
2590
 
2589
- export { Delete, Input, InsertTextCommand, TextTransformation, TextWatcher, TwoStepCaretMovement, Typing, findAttributeRange, findAttributeRangeBound, getLastTextLine, inlineHighlight };
2591
+ export { Delete, DeleteCommand, Input, InsertTextCommand, TextTransformation, TextWatcher, TwoStepCaretMovement, Typing, TypingChangeBuffer, DeleteObserver as _DeleteObserver, findAttributeRange, findAttributeRangeBound, getLastTextLine, inlineHighlight };
2590
2592
  //# sourceMappingURL=index.js.map