/*! * VisualEditor DataModel MWBlockImageNode class. * * @copyright 2011-2019 VisualEditor Team and others; see AUTHORS.txt * @license The MIT License (MIT); see LICENSE.txt */ /** * DataModel MediaWiki image node. * * @class * @extends ve.dm.BranchNode * @mixins ve.dm.MWImageNode * @mixins ve.dm.ClassAttributeNode * * @constructor * @param {Object} [element] Reference to element in linear model * @param {ve.dm.Node[]} [children] */ ve.dm.MWBlockImageNode = function VeDmMWBlockImageNode() { // Parent constructor ve.dm.MWBlockImageNode.super.apply( this, arguments ); // Mixin constructors ve.dm.MWImageNode.call( this ); ve.dm.ClassAttributeNode.call( this ); }; /* Inheritance */ OO.inheritClass( ve.dm.MWBlockImageNode, ve.dm.BranchNode ); // Need to mixin base class as well (T92540) OO.mixinClass( ve.dm.MWBlockImageNode, ve.dm.GeneratedContentNode ); OO.mixinClass( ve.dm.MWBlockImageNode, ve.dm.MWImageNode ); OO.mixinClass( ve.dm.MWBlockImageNode, ve.dm.ClassAttributeNode ); /* Static Properties */ ve.dm.MWBlockImageNode.static.name = 'mwBlockImage'; ve.dm.MWBlockImageNode.static.preserveHtmlAttributes = function ( attribute ) { var attributes = [ 'typeof', 'class', 'src', 'resource', 'width', 'height', 'href', 'rel', 'data-mw' ]; return attributes.indexOf( attribute ) === -1; }; ve.dm.MWBlockImageNode.static.handlesOwnChildren = true; ve.dm.MWBlockImageNode.static.ignoreChildren = true; ve.dm.MWBlockImageNode.static.childNodeTypes = [ 'mwImageCaption' ]; ve.dm.MWBlockImageNode.static.matchTagNames = [ 'figure' ]; ve.dm.MWBlockImageNode.static.blacklistedAnnotationTypes = [ 'link' ]; ve.dm.MWBlockImageNode.static.classAttributes = { 'mw-image-border': { borderImage: true }, 'mw-halign-left': { align: 'left' }, 'mw-halign-right': { align: 'right' }, 'mw-halign-center': { align: 'center' }, 'mw-halign-none': { align: 'none' }, 'mw-default-size': { defaultSize: true } }; ve.dm.MWBlockImageNode.static.toDataElement = function ( domElements, converter ) { var dataElement, newDimensions, attributes, figure, imgWrapper, img, captionNode, caption, classAttr, typeofAttrs, errorIndex, width, height, types, mwDataJSON, mwData; figure = domElements[ 0 ]; imgWrapper = figure.children[ 0 ]; // or img = imgWrapper.children[ 0 ]; // ,