/*! * 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 * @mixes ve.dm.MWImageNode * @mixes 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 ) { const 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 ) { const figure = domElements[ 0 ]; const img = figure.querySelector( '.mw-file-element' ); // ,