|
|
@@ -9,6 +9,7 @@
|
|
|
|
|
|
import Element from './element';
|
|
|
import CKEditorError from 'ckeditor5-utils/src/ckeditorerror';
|
|
|
+import Node from './node';
|
|
|
|
|
|
/**
|
|
|
* EmptyElement class. It is used to represent elements that cannot contain any child nodes.
|
|
|
@@ -36,33 +37,22 @@ export default class EmptyElement extends Element {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * Overrides {@link module:engine/view/element~Element#appendChildren} method.
|
|
|
- * Throws {@link module:utils/ckeditorerror~CKEditorError CKEditorError} `view-emptyelement-cannot-add` to prevent adding any child nodes
|
|
|
- * to EmptyElement.
|
|
|
- */
|
|
|
- appendChildren() {
|
|
|
- throwCannotAdd();
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
* Overrides {@link module:engine/view/element~Element#insertChildren} method.
|
|
|
* Throws {@link module:utils/ckeditorerror~CKEditorError CKEditorError} `view-emptyelement-cannot-add` to prevent adding any child nodes
|
|
|
* to EmptyElement.
|
|
|
*/
|
|
|
- insertChildren() {
|
|
|
- throwCannotAdd();
|
|
|
+ insertChildren( index, nodes ) {
|
|
|
+ if ( nodes && ( nodes instanceof Node || Array.from( nodes ).length > 0 ) ) {
|
|
|
+ /**
|
|
|
+ * Cannot add children to {@link module:engine/view/emptyelement~EmptyElement}.
|
|
|
+ *
|
|
|
+ * @error view-emptyelement-cannot-add
|
|
|
+ */
|
|
|
+ throw new CKEditorError( 'view-emptyelement-cannot-add: Cannot add child nodes to EmptyElement instance.' );
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-function throwCannotAdd() {
|
|
|
- /**
|
|
|
- * Cannot add children to {@link module:engine/view/emptyelement~EmptyElement}.
|
|
|
- *
|
|
|
- * @error view-emptyelement-cannot-add
|
|
|
- */
|
|
|
- throw new CKEditorError( 'view-emptyelement-cannot-add: Cannot add child nodes to EmptyElement instance.' );
|
|
|
-}
|
|
|
-
|
|
|
// Returns `null` because block filler is not needed for EmptyElements.
|
|
|
//
|
|
|
// @returns {null}
|