Skip to content

Commit 9ab1f3c

Browse files
committed
custom plugins
1 parent 74cbd4d commit 9ab1f3c

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

src/angular-annotator.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,33 @@ angular.module('mwAnnotator').directive('mwAnnotator', function () {
4242
annotator.addPlugin('Markdown');
4343
}
4444

45+
if(attrs.annotatorPlugins){
46+
var pluginList = scope.$eval(attrs.annotatorPlugins);
47+
if(pluginList instanceof Array){
48+
for(var i=0; i<pluginList.length; i++){
49+
var plugin = pluginList[i];
4550

51+
52+
var pluginName = null;
53+
var pluginOptions = null;
54+
if(typeof plugin === 'object'){
55+
pluginName = plugin.name;
56+
pluginOptions = plugin.options;
57+
}else if(typeof plugin === 'string'){
58+
pluginName = plugin;
59+
}
60+
if(pluginName){
61+
if(!pluginOptions){
62+
annotator.addPlugin(pluginName)
63+
}else{
64+
annotator.addPlugin(pluginName, pluginOptions);
65+
}
66+
67+
}
68+
69+
}
70+
}
71+
}
4672
}
4773
};
4874
});

0 commit comments

Comments
 (0)