-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathplugin.min.js
More file actions
1 lines (1 loc) · 1.87 KB
/
plugin.min.js
File metadata and controls
1 lines (1 loc) · 1.87 KB
1
tinymce.PluginManager.requireLangPack("blockquote");tinymce.PluginManager.add("blockquote",function(d){var e=false,b=false,c={};function a(){var j=d.selection,l=d.dom,g=j.getContent(),m,h,f;c={quote:"",author:"",linkLabel:"",linkUrl:""};e=j.getNode();if(e.nodeName=="BODY"&&g.length==0){b=false}else{b=true;try{while(l.getParent(e).parentNode){if(e.nodeName=="BLOCKQUOTE"){for(h=0;h<e.childNodes.length;h++){m=e.childNodes[h];if(m.nodeName!="CITE"){c.quote+=m.textContent}else{f=m.getElementsByTagName("a");if(f.length>0){c.linkUrl=f[0].href;c.linkLabel=f[0].textContent}c.author=m.textContent;if(c.linkLabel!=""){c.author=c.author.replace(c.linkLabel,"")}}}break}e=l.getParent(e).parentNode}}catch(k){e=j.getNode();if(e.nodeName=="BODY"){e=j.getSelectedBlocks();c.quote=g.replace(/<br \/>/g,"\r\n").replace(/<\/p>/g,"\r\n").replace(/(<[^>]*>)/g,"").replace(/ /g,"")}else{e=l.getParent(j.getNode());c.quote=e.innerHTML.replace(/<br \/>/g,"\r\n").replace(/(<[^>]*>)/g,"").replace(/ /g,"")}}}d.windowManager.open({title:"Quote",data:c,body:[{type:"label",text:"Quote :"},{name:"quote",type:"textbox",minHeight:150,minWidth:500,multiline:true},{type:"label",text:"Cite :"},{name:"author",type:"textbox"},{type:"label",text:"Link label :"},{name:"linkLabel",type:"textbox"},{type:"label",text:"Link url :"},{name:"linkUrl",type:"textbox"}],onsubmit:function(q){var n=q.data.quote.replace(/(\r|\r\n|\n)/g,"<br />"),p=q.data.author,o=q.data.linkLabel,i=q.data.linkUrl;p=(p!="")?p+" ":"";o=(o!="")?o:i;o=(i!="")?'<a href="'+i+'">'+o+"</a>":"";if(p!=""||o!=""||i!=""){p="<cite>"+p+o+"</cite>"}if(b==true){d.dom.remove(e)}d.insertContent("<blockquote><p>"+n+"</p>"+p+"</blockquote><p> </p>",{format:"raw"})}})}d.addButton("blockquote",{icon:"blockquote",tooltip:"Insert Quote",onclick:function(){a()}});d.addMenuItem("blockquote",{text:"Quote",icon:"blockquote",context:"insert",onclick:function(){a()}})});