/** * @license Copyright (c) 2003-2018, CKSource - Frederico Knabben. All rights reserved. * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license */ 'use strict'; /** * A lightweight representation of an HTML DOM structure. * * @class * @constructor Creates a fragment class instance. */ CKEDITOR.htmlParser.fragment = function() { /** * The nodes contained in the root of this fragment. * * var fragment = CKEDITOR.htmlParser.fragment.fromHtml( 'Sample Text' ); * alert( fragment.children.length ); // 2 */ this.children = []; /** * Get the fragment parent. Should always be null. * * @property {Object} [=null] */ this.parent = null; /** @private */ this._ = { isBlockLike: true, hasInlineStarted: false }; }; ( function() { // Block-level elements whose internal structure should be respected during // parser fixing. var nonBreakingBlocks = CKEDITOR.tools.extend( { table: 1, ul: 1, ol: 1, dl: 1 }, CKEDITOR.dtd.table, CKEDITOR.dtd.ul, CKEDITOR.dtd.ol, CKEDITOR.dtd.dl ); var listBlocks = { ol: 1, ul: 1 }; // Dtd of the fragment element, basically it accept anything except for intermediate structure, e.g. orphan
foo
`. * @returns {CKEDITOR.htmlParser.fragment/CKEDITOR.htmlParser.element} The created fragment or passed `parent`. */ CKEDITOR.htmlParser.fragment.fromHtml = function( fragmentHtml, parent, fixingBlock ) { var parser = new CKEDITOR.htmlParser(); var root = parent instanceof CKEDITOR.htmlParser.element ? parent : typeof parent == 'string' ? new CKEDITOR.htmlParser.element( parent ) : new CKEDITOR.htmlParser.fragment(); var pendingInline = [], pendingBRs = [], currentNode = root, // Indicate we're inside a