2018-06-17 16:07:19 +00:00
|
|
|
/**
|
|
|
|
* @license Copyright (c) 2003-2018, CKSource - Frederico Knabben. All rights reserved.
|
|
|
|
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
2014-04-11 20:07:18 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* DocumentFragment is a "lightweight" or "minimal" Document object. It is
|
|
|
|
* commonly used to extract a portion of a document's tree or to create a new
|
2018-06-17 16:07:19 +00:00
|
|
|
* fragment of a document. Various operations may take document fragment objects
|
|
|
|
* as arguments and result in all the child nodes of the document fragment being
|
2014-04-11 20:07:18 +00:00
|
|
|
* moved to the child list of this node.
|
|
|
|
*
|
|
|
|
* @class
|
|
|
|
* @constructor Creates a document fragment class instance.
|
2018-06-17 16:07:19 +00:00
|
|
|
* @param {CKEDITOR.dom.document/DocumentFragment} [nodeOrDoc=CKEDITOR.document]
|
2014-04-11 20:07:18 +00:00
|
|
|
*/
|
|
|
|
CKEDITOR.dom.documentFragment = function( nodeOrDoc ) {
|
|
|
|
nodeOrDoc = nodeOrDoc || CKEDITOR.document;
|
|
|
|
|
|
|
|
if ( nodeOrDoc.type == CKEDITOR.NODE_DOCUMENT )
|
|
|
|
this.$ = nodeOrDoc.$.createDocumentFragment();
|
|
|
|
else
|
|
|
|
this.$ = nodeOrDoc;
|
|
|
|
};
|
|
|
|
|
|
|
|
CKEDITOR.tools.extend( CKEDITOR.dom.documentFragment.prototype, CKEDITOR.dom.element.prototype, {
|
|
|
|
/**
|
|
|
|
* The node type. This is a constant value set to {@link CKEDITOR#NODE_DOCUMENT_FRAGMENT}.
|
|
|
|
*
|
|
|
|
* @readonly
|
|
|
|
* @property {Number} [=CKEDITOR.NODE_DOCUMENT_FRAGMENT]
|
|
|
|
*/
|
|
|
|
type: CKEDITOR.NODE_DOCUMENT_FRAGMENT,
|
|
|
|
|
|
|
|
/**
|
2018-06-17 16:07:19 +00:00
|
|
|
* Inserts the document fragment content after the specified node.
|
2014-04-11 20:07:18 +00:00
|
|
|
*
|
|
|
|
* @param {CKEDITOR.dom.node} node
|
|
|
|
*/
|
|
|
|
insertAfterNode: function( node ) {
|
|
|
|
node = node.$;
|
|
|
|
node.parentNode.insertBefore( this.$, node.nextSibling );
|
2018-06-17 16:07:19 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets HTML of this document fragment's children.
|
|
|
|
*
|
|
|
|
* @since 4.5
|
|
|
|
* @returns {String} The HTML of this document fragment's children.
|
|
|
|
*/
|
|
|
|
getHtml: function() {
|
|
|
|
var container = new CKEDITOR.dom.element( 'div' );
|
|
|
|
|
|
|
|
this.clone( 1, 1 ).appendTo( container );
|
|
|
|
|
|
|
|
return container.getHtml().replace( /\s*data-cke-expando=".*?"/g, '' );
|
2014-04-11 20:07:18 +00:00
|
|
|
}
|
2018-06-17 16:07:19 +00:00
|
|
|
}, true, {
|
|
|
|
'append': 1, 'appendBogus': 1, 'clone': 1, 'getFirst': 1, 'getHtml': 1, 'getLast': 1, 'getParent': 1, 'getNext': 1, 'getPrevious': 1,
|
|
|
|
'appendTo': 1, 'moveChildren': 1, 'insertBefore': 1, 'insertAfterNode': 1, 'replace': 1, 'trim': 1, 'type': 1,
|
|
|
|
'ltrim': 1, 'rtrim': 1, 'getDocument': 1, 'getChildCount': 1, 'getChild': 1, 'getChildren': 1
|
|
|
|
} );
|