VE: Add explicit dependency on targetLoader

Change-Id: Ied1af70713b3595b87e2ea2f45797777f32ff7a0
This commit is contained in:
Ed Sanders 2020-06-30 16:14:17 +01:00
parent 6d19fd9033
commit 4b5e2362fe

View file

@ -1,27 +1,29 @@
mw.libs.ve.targetLoader.addPlugin( function () {
mw.loader.using( 'ext.visualEditor.targetLoader' ).then( function () {
mw.libs.ve.targetLoader.addPlugin( function () {
ve.init.mw.AbuseFilterSaveErrorHandler = function () {};
ve.init.mw.AbuseFilterSaveErrorHandler = function () {};
OO.inheritClass( ve.init.mw.AbuseFilterSaveErrorHandler, ve.init.mw.SaveErrorHandler );
OO.inheritClass( ve.init.mw.AbuseFilterSaveErrorHandler, ve.init.mw.SaveErrorHandler );
ve.init.mw.AbuseFilterSaveErrorHandler.static.name = 'abuseFilter';
ve.init.mw.AbuseFilterSaveErrorHandler.static.name = 'abuseFilter';
ve.init.mw.AbuseFilterSaveErrorHandler.static.matchFunction = function ( data ) {
return data.errors && data.errors.some( function ( err ) {
return err.code === 'abusefilter-disallowed' || err.code === 'abusefilter-warning';
} );
};
ve.init.mw.AbuseFilterSaveErrorHandler.static.matchFunction = function ( data ) {
return data.errors && data.errors.some( function ( err ) {
return err.code === 'abusefilter-disallowed' || err.code === 'abusefilter-warning';
} );
};
ve.init.mw.AbuseFilterSaveErrorHandler.static.process = function ( data, target ) {
var isWarning = data.errors.every( function ( err ) {
return err.code === 'abusefilter-warning';
} );
// Handle warnings/errors from Extension:AbuseFilter
target.showSaveError( target.extractErrorMessages( data ), isWarning, isWarning );
// Emit event for tracking. TODO: This is a bad design
target.emit( 'saveErrorAbuseFilter' );
};
ve.init.mw.AbuseFilterSaveErrorHandler.static.process = function ( data, target ) {
var isWarning = data.errors.every( function ( err ) {
return err.code === 'abusefilter-warning';
} );
// Handle warnings/errors from Extension:AbuseFilter
target.showSaveError( target.extractErrorMessages( data ), isWarning, isWarning );
// Emit event for tracking. TODO: This is a bad design
target.emit( 'saveErrorAbuseFilter' );
};
ve.init.mw.saveErrorHandlerFactory.register( ve.init.mw.AbuseFilterSaveErrorHandler );
ve.init.mw.saveErrorHandlerFactory.register( ve.init.mw.AbuseFilterSaveErrorHandler );
} );
} );