mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Math
synced 2024-11-27 17:01:07 +00:00
Merge "build: Updating npm dependencies"
This commit is contained in:
commit
63ccfb9d5d
|
@ -107,7 +107,7 @@ const regexp = /\\x(\d\d)/g;
|
|||
if ( options.debug ) {
|
||||
const matches = parser.match( regexp );
|
||||
for ( const match of matches ) {
|
||||
console.log( `Found ${match}.` );
|
||||
console.log( `Found ${ match }.` );
|
||||
}
|
||||
}
|
||||
const newParse = parser.replace( regexp, '\\x{00$1}' );
|
||||
|
|
|
@ -1,25 +1,25 @@
|
|||
( function () {
|
||||
'use strict';
|
||||
var previewType = 'math';
|
||||
var api = new mw.Rest();
|
||||
var isValidId = function ( qid ) {
|
||||
const previewType = 'math';
|
||||
const api = new mw.Rest();
|
||||
const isValidId = function ( qid ) {
|
||||
return qid.match( /Q\d+/g ) === null;
|
||||
};
|
||||
var fetch = function ( qid ) {
|
||||
const fetch = function ( qid ) {
|
||||
return api.get( '/math/v0/popup/html/' + qid, {}, {
|
||||
Accept: 'application/json; charset=utf-8',
|
||||
'Accept-Language': mw.config.language
|
||||
} );
|
||||
};
|
||||
var fetchPreviewForTitle = function ( title, el ) {
|
||||
var deferred = $.Deferred();
|
||||
var qidstr = el.parentNode.parentNode.dataset.qid;
|
||||
const fetchPreviewForTitle = function ( title, el ) {
|
||||
const deferred = $.Deferred();
|
||||
let qidstr = el.parentNode.parentNode.dataset.qid;
|
||||
if ( isValidId( qidstr ) ) {
|
||||
return deferred.reject();
|
||||
}
|
||||
qidstr = qidstr.slice( 1 );
|
||||
fetch( qidstr ).then( function ( body ) {
|
||||
var model = {
|
||||
const model = {
|
||||
title: body.title,
|
||||
url: body.canonicalurl,
|
||||
languageCode: body.pagelanguagehtmlcode,
|
||||
|
|
|
@ -86,7 +86,7 @@
|
|||
* @inheritdoc
|
||||
*/
|
||||
mw.widgets.MathWbEntitySelector.prototype.getLookupRequest = function () {
|
||||
var api = this.getApi(),
|
||||
const api = this.getApi(),
|
||||
query = this.getQueryValue(),
|
||||
widget = this,
|
||||
promiseAbortObject = {
|
||||
|
@ -101,7 +101,7 @@
|
|||
};
|
||||
|
||||
// eslint-disable-next-line no-jquery/no-global-selector
|
||||
var $wbEntitySelector = $( '#wbEntitySelector' );
|
||||
const $wbEntitySelector = $( '#wbEntitySelector' );
|
||||
if ( $wbEntitySelector.length ) {
|
||||
OO.ui.infuse( $wbEntitySelector );
|
||||
}
|
||||
|
|
|
@ -38,7 +38,7 @@ ve.dm.MWLatexNode.static.tagName = 'img';
|
|||
*/
|
||||
ve.dm.MWLatexNode.static.getHashObjectForRendering = function ( dataElement ) {
|
||||
// Parent method
|
||||
var hashObject = ve.dm.MWLatexNode.super.static.getHashObjectForRendering.call( this, dataElement );
|
||||
const hashObject = ve.dm.MWLatexNode.super.static.getHashObjectForRendering.call( this, dataElement );
|
||||
|
||||
// The id does not affect the rendering.
|
||||
if ( hashObject.mw.attrs ) {
|
||||
|
|
|
@ -39,7 +39,7 @@ ve.ui.MWLatexDialog.static.symbolsModule = null;
|
|||
* @inheritdoc
|
||||
*/
|
||||
ve.ui.MWLatexDialog.prototype.initialize = function () {
|
||||
var dialog = this;
|
||||
const dialog = this;
|
||||
|
||||
// Parent method
|
||||
ve.ui.MWLatexDialog.super.prototype.initialize.call( this );
|
||||
|
@ -47,12 +47,12 @@ ve.ui.MWLatexDialog.prototype.initialize = function () {
|
|||
// Layout for the formula inserter (formula tab panel) and options form (options tab panel)
|
||||
this.indexLayout = new OO.ui.IndexLayout();
|
||||
|
||||
var formulaTabPanel = new OO.ui.TabPanelLayout( 'formula', {
|
||||
const formulaTabPanel = new OO.ui.TabPanelLayout( 'formula', {
|
||||
label: ve.msg( 'math-visualeditor-mwlatexdialog-card-formula' ),
|
||||
padded: true,
|
||||
classes: [ 'latex-dialog-formula-panel' ]
|
||||
} );
|
||||
var optionsTabPanel = new OO.ui.TabPanelLayout( 'options', {
|
||||
const optionsTabPanel = new OO.ui.TabPanelLayout( 'options', {
|
||||
label: ve.msg( 'math-visualeditor-mwlatexdialog-card-options' ),
|
||||
padded: true,
|
||||
classes: [ 'latex-dialog-options-panel' ]
|
||||
|
@ -104,28 +104,28 @@ ve.ui.MWLatexDialog.prototype.initialize = function () {
|
|||
this.idInput = new OO.ui.TextInputWidget();
|
||||
this.qidInput = new mw.widgets.MathWbEntitySelector();
|
||||
|
||||
var inputField = new OO.ui.FieldLayout( this.input, {
|
||||
const inputField = new OO.ui.FieldLayout( this.input, {
|
||||
align: 'top',
|
||||
classes: [ 'latex-dialog-formula-field' ],
|
||||
label: ve.msg( 'math-visualeditor-mwlatexdialog-card-formula' )
|
||||
} );
|
||||
var displayField = new OO.ui.FieldLayout( this.displaySelect, {
|
||||
const displayField = new OO.ui.FieldLayout( this.displaySelect, {
|
||||
align: 'top',
|
||||
classes: [ 'latex-dialog-display-field' ],
|
||||
label: ve.msg( 'math-visualeditor-mwlatexinspector-display' )
|
||||
} );
|
||||
var idField = new OO.ui.FieldLayout( this.idInput, {
|
||||
const idField = new OO.ui.FieldLayout( this.idInput, {
|
||||
align: 'top',
|
||||
classes: [ 'latex-dialog-id-field' ],
|
||||
label: ve.msg( 'math-visualeditor-mwlatexinspector-id' )
|
||||
} );
|
||||
var qidField = new OO.ui.FieldLayout( this.qidInput, {
|
||||
const qidField = new OO.ui.FieldLayout( this.qidInput, {
|
||||
align: 'top',
|
||||
classes: [ 'latex-dialog-qid-field' ],
|
||||
label: ve.msg( 'math-visualeditor-mwlatexinspector-qid' )
|
||||
} );
|
||||
|
||||
var formulaPanel = new OO.ui.PanelLayout( {
|
||||
const formulaPanel = new OO.ui.PanelLayout( {
|
||||
scrollable: true,
|
||||
padded: true
|
||||
} );
|
||||
|
@ -139,8 +139,8 @@ ve.ui.MWLatexDialog.prototype.initialize = function () {
|
|||
} );
|
||||
this.pages = [];
|
||||
this.symbolsPromise = mw.loader.using( this.constructor.static.symbolsModule ).done( function ( require ) {
|
||||
var symbols = require( dialog.constructor.static.symbolsModule );
|
||||
for ( var category in symbols ) {
|
||||
const symbols = require( dialog.constructor.static.symbolsModule );
|
||||
for ( const category in symbols ) {
|
||||
dialog.pages.push(
|
||||
new ve.ui.MWLatexPage(
|
||||
// eslint-disable-next-line mediawiki/msg-doc
|
||||
|
@ -190,7 +190,7 @@ ve.ui.MWLatexDialog.prototype.initialize = function () {
|
|||
ve.ui.MWLatexDialog.prototype.getSetupProcess = function ( data ) {
|
||||
return ve.ui.MWLatexDialog.super.prototype.getSetupProcess.call( this, data )
|
||||
.next( function () {
|
||||
var attributes = this.selectedNode && this.selectedNode.getAttribute( 'mw' ).attrs,
|
||||
const attributes = this.selectedNode && this.selectedNode.getAttribute( 'mw' ).attrs,
|
||||
display = attributes && attributes.display || 'default',
|
||||
id = attributes && attributes.id || '',
|
||||
qid = attributes && attributes.qid || '',
|
||||
|
@ -253,9 +253,9 @@ ve.ui.MWLatexDialog.prototype.updateMwData = function ( mwData ) {
|
|||
ve.ui.MWLatexDialog.super.prototype.updateMwData.call( this, mwData );
|
||||
|
||||
// Get data from dialog
|
||||
var display = this.displaySelect.findSelectedItem().getData();
|
||||
var id = this.idInput.getValue();
|
||||
var qid = this.qidInput.getValue();
|
||||
const display = this.displaySelect.findSelectedItem().getData();
|
||||
const id = this.idInput.getValue();
|
||||
const qid = this.qidInput.getValue();
|
||||
|
||||
// Update attributes
|
||||
mwData.attrs.display = display !== 'default' ? display : undefined;
|
||||
|
@ -274,7 +274,7 @@ ve.ui.MWLatexDialog.prototype.getBodyHeight = function () {
|
|||
* Handle the window resize event
|
||||
*/
|
||||
ve.ui.MWLatexDialog.prototype.onWindowManagerResize = function () {
|
||||
var dialog = this;
|
||||
const dialog = this;
|
||||
this.input.loadingPromise.always( function () {
|
||||
// Toggle short mode as necessary
|
||||
// NB a change of mode triggers a transition...
|
||||
|
@ -285,14 +285,14 @@ ve.ui.MWLatexDialog.prototype.onWindowManagerResize = function () {
|
|||
// ...So wait for the possible menuLayout transition to finish
|
||||
setTimeout( function () {
|
||||
// Give the input the right number of rows to fit the space
|
||||
var availableSpace = dialog.menuLayout.$content.height() - dialog.input.$element.position().top;
|
||||
const availableSpace = dialog.menuLayout.$content.height() - dialog.input.$element.position().top;
|
||||
// TODO: Compute this line height from the skin
|
||||
var singleLineHeight = 21;
|
||||
var border = 1;
|
||||
var padding = 3;
|
||||
var borderAndPadding = 2 * ( border + padding );
|
||||
var maxInputHeight = availableSpace - borderAndPadding;
|
||||
var minRows = Math.floor( maxInputHeight / singleLineHeight );
|
||||
const singleLineHeight = 21;
|
||||
const border = 1;
|
||||
const padding = 3;
|
||||
const borderAndPadding = 2 * ( border + padding );
|
||||
const maxInputHeight = availableSpace - borderAndPadding;
|
||||
const minRows = Math.floor( maxInputHeight / singleLineHeight );
|
||||
dialog.input.loadingPromise.done( function () {
|
||||
dialog.input.setMinRows( minRows );
|
||||
} ).fail( function () {
|
||||
|
@ -312,18 +312,18 @@ ve.ui.MWLatexDialog.prototype.onListClick = function ( e ) {
|
|||
return;
|
||||
}
|
||||
|
||||
var symbol = $( e.target ).data( 'symbol' ),
|
||||
const symbol = $( e.target ).data( 'symbol' ),
|
||||
encapsulate = symbol.encapsulate;
|
||||
|
||||
if ( encapsulate ) {
|
||||
var range = this.input.getRange();
|
||||
const range = this.input.getRange();
|
||||
if ( range.from === range.to ) {
|
||||
this.input.insertContent( encapsulate.placeholder );
|
||||
this.input.selectRange( range.from, range.from + encapsulate.placeholder.length );
|
||||
}
|
||||
this.input.encapsulateContent( encapsulate.pre, encapsulate.post );
|
||||
} else {
|
||||
var insert = symbol.insert;
|
||||
const insert = symbol.insert;
|
||||
this.input.insertContent( insert );
|
||||
}
|
||||
};
|
||||
|
|
|
@ -61,19 +61,19 @@ ve.ui.MWLatexInspector.prototype.initialize = function () {
|
|||
this.idInput = new OO.ui.TextInputWidget();
|
||||
this.qidInput = new mw.widgets.MathWbEntitySelector();
|
||||
|
||||
var inputField = new OO.ui.FieldLayout( this.input, {
|
||||
const inputField = new OO.ui.FieldLayout( this.input, {
|
||||
align: 'top',
|
||||
label: ve.msg( 'math-visualeditor-mwlatexdialog-card-formula' )
|
||||
} );
|
||||
var displayField = new OO.ui.FieldLayout( this.displaySelect, {
|
||||
const displayField = new OO.ui.FieldLayout( this.displaySelect, {
|
||||
align: 'top',
|
||||
label: ve.msg( 'math-visualeditor-mwlatexinspector-display' )
|
||||
} );
|
||||
var idField = new OO.ui.FieldLayout( this.idInput, {
|
||||
const idField = new OO.ui.FieldLayout( this.idInput, {
|
||||
align: 'top',
|
||||
label: ve.msg( 'math-visualeditor-mwlatexinspector-id' )
|
||||
} );
|
||||
var qidField = new OO.ui.FieldLayout( this.qidInput, {
|
||||
const qidField = new OO.ui.FieldLayout( this.qidInput, {
|
||||
align: 'top',
|
||||
label: ve.msg( 'math-visualeditor-mwlatexinspector-qid' )
|
||||
} );
|
||||
|
@ -95,8 +95,8 @@ ve.ui.MWLatexInspector.prototype.initialize = function () {
|
|||
ve.ui.MWLatexInspector.prototype.getSetupProcess = function ( data ) {
|
||||
return ve.ui.MWLatexInspector.super.prototype.getSetupProcess.call( this, data )
|
||||
.next( function () {
|
||||
var display = this.selectedNode.getAttribute( 'mw' ).attrs.display || 'default';
|
||||
var attributes = this.selectedNode && this.selectedNode.getAttribute( 'mw' ).attrs,
|
||||
const display = this.selectedNode.getAttribute( 'mw' ).attrs.display || 'default';
|
||||
const attributes = this.selectedNode && this.selectedNode.getAttribute( 'mw' ).attrs,
|
||||
id = attributes && attributes.id || '',
|
||||
qid = attributes && attributes.qid || '',
|
||||
isReadOnly = this.isReadOnly();
|
||||
|
@ -133,9 +133,9 @@ ve.ui.MWLatexInspector.prototype.updateMwData = function ( mwData ) {
|
|||
// Parent method
|
||||
ve.ui.MWLatexInspector.super.prototype.updateMwData.call( this, mwData );
|
||||
|
||||
var display = this.displaySelect.findSelectedItem().getData();
|
||||
var id = this.idInput.getValue();
|
||||
var qid = this.qidInput.getValue();
|
||||
const display = this.displaySelect.findSelectedItem().getData();
|
||||
const id = this.idInput.getValue();
|
||||
const qid = this.qidInput.getValue();
|
||||
|
||||
mwData.attrs.display = display !== 'default' ? display : undefined;
|
||||
mwData.attrs.id = id || undefined;
|
||||
|
|
|
@ -21,15 +21,15 @@ ve.ui.MWLatexPage = function VeUiMWLatexPage( name, config ) {
|
|||
|
||||
this.label = config.label;
|
||||
|
||||
var symbols = config.symbols;
|
||||
var $symbols = $( '<div>' ).addClass( 've-ui-specialCharacterPage-characters' );
|
||||
var symbolsNode = $symbols[ 0 ];
|
||||
const symbols = config.symbols;
|
||||
const $symbols = $( '<div>' ).addClass( 've-ui-specialCharacterPage-characters' );
|
||||
const symbolsNode = $symbols[ 0 ];
|
||||
|
||||
// Avoiding jQuery wrappers as advised in ve.ui.SpecialCharacterPage
|
||||
symbols.forEach( function ( symbol ) {
|
||||
if ( !symbol.notWorking && !symbol.duplicate ) {
|
||||
var tex = symbol.tex || symbol.insert;
|
||||
var classes = [ 've-ui-mwLatexPage-symbol' ];
|
||||
const tex = symbol.tex || symbol.insert;
|
||||
const classes = [ 've-ui-mwLatexPage-symbol' ];
|
||||
classes.push(
|
||||
've-ui-mwLatexSymbol-' + tex.replace( /[^\w]/g, function ( c ) {
|
||||
return '_' + c.charCodeAt( 0 ) + '_';
|
||||
|
@ -44,7 +44,7 @@ ve.ui.MWLatexPage = function VeUiMWLatexPage( name, config ) {
|
|||
if ( symbol.largeLayout ) {
|
||||
classes.push( 've-ui-mwLatexPage-symbol-largeLayout' );
|
||||
}
|
||||
var symbolNode = document.createElement( 'div' );
|
||||
const symbolNode = document.createElement( 'div' );
|
||||
classes.forEach( function ( className ) {
|
||||
// The following classes are used here:
|
||||
// * ve-ui-mwLatexPage-symbol
|
||||
|
|
2049
package-lock.json
generated
2049
package-lock.json
generated
File diff suppressed because it is too large
Load diff
|
@ -17,9 +17,9 @@
|
|||
"@wdio/spec-reporter": "7.16.13",
|
||||
"api-testing": "1.6.0",
|
||||
"commander": "^9.4.1",
|
||||
"eslint-config-wikimedia": "0.25.1",
|
||||
"eslint-config-wikimedia": "0.26.0",
|
||||
"grunt": "1.6.1",
|
||||
"grunt-banana-checker": "0.11.0",
|
||||
"grunt-banana-checker": "0.11.1",
|
||||
"grunt-contrib-watch": "1.1.0",
|
||||
"grunt-eslint": "24.3.0",
|
||||
"grunt-stylelint": "0.19.0",
|
||||
|
@ -27,6 +27,6 @@
|
|||
"peggy": "1.0.0",
|
||||
"phpeggy": "^1.0.1",
|
||||
"stylelint-config-wikimedia": "0.16.1",
|
||||
"wdio-mediawiki": "2.1.0"
|
||||
"wdio-mediawiki": "2.5.0"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,7 +3,9 @@ const Page = require( 'wdio-mediawiki/Page' );
|
|||
|
||||
class MathPage extends Page {
|
||||
|
||||
get img() { return $( '.mwe-math-fallback-image-inline' ); }
|
||||
get img() {
|
||||
return $( '.mwe-math-fallback-image-inline' );
|
||||
}
|
||||
|
||||
}
|
||||
module.exports = new MathPage();
|
||||
|
|
Loading…
Reference in a new issue