@ckeditor/ckeditor5-engine 47.4.0 → 47.5.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ckeditor/ckeditor5-engine",
3
- "version": "47.4.0",
3
+ "version": "47.5.0-alpha.1",
4
4
  "description": "The editing engine of CKEditor 5 – the best browser-based rich text editor.",
5
5
  "keywords": [
6
6
  "wysiwyg",
@@ -24,7 +24,7 @@
24
24
  "type": "module",
25
25
  "main": "src/index.js",
26
26
  "dependencies": {
27
- "@ckeditor/ckeditor5-utils": "47.4.0",
27
+ "@ckeditor/ckeditor5-utils": "47.5.0-alpha.1",
28
28
  "es-toolkit": "1.39.5"
29
29
  },
30
30
  "author": "CKSource (http://cksource.com/)",
@@ -64,4 +64,4 @@
64
64
  "./theme/*": "./theme/*",
65
65
  "./package.json": "./package.json"
66
66
  }
67
- }
67
+ }
@@ -492,9 +492,14 @@ export declare class ModelSchema extends /* #__PURE__ */ ModelSchema_base {
492
492
  *
493
493
  * @param ranges Ranges to be validated.
494
494
  * @param attribute The name of the attribute to check.
495
+ * @param options Optional configuration.
496
+ * @param options.includeEmptyRanges When `true`, empty ranges that allow the attribute are also included
497
+ * in the returned ranges.
495
498
  * @returns Ranges in which the attribute is allowed.
496
499
  */
497
- getValidRanges(ranges: Iterable<ModelRange>, attribute: string): IterableIterator<ModelRange>;
500
+ getValidRanges(ranges: Iterable<ModelRange>, attribute: string, options?: {
501
+ includeEmptyRanges?: boolean;
502
+ }): IterableIterator<ModelRange>;
498
503
  /**
499
504
  * Basing on given `position`, finds and returns a {@link module:engine/model/range~ModelRange range} which is
500
505
  * nearest to that `position` and is a correct range for selection.
@@ -722,12 +722,15 @@ export class ModelSchema extends /* #__PURE__ */ ObservableMixin() {
722
722
  *
723
723
  * @param ranges Ranges to be validated.
724
724
  * @param attribute The name of the attribute to check.
725
+ * @param options Optional configuration.
726
+ * @param options.includeEmptyRanges When `true`, empty ranges that allow the attribute are also included
727
+ * in the returned ranges.
725
728
  * @returns Ranges in which the attribute is allowed.
726
729
  */
727
- *getValidRanges(ranges, attribute) {
730
+ *getValidRanges(ranges, attribute, options = {}) {
728
731
  ranges = convertToMinimalFlatRanges(ranges);
729
732
  for (const range of ranges) {
730
- yield* this._getValidRangesForRange(range, attribute);
733
+ yield* this._getValidRangesForRange(range, attribute, options);
731
734
  }
732
735
  }
733
736
  /**
@@ -1004,12 +1007,22 @@ export class ModelSchema extends /* #__PURE__ */ ObservableMixin() {
1004
1007
  * @param attribute The name of the attribute to check.
1005
1008
  * @returns Ranges in which the attribute is allowed.
1006
1009
  */
1007
- *_getValidRangesForRange(range, attribute) {
1010
+ *_getValidRangesForRange(range, attribute, options) {
1008
1011
  let start = range.start;
1009
1012
  let end = range.start;
1010
1013
  for (const item of range.getItems({ shallow: true })) {
1011
1014
  if (item.is('element')) {
1012
- yield* this._getValidRangesForRange(ModelRange._createIn(item), attribute);
1015
+ if (options.includeEmptyRanges && item.isEmpty) {
1016
+ // In empty block check if it accepts text with the given attribute.
1017
+ const context = this.createContext(item);
1018
+ if (this.checkChild(context, '$text') &&
1019
+ this.checkAttribute(context.push('$text'), attribute)) {
1020
+ yield ModelRange._createIn(item);
1021
+ }
1022
+ }
1023
+ else {
1024
+ yield* this._getValidRangesForRange(ModelRange._createIn(item), attribute, options);
1025
+ }
1013
1026
  }
1014
1027
  if (!this.checkAttribute(item, attribute)) {
1015
1028
  if (!start.isEqual(end)) {