2016-11-19 23:11:06 +00:00
|
|
|
/*!
|
|
|
|
* VisualEditor DataModel MWGalleryImageNode class.
|
|
|
|
*
|
2023-12-01 16:06:11 +00:00
|
|
|
* @copyright See AUTHORS.txt
|
2016-11-19 23:11:06 +00:00
|
|
|
* @license The MIT License (MIT); see LICENSE.txt
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* DataModel MediaWiki gallery image node.
|
|
|
|
*
|
|
|
|
* @class
|
|
|
|
* @extends ve.dm.BranchNode
|
|
|
|
*
|
|
|
|
* @constructor
|
|
|
|
* @param {Object} [element] Reference to element in linear model
|
|
|
|
* @param {ve.dm.Node[]} [children]
|
|
|
|
*/
|
|
|
|
ve.dm.MWGalleryImageNode = function VeDmMWGalleryImageNode() {
|
|
|
|
// Parent constructor
|
|
|
|
ve.dm.MWGalleryImageNode.super.apply( this, arguments );
|
|
|
|
};
|
|
|
|
|
|
|
|
/* Inheritance */
|
|
|
|
|
|
|
|
OO.inheritClass( ve.dm.MWGalleryImageNode, ve.dm.BranchNode );
|
|
|
|
|
|
|
|
/* Static members */
|
|
|
|
|
|
|
|
ve.dm.MWGalleryImageNode.static.name = 'mwGalleryImage';
|
|
|
|
|
|
|
|
ve.dm.MWGalleryImageNode.static.matchTagNames = [ 'li' ];
|
|
|
|
|
2018-04-03 18:33:00 +00:00
|
|
|
ve.dm.MWGalleryImageNode.static.childNodeTypes = [ 'mwGalleryImageCaption' ];
|
|
|
|
|
2016-11-19 23:11:06 +00:00
|
|
|
ve.dm.MWGalleryImageNode.static.matchFunction = function ( element ) {
|
2024-05-21 14:22:56 +00:00
|
|
|
const parentTypeof = ( element.parentNode && element.parentNode.getAttribute( 'typeof' ) ) || '';
|
2016-11-19 23:11:06 +00:00
|
|
|
return element.getAttribute( 'class' ) === 'gallerybox' &&
|
2018-10-02 20:48:25 +00:00
|
|
|
parentTypeof.trim().split( /\s+/ ).indexOf( 'mw:Extension/gallery' ) !== -1;
|
2016-11-19 23:11:06 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
ve.dm.MWGalleryImageNode.static.parentNodeTypes = [ 'mwGallery' ];
|
|
|
|
|
2023-02-15 01:53:10 +00:00
|
|
|
ve.dm.MWGalleryImageNode.static.preserveHtmlAttributes = function ( attribute ) {
|
2024-05-21 14:22:56 +00:00
|
|
|
const attributes = [ 'typeof', 'class', 'src', 'resource', 'width', 'height', 'href', 'rel', 'alt', 'data-mw' ];
|
2023-02-15 01:53:10 +00:00
|
|
|
return attributes.indexOf( attribute ) === -1;
|
|
|
|
};
|
|
|
|
// By handling our own children we ensure that original DOM attributes
|
|
|
|
// are deep copied back by the converter (in renderHtmlAttributeList)
|
|
|
|
ve.dm.MWGalleryImageNode.static.handlesOwnChildren = true;
|
|
|
|
|
2023-08-09 23:40:17 +00:00
|
|
|
// This should be kept in sync with Parsoid's WTUtils::textContentFromCaption
|
|
|
|
// which drops <ref>s and metadata tags
|
|
|
|
ve.dm.MWGalleryImageNode.static.textContentFromCaption = function textContentFromCaption( node ) {
|
2024-05-21 14:22:56 +00:00
|
|
|
const metaDataTags = [ 'base', 'link', 'meta', 'noscript', 'script', 'style', 'template', 'title' ];
|
|
|
|
let content = '';
|
|
|
|
let c = node.firstChild;
|
2023-08-09 23:40:17 +00:00
|
|
|
while ( c ) {
|
|
|
|
if ( c.nodeName === '#text' ) {
|
|
|
|
content += c.nodeValue;
|
|
|
|
} else if (
|
|
|
|
c instanceof HTMLElement &&
|
|
|
|
( metaDataTags.indexOf( c.nodeName.toLowerCase() ) === -1 ) &&
|
|
|
|
!/\bmw:Extension\/ref\b/.test( c.getAttribute( 'typeOf' ) )
|
|
|
|
) {
|
|
|
|
content += textContentFromCaption( c );
|
|
|
|
}
|
|
|
|
c = c.nextSibling;
|
|
|
|
}
|
|
|
|
return content;
|
|
|
|
};
|
|
|
|
|
2016-11-19 23:11:06 +00:00
|
|
|
ve.dm.MWGalleryImageNode.static.toDataElement = function ( domElements, converter ) {
|
|
|
|
// TODO: Improve handling of missing files. See 'isError' in MWBlockImageNode#toDataElement
|
2024-05-21 14:22:56 +00:00
|
|
|
const li = domElements[ 0 ];
|
|
|
|
const img = li.querySelector( '.mw-file-element' );
|
|
|
|
const imgWrapper = img.parentNode;
|
|
|
|
const container = imgWrapper.parentNode;
|
2016-11-19 23:11:06 +00:00
|
|
|
|
|
|
|
// Get caption (may be missing for mode="packed-hover" galleries)
|
2024-05-21 14:22:56 +00:00
|
|
|
let captionNode = li.querySelector( '.gallerytext' );
|
2018-08-01 02:35:49 +00:00
|
|
|
if ( captionNode ) {
|
|
|
|
captionNode = captionNode.cloneNode( true );
|
2016-11-19 23:11:06 +00:00
|
|
|
// If showFilename is 'yes', the filename is also inside the caption, so throw this out
|
2024-05-21 14:22:56 +00:00
|
|
|
const filename = captionNode.querySelector( '.galleryfilename' );
|
2016-11-19 23:11:06 +00:00
|
|
|
if ( filename ) {
|
|
|
|
filename.remove();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-10-12 21:13:28 +00:00
|
|
|
// For video thumbnails, the `alt` attribute is only in the data-mw of the container (see: T348703)
|
2024-05-21 14:22:56 +00:00
|
|
|
const mwDataJSON = container.getAttribute( 'data-mw' );
|
|
|
|
const mwData = mwDataJSON ? JSON.parse( mwDataJSON ) : {};
|
|
|
|
const mwAttribs = mwData.attribs || [];
|
|
|
|
let containerAlt;
|
|
|
|
for ( let i = mwAttribs.length - 1; i >= 0; i-- ) {
|
2023-10-12 21:13:28 +00:00
|
|
|
if ( mwAttribs[ i ][ 0 ] === 'alt' && mwAttribs[ i ][ 1 ].txt ) {
|
|
|
|
containerAlt = mwAttribs[ i ][ 1 ].txt;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-05-21 14:22:56 +00:00
|
|
|
const altPresent = img.hasAttribute( 'alt' ) || containerAlt !== undefined;
|
|
|
|
let altText = null;
|
2023-10-12 21:13:28 +00:00
|
|
|
if ( altPresent ) {
|
|
|
|
altText = img.hasAttribute( 'alt' ) ? img.getAttribute( 'alt' ) : containerAlt;
|
|
|
|
}
|
|
|
|
|
2024-05-21 14:22:56 +00:00
|
|
|
const altFromCaption = captionNode ?
|
2023-08-09 23:40:17 +00:00
|
|
|
ve.dm.MWGalleryImageNode.static.textContentFromCaption( captionNode ).trim() : '';
|
2024-05-21 14:22:56 +00:00
|
|
|
const altTextSame = altPresent && altFromCaption &&
|
2023-10-12 21:13:28 +00:00
|
|
|
( altText.trim() === altFromCaption );
|
Add a checkbox to use the image caption as the alt text for galleries
The need for something like this was anticipated in
I2bf43c7e83283f43e047229eb53c244918fcbb0c.
As of version 2.5.0 of Parsoid's output, if alternate text is missing
for an image but a caption is present and image isn't displaying the
caption (ie. it isn't a thumb or frame), then the text content of the
caption will be set as the alt attribute. Parsoid will then drop the
alt attribute when serializing if it matches the caption text, since
it's unnecessary.
However, if the caption is modified and the alt text isn't, the alt will
be serialized. This is likely to be unexpected to editor. They may
have missed that the both the caption and alt are populated in VE and
only edited one place.
Since all of the above is happening only for images where the caption
isn't visible, it doesn't appear to be a much used feature since, at
least for inline images, the experience of caption editing was already
less than optimal.
However, because of a quirk in how galleries are rendered in Parsoid,
this affects gallery caption editing, which is visible and presumably
used more often. See T268250 for a discussion on an improved gallery
structure. But for now, gallery images are effectively inline and set
the alternate text, thus subject to the above.
Here we add a checkbox so that the default is to ignore the alt if it's
the same as the caption. And only make use of it if it differed
originally or was explicitly unchecked to modify.
Bug: T311677
Change-Id: Idf297d8a98995971c5835b0cea56c3317a3626e2
2022-07-04 21:01:40 +00:00
|
|
|
|
2024-05-21 14:22:56 +00:00
|
|
|
let caption;
|
2018-08-01 02:35:49 +00:00
|
|
|
if ( captionNode ) {
|
|
|
|
caption = converter.getDataFromDomClean( captionNode, { type: 'mwGalleryImageCaption' } );
|
2016-11-19 23:11:06 +00:00
|
|
|
} else {
|
2018-08-01 02:35:49 +00:00
|
|
|
caption = [
|
|
|
|
{ type: 'mwGalleryImageCaption' },
|
|
|
|
{ type: 'paragraph', internal: { generated: 'wrapper' } },
|
|
|
|
{ type: '/paragraph' },
|
|
|
|
{ type: '/mwGalleryImageCaption' }
|
|
|
|
];
|
2016-11-19 23:11:06 +00:00
|
|
|
}
|
|
|
|
|
2024-05-21 14:22:56 +00:00
|
|
|
const typeofAttrs = container.getAttribute( 'typeof' ).trim().split( /\s+/ );
|
|
|
|
const errorIndex = typeofAttrs.indexOf( 'mw:Error' );
|
|
|
|
const isError = errorIndex !== -1;
|
|
|
|
const errorText = isError ? img.textContent : null;
|
|
|
|
const width = img.getAttribute( isError ? 'data-width' : 'width' );
|
|
|
|
const height = img.getAttribute( isError ? 'data-height' : 'height' );
|
2022-05-21 12:59:31 +00:00
|
|
|
|
2022-05-30 23:17:46 +00:00
|
|
|
if ( isError ) {
|
|
|
|
typeofAttrs.splice( errorIndex, 1 );
|
|
|
|
}
|
|
|
|
|
2024-05-21 14:22:56 +00:00
|
|
|
const types = ve.dm.MWImageNode.static.rdfaToTypes[ typeofAttrs[ 0 ] ];
|
2022-05-30 23:17:46 +00:00
|
|
|
|
2024-05-21 14:22:56 +00:00
|
|
|
let href = imgWrapper.getAttribute( 'href' );
|
2023-10-26 19:21:27 +00:00
|
|
|
if ( href ) {
|
|
|
|
// Convert absolute URLs to relative if the href refers to a page on this wiki.
|
|
|
|
// Otherwise Parsoid generates |link= options for copy-pasted images (T193253).
|
2024-05-21 14:22:56 +00:00
|
|
|
const targetData = mw.libs.ve.getTargetDataFromHref( href, converter.getTargetHtmlDocument() );
|
2023-10-26 19:21:27 +00:00
|
|
|
if ( targetData.isInternal ) {
|
|
|
|
href = mw.libs.ve.encodeParsoidResourceName( targetData.title );
|
|
|
|
}
|
|
|
|
}
|
2023-02-15 01:53:10 +00:00
|
|
|
|
2024-05-21 14:22:56 +00:00
|
|
|
const dataElement = {
|
2016-11-19 23:11:06 +00:00
|
|
|
type: this.name,
|
|
|
|
attributes: {
|
2022-05-30 23:17:46 +00:00
|
|
|
mediaClass: types.mediaClass,
|
|
|
|
mediaTag: img.nodeName.toLowerCase(),
|
2023-02-15 01:53:10 +00:00
|
|
|
resource: img.getAttribute( 'resource' ),
|
2023-10-12 21:13:28 +00:00
|
|
|
altText: altText,
|
Add a checkbox to use the image caption as the alt text for galleries
The need for something like this was anticipated in
I2bf43c7e83283f43e047229eb53c244918fcbb0c.
As of version 2.5.0 of Parsoid's output, if alternate text is missing
for an image but a caption is present and image isn't displaying the
caption (ie. it isn't a thumb or frame), then the text content of the
caption will be set as the alt attribute. Parsoid will then drop the
alt attribute when serializing if it matches the caption text, since
it's unnecessary.
However, if the caption is modified and the alt text isn't, the alt will
be serialized. This is likely to be unexpected to editor. They may
have missed that the both the caption and alt are populated in VE and
only edited one place.
Since all of the above is happening only for images where the caption
isn't visible, it doesn't appear to be a much used feature since, at
least for inline images, the experience of caption editing was already
less than optimal.
However, because of a quirk in how galleries are rendered in Parsoid,
this affects gallery caption editing, which is visible and presumably
used more often. See T268250 for a discussion on an improved gallery
structure. But for now, gallery images are effectively inline and set
the alternate text, thus subject to the above.
Here we add a checkbox so that the default is to ignore the alt if it's
the same as the caption. And only make use of it if it differed
originally or was explicitly unchecked to modify.
Bug: T311677
Change-Id: Idf297d8a98995971c5835b0cea56c3317a3626e2
2022-07-04 21:01:40 +00:00
|
|
|
altTextSame: altTextSame,
|
2023-10-26 19:21:27 +00:00
|
|
|
href: href,
|
2018-04-05 21:14:16 +00:00
|
|
|
// 'src' for images, 'poster' for video/audio
|
|
|
|
src: img.getAttribute( 'src' ) || img.getAttribute( 'poster' ),
|
2022-05-21 12:59:31 +00:00
|
|
|
width: width !== null && width !== '' ? +width : null,
|
|
|
|
height: height !== null && height !== '' ? +height : null,
|
2023-02-16 02:28:35 +00:00
|
|
|
isError: isError,
|
2023-05-11 00:19:47 +00:00
|
|
|
errorText: errorText,
|
2023-10-24 23:12:22 +00:00
|
|
|
mw: mwData,
|
2023-05-11 00:19:47 +00:00
|
|
|
imageClassAttr: img.getAttribute( 'class' ),
|
2023-10-26 19:21:27 +00:00
|
|
|
imgWrapperClassAttr: imgWrapper.getAttribute( 'class' )
|
2016-11-19 23:11:06 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
return [ dataElement ]
|
|
|
|
.concat( caption )
|
|
|
|
.concat( { type: '/' + this.name } );
|
|
|
|
};
|
|
|
|
|
2023-02-15 01:53:10 +00:00
|
|
|
ve.dm.MWGalleryImageNode.static.toDomElements = function ( data, doc, converter ) {
|
2016-11-19 23:11:06 +00:00
|
|
|
// ImageNode:
|
2019-12-31 00:17:40 +00:00
|
|
|
// <li> li (gallerybox)
|
2018-11-21 12:33:32 +00:00
|
|
|
// <div> thumbDiv
|
2022-05-31 18:35:52 +00:00
|
|
|
// <span> container
|
2018-11-21 12:33:32 +00:00
|
|
|
// <a> a
|
2022-05-23 14:18:20 +00:00
|
|
|
// <img> img (or span if error)
|
2024-05-21 14:22:56 +00:00
|
|
|
const model = data[ 0 ],
|
2022-05-23 14:18:20 +00:00
|
|
|
attributes = model.attributes,
|
2016-11-19 23:11:06 +00:00
|
|
|
li = doc.createElement( 'li' ),
|
|
|
|
thumbDiv = doc.createElement( 'div' ),
|
2022-05-31 18:35:52 +00:00
|
|
|
container = doc.createElement( 'span' ),
|
2023-10-26 19:21:27 +00:00
|
|
|
imgWrapper = doc.createElement( attributes.href ? 'a' : 'span' ),
|
2023-10-25 17:23:22 +00:00
|
|
|
img = doc.createElement( attributes.isError ? 'span' : attributes.mediaTag ),
|
2023-10-24 23:12:22 +00:00
|
|
|
alt = attributes.altText,
|
|
|
|
mwData = ve.copy( attributes.mw ) || {};
|
2016-11-19 23:11:06 +00:00
|
|
|
|
|
|
|
li.classList.add( 'gallerybox' );
|
|
|
|
thumbDiv.classList.add( 'thumb' );
|
2022-05-30 23:17:46 +00:00
|
|
|
container.setAttribute( 'typeof', ve.dm.MWImageNode.static.getRdfa(
|
2023-10-25 17:23:22 +00:00
|
|
|
attributes.mediaClass, 'none', attributes.isError
|
2022-05-30 23:17:46 +00:00
|
|
|
) );
|
2016-11-19 23:11:06 +00:00
|
|
|
|
2023-10-26 19:21:27 +00:00
|
|
|
if ( attributes.href ) {
|
|
|
|
imgWrapper.setAttribute( 'href', attributes.href );
|
2023-05-11 00:19:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if ( attributes.imageClassAttr ) {
|
|
|
|
// eslint-disable-next-line mediawiki/class-doc
|
|
|
|
img.className = attributes.imageClassAttr;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( attributes.imgWrapperClassAttr ) {
|
|
|
|
// eslint-disable-next-line mediawiki/class-doc
|
2023-10-26 19:21:27 +00:00
|
|
|
imgWrapper.className = attributes.imgWrapperClassAttr;
|
2023-02-15 01:53:10 +00:00
|
|
|
}
|
2016-11-19 23:11:06 +00:00
|
|
|
|
2022-05-23 14:18:20 +00:00
|
|
|
img.setAttribute( 'resource', attributes.resource );
|
|
|
|
if ( attributes.isError ) {
|
2024-05-21 14:22:56 +00:00
|
|
|
const filename = mw.libs.ve.normalizeParsoidResourceName( attributes.resource || '' );
|
2023-02-16 02:28:35 +00:00
|
|
|
img.appendChild( doc.createTextNode( attributes.errorText ? attributes.errorText : filename ) );
|
2022-05-23 14:18:20 +00:00
|
|
|
} else {
|
2024-05-21 14:22:56 +00:00
|
|
|
const srcAttr = ve.dm.MWImageNode.static.tagsToSrcAttrs[ img.nodeName.toLowerCase() ];
|
2022-05-30 23:17:46 +00:00
|
|
|
img.setAttribute( srcAttr, attributes.src );
|
2022-05-23 14:18:20 +00:00
|
|
|
}
|
|
|
|
img.setAttribute( attributes.isError ? 'data-width' : 'width', attributes.width );
|
|
|
|
img.setAttribute( attributes.isError ? 'data-height' : 'height', attributes.height );
|
Add a checkbox to use the image caption as the alt text for galleries
The need for something like this was anticipated in
I2bf43c7e83283f43e047229eb53c244918fcbb0c.
As of version 2.5.0 of Parsoid's output, if alternate text is missing
for an image but a caption is present and image isn't displaying the
caption (ie. it isn't a thumb or frame), then the text content of the
caption will be set as the alt attribute. Parsoid will then drop the
alt attribute when serializing if it matches the caption text, since
it's unnecessary.
However, if the caption is modified and the alt text isn't, the alt will
be serialized. This is likely to be unexpected to editor. They may
have missed that the both the caption and alt are populated in VE and
only edited one place.
Since all of the above is happening only for images where the caption
isn't visible, it doesn't appear to be a much used feature since, at
least for inline images, the experience of caption editing was already
less than optimal.
However, because of a quirk in how galleries are rendered in Parsoid,
this affects gallery caption editing, which is visible and presumably
used more often. See T268250 for a discussion on an improved gallery
structure. But for now, gallery images are effectively inline and set
the alternate text, thus subject to the above.
Here we add a checkbox so that the default is to ignore the alt if it's
the same as the caption. And only make use of it if it differed
originally or was explicitly unchecked to modify.
Bug: T311677
Change-Id: Idf297d8a98995971c5835b0cea56c3317a3626e2
2022-07-04 21:01:40 +00:00
|
|
|
|
2023-10-26 19:21:27 +00:00
|
|
|
imgWrapper.appendChild( img );
|
|
|
|
container.appendChild( imgWrapper );
|
2022-05-31 18:35:52 +00:00
|
|
|
thumbDiv.appendChild( container );
|
2019-12-31 00:17:40 +00:00
|
|
|
li.appendChild( thumbDiv );
|
2016-11-19 23:11:06 +00:00
|
|
|
|
2024-05-21 14:22:56 +00:00
|
|
|
const captionData = data.slice( 1, -1 );
|
|
|
|
const captionWrapper = doc.createElement( 'div' );
|
2023-02-15 01:53:10 +00:00
|
|
|
converter.getDomSubtreeFromData( captionData, captionWrapper );
|
|
|
|
while ( captionWrapper.firstChild ) {
|
|
|
|
li.appendChild( captionWrapper.firstChild );
|
|
|
|
}
|
2024-05-21 14:22:56 +00:00
|
|
|
const captionText = ve.dm.MWGalleryImageNode.static.textContentFromCaption( li ).trim();
|
2023-02-15 01:53:10 +00:00
|
|
|
|
2023-10-24 23:12:22 +00:00
|
|
|
if ( img.nodeName.toLowerCase() === 'img' ) {
|
2023-11-28 17:37:42 +00:00
|
|
|
if ( attributes.altTextSame && captionText ) {
|
|
|
|
img.setAttribute( 'alt', captionText );
|
2023-10-24 23:12:22 +00:00
|
|
|
} else if ( typeof alt === 'string' ) {
|
|
|
|
img.setAttribute( 'alt', alt );
|
|
|
|
}
|
|
|
|
} else {
|
2024-05-21 14:22:56 +00:00
|
|
|
let mwAttribs = mwData.attribs || [];
|
2023-10-24 23:12:22 +00:00
|
|
|
mwAttribs = mwAttribs.filter(
|
2024-04-30 16:44:25 +00:00
|
|
|
( attr ) => attr[ 0 ] !== 'alt'
|
2023-10-24 23:12:22 +00:00
|
|
|
);
|
|
|
|
// Parsoid only sets an alt in the data-mw.attribs if it's explicit
|
|
|
|
// in the source
|
|
|
|
if ( !attributes.altTextSame && typeof alt === 'string' ) {
|
|
|
|
mwAttribs.push( [ 'alt', { txt: alt } ] );
|
|
|
|
}
|
|
|
|
if ( mwData.attribs || mwAttribs.length ) {
|
|
|
|
mwData.attribs = mwAttribs;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( !ve.isEmptyObject( mwData ) ) {
|
|
|
|
container.setAttribute( 'data-mw', JSON.stringify( mwData ) );
|
2023-02-15 01:53:10 +00:00
|
|
|
}
|
|
|
|
|
2016-11-19 23:11:06 +00:00
|
|
|
return [ li ];
|
|
|
|
};
|
|
|
|
|
2018-04-04 16:28:26 +00:00
|
|
|
ve.dm.MWGalleryImageNode.static.describeChange = function ( key ) {
|
2022-07-12 15:59:02 +00:00
|
|
|
if ( key === 'altText' ) {
|
2022-07-01 12:14:49 +00:00
|
|
|
// Parent method
|
|
|
|
return ve.dm.MWGalleryImageNode.super.static.describeChange.apply( this, arguments );
|
2018-04-04 16:28:26 +00:00
|
|
|
}
|
2022-07-12 15:59:02 +00:00
|
|
|
// All other attributes are computed, or result in nodes being incomparable (`resource`)
|
2022-07-01 12:14:49 +00:00
|
|
|
return null;
|
2018-04-04 16:28:26 +00:00
|
|
|
};
|
|
|
|
|
2022-05-19 00:28:10 +00:00
|
|
|
ve.dm.MWGalleryImageNode.static.isDiffComparable = function ( element, other ) {
|
|
|
|
// Images with different src's shouldn't be diffed
|
|
|
|
return element.type === other.type && element.attributes.resource === other.attributes.resource;
|
|
|
|
};
|
|
|
|
|
2016-11-19 23:11:06 +00:00
|
|
|
/* Methods */
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the image's caption node.
|
|
|
|
*
|
|
|
|
* @return {ve.dm.MWImageCaptionNode|null} Caption node, if present
|
|
|
|
*/
|
|
|
|
ve.dm.MWGalleryImageNode.prototype.getCaptionNode = function () {
|
|
|
|
return this.children.length > 0 ? this.children[ 0 ] : null;
|
|
|
|
};
|
|
|
|
|
|
|
|
/* Registration */
|
|
|
|
|
|
|
|
ve.dm.modelRegistry.register( ve.dm.MWGalleryImageNode );
|