/*! * VisualEditor DataModel MWInlineImage class. * * @copyright 2011-2020 VisualEditor Team and others; see AUTHORS.txt * @license The MIT License (MIT); see LICENSE.txt */ /** * DataModel MediaWiki image node. * * @class * @extends ve.dm.LeafNode * @mixins ve.dm.MWImageNode * * @constructor * @param {Object} [element] Reference to element in linear model */ ve.dm.MWInlineImageNode = function VeDmMWInlineImageNode() { // Parent constructor ve.dm.MWInlineImageNode.super.apply( this, arguments ); // Mixin constructors ve.dm.MWImageNode.call( this ); }; /* Inheritance */ OO.inheritClass( ve.dm.MWInlineImageNode, ve.dm.LeafNode ); // Need to mixin base class as well (T92540) OO.mixinClass( ve.dm.MWInlineImageNode, ve.dm.GeneratedContentNode ); OO.mixinClass( ve.dm.MWInlineImageNode, ve.dm.MWImageNode ); /* Static Properties */ ve.dm.MWInlineImageNode.static.isContent = true; ve.dm.MWInlineImageNode.static.name = 'mwInlineImage'; ve.dm.MWInlineImageNode.static.preserveHtmlAttributes = function ( attribute ) { var attributes = [ 'typeof', 'class', 'src', 'resource', 'width', 'height', 'href', 'data-mw' ]; return attributes.indexOf( attribute ) === -1; }; // For a while, Parsoid switched to for inline images, but // then decided to switch back to in T266143. ve.dm.MWInlineImageNode.static.matchTagNames = [ 'span', 'figure-inline' ]; ve.dm.MWInlineImageNode.static.disallowedAnnotationTypes = [ 'link' ]; ve.dm.MWInlineImageNode.static.toDataElement = function ( domElements, converter ) { var dataElement, attributes, href, targetData, container, imgWrapper, img, typeofAttrs, classes, recognizedClasses, errorIndex, width, height, types, mwDataJSON, mwData; container = domElements[ 0 ]; // or imgWrapper = container.children[ 0 ]; // or if ( !imgWrapper ) { // Malformed figure, alienate (T267282) return null; } img = imgWrapper.children[ 0 ]; // ,