Page Menu
Home
WickedGov Phorge
Search
Configure Global Search
Log In
Files
F5937850
codemirror.javascript.js
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
2 KB
Referenced Files
None
Subscribers
None
codemirror.javascript.js
View Options
const
{
javascript
,
javascriptLanguage
,
scopeCompletionSource
}
=
require
(
'../lib/codemirror6.bundle.modes.js'
);
const
CodeMirrorMode
=
require
(
'./codemirror.mode.js'
);
const
CodeMirrorWorker
=
require
(
'../workers/codemirror.worker.js'
);
/**
* JavaScript language support for CodeMirror.
*
* @example
* const require = await mw.loader.using( [ 'ext.CodeMirror.v6', 'ext.CodeMirror.v6.modes' ] );
* const CodeMirror = require( 'ext.CodeMirror.v6' );
* const { javascript } = require( 'ext.CodeMirror.v6.modes' );
* const cm = new CodeMirror( myTextarea, javascript() );
* cm.initialize();
* @extends CodeMirrorMode
* @hideconstructor
*/
class
CodeMirrorJavaScript
extends
CodeMirrorMode
{
/** @inheritDoc */
get
language
()
{
return
javascriptLanguage
;
}
/** @inheritDoc */
get
lintSource
()
{
return
async
(
view
)
=>
{
const
data
=
await
this
.
worker
.
lint
(
view
);
return
data
.
map
(
(
{
ruleId
,
message
,
severity
,
line
,
column
,
endLine
,
endColumn
,
fix
,
suggestions
=
[]
}
)
=>
{
const
start
=
CodeMirrorWorker
.
pos
(
view
,
line
,
column
);
const
diagnostic
=
{
rule
:
ruleId
,
source
:
'ESLint'
,
message
:
message
+
(
ruleId
?
` (
${
ruleId
}
)`
:
''
),
severity
:
severity
===
1
?
'info'
:
'error'
,
from
:
start
,
to
:
endLine
===
undefined
?
start
+
1
:
CodeMirrorWorker
.
pos
(
view
,
endLine
,
endColumn
)
};
if
(
fix
||
suggestions
.
length
)
{
diagnostic
.
actions
=
[
...
fix
?
[
{
name
:
'fix'
,
fix
}
]
:
[],
...
suggestions
.
map
(
(
suggestion
)
=>
(
{
name
:
'suggestion'
,
fix
:
suggestion
.
fix
}
)
)
].
map
(
(
{
name
,
fix
:
{
range
:
[
from
,
to
],
text
}
}
)
=>
(
{
name
,
apply
(
v
)
{
v
.
dispatch
(
{
changes
:
{
from
,
to
,
insert
:
text
}
}
);
}
}
)
);
}
return
diagnostic
;
}
);
};
}
/** @inheritDoc */
get
support
()
{
return
[
javascript
().
support
,
javascriptLanguage
.
data
.
of
(
{
autocomplete
:
scopeCompletionSource
(
window
)
}
)
];
}
}
module
.
exports
=
CodeMirrorJavaScript
;
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Oct 2 2026, 16:02 (6 w, 5 d ago)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
99/42/a1db581ddd7662ed7fbc87b7e693
Default Alt Text
codemirror.javascript.js (2 KB)
Attached To
Mode
rMWPROD MediaWiki Production
Attached
Detach File
Event Timeline
Log In to Comment