|
@@ -9,7 +9,6 @@
|
|
|
|
|
|
|
|
import { isArray } from 'lodash-es';
|
|
import { isArray } from 'lodash-es';
|
|
|
import CKEditorError from '@ckeditor/ckeditor5-utils/src/ckeditorerror';
|
|
import CKEditorError from '@ckeditor/ckeditor5-utils/src/ckeditorerror';
|
|
|
-import StylesMap from '../view/stylesmap';
|
|
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* Class used for handling consumption of view {@link module:engine/view/element~Element elements},
|
|
* Class used for handling consumption of view {@link module:engine/view/element~Element elements},
|
|
@@ -89,7 +88,7 @@ export default class ViewConsumable {
|
|
|
|
|
|
|
|
// For elements create new ViewElementConsumables or update already existing one.
|
|
// For elements create new ViewElementConsumables or update already existing one.
|
|
|
if ( !this._consumables.has( element ) ) {
|
|
if ( !this._consumables.has( element ) ) {
|
|
|
- elementConsumables = new ViewElementConsumables();
|
|
|
|
|
|
|
+ elementConsumables = new ViewElementConsumables( element );
|
|
|
this._consumables.set( element, elementConsumables );
|
|
this._consumables.set( element, elementConsumables );
|
|
|
} else {
|
|
} else {
|
|
|
elementConsumables = this._consumables.get( element );
|
|
elementConsumables = this._consumables.get( element );
|
|
@@ -239,6 +238,7 @@ export default class ViewConsumable {
|
|
|
*/
|
|
*/
|
|
|
static consumablesFromElement( element ) {
|
|
static consumablesFromElement( element ) {
|
|
|
const consumables = {
|
|
const consumables = {
|
|
|
|
|
+ element,
|
|
|
name: true,
|
|
name: true,
|
|
|
attributes: [],
|
|
attributes: [],
|
|
|
classes: [],
|
|
classes: [],
|
|
@@ -284,7 +284,7 @@ export default class ViewConsumable {
|
|
|
*/
|
|
*/
|
|
|
static createFrom( from, instance ) {
|
|
static createFrom( from, instance ) {
|
|
|
if ( !instance ) {
|
|
if ( !instance ) {
|
|
|
- instance = new ViewConsumable();
|
|
|
|
|
|
|
+ instance = new ViewConsumable( from );
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
if ( from.is( 'text' ) ) {
|
|
if ( from.is( 'text' ) ) {
|
|
@@ -319,8 +319,17 @@ export default class ViewConsumable {
|
|
|
class ViewElementConsumables {
|
|
class ViewElementConsumables {
|
|
|
/**
|
|
/**
|
|
|
* Creates ViewElementConsumables instance.
|
|
* Creates ViewElementConsumables instance.
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param {module:engine/view/node~Node|module:engine/view/documentfragment~DocumentFragment} from View node or document fragment
|
|
|
|
|
+ * from which `ViewElementConsumables` is being created.
|
|
|
*/
|
|
*/
|
|
|
- constructor() {
|
|
|
|
|
|
|
+ constructor( from ) {
|
|
|
|
|
+ /**
|
|
|
|
|
+ * @readonly
|
|
|
|
|
+ * @member {module:engine/view/node~Node|module:engine/view/documentfragment~DocumentFragment}
|
|
|
|
|
+ */
|
|
|
|
|
+ this.element = from;
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* Flag indicating if name of the element can be consumed.
|
|
* Flag indicating if name of the element can be consumed.
|
|
|
*
|
|
*
|
|
@@ -510,7 +519,7 @@ class ViewElementConsumables {
|
|
|
consumables.set( name, true );
|
|
consumables.set( name, true );
|
|
|
|
|
|
|
|
if ( type === 'styles' ) {
|
|
if ( type === 'styles' ) {
|
|
|
- for ( const alsoName of StylesMap.getRelatedStyles( name ) ) {
|
|
|
|
|
|
|
+ for ( const alsoName of this.element.document.stylesProcessor.getRelatedStyles( name ) ) {
|
|
|
consumables.set( alsoName, true );
|
|
consumables.set( alsoName, true );
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -577,7 +586,7 @@ class ViewElementConsumables {
|
|
|
consumables.set( name, false );
|
|
consumables.set( name, false );
|
|
|
|
|
|
|
|
if ( type == 'styles' ) {
|
|
if ( type == 'styles' ) {
|
|
|
- for ( const toConsume of StylesMap.getRelatedStyles( name ) ) {
|
|
|
|
|
|
|
+ for ( const toConsume of this.element.document.stylesProcessor.getRelatedStyles( name ) ) {
|
|
|
consumables.set( toConsume, false );
|
|
consumables.set( toConsume, false );
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|