tinymce.PluginManager.add("importcss",function(e){function t(t){var n=e.settings,r=n.skin!==!1?n.skin||"lightgray":!1;if(r){var i=n.skin_url;return i=i?e.documentBaseURI.toAbsolute(i):tinymce.baseURL+"/skins/"+r,t===i+"/content"+(e.inline?".inline":"")+".min.css"}return!1}function n(e){return"string"==typeof e?function(t){return-1!==t.indexOf(e)}:e instanceof RegExp?function(t){return e.test(t)}:e}function r(n,r){function i(e,n){var s,l=e.href;if(l&&r(l,n)&&!t(l)){a(e.imports,function(e){i(e,!0)});try{s=e.cssRules||e.rules}catch(c){}a(s,function(e){e.styleSheet?i(e.styleSheet,!0):e.selectorText&&a(e.selectorText.split(","),function(e){o.push(tinymce.trim(e))})})}}var o=[],s={};a(e.contentCSS,function(e){s[e]=!0}),r||(r=function(e,t){return t||s[e]});try{a(n.styleSheets,function(e){i(e)})}catch(l){}return o}function i(t){var n,r=/^(?:([a-z0-9\-_]+))?(\.[a-z0-9_\-\.]+)$/i.exec(t);if(r){var i=r[1],o=r[2].substr(1).split(".").join(" "),a=tinymce.makeMap("a,img");return r[1]?(n={title:t},e.schema.getTextBlockElements()[i]?n.block=i:e.schema.getBlockElements()[i]||a[i.toLowerCase()]?n.selector=i:n.inline=i):r[2]&&(n={inline:"span",title:t.substr(1),classes:o}),e.settings.importcss_merge_classes!==!1?n.classes=o:n.attributes={"class":o},n}}var o=this,a=tinymce.each;e.on("renderFormatsMenu",function(t){var s=e.settings,l={},c=s.importcss_selector_converter||i,u=n(s.importcss_selector_filter),d=t.control;e.settings.importcss_append||d.items().remove();var f=[];tinymce.each(s.importcss_groups,function(e){e=tinymce.extend({},e),e.filter=n(e.filter),f.push(e)}),a(r(t.doc||e.getDoc(),n(s.importcss_file_filter)),function(t){if(-1===t.indexOf(".mce-")&&!l[t]&&(!u||u(t))){var n,r=c.call(o,t);if(r){var i=r.name||tinymce.DOM.uniqueId();if(f)for(var a=0;a<f.length;a++)if(!f[a].filter||f[a].filter(t)){f[a].item||(f[a].item={text:f[a].title,menu:[]}),n=f[a].item.menu;break}e.formatter.register(i,r);var s=tinymce.extend({},d.settings.itemDefaults,{text:r.title,format:i});n?n.push(s):d.add(s)}l[t]=!0}}),a(f,function(e){d.add(e.item)}),t.control.renderNew()}),o.convertSelectorToFormat=i});
|