|
|
@@ -39,6 +39,18 @@ export default class AttributeElement extends Element {
|
|
|
* @member {Number} module:engine/view/attributeelement~AttributeElement#priority
|
|
|
*/
|
|
|
this.priority = DEFAULT_PRIORITY;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Returns block {@link module:engine/view/filter~Filter filler} offset or `null` if block filler is not needed.
|
|
|
+ * This method is implemented in a constructor because it is treated as an injected behaviour and it might be
|
|
|
+ * changed during execution (in elements representing widgets for example).
|
|
|
+ * When {@link module:engine/view/element~Element.clone element is cloned}, this method will be referenced from
|
|
|
+ * source object.
|
|
|
+ *
|
|
|
+ * @method #getFillerOffset
|
|
|
+ * @returns {Number|null} Block filler offset or `null` if block filler is not needed.
|
|
|
+ */
|
|
|
+ this.getFillerOffset = getFillerOffset;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -68,40 +80,40 @@ export default class AttributeElement extends Element {
|
|
|
isSimilar( otherElement ) {
|
|
|
return super.isSimilar( otherElement ) && this.priority == otherElement.priority;
|
|
|
}
|
|
|
+}
|
|
|
|
|
|
- /**
|
|
|
- * Returns block {@link module:engine/view/filter~Filter filler} offset or `null` if a block filler is not needed.
|
|
|
- *
|
|
|
- * @returns {Number|null} Block filler offset or `null` if block filler is not needed.
|
|
|
- */
|
|
|
- getFillerOffset() {
|
|
|
- // <b>foo</b> does not need filler.
|
|
|
- if ( this.childCount ) {
|
|
|
- return null;
|
|
|
- }
|
|
|
+/**
|
|
|
+ * Default attribute priority.
|
|
|
+ *
|
|
|
+ * @member {Number} module:engine/view/attributeelement~AttributeElement.DEFAULT_PRIORITY
|
|
|
+ */
|
|
|
+AttributeElement.DEFAULT_PRIORITY = DEFAULT_PRIORITY;
|
|
|
|
|
|
- let element = this.parent;
|
|
|
+// Returns block {@link module:engine/view/filter~Filter filler} offset or `null` if block filler is not needed.
|
|
|
+//
|
|
|
+// @returns {Number|null} Block filler offset or `null` if block filler is not needed.
|
|
|
+function getFillerOffset() {
|
|
|
+ /*jshint validthis:true */
|
|
|
|
|
|
- // <p><b></b></p> needs filler -> <p><b><br></b></p>
|
|
|
- while ( element instanceof AttributeElement ) {
|
|
|
- if ( element.childCount > 1 ) {
|
|
|
- return null;
|
|
|
- }
|
|
|
+ // <b>foo</b> does not need filler.
|
|
|
+ if ( this.childCount ) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
|
|
|
- element = element.parent;
|
|
|
- }
|
|
|
+ let element = this.parent;
|
|
|
|
|
|
- if ( !element || element.childCount > 1 ) {
|
|
|
+ // <p><b></b></p> needs filler -> <p><b><br></b></p>
|
|
|
+ while ( element instanceof AttributeElement ) {
|
|
|
+ if ( element.childCount > 1 ) {
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
- return 0;
|
|
|
+ element = element.parent;
|
|
|
}
|
|
|
-}
|
|
|
|
|
|
-/**
|
|
|
- * Default attribute priority.
|
|
|
- *
|
|
|
- * @member {Number} module:engine/view/attributeelement~AttributeElement.DEFAULT_PRIORITY
|
|
|
- */
|
|
|
-AttributeElement.DEFAULT_PRIORITY = DEFAULT_PRIORITY;
|
|
|
+ if ( !element || element.childCount > 1 ) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ return 0;
|
|
|
+}
|