-
Notifications
You must be signed in to change notification settings - Fork 1
/
editor_plugin.js
1 lines (1 loc) · 1.72 KB
/
editor_plugin.js
1
(function(){tinymce.PluginManager.requireLangPack('etherpadlite');tinymce.create('tinymce.plugins.EtherPadLitePlugin',{init:function(ed,url){var t=this;t.editor=ed;if(!ed.getParam("plugin_etherpadlite_padServerUrl")){alert(etherpadlite.error);return null}var padUrl=ed.getParam("plugin_etherpadlite_padServerUrl");var padPrefix=(ed.getParam("plugin_etherpadlite_padNamesPrefix"))?ed.getParam("plugin_etherpadlite_padNamesPrefix"):"";var padWidth=(ed.getParam("plugin_etherpadlite_padWidth"))?ed.getParam("plugin_etherpadlite_padWidth"):"100%";var padHeight=(ed.getParam("plugin_etherpadlite_padHeight"))?ed.getParam("plugin_etherpadlite_padHeight"):"400";ed.addCommand('mceEtherPadLite',function(){var padName=padPrefix+'.'+randomPadName();var iframe="<iframe name='embed_readwrite' src='"+padUrl+padName+"?showControls=true&showChat=true&&alwaysShowChat=true&lang=pt&showLineNumbers=true&useMonospaceFont=false' width='"+padWidth+"' height='"+padHeight+"'></iframe>";ed.execCommand('mceInsertContent',false,iframe)});ed.addButton('etherpadlite',{title:'etherpadlite.desc',cmd:'mceEtherPadLite',image:url+'/img/etherpadlite.gif'})},getInfo:function(){return{longname:'Insert a collaborative text with Etherpad Lite',author:'Daniel Tygel',authorurl:'http://cirandas.net/dtygel',infourl:'https://github.com/dtygel/tinymce-etherpadlite-embed',version:tinymce.majorVersion+"."+tinymce.minorVersion}}});function randomPadName(){var chars="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";var string_length=10;var randomstring='';for(var i=0;i<string_length;i++){var rnum=Math.floor(Math.random()*chars.length);randomstring+=chars.substring(rnum,rnum+1)}return randomstring}tinymce.PluginManager.add('etherpadlite',tinymce.plugins.EtherPadLitePlugin)})();