mediawiki-extensions-SpamBl.../modules/ve-spamblacklist/ve.init.mw.SpamBlacklistSaveErrorHandler.js
Ed Sanders 6f12ed377f VE: Add explicit dependency on targetLoader
Change-Id: Ib61e5ae5f2bc28a02851d78cfa368438860bf871
2020-06-30 22:47:28 +01:00

30 lines
1,019 B
JavaScript

mw.loader.using( 'ext.visualEditor.targetLoader' ).then( function () {
mw.libs.ve.targetLoader.addPlugin( function () {
ve.init.mw.SpamBlacklistSaveErrorHandler = function () {};
OO.inheritClass( ve.init.mw.SpamBlacklistSaveErrorHandler, ve.init.mw.SaveErrorHandler );
ve.init.mw.SpamBlacklistSaveErrorHandler.static.name = 'spamBlacklist';
ve.init.mw.SpamBlacklistSaveErrorHandler.static.matchFunction = function ( data ) {
return data.errors && data.errors.some( function ( err ) {
return err.code === 'spamblacklist';
} );
};
ve.init.mw.SpamBlacklistSaveErrorHandler.static.process = function ( data, target ) {
// Handle spam blacklist error from Extension:SpamBlacklist
target.showSaveError(
target.extractErrorMessages( data ),
false // prevents reapply
);
// Emit event for tracking. TODO: This is a bad design
target.emit( 'saveErrorSpamBlacklist' );
};
ve.init.mw.saveErrorHandlerFactory.register( ve.init.mw.SpamBlacklistSaveErrorHandler );
} );
} );