|
@@ -25,6 +25,7 @@ import AttributeElement from '../view/attributeelement';
|
|
|
import ContainerElement from '../view/containerelement';
|
|
import ContainerElement from '../view/containerelement';
|
|
|
import EmptyElement from '../view/emptyelement';
|
|
import EmptyElement from '../view/emptyelement';
|
|
|
import UIElement from '../view/uielement';
|
|
import UIElement from '../view/uielement';
|
|
|
|
|
+import RawElement from '../view/rawelement';
|
|
|
import { StylesProcessor } from '../view/stylesmap';
|
|
import { StylesProcessor } from '../view/stylesmap';
|
|
|
|
|
|
|
|
const ELEMENT_RANGE_START_TOKEN = '[';
|
|
const ELEMENT_RANGE_START_TOKEN = '[';
|
|
@@ -35,7 +36,8 @@ const allowedTypes = {
|
|
|
'container': ContainerElement,
|
|
'container': ContainerElement,
|
|
|
'attribute': AttributeElement,
|
|
'attribute': AttributeElement,
|
|
|
'empty': EmptyElement,
|
|
'empty': EmptyElement,
|
|
|
- 'ui': UIElement
|
|
|
|
|
|
|
+ 'ui': UIElement,
|
|
|
|
|
+ 'raw': RawElement
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -55,6 +57,8 @@ const allowedTypes = {
|
|
|
* (`<span id="marker:foo">`).
|
|
* (`<span id="marker:foo">`).
|
|
|
* @param {Boolean} [options.renderUIElements=false] When set to `true`, the inner content of each
|
|
* @param {Boolean} [options.renderUIElements=false] When set to `true`, the inner content of each
|
|
|
* {@link module:engine/view/uielement~UIElement} will be printed.
|
|
* {@link module:engine/view/uielement~UIElement} will be printed.
|
|
|
|
|
+ * @param {Boolean} [options.renderRawElements=false] When set to `true`, the inner content of each
|
|
|
|
|
+ * {@link module:engine/view/rawelement~RawElement} will be printed.
|
|
|
* @returns {String} The stringified data.
|
|
* @returns {String} The stringified data.
|
|
|
*/
|
|
*/
|
|
|
export function getData( view, options = {} ) {
|
|
export function getData( view, options = {} ) {
|
|
@@ -70,6 +74,7 @@ export function getData( view, options = {} ) {
|
|
|
showType: options.showType,
|
|
showType: options.showType,
|
|
|
showPriority: options.showPriority,
|
|
showPriority: options.showPriority,
|
|
|
renderUIElements: options.renderUIElements,
|
|
renderUIElements: options.renderUIElements,
|
|
|
|
|
+ renderRawElements: options.renderRawElements,
|
|
|
ignoreRoot: true
|
|
ignoreRoot: true
|
|
|
};
|
|
};
|
|
|
|
|
|
|
@@ -234,6 +239,8 @@ setData._parse = parse;
|
|
|
* `{` and `}` and the selection outside the text as `[` and `]`. When set to `false`, both will be marked as `[` and `]` only.
|
|
* `{` and `}` and the selection outside the text as `[` and `]`. When set to `false`, both will be marked as `[` and `]` only.
|
|
|
* @param {Boolean} [options.renderUIElements=false] When set to `true`, the inner content of each
|
|
* @param {Boolean} [options.renderUIElements=false] When set to `true`, the inner content of each
|
|
|
* {@link module:engine/view/uielement~UIElement} will be printed.
|
|
* {@link module:engine/view/uielement~UIElement} will be printed.
|
|
|
|
|
+ * @param {Boolean} [options.renderRawElements=false] When set to `true`, the inner content of each
|
|
|
|
|
+ * {@link module:engine/view/rawelement~RawElement} will be printed.
|
|
|
* @returns {String} An HTML-like string representing the view.
|
|
* @returns {String} An HTML-like string representing the view.
|
|
|
*/
|
|
*/
|
|
|
export function stringify( node, selectionOrPositionOrRange = null, options = {} ) {
|
|
export function stringify( node, selectionOrPositionOrRange = null, options = {} ) {
|
|
@@ -622,6 +629,8 @@ class ViewStringify {
|
|
|
* `{` and `}` and the selection outside the text as `[` and `]`. When set to `false`, both are marked as `[` and `]`.
|
|
* `{` and `}` and the selection outside the text as `[` and `]`. When set to `false`, both are marked as `[` and `]`.
|
|
|
* @param {Boolean} [options.renderUIElements=false] When set to `true`, the inner content of each
|
|
* @param {Boolean} [options.renderUIElements=false] When set to `true`, the inner content of each
|
|
|
* {@link module:engine/view/uielement~UIElement} will be printed.
|
|
* {@link module:engine/view/uielement~UIElement} will be printed.
|
|
|
|
|
+ * @param {Boolean} [options.renderRawElements=false] When set to `true`, the inner content of each
|
|
|
|
|
+ * {@link module:engine/view/rawelement~RawElement} will be printed.
|
|
|
*/
|
|
*/
|
|
|
constructor( root, selection, options ) {
|
|
constructor( root, selection, options ) {
|
|
|
this.root = root;
|
|
this.root = root;
|
|
@@ -638,6 +647,7 @@ class ViewStringify {
|
|
|
this.ignoreRoot = !!options.ignoreRoot;
|
|
this.ignoreRoot = !!options.ignoreRoot;
|
|
|
this.sameSelectionCharacters = !!options.sameSelectionCharacters;
|
|
this.sameSelectionCharacters = !!options.sameSelectionCharacters;
|
|
|
this.renderUIElements = !!options.renderUIElements;
|
|
this.renderUIElements = !!options.renderUIElements;
|
|
|
|
|
+ this.renderRawElements = !!options.renderRawElements;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -670,7 +680,7 @@ class ViewStringify {
|
|
|
callback( this._stringifyElementOpen( root ) );
|
|
callback( this._stringifyElementOpen( root ) );
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- if ( this.renderUIElements && root.is( 'uiElement' ) ) {
|
|
|
|
|
|
|
+ if ( ( this.renderUIElements && root.is( 'uiElement' ) ) || ( this.renderRawElements && root.is( 'rawElement' ) ) ) {
|
|
|
callback( root.render( document ).innerHTML );
|
|
callback( root.render( document ).innerHTML );
|
|
|
} else {
|
|
} else {
|
|
|
let offset = 0;
|
|
let offset = 0;
|
|
@@ -943,10 +953,10 @@ function _convertViewElements( rootNode ) {
|
|
|
for ( const child of [ ...rootNode.getChildren() ] ) {
|
|
for ( const child of [ ...rootNode.getChildren() ] ) {
|
|
|
if ( convertedElement.is( 'emptyElement' ) ) {
|
|
if ( convertedElement.is( 'emptyElement' ) ) {
|
|
|
throw new Error( 'Parse error - cannot parse inside EmptyElement.' );
|
|
throw new Error( 'Parse error - cannot parse inside EmptyElement.' );
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- if ( convertedElement.is( 'uiElement' ) ) {
|
|
|
|
|
|
|
+ } else if ( convertedElement.is( 'uiElement' ) ) {
|
|
|
throw new Error( 'Parse error - cannot parse inside UIElement.' );
|
|
throw new Error( 'Parse error - cannot parse inside UIElement.' );
|
|
|
|
|
+ } else if ( convertedElement.is( 'rawElement' ) ) {
|
|
|
|
|
+ throw new Error( 'Parse error - cannot parse inside RawElement.' );
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
convertedElement._appendChild( _convertViewElements( child ) );
|
|
convertedElement._appendChild( _convertViewElements( child ) );
|