diff options
author | Ismaël Bouya <ismael.bouya@normalesup.org> | 2017-01-20 00:55:51 +0100 |
---|---|---|
committer | Ismaël Bouya <ismael.bouya@normalesup.org> | 2017-01-20 00:55:51 +0100 |
commit | c63493c899de714b05b0521bb38aab60d19030ef (patch) | |
tree | fcb2b261afa0f3c2bd6b48929b64724c71192bae /sources/core/dom/documentfragment.js | |
download | ludivine-ckeditor-component-c63493c899de714b05b0521bb38aab60d19030ef.tar.gz ludivine-ckeditor-component-c63493c899de714b05b0521bb38aab60d19030ef.tar.zst ludivine-ckeditor-component-c63493c899de714b05b0521bb38aab60d19030ef.zip |
Validation initiale4.6.2.1
Diffstat (limited to 'sources/core/dom/documentfragment.js')
-rw-r--r-- | sources/core/dom/documentfragment.js | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/sources/core/dom/documentfragment.js b/sources/core/dom/documentfragment.js new file mode 100644 index 0000000..1058144 --- /dev/null +++ b/sources/core/dom/documentfragment.js | |||
@@ -0,0 +1,62 @@ | |||
1 | /** | ||
2 | * @license Copyright (c) 2003-2017, CKSource - Frederico Knabben. All rights reserved. | ||
3 | * For licensing, see LICENSE.md or http://ckeditor.com/license | ||
4 | */ | ||
5 | |||
6 | /** | ||
7 | * DocumentFragment is a "lightweight" or "minimal" Document object. It is | ||
8 | * commonly used to extract a portion of a document's tree or to create a new | ||
9 | * fragment of a document. Various operations may take document fragment objects | ||
10 | * as arguments and result in all the child nodes of the document fragment being | ||
11 | * moved to the child list of this node. | ||
12 | * | ||
13 | * @class | ||
14 | * @constructor Creates a document fragment class instance. | ||
15 | * @param {CKEDITOR.dom.document/DocumentFragment} [nodeOrDoc=CKEDITOR.document] | ||
16 | */ | ||
17 | CKEDITOR.dom.documentFragment = function( nodeOrDoc ) { | ||
18 | nodeOrDoc = nodeOrDoc || CKEDITOR.document; | ||
19 | |||
20 | if ( nodeOrDoc.type == CKEDITOR.NODE_DOCUMENT ) | ||
21 | this.$ = nodeOrDoc.$.createDocumentFragment(); | ||
22 | else | ||
23 | this.$ = nodeOrDoc; | ||
24 | }; | ||
25 | |||
26 | CKEDITOR.tools.extend( CKEDITOR.dom.documentFragment.prototype, CKEDITOR.dom.element.prototype, { | ||
27 | /** | ||
28 | * The node type. This is a constant value set to {@link CKEDITOR#NODE_DOCUMENT_FRAGMENT}. | ||
29 | * | ||
30 | * @readonly | ||
31 | * @property {Number} [=CKEDITOR.NODE_DOCUMENT_FRAGMENT] | ||
32 | */ | ||
33 | type: CKEDITOR.NODE_DOCUMENT_FRAGMENT, | ||
34 | |||
35 | /** | ||
36 | * Inserts the document fragment content after the specified node. | ||
37 | * | ||
38 | * @param {CKEDITOR.dom.node} node | ||
39 | */ | ||
40 | insertAfterNode: function( node ) { | ||
41 | node = node.$; | ||
42 | node.parentNode.insertBefore( this.$, node.nextSibling ); | ||
43 | }, | ||
44 | |||
45 | /** | ||
46 | * Gets HTML of this document fragment's children. | ||
47 | * | ||
48 | * @since 4.5 | ||
49 | * @returns {String} The HTML of this document fragment's children. | ||
50 | */ | ||
51 | getHtml: function() { | ||
52 | var container = new CKEDITOR.dom.element( 'div' ); | ||
53 | |||
54 | this.clone( 1, 1 ).appendTo( container ); | ||
55 | |||
56 | return container.getHtml().replace( /\s*data-cke-expando=".*?"/g, '' ); | ||
57 | } | ||
58 | }, true, { | ||
59 | 'append': 1, 'appendBogus': 1, 'clone': 1, 'getFirst': 1, 'getHtml': 1, 'getLast': 1, 'getParent': 1, 'getNext': 1, 'getPrevious': 1, | ||
60 | 'appendTo': 1, 'moveChildren': 1, 'insertBefore': 1, 'insertAfterNode': 1, 'replace': 1, 'trim': 1, 'type': 1, | ||
61 | 'ltrim': 1, 'rtrim': 1, 'getDocument': 1, 'getChildCount': 1, 'getChild': 1, 'getChildren': 1 | ||
62 | } ); | ||