This repository has been archived by the owner on Jun 26, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #798 from ckeditor/t/788
Feature: Introduced `view.UIElement` and `view.writer.clear()` method. Closes #788. BREAKING CHANGES: Removed `view.DocumentFragment#getAncestors()`. Closes #803. Closes #805. BREAKING CHANGES: `Position.getAncestors()` should return elements in the same order as `Node.getAncestors()`.
- Loading branch information
Showing
25 changed files
with
711 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
/** | ||
* @license Copyright (c) 2003-2017, CKSource - Frederico Knabben. All rights reserved. | ||
* For licensing, see LICENSE.md. | ||
*/ | ||
|
||
/** | ||
* @module engine/view/uielement | ||
*/ | ||
|
||
import Element from './element'; | ||
import CKEditorError from '@ckeditor/ckeditor5-utils/src/ckeditorerror'; | ||
import Node from './node'; | ||
|
||
/** | ||
* UIElement class. It is used to represent UI not a content of the document. | ||
* This element can't be split and selection can't be placed inside this element. | ||
*/ | ||
export default class UIElement extends Element { | ||
/** | ||
* Creates new instance of UIElement. | ||
* | ||
* Throws {@link module:utils/ckeditorerror~CKEditorError CKEditorError} `view-uielement-cannot-add` when third parameter is passed, | ||
* to inform that usage of UIElement is incorrect (adding child nodes to UIElement is forbidden). | ||
* | ||
* @param {String} name Node name. | ||
* @param {Object|Iterable} [attributes] Collection of attributes. | ||
*/ | ||
constructor( name, attributes, children ) { | ||
super( name, attributes, children ); | ||
|
||
/** | ||
* Returns `null` because filler is not needed for UIElements. | ||
* | ||
* @method #getFillerOffset | ||
* @returns {null} Always returns null. | ||
*/ | ||
this.getFillerOffset = getFillerOffset; | ||
} | ||
|
||
/** | ||
* Overrides {@link module:engine/view/element~Element#insertChildren} method. | ||
* Throws {@link module:utils/ckeditorerror~CKEditorError CKEditorError} `view-uielement-cannot-add` to prevent adding any child nodes | ||
* to UIElement. | ||
*/ | ||
insertChildren( index, nodes ) { | ||
if ( nodes && ( nodes instanceof Node || Array.from( nodes ).length > 0 ) ) { | ||
/** | ||
* Cannot add children to {@link module:engine/view/uielement~UIElement}. | ||
* | ||
* @error view-uielement-cannot-add | ||
*/ | ||
throw new CKEditorError( 'view-uielement-cannot-add: Cannot add child nodes to UIElement instance.' ); | ||
} | ||
} | ||
} | ||
|
||
// Returns `null` because block filler is not needed for UIElements. | ||
// | ||
// @returns {null} | ||
function getFillerOffset() { | ||
return null; | ||
} |
Oops, something went wrong.