|
|
@@ -531,42 +531,6 @@ export default class Schema {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * Takes a flat range and an attribute name. Traverses the range recursively and deeply to find and return all ranges
|
|
|
- * inside the given range on which the attribute can be applied.
|
|
|
- *
|
|
|
- * This is a helper function for {@link ~Schema#getValidRanges}.
|
|
|
- *
|
|
|
- * @private
|
|
|
- * @param {module:engine/model/range~Range} range Range to process.
|
|
|
- * @param {String} attribute The name of the attribute to check.
|
|
|
- * @returns {Iterable.<module:engine/model/range~Range>} Ranges in which the attribute is allowed.
|
|
|
- */
|
|
|
- * _getValidRangesForRange( range, attribute ) {
|
|
|
- let start = range.start;
|
|
|
- let end = range.start;
|
|
|
-
|
|
|
- for ( const item of range.getItems( { shallow: true } ) ) {
|
|
|
- if ( item.is( 'element' ) ) {
|
|
|
- yield* this._getValidRangesForRange( Range._createIn( item ), attribute );
|
|
|
- }
|
|
|
-
|
|
|
- if ( !this.checkAttribute( item, attribute ) ) {
|
|
|
- if ( !start.isEqual( end ) ) {
|
|
|
- yield new Range( start, end );
|
|
|
- }
|
|
|
-
|
|
|
- start = Position._createAfter( item );
|
|
|
- }
|
|
|
-
|
|
|
- end = Position._createAfter( item );
|
|
|
- }
|
|
|
-
|
|
|
- if ( !start.isEqual( end ) ) {
|
|
|
- yield new Range( start, end );
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
* Basing on given `position`, finds and returns a {@link module:engine/model/range~Range range} which is
|
|
|
* nearest to that `position` and is a correct range for selection.
|
|
|
*
|
|
|
@@ -738,6 +702,42 @@ export default class Schema {
|
|
|
return false;
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Takes a flat range and an attribute name. Traverses the range recursively and deeply to find and return all ranges
|
|
|
+ * inside the given range on which the attribute can be applied.
|
|
|
+ *
|
|
|
+ * This is a helper function for {@link ~Schema#getValidRanges}.
|
|
|
+ *
|
|
|
+ * @private
|
|
|
+ * @param {module:engine/model/range~Range} range Range to process.
|
|
|
+ * @param {String} attribute The name of the attribute to check.
|
|
|
+ * @returns {Iterable.<module:engine/model/range~Range>} Ranges in which the attribute is allowed.
|
|
|
+ */
|
|
|
+ * _getValidRangesForRange( range, attribute ) {
|
|
|
+ let start = range.start;
|
|
|
+ let end = range.start;
|
|
|
+
|
|
|
+ for ( const item of range.getItems( { shallow: true } ) ) {
|
|
|
+ if ( item.is( 'element' ) ) {
|
|
|
+ yield* this._getValidRangesForRange( Range._createIn( item ), attribute );
|
|
|
+ }
|
|
|
+
|
|
|
+ if ( !this.checkAttribute( item, attribute ) ) {
|
|
|
+ if ( !start.isEqual( end ) ) {
|
|
|
+ yield new Range( start, end );
|
|
|
+ }
|
|
|
+
|
|
|
+ start = Position._createAfter( item );
|
|
|
+ }
|
|
|
+
|
|
|
+ end = Position._createAfter( item );
|
|
|
+ }
|
|
|
+
|
|
|
+ if ( !start.isEqual( end ) ) {
|
|
|
+ yield new Range( start, end );
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
mix( Schema, ObservableMixin );
|