editor.js/plugins/paste/paste.js

40 lines
743 B
JavaScript
Raw Normal View History

/**
* Paste plugin.
*
2017-01-12 15:42:10 +01:00
* Listen to clipboard paste event and analize pasted text whit patterns in pattern.js
*/
/**
* @protected
*
* Main tool settings.
*/
var pasteTool = {
/**
* Saves data
* @param event
*/
pasted : function(event) {
var clipBoardData = event.clipboardData || window.clipboardData,
content = clipBoardData.getData('Text');
pasteTool.analize(content);
},
/**
* Analizes pated string and calls necessary method
*/
analize : function(string) {
pasteTool.patterns.map(function(pattern, i){
if (pattern.regex.test(string)) {
pattern.callback.call(null, string, pattern);
}
})
2017-01-11 16:48:57 +01:00
}
};