1 line
3.7 KiB
JavaScript
1 line
3.7 KiB
JavaScript
ace.define("ace/ext/static_highlight",["require","exports","module","ace/edit_session","ace/layer/text","ace/config","ace/lib/dom","ace/lib/lang"],(function(e,t,n){"use strict";var i=e("../edit_session").EditSession,o=e("../layer/text").Text,r=e("../config"),s=e("../lib/dom"),a=e("../lib/lang").escapeHTML;function c(e){this.type=e,this.style={},this.textContent=""}c.prototype.cloneNode=function(){return this},c.prototype.appendChild=function(e){this.textContent+=e.toString()},c.prototype.toString=function(){var e=[];if("fragment"!=this.type){e.push("<",this.type),this.className&&e.push(" class='",this.className,"'");var t=[];for(var n in this.style)t.push(n,":",this.style[n]);t.length&&e.push(" style='",t.join(""),"'"),e.push(">")}return this.textContent&&e.push(this.textContent),"fragment"!=this.type&&e.push("</",this.type,">"),e.join("")};var l={createTextNode:function(e,t){return a(e)},createElement:function(e){return new c(e)},createFragment:function(){return new c("fragment")}},h=function(){this.config={},this.dom=l};h.prototype=o.prototype;var g=function e(t,n,i){var o=t.className.match(/lang-(\w+)/),r=n.mode||o&&"ace/mode/"+o[1];if(!r)return!1;var a=n.theme||"ace/theme/textmate",c="",l=[];if(t.firstElementChild)for(var h=0,g=0;g<t.childNodes.length;g++){var u=t.childNodes[g];3==u.nodeType?(h+=u.data.length,c+=u.data):l.push(h,u)}else c=t.textContent,n.trim&&(c=c.trim());e.render(c,r,a,n.firstLineNumber,!n.showGutter,(function(e){s.importCssString(e.css,"ace_highlight"),t.innerHTML=e.html;for(var n=t.firstChild.firstChild,o=0;o<l.length;o+=2){var r=e.session.doc.indexToPosition(l[o]),a=l[o+1],c=n.children[r.row];c&&c.appendChild(a)}i&&i()}))};g.render=function(e,t,n,o,s,a){var c,l=1,h=i.prototype.$modes;function u(){var i=g.renderSync(e,t,n,o,s);return a?a(i):i}return"string"==typeof n&&(l++,r.loadModule(["theme",n],(function(e){n=e,--l||u()}))),t&&"object"===typeof t&&!t.getTokenizer&&(t=(c=t).path),"string"==typeof t&&(l++,r.loadModule(["mode",t],(function(e){h[t]&&!c||(h[t]=new e.Mode(c)),t=h[t],--l||u()}))),--l||u()},g.renderSync=function(e,t,n,o,r){o=parseInt(o||1,10);var s=new i("");s.setUseWorker(!1),s.setMode(t);var a=new h;a.setSession(s),Object.keys(a.$tabStrings).forEach((function(e){if("string"==typeof a.$tabStrings[e]){var t=l.createFragment();t.textContent=a.$tabStrings[e],a.$tabStrings[e]=t}})),s.setValue(e);var c=s.getLength(),g=l.createElement("div");g.className=n.cssClass;var u=l.createElement("div");u.className="ace_static_highlight"+(r?"":" ace_show_gutter"),u.style["counter-reset"]="ace_line "+(o-1);for(var p=0;p<c;p++){var d=l.createElement("div");if(d.className="ace_line",!r){var f=l.createElement("span");f.className="ace_gutter ace_gutter-cell",f.textContent="",d.appendChild(f)}a.$renderLine(d,p,!1),d.textContent+="\n",u.appendChild(d)}return g.appendChild(u),{css:".ace_static_highlight {font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', 'Consolas', 'source-code-pro', 'Droid Sans Mono', monospace;font-size: 12px;white-space: pre-wrap}.ace_static_highlight .ace_gutter {width: 2em;text-align: right;padding: 0 3px 0 0;margin-right: 3px;contain: none;}.ace_static_highlight.ace_show_gutter .ace_line {padding-left: 2.6em;}.ace_static_highlight .ace_line { position: relative; }.ace_static_highlight .ace_gutter-cell {-moz-user-select: -moz-none;-khtml-user-select: none;-webkit-user-select: none;user-select: none;top: 0;bottom: 0;left: 0;position: absolute;}.ace_static_highlight .ace_gutter-cell:before {content: counter(ace_line, decimal);counter-increment: ace_line;}.ace_static_highlight {counter-reset: ace_line;}"+n.cssText,html:g.toString(),session:s}},n.exports=g,n.exports.highlight=g})),ace.require(["ace/ext/static_highlight"],(function(e){"object"==typeof module&&"object"==typeof exports&&module&&(module.exports=e)})); |