@ckeditor/ckeditor5-engine 48.4.0-alpha.7 → 48.5.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/index.js CHANGED
@@ -1823,7 +1823,8 @@ var StylesMap = class {
1823
1823
  match.push(styleName);
1824
1824
  continue;
1825
1825
  }
1826
- if (isPatternMatched(valuePattern, this.getAsString(styleName))) match.push(styleName);
1826
+ const value = this.getAsString(styleName);
1827
+ if (isPatternMatched(valuePattern, value)) match.push(styleName);
1827
1828
  }
1828
1829
  return match.length ? match : void 0;
1829
1830
  }
@@ -6991,7 +6992,8 @@ var ViewDowncastWriter = class {
6991
6992
  const newRange = this._unwrapChildren(parentContainer, breakStart.offset, breakEnd.offset, attribute);
6992
6993
  const start = this.mergeAttributes(newRange.start);
6993
6994
  if (!start.isEqual(newRange.start)) newRange.end.offset--;
6994
- return new ViewRange(start, this.mergeAttributes(newRange.end));
6995
+ const end = this.mergeAttributes(newRange.end);
6996
+ return new ViewRange(start, end);
6995
6997
  }
6996
6998
  /**
6997
6999
  * Renames element by creating a copy of renamed element but with changed name and then moving contents of the
@@ -7177,7 +7179,8 @@ var ViewDowncastWriter = class {
7177
7179
  const endPosition = insertionPosition.getShiftedBy(length);
7178
7180
  const start = this.mergeAttributes(insertionPosition);
7179
7181
  if (!start.isEqual(insertionPosition)) endPosition.offset--;
7180
- return new ViewRange(start, this.mergeAttributes(endPosition));
7182
+ const end = this.mergeAttributes(endPosition);
7183
+ return new ViewRange(start, end);
7181
7184
  }
7182
7185
  /**
7183
7186
  * Wraps children with provided `wrapElement`. Only children contained in `parent` element between
@@ -7273,7 +7276,8 @@ var ViewDowncastWriter = class {
7273
7276
  const newRange = this._wrapChildren(parentContainer, breakStart.offset, breakEnd.offset, attribute);
7274
7277
  const start = this.mergeAttributes(newRange.start);
7275
7278
  if (!start.isEqual(newRange.start)) newRange.end.offset--;
7276
- return new ViewRange(start, this.mergeAttributes(newRange.end));
7279
+ const end = this.mergeAttributes(newRange.end);
7280
+ return new ViewRange(start, end);
7277
7281
  }
7278
7282
  /**
7279
7283
  * Helper function for {@link #wrap}. Wraps position with provided attribute element.
@@ -10113,7 +10117,9 @@ var MutationObserver = class extends Observer {
10113
10117
  });
10114
10118
  for (const viewElement of elementsWithMutatedChildren) {
10115
10119
  const domElement = domConverter.mapViewToDom(viewElement);
10116
- if (!isEqualWith(Array.from(viewElement.getChildren()), Array.from(domConverter.domChildrenToView(domElement, { withChildren: false })), sameNodes)) mutations.push({
10120
+ const viewChildren = Array.from(viewElement.getChildren());
10121
+ const newViewChildren = Array.from(domConverter.domChildrenToView(domElement, { withChildren: false }));
10122
+ if (!isEqualWith(viewChildren, newViewChildren, sameNodes)) mutations.push({
10117
10123
  type: "children",
10118
10124
  node: viewElement
10119
10125
  });
@@ -11642,7 +11648,8 @@ var ModelTreeWalker = class {
11642
11648
  if (this._boundaryEndParent == parent && this.boundaries.end.offset < offset) offset = this.boundaries.end.offset;
11643
11649
  charactersCount = offset - position.offset;
11644
11650
  }
11645
- const item = new ModelTextProxy(node, position.offset - node.startOffset, charactersCount);
11651
+ const offsetInTextNode = position.offset - node.startOffset;
11652
+ const item = new ModelTextProxy(node, offsetInTextNode, charactersCount);
11646
11653
  position.offset += charactersCount;
11647
11654
  this._position = position;
11648
11655
  return formatReturnValue("text", item, previousPosition, position, charactersCount);
@@ -11692,7 +11699,8 @@ var ModelTreeWalker = class {
11692
11699
  if (this._boundaryStartParent == parent && this.boundaries.start.offset > offset) offset = this.boundaries.start.offset;
11693
11700
  charactersCount = position.offset - offset;
11694
11701
  }
11695
- const item = new ModelTextProxy(node, position.offset - node.startOffset - charactersCount, charactersCount);
11702
+ const offsetInTextNode = position.offset - node.startOffset;
11703
+ const item = new ModelTextProxy(node, offsetInTextNode - charactersCount, charactersCount);
11696
11704
  position.offset -= charactersCount;
11697
11705
  this._position = position;
11698
11706
  return formatReturnValue("text", item, previousPosition, position, charactersCount);
@@ -12140,7 +12148,9 @@ var ModelPosition = class ModelPosition extends ModelTypeCheckable {
12140
12148
  */
12141
12149
  hasSameParentAs(position) {
12142
12150
  if (this.root !== position.root) return false;
12143
- return compareArrays(this.getParentPath(), position.getParentPath()) == "same";
12151
+ const thisParentPath = this.getParentPath();
12152
+ const posParentPath = position.getParentPath();
12153
+ return compareArrays(thisParentPath, posParentPath) == "same";
12144
12154
  }
12145
12155
  /**
12146
12156
  * Returns a copy of this position that is transformed by given `operation`.
@@ -12175,9 +12185,7 @@ var ModelPosition = class ModelPosition extends ModelTypeCheckable {
12175
12185
  case "detach":
12176
12186
  result = this._getTransformedByDetachOperation(operation);
12177
12187
  break;
12178
- default:
12179
- result = ModelPosition._createAt(this);
12180
- break;
12188
+ default: result = ModelPosition._createAt(this);
12181
12189
  }
12182
12190
  return result;
12183
12191
  }
@@ -12640,7 +12648,9 @@ var ModelRange = class ModelRange extends ModelTypeCheckable {
12640
12648
  * {@link #end} position are in the same {@link module:engine/model/position~ModelPosition#parent}.
12641
12649
  */
12642
12650
  get isFlat() {
12643
- return compareArrays(this.start.getParentPath(), this.end.getParentPath()) == "same";
12651
+ const startParentPath = this.start.getParentPath();
12652
+ const endParentPath = this.end.getParentPath();
12653
+ return compareArrays(startParentPath, endParentPath) == "same";
12644
12654
  }
12645
12655
  /**
12646
12656
  * Range root element.
@@ -24012,7 +24022,8 @@ var SplitOperation = class SplitOperation extends Operation {
24012
24022
  const newElement = splitElement._clone();
24013
24023
  _insert(this.insertionPosition, newElement);
24014
24024
  }
24015
- _move(new ModelRange(ModelPosition._createAt(splitElement, this.splitPosition.offset), ModelPosition._createAt(splitElement, splitElement.maxOffset)), this.moveTargetPosition);
24025
+ const sourceRange = new ModelRange(ModelPosition._createAt(splitElement, this.splitPosition.offset), ModelPosition._createAt(splitElement, splitElement.maxOffset));
24026
+ _move(sourceRange, this.moveTargetPosition);
24016
24027
  }
24017
24028
  /**
24018
24029
  * @inheritDoc
@@ -24187,7 +24198,8 @@ var MergeOperation = class MergeOperation extends Operation {
24187
24198
  */
24188
24199
  _execute() {
24189
24200
  const mergedElement = this.sourcePosition.parent;
24190
- _move(ModelRange._createIn(mergedElement), this.targetPosition);
24201
+ const sourceRange = ModelRange._createIn(mergedElement);
24202
+ _move(sourceRange, this.targetPosition);
24191
24203
  _move(ModelRange._createOn(mergedElement), this.graveyardPosition);
24192
24204
  }
24193
24205
  /**
@@ -25397,7 +25409,8 @@ setTransformation(AttributeOperation, InsertOperation, (a, b) => {
25397
25409
  function _getComplementaryAttributeOperations(insertOperation, key, newValue) {
25398
25410
  const insertValue = insertOperation.nodes.getNode(0).getAttribute(key);
25399
25411
  if (insertValue == newValue) return null;
25400
- return new AttributeOperation(new ModelRange(insertOperation.position, insertOperation.position.getShiftedBy(insertOperation.howMany)), key, insertValue, newValue, 0);
25412
+ const range = new ModelRange(insertOperation.position, insertOperation.position.getShiftedBy(insertOperation.howMany));
25413
+ return new AttributeOperation(range, key, insertValue, newValue, 0);
25401
25414
  }
25402
25415
  setTransformation(AttributeOperation, MergeOperation, (a, b) => {
25403
25416
  const ranges = [];
@@ -25763,7 +25776,8 @@ setTransformation(RenameOperation, RenameOperation, (a, b, context) => {
25763
25776
  });
25764
25777
  setTransformation(RenameOperation, SplitOperation, (a, b) => {
25765
25778
  const renamePath = a.position.path;
25766
- if (compareArrays(renamePath, b.splitPosition.getParentPath()) == "same" && !b.graveyardPosition) return [a, new RenameOperation(a.position.getShiftedBy(1), a.oldName, a.newName, 0)];
25779
+ const splitPath = b.splitPosition.getParentPath();
25780
+ if (compareArrays(renamePath, splitPath) == "same" && !b.graveyardPosition) return [a, new RenameOperation(a.position.getShiftedBy(1), a.oldName, a.newName, 0)];
25767
25781
  a.position = a.position._getTransformedBySplitOperation(b);
25768
25782
  return [a];
25769
25783
  });
@@ -25786,7 +25800,9 @@ setTransformation(SplitOperation, MergeOperation, (a, b, context) => {
25786
25800
  if (!a.graveyardPosition && !context.bWasUndone && a.splitPosition.hasSameParentAs(b.sourcePosition)) {
25787
25801
  const splitPath = b.graveyardPosition.path.slice();
25788
25802
  splitPath.push(0);
25789
- const additionalSplit = new SplitOperation(new ModelPosition(b.graveyardPosition.root, splitPath), 0, SplitOperation.getInsertionPosition(new ModelPosition(b.graveyardPosition.root, splitPath)), null, 0);
25803
+ const splitPosition = new ModelPosition(b.graveyardPosition.root, splitPath);
25804
+ const insertionPosition = SplitOperation.getInsertionPosition(new ModelPosition(b.graveyardPosition.root, splitPath));
25805
+ const additionalSplit = new SplitOperation(splitPosition, 0, insertionPosition, null, 0);
25790
25806
  a.splitPosition = a.splitPosition._getTransformedByMergeOperation(b);
25791
25807
  a.insertionPosition = SplitOperation.getInsertionPosition(a.splitPosition);
25792
25808
  a.graveyardPosition = additionalSplit.insertionPosition.clone();
@@ -28592,7 +28608,8 @@ var ModelWriter = class {
28592
28608
  throw new CKEditorError("model-writer-insert-forbidden-move", this);
28593
28609
  else this.remove(item);
28594
28610
  const version = position.root.document ? position.root.document.version : null;
28595
- const insert = new InsertOperation(position, item instanceof ModelDocumentFragment ? item._removeChildren(0, item.childCount) : item, version);
28611
+ const children = item instanceof ModelDocumentFragment ? item._removeChildren(0, item.childCount) : item;
28612
+ const insert = new InsertOperation(position, children, version);
28596
28613
  if (item instanceof ModelText) insert.shouldReceiveAttributes = true;
28597
28614
  this.batch.addOperation(insert);
28598
28615
  this.model.applyOperation(insert);
@@ -29482,8 +29499,10 @@ function setAttributeOnItem(writer, key, value, item) {
29482
29499
  const previousValue = item.getAttribute(key);
29483
29500
  let range, operation;
29484
29501
  if (previousValue != value) {
29485
- if (item.root === item) operation = new RootAttributeOperation(item, key, previousValue, value, item.document ? doc.version : null);
29486
- else {
29502
+ if (item.root === item) {
29503
+ const version = item.document ? doc.version : null;
29504
+ operation = new RootAttributeOperation(item, key, previousValue, value, version);
29505
+ } else {
29487
29506
  range = new ModelRange(ModelPosition._createBefore(item), writer.createPositionAfter(item));
29488
29507
  const version = range.root.document ? doc.version : null;
29489
29508
  operation = new AttributeOperation(range, key, previousValue, value, version);
@@ -29515,7 +29534,8 @@ function applyRemoveOperation(position, howMany, batch, model) {
29515
29534
  let operation;
29516
29535
  if (position.root.document) {
29517
29536
  const doc = model.document;
29518
- operation = new MoveOperation(position, howMany, new ModelPosition(doc.graveyard, [0]), doc.version);
29537
+ const graveyardPosition = new ModelPosition(doc.graveyard, [0]);
29538
+ operation = new MoveOperation(position, howMany, graveyardPosition, doc.version);
29519
29539
  } else operation = new DetachOperation(position, howMany);
29520
29540
  batch.addOperation(operation);
29521
29541
  model.applyOperation(operation);
@@ -29666,7 +29686,9 @@ function tryFixingNonCollapsedRage(range, schema) {
29666
29686
  if (checkSelectionOnNonLimitElements(start, end, schema)) {
29667
29687
  const fixedStart = start.nodeAfter && schema.isSelectable(start.nodeAfter) ? null : schema.getNearestSelectionRange(start, "forward");
29668
29688
  const fixedEnd = end.nodeBefore && schema.isSelectable(end.nodeBefore) ? null : schema.getNearestSelectionRange(end, "backward");
29669
- return new ModelRange(fixedStart ? fixedStart.start : start, fixedEnd ? fixedEnd.end : end);
29689
+ const rangeStart = fixedStart ? fixedStart.start : start;
29690
+ const rangeEnd = fixedEnd ? fixedEnd.end : end;
29691
+ return new ModelRange(rangeStart, rangeEnd);
29670
29692
  }
29671
29693
  }
29672
29694
  const isStartInLimit = startLimitElement && !startLimitElement.is("rootElement");
@@ -34328,7 +34350,8 @@ function _stringifyModel(node, selectionOrPositionOrRange = null, markers = null
34328
34350
  else if (selectionOrPositionOrRange instanceof ModelDocumentSelection) selection = selectionOrPositionOrRange;
34329
34351
  else if (selectionOrPositionOrRange instanceof ModelRange) selection = new ModelSelection(selectionOrPositionOrRange);
34330
34352
  else if (selectionOrPositionOrRange instanceof ModelPosition) selection = new ModelSelection(selectionOrPositionOrRange);
34331
- const view = new EditingView(new StylesProcessor());
34353
+ const stylesProcessor = new StylesProcessor();
34354
+ const view = new EditingView(stylesProcessor);
34332
34355
  const viewDocument = view.document;
34333
34356
  const viewRoot = new ViewRootEditableElement(viewDocument, "div");
34334
34357
  viewRoot.rootName = "main";