Created
August 7, 2015 15:58
-
-
Save edg2s/8ceee4f112c8663c3913 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*! | |
* VisualEditor UserInterface my pattern transfer handler class. | |
* | |
* @copyright 2011-2015 VisualEditor Team and others; see http://ve.mit-license.org | |
*/ | |
/** | |
* My pattern transfer handler. | |
* | |
* @class | |
* @extends ve.ui.PlainTextStringTransferHandler | |
* | |
* @constructor | |
* @param {ve.ui.Surface} surface | |
* @param {ve.ui.DataTransferItem} item | |
*/ | |
ve.ui.MyPatternTransferHandler = function VeUiMyPatternTransferHandler() { | |
// Parent constructor | |
ve.ui.MyPatternTransferHandler.super.apply( this, arguments ); | |
}; | |
/* Inheritance */ | |
OO.inheritClass( ve.ui.MyPatternTransferHandler, ve.ui.PlainTextStringTransferHandler ); | |
/* Static properties */ | |
ve.ui.MyPatternTransferHandler.static.name = 'myPattern'; | |
ve.ui.MyPatternTransferHandler.static.handlesPaste = true; | |
ve.ui.MyPatternTransferHandler.static.matchFunction = function ( item ) { | |
return /MyPattern/.test( item.getAsString() ); | |
}; | |
/* Methods */ | |
/** | |
* @inheritdoc | |
*/ | |
ve.ui.MyPatternTransferHandler.prototype.process = function () { | |
var text = this.item.getAsString(); | |
// convert text to dataToInsert | |
this.resolve( dataToInsert ); | |
}; | |
/* Registration */ | |
ve.ui.dataTransferHandlerFactory.register( ve.ui.MyPatternTransferHandler ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment