mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/CodeMirror
synced 2024-11-23 22:03:28 +00:00
Remove unnecessary local context variables
Change-Id: If73c0cfca93711003ece3332c9cdc6f3e3fa4944
This commit is contained in:
parent
f0fb93d3e1
commit
b3316356c0
|
@ -51,8 +51,7 @@ ve.ui.CodeMirrorAction.static.isLineNumbering = function () {
|
||||||
* @return {boolean} Action was executed
|
* @return {boolean} Action was executed
|
||||||
*/
|
*/
|
||||||
ve.ui.CodeMirrorAction.prototype.toggle = function ( enable ) {
|
ve.ui.CodeMirrorAction.prototype.toggle = function ( enable ) {
|
||||||
const action = this,
|
const surface = this.surface,
|
||||||
surface = this.surface,
|
|
||||||
surfaceView = surface.getView(),
|
surfaceView = surface.getView(),
|
||||||
doc = surface.getModel().getDocument();
|
doc = surface.getModel().getDocument();
|
||||||
|
|
||||||
|
@ -133,7 +132,7 @@ ve.ui.CodeMirrorAction.prototype.toggle = function ( enable ) {
|
||||||
|
|
||||||
if ( cmOptions.lineNumbers ) {
|
if ( cmOptions.lineNumbers ) {
|
||||||
// Transfer gutter width to VE overlay.
|
// Transfer gutter width to VE overlay.
|
||||||
const updateGutter = function ( cmDisplay ) {
|
const updateGutter = ( cmDisplay ) => {
|
||||||
surfaceView.$documentNode.css( 'margin-left', cmDisplay.gutters.offsetWidth );
|
surfaceView.$documentNode.css( 'margin-left', cmDisplay.gutters.offsetWidth );
|
||||||
};
|
};
|
||||||
CodeMirror.on( surface.mirror.display, 'updateGutter', updateGutter );
|
CodeMirror.on( surface.mirror.display, 'updateGutter', updateGutter );
|
||||||
|
@ -144,15 +143,15 @@ ve.ui.CodeMirrorAction.prototype.toggle = function ( enable ) {
|
||||||
|
|
||||||
// As the action is regenerated each time, we need to store bound listeners
|
// As the action is regenerated each time, we need to store bound listeners
|
||||||
// in the mirror for later disconnection.
|
// in the mirror for later disconnection.
|
||||||
surface.mirror.veTransactionListener = action.onDocumentPrecommit.bind( action );
|
surface.mirror.veTransactionListener = this.onDocumentPrecommit.bind( this );
|
||||||
surface.mirror.veLangChangeListener = action.onLangChange.bind( action );
|
surface.mirror.veLangChangeListener = this.onLangChange.bind( this );
|
||||||
surface.mirror.veSelectListener = action.onSelect.bind( action );
|
surface.mirror.veSelectListener = this.onSelect.bind( this );
|
||||||
|
|
||||||
doc.on( 'precommit', surface.mirror.veTransactionListener );
|
doc.on( 'precommit', surface.mirror.veTransactionListener );
|
||||||
surfaceView.getDocument().on( 'langChange', surface.mirror.veLangChangeListener );
|
surfaceView.getDocument().on( 'langChange', surface.mirror.veLangChangeListener );
|
||||||
surface.getModel().on( 'select', surface.mirror.veSelectListener );
|
surface.getModel().on( 'select', surface.mirror.veSelectListener );
|
||||||
|
|
||||||
action.onLangChange();
|
this.onLangChange();
|
||||||
|
|
||||||
ve.init.target.once( 'surfaceReady', () => {
|
ve.init.target.once( 'surfaceReady', () => {
|
||||||
if ( surface.mirror ) {
|
if ( surface.mirror ) {
|
||||||
|
@ -227,7 +226,6 @@ ve.ui.CodeMirrorAction.prototype.onLangChange = function () {
|
||||||
*/
|
*/
|
||||||
ve.ui.CodeMirrorAction.prototype.onDocumentPrecommit = function ( tx ) {
|
ve.ui.CodeMirrorAction.prototype.onDocumentPrecommit = function ( tx ) {
|
||||||
const replacements = [],
|
const replacements = [],
|
||||||
action = this,
|
|
||||||
store = this.surface.getModel().getDocument().getStore(),
|
store = this.surface.getModel().getDocument().getStore(),
|
||||||
mirror = this.surface.mirror;
|
mirror = this.surface.mirror;
|
||||||
|
|
||||||
|
@ -237,9 +235,9 @@ ve.ui.CodeMirrorAction.prototype.onDocumentPrecommit = function ( tx ) {
|
||||||
offset += op.length;
|
offset += op.length;
|
||||||
} else if ( op.type === 'replace' ) {
|
} else if ( op.type === 'replace' ) {
|
||||||
replacements.push( {
|
replacements.push( {
|
||||||
start: action.getPosFromOffset( offset ),
|
start: this.getPosFromOffset( offset ),
|
||||||
// Don't bother recalculating end offset if not a removal, replaceRange works with just one arg
|
// Don't bother recalculating end offset if not a removal, replaceRange works with just one arg
|
||||||
end: op.remove.length ? action.getPosFromOffset( offset + op.remove.length ) : undefined,
|
end: op.remove.length ? this.getPosFromOffset( offset + op.remove.length ) : undefined,
|
||||||
data: new ve.dm.ElementLinearData( store, op.insert ).getSourceText()
|
data: new ve.dm.ElementLinearData( store, op.insert ).getSourceText()
|
||||||
} );
|
} );
|
||||||
offset += op.remove.length;
|
offset += op.remove.length;
|
||||||
|
|
Loading…
Reference in a new issue