mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/MultimediaViewer
synced 2024-11-23 15:56:47 +00:00
Move HtmlUtils from mmv.bootstrap to mmv module
HtmlUtils is used for stripping HTML code. This is the responsibility of the individual UI components. More specifically, MultimediaViewerBootstrap.processParsoidThumb no longer strips HTML code. Various UI components were already calling HtmlUtils.htmlToTextWithLinks. Only the error case in MultimediaViewer.loadImage newly needs HTML stripping applied. Bug: T65504 Change-Id: If24b9c220a6ec43f35251a4ec6a716fd4ba03df6
This commit is contained in:
parent
fe5687b6ef
commit
fb4e80a1b1
|
@ -2,7 +2,7 @@
|
|||
"modules": [
|
||||
{
|
||||
"resourceModule": "mmv",
|
||||
"maxSize": "24.6 kB"
|
||||
"maxSize": "25.2 kB"
|
||||
},
|
||||
{
|
||||
"resourceModule": "mmv.ui.restriction",
|
||||
|
@ -18,7 +18,7 @@
|
|||
},
|
||||
{
|
||||
"resourceModule": "mmv.bootstrap",
|
||||
"maxSize": "5.3 kB"
|
||||
"maxSize": "4.8 kB"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
|
@ -62,6 +62,7 @@
|
|||
"mmv/provider/mmv.provider.ThumbnailInfo.js",
|
||||
"mmv/provider/mmv.provider.GuessedThumbnailInfo.js",
|
||||
"mmv/provider/mmv.provider.Image.js",
|
||||
"mmv/mmv.HtmlUtils.js",
|
||||
"mmv/mmv.ThumbnailWidthCalculator.js",
|
||||
"mmv/ui/mmv.ui.js",
|
||||
"mmv/ui/mmv.ui.dialog.js",
|
||||
|
@ -281,8 +282,7 @@
|
|||
"mmv.bootstrap/mmv.bootstrap.autostart.js",
|
||||
"mmv.bootstrap/mmv.bootstrap.js",
|
||||
"mmv.bootstrap/mmv.lightboximage.js",
|
||||
"mmv.bootstrap/mmv.Config.js",
|
||||
"mmv.bootstrap/mmv.HtmlUtils.js"
|
||||
"mmv.bootstrap/mmv.Config.js"
|
||||
],
|
||||
"styles": [
|
||||
"mmv.bootstrap/mmv.bootstrap.less"
|
||||
|
|
|
@ -21,10 +21,9 @@
|
|||
const Config = require( './mmv.Config.js' );
|
||||
const MultimediaViewerBootstrap = require( './mmv.bootstrap.js' );
|
||||
const LightboxImage = require( './mmv.lightboximage.js' );
|
||||
const HtmlUtils = require( './mmv.HtmlUtils.js' );
|
||||
|
||||
const bootstrap = new MultimediaViewerBootstrap();
|
||||
|
||||
$( bootstrap.setupEventHandlers.bind( bootstrap ) );
|
||||
|
||||
module.exports = { MultimediaViewerBootstrap, LightboxImage, Config, HtmlUtils };
|
||||
module.exports = { MultimediaViewerBootstrap, LightboxImage, Config };
|
||||
|
|
|
@ -16,7 +16,6 @@
|
|||
*/
|
||||
|
||||
const Config = require( './mmv.Config.js' );
|
||||
const HtmlUtils = require( './mmv.HtmlUtils.js' );
|
||||
const LightboxImage = require( './mmv.lightboximage.js' );
|
||||
const { extensions } = require( './config.json' );
|
||||
const mwRouter = require( 'mediawiki.router' );
|
||||
|
@ -332,7 +331,6 @@ class MultimediaViewerBootstrap {
|
|||
);
|
||||
const title = mw.Title.newFromImg( $thumb );
|
||||
let caption;
|
||||
let $thumbCaption;
|
||||
|
||||
if ( !this.isValidExtension( title ) ) {
|
||||
// Short-circuit event handler and interface setup, because
|
||||
|
@ -349,8 +347,7 @@ class MultimediaViewerBootstrap {
|
|||
}
|
||||
|
||||
if ( ( $thumbContainer.prop( 'tagName' ) || '' ).toLowerCase() === 'figure' ) {
|
||||
$thumbCaption = $thumbContainer.find( 'figcaption' );
|
||||
caption = HtmlUtils.htmlToTextWithTags( $thumbCaption.html() || '' );
|
||||
caption = $thumbContainer.find( 'figcaption' ).html() || '';
|
||||
} else {
|
||||
caption = $link.prop( 'title' ) || undefined;
|
||||
}
|
||||
|
@ -482,7 +479,7 @@ class MultimediaViewerBootstrap {
|
|||
$thumbCaption.find( '.magnify' ).remove();
|
||||
}
|
||||
|
||||
return HtmlUtils.htmlToTextWithTags( $thumbCaption.html() || '' );
|
||||
return $thumbCaption.html() || '';
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -15,7 +15,8 @@
|
|||
* along with MediaViewer. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
const { Config, HtmlUtils } = require( 'mmv.bootstrap' );
|
||||
const { Config } = require( 'mmv.bootstrap' );
|
||||
const { HtmlUtils } = require( 'mmv' );
|
||||
|
||||
/**
|
||||
* Converts data in various formats needed by the Embed sub-dialog
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
*/
|
||||
|
||||
const { Config } = require( 'mmv.bootstrap' );
|
||||
const HtmlUtils = require( './mmv.HtmlUtils.js' );
|
||||
const ViewLogger = require( './logging/mmv.logging.ViewLogger.js' );
|
||||
const Api = require( './provider/mmv.provider.Api.js' );
|
||||
const GuessedThumbnailInfo = require( './provider/mmv.provider.GuessedThumbnailInfo.js' );
|
||||
|
@ -265,7 +266,9 @@ class MultimediaViewer {
|
|||
if ( this.currentIndex === image.index ) {
|
||||
// Set title to caption or file name if caption is not available;
|
||||
// see setTitle() in mmv.ui.metadataPanel for extended caption fallback
|
||||
this.ui.panel.showError( image.caption || image.filePageTitle.getNameText(), error );
|
||||
this.ui.panel.showError( image.caption ?
|
||||
HtmlUtils.htmlToTextWithTags( image.caption ) :
|
||||
image.filePageTitle.getNameText(), error );
|
||||
}
|
||||
|
||||
return $.Deferred().reject( error );
|
||||
|
@ -871,6 +874,7 @@ module.exports = {
|
|||
Description,
|
||||
Dialog,
|
||||
GuessedThumbnailInfo,
|
||||
HtmlUtils,
|
||||
ImageInfo,
|
||||
ImageModel,
|
||||
ImageProvider,
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
* along with MediaViewer. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
const { HtmlUtils } = require( 'mmv.bootstrap' );
|
||||
const HtmlUtils = require( '../mmv.HtmlUtils.js' );
|
||||
|
||||
/**
|
||||
* Class for storing license information about an image. For available fields, see
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
* along with MediaViewer. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
const { HtmlUtils } = require( 'mmv.bootstrap' );
|
||||
const HtmlUtils = require( '../mmv.HtmlUtils.js' );
|
||||
const ThumbnailWidthCalculator = require( '../mmv.ThumbnailWidthCalculator.js' );
|
||||
const UiElement = require( './mmv.ui.js' );
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
* along with MultimediaViewer. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
const { HtmlUtils } = require( 'mmv.bootstrap' );
|
||||
const HtmlUtils = require( '../mmv.HtmlUtils.js' );
|
||||
const UiElement = require( './mmv.ui.js' );
|
||||
|
||||
/**
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
* along with MultimediaViewer. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
const { HtmlUtils } = require( 'mmv.bootstrap' );
|
||||
const HtmlUtils = require( '../mmv.HtmlUtils.js' );
|
||||
const Description = require( './mmv.ui.description.js' );
|
||||
const UiElement = require( './mmv.ui.js' );
|
||||
const MetadataPanelScroller = require( './mmv.ui.metadataPanelScroller.js' );
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
* along with MediaViewer. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
const { HtmlUtils } = require( 'mmv.bootstrap' );
|
||||
const HtmlUtils = require( '../mmv.HtmlUtils.js' );
|
||||
const UiElement = require( './mmv.ui.js' );
|
||||
const MetadataPanelScroller = require( './mmv.ui.metadataPanelScroller.js' );
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
* along with MultimediaViewer. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
const { HtmlUtils } = require( 'mmv.bootstrap' );
|
||||
const HtmlUtils = require( '../mmv.HtmlUtils.js' );
|
||||
const UiElement = require( './mmv.ui.js' );
|
||||
|
||||
/**
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
* along with MediaViewer. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
const { HtmlUtils } = require( 'mmv.bootstrap' );
|
||||
const { HtmlUtils } = require( 'mmv' );
|
||||
|
||||
( function () {
|
||||
/* eslint-disable no-jquery/no-parse-html-literal */
|
||||
|
|
Loading…
Reference in a new issue