Isolate build step to CM6 library and restructure files to work with RL
CodeMirror 6 requires the use of NPM, but we can still bundle all CM
packages into one file, and then everything else (i.e. our code) is
managed by ResourceLoader as per usual. This makes contribution
considerably easier as we no longer need a build step for each change.
CM5 files are now under resources/legacy, and the CM6 files are moved to
the root of the resources/ directory. Only one file,
codemirror.bundle.js, is managed by Rollup, while everything else is RL.
The Rollup output for now is put under resources/lib/ alongside the CM5
upstream files.
This patch is *mostly* renames of files, along with changing ECMAScript
Module (ESM) syntax into the CommonJS style that ResourceLoader prefers.
We also remove more modern JS syntax (i.e. private class methods) that
we were able to use before because we had a build step with Babel.
This patch should effectively make no user-facing changes, or to the
ResourceLoader modules we offer in Extension:CodeMirror.
Finally, bump version in extension.json to 6, to match the upstream lib,
and add Bhsd as an author :-)
Bug: T368053
Change-Id: Ie258e49f5df8db23a7344ac3c4c9300aaa991042
2024-06-21 03:21:09 +00:00
|
|
|
const {
|
2024-01-04 04:01:27 +00:00
|
|
|
HighlightStyle,
|
|
|
|
LanguageSupport,
|
|
|
|
StreamLanguage,
|
|
|
|
StreamParser,
|
|
|
|
StringStream,
|
Isolate build step to CM6 library and restructure files to work with RL
CodeMirror 6 requires the use of NPM, but we can still bundle all CM
packages into one file, and then everything else (i.e. our code) is
managed by ResourceLoader as per usual. This makes contribution
considerably easier as we no longer need a build step for each change.
CM5 files are now under resources/legacy, and the CM6 files are moved to
the root of the resources/ directory. Only one file,
codemirror.bundle.js, is managed by Rollup, while everything else is RL.
The Rollup output for now is put under resources/lib/ alongside the CM5
upstream files.
This patch is *mostly* renames of files, along with changing ECMAScript
Module (ESM) syntax into the CommonJS style that ResourceLoader prefers.
We also remove more modern JS syntax (i.e. private class methods) that
we were able to use before because we had a build step with Babel.
This patch should effectively make no user-facing changes, or to the
ResourceLoader modules we offer in Extension:CodeMirror.
Finally, bump version in extension.json to 6, to match the upstream lib,
and add Bhsd as an author :-)
Bug: T368053
Change-Id: Ie258e49f5df8db23a7344ac3c4c9300aaa991042
2024-06-21 03:21:09 +00:00
|
|
|
Tag,
|
2024-01-04 04:01:27 +00:00
|
|
|
syntaxHighlighting
|
Isolate build step to CM6 library and restructure files to work with RL
CodeMirror 6 requires the use of NPM, but we can still bundle all CM
packages into one file, and then everything else (i.e. our code) is
managed by ResourceLoader as per usual. This makes contribution
considerably easier as we no longer need a build step for each change.
CM5 files are now under resources/legacy, and the CM6 files are moved to
the root of the resources/ directory. Only one file,
codemirror.bundle.js, is managed by Rollup, while everything else is RL.
The Rollup output for now is put under resources/lib/ alongside the CM5
upstream files.
This patch is *mostly* renames of files, along with changing ECMAScript
Module (ESM) syntax into the CommonJS style that ResourceLoader prefers.
We also remove more modern JS syntax (i.e. private class methods) that
we were able to use before because we had a build step with Babel.
This patch should effectively make no user-facing changes, or to the
ResourceLoader modules we offer in Extension:CodeMirror.
Finally, bump version in extension.json to 6, to match the upstream lib,
and add Bhsd as an author :-)
Bug: T368053
Change-Id: Ie258e49f5df8db23a7344ac3c4c9300aaa991042
2024-06-21 03:21:09 +00:00
|
|
|
} = require( 'ext.CodeMirror.v6.lib' );
|
|
|
|
const mwModeConfig = require( './codemirror.mediawiki.config.js' );
|
|
|
|
const bidiIsolationExtension = require( './codemirror.mediawiki.bidiIsolation.js' );
|
|
|
|
const templateFoldingExtension = require( './codemirror.mediawiki.templateFolding.js' );
|
2023-12-06 18:49:40 +00:00
|
|
|
|
|
|
|
/**
|
2024-03-19 03:10:11 +00:00
|
|
|
* MediaWiki language support for CodeMirror 6.
|
|
|
|
* Adapted from the original CodeMirror 5 stream parser by Pavel Astakhov.
|
2023-12-06 18:49:40 +00:00
|
|
|
*
|
2024-03-19 03:10:11 +00:00
|
|
|
* @module CodeMirrorModeMediaWiki
|
|
|
|
*
|
|
|
|
* @example
|
|
|
|
* mw.loader.using( [
|
|
|
|
* 'ext.CodeMirror.v6',
|
|
|
|
* 'ext.CodeMirror.v6.mode.mediawiki'
|
|
|
|
* ] ).then( ( require ) => {
|
|
|
|
* const CodeMirror = require( 'ext.CodeMirror.v6' );
|
|
|
|
* const mediawikiLang = require( 'ext.CodeMirror.v6.mode.mediawiki' );
|
|
|
|
* const cm = new CodeMirror( myTextarea );
|
|
|
|
* cm.initialize( [ cm.defaultExtensions, mediawikiLang() ] );
|
|
|
|
* } );
|
2023-12-06 18:49:40 +00:00
|
|
|
*/
|
|
|
|
class CodeMirrorModeMediaWiki {
|
|
|
|
/**
|
2024-03-19 03:10:11 +00:00
|
|
|
* @param {Object} config MediaWiki configuration as generated by DataScript.php
|
|
|
|
* @internal
|
2023-12-06 18:49:40 +00:00
|
|
|
*/
|
|
|
|
constructor( config ) {
|
|
|
|
this.config = config;
|
2024-06-14 11:51:53 +00:00
|
|
|
|
2024-01-18 18:06:06 +00:00
|
|
|
this.urlProtocols = new RegExp( `^(?:${ this.config.urlProtocols })(?=[^\\s\u00a0{[\\]<>~).,'])`, 'i' );
|
2023-12-06 18:49:40 +00:00
|
|
|
this.isBold = false;
|
|
|
|
this.wasBold = false;
|
|
|
|
this.isItalic = false;
|
|
|
|
this.wasItalic = false;
|
|
|
|
this.firstSingleLetterWord = null;
|
|
|
|
this.firstMultiLetterWord = null;
|
|
|
|
this.firstSpace = null;
|
|
|
|
this.oldStyle = null;
|
|
|
|
this.tokens = [];
|
|
|
|
this.oldTokens = [];
|
Isolate build step to CM6 library and restructure files to work with RL
CodeMirror 6 requires the use of NPM, but we can still bundle all CM
packages into one file, and then everything else (i.e. our code) is
managed by ResourceLoader as per usual. This makes contribution
considerably easier as we no longer need a build step for each change.
CM5 files are now under resources/legacy, and the CM6 files are moved to
the root of the resources/ directory. Only one file,
codemirror.bundle.js, is managed by Rollup, while everything else is RL.
The Rollup output for now is put under resources/lib/ alongside the CM5
upstream files.
This patch is *mostly* renames of files, along with changing ECMAScript
Module (ESM) syntax into the CommonJS style that ResourceLoader prefers.
We also remove more modern JS syntax (i.e. private class methods) that
we were able to use before because we had a build step with Babel.
This patch should effectively make no user-facing changes, or to the
ResourceLoader modules we offer in Extension:CodeMirror.
Finally, bump version in extension.json to 6, to match the upstream lib,
and add Bhsd as an author :-)
Bug: T368053
Change-Id: Ie258e49f5df8db23a7344ac3c4c9300aaa991042
2024-06-21 03:21:09 +00:00
|
|
|
this.tokenTable = mwModeConfig.tokenTable;
|
2024-02-28 02:03:46 +00:00
|
|
|
this.registerGroundTokens();
|
2024-01-04 04:01:27 +00:00
|
|
|
|
|
|
|
// Dynamically register any tags that aren't already in CodeMirrorModeMediaWikiConfig
|
Isolate build step to CM6 library and restructure files to work with RL
CodeMirror 6 requires the use of NPM, but we can still bundle all CM
packages into one file, and then everything else (i.e. our code) is
managed by ResourceLoader as per usual. This makes contribution
considerably easier as we no longer need a build step for each change.
CM5 files are now under resources/legacy, and the CM6 files are moved to
the root of the resources/ directory. Only one file,
codemirror.bundle.js, is managed by Rollup, while everything else is RL.
The Rollup output for now is put under resources/lib/ alongside the CM5
upstream files.
This patch is *mostly* renames of files, along with changing ECMAScript
Module (ESM) syntax into the CommonJS style that ResourceLoader prefers.
We also remove more modern JS syntax (i.e. private class methods) that
we were able to use before because we had a build step with Babel.
This patch should effectively make no user-facing changes, or to the
ResourceLoader modules we offer in Extension:CodeMirror.
Finally, bump version in extension.json to 6, to match the upstream lib,
and add Bhsd as an author :-)
Bug: T368053
Change-Id: Ie258e49f5df8db23a7344ac3c4c9300aaa991042
2024-06-21 03:21:09 +00:00
|
|
|
Object.keys( this.config.tags ).forEach( ( tag ) => mwModeConfig.addTag( tag ) );
|
2023-12-06 18:49:40 +00:00
|
|
|
}
|
|
|
|
|
2024-02-28 02:03:46 +00:00
|
|
|
/**
|
|
|
|
* Register the ground tokens. These aren't referenced directly in the StreamParser, nor do
|
|
|
|
* they have a parent Tag, so we don't need them as constants like we do for other tokens.
|
|
|
|
* See this.makeLocalStyle() for how these tokens are used.
|
2024-03-19 03:10:11 +00:00
|
|
|
*
|
|
|
|
* @private
|
2024-02-28 02:03:46 +00:00
|
|
|
*/
|
|
|
|
registerGroundTokens() {
|
|
|
|
[
|
|
|
|
'mw-ext-ground',
|
|
|
|
'mw-ext-link-ground',
|
|
|
|
'mw-ext2-ground',
|
|
|
|
'mw-ext2-link-ground',
|
|
|
|
'mw-ext3-ground',
|
|
|
|
'mw-ext3-link-ground',
|
|
|
|
'mw-link-ground',
|
|
|
|
'mw-template-ext-ground',
|
|
|
|
'mw-template-ext-link-ground',
|
|
|
|
'mw-template-ext2-ground',
|
|
|
|
'mw-template-ext2-link-ground',
|
|
|
|
'mw-template-ext3-ground',
|
|
|
|
'mw-template-ext3-link-ground',
|
|
|
|
'mw-template-ground',
|
|
|
|
'mw-template-link-ground',
|
|
|
|
'mw-template2-ext-ground',
|
|
|
|
'mw-template2-ext-link-ground',
|
|
|
|
'mw-template2-ext2-ground',
|
|
|
|
'mw-template2-ext2-link-ground',
|
|
|
|
'mw-template2-ext3-ground',
|
|
|
|
'mw-template2-ext3-link-ground',
|
|
|
|
'mw-template2-ground',
|
|
|
|
'mw-template2-link-ground',
|
|
|
|
'mw-template3-ext-ground',
|
|
|
|
'mw-template3-ext-link-ground',
|
|
|
|
'mw-template3-ext2-ground',
|
|
|
|
'mw-template3-ext2-link-ground',
|
|
|
|
'mw-template3-ext3-ground',
|
|
|
|
'mw-template3-ext3-link-ground',
|
|
|
|
'mw-template3-ground',
|
|
|
|
'mw-template3-link-ground'
|
Isolate build step to CM6 library and restructure files to work with RL
CodeMirror 6 requires the use of NPM, but we can still bundle all CM
packages into one file, and then everything else (i.e. our code) is
managed by ResourceLoader as per usual. This makes contribution
considerably easier as we no longer need a build step for each change.
CM5 files are now under resources/legacy, and the CM6 files are moved to
the root of the resources/ directory. Only one file,
codemirror.bundle.js, is managed by Rollup, while everything else is RL.
The Rollup output for now is put under resources/lib/ alongside the CM5
upstream files.
This patch is *mostly* renames of files, along with changing ECMAScript
Module (ESM) syntax into the CommonJS style that ResourceLoader prefers.
We also remove more modern JS syntax (i.e. private class methods) that
we were able to use before because we had a build step with Babel.
This patch should effectively make no user-facing changes, or to the
ResourceLoader modules we offer in Extension:CodeMirror.
Finally, bump version in extension.json to 6, to match the upstream lib,
and add Bhsd as an author :-)
Bug: T368053
Change-Id: Ie258e49f5df8db23a7344ac3c4c9300aaa991042
2024-06-21 03:21:09 +00:00
|
|
|
].forEach( ( ground ) => mwModeConfig.addToken( ground ) );
|
2024-02-28 02:03:46 +00:00
|
|
|
}
|
|
|
|
|
2024-01-03 06:05:35 +00:00
|
|
|
eatHtmlEntity( stream, style ) {
|
2023-12-06 18:49:40 +00:00
|
|
|
let ok;
|
|
|
|
if ( stream.eat( '#' ) ) {
|
|
|
|
if ( stream.eat( 'x' ) ) {
|
|
|
|
ok = stream.eatWhile( /[a-fA-F\d]/ ) && stream.eat( ';' );
|
|
|
|
} else {
|
|
|
|
ok = stream.eatWhile( /[\d]/ ) && stream.eat( ';' );
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
ok = stream.eatWhile( /[\w.\-:]/ ) && stream.eat( ';' );
|
|
|
|
}
|
|
|
|
if ( ok ) {
|
Isolate build step to CM6 library and restructure files to work with RL
CodeMirror 6 requires the use of NPM, but we can still bundle all CM
packages into one file, and then everything else (i.e. our code) is
managed by ResourceLoader as per usual. This makes contribution
considerably easier as we no longer need a build step for each change.
CM5 files are now under resources/legacy, and the CM6 files are moved to
the root of the resources/ directory. Only one file,
codemirror.bundle.js, is managed by Rollup, while everything else is RL.
The Rollup output for now is put under resources/lib/ alongside the CM5
upstream files.
This patch is *mostly* renames of files, along with changing ECMAScript
Module (ESM) syntax into the CommonJS style that ResourceLoader prefers.
We also remove more modern JS syntax (i.e. private class methods) that
we were able to use before because we had a build step with Babel.
This patch should effectively make no user-facing changes, or to the
ResourceLoader modules we offer in Extension:CodeMirror.
Finally, bump version in extension.json to 6, to match the upstream lib,
and add Bhsd as an author :-)
Bug: T368053
Change-Id: Ie258e49f5df8db23a7344ac3c4c9300aaa991042
2024-06-21 03:21:09 +00:00
|
|
|
return mwModeConfig.tags.htmlEntity;
|
2023-12-06 18:49:40 +00:00
|
|
|
}
|
|
|
|
return style;
|
|
|
|
}
|
|
|
|
|
2024-02-29 09:26:36 +00:00
|
|
|
isNested( state ) {
|
|
|
|
return state.nExt > 0 || state.nTemplate > 0 || state.nLink > 0;
|
|
|
|
}
|
|
|
|
|
2023-12-06 18:49:40 +00:00
|
|
|
makeStyle( style, state, endGround ) {
|
2024-02-29 09:26:36 +00:00
|
|
|
if ( this.isBold || state.nDt > 0 ) {
|
Isolate build step to CM6 library and restructure files to work with RL
CodeMirror 6 requires the use of NPM, but we can still bundle all CM
packages into one file, and then everything else (i.e. our code) is
managed by ResourceLoader as per usual. This makes contribution
considerably easier as we no longer need a build step for each change.
CM5 files are now under resources/legacy, and the CM6 files are moved to
the root of the resources/ directory. Only one file,
codemirror.bundle.js, is managed by Rollup, while everything else is RL.
The Rollup output for now is put under resources/lib/ alongside the CM5
upstream files.
This patch is *mostly* renames of files, along with changing ECMAScript
Module (ESM) syntax into the CommonJS style that ResourceLoader prefers.
We also remove more modern JS syntax (i.e. private class methods) that
we were able to use before because we had a build step with Babel.
This patch should effectively make no user-facing changes, or to the
ResourceLoader modules we offer in Extension:CodeMirror.
Finally, bump version in extension.json to 6, to match the upstream lib,
and add Bhsd as an author :-)
Bug: T368053
Change-Id: Ie258e49f5df8db23a7344ac3c4c9300aaa991042
2024-06-21 03:21:09 +00:00
|
|
|
style += ' ' + mwModeConfig.tags.strong;
|
2023-12-06 18:49:40 +00:00
|
|
|
}
|
|
|
|
if ( this.isItalic ) {
|
Isolate build step to CM6 library and restructure files to work with RL
CodeMirror 6 requires the use of NPM, but we can still bundle all CM
packages into one file, and then everything else (i.e. our code) is
managed by ResourceLoader as per usual. This makes contribution
considerably easier as we no longer need a build step for each change.
CM5 files are now under resources/legacy, and the CM6 files are moved to
the root of the resources/ directory. Only one file,
codemirror.bundle.js, is managed by Rollup, while everything else is RL.
The Rollup output for now is put under resources/lib/ alongside the CM5
upstream files.
This patch is *mostly* renames of files, along with changing ECMAScript
Module (ESM) syntax into the CommonJS style that ResourceLoader prefers.
We also remove more modern JS syntax (i.e. private class methods) that
we were able to use before because we had a build step with Babel.
This patch should effectively make no user-facing changes, or to the
ResourceLoader modules we offer in Extension:CodeMirror.
Finally, bump version in extension.json to 6, to match the upstream lib,
and add Bhsd as an author :-)
Bug: T368053
Change-Id: Ie258e49f5df8db23a7344ac3c4c9300aaa991042
2024-06-21 03:21:09 +00:00
|
|
|
style += ' ' + mwModeConfig.tags.em;
|
2023-12-06 18:49:40 +00:00
|
|
|
}
|
|
|
|
return this.makeLocalStyle( style, state, endGround );
|
|
|
|
}
|
|
|
|
|
|
|
|
makeLocalStyle( style, state, endGround ) {
|
|
|
|
let ground = '';
|
|
|
|
switch ( state.nTemplate ) {
|
|
|
|
case 0:
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
ground += '-template';
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
ground += '-template2';
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
ground += '-template3';
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
switch ( state.nExt ) {
|
|
|
|
case 0:
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
ground += '-ext';
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
ground += '-ext2';
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
ground += '-ext3';
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if ( state.nLink > 0 ) {
|
|
|
|
ground += '-link';
|
|
|
|
}
|
|
|
|
if ( ground !== '' ) {
|
|
|
|
style = `mw${ ground }-ground ${ style }`;
|
|
|
|
}
|
|
|
|
if ( endGround ) {
|
|
|
|
state[ endGround ]--;
|
|
|
|
}
|
|
|
|
return style.trim();
|
|
|
|
}
|
|
|
|
|
|
|
|
eatBlock( style, terminator, consumeLast ) {
|
|
|
|
return ( stream, state ) => {
|
|
|
|
if ( stream.skipTo( terminator ) ) {
|
|
|
|
if ( consumeLast !== false ) {
|
|
|
|
stream.match( terminator );
|
|
|
|
}
|
|
|
|
state.tokenize = state.stack.pop();
|
|
|
|
} else {
|
|
|
|
stream.skipToEnd();
|
|
|
|
}
|
|
|
|
return this.makeLocalStyle( style, state );
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
eatEnd( style ) {
|
|
|
|
return ( stream, state ) => {
|
|
|
|
stream.skipToEnd();
|
|
|
|
state.tokenize = state.stack.pop();
|
|
|
|
return this.makeLocalStyle( style, state );
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
eatChar( char, style ) {
|
|
|
|
return ( stream, state ) => {
|
|
|
|
state.tokenize = state.stack.pop();
|
|
|
|
if ( stream.eat( char ) ) {
|
|
|
|
return this.makeLocalStyle( style, state );
|
|
|
|
}
|
Isolate build step to CM6 library and restructure files to work with RL
CodeMirror 6 requires the use of NPM, but we can still bundle all CM
packages into one file, and then everything else (i.e. our code) is
managed by ResourceLoader as per usual. This makes contribution
considerably easier as we no longer need a build step for each change.
CM5 files are now under resources/legacy, and the CM6 files are moved to
the root of the resources/ directory. Only one file,
codemirror.bundle.js, is managed by Rollup, while everything else is RL.
The Rollup output for now is put under resources/lib/ alongside the CM5
upstream files.
This patch is *mostly* renames of files, along with changing ECMAScript
Module (ESM) syntax into the CommonJS style that ResourceLoader prefers.
We also remove more modern JS syntax (i.e. private class methods) that
we were able to use before because we had a build step with Babel.
This patch should effectively make no user-facing changes, or to the
ResourceLoader modules we offer in Extension:CodeMirror.
Finally, bump version in extension.json to 6, to match the upstream lib,
and add Bhsd as an author :-)
Bug: T368053
Change-Id: Ie258e49f5df8db23a7344ac3c4c9300aaa991042
2024-06-21 03:21:09 +00:00
|
|
|
return this.makeLocalStyle( mwModeConfig.tags.error, state );
|
2023-12-06 18:49:40 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
eatSectionHeader( count ) {
|
|
|
|
return ( stream, state ) => {
|
|
|
|
if ( stream.match( /^[^&<[{~]+/ ) ) {
|
|
|
|
if ( stream.eol() ) {
|
|
|
|
stream.backUp( count );
|
Isolate build step to CM6 library and restructure files to work with RL
CodeMirror 6 requires the use of NPM, but we can still bundle all CM
packages into one file, and then everything else (i.e. our code) is
managed by ResourceLoader as per usual. This makes contribution
considerably easier as we no longer need a build step for each change.
CM5 files are now under resources/legacy, and the CM6 files are moved to
the root of the resources/ directory. Only one file,
codemirror.bundle.js, is managed by Rollup, while everything else is RL.
The Rollup output for now is put under resources/lib/ alongside the CM5
upstream files.
This patch is *mostly* renames of files, along with changing ECMAScript
Module (ESM) syntax into the CommonJS style that ResourceLoader prefers.
We also remove more modern JS syntax (i.e. private class methods) that
we were able to use before because we had a build step with Babel.
This patch should effectively make no user-facing changes, or to the
ResourceLoader modules we offer in Extension:CodeMirror.
Finally, bump version in extension.json to 6, to match the upstream lib,
and add Bhsd as an author :-)
Bug: T368053
Change-Id: Ie258e49f5df8db23a7344ac3c4c9300aaa991042
2024-06-21 03:21:09 +00:00
|
|
|
state.tokenize = this.eatEnd( mwModeConfig.tags.sectionHeader );
|
2023-12-06 18:49:40 +00:00
|
|
|
} else if ( stream.match( /^<!--(?!.*?-->.*?=)/, false ) ) {
|
|
|
|
// T171074: handle trailing comments
|
|
|
|
stream.backUp( count );
|
Isolate build step to CM6 library and restructure files to work with RL
CodeMirror 6 requires the use of NPM, but we can still bundle all CM
packages into one file, and then everything else (i.e. our code) is
managed by ResourceLoader as per usual. This makes contribution
considerably easier as we no longer need a build step for each change.
CM5 files are now under resources/legacy, and the CM6 files are moved to
the root of the resources/ directory. Only one file,
codemirror.bundle.js, is managed by Rollup, while everything else is RL.
The Rollup output for now is put under resources/lib/ alongside the CM5
upstream files.
This patch is *mostly* renames of files, along with changing ECMAScript
Module (ESM) syntax into the CommonJS style that ResourceLoader prefers.
We also remove more modern JS syntax (i.e. private class methods) that
we were able to use before because we had a build step with Babel.
This patch should effectively make no user-facing changes, or to the
ResourceLoader modules we offer in Extension:CodeMirror.
Finally, bump version in extension.json to 6, to match the upstream lib,
and add Bhsd as an author :-)
Bug: T368053
Change-Id: Ie258e49f5df8db23a7344ac3c4c9300aaa991042
2024-06-21 03:21:09 +00:00
|
|
|
state.tokenize = this.eatBlock( mwModeConfig.tags.sectionHeader, '<!--', false );
|
2023-12-06 18:49:40 +00:00
|
|
|
}
|
Isolate build step to CM6 library and restructure files to work with RL
CodeMirror 6 requires the use of NPM, but we can still bundle all CM
packages into one file, and then everything else (i.e. our code) is
managed by ResourceLoader as per usual. This makes contribution
considerably easier as we no longer need a build step for each change.
CM5 files are now under resources/legacy, and the CM6 files are moved to
the root of the resources/ directory. Only one file,
codemirror.bundle.js, is managed by Rollup, while everything else is RL.
The Rollup output for now is put under resources/lib/ alongside the CM5
upstream files.
This patch is *mostly* renames of files, along with changing ECMAScript
Module (ESM) syntax into the CommonJS style that ResourceLoader prefers.
We also remove more modern JS syntax (i.e. private class methods) that
we were able to use before because we had a build step with Babel.
This patch should effectively make no user-facing changes, or to the
ResourceLoader modules we offer in Extension:CodeMirror.
Finally, bump version in extension.json to 6, to match the upstream lib,
and add Bhsd as an author :-)
Bug: T368053
Change-Id: Ie258e49f5df8db23a7344ac3c4c9300aaa991042
2024-06-21 03:21:09 +00:00
|
|
|
return mwModeConfig.tags.section; // style is null
|
2023-12-06 18:49:40 +00:00
|
|
|
}
|
Isolate build step to CM6 library and restructure files to work with RL
CodeMirror 6 requires the use of NPM, but we can still bundle all CM
packages into one file, and then everything else (i.e. our code) is
managed by ResourceLoader as per usual. This makes contribution
considerably easier as we no longer need a build step for each change.
CM5 files are now under resources/legacy, and the CM6 files are moved to
the root of the resources/ directory. Only one file,
codemirror.bundle.js, is managed by Rollup, while everything else is RL.
The Rollup output for now is put under resources/lib/ alongside the CM5
upstream files.
This patch is *mostly* renames of files, along with changing ECMAScript
Module (ESM) syntax into the CommonJS style that ResourceLoader prefers.
We also remove more modern JS syntax (i.e. private class methods) that
we were able to use before because we had a build step with Babel.
This patch should effectively make no user-facing changes, or to the
ResourceLoader modules we offer in Extension:CodeMirror.
Finally, bump version in extension.json to 6, to match the upstream lib,
and add Bhsd as an author :-)
Bug: T368053
Change-Id: Ie258e49f5df8db23a7344ac3c4c9300aaa991042
2024-06-21 03:21:09 +00:00
|
|
|
return this.eatWikiText( mwModeConfig.tags.section )( stream, state );
|
2023-12-06 18:49:40 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
inVariable( stream, state ) {
|
|
|
|
if ( stream.match( /^[^{}|]+/ ) ) {
|
Isolate build step to CM6 library and restructure files to work with RL
CodeMirror 6 requires the use of NPM, but we can still bundle all CM
packages into one file, and then everything else (i.e. our code) is
managed by ResourceLoader as per usual. This makes contribution
considerably easier as we no longer need a build step for each change.
CM5 files are now under resources/legacy, and the CM6 files are moved to
the root of the resources/ directory. Only one file,
codemirror.bundle.js, is managed by Rollup, while everything else is RL.
The Rollup output for now is put under resources/lib/ alongside the CM5
upstream files.
This patch is *mostly* renames of files, along with changing ECMAScript
Module (ESM) syntax into the CommonJS style that ResourceLoader prefers.
We also remove more modern JS syntax (i.e. private class methods) that
we were able to use before because we had a build step with Babel.
This patch should effectively make no user-facing changes, or to the
ResourceLoader modules we offer in Extension:CodeMirror.
Finally, bump version in extension.json to 6, to match the upstream lib,
and add Bhsd as an author :-)
Bug: T368053
Change-Id: Ie258e49f5df8db23a7344ac3c4c9300aaa991042
2024-06-21 03:21:09 +00:00
|
|
|
return this.makeLocalStyle( mwModeConfig.tags.templateVariableName, state );
|
2023-12-06 18:49:40 +00:00
|
|
|
}
|
|
|
|
if ( stream.eat( '|' ) ) {
|
|
|
|
state.tokenize = this.inVariableDefault.bind( this );
|
Isolate build step to CM6 library and restructure files to work with RL
CodeMirror 6 requires the use of NPM, but we can still bundle all CM
packages into one file, and then everything else (i.e. our code) is
managed by ResourceLoader as per usual. This makes contribution
considerably easier as we no longer need a build step for each change.
CM5 files are now under resources/legacy, and the CM6 files are moved to
the root of the resources/ directory. Only one file,
codemirror.bundle.js, is managed by Rollup, while everything else is RL.
The Rollup output for now is put under resources/lib/ alongside the CM5
upstream files.
This patch is *mostly* renames of files, along with changing ECMAScript
Module (ESM) syntax into the CommonJS style that ResourceLoader prefers.
We also remove more modern JS syntax (i.e. private class methods) that
we were able to use before because we had a build step with Babel.
This patch should effectively make no user-facing changes, or to the
ResourceLoader modules we offer in Extension:CodeMirror.
Finally, bump version in extension.json to 6, to match the upstream lib,
and add Bhsd as an author :-)
Bug: T368053
Change-Id: Ie258e49f5df8db23a7344ac3c4c9300aaa991042
2024-06-21 03:21:09 +00:00
|
|
|
return this.makeLocalStyle( mwModeConfig.tags.templateVariableDelimiter, state );
|
2023-12-06 18:49:40 +00:00
|
|
|
}
|
|
|
|
if ( stream.match( '}}}' ) ) {
|
|
|
|
state.tokenize = state.stack.pop();
|
Isolate build step to CM6 library and restructure files to work with RL
CodeMirror 6 requires the use of NPM, but we can still bundle all CM
packages into one file, and then everything else (i.e. our code) is
managed by ResourceLoader as per usual. This makes contribution
considerably easier as we no longer need a build step for each change.
CM5 files are now under resources/legacy, and the CM6 files are moved to
the root of the resources/ directory. Only one file,
codemirror.bundle.js, is managed by Rollup, while everything else is RL.
The Rollup output for now is put under resources/lib/ alongside the CM5
upstream files.
This patch is *mostly* renames of files, along with changing ECMAScript
Module (ESM) syntax into the CommonJS style that ResourceLoader prefers.
We also remove more modern JS syntax (i.e. private class methods) that
we were able to use before because we had a build step with Babel.
This patch should effectively make no user-facing changes, or to the
ResourceLoader modules we offer in Extension:CodeMirror.
Finally, bump version in extension.json to 6, to match the upstream lib,
and add Bhsd as an author :-)
Bug: T368053
Change-Id: Ie258e49f5df8db23a7344ac3c4c9300aaa991042
2024-06-21 03:21:09 +00:00
|
|
|
return this.makeLocalStyle( mwModeConfig.tags.templateVariableBracket, state );
|
2023-12-06 18:49:40 +00:00
|
|
|
}
|
|
|
|
if ( stream.match( '{{{' ) ) {
|
|
|
|
state.stack.push( state.tokenize );
|
Isolate build step to CM6 library and restructure files to work with RL
CodeMirror 6 requires the use of NPM, but we can still bundle all CM
packages into one file, and then everything else (i.e. our code) is
managed by ResourceLoader as per usual. This makes contribution
considerably easier as we no longer need a build step for each change.
CM5 files are now under resources/legacy, and the CM6 files are moved to
the root of the resources/ directory. Only one file,
codemirror.bundle.js, is managed by Rollup, while everything else is RL.
The Rollup output for now is put under resources/lib/ alongside the CM5
upstream files.
This patch is *mostly* renames of files, along with changing ECMAScript
Module (ESM) syntax into the CommonJS style that ResourceLoader prefers.
We also remove more modern JS syntax (i.e. private class methods) that
we were able to use before because we had a build step with Babel.
This patch should effectively make no user-facing changes, or to the
ResourceLoader modules we offer in Extension:CodeMirror.
Finally, bump version in extension.json to 6, to match the upstream lib,
and add Bhsd as an author :-)
Bug: T368053
Change-Id: Ie258e49f5df8db23a7344ac3c4c9300aaa991042
2024-06-21 03:21:09 +00:00
|
|
|
return this.makeLocalStyle( mwModeConfig.tags.templateVariableBracket, state );
|
2023-12-06 18:49:40 +00:00
|
|
|
}
|
|
|
|
stream.next();
|
Isolate build step to CM6 library and restructure files to work with RL
CodeMirror 6 requires the use of NPM, but we can still bundle all CM
packages into one file, and then everything else (i.e. our code) is
managed by ResourceLoader as per usual. This makes contribution
considerably easier as we no longer need a build step for each change.
CM5 files are now under resources/legacy, and the CM6 files are moved to
the root of the resources/ directory. Only one file,
codemirror.bundle.js, is managed by Rollup, while everything else is RL.
The Rollup output for now is put under resources/lib/ alongside the CM5
upstream files.
This patch is *mostly* renames of files, along with changing ECMAScript
Module (ESM) syntax into the CommonJS style that ResourceLoader prefers.
We also remove more modern JS syntax (i.e. private class methods) that
we were able to use before because we had a build step with Babel.
This patch should effectively make no user-facing changes, or to the
ResourceLoader modules we offer in Extension:CodeMirror.
Finally, bump version in extension.json to 6, to match the upstream lib,
and add Bhsd as an author :-)
Bug: T368053
Change-Id: Ie258e49f5df8db23a7344ac3c4c9300aaa991042
2024-06-21 03:21:09 +00:00
|
|
|
return this.makeLocalStyle( mwModeConfig.tags.templateVariableName, state );
|
2023-12-06 18:49:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
inVariableDefault( stream, state ) {
|
|
|
|
if ( stream.match( /^[^{}[<&~]+/ ) ) {
|
Isolate build step to CM6 library and restructure files to work with RL
CodeMirror 6 requires the use of NPM, but we can still bundle all CM
packages into one file, and then everything else (i.e. our code) is
managed by ResourceLoader as per usual. This makes contribution
considerably easier as we no longer need a build step for each change.
CM5 files are now under resources/legacy, and the CM6 files are moved to
the root of the resources/ directory. Only one file,
codemirror.bundle.js, is managed by Rollup, while everything else is RL.
The Rollup output for now is put under resources/lib/ alongside the CM5
upstream files.
This patch is *mostly* renames of files, along with changing ECMAScript
Module (ESM) syntax into the CommonJS style that ResourceLoader prefers.
We also remove more modern JS syntax (i.e. private class methods) that
we were able to use before because we had a build step with Babel.
This patch should effectively make no user-facing changes, or to the
ResourceLoader modules we offer in Extension:CodeMirror.
Finally, bump version in extension.json to 6, to match the upstream lib,
and add Bhsd as an author :-)
Bug: T368053
Change-Id: Ie258e49f5df8db23a7344ac3c4c9300aaa991042
2024-06-21 03:21:09 +00:00
|
|
|
return this.makeLocalStyle( mwModeConfig.tags.templateVariable, state );
|
2023-12-06 18:49:40 +00:00
|
|
|
}
|
|
|
|
if ( stream.match( '}}}' ) ) {
|
|
|
|
state.tokenize = state.stack.pop();
|
Isolate build step to CM6 library and restructure files to work with RL
CodeMirror 6 requires the use of NPM, but we can still bundle all CM
packages into one file, and then everything else (i.e. our code) is
managed by ResourceLoader as per usual. This makes contribution
considerably easier as we no longer need a build step for each change.
CM5 files are now under resources/legacy, and the CM6 files are moved to
the root of the resources/ directory. Only one file,
codemirror.bundle.js, is managed by Rollup, while everything else is RL.
The Rollup output for now is put under resources/lib/ alongside the CM5
upstream files.
This patch is *mostly* renames of files, along with changing ECMAScript
Module (ESM) syntax into the CommonJS style that ResourceLoader prefers.
We also remove more modern JS syntax (i.e. private class methods) that
we were able to use before because we had a build step with Babel.
This patch should effectively make no user-facing changes, or to the
ResourceLoader modules we offer in Extension:CodeMirror.
Finally, bump version in extension.json to 6, to match the upstream lib,
and add Bhsd as an author :-)
Bug: T368053
Change-Id: Ie258e49f5df8db23a7344ac3c4c9300aaa991042
2024-06-21 03:21:09 +00:00
|
|
|
return this.makeLocalStyle( mwModeConfig.tags.templateVariableBracket, state );
|
2023-12-06 18:49:40 +00:00
|
|
|
}
|
Isolate build step to CM6 library and restructure files to work with RL
CodeMirror 6 requires the use of NPM, but we can still bundle all CM
packages into one file, and then everything else (i.e. our code) is
managed by ResourceLoader as per usual. This makes contribution
considerably easier as we no longer need a build step for each change.
CM5 files are now under resources/legacy, and the CM6 files are moved to
the root of the resources/ directory. Only one file,
codemirror.bundle.js, is managed by Rollup, while everything else is RL.
The Rollup output for now is put under resources/lib/ alongside the CM5
upstream files.
This patch is *mostly* renames of files, along with changing ECMAScript
Module (ESM) syntax into the CommonJS style that ResourceLoader prefers.
We also remove more modern JS syntax (i.e. private class methods) that
we were able to use before because we had a build step with Babel.
This patch should effectively make no user-facing changes, or to the
ResourceLoader modules we offer in Extension:CodeMirror.
Finally, bump version in extension.json to 6, to match the upstream lib,
and add Bhsd as an author :-)
Bug: T368053
Change-Id: Ie258e49f5df8db23a7344ac3c4c9300aaa991042
2024-06-21 03:21:09 +00:00
|
|
|
return this.eatWikiText( mwModeConfig.tags.templateVariable )( stream, state );
|
2023-12-06 18:49:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
inParserFunctionName( stream, state ) {
|
|
|
|
// FIXME: {{#name}} and {{uc}} are wrong, must have ':'
|
|
|
|
if ( stream.match( /^#?[^:}{~]+/ ) ) {
|
Isolate build step to CM6 library and restructure files to work with RL
CodeMirror 6 requires the use of NPM, but we can still bundle all CM
packages into one file, and then everything else (i.e. our code) is
managed by ResourceLoader as per usual. This makes contribution
considerably easier as we no longer need a build step for each change.
CM5 files are now under resources/legacy, and the CM6 files are moved to
the root of the resources/ directory. Only one file,
codemirror.bundle.js, is managed by Rollup, while everything else is RL.
The Rollup output for now is put under resources/lib/ alongside the CM5
upstream files.
This patch is *mostly* renames of files, along with changing ECMAScript
Module (ESM) syntax into the CommonJS style that ResourceLoader prefers.
We also remove more modern JS syntax (i.e. private class methods) that
we were able to use before because we had a build step with Babel.
This patch should effectively make no user-facing changes, or to the
ResourceLoader modules we offer in Extension:CodeMirror.
Finally, bump version in extension.json to 6, to match the upstream lib,
and add Bhsd as an author :-)
Bug: T368053
Change-Id: Ie258e49f5df8db23a7344ac3c4c9300aaa991042
2024-06-21 03:21:09 +00:00
|
|
|
return this.makeLocalStyle( mwModeConfig.tags.parserFunctionName, state );
|
2023-12-06 18:49:40 +00:00
|
|
|
}
|
|
|
|
if ( stream.eat( ':' ) ) {
|
|
|
|
state.tokenize = this.inParserFunctionArguments.bind( this );
|
Isolate build step to CM6 library and restructure files to work with RL
CodeMirror 6 requires the use of NPM, but we can still bundle all CM
packages into one file, and then everything else (i.e. our code) is
managed by ResourceLoader as per usual. This makes contribution
considerably easier as we no longer need a build step for each change.
CM5 files are now under resources/legacy, and the CM6 files are moved to
the root of the resources/ directory. Only one file,
codemirror.bundle.js, is managed by Rollup, while everything else is RL.
The Rollup output for now is put under resources/lib/ alongside the CM5
upstream files.
This patch is *mostly* renames of files, along with changing ECMAScript
Module (ESM) syntax into the CommonJS style that ResourceLoader prefers.
We also remove more modern JS syntax (i.e. private class methods) that
we were able to use before because we had a build step with Babel.
This patch should effectively make no user-facing changes, or to the
ResourceLoader modules we offer in Extension:CodeMirror.
Finally, bump version in extension.json to 6, to match the upstream lib,
and add Bhsd as an author :-)
Bug: T368053
Change-Id: Ie258e49f5df8db23a7344ac3c4c9300aaa991042
2024-06-21 03:21:09 +00:00
|
|
|
return this.makeLocalStyle( mwModeConfig.tags.parserFunctionDelimiter, state );
|
2023-12-06 18:49:40 +00:00
|
|
|
}
|
|
|
|
if ( stream.match( '}}' ) ) {
|
|
|
|
state.tokenize = state.stack.pop();
|
Isolate build step to CM6 library and restructure files to work with RL
CodeMirror 6 requires the use of NPM, but we can still bundle all CM
packages into one file, and then everything else (i.e. our code) is
managed by ResourceLoader as per usual. This makes contribution
considerably easier as we no longer need a build step for each change.
CM5 files are now under resources/legacy, and the CM6 files are moved to
the root of the resources/ directory. Only one file,
codemirror.bundle.js, is managed by Rollup, while everything else is RL.
The Rollup output for now is put under resources/lib/ alongside the CM5
upstream files.
This patch is *mostly* renames of files, along with changing ECMAScript
Module (ESM) syntax into the CommonJS style that ResourceLoader prefers.
We also remove more modern JS syntax (i.e. private class methods) that
we were able to use before because we had a build step with Babel.
This patch should effectively make no user-facing changes, or to the
ResourceLoader modules we offer in Extension:CodeMirror.
Finally, bump version in extension.json to 6, to match the upstream lib,
and add Bhsd as an author :-)
Bug: T368053
Change-Id: Ie258e49f5df8db23a7344ac3c4c9300aaa991042
2024-06-21 03:21:09 +00:00
|
|
|
return this.makeLocalStyle( mwModeConfig.tags.parserFunctionBracket, state, 'nExt' );
|
2023-12-06 18:49:40 +00:00
|
|
|
}
|
Isolate build step to CM6 library and restructure files to work with RL
CodeMirror 6 requires the use of NPM, but we can still bundle all CM
packages into one file, and then everything else (i.e. our code) is
managed by ResourceLoader as per usual. This makes contribution
considerably easier as we no longer need a build step for each change.
CM5 files are now under resources/legacy, and the CM6 files are moved to
the root of the resources/ directory. Only one file,
codemirror.bundle.js, is managed by Rollup, while everything else is RL.
The Rollup output for now is put under resources/lib/ alongside the CM5
upstream files.
This patch is *mostly* renames of files, along with changing ECMAScript
Module (ESM) syntax into the CommonJS style that ResourceLoader prefers.
We also remove more modern JS syntax (i.e. private class methods) that
we were able to use before because we had a build step with Babel.
This patch should effectively make no user-facing changes, or to the
ResourceLoader modules we offer in Extension:CodeMirror.
Finally, bump version in extension.json to 6, to match the upstream lib,
and add Bhsd as an author :-)
Bug: T368053
Change-Id: Ie258e49f5df8db23a7344ac3c4c9300aaa991042
2024-06-21 03:21:09 +00:00
|
|
|
return this.eatWikiText( mwModeConfig.tags.parserFunction )( stream, state );
|
2023-12-06 18:49:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
inParserFunctionArguments( stream, state ) {
|
|
|
|
if ( stream.match( /^[^|}{[<&~]+/ ) ) {
|
Isolate build step to CM6 library and restructure files to work with RL
CodeMirror 6 requires the use of NPM, but we can still bundle all CM
packages into one file, and then everything else (i.e. our code) is
managed by ResourceLoader as per usual. This makes contribution
considerably easier as we no longer need a build step for each change.
CM5 files are now under resources/legacy, and the CM6 files are moved to
the root of the resources/ directory. Only one file,
codemirror.bundle.js, is managed by Rollup, while everything else is RL.
The Rollup output for now is put under resources/lib/ alongside the CM5
upstream files.
This patch is *mostly* renames of files, along with changing ECMAScript
Module (ESM) syntax into the CommonJS style that ResourceLoader prefers.
We also remove more modern JS syntax (i.e. private class methods) that
we were able to use before because we had a build step with Babel.
This patch should effectively make no user-facing changes, or to the
ResourceLoader modules we offer in Extension:CodeMirror.
Finally, bump version in extension.json to 6, to match the upstream lib,
and add Bhsd as an author :-)
Bug: T368053
Change-Id: Ie258e49f5df8db23a7344ac3c4c9300aaa991042
2024-06-21 03:21:09 +00:00
|
|
|
return this.makeLocalStyle( mwModeConfig.tags.parserFunction, state );
|
2023-12-06 18:49:40 +00:00
|
|
|
} else if ( stream.eat( '|' ) ) {
|
Isolate build step to CM6 library and restructure files to work with RL
CodeMirror 6 requires the use of NPM, but we can still bundle all CM
packages into one file, and then everything else (i.e. our code) is
managed by ResourceLoader as per usual. This makes contribution
considerably easier as we no longer need a build step for each change.
CM5 files are now under resources/legacy, and the CM6 files are moved to
the root of the resources/ directory. Only one file,
codemirror.bundle.js, is managed by Rollup, while everything else is RL.
The Rollup output for now is put under resources/lib/ alongside the CM5
upstream files.
This patch is *mostly* renames of files, along with changing ECMAScript
Module (ESM) syntax into the CommonJS style that ResourceLoader prefers.
We also remove more modern JS syntax (i.e. private class methods) that
we were able to use before because we had a build step with Babel.
This patch should effectively make no user-facing changes, or to the
ResourceLoader modules we offer in Extension:CodeMirror.
Finally, bump version in extension.json to 6, to match the upstream lib,
and add Bhsd as an author :-)
Bug: T368053
Change-Id: Ie258e49f5df8db23a7344ac3c4c9300aaa991042
2024-06-21 03:21:09 +00:00
|
|
|
return this.makeLocalStyle( mwModeConfig.tags.parserFunctionDelimiter, state );
|
2023-12-06 18:49:40 +00:00
|
|
|
} else if ( stream.match( '}}' ) ) {
|
|
|
|
state.tokenize = state.stack.pop();
|
Isolate build step to CM6 library and restructure files to work with RL
CodeMirror 6 requires the use of NPM, but we can still bundle all CM
packages into one file, and then everything else (i.e. our code) is
managed by ResourceLoader as per usual. This makes contribution
considerably easier as we no longer need a build step for each change.
CM5 files are now under resources/legacy, and the CM6 files are moved to
the root of the resources/ directory. Only one file,
codemirror.bundle.js, is managed by Rollup, while everything else is RL.
The Rollup output for now is put under resources/lib/ alongside the CM5
upstream files.
This patch is *mostly* renames of files, along with changing ECMAScript
Module (ESM) syntax into the CommonJS style that ResourceLoader prefers.
We also remove more modern JS syntax (i.e. private class methods) that
we were able to use before because we had a build step with Babel.
This patch should effectively make no user-facing changes, or to the
ResourceLoader modules we offer in Extension:CodeMirror.
Finally, bump version in extension.json to 6, to match the upstream lib,
and add Bhsd as an author :-)
Bug: T368053
Change-Id: Ie258e49f5df8db23a7344ac3c4c9300aaa991042
2024-06-21 03:21:09 +00:00
|
|
|
return this.makeLocalStyle( mwModeConfig.tags.parserFunctionBracket, state, 'nExt' );
|
2023-12-06 18:49:40 +00:00
|
|
|
}
|
Isolate build step to CM6 library and restructure files to work with RL
CodeMirror 6 requires the use of NPM, but we can still bundle all CM
packages into one file, and then everything else (i.e. our code) is
managed by ResourceLoader as per usual. This makes contribution
considerably easier as we no longer need a build step for each change.
CM5 files are now under resources/legacy, and the CM6 files are moved to
the root of the resources/ directory. Only one file,
codemirror.bundle.js, is managed by Rollup, while everything else is RL.
The Rollup output for now is put under resources/lib/ alongside the CM5
upstream files.
This patch is *mostly* renames of files, along with changing ECMAScript
Module (ESM) syntax into the CommonJS style that ResourceLoader prefers.
We also remove more modern JS syntax (i.e. private class methods) that
we were able to use before because we had a build step with Babel.
This patch should effectively make no user-facing changes, or to the
ResourceLoader modules we offer in Extension:CodeMirror.
Finally, bump version in extension.json to 6, to match the upstream lib,
and add Bhsd as an author :-)
Bug: T368053
Change-Id: Ie258e49f5df8db23a7344ac3c4c9300aaa991042
2024-06-21 03:21:09 +00:00
|
|
|
return this.eatWikiText( mwModeConfig.tags.parserFunction )( stream, state );
|
2023-12-06 18:49:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
eatTemplatePageName( haveAte ) {
|
|
|
|
return ( stream, state ) => {
|
|
|
|
if ( stream.match( /^[\s\u00a0]*\|[\s\u00a0]*/ ) ) {
|
|
|
|
state.tokenize = this.eatTemplateArgument( true );
|
Isolate build step to CM6 library and restructure files to work with RL
CodeMirror 6 requires the use of NPM, but we can still bundle all CM
packages into one file, and then everything else (i.e. our code) is
managed by ResourceLoader as per usual. This makes contribution
considerably easier as we no longer need a build step for each change.
CM5 files are now under resources/legacy, and the CM6 files are moved to
the root of the resources/ directory. Only one file,
codemirror.bundle.js, is managed by Rollup, while everything else is RL.
The Rollup output for now is put under resources/lib/ alongside the CM5
upstream files.
This patch is *mostly* renames of files, along with changing ECMAScript
Module (ESM) syntax into the CommonJS style that ResourceLoader prefers.
We also remove more modern JS syntax (i.e. private class methods) that
we were able to use before because we had a build step with Babel.
This patch should effectively make no user-facing changes, or to the
ResourceLoader modules we offer in Extension:CodeMirror.
Finally, bump version in extension.json to 6, to match the upstream lib,
and add Bhsd as an author :-)
Bug: T368053
Change-Id: Ie258e49f5df8db23a7344ac3c4c9300aaa991042
2024-06-21 03:21:09 +00:00
|
|
|
return this.makeLocalStyle( mwModeConfig.tags.templateDelimiter, state );
|
2023-12-06 18:49:40 +00:00
|
|
|
}
|
|
|
|
if ( stream.match( /^[\s\u00a0]*\}\}/ ) ) {
|
|
|
|
state.tokenize = state.stack.pop();
|
Isolate build step to CM6 library and restructure files to work with RL
CodeMirror 6 requires the use of NPM, but we can still bundle all CM
packages into one file, and then everything else (i.e. our code) is
managed by ResourceLoader as per usual. This makes contribution
considerably easier as we no longer need a build step for each change.
CM5 files are now under resources/legacy, and the CM6 files are moved to
the root of the resources/ directory. Only one file,
codemirror.bundle.js, is managed by Rollup, while everything else is RL.
The Rollup output for now is put under resources/lib/ alongside the CM5
upstream files.
This patch is *mostly* renames of files, along with changing ECMAScript
Module (ESM) syntax into the CommonJS style that ResourceLoader prefers.
We also remove more modern JS syntax (i.e. private class methods) that
we were able to use before because we had a build step with Babel.
This patch should effectively make no user-facing changes, or to the
ResourceLoader modules we offer in Extension:CodeMirror.
Finally, bump version in extension.json to 6, to match the upstream lib,
and add Bhsd as an author :-)
Bug: T368053
Change-Id: Ie258e49f5df8db23a7344ac3c4c9300aaa991042
2024-06-21 03:21:09 +00:00
|
|
|
return this.makeLocalStyle( mwModeConfig.tags.templateBracket, state, 'nTemplate' );
|
2023-12-06 18:49:40 +00:00
|
|
|
}
|
|
|
|
if ( stream.match( /^[\s\u00a0]*<!--.*?-->/ ) ) {
|
Isolate build step to CM6 library and restructure files to work with RL
CodeMirror 6 requires the use of NPM, but we can still bundle all CM
packages into one file, and then everything else (i.e. our code) is
managed by ResourceLoader as per usual. This makes contribution
considerably easier as we no longer need a build step for each change.
CM5 files are now under resources/legacy, and the CM6 files are moved to
the root of the resources/ directory. Only one file,
codemirror.bundle.js, is managed by Rollup, while everything else is RL.
The Rollup output for now is put under resources/lib/ alongside the CM5
upstream files.
This patch is *mostly* renames of files, along with changing ECMAScript
Module (ESM) syntax into the CommonJS style that ResourceLoader prefers.
We also remove more modern JS syntax (i.e. private class methods) that
we were able to use before because we had a build step with Babel.
This patch should effectively make no user-facing changes, or to the
ResourceLoader modules we offer in Extension:CodeMirror.
Finally, bump version in extension.json to 6, to match the upstream lib,
and add Bhsd as an author :-)
Bug: T368053
Change-Id: Ie258e49f5df8db23a7344ac3c4c9300aaa991042
2024-06-21 03:21:09 +00:00
|
|
|
return this.makeLocalStyle( mwModeConfig.tags.comment, state );
|
2023-12-06 18:49:40 +00:00
|
|
|
}
|
|
|
|
if ( haveAte && stream.sol() ) {
|
|
|
|
// @todo error message
|
|
|
|
state.nTemplate--;
|
|
|
|
state.tokenize = state.stack.pop();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if ( stream.match( /^[\s\u00a0]*[^\s\u00a0|}<{&~]+/ ) ) {
|
|
|
|
state.tokenize = this.eatTemplatePageName( true );
|
Isolate build step to CM6 library and restructure files to work with RL
CodeMirror 6 requires the use of NPM, but we can still bundle all CM
packages into one file, and then everything else (i.e. our code) is
managed by ResourceLoader as per usual. This makes contribution
considerably easier as we no longer need a build step for each change.
CM5 files are now under resources/legacy, and the CM6 files are moved to
the root of the resources/ directory. Only one file,
codemirror.bundle.js, is managed by Rollup, while everything else is RL.
The Rollup output for now is put under resources/lib/ alongside the CM5
upstream files.
This patch is *mostly* renames of files, along with changing ECMAScript
Module (ESM) syntax into the CommonJS style that ResourceLoader prefers.
We also remove more modern JS syntax (i.e. private class methods) that
we were able to use before because we had a build step with Babel.
This patch should effectively make no user-facing changes, or to the
ResourceLoader modules we offer in Extension:CodeMirror.
Finally, bump version in extension.json to 6, to match the upstream lib,
and add Bhsd as an author :-)
Bug: T368053
Change-Id: Ie258e49f5df8db23a7344ac3c4c9300aaa991042
2024-06-21 03:21:09 +00:00
|
|
|
return this.makeLocalStyle( mwModeConfig.tags.templateName, state );
|
2023-12-06 18:49:40 +00:00
|
|
|
} else if ( stream.eatSpace() ) {
|
|
|
|
if ( stream.eol() === true ) {
|
Isolate build step to CM6 library and restructure files to work with RL
CodeMirror 6 requires the use of NPM, but we can still bundle all CM
packages into one file, and then everything else (i.e. our code) is
managed by ResourceLoader as per usual. This makes contribution
considerably easier as we no longer need a build step for each change.
CM5 files are now under resources/legacy, and the CM6 files are moved to
the root of the resources/ directory. Only one file,
codemirror.bundle.js, is managed by Rollup, while everything else is RL.
The Rollup output for now is put under resources/lib/ alongside the CM5
upstream files.
This patch is *mostly* renames of files, along with changing ECMAScript
Module (ESM) syntax into the CommonJS style that ResourceLoader prefers.
We also remove more modern JS syntax (i.e. private class methods) that
we were able to use before because we had a build step with Babel.
This patch should effectively make no user-facing changes, or to the
ResourceLoader modules we offer in Extension:CodeMirror.
Finally, bump version in extension.json to 6, to match the upstream lib,
and add Bhsd as an author :-)
Bug: T368053
Change-Id: Ie258e49f5df8db23a7344ac3c4c9300aaa991042
2024-06-21 03:21:09 +00:00
|
|
|
return this.makeLocalStyle( mwModeConfig.tags.templateName, state );
|
2023-12-06 18:49:40 +00:00
|
|
|
}
|
Isolate build step to CM6 library and restructure files to work with RL
CodeMirror 6 requires the use of NPM, but we can still bundle all CM
packages into one file, and then everything else (i.e. our code) is
managed by ResourceLoader as per usual. This makes contribution
considerably easier as we no longer need a build step for each change.
CM5 files are now under resources/legacy, and the CM6 files are moved to
the root of the resources/ directory. Only one file,
codemirror.bundle.js, is managed by Rollup, while everything else is RL.
The Rollup output for now is put under resources/lib/ alongside the CM5
upstream files.
This patch is *mostly* renames of files, along with changing ECMAScript
Module (ESM) syntax into the CommonJS style that ResourceLoader prefers.
We also remove more modern JS syntax (i.e. private class methods) that
we were able to use before because we had a build step with Babel.
This patch should effectively make no user-facing changes, or to the
ResourceLoader modules we offer in Extension:CodeMirror.
Finally, bump version in extension.json to 6, to match the upstream lib,
and add Bhsd as an author :-)
Bug: T368053
Change-Id: Ie258e49f5df8db23a7344ac3c4c9300aaa991042
2024-06-21 03:21:09 +00:00
|
|
|
return this.makeLocalStyle( mwModeConfig.tags.templateName, state );
|
2023-12-06 18:49:40 +00:00
|
|
|
}
|
Isolate build step to CM6 library and restructure files to work with RL
CodeMirror 6 requires the use of NPM, but we can still bundle all CM
packages into one file, and then everything else (i.e. our code) is
managed by ResourceLoader as per usual. This makes contribution
considerably easier as we no longer need a build step for each change.
CM5 files are now under resources/legacy, and the CM6 files are moved to
the root of the resources/ directory. Only one file,
codemirror.bundle.js, is managed by Rollup, while everything else is RL.
The Rollup output for now is put under resources/lib/ alongside the CM5
upstream files.
This patch is *mostly* renames of files, along with changing ECMAScript
Module (ESM) syntax into the CommonJS style that ResourceLoader prefers.
We also remove more modern JS syntax (i.e. private class methods) that
we were able to use before because we had a build step with Babel.
This patch should effectively make no user-facing changes, or to the
ResourceLoader modules we offer in Extension:CodeMirror.
Finally, bump version in extension.json to 6, to match the upstream lib,
and add Bhsd as an author :-)
Bug: T368053
Change-Id: Ie258e49f5df8db23a7344ac3c4c9300aaa991042
2024-06-21 03:21:09 +00:00
|
|
|
return this.eatWikiText( mwModeConfig.tags.templateName )( stream, state );
|
2023-12-06 18:49:40 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
eatTemplateArgument( expectArgName ) {
|
|
|
|
return ( stream, state ) => {
|
|
|
|
if ( expectArgName && stream.eatWhile( /[^=|}{[<&~]/ ) ) {
|
|
|
|
if ( stream.eat( '=' ) ) {
|
|
|
|
state.tokenize = this.eatTemplateArgument( false );
|
Isolate build step to CM6 library and restructure files to work with RL
CodeMirror 6 requires the use of NPM, but we can still bundle all CM
packages into one file, and then everything else (i.e. our code) is
managed by ResourceLoader as per usual. This makes contribution
considerably easier as we no longer need a build step for each change.
CM5 files are now under resources/legacy, and the CM6 files are moved to
the root of the resources/ directory. Only one file,
codemirror.bundle.js, is managed by Rollup, while everything else is RL.
The Rollup output for now is put under resources/lib/ alongside the CM5
upstream files.
This patch is *mostly* renames of files, along with changing ECMAScript
Module (ESM) syntax into the CommonJS style that ResourceLoader prefers.
We also remove more modern JS syntax (i.e. private class methods) that
we were able to use before because we had a build step with Babel.
This patch should effectively make no user-facing changes, or to the
ResourceLoader modules we offer in Extension:CodeMirror.
Finally, bump version in extension.json to 6, to match the upstream lib,
and add Bhsd as an author :-)
Bug: T368053
Change-Id: Ie258e49f5df8db23a7344ac3c4c9300aaa991042
2024-06-21 03:21:09 +00:00
|
|
|
return this.makeLocalStyle( mwModeConfig.tags.templateArgumentName, state );
|
2023-12-06 18:49:40 +00:00
|
|
|
}
|
Isolate build step to CM6 library and restructure files to work with RL
CodeMirror 6 requires the use of NPM, but we can still bundle all CM
packages into one file, and then everything else (i.e. our code) is
managed by ResourceLoader as per usual. This makes contribution
considerably easier as we no longer need a build step for each change.
CM5 files are now under resources/legacy, and the CM6 files are moved to
the root of the resources/ directory. Only one file,
codemirror.bundle.js, is managed by Rollup, while everything else is RL.
The Rollup output for now is put under resources/lib/ alongside the CM5
upstream files.
This patch is *mostly* renames of files, along with changing ECMAScript
Module (ESM) syntax into the CommonJS style that ResourceLoader prefers.
We also remove more modern JS syntax (i.e. private class methods) that
we were able to use before because we had a build step with Babel.
This patch should effectively make no user-facing changes, or to the
ResourceLoader modules we offer in Extension:CodeMirror.
Finally, bump version in extension.json to 6, to match the upstream lib,
and add Bhsd as an author :-)
Bug: T368053
Change-Id: Ie258e49f5df8db23a7344ac3c4c9300aaa991042
2024-06-21 03:21:09 +00:00
|
|
|
return this.makeLocalStyle( mwModeConfig.tags.template, state );
|
2023-12-06 18:49:40 +00:00
|
|
|
} else if ( stream.eatWhile( /[^|}{[<&~]/ ) ) {
|
Isolate build step to CM6 library and restructure files to work with RL
CodeMirror 6 requires the use of NPM, but we can still bundle all CM
packages into one file, and then everything else (i.e. our code) is
managed by ResourceLoader as per usual. This makes contribution
considerably easier as we no longer need a build step for each change.
CM5 files are now under resources/legacy, and the CM6 files are moved to
the root of the resources/ directory. Only one file,
codemirror.bundle.js, is managed by Rollup, while everything else is RL.
The Rollup output for now is put under resources/lib/ alongside the CM5
upstream files.
This patch is *mostly* renames of files, along with changing ECMAScript
Module (ESM) syntax into the CommonJS style that ResourceLoader prefers.
We also remove more modern JS syntax (i.e. private class methods) that
we were able to use before because we had a build step with Babel.
This patch should effectively make no user-facing changes, or to the
ResourceLoader modules we offer in Extension:CodeMirror.
Finally, bump version in extension.json to 6, to match the upstream lib,
and add Bhsd as an author :-)
Bug: T368053
Change-Id: Ie258e49f5df8db23a7344ac3c4c9300aaa991042
2024-06-21 03:21:09 +00:00
|
|
|
return this.makeLocalStyle( mwModeConfig.tags.template, state );
|
2023-12-06 18:49:40 +00:00
|
|
|
} else if ( stream.eat( '|' ) ) {
|
|
|
|
state.tokenize = this.eatTemplateArgument( true );
|
Isolate build step to CM6 library and restructure files to work with RL
CodeMirror 6 requires the use of NPM, but we can still bundle all CM
packages into one file, and then everything else (i.e. our code) is
managed by ResourceLoader as per usual. This makes contribution
considerably easier as we no longer need a build step for each change.
CM5 files are now under resources/legacy, and the CM6 files are moved to
the root of the resources/ directory. Only one file,
codemirror.bundle.js, is managed by Rollup, while everything else is RL.
The Rollup output for now is put under resources/lib/ alongside the CM5
upstream files.
This patch is *mostly* renames of files, along with changing ECMAScript
Module (ESM) syntax into the CommonJS style that ResourceLoader prefers.
We also remove more modern JS syntax (i.e. private class methods) that
we were able to use before because we had a build step with Babel.
This patch should effectively make no user-facing changes, or to the
ResourceLoader modules we offer in Extension:CodeMirror.
Finally, bump version in extension.json to 6, to match the upstream lib,
and add Bhsd as an author :-)
Bug: T368053
Change-Id: Ie258e49f5df8db23a7344ac3c4c9300aaa991042
2024-06-21 03:21:09 +00:00
|
|
|
return this.makeLocalStyle( mwModeConfig.tags.templateDelimiter, state );
|
2023-12-06 18:49:40 +00:00
|
|
|
} else if ( stream.match( '}}' ) ) {
|
|
|
|
state.tokenize = state.stack.pop();
|
Isolate build step to CM6 library and restructure files to work with RL
CodeMirror 6 requires the use of NPM, but we can still bundle all CM
packages into one file, and then everything else (i.e. our code) is
managed by ResourceLoader as per usual. This makes contribution
considerably easier as we no longer need a build step for each change.
CM5 files are now under resources/legacy, and the CM6 files are moved to
the root of the resources/ directory. Only one file,
codemirror.bundle.js, is managed by Rollup, while everything else is RL.
The Rollup output for now is put under resources/lib/ alongside the CM5
upstream files.
This patch is *mostly* renames of files, along with changing ECMAScript
Module (ESM) syntax into the CommonJS style that ResourceLoader prefers.
We also remove more modern JS syntax (i.e. private class methods) that
we were able to use before because we had a build step with Babel.
This patch should effectively make no user-facing changes, or to the
ResourceLoader modules we offer in Extension:CodeMirror.
Finally, bump version in extension.json to 6, to match the upstream lib,
and add Bhsd as an author :-)
Bug: T368053
Change-Id: Ie258e49f5df8db23a7344ac3c4c9300aaa991042
2024-06-21 03:21:09 +00:00
|
|
|
return this.makeLocalStyle( mwModeConfig.tags.templateBracket, state, 'nTemplate' );
|
2023-12-06 18:49:40 +00:00
|
|
|
}
|
Isolate build step to CM6 library and restructure files to work with RL
CodeMirror 6 requires the use of NPM, but we can still bundle all CM
packages into one file, and then everything else (i.e. our code) is
managed by ResourceLoader as per usual. This makes contribution
considerably easier as we no longer need a build step for each change.
CM5 files are now under resources/legacy, and the CM6 files are moved to
the root of the resources/ directory. Only one file,
codemirror.bundle.js, is managed by Rollup, while everything else is RL.
The Rollup output for now is put under resources/lib/ alongside the CM5
upstream files.
This patch is *mostly* renames of files, along with changing ECMAScript
Module (ESM) syntax into the CommonJS style that ResourceLoader prefers.
We also remove more modern JS syntax (i.e. private class methods) that
we were able to use before because we had a build step with Babel.
This patch should effectively make no user-facing changes, or to the
ResourceLoader modules we offer in Extension:CodeMirror.
Finally, bump version in extension.json to 6, to match the upstream lib,
and add Bhsd as an author :-)
Bug: T368053
Change-Id: Ie258e49f5df8db23a7344ac3c4c9300aaa991042
2024-06-21 03:21:09 +00:00
|
|
|
return this.eatWikiText( mwModeConfig.tags.template )( stream, state );
|
2023-12-06 18:49:40 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
eatExternalLinkProtocol( chars ) {
|
|
|
|
return ( stream, state ) => {
|
|
|
|
while ( chars > 0 ) {
|
|
|
|
chars--;
|
|
|
|
stream.next();
|
|
|
|
}
|
|
|
|
if ( stream.eol() ) {
|
|
|
|
state.nLink--;
|
|
|
|
// @todo error message
|
|
|
|
state.tokenize = state.stack.pop();
|
|
|
|
} else {
|
|
|
|
state.tokenize = this.inExternalLink.bind( this );
|
|
|
|
}
|
Isolate build step to CM6 library and restructure files to work with RL
CodeMirror 6 requires the use of NPM, but we can still bundle all CM
packages into one file, and then everything else (i.e. our code) is
managed by ResourceLoader as per usual. This makes contribution
considerably easier as we no longer need a build step for each change.
CM5 files are now under resources/legacy, and the CM6 files are moved to
the root of the resources/ directory. Only one file,
codemirror.bundle.js, is managed by Rollup, while everything else is RL.
The Rollup output for now is put under resources/lib/ alongside the CM5
upstream files.
This patch is *mostly* renames of files, along with changing ECMAScript
Module (ESM) syntax into the CommonJS style that ResourceLoader prefers.
We also remove more modern JS syntax (i.e. private class methods) that
we were able to use before because we had a build step with Babel.
This patch should effectively make no user-facing changes, or to the
ResourceLoader modules we offer in Extension:CodeMirror.
Finally, bump version in extension.json to 6, to match the upstream lib,
and add Bhsd as an author :-)
Bug: T368053
Change-Id: Ie258e49f5df8db23a7344ac3c4c9300aaa991042
2024-06-21 03:21:09 +00:00
|
|
|
return this.makeLocalStyle( mwModeConfig.tags.extLinkProtocol, state );
|
2023-12-06 18:49:40 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
inExternalLink( stream, state ) {
|
|
|
|
if ( stream.sol() ) {
|
|
|
|
state.nLink--;
|
|
|
|
// @todo error message
|
|
|
|
state.tokenize = state.stack.pop();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if ( stream.match( /^[\s\u00a0]*\]/ ) ) {
|
|
|
|
state.tokenize = state.stack.pop();
|
Isolate build step to CM6 library and restructure files to work with RL
CodeMirror 6 requires the use of NPM, but we can still bundle all CM
packages into one file, and then everything else (i.e. our code) is
managed by ResourceLoader as per usual. This makes contribution
considerably easier as we no longer need a build step for each change.
CM5 files are now under resources/legacy, and the CM6 files are moved to
the root of the resources/ directory. Only one file,
codemirror.bundle.js, is managed by Rollup, while everything else is RL.
The Rollup output for now is put under resources/lib/ alongside the CM5
upstream files.
This patch is *mostly* renames of files, along with changing ECMAScript
Module (ESM) syntax into the CommonJS style that ResourceLoader prefers.
We also remove more modern JS syntax (i.e. private class methods) that
we were able to use before because we had a build step with Babel.
This patch should effectively make no user-facing changes, or to the
ResourceLoader modules we offer in Extension:CodeMirror.
Finally, bump version in extension.json to 6, to match the upstream lib,
and add Bhsd as an author :-)
Bug: T368053
Change-Id: Ie258e49f5df8db23a7344ac3c4c9300aaa991042
2024-06-21 03:21:09 +00:00
|
|
|
return this.makeLocalStyle( mwModeConfig.tags.extLinkBracket, state, 'nLink' );
|
2023-12-06 18:49:40 +00:00
|
|
|
}
|
|
|
|
if ( stream.eatSpace() ) {
|
|
|
|
state.tokenize = this.inExternalLinkText.bind( this );
|
|
|
|
return this.makeStyle( '', state );
|
|
|
|
}
|
|
|
|
if ( stream.match( /^[^\s\u00a0\]{&~']+/ ) || stream.eatSpace() ) {
|
|
|
|
if ( stream.peek() === '\'' ) {
|
|
|
|
if ( stream.match( '\'\'', false ) ) {
|
|
|
|
state.tokenize = this.inExternalLinkText.bind( this );
|
|
|
|
} else {
|
|
|
|
stream.next();
|
|
|
|
}
|
|
|
|
}
|
Isolate build step to CM6 library and restructure files to work with RL
CodeMirror 6 requires the use of NPM, but we can still bundle all CM
packages into one file, and then everything else (i.e. our code) is
managed by ResourceLoader as per usual. This makes contribution
considerably easier as we no longer need a build step for each change.
CM5 files are now under resources/legacy, and the CM6 files are moved to
the root of the resources/ directory. Only one file,
codemirror.bundle.js, is managed by Rollup, while everything else is RL.
The Rollup output for now is put under resources/lib/ alongside the CM5
upstream files.
This patch is *mostly* renames of files, along with changing ECMAScript
Module (ESM) syntax into the CommonJS style that ResourceLoader prefers.
We also remove more modern JS syntax (i.e. private class methods) that
we were able to use before because we had a build step with Babel.
This patch should effectively make no user-facing changes, or to the
ResourceLoader modules we offer in Extension:CodeMirror.
Finally, bump version in extension.json to 6, to match the upstream lib,
and add Bhsd as an author :-)
Bug: T368053
Change-Id: Ie258e49f5df8db23a7344ac3c4c9300aaa991042
2024-06-21 03:21:09 +00:00
|
|
|
return this.makeStyle( mwModeConfig.tags.extLink, state );
|
2023-12-06 18:49:40 +00:00
|
|
|
}
|
Isolate build step to CM6 library and restructure files to work with RL
CodeMirror 6 requires the use of NPM, but we can still bundle all CM
packages into one file, and then everything else (i.e. our code) is
managed by ResourceLoader as per usual. This makes contribution
considerably easier as we no longer need a build step for each change.
CM5 files are now under resources/legacy, and the CM6 files are moved to
the root of the resources/ directory. Only one file,
codemirror.bundle.js, is managed by Rollup, while everything else is RL.
The Rollup output for now is put under resources/lib/ alongside the CM5
upstream files.
This patch is *mostly* renames of files, along with changing ECMAScript
Module (ESM) syntax into the CommonJS style that ResourceLoader prefers.
We also remove more modern JS syntax (i.e. private class methods) that
we were able to use before because we had a build step with Babel.
This patch should effectively make no user-facing changes, or to the
ResourceLoader modules we offer in Extension:CodeMirror.
Finally, bump version in extension.json to 6, to match the upstream lib,
and add Bhsd as an author :-)
Bug: T368053
Change-Id: Ie258e49f5df8db23a7344ac3c4c9300aaa991042
2024-06-21 03:21:09 +00:00
|
|
|
return this.eatWikiText( mwModeConfig.tags.extLink )( stream, state );
|
2023-12-06 18:49:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
inExternalLinkText( stream, state ) {
|
|
|
|
if ( stream.sol() ) {
|
|
|
|
state.nLink--;
|
|
|
|
// @todo error message
|
|
|
|
state.tokenize = state.stack.pop();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if ( stream.eat( ']' ) ) {
|
|
|
|
state.tokenize = state.stack.pop();
|
Isolate build step to CM6 library and restructure files to work with RL
CodeMirror 6 requires the use of NPM, but we can still bundle all CM
packages into one file, and then everything else (i.e. our code) is
managed by ResourceLoader as per usual. This makes contribution
considerably easier as we no longer need a build step for each change.
CM5 files are now under resources/legacy, and the CM6 files are moved to
the root of the resources/ directory. Only one file,
codemirror.bundle.js, is managed by Rollup, while everything else is RL.
The Rollup output for now is put under resources/lib/ alongside the CM5
upstream files.
This patch is *mostly* renames of files, along with changing ECMAScript
Module (ESM) syntax into the CommonJS style that ResourceLoader prefers.
We also remove more modern JS syntax (i.e. private class methods) that
we were able to use before because we had a build step with Babel.
This patch should effectively make no user-facing changes, or to the
ResourceLoader modules we offer in Extension:CodeMirror.
Finally, bump version in extension.json to 6, to match the upstream lib,
and add Bhsd as an author :-)
Bug: T368053
Change-Id: Ie258e49f5df8db23a7344ac3c4c9300aaa991042
2024-06-21 03:21:09 +00:00
|
|
|
return this.makeLocalStyle( mwModeConfig.tags.extLinkBracket, state, 'nLink' );
|
2023-12-06 18:49:40 +00:00
|
|
|
}
|
|
|
|
if ( stream.match( /^[^'\]{&~<]+/ ) ) {
|
Isolate build step to CM6 library and restructure files to work with RL
CodeMirror 6 requires the use of NPM, but we can still bundle all CM
packages into one file, and then everything else (i.e. our code) is
managed by ResourceLoader as per usual. This makes contribution
considerably easier as we no longer need a build step for each change.
CM5 files are now under resources/legacy, and the CM6 files are moved to
the root of the resources/ directory. Only one file,
codemirror.bundle.js, is managed by Rollup, while everything else is RL.
The Rollup output for now is put under resources/lib/ alongside the CM5
upstream files.
This patch is *mostly* renames of files, along with changing ECMAScript
Module (ESM) syntax into the CommonJS style that ResourceLoader prefers.
We also remove more modern JS syntax (i.e. private class methods) that
we were able to use before because we had a build step with Babel.
This patch should effectively make no user-facing changes, or to the
ResourceLoader modules we offer in Extension:CodeMirror.
Finally, bump version in extension.json to 6, to match the upstream lib,
and add Bhsd as an author :-)
Bug: T368053
Change-Id: Ie258e49f5df8db23a7344ac3c4c9300aaa991042
2024-06-21 03:21:09 +00:00
|
|
|
return this.makeStyle( mwModeConfig.tags.extLinkText, state );
|
2023-12-06 18:49:40 +00:00
|
|
|
}
|
Isolate build step to CM6 library and restructure files to work with RL
CodeMirror 6 requires the use of NPM, but we can still bundle all CM
packages into one file, and then everything else (i.e. our code) is
managed by ResourceLoader as per usual. This makes contribution
considerably easier as we no longer need a build step for each change.
CM5 files are now under resources/legacy, and the CM6 files are moved to
the root of the resources/ directory. Only one file,
codemirror.bundle.js, is managed by Rollup, while everything else is RL.
The Rollup output for now is put under resources/lib/ alongside the CM5
upstream files.
This patch is *mostly* renames of files, along with changing ECMAScript
Module (ESM) syntax into the CommonJS style that ResourceLoader prefers.
We also remove more modern JS syntax (i.e. private class methods) that
we were able to use before because we had a build step with Babel.
This patch should effectively make no user-facing changes, or to the
ResourceLoader modules we offer in Extension:CodeMirror.
Finally, bump version in extension.json to 6, to match the upstream lib,
and add Bhsd as an author :-)
Bug: T368053
Change-Id: Ie258e49f5df8db23a7344ac3c4c9300aaa991042
2024-06-21 03:21:09 +00:00
|
|
|
return this.eatWikiText( mwModeConfig.tags.extLinkText )( stream, state );
|
2023-12-06 18:49:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
inLink( stream, state ) {
|
|
|
|
if ( stream.sol() ) {
|
|
|
|
state.nLink--;
|
|
|
|
// @todo error message
|
|
|
|
state.tokenize = state.stack.pop();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if ( stream.match( /^[\s\u00a0]*#[\s\u00a0]*/ ) ) {
|
|
|
|
state.tokenize = this.inLinkToSection.bind( this );
|
Isolate build step to CM6 library and restructure files to work with RL
CodeMirror 6 requires the use of NPM, but we can still bundle all CM
packages into one file, and then everything else (i.e. our code) is
managed by ResourceLoader as per usual. This makes contribution
considerably easier as we no longer need a build step for each change.
CM5 files are now under resources/legacy, and the CM6 files are moved to
the root of the resources/ directory. Only one file,
codemirror.bundle.js, is managed by Rollup, while everything else is RL.
The Rollup output for now is put under resources/lib/ alongside the CM5
upstream files.
This patch is *mostly* renames of files, along with changing ECMAScript
Module (ESM) syntax into the CommonJS style that ResourceLoader prefers.
We also remove more modern JS syntax (i.e. private class methods) that
we were able to use before because we had a build step with Babel.
This patch should effectively make no user-facing changes, or to the
ResourceLoader modules we offer in Extension:CodeMirror.
Finally, bump version in extension.json to 6, to match the upstream lib,
and add Bhsd as an author :-)
Bug: T368053
Change-Id: Ie258e49f5df8db23a7344ac3c4c9300aaa991042
2024-06-21 03:21:09 +00:00
|
|
|
return this.makeLocalStyle( mwModeConfig.tags.link, state );
|
2023-12-06 18:49:40 +00:00
|
|
|
}
|
|
|
|
if ( stream.match( /^[\s\u00a0]*\|[\s\u00a0]*/ ) ) {
|
|
|
|
state.tokenize = this.eatLinkText();
|
Isolate build step to CM6 library and restructure files to work with RL
CodeMirror 6 requires the use of NPM, but we can still bundle all CM
packages into one file, and then everything else (i.e. our code) is
managed by ResourceLoader as per usual. This makes contribution
considerably easier as we no longer need a build step for each change.
CM5 files are now under resources/legacy, and the CM6 files are moved to
the root of the resources/ directory. Only one file,
codemirror.bundle.js, is managed by Rollup, while everything else is RL.
The Rollup output for now is put under resources/lib/ alongside the CM5
upstream files.
This patch is *mostly* renames of files, along with changing ECMAScript
Module (ESM) syntax into the CommonJS style that ResourceLoader prefers.
We also remove more modern JS syntax (i.e. private class methods) that
we were able to use before because we had a build step with Babel.
This patch should effectively make no user-facing changes, or to the
ResourceLoader modules we offer in Extension:CodeMirror.
Finally, bump version in extension.json to 6, to match the upstream lib,
and add Bhsd as an author :-)
Bug: T368053
Change-Id: Ie258e49f5df8db23a7344ac3c4c9300aaa991042
2024-06-21 03:21:09 +00:00
|
|
|
return this.makeLocalStyle( mwModeConfig.tags.linkDelimiter, state );
|
2023-12-06 18:49:40 +00:00
|
|
|
}
|
|
|
|
if ( stream.match( /^[\s\u00a0]*\]\]/ ) ) {
|
|
|
|
state.tokenize = state.stack.pop();
|
Isolate build step to CM6 library and restructure files to work with RL
CodeMirror 6 requires the use of NPM, but we can still bundle all CM
packages into one file, and then everything else (i.e. our code) is
managed by ResourceLoader as per usual. This makes contribution
considerably easier as we no longer need a build step for each change.
CM5 files are now under resources/legacy, and the CM6 files are moved to
the root of the resources/ directory. Only one file,
codemirror.bundle.js, is managed by Rollup, while everything else is RL.
The Rollup output for now is put under resources/lib/ alongside the CM5
upstream files.
This patch is *mostly* renames of files, along with changing ECMAScript
Module (ESM) syntax into the CommonJS style that ResourceLoader prefers.
We also remove more modern JS syntax (i.e. private class methods) that
we were able to use before because we had a build step with Babel.
This patch should effectively make no user-facing changes, or to the
ResourceLoader modules we offer in Extension:CodeMirror.
Finally, bump version in extension.json to 6, to match the upstream lib,
and add Bhsd as an author :-)
Bug: T368053
Change-Id: Ie258e49f5df8db23a7344ac3c4c9300aaa991042
2024-06-21 03:21:09 +00:00
|
|
|
return this.makeLocalStyle( mwModeConfig.tags.linkBracket, state, 'nLink' );
|
2023-12-06 18:49:40 +00:00
|
|
|
}
|
|
|
|
if ( stream.match( /^[\s\u00a0]*[^\s\u00a0#|\]&~{]+/ ) || stream.eatSpace() ) {
|
|
|
|
return this.makeStyle(
|
Isolate build step to CM6 library and restructure files to work with RL
CodeMirror 6 requires the use of NPM, but we can still bundle all CM
packages into one file, and then everything else (i.e. our code) is
managed by ResourceLoader as per usual. This makes contribution
considerably easier as we no longer need a build step for each change.
CM5 files are now under resources/legacy, and the CM6 files are moved to
the root of the resources/ directory. Only one file,
codemirror.bundle.js, is managed by Rollup, while everything else is RL.
The Rollup output for now is put under resources/lib/ alongside the CM5
upstream files.
This patch is *mostly* renames of files, along with changing ECMAScript
Module (ESM) syntax into the CommonJS style that ResourceLoader prefers.
We also remove more modern JS syntax (i.e. private class methods) that
we were able to use before because we had a build step with Babel.
This patch should effectively make no user-facing changes, or to the
ResourceLoader modules we offer in Extension:CodeMirror.
Finally, bump version in extension.json to 6, to match the upstream lib,
and add Bhsd as an author :-)
Bug: T368053
Change-Id: Ie258e49f5df8db23a7344ac3c4c9300aaa991042
2024-06-21 03:21:09 +00:00
|
|
|
`${ mwModeConfig.tags.linkPageName } ${ mwModeConfig.tags.pageName }`,
|
2023-12-06 18:49:40 +00:00
|
|
|
state
|
|
|
|
);
|
|
|
|
}
|
|
|
|
return this.eatWikiText(
|
Isolate build step to CM6 library and restructure files to work with RL
CodeMirror 6 requires the use of NPM, but we can still bundle all CM
packages into one file, and then everything else (i.e. our code) is
managed by ResourceLoader as per usual. This makes contribution
considerably easier as we no longer need a build step for each change.
CM5 files are now under resources/legacy, and the CM6 files are moved to
the root of the resources/ directory. Only one file,
codemirror.bundle.js, is managed by Rollup, while everything else is RL.
The Rollup output for now is put under resources/lib/ alongside the CM5
upstream files.
This patch is *mostly* renames of files, along with changing ECMAScript
Module (ESM) syntax into the CommonJS style that ResourceLoader prefers.
We also remove more modern JS syntax (i.e. private class methods) that
we were able to use before because we had a build step with Babel.
This patch should effectively make no user-facing changes, or to the
ResourceLoader modules we offer in Extension:CodeMirror.
Finally, bump version in extension.json to 6, to match the upstream lib,
and add Bhsd as an author :-)
Bug: T368053
Change-Id: Ie258e49f5df8db23a7344ac3c4c9300aaa991042
2024-06-21 03:21:09 +00:00
|
|
|
`${ mwModeConfig.tags.linkPageName } ${ mwModeConfig.tags.pageName }`
|
2023-12-06 18:49:40 +00:00
|
|
|
)( stream, state );
|
|
|
|
}
|
|
|
|
|
|
|
|
inLinkToSection( stream, state ) {
|
|
|
|
if ( stream.sol() ) {
|
|
|
|
// @todo error message
|
|
|
|
state.nLink--;
|
|
|
|
state.tokenize = state.stack.pop();
|
|
|
|
return;
|
|
|
|
}
|
2024-01-04 04:01:27 +00:00
|
|
|
// FIXME '{{' breaks links, example: [[z{{page]]
|
2024-01-03 21:19:06 +00:00
|
|
|
if ( stream.match( /^[^|\]&~{}]+/ ) ) {
|
Isolate build step to CM6 library and restructure files to work with RL
CodeMirror 6 requires the use of NPM, but we can still bundle all CM
packages into one file, and then everything else (i.e. our code) is
managed by ResourceLoader as per usual. This makes contribution
considerably easier as we no longer need a build step for each change.
CM5 files are now under resources/legacy, and the CM6 files are moved to
the root of the resources/ directory. Only one file,
codemirror.bundle.js, is managed by Rollup, while everything else is RL.
The Rollup output for now is put under resources/lib/ alongside the CM5
upstream files.
This patch is *mostly* renames of files, along with changing ECMAScript
Module (ESM) syntax into the CommonJS style that ResourceLoader prefers.
We also remove more modern JS syntax (i.e. private class methods) that
we were able to use before because we had a build step with Babel.
This patch should effectively make no user-facing changes, or to the
ResourceLoader modules we offer in Extension:CodeMirror.
Finally, bump version in extension.json to 6, to match the upstream lib,
and add Bhsd as an author :-)
Bug: T368053
Change-Id: Ie258e49f5df8db23a7344ac3c4c9300aaa991042
2024-06-21 03:21:09 +00:00
|
|
|
return this.makeLocalStyle( mwModeConfig.tags.linkToSection, state );
|
2023-12-06 18:49:40 +00:00
|
|
|
}
|
|
|
|
if ( stream.eat( '|' ) ) {
|
|
|
|
state.tokenize = this.eatLinkText();
|
Isolate build step to CM6 library and restructure files to work with RL
CodeMirror 6 requires the use of NPM, but we can still bundle all CM
packages into one file, and then everything else (i.e. our code) is
managed by ResourceLoader as per usual. This makes contribution
considerably easier as we no longer need a build step for each change.
CM5 files are now under resources/legacy, and the CM6 files are moved to
the root of the resources/ directory. Only one file,
codemirror.bundle.js, is managed by Rollup, while everything else is RL.
The Rollup output for now is put under resources/lib/ alongside the CM5
upstream files.
This patch is *mostly* renames of files, along with changing ECMAScript
Module (ESM) syntax into the CommonJS style that ResourceLoader prefers.
We also remove more modern JS syntax (i.e. private class methods) that
we were able to use before because we had a build step with Babel.
This patch should effectively make no user-facing changes, or to the
ResourceLoader modules we offer in Extension:CodeMirror.
Finally, bump version in extension.json to 6, to match the upstream lib,
and add Bhsd as an author :-)
Bug: T368053
Change-Id: Ie258e49f5df8db23a7344ac3c4c9300aaa991042
2024-06-21 03:21:09 +00:00
|
|
|
return this.makeLocalStyle( mwModeConfig.tags.linkDelimiter, state );
|
2023-12-06 18:49:40 +00:00
|
|
|
}
|
|
|
|
if ( stream.match( ']]' ) ) {
|
|
|
|
state.tokenize = state.stack.pop();
|
Isolate build step to CM6 library and restructure files to work with RL
CodeMirror 6 requires the use of NPM, but we can still bundle all CM
packages into one file, and then everything else (i.e. our code) is
managed by ResourceLoader as per usual. This makes contribution
considerably easier as we no longer need a build step for each change.
CM5 files are now under resources/legacy, and the CM6 files are moved to
the root of the resources/ directory. Only one file,
codemirror.bundle.js, is managed by Rollup, while everything else is RL.
The Rollup output for now is put under resources/lib/ alongside the CM5
upstream files.
This patch is *mostly* renames of files, along with changing ECMAScript
Module (ESM) syntax into the CommonJS style that ResourceLoader prefers.
We also remove more modern JS syntax (i.e. private class methods) that
we were able to use before because we had a build step with Babel.
This patch should effectively make no user-facing changes, or to the
ResourceLoader modules we offer in Extension:CodeMirror.
Finally, bump version in extension.json to 6, to match the upstream lib,
and add Bhsd as an author :-)
Bug: T368053
Change-Id: Ie258e49f5df8db23a7344ac3c4c9300aaa991042
2024-06-21 03:21:09 +00:00
|
|
|
return this.makeLocalStyle( mwModeConfig.tags.linkBracket, state, 'nLink' );
|
2023-12-06 18:49:40 +00:00
|
|
|
}
|
Isolate build step to CM6 library and restructure files to work with RL
CodeMirror 6 requires the use of NPM, but we can still bundle all CM
packages into one file, and then everything else (i.e. our code) is
managed by ResourceLoader as per usual. This makes contribution
considerably easier as we no longer need a build step for each change.
CM5 files are now under resources/legacy, and the CM6 files are moved to
the root of the resources/ directory. Only one file,
codemirror.bundle.js, is managed by Rollup, while everything else is RL.
The Rollup output for now is put under resources/lib/ alongside the CM5
upstream files.
This patch is *mostly* renames of files, along with changing ECMAScript
Module (ESM) syntax into the CommonJS style that ResourceLoader prefers.
We also remove more modern JS syntax (i.e. private class methods) that
we were able to use before because we had a build step with Babel.
This patch should effectively make no user-facing changes, or to the
ResourceLoader modules we offer in Extension:CodeMirror.
Finally, bump version in extension.json to 6, to match the upstream lib,
and add Bhsd as an author :-)
Bug: T368053
Change-Id: Ie258e49f5df8db23a7344ac3c4c9300aaa991042
2024-06-21 03:21:09 +00:00
|
|
|
return this.eatWikiText( mwModeConfig.tags.linkToSection )( stream, state );
|
2023-12-06 18:49:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
eatLinkText() {
|
|
|
|
let linkIsBold, linkIsItalic;
|
|
|
|
return ( stream, state ) => {
|
|
|
|
let tmpstyle;
|
|
|
|
if ( stream.match( ']]' ) ) {
|
|
|
|
state.tokenize = state.stack.pop();
|
Isolate build step to CM6 library and restructure files to work with RL
CodeMirror 6 requires the use of NPM, but we can still bundle all CM
packages into one file, and then everything else (i.e. our code) is
managed by ResourceLoader as per usual. This makes contribution
considerably easier as we no longer need a build step for each change.
CM5 files are now under resources/legacy, and the CM6 files are moved to
the root of the resources/ directory. Only one file,
codemirror.bundle.js, is managed by Rollup, while everything else is RL.
The Rollup output for now is put under resources/lib/ alongside the CM5
upstream files.
This patch is *mostly* renames of files, along with changing ECMAScript
Module (ESM) syntax into the CommonJS style that ResourceLoader prefers.
We also remove more modern JS syntax (i.e. private class methods) that
we were able to use before because we had a build step with Babel.
This patch should effectively make no user-facing changes, or to the
ResourceLoader modules we offer in Extension:CodeMirror.
Finally, bump version in extension.json to 6, to match the upstream lib,
and add Bhsd as an author :-)
Bug: T368053
Change-Id: Ie258e49f5df8db23a7344ac3c4c9300aaa991042
2024-06-21 03:21:09 +00:00
|
|
|
return this.makeLocalStyle( mwModeConfig.tags.linkBracket, state, 'nLink' );
|
2023-12-06 18:49:40 +00:00
|
|
|
}
|
|
|
|
if ( stream.match( '\'\'\'' ) ) {
|
|
|
|
linkIsBold = !linkIsBold;
|
|
|
|
return this.makeLocalStyle(
|
Isolate build step to CM6 library and restructure files to work with RL
CodeMirror 6 requires the use of NPM, but we can still bundle all CM
packages into one file, and then everything else (i.e. our code) is
managed by ResourceLoader as per usual. This makes contribution
considerably easier as we no longer need a build step for each change.
CM5 files are now under resources/legacy, and the CM6 files are moved to
the root of the resources/ directory. Only one file,
codemirror.bundle.js, is managed by Rollup, while everything else is RL.
The Rollup output for now is put under resources/lib/ alongside the CM5
upstream files.
This patch is *mostly* renames of files, along with changing ECMAScript
Module (ESM) syntax into the CommonJS style that ResourceLoader prefers.
We also remove more modern JS syntax (i.e. private class methods) that
we were able to use before because we had a build step with Babel.
This patch should effectively make no user-facing changes, or to the
ResourceLoader modules we offer in Extension:CodeMirror.
Finally, bump version in extension.json to 6, to match the upstream lib,
and add Bhsd as an author :-)
Bug: T368053
Change-Id: Ie258e49f5df8db23a7344ac3c4c9300aaa991042
2024-06-21 03:21:09 +00:00
|
|
|
`${ mwModeConfig.tags.linkText } ${ mwModeConfig.tags.apostrophes }`,
|
2023-12-06 18:49:40 +00:00
|
|
|
state
|
|
|
|
);
|
|
|
|
}
|
|
|
|
if ( stream.match( '\'\'' ) ) {
|
|
|
|
linkIsItalic = !linkIsItalic;
|
|
|
|
return this.makeLocalStyle(
|
Isolate build step to CM6 library and restructure files to work with RL
CodeMirror 6 requires the use of NPM, but we can still bundle all CM
packages into one file, and then everything else (i.e. our code) is
managed by ResourceLoader as per usual. This makes contribution
considerably easier as we no longer need a build step for each change.
CM5 files are now under resources/legacy, and the CM6 files are moved to
the root of the resources/ directory. Only one file,
codemirror.bundle.js, is managed by Rollup, while everything else is RL.
The Rollup output for now is put under resources/lib/ alongside the CM5
upstream files.
This patch is *mostly* renames of files, along with changing ECMAScript
Module (ESM) syntax into the CommonJS style that ResourceLoader prefers.
We also remove more modern JS syntax (i.e. private class methods) that
we were able to use before because we had a build step with Babel.
This patch should effectively make no user-facing changes, or to the
ResourceLoader modules we offer in Extension:CodeMirror.
Finally, bump version in extension.json to 6, to match the upstream lib,
and add Bhsd as an author :-)
Bug: T368053
Change-Id: Ie258e49f5df8db23a7344ac3c4c9300aaa991042
2024-06-21 03:21:09 +00:00
|
|
|
`${ mwModeConfig.tags.linkText } ${ mwModeConfig.tags.apostrophes }`,
|
2023-12-06 18:49:40 +00:00
|
|
|
state
|
|
|
|
);
|
|
|
|
}
|
Isolate build step to CM6 library and restructure files to work with RL
CodeMirror 6 requires the use of NPM, but we can still bundle all CM
packages into one file, and then everything else (i.e. our code) is
managed by ResourceLoader as per usual. This makes contribution
considerably easier as we no longer need a build step for each change.
CM5 files are now under resources/legacy, and the CM6 files are moved to
the root of the resources/ directory. Only one file,
codemirror.bundle.js, is managed by Rollup, while everything else is RL.
The Rollup output for now is put under resources/lib/ alongside the CM5
upstream files.
This patch is *mostly* renames of files, along with changing ECMAScript
Module (ESM) syntax into the CommonJS style that ResourceLoader prefers.
We also remove more modern JS syntax (i.e. private class methods) that
we were able to use before because we had a build step with Babel.
This patch should effectively make no user-facing changes, or to the
ResourceLoader modules we offer in Extension:CodeMirror.
Finally, bump version in extension.json to 6, to match the upstream lib,
and add Bhsd as an author :-)
Bug: T368053
Change-Id: Ie258e49f5df8db23a7344ac3c4c9300aaa991042
2024-06-21 03:21:09 +00:00
|
|
|
tmpstyle = mwModeConfig.tags.linkText;
|
2023-12-06 18:49:40 +00:00
|
|
|
if ( linkIsBold ) {
|
Isolate build step to CM6 library and restructure files to work with RL
CodeMirror 6 requires the use of NPM, but we can still bundle all CM
packages into one file, and then everything else (i.e. our code) is
managed by ResourceLoader as per usual. This makes contribution
considerably easier as we no longer need a build step for each change.
CM5 files are now under resources/legacy, and the CM6 files are moved to
the root of the resources/ directory. Only one file,
codemirror.bundle.js, is managed by Rollup, while everything else is RL.
The Rollup output for now is put under resources/lib/ alongside the CM5
upstream files.
This patch is *mostly* renames of files, along with changing ECMAScript
Module (ESM) syntax into the CommonJS style that ResourceLoader prefers.
We also remove more modern JS syntax (i.e. private class methods) that
we were able to use before because we had a build step with Babel.
This patch should effectively make no user-facing changes, or to the
ResourceLoader modules we offer in Extension:CodeMirror.
Finally, bump version in extension.json to 6, to match the upstream lib,
and add Bhsd as an author :-)
Bug: T368053
Change-Id: Ie258e49f5df8db23a7344ac3c4c9300aaa991042
2024-06-21 03:21:09 +00:00
|
|
|
tmpstyle += ' ' + mwModeConfig.tags.strong;
|
2023-12-06 18:49:40 +00:00
|
|
|
}
|
|
|
|
if ( linkIsItalic ) {
|
Isolate build step to CM6 library and restructure files to work with RL
CodeMirror 6 requires the use of NPM, but we can still bundle all CM
packages into one file, and then everything else (i.e. our code) is
managed by ResourceLoader as per usual. This makes contribution
considerably easier as we no longer need a build step for each change.
CM5 files are now under resources/legacy, and the CM6 files are moved to
the root of the resources/ directory. Only one file,
codemirror.bundle.js, is managed by Rollup, while everything else is RL.
The Rollup output for now is put under resources/lib/ alongside the CM5
upstream files.
This patch is *mostly* renames of files, along with changing ECMAScript
Module (ESM) syntax into the CommonJS style that ResourceLoader prefers.
We also remove more modern JS syntax (i.e. private class methods) that
we were able to use before because we had a build step with Babel.
This patch should effectively make no user-facing changes, or to the
ResourceLoader modules we offer in Extension:CodeMirror.
Finally, bump version in extension.json to 6, to match the upstream lib,
and add Bhsd as an author :-)
Bug: T368053
Change-Id: Ie258e49f5df8db23a7344ac3c4c9300aaa991042
2024-06-21 03:21:09 +00:00
|
|
|
tmpstyle += ' ' + mwModeConfig.tags.em;
|
2023-12-06 18:49:40 +00:00
|
|
|
}
|
|
|
|
if ( stream.match( /^[^'\]{&~<]+/ ) ) {
|
|
|
|
return this.makeStyle( tmpstyle, state );
|
|
|
|
}
|
2024-01-03 06:05:35 +00:00
|
|
|
return this.eatWikiText( tmpstyle )( stream, state );
|
2023-12-06 18:49:40 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
eatTagName( chars, isCloseTag, isHtmlTag ) {
|
|
|
|
return ( stream, state ) => {
|
|
|
|
let name = '';
|
|
|
|
while ( chars > 0 ) {
|
|
|
|
chars--;
|
|
|
|
name = name + stream.next();
|
|
|
|
}
|
|
|
|
stream.eatSpace();
|
2024-01-04 04:01:27 +00:00
|
|
|
name = name.toLowerCase();
|
2023-12-06 18:49:40 +00:00
|
|
|
|
|
|
|
if ( isHtmlTag ) {
|
Isolate build step to CM6 library and restructure files to work with RL
CodeMirror 6 requires the use of NPM, but we can still bundle all CM
packages into one file, and then everything else (i.e. our code) is
managed by ResourceLoader as per usual. This makes contribution
considerably easier as we no longer need a build step for each change.
CM5 files are now under resources/legacy, and the CM6 files are moved to
the root of the resources/ directory. Only one file,
codemirror.bundle.js, is managed by Rollup, while everything else is RL.
The Rollup output for now is put under resources/lib/ alongside the CM5
upstream files.
This patch is *mostly* renames of files, along with changing ECMAScript
Module (ESM) syntax into the CommonJS style that ResourceLoader prefers.
We also remove more modern JS syntax (i.e. private class methods) that
we were able to use before because we had a build step with Babel.
This patch should effectively make no user-facing changes, or to the
ResourceLoader modules we offer in Extension:CodeMirror.
Finally, bump version in extension.json to 6, to match the upstream lib,
and add Bhsd as an author :-)
Bug: T368053
Change-Id: Ie258e49f5df8db23a7344ac3c4c9300aaa991042
2024-06-21 03:21:09 +00:00
|
|
|
if ( isCloseTag && !mwModeConfig.implicitlyClosedHtmlTags[ name ] ) {
|
|
|
|
state.tokenize = this.eatChar( '>', mwModeConfig.tags.htmlTagBracket );
|
2023-12-06 18:49:40 +00:00
|
|
|
} else {
|
|
|
|
state.tokenize = this.eatHtmlTagAttribute( name );
|
|
|
|
}
|
Isolate build step to CM6 library and restructure files to work with RL
CodeMirror 6 requires the use of NPM, but we can still bundle all CM
packages into one file, and then everything else (i.e. our code) is
managed by ResourceLoader as per usual. This makes contribution
considerably easier as we no longer need a build step for each change.
CM5 files are now under resources/legacy, and the CM6 files are moved to
the root of the resources/ directory. Only one file,
codemirror.bundle.js, is managed by Rollup, while everything else is RL.
The Rollup output for now is put under resources/lib/ alongside the CM5
upstream files.
This patch is *mostly* renames of files, along with changing ECMAScript
Module (ESM) syntax into the CommonJS style that ResourceLoader prefers.
We also remove more modern JS syntax (i.e. private class methods) that
we were able to use before because we had a build step with Babel.
This patch should effectively make no user-facing changes, or to the
ResourceLoader modules we offer in Extension:CodeMirror.
Finally, bump version in extension.json to 6, to match the upstream lib,
and add Bhsd as an author :-)
Bug: T368053
Change-Id: Ie258e49f5df8db23a7344ac3c4c9300aaa991042
2024-06-21 03:21:09 +00:00
|
|
|
return this.makeLocalStyle( mwModeConfig.tags.htmlTagName, state );
|
2024-01-03 21:19:06 +00:00
|
|
|
}
|
|
|
|
// it is the extension tag
|
2023-12-06 18:49:40 +00:00
|
|
|
if ( isCloseTag ) {
|
|
|
|
state.tokenize = this.eatChar(
|
|
|
|
'>',
|
Isolate build step to CM6 library and restructure files to work with RL
CodeMirror 6 requires the use of NPM, but we can still bundle all CM
packages into one file, and then everything else (i.e. our code) is
managed by ResourceLoader as per usual. This makes contribution
considerably easier as we no longer need a build step for each change.
CM5 files are now under resources/legacy, and the CM6 files are moved to
the root of the resources/ directory. Only one file,
codemirror.bundle.js, is managed by Rollup, while everything else is RL.
The Rollup output for now is put under resources/lib/ alongside the CM5
upstream files.
This patch is *mostly* renames of files, along with changing ECMAScript
Module (ESM) syntax into the CommonJS style that ResourceLoader prefers.
We also remove more modern JS syntax (i.e. private class methods) that
we were able to use before because we had a build step with Babel.
This patch should effectively make no user-facing changes, or to the
ResourceLoader modules we offer in Extension:CodeMirror.
Finally, bump version in extension.json to 6, to match the upstream lib,
and add Bhsd as an author :-)
Bug: T368053
Change-Id: Ie258e49f5df8db23a7344ac3c4c9300aaa991042
2024-06-21 03:21:09 +00:00
|
|
|
`${ mwModeConfig.tags.extTagBracket } mw-ext-${ name }`
|
2023-12-06 18:49:40 +00:00
|
|
|
);
|
|
|
|
} else {
|
|
|
|
state.tokenize = this.eatExtTagAttribute( name );
|
|
|
|
}
|
Isolate build step to CM6 library and restructure files to work with RL
CodeMirror 6 requires the use of NPM, but we can still bundle all CM
packages into one file, and then everything else (i.e. our code) is
managed by ResourceLoader as per usual. This makes contribution
considerably easier as we no longer need a build step for each change.
CM5 files are now under resources/legacy, and the CM6 files are moved to
the root of the resources/ directory. Only one file,
codemirror.bundle.js, is managed by Rollup, while everything else is RL.
The Rollup output for now is put under resources/lib/ alongside the CM5
upstream files.
This patch is *mostly* renames of files, along with changing ECMAScript
Module (ESM) syntax into the CommonJS style that ResourceLoader prefers.
We also remove more modern JS syntax (i.e. private class methods) that
we were able to use before because we had a build step with Babel.
This patch should effectively make no user-facing changes, or to the
ResourceLoader modules we offer in Extension:CodeMirror.
Finally, bump version in extension.json to 6, to match the upstream lib,
and add Bhsd as an author :-)
Bug: T368053
Change-Id: Ie258e49f5df8db23a7344ac3c4c9300aaa991042
2024-06-21 03:21:09 +00:00
|
|
|
return this.makeLocalStyle( `${ mwModeConfig.tags.extTagName } mw-ext-${ name }`, state );
|
2023-12-06 18:49:40 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
eatHtmlTagAttribute( name ) {
|
|
|
|
return ( stream, state ) => {
|
2024-06-14 11:51:53 +00:00
|
|
|
|
2023-12-06 18:49:40 +00:00
|
|
|
if ( stream.match( /^(?:"[^<">]*"|'[^<'>]*'|[^>/<{&~])+/ ) ) {
|
Isolate build step to CM6 library and restructure files to work with RL
CodeMirror 6 requires the use of NPM, but we can still bundle all CM
packages into one file, and then everything else (i.e. our code) is
managed by ResourceLoader as per usual. This makes contribution
considerably easier as we no longer need a build step for each change.
CM5 files are now under resources/legacy, and the CM6 files are moved to
the root of the resources/ directory. Only one file,
codemirror.bundle.js, is managed by Rollup, while everything else is RL.
The Rollup output for now is put under resources/lib/ alongside the CM5
upstream files.
This patch is *mostly* renames of files, along with changing ECMAScript
Module (ESM) syntax into the CommonJS style that ResourceLoader prefers.
We also remove more modern JS syntax (i.e. private class methods) that
we were able to use before because we had a build step with Babel.
This patch should effectively make no user-facing changes, or to the
ResourceLoader modules we offer in Extension:CodeMirror.
Finally, bump version in extension.json to 6, to match the upstream lib,
and add Bhsd as an author :-)
Bug: T368053
Change-Id: Ie258e49f5df8db23a7344ac3c4c9300aaa991042
2024-06-21 03:21:09 +00:00
|
|
|
return this.makeLocalStyle( mwModeConfig.tags.htmlTagAttribute, state );
|
2023-12-06 18:49:40 +00:00
|
|
|
}
|
|
|
|
if ( stream.eat( '>' ) ) {
|
Isolate build step to CM6 library and restructure files to work with RL
CodeMirror 6 requires the use of NPM, but we can still bundle all CM
packages into one file, and then everything else (i.e. our code) is
managed by ResourceLoader as per usual. This makes contribution
considerably easier as we no longer need a build step for each change.
CM5 files are now under resources/legacy, and the CM6 files are moved to
the root of the resources/ directory. Only one file,
codemirror.bundle.js, is managed by Rollup, while everything else is RL.
The Rollup output for now is put under resources/lib/ alongside the CM5
upstream files.
This patch is *mostly* renames of files, along with changing ECMAScript
Module (ESM) syntax into the CommonJS style that ResourceLoader prefers.
We also remove more modern JS syntax (i.e. private class methods) that
we were able to use before because we had a build step with Babel.
This patch should effectively make no user-facing changes, or to the
ResourceLoader modules we offer in Extension:CodeMirror.
Finally, bump version in extension.json to 6, to match the upstream lib,
and add Bhsd as an author :-)
Bug: T368053
Change-Id: Ie258e49f5df8db23a7344ac3c4c9300aaa991042
2024-06-21 03:21:09 +00:00
|
|
|
if ( !( name in mwModeConfig.implicitlyClosedHtmlTags ) ) {
|
2023-12-06 18:49:40 +00:00
|
|
|
state.inHtmlTag.push( name );
|
|
|
|
}
|
|
|
|
state.tokenize = state.stack.pop();
|
Isolate build step to CM6 library and restructure files to work with RL
CodeMirror 6 requires the use of NPM, but we can still bundle all CM
packages into one file, and then everything else (i.e. our code) is
managed by ResourceLoader as per usual. This makes contribution
considerably easier as we no longer need a build step for each change.
CM5 files are now under resources/legacy, and the CM6 files are moved to
the root of the resources/ directory. Only one file,
codemirror.bundle.js, is managed by Rollup, while everything else is RL.
The Rollup output for now is put under resources/lib/ alongside the CM5
upstream files.
This patch is *mostly* renames of files, along with changing ECMAScript
Module (ESM) syntax into the CommonJS style that ResourceLoader prefers.
We also remove more modern JS syntax (i.e. private class methods) that
we were able to use before because we had a build step with Babel.
This patch should effectively make no user-facing changes, or to the
ResourceLoader modules we offer in Extension:CodeMirror.
Finally, bump version in extension.json to 6, to match the upstream lib,
and add Bhsd as an author :-)
Bug: T368053
Change-Id: Ie258e49f5df8db23a7344ac3c4c9300aaa991042
2024-06-21 03:21:09 +00:00
|
|
|
return this.makeLocalStyle( mwModeConfig.tags.htmlTagBracket, state );
|
2023-12-06 18:49:40 +00:00
|
|
|
}
|
|
|
|
if ( stream.match( '/>' ) ) {
|
|
|
|
state.tokenize = state.stack.pop();
|
Isolate build step to CM6 library and restructure files to work with RL
CodeMirror 6 requires the use of NPM, but we can still bundle all CM
packages into one file, and then everything else (i.e. our code) is
managed by ResourceLoader as per usual. This makes contribution
considerably easier as we no longer need a build step for each change.
CM5 files are now under resources/legacy, and the CM6 files are moved to
the root of the resources/ directory. Only one file,
codemirror.bundle.js, is managed by Rollup, while everything else is RL.
The Rollup output for now is put under resources/lib/ alongside the CM5
upstream files.
This patch is *mostly* renames of files, along with changing ECMAScript
Module (ESM) syntax into the CommonJS style that ResourceLoader prefers.
We also remove more modern JS syntax (i.e. private class methods) that
we were able to use before because we had a build step with Babel.
This patch should effectively make no user-facing changes, or to the
ResourceLoader modules we offer in Extension:CodeMirror.
Finally, bump version in extension.json to 6, to match the upstream lib,
and add Bhsd as an author :-)
Bug: T368053
Change-Id: Ie258e49f5df8db23a7344ac3c4c9300aaa991042
2024-06-21 03:21:09 +00:00
|
|
|
return this.makeLocalStyle( mwModeConfig.tags.htmlTagBracket, state );
|
2023-12-06 18:49:40 +00:00
|
|
|
}
|
Isolate build step to CM6 library and restructure files to work with RL
CodeMirror 6 requires the use of NPM, but we can still bundle all CM
packages into one file, and then everything else (i.e. our code) is
managed by ResourceLoader as per usual. This makes contribution
considerably easier as we no longer need a build step for each change.
CM5 files are now under resources/legacy, and the CM6 files are moved to
the root of the resources/ directory. Only one file,
codemirror.bundle.js, is managed by Rollup, while everything else is RL.
The Rollup output for now is put under resources/lib/ alongside the CM5
upstream files.
This patch is *mostly* renames of files, along with changing ECMAScript
Module (ESM) syntax into the CommonJS style that ResourceLoader prefers.
We also remove more modern JS syntax (i.e. private class methods) that
we were able to use before because we had a build step with Babel.
This patch should effectively make no user-facing changes, or to the
ResourceLoader modules we offer in Extension:CodeMirror.
Finally, bump version in extension.json to 6, to match the upstream lib,
and add Bhsd as an author :-)
Bug: T368053
Change-Id: Ie258e49f5df8db23a7344ac3c4c9300aaa991042
2024-06-21 03:21:09 +00:00
|
|
|
return this.eatWikiText( mwModeConfig.tags.htmlTagAttribute )( stream, state );
|
2023-12-06 18:49:40 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2024-01-04 04:01:27 +00:00
|
|
|
eatNowiki() {
|
2024-01-03 21:19:06 +00:00
|
|
|
return ( stream ) => {
|
|
|
|
if ( stream.match( /^[^&]+/ ) ) {
|
2024-01-04 04:01:27 +00:00
|
|
|
return '';
|
2024-01-03 21:19:06 +00:00
|
|
|
}
|
|
|
|
// eat &
|
|
|
|
stream.next();
|
2024-01-18 15:39:31 +00:00
|
|
|
return this.eatHtmlEntity( stream, '' );
|
2024-01-03 21:19:06 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2023-12-06 18:49:40 +00:00
|
|
|
eatExtTagAttribute( name ) {
|
|
|
|
return ( stream, state ) => {
|
2024-06-14 11:51:53 +00:00
|
|
|
|
2023-12-06 18:49:40 +00:00
|
|
|
if ( stream.match( /^(?:"[^">]*"|'[^'>]*'|[^>/<{&~])+/ ) ) {
|
Isolate build step to CM6 library and restructure files to work with RL
CodeMirror 6 requires the use of NPM, but we can still bundle all CM
packages into one file, and then everything else (i.e. our code) is
managed by ResourceLoader as per usual. This makes contribution
considerably easier as we no longer need a build step for each change.
CM5 files are now under resources/legacy, and the CM6 files are moved to
the root of the resources/ directory. Only one file,
codemirror.bundle.js, is managed by Rollup, while everything else is RL.
The Rollup output for now is put under resources/lib/ alongside the CM5
upstream files.
This patch is *mostly* renames of files, along with changing ECMAScript
Module (ESM) syntax into the CommonJS style that ResourceLoader prefers.
We also remove more modern JS syntax (i.e. private class methods) that
we were able to use before because we had a build step with Babel.
This patch should effectively make no user-facing changes, or to the
ResourceLoader modules we offer in Extension:CodeMirror.
Finally, bump version in extension.json to 6, to match the upstream lib,
and add Bhsd as an author :-)
Bug: T368053
Change-Id: Ie258e49f5df8db23a7344ac3c4c9300aaa991042
2024-06-21 03:21:09 +00:00
|
|
|
return this.makeLocalStyle( `${ mwModeConfig.tags.extTagAttribute } mw-ext-${ name }`, state );
|
2023-12-06 18:49:40 +00:00
|
|
|
}
|
|
|
|
if ( stream.eat( '>' ) ) {
|
|
|
|
state.extName = name;
|
2024-01-03 21:19:06 +00:00
|
|
|
|
2024-01-04 04:01:27 +00:00
|
|
|
// FIXME: remove nowiki and pre from TagModes in extension.json after CM6 upgrade
|
2024-01-03 21:19:06 +00:00
|
|
|
// leverage the tagModes system for <nowiki> and <pre>
|
|
|
|
if ( name === 'nowiki' || name === 'pre' ) {
|
|
|
|
// There's no actual processing within these tags (apart from HTML entities),
|
|
|
|
// so startState and copyState can be no-ops.
|
|
|
|
state.extMode = {
|
|
|
|
startState: () => {},
|
|
|
|
copyState: () => {},
|
2024-01-04 04:01:27 +00:00
|
|
|
token: this.eatNowiki()
|
2024-01-03 21:19:06 +00:00
|
|
|
};
|
|
|
|
} else if ( name in this.config.tagModes ) {
|
2024-01-04 04:01:27 +00:00
|
|
|
const mode = this.config.tagModes[ name ];
|
|
|
|
if ( mode === 'mediawiki' || mode === 'text/mediawiki' ) {
|
|
|
|
state.extMode = this.mediawiki;
|
|
|
|
state.extState = state.extMode.startState();
|
|
|
|
}
|
2023-12-06 18:49:40 +00:00
|
|
|
}
|
2024-01-03 21:19:06 +00:00
|
|
|
|
2023-12-06 18:49:40 +00:00
|
|
|
state.tokenize = this.eatExtTagArea( name );
|
Isolate build step to CM6 library and restructure files to work with RL
CodeMirror 6 requires the use of NPM, but we can still bundle all CM
packages into one file, and then everything else (i.e. our code) is
managed by ResourceLoader as per usual. This makes contribution
considerably easier as we no longer need a build step for each change.
CM5 files are now under resources/legacy, and the CM6 files are moved to
the root of the resources/ directory. Only one file,
codemirror.bundle.js, is managed by Rollup, while everything else is RL.
The Rollup output for now is put under resources/lib/ alongside the CM5
upstream files.
This patch is *mostly* renames of files, along with changing ECMAScript
Module (ESM) syntax into the CommonJS style that ResourceLoader prefers.
We also remove more modern JS syntax (i.e. private class methods) that
we were able to use before because we had a build step with Babel.
This patch should effectively make no user-facing changes, or to the
ResourceLoader modules we offer in Extension:CodeMirror.
Finally, bump version in extension.json to 6, to match the upstream lib,
and add Bhsd as an author :-)
Bug: T368053
Change-Id: Ie258e49f5df8db23a7344ac3c4c9300aaa991042
2024-06-21 03:21:09 +00:00
|
|
|
return this.makeLocalStyle( `${ mwModeConfig.tags.extTagBracket } mw-ext-${ name }`, state );
|
2023-12-06 18:49:40 +00:00
|
|
|
}
|
|
|
|
if ( stream.match( '/>' ) ) {
|
|
|
|
state.tokenize = state.stack.pop();
|
Isolate build step to CM6 library and restructure files to work with RL
CodeMirror 6 requires the use of NPM, but we can still bundle all CM
packages into one file, and then everything else (i.e. our code) is
managed by ResourceLoader as per usual. This makes contribution
considerably easier as we no longer need a build step for each change.
CM5 files are now under resources/legacy, and the CM6 files are moved to
the root of the resources/ directory. Only one file,
codemirror.bundle.js, is managed by Rollup, while everything else is RL.
The Rollup output for now is put under resources/lib/ alongside the CM5
upstream files.
This patch is *mostly* renames of files, along with changing ECMAScript
Module (ESM) syntax into the CommonJS style that ResourceLoader prefers.
We also remove more modern JS syntax (i.e. private class methods) that
we were able to use before because we had a build step with Babel.
This patch should effectively make no user-facing changes, or to the
ResourceLoader modules we offer in Extension:CodeMirror.
Finally, bump version in extension.json to 6, to match the upstream lib,
and add Bhsd as an author :-)
Bug: T368053
Change-Id: Ie258e49f5df8db23a7344ac3c4c9300aaa991042
2024-06-21 03:21:09 +00:00
|
|
|
return this.makeLocalStyle( `${ mwModeConfig.tags.extTagBracket } mw-ext-${ name }`, state );
|
2023-12-06 18:49:40 +00:00
|
|
|
}
|
Isolate build step to CM6 library and restructure files to work with RL
CodeMirror 6 requires the use of NPM, but we can still bundle all CM
packages into one file, and then everything else (i.e. our code) is
managed by ResourceLoader as per usual. This makes contribution
considerably easier as we no longer need a build step for each change.
CM5 files are now under resources/legacy, and the CM6 files are moved to
the root of the resources/ directory. Only one file,
codemirror.bundle.js, is managed by Rollup, while everything else is RL.
The Rollup output for now is put under resources/lib/ alongside the CM5
upstream files.
This patch is *mostly* renames of files, along with changing ECMAScript
Module (ESM) syntax into the CommonJS style that ResourceLoader prefers.
We also remove more modern JS syntax (i.e. private class methods) that
we were able to use before because we had a build step with Babel.
This patch should effectively make no user-facing changes, or to the
ResourceLoader modules we offer in Extension:CodeMirror.
Finally, bump version in extension.json to 6, to match the upstream lib,
and add Bhsd as an author :-)
Bug: T368053
Change-Id: Ie258e49f5df8db23a7344ac3c4c9300aaa991042
2024-06-21 03:21:09 +00:00
|
|
|
return this.eatWikiText( `${ mwModeConfig.tags.extTagAttribute } mw-ext-${ name }` )( stream, state );
|
2023-12-06 18:49:40 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
eatExtTagArea( name ) {
|
|
|
|
return ( stream, state ) => {
|
|
|
|
const from = stream.pos,
|
2024-06-14 11:51:53 +00:00
|
|
|
|
2023-12-06 18:49:40 +00:00
|
|
|
pattern = new RegExp( `</${ name }\\s*>`, 'i' ),
|
|
|
|
m = pattern.exec( from ? stream.string.slice( from ) : stream.string );
|
|
|
|
let origString = false,
|
|
|
|
to;
|
|
|
|
|
|
|
|
if ( m ) {
|
|
|
|
if ( m.index === 0 ) {
|
|
|
|
state.tokenize = this.eatExtCloseTag( name );
|
|
|
|
state.extName = false;
|
|
|
|
if ( state.extMode !== false ) {
|
|
|
|
state.extMode = false;
|
|
|
|
state.extState = false;
|
|
|
|
}
|
|
|
|
return state.tokenize( stream, state );
|
|
|
|
}
|
|
|
|
to = m.index + from;
|
|
|
|
origString = stream.string;
|
|
|
|
stream.string = origString.slice( 0, to );
|
|
|
|
}
|
|
|
|
|
|
|
|
state.stack.push( state.tokenize );
|
|
|
|
state.tokenize = this.eatExtTokens( origString );
|
|
|
|
return state.tokenize( stream, state );
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
eatExtCloseTag( name ) {
|
|
|
|
return ( stream, state ) => {
|
|
|
|
stream.next(); // eat <
|
|
|
|
stream.next(); // eat /
|
|
|
|
state.tokenize = this.eatTagName( name.length, true, false );
|
Isolate build step to CM6 library and restructure files to work with RL
CodeMirror 6 requires the use of NPM, but we can still bundle all CM
packages into one file, and then everything else (i.e. our code) is
managed by ResourceLoader as per usual. This makes contribution
considerably easier as we no longer need a build step for each change.
CM5 files are now under resources/legacy, and the CM6 files are moved to
the root of the resources/ directory. Only one file,
codemirror.bundle.js, is managed by Rollup, while everything else is RL.
The Rollup output for now is put under resources/lib/ alongside the CM5
upstream files.
This patch is *mostly* renames of files, along with changing ECMAScript
Module (ESM) syntax into the CommonJS style that ResourceLoader prefers.
We also remove more modern JS syntax (i.e. private class methods) that
we were able to use before because we had a build step with Babel.
This patch should effectively make no user-facing changes, or to the
ResourceLoader modules we offer in Extension:CodeMirror.
Finally, bump version in extension.json to 6, to match the upstream lib,
and add Bhsd as an author :-)
Bug: T368053
Change-Id: Ie258e49f5df8db23a7344ac3c4c9300aaa991042
2024-06-21 03:21:09 +00:00
|
|
|
return this.makeLocalStyle( `${ mwModeConfig.tags.extTagBracket } mw-ext-${ name }`, state );
|
2023-12-06 18:49:40 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
eatExtTokens( origString ) {
|
|
|
|
return ( stream, state ) => {
|
|
|
|
let ret;
|
|
|
|
if ( state.extMode === false ) {
|
Isolate build step to CM6 library and restructure files to work with RL
CodeMirror 6 requires the use of NPM, but we can still bundle all CM
packages into one file, and then everything else (i.e. our code) is
managed by ResourceLoader as per usual. This makes contribution
considerably easier as we no longer need a build step for each change.
CM5 files are now under resources/legacy, and the CM6 files are moved to
the root of the resources/ directory. Only one file,
codemirror.bundle.js, is managed by Rollup, while everything else is RL.
The Rollup output for now is put under resources/lib/ alongside the CM5
upstream files.
This patch is *mostly* renames of files, along with changing ECMAScript
Module (ESM) syntax into the CommonJS style that ResourceLoader prefers.
We also remove more modern JS syntax (i.e. private class methods) that
we were able to use before because we had a build step with Babel.
This patch should effectively make no user-facing changes, or to the
ResourceLoader modules we offer in Extension:CodeMirror.
Finally, bump version in extension.json to 6, to match the upstream lib,
and add Bhsd as an author :-)
Bug: T368053
Change-Id: Ie258e49f5df8db23a7344ac3c4c9300aaa991042
2024-06-21 03:21:09 +00:00
|
|
|
ret = mwModeConfig.tags.extTag;
|
2023-12-06 18:49:40 +00:00
|
|
|
stream.skipToEnd();
|
|
|
|
} else {
|
2024-01-04 04:01:27 +00:00
|
|
|
ret = `mw-tag-${ state.extName } ` +
|
|
|
|
state.extMode.token( stream, state.extState, origString === false );
|
2023-12-06 18:49:40 +00:00
|
|
|
}
|
|
|
|
if ( stream.eol() ) {
|
|
|
|
if ( origString !== false ) {
|
|
|
|
stream.string = origString;
|
|
|
|
}
|
|
|
|
state.tokenize = state.stack.pop();
|
|
|
|
}
|
|
|
|
return this.makeLocalStyle( ret, state );
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
eatStartTable( stream, state ) {
|
|
|
|
stream.match( '{|' );
|
|
|
|
stream.eatSpace();
|
|
|
|
state.tokenize = this.inTableDefinition.bind( this );
|
Isolate build step to CM6 library and restructure files to work with RL
CodeMirror 6 requires the use of NPM, but we can still bundle all CM
packages into one file, and then everything else (i.e. our code) is
managed by ResourceLoader as per usual. This makes contribution
considerably easier as we no longer need a build step for each change.
CM5 files are now under resources/legacy, and the CM6 files are moved to
the root of the resources/ directory. Only one file,
codemirror.bundle.js, is managed by Rollup, while everything else is RL.
The Rollup output for now is put under resources/lib/ alongside the CM5
upstream files.
This patch is *mostly* renames of files, along with changing ECMAScript
Module (ESM) syntax into the CommonJS style that ResourceLoader prefers.
We also remove more modern JS syntax (i.e. private class methods) that
we were able to use before because we had a build step with Babel.
This patch should effectively make no user-facing changes, or to the
ResourceLoader modules we offer in Extension:CodeMirror.
Finally, bump version in extension.json to 6, to match the upstream lib,
and add Bhsd as an author :-)
Bug: T368053
Change-Id: Ie258e49f5df8db23a7344ac3c4c9300aaa991042
2024-06-21 03:21:09 +00:00
|
|
|
return mwModeConfig.tags.tableBracket;
|
2023-12-06 18:49:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
inTableDefinition( stream, state ) {
|
|
|
|
if ( stream.sol() ) {
|
|
|
|
state.tokenize = this.inTable.bind( this );
|
|
|
|
return this.inTable( stream, state );
|
|
|
|
}
|
Isolate build step to CM6 library and restructure files to work with RL
CodeMirror 6 requires the use of NPM, but we can still bundle all CM
packages into one file, and then everything else (i.e. our code) is
managed by ResourceLoader as per usual. This makes contribution
considerably easier as we no longer need a build step for each change.
CM5 files are now under resources/legacy, and the CM6 files are moved to
the root of the resources/ directory. Only one file,
codemirror.bundle.js, is managed by Rollup, while everything else is RL.
The Rollup output for now is put under resources/lib/ alongside the CM5
upstream files.
This patch is *mostly* renames of files, along with changing ECMAScript
Module (ESM) syntax into the CommonJS style that ResourceLoader prefers.
We also remove more modern JS syntax (i.e. private class methods) that
we were able to use before because we had a build step with Babel.
This patch should effectively make no user-facing changes, or to the
ResourceLoader modules we offer in Extension:CodeMirror.
Finally, bump version in extension.json to 6, to match the upstream lib,
and add Bhsd as an author :-)
Bug: T368053
Change-Id: Ie258e49f5df8db23a7344ac3c4c9300aaa991042
2024-06-21 03:21:09 +00:00
|
|
|
return this.eatWikiText( mwModeConfig.tags.tableDefinition )( stream, state );
|
2023-12-06 18:49:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
inTable( stream, state ) {
|
|
|
|
if ( stream.sol() ) {
|
|
|
|
stream.eatSpace();
|
|
|
|
if ( stream.eat( '|' ) ) {
|
|
|
|
if ( stream.eat( '-' ) ) {
|
|
|
|
stream.eatSpace();
|
|
|
|
state.tokenize = this.inTableDefinition.bind( this );
|
Isolate build step to CM6 library and restructure files to work with RL
CodeMirror 6 requires the use of NPM, but we can still bundle all CM
packages into one file, and then everything else (i.e. our code) is
managed by ResourceLoader as per usual. This makes contribution
considerably easier as we no longer need a build step for each change.
CM5 files are now under resources/legacy, and the CM6 files are moved to
the root of the resources/ directory. Only one file,
codemirror.bundle.js, is managed by Rollup, while everything else is RL.
The Rollup output for now is put under resources/lib/ alongside the CM5
upstream files.
This patch is *mostly* renames of files, along with changing ECMAScript
Module (ESM) syntax into the CommonJS style that ResourceLoader prefers.
We also remove more modern JS syntax (i.e. private class methods) that
we were able to use before because we had a build step with Babel.
This patch should effectively make no user-facing changes, or to the
ResourceLoader modules we offer in Extension:CodeMirror.
Finally, bump version in extension.json to 6, to match the upstream lib,
and add Bhsd as an author :-)
Bug: T368053
Change-Id: Ie258e49f5df8db23a7344ac3c4c9300aaa991042
2024-06-21 03:21:09 +00:00
|
|
|
return this.makeLocalStyle( mwModeConfig.tags.tableDelimiter, state );
|
2023-12-06 18:49:40 +00:00
|
|
|
}
|
|
|
|
if ( stream.eat( '+' ) ) {
|
|
|
|
stream.eatSpace();
|
2024-01-18 19:16:00 +00:00
|
|
|
state.tokenize = this.eatTableRow( true, false, true );
|
Isolate build step to CM6 library and restructure files to work with RL
CodeMirror 6 requires the use of NPM, but we can still bundle all CM
packages into one file, and then everything else (i.e. our code) is
managed by ResourceLoader as per usual. This makes contribution
considerably easier as we no longer need a build step for each change.
CM5 files are now under resources/legacy, and the CM6 files are moved to
the root of the resources/ directory. Only one file,
codemirror.bundle.js, is managed by Rollup, while everything else is RL.
The Rollup output for now is put under resources/lib/ alongside the CM5
upstream files.
This patch is *mostly* renames of files, along with changing ECMAScript
Module (ESM) syntax into the CommonJS style that ResourceLoader prefers.
We also remove more modern JS syntax (i.e. private class methods) that
we were able to use before because we had a build step with Babel.
This patch should effectively make no user-facing changes, or to the
ResourceLoader modules we offer in Extension:CodeMirror.
Finally, bump version in extension.json to 6, to match the upstream lib,
and add Bhsd as an author :-)
Bug: T368053
Change-Id: Ie258e49f5df8db23a7344ac3c4c9300aaa991042
2024-06-21 03:21:09 +00:00
|
|
|
return this.makeLocalStyle( mwModeConfig.tags.tableDelimiter, state );
|
2023-12-06 18:49:40 +00:00
|
|
|
}
|
|
|
|
if ( stream.eat( '}' ) ) {
|
|
|
|
state.tokenize = state.stack.pop();
|
Isolate build step to CM6 library and restructure files to work with RL
CodeMirror 6 requires the use of NPM, but we can still bundle all CM
packages into one file, and then everything else (i.e. our code) is
managed by ResourceLoader as per usual. This makes contribution
considerably easier as we no longer need a build step for each change.
CM5 files are now under resources/legacy, and the CM6 files are moved to
the root of the resources/ directory. Only one file,
codemirror.bundle.js, is managed by Rollup, while everything else is RL.
The Rollup output for now is put under resources/lib/ alongside the CM5
upstream files.
This patch is *mostly* renames of files, along with changing ECMAScript
Module (ESM) syntax into the CommonJS style that ResourceLoader prefers.
We also remove more modern JS syntax (i.e. private class methods) that
we were able to use before because we had a build step with Babel.
This patch should effectively make no user-facing changes, or to the
ResourceLoader modules we offer in Extension:CodeMirror.
Finally, bump version in extension.json to 6, to match the upstream lib,
and add Bhsd as an author :-)
Bug: T368053
Change-Id: Ie258e49f5df8db23a7344ac3c4c9300aaa991042
2024-06-21 03:21:09 +00:00
|
|
|
return this.makeLocalStyle( mwModeConfig.tags.tableBracket, state );
|
2023-12-06 18:49:40 +00:00
|
|
|
}
|
|
|
|
stream.eatSpace();
|
|
|
|
state.tokenize = this.eatTableRow( true, false );
|
Isolate build step to CM6 library and restructure files to work with RL
CodeMirror 6 requires the use of NPM, but we can still bundle all CM
packages into one file, and then everything else (i.e. our code) is
managed by ResourceLoader as per usual. This makes contribution
considerably easier as we no longer need a build step for each change.
CM5 files are now under resources/legacy, and the CM6 files are moved to
the root of the resources/ directory. Only one file,
codemirror.bundle.js, is managed by Rollup, while everything else is RL.
The Rollup output for now is put under resources/lib/ alongside the CM5
upstream files.
This patch is *mostly* renames of files, along with changing ECMAScript
Module (ESM) syntax into the CommonJS style that ResourceLoader prefers.
We also remove more modern JS syntax (i.e. private class methods) that
we were able to use before because we had a build step with Babel.
This patch should effectively make no user-facing changes, or to the
ResourceLoader modules we offer in Extension:CodeMirror.
Finally, bump version in extension.json to 6, to match the upstream lib,
and add Bhsd as an author :-)
Bug: T368053
Change-Id: Ie258e49f5df8db23a7344ac3c4c9300aaa991042
2024-06-21 03:21:09 +00:00
|
|
|
return this.makeLocalStyle( mwModeConfig.tags.tableDelimiter, state );
|
2023-12-06 18:49:40 +00:00
|
|
|
}
|
|
|
|
if ( stream.eat( '!' ) ) {
|
|
|
|
stream.eatSpace();
|
|
|
|
state.tokenize = this.eatTableRow( true, true );
|
Isolate build step to CM6 library and restructure files to work with RL
CodeMirror 6 requires the use of NPM, but we can still bundle all CM
packages into one file, and then everything else (i.e. our code) is
managed by ResourceLoader as per usual. This makes contribution
considerably easier as we no longer need a build step for each change.
CM5 files are now under resources/legacy, and the CM6 files are moved to
the root of the resources/ directory. Only one file,
codemirror.bundle.js, is managed by Rollup, while everything else is RL.
The Rollup output for now is put under resources/lib/ alongside the CM5
upstream files.
This patch is *mostly* renames of files, along with changing ECMAScript
Module (ESM) syntax into the CommonJS style that ResourceLoader prefers.
We also remove more modern JS syntax (i.e. private class methods) that
we were able to use before because we had a build step with Babel.
This patch should effectively make no user-facing changes, or to the
ResourceLoader modules we offer in Extension:CodeMirror.
Finally, bump version in extension.json to 6, to match the upstream lib,
and add Bhsd as an author :-)
Bug: T368053
Change-Id: Ie258e49f5df8db23a7344ac3c4c9300aaa991042
2024-06-21 03:21:09 +00:00
|
|
|
return this.makeLocalStyle( mwModeConfig.tags.tableDelimiter, state );
|
2023-12-06 18:49:40 +00:00
|
|
|
}
|
|
|
|
}
|
2024-01-03 06:05:35 +00:00
|
|
|
return this.eatWikiText( '' )( stream, state );
|
2023-12-06 18:49:40 +00:00
|
|
|
}
|
|
|
|
|
2024-01-18 19:16:00 +00:00
|
|
|
// isStart actually means whether there may be attributes */
|
|
|
|
eatTableRow( isStart, isHead, isCaption ) {
|
|
|
|
let tag = '';
|
|
|
|
if ( isCaption ) {
|
Isolate build step to CM6 library and restructure files to work with RL
CodeMirror 6 requires the use of NPM, but we can still bundle all CM
packages into one file, and then everything else (i.e. our code) is
managed by ResourceLoader as per usual. This makes contribution
considerably easier as we no longer need a build step for each change.
CM5 files are now under resources/legacy, and the CM6 files are moved to
the root of the resources/ directory. Only one file,
codemirror.bundle.js, is managed by Rollup, while everything else is RL.
The Rollup output for now is put under resources/lib/ alongside the CM5
upstream files.
This patch is *mostly* renames of files, along with changing ECMAScript
Module (ESM) syntax into the CommonJS style that ResourceLoader prefers.
We also remove more modern JS syntax (i.e. private class methods) that
we were able to use before because we had a build step with Babel.
This patch should effectively make no user-facing changes, or to the
ResourceLoader modules we offer in Extension:CodeMirror.
Finally, bump version in extension.json to 6, to match the upstream lib,
and add Bhsd as an author :-)
Bug: T368053
Change-Id: Ie258e49f5df8db23a7344ac3c4c9300aaa991042
2024-06-21 03:21:09 +00:00
|
|
|
tag = mwModeConfig.tags.tableCaption;
|
2024-01-18 19:16:00 +00:00
|
|
|
} else if ( isHead ) {
|
Isolate build step to CM6 library and restructure files to work with RL
CodeMirror 6 requires the use of NPM, but we can still bundle all CM
packages into one file, and then everything else (i.e. our code) is
managed by ResourceLoader as per usual. This makes contribution
considerably easier as we no longer need a build step for each change.
CM5 files are now under resources/legacy, and the CM6 files are moved to
the root of the resources/ directory. Only one file,
codemirror.bundle.js, is managed by Rollup, while everything else is RL.
The Rollup output for now is put under resources/lib/ alongside the CM5
upstream files.
This patch is *mostly* renames of files, along with changing ECMAScript
Module (ESM) syntax into the CommonJS style that ResourceLoader prefers.
We also remove more modern JS syntax (i.e. private class methods) that
we were able to use before because we had a build step with Babel.
This patch should effectively make no user-facing changes, or to the
ResourceLoader modules we offer in Extension:CodeMirror.
Finally, bump version in extension.json to 6, to match the upstream lib,
and add Bhsd as an author :-)
Bug: T368053
Change-Id: Ie258e49f5df8db23a7344ac3c4c9300aaa991042
2024-06-21 03:21:09 +00:00
|
|
|
tag = mwModeConfig.tags.strong;
|
2024-01-18 19:16:00 +00:00
|
|
|
}
|
2023-12-06 18:49:40 +00:00
|
|
|
return ( stream, state ) => {
|
|
|
|
if ( stream.sol() ) {
|
|
|
|
if ( stream.match( /^[\s\u00a0]*[|!]/, false ) ) {
|
|
|
|
state.tokenize = this.inTable.bind( this );
|
|
|
|
return this.inTable( stream, state );
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if ( stream.match( /^[^'|{[<&~!]+/ ) ) {
|
2024-01-18 19:16:00 +00:00
|
|
|
return this.makeStyle( tag, state );
|
2023-12-06 18:49:40 +00:00
|
|
|
}
|
2024-01-18 19:16:00 +00:00
|
|
|
if ( stream.match( '||' ) || ( isHead && stream.match( '!!' ) ) ) {
|
2023-12-06 18:49:40 +00:00
|
|
|
this.isBold = false;
|
|
|
|
this.isItalic = false;
|
2024-01-18 19:16:00 +00:00
|
|
|
state.tokenize = this.eatTableRow( true, isHead, isCaption );
|
Isolate build step to CM6 library and restructure files to work with RL
CodeMirror 6 requires the use of NPM, but we can still bundle all CM
packages into one file, and then everything else (i.e. our code) is
managed by ResourceLoader as per usual. This makes contribution
considerably easier as we no longer need a build step for each change.
CM5 files are now under resources/legacy, and the CM6 files are moved to
the root of the resources/ directory. Only one file,
codemirror.bundle.js, is managed by Rollup, while everything else is RL.
The Rollup output for now is put under resources/lib/ alongside the CM5
upstream files.
This patch is *mostly* renames of files, along with changing ECMAScript
Module (ESM) syntax into the CommonJS style that ResourceLoader prefers.
We also remove more modern JS syntax (i.e. private class methods) that
we were able to use before because we had a build step with Babel.
This patch should effectively make no user-facing changes, or to the
ResourceLoader modules we offer in Extension:CodeMirror.
Finally, bump version in extension.json to 6, to match the upstream lib,
and add Bhsd as an author :-)
Bug: T368053
Change-Id: Ie258e49f5df8db23a7344ac3c4c9300aaa991042
2024-06-21 03:21:09 +00:00
|
|
|
return this.makeLocalStyle( mwModeConfig.tags.tableDelimiter, state );
|
2024-01-18 19:16:00 +00:00
|
|
|
}
|
|
|
|
if ( isStart && stream.eat( '|' ) ) {
|
|
|
|
state.tokenize = this.eatTableRow( false, isHead, isCaption );
|
Isolate build step to CM6 library and restructure files to work with RL
CodeMirror 6 requires the use of NPM, but we can still bundle all CM
packages into one file, and then everything else (i.e. our code) is
managed by ResourceLoader as per usual. This makes contribution
considerably easier as we no longer need a build step for each change.
CM5 files are now under resources/legacy, and the CM6 files are moved to
the root of the resources/ directory. Only one file,
codemirror.bundle.js, is managed by Rollup, while everything else is RL.
The Rollup output for now is put under resources/lib/ alongside the CM5
upstream files.
This patch is *mostly* renames of files, along with changing ECMAScript
Module (ESM) syntax into the CommonJS style that ResourceLoader prefers.
We also remove more modern JS syntax (i.e. private class methods) that
we were able to use before because we had a build step with Babel.
This patch should effectively make no user-facing changes, or to the
ResourceLoader modules we offer in Extension:CodeMirror.
Finally, bump version in extension.json to 6, to match the upstream lib,
and add Bhsd as an author :-)
Bug: T368053
Change-Id: Ie258e49f5df8db23a7344ac3c4c9300aaa991042
2024-06-21 03:21:09 +00:00
|
|
|
return this.makeLocalStyle( mwModeConfig.tags.tableDelimiter, state );
|
2023-12-06 18:49:40 +00:00
|
|
|
}
|
|
|
|
}
|
2024-01-03 06:05:35 +00:00
|
|
|
return this.eatWikiText( tag )( stream, state );
|
2023-12-06 18:49:40 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
eatFreeExternalLinkProtocol( stream, state ) {
|
|
|
|
stream.match( this.urlProtocols );
|
|
|
|
state.tokenize = this.eatFreeExternalLink.bind( this );
|
Isolate build step to CM6 library and restructure files to work with RL
CodeMirror 6 requires the use of NPM, but we can still bundle all CM
packages into one file, and then everything else (i.e. our code) is
managed by ResourceLoader as per usual. This makes contribution
considerably easier as we no longer need a build step for each change.
CM5 files are now under resources/legacy, and the CM6 files are moved to
the root of the resources/ directory. Only one file,
codemirror.bundle.js, is managed by Rollup, while everything else is RL.
The Rollup output for now is put under resources/lib/ alongside the CM5
upstream files.
This patch is *mostly* renames of files, along with changing ECMAScript
Module (ESM) syntax into the CommonJS style that ResourceLoader prefers.
We also remove more modern JS syntax (i.e. private class methods) that
we were able to use before because we had a build step with Babel.
This patch should effectively make no user-facing changes, or to the
ResourceLoader modules we offer in Extension:CodeMirror.
Finally, bump version in extension.json to 6, to match the upstream lib,
and add Bhsd as an author :-)
Bug: T368053
Change-Id: Ie258e49f5df8db23a7344ac3c4c9300aaa991042
2024-06-21 03:21:09 +00:00
|
|
|
return this.makeLocalStyle( mwModeConfig.tags.freeExtLinkProtocol, state );
|
2023-12-06 18:49:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
eatFreeExternalLink( stream, state ) {
|
2024-05-17 12:12:13 +00:00
|
|
|
if ( stream.sol() ) {
|
2023-12-06 18:49:40 +00:00
|
|
|
// @todo error message
|
|
|
|
} else if ( stream.match( /^[^\s\u00a0{[\]<>~).,']*/ ) ) {
|
|
|
|
if ( stream.peek() === '~' ) {
|
|
|
|
if ( !stream.match( /^~~~+/, false ) ) {
|
|
|
|
stream.match( /^~*/ );
|
Isolate build step to CM6 library and restructure files to work with RL
CodeMirror 6 requires the use of NPM, but we can still bundle all CM
packages into one file, and then everything else (i.e. our code) is
managed by ResourceLoader as per usual. This makes contribution
considerably easier as we no longer need a build step for each change.
CM5 files are now under resources/legacy, and the CM6 files are moved to
the root of the resources/ directory. Only one file,
codemirror.bundle.js, is managed by Rollup, while everything else is RL.
The Rollup output for now is put under resources/lib/ alongside the CM5
upstream files.
This patch is *mostly* renames of files, along with changing ECMAScript
Module (ESM) syntax into the CommonJS style that ResourceLoader prefers.
We also remove more modern JS syntax (i.e. private class methods) that
we were able to use before because we had a build step with Babel.
This patch should effectively make no user-facing changes, or to the
ResourceLoader modules we offer in Extension:CodeMirror.
Finally, bump version in extension.json to 6, to match the upstream lib,
and add Bhsd as an author :-)
Bug: T368053
Change-Id: Ie258e49f5df8db23a7344ac3c4c9300aaa991042
2024-06-21 03:21:09 +00:00
|
|
|
return this.makeLocalStyle( mwModeConfig.tags.freeExtLink, state );
|
2023-12-06 18:49:40 +00:00
|
|
|
}
|
|
|
|
} else if ( stream.peek() === '{' ) {
|
|
|
|
if ( !stream.match( '{{', false ) ) {
|
|
|
|
stream.next();
|
Isolate build step to CM6 library and restructure files to work with RL
CodeMirror 6 requires the use of NPM, but we can still bundle all CM
packages into one file, and then everything else (i.e. our code) is
managed by ResourceLoader as per usual. This makes contribution
considerably easier as we no longer need a build step for each change.
CM5 files are now under resources/legacy, and the CM6 files are moved to
the root of the resources/ directory. Only one file,
codemirror.bundle.js, is managed by Rollup, while everything else is RL.
The Rollup output for now is put under resources/lib/ alongside the CM5
upstream files.
This patch is *mostly* renames of files, along with changing ECMAScript
Module (ESM) syntax into the CommonJS style that ResourceLoader prefers.
We also remove more modern JS syntax (i.e. private class methods) that
we were able to use before because we had a build step with Babel.
This patch should effectively make no user-facing changes, or to the
ResourceLoader modules we offer in Extension:CodeMirror.
Finally, bump version in extension.json to 6, to match the upstream lib,
and add Bhsd as an author :-)
Bug: T368053
Change-Id: Ie258e49f5df8db23a7344ac3c4c9300aaa991042
2024-06-21 03:21:09 +00:00
|
|
|
return this.makeLocalStyle( mwModeConfig.tags.freeExtLink, state );
|
2023-12-06 18:49:40 +00:00
|
|
|
}
|
|
|
|
} else if ( stream.peek() === '\'' ) {
|
|
|
|
if ( !stream.match( '\'\'', false ) ) {
|
|
|
|
stream.next();
|
Isolate build step to CM6 library and restructure files to work with RL
CodeMirror 6 requires the use of NPM, but we can still bundle all CM
packages into one file, and then everything else (i.e. our code) is
managed by ResourceLoader as per usual. This makes contribution
considerably easier as we no longer need a build step for each change.
CM5 files are now under resources/legacy, and the CM6 files are moved to
the root of the resources/ directory. Only one file,
codemirror.bundle.js, is managed by Rollup, while everything else is RL.
The Rollup output for now is put under resources/lib/ alongside the CM5
upstream files.
This patch is *mostly* renames of files, along with changing ECMAScript
Module (ESM) syntax into the CommonJS style that ResourceLoader prefers.
We also remove more modern JS syntax (i.e. private class methods) that
we were able to use before because we had a build step with Babel.
This patch should effectively make no user-facing changes, or to the
ResourceLoader modules we offer in Extension:CodeMirror.
Finally, bump version in extension.json to 6, to match the upstream lib,
and add Bhsd as an author :-)
Bug: T368053
Change-Id: Ie258e49f5df8db23a7344ac3c4c9300aaa991042
2024-06-21 03:21:09 +00:00
|
|
|
return this.makeLocalStyle( mwModeConfig.tags.freeExtLink, state );
|
2023-12-06 18:49:40 +00:00
|
|
|
}
|
|
|
|
} else if ( stream.match( /^[).,]+(?=[^\s\u00a0{[\]<>~).,])/ ) ) {
|
Isolate build step to CM6 library and restructure files to work with RL
CodeMirror 6 requires the use of NPM, but we can still bundle all CM
packages into one file, and then everything else (i.e. our code) is
managed by ResourceLoader as per usual. This makes contribution
considerably easier as we no longer need a build step for each change.
CM5 files are now under resources/legacy, and the CM6 files are moved to
the root of the resources/ directory. Only one file,
codemirror.bundle.js, is managed by Rollup, while everything else is RL.
The Rollup output for now is put under resources/lib/ alongside the CM5
upstream files.
This patch is *mostly* renames of files, along with changing ECMAScript
Module (ESM) syntax into the CommonJS style that ResourceLoader prefers.
We also remove more modern JS syntax (i.e. private class methods) that
we were able to use before because we had a build step with Babel.
This patch should effectively make no user-facing changes, or to the
ResourceLoader modules we offer in Extension:CodeMirror.
Finally, bump version in extension.json to 6, to match the upstream lib,
and add Bhsd as an author :-)
Bug: T368053
Change-Id: Ie258e49f5df8db23a7344ac3c4c9300aaa991042
2024-06-21 03:21:09 +00:00
|
|
|
return this.makeLocalStyle( mwModeConfig.tags.freeExtLink, state );
|
2023-12-06 18:49:40 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
state.tokenize = state.stack.pop();
|
Isolate build step to CM6 library and restructure files to work with RL
CodeMirror 6 requires the use of NPM, but we can still bundle all CM
packages into one file, and then everything else (i.e. our code) is
managed by ResourceLoader as per usual. This makes contribution
considerably easier as we no longer need a build step for each change.
CM5 files are now under resources/legacy, and the CM6 files are moved to
the root of the resources/ directory. Only one file,
codemirror.bundle.js, is managed by Rollup, while everything else is RL.
The Rollup output for now is put under resources/lib/ alongside the CM5
upstream files.
This patch is *mostly* renames of files, along with changing ECMAScript
Module (ESM) syntax into the CommonJS style that ResourceLoader prefers.
We also remove more modern JS syntax (i.e. private class methods) that
we were able to use before because we had a build step with Babel.
This patch should effectively make no user-facing changes, or to the
ResourceLoader modules we offer in Extension:CodeMirror.
Finally, bump version in extension.json to 6, to match the upstream lib,
and add Bhsd as an author :-)
Bug: T368053
Change-Id: Ie258e49f5df8db23a7344ac3c4c9300aaa991042
2024-06-21 03:21:09 +00:00
|
|
|
return this.makeLocalStyle( mwModeConfig.tags.freeExtLink, state );
|
2023-12-06 18:49:40 +00:00
|
|
|
}
|
|
|
|
|
2024-02-29 09:26:36 +00:00
|
|
|
eatList( stream, state ) {
|
|
|
|
// Just consume all nested list and indention syntax when there is more
|
|
|
|
const mt = stream.match( /^[*#;:]*/u );
|
|
|
|
if ( mt && !this.isNested( state ) && mt[ 0 ].includes( ';' ) ) {
|
|
|
|
state.nDt += mt[ 0 ].split( ';' ).length - 1;
|
|
|
|
}
|
Isolate build step to CM6 library and restructure files to work with RL
CodeMirror 6 requires the use of NPM, but we can still bundle all CM
packages into one file, and then everything else (i.e. our code) is
managed by ResourceLoader as per usual. This makes contribution
considerably easier as we no longer need a build step for each change.
CM5 files are now under resources/legacy, and the CM6 files are moved to
the root of the resources/ directory. Only one file,
codemirror.bundle.js, is managed by Rollup, while everything else is RL.
The Rollup output for now is put under resources/lib/ alongside the CM5
upstream files.
This patch is *mostly* renames of files, along with changing ECMAScript
Module (ESM) syntax into the CommonJS style that ResourceLoader prefers.
We also remove more modern JS syntax (i.e. private class methods) that
we were able to use before because we had a build step with Babel.
This patch should effectively make no user-facing changes, or to the
ResourceLoader modules we offer in Extension:CodeMirror.
Finally, bump version in extension.json to 6, to match the upstream lib,
and add Bhsd as an author :-)
Bug: T368053
Change-Id: Ie258e49f5df8db23a7344ac3c4c9300aaa991042
2024-06-21 03:21:09 +00:00
|
|
|
return this.makeLocalStyle( mwModeConfig.tags.list, state );
|
2024-02-29 09:26:36 +00:00
|
|
|
}
|
|
|
|
|
2023-12-06 18:49:40 +00:00
|
|
|
/**
|
|
|
|
* @param {string} style
|
|
|
|
* @return {string|Function}
|
2024-03-19 03:10:11 +00:00
|
|
|
* @private
|
2023-12-06 18:49:40 +00:00
|
|
|
*/
|
2024-01-03 06:05:35 +00:00
|
|
|
eatWikiText( style ) {
|
2023-12-06 18:49:40 +00:00
|
|
|
return ( stream, state ) => {
|
|
|
|
let ch, tmp, mt, name, isCloseTag, tagname;
|
|
|
|
const sol = stream.sol();
|
|
|
|
|
|
|
|
function chain( parser ) {
|
|
|
|
state.stack.push( state.tokenize );
|
|
|
|
state.tokenize = parser;
|
|
|
|
return parser( stream, state );
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( sol ) {
|
|
|
|
// highlight free external links, see T108448
|
|
|
|
if ( !stream.match( '//', false ) && stream.match( this.urlProtocols ) ) {
|
|
|
|
state.stack.push( state.tokenize );
|
|
|
|
state.tokenize = this.eatFreeExternalLink.bind( this );
|
Isolate build step to CM6 library and restructure files to work with RL
CodeMirror 6 requires the use of NPM, but we can still bundle all CM
packages into one file, and then everything else (i.e. our code) is
managed by ResourceLoader as per usual. This makes contribution
considerably easier as we no longer need a build step for each change.
CM5 files are now under resources/legacy, and the CM6 files are moved to
the root of the resources/ directory. Only one file,
codemirror.bundle.js, is managed by Rollup, while everything else is RL.
The Rollup output for now is put under resources/lib/ alongside the CM5
upstream files.
This patch is *mostly* renames of files, along with changing ECMAScript
Module (ESM) syntax into the CommonJS style that ResourceLoader prefers.
We also remove more modern JS syntax (i.e. private class methods) that
we were able to use before because we had a build step with Babel.
This patch should effectively make no user-facing changes, or to the
ResourceLoader modules we offer in Extension:CodeMirror.
Finally, bump version in extension.json to 6, to match the upstream lib,
and add Bhsd as an author :-)
Bug: T368053
Change-Id: Ie258e49f5df8db23a7344ac3c4c9300aaa991042
2024-06-21 03:21:09 +00:00
|
|
|
return this.makeLocalStyle( mwModeConfig.tags.freeExtLinkProtocol, state );
|
2023-12-06 18:49:40 +00:00
|
|
|
}
|
|
|
|
ch = stream.next();
|
|
|
|
switch ( ch ) {
|
|
|
|
case '-':
|
|
|
|
if ( stream.match( /^---+/ ) ) {
|
Isolate build step to CM6 library and restructure files to work with RL
CodeMirror 6 requires the use of NPM, but we can still bundle all CM
packages into one file, and then everything else (i.e. our code) is
managed by ResourceLoader as per usual. This makes contribution
considerably easier as we no longer need a build step for each change.
CM5 files are now under resources/legacy, and the CM6 files are moved to
the root of the resources/ directory. Only one file,
codemirror.bundle.js, is managed by Rollup, while everything else is RL.
The Rollup output for now is put under resources/lib/ alongside the CM5
upstream files.
This patch is *mostly* renames of files, along with changing ECMAScript
Module (ESM) syntax into the CommonJS style that ResourceLoader prefers.
We also remove more modern JS syntax (i.e. private class methods) that
we were able to use before because we had a build step with Babel.
This patch should effectively make no user-facing changes, or to the
ResourceLoader modules we offer in Extension:CodeMirror.
Finally, bump version in extension.json to 6, to match the upstream lib,
and add Bhsd as an author :-)
Bug: T368053
Change-Id: Ie258e49f5df8db23a7344ac3c4c9300aaa991042
2024-06-21 03:21:09 +00:00
|
|
|
return mwModeConfig.tags.hr;
|
2023-12-06 18:49:40 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case '=':
|
2024-06-14 11:51:53 +00:00
|
|
|
|
2023-12-06 18:49:40 +00:00
|
|
|
tmp = stream.match( /^(={0,5})(.+?(=\1\s*)(<!--(?!.*-->.*\S).*?)?)$/ );
|
|
|
|
// Title
|
|
|
|
if ( tmp ) {
|
|
|
|
stream.backUp( tmp[ 2 ].length );
|
|
|
|
state.stack.push( state.tokenize );
|
|
|
|
state.tokenize = this.eatSectionHeader( tmp[ 3 ].length );
|
Isolate build step to CM6 library and restructure files to work with RL
CodeMirror 6 requires the use of NPM, but we can still bundle all CM
packages into one file, and then everything else (i.e. our code) is
managed by ResourceLoader as per usual. This makes contribution
considerably easier as we no longer need a build step for each change.
CM5 files are now under resources/legacy, and the CM6 files are moved to
the root of the resources/ directory. Only one file,
codemirror.bundle.js, is managed by Rollup, while everything else is RL.
The Rollup output for now is put under resources/lib/ alongside the CM5
upstream files.
This patch is *mostly* renames of files, along with changing ECMAScript
Module (ESM) syntax into the CommonJS style that ResourceLoader prefers.
We also remove more modern JS syntax (i.e. private class methods) that
we were able to use before because we had a build step with Babel.
This patch should effectively make no user-facing changes, or to the
ResourceLoader modules we offer in Extension:CodeMirror.
Finally, bump version in extension.json to 6, to match the upstream lib,
and add Bhsd as an author :-)
Bug: T368053
Change-Id: Ie258e49f5df8db23a7344ac3c4c9300aaa991042
2024-06-21 03:21:09 +00:00
|
|
|
return mwModeConfig.tags.sectionHeader + ' ' +
|
2023-12-06 18:49:40 +00:00
|
|
|
/**
|
|
|
|
* Tokens used here include:
|
|
|
|
* - cm-mw-section-1
|
|
|
|
* - cm-mw-section-2
|
|
|
|
* - cm-mw-section-3
|
|
|
|
* - cm-mw-section-4
|
|
|
|
* - cm-mw-section-5
|
|
|
|
* - cm-mw-section-6
|
|
|
|
*/
|
Isolate build step to CM6 library and restructure files to work with RL
CodeMirror 6 requires the use of NPM, but we can still bundle all CM
packages into one file, and then everything else (i.e. our code) is
managed by ResourceLoader as per usual. This makes contribution
considerably easier as we no longer need a build step for each change.
CM5 files are now under resources/legacy, and the CM6 files are moved to
the root of the resources/ directory. Only one file,
codemirror.bundle.js, is managed by Rollup, while everything else is RL.
The Rollup output for now is put under resources/lib/ alongside the CM5
upstream files.
This patch is *mostly* renames of files, along with changing ECMAScript
Module (ESM) syntax into the CommonJS style that ResourceLoader prefers.
We also remove more modern JS syntax (i.e. private class methods) that
we were able to use before because we had a build step with Babel.
This patch should effectively make no user-facing changes, or to the
ResourceLoader modules we offer in Extension:CodeMirror.
Finally, bump version in extension.json to 6, to match the upstream lib,
and add Bhsd as an author :-)
Bug: T368053
Change-Id: Ie258e49f5df8db23a7344ac3c4c9300aaa991042
2024-06-21 03:21:09 +00:00
|
|
|
mwModeConfig.tags[ `sectionHeader${ tmp[ 1 ].length + 1 }` ];
|
2023-12-06 18:49:40 +00:00
|
|
|
}
|
|
|
|
break;
|
2024-02-29 09:26:36 +00:00
|
|
|
case ';':
|
|
|
|
stream.backUp( 1 );
|
Isolate build step to CM6 library and restructure files to work with RL
CodeMirror 6 requires the use of NPM, but we can still bundle all CM
packages into one file, and then everything else (i.e. our code) is
managed by ResourceLoader as per usual. This makes contribution
considerably easier as we no longer need a build step for each change.
CM5 files are now under resources/legacy, and the CM6 files are moved to
the root of the resources/ directory. Only one file,
codemirror.bundle.js, is managed by Rollup, while everything else is RL.
The Rollup output for now is put under resources/lib/ alongside the CM5
upstream files.
This patch is *mostly* renames of files, along with changing ECMAScript
Module (ESM) syntax into the CommonJS style that ResourceLoader prefers.
We also remove more modern JS syntax (i.e. private class methods) that
we were able to use before because we had a build step with Babel.
This patch should effectively make no user-facing changes, or to the
ResourceLoader modules we offer in Extension:CodeMirror.
Finally, bump version in extension.json to 6, to match the upstream lib,
and add Bhsd as an author :-)
Bug: T368053
Change-Id: Ie258e49f5df8db23a7344ac3c4c9300aaa991042
2024-06-21 03:21:09 +00:00
|
|
|
// fall through
|
2023-12-06 18:49:40 +00:00
|
|
|
case '*':
|
|
|
|
case '#':
|
2024-02-29 09:26:36 +00:00
|
|
|
return this.eatList( stream, state );
|
2023-12-06 18:49:40 +00:00
|
|
|
case ':':
|
|
|
|
// Highlight indented tables :{|, bug T108454
|
2024-08-15 04:59:13 +00:00
|
|
|
if ( stream.match( /^:*[\s\u00a0]*(?={\|)/ ) ) {
|
2023-12-06 18:49:40 +00:00
|
|
|
state.stack.push( state.tokenize );
|
|
|
|
state.tokenize = this.eatStartTable.bind( this );
|
2024-08-15 04:59:13 +00:00
|
|
|
return mwModeConfig.tags.indenting;
|
2023-12-06 18:49:40 +00:00
|
|
|
}
|
2024-02-29 09:26:36 +00:00
|
|
|
return this.eatList( stream, state );
|
2023-12-06 18:49:40 +00:00
|
|
|
case ' ':
|
|
|
|
// Leading spaces is valid syntax for tables, bug T108454
|
2024-05-17 12:12:13 +00:00
|
|
|
if ( stream.match( /^[\s\u00a0]*(?::+[\s\u00a0]*)?{\|/, false ) ) {
|
2023-12-06 18:49:40 +00:00
|
|
|
stream.eatSpace();
|
|
|
|
if ( stream.match( /^:+/ ) ) { // ::{|
|
2024-05-17 12:12:13 +00:00
|
|
|
stream.eatSpace();
|
2023-12-06 18:49:40 +00:00
|
|
|
state.stack.push( state.tokenize );
|
|
|
|
state.tokenize = this.eatStartTable.bind( this );
|
Isolate build step to CM6 library and restructure files to work with RL
CodeMirror 6 requires the use of NPM, but we can still bundle all CM
packages into one file, and then everything else (i.e. our code) is
managed by ResourceLoader as per usual. This makes contribution
considerably easier as we no longer need a build step for each change.
CM5 files are now under resources/legacy, and the CM6 files are moved to
the root of the resources/ directory. Only one file,
codemirror.bundle.js, is managed by Rollup, while everything else is RL.
The Rollup output for now is put under resources/lib/ alongside the CM5
upstream files.
This patch is *mostly* renames of files, along with changing ECMAScript
Module (ESM) syntax into the CommonJS style that ResourceLoader prefers.
We also remove more modern JS syntax (i.e. private class methods) that
we were able to use before because we had a build step with Babel.
This patch should effectively make no user-facing changes, or to the
ResourceLoader modules we offer in Extension:CodeMirror.
Finally, bump version in extension.json to 6, to match the upstream lib,
and add Bhsd as an author :-)
Bug: T368053
Change-Id: Ie258e49f5df8db23a7344ac3c4c9300aaa991042
2024-06-21 03:21:09 +00:00
|
|
|
return mwModeConfig.tags.indenting;
|
2023-12-06 18:49:40 +00:00
|
|
|
}
|
|
|
|
stream.eat( '{' );
|
|
|
|
} else {
|
Isolate build step to CM6 library and restructure files to work with RL
CodeMirror 6 requires the use of NPM, but we can still bundle all CM
packages into one file, and then everything else (i.e. our code) is
managed by ResourceLoader as per usual. This makes contribution
considerably easier as we no longer need a build step for each change.
CM5 files are now under resources/legacy, and the CM6 files are moved to
the root of the resources/ directory. Only one file,
codemirror.bundle.js, is managed by Rollup, while everything else is RL.
The Rollup output for now is put under resources/lib/ alongside the CM5
upstream files.
This patch is *mostly* renames of files, along with changing ECMAScript
Module (ESM) syntax into the CommonJS style that ResourceLoader prefers.
We also remove more modern JS syntax (i.e. private class methods) that
we were able to use before because we had a build step with Babel.
This patch should effectively make no user-facing changes, or to the
ResourceLoader modules we offer in Extension:CodeMirror.
Finally, bump version in extension.json to 6, to match the upstream lib,
and add Bhsd as an author :-)
Bug: T368053
Change-Id: Ie258e49f5df8db23a7344ac3c4c9300aaa991042
2024-06-21 03:21:09 +00:00
|
|
|
return mwModeConfig.tags.skipFormatting;
|
2023-12-06 18:49:40 +00:00
|
|
|
}
|
|
|
|
// break is not necessary here
|
|
|
|
// falls through
|
|
|
|
case '{':
|
|
|
|
if ( stream.eat( '|' ) ) {
|
|
|
|
stream.eatSpace();
|
|
|
|
state.stack.push( state.tokenize );
|
|
|
|
state.tokenize = this.inTableDefinition.bind( this );
|
Isolate build step to CM6 library and restructure files to work with RL
CodeMirror 6 requires the use of NPM, but we can still bundle all CM
packages into one file, and then everything else (i.e. our code) is
managed by ResourceLoader as per usual. This makes contribution
considerably easier as we no longer need a build step for each change.
CM5 files are now under resources/legacy, and the CM6 files are moved to
the root of the resources/ directory. Only one file,
codemirror.bundle.js, is managed by Rollup, while everything else is RL.
The Rollup output for now is put under resources/lib/ alongside the CM5
upstream files.
This patch is *mostly* renames of files, along with changing ECMAScript
Module (ESM) syntax into the CommonJS style that ResourceLoader prefers.
We also remove more modern JS syntax (i.e. private class methods) that
we were able to use before because we had a build step with Babel.
This patch should effectively make no user-facing changes, or to the
ResourceLoader modules we offer in Extension:CodeMirror.
Finally, bump version in extension.json to 6, to match the upstream lib,
and add Bhsd as an author :-)
Bug: T368053
Change-Id: Ie258e49f5df8db23a7344ac3c4c9300aaa991042
2024-06-21 03:21:09 +00:00
|
|
|
return mwModeConfig.tags.tableBracket;
|
2023-12-06 18:49:40 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
ch = stream.next();
|
|
|
|
}
|
|
|
|
|
|
|
|
switch ( ch ) {
|
|
|
|
case '&':
|
|
|
|
return this.makeStyle(
|
2024-01-03 06:05:35 +00:00
|
|
|
this.eatHtmlEntity( stream, style ),
|
2023-12-06 18:49:40 +00:00
|
|
|
state
|
|
|
|
);
|
|
|
|
case '\'':
|
|
|
|
// skip the irrelevant apostrophes ( >5 or =4 )
|
|
|
|
if ( stream.match( /^'*(?=''''')/ ) || stream.match( /^'''(?!')/, false ) ) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if ( stream.match( '\'\'' ) ) { // bold
|
|
|
|
if ( !( this.firstSingleLetterWord || stream.match( '\'\'', false ) ) ) {
|
|
|
|
this.prepareItalicForCorrection( stream );
|
|
|
|
}
|
|
|
|
this.isBold = !this.isBold;
|
Isolate build step to CM6 library and restructure files to work with RL
CodeMirror 6 requires the use of NPM, but we can still bundle all CM
packages into one file, and then everything else (i.e. our code) is
managed by ResourceLoader as per usual. This makes contribution
considerably easier as we no longer need a build step for each change.
CM5 files are now under resources/legacy, and the CM6 files are moved to
the root of the resources/ directory. Only one file,
codemirror.bundle.js, is managed by Rollup, while everything else is RL.
The Rollup output for now is put under resources/lib/ alongside the CM5
upstream files.
This patch is *mostly* renames of files, along with changing ECMAScript
Module (ESM) syntax into the CommonJS style that ResourceLoader prefers.
We also remove more modern JS syntax (i.e. private class methods) that
we were able to use before because we had a build step with Babel.
This patch should effectively make no user-facing changes, or to the
ResourceLoader modules we offer in Extension:CodeMirror.
Finally, bump version in extension.json to 6, to match the upstream lib,
and add Bhsd as an author :-)
Bug: T368053
Change-Id: Ie258e49f5df8db23a7344ac3c4c9300aaa991042
2024-06-21 03:21:09 +00:00
|
|
|
return this.makeLocalStyle( mwModeConfig.tags.apostrophesBold, state );
|
2023-12-06 18:49:40 +00:00
|
|
|
} else if ( stream.eat( '\'' ) ) { // italic
|
|
|
|
this.isItalic = !this.isItalic;
|
Isolate build step to CM6 library and restructure files to work with RL
CodeMirror 6 requires the use of NPM, but we can still bundle all CM
packages into one file, and then everything else (i.e. our code) is
managed by ResourceLoader as per usual. This makes contribution
considerably easier as we no longer need a build step for each change.
CM5 files are now under resources/legacy, and the CM6 files are moved to
the root of the resources/ directory. Only one file,
codemirror.bundle.js, is managed by Rollup, while everything else is RL.
The Rollup output for now is put under resources/lib/ alongside the CM5
upstream files.
This patch is *mostly* renames of files, along with changing ECMAScript
Module (ESM) syntax into the CommonJS style that ResourceLoader prefers.
We also remove more modern JS syntax (i.e. private class methods) that
we were able to use before because we had a build step with Babel.
This patch should effectively make no user-facing changes, or to the
ResourceLoader modules we offer in Extension:CodeMirror.
Finally, bump version in extension.json to 6, to match the upstream lib,
and add Bhsd as an author :-)
Bug: T368053
Change-Id: Ie258e49f5df8db23a7344ac3c4c9300aaa991042
2024-06-21 03:21:09 +00:00
|
|
|
return this.makeLocalStyle( mwModeConfig.tags.apostrophesItalic, state );
|
2023-12-06 18:49:40 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case '[':
|
|
|
|
if ( stream.eat( '[' ) ) { // Link Example: [[ Foo | Bar ]]
|
|
|
|
stream.eatSpace();
|
|
|
|
if ( /[^\]|[]/.test( stream.peek() ) ) {
|
|
|
|
state.nLink++;
|
|
|
|
state.stack.push( state.tokenize );
|
|
|
|
state.tokenize = this.inLink.bind( this );
|
Isolate build step to CM6 library and restructure files to work with RL
CodeMirror 6 requires the use of NPM, but we can still bundle all CM
packages into one file, and then everything else (i.e. our code) is
managed by ResourceLoader as per usual. This makes contribution
considerably easier as we no longer need a build step for each change.
CM5 files are now under resources/legacy, and the CM6 files are moved to
the root of the resources/ directory. Only one file,
codemirror.bundle.js, is managed by Rollup, while everything else is RL.
The Rollup output for now is put under resources/lib/ alongside the CM5
upstream files.
This patch is *mostly* renames of files, along with changing ECMAScript
Module (ESM) syntax into the CommonJS style that ResourceLoader prefers.
We also remove more modern JS syntax (i.e. private class methods) that
we were able to use before because we had a build step with Babel.
This patch should effectively make no user-facing changes, or to the
ResourceLoader modules we offer in Extension:CodeMirror.
Finally, bump version in extension.json to 6, to match the upstream lib,
and add Bhsd as an author :-)
Bug: T368053
Change-Id: Ie258e49f5df8db23a7344ac3c4c9300aaa991042
2024-06-21 03:21:09 +00:00
|
|
|
return this.makeLocalStyle( mwModeConfig.tags.linkBracket, state );
|
2023-12-06 18:49:40 +00:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
mt = stream.match( this.urlProtocols );
|
|
|
|
if ( mt ) {
|
|
|
|
state.nLink++;
|
|
|
|
stream.backUp( mt[ 0 ].length );
|
|
|
|
state.stack.push( state.tokenize );
|
|
|
|
state.tokenize = this.eatExternalLinkProtocol( mt[ 0 ].length );
|
Isolate build step to CM6 library and restructure files to work with RL
CodeMirror 6 requires the use of NPM, but we can still bundle all CM
packages into one file, and then everything else (i.e. our code) is
managed by ResourceLoader as per usual. This makes contribution
considerably easier as we no longer need a build step for each change.
CM5 files are now under resources/legacy, and the CM6 files are moved to
the root of the resources/ directory. Only one file,
codemirror.bundle.js, is managed by Rollup, while everything else is RL.
The Rollup output for now is put under resources/lib/ alongside the CM5
upstream files.
This patch is *mostly* renames of files, along with changing ECMAScript
Module (ESM) syntax into the CommonJS style that ResourceLoader prefers.
We also remove more modern JS syntax (i.e. private class methods) that
we were able to use before because we had a build step with Babel.
This patch should effectively make no user-facing changes, or to the
ResourceLoader modules we offer in Extension:CodeMirror.
Finally, bump version in extension.json to 6, to match the upstream lib,
and add Bhsd as an author :-)
Bug: T368053
Change-Id: Ie258e49f5df8db23a7344ac3c4c9300aaa991042
2024-06-21 03:21:09 +00:00
|
|
|
return this.makeLocalStyle( mwModeConfig.tags.extLinkBracket, state );
|
2023-12-06 18:49:40 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case '{':
|
2023-12-08 02:34:01 +00:00
|
|
|
// Can't be a variable when it starts with more than 3 brackets (T108450) or
|
|
|
|
// a single { followed by a template. E.g. {{{!}} starts a table (T292967).
|
|
|
|
if ( stream.match( /^{{(?!{|[^{}]*}}(?!}))/ ) ) {
|
2023-12-06 18:49:40 +00:00
|
|
|
stream.eatSpace();
|
|
|
|
state.stack.push( state.tokenize );
|
|
|
|
state.tokenize = this.inVariable.bind( this );
|
|
|
|
return this.makeLocalStyle(
|
Isolate build step to CM6 library and restructure files to work with RL
CodeMirror 6 requires the use of NPM, but we can still bundle all CM
packages into one file, and then everything else (i.e. our code) is
managed by ResourceLoader as per usual. This makes contribution
considerably easier as we no longer need a build step for each change.
CM5 files are now under resources/legacy, and the CM6 files are moved to
the root of the resources/ directory. Only one file,
codemirror.bundle.js, is managed by Rollup, while everything else is RL.
The Rollup output for now is put under resources/lib/ alongside the CM5
upstream files.
This patch is *mostly* renames of files, along with changing ECMAScript
Module (ESM) syntax into the CommonJS style that ResourceLoader prefers.
We also remove more modern JS syntax (i.e. private class methods) that
we were able to use before because we had a build step with Babel.
This patch should effectively make no user-facing changes, or to the
ResourceLoader modules we offer in Extension:CodeMirror.
Finally, bump version in extension.json to 6, to match the upstream lib,
and add Bhsd as an author :-)
Bug: T368053
Change-Id: Ie258e49f5df8db23a7344ac3c4c9300aaa991042
2024-06-21 03:21:09 +00:00
|
|
|
mwModeConfig.tags.templateVariableBracket,
|
2023-12-06 18:49:40 +00:00
|
|
|
state
|
|
|
|
);
|
2023-12-08 02:34:01 +00:00
|
|
|
} else if ( stream.match( /^{(?!{(?!{))[\s\u00a0]*/ ) ) {
|
|
|
|
// Parser function
|
|
|
|
if ( stream.peek() === '#' ) {
|
2023-12-06 18:49:40 +00:00
|
|
|
state.nExt++;
|
|
|
|
state.stack.push( state.tokenize );
|
|
|
|
state.tokenize = this.inParserFunctionName.bind( this );
|
|
|
|
return this.makeLocalStyle(
|
Isolate build step to CM6 library and restructure files to work with RL
CodeMirror 6 requires the use of NPM, but we can still bundle all CM
packages into one file, and then everything else (i.e. our code) is
managed by ResourceLoader as per usual. This makes contribution
considerably easier as we no longer need a build step for each change.
CM5 files are now under resources/legacy, and the CM6 files are moved to
the root of the resources/ directory. Only one file,
codemirror.bundle.js, is managed by Rollup, while everything else is RL.
The Rollup output for now is put under resources/lib/ alongside the CM5
upstream files.
This patch is *mostly* renames of files, along with changing ECMAScript
Module (ESM) syntax into the CommonJS style that ResourceLoader prefers.
We also remove more modern JS syntax (i.e. private class methods) that
we were able to use before because we had a build step with Babel.
This patch should effectively make no user-facing changes, or to the
ResourceLoader modules we offer in Extension:CodeMirror.
Finally, bump version in extension.json to 6, to match the upstream lib,
and add Bhsd as an author :-)
Bug: T368053
Change-Id: Ie258e49f5df8db23a7344ac3c4c9300aaa991042
2024-06-21 03:21:09 +00:00
|
|
|
mwModeConfig.tags.parserFunctionBracket,
|
2023-12-06 18:49:40 +00:00
|
|
|
state
|
|
|
|
);
|
|
|
|
}
|
|
|
|
// Check for parser function without '#'
|
2024-05-17 12:12:13 +00:00
|
|
|
name = stream.match( /^([^}[\]<{|:]+)(.)?/, false );
|
2023-12-06 18:49:40 +00:00
|
|
|
if ( name ) {
|
2024-05-17 12:12:13 +00:00
|
|
|
const [ , f, delimiter ] = name,
|
|
|
|
ff = delimiter === ':' ? f : f.trim(),
|
|
|
|
ffLower = ff.toLowerCase(),
|
|
|
|
{ config: { functionSynonyms } } = this;
|
2023-12-06 18:49:40 +00:00
|
|
|
if (
|
2024-05-17 12:12:13 +00:00
|
|
|
( !delimiter || delimiter === ':' || delimiter === '}' ) &&
|
2023-12-06 18:49:40 +00:00
|
|
|
(
|
2024-05-17 12:12:13 +00:00
|
|
|
Object.prototype.hasOwnProperty.call(
|
|
|
|
functionSynonyms[ 0 ], ffLower
|
|
|
|
) ||
|
|
|
|
Object.prototype.hasOwnProperty.call(
|
|
|
|
functionSynonyms[ 1 ], ff
|
|
|
|
)
|
2023-12-06 18:49:40 +00:00
|
|
|
)
|
|
|
|
) {
|
|
|
|
state.nExt++;
|
|
|
|
state.stack.push( state.tokenize );
|
|
|
|
state.tokenize = this.inParserFunctionName.bind( this );
|
|
|
|
return this.makeLocalStyle(
|
Isolate build step to CM6 library and restructure files to work with RL
CodeMirror 6 requires the use of NPM, but we can still bundle all CM
packages into one file, and then everything else (i.e. our code) is
managed by ResourceLoader as per usual. This makes contribution
considerably easier as we no longer need a build step for each change.
CM5 files are now under resources/legacy, and the CM6 files are moved to
the root of the resources/ directory. Only one file,
codemirror.bundle.js, is managed by Rollup, while everything else is RL.
The Rollup output for now is put under resources/lib/ alongside the CM5
upstream files.
This patch is *mostly* renames of files, along with changing ECMAScript
Module (ESM) syntax into the CommonJS style that ResourceLoader prefers.
We also remove more modern JS syntax (i.e. private class methods) that
we were able to use before because we had a build step with Babel.
This patch should effectively make no user-facing changes, or to the
ResourceLoader modules we offer in Extension:CodeMirror.
Finally, bump version in extension.json to 6, to match the upstream lib,
and add Bhsd as an author :-)
Bug: T368053
Change-Id: Ie258e49f5df8db23a7344ac3c4c9300aaa991042
2024-06-21 03:21:09 +00:00
|
|
|
mwModeConfig.tags.parserFunctionBracket,
|
2023-12-06 18:49:40 +00:00
|
|
|
state
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// Template
|
|
|
|
state.nTemplate++;
|
|
|
|
state.stack.push( state.tokenize );
|
|
|
|
state.tokenize = this.eatTemplatePageName( false );
|
Isolate build step to CM6 library and restructure files to work with RL
CodeMirror 6 requires the use of NPM, but we can still bundle all CM
packages into one file, and then everything else (i.e. our code) is
managed by ResourceLoader as per usual. This makes contribution
considerably easier as we no longer need a build step for each change.
CM5 files are now under resources/legacy, and the CM6 files are moved to
the root of the resources/ directory. Only one file,
codemirror.bundle.js, is managed by Rollup, while everything else is RL.
The Rollup output for now is put under resources/lib/ alongside the CM5
upstream files.
This patch is *mostly* renames of files, along with changing ECMAScript
Module (ESM) syntax into the CommonJS style that ResourceLoader prefers.
We also remove more modern JS syntax (i.e. private class methods) that
we were able to use before because we had a build step with Babel.
This patch should effectively make no user-facing changes, or to the
ResourceLoader modules we offer in Extension:CodeMirror.
Finally, bump version in extension.json to 6, to match the upstream lib,
and add Bhsd as an author :-)
Bug: T368053
Change-Id: Ie258e49f5df8db23a7344ac3c4c9300aaa991042
2024-06-21 03:21:09 +00:00
|
|
|
return this.makeLocalStyle( mwModeConfig.tags.templateBracket, state );
|
2023-12-06 18:49:40 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case '<':
|
|
|
|
if ( stream.match( '!--' ) ) { // comment
|
Isolate build step to CM6 library and restructure files to work with RL
CodeMirror 6 requires the use of NPM, but we can still bundle all CM
packages into one file, and then everything else (i.e. our code) is
managed by ResourceLoader as per usual. This makes contribution
considerably easier as we no longer need a build step for each change.
CM5 files are now under resources/legacy, and the CM6 files are moved to
the root of the resources/ directory. Only one file,
codemirror.bundle.js, is managed by Rollup, while everything else is RL.
The Rollup output for now is put under resources/lib/ alongside the CM5
upstream files.
This patch is *mostly* renames of files, along with changing ECMAScript
Module (ESM) syntax into the CommonJS style that ResourceLoader prefers.
We also remove more modern JS syntax (i.e. private class methods) that
we were able to use before because we had a build step with Babel.
This patch should effectively make no user-facing changes, or to the
ResourceLoader modules we offer in Extension:CodeMirror.
Finally, bump version in extension.json to 6, to match the upstream lib,
and add Bhsd as an author :-)
Bug: T368053
Change-Id: Ie258e49f5df8db23a7344ac3c4c9300aaa991042
2024-06-21 03:21:09 +00:00
|
|
|
return chain( this.eatBlock( mwModeConfig.tags.comment, '-->' ) );
|
2023-12-06 18:49:40 +00:00
|
|
|
}
|
2024-05-17 12:12:13 +00:00
|
|
|
isCloseTag = !!stream.eat( '/' );
|
|
|
|
tagname = stream.match( /^[a-z][^>/\s\u00a0]*/i );
|
2023-12-06 18:49:40 +00:00
|
|
|
if ( tagname ) {
|
|
|
|
tagname = tagname[ 0 ].toLowerCase();
|
2024-01-03 21:19:06 +00:00
|
|
|
if ( tagname in this.config.tags ) {
|
2023-12-06 18:49:40 +00:00
|
|
|
// Parser function
|
|
|
|
if ( isCloseTag === true ) {
|
Isolate build step to CM6 library and restructure files to work with RL
CodeMirror 6 requires the use of NPM, but we can still bundle all CM
packages into one file, and then everything else (i.e. our code) is
managed by ResourceLoader as per usual. This makes contribution
considerably easier as we no longer need a build step for each change.
CM5 files are now under resources/legacy, and the CM6 files are moved to
the root of the resources/ directory. Only one file,
codemirror.bundle.js, is managed by Rollup, while everything else is RL.
The Rollup output for now is put under resources/lib/ alongside the CM5
upstream files.
This patch is *mostly* renames of files, along with changing ECMAScript
Module (ESM) syntax into the CommonJS style that ResourceLoader prefers.
We also remove more modern JS syntax (i.e. private class methods) that
we were able to use before because we had a build step with Babel.
This patch should effectively make no user-facing changes, or to the
ResourceLoader modules we offer in Extension:CodeMirror.
Finally, bump version in extension.json to 6, to match the upstream lib,
and add Bhsd as an author :-)
Bug: T368053
Change-Id: Ie258e49f5df8db23a7344ac3c4c9300aaa991042
2024-06-21 03:21:09 +00:00
|
|
|
return mwModeConfig.tags.error;
|
2023-12-06 18:49:40 +00:00
|
|
|
}
|
|
|
|
stream.backUp( tagname.length );
|
|
|
|
state.stack.push( state.tokenize );
|
|
|
|
state.tokenize = this.eatTagName( tagname.length, isCloseTag, false );
|
Isolate build step to CM6 library and restructure files to work with RL
CodeMirror 6 requires the use of NPM, but we can still bundle all CM
packages into one file, and then everything else (i.e. our code) is
managed by ResourceLoader as per usual. This makes contribution
considerably easier as we no longer need a build step for each change.
CM5 files are now under resources/legacy, and the CM6 files are moved to
the root of the resources/ directory. Only one file,
codemirror.bundle.js, is managed by Rollup, while everything else is RL.
The Rollup output for now is put under resources/lib/ alongside the CM5
upstream files.
This patch is *mostly* renames of files, along with changing ECMAScript
Module (ESM) syntax into the CommonJS style that ResourceLoader prefers.
We also remove more modern JS syntax (i.e. private class methods) that
we were able to use before because we had a build step with Babel.
This patch should effectively make no user-facing changes, or to the
ResourceLoader modules we offer in Extension:CodeMirror.
Finally, bump version in extension.json to 6, to match the upstream lib,
and add Bhsd as an author :-)
Bug: T368053
Change-Id: Ie258e49f5df8db23a7344ac3c4c9300aaa991042
2024-06-21 03:21:09 +00:00
|
|
|
return this.makeLocalStyle( `${ mwModeConfig.tags.extTagBracket } mw-ext-${ tagname }`, state );
|
2023-12-06 18:49:40 +00:00
|
|
|
}
|
Isolate build step to CM6 library and restructure files to work with RL
CodeMirror 6 requires the use of NPM, but we can still bundle all CM
packages into one file, and then everything else (i.e. our code) is
managed by ResourceLoader as per usual. This makes contribution
considerably easier as we no longer need a build step for each change.
CM5 files are now under resources/legacy, and the CM6 files are moved to
the root of the resources/ directory. Only one file,
codemirror.bundle.js, is managed by Rollup, while everything else is RL.
The Rollup output for now is put under resources/lib/ alongside the CM5
upstream files.
This patch is *mostly* renames of files, along with changing ECMAScript
Module (ESM) syntax into the CommonJS style that ResourceLoader prefers.
We also remove more modern JS syntax (i.e. private class methods) that
we were able to use before because we had a build step with Babel.
This patch should effectively make no user-facing changes, or to the
ResourceLoader modules we offer in Extension:CodeMirror.
Finally, bump version in extension.json to 6, to match the upstream lib,
and add Bhsd as an author :-)
Bug: T368053
Change-Id: Ie258e49f5df8db23a7344ac3c4c9300aaa991042
2024-06-21 03:21:09 +00:00
|
|
|
if ( tagname in mwModeConfig.permittedHtmlTags ) {
|
2023-12-06 18:49:40 +00:00
|
|
|
// Html tag
|
|
|
|
if ( isCloseTag === true && tagname !== state.inHtmlTag.pop() ) {
|
|
|
|
// Increment position so that the closing '>' gets highlighted red.
|
|
|
|
stream.pos++;
|
Isolate build step to CM6 library and restructure files to work with RL
CodeMirror 6 requires the use of NPM, but we can still bundle all CM
packages into one file, and then everything else (i.e. our code) is
managed by ResourceLoader as per usual. This makes contribution
considerably easier as we no longer need a build step for each change.
CM5 files are now under resources/legacy, and the CM6 files are moved to
the root of the resources/ directory. Only one file,
codemirror.bundle.js, is managed by Rollup, while everything else is RL.
The Rollup output for now is put under resources/lib/ alongside the CM5
upstream files.
This patch is *mostly* renames of files, along with changing ECMAScript
Module (ESM) syntax into the CommonJS style that ResourceLoader prefers.
We also remove more modern JS syntax (i.e. private class methods) that
we were able to use before because we had a build step with Babel.
This patch should effectively make no user-facing changes, or to the
ResourceLoader modules we offer in Extension:CodeMirror.
Finally, bump version in extension.json to 6, to match the upstream lib,
and add Bhsd as an author :-)
Bug: T368053
Change-Id: Ie258e49f5df8db23a7344ac3c4c9300aaa991042
2024-06-21 03:21:09 +00:00
|
|
|
return mwModeConfig.tags.error;
|
2023-12-06 18:49:40 +00:00
|
|
|
}
|
|
|
|
if (
|
|
|
|
isCloseTag === true &&
|
Isolate build step to CM6 library and restructure files to work with RL
CodeMirror 6 requires the use of NPM, but we can still bundle all CM
packages into one file, and then everything else (i.e. our code) is
managed by ResourceLoader as per usual. This makes contribution
considerably easier as we no longer need a build step for each change.
CM5 files are now under resources/legacy, and the CM6 files are moved to
the root of the resources/ directory. Only one file,
codemirror.bundle.js, is managed by Rollup, while everything else is RL.
The Rollup output for now is put under resources/lib/ alongside the CM5
upstream files.
This patch is *mostly* renames of files, along with changing ECMAScript
Module (ESM) syntax into the CommonJS style that ResourceLoader prefers.
We also remove more modern JS syntax (i.e. private class methods) that
we were able to use before because we had a build step with Babel.
This patch should effectively make no user-facing changes, or to the
ResourceLoader modules we offer in Extension:CodeMirror.
Finally, bump version in extension.json to 6, to match the upstream lib,
and add Bhsd as an author :-)
Bug: T368053
Change-Id: Ie258e49f5df8db23a7344ac3c4c9300aaa991042
2024-06-21 03:21:09 +00:00
|
|
|
tagname in mwModeConfig.implicitlyClosedHtmlTags
|
2023-12-06 18:49:40 +00:00
|
|
|
) {
|
Isolate build step to CM6 library and restructure files to work with RL
CodeMirror 6 requires the use of NPM, but we can still bundle all CM
packages into one file, and then everything else (i.e. our code) is
managed by ResourceLoader as per usual. This makes contribution
considerably easier as we no longer need a build step for each change.
CM5 files are now under resources/legacy, and the CM6 files are moved to
the root of the resources/ directory. Only one file,
codemirror.bundle.js, is managed by Rollup, while everything else is RL.
The Rollup output for now is put under resources/lib/ alongside the CM5
upstream files.
This patch is *mostly* renames of files, along with changing ECMAScript
Module (ESM) syntax into the CommonJS style that ResourceLoader prefers.
We also remove more modern JS syntax (i.e. private class methods) that
we were able to use before because we had a build step with Babel.
This patch should effectively make no user-facing changes, or to the
ResourceLoader modules we offer in Extension:CodeMirror.
Finally, bump version in extension.json to 6, to match the upstream lib,
and add Bhsd as an author :-)
Bug: T368053
Change-Id: Ie258e49f5df8db23a7344ac3c4c9300aaa991042
2024-06-21 03:21:09 +00:00
|
|
|
return mwModeConfig.tags.error;
|
2023-12-06 18:49:40 +00:00
|
|
|
}
|
|
|
|
stream.backUp( tagname.length );
|
|
|
|
state.stack.push( state.tokenize );
|
|
|
|
state.tokenize = this.eatTagName(
|
|
|
|
tagname.length,
|
|
|
|
// Opening void tags should also be treated as the closing tag.
|
|
|
|
isCloseTag ||
|
Isolate build step to CM6 library and restructure files to work with RL
CodeMirror 6 requires the use of NPM, but we can still bundle all CM
packages into one file, and then everything else (i.e. our code) is
managed by ResourceLoader as per usual. This makes contribution
considerably easier as we no longer need a build step for each change.
CM5 files are now under resources/legacy, and the CM6 files are moved to
the root of the resources/ directory. Only one file,
codemirror.bundle.js, is managed by Rollup, while everything else is RL.
The Rollup output for now is put under resources/lib/ alongside the CM5
upstream files.
This patch is *mostly* renames of files, along with changing ECMAScript
Module (ESM) syntax into the CommonJS style that ResourceLoader prefers.
We also remove more modern JS syntax (i.e. private class methods) that
we were able to use before because we had a build step with Babel.
This patch should effectively make no user-facing changes, or to the
ResourceLoader modules we offer in Extension:CodeMirror.
Finally, bump version in extension.json to 6, to match the upstream lib,
and add Bhsd as an author :-)
Bug: T368053
Change-Id: Ie258e49f5df8db23a7344ac3c4c9300aaa991042
2024-06-21 03:21:09 +00:00
|
|
|
( tagname in mwModeConfig.implicitlyClosedHtmlTags ),
|
2023-12-06 18:49:40 +00:00
|
|
|
true
|
|
|
|
);
|
Isolate build step to CM6 library and restructure files to work with RL
CodeMirror 6 requires the use of NPM, but we can still bundle all CM
packages into one file, and then everything else (i.e. our code) is
managed by ResourceLoader as per usual. This makes contribution
considerably easier as we no longer need a build step for each change.
CM5 files are now under resources/legacy, and the CM6 files are moved to
the root of the resources/ directory. Only one file,
codemirror.bundle.js, is managed by Rollup, while everything else is RL.
The Rollup output for now is put under resources/lib/ alongside the CM5
upstream files.
This patch is *mostly* renames of files, along with changing ECMAScript
Module (ESM) syntax into the CommonJS style that ResourceLoader prefers.
We also remove more modern JS syntax (i.e. private class methods) that
we were able to use before because we had a build step with Babel.
This patch should effectively make no user-facing changes, or to the
ResourceLoader modules we offer in Extension:CodeMirror.
Finally, bump version in extension.json to 6, to match the upstream lib,
and add Bhsd as an author :-)
Bug: T368053
Change-Id: Ie258e49f5df8db23a7344ac3c4c9300aaa991042
2024-06-21 03:21:09 +00:00
|
|
|
return this.makeLocalStyle( mwModeConfig.tags.htmlTagBracket, state );
|
2023-12-06 18:49:40 +00:00
|
|
|
}
|
|
|
|
stream.backUp( tagname.length );
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case '~':
|
|
|
|
if ( stream.match( /^~{2,4}/ ) ) {
|
Isolate build step to CM6 library and restructure files to work with RL
CodeMirror 6 requires the use of NPM, but we can still bundle all CM
packages into one file, and then everything else (i.e. our code) is
managed by ResourceLoader as per usual. This makes contribution
considerably easier as we no longer need a build step for each change.
CM5 files are now under resources/legacy, and the CM6 files are moved to
the root of the resources/ directory. Only one file,
codemirror.bundle.js, is managed by Rollup, while everything else is RL.
The Rollup output for now is put under resources/lib/ alongside the CM5
upstream files.
This patch is *mostly* renames of files, along with changing ECMAScript
Module (ESM) syntax into the CommonJS style that ResourceLoader prefers.
We also remove more modern JS syntax (i.e. private class methods) that
we were able to use before because we had a build step with Babel.
This patch should effectively make no user-facing changes, or to the
ResourceLoader modules we offer in Extension:CodeMirror.
Finally, bump version in extension.json to 6, to match the upstream lib,
and add Bhsd as an author :-)
Bug: T368053
Change-Id: Ie258e49f5df8db23a7344ac3c4c9300aaa991042
2024-06-21 03:21:09 +00:00
|
|
|
return mwModeConfig.tags.signature;
|
2023-12-06 18:49:40 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
// Maybe double underscored Magic Word such as __TOC__
|
|
|
|
case '_':
|
|
|
|
tmp = 1;
|
|
|
|
// Optimize processing of many underscore symbols
|
|
|
|
while ( stream.eat( '_' ) ) {
|
|
|
|
tmp++;
|
|
|
|
}
|
|
|
|
// Many underscore symbols
|
|
|
|
if ( tmp > 2 ) {
|
|
|
|
if ( !stream.eol() ) {
|
|
|
|
// Leave last two underscore symbols for processing in next iteration
|
|
|
|
stream.backUp( 2 );
|
|
|
|
}
|
|
|
|
// Optimization: skip regex function for EOL and backup-ed symbols
|
|
|
|
return this.makeStyle( style, state );
|
Isolate build step to CM6 library and restructure files to work with RL
CodeMirror 6 requires the use of NPM, but we can still bundle all CM
packages into one file, and then everything else (i.e. our code) is
managed by ResourceLoader as per usual. This makes contribution
considerably easier as we no longer need a build step for each change.
CM5 files are now under resources/legacy, and the CM6 files are moved to
the root of the resources/ directory. Only one file,
codemirror.bundle.js, is managed by Rollup, while everything else is RL.
The Rollup output for now is put under resources/lib/ alongside the CM5
upstream files.
This patch is *mostly* renames of files, along with changing ECMAScript
Module (ESM) syntax into the CommonJS style that ResourceLoader prefers.
We also remove more modern JS syntax (i.e. private class methods) that
we were able to use before because we had a build step with Babel.
This patch should effectively make no user-facing changes, or to the
ResourceLoader modules we offer in Extension:CodeMirror.
Finally, bump version in extension.json to 6, to match the upstream lib,
and add Bhsd as an author :-)
Bug: T368053
Change-Id: Ie258e49f5df8db23a7344ac3c4c9300aaa991042
2024-06-21 03:21:09 +00:00
|
|
|
// Check on double underscore Magic Word
|
2023-12-06 18:49:40 +00:00
|
|
|
} else if ( tmp === 2 ) {
|
|
|
|
// The same as the end of function except '_' inside and '__' at the end.
|
|
|
|
name = stream.match( /^([^\s\u00a0>}[\]<{'|&:~]+?)__/ );
|
|
|
|
if ( name && name[ 0 ] ) {
|
|
|
|
if (
|
|
|
|
'__' + name[ 0 ].toLowerCase() in this.config.doubleUnderscore[ 0 ] ||
|
|
|
|
'__' + name[ 0 ] in this.config.doubleUnderscore[ 1 ]
|
|
|
|
) {
|
Isolate build step to CM6 library and restructure files to work with RL
CodeMirror 6 requires the use of NPM, but we can still bundle all CM
packages into one file, and then everything else (i.e. our code) is
managed by ResourceLoader as per usual. This makes contribution
considerably easier as we no longer need a build step for each change.
CM5 files are now under resources/legacy, and the CM6 files are moved to
the root of the resources/ directory. Only one file,
codemirror.bundle.js, is managed by Rollup, while everything else is RL.
The Rollup output for now is put under resources/lib/ alongside the CM5
upstream files.
This patch is *mostly* renames of files, along with changing ECMAScript
Module (ESM) syntax into the CommonJS style that ResourceLoader prefers.
We also remove more modern JS syntax (i.e. private class methods) that
we were able to use before because we had a build step with Babel.
This patch should effectively make no user-facing changes, or to the
ResourceLoader modules we offer in Extension:CodeMirror.
Finally, bump version in extension.json to 6, to match the upstream lib,
and add Bhsd as an author :-)
Bug: T368053
Change-Id: Ie258e49f5df8db23a7344ac3c4c9300aaa991042
2024-06-21 03:21:09 +00:00
|
|
|
return mwModeConfig.tags.doubleUnderscore;
|
2023-12-06 18:49:40 +00:00
|
|
|
}
|
|
|
|
if ( !stream.eol() ) {
|
|
|
|
// Two underscore symbols at the end can be the
|
|
|
|
// beginning of another double underscored Magic Word
|
|
|
|
stream.backUp( 2 );
|
|
|
|
}
|
|
|
|
// Optimization: skip regex for EOL and backup-ed symbols
|
|
|
|
return this.makeStyle( style, state );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
2024-02-29 09:26:36 +00:00
|
|
|
case ':':
|
|
|
|
if ( state.nDt > 0 && !this.isNested( state ) ) {
|
|
|
|
state.nDt--;
|
Isolate build step to CM6 library and restructure files to work with RL
CodeMirror 6 requires the use of NPM, but we can still bundle all CM
packages into one file, and then everything else (i.e. our code) is
managed by ResourceLoader as per usual. This makes contribution
considerably easier as we no longer need a build step for each change.
CM5 files are now under resources/legacy, and the CM6 files are moved to
the root of the resources/ directory. Only one file,
codemirror.bundle.js, is managed by Rollup, while everything else is RL.
The Rollup output for now is put under resources/lib/ alongside the CM5
upstream files.
This patch is *mostly* renames of files, along with changing ECMAScript
Module (ESM) syntax into the CommonJS style that ResourceLoader prefers.
We also remove more modern JS syntax (i.e. private class methods) that
we were able to use before because we had a build step with Babel.
This patch should effectively make no user-facing changes, or to the
ResourceLoader modules we offer in Extension:CodeMirror.
Finally, bump version in extension.json to 6, to match the upstream lib,
and add Bhsd as an author :-)
Bug: T368053
Change-Id: Ie258e49f5df8db23a7344ac3c4c9300aaa991042
2024-06-21 03:21:09 +00:00
|
|
|
return mwModeConfig.tags.indenting;
|
2024-02-29 09:26:36 +00:00
|
|
|
}
|
|
|
|
break;
|
2023-12-06 18:49:40 +00:00
|
|
|
default:
|
|
|
|
if ( /[\s\u00a0]/.test( ch ) ) {
|
|
|
|
stream.eatSpace();
|
|
|
|
// highlight free external links, bug T108448
|
|
|
|
if ( stream.match( this.urlProtocols, false ) && !stream.match( '//' ) ) {
|
|
|
|
state.stack.push( state.tokenize );
|
|
|
|
state.tokenize = this.eatFreeExternalLinkProtocol.bind( this );
|
|
|
|
return this.makeStyle( style, state );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
stream.match( /^[^\s\u00a0_>}[\]<{'|&:~=]+/ );
|
|
|
|
return this.makeStyle( style, state );
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Remembers position and status for rollbacking.
|
|
|
|
* It is needed for changing from bold to italic with apostrophes before it, if required.
|
|
|
|
*
|
|
|
|
* @see https://phabricator.wikimedia.org/T108455
|
|
|
|
*
|
|
|
|
* @param {StringStream} stream
|
2024-03-19 03:10:11 +00:00
|
|
|
* @private
|
2023-12-06 18:49:40 +00:00
|
|
|
*/
|
|
|
|
prepareItalicForCorrection( stream ) {
|
|
|
|
// See Parser::doQuotes() in MediaWiki Core, it works similarly.
|
|
|
|
// this.firstSingleLetterWord has maximum priority
|
|
|
|
// this.firstMultiLetterWord has medium priority
|
|
|
|
// this.firstSpace has low priority
|
|
|
|
const end = stream.pos,
|
|
|
|
str = stream.string.slice( 0, end - 3 ),
|
|
|
|
x1 = str.slice( -1 ),
|
|
|
|
x2 = str.slice( -2, -1 );
|
|
|
|
|
|
|
|
// this.firstSingleLetterWord always is undefined here
|
|
|
|
if ( x1 === ' ' ) {
|
|
|
|
if ( this.firstMultiLetterWord || this.firstSpace ) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
this.firstSpace = end;
|
|
|
|
} else if ( x2 === ' ' ) {
|
|
|
|
this.firstSingleLetterWord = end;
|
|
|
|
} else if ( this.firstMultiLetterWord ) {
|
|
|
|
return;
|
|
|
|
} else {
|
|
|
|
this.firstMultiLetterWord = end;
|
|
|
|
}
|
|
|
|
// remember bold and italic state for later restoration
|
|
|
|
this.wasBold = this.isBold;
|
|
|
|
this.wasItalic = this.isItalic;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @see https://codemirror.net/docs/ref/#language.StreamParser
|
|
|
|
* @return {StreamParser}
|
2024-03-19 03:10:11 +00:00
|
|
|
* @private
|
2023-12-06 18:49:40 +00:00
|
|
|
*/
|
|
|
|
get mediawiki() {
|
|
|
|
return {
|
|
|
|
name: 'mediawiki',
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Initial State for the parser.
|
|
|
|
*
|
|
|
|
* @return {Object}
|
2024-03-19 03:10:11 +00:00
|
|
|
* @private
|
2023-12-06 18:49:40 +00:00
|
|
|
*/
|
2024-06-14 11:51:53 +00:00
|
|
|
startState: () => ( {
|
|
|
|
tokenize: this.eatWikiText( '' ),
|
|
|
|
stack: [],
|
|
|
|
inHtmlTag: [],
|
|
|
|
extName: false,
|
|
|
|
extMode: false,
|
|
|
|
extState: false,
|
|
|
|
nTemplate: 0,
|
|
|
|
nLink: 0,
|
|
|
|
nExt: 0,
|
|
|
|
nDt: 0
|
|
|
|
} ),
|
2023-12-06 18:49:40 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Copies the given state.
|
|
|
|
*
|
|
|
|
* @param {Object} state
|
|
|
|
* @return {Object}
|
2024-03-19 03:10:11 +00:00
|
|
|
* @private
|
2023-12-06 18:49:40 +00:00
|
|
|
*/
|
2024-06-14 11:51:53 +00:00
|
|
|
copyState: ( state ) => ( {
|
|
|
|
tokenize: state.tokenize,
|
|
|
|
stack: state.stack.concat( [] ),
|
|
|
|
inHtmlTag: state.inHtmlTag.concat( [] ),
|
|
|
|
extName: state.extName,
|
|
|
|
extMode: state.extMode,
|
|
|
|
extState: state.extMode !== false && state.extMode.copyState( state.extState ),
|
|
|
|
nTemplate: state.nTemplate,
|
|
|
|
nLink: state.nLink,
|
|
|
|
nExt: state.nExt,
|
|
|
|
nDt: state.nDt
|
|
|
|
} ),
|
2023-12-06 18:49:40 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Reads one token, advancing the stream past it,
|
|
|
|
* and returning a string indicating the token's style tag.
|
|
|
|
*
|
|
|
|
* @param {StringStream} stream
|
|
|
|
* @param {Object} state
|
|
|
|
* @return {string|null}
|
2024-03-19 03:10:11 +00:00
|
|
|
* @private
|
2023-12-06 18:49:40 +00:00
|
|
|
*/
|
|
|
|
token: ( stream, state ) => {
|
|
|
|
let style, p, t, f,
|
|
|
|
readyTokens = [],
|
|
|
|
tmpTokens = [];
|
|
|
|
|
|
|
|
if ( this.oldTokens.length > 0 ) {
|
|
|
|
// just send saved tokens till they exists
|
|
|
|
t = this.oldTokens.shift();
|
|
|
|
stream.pos = t.pos;
|
|
|
|
state = t.state;
|
|
|
|
return t.style;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( stream.sol() ) {
|
|
|
|
// reset bold and italic status in every new line
|
2024-02-29 09:26:36 +00:00
|
|
|
state.nDt = 0;
|
2023-12-06 18:49:40 +00:00
|
|
|
this.isBold = false;
|
|
|
|
this.isItalic = false;
|
|
|
|
this.firstSingleLetterWord = null;
|
|
|
|
this.firstMultiLetterWord = null;
|
|
|
|
this.firstSpace = null;
|
|
|
|
}
|
|
|
|
|
|
|
|
do {
|
|
|
|
// get token style
|
|
|
|
style = state.tokenize( stream, state );
|
|
|
|
f = this.firstSingleLetterWord || this.firstMultiLetterWord || this.firstSpace;
|
|
|
|
if ( f ) {
|
|
|
|
// rollback point exists
|
|
|
|
if ( f !== p ) {
|
|
|
|
// new rollback point
|
|
|
|
p = f;
|
|
|
|
// it's not first rollback point
|
|
|
|
if ( tmpTokens.length > 0 ) {
|
|
|
|
// save tokens
|
|
|
|
readyTokens = readyTokens.concat( tmpTokens );
|
|
|
|
tmpTokens = [];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// save token
|
|
|
|
tmpTokens.push( {
|
|
|
|
pos: stream.pos,
|
|
|
|
style,
|
|
|
|
state: ( state.extMode || this.mediawiki ).copyState( state )
|
|
|
|
} );
|
|
|
|
} else {
|
|
|
|
// rollback point does not exist
|
|
|
|
// remember style before possible rollback point
|
|
|
|
this.oldStyle = style;
|
|
|
|
// just return token style
|
|
|
|
return style;
|
|
|
|
}
|
|
|
|
} while ( !stream.eol() );
|
|
|
|
|
|
|
|
if ( this.isBold && this.isItalic ) {
|
|
|
|
// needs to rollback
|
|
|
|
// restore status
|
|
|
|
this.isItalic = this.wasItalic;
|
|
|
|
this.isBold = this.wasBold;
|
|
|
|
this.firstSingleLetterWord = null;
|
|
|
|
this.firstMultiLetterWord = null;
|
|
|
|
this.firstSpace = null;
|
|
|
|
if ( readyTokens.length > 0 ) {
|
|
|
|
// it contains tickets before the point of rollback
|
|
|
|
// add one apostrophe, next token will be italic (two apostrophes)
|
|
|
|
readyTokens[ readyTokens.length - 1 ].pos++;
|
|
|
|
// for sending tokens till the point of rollback
|
|
|
|
this.oldTokens = readyTokens;
|
|
|
|
} else {
|
|
|
|
// there are no tickets before the point of rollback
|
|
|
|
stream.pos = tmpTokens[ 0 ].pos - 2; // eat( '\'')
|
|
|
|
// send saved Style
|
|
|
|
return this.oldStyle;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
// do not need to rollback
|
|
|
|
// send all saved tokens
|
|
|
|
this.oldTokens = readyTokens.concat( tmpTokens );
|
|
|
|
}
|
|
|
|
// return first saved token
|
|
|
|
t = this.oldTokens.shift();
|
|
|
|
stream.pos = t.pos;
|
|
|
|
state = t.state;
|
|
|
|
return t.style;
|
|
|
|
},
|
|
|
|
|
2024-03-19 03:10:11 +00:00
|
|
|
/**
|
|
|
|
* @param {Object} state
|
|
|
|
* @private
|
|
|
|
*/
|
2023-12-06 18:49:40 +00:00
|
|
|
blankLine: ( state ) => {
|
|
|
|
if ( state.extMode && state.extMode.blankLine ) {
|
|
|
|
state.extMode.blankLine( state.extState );
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Extra tokens to use in this parser.
|
|
|
|
*
|
2024-03-11 18:10:08 +00:00
|
|
|
* @see CodeMirrorModeMediaWikiConfig.defaultTokenTable
|
2023-12-06 18:49:40 +00:00
|
|
|
* @return {Object<Tag>}
|
2024-03-19 03:10:11 +00:00
|
|
|
* @private
|
2023-12-06 18:49:40 +00:00
|
|
|
*/
|
2024-01-04 04:01:27 +00:00
|
|
|
tokenTable: this.tokenTable
|
2023-12-06 18:49:40 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets a LanguageSupport instance for the MediaWiki mode.
|
|
|
|
*
|
2024-03-19 03:10:11 +00:00
|
|
|
* @member CodeMirrorModeMediaWiki
|
|
|
|
* @method
|
|
|
|
* @param {Object} [config] Configuration options for the MediaWiki mode.
|
|
|
|
* @param {boolean} [config.bidiIsolation=false] Enable bidi isolation around HTML tags.
|
|
|
|
* This should generally always be enabled on RTL pages, but it comes with a performance cost.
|
2024-06-08 03:10:11 +00:00
|
|
|
* @param {boolean} [config.templateFolding=true] Enable template folding.
|
2024-03-14 18:32:14 +00:00
|
|
|
* @param {Object|null} [mwConfig] Ignore; used only by unit tests.
|
2023-12-06 18:49:40 +00:00
|
|
|
* @return {LanguageSupport}
|
2024-03-19 03:10:11 +00:00
|
|
|
* @stable to call
|
2023-12-06 18:49:40 +00:00
|
|
|
*/
|
Isolate build step to CM6 library and restructure files to work with RL
CodeMirror 6 requires the use of NPM, but we can still bundle all CM
packages into one file, and then everything else (i.e. our code) is
managed by ResourceLoader as per usual. This makes contribution
considerably easier as we no longer need a build step for each change.
CM5 files are now under resources/legacy, and the CM6 files are moved to
the root of the resources/ directory. Only one file,
codemirror.bundle.js, is managed by Rollup, while everything else is RL.
The Rollup output for now is put under resources/lib/ alongside the CM5
upstream files.
This patch is *mostly* renames of files, along with changing ECMAScript
Module (ESM) syntax into the CommonJS style that ResourceLoader prefers.
We also remove more modern JS syntax (i.e. private class methods) that
we were able to use before because we had a build step with Babel.
This patch should effectively make no user-facing changes, or to the
ResourceLoader modules we offer in Extension:CodeMirror.
Finally, bump version in extension.json to 6, to match the upstream lib,
and add Bhsd as an author :-)
Bug: T368053
Change-Id: Ie258e49f5df8db23a7344ac3c4c9300aaa991042
2024-06-21 03:21:09 +00:00
|
|
|
const mediaWikiLang = ( config = { bidiIsolation: false }, mwConfig = null ) => {
|
2024-03-14 18:32:14 +00:00
|
|
|
mwConfig = mwConfig || mw.config.get( 'extCodeMirrorConfig' );
|
|
|
|
const mode = new CodeMirrorModeMediaWiki( mwConfig );
|
2024-01-04 04:01:27 +00:00
|
|
|
const parser = mode.mediawiki;
|
2023-12-06 18:49:40 +00:00
|
|
|
const lang = StreamLanguage.define( parser );
|
2024-03-11 18:10:08 +00:00
|
|
|
const langExtension = [ syntaxHighlighting(
|
2024-01-04 04:01:27 +00:00
|
|
|
HighlightStyle.define(
|
Isolate build step to CM6 library and restructure files to work with RL
CodeMirror 6 requires the use of NPM, but we can still bundle all CM
packages into one file, and then everything else (i.e. our code) is
managed by ResourceLoader as per usual. This makes contribution
considerably easier as we no longer need a build step for each change.
CM5 files are now under resources/legacy, and the CM6 files are moved to
the root of the resources/ directory. Only one file,
codemirror.bundle.js, is managed by Rollup, while everything else is RL.
The Rollup output for now is put under resources/lib/ alongside the CM5
upstream files.
This patch is *mostly* renames of files, along with changing ECMAScript
Module (ESM) syntax into the CommonJS style that ResourceLoader prefers.
We also remove more modern JS syntax (i.e. private class methods) that
we were able to use before because we had a build step with Babel.
This patch should effectively make no user-facing changes, or to the
ResourceLoader modules we offer in Extension:CodeMirror.
Finally, bump version in extension.json to 6, to match the upstream lib,
and add Bhsd as an author :-)
Bug: T368053
Change-Id: Ie258e49f5df8db23a7344ac3c4c9300aaa991042
2024-06-21 03:21:09 +00:00
|
|
|
mwModeConfig.getTagStyles( parser )
|
2024-01-04 04:01:27 +00:00
|
|
|
)
|
2024-03-11 18:10:08 +00:00
|
|
|
) ];
|
|
|
|
|
CodeMirrorPreferences: add panel to tweak prefs with the editor open
This is toggled by pressing Mod-Shift-, (or Command-Shift-, on MacOS),
which then puts focus on the preferences panel. It can be closed with
the Escape key, just like other CM panels.
The CodeMirror class comes with these extension which can be toggled in
preferences:
* Bracket matching
* Line numbering
* Line wrapping
* Highlight the active line
* Show special characters
Only bracket matching, line numbering, and line wrapping are available
in the 2017 editor.
The bidi isolation and template folding extensions are registered in
CodeMirrorModeMediaWiki as they are MW-specific. CodeMirrorPreferences'
new registerExtension() method allows any consumer of CodeMirror to add
any arbitrary extensions to the preferences panel. This is expected to
be called *after* CodeMirror has finished initializing. The
'ext.CodeMirror.ready' hook now passes the CodeMirror instance to
accommodate this.
The preferences are stored as a single user option in the database,
called 'codemirror-preferences'. The defaults can be configured with the
$wgCodeMirrorDefaultPreferences configuration setting. The
sysadmin-facing values are the familiar boolean, but since CodeMirror is
widely used, we make extra efforts to reduce the storage footprint (see
T54777). This includes only storing preferences that differ from the
defaults, and using binary representation instead of boolean values,
since the user option is stored as a string.
For now, all preferences are ignored in the 2017 editor. In a future
patch, we may add some as toggleable Tools in the VE toolbar.
Other changes:
* Refactor CSS to use a .darkmode() mixin
* Add a method to create a CSS-only fieldset in CodeMirrorPanel
* Fix Jest tests now that there are more calls to mw.user.options.get()
* Adjust Selenium tests to always use CM6
* Adjust Selenium tests to delete test pages (useful for local dev)
* Remove unused code
Bug: T359498
Change-Id: I70dcf2f49418cea632c452c1266440effad634f3
2024-08-16 01:52:13 +00:00
|
|
|
// Register MW-specific Extensions into CodeMirror preferences. Whether they are enabled
|
|
|
|
// or not is determined by the user's preferences and wiki configuration.
|
|
|
|
mw.hook( 'ext.CodeMirror.ready' ).add( ( $textarea, cm ) => {
|
|
|
|
if ( config.templateFolding !== false ) {
|
|
|
|
cm.preferences.registerExtension( 'templateFolding', templateFoldingExtension, cm.view );
|
|
|
|
}
|
|
|
|
if ( config.bidiIsolation ) {
|
|
|
|
cm.preferences.registerExtension( 'bidiIsolation', bidiIsolationExtension, cm.view );
|
|
|
|
}
|
|
|
|
} );
|
2024-03-14 18:32:14 +00:00
|
|
|
|
2024-03-11 18:10:08 +00:00
|
|
|
return new LanguageSupport( lang, langExtension );
|
2023-12-06 18:49:40 +00:00
|
|
|
};
|
Isolate build step to CM6 library and restructure files to work with RL
CodeMirror 6 requires the use of NPM, but we can still bundle all CM
packages into one file, and then everything else (i.e. our code) is
managed by ResourceLoader as per usual. This makes contribution
considerably easier as we no longer need a build step for each change.
CM5 files are now under resources/legacy, and the CM6 files are moved to
the root of the resources/ directory. Only one file,
codemirror.bundle.js, is managed by Rollup, while everything else is RL.
The Rollup output for now is put under resources/lib/ alongside the CM5
upstream files.
This patch is *mostly* renames of files, along with changing ECMAScript
Module (ESM) syntax into the CommonJS style that ResourceLoader prefers.
We also remove more modern JS syntax (i.e. private class methods) that
we were able to use before because we had a build step with Babel.
This patch should effectively make no user-facing changes, or to the
ResourceLoader modules we offer in Extension:CodeMirror.
Finally, bump version in extension.json to 6, to match the upstream lib,
and add Bhsd as an author :-)
Bug: T368053
Change-Id: Ie258e49f5df8db23a7344ac3c4c9300aaa991042
2024-06-21 03:21:09 +00:00
|
|
|
|
|
|
|
module.exports = mediaWikiLang;
|