/*! * VisualEditor DataModel MWBlockImageNode class. * * @copyright 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', 'alt' ]; return attributes.indexOf( attribute ) === -1; }; ve.dm.MWBlockImageNode.static.handlesOwnChildren = true; ve.dm.MWBlockImageNode.static.childNodeTypes = [ 'mwImageCaption' ]; ve.dm.MWBlockImageNode.static.matchTagNames = [ 'figure' ]; ve.dm.MWBlockImageNode.static.disallowedAnnotationTypes = [ '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 figure = domElements[ 0 ]; var img = figure.querySelector( '.mw-file-element' ); // ,