Page Menu
Home
WickedGov Phorge
Search
Configure Global Search
Log In
Files
F7448511
ve.ui.CodeMirrorTool.v6.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
ve.ui.CodeMirrorTool.v6.js
View Options
/**
* VisualEditor UserInterface CodeMirror tool.
*
* @class
* @abstract
* @extends ve.ui.Tool
* @constructor
* @param {OO.ui.ToolGroup} toolGroup
* @param {Object} [config] Configuration options
*/
ve
.
ui
.
CodeMirrorTool
=
function
VeUiCodeMirrorTool
()
{
// Parent constructor
ve
.
ui
.
CodeMirrorTool
.
super
.
apply
(
this
,
arguments
);
// Events
this
.
toolbar
.
connect
(
this
,
{
surfaceChange
:
'onSurfaceChange'
}
);
};
/* Inheritance */
OO
.
inheritClass
(
ve
.
ui
.
CodeMirrorTool
,
ve
.
ui
.
Tool
);
/* Static properties */
ve
.
ui
.
CodeMirrorTool
.
static
.
name
=
'codeMirror'
;
ve
.
ui
.
CodeMirrorTool
.
static
.
autoAddToCatchall
=
false
;
ve
.
ui
.
CodeMirrorTool
.
static
.
title
=
OO
.
ui
.
deferMsg
(
'codemirror-toggle-label'
);
ve
.
ui
.
CodeMirrorTool
.
static
.
icon
=
'highlight'
;
ve
.
ui
.
CodeMirrorTool
.
static
.
group
=
'utility'
;
ve
.
ui
.
CodeMirrorTool
.
static
.
commandName
=
'codeMirror'
;
ve
.
ui
.
CodeMirrorTool
.
static
.
deactivateOnSelect
=
false
;
/**
* @inheritdoc
*/
ve
.
ui
.
CodeMirrorTool
.
prototype
.
onSelect
=
function
()
{
// Parent method
ve
.
ui
.
CodeMirrorTool
.
super
.
prototype
.
onSelect
.
apply
(
this
,
arguments
);
// This is the value of what CM will be toggled to.
// When CM has not been loaded yet (the mirror property is undefined), this should return true.
const
useCodeMirror
=
!
this
.
toolbar
.
surface
.
mirror
||
this
.
toolbar
.
surface
.
mirror
.
isActive
;
this
.
setActive
(
useCodeMirror
);
};
/**
* @inheritdoc
*/
ve
.
ui
.
CodeMirrorTool
.
prototype
.
onSurfaceChange
=
function
(
oldSurface
,
newSurface
)
{
const
isDisabled
=
newSurface
.
getMode
()
!==
'source'
;
this
.
setDisabled
(
isDisabled
);
if
(
!
isDisabled
)
{
const
command
=
this
.
getCommand
();
const
surface
=
this
.
toolbar
.
getSurface
();
const
useCodeMirror
=
mw
.
user
.
options
.
get
(
'usecodemirror'
)
>
0
;
command
.
execute
(
surface
,
[
useCodeMirror
]
);
this
.
setActive
(
useCodeMirror
);
}
};
ve
.
ui
.
CodeMirrorTool
.
prototype
.
onUpdateState
=
function
()
{};
/* Registration */
ve
.
ui
.
toolFactory
.
register
(
ve
.
ui
.
CodeMirrorTool
);
/* Command */
ve
.
ui
.
commandRegistry
.
register
(
new
ve
.
ui
.
Command
(
'codeMirror'
,
'codeMirror'
,
'toggle'
)
);
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Nov 22, 19:41 (1 d, 12 h ago)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
99/e9/4cc3ae8c12d4ab9125bfd428fddc
Default Alt Text
ve.ui.CodeMirrorTool.v6.js (2 KB)
Attached To
Mode
rMWPROD MediaWiki Production
Attached
Detach File
Event Timeline
Log In to Comment