From dc7ccbeb26c8ea112dd8df8ccd8209a8858dfec2 Mon Sep 17 00:00:00 2001 From: SyntacticSalt Date: Fri, 15 Aug 2025 12:53:22 +0200 Subject: [PATCH 1/3] feat: Support alt-click for widget invokes --- resources/scripts/codemirror.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/resources/scripts/codemirror.js b/resources/scripts/codemirror.js index 372925a..b9111e9 100644 --- a/resources/scripts/codemirror.js +++ b/resources/scripts/codemirror.js @@ -380,6 +380,10 @@ if ( !String.prototype.includes ) { if ( pagename.startsWith( 'module=' ) ) { pagename = pagename.slice( 7 ); + } else if ( pagename.startsWith( 'widget=' ) ) { + // Support invokes of style + // {{#invoke:Lua|invoke|module=Widget/Factory|fn=fromTemplate|widget=pagename}} + pagename = pagename.replace( 'widget=', 'Widget/' ) } else if ( !parserfunction.hasClass( 'cm-mw-parserfunction-name' ) || parserfunction.text() !== '#invoke' ) { return; From 1d4e77fc9d87d780da6192d8cd27158a7cf69304 Mon Sep 17 00:00:00 2001 From: SyntacticSalt Date: Fri, 15 Aug 2025 12:56:59 +0200 Subject: [PATCH 2/3] add semicolon --- resources/scripts/codemirror.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/scripts/codemirror.js b/resources/scripts/codemirror.js index b9111e9..72bd9e9 100644 --- a/resources/scripts/codemirror.js +++ b/resources/scripts/codemirror.js @@ -383,7 +383,7 @@ if ( !String.prototype.includes ) { } else if ( pagename.startsWith( 'widget=' ) ) { // Support invokes of style // {{#invoke:Lua|invoke|module=Widget/Factory|fn=fromTemplate|widget=pagename}} - pagename = pagename.replace( 'widget=', 'Widget/' ) + pagename = pagename.replace( 'widget=', 'Widget/' ); } else if ( !parserfunction.hasClass( 'cm-mw-parserfunction-name' ) || parserfunction.text() !== '#invoke' ) { return; From c817a66f5fb5b460f611a59a591e608980ef16b5 Mon Sep 17 00:00:00 2001 From: Alex Winkler Date: Fri, 15 Aug 2025 13:53:30 +0200 Subject: [PATCH 3/3] Remove a bunch of unneeded code This stuff was for browsers so old they aren't supported anymore anyways --- resources/scripts/codemirror.js | 37 --------------------------------- 1 file changed, 37 deletions(-) diff --git a/resources/scripts/codemirror.js b/resources/scripts/codemirror.js index 72bd9e9..dba6958 100644 --- a/resources/scripts/codemirror.js +++ b/resources/scripts/codemirror.js @@ -1,36 +1,3 @@ -if ( !String.prototype.startsWith ) { - String.prototype.startsWith = function( searchString, position ) { - position = position || 0; - return this.slice( position, position + searchString.length ) === searchString; - }; -} - -if ( !String.prototype.endsWith ) { - String.prototype.endsWith = function( searchString, position ) { - const subjectString = this.toString(); - if ( typeof position !== 'number' || !isFinite( position ) || Math.floor( position ) !== position || position > subjectString.length ) { - position = subjectString.length; - } - position -= searchString.length; - const lastIndex = subjectString.indexOf( searchString, position ); - return lastIndex !== -1 && lastIndex === position; - }; -} - -if ( !String.prototype.includes ) { - String.prototype.includes = function( search, start ) { - 'use strict'; - if ( typeof start !== 'number' ) { - start = 0; - } - if ( start + search.length > this.length ) { - return false; - } else { - return this.indexOf( search, start ) !== -1; - } - }; -} - /* * Adapted from https://www.mediawiki.org/wiki/Extension:CodeMirror * License: GPL 2.0 or later @@ -328,10 +295,6 @@ if ( !String.prototype.includes ) { lineWrapping: linewrapping, styleActiveLine: true } ); - // Our best friend, IE, needs some special css - if ( window.navigator.userAgent.indexOf( 'Trident/' ) > -1 ) { - $( '.CodeMirror' ).addClass( 'CodeMirrorIE' ); - } if ( linewrapping ) { $( '.CodeMirror' ).addClass( 'lineWrapping' ); }