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