All files / src/dm ve.dm.Converter.js

90.9% Statements 30/33
100% Branches 0/0
62.5% Functions 5/8
90.9% Lines 30/33

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94                                  1x 1x 1x         1x                             1x   1x 1x 1x 1x 1x 1x 1x   1x   1x 1x 1x       1x   1x       1x 544x     1x 1x     1x 72x     1x       1x 815x     1x       1x         1x  
/*!
 * VisualEditor DataModel Converter class.
 *
 * @copyright See AUTHORS.txt
 */
 
/**
 * DataModel converter.
 *
 * Converts between HTML DOM and VisualEditor linear data.
 *
 * @class
 * @constructor
 * @param {ve.dm.ModelRegistry} modelRegistry
 * @param {ve.dm.NodeFactory} nodeFactory
 * @param {ve.dm.AnnotationFactory} annotationFactory
 */
ve.dm.Converter = function VeDmConverter( modelRegistry, nodeFactory, annotationFactory ) {
	this.domFromModelConverter = new ve.dm.DomFromModelConverter( modelRegistry, nodeFactory, annotationFactory );
	this.modelFromDomConverter = new ve.dm.ModelFromDomConverter( modelRegistry, nodeFactory, annotationFactory );
};
 
/* Inheritance */
 
OO.initClass( ve.dm.Converter );
 
// Proxy public APIs back to ve.dm.Converter
 
/* Static Properties */
 
/**
 * Pattern matching 'white space characters' as defined by the HTML spec only.
 *
 * All other whitespace should be treated as text, e.g. non-breaking spaces.
 *
 * See https://www.w3.org/TR/html4/struct/text.html#h-9.1
 *
 * @type {string}
 */
ve.dm.Converter.static.whitespaceList = ' \\t\\f\\u200b\\r\\n';
 
const whitespaceList = ve.dm.Converter.static.whitespaceList;
ve.dm.Converter.static.leadingWhitespaceRegex = new RegExp( '^[' + whitespaceList + ']' );
ve.dm.Converter.static.leadingWhitespacesRegex = new RegExp( '^[' + whitespaceList + ']+' );
ve.dm.Converter.static.trailingWhitespaceRegex = new RegExp( '[' + whitespaceList + ']$' );
ve.dm.Converter.static.trailingWhitespacesRegex = new RegExp( '[' + whitespaceList + ']+$' );
ve.dm.Converter.static.onlyWhitespaceRegex = new RegExp( '^[' + whitespaceList + ']+$' );
ve.dm.Converter.static.trimWhitespaceRegex = new RegExp( '^([' + whitespaceList + ']*)([\\s\\S]*?)([' + whitespaceList + ']*)$' );
 
ve.dm.Converter.static.computedAttributes = ve.dm.DomFromModelConverter.static.computedAttributes;
 
ve.dm.Converter.static.PARSER_MODE = ve.dm.DomFromModelConverter.static.PARSER_MODE;
ve.dm.Converter.static.CLIPBOARD_MODE = ve.dm.DomFromModelConverter.static.CLIPBOARD_MODE;
ve.dm.Converter.static.PREVIEW_MODE = ve.dm.DomFromModelConverter.static.PREVIEW_MODE;
 
/* Static methods */
 
ve.dm.Converter.static.openAndCloseAnnotations = ve.dm.DomFromModelConverter.static.openAndCloseAnnotations;
 
ve.dm.Converter.static.renderHtmlAttributeList = ve.dm.DomFromModelConverter.static.renderHtmlAttributeList;
 
/* Methods */
 
ve.dm.Converter.prototype.getDomFromModel = function () {
	return this.domFromModelConverter.getDomFromModel( ...arguments );
};
 
ve.dm.Converter.prototype.getDomFromNode = function () {
	return this.domFromModelConverter.getDomFromNode( ...arguments );
};
 
ve.dm.Converter.prototype.getDomSubtreeFromModel = function () {
	return this.domFromModelConverter.getDomSubtreeFromModel( ...arguments );
};
 
ve.dm.Converter.prototype.getDomSubtreeFromData = function () {
	return this.domFromModelConverter.getDomSubtreeFromData( ...arguments );
};
 
ve.dm.Converter.prototype.getModelFromDom = function () {
	return this.modelFromDomConverter.getModelFromDom( ...arguments );
};
 
ve.dm.Converter.prototype.getDataFromDomClean = function () {
	return this.modelFromDomConverter.getDataFromDomClean( ...arguments );
};
 
ve.dm.Converter.prototype.getDataFromDomSubtree = function () {
	return this.modelFromDomConverter.getDataFromDomSubtree( ...arguments );
};
/* Initialization */
 
ve.dm.converter = new ve.dm.Converter( ve.dm.modelRegistry, ve.dm.nodeFactory, ve.dm.annotationFactory );