Version Description
- 21 January 2016=
- Updated to latest version of Code Mirror.
Download this release
Release Info
Developer | gpriday |
Plugin | SiteOrigin CSS |
Version | 1.0.5 |
Comparing to | |
See all releases |
Code changes from version 1.0.4 to 1.0.5
- js/editor.js +1 -0
- js/editor.min.js +1 -1
- lib/codemirror/addon/fold/comment-fold.js +3 -1
- lib/codemirror/addon/fold/comment-fold.min.js +1 -1
- lib/codemirror/addon/fold/markdown-fold.min.js +1 -1
- lib/codemirror/addon/hint/anyword-hint.js +1 -1
- lib/codemirror/addon/hint/anyword-hint.min.js +1 -1
- lib/codemirror/addon/hint/show-hint.js +102 -54
- lib/codemirror/addon/hint/show-hint.min.js +1 -1
- lib/codemirror/addon/hint/sql-hint.js +13 -4
- lib/codemirror/addon/hint/sql-hint.min.js +1 -1
- lib/codemirror/addon/lint/css-lint.js +1 -9
- lib/codemirror/addon/lint/css-lint.min.js +1 -1
- lib/codemirror/addon/lint/html-lint.js +46 -0
- lib/codemirror/addon/lint/html-lint.min.js +1 -0
- lib/codemirror/addon/lint/lint.js +33 -9
- lib/codemirror/addon/lint/lint.min.js +1 -1
- lib/codemirror/addon/merge/merge.js +5 -8
- lib/codemirror/addon/merge/merge.min.js +1 -1
- lib/codemirror/lib/codemirror.css +41 -32
- lib/codemirror/lib/codemirror.js +395 -246
- lib/codemirror/lib/codemirror.min.js +5 -5
- lib/codemirror/mode/css/css.js +97 -42
- lib/codemirror/mode/css/css.min.js +1 -1
- lib/codemirror/mode/css/gss.html +103 -0
- lib/codemirror/mode/css/gss_test.js +17 -0
- lib/codemirror/mode/css/gss_test.min.js +1 -0
- lib/codemirror/mode/css/test.js +17 -12
- lib/codemirror/mode/css/test.min.js +1 -1
- lib/codemirror/theme/neat.css +3 -3
- readme.txt +5 -2
- so-css.php +2 -2
js/editor.js
CHANGED
@@ -113,6 +113,7 @@
|
|
113 |
// Setup the Codemirror instance
|
114 |
this.codeMirror = CodeMirror.fromTextArea(this.$('textarea.css-editor').get(0), {
|
115 |
tabSize: 2,
|
|
|
116 |
mode: 'css',
|
117 |
theme: 'neat',
|
118 |
gutters: [
|
113 |
// Setup the Codemirror instance
|
114 |
this.codeMirror = CodeMirror.fromTextArea(this.$('textarea.css-editor').get(0), {
|
115 |
tabSize: 2,
|
116 |
+
lineNumbers: true,
|
117 |
mode: 'css',
|
118 |
theme: 'neat',
|
119 |
gutters: [
|
js/editor.min.js
CHANGED
@@ -1 +1 @@
|
|
1 |
-
!function(e,t,i){var s={model:{},collection:{},view:{},fn:{}};window.socss=s,s.view.toolbar=Backbone.View.extend({button:t.template('<li><a href="#" class="toolbar-button socss-button"><%= text %></a></li>'),editor:null,initialize:function(t){this.editor=t.editor;var i=this;this.$(".editor-expand").click(function(t){t.preventDefault(),e(this).blur(),i.trigger("click_expand")}),this.$(".editor-visual").click(function(t){t.preventDefault(),e(this).blur(),i.trigger("click_visual")})},addButton:function(t,i){var s=this,n=e(this.button({text:t})).appendTo(this.$(".toolbar-function-buttons .toolbar-buttons")).click(function(t){t.preventDefault(),e(this).blur(),s.trigger("click_"+i)});return n}}),s.view.editor=Backbone.View.extend({codeMirror:null,snippets:null,toolbar:null,visualProperties:null,inspector:null,cssSelectors:[],initialize:function(e){this.setupEditor()},render:function(){var t=this;this.toolbar=new s.view.toolbar({editor:this,el:this.$(".custom-css-toolbar")}),this.toolbar.editor=this,this.toolbar.render(),this.visualProperties=new s.view.properties({editor:this,el:e("#so-custom-css-properties")}),this.visualProperties.render(),this.toolbar.on("click_expand",function(){t.toggleExpand()}),this.toolbar.on("click_visual",function(){t.visualProperties.loadCSS(t.codeMirror.getValue()),t.visualProperties.show()}),this.preview=new s.view.preview({editor:this,el:this.$(".custom-css-preview")}),this.preview.render()},setupEditor:function(){var t=this;this.registerCodeMirrorAutocomplete(),this.codeMirror=CodeMirror.fromTextArea(this.$("textarea.css-editor").get(0),{tabSize:2,mode:"css",theme:"neat",gutters:["CodeMirror-lint-markers"],lint:!0});var s=this.$("textarea.css-editor").val();this.$el.on("submit",function(){s=t.codeMirror.getValue()}),e(window).bind("beforeunload",function(){return t.codeMirror.getValue()!==s?i.loc.leave:void 0}),this.$el.find(".custom-css-container").css("overflow","visible"),this.scaleEditor(),e(window).resize(function(){t.scaleEditor()}),this.setupCodeMirrorExtensions()},registerCodeMirrorAutocomplete:function(){var e=this,t={link:1,visited:1,active:1,hover:1,focus:1,"first-letter":1,"first-line":1,"first-child":1,before:1,after:1,lang:1};CodeMirror.registerHelper("hint","css",function(i){function s(e){for(var t in e)c&&0!==t.lastIndexOf(c,0)||p.push(t)}var n=i.getCursor(),r=i.getTokenAt(n),o=CodeMirror.innerMode(i.getMode(),r.state);if("css"===o.mode.name){if("keyword"===r.type&&0==="!important".indexOf(r.string))return{list:["!important"],from:CodeMirror.Pos(n.line,r.start),to:CodeMirror.Pos(n.line,r.end)};var a=r.start,l=n.ch,c=r.string.slice(0,l-a);/[^\w$_-]/.test(c)&&(c="",a=l=n.ch);var d=CodeMirror.resolveMode("text/css"),p=[],h=o.state.state;if("top"===h){for(var u=i.getLine(n.line).trim(),v=e.cssSelectors,f=0;f<v.length;f++)-1!==v[f].selector.indexOf(u)&&p.push(v[f].selector);if(p.length)return{list:p,from:CodeMirror.Pos(n.line,0),to:CodeMirror.Pos(n.line,l)}}else if("pseudo"===h||"variable-3"===r.type?s(t):"block"===h||"maybeprop"===h?s(d.propertyKeywords):"prop"===h||"parens"===h||"at"===h||"params"===h?(s(d.valueKeywords),s(d.colorKeywords)):("media"===h||"media_parens"===h)&&(s(d.mediaTypes),s(d.mediaFeatures)),p.length)return{list:p,from:CodeMirror.Pos(n.line,a),to:CodeMirror.Pos(n.line,l)}}})},setupCodeMirrorExtensions:function(){var e=this;this.codeMirror.on("cursorActivity",function(t){var i=t.getCursor(),s=t.getTokenAt(i);CodeMirror.innerMode(t.getMode(),s.state);if("qualifier"===s.type||"tag"===s.type||"builtin"===s.type){var n=t.getLine(i.line),r=n.substring(0,s.end);e.preview.highlight(r)}else e.preview.clearHighlight()}),this.codeMirror.on("keyup",function(e,t){(t.keyCode>=65&&t.keyCode<=90||189===t.keyCode&&!t.shiftKey||190===t.keyCode&&!t.shiftKey||51===t.keyCode&&t.shiftKey||189===t.keyCode&&t.shiftKey)&&e.showHint(t)})},scaleEditor:function(){this.$el.hasClass("expanded")?this.codeMirror.setSize("100%",e(window).outerHeight()-this.$(".custom-css-toolbar").outerHeight()):this.codeMirror.setSize("100%","auto")},isExpanded:function(){return this.$el.hasClass("expanded")},toggleExpand:function(){this.$el.toggleClass("expanded"),this.scaleEditor()},setExpand:function(e){e?this.$el.addClass("expanded"):this.$el.removeClass("expanded"),this.scaleEditor()},setSnippets:function(e){if(!t.isEmpty(e)){var i=this;this.snippets=new s.view.snippets({snippets:e}),this.snippets.editor=this,this.snippets.render(),this.toolbar.addButton("Snippets","snippets"),this.toolbar.on("click_snippets",function(){i.snippets.show()})}},addCode:function(e){var t=this.codeMirror,i="";i=1===t.doc.lineCount()&&0===t.doc.getLine(t.doc.lastLine()).length?"":0===t.doc.getLine(t.doc.lastLine()).length?"\n":"\n\n",t.doc.setCursor(t.doc.lastLine(),t.doc.getLine(t.doc.lastLine()).length),t.doc.replaceSelection(i+e)},addEmptySelector:function(e){this.addCode(e+" {\n \n}")},setInspector:function(e){var t=this;this.inspector=e,this.cssSelectors=e.pageSelectors,e.on("click_selector",function(e){t.visualProperties.isVisible()?t.visualProperties.addSelector(e):t.addEmptySelector(e)}),e.on("click_property",function(e){t.visualProperties.isVisible()||t.codeMirror.replaceSelection(e+";\n ")}),e.on("set_active_element",function(e,i){t.visualProperties.isVisible()&&i.length&&t.visualProperties.addSelector(i[0].selector)})}}),s.view.preview=Backbone.View.extend({template:t.template('<iframe class="preview-iframe" seamless="seamless"></iframe>'),editor:null,initialize:function(e){this.editor=e.editor;var t=this;this.editor.codeMirror.on("change",function(e,i){t.updatePreviewCss()})},render:function(){var t=this;this.$el.html(this.template()),this.$(".preview-iframe").attr("src",i.homeURL).load(function(){var i=e(this);i.contents().find("a").each(function(){var t=e(this).attr("href");if(void 0===t)return!0;var i=-1===t.indexOf("?")?"?":"&";e(this).attr("href",t+i+"so_css_preview=1")}),t.updatePreviewCss()}).mouseleave(function(){t.clearHighlight()})},updatePreviewCss:function(){var e=this.$(".preview-iframe");if(0!==e.length){var t=e.contents().find("head");0===t.find("style.siteorigin-custom-css").length&&t.append('<style class="siteorigin-custom-css" type="text/css"></style>');var i=t.find("style.siteorigin-custom-css"),s=this.editor.codeMirror.getValue();i.html(s)}},highlight:function(e){try{this.editor.inspector.hl.highlight(e)}catch(t){console.log("No inspector to highlight with")}},clearHighlight:function(){try{this.editor.inspector.hl.clear()}catch(e){console.log("No inspector to highlight with")}}}),s.view.snippets=Backbone.View.extend({template:t.template(e("#template-snippet-browser").html()),snippet:t.template('<li class="snippet"><%- name %></li>'),className:"css-editor-snippet-browser",snippets:null,editor:null,events:{"click .close":"hide","click .buttons .insert-snippet":"insertSnippet"},currentSnippet:null,initialize:function(e){this.snippets=e.snippets},render:function(){var t=this,i=function(i){i.preventDefault();var s=e(this);t.$(".snippets li.snippet").removeClass("active"),e(this).addClass("active"),t.viewSnippet({name:s.html(),description:s.data("description"),css:s.data("css")})};this.$el.html(this.template());for(var s=0;s<this.snippets.length;s++)e(this.snippet({name:this.snippets[s].Name})).data({description:this.snippets[s].Description,css:this.snippets[s].css}).appendTo(this.$("ul.snippets")).click(i);return t.$(".snippets li.snippet").eq(0).click(),this.attach(),this},viewSnippet:function(e){var t=this.$(".main .snippet-view");t.find(".snippet-title").html(e.name),t.find(".snippet-description").html(e.description),t.find(".snippet-code").html(e.css),this.currentSnippet=e},insertSnippet:function(){var e=this.editor.codeMirror,t=this.currentSnippet.css,i="";i=1===e.doc.lineCount()&&0===e.doc.getLine(e.doc.lastLine()).length?"":0===e.doc.getLine(e.doc.lastLine()).length?"\n":"\n\n",e.doc.setCursor(e.doc.lastLine(),e.doc.getLine(e.doc.lastLine()).length),e.doc.replaceSelection(i+t),this.hide()},attach:function(){this.$el.appendTo("body")},show:function(){this.$el.show()},hide:function(){this.$el.hide()}}),s.view.properties=Backbone.View.extend({model:s.model.cssRules,tabTemplate:t.template('<li data-section="<%- id %>"><span class="fa fa-<%- icon %>"></span> <%- title %></li>'),sectionTemplate:t.template('<div class="section" data-section="<%- id %>"><table class="fields-table"><tbody></tbody></table></div>'),controllerTemplate:t.template('<tr><th scope="row"><%- title %></th><td></td></tr>'),propertyControllers:[],editor:null,css:"",parsed:{},activeSelector:"",editorExpandedBefore:!1,events:{"click .close":"hide"},initialize:function(e){this.parser=new cssjs,this.editor=e.editor},render:function(){var n=this,r=i.propertyControllers;for(var o in r){var a=(e(this.tabTemplate({id:o,icon:r[o].icon,title:r[o].title})).appendTo(this.$(".section-tabs")),e(this.sectionTemplate({id:o})).appendTo(this.$(".sections")));if(!t.isEmpty(r[o].controllers))for(var l=0;l<r[o].controllers.length;l++){var c,d=e(n.controllerTemplate({title:r[o].controllers[l].title})).appendTo(a.find("tbody")),p=r[o].controllers[l];c="undefined"==typeof s.view.properties.controllers[p.type]?new s.view.propertyController({el:d.find("td"),propertiesView:n,args:"undefined"==typeof p.args?{}:p.args}):new s.view.properties.controllers[p.type]({el:d.find("td"),propertiesView:n,args:"undefined"==typeof p.args?{}:p.args}),n.propertyControllers.push(c),c.render(),c.initChangeEvents()}}this.$(".section-tabs li").click(function(){var t=e(this),i=n.$('.sections .section[data-section="'+t.data("section")+'"]');n.$(".sections .section").not(i).hide().removeClass("active"),i.show().addClass("active"),n.$(".section-tabs li").not(t).removeClass("active"),t.addClass("active")}).eq(0).click(),this.$(".toolbar select").change(function(){n.setActivateSelector(e(this).find(":selected").data("selector"))})},setRuleValue:function(e,t){if("undefined"!=typeof this.activeSelector&&"undefined"!=typeof this.activeSelector.rules){for(var i=!0,s=0;s<this.activeSelector.rules.length;s++)if(this.activeSelector.rules[s].directive===e){this.activeSelector.rules[s].value=t,i=!1;break}i&&this.activeSelector.rules.push({directive:e,value:t}),this.updateMainEditor(!1)}},getRuleValue:function(e){if("undefined"==typeof this.activeSelector||"undefined"==typeof this.activeSelector.rules)return"";for(var t=0;t<this.activeSelector.rules.length;t++)if(this.activeSelector.rules[t].directive===e)return this.activeSelector.rules[t].value;return""},updateMainEditor:function(e){var t;"undefined"==typeof e||e===!0?(t=this.parser.compressCSS(this.parsed),t=t.filter(function(e){return"undefined"!=typeof e.type||e.rules.length>0})):t=this.parsed,this.editor.codeMirror.setValue(this.parser.getCSSForEditor(t).trim())},show:function(){this.editorExpandedBefore=this.editor.isExpanded(),this.editor.setExpand(!0),this.$el.show().animate({left:0},"fast")},hide:function(){this.editor.setExpand(this.editorExpandedBefore),this.$el.animate({left:-338},"fast",function(){e(this).hide()}),this.updateMainEditor(!0)},isVisible:function(){return this.$el.is(":visible")},loadCSS:function(t,i){this.css=t,this.parsed=this.parser.compressCSS(this.parser.parseCSS(t));for(var s=this.$(".toolbar select").empty(),n=0;n<this.parsed.length;n++){var r=this.parsed[n];if("undefined"!=typeof r.subStyles)for(var o=0;o<r.subStyles.length;o++){var a=r.subStyles[o];s.append(e("<option>").html(r.selector+": "+a.selector).attr("val",r.selector+": "+a.selector).data("selector",a))}else s.append(e("<option>").html(r.selector).attr("val",r.selector).data("selector",r))}"undefined"==typeof i&&(i=s.find("option").eq(0).attr("val")),s.val(i).change()},setActivateSelector:function(e){this.activeSelector=e;for(var t=0;t<this.propertyControllers.length;t++)this.propertyControllers[t].refreshFromRule()},addSelector:function(e){var t=this.$(".toolbar select");t.val(e),t.val()===e?t.change():(this.editor.addEmptySelector(e),this.loadCSS(this.editor.codeMirror.getValue(),e)),t.addClass("highlighted"),setTimeout(function(){t.removeClass("highlighted")},2e3)}}),s.view.propertyController=Backbone.View.extend({template:t.template('<input type="text" value="" />'),activeRule:null,args:null,propertiesView:null,initialize:function(e){this.args=e.args,this.propertiesView=e.propertiesView,this.on("set_value",this.updateRule,this),this.on("change",this.updateRule,this)},render:function(){this.$el.append(e(this.template({}))),this.field=this.$("input")},initChangeEvents:function(){var t=this;this.field.on("change keyup",function(){t.trigger("change",e(this).val())})},updateRule:function(){this.propertiesView.setRuleValue(this.args.property,this.getValue())},refreshFromRule:function(){var e=this.propertiesView.getRuleValue(this.args.property);this.setValue(e,{silent:!0})},getValue:function(){return this.field.val()},setValue:function(e,i){i=t.extend({silent:!1},i),this.field.val(e),i.silent||this.trigger("set_value",e)},reset:function(e){e=t.extend({silent:!1},e),this.setValue("",e)}}),s.view.properties.controllers={},s.view.properties.controllers.color=s.view.propertyController.extend({template:t.template('<input type="text" value="" />'),render:function(){this.$el.append(e(this.template({}))),this.field=this.$el.find("input"),this.field.minicolors({})},initChangeEvents:function(){var e=this;this.field.on("change keyup",function(){e.trigger("change",e.field.minicolors("value"))})},getValue:function(){return this.field.minicolors("value")},setValue:function(e,i){i=t.extend({silent:!1},i),this.field.minicolors("value",e),i.silent||this.trigger("set_value",e)}}),s.view.properties.controllers.select=s.view.propertyController.extend({template:t.template("<select></select>"),render:function(){this.$el.append(e(this.template({}))),this.field=this.$el.find("select"),this.field.append(e('<option value=""></option>').html(""));for(var t in this.args.options)this.field.append(e("<option></option>").attr("value",t).html(this.args.options[t]));"undefined"!=typeof this.args.option_icons&&this.setupVisualSelect()},setupVisualSelect:function(){var t=this;this.field.hide();var i=e('<div class="select-tabs"></div>').appendTo(this.$el);e('<div class="select-tab" data-value=""><span class="fa fa-circle-o"></span></div>').appendTo(i);for(var s in this.args.option_icons)e('<div class="select-tab"></div>').appendTo(i).append(e('<span class="fa"></span>').addClass("fa-"+this.args.option_icons[s])).attr("data-value",s);i.find(".select-tab").css("width",100/i.find(">div").length+"%").click(function(){var s=e(this);i.find(".select-tab").removeClass("active"),s.addClass("active"),t.field.val(s.data("value")).change()})},setValue:function(e,i){i=t.extend({silent:!1},i),this.field.val(e),this.$(".select-tabs .select-tab").removeClass("active").filter('[data-value="'+e+'"]').addClass("active"),i.silent||this.trigger("set_value",e)}}),s.view.properties.controllers.image=s.view.propertyController.extend({template:t.template('<input type="text" value="" /> <span class="select socss-button"><span class="fa fa-upload"></span></span>'),render:function(){var t=this;this.media=wp.media({title:i.loc.select_image,library:{type:"image"},button:{text:i.loc.select,close:!1}}),this.$el.append(e(this.template({select:i.loc.select}))),this.field=this.$el.find("input"),this.$(".select").click(function(){t.media.open()}),this.media.on("select",function(){var e=this.state().get("selection").first().attributes,i=t.args.value.replace("{{url}}",e.url);t.field.val(i).change(),t.media.close()},this.media)}}),s.view.properties.controllers.measurement=s.view.propertyController.extend({wrapperClass:"socss-field-measurement",render:function(){this.$el.append(e(this.template({}))),this.field=this.$("input"),this.setupMeasurementField(this.field,{})},setValue:function(e,i){i=t.extend({silent:!1},i),this.field.val(e).trigger("measurement_refresh"),i.silent||this.trigger("set_value",e)},units:["px","%","em","cm","mm","in","pt","pc","ex","ch","rem","vw","vh","vmin","vmax"],parseUnits:function(e){var t=function(e){return e.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&")},i=this.units.map(t),s=new RegExp("([0-9\\.\\-]+)("+i.join("|")+")?","i"),n=s.exec(e);return null===n?{value:"",unit:""}:{value:n[1],unit:void 0===n[2]?"":n[2]}},setupMeasurementField:function(i,s){var n=this,r=i.parent();s=t.extend({defaultUnit:"px"},s),i.hide(),r.addClass(this.wrapperClass).data("unit",s.defaultUnit);for(var o=e('<input type="text" class="socss-field-input"/>').appendTo(r),a=e('<span class="dashicons dashicons-arrow-down"></span>').appendTo(r),l=e('<ul class="dropdown"></ul>').appendTo(r),c=e('<span class="units"></span>').html(s.defaultUnit).appendTo(r),d=0;d<n.units.length;d++){var p=e("<li></li>").html(n.units[d]).data("unit",n.units[d]);n.units[d]===s.defaultUnit&&p.addClass("active"),l.append(p)}var h=function(){var e=n.parseUnits(o.val());""!==e.unit&&e.unit!==r.data("unit")&&(o.val(e.value),u(e.unit)),""===e.value?i.val(""):i.val(e.value+r.data("unit"))},u=function(e){c.html(e),r.data("unit",e),o.trigger("keydown")};a.click(function(){l.toggle()}),l.find("li").click(function(){l.toggle(),u(e(this).data("unit")),h(),i.trigger("change")}),o.on("keyup keydown",function(t){var i=(e(this),"");"keydown"===t.type&&(t.keyCode>=48&&t.keyCode<=57?i=String.fromCharCode(t.keyCode):189===t.keyCode?i="-":190===t.keyCode&&(i="."));var s=e('<span class="socss-hidden-placeholder"></span>').css({"font-size":"14px"}).html(o.val()+i).appendTo("body"),n=s.width();n=Math.min(n,63),s.remove(),c.css("left",n+12)}),o.on("keyup",function(e){h(),i.trigger("change")}),i.on("measurement_refresh",function(){var t=n.parseUnits(i.val());o.val(t.value);var a=""===t.unit?s.defaultUnit:t.unit;r.data("unit",a),c.html(a);var l=e('<span class="socss-hidden-placeholder"></span>').css({"font-size":"14px"}).html(t.value).appendTo("body"),d=l.width();d=Math.min(d,63),l.remove(),c.css("left",d+12)});var v=e('<div class="socss-diw"></div>').appendTo(r),f=e('<div class="dec-button socss-button"><span class="fa fa-minus"></span></div>').appendTo(v),g=e('<div class="inc-button socss-button"><span class="fa fa-plus"></span></div>').appendTo(v);g.click(function(){var e=n.parseUnits(i.val());if(""===e.value)return!0;var t=Math.ceil(1.05*e.value);o.val(t),h(),i.trigger("change").trigger("measurement_refresh")}),f.click(function(){var e=n.parseUnits(i.val());if(""===e.value)return!0;var t=Math.floor(e.value/1.05);o.val(t),h(),i.trigger("change").trigger("measurement_refresh")})}}),s.view.properties.controllers.number=s.view.propertyController.extend({render:function(){this.$el.append(e(this.template({}))),this.field=this.$("input"),this.setupNumberField(this.field,this.args)},setupNumberField:function(i,s){s=t.extend({change:null,"default":0,increment:1,decrement:-1,max:null,min:null},s);var n=i.parent();n.addClass("socss-field-number");var r=e('<div class="socss-diw"></div>').appendTo(n),o=e('<div class="dec-button socss-button">-</div>').appendTo(r);e('<div class="inc-button socss-button">+</div>').appendTo(r);return r.find("> div").click(function(t){t.preventDefault();var n=s["default"];""!==i.val()&&(n=Number(i.val())),n+=e(this).is(o)?s.decrement:s.increment,n=Math.round(100*n)/100,null!==s.max&&(n=Math.min(s.max,n)),null!==s.min&&(n=Math.max(s.min,n)),i.val(n),i.trigger("change")}),this}}),s.view.properties.controllers.sides=s.view.propertyController.extend({template:t.template(e("#template-sides-field").html().trim()),controllers:[],render:function(){var i=this;this.$el.append(e(this.template({}))),this.field=this.$el.find("input"),i.args.hasAll||(this.$(".select-tab").eq(0).remove(),this.$(".select-tab").css("width","25%")),this.$(".select-tab").each(function(){for(var n=e(this).data("direction"),r=e('<li class="side">').appendTo(i.$(".sides")).hide(),o=0;o<i.args.controllers.length;o++){var a=i.args.controllers[o],l="";l="all"===n?a.args.propertyAll:a.args.property.replace("{dir}",n);var c=t.extend({},a.args,{property:l}),d=new s.view.properties.controllers[a.type]({el:e("<div>").appendTo(r),propertiesView:i.propertiesView,args:c});d.render(),d.initChangeEvents(),i.propertiesView.propertyControllers.push(d)}e(this).on("click",function(){i.$(".select-tab").removeClass("active"),e(this).addClass("active"),i.$(".sides .side").hide(),r.show()})}),this.$(".select-tab").eq(0).click()}})}(jQuery,_,socssOptions),jQuery(function(e){var t=window.socss,i=new t.view.editor({el:e("#so-custom-css-form").get(0)});i.render(),i.setSnippets(socssOptions.snippets),window.socss.mainEditor=i,e("#so-custom-css-getting-started a.hide").click(function(t){t.preventDefault(),e("#so-custom-css-getting-started").slideUp(),e.get(e(this).attr("href"))})});
|
1 |
+
!function(e,t,i){var s={model:{},collection:{},view:{},fn:{}};window.socss=s,s.view.toolbar=Backbone.View.extend({button:t.template('<li><a href="#" class="toolbar-button socss-button"><%= text %></a></li>'),editor:null,initialize:function(t){this.editor=t.editor;var i=this;this.$(".editor-expand").click(function(t){t.preventDefault(),e(this).blur(),i.trigger("click_expand")}),this.$(".editor-visual").click(function(t){t.preventDefault(),e(this).blur(),i.trigger("click_visual")})},addButton:function(t,i){var s=this,n=e(this.button({text:t})).appendTo(this.$(".toolbar-function-buttons .toolbar-buttons")).click(function(t){t.preventDefault(),e(this).blur(),s.trigger("click_"+i)});return n}}),s.view.editor=Backbone.View.extend({codeMirror:null,snippets:null,toolbar:null,visualProperties:null,inspector:null,cssSelectors:[],initialize:function(e){this.setupEditor()},render:function(){var t=this;this.toolbar=new s.view.toolbar({editor:this,el:this.$(".custom-css-toolbar")}),this.toolbar.editor=this,this.toolbar.render(),this.visualProperties=new s.view.properties({editor:this,el:e("#so-custom-css-properties")}),this.visualProperties.render(),this.toolbar.on("click_expand",function(){t.toggleExpand()}),this.toolbar.on("click_visual",function(){t.visualProperties.loadCSS(t.codeMirror.getValue()),t.visualProperties.show()}),this.preview=new s.view.preview({editor:this,el:this.$(".custom-css-preview")}),this.preview.render()},setupEditor:function(){var t=this;this.registerCodeMirrorAutocomplete(),this.codeMirror=CodeMirror.fromTextArea(this.$("textarea.css-editor").get(0),{tabSize:2,lineNumbers:!0,mode:"css",theme:"neat",gutters:["CodeMirror-lint-markers"],lint:!0});var s=this.$("textarea.css-editor").val();this.$el.on("submit",function(){s=t.codeMirror.getValue()}),e(window).bind("beforeunload",function(){return t.codeMirror.getValue()!==s?i.loc.leave:void 0}),this.$el.find(".custom-css-container").css("overflow","visible"),this.scaleEditor(),e(window).resize(function(){t.scaleEditor()}),this.setupCodeMirrorExtensions()},registerCodeMirrorAutocomplete:function(){var e=this,t={link:1,visited:1,active:1,hover:1,focus:1,"first-letter":1,"first-line":1,"first-child":1,before:1,after:1,lang:1};CodeMirror.registerHelper("hint","css",function(i){function s(e){for(var t in e)c&&0!==t.lastIndexOf(c,0)||p.push(t)}var n=i.getCursor(),r=i.getTokenAt(n),o=CodeMirror.innerMode(i.getMode(),r.state);if("css"===o.mode.name){if("keyword"===r.type&&0==="!important".indexOf(r.string))return{list:["!important"],from:CodeMirror.Pos(n.line,r.start),to:CodeMirror.Pos(n.line,r.end)};var a=r.start,l=n.ch,c=r.string.slice(0,l-a);/[^\w$_-]/.test(c)&&(c="",a=l=n.ch);var d=CodeMirror.resolveMode("text/css"),p=[],h=o.state.state;if("top"===h){for(var u=i.getLine(n.line).trim(),v=e.cssSelectors,f=0;f<v.length;f++)-1!==v[f].selector.indexOf(u)&&p.push(v[f].selector);if(p.length)return{list:p,from:CodeMirror.Pos(n.line,0),to:CodeMirror.Pos(n.line,l)}}else if("pseudo"===h||"variable-3"===r.type?s(t):"block"===h||"maybeprop"===h?s(d.propertyKeywords):"prop"===h||"parens"===h||"at"===h||"params"===h?(s(d.valueKeywords),s(d.colorKeywords)):("media"===h||"media_parens"===h)&&(s(d.mediaTypes),s(d.mediaFeatures)),p.length)return{list:p,from:CodeMirror.Pos(n.line,a),to:CodeMirror.Pos(n.line,l)}}})},setupCodeMirrorExtensions:function(){var e=this;this.codeMirror.on("cursorActivity",function(t){var i=t.getCursor(),s=t.getTokenAt(i);CodeMirror.innerMode(t.getMode(),s.state);if("qualifier"===s.type||"tag"===s.type||"builtin"===s.type){var n=t.getLine(i.line),r=n.substring(0,s.end);e.preview.highlight(r)}else e.preview.clearHighlight()}),this.codeMirror.on("keyup",function(e,t){(t.keyCode>=65&&t.keyCode<=90||189===t.keyCode&&!t.shiftKey||190===t.keyCode&&!t.shiftKey||51===t.keyCode&&t.shiftKey||189===t.keyCode&&t.shiftKey)&&e.showHint(t)})},scaleEditor:function(){this.$el.hasClass("expanded")?this.codeMirror.setSize("100%",e(window).outerHeight()-this.$(".custom-css-toolbar").outerHeight()):this.codeMirror.setSize("100%","auto")},isExpanded:function(){return this.$el.hasClass("expanded")},toggleExpand:function(){this.$el.toggleClass("expanded"),this.scaleEditor()},setExpand:function(e){e?this.$el.addClass("expanded"):this.$el.removeClass("expanded"),this.scaleEditor()},setSnippets:function(e){if(!t.isEmpty(e)){var i=this;this.snippets=new s.view.snippets({snippets:e}),this.snippets.editor=this,this.snippets.render(),this.toolbar.addButton("Snippets","snippets"),this.toolbar.on("click_snippets",function(){i.snippets.show()})}},addCode:function(e){var t=this.codeMirror,i="";i=1===t.doc.lineCount()&&0===t.doc.getLine(t.doc.lastLine()).length?"":0===t.doc.getLine(t.doc.lastLine()).length?"\n":"\n\n",t.doc.setCursor(t.doc.lastLine(),t.doc.getLine(t.doc.lastLine()).length),t.doc.replaceSelection(i+e)},addEmptySelector:function(e){this.addCode(e+" {\n \n}")},setInspector:function(e){var t=this;this.inspector=e,this.cssSelectors=e.pageSelectors,e.on("click_selector",function(e){t.visualProperties.isVisible()?t.visualProperties.addSelector(e):t.addEmptySelector(e)}),e.on("click_property",function(e){t.visualProperties.isVisible()||t.codeMirror.replaceSelection(e+";\n ")}),e.on("set_active_element",function(e,i){t.visualProperties.isVisible()&&i.length&&t.visualProperties.addSelector(i[0].selector)})}}),s.view.preview=Backbone.View.extend({template:t.template('<iframe class="preview-iframe" seamless="seamless"></iframe>'),editor:null,initialize:function(e){this.editor=e.editor;var t=this;this.editor.codeMirror.on("change",function(e,i){t.updatePreviewCss()})},render:function(){var t=this;this.$el.html(this.template()),this.$(".preview-iframe").attr("src",i.homeURL).load(function(){var i=e(this);i.contents().find("a").each(function(){var t=e(this).attr("href");if(void 0===t)return!0;var i=-1===t.indexOf("?")?"?":"&";e(this).attr("href",t+i+"so_css_preview=1")}),t.updatePreviewCss()}).mouseleave(function(){t.clearHighlight()})},updatePreviewCss:function(){var e=this.$(".preview-iframe");if(0!==e.length){var t=e.contents().find("head");0===t.find("style.siteorigin-custom-css").length&&t.append('<style class="siteorigin-custom-css" type="text/css"></style>');var i=t.find("style.siteorigin-custom-css"),s=this.editor.codeMirror.getValue();i.html(s)}},highlight:function(e){try{this.editor.inspector.hl.highlight(e)}catch(t){console.log("No inspector to highlight with")}},clearHighlight:function(){try{this.editor.inspector.hl.clear()}catch(e){console.log("No inspector to highlight with")}}}),s.view.snippets=Backbone.View.extend({template:t.template(e("#template-snippet-browser").html()),snippet:t.template('<li class="snippet"><%- name %></li>'),className:"css-editor-snippet-browser",snippets:null,editor:null,events:{"click .close":"hide","click .buttons .insert-snippet":"insertSnippet"},currentSnippet:null,initialize:function(e){this.snippets=e.snippets},render:function(){var t=this,i=function(i){i.preventDefault();var s=e(this);t.$(".snippets li.snippet").removeClass("active"),e(this).addClass("active"),t.viewSnippet({name:s.html(),description:s.data("description"),css:s.data("css")})};this.$el.html(this.template());for(var s=0;s<this.snippets.length;s++)e(this.snippet({name:this.snippets[s].Name})).data({description:this.snippets[s].Description,css:this.snippets[s].css}).appendTo(this.$("ul.snippets")).click(i);return t.$(".snippets li.snippet").eq(0).click(),this.attach(),this},viewSnippet:function(e){var t=this.$(".main .snippet-view");t.find(".snippet-title").html(e.name),t.find(".snippet-description").html(e.description),t.find(".snippet-code").html(e.css),this.currentSnippet=e},insertSnippet:function(){var e=this.editor.codeMirror,t=this.currentSnippet.css,i="";i=1===e.doc.lineCount()&&0===e.doc.getLine(e.doc.lastLine()).length?"":0===e.doc.getLine(e.doc.lastLine()).length?"\n":"\n\n",e.doc.setCursor(e.doc.lastLine(),e.doc.getLine(e.doc.lastLine()).length),e.doc.replaceSelection(i+t),this.hide()},attach:function(){this.$el.appendTo("body")},show:function(){this.$el.show()},hide:function(){this.$el.hide()}}),s.view.properties=Backbone.View.extend({model:s.model.cssRules,tabTemplate:t.template('<li data-section="<%- id %>"><span class="fa fa-<%- icon %>"></span> <%- title %></li>'),sectionTemplate:t.template('<div class="section" data-section="<%- id %>"><table class="fields-table"><tbody></tbody></table></div>'),controllerTemplate:t.template('<tr><th scope="row"><%- title %></th><td></td></tr>'),propertyControllers:[],editor:null,css:"",parsed:{},activeSelector:"",editorExpandedBefore:!1,events:{"click .close":"hide"},initialize:function(e){this.parser=new cssjs,this.editor=e.editor},render:function(){var n=this,r=i.propertyControllers;for(var o in r){var a=(e(this.tabTemplate({id:o,icon:r[o].icon,title:r[o].title})).appendTo(this.$(".section-tabs")),e(this.sectionTemplate({id:o})).appendTo(this.$(".sections")));if(!t.isEmpty(r[o].controllers))for(var l=0;l<r[o].controllers.length;l++){var c,d=e(n.controllerTemplate({title:r[o].controllers[l].title})).appendTo(a.find("tbody")),p=r[o].controllers[l];c="undefined"==typeof s.view.properties.controllers[p.type]?new s.view.propertyController({el:d.find("td"),propertiesView:n,args:"undefined"==typeof p.args?{}:p.args}):new s.view.properties.controllers[p.type]({el:d.find("td"),propertiesView:n,args:"undefined"==typeof p.args?{}:p.args}),n.propertyControllers.push(c),c.render(),c.initChangeEvents()}}this.$(".section-tabs li").click(function(){var t=e(this),i=n.$('.sections .section[data-section="'+t.data("section")+'"]');n.$(".sections .section").not(i).hide().removeClass("active"),i.show().addClass("active"),n.$(".section-tabs li").not(t).removeClass("active"),t.addClass("active")}).eq(0).click(),this.$(".toolbar select").change(function(){n.setActivateSelector(e(this).find(":selected").data("selector"))})},setRuleValue:function(e,t){if("undefined"!=typeof this.activeSelector&&"undefined"!=typeof this.activeSelector.rules){for(var i=!0,s=0;s<this.activeSelector.rules.length;s++)if(this.activeSelector.rules[s].directive===e){this.activeSelector.rules[s].value=t,i=!1;break}i&&this.activeSelector.rules.push({directive:e,value:t}),this.updateMainEditor(!1)}},getRuleValue:function(e){if("undefined"==typeof this.activeSelector||"undefined"==typeof this.activeSelector.rules)return"";for(var t=0;t<this.activeSelector.rules.length;t++)if(this.activeSelector.rules[t].directive===e)return this.activeSelector.rules[t].value;return""},updateMainEditor:function(e){var t;"undefined"==typeof e||e===!0?(t=this.parser.compressCSS(this.parsed),t=t.filter(function(e){return"undefined"!=typeof e.type||e.rules.length>0})):t=this.parsed,this.editor.codeMirror.setValue(this.parser.getCSSForEditor(t).trim())},show:function(){this.editorExpandedBefore=this.editor.isExpanded(),this.editor.setExpand(!0),this.$el.show().animate({left:0},"fast")},hide:function(){this.editor.setExpand(this.editorExpandedBefore),this.$el.animate({left:-338},"fast",function(){e(this).hide()}),this.updateMainEditor(!0)},isVisible:function(){return this.$el.is(":visible")},loadCSS:function(t,i){this.css=t,this.parsed=this.parser.compressCSS(this.parser.parseCSS(t));for(var s=this.$(".toolbar select").empty(),n=0;n<this.parsed.length;n++){var r=this.parsed[n];if("undefined"!=typeof r.subStyles)for(var o=0;o<r.subStyles.length;o++){var a=r.subStyles[o];s.append(e("<option>").html(r.selector+": "+a.selector).attr("val",r.selector+": "+a.selector).data("selector",a))}else s.append(e("<option>").html(r.selector).attr("val",r.selector).data("selector",r))}"undefined"==typeof i&&(i=s.find("option").eq(0).attr("val")),s.val(i).change()},setActivateSelector:function(e){this.activeSelector=e;for(var t=0;t<this.propertyControllers.length;t++)this.propertyControllers[t].refreshFromRule()},addSelector:function(e){var t=this.$(".toolbar select");t.val(e),t.val()===e?t.change():(this.editor.addEmptySelector(e),this.loadCSS(this.editor.codeMirror.getValue(),e)),t.addClass("highlighted"),setTimeout(function(){t.removeClass("highlighted")},2e3)}}),s.view.propertyController=Backbone.View.extend({template:t.template('<input type="text" value="" />'),activeRule:null,args:null,propertiesView:null,initialize:function(e){this.args=e.args,this.propertiesView=e.propertiesView,this.on("set_value",this.updateRule,this),this.on("change",this.updateRule,this)},render:function(){this.$el.append(e(this.template({}))),this.field=this.$("input")},initChangeEvents:function(){var t=this;this.field.on("change keyup",function(){t.trigger("change",e(this).val())})},updateRule:function(){this.propertiesView.setRuleValue(this.args.property,this.getValue())},refreshFromRule:function(){var e=this.propertiesView.getRuleValue(this.args.property);this.setValue(e,{silent:!0})},getValue:function(){return this.field.val()},setValue:function(e,i){i=t.extend({silent:!1},i),this.field.val(e),i.silent||this.trigger("set_value",e)},reset:function(e){e=t.extend({silent:!1},e),this.setValue("",e)}}),s.view.properties.controllers={},s.view.properties.controllers.color=s.view.propertyController.extend({template:t.template('<input type="text" value="" />'),render:function(){this.$el.append(e(this.template({}))),this.field=this.$el.find("input"),this.field.minicolors({})},initChangeEvents:function(){var e=this;this.field.on("change keyup",function(){e.trigger("change",e.field.minicolors("value"))})},getValue:function(){return this.field.minicolors("value")},setValue:function(e,i){i=t.extend({silent:!1},i),this.field.minicolors("value",e),i.silent||this.trigger("set_value",e)}}),s.view.properties.controllers.select=s.view.propertyController.extend({template:t.template("<select></select>"),render:function(){this.$el.append(e(this.template({}))),this.field=this.$el.find("select"),this.field.append(e('<option value=""></option>').html(""));for(var t in this.args.options)this.field.append(e("<option></option>").attr("value",t).html(this.args.options[t]));"undefined"!=typeof this.args.option_icons&&this.setupVisualSelect()},setupVisualSelect:function(){var t=this;this.field.hide();var i=e('<div class="select-tabs"></div>').appendTo(this.$el);e('<div class="select-tab" data-value=""><span class="fa fa-circle-o"></span></div>').appendTo(i);for(var s in this.args.option_icons)e('<div class="select-tab"></div>').appendTo(i).append(e('<span class="fa"></span>').addClass("fa-"+this.args.option_icons[s])).attr("data-value",s);i.find(".select-tab").css("width",100/i.find(">div").length+"%").click(function(){var s=e(this);i.find(".select-tab").removeClass("active"),s.addClass("active"),t.field.val(s.data("value")).change()})},setValue:function(e,i){i=t.extend({silent:!1},i),this.field.val(e),this.$(".select-tabs .select-tab").removeClass("active").filter('[data-value="'+e+'"]').addClass("active"),i.silent||this.trigger("set_value",e)}}),s.view.properties.controllers.image=s.view.propertyController.extend({template:t.template('<input type="text" value="" /> <span class="select socss-button"><span class="fa fa-upload"></span></span>'),render:function(){var t=this;this.media=wp.media({title:i.loc.select_image,library:{type:"image"},button:{text:i.loc.select,close:!1}}),this.$el.append(e(this.template({select:i.loc.select}))),this.field=this.$el.find("input"),this.$(".select").click(function(){t.media.open()}),this.media.on("select",function(){var e=this.state().get("selection").first().attributes,i=t.args.value.replace("{{url}}",e.url);t.field.val(i).change(),t.media.close()},this.media)}}),s.view.properties.controllers.measurement=s.view.propertyController.extend({wrapperClass:"socss-field-measurement",render:function(){this.$el.append(e(this.template({}))),this.field=this.$("input"),this.setupMeasurementField(this.field,{})},setValue:function(e,i){i=t.extend({silent:!1},i),this.field.val(e).trigger("measurement_refresh"),i.silent||this.trigger("set_value",e)},units:["px","%","em","cm","mm","in","pt","pc","ex","ch","rem","vw","vh","vmin","vmax"],parseUnits:function(e){var t=function(e){return e.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&")},i=this.units.map(t),s=new RegExp("([0-9\\.\\-]+)("+i.join("|")+")?","i"),n=s.exec(e);return null===n?{value:"",unit:""}:{value:n[1],unit:void 0===n[2]?"":n[2]}},setupMeasurementField:function(i,s){var n=this,r=i.parent();s=t.extend({defaultUnit:"px"},s),i.hide(),r.addClass(this.wrapperClass).data("unit",s.defaultUnit);for(var o=e('<input type="text" class="socss-field-input"/>').appendTo(r),a=e('<span class="dashicons dashicons-arrow-down"></span>').appendTo(r),l=e('<ul class="dropdown"></ul>').appendTo(r),c=e('<span class="units"></span>').html(s.defaultUnit).appendTo(r),d=0;d<n.units.length;d++){var p=e("<li></li>").html(n.units[d]).data("unit",n.units[d]);n.units[d]===s.defaultUnit&&p.addClass("active"),l.append(p)}var h=function(){var e=n.parseUnits(o.val());""!==e.unit&&e.unit!==r.data("unit")&&(o.val(e.value),u(e.unit)),""===e.value?i.val(""):i.val(e.value+r.data("unit"))},u=function(e){c.html(e),r.data("unit",e),o.trigger("keydown")};a.click(function(){l.toggle()}),l.find("li").click(function(){l.toggle(),u(e(this).data("unit")),h(),i.trigger("change")}),o.on("keyup keydown",function(t){var i=(e(this),"");"keydown"===t.type&&(t.keyCode>=48&&t.keyCode<=57?i=String.fromCharCode(t.keyCode):189===t.keyCode?i="-":190===t.keyCode&&(i="."));var s=e('<span class="socss-hidden-placeholder"></span>').css({"font-size":"14px"}).html(o.val()+i).appendTo("body"),n=s.width();n=Math.min(n,63),s.remove(),c.css("left",n+12)}),o.on("keyup",function(e){h(),i.trigger("change")}),i.on("measurement_refresh",function(){var t=n.parseUnits(i.val());o.val(t.value);var a=""===t.unit?s.defaultUnit:t.unit;r.data("unit",a),c.html(a);var l=e('<span class="socss-hidden-placeholder"></span>').css({"font-size":"14px"}).html(t.value).appendTo("body"),d=l.width();d=Math.min(d,63),l.remove(),c.css("left",d+12)});var v=e('<div class="socss-diw"></div>').appendTo(r),f=e('<div class="dec-button socss-button"><span class="fa fa-minus"></span></div>').appendTo(v),m=e('<div class="inc-button socss-button"><span class="fa fa-plus"></span></div>').appendTo(v);m.click(function(){var e=n.parseUnits(i.val());if(""===e.value)return!0;var t=Math.ceil(1.05*e.value);o.val(t),h(),i.trigger("change").trigger("measurement_refresh")}),f.click(function(){var e=n.parseUnits(i.val());if(""===e.value)return!0;var t=Math.floor(e.value/1.05);o.val(t),h(),i.trigger("change").trigger("measurement_refresh")})}}),s.view.properties.controllers.number=s.view.propertyController.extend({render:function(){this.$el.append(e(this.template({}))),this.field=this.$("input"),this.setupNumberField(this.field,this.args)},setupNumberField:function(i,s){s=t.extend({change:null,"default":0,increment:1,decrement:-1,max:null,min:null},s);var n=i.parent();n.addClass("socss-field-number");var r=e('<div class="socss-diw"></div>').appendTo(n),o=e('<div class="dec-button socss-button">-</div>').appendTo(r);e('<div class="inc-button socss-button">+</div>').appendTo(r);return r.find("> div").click(function(t){t.preventDefault();var n=s["default"];""!==i.val()&&(n=Number(i.val())),n+=e(this).is(o)?s.decrement:s.increment,n=Math.round(100*n)/100,null!==s.max&&(n=Math.min(s.max,n)),null!==s.min&&(n=Math.max(s.min,n)),i.val(n),i.trigger("change")}),this}}),s.view.properties.controllers.sides=s.view.propertyController.extend({template:t.template(e("#template-sides-field").html().trim()),controllers:[],render:function(){var i=this;this.$el.append(e(this.template({}))),this.field=this.$el.find("input"),i.args.hasAll||(this.$(".select-tab").eq(0).remove(),this.$(".select-tab").css("width","25%")),this.$(".select-tab").each(function(){for(var n=e(this).data("direction"),r=e('<li class="side">').appendTo(i.$(".sides")).hide(),o=0;o<i.args.controllers.length;o++){var a=i.args.controllers[o],l="";l="all"===n?a.args.propertyAll:a.args.property.replace("{dir}",n);var c=t.extend({},a.args,{property:l}),d=new s.view.properties.controllers[a.type]({el:e("<div>").appendTo(r),propertiesView:i.propertiesView,args:c});d.render(),d.initChangeEvents(),i.propertiesView.propertyControllers.push(d)}e(this).on("click",function(){i.$(".select-tab").removeClass("active"),e(this).addClass("active"),i.$(".sides .side").hide(),r.show()})}),this.$(".select-tab").eq(0).click()}})}(jQuery,_,socssOptions),jQuery(function(e){var t=window.socss,i=new t.view.editor({el:e("#so-custom-css-form").get(0)});i.render(),i.setSnippets(socssOptions.snippets),window.socss.mainEditor=i,e("#so-custom-css-getting-started a.hide").click(function(t){t.preventDefault(),e("#so-custom-css-getting-started").slideUp(),e.get(e(this).attr("href"))})});
|
lib/codemirror/addon/fold/comment-fold.js
CHANGED
@@ -28,7 +28,9 @@ CodeMirror.registerGlobalHelper("fold", "comment", function(mode) {
|
|
28 |
continue;
|
29 |
}
|
30 |
if (pass == 1 && found < start.ch) return;
|
31 |
-
if (/comment/.test(cm.getTokenTypeAt(CodeMirror.Pos(line, found + 1)))
|
|
|
|
|
32 |
startCh = found + startToken.length;
|
33 |
break;
|
34 |
}
|
28 |
continue;
|
29 |
}
|
30 |
if (pass == 1 && found < start.ch) return;
|
31 |
+
if (/comment/.test(cm.getTokenTypeAt(CodeMirror.Pos(line, found + 1))) &&
|
32 |
+
(lineText.slice(found - endToken.length, found) == endToken ||
|
33 |
+
!/comment/.test(cm.getTokenTypeAt(CodeMirror.Pos(line, found))))) {
|
34 |
startCh = found + startToken.length;
|
35 |
break;
|
36 |
}
|
lib/codemirror/addon/fold/comment-fold.min.js
CHANGED
@@ -1 +1 @@
|
|
1 |
-
!function(e){"object"==typeof exports&&"object"==typeof module?e(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],e):e(CodeMirror)}(function(e){"use strict";e.registerGlobalHelper("fold","comment",function(e){return e.blockCommentStart&&e.blockCommentEnd},function(t,n){var o=t.getModeAt(n),r=o.blockCommentStart,i=o.blockCommentEnd;if(r&&i){for(var f,l=n.line,c=t.getLine(l),m=n.ch,a=0;;){var d=0>=m?-1:c.lastIndexOf(r,m-1);if(-1!=d){if(1==a&&d<n.ch)return;if(/comment/.test(t.getTokenTypeAt(e.Pos(l,d+1)))){f=d+r.length;break}m=d-1}else{if(1==a)return;a=1,m=c.length}}var u,b
|
1 |
+
!function(e){"object"==typeof exports&&"object"==typeof module?e(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],e):e(CodeMirror)}(function(e){"use strict";e.registerGlobalHelper("fold","comment",function(e){return e.blockCommentStart&&e.blockCommentEnd},function(t,n){var o=t.getModeAt(n),r=o.blockCommentStart,i=o.blockCommentEnd;if(r&&i){for(var f,l=n.line,c=t.getLine(l),m=n.ch,a=0;;){var d=0>=m?-1:c.lastIndexOf(r,m-1);if(-1!=d){if(1==a&&d<n.ch)return;if(/comment/.test(t.getTokenTypeAt(e.Pos(l,d+1)))&&(c.slice(d-i.length,d)==i||!/comment/.test(t.getTokenTypeAt(e.Pos(l,d))))){f=d+r.length;break}m=d-1}else{if(1==a)return;a=1,m=c.length}}var s,u,b=1,g=t.lastLine();e:for(var h=l;g>=h;++h)for(var k=t.getLine(h),p=h==l?f:0;;){var v=k.indexOf(r,p),y=k.indexOf(i,p);if(0>v&&(v=k.length),0>y&&(y=k.length),p=Math.min(v,y),p==k.length)break;if(p==v)++b;else if(!--b){s=h,u=p;break e}++p}if(null!=s&&(l!=s||u!=f))return{from:e.Pos(l,f),to:e.Pos(s,u)}}})});
|
lib/codemirror/addon/fold/markdown-fold.min.js
CHANGED
@@ -1 +1 @@
|
|
1 |
-
!function(e){"object"==typeof exports&&"object"==typeof module?e(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],e):e(CodeMirror)}(function(e){"use strict";e.registerHelper("fold","markdown",function(n,t){function r(t){var r=n.getTokenTypeAt(e.Pos(t,0));return r&&/\bheader\b/.test(r)}function i(e,n,t){var i=n&&n.match(/^#+/);return i&&r(e)?i[0].length:(i=t&&t.match(/^[=\-]+\s*$/),i&&r(e+1)?"="==t[0]?1:2:o)}var o=100,f=n.getLine(t.line),l=n.getLine(t.line+1),c=i(t.line,f,l);if(c
|
1 |
+
!function(e){"object"==typeof exports&&"object"==typeof module?e(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],e):e(CodeMirror)}(function(e){"use strict";e.registerHelper("fold","markdown",function(n,t){function r(t){var r=n.getTokenTypeAt(e.Pos(t,0));return r&&/\bheader\b/.test(r)}function i(e,n,t){var i=n&&n.match(/^#+/);return i&&r(e)?i[0].length:(i=t&&t.match(/^[=\-]+\s*$/),i&&r(e+1)?"="==t[0]?1:2:o)}var o=100,f=n.getLine(t.line),l=n.getLine(t.line+1),c=i(t.line,f,l);if(c!==o){for(var u=n.lastLine(),d=t.line,a=n.getLine(d+2);u>d&&!(i(d+1,l,a)<=c);)++d,l=a,a=n.getLine(d+2);return{from:e.Pos(t.line,f.length),to:e.Pos(d,n.getLine(d).length)}}})});
|
lib/codemirror/addon/hint/anyword-hint.js
CHANGED
@@ -21,7 +21,7 @@
|
|
21 |
while (start && word.test(curLine.charAt(start - 1))) --start;
|
22 |
var curWord = start != end && curLine.slice(start, end);
|
23 |
|
24 |
-
var list = [], seen = {};
|
25 |
var re = new RegExp(word.source, "g");
|
26 |
for (var dir = -1; dir <= 1; dir += 2) {
|
27 |
var line = cur.line, endLine = Math.min(Math.max(line + dir * range, editor.firstLine()), editor.lastLine()) + dir;
|
21 |
while (start && word.test(curLine.charAt(start - 1))) --start;
|
22 |
var curWord = start != end && curLine.slice(start, end);
|
23 |
|
24 |
+
var list = options && options.list || [], seen = {};
|
25 |
var re = new RegExp(word.source, "g");
|
26 |
for (var dir = -1; dir <= 1; dir += 2) {
|
27 |
var line = cur.line, endLine = Math.min(Math.max(line + dir * range, editor.firstLine()), editor.lastLine()) + dir;
|
lib/codemirror/addon/hint/anyword-hint.min.js
CHANGED
@@ -1 +1 @@
|
|
1 |
-
!function(e){"object"==typeof exports&&"object"==typeof module?e(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],e):e(CodeMirror)}(function(e){"use strict";var r=/[\w$]+/,
|
1 |
+
!function(e){"object"==typeof exports&&"object"==typeof module?e(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],e):e(CodeMirror)}(function(e){"use strict";var r=/[\w$]+/,t=500;e.registerHelper("hint","anyword",function(o,i){for(var n=i&&i.word||r,f=i&&i.range||t,s=o.getCursor(),a=o.getLine(s.line),c=s.ch,l=c;l&&n.test(a.charAt(l-1));)--l;for(var d=l!=c&&a.slice(l,c),u=i&&i.list||[],p={},g=new RegExp(n.source,"g"),h=-1;1>=h;h+=2)for(var m=s.line,y=Math.min(Math.max(m+h*f,o.firstLine()),o.lastLine())+h;m!=y;m+=h)for(var b,v=o.getLine(m);b=g.exec(v);)(m!=s.line||b[0]!==d)&&(d&&0!=b[0].lastIndexOf(d,0)||Object.prototype.hasOwnProperty.call(p,b[0])||(p[b[0]]=!0,u.push(b[0])));return{list:u,from:e.Pos(s.line,l),to:e.Pos(s.line,c)}})});
|
lib/codemirror/addon/hint/show-hint.js
CHANGED
@@ -25,25 +25,35 @@
|
|
25 |
};
|
26 |
|
27 |
CodeMirror.defineExtension("showHint", function(options) {
|
28 |
-
|
29 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
30 |
|
31 |
if (this.state.completionActive) this.state.completionActive.close();
|
32 |
var completion = this.state.completionActive = new Completion(this, options);
|
33 |
if (!completion.options.hint) return;
|
34 |
|
35 |
CodeMirror.signal(this, "startCompletion", this);
|
36 |
-
completion.update();
|
37 |
});
|
38 |
|
39 |
function Completion(cm, options) {
|
40 |
this.cm = cm;
|
41 |
-
this.options =
|
42 |
this.widget = null;
|
43 |
this.debounce = 0;
|
44 |
this.tick = 0;
|
45 |
-
this.startPos = this.cm.getCursor();
|
46 |
-
this.startLen = this.cm.getLine(this.startPos.line).length;
|
47 |
|
48 |
var self = this;
|
49 |
cm.on("cursorActivity", this.activityFunc = function() { self.cursorActivity(); });
|
@@ -61,6 +71,7 @@
|
|
61 |
this.tick = null;
|
62 |
this.cm.off("cursorActivity", this.activityFunc);
|
63 |
|
|
|
64 |
if (this.widget) this.widget.close();
|
65 |
CodeMirror.signal(this.cm, "endCompletion", this.cm);
|
66 |
},
|
@@ -78,15 +89,6 @@
|
|
78 |
this.close();
|
79 |
},
|
80 |
|
81 |
-
showHints: function(data) {
|
82 |
-
if (!data || !data.list.length || !this.active()) return this.close();
|
83 |
-
|
84 |
-
if (this.options.completeSingle && data.list.length == 1)
|
85 |
-
this.pick(data, 0);
|
86 |
-
else
|
87 |
-
this.showWidget(data);
|
88 |
-
},
|
89 |
-
|
90 |
cursorActivity: function() {
|
91 |
if (this.debounce) {
|
92 |
cancelAnimationFrame(this.debounce);
|
@@ -105,47 +107,48 @@
|
|
105 |
}
|
106 |
},
|
107 |
|
108 |
-
update: function() {
|
109 |
if (this.tick == null) return;
|
110 |
-
if (this.data) CodeMirror.signal(this.data, "update");
|
111 |
if (!this.options.hint.async) {
|
112 |
-
this.finishUpdate(this.options.hint(this.cm, this.options),
|
113 |
} else {
|
114 |
var myTick = ++this.tick, self = this;
|
115 |
this.options.hint(this.cm, function(data) {
|
116 |
-
if (self.tick == myTick) self.finishUpdate(data);
|
117 |
}, this.options);
|
118 |
}
|
119 |
},
|
120 |
|
121 |
-
finishUpdate: function(data) {
|
|
|
|
|
122 |
this.data = data;
|
123 |
-
|
|
|
124 |
if (this.widget) this.widget.close();
|
125 |
if (data && data.list.length) {
|
126 |
-
if (picked && data.list.length == 1)
|
127 |
-
|
|
|
|
|
|
|
|
|
128 |
}
|
129 |
-
},
|
130 |
-
|
131 |
-
showWidget: function(data) {
|
132 |
-
this.data = data;
|
133 |
-
this.widget = new Widget(this, data);
|
134 |
-
CodeMirror.signal(data, "shown");
|
135 |
-
},
|
136 |
-
|
137 |
-
buildOptions: function(options) {
|
138 |
-
var editor = this.cm.options.hintOptions;
|
139 |
-
var out = {};
|
140 |
-
for (var prop in defaultOptions) out[prop] = defaultOptions[prop];
|
141 |
-
if (editor) for (var prop in editor)
|
142 |
-
if (editor[prop] !== undefined) out[prop] = editor[prop];
|
143 |
-
if (options) for (var prop in options)
|
144 |
-
if (options[prop] !== undefined) out[prop] = options[prop];
|
145 |
-
return out;
|
146 |
}
|
147 |
};
|
148 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
149 |
function getText(completion) {
|
150 |
if (typeof completion == "string") return completion;
|
151 |
else return completion.text;
|
@@ -344,34 +347,79 @@
|
|
344 |
}
|
345 |
};
|
346 |
|
347 |
-
|
348 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
349 |
if (helpers.length) {
|
350 |
-
|
351 |
-
|
352 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
353 |
}
|
|
|
|
|
354 |
} else if (words = cm.getHelper(cm.getCursor(), "hintWords")) {
|
355 |
-
|
356 |
} else if (CodeMirror.hint.anyword) {
|
357 |
-
return CodeMirror.hint.anyword(cm, options)
|
|
|
|
|
358 |
}
|
|
|
|
|
|
|
|
|
359 |
});
|
360 |
|
361 |
CodeMirror.registerHelper("hint", "fromList", function(cm, options) {
|
362 |
var cur = cm.getCursor(), token = cm.getTokenAt(cur);
|
|
|
|
|
|
|
|
|
|
|
|
|
363 |
var found = [];
|
364 |
for (var i = 0; i < options.words.length; i++) {
|
365 |
var word = options.words[i];
|
366 |
-
if (word.slice(0,
|
367 |
found.push(word);
|
368 |
}
|
369 |
|
370 |
-
if (found.length) return {
|
371 |
-
list: found,
|
372 |
-
from: CodeMirror.Pos(cur.line, token.start),
|
373 |
-
to: CodeMirror.Pos(cur.line, token.end)
|
374 |
-
};
|
375 |
});
|
376 |
|
377 |
CodeMirror.commands.autocomplete = CodeMirror.showHint;
|
@@ -382,7 +430,7 @@
|
|
382 |
alignWithWord: true,
|
383 |
closeCharacters: /[\s()\[\]{};:>,]/,
|
384 |
closeOnUnfocus: true,
|
385 |
-
completeOnSingleClick:
|
386 |
container: null,
|
387 |
customKeys: null,
|
388 |
extraKeys: null
|
25 |
};
|
26 |
|
27 |
CodeMirror.defineExtension("showHint", function(options) {
|
28 |
+
options = parseOptions(this, this.getCursor("start"), options);
|
29 |
+
var selections = this.listSelections()
|
30 |
+
if (selections.length > 1) return;
|
31 |
+
// By default, don't allow completion when something is selected.
|
32 |
+
// A hint function can have a `supportsSelection` property to
|
33 |
+
// indicate that it can handle selections.
|
34 |
+
if (this.somethingSelected()) {
|
35 |
+
if (!options.hint.supportsSelection) return;
|
36 |
+
// Don't try with cross-line selections
|
37 |
+
for (var i = 0; i < selections.length; i++)
|
38 |
+
if (selections[i].head.line != selections[i].anchor.line) return;
|
39 |
+
}
|
40 |
|
41 |
if (this.state.completionActive) this.state.completionActive.close();
|
42 |
var completion = this.state.completionActive = new Completion(this, options);
|
43 |
if (!completion.options.hint) return;
|
44 |
|
45 |
CodeMirror.signal(this, "startCompletion", this);
|
46 |
+
completion.update(true);
|
47 |
});
|
48 |
|
49 |
function Completion(cm, options) {
|
50 |
this.cm = cm;
|
51 |
+
this.options = options;
|
52 |
this.widget = null;
|
53 |
this.debounce = 0;
|
54 |
this.tick = 0;
|
55 |
+
this.startPos = this.cm.getCursor("start");
|
56 |
+
this.startLen = this.cm.getLine(this.startPos.line).length - this.cm.getSelection().length;
|
57 |
|
58 |
var self = this;
|
59 |
cm.on("cursorActivity", this.activityFunc = function() { self.cursorActivity(); });
|
71 |
this.tick = null;
|
72 |
this.cm.off("cursorActivity", this.activityFunc);
|
73 |
|
74 |
+
if (this.widget && this.data) CodeMirror.signal(this.data, "close");
|
75 |
if (this.widget) this.widget.close();
|
76 |
CodeMirror.signal(this.cm, "endCompletion", this.cm);
|
77 |
},
|
89 |
this.close();
|
90 |
},
|
91 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
92 |
cursorActivity: function() {
|
93 |
if (this.debounce) {
|
94 |
cancelAnimationFrame(this.debounce);
|
107 |
}
|
108 |
},
|
109 |
|
110 |
+
update: function(first) {
|
111 |
if (this.tick == null) return;
|
|
|
112 |
if (!this.options.hint.async) {
|
113 |
+
this.finishUpdate(this.options.hint(this.cm, this.options), first);
|
114 |
} else {
|
115 |
var myTick = ++this.tick, self = this;
|
116 |
this.options.hint(this.cm, function(data) {
|
117 |
+
if (self.tick == myTick) self.finishUpdate(data, first);
|
118 |
}, this.options);
|
119 |
}
|
120 |
},
|
121 |
|
122 |
+
finishUpdate: function(data, first) {
|
123 |
+
if (this.data) CodeMirror.signal(this.data, "update");
|
124 |
+
if (data && this.data && CodeMirror.cmpPos(data.from, this.data.from)) data = null;
|
125 |
this.data = data;
|
126 |
+
|
127 |
+
var picked = (this.widget && this.widget.picked) || (first && this.options.completeSingle);
|
128 |
if (this.widget) this.widget.close();
|
129 |
if (data && data.list.length) {
|
130 |
+
if (picked && data.list.length == 1) {
|
131 |
+
this.pick(data, 0);
|
132 |
+
} else {
|
133 |
+
this.widget = new Widget(this, data);
|
134 |
+
CodeMirror.signal(data, "shown");
|
135 |
+
}
|
136 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
137 |
}
|
138 |
};
|
139 |
|
140 |
+
function parseOptions(cm, pos, options) {
|
141 |
+
var editor = cm.options.hintOptions;
|
142 |
+
var out = {};
|
143 |
+
for (var prop in defaultOptions) out[prop] = defaultOptions[prop];
|
144 |
+
if (editor) for (var prop in editor)
|
145 |
+
if (editor[prop] !== undefined) out[prop] = editor[prop];
|
146 |
+
if (options) for (var prop in options)
|
147 |
+
if (options[prop] !== undefined) out[prop] = options[prop];
|
148 |
+
if (out.hint.resolve) out.hint = out.hint.resolve(cm, pos)
|
149 |
+
return out;
|
150 |
+
}
|
151 |
+
|
152 |
function getText(completion) {
|
153 |
if (typeof completion == "string") return completion;
|
154 |
else return completion.text;
|
347 |
}
|
348 |
};
|
349 |
|
350 |
+
function applicableHelpers(cm, helpers) {
|
351 |
+
if (!cm.somethingSelected()) return helpers
|
352 |
+
var result = []
|
353 |
+
for (var i = 0; i < helpers.length; i++)
|
354 |
+
if (helpers[i].supportsSelection) result.push(helpers[i])
|
355 |
+
return result
|
356 |
+
}
|
357 |
+
|
358 |
+
function resolveAutoHints(cm, pos) {
|
359 |
+
var helpers = cm.getHelpers(pos, "hint"), words
|
360 |
if (helpers.length) {
|
361 |
+
var async = false, resolved
|
362 |
+
for (var i = 0; i < helpers.length; i++) if (helpers[i].async) async = true
|
363 |
+
if (async) {
|
364 |
+
resolved = function(cm, callback, options) {
|
365 |
+
var app = applicableHelpers(cm, helpers)
|
366 |
+
function run(i, result) {
|
367 |
+
if (i == app.length) return callback(null)
|
368 |
+
var helper = app[i]
|
369 |
+
if (helper.async) {
|
370 |
+
helper(cm, function(result) {
|
371 |
+
if (result) callback(result)
|
372 |
+
else run(i + 1)
|
373 |
+
}, options)
|
374 |
+
} else {
|
375 |
+
var result = helper(cm, options)
|
376 |
+
if (result) callback(result)
|
377 |
+
else run(i + 1)
|
378 |
+
}
|
379 |
+
}
|
380 |
+
run(0)
|
381 |
+
}
|
382 |
+
resolved.async = true
|
383 |
+
} else {
|
384 |
+
resolved = function(cm, options) {
|
385 |
+
var app = applicableHelpers(cm, helpers)
|
386 |
+
for (var i = 0; i < app.length; i++) {
|
387 |
+
var cur = app[i](cm, options)
|
388 |
+
if (cur && cur.list.length) return cur
|
389 |
+
}
|
390 |
+
}
|
391 |
}
|
392 |
+
resolved.supportsSelection = true
|
393 |
+
return resolved
|
394 |
} else if (words = cm.getHelper(cm.getCursor(), "hintWords")) {
|
395 |
+
return function(cm) { return CodeMirror.hint.fromList(cm, {words: words}) }
|
396 |
} else if (CodeMirror.hint.anyword) {
|
397 |
+
return function(cm, options) { return CodeMirror.hint.anyword(cm, options) }
|
398 |
+
} else {
|
399 |
+
return function() {}
|
400 |
}
|
401 |
+
}
|
402 |
+
|
403 |
+
CodeMirror.registerHelper("hint", "auto", {
|
404 |
+
resolve: resolveAutoHints
|
405 |
});
|
406 |
|
407 |
CodeMirror.registerHelper("hint", "fromList", function(cm, options) {
|
408 |
var cur = cm.getCursor(), token = cm.getTokenAt(cur);
|
409 |
+
var to = CodeMirror.Pos(cur.line, token.end);
|
410 |
+
if (token.string && /\w/.test(token.string[token.string.length - 1])) {
|
411 |
+
var term = token.string, from = CodeMirror.Pos(cur.line, token.start);
|
412 |
+
} else {
|
413 |
+
var term = "", from = to;
|
414 |
+
}
|
415 |
var found = [];
|
416 |
for (var i = 0; i < options.words.length; i++) {
|
417 |
var word = options.words[i];
|
418 |
+
if (word.slice(0, term.length) == term)
|
419 |
found.push(word);
|
420 |
}
|
421 |
|
422 |
+
if (found.length) return {list: found, from: from, to: to};
|
|
|
|
|
|
|
|
|
423 |
});
|
424 |
|
425 |
CodeMirror.commands.autocomplete = CodeMirror.showHint;
|
430 |
alignWithWord: true,
|
431 |
closeCharacters: /[\s()\[\]{};:>,]/,
|
432 |
closeOnUnfocus: true,
|
433 |
+
completeOnSingleClick: true,
|
434 |
container: null,
|
435 |
customKeys: null,
|
436 |
extraKeys: null
|
lib/codemirror/addon/hint/show-hint.min.js
CHANGED
@@ -1 +1 @@
|
|
1 |
-
!function(t){"object"==typeof exports&&"object"==typeof module?t(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],t):t(CodeMirror)}(function(t){"use strict";function i(t,i){this.cm=t,this.options=
|
1 |
+
!function(t){"object"==typeof exports&&"object"==typeof module?t(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],t):t(CodeMirror)}(function(t){"use strict";function i(t,i){this.cm=t,this.options=i,this.widget=null,this.debounce=0,this.tick=0,this.startPos=this.cm.getCursor("start"),this.startLen=this.cm.getLine(this.startPos.line).length-this.cm.getSelection().length;var e=this;t.on("cursorActivity",this.activityFunc=function(){e.cursorActivity()})}function e(t,i,e){var n=t.options.hintOptions,o={};for(var s in d)o[s]=d[s];if(n)for(var s in n)void 0!==n[s]&&(o[s]=n[s]);if(e)for(var s in e)void 0!==e[s]&&(o[s]=e[s]);return o.hint.resolve&&(o.hint=o.hint.resolve(t,i)),o}function n(t){return"string"==typeof t?t:t.text}function o(t,i){function e(t,e){var o;o="string"!=typeof e?function(t){return e(t,i)}:n.hasOwnProperty(e)?n[e]:e,s[t]=o}var n={Up:function(){i.moveFocus(-1)},Down:function(){i.moveFocus(1)},PageUp:function(){i.moveFocus(-i.menuSize()+1,!0)},PageDown:function(){i.moveFocus(i.menuSize()-1,!0)},Home:function(){i.setFocus(0)},End:function(){i.setFocus(i.length-1)},Enter:i.pick,Tab:i.pick,Esc:i.close},o=t.options.customKeys,s=o?{}:n;if(o)for(var c in o)o.hasOwnProperty(c)&&e(c,o[c]);var r=t.options.extraKeys;if(r)for(var c in r)r.hasOwnProperty(c)&&e(c,r[c]);return s}function s(t,i){for(;i&&i!=t;){if("LI"===i.nodeName.toUpperCase()&&i.parentNode==t)return i;i=i.parentNode}}function c(i,e){this.completion=i,this.data=e,this.picked=!1;var c=this,r=i.cm,h=this.hints=document.createElement("ul");h.className="CodeMirror-hints",this.selectedHint=e.selectedHint||0;for(var u=e.list,f=0;f<u.length;++f){var d=h.appendChild(document.createElement("li")),p=u[f],m=l+(f!=this.selectedHint?"":" "+a);null!=p.className&&(m=p.className+" "+m),d.className=m,p.render?p.render(d,e,p):d.appendChild(document.createTextNode(p.displayText||n(p))),d.hintId=f}var g=r.cursorCoords(i.options.alignWithWord?e.from:null),v=g.left,y=g.bottom,w=!0;h.style.left=v+"px",h.style.top=y+"px";var k=window.innerWidth||Math.max(document.body.offsetWidth,document.documentElement.offsetWidth),H=window.innerHeight||Math.max(document.body.offsetHeight,document.documentElement.offsetHeight);(i.options.container||document.body).appendChild(h);var C=h.getBoundingClientRect(),b=C.bottom-H;if(b>0){var A=C.bottom-C.top,x=g.top-(g.bottom-C.top);if(x-A>0)h.style.top=(y=g.top-A)+"px",w=!1;else if(A>H){h.style.height=H-5+"px",h.style.top=(y=g.bottom-C.top)+"px";var S=r.getCursor();e.from.ch!=S.ch&&(g=r.cursorCoords(S),h.style.left=(v=g.left)+"px",C=h.getBoundingClientRect())}}var T=C.right-k;if(T>0&&(C.right-C.left>k&&(h.style.width=k-5+"px",T-=C.right-C.left-k),h.style.left=(v=g.left-T)+"px"),r.addKeyMap(this.keyMap=o(i,{moveFocus:function(t,i){c.changeActive(c.selectedHint+t,i)},setFocus:function(t){c.changeActive(t)},menuSize:function(){return c.screenAmount()},length:u.length,close:function(){i.close()},pick:function(){c.pick()},data:e})),i.options.closeOnUnfocus){var M;r.on("blur",this.onBlur=function(){M=setTimeout(function(){i.close()},100)}),r.on("focus",this.onFocus=function(){clearTimeout(M)})}var F=r.getScrollInfo();return r.on("scroll",this.onScroll=function(){var t=r.getScrollInfo(),e=r.getWrapperElement().getBoundingClientRect(),n=y+F.top-t.top,o=n-(window.pageYOffset||(document.documentElement||document.body).scrollTop);return w||(o+=h.offsetHeight),o<=e.top||o>=e.bottom?i.close():(h.style.top=n+"px",void(h.style.left=v+F.left-t.left+"px"))}),t.on(h,"dblclick",function(t){var i=s(h,t.target||t.srcElement);i&&null!=i.hintId&&(c.changeActive(i.hintId),c.pick())}),t.on(h,"click",function(t){var e=s(h,t.target||t.srcElement);e&&null!=e.hintId&&(c.changeActive(e.hintId),i.options.completeOnSingleClick&&c.pick())}),t.on(h,"mousedown",function(){setTimeout(function(){r.focus()},20)}),t.signal(e,"select",u[0],h.firstChild),!0}function r(t,i){if(!t.somethingSelected())return i;for(var e=[],n=0;n<i.length;n++)i[n].supportsSelection&&e.push(i[n]);return e}function h(i,e){var n,o=i.getHelpers(e,"hint");if(o.length){for(var s,c=!1,h=0;h<o.length;h++)o[h].async&&(c=!0);return c?(s=function(t,i,e){function n(o,c){if(o==s.length)return i(null);var r=s[o];if(r.async)r(t,function(t){t?i(t):n(o+1)},e);else{var c=r(t,e);c?i(c):n(o+1)}}var s=r(t,o);n(0)},s.async=!0):s=function(t,i){for(var e=r(t,o),n=0;n<e.length;n++){var s=e[n](t,i);if(s&&s.list.length)return s}},s.supportsSelection=!0,s}return(n=i.getHelper(i.getCursor(),"hintWords"))?function(i){return t.hint.fromList(i,{words:n})}:t.hint.anyword?function(i,e){return t.hint.anyword(i,e)}:function(){}}var l="CodeMirror-hint",a="CodeMirror-hint-active";t.showHint=function(t,i,e){if(!i)return t.showHint(e);e&&e.async&&(i.async=!0);var n={hint:i};if(e)for(var o in e)n[o]=e[o];return t.showHint(n)},t.defineExtension("showHint",function(n){n=e(this,this.getCursor("start"),n);var o=this.listSelections();if(!(o.length>1)){if(this.somethingSelected()){if(!n.hint.supportsSelection)return;for(var s=0;s<o.length;s++)if(o[s].head.line!=o[s].anchor.line)return}this.state.completionActive&&this.state.completionActive.close();var c=this.state.completionActive=new i(this,n);c.options.hint&&(t.signal(this,"startCompletion",this),c.update(!0))}});var u=window.requestAnimationFrame||function(t){return setTimeout(t,1e3/60)},f=window.cancelAnimationFrame||clearTimeout;i.prototype={close:function(){this.active()&&(this.cm.state.completionActive=null,this.tick=null,this.cm.off("cursorActivity",this.activityFunc),this.widget&&this.data&&t.signal(this.data,"close"),this.widget&&this.widget.close(),t.signal(this.cm,"endCompletion",this.cm))},active:function(){return this.cm.state.completionActive==this},pick:function(i,e){var o=i.list[e];o.hint?o.hint(this.cm,i,o):this.cm.replaceRange(n(o),o.from||i.from,o.to||i.to,"complete"),t.signal(i,"pick",o),this.close()},cursorActivity:function(){this.debounce&&(f(this.debounce),this.debounce=0);var t=this.cm.getCursor(),i=this.cm.getLine(t.line);if(t.line!=this.startPos.line||i.length-t.ch!=this.startLen-this.startPos.ch||t.ch<this.startPos.ch||this.cm.somethingSelected()||t.ch&&this.options.closeCharacters.test(i.charAt(t.ch-1)))this.close();else{var e=this;this.debounce=u(function(){e.update()}),this.widget&&this.widget.disable()}},update:function(t){if(null!=this.tick)if(this.options.hint.async){var i=++this.tick,e=this;this.options.hint(this.cm,function(n){e.tick==i&&e.finishUpdate(n,t)},this.options)}else this.finishUpdate(this.options.hint(this.cm,this.options),t)},finishUpdate:function(i,e){this.data&&t.signal(this.data,"update"),i&&this.data&&t.cmpPos(i.from,this.data.from)&&(i=null),this.data=i;var n=this.widget&&this.widget.picked||e&&this.options.completeSingle;this.widget&&this.widget.close(),i&&i.list.length&&(n&&1==i.list.length?this.pick(i,0):(this.widget=new c(this,i),t.signal(i,"shown")))}},c.prototype={close:function(){if(this.completion.widget==this){this.completion.widget=null,this.hints.parentNode.removeChild(this.hints),this.completion.cm.removeKeyMap(this.keyMap);var t=this.completion.cm;this.completion.options.closeOnUnfocus&&(t.off("blur",this.onBlur),t.off("focus",this.onFocus)),t.off("scroll",this.onScroll)}},disable:function(){this.completion.cm.removeKeyMap(this.keyMap);var t=this;this.keyMap={Enter:function(){t.picked=!0}},this.completion.cm.addKeyMap(this.keyMap)},pick:function(){this.completion.pick(this.data,this.selectedHint)},changeActive:function(i,e){if(i>=this.data.list.length?i=e?this.data.list.length-1:0:0>i&&(i=e?0:this.data.list.length-1),this.selectedHint!=i){var n=this.hints.childNodes[this.selectedHint];n.className=n.className.replace(" "+a,""),n=this.hints.childNodes[this.selectedHint=i],n.className+=" "+a,n.offsetTop<this.hints.scrollTop?this.hints.scrollTop=n.offsetTop-3:n.offsetTop+n.offsetHeight>this.hints.scrollTop+this.hints.clientHeight&&(this.hints.scrollTop=n.offsetTop+n.offsetHeight-this.hints.clientHeight+3),t.signal(this.data,"select",this.data.list[this.selectedHint],n)}},screenAmount:function(){return Math.floor(this.hints.clientHeight/this.hints.firstChild.offsetHeight)||1}},t.registerHelper("hint","auto",{resolve:h}),t.registerHelper("hint","fromList",function(i,e){var n=i.getCursor(),o=i.getTokenAt(n),s=t.Pos(n.line,o.end);if(o.string&&/\w/.test(o.string[o.string.length-1]))var c=o.string,r=t.Pos(n.line,o.start);else var c="",r=s;for(var h=[],l=0;l<e.words.length;l++){var a=e.words[l];a.slice(0,c.length)==c&&h.push(a)}return h.length?{list:h,from:r,to:s}:void 0}),t.commands.autocomplete=t.showHint;var d={hint:t.hint.auto,completeSingle:!0,alignWithWord:!0,closeCharacters:/[\s()\[\]{};:>,]/,closeOnUnfocus:!0,completeOnSingleClick:!0,container:null,customKeys:null,extraKeys:null};t.defineOption("hintOptions",null)});
|
lib/codemirror/addon/hint/sql-hint.js
CHANGED
@@ -112,9 +112,14 @@
|
|
112 |
string = nameParts.pop();
|
113 |
var table = nameParts.join(".");
|
114 |
|
|
|
|
|
115 |
// Check if table is available. If not, find table by Alias
|
116 |
-
if (!getItem(tables, table))
|
|
|
117 |
table = findTableByAlias(table, editor);
|
|
|
|
|
118 |
|
119 |
var columns = getItem(tables, table);
|
120 |
if (columns && columns.columns)
|
@@ -122,11 +127,13 @@
|
|
122 |
|
123 |
if (columns) {
|
124 |
addMatches(result, string, columns, function(w) {
|
|
|
|
|
125 |
if (typeof w == "string") {
|
126 |
-
w =
|
127 |
} else {
|
128 |
w = shallowClone(w);
|
129 |
-
w.text =
|
130 |
}
|
131 |
return useBacktick ? insertBackticks(w) : w;
|
132 |
});
|
@@ -205,6 +212,7 @@
|
|
205 |
CodeMirror.registerHelper("hint", "sql", function(editor, options) {
|
206 |
tables = (options && options.tables) || {};
|
207 |
var defaultTableName = options && options.defaultTable;
|
|
|
208 |
defaultTable = defaultTableName && getItem(tables, defaultTableName);
|
209 |
keywords = keywords || getKeywords(editor);
|
210 |
|
@@ -237,7 +245,8 @@
|
|
237 |
} else {
|
238 |
addMatches(result, search, tables, function(w) {return w;});
|
239 |
addMatches(result, search, defaultTable, function(w) {return w;});
|
240 |
-
|
|
|
241 |
}
|
242 |
|
243 |
return {list: result, from: Pos(cur.line, start), to: Pos(cur.line, end)};
|
112 |
string = nameParts.pop();
|
113 |
var table = nameParts.join(".");
|
114 |
|
115 |
+
var alias = false;
|
116 |
+
var aliasTable = table;
|
117 |
// Check if table is available. If not, find table by Alias
|
118 |
+
if (!getItem(tables, table)) {
|
119 |
+
var oldTable = table;
|
120 |
table = findTableByAlias(table, editor);
|
121 |
+
if (table !== oldTable) alias = true;
|
122 |
+
}
|
123 |
|
124 |
var columns = getItem(tables, table);
|
125 |
if (columns && columns.columns)
|
127 |
|
128 |
if (columns) {
|
129 |
addMatches(result, string, columns, function(w) {
|
130 |
+
var tableInsert = table;
|
131 |
+
if (alias == true) tableInsert = aliasTable;
|
132 |
if (typeof w == "string") {
|
133 |
+
w = tableInsert + "." + w;
|
134 |
} else {
|
135 |
w = shallowClone(w);
|
136 |
+
w.text = tableInsert + "." + w.text;
|
137 |
}
|
138 |
return useBacktick ? insertBackticks(w) : w;
|
139 |
});
|
212 |
CodeMirror.registerHelper("hint", "sql", function(editor, options) {
|
213 |
tables = (options && options.tables) || {};
|
214 |
var defaultTableName = options && options.defaultTable;
|
215 |
+
var disableKeywords = options && options.disableKeywords;
|
216 |
defaultTable = defaultTableName && getItem(tables, defaultTableName);
|
217 |
keywords = keywords || getKeywords(editor);
|
218 |
|
245 |
} else {
|
246 |
addMatches(result, search, tables, function(w) {return w;});
|
247 |
addMatches(result, search, defaultTable, function(w) {return w;});
|
248 |
+
if (!disableKeywords)
|
249 |
+
addMatches(result, search, keywords, function(w) {return w.toUpperCase();});
|
250 |
}
|
251 |
|
252 |
return {list: result, from: Pos(cur.line, start), to: Pos(cur.line, end)};
|
lib/codemirror/addon/hint/sql-hint.min.js
CHANGED
@@ -1 +1 @@
|
|
1 |
-
!function(t){"object"==typeof exports&&"object"==typeof module?t(require("../../lib/codemirror"),require("../../mode/sql/sql")):"function"==typeof define&&define.amd?define(["../../lib/codemirror","../../mode/sql/sql"],t):t(CodeMirror)}(function(t){"use strict";function r(r){var n=r.doc.modeOption;return"sql"===n&&(n="text/x-sql"),t.resolveMode(n).keywords}function n(t){return"string"==typeof t?t:t.text}function e(t,r){if(!t.slice)return t[r];for(var e=t.length-1;e>=0;e--)if(n(t[e])==r)return t[e]}function o(t){var r={};for(var n in t)t.hasOwnProperty(n)&&(r[n]=t[n]);return r}function i(t,r){var e=t.length,o=n(r).substr(0,e);return t.toUpperCase()===o.toUpperCase()}function s(t,r,n,e){for(var o in n)n.hasOwnProperty(o)&&(n.slice&&(o=n[o]),i(r,o)&&t.push(e(o)))}function a(t){return"."==t.charAt(0)&&(t=t.substr(1)),t.replace(/`/g,"")}function u(t){for(var r=n(t).split("."),e=0;e<r.length;e++)r[e]="`"+r[e]+"`";var i=r.join(".");return"string"==typeof t?i:(t=o(t),t.text=i,t)}function f(t,r,n,i){for(var f=!1,c=[],l=r.start,p=!0;p;)p="."==r.string.charAt(0),f=f||"`"==r.string.charAt(0),l=r.start,c.unshift(a(r.string)),r=i.getTokenAt(A(t.line,r.start)),"."==r.string&&(p=!0,r=i.getTokenAt(A(t.line,r.start)));var v=c.join(".");s(n,v,
|
1 |
+
!function(t){"object"==typeof exports&&"object"==typeof module?t(require("../../lib/codemirror"),require("../../mode/sql/sql")):"function"==typeof define&&define.amd?define(["../../lib/codemirror","../../mode/sql/sql"],t):t(CodeMirror)}(function(t){"use strict";function r(r){var n=r.doc.modeOption;return"sql"===n&&(n="text/x-sql"),t.resolveMode(n).keywords}function n(t){return"string"==typeof t?t:t.text}function e(t,r){if(!t.slice)return t[r];for(var e=t.length-1;e>=0;e--)if(n(t[e])==r)return t[e]}function o(t){var r={};for(var n in t)t.hasOwnProperty(n)&&(r[n]=t[n]);return r}function i(t,r){var e=t.length,o=n(r).substr(0,e);return t.toUpperCase()===o.toUpperCase()}function s(t,r,n,e){for(var o in n)n.hasOwnProperty(o)&&(n.slice&&(o=n[o]),i(r,o)&&t.push(e(o)))}function a(t){return"."==t.charAt(0)&&(t=t.substr(1)),t.replace(/`/g,"")}function u(t){for(var r=n(t).split("."),e=0;e<r.length;e++)r[e]="`"+r[e]+"`";var i=r.join(".");return"string"==typeof t?i:(t=o(t),t.text=i,t)}function f(t,r,n,i){for(var f=!1,c=[],l=r.start,p=!0;p;)p="."==r.string.charAt(0),f=f||"`"==r.string.charAt(0),l=r.start,c.unshift(a(r.string)),r=i.getTokenAt(A(t.line,r.start)),"."==r.string&&(p=!0,r=i.getTokenAt(A(t.line,r.start)));var v=c.join(".");s(n,v,d,function(t){return f?u(t):t}),s(n,v,h,function(t){return f?u(t):t}),v=c.pop();var m=c.join("."),b=!1,x=m;if(!e(d,m)){var y=m;m=g(m,i),m!==y&&(b=!0)}var q=e(d,m);return q&&q.columns&&(q=q.columns),q&&s(n,v,q,function(t){var r=m;return 1==b&&(r=x),"string"==typeof t?t=r+"."+t:(t=o(t),t.text=r+"."+t.text),f?u(t):t}),l}function c(t,r){if(t)for(var n=/[,;]/g,e=t.split(" "),o=0;o<e.length;o++)r(e[o]?e[o].replace(n,""):"")}function l(t){return t.line+t.ch/Math.pow(10,6)}function p(t){return A(Math.floor(t),+t.toString().split(".").pop())}function g(t,r){for(var n=r.doc,o=n.getValue(),i=t.toUpperCase(),s="",a="",u=[],f={start:A(0,0),end:A(r.lastLine(),r.getLineHandle(r.lastLine()).length)},g=o.indexOf(m.QUERY_DIV);-1!=g;)u.push(n.posFromIndex(g)),g=o.indexOf(m.QUERY_DIV,g+1);u.unshift(A(0,0)),u.push(A(r.lastLine(),r.getLineHandle(r.lastLine()).text.length));for(var h=0,v=l(r.getCursor()),b=0;b<u.length;b++){var x=l(u[b]);if(v>h&&x>=v){f={start:p(h),end:p(x)};break}h=x}for(var y=n.getRange(f.start,f.end,!1),b=0;b<y.length;b++){var q=y[b];if(c(q,function(t){var r=t.toUpperCase();r===i&&e(d,s)&&(a=s),r!==m.ALIAS_KEYWORD&&(s=t)}),a)break}return a}var d,h,v,m={QUERY_DIV:";",ALIAS_KEYWORD:"AS"},A=t.Pos;t.registerHelper("hint","sql",function(t,n){d=n&&n.tables||{};var o=n&&n.defaultTable,i=n&&n.disableKeywords;h=o&&e(d,o),v=v||r(t),o&&!h&&(h=g(o,t)),h=h||[],h.columns&&(h=h.columns);var a,u,c,l=t.getCursor(),p=[],m=t.getTokenAt(l);return m.end>l.ch&&(m.end=l.ch,m.string=m.string.slice(0,l.ch-m.start)),m.string.match(/^[.`\w@]\w*$/)?(c=m.string,a=m.start,u=m.end):(a=u=l.ch,c=""),"."==c.charAt(0)||"`"==c.charAt(0)?a=f(l,m,p,t):(s(p,c,d,function(t){return t}),s(p,c,h,function(t){return t}),i||s(p,c,v,function(t){return t.toUpperCase()})),{list:p,from:A(l.line,a),to:A(l.line,u)}})});
|
lib/codemirror/addon/lint/css-lint.js
CHANGED
@@ -18,15 +18,7 @@
|
|
18 |
CodeMirror.registerHelper("lint", "css", function(text) {
|
19 |
var found = [];
|
20 |
if (!window.CSSLint) return found;
|
21 |
-
|
22 |
-
var results = CSSLint.verify(text, {
|
23 |
-
"box-model": 1,
|
24 |
-
"display-property-grouping": 1,
|
25 |
-
"duplicate-properties": 1,
|
26 |
-
"empty-rules": 1,
|
27 |
-
"known-properties": 1
|
28 |
-
}), messages = results.messages, message = null;
|
29 |
-
|
30 |
for ( var i = 0; i < messages.length; i++) {
|
31 |
message = messages[i];
|
32 |
var startLine = message.line -1, endLine = message.line -1, startCol = message.col -1, endCol = message.col;
|
18 |
CodeMirror.registerHelper("lint", "css", function(text) {
|
19 |
var found = [];
|
20 |
if (!window.CSSLint) return found;
|
21 |
+
var results = CSSLint.verify(text), messages = results.messages, message = null;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
22 |
for ( var i = 0; i < messages.length; i++) {
|
23 |
message = messages[i];
|
24 |
var startLine = message.line -1, endLine = message.line -1, startCol = message.col -1, endCol = message.col;
|
lib/codemirror/addon/lint/css-lint.min.js
CHANGED
@@ -1 +1 @@
|
|
1 |
-
!function(e){"object"==typeof exports&&"object"==typeof module?e(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],e):e(CodeMirror)}(function(e){"use strict";e.registerHelper("lint","css",function(r){var o=[];if(!window.CSSLint)return o;for(var i=CSSLint.verify(r
|
1 |
+
!function(e){"object"==typeof exports&&"object"==typeof module?e(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],e):e(CodeMirror)}(function(e){"use strict";e.registerHelper("lint","css",function(r){var o=[];if(!window.CSSLint)return o;for(var i=CSSLint.verify(r),t=i.messages,n=null,s=0;s<t.length;s++){n=t[s];var f=n.line-1,c=n.line-1,l=n.col-1,u=n.col;o.push({from:e.Pos(f,l),to:e.Pos(c,u),message:n.message,severity:n.type})}return o})});
|
lib/codemirror/addon/lint/html-lint.js
ADDED
@@ -0,0 +1,46 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
2 |
+
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
3 |
+
|
4 |
+
// Depends on htmlhint.js from http://htmlhint.com/js/htmlhint.js
|
5 |
+
|
6 |
+
// declare global: HTMLHint
|
7 |
+
|
8 |
+
(function(mod) {
|
9 |
+
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
10 |
+
mod(require("../../lib/codemirror"), require("htmlhint"));
|
11 |
+
else if (typeof define == "function" && define.amd) // AMD
|
12 |
+
define(["../../lib/codemirror", "htmlhint"], mod);
|
13 |
+
else // Plain browser env
|
14 |
+
mod(CodeMirror);
|
15 |
+
})(function(CodeMirror) {
|
16 |
+
"use strict";
|
17 |
+
|
18 |
+
var defaultRules = {
|
19 |
+
"tagname-lowercase": true,
|
20 |
+
"attr-lowercase": true,
|
21 |
+
"attr-value-double-quotes": true,
|
22 |
+
"doctype-first": false,
|
23 |
+
"tag-pair": true,
|
24 |
+
"spec-char-escape": true,
|
25 |
+
"id-unique": true,
|
26 |
+
"src-not-empty": true,
|
27 |
+
"attr-no-duplication": true
|
28 |
+
};
|
29 |
+
|
30 |
+
CodeMirror.registerHelper("lint", "html", function(text, options) {
|
31 |
+
var found = [];
|
32 |
+
if (!window.HTMLHint) return found;
|
33 |
+
var messages = HTMLHint.verify(text, options && options.rules || defaultRules);
|
34 |
+
for (var i = 0; i < messages.length; i++) {
|
35 |
+
var message = messages[i];
|
36 |
+
var startLine = message.line - 1, endLine = message.line - 1, startCol = message.col - 1, endCol = message.col;
|
37 |
+
found.push({
|
38 |
+
from: CodeMirror.Pos(startLine, startCol),
|
39 |
+
to: CodeMirror.Pos(endLine, endCol),
|
40 |
+
message: message.message,
|
41 |
+
severity : message.type
|
42 |
+
});
|
43 |
+
}
|
44 |
+
return found;
|
45 |
+
});
|
46 |
+
});
|
lib/codemirror/addon/lint/html-lint.min.js
ADDED
@@ -0,0 +1 @@
|
|
|
1 |
+
!function(e){"object"==typeof exports&&"object"==typeof module?e(require("../../lib/codemirror"),require("htmlhint")):"function"==typeof define&&define.amd?define(["../../lib/codemirror","htmlhint"],e):e(CodeMirror)}(function(e){"use strict";var t={"tagname-lowercase":!0,"attr-lowercase":!0,"attr-value-double-quotes":!0,"doctype-first":!1,"tag-pair":!0,"spec-char-escape":!0,"id-unique":!0,"src-not-empty":!0,"attr-no-duplication":!0};e.registerHelper("lint","html",function(r,i){var o=[];if(!window.HTMLHint)return o;for(var n=HTMLHint.verify(r,i&&i.rules||t),a=0;a<n.length;a++){var s=n[a],c=s.line-1,l=s.line-1,u=s.col-1,f=s.col;o.push({from:e.Pos(c,u),to:e.Pos(l,f),message:s.message,severity:s.type})}return o})});
|
lib/codemirror/addon/lint/lint.js
CHANGED
@@ -61,13 +61,12 @@
|
|
61 |
this.timeout = null;
|
62 |
this.hasGutter = hasGutter;
|
63 |
this.onMouseOver = function(e) { onMouseOver(cm, e); };
|
|
|
64 |
}
|
65 |
|
66 |
-
function parseOptions(
|
67 |
if (options instanceof Function) return {getAnnotations: options};
|
68 |
if (!options || options === true) options = {};
|
69 |
-
if (!options.getAnnotations) options.getAnnotations = cm.getHelper(CodeMirror.Pos(0, 0), "lint");
|
70 |
-
if (!options.getAnnotations) throw new Error("Required option 'getAnnotations' missing (lint addon)");
|
71 |
return options;
|
72 |
}
|
73 |
|
@@ -117,13 +116,32 @@
|
|
117 |
return tip;
|
118 |
}
|
119 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
120 |
function startLinting(cm) {
|
121 |
var state = cm.state.lint, options = state.options;
|
122 |
var passOptions = options.options || options; // Support deprecated passing of `options` property in options
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
|
|
|
|
|
|
127 |
}
|
128 |
|
129 |
function updateLinting(cm, annotationsNotSorted) {
|
@@ -187,7 +205,8 @@
|
|
187 |
CodeMirror.defineOption("lint", false, function(cm, val, old) {
|
188 |
if (old && old != CodeMirror.Init) {
|
189 |
clearMarks(cm);
|
190 |
-
cm.
|
|
|
191 |
CodeMirror.off(cm.getWrapperElement(), "mouseover", cm.state.lint.onMouseOver);
|
192 |
clearTimeout(cm.state.lint.timeout);
|
193 |
delete cm.state.lint;
|
@@ -197,11 +216,16 @@
|
|
197 |
var gutters = cm.getOption("gutters"), hasLintGutter = false;
|
198 |
for (var i = 0; i < gutters.length; ++i) if (gutters[i] == GUTTER_ID) hasLintGutter = true;
|
199 |
var state = cm.state.lint = new LintState(cm, parseOptions(cm, val), hasLintGutter);
|
200 |
-
|
|
|
201 |
if (state.options.tooltips != false)
|
202 |
CodeMirror.on(cm.getWrapperElement(), "mouseover", state.onMouseOver);
|
203 |
|
204 |
startLinting(cm);
|
205 |
}
|
206 |
});
|
|
|
|
|
|
|
|
|
207 |
});
|
61 |
this.timeout = null;
|
62 |
this.hasGutter = hasGutter;
|
63 |
this.onMouseOver = function(e) { onMouseOver(cm, e); };
|
64 |
+
this.waitingFor = 0
|
65 |
}
|
66 |
|
67 |
+
function parseOptions(_cm, options) {
|
68 |
if (options instanceof Function) return {getAnnotations: options};
|
69 |
if (!options || options === true) options = {};
|
|
|
|
|
70 |
return options;
|
71 |
}
|
72 |
|
116 |
return tip;
|
117 |
}
|
118 |
|
119 |
+
function lintAsync(cm, getAnnotations, passOptions) {
|
120 |
+
var state = cm.state.lint
|
121 |
+
var id = ++state.waitingFor
|
122 |
+
function abort() {
|
123 |
+
id = -1
|
124 |
+
cm.off("change", abort)
|
125 |
+
}
|
126 |
+
cm.on("change", abort)
|
127 |
+
getAnnotations(cm.getValue(), function(annotations, arg2) {
|
128 |
+
cm.off("change", abort)
|
129 |
+
if (state.waitingFor != id) return
|
130 |
+
if (arg2 && annotations instanceof CodeMirror) annotations = arg2
|
131 |
+
updateLinting(cm, annotations)
|
132 |
+
}, passOptions, cm);
|
133 |
+
}
|
134 |
+
|
135 |
function startLinting(cm) {
|
136 |
var state = cm.state.lint, options = state.options;
|
137 |
var passOptions = options.options || options; // Support deprecated passing of `options` property in options
|
138 |
+
var getAnnotations = options.getAnnotations || cm.getHelper(CodeMirror.Pos(0, 0), "lint");
|
139 |
+
if (!getAnnotations) return;
|
140 |
+
if (options.async || getAnnotations.async) {
|
141 |
+
lintAsync(cm, getAnnotations, passOptions)
|
142 |
+
} else {
|
143 |
+
updateLinting(cm, getAnnotations(cm.getValue(), passOptions, cm));
|
144 |
+
}
|
145 |
}
|
146 |
|
147 |
function updateLinting(cm, annotationsNotSorted) {
|
205 |
CodeMirror.defineOption("lint", false, function(cm, val, old) {
|
206 |
if (old && old != CodeMirror.Init) {
|
207 |
clearMarks(cm);
|
208 |
+
if (cm.state.lint.options.lintOnChange !== false)
|
209 |
+
cm.off("change", onChange);
|
210 |
CodeMirror.off(cm.getWrapperElement(), "mouseover", cm.state.lint.onMouseOver);
|
211 |
clearTimeout(cm.state.lint.timeout);
|
212 |
delete cm.state.lint;
|
216 |
var gutters = cm.getOption("gutters"), hasLintGutter = false;
|
217 |
for (var i = 0; i < gutters.length; ++i) if (gutters[i] == GUTTER_ID) hasLintGutter = true;
|
218 |
var state = cm.state.lint = new LintState(cm, parseOptions(cm, val), hasLintGutter);
|
219 |
+
if (state.options.lintOnChange !== false)
|
220 |
+
cm.on("change", onChange);
|
221 |
if (state.options.tooltips != false)
|
222 |
CodeMirror.on(cm.getWrapperElement(), "mouseover", state.onMouseOver);
|
223 |
|
224 |
startLinting(cm);
|
225 |
}
|
226 |
});
|
227 |
+
|
228 |
+
CodeMirror.defineExtension("performLint", function() {
|
229 |
+
if (this.state.lint) startLinting(this);
|
230 |
+
});
|
231 |
});
|
lib/codemirror/addon/lint/lint.min.js
CHANGED
@@ -1 +1 @@
|
|
1 |
-
!function(t){"object"==typeof exports&&"object"==typeof module?t(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],t):t(CodeMirror)}(function(t){"use strict";function e(e,n){function o(e){return r.parentNode?(r.style.top=Math.max(0,e.clientY-r.offsetHeight-5)+"px",void(r.style.left=e.clientX+5+"px")):t.off(document,"mousemove",o)}var r=document.createElement("div");return r.className="CodeMirror-lint-tooltip",r.appendChild(n.cloneNode(!0)),document.body.appendChild(r),t.on(document,"mousemove",o),o(e),null!=r.style.opacity&&(r.style.opacity=1),r}function n(t){t.parentNode&&t.parentNode.removeChild(t)}function o(t){t.parentNode&&(null==t.style.opacity&&n(t),t.style.opacity=0,setTimeout(function(){n(t)},600))}function r(n,r,i){function a(){t.off(i,"mouseout",a),
|
1 |
+
!function(t){"object"==typeof exports&&"object"==typeof module?t(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],t):t(CodeMirror)}(function(t){"use strict";function e(e,n){function o(e){return r.parentNode?(r.style.top=Math.max(0,e.clientY-r.offsetHeight-5)+"px",void(r.style.left=e.clientX+5+"px")):t.off(document,"mousemove",o)}var r=document.createElement("div");return r.className="CodeMirror-lint-tooltip",r.appendChild(n.cloneNode(!0)),document.body.appendChild(r),t.on(document,"mousemove",o),o(e),null!=r.style.opacity&&(r.style.opacity=1),r}function n(t){t.parentNode&&t.parentNode.removeChild(t)}function o(t){t.parentNode&&(null==t.style.opacity&&n(t),t.style.opacity=0,setTimeout(function(){n(t)},600))}function r(n,r,i){function a(){t.off(i,"mouseout",a),l&&(o(l),l=null)}var l=e(n,r),s=setInterval(function(){if(l)for(var t=i;;t=t.parentNode){if(t&&11==t.nodeType&&(t=t.host),t==document.body)return;if(!t){a();break}}return l?void 0:clearInterval(s)},400);t.on(i,"mouseout",a)}function i(t,e,n){this.marked=[],this.options=e,this.timeout=null,this.hasGutter=n,this.onMouseOver=function(e){g(t,e)},this.waitingFor=0}function a(t,e){return e instanceof Function?{getAnnotations:e}:(e&&e!==!0||(e={}),e)}function l(t){var e=t.state.lint;e.hasGutter&&t.clearGutter(y);for(var n=0;n<e.marked.length;++n)e.marked[n].clear();e.marked.length=0}function s(e,n,o,i){var a=document.createElement("div"),l=a;return a.className="CodeMirror-lint-marker-"+n,o&&(l=a.appendChild(document.createElement("div")),l.className="CodeMirror-lint-marker-multiple"),0!=i&&t.on(l,"mouseover",function(t){r(t,e,l)}),a}function u(t,e){return"error"==t?t:e}function c(t){for(var e=[],n=0;n<t.length;++n){var o=t[n],r=o.from.line;(e[r]||(e[r]=[])).push(o)}return e}function f(t){var e=t.severity;e||(e="error");var n=document.createElement("div");return n.className="CodeMirror-lint-message-"+e,n.appendChild(document.createTextNode(t.message)),n}function m(e,n,o){function r(){a=-1,e.off("change",r)}var i=e.state.lint,a=++i.waitingFor;e.on("change",r),n(e.getValue(),function(n,o){e.off("change",r),i.waitingFor==a&&(o&&n instanceof t&&(n=o),p(e,n))},o,e)}function d(e){var n=e.state.lint,o=n.options,r=o.options||o,i=o.getAnnotations||e.getHelper(t.Pos(0,0),"lint");i&&(o.async||i.async?m(e,i,r):p(e,i(e.getValue(),r,e)))}function p(t,e){l(t);for(var n=t.state.lint,o=n.options,r=c(e),i=0;i<r.length;++i){var a=r[i];if(a){for(var m=null,d=n.hasGutter&&document.createDocumentFragment(),p=0;p<a.length;++p){var v=a[p],h=v.severity;h||(h="error"),m=u(m,h),o.formatAnnotation&&(v=o.formatAnnotation(v)),n.hasGutter&&d.appendChild(f(v)),v.to&&n.marked.push(t.markText(v.from,v.to,{className:"CodeMirror-lint-mark-"+h,__annotation:v}))}n.hasGutter&&t.setGutterMarker(i,y,s(d,m,a.length>1,n.options.tooltips))}}o.onUpdateLinting&&o.onUpdateLinting(e,r,t)}function v(t){var e=t.state.lint;e&&(clearTimeout(e.timeout),e.timeout=setTimeout(function(){d(t)},e.options.delay||500))}function h(t,e){var n=e.target||e.srcElement;r(e,f(t),n)}function g(t,e){var n=e.target||e.srcElement;if(/\bCodeMirror-lint-mark-/.test(n.className))for(var o=n.getBoundingClientRect(),r=(o.left+o.right)/2,i=(o.top+o.bottom)/2,a=t.findMarksAt(t.coordsChar({left:r,top:i},"client")),l=0;l<a.length;++l){var s=a[l].__annotation;if(s)return h(s,e)}}var y="CodeMirror-lint-markers";t.defineOption("lint",!1,function(e,n,o){if(o&&o!=t.Init&&(l(e),e.state.lint.options.lintOnChange!==!1&&e.off("change",v),t.off(e.getWrapperElement(),"mouseover",e.state.lint.onMouseOver),clearTimeout(e.state.lint.timeout),delete e.state.lint),n){for(var r=e.getOption("gutters"),s=!1,u=0;u<r.length;++u)r[u]==y&&(s=!0);var c=e.state.lint=new i(e,a(e,n),s);c.options.lintOnChange!==!1&&e.on("change",v),0!=c.options.tooltips&&t.on(e.getWrapperElement(),"mouseover",c.onMouseOver),d(e)}}),t.defineExtension("performLint",function(){this.state.lint&&d(this)})});
|
lib/codemirror/addon/merge/merge.js
CHANGED
@@ -5,12 +5,12 @@
|
|
5 |
|
6 |
(function(mod) {
|
7 |
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
8 |
-
mod(require("../../lib/codemirror")
|
9 |
else if (typeof define == "function" && define.amd) // AMD
|
10 |
define(["../../lib/codemirror", "diff_match_patch"], mod);
|
11 |
else // Plain browser env
|
12 |
-
mod(CodeMirror
|
13 |
-
})(function(CodeMirror
|
14 |
"use strict";
|
15 |
var Pos = CodeMirror.Pos;
|
16 |
var svgNS = "http://www.w3.org/2000/svg";
|
@@ -471,13 +471,10 @@
|
|
471 |
if (left) left.init(leftPane, origLeft, options);
|
472 |
if (right) right.init(rightPane, origRight, options);
|
473 |
|
474 |
-
if (options.collapseIdentical)
|
475 |
-
updating = true;
|
476 |
this.editor().operation(function() {
|
477 |
collapseIdenticalStretches(self, options.collapseIdentical);
|
478 |
});
|
479 |
-
updating = false;
|
480 |
-
}
|
481 |
if (options.connect == "align") {
|
482 |
this.aligners = [];
|
483 |
alignChunks(this.left || this.right, true);
|
@@ -640,7 +637,7 @@
|
|
640 |
mark.clear();
|
641 |
cm.removeLineClass(from, "wrap", "CodeMirror-merge-collapsed-line");
|
642 |
}
|
643 |
-
|
644 |
return {mark: mark, clear: clear};
|
645 |
}
|
646 |
|
5 |
|
6 |
(function(mod) {
|
7 |
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
8 |
+
mod(require("../../lib/codemirror")); // Note non-packaged dependency diff_match_patch
|
9 |
else if (typeof define == "function" && define.amd) // AMD
|
10 |
define(["../../lib/codemirror", "diff_match_patch"], mod);
|
11 |
else // Plain browser env
|
12 |
+
mod(CodeMirror);
|
13 |
+
})(function(CodeMirror) {
|
14 |
"use strict";
|
15 |
var Pos = CodeMirror.Pos;
|
16 |
var svgNS = "http://www.w3.org/2000/svg";
|
471 |
if (left) left.init(leftPane, origLeft, options);
|
472 |
if (right) right.init(rightPane, origRight, options);
|
473 |
|
474 |
+
if (options.collapseIdentical)
|
|
|
475 |
this.editor().operation(function() {
|
476 |
collapseIdenticalStretches(self, options.collapseIdentical);
|
477 |
});
|
|
|
|
|
478 |
if (options.connect == "align") {
|
479 |
this.aligners = [];
|
480 |
alignChunks(this.left || this.right, true);
|
637 |
mark.clear();
|
638 |
cm.removeLineClass(from, "wrap", "CodeMirror-merge-collapsed-line");
|
639 |
}
|
640 |
+
CodeMirror.on(widget, "click", clear);
|
641 |
return {mark: mark, clear: clear};
|
642 |
}
|
643 |
|
lib/codemirror/addon/merge/merge.min.js
CHANGED
@@ -1 +1 @@
|
|
1 |
-
!function(e){"object"==typeof exports&&"object"==typeof module?e(require("../../lib/codemirror"),require("diff_match_patch")):"function"==typeof define&&define.amd?define(["../../lib/codemirror","diff_match_patch"],e):e(CodeMirror,diff_match_patch)}(function(e,t){"use strict";function r(e,t){this.mv=e,this.type=t,this.classes="left"==t?{chunk:"CodeMirror-merge-l-chunk",start:"CodeMirror-merge-l-chunk-start",end:"CodeMirror-merge-l-chunk-end",insert:"CodeMirror-merge-l-inserted",del:"CodeMirror-merge-l-deleted",connect:"CodeMirror-merge-l-connect"}:{chunk:"CodeMirror-merge-r-chunk",start:"CodeMirror-merge-r-chunk-start",end:"CodeMirror-merge-r-chunk-end",insert:"CodeMirror-merge-r-inserted",del:"CodeMirror-merge-r-deleted",connect:"CodeMirror-merge-r-connect"}}function i(t){t.diffOutOfDate&&(t.diff=w(t.orig.getValue(),t.edit.getValue()),t.chunks=y(t.diff),t.diffOutOfDate=!1,e.signal(t.edit,"updateDiff",t.diff))}function o(e){function t(t){j=!0,h=!1,"full"==t&&(e.svg&&N(e.svg),e.copyButtons&&N(e.copyButtons),c(e.edit,a.marked,e.classes),c(e.orig,s.marked,e.classes),a.from=a.to=s.from=s.to=0),i(e),e.showDifferences&&(f(e.edit,e.diff,a,DIFF_INSERT,e.classes),f(e.orig,e.diff,s,DIFF_DELETE,e.classes)),d(e),"align"==e.mv.options.connect&&v(e),j=!1}function r(t){j||(e.dealigned=!0,o(t))}function o(e){j||h||(clearTimeout(l),e===!0&&(h=!0),l=setTimeout(t,e===!0?20:250))}function n(t,i){e.diffOutOfDate||(e.diffOutOfDate=!0,a.from=a.to=s.from=s.to=0),r(i.text.length-1!=i.to.line-i.from.line)}var l,a={from:0,to:0,marked:[]},s={from:0,to:0,marked:[]},h=!1;return e.edit.on("change",n),e.orig.on("change",n),e.edit.on("markerAdded",r),e.edit.on("markerCleared",r),e.orig.on("markerAdded",r),e.orig.on("markerCleared",r),e.edit.on("viewportChange",function(){o(!1)}),e.orig.on("viewportChange",function(){o(!1)}),t(),t}function n(e){e.edit.on("scroll",function(){l(e,DIFF_INSERT)&&d(e)}),e.orig.on("scroll",function(){l(e,DIFF_DELETE)&&d(e)})}function l(e,t){if(e.diffOutOfDate)return!1;if(!e.lockScroll)return!0;var r,i,o=+new Date;if(t==DIFF_INSERT?(r=e.edit,i=e.orig):(r=e.orig,i=e.edit),r.state.scrollSetBy==e&&(r.state.scrollSetAt||0)+50>o)return!1;var n=r.getScrollInfo();if("align"==e.mv.options.connect)m=n.top;else{var l,s,c=.5*n.clientHeight,f=n.top+c,h=r.lineAtHeight(f,"local"),d=L(e.chunks,h,t==DIFF_INSERT),u=a(r,t==DIFF_INSERT?d.edit:d.orig),g=a(i,t==DIFF_INSERT?d.orig:d.edit),v=(f-u.top)/(u.bot-u.top),m=g.top-c+v*(g.bot-g.top);if(m>n.top&&(s=n.top/c)<1)m=m*s+n.top*(1-s);else if((l=n.height-n.clientHeight-n.top)<c){var p=i.getScrollInfo(),k=p.height-p.clientHeight-m;k>l&&(s=l/c)<1&&(m=m*s+(p.height-p.clientHeight-l)*(1-s))}}return i.scrollTo(n.left,m),i.state.scrollSetAt=o,i.state.scrollSetBy=e,!0}function a(e,t){var r=t.after;return null==r&&(r=e.lastLine()+1),{top:e.heightAtLine(t.before||0,"local"),bot:e.heightAtLine(r,"local")}}function s(e,t,r){e.lockScroll=t,t&&0!=r&&l(e,DIFF_INSERT)&&d(e),e.lockButton.innerHTML=t?"⇛⇚":"⇛ ⇚"}function c(t,r,i){for(var o=0;o<r.length;++o){var n=r[o];n instanceof e.TextMarker?n.clear():n.parent&&(t.removeLineClass(n,"background",i.chunk),t.removeLineClass(n,"background",i.start),t.removeLineClass(n,"background",i.end))}r.length=0}function f(e,t,r,i,o){var n=e.getViewport();e.operation(function(){r.from==r.to||n.from-r.to>20||r.from-n.to>20?(c(e,r.marked,o),h(e,t,i,r.marked,n.from,n.to,o),r.from=n.from,r.to=n.to):(n.from<r.from&&(h(e,t,i,r.marked,n.from,r.from,o),r.from=n.from),n.to>r.to&&(h(e,t,i,r.marked,r.to,n.to,o),r.to=n.to))})}function h(e,t,r,i,o,n,l){function a(t,r){for(var a=Math.max(o,t),s=Math.min(n,r),c=a;s>c;++c){var f=e.addLineClass(c,"background",l.chunk);c==t&&e.addLineClass(f,"background",l.start),c==r-1&&e.addLineClass(f,"background",l.end),i.push(f)}t==r&&a==r&&s==r&&(a?i.push(e.addLineClass(a-1,"background",l.end)):i.push(e.addLineClass(a,"background",l.start)))}for(var s=W(0,0),c=W(o,0),f=e.clipPos(W(n-1)),h=r==DIFF_DELETE?l.del:l.insert,d=0,u=0;u<t.length;++u){var g=t[u],v=g[0],m=g[1];if(v==DIFF_EQUAL){var p=s.line+(M(t,u)?0:1);x(s,m);var k=s.line+(D(t,u)?1:0);k>p&&(u&&a(d,p),d=k)}else if(v==r){var C=x(s,m,!0),T=R(c,s),F=B(f,C);V(T,F)||i.push(e.markText(T,F,{className:h})),s=C}}d<=s.line&&a(d,s.line+1)}function d(e){if(e.showDifferences){if(e.svg){N(e.svg);var t=e.gap.offsetWidth;_(e.svg,"width",t,"height",e.gap.offsetHeight)}e.copyButtons&&N(e.copyButtons);for(var r=e.edit.getViewport(),i=e.orig.getViewport(),o=e.edit.getScrollInfo().top,n=e.orig.getScrollInfo().top,l=0;l<e.chunks.length;l++){var a=e.chunks[l];a.editFrom<=r.to&&a.editTo>=r.from&&a.origFrom<=i.to&&a.origTo>=i.from&&k(e,a,n,o,t)}}}function u(e,t){for(var r=0,i=0,o=0;o<t.length;o++){var n=t[o];if(n.editTo>e&&n.editFrom<=e)return null;if(n.editFrom>e)break;r=n.editTo,i=n.origTo}return i+(e-r)}function g(e,t){for(var r=[],i=0;i<e.chunks.length;i++){var o=e.chunks[i];r.push([o.origTo,o.editTo,t?u(o.editTo,t.chunks):null])}if(t)for(var i=0;i<t.chunks.length;i++){for(var o=t.chunks[i],n=0;n<r.length;n++){var l=r[n];if(l[1]==o.editTo){n=-1;break}if(l[1]>o.editTo)break}n>-1&&r.splice(n-1,0,[u(o.editTo,e.chunks),o.editTo,o.origTo])}return r}function v(e,t){if(e.dealigned||t){if(!e.orig.curOp)return e.orig.operation(function(){v(e,t)});e.dealigned=!1;var r=e.mv.left==e?e.mv.right:e.mv.left;r&&(i(r),r.dealigned=!1);for(var o=g(e,r),n=e.mv.aligners,l=0;l<n.length;l++)n[l].clear();n.length=0;var a=[e.orig,e.edit],s=[];r&&a.push(r.orig);for(var l=0;l<a.length;l++)s.push(a[l].getScrollInfo().top);for(var c=0;c<o.length;c++)m(a,o[c],n);for(var l=0;l<a.length;l++)a[l].scrollTo(null,s[l])}}function m(e,t,r){for(var i=0,o=[],n=0;n<e.length;n++)if(null!=t[n]){var l=e[n].heightAtLine(t[n],"local");o[n]=l,i=Math.max(i,l)}for(var n=0;n<e.length;n++)if(null!=t[n]){var a=i-o[n];a>1&&r.push(p(e[n],t[n],a))}}function p(e,t,r){var i=!0;t>e.lastLine()&&(t--,i=!1);var o=document.createElement("div");return o.className="CodeMirror-merge-spacer",o.style.height=r+"px",o.style.minWidth="1px",e.addLineWidget(t,o,{height:r,above:i})}function k(e,t,r,i,o){var n="left"==e.type,l=e.orig.heightAtLine(t.origFrom,"local")-r;if(e.svg){var a=l,s=e.edit.heightAtLine(t.editFrom,"local")-i;if(n){var c=a;a=s,s=c}var f=e.orig.heightAtLine(t.origTo,"local")-r,h=e.edit.heightAtLine(t.editTo,"local")-i;if(n){var c=f;f=h,h=c}var d=" C "+o/2+" "+s+" "+o/2+" "+a+" "+(o+2)+" "+a,u=" C "+o/2+" "+f+" "+o/2+" "+h+" -1 "+h;_(e.svg.appendChild(document.createElementNS(z,"path")),"d","M -1 "+s+d+" L "+(o+2)+" "+f+u+" z","class",e.classes.connect)}if(e.copyButtons){var g=e.copyButtons.appendChild(O("div","left"==e.type?"⇝":"⇜","CodeMirror-merge-copy")),v=e.mv.options.allowEditingOriginals;if(g.title=v?"Push to left":"Revert chunk",g.chunk=t,g.style.top=l+"px",v){var m=e.orig.heightAtLine(t.editFrom,"local")-i,p=e.copyButtons.appendChild(O("div","right"==e.type?"⇝":"⇜","CodeMirror-merge-copy-reverse"));p.title="Push to right",p.chunk={editFrom:t.origFrom,editTo:t.origTo,origFrom:t.editFrom,origTo:t.editTo},p.style.top=m+"px","right"==e.type?p.style.left="2px":p.style.right="2px"}}}function C(e,t,r,i){e.diffOutOfDate||t.replaceRange(r.getRange(W(i.origFrom,0),W(i.origTo,0)),W(i.editFrom,0),W(i.editTo,0))}function T(t){var r=t.lockButton=O("div",null,"CodeMirror-merge-scrolllock");r.title="Toggle locked scrolling";var i=O("div",[r],"CodeMirror-merge-scrolllock-wrap");e.on(r,"click",function(){s(t,!t.lockScroll)});var o=[i];if(t.mv.options.revertButtons!==!1&&(t.copyButtons=O("div",null,"CodeMirror-merge-copybuttons-"+t.type),e.on(t.copyButtons,"click",function(e){var r=e.target||e.srcElement;if(r.chunk)return"CodeMirror-merge-copy-reverse"==r.className?void C(t,t.orig,t.edit,r.chunk):void C(t,t.edit,t.orig,r.chunk)}),o.unshift(t.copyButtons)),"align"!=t.mv.options.connect){var n=document.createElementNS&&document.createElementNS(z,"svg");n&&!n.createSVGRect&&(n=null),t.svg=n,n&&o.push(n)}return t.gap=O("div",o,"CodeMirror-merge-gap")}function F(e){return"string"==typeof e?e:e.getValue()}function w(e,t){var r=Q.diff_main(e,t);Q.diff_cleanupSemantic(r);for(var i=0;i<r.length;++i){var o=r[i];o[1]?i&&r[i-1][0]==o[0]&&(r.splice(i--,1),r[i][1]+=o[1]):r.splice(i--,1)}return r}function y(e){for(var t=[],r=0,i=0,o=W(0,0),n=W(0,0),l=0;l<e.length;++l){var a=e[l],s=a[0];if(s==DIFF_EQUAL){var c=M(e,l)?0:1,f=o.line+c,h=n.line+c;x(o,a[1],null,n);var d=D(e,l)?1:0,u=o.line+d,g=n.line+d;u>f&&(l&&t.push({origFrom:i,origTo:h,editFrom:r,editTo:f}),r=u,i=g)}else x(s==DIFF_INSERT?o:n,a[1])}return(r<=o.line||i<=n.line)&&t.push({origFrom:i,origTo:n.line+1,editFrom:r,editTo:o.line+1}),t}function D(e,t){if(t==e.length-1)return!0;var r=e[t+1][1];return 1==r.length||10!=r.charCodeAt(0)?!1:t==e.length-2?!0:(r=e[t+2][1],r.length>1&&10==r.charCodeAt(0))}function M(e,t){if(0==t)return!0;var r=e[t-1][1];return 10!=r.charCodeAt(r.length-1)?!1:1==t?!0:(r=e[t-2][1],10==r.charCodeAt(r.length-1))}function L(e,t,r){for(var i,o,n,l,a=0;a<e.length;a++){var s=e[a],c=r?s.editFrom:s.origFrom,f=r?s.editTo:s.origTo;null==o&&(c>t?(o=s.editFrom,l=s.origFrom):f>t&&(o=s.editTo,l=s.origTo)),t>=f?(i=s.editTo,n=s.origTo):t>=c&&(i=s.editFrom,n=s.origFrom)}return{edit:{before:i,after:o},orig:{before:n,after:l}}}function I(e,t,r){function i(){n.clear(),e.removeLineClass(t,"wrap","CodeMirror-merge-collapsed-line")}e.addLineClass(t,"wrap","CodeMirror-merge-collapsed-line");var o=document.createElement("span");o.className="CodeMirror-merge-collapsed-widget",o.title="Identical text collapsed. Click to expand.";var n=e.markText(W(t,0),W(r-1),{inclusiveLeft:!0,inclusiveRight:!0,replacedWith:o,clearOnEnter:!0});return o.addEventListener("click",i),{mark:n,clear:i}}function b(e,t){function r(){for(var e=0;e<i.length;e++)i[e].clear()}for(var i=[],o=0;o<t.length;o++){var n=t[o],l=I(n.cm,n.line,n.line+e);i.push(l),l.mark.on("clear",r)}return i[0].mark}function E(e,t,r,i){for(var o=0;o<e.chunks.length;o++)for(var n=e.chunks[o],l=n.editFrom-t;l<n.editTo+t;l++){var a=l+r;a>=0&&a<i.length&&(i[a]=!1)}}function S(e,t){"number"!=typeof t&&(t=2);for(var r=[],i=e.editor(),o=i.firstLine(),n=o,l=i.lastLine();l>=n;n++)r.push(!0);e.left&&E(e.left,t,o,r),e.right&&E(e.right,t,o,r);for(var a=0;a<r.length;a++)if(r[a]){for(var s=a+o,c=1;a<r.length-1&&r[a+1];a++,c++);if(c>t){var f=[{line:s,cm:i}];e.left&&f.push({line:u(s,e.left.chunks),cm:e.left.orig}),e.right&&f.push({line:u(s,e.right.chunks),cm:e.right.orig});var h=b(c,f);e.options.onCollapse&&e.options.onCollapse(e,s,c,h)}}}function O(e,t,r,i){var o=document.createElement(e);if(r&&(o.className=r),i&&(o.style.cssText=i),"string"==typeof t)o.appendChild(document.createTextNode(t));else if(t)for(var n=0;n<t.length;++n)o.appendChild(t[n]);return o}function N(e){for(var t=e.childNodes.length;t>0;--t)e.removeChild(e.firstChild)}function _(e){for(var t=1;t<arguments.length;t+=2)e.setAttribute(arguments[t],arguments[t+1])}function A(e,t){t||(t={});for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r]);return t}function x(e,t,r,i){for(var o=r?W(e.line,e.ch):e,n=0;;){var l=t.indexOf("\n",n);if(-1==l)break;++o.line,i&&++i.line,n=l+1}return o.ch=(n?0:o.ch)+(t.length-n),i&&(i.ch=(n?0:i.ch)+(t.length-n)),o}function B(e,t){return(e.line-t.line||e.ch-t.ch)<0?e:t}function R(e,t){return(e.line-t.line||e.ch-t.ch)>0?e:t}function V(e,t){return e.line==t.line&&e.ch==t.ch}function H(e,t,r){for(var i=e.length-1;i>=0;i--){var o=e[i],n=(r?o.origTo:o.editTo)-1;if(t>n)return n}}function P(e,t,r){for(var i=0;i<e.length;i++){var o=e[i],n=r?o.origFrom:o.editFrom;if(n>t)return n}}function U(t,r){var o=null,n=t.state.diffViews,l=t.getCursor().line;if(n)for(var a=0;a<n.length;a++){var s=n[a],c=t==s.orig;i(s);var f=0>r?H(s.chunks,l,c):P(s.chunks,l,c);null==f||null!=o&&!(0>r?f>o:o>f)||(o=f)}return null==o?e.Pass:void t.setCursor(o,0)}var W=e.Pos,z="http://www.w3.org/2000/svg";r.prototype={constructor:r,init:function(t,r,i){this.edit=this.mv.edit,(this.edit.state.diffViews||(this.edit.state.diffViews=[])).push(this),this.orig=e(t,A({value:r,readOnly:!this.mv.options.allowEditingOriginals},A(i))),this.orig.state.diffViews=[this],this.diff=w(F(r),F(i.value)),this.chunks=y(this.diff),this.diffOutOfDate=this.dealigned=!1,this.showDifferences=i.showDifferences!==!1,this.forceUpdate=o(this),s(this,!0,!1),n(this)},setShowDifferences:function(e){e=e!==!1,e!=this.showDifferences&&(this.showDifferences=e,this.forceUpdate("full"))}};var j=!1,q=e.MergeView=function(t,i){if(!(this instanceof q))return new q(t,i);this.options=i;var o=i.origLeft,n=null==i.origRight?i.orig:i.origRight,l=null!=o,a=null!=n,s=1+(l?1:0)+(a?1:0),c=[],f=this.left=null,h=this.right=null,u=this;if(l){f=this.left=new r(this,"left");var g=O("div",null,"CodeMirror-merge-pane");c.push(g),c.push(T(f))}var m=O("div",null,"CodeMirror-merge-pane");if(c.push(m),a){h=this.right=new r(this,"right"),c.push(T(h));var p=O("div",null,"CodeMirror-merge-pane");c.push(p)}(a?p:m).className+=" CodeMirror-merge-pane-rightmost",c.push(O("div",null,null,"height: 0; clear: both;"));var k=this.wrap=t.appendChild(O("div",c,"CodeMirror-merge CodeMirror-merge-"+s+"pane"));this.edit=e(m,A(i)),f&&f.init(g,o,i),h&&h.init(p,n,i),i.collapseIdentical&&(j=!0,this.editor().operation(function(){S(u,i.collapseIdentical)}),j=!1),"align"==i.connect&&(this.aligners=[],v(this.left||this.right,!0));var C=function(){f&&d(f),h&&d(h)};e.on(window,"resize",C);var F=setInterval(function(){for(var t=k.parentNode;t&&t!=document.body;t=t.parentNode);t||(clearInterval(F),e.off(window,"resize",C))},5e3)};q.prototype={constuctor:q,editor:function(){return this.edit},rightOriginal:function(){return this.right&&this.right.orig},leftOriginal:function(){return this.left&&this.left.orig},setShowDifferences:function(e){this.right&&this.right.setShowDifferences(e),this.left&&this.left.setShowDifferences(e)},rightChunks:function(){return this.right?(i(this.right),this.right.chunks):void 0},leftChunks:function(){return this.left?(i(this.left),this.left.chunks):void 0}};var Q=new t;e.commands.goNextDiff=function(e){return U(e,1)},e.commands.goPrevDiff=function(e){return U(e,-1)}});
|
1 |
+
!function(e){"object"==typeof exports&&"object"==typeof module?e(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror","diff_match_patch"],e):e(CodeMirror)}(function(e){"use strict";function t(e,t){this.mv=e,this.type=t,this.classes="left"==t?{chunk:"CodeMirror-merge-l-chunk",start:"CodeMirror-merge-l-chunk-start",end:"CodeMirror-merge-l-chunk-end",insert:"CodeMirror-merge-l-inserted",del:"CodeMirror-merge-l-deleted",connect:"CodeMirror-merge-l-connect"}:{chunk:"CodeMirror-merge-r-chunk",start:"CodeMirror-merge-r-chunk-start",end:"CodeMirror-merge-r-chunk-end",insert:"CodeMirror-merge-r-inserted",del:"CodeMirror-merge-r-deleted",connect:"CodeMirror-merge-r-connect"}}function r(t){t.diffOutOfDate&&(t.diff=F(t.orig.getValue(),t.edit.getValue()),t.chunks=w(t.diff),t.diffOutOfDate=!1,e.signal(t.edit,"updateDiff",t.diff))}function i(e){function t(t){z=!0,d=!1,"full"==t&&(e.svg&&O(e.svg),e.copyButtons&&O(e.copyButtons),s(e.edit,a.marked,e.classes),s(e.orig,f.marked,e.classes),a.from=a.to=f.from=f.to=0),r(e),e.showDifferences&&(c(e.edit,e.diff,a,DIFF_INSERT,e.classes),c(e.orig,e.diff,f,DIFF_DELETE,e.classes)),h(e),"align"==e.mv.options.connect&&g(e),z=!1}function i(t){z||(e.dealigned=!0,o(t))}function o(e){z||d||(clearTimeout(l),e===!0&&(d=!0),l=setTimeout(t,e===!0?20:250))}function n(t,r){e.diffOutOfDate||(e.diffOutOfDate=!0,a.from=a.to=f.from=f.to=0),i(r.text.length-1!=r.to.line-r.from.line)}var l,a={from:0,to:0,marked:[]},f={from:0,to:0,marked:[]},d=!1;return e.edit.on("change",n),e.orig.on("change",n),e.edit.on("markerAdded",i),e.edit.on("markerCleared",i),e.orig.on("markerAdded",i),e.orig.on("markerCleared",i),e.edit.on("viewportChange",function(){o(!1)}),e.orig.on("viewportChange",function(){o(!1)}),t(),t}function o(e){e.edit.on("scroll",function(){n(e,DIFF_INSERT)&&h(e)}),e.orig.on("scroll",function(){n(e,DIFF_DELETE)&&h(e)})}function n(e,t){if(e.diffOutOfDate)return!1;if(!e.lockScroll)return!0;var r,i,o=+new Date;if(t==DIFF_INSERT?(r=e.edit,i=e.orig):(r=e.orig,i=e.edit),r.state.scrollSetBy==e&&(r.state.scrollSetAt||0)+50>o)return!1;var n=r.getScrollInfo();if("align"==e.mv.options.connect)m=n.top;else{var a,s,c=.5*n.clientHeight,f=n.top+c,h=r.lineAtHeight(f,"local"),d=M(e.chunks,h,t==DIFF_INSERT),u=l(r,t==DIFF_INSERT?d.edit:d.orig),g=l(i,t==DIFF_INSERT?d.orig:d.edit),v=(f-u.top)/(u.bot-u.top),m=g.top-c+v*(g.bot-g.top);if(m>n.top&&(s=n.top/c)<1)m=m*s+n.top*(1-s);else if((a=n.height-n.clientHeight-n.top)<c){var p=i.getScrollInfo(),k=p.height-p.clientHeight-m;k>a&&(s=a/c)<1&&(m=m*s+(p.height-p.clientHeight-a)*(1-s))}}return i.scrollTo(n.left,m),i.state.scrollSetAt=o,i.state.scrollSetBy=e,!0}function l(e,t){var r=t.after;return null==r&&(r=e.lastLine()+1),{top:e.heightAtLine(t.before||0,"local"),bot:e.heightAtLine(r,"local")}}function a(e,t,r){e.lockScroll=t,t&&0!=r&&n(e,DIFF_INSERT)&&h(e),e.lockButton.innerHTML=t?"⇛⇚":"⇛ ⇚"}function s(t,r,i){for(var o=0;o<r.length;++o){var n=r[o];n instanceof e.TextMarker?n.clear():n.parent&&(t.removeLineClass(n,"background",i.chunk),t.removeLineClass(n,"background",i.start),t.removeLineClass(n,"background",i.end))}r.length=0}function c(e,t,r,i,o){var n=e.getViewport();e.operation(function(){r.from==r.to||n.from-r.to>20||r.from-n.to>20?(s(e,r.marked,o),f(e,t,i,r.marked,n.from,n.to,o),r.from=n.from,r.to=n.to):(n.from<r.from&&(f(e,t,i,r.marked,n.from,r.from,o),r.from=n.from),n.to>r.to&&(f(e,t,i,r.marked,r.to,n.to,o),r.to=n.to))})}function f(e,t,r,i,o,n,l){function a(t,r){for(var a=Math.max(o,t),s=Math.min(n,r),c=a;s>c;++c){var f=e.addLineClass(c,"background",l.chunk);c==t&&e.addLineClass(f,"background",l.start),c==r-1&&e.addLineClass(f,"background",l.end),i.push(f)}t==r&&a==r&&s==r&&(a?i.push(e.addLineClass(a-1,"background",l.end)):i.push(e.addLineClass(a,"background",l.start)))}for(var s=U(0,0),c=U(o,0),f=e.clipPos(U(n-1)),h=r==DIFF_DELETE?l.del:l.insert,d=0,u=0;u<t.length;++u){var g=t[u],v=g[0],m=g[1];if(v==DIFF_EQUAL){var p=s.line+(D(t,u)?0:1);x(s,m);var k=s.line+(y(t,u)?1:0);k>p&&(u&&a(d,p),d=k)}else if(v==r){var C=x(s,m,!0),T=B(c,s),F=_(f,C);R(T,F)||i.push(e.markText(T,F,{className:h})),s=C}}d<=s.line&&a(d,s.line+1)}function h(e){if(e.showDifferences){if(e.svg){O(e.svg);var t=e.gap.offsetWidth;N(e.svg,"width",t,"height",e.gap.offsetHeight)}e.copyButtons&&O(e.copyButtons);for(var r=e.edit.getViewport(),i=e.orig.getViewport(),o=e.edit.getScrollInfo().top,n=e.orig.getScrollInfo().top,l=0;l<e.chunks.length;l++){var a=e.chunks[l];a.editFrom<=r.to&&a.editTo>=r.from&&a.origFrom<=i.to&&a.origTo>=i.from&&p(e,a,n,o,t)}}}function d(e,t){for(var r=0,i=0,o=0;o<t.length;o++){var n=t[o];if(n.editTo>e&&n.editFrom<=e)return null;if(n.editFrom>e)break;r=n.editTo,i=n.origTo}return i+(e-r)}function u(e,t){for(var r=[],i=0;i<e.chunks.length;i++){var o=e.chunks[i];r.push([o.origTo,o.editTo,t?d(o.editTo,t.chunks):null])}if(t)for(var i=0;i<t.chunks.length;i++){for(var o=t.chunks[i],n=0;n<r.length;n++){var l=r[n];if(l[1]==o.editTo){n=-1;break}if(l[1]>o.editTo)break}n>-1&&r.splice(n-1,0,[d(o.editTo,e.chunks),o.editTo,o.origTo])}return r}function g(e,t){if(e.dealigned||t){if(!e.orig.curOp)return e.orig.operation(function(){g(e,t)});e.dealigned=!1;var i=e.mv.left==e?e.mv.right:e.mv.left;i&&(r(i),i.dealigned=!1);for(var o=u(e,i),n=e.mv.aligners,l=0;l<n.length;l++)n[l].clear();n.length=0;var a=[e.orig,e.edit],s=[];i&&a.push(i.orig);for(var l=0;l<a.length;l++)s.push(a[l].getScrollInfo().top);for(var c=0;c<o.length;c++)v(a,o[c],n);for(var l=0;l<a.length;l++)a[l].scrollTo(null,s[l])}}function v(e,t,r){for(var i=0,o=[],n=0;n<e.length;n++)if(null!=t[n]){var l=e[n].heightAtLine(t[n],"local");o[n]=l,i=Math.max(i,l)}for(var n=0;n<e.length;n++)if(null!=t[n]){var a=i-o[n];a>1&&r.push(m(e[n],t[n],a))}}function m(e,t,r){var i=!0;t>e.lastLine()&&(t--,i=!1);var o=document.createElement("div");return o.className="CodeMirror-merge-spacer",o.style.height=r+"px",o.style.minWidth="1px",e.addLineWidget(t,o,{height:r,above:i})}function p(e,t,r,i,o){var n="left"==e.type,l=e.orig.heightAtLine(t.origFrom,"local")-r;if(e.svg){var a=l,s=e.edit.heightAtLine(t.editFrom,"local")-i;if(n){var c=a;a=s,s=c}var f=e.orig.heightAtLine(t.origTo,"local")-r,h=e.edit.heightAtLine(t.editTo,"local")-i;if(n){var c=f;f=h,h=c}var d=" C "+o/2+" "+s+" "+o/2+" "+a+" "+(o+2)+" "+a,u=" C "+o/2+" "+f+" "+o/2+" "+h+" -1 "+h;N(e.svg.appendChild(document.createElementNS(W,"path")),"d","M -1 "+s+d+" L "+(o+2)+" "+f+u+" z","class",e.classes.connect)}if(e.copyButtons){var g=e.copyButtons.appendChild(S("div","left"==e.type?"⇝":"⇜","CodeMirror-merge-copy")),v=e.mv.options.allowEditingOriginals;if(g.title=v?"Push to left":"Revert chunk",g.chunk=t,g.style.top=l+"px",v){var m=e.orig.heightAtLine(t.editFrom,"local")-i,p=e.copyButtons.appendChild(S("div","right"==e.type?"⇝":"⇜","CodeMirror-merge-copy-reverse"));p.title="Push to right",p.chunk={editFrom:t.origFrom,editTo:t.origTo,origFrom:t.editFrom,origTo:t.editTo},p.style.top=m+"px","right"==e.type?p.style.left="2px":p.style.right="2px"}}}function k(e,t,r,i){e.diffOutOfDate||t.replaceRange(r.getRange(U(i.origFrom,0),U(i.origTo,0)),U(i.editFrom,0),U(i.editTo,0))}function C(t){var r=t.lockButton=S("div",null,"CodeMirror-merge-scrolllock");r.title="Toggle locked scrolling";var i=S("div",[r],"CodeMirror-merge-scrolllock-wrap");e.on(r,"click",function(){a(t,!t.lockScroll)});var o=[i];if(t.mv.options.revertButtons!==!1&&(t.copyButtons=S("div",null,"CodeMirror-merge-copybuttons-"+t.type),e.on(t.copyButtons,"click",function(e){var r=e.target||e.srcElement;if(r.chunk)return"CodeMirror-merge-copy-reverse"==r.className?void k(t,t.orig,t.edit,r.chunk):void k(t,t.edit,t.orig,r.chunk)}),o.unshift(t.copyButtons)),"align"!=t.mv.options.connect){var n=document.createElementNS&&document.createElementNS(W,"svg");n&&!n.createSVGRect&&(n=null),t.svg=n,n&&o.push(n)}return t.gap=S("div",o,"CodeMirror-merge-gap")}function T(e){return"string"==typeof e?e:e.getValue()}function F(e,t){var r=Q.diff_main(e,t);Q.diff_cleanupSemantic(r);for(var i=0;i<r.length;++i){var o=r[i];o[1]?i&&r[i-1][0]==o[0]&&(r.splice(i--,1),r[i][1]+=o[1]):r.splice(i--,1)}return r}function w(e){for(var t=[],r=0,i=0,o=U(0,0),n=U(0,0),l=0;l<e.length;++l){var a=e[l],s=a[0];if(s==DIFF_EQUAL){var c=D(e,l)?0:1,f=o.line+c,h=n.line+c;x(o,a[1],null,n);var d=y(e,l)?1:0,u=o.line+d,g=n.line+d;u>f&&(l&&t.push({origFrom:i,origTo:h,editFrom:r,editTo:f}),r=u,i=g)}else x(s==DIFF_INSERT?o:n,a[1])}return(r<=o.line||i<=n.line)&&t.push({origFrom:i,origTo:n.line+1,editFrom:r,editTo:o.line+1}),t}function y(e,t){if(t==e.length-1)return!0;var r=e[t+1][1];return 1==r.length||10!=r.charCodeAt(0)?!1:t==e.length-2?!0:(r=e[t+2][1],r.length>1&&10==r.charCodeAt(0))}function D(e,t){if(0==t)return!0;var r=e[t-1][1];return 10!=r.charCodeAt(r.length-1)?!1:1==t?!0:(r=e[t-2][1],10==r.charCodeAt(r.length-1))}function M(e,t,r){for(var i,o,n,l,a=0;a<e.length;a++){var s=e[a],c=r?s.editFrom:s.origFrom,f=r?s.editTo:s.origTo;null==o&&(c>t?(o=s.editFrom,l=s.origFrom):f>t&&(o=s.editTo,l=s.origTo)),t>=f?(i=s.editTo,n=s.origTo):t>=c&&(i=s.editFrom,n=s.origFrom)}return{edit:{before:i,after:o},orig:{before:n,after:l}}}function L(t,r,i){function o(){l.clear(),t.removeLineClass(r,"wrap","CodeMirror-merge-collapsed-line")}t.addLineClass(r,"wrap","CodeMirror-merge-collapsed-line");var n=document.createElement("span");n.className="CodeMirror-merge-collapsed-widget",n.title="Identical text collapsed. Click to expand.";var l=t.markText(U(r,0),U(i-1),{inclusiveLeft:!0,inclusiveRight:!0,replacedWith:n,clearOnEnter:!0});return e.on(n,"click",o),{mark:l,clear:o}}function I(e,t){function r(){for(var e=0;e<i.length;e++)i[e].clear()}for(var i=[],o=0;o<t.length;o++){var n=t[o],l=L(n.cm,n.line,n.line+e);i.push(l),l.mark.on("clear",r)}return i[0].mark}function b(e,t,r,i){for(var o=0;o<e.chunks.length;o++)for(var n=e.chunks[o],l=n.editFrom-t;l<n.editTo+t;l++){var a=l+r;a>=0&&a<i.length&&(i[a]=!1)}}function E(e,t){"number"!=typeof t&&(t=2);for(var r=[],i=e.editor(),o=i.firstLine(),n=o,l=i.lastLine();l>=n;n++)r.push(!0);e.left&&b(e.left,t,o,r),e.right&&b(e.right,t,o,r);for(var a=0;a<r.length;a++)if(r[a]){for(var s=a+o,c=1;a<r.length-1&&r[a+1];a++,c++);if(c>t){var f=[{line:s,cm:i}];e.left&&f.push({line:d(s,e.left.chunks),cm:e.left.orig}),e.right&&f.push({line:d(s,e.right.chunks),cm:e.right.orig});var h=I(c,f);e.options.onCollapse&&e.options.onCollapse(e,s,c,h)}}}function S(e,t,r,i){var o=document.createElement(e);if(r&&(o.className=r),i&&(o.style.cssText=i),"string"==typeof t)o.appendChild(document.createTextNode(t));else if(t)for(var n=0;n<t.length;++n)o.appendChild(t[n]);return o}function O(e){for(var t=e.childNodes.length;t>0;--t)e.removeChild(e.firstChild)}function N(e){for(var t=1;t<arguments.length;t+=2)e.setAttribute(arguments[t],arguments[t+1])}function A(e,t){t||(t={});for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r]);return t}function x(e,t,r,i){for(var o=r?U(e.line,e.ch):e,n=0;;){var l=t.indexOf("\n",n);if(-1==l)break;++o.line,i&&++i.line,n=l+1}return o.ch=(n?0:o.ch)+(t.length-n),i&&(i.ch=(n?0:i.ch)+(t.length-n)),o}function _(e,t){return(e.line-t.line||e.ch-t.ch)<0?e:t}function B(e,t){return(e.line-t.line||e.ch-t.ch)>0?e:t}function R(e,t){return e.line==t.line&&e.ch==t.ch}function V(e,t,r){for(var i=e.length-1;i>=0;i--){var o=e[i],n=(r?o.origTo:o.editTo)-1;if(t>n)return n}}function H(e,t,r){for(var i=0;i<e.length;i++){var o=e[i],n=r?o.origFrom:o.editFrom;if(n>t)return n}}function P(t,i){var o=null,n=t.state.diffViews,l=t.getCursor().line;if(n)for(var a=0;a<n.length;a++){var s=n[a],c=t==s.orig;r(s);var f=0>i?V(s.chunks,l,c):H(s.chunks,l,c);null==f||null!=o&&!(0>i?f>o:o>f)||(o=f)}return null==o?e.Pass:void t.setCursor(o,0)}var U=e.Pos,W="http://www.w3.org/2000/svg";t.prototype={constructor:t,init:function(t,r,n){this.edit=this.mv.edit,(this.edit.state.diffViews||(this.edit.state.diffViews=[])).push(this),this.orig=e(t,A({value:r,readOnly:!this.mv.options.allowEditingOriginals},A(n))),this.orig.state.diffViews=[this],this.diff=F(T(r),T(n.value)),this.chunks=w(this.diff),this.diffOutOfDate=this.dealigned=!1,this.showDifferences=n.showDifferences!==!1,this.forceUpdate=i(this),a(this,!0,!1),o(this)},setShowDifferences:function(e){e=e!==!1,e!=this.showDifferences&&(this.showDifferences=e,this.forceUpdate("full"))}};var z=!1,j=e.MergeView=function(r,i){if(!(this instanceof j))return new j(r,i);this.options=i;var o=i.origLeft,n=null==i.origRight?i.orig:i.origRight,l=null!=o,a=null!=n,s=1+(l?1:0)+(a?1:0),c=[],f=this.left=null,d=this.right=null,u=this;if(l){f=this.left=new t(this,"left");var v=S("div",null,"CodeMirror-merge-pane");c.push(v),c.push(C(f))}var m=S("div",null,"CodeMirror-merge-pane");if(c.push(m),a){d=this.right=new t(this,"right"),c.push(C(d));var p=S("div",null,"CodeMirror-merge-pane");c.push(p)}(a?p:m).className+=" CodeMirror-merge-pane-rightmost",c.push(S("div",null,null,"height: 0; clear: both;"));var k=this.wrap=r.appendChild(S("div",c,"CodeMirror-merge CodeMirror-merge-"+s+"pane"));this.edit=e(m,A(i)),f&&f.init(v,o,i),d&&d.init(p,n,i),i.collapseIdentical&&this.editor().operation(function(){E(u,i.collapseIdentical)}),"align"==i.connect&&(this.aligners=[],g(this.left||this.right,!0));var T=function(){f&&h(f),d&&h(d)};e.on(window,"resize",T);var F=setInterval(function(){for(var t=k.parentNode;t&&t!=document.body;t=t.parentNode);t||(clearInterval(F),e.off(window,"resize",T))},5e3)};j.prototype={constuctor:j,editor:function(){return this.edit},rightOriginal:function(){return this.right&&this.right.orig},leftOriginal:function(){return this.left&&this.left.orig},setShowDifferences:function(e){this.right&&this.right.setShowDifferences(e),this.left&&this.left.setShowDifferences(e)},rightChunks:function(){return this.right?(r(this.right),this.right.chunks):void 0},leftChunks:function(){return this.left?(r(this.left),this.left.chunks):void 0}};var Q=new diff_match_patch;e.commands.goNextDiff=function(e){return P(e,1)},e.commands.goPrevDiff=function(e){return P(e,-1)}});
|
lib/codemirror/lib/codemirror.css
CHANGED
@@ -41,19 +41,21 @@
|
|
41 |
|
42 |
/* CURSOR */
|
43 |
|
44 |
-
.CodeMirror
|
45 |
border-left: 1px solid black;
|
|
|
|
|
46 |
}
|
47 |
/* Shown when moving in bi-directional text */
|
48 |
.CodeMirror div.CodeMirror-secondarycursor {
|
49 |
border-left: 1px solid silver;
|
50 |
}
|
51 |
-
.
|
52 |
width: auto;
|
53 |
border: 0;
|
54 |
background: #7e7;
|
55 |
}
|
56 |
-
.
|
57 |
z-index: 1;
|
58 |
}
|
59 |
|
@@ -63,25 +65,26 @@
|
|
63 |
-webkit-animation: blink 1.06s steps(1) infinite;
|
64 |
-moz-animation: blink 1.06s steps(1) infinite;
|
65 |
animation: blink 1.06s steps(1) infinite;
|
|
|
66 |
}
|
67 |
@-moz-keyframes blink {
|
68 |
-
0% {
|
69 |
-
50% { background:
|
70 |
-
100% {
|
71 |
}
|
72 |
@-webkit-keyframes blink {
|
73 |
-
0% {
|
74 |
-
50% { background:
|
75 |
-
100% {
|
76 |
}
|
77 |
@keyframes blink {
|
78 |
-
0% {
|
79 |
-
50% { background:
|
80 |
-
100% {
|
81 |
}
|
82 |
|
83 |
/* Can style cursor different in overwrite (non-insert) mode */
|
84 |
-
|
85 |
|
86 |
.cm-tab { display: inline-block; text-decoration: inherit; }
|
87 |
|
@@ -92,6 +95,15 @@ div.CodeMirror-overwrite div.CodeMirror-cursor {}
|
|
92 |
|
93 |
/* DEFAULT THEME */
|
94 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
95 |
.cm-s-default .cm-keyword {color: #708;}
|
96 |
.cm-s-default .cm-atom {color: #219;}
|
97 |
.cm-s-default .cm-number {color: #164;}
|
@@ -111,18 +123,9 @@ div.CodeMirror-overwrite div.CodeMirror-cursor {}
|
|
111 |
.cm-s-default .cm-bracket {color: #997;}
|
112 |
.cm-s-default .cm-tag {color: #170;}
|
113 |
.cm-s-default .cm-attribute {color: #00c;}
|
114 |
-
.cm-s-default .cm-header {color: blue;}
|
115 |
-
.cm-s-default .cm-quote {color: #090;}
|
116 |
.cm-s-default .cm-hr {color: #999;}
|
117 |
.cm-s-default .cm-link {color: #00c;}
|
118 |
|
119 |
-
.cm-negative {color: #d44;}
|
120 |
-
.cm-positive {color: #292;}
|
121 |
-
.cm-header, .cm-strong {font-weight: bold;}
|
122 |
-
.cm-em {font-style: italic;}
|
123 |
-
.cm-link {text-decoration: underline;}
|
124 |
-
.cm-strikethrough {text-decoration: line-through;}
|
125 |
-
|
126 |
.cm-s-default .cm-error {color: #f00;}
|
127 |
.cm-invalidchar {color: #f00;}
|
128 |
|
@@ -162,7 +165,7 @@ div.CodeMirror span.CodeMirror-nonmatchingbracket {color: #f22;}
|
|
162 |
}
|
163 |
|
164 |
/* The fake, visible scrollbars. Used to force redraw during scrolling
|
165 |
-
before
|
166 |
flickering artifacts. */
|
167 |
.CodeMirror-vscrollbar, .CodeMirror-hscrollbar, .CodeMirror-scrollbar-filler, .CodeMirror-gutter-filler {
|
168 |
position: absolute;
|
@@ -202,7 +205,13 @@ div.CodeMirror span.CodeMirror-nonmatchingbracket {color: #f22;}
|
|
202 |
.CodeMirror-gutter-wrapper {
|
203 |
position: absolute;
|
204 |
z-index: 4;
|
205 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
206 |
}
|
207 |
.CodeMirror-gutter-elt {
|
208 |
position: absolute;
|
@@ -277,19 +286,19 @@ div.CodeMirror span.CodeMirror-nonmatchingbracket {color: #f22;}
|
|
277 |
overflow: hidden;
|
278 |
visibility: hidden;
|
279 |
}
|
280 |
-
.CodeMirror-measure pre { position: static; }
|
281 |
|
282 |
-
.CodeMirror
|
283 |
-
|
284 |
-
border-right: none;
|
285 |
-
width: 0;
|
286 |
-
}
|
287 |
|
288 |
div.CodeMirror-cursors {
|
289 |
visibility: hidden;
|
290 |
position: relative;
|
291 |
z-index: 3;
|
292 |
}
|
|
|
|
|
|
|
|
|
293 |
.CodeMirror-focused div.CodeMirror-cursors {
|
294 |
visibility: visible;
|
295 |
}
|
@@ -297,8 +306,8 @@ div.CodeMirror-cursors {
|
|
297 |
.CodeMirror-selected { background: #d9d9d9; }
|
298 |
.CodeMirror-focused .CodeMirror-selected { background: #d7d4f0; }
|
299 |
.CodeMirror-crosshair { cursor: crosshair; }
|
300 |
-
.CodeMirror ::selection { background: #d7d4f0; }
|
301 |
-
.CodeMirror ::-moz-selection { background: #d7d4f0; }
|
302 |
|
303 |
.cm-searching {
|
304 |
background: #ffa;
|
41 |
|
42 |
/* CURSOR */
|
43 |
|
44 |
+
.CodeMirror-cursor {
|
45 |
border-left: 1px solid black;
|
46 |
+
border-right: none;
|
47 |
+
width: 0;
|
48 |
}
|
49 |
/* Shown when moving in bi-directional text */
|
50 |
.CodeMirror div.CodeMirror-secondarycursor {
|
51 |
border-left: 1px solid silver;
|
52 |
}
|
53 |
+
.cm-fat-cursor .CodeMirror-cursor {
|
54 |
width: auto;
|
55 |
border: 0;
|
56 |
background: #7e7;
|
57 |
}
|
58 |
+
.cm-fat-cursor div.CodeMirror-cursors {
|
59 |
z-index: 1;
|
60 |
}
|
61 |
|
65 |
-webkit-animation: blink 1.06s steps(1) infinite;
|
66 |
-moz-animation: blink 1.06s steps(1) infinite;
|
67 |
animation: blink 1.06s steps(1) infinite;
|
68 |
+
background-color: #7e7;
|
69 |
}
|
70 |
@-moz-keyframes blink {
|
71 |
+
0% {}
|
72 |
+
50% { background-color: transparent; }
|
73 |
+
100% {}
|
74 |
}
|
75 |
@-webkit-keyframes blink {
|
76 |
+
0% {}
|
77 |
+
50% { background-color: transparent; }
|
78 |
+
100% {}
|
79 |
}
|
80 |
@keyframes blink {
|
81 |
+
0% {}
|
82 |
+
50% { background-color: transparent; }
|
83 |
+
100% {}
|
84 |
}
|
85 |
|
86 |
/* Can style cursor different in overwrite (non-insert) mode */
|
87 |
+
.CodeMirror-overwrite .CodeMirror-cursor {}
|
88 |
|
89 |
.cm-tab { display: inline-block; text-decoration: inherit; }
|
90 |
|
95 |
|
96 |
/* DEFAULT THEME */
|
97 |
|
98 |
+
.cm-s-default .cm-header {color: blue;}
|
99 |
+
.cm-s-default .cm-quote {color: #090;}
|
100 |
+
.cm-negative {color: #d44;}
|
101 |
+
.cm-positive {color: #292;}
|
102 |
+
.cm-header, .cm-strong {font-weight: bold;}
|
103 |
+
.cm-em {font-style: italic;}
|
104 |
+
.cm-link {text-decoration: underline;}
|
105 |
+
.cm-strikethrough {text-decoration: line-through;}
|
106 |
+
|
107 |
.cm-s-default .cm-keyword {color: #708;}
|
108 |
.cm-s-default .cm-atom {color: #219;}
|
109 |
.cm-s-default .cm-number {color: #164;}
|
123 |
.cm-s-default .cm-bracket {color: #997;}
|
124 |
.cm-s-default .cm-tag {color: #170;}
|
125 |
.cm-s-default .cm-attribute {color: #00c;}
|
|
|
|
|
126 |
.cm-s-default .cm-hr {color: #999;}
|
127 |
.cm-s-default .cm-link {color: #00c;}
|
128 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
129 |
.cm-s-default .cm-error {color: #f00;}
|
130 |
.cm-invalidchar {color: #f00;}
|
131 |
|
165 |
}
|
166 |
|
167 |
/* The fake, visible scrollbars. Used to force redraw during scrolling
|
168 |
+
before actual scrolling happens, thus preventing shaking and
|
169 |
flickering artifacts. */
|
170 |
.CodeMirror-vscrollbar, .CodeMirror-hscrollbar, .CodeMirror-scrollbar-filler, .CodeMirror-gutter-filler {
|
171 |
position: absolute;
|
205 |
.CodeMirror-gutter-wrapper {
|
206 |
position: absolute;
|
207 |
z-index: 4;
|
208 |
+
background: none !important;
|
209 |
+
border: none !important;
|
210 |
+
}
|
211 |
+
.CodeMirror-gutter-background {
|
212 |
+
position: absolute;
|
213 |
+
top: 0; bottom: 0;
|
214 |
+
z-index: 4;
|
215 |
}
|
216 |
.CodeMirror-gutter-elt {
|
217 |
position: absolute;
|
286 |
overflow: hidden;
|
287 |
visibility: hidden;
|
288 |
}
|
|
|
289 |
|
290 |
+
.CodeMirror-cursor { position: absolute; }
|
291 |
+
.CodeMirror-measure pre { position: static; }
|
|
|
|
|
|
|
292 |
|
293 |
div.CodeMirror-cursors {
|
294 |
visibility: hidden;
|
295 |
position: relative;
|
296 |
z-index: 3;
|
297 |
}
|
298 |
+
div.CodeMirror-dragcursors {
|
299 |
+
visibility: visible;
|
300 |
+
}
|
301 |
+
|
302 |
.CodeMirror-focused div.CodeMirror-cursors {
|
303 |
visibility: visible;
|
304 |
}
|
306 |
.CodeMirror-selected { background: #d9d9d9; }
|
307 |
.CodeMirror-focused .CodeMirror-selected { background: #d7d4f0; }
|
308 |
.CodeMirror-crosshair { cursor: crosshair; }
|
309 |
+
.CodeMirror-line::selection, .CodeMirror-line > span::selection, .CodeMirror-line > span > span::selection { background: #d7d4f0; }
|
310 |
+
.CodeMirror-line::-moz-selection, .CodeMirror-line > span::-moz-selection, .CodeMirror-line > span > span::-moz-selection { background: #d7d4f0; }
|
311 |
|
312 |
.cm-searching {
|
313 |
background: #ffa;
|
lib/codemirror/lib/codemirror.js
CHANGED
@@ -13,7 +13,7 @@
|
|
13 |
else if (typeof define == "function" && define.amd) // AMD
|
14 |
return define([], mod);
|
15 |
else // Plain browser env
|
16 |
-
this.CodeMirror = mod();
|
17 |
})(function() {
|
18 |
"use strict";
|
19 |
|
@@ -21,27 +21,29 @@
|
|
21 |
|
22 |
// Kludges for bugs and behavior differences that can't be feature
|
23 |
// detected are enabled based on userAgent etc sniffing.
|
|
|
|
|
24 |
|
25 |
-
var gecko = /gecko\/\d/i.test(
|
26 |
-
var ie_upto10 = /MSIE \d/.test(
|
27 |
-
var ie_11up = /Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(
|
28 |
var ie = ie_upto10 || ie_11up;
|
29 |
var ie_version = ie && (ie_upto10 ? document.documentMode || 6 : ie_11up[1]);
|
30 |
-
var webkit = /WebKit\//.test(
|
31 |
-
var qtwebkit = webkit && /Qt\/\d+\.\d+/.test(
|
32 |
-
var chrome = /Chrome\//.test(
|
33 |
-
var presto = /Opera\//.test(
|
34 |
var safari = /Apple Computer/.test(navigator.vendor);
|
35 |
-
var mac_geMountainLion = /Mac OS X 1\d\D([8-9]|\d\d)\D/.test(
|
36 |
-
var phantom = /PhantomJS/.test(
|
37 |
|
38 |
-
var ios = /AppleWebKit/.test(
|
39 |
// This is woefully incomplete. Suggestions for alternative methods welcome.
|
40 |
-
var mobile = ios || /Android|webOS|BlackBerry|Opera Mini|Opera Mobi|IEMobile/i.test(
|
41 |
-
var mac = ios || /Mac/.test(
|
42 |
-
var windows = /win/i.test(
|
43 |
|
44 |
-
var presto_version = presto &&
|
45 |
if (presto_version) presto_version = Number(presto_version[1]);
|
46 |
if (presto_version && presto_version >= 15) { presto = false; webkit = true; }
|
47 |
// Some browsers use the wrong event properties to signal cmd/ctrl on OS X
|
@@ -65,7 +67,7 @@
|
|
65 |
setGuttersForLineNumbers(options);
|
66 |
|
67 |
var doc = options.value;
|
68 |
-
if (typeof doc == "string") doc = new Doc(doc, options.mode);
|
69 |
this.doc = doc;
|
70 |
|
71 |
var input = new CodeMirror.inputStyles[options.inputStyle](this);
|
@@ -87,6 +89,7 @@
|
|
87 |
focused: false,
|
88 |
suppressEdits: false, // used to disable editing during key handlers when in readOnly mode
|
89 |
pasteIncoming: false, cutIncoming: false, // help recognize paste/cut edits in input.poll
|
|
|
90 |
draggingText: false,
|
91 |
highlight: new Delayed(), // stores highlight worker timeout
|
92 |
keySeq: null, // Unfinished key sequence
|
@@ -407,7 +410,7 @@
|
|
407 |
if (horiz.clientWidth) scroll(horiz.scrollLeft, "horizontal");
|
408 |
});
|
409 |
|
410 |
-
this.
|
411 |
// Need to set a minimum width to see the scrollbar on IE7 (but must not set it on IE8).
|
412 |
if (ie && ie_version < 8) this.horiz.style.minHeight = this.vert.style.minWidth = "18px";
|
413 |
}
|
@@ -442,29 +445,43 @@
|
|
442 |
this.horiz.firstChild.style.width = "0";
|
443 |
}
|
444 |
|
445 |
-
if (!this.
|
446 |
-
if (sWidth == 0) this.
|
447 |
-
this.
|
448 |
}
|
449 |
|
450 |
return {right: needsV ? sWidth : 0, bottom: needsH ? sWidth : 0};
|
451 |
},
|
452 |
setScrollLeft: function(pos) {
|
453 |
if (this.horiz.scrollLeft != pos) this.horiz.scrollLeft = pos;
|
|
|
454 |
},
|
455 |
setScrollTop: function(pos) {
|
456 |
if (this.vert.scrollTop != pos) this.vert.scrollTop = pos;
|
|
|
457 |
},
|
458 |
-
|
459 |
var w = mac && !mac_geMountainLion ? "12px" : "18px";
|
460 |
-
this.horiz.style.
|
461 |
-
|
462 |
-
|
463 |
-
|
464 |
-
|
465 |
-
|
466 |
-
|
467 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
468 |
},
|
469 |
clear: function() {
|
470 |
var parent = this.horiz.parentNode;
|
@@ -714,7 +731,7 @@
|
|
714 |
// width and height.
|
715 |
removeChildren(display.cursorDiv);
|
716 |
removeChildren(display.selectionDiv);
|
717 |
-
display.gutters.style.height = 0;
|
718 |
|
719 |
if (different) {
|
720 |
display.lastWrapHeight = update.wrapperHeight;
|
@@ -728,12 +745,9 @@
|
|
728 |
}
|
729 |
|
730 |
function postUpdateDisplay(cm, update) {
|
731 |
-
var
|
732 |
for (var first = true;; first = false) {
|
733 |
-
if (first
|
734 |
-
force = true;
|
735 |
-
} else {
|
736 |
-
force = false;
|
737 |
// Clip forced viewport to actual scrollable area.
|
738 |
if (viewport && viewport.top != null)
|
739 |
viewport = {top: Math.min(cm.doc.height + paddingVert(cm.display) - displayHeight(cm), viewport.top)};
|
@@ -809,7 +823,7 @@
|
|
809 |
// given line.
|
810 |
function updateWidgetHeight(line) {
|
811 |
if (line.widgets) for (var i = 0; i < line.widgets.length; ++i)
|
812 |
-
line.widgets[i].height = line.widgets[i].node.offsetHeight;
|
813 |
}
|
814 |
|
815 |
// Do a bulk-read of the DOM positions and sizes needed to draw the
|
@@ -958,12 +972,22 @@
|
|
958 |
lineView.node.removeChild(lineView.gutter);
|
959 |
lineView.gutter = null;
|
960 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
961 |
var markers = lineView.line.gutterMarkers;
|
962 |
if (cm.options.lineNumbers || markers) {
|
963 |
var wrap = ensureLineWrapped(lineView);
|
964 |
var gutterWrap = lineView.gutter = elt("div", null, "CodeMirror-gutter-wrapper", "left: " +
|
965 |
-
(cm.options.fixedGutter ? dims.fixedPos : -dims.gutterTotalWidth) +
|
966 |
-
"px; width: " + dims.gutterTotalWidth + "px");
|
967 |
cm.display.input.setUneditable(gutterWrap);
|
968 |
wrap.insertBefore(gutterWrap, lineView.text);
|
969 |
if (lineView.line.gutterClass)
|
@@ -1070,10 +1094,6 @@
|
|
1070 |
if (!cm.state.focused) { cm.display.input.focus(); onFocus(cm); }
|
1071 |
}
|
1072 |
|
1073 |
-
function isReadOnly(cm) {
|
1074 |
-
return cm.options.readOnly || cm.doc.cantEdit;
|
1075 |
-
}
|
1076 |
-
|
1077 |
// This will be set to an array of strings when copying, so that,
|
1078 |
// when pasting, we know what kind of selections the copied text
|
1079 |
// was made out of.
|
@@ -1084,13 +1104,19 @@
|
|
1084 |
cm.display.shift = false;
|
1085 |
if (!sel) sel = doc.sel;
|
1086 |
|
1087 |
-
var
|
|
|
1088 |
// When pasing N lines into N selections, insert one line per selection
|
1089 |
-
if (
|
1090 |
-
if (lastCopied && lastCopied.join("\n") == inserted)
|
1091 |
-
|
1092 |
-
|
|
|
|
|
|
|
|
|
1093 |
multiPaste = map(textLines, function(l) { return [l]; });
|
|
|
1094 |
}
|
1095 |
|
1096 |
// Normal behavior is to insert the new text into every selection
|
@@ -1100,40 +1126,58 @@
|
|
1100 |
if (range.empty()) {
|
1101 |
if (deleted && deleted > 0) // Handle deletion
|
1102 |
from = Pos(from.line, from.ch - deleted);
|
1103 |
-
else if (cm.state.overwrite && !
|
1104 |
to = Pos(to.line, Math.min(getLine(doc, to.line).text.length, to.ch + lst(textLines).length));
|
1105 |
}
|
1106 |
var updateInput = cm.curOp.updateInput;
|
1107 |
var changeEvent = {from: from, to: to, text: multiPaste ? multiPaste[i % multiPaste.length] : textLines,
|
1108 |
-
origin: origin || (
|
1109 |
makeChange(cm.doc, changeEvent);
|
1110 |
signalLater(cm, "inputRead", cm, changeEvent);
|
1111 |
-
// When an 'electric' character is inserted, immediately trigger a reindent
|
1112 |
-
if (inserted && !cm.state.pasteIncoming && cm.options.electricChars &&
|
1113 |
-
cm.options.smartIndent && range.head.ch < 100 &&
|
1114 |
-
(!i || sel.ranges[i - 1].head.line != range.head.line)) {
|
1115 |
-
var mode = cm.getModeAt(range.head);
|
1116 |
-
var end = changeEnd(changeEvent);
|
1117 |
-
var indented = false;
|
1118 |
-
if (mode.electricChars) {
|
1119 |
-
for (var j = 0; j < mode.electricChars.length; j++)
|
1120 |
-
if (inserted.indexOf(mode.electricChars.charAt(j)) > -1) {
|
1121 |
-
indented = indentLine(cm, end.line, "smart");
|
1122 |
-
break;
|
1123 |
-
}
|
1124 |
-
} else if (mode.electricInput) {
|
1125 |
-
if (mode.electricInput.test(getLine(doc, end.line).text.slice(0, end.ch)))
|
1126 |
-
indented = indentLine(cm, end.line, "smart");
|
1127 |
-
}
|
1128 |
-
if (indented) signalLater(cm, "electricInput", cm, end.line);
|
1129 |
-
}
|
1130 |
}
|
|
|
|
|
|
|
1131 |
ensureCursorVisible(cm);
|
1132 |
cm.curOp.updateInput = updateInput;
|
1133 |
cm.curOp.typing = true;
|
1134 |
cm.state.pasteIncoming = cm.state.cutIncoming = false;
|
1135 |
}
|
1136 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1137 |
function copyableRanges(cm) {
|
1138 |
var text = [], ranges = [];
|
1139 |
for (var i = 0; i < cm.doc.sel.ranges.length; i++) {
|
@@ -1206,21 +1250,9 @@
|
|
1206 |
input.poll();
|
1207 |
});
|
1208 |
|
1209 |
-
on(te, "paste", function() {
|
1210 |
-
|
1211 |
-
|
1212 |
-
// selection doesn't span to the end of textarea.
|
1213 |
-
if (webkit && !cm.state.fakedLastChar && !(new Date - cm.state.lastMiddleDown < 200)) {
|
1214 |
-
var start = te.selectionStart, end = te.selectionEnd;
|
1215 |
-
te.value += "$";
|
1216 |
-
// The selection end needs to be set before the start, otherwise there
|
1217 |
-
// can be an intermediate non-empty selection between the two, which
|
1218 |
-
// can override the middle-click paste buffer on linux and cause the
|
1219 |
-
// wrong thing to get pasted.
|
1220 |
-
te.selectionEnd = end;
|
1221 |
-
te.selectionStart = start;
|
1222 |
-
cm.state.fakedLastChar = true;
|
1223 |
-
}
|
1224 |
cm.state.pasteIncoming = true;
|
1225 |
input.fastPoll();
|
1226 |
});
|
@@ -1253,7 +1285,7 @@
|
|
1253 |
on(te, "copy", prepareCopyCut);
|
1254 |
|
1255 |
on(display.scroller, "paste", function(e) {
|
1256 |
-
if (eventInWidget(display, e)) return;
|
1257 |
cm.state.pasteIncoming = true;
|
1258 |
input.focus();
|
1259 |
});
|
@@ -1265,6 +1297,7 @@
|
|
1265 |
|
1266 |
on(te, "compositionstart", function() {
|
1267 |
var start = cm.getCursor("from");
|
|
|
1268 |
input.composing = {
|
1269 |
start: start,
|
1270 |
range: cm.markText(start, cm.getCursor("to"), {className: "CodeMirror-composing"})
|
@@ -1384,14 +1417,11 @@
|
|
1384 |
// possible when it is clear that nothing happened. hasSelection
|
1385 |
// will be the case when there is a lot of text in the textarea,
|
1386 |
// in which case reading its value would be expensive.
|
1387 |
-
if (!cm.state.focused ||
|
1388 |
-
|
|
|
1389 |
return false;
|
1390 |
-
|
1391 |
-
if (cm.state.pasteIncoming && cm.state.fakedLastChar) {
|
1392 |
-
input.value = input.value.substring(0, input.value.length - 1);
|
1393 |
-
cm.state.fakedLastChar = false;
|
1394 |
-
}
|
1395 |
var text = input.value;
|
1396 |
// If nothing changed, bail.
|
1397 |
if (text == prevInput && !cm.somethingSelected()) return false;
|
@@ -1516,6 +1546,10 @@
|
|
1516 |
}
|
1517 |
},
|
1518 |
|
|
|
|
|
|
|
|
|
1519 |
setUneditable: nothing,
|
1520 |
|
1521 |
needsContentAttribute: false
|
@@ -1534,16 +1568,11 @@
|
|
1534 |
init: function(display) {
|
1535 |
var input = this, cm = input.cm;
|
1536 |
var div = input.div = display.lineDiv;
|
1537 |
-
div.contentEditable = "true";
|
1538 |
disableBrowserMagic(div);
|
1539 |
|
1540 |
on(div, "paste", function(e) {
|
1541 |
-
|
1542 |
-
|
1543 |
-
e.preventDefault();
|
1544 |
-
cm.replaceSelection(pasted, null, "paste");
|
1545 |
-
}
|
1546 |
-
});
|
1547 |
|
1548 |
on(div, "compositionstart", function(e) {
|
1549 |
var data = e.data;
|
@@ -1581,7 +1610,7 @@
|
|
1581 |
|
1582 |
on(div, "input", function() {
|
1583 |
if (input.composing) return;
|
1584 |
-
if (!input.pollContent())
|
1585 |
runInOp(input.cm, function() {regChange(cm);});
|
1586 |
});
|
1587 |
|
@@ -1661,8 +1690,13 @@
|
|
1661 |
try { var rng = range(start.node, start.offset, end.offset, end.node); }
|
1662 |
catch(e) {} // Our model of the DOM might be outdated, in which case the range we try to set can be impossible
|
1663 |
if (rng) {
|
1664 |
-
|
1665 |
-
|
|
|
|
|
|
|
|
|
|
|
1666 |
if (old && sel.anchorNode == null) sel.addRange(old);
|
1667 |
else if (gecko) this.startGracePeriod();
|
1668 |
}
|
@@ -1756,13 +1790,13 @@
|
|
1756 |
var toIndex = findViewIndex(cm, to.line);
|
1757 |
if (toIndex == display.view.length - 1) {
|
1758 |
var toLine = display.viewTo - 1;
|
1759 |
-
var toNode = display.
|
1760 |
} else {
|
1761 |
var toLine = lineNo(display.view[toIndex + 1].line) - 1;
|
1762 |
var toNode = display.view[toIndex + 1].node.previousSibling;
|
1763 |
}
|
1764 |
|
1765 |
-
var newText = splitLines(domTextBetween(cm, fromNode, toNode, fromLine, toLine));
|
1766 |
var oldText = getBetween(cm.doc, Pos(fromLine, 0), Pos(toLine, getLine(cm.doc, toLine).text.length));
|
1767 |
while (newText.length > 1 && oldText.length > 1) {
|
1768 |
if (lst(newText) == lst(oldText)) { newText.pop(); oldText.pop(); toLine--; }
|
@@ -1806,17 +1840,24 @@
|
|
1806 |
this.div.focus();
|
1807 |
},
|
1808 |
applyComposition: function(composing) {
|
1809 |
-
if (
|
|
|
|
|
1810 |
operation(this.cm, applyTextInput)(this.cm, composing.data, 0, composing.sel);
|
1811 |
},
|
1812 |
|
1813 |
setUneditable: function(node) {
|
1814 |
-
node.
|
1815 |
},
|
1816 |
|
1817 |
onKeyPress: function(e) {
|
1818 |
e.preventDefault();
|
1819 |
-
|
|
|
|
|
|
|
|
|
|
|
1820 |
},
|
1821 |
|
1822 |
onContextMenu: nothing,
|
@@ -1836,7 +1877,7 @@
|
|
1836 |
var partPos = getBidiPartAt(order, pos.ch);
|
1837 |
side = partPos % 2 ? "right" : "left";
|
1838 |
}
|
1839 |
-
var result = nodeAndOffsetInLineMap(info.map, pos.ch,
|
1840 |
result.offset = result.collapse == "right" ? result.end : result.start;
|
1841 |
return result;
|
1842 |
}
|
@@ -1918,7 +1959,7 @@
|
|
1918 |
}
|
1919 |
|
1920 |
function domTextBetween(cm, from, to, fromLine, toLine) {
|
1921 |
-
var text = "", closing = false;
|
1922 |
function recognizeMarker(id) { return function(marker) { return marker.id == id; }; }
|
1923 |
function walk(node) {
|
1924 |
if (node.nodeType == 1) {
|
@@ -1932,7 +1973,7 @@
|
|
1932 |
if (markerID) {
|
1933 |
var found = cm.findMarks(Pos(fromLine, 0), Pos(toLine + 1, 0), recognizeMarker(+markerID));
|
1934 |
if (found.length && (range = found[0].find()))
|
1935 |
-
text += getBetween(cm.doc, range.from, range.to).join(
|
1936 |
return;
|
1937 |
}
|
1938 |
if (node.getAttribute("contenteditable") == "false") return;
|
@@ -1944,7 +1985,7 @@
|
|
1944 |
var val = node.nodeValue;
|
1945 |
if (!val) return;
|
1946 |
if (closing) {
|
1947 |
-
text +=
|
1948 |
closing = false;
|
1949 |
}
|
1950 |
text += val;
|
@@ -2116,7 +2157,7 @@
|
|
2116 |
|
2117 |
// Give beforeSelectionChange handlers a change to influence a
|
2118 |
// selection update.
|
2119 |
-
function filterSelectionChange(doc, sel) {
|
2120 |
var obj = {
|
2121 |
ranges: sel.ranges,
|
2122 |
update: function(ranges) {
|
@@ -2124,7 +2165,8 @@
|
|
2124 |
for (var i = 0; i < ranges.length; i++)
|
2125 |
this.ranges[i] = new Range(clipPos(doc, ranges[i].anchor),
|
2126 |
clipPos(doc, ranges[i].head));
|
2127 |
-
}
|
|
|
2128 |
};
|
2129 |
signal(doc, "beforeSelectionChange", doc, obj);
|
2130 |
if (doc.cm) signal(doc.cm, "beforeSelectionChange", doc.cm, obj);
|
@@ -2150,7 +2192,7 @@
|
|
2150 |
|
2151 |
function setSelectionNoUndo(doc, sel, options) {
|
2152 |
if (hasHandler(doc, "beforeSelectionChange") || doc.cm && hasHandler(doc.cm, "beforeSelectionChange"))
|
2153 |
-
sel = filterSelectionChange(doc, sel);
|
2154 |
|
2155 |
var bias = options && options.bias ||
|
2156 |
(cmp(sel.primary().head, doc.sel.primary().head) < 0 ? -1 : 1);
|
@@ -2184,8 +2226,9 @@
|
|
2184 |
var out;
|
2185 |
for (var i = 0; i < sel.ranges.length; i++) {
|
2186 |
var range = sel.ranges[i];
|
2187 |
-
var
|
2188 |
-
var
|
|
|
2189 |
if (out || newAnchor != range.anchor || newHead != range.head) {
|
2190 |
if (!out) out = sel.ranges.slice(0, i);
|
2191 |
out[i] = new Range(newAnchor, newHead);
|
@@ -2194,54 +2237,59 @@
|
|
2194 |
return out ? normalizeSelection(out, sel.primIndex) : sel;
|
2195 |
}
|
2196 |
|
2197 |
-
|
2198 |
-
|
2199 |
-
var
|
2200 |
-
|
2201 |
-
|
2202 |
-
|
2203 |
-
|
2204 |
-
|
2205 |
-
|
2206 |
-
|
2207 |
-
|
2208 |
-
(sp.to == null || (m.inclusiveRight ? sp.to >= curPos.ch : sp.to > curPos.ch))) {
|
2209 |
-
if (mayClear) {
|
2210 |
-
signal(m, "beforeCursorEnter");
|
2211 |
-
if (m.explicitlyCleared) {
|
2212 |
-
if (!line.markedSpans) break;
|
2213 |
-
else {--i; continue;}
|
2214 |
-
}
|
2215 |
-
}
|
2216 |
-
if (!m.atomic) continue;
|
2217 |
-
var newPos = m.find(dir < 0 ? -1 : 1);
|
2218 |
-
if (cmp(newPos, curPos) == 0) {
|
2219 |
-
newPos.ch += dir;
|
2220 |
-
if (newPos.ch < 0) {
|
2221 |
-
if (newPos.line > doc.first) newPos = clipPos(doc, Pos(newPos.line - 1));
|
2222 |
-
else newPos = null;
|
2223 |
-
} else if (newPos.ch > line.text.length) {
|
2224 |
-
if (newPos.line < doc.first + doc.size - 1) newPos = Pos(newPos.line + 1, 0);
|
2225 |
-
else newPos = null;
|
2226 |
-
}
|
2227 |
-
if (!newPos) {
|
2228 |
-
if (flipped) {
|
2229 |
-
// Driven in a corner -- no valid cursor position found at all
|
2230 |
-
// -- try again *with* clearing, if we didn't already
|
2231 |
-
if (!mayClear) return skipAtomic(doc, pos, bias, true);
|
2232 |
-
// Otherwise, turn off editing until further notice, and return the start of the doc
|
2233 |
-
doc.cantEdit = true;
|
2234 |
-
return Pos(doc.first, 0);
|
2235 |
-
}
|
2236 |
-
flipped = true; newPos = pos; dir = -dir;
|
2237 |
-
}
|
2238 |
-
}
|
2239 |
-
curPos = newPos;
|
2240 |
-
continue search;
|
2241 |
}
|
2242 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2243 |
}
|
2244 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2245 |
}
|
2246 |
}
|
2247 |
|
@@ -2261,7 +2309,7 @@
|
|
2261 |
var range = doc.sel.ranges[i];
|
2262 |
var collapsed = range.empty();
|
2263 |
if (collapsed || cm.options.showCursorWhenSelecting)
|
2264 |
-
drawSelectionCursor(cm, range, curFragment);
|
2265 |
if (!collapsed)
|
2266 |
drawSelectionRange(cm, range, selFragment);
|
2267 |
}
|
@@ -2269,8 +2317,8 @@
|
|
2269 |
}
|
2270 |
|
2271 |
// Draws a cursor for the given range
|
2272 |
-
function drawSelectionCursor(cm,
|
2273 |
-
var pos = cursorCoords(cm,
|
2274 |
|
2275 |
var cursor = output.appendChild(elt("div", "\u00a0", "CodeMirror-cursor"));
|
2276 |
cursor.style.left = pos.left + "px";
|
@@ -2394,8 +2442,8 @@
|
|
2394 |
|
2395 |
doc.iter(doc.frontier, Math.min(doc.first + doc.size, cm.display.viewTo + 500), function(line) {
|
2396 |
if (doc.frontier >= cm.display.viewFrom) { // Visible
|
2397 |
-
var oldStyles = line.styles;
|
2398 |
-
var highlighted = highlightLine(cm, line, state, true);
|
2399 |
line.styles = highlighted.styles;
|
2400 |
var oldCls = line.styleClasses, newCls = highlighted.classes;
|
2401 |
if (newCls) line.styleClasses = newCls;
|
@@ -2404,9 +2452,10 @@
|
|
2404 |
oldCls != newCls && (!oldCls || !newCls || oldCls.bgClass != newCls.bgClass || oldCls.textClass != newCls.textClass);
|
2405 |
for (var i = 0; !ischange && i < oldStyles.length; ++i) ischange = oldStyles[i] != line.styles[i];
|
2406 |
if (ischange) changedLines.push(doc.frontier);
|
2407 |
-
line.stateAfter = copyState(doc.mode, state);
|
2408 |
} else {
|
2409 |
-
|
|
|
2410 |
line.stateAfter = doc.frontier % 5 == 0 ? copyState(doc.mode, state) : null;
|
2411 |
}
|
2412 |
++doc.frontier;
|
@@ -2551,10 +2600,12 @@
|
|
2551 |
function prepareMeasureForLine(cm, line) {
|
2552 |
var lineN = lineNo(line);
|
2553 |
var view = findViewForLine(cm, lineN);
|
2554 |
-
if (view && !view.text)
|
2555 |
view = null;
|
2556 |
-
else if (view && view.changes)
|
2557 |
updateLineForChanges(cm, view, lineN, getDimensions(cm));
|
|
|
|
|
2558 |
if (!view)
|
2559 |
view = updateExternalMeasurement(cm, line);
|
2560 |
|
@@ -2967,12 +3018,12 @@
|
|
2967 |
var callbacks = group.delayedCallbacks, i = 0;
|
2968 |
do {
|
2969 |
for (; i < callbacks.length; i++)
|
2970 |
-
callbacks[i]();
|
2971 |
for (var j = 0; j < group.ops.length; j++) {
|
2972 |
var op = group.ops[j];
|
2973 |
if (op.cursorActivityHandlers)
|
2974 |
while (op.cursorActivityCalled < op.cursorActivityHandlers.length)
|
2975 |
-
op.cursorActivityHandlers[op.cursorActivityCalled++](op.cm);
|
2976 |
}
|
2977 |
} while (i < callbacks.length);
|
2978 |
}
|
@@ -3066,7 +3117,8 @@
|
|
3066 |
|
3067 |
if (cm.state.focused && op.updateInput)
|
3068 |
cm.display.input.reset(op.typing);
|
3069 |
-
if (op.focus && op.focus == activeElt()
|
|
|
3070 |
}
|
3071 |
|
3072 |
function endOperation_finish(op) {
|
@@ -3432,9 +3484,11 @@
|
|
3432 |
on(d.wrapper, "scroll", function() { d.wrapper.scrollTop = d.wrapper.scrollLeft = 0; });
|
3433 |
|
3434 |
d.dragFunctions = {
|
3435 |
-
|
|
|
3436 |
start: function(e){onDragStart(cm, e);},
|
3437 |
-
drop: operation(cm, onDrop)
|
|
|
3438 |
};
|
3439 |
|
3440 |
var inp = d.input.getField();
|
@@ -3451,8 +3505,9 @@
|
|
3451 |
var funcs = cm.display.dragFunctions;
|
3452 |
var toggle = value ? on : off;
|
3453 |
toggle(cm.display.scroller, "dragstart", funcs.start);
|
3454 |
-
toggle(cm.display.scroller, "dragenter", funcs.
|
3455 |
-
toggle(cm.display.scroller, "dragover", funcs.
|
|
|
3456 |
toggle(cm.display.scroller, "drop", funcs.drop);
|
3457 |
}
|
3458 |
}
|
@@ -3525,7 +3580,10 @@
|
|
3525 |
|
3526 |
switch (e_button(e)) {
|
3527 |
case 1:
|
3528 |
-
|
|
|
|
|
|
|
3529 |
leftButtonDown(cm, e, start);
|
3530 |
else if (e_target(e) == display.scroller)
|
3531 |
e_preventDefault(e);
|
@@ -3560,9 +3618,10 @@
|
|
3560 |
}
|
3561 |
|
3562 |
var sel = cm.doc.sel, modifier = mac ? e.metaKey : e.ctrlKey, contained;
|
3563 |
-
if (cm.options.dragDrop && dragAndDrop && !isReadOnly(
|
3564 |
type == "single" && (contained = sel.contains(start)) > -1 &&
|
3565 |
-
|
|
|
3566 |
leftButtonStartDrag(cm, e, start, modifier);
|
3567 |
else
|
3568 |
leftButtonSelect(cm, e, start, type, modifier);
|
@@ -3644,7 +3703,8 @@
|
|
3644 |
setSelection(doc, normalizeSelection(ranges.concat([ourRange]), ourIndex),
|
3645 |
{scroll: false, origin: "*mouse"});
|
3646 |
} else if (ranges.length > 1 && ranges[ourIndex].empty() && type == "single" && !e.shiftKey) {
|
3647 |
-
setSelection(doc, normalizeSelection(ranges.slice(0, ourIndex).concat(ranges.slice(ourIndex + 1)), 0)
|
|
|
3648 |
startSel = doc.sel;
|
3649 |
} else {
|
3650 |
replaceOneSelection(doc, ourIndex, ourRange, sel_mouse);
|
@@ -3722,6 +3782,7 @@
|
|
3722 |
}
|
3723 |
|
3724 |
function done(e) {
|
|
|
3725 |
counter = Infinity;
|
3726 |
e_preventDefault(e);
|
3727 |
display.input.focus();
|
@@ -3735,13 +3796,14 @@
|
|
3735 |
else extend(e);
|
3736 |
});
|
3737 |
var up = operation(cm, done);
|
|
|
3738 |
on(document, "mousemove", move);
|
3739 |
on(document, "mouseup", up);
|
3740 |
}
|
3741 |
|
3742 |
// Determines whether an event happened in the gutter, and fires the
|
3743 |
// handlers for the corresponding event.
|
3744 |
-
function gutterEvent(cm, e, type, prevent
|
3745 |
try { var mX = e.clientX, mY = e.clientY; }
|
3746 |
catch(e) { return false; }
|
3747 |
if (mX >= Math.floor(cm.display.gutters.getBoundingClientRect().right)) return false;
|
@@ -3758,14 +3820,14 @@
|
|
3758 |
if (g && g.getBoundingClientRect().right >= mX) {
|
3759 |
var line = lineAtHeight(cm.doc, mY);
|
3760 |
var gutter = cm.options.gutters[i];
|
3761 |
-
|
3762 |
return e_defaultPrevented(e);
|
3763 |
}
|
3764 |
}
|
3765 |
}
|
3766 |
|
3767 |
function clickInGutter(cm, e) {
|
3768 |
-
return gutterEvent(cm, e, "gutterClick", true
|
3769 |
}
|
3770 |
|
3771 |
// Kludge to work around strange IE behavior where it'll sometimes
|
@@ -3774,23 +3836,32 @@
|
|
3774 |
|
3775 |
function onDrop(e) {
|
3776 |
var cm = this;
|
|
|
3777 |
if (signalDOMEvent(cm, e) || eventInWidget(cm.display, e))
|
3778 |
return;
|
3779 |
e_preventDefault(e);
|
3780 |
if (ie) lastDrop = +new Date;
|
3781 |
var pos = posFromMouse(cm, e, true), files = e.dataTransfer.files;
|
3782 |
-
if (!pos || isReadOnly(
|
3783 |
// Might be a file drop, in which case we simply extract the text
|
3784 |
// and insert it.
|
3785 |
if (files && files.length && window.FileReader && window.File) {
|
3786 |
var n = files.length, text = Array(n), read = 0;
|
3787 |
var loadFile = function(file, i) {
|
|
|
|
|
|
|
|
|
3788 |
var reader = new FileReader;
|
3789 |
reader.onload = operation(cm, function() {
|
3790 |
-
|
|
|
|
|
3791 |
if (++read == n) {
|
3792 |
pos = clipPos(cm.doc, pos);
|
3793 |
-
var change = {from: pos, to: pos,
|
|
|
|
|
3794 |
makeChange(cm.doc, change);
|
3795 |
setSelectionReplaceHistory(cm.doc, simpleSelection(pos, changeEnd(change)));
|
3796 |
}
|
@@ -3844,6 +3915,25 @@
|
|
3844 |
}
|
3845 |
}
|
3846 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3847 |
// SCROLL EVENTS
|
3848 |
|
3849 |
// Sync the scrollable area and scrollbars, ensure the viewport
|
@@ -3908,8 +3998,9 @@
|
|
3908 |
|
3909 |
var display = cm.display, scroll = display.scroller;
|
3910 |
// Quit if there's nothing to scroll here
|
3911 |
-
|
3912 |
-
|
|
|
3913 |
|
3914 |
// Webkit browsers on OS X abort momentum scrolls when the target
|
3915 |
// of the scroll event is removed from the scrollable element.
|
@@ -3933,10 +4024,15 @@
|
|
3933 |
// scrolling entirely here. It'll be slightly off from native, but
|
3934 |
// better than glitching out.
|
3935 |
if (dx && !gecko && !presto && wheelPixelsPerUnit != null) {
|
3936 |
-
if (dy)
|
3937 |
setScrollTop(cm, Math.max(0, Math.min(scroll.scrollTop + dy * wheelPixelsPerUnit, scroll.scrollHeight - scroll.clientHeight)));
|
3938 |
setScrollLeft(cm, Math.max(0, Math.min(scroll.scrollLeft + dx * wheelPixelsPerUnit, scroll.scrollWidth - scroll.clientWidth)));
|
3939 |
-
|
|
|
|
|
|
|
|
|
|
|
3940 |
display.wheelStartX = null; // Abort measurement, if in progress
|
3941 |
return;
|
3942 |
}
|
@@ -3985,7 +4081,7 @@
|
|
3985 |
cm.display.input.ensurePolled();
|
3986 |
var prevShift = cm.display.shift, done = false;
|
3987 |
try {
|
3988 |
-
if (isReadOnly(
|
3989 |
if (dropShift) cm.display.shift = false;
|
3990 |
done = bound(cm) != Pass;
|
3991 |
} finally {
|
@@ -4164,12 +4260,13 @@
|
|
4164 |
// right-click take effect on it.
|
4165 |
function onContextMenu(cm, e) {
|
4166 |
if (eventInWidget(cm.display, e) || contextMenuInGutter(cm, e)) return;
|
|
|
4167 |
cm.display.input.onContextMenu(e);
|
4168 |
}
|
4169 |
|
4170 |
function contextMenuInGutter(cm, e) {
|
4171 |
if (!hasHandler(cm, "gutterContextMenu")) return false;
|
4172 |
-
return gutterEvent(cm, e, "gutterContextMenu", false
|
4173 |
}
|
4174 |
|
4175 |
// UPDATING
|
@@ -4473,7 +4570,7 @@
|
|
4473 |
function replaceRange(doc, code, from, to, origin) {
|
4474 |
if (!to) to = from;
|
4475 |
if (cmp(to, from) < 0) { var tmp = to; to = from; from = tmp; }
|
4476 |
-
if (typeof code == "string") code = splitLines(code);
|
4477 |
makeChange(doc, {from: from, to: to, text: code, origin: origin});
|
4478 |
}
|
4479 |
|
@@ -4757,7 +4854,7 @@
|
|
4757 |
if (dir > 0 && !moveOnce(!first)) break;
|
4758 |
}
|
4759 |
}
|
4760 |
-
var result = skipAtomic(doc, Pos(line, ch), origDir, true);
|
4761 |
if (!possible) result.hitSide = true;
|
4762 |
return result;
|
4763 |
}
|
@@ -5050,9 +5147,11 @@
|
|
5050 |
|
5051 |
execCommand: function(cmd) {
|
5052 |
if (commands.hasOwnProperty(cmd))
|
5053 |
-
return commands[cmd](this);
|
5054 |
},
|
5055 |
|
|
|
|
|
5056 |
findPosH: function(from, amount, unit, visually) {
|
5057 |
var dir = 1;
|
5058 |
if (amount < 0) { dir = -1; amount = -amount; }
|
@@ -5143,6 +5242,7 @@
|
|
5143 |
signal(this, "overwriteToggle", this, this.state.overwrite);
|
5144 |
},
|
5145 |
hasFocus: function() { return this.display.input.getField() == activeElt(); },
|
|
|
5146 |
|
5147 |
scrollTo: methodOp(function(x, y) {
|
5148 |
if (x != null || y != null) resolveScrollToPos(this);
|
@@ -5266,6 +5366,22 @@
|
|
5266 |
clearCaches(cm);
|
5267 |
regChange(cm);
|
5268 |
}, true);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5269 |
option("specialChars", /[\t\u0000-\u0019\u00ad\u200b-\u200f\u2028\u2029\ufeff]/g, function(cm, val, old) {
|
5270 |
cm.state.specialChars = new RegExp(val.source + (val.test("\t") ? "" : "|\t"), "g");
|
5271 |
if (old != CodeMirror.Init) cm.refresh();
|
@@ -5324,11 +5440,12 @@
|
|
5324 |
cm.display.disabled = true;
|
5325 |
} else {
|
5326 |
cm.display.disabled = false;
|
5327 |
-
if (!val) cm.display.input.reset();
|
5328 |
}
|
|
|
5329 |
});
|
5330 |
option("disableInput", false, function(cm, val) {if (!val) cm.display.input.reset();}, true);
|
5331 |
option("dragDrop", true, dragDropChanged);
|
|
|
5332 |
|
5333 |
option("cursorBlinkRate", 530);
|
5334 |
option("cursorScrollMargin", 0);
|
@@ -5616,7 +5733,8 @@
|
|
5616 |
} else if (cur.line > cm.doc.first) {
|
5617 |
var prev = getLine(cm.doc, cur.line - 1).text;
|
5618 |
if (prev)
|
5619 |
-
cm.replaceRange(line.charAt(0) +
|
|
|
5620 |
Pos(cur.line - 1, prev.length - 1), Pos(cur.line, 1), "+transpose");
|
5621 |
}
|
5622 |
}
|
@@ -5630,10 +5748,10 @@
|
|
5630 |
var len = cm.listSelections().length;
|
5631 |
for (var i = 0; i < len; i++) {
|
5632 |
var range = cm.listSelections()[i];
|
5633 |
-
cm.replaceRange(
|
5634 |
cm.indentLine(range.from().line + 1, null, true);
|
5635 |
-
ensureCursorVisible(cm);
|
5636 |
}
|
|
|
5637 |
});
|
5638 |
},
|
5639 |
toggleOverwrite: function(cm) {cm.toggleOverwrite();}
|
@@ -5720,7 +5838,7 @@
|
|
5720 |
for (var i = 0; i < keys.length; i++) {
|
5721 |
var val, name;
|
5722 |
if (i == keys.length - 1) {
|
5723 |
-
name =
|
5724 |
val = value;
|
5725 |
} else {
|
5726 |
name = keys.slice(0, i + 1).join(" ");
|
@@ -6561,7 +6679,7 @@
|
|
6561 |
parentStyle += "width: " + cm.display.wrapper.clientWidth + "px;";
|
6562 |
removeChildrenAndAdd(cm.display.measure, elt("div", [widget.node], null, parentStyle));
|
6563 |
}
|
6564 |
-
return widget.height = widget.node.offsetHeight;
|
6565 |
}
|
6566 |
|
6567 |
function addLineWidget(doc, handle, node, options) {
|
@@ -6750,7 +6868,9 @@
|
|
6750 |
|
6751 |
function getLineStyles(cm, line, updateFrontier) {
|
6752 |
if (!line.styles || line.styles[0] != cm.state.modeGen) {
|
6753 |
-
var
|
|
|
|
|
6754 |
line.styles = result.styles;
|
6755 |
if (result.classes) line.styleClasses = result.classes;
|
6756 |
else if (line.styleClasses) line.styleClasses = null;
|
@@ -6767,7 +6887,7 @@
|
|
6767 |
var stream = new StringStream(text, cm.options.tabSize);
|
6768 |
stream.start = stream.pos = startAt || 0;
|
6769 |
if (text == "") callBlankLine(mode, state);
|
6770 |
-
while (!stream.eol()
|
6771 |
readToken(mode, stream, state);
|
6772 |
stream.start = stream.pos;
|
6773 |
}
|
@@ -6794,7 +6914,7 @@
|
|
6794 |
// is needed on Webkit to be able to get line-level bounding
|
6795 |
// rectangles for it (in measureChar).
|
6796 |
var content = elt("span", null, null, webkit ? "padding-right: .1px" : null);
|
6797 |
-
var builder = {pre: elt("pre", [content]), content: content,
|
6798 |
col: 0, pos: 0, cm: cm,
|
6799 |
splitSpaces: (ie || webkit) && cm.getOption("lineWrapping")};
|
6800 |
lineView.measure = {};
|
@@ -6884,6 +7004,10 @@
|
|
6884 |
txt.setAttribute("role", "presentation");
|
6885 |
txt.setAttribute("cm-text", "\t");
|
6886 |
builder.col += tabWidth;
|
|
|
|
|
|
|
|
|
6887 |
} else {
|
6888 |
var txt = builder.cm.options.specialCharPlaceholder(m[0]);
|
6889 |
txt.setAttribute("cm-text", m[0]);
|
@@ -6965,7 +7089,7 @@
|
|
6965 |
if (nextChange == pos) { // Update current marker set
|
6966 |
spanStyle = spanEndStyle = spanStartStyle = title = css = "";
|
6967 |
collapsed = null; nextChange = Infinity;
|
6968 |
-
var foundBookmarks = []
|
6969 |
for (var j = 0; j < spans.length; ++j) {
|
6970 |
var sp = spans[j], m = sp.marker;
|
6971 |
if (m.type == "bookmark" && sp.from == pos && m.widgetNode) {
|
@@ -6976,9 +7100,9 @@
|
|
6976 |
spanEndStyle = "";
|
6977 |
}
|
6978 |
if (m.className) spanStyle += " " + m.className;
|
6979 |
-
if (m.css) css = m.css;
|
6980 |
if (m.startStyle && sp.from == pos) spanStartStyle += " " + m.startStyle;
|
6981 |
-
if (m.endStyle && sp.to == nextChange)
|
6982 |
if (m.title && !title) title = m.title;
|
6983 |
if (m.collapsed && (!collapsed || compareCollapsedMarkers(collapsed.marker, m) < 0))
|
6984 |
collapsed = sp;
|
@@ -6986,6 +7110,9 @@
|
|
6986 |
nextChange = sp.from;
|
6987 |
}
|
6988 |
}
|
|
|
|
|
|
|
6989 |
if (collapsed && (collapsed.from || 0) == pos) {
|
6990 |
buildCollapsedSpan(builder, (collapsed.to == null ? len + 1 : collapsed.to) - pos,
|
6991 |
collapsed.marker, collapsed.from == null);
|
@@ -7229,8 +7356,8 @@
|
|
7229 |
};
|
7230 |
|
7231 |
var nextDocId = 0;
|
7232 |
-
var Doc = CodeMirror.Doc = function(text, mode, firstLine) {
|
7233 |
-
if (!(this instanceof Doc)) return new Doc(text, mode, firstLine);
|
7234 |
if (firstLine == null) firstLine = 0;
|
7235 |
|
7236 |
BranchChunk.call(this, [new LeafChunk([new Line("", null)])]);
|
@@ -7244,8 +7371,10 @@
|
|
7244 |
this.history = new History(null);
|
7245 |
this.id = ++nextDocId;
|
7246 |
this.modeOption = mode;
|
|
|
|
|
7247 |
|
7248 |
-
if (typeof text == "string") text = splitLines(text);
|
7249 |
updateDoc(this, {from: start, to: start, text: text});
|
7250 |
setSelection(this, simpleSelection(start), sel_dontScroll);
|
7251 |
};
|
@@ -7275,12 +7404,12 @@
|
|
7275 |
getValue: function(lineSep) {
|
7276 |
var lines = getLines(this, this.first, this.first + this.size);
|
7277 |
if (lineSep === false) return lines;
|
7278 |
-
return lines.join(lineSep ||
|
7279 |
},
|
7280 |
setValue: docMethodOp(function(code) {
|
7281 |
var top = Pos(this.first, 0), last = this.first + this.size - 1;
|
7282 |
makeChange(this, {from: top, to: Pos(last, getLine(this, last).text.length),
|
7283 |
-
text: splitLines(code), origin: "setValue", full: true}, true);
|
7284 |
setSelection(this, simpleSelection(top));
|
7285 |
}),
|
7286 |
replaceRange: function(code, from, to, origin) {
|
@@ -7291,7 +7420,7 @@
|
|
7291 |
getRange: function(from, to, lineSep) {
|
7292 |
var lines = getBetween(this, clipPos(this, from), clipPos(this, to));
|
7293 |
if (lineSep === false) return lines;
|
7294 |
-
return lines.join(lineSep ||
|
7295 |
},
|
7296 |
|
7297 |
getLine: function(line) {var l = this.getLineHandle(line); return l && l.text;},
|
@@ -7331,10 +7460,11 @@
|
|
7331 |
extendSelection(this, clipPos(this, head), other && clipPos(this, other), options);
|
7332 |
}),
|
7333 |
extendSelections: docMethodOp(function(heads, options) {
|
7334 |
-
extendSelections(this, clipPosArray(this, heads, options)
|
7335 |
}),
|
7336 |
extendSelectionsBy: docMethodOp(function(f, options) {
|
7337 |
-
|
|
|
7338 |
}),
|
7339 |
setSelections: docMethodOp(function(ranges, primary, options) {
|
7340 |
if (!ranges.length) return;
|
@@ -7357,13 +7487,13 @@
|
|
7357 |
lines = lines ? lines.concat(sel) : sel;
|
7358 |
}
|
7359 |
if (lineSep === false) return lines;
|
7360 |
-
else return lines.join(lineSep ||
|
7361 |
},
|
7362 |
getSelections: function(lineSep) {
|
7363 |
var parts = [], ranges = this.sel.ranges;
|
7364 |
for (var i = 0; i < ranges.length; i++) {
|
7365 |
var sel = getBetween(this, ranges[i].from(), ranges[i].to());
|
7366 |
-
if (lineSep !== false) sel = sel.join(lineSep ||
|
7367 |
parts[i] = sel;
|
7368 |
}
|
7369 |
return parts;
|
@@ -7378,7 +7508,7 @@
|
|
7378 |
var changes = [], sel = this.sel;
|
7379 |
for (var i = 0; i < sel.ranges.length; i++) {
|
7380 |
var range = sel.ranges[i];
|
7381 |
-
changes[i] = {from: range.from(), to: range.to(), text: splitLines(code[i]), origin: origin};
|
7382 |
}
|
7383 |
var newSel = collapse && collapse != "end" && computeReplacedSel(this, changes, collapse);
|
7384 |
for (var i = changes.length - 1; i >= 0; i--)
|
@@ -7459,7 +7589,7 @@
|
|
7459 |
removeLineWidget: function(widget) { widget.clear(); },
|
7460 |
|
7461 |
markText: function(from, to, options) {
|
7462 |
-
return markText(this, clipPos(this, from), clipPos(this, to), options, "range");
|
7463 |
},
|
7464 |
setBookmark: function(pos, options) {
|
7465 |
var realOpts = {replacedWith: options && (options.nodeType == null ? options.widget : options),
|
@@ -7528,7 +7658,8 @@
|
|
7528 |
},
|
7529 |
|
7530 |
copy: function(copyHistory) {
|
7531 |
-
var doc = new Doc(getLines(this, this.first, this.first + this.size),
|
|
|
7532 |
doc.scrollTop = this.scrollTop; doc.scrollLeft = this.scrollLeft;
|
7533 |
doc.sel = this.sel;
|
7534 |
doc.extend = false;
|
@@ -7544,7 +7675,7 @@
|
|
7544 |
var from = this.first, to = this.first + this.size;
|
7545 |
if (options.from != null && options.from > from) from = options.from;
|
7546 |
if (options.to != null && options.to < to) to = options.to;
|
7547 |
-
var copy = new Doc(getLines(this, from, to), options.mode || this.modeOption, from);
|
7548 |
if (options.sharedHist) copy.history = this.history;
|
7549 |
(this.linked || (this.linked = [])).push({doc: copy, sharedHist: options.sharedHist});
|
7550 |
copy.linked = [{doc: this, isParent: true, sharedHist: options.sharedHist}];
|
@@ -7573,14 +7704,20 @@
|
|
7573 |
iterLinkedDocs: function(f) {linkedDocs(this, f);},
|
7574 |
|
7575 |
getMode: function() {return this.mode;},
|
7576 |
-
getEditor: function() {return this.cm;}
|
|
|
|
|
|
|
|
|
|
|
|
|
7577 |
});
|
7578 |
|
7579 |
// Public alias.
|
7580 |
Doc.prototype.eachLine = Doc.prototype.iter;
|
7581 |
|
7582 |
// Set up methods on CodeMirror's prototype to redirect to the editor's document.
|
7583 |
-
var dontDelegate = "iter insert remove copy getEditor".split(" ");
|
7584 |
for (var prop in Doc.prototype) if (Doc.prototype.hasOwnProperty(prop) && indexOf(dontDelegate, prop) < 0)
|
7585 |
CodeMirror.prototype[prop] = (function(method) {
|
7586 |
return function() {return method.apply(this.doc, arguments);};
|
@@ -8013,24 +8150,30 @@
|
|
8013 |
}
|
8014 |
};
|
8015 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
8016 |
var off = CodeMirror.off = function(emitter, type, f) {
|
8017 |
if (emitter.removeEventListener)
|
8018 |
emitter.removeEventListener(type, f, false);
|
8019 |
else if (emitter.detachEvent)
|
8020 |
emitter.detachEvent("on" + type, f);
|
8021 |
else {
|
8022 |
-
var
|
8023 |
-
|
8024 |
-
|
8025 |
-
if (arr[i] == f) { arr.splice(i, 1); break; }
|
8026 |
}
|
8027 |
};
|
8028 |
|
8029 |
var signal = CodeMirror.signal = function(emitter, type /*, values...*/) {
|
8030 |
-
var
|
8031 |
-
if (!
|
8032 |
var args = Array.prototype.slice.call(arguments, 2);
|
8033 |
-
for (var i = 0; i <
|
8034 |
};
|
8035 |
|
8036 |
var orphanDelayedCallbacks = null;
|
@@ -8043,8 +8186,8 @@
|
|
8043 |
// them to be executed when the last operation ends, or, if no
|
8044 |
// operation is active, when a timeout fires.
|
8045 |
function signalLater(emitter, type /*, values...*/) {
|
8046 |
-
var arr = emitter
|
8047 |
-
if (!arr) return;
|
8048 |
var args = Array.prototype.slice.call(arguments, 2), list;
|
8049 |
if (operationGroup) {
|
8050 |
list = operationGroup.delayedCallbacks;
|
@@ -8084,8 +8227,7 @@
|
|
8084 |
}
|
8085 |
|
8086 |
function hasHandler(emitter, type) {
|
8087 |
-
|
8088 |
-
return arr && arr.length > 0;
|
8089 |
}
|
8090 |
|
8091 |
// Add on and off methods to a constructor's prototype, to make
|
@@ -8132,7 +8274,7 @@
|
|
8132 |
|
8133 |
// The inverse of countColumn -- find the offset that corresponds to
|
8134 |
// a particular column.
|
8135 |
-
|
8136 |
for (var pos = 0, col = 0;;) {
|
8137 |
var nextTab = string.indexOf("\t", pos);
|
8138 |
if (nextTab == -1) nextTab = string.length;
|
@@ -8272,7 +8414,12 @@
|
|
8272 |
} while (child = child.parentNode);
|
8273 |
};
|
8274 |
|
8275 |
-
function activeElt() {
|
|
|
|
|
|
|
|
|
|
|
8276 |
// Older versions of IE throws unspecified error when touching
|
8277 |
// document.activeElement in some cases (during loading, in iframe)
|
8278 |
if (ie && ie_version < 11) activeElt = function() {
|
@@ -8374,7 +8521,7 @@
|
|
8374 |
|
8375 |
// See if "".split is the broken IE version, if so, provide an
|
8376 |
// alternative way to split lines.
|
8377 |
-
var
|
8378 |
var pos = 0, result = [], l = string.length;
|
8379 |
while (pos <= l) {
|
8380 |
var nl = string.indexOf("\n", pos);
|
@@ -8420,14 +8567,16 @@
|
|
8420 |
|
8421 |
// KEY NAMES
|
8422 |
|
8423 |
-
var keyNames =
|
8424 |
-
|
8425 |
-
|
8426 |
-
|
8427 |
-
|
8428 |
-
|
8429 |
-
|
8430 |
-
|
|
|
|
|
8431 |
(function() {
|
8432 |
// Number keys
|
8433 |
for (var i = 0; i < 10; i++) keyNames[i + 48] = keyNames[i + 96] = String(i);
|
@@ -8732,7 +8881,7 @@
|
|
8732 |
|
8733 |
// THE END
|
8734 |
|
8735 |
-
CodeMirror.version = "5.
|
8736 |
|
8737 |
return CodeMirror;
|
8738 |
});
|
13 |
else if (typeof define == "function" && define.amd) // AMD
|
14 |
return define([], mod);
|
15 |
else // Plain browser env
|
16 |
+
(this || window).CodeMirror = mod();
|
17 |
})(function() {
|
18 |
"use strict";
|
19 |
|
21 |
|
22 |
// Kludges for bugs and behavior differences that can't be feature
|
23 |
// detected are enabled based on userAgent etc sniffing.
|
24 |
+
var userAgent = navigator.userAgent;
|
25 |
+
var platform = navigator.platform;
|
26 |
|
27 |
+
var gecko = /gecko\/\d/i.test(userAgent);
|
28 |
+
var ie_upto10 = /MSIE \d/.test(userAgent);
|
29 |
+
var ie_11up = /Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(userAgent);
|
30 |
var ie = ie_upto10 || ie_11up;
|
31 |
var ie_version = ie && (ie_upto10 ? document.documentMode || 6 : ie_11up[1]);
|
32 |
+
var webkit = /WebKit\//.test(userAgent);
|
33 |
+
var qtwebkit = webkit && /Qt\/\d+\.\d+/.test(userAgent);
|
34 |
+
var chrome = /Chrome\//.test(userAgent);
|
35 |
+
var presto = /Opera\//.test(userAgent);
|
36 |
var safari = /Apple Computer/.test(navigator.vendor);
|
37 |
+
var mac_geMountainLion = /Mac OS X 1\d\D([8-9]|\d\d)\D/.test(userAgent);
|
38 |
+
var phantom = /PhantomJS/.test(userAgent);
|
39 |
|
40 |
+
var ios = /AppleWebKit/.test(userAgent) && /Mobile\/\w+/.test(userAgent);
|
41 |
// This is woefully incomplete. Suggestions for alternative methods welcome.
|
42 |
+
var mobile = ios || /Android|webOS|BlackBerry|Opera Mini|Opera Mobi|IEMobile/i.test(userAgent);
|
43 |
+
var mac = ios || /Mac/.test(platform);
|
44 |
+
var windows = /win/i.test(platform);
|
45 |
|
46 |
+
var presto_version = presto && userAgent.match(/Version\/(\d*\.\d*)/);
|
47 |
if (presto_version) presto_version = Number(presto_version[1]);
|
48 |
if (presto_version && presto_version >= 15) { presto = false; webkit = true; }
|
49 |
// Some browsers use the wrong event properties to signal cmd/ctrl on OS X
|
67 |
setGuttersForLineNumbers(options);
|
68 |
|
69 |
var doc = options.value;
|
70 |
+
if (typeof doc == "string") doc = new Doc(doc, options.mode, null, options.lineSeparator);
|
71 |
this.doc = doc;
|
72 |
|
73 |
var input = new CodeMirror.inputStyles[options.inputStyle](this);
|
89 |
focused: false,
|
90 |
suppressEdits: false, // used to disable editing during key handlers when in readOnly mode
|
91 |
pasteIncoming: false, cutIncoming: false, // help recognize paste/cut edits in input.poll
|
92 |
+
selectingText: false,
|
93 |
draggingText: false,
|
94 |
highlight: new Delayed(), // stores highlight worker timeout
|
95 |
keySeq: null, // Unfinished key sequence
|
410 |
if (horiz.clientWidth) scroll(horiz.scrollLeft, "horizontal");
|
411 |
});
|
412 |
|
413 |
+
this.checkedZeroWidth = false;
|
414 |
// Need to set a minimum width to see the scrollbar on IE7 (but must not set it on IE8).
|
415 |
if (ie && ie_version < 8) this.horiz.style.minHeight = this.vert.style.minWidth = "18px";
|
416 |
}
|
445 |
this.horiz.firstChild.style.width = "0";
|
446 |
}
|
447 |
|
448 |
+
if (!this.checkedZeroWidth && measure.clientHeight > 0) {
|
449 |
+
if (sWidth == 0) this.zeroWidthHack();
|
450 |
+
this.checkedZeroWidth = true;
|
451 |
}
|
452 |
|
453 |
return {right: needsV ? sWidth : 0, bottom: needsH ? sWidth : 0};
|
454 |
},
|
455 |
setScrollLeft: function(pos) {
|
456 |
if (this.horiz.scrollLeft != pos) this.horiz.scrollLeft = pos;
|
457 |
+
if (this.disableHoriz) this.enableZeroWidthBar(this.horiz, this.disableHoriz);
|
458 |
},
|
459 |
setScrollTop: function(pos) {
|
460 |
if (this.vert.scrollTop != pos) this.vert.scrollTop = pos;
|
461 |
+
if (this.disableVert) this.enableZeroWidthBar(this.vert, this.disableVert);
|
462 |
},
|
463 |
+
zeroWidthHack: function() {
|
464 |
var w = mac && !mac_geMountainLion ? "12px" : "18px";
|
465 |
+
this.horiz.style.height = this.vert.style.width = w;
|
466 |
+
this.horiz.style.pointerEvents = this.vert.style.pointerEvents = "none";
|
467 |
+
this.disableHoriz = new Delayed;
|
468 |
+
this.disableVert = new Delayed;
|
469 |
+
},
|
470 |
+
enableZeroWidthBar: function(bar, delay) {
|
471 |
+
bar.style.pointerEvents = "auto";
|
472 |
+
function maybeDisable() {
|
473 |
+
// To find out whether the scrollbar is still visible, we
|
474 |
+
// check whether the element under the pixel in the bottom
|
475 |
+
// left corner of the scrollbar box is the scrollbar box
|
476 |
+
// itself (when the bar is still visible) or its filler child
|
477 |
+
// (when the bar is hidden). If it is still visible, we keep
|
478 |
+
// it enabled, if it's hidden, we disable pointer events.
|
479 |
+
var box = bar.getBoundingClientRect();
|
480 |
+
var elt = document.elementFromPoint(box.left + 1, box.bottom - 1);
|
481 |
+
if (elt != bar) bar.style.pointerEvents = "none";
|
482 |
+
else delay.set(1000, maybeDisable);
|
483 |
+
}
|
484 |
+
delay.set(1000, maybeDisable);
|
485 |
},
|
486 |
clear: function() {
|
487 |
var parent = this.horiz.parentNode;
|
731 |
// width and height.
|
732 |
removeChildren(display.cursorDiv);
|
733 |
removeChildren(display.selectionDiv);
|
734 |
+
display.gutters.style.height = display.sizer.style.minHeight = 0;
|
735 |
|
736 |
if (different) {
|
737 |
display.lastWrapHeight = update.wrapperHeight;
|
745 |
}
|
746 |
|
747 |
function postUpdateDisplay(cm, update) {
|
748 |
+
var viewport = update.viewport;
|
749 |
for (var first = true;; first = false) {
|
750 |
+
if (!first || !cm.options.lineWrapping || update.oldDisplayWidth == displayWidth(cm)) {
|
|
|
|
|
|
|
751 |
// Clip forced viewport to actual scrollable area.
|
752 |
if (viewport && viewport.top != null)
|
753 |
viewport = {top: Math.min(cm.doc.height + paddingVert(cm.display) - displayHeight(cm), viewport.top)};
|
823 |
// given line.
|
824 |
function updateWidgetHeight(line) {
|
825 |
if (line.widgets) for (var i = 0; i < line.widgets.length; ++i)
|
826 |
+
line.widgets[i].height = line.widgets[i].node.parentNode.offsetHeight;
|
827 |
}
|
828 |
|
829 |
// Do a bulk-read of the DOM positions and sizes needed to draw the
|
972 |
lineView.node.removeChild(lineView.gutter);
|
973 |
lineView.gutter = null;
|
974 |
}
|
975 |
+
if (lineView.gutterBackground) {
|
976 |
+
lineView.node.removeChild(lineView.gutterBackground);
|
977 |
+
lineView.gutterBackground = null;
|
978 |
+
}
|
979 |
+
if (lineView.line.gutterClass) {
|
980 |
+
var wrap = ensureLineWrapped(lineView);
|
981 |
+
lineView.gutterBackground = elt("div", null, "CodeMirror-gutter-background " + lineView.line.gutterClass,
|
982 |
+
"left: " + (cm.options.fixedGutter ? dims.fixedPos : -dims.gutterTotalWidth) +
|
983 |
+
"px; width: " + dims.gutterTotalWidth + "px");
|
984 |
+
wrap.insertBefore(lineView.gutterBackground, lineView.text);
|
985 |
+
}
|
986 |
var markers = lineView.line.gutterMarkers;
|
987 |
if (cm.options.lineNumbers || markers) {
|
988 |
var wrap = ensureLineWrapped(lineView);
|
989 |
var gutterWrap = lineView.gutter = elt("div", null, "CodeMirror-gutter-wrapper", "left: " +
|
990 |
+
(cm.options.fixedGutter ? dims.fixedPos : -dims.gutterTotalWidth) + "px");
|
|
|
991 |
cm.display.input.setUneditable(gutterWrap);
|
992 |
wrap.insertBefore(gutterWrap, lineView.text);
|
993 |
if (lineView.line.gutterClass)
|
1094 |
if (!cm.state.focused) { cm.display.input.focus(); onFocus(cm); }
|
1095 |
}
|
1096 |
|
|
|
|
|
|
|
|
|
1097 |
// This will be set to an array of strings when copying, so that,
|
1098 |
// when pasting, we know what kind of selections the copied text
|
1099 |
// was made out of.
|
1104 |
cm.display.shift = false;
|
1105 |
if (!sel) sel = doc.sel;
|
1106 |
|
1107 |
+
var paste = cm.state.pasteIncoming || origin == "paste";
|
1108 |
+
var textLines = doc.splitLines(inserted), multiPaste = null;
|
1109 |
// When pasing N lines into N selections, insert one line per selection
|
1110 |
+
if (paste && sel.ranges.length > 1) {
|
1111 |
+
if (lastCopied && lastCopied.join("\n") == inserted) {
|
1112 |
+
if (sel.ranges.length % lastCopied.length == 0) {
|
1113 |
+
multiPaste = [];
|
1114 |
+
for (var i = 0; i < lastCopied.length; i++)
|
1115 |
+
multiPaste.push(doc.splitLines(lastCopied[i]));
|
1116 |
+
}
|
1117 |
+
} else if (textLines.length == sel.ranges.length) {
|
1118 |
multiPaste = map(textLines, function(l) { return [l]; });
|
1119 |
+
}
|
1120 |
}
|
1121 |
|
1122 |
// Normal behavior is to insert the new text into every selection
|
1126 |
if (range.empty()) {
|
1127 |
if (deleted && deleted > 0) // Handle deletion
|
1128 |
from = Pos(from.line, from.ch - deleted);
|
1129 |
+
else if (cm.state.overwrite && !paste) // Handle overwrite
|
1130 |
to = Pos(to.line, Math.min(getLine(doc, to.line).text.length, to.ch + lst(textLines).length));
|
1131 |
}
|
1132 |
var updateInput = cm.curOp.updateInput;
|
1133 |
var changeEvent = {from: from, to: to, text: multiPaste ? multiPaste[i % multiPaste.length] : textLines,
|
1134 |
+
origin: origin || (paste ? "paste" : cm.state.cutIncoming ? "cut" : "+input")};
|
1135 |
makeChange(cm.doc, changeEvent);
|
1136 |
signalLater(cm, "inputRead", cm, changeEvent);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1137 |
}
|
1138 |
+
if (inserted && !paste)
|
1139 |
+
triggerElectric(cm, inserted);
|
1140 |
+
|
1141 |
ensureCursorVisible(cm);
|
1142 |
cm.curOp.updateInput = updateInput;
|
1143 |
cm.curOp.typing = true;
|
1144 |
cm.state.pasteIncoming = cm.state.cutIncoming = false;
|
1145 |
}
|
1146 |
|
1147 |
+
function handlePaste(e, cm) {
|
1148 |
+
var pasted = e.clipboardData && e.clipboardData.getData("text/plain");
|
1149 |
+
if (pasted) {
|
1150 |
+
e.preventDefault();
|
1151 |
+
if (!cm.isReadOnly() && !cm.options.disableInput)
|
1152 |
+
runInOp(cm, function() { applyTextInput(cm, pasted, 0, null, "paste"); });
|
1153 |
+
return true;
|
1154 |
+
}
|
1155 |
+
}
|
1156 |
+
|
1157 |
+
function triggerElectric(cm, inserted) {
|
1158 |
+
// When an 'electric' character is inserted, immediately trigger a reindent
|
1159 |
+
if (!cm.options.electricChars || !cm.options.smartIndent) return;
|
1160 |
+
var sel = cm.doc.sel;
|
1161 |
+
|
1162 |
+
for (var i = sel.ranges.length - 1; i >= 0; i--) {
|
1163 |
+
var range = sel.ranges[i];
|
1164 |
+
if (range.head.ch > 100 || (i && sel.ranges[i - 1].head.line == range.head.line)) continue;
|
1165 |
+
var mode = cm.getModeAt(range.head);
|
1166 |
+
var indented = false;
|
1167 |
+
if (mode.electricChars) {
|
1168 |
+
for (var j = 0; j < mode.electricChars.length; j++)
|
1169 |
+
if (inserted.indexOf(mode.electricChars.charAt(j)) > -1) {
|
1170 |
+
indented = indentLine(cm, range.head.line, "smart");
|
1171 |
+
break;
|
1172 |
+
}
|
1173 |
+
} else if (mode.electricInput) {
|
1174 |
+
if (mode.electricInput.test(getLine(cm.doc, range.head.line).text.slice(0, range.head.ch)))
|
1175 |
+
indented = indentLine(cm, range.head.line, "smart");
|
1176 |
+
}
|
1177 |
+
if (indented) signalLater(cm, "electricInput", cm, range.head.line);
|
1178 |
+
}
|
1179 |
+
}
|
1180 |
+
|
1181 |
function copyableRanges(cm) {
|
1182 |
var text = [], ranges = [];
|
1183 |
for (var i = 0; i < cm.doc.sel.ranges.length; i++) {
|
1250 |
input.poll();
|
1251 |
});
|
1252 |
|
1253 |
+
on(te, "paste", function(e) {
|
1254 |
+
if (signalDOMEvent(cm, e) || handlePaste(e, cm)) return
|
1255 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1256 |
cm.state.pasteIncoming = true;
|
1257 |
input.fastPoll();
|
1258 |
});
|
1285 |
on(te, "copy", prepareCopyCut);
|
1286 |
|
1287 |
on(display.scroller, "paste", function(e) {
|
1288 |
+
if (eventInWidget(display, e) || signalDOMEvent(cm, e)) return;
|
1289 |
cm.state.pasteIncoming = true;
|
1290 |
input.focus();
|
1291 |
});
|
1297 |
|
1298 |
on(te, "compositionstart", function() {
|
1299 |
var start = cm.getCursor("from");
|
1300 |
+
if (input.composing) input.composing.range.clear()
|
1301 |
input.composing = {
|
1302 |
start: start,
|
1303 |
range: cm.markText(start, cm.getCursor("to"), {className: "CodeMirror-composing"})
|
1417 |
// possible when it is clear that nothing happened. hasSelection
|
1418 |
// will be the case when there is a lot of text in the textarea,
|
1419 |
// in which case reading its value would be expensive.
|
1420 |
+
if (this.contextMenuPending || !cm.state.focused ||
|
1421 |
+
(hasSelection(input) && !prevInput && !this.composing) ||
|
1422 |
+
cm.isReadOnly() || cm.options.disableInput || cm.state.keySeq)
|
1423 |
return false;
|
1424 |
+
|
|
|
|
|
|
|
|
|
1425 |
var text = input.value;
|
1426 |
// If nothing changed, bail.
|
1427 |
if (text == prevInput && !cm.somethingSelected()) return false;
|
1546 |
}
|
1547 |
},
|
1548 |
|
1549 |
+
readOnlyChanged: function(val) {
|
1550 |
+
if (!val) this.reset();
|
1551 |
+
},
|
1552 |
+
|
1553 |
setUneditable: nothing,
|
1554 |
|
1555 |
needsContentAttribute: false
|
1568 |
init: function(display) {
|
1569 |
var input = this, cm = input.cm;
|
1570 |
var div = input.div = display.lineDiv;
|
|
|
1571 |
disableBrowserMagic(div);
|
1572 |
|
1573 |
on(div, "paste", function(e) {
|
1574 |
+
if (!signalDOMEvent(cm, e)) handlePaste(e, cm);
|
1575 |
+
})
|
|
|
|
|
|
|
|
|
1576 |
|
1577 |
on(div, "compositionstart", function(e) {
|
1578 |
var data = e.data;
|
1610 |
|
1611 |
on(div, "input", function() {
|
1612 |
if (input.composing) return;
|
1613 |
+
if (cm.isReadOnly() || !input.pollContent())
|
1614 |
runInOp(input.cm, function() {regChange(cm);});
|
1615 |
});
|
1616 |
|
1690 |
try { var rng = range(start.node, start.offset, end.offset, end.node); }
|
1691 |
catch(e) {} // Our model of the DOM might be outdated, in which case the range we try to set can be impossible
|
1692 |
if (rng) {
|
1693 |
+
if (!gecko && this.cm.state.focused) {
|
1694 |
+
sel.collapse(start.node, start.offset);
|
1695 |
+
if (!rng.collapsed) sel.addRange(rng);
|
1696 |
+
} else {
|
1697 |
+
sel.removeAllRanges();
|
1698 |
+
sel.addRange(rng);
|
1699 |
+
}
|
1700 |
if (old && sel.anchorNode == null) sel.addRange(old);
|
1701 |
else if (gecko) this.startGracePeriod();
|
1702 |
}
|
1790 |
var toIndex = findViewIndex(cm, to.line);
|
1791 |
if (toIndex == display.view.length - 1) {
|
1792 |
var toLine = display.viewTo - 1;
|
1793 |
+
var toNode = display.lineDiv.lastChild;
|
1794 |
} else {
|
1795 |
var toLine = lineNo(display.view[toIndex + 1].line) - 1;
|
1796 |
var toNode = display.view[toIndex + 1].node.previousSibling;
|
1797 |
}
|
1798 |
|
1799 |
+
var newText = cm.doc.splitLines(domTextBetween(cm, fromNode, toNode, fromLine, toLine));
|
1800 |
var oldText = getBetween(cm.doc, Pos(fromLine, 0), Pos(toLine, getLine(cm.doc, toLine).text.length));
|
1801 |
while (newText.length > 1 && oldText.length > 1) {
|
1802 |
if (lst(newText) == lst(oldText)) { newText.pop(); oldText.pop(); toLine--; }
|
1840 |
this.div.focus();
|
1841 |
},
|
1842 |
applyComposition: function(composing) {
|
1843 |
+
if (this.cm.isReadOnly())
|
1844 |
+
operation(this.cm, regChange)(this.cm)
|
1845 |
+
else if (composing.data && composing.data != composing.startData)
|
1846 |
operation(this.cm, applyTextInput)(this.cm, composing.data, 0, composing.sel);
|
1847 |
},
|
1848 |
|
1849 |
setUneditable: function(node) {
|
1850 |
+
node.contentEditable = "false"
|
1851 |
},
|
1852 |
|
1853 |
onKeyPress: function(e) {
|
1854 |
e.preventDefault();
|
1855 |
+
if (!this.cm.isReadOnly())
|
1856 |
+
operation(this.cm, applyTextInput)(this.cm, String.fromCharCode(e.charCode == null ? e.keyCode : e.charCode), 0);
|
1857 |
+
},
|
1858 |
+
|
1859 |
+
readOnlyChanged: function(val) {
|
1860 |
+
this.div.contentEditable = String(val != "nocursor")
|
1861 |
},
|
1862 |
|
1863 |
onContextMenu: nothing,
|
1877 |
var partPos = getBidiPartAt(order, pos.ch);
|
1878 |
side = partPos % 2 ? "right" : "left";
|
1879 |
}
|
1880 |
+
var result = nodeAndOffsetInLineMap(info.map, pos.ch, side);
|
1881 |
result.offset = result.collapse == "right" ? result.end : result.start;
|
1882 |
return result;
|
1883 |
}
|
1959 |
}
|
1960 |
|
1961 |
function domTextBetween(cm, from, to, fromLine, toLine) {
|
1962 |
+
var text = "", closing = false, lineSep = cm.doc.lineSeparator();
|
1963 |
function recognizeMarker(id) { return function(marker) { return marker.id == id; }; }
|
1964 |
function walk(node) {
|
1965 |
if (node.nodeType == 1) {
|
1973 |
if (markerID) {
|
1974 |
var found = cm.findMarks(Pos(fromLine, 0), Pos(toLine + 1, 0), recognizeMarker(+markerID));
|
1975 |
if (found.length && (range = found[0].find()))
|
1976 |
+
text += getBetween(cm.doc, range.from, range.to).join(lineSep);
|
1977 |
return;
|
1978 |
}
|
1979 |
if (node.getAttribute("contenteditable") == "false") return;
|
1985 |
var val = node.nodeValue;
|
1986 |
if (!val) return;
|
1987 |
if (closing) {
|
1988 |
+
text += lineSep;
|
1989 |
closing = false;
|
1990 |
}
|
1991 |
text += val;
|
2157 |
|
2158 |
// Give beforeSelectionChange handlers a change to influence a
|
2159 |
// selection update.
|
2160 |
+
function filterSelectionChange(doc, sel, options) {
|
2161 |
var obj = {
|
2162 |
ranges: sel.ranges,
|
2163 |
update: function(ranges) {
|
2165 |
for (var i = 0; i < ranges.length; i++)
|
2166 |
this.ranges[i] = new Range(clipPos(doc, ranges[i].anchor),
|
2167 |
clipPos(doc, ranges[i].head));
|
2168 |
+
},
|
2169 |
+
origin: options && options.origin
|
2170 |
};
|
2171 |
signal(doc, "beforeSelectionChange", doc, obj);
|
2172 |
if (doc.cm) signal(doc.cm, "beforeSelectionChange", doc.cm, obj);
|
2192 |
|
2193 |
function setSelectionNoUndo(doc, sel, options) {
|
2194 |
if (hasHandler(doc, "beforeSelectionChange") || doc.cm && hasHandler(doc.cm, "beforeSelectionChange"))
|
2195 |
+
sel = filterSelectionChange(doc, sel, options);
|
2196 |
|
2197 |
var bias = options && options.bias ||
|
2198 |
(cmp(sel.primary().head, doc.sel.primary().head) < 0 ? -1 : 1);
|
2226 |
var out;
|
2227 |
for (var i = 0; i < sel.ranges.length; i++) {
|
2228 |
var range = sel.ranges[i];
|
2229 |
+
var old = sel.ranges.length == doc.sel.ranges.length && doc.sel.ranges[i];
|
2230 |
+
var newAnchor = skipAtomic(doc, range.anchor, old && old.anchor, bias, mayClear);
|
2231 |
+
var newHead = skipAtomic(doc, range.head, old && old.head, bias, mayClear);
|
2232 |
if (out || newAnchor != range.anchor || newHead != range.head) {
|
2233 |
if (!out) out = sel.ranges.slice(0, i);
|
2234 |
out[i] = new Range(newAnchor, newHead);
|
2237 |
return out ? normalizeSelection(out, sel.primIndex) : sel;
|
2238 |
}
|
2239 |
|
2240 |
+
function skipAtomicInner(doc, pos, oldPos, dir, mayClear) {
|
2241 |
+
var line = getLine(doc, pos.line);
|
2242 |
+
if (line.markedSpans) for (var i = 0; i < line.markedSpans.length; ++i) {
|
2243 |
+
var sp = line.markedSpans[i], m = sp.marker;
|
2244 |
+
if ((sp.from == null || (m.inclusiveLeft ? sp.from <= pos.ch : sp.from < pos.ch)) &&
|
2245 |
+
(sp.to == null || (m.inclusiveRight ? sp.to >= pos.ch : sp.to > pos.ch))) {
|
2246 |
+
if (mayClear) {
|
2247 |
+
signal(m, "beforeCursorEnter");
|
2248 |
+
if (m.explicitlyCleared) {
|
2249 |
+
if (!line.markedSpans) break;
|
2250 |
+
else {--i; continue;}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2251 |
}
|
2252 |
}
|
2253 |
+
if (!m.atomic) continue;
|
2254 |
+
|
2255 |
+
if (oldPos) {
|
2256 |
+
var near = m.find(dir < 0 ? 1 : -1), diff;
|
2257 |
+
if (dir < 0 ? m.inclusiveRight : m.inclusiveLeft) near = movePos(doc, near, -dir, line);
|
2258 |
+
if (near && near.line == pos.line && (diff = cmp(near, oldPos)) && (dir < 0 ? diff < 0 : diff > 0))
|
2259 |
+
return skipAtomicInner(doc, near, pos, dir, mayClear);
|
2260 |
+
}
|
2261 |
+
|
2262 |
+
var far = m.find(dir < 0 ? -1 : 1);
|
2263 |
+
if (dir < 0 ? m.inclusiveLeft : m.inclusiveRight) far = movePos(doc, far, dir, line);
|
2264 |
+
return far ? skipAtomicInner(doc, far, pos, dir, mayClear) : null;
|
2265 |
}
|
2266 |
+
}
|
2267 |
+
return pos;
|
2268 |
+
}
|
2269 |
+
|
2270 |
+
// Ensure a given position is not inside an atomic range.
|
2271 |
+
function skipAtomic(doc, pos, oldPos, bias, mayClear) {
|
2272 |
+
var dir = bias || 1;
|
2273 |
+
var found = skipAtomicInner(doc, pos, oldPos, dir, mayClear) ||
|
2274 |
+
(!mayClear && skipAtomicInner(doc, pos, oldPos, dir, true)) ||
|
2275 |
+
skipAtomicInner(doc, pos, oldPos, -dir, mayClear) ||
|
2276 |
+
(!mayClear && skipAtomicInner(doc, pos, oldPos, -dir, true));
|
2277 |
+
if (!found) {
|
2278 |
+
doc.cantEdit = true;
|
2279 |
+
return Pos(doc.first, 0);
|
2280 |
+
}
|
2281 |
+
return found;
|
2282 |
+
}
|
2283 |
+
|
2284 |
+
function movePos(doc, pos, dir, line) {
|
2285 |
+
if (dir < 0 && pos.ch == 0) {
|
2286 |
+
if (pos.line > doc.first) return clipPos(doc, Pos(pos.line - 1));
|
2287 |
+
else return null;
|
2288 |
+
} else if (dir > 0 && pos.ch == (line || getLine(doc, pos.line)).text.length) {
|
2289 |
+
if (pos.line < doc.first + doc.size - 1) return Pos(pos.line + 1, 0);
|
2290 |
+
else return null;
|
2291 |
+
} else {
|
2292 |
+
return new Pos(pos.line, pos.ch + dir);
|
2293 |
}
|
2294 |
}
|
2295 |
|
2309 |
var range = doc.sel.ranges[i];
|
2310 |
var collapsed = range.empty();
|
2311 |
if (collapsed || cm.options.showCursorWhenSelecting)
|
2312 |
+
drawSelectionCursor(cm, range.head, curFragment);
|
2313 |
if (!collapsed)
|
2314 |
drawSelectionRange(cm, range, selFragment);
|
2315 |
}
|
2317 |
}
|
2318 |
|
2319 |
// Draws a cursor for the given range
|
2320 |
+
function drawSelectionCursor(cm, head, output) {
|
2321 |
+
var pos = cursorCoords(cm, head, "div", null, null, !cm.options.singleCursorHeightPerLine);
|
2322 |
|
2323 |
var cursor = output.appendChild(elt("div", "\u00a0", "CodeMirror-cursor"));
|
2324 |
cursor.style.left = pos.left + "px";
|
2442 |
|
2443 |
doc.iter(doc.frontier, Math.min(doc.first + doc.size, cm.display.viewTo + 500), function(line) {
|
2444 |
if (doc.frontier >= cm.display.viewFrom) { // Visible
|
2445 |
+
var oldStyles = line.styles, tooLong = line.text.length > cm.options.maxHighlightLength;
|
2446 |
+
var highlighted = highlightLine(cm, line, tooLong ? copyState(doc.mode, state) : state, true);
|
2447 |
line.styles = highlighted.styles;
|
2448 |
var oldCls = line.styleClasses, newCls = highlighted.classes;
|
2449 |
if (newCls) line.styleClasses = newCls;
|
2452 |
oldCls != newCls && (!oldCls || !newCls || oldCls.bgClass != newCls.bgClass || oldCls.textClass != newCls.textClass);
|
2453 |
for (var i = 0; !ischange && i < oldStyles.length; ++i) ischange = oldStyles[i] != line.styles[i];
|
2454 |
if (ischange) changedLines.push(doc.frontier);
|
2455 |
+
line.stateAfter = tooLong ? state : copyState(doc.mode, state);
|
2456 |
} else {
|
2457 |
+
if (line.text.length <= cm.options.maxHighlightLength)
|
2458 |
+
processLine(cm, line.text, state);
|
2459 |
line.stateAfter = doc.frontier % 5 == 0 ? copyState(doc.mode, state) : null;
|
2460 |
}
|
2461 |
++doc.frontier;
|
2600 |
function prepareMeasureForLine(cm, line) {
|
2601 |
var lineN = lineNo(line);
|
2602 |
var view = findViewForLine(cm, lineN);
|
2603 |
+
if (view && !view.text) {
|
2604 |
view = null;
|
2605 |
+
} else if (view && view.changes) {
|
2606 |
updateLineForChanges(cm, view, lineN, getDimensions(cm));
|
2607 |
+
cm.curOp.forceUpdate = true;
|
2608 |
+
}
|
2609 |
if (!view)
|
2610 |
view = updateExternalMeasurement(cm, line);
|
2611 |
|
3018 |
var callbacks = group.delayedCallbacks, i = 0;
|
3019 |
do {
|
3020 |
for (; i < callbacks.length; i++)
|
3021 |
+
callbacks[i].call(null);
|
3022 |
for (var j = 0; j < group.ops.length; j++) {
|
3023 |
var op = group.ops[j];
|
3024 |
if (op.cursorActivityHandlers)
|
3025 |
while (op.cursorActivityCalled < op.cursorActivityHandlers.length)
|
3026 |
+
op.cursorActivityHandlers[op.cursorActivityCalled++].call(null, op.cm);
|
3027 |
}
|
3028 |
} while (i < callbacks.length);
|
3029 |
}
|
3117 |
|
3118 |
if (cm.state.focused && op.updateInput)
|
3119 |
cm.display.input.reset(op.typing);
|
3120 |
+
if (op.focus && op.focus == activeElt() && (!document.hasFocus || document.hasFocus()))
|
3121 |
+
ensureFocus(op.cm);
|
3122 |
}
|
3123 |
|
3124 |
function endOperation_finish(op) {
|
3484 |
on(d.wrapper, "scroll", function() { d.wrapper.scrollTop = d.wrapper.scrollLeft = 0; });
|
3485 |
|
3486 |
d.dragFunctions = {
|
3487 |
+
enter: function(e) {if (!signalDOMEvent(cm, e)) e_stop(e);},
|
3488 |
+
over: function(e) {if (!signalDOMEvent(cm, e)) { onDragOver(cm, e); e_stop(e); }},
|
3489 |
start: function(e){onDragStart(cm, e);},
|
3490 |
+
drop: operation(cm, onDrop),
|
3491 |
+
leave: function() {clearDragCursor(cm);}
|
3492 |
};
|
3493 |
|
3494 |
var inp = d.input.getField();
|
3505 |
var funcs = cm.display.dragFunctions;
|
3506 |
var toggle = value ? on : off;
|
3507 |
toggle(cm.display.scroller, "dragstart", funcs.start);
|
3508 |
+
toggle(cm.display.scroller, "dragenter", funcs.enter);
|
3509 |
+
toggle(cm.display.scroller, "dragover", funcs.over);
|
3510 |
+
toggle(cm.display.scroller, "dragleave", funcs.leave);
|
3511 |
toggle(cm.display.scroller, "drop", funcs.drop);
|
3512 |
}
|
3513 |
}
|
3580 |
|
3581 |
switch (e_button(e)) {
|
3582 |
case 1:
|
3583 |
+
// #3261: make sure, that we're not starting a second selection
|
3584 |
+
if (cm.state.selectingText)
|
3585 |
+
cm.state.selectingText(e);
|
3586 |
+
else if (start)
|
3587 |
leftButtonDown(cm, e, start);
|
3588 |
else if (e_target(e) == display.scroller)
|
3589 |
e_preventDefault(e);
|
3618 |
}
|
3619 |
|
3620 |
var sel = cm.doc.sel, modifier = mac ? e.metaKey : e.ctrlKey, contained;
|
3621 |
+
if (cm.options.dragDrop && dragAndDrop && !cm.isReadOnly() &&
|
3622 |
type == "single" && (contained = sel.contains(start)) > -1 &&
|
3623 |
+
(cmp((contained = sel.ranges[contained]).from(), start) < 0 || start.xRel > 0) &&
|
3624 |
+
(cmp(contained.to(), start) > 0 || start.xRel < 0))
|
3625 |
leftButtonStartDrag(cm, e, start, modifier);
|
3626 |
else
|
3627 |
leftButtonSelect(cm, e, start, type, modifier);
|
3703 |
setSelection(doc, normalizeSelection(ranges.concat([ourRange]), ourIndex),
|
3704 |
{scroll: false, origin: "*mouse"});
|
3705 |
} else if (ranges.length > 1 && ranges[ourIndex].empty() && type == "single" && !e.shiftKey) {
|
3706 |
+
setSelection(doc, normalizeSelection(ranges.slice(0, ourIndex).concat(ranges.slice(ourIndex + 1)), 0),
|
3707 |
+
{scroll: false, origin: "*mouse"});
|
3708 |
startSel = doc.sel;
|
3709 |
} else {
|
3710 |
replaceOneSelection(doc, ourIndex, ourRange, sel_mouse);
|
3782 |
}
|
3783 |
|
3784 |
function done(e) {
|
3785 |
+
cm.state.selectingText = false;
|
3786 |
counter = Infinity;
|
3787 |
e_preventDefault(e);
|
3788 |
display.input.focus();
|
3796 |
else extend(e);
|
3797 |
});
|
3798 |
var up = operation(cm, done);
|
3799 |
+
cm.state.selectingText = up;
|
3800 |
on(document, "mousemove", move);
|
3801 |
on(document, "mouseup", up);
|
3802 |
}
|
3803 |
|
3804 |
// Determines whether an event happened in the gutter, and fires the
|
3805 |
// handlers for the corresponding event.
|
3806 |
+
function gutterEvent(cm, e, type, prevent) {
|
3807 |
try { var mX = e.clientX, mY = e.clientY; }
|
3808 |
catch(e) { return false; }
|
3809 |
if (mX >= Math.floor(cm.display.gutters.getBoundingClientRect().right)) return false;
|
3820 |
if (g && g.getBoundingClientRect().right >= mX) {
|
3821 |
var line = lineAtHeight(cm.doc, mY);
|
3822 |
var gutter = cm.options.gutters[i];
|
3823 |
+
signal(cm, type, cm, line, gutter, e);
|
3824 |
return e_defaultPrevented(e);
|
3825 |
}
|
3826 |
}
|
3827 |
}
|
3828 |
|
3829 |
function clickInGutter(cm, e) {
|
3830 |
+
return gutterEvent(cm, e, "gutterClick", true);
|
3831 |
}
|
3832 |
|
3833 |
// Kludge to work around strange IE behavior where it'll sometimes
|
3836 |
|
3837 |
function onDrop(e) {
|
3838 |
var cm = this;
|
3839 |
+
clearDragCursor(cm);
|
3840 |
if (signalDOMEvent(cm, e) || eventInWidget(cm.display, e))
|
3841 |
return;
|
3842 |
e_preventDefault(e);
|
3843 |
if (ie) lastDrop = +new Date;
|
3844 |
var pos = posFromMouse(cm, e, true), files = e.dataTransfer.files;
|
3845 |
+
if (!pos || cm.isReadOnly()) return;
|
3846 |
// Might be a file drop, in which case we simply extract the text
|
3847 |
// and insert it.
|
3848 |
if (files && files.length && window.FileReader && window.File) {
|
3849 |
var n = files.length, text = Array(n), read = 0;
|
3850 |
var loadFile = function(file, i) {
|
3851 |
+
if (cm.options.allowDropFileTypes &&
|
3852 |
+
indexOf(cm.options.allowDropFileTypes, file.type) == -1)
|
3853 |
+
return;
|
3854 |
+
|
3855 |
var reader = new FileReader;
|
3856 |
reader.onload = operation(cm, function() {
|
3857 |
+
var content = reader.result;
|
3858 |
+
if (/[\x00-\x08\x0e-\x1f]{2}/.test(content)) content = "";
|
3859 |
+
text[i] = content;
|
3860 |
if (++read == n) {
|
3861 |
pos = clipPos(cm.doc, pos);
|
3862 |
+
var change = {from: pos, to: pos,
|
3863 |
+
text: cm.doc.splitLines(text.join(cm.doc.lineSeparator())),
|
3864 |
+
origin: "paste"};
|
3865 |
makeChange(cm.doc, change);
|
3866 |
setSelectionReplaceHistory(cm.doc, simpleSelection(pos, changeEnd(change)));
|
3867 |
}
|
3915 |
}
|
3916 |
}
|
3917 |
|
3918 |
+
function onDragOver(cm, e) {
|
3919 |
+
var pos = posFromMouse(cm, e);
|
3920 |
+
if (!pos) return;
|
3921 |
+
var frag = document.createDocumentFragment();
|
3922 |
+
drawSelectionCursor(cm, pos, frag);
|
3923 |
+
if (!cm.display.dragCursor) {
|
3924 |
+
cm.display.dragCursor = elt("div", null, "CodeMirror-cursors CodeMirror-dragcursors");
|
3925 |
+
cm.display.lineSpace.insertBefore(cm.display.dragCursor, cm.display.cursorDiv);
|
3926 |
+
}
|
3927 |
+
removeChildrenAndAdd(cm.display.dragCursor, frag);
|
3928 |
+
}
|
3929 |
+
|
3930 |
+
function clearDragCursor(cm) {
|
3931 |
+
if (cm.display.dragCursor) {
|
3932 |
+
cm.display.lineSpace.removeChild(cm.display.dragCursor);
|
3933 |
+
cm.display.dragCursor = null;
|
3934 |
+
}
|
3935 |
+
}
|
3936 |
+
|
3937 |
// SCROLL EVENTS
|
3938 |
|
3939 |
// Sync the scrollable area and scrollbars, ensure the viewport
|
3998 |
|
3999 |
var display = cm.display, scroll = display.scroller;
|
4000 |
// Quit if there's nothing to scroll here
|
4001 |
+
var canScrollX = scroll.scrollWidth > scroll.clientWidth;
|
4002 |
+
var canScrollY = scroll.scrollHeight > scroll.clientHeight;
|
4003 |
+
if (!(dx && canScrollX || dy && canScrollY)) return;
|
4004 |
|
4005 |
// Webkit browsers on OS X abort momentum scrolls when the target
|
4006 |
// of the scroll event is removed from the scrollable element.
|
4024 |
// scrolling entirely here. It'll be slightly off from native, but
|
4025 |
// better than glitching out.
|
4026 |
if (dx && !gecko && !presto && wheelPixelsPerUnit != null) {
|
4027 |
+
if (dy && canScrollY)
|
4028 |
setScrollTop(cm, Math.max(0, Math.min(scroll.scrollTop + dy * wheelPixelsPerUnit, scroll.scrollHeight - scroll.clientHeight)));
|
4029 |
setScrollLeft(cm, Math.max(0, Math.min(scroll.scrollLeft + dx * wheelPixelsPerUnit, scroll.scrollWidth - scroll.clientWidth)));
|
4030 |
+
// Only prevent default scrolling if vertical scrolling is
|
4031 |
+
// actually possible. Otherwise, it causes vertical scroll
|
4032 |
+
// jitter on OSX trackpads when deltaX is small and deltaY
|
4033 |
+
// is large (issue #3579)
|
4034 |
+
if (!dy || (dy && canScrollY))
|
4035 |
+
e_preventDefault(e);
|
4036 |
display.wheelStartX = null; // Abort measurement, if in progress
|
4037 |
return;
|
4038 |
}
|
4081 |
cm.display.input.ensurePolled();
|
4082 |
var prevShift = cm.display.shift, done = false;
|
4083 |
try {
|
4084 |
+
if (cm.isReadOnly()) cm.state.suppressEdits = true;
|
4085 |
if (dropShift) cm.display.shift = false;
|
4086 |
done = bound(cm) != Pass;
|
4087 |
} finally {
|
4260 |
// right-click take effect on it.
|
4261 |
function onContextMenu(cm, e) {
|
4262 |
if (eventInWidget(cm.display, e) || contextMenuInGutter(cm, e)) return;
|
4263 |
+
if (signalDOMEvent(cm, e, "contextmenu")) return;
|
4264 |
cm.display.input.onContextMenu(e);
|
4265 |
}
|
4266 |
|
4267 |
function contextMenuInGutter(cm, e) {
|
4268 |
if (!hasHandler(cm, "gutterContextMenu")) return false;
|
4269 |
+
return gutterEvent(cm, e, "gutterContextMenu", false);
|
4270 |
}
|
4271 |
|
4272 |
// UPDATING
|
4570 |
function replaceRange(doc, code, from, to, origin) {
|
4571 |
if (!to) to = from;
|
4572 |
if (cmp(to, from) < 0) { var tmp = to; to = from; from = tmp; }
|
4573 |
+
if (typeof code == "string") code = doc.splitLines(code);
|
4574 |
makeChange(doc, {from: from, to: to, text: code, origin: origin});
|
4575 |
}
|
4576 |
|
4854 |
if (dir > 0 && !moveOnce(!first)) break;
|
4855 |
}
|
4856 |
}
|
4857 |
+
var result = skipAtomic(doc, Pos(line, ch), pos, origDir, true);
|
4858 |
if (!possible) result.hitSide = true;
|
4859 |
return result;
|
4860 |
}
|
5147 |
|
5148 |
execCommand: function(cmd) {
|
5149 |
if (commands.hasOwnProperty(cmd))
|
5150 |
+
return commands[cmd].call(null, this);
|
5151 |
},
|
5152 |
|
5153 |
+
triggerElectric: methodOp(function(text) { triggerElectric(this, text); }),
|
5154 |
+
|
5155 |
findPosH: function(from, amount, unit, visually) {
|
5156 |
var dir = 1;
|
5157 |
if (amount < 0) { dir = -1; amount = -amount; }
|
5242 |
signal(this, "overwriteToggle", this, this.state.overwrite);
|
5243 |
},
|
5244 |
hasFocus: function() { return this.display.input.getField() == activeElt(); },
|
5245 |
+
isReadOnly: function() { return !!(this.options.readOnly || this.doc.cantEdit); },
|
5246 |
|
5247 |
scrollTo: methodOp(function(x, y) {
|
5248 |
if (x != null || y != null) resolveScrollToPos(this);
|
5366 |
clearCaches(cm);
|
5367 |
regChange(cm);
|
5368 |
}, true);
|
5369 |
+
option("lineSeparator", null, function(cm, val) {
|
5370 |
+
cm.doc.lineSep = val;
|
5371 |
+
if (!val) return;
|
5372 |
+
var newBreaks = [], lineNo = cm.doc.first;
|
5373 |
+
cm.doc.iter(function(line) {
|
5374 |
+
for (var pos = 0;;) {
|
5375 |
+
var found = line.text.indexOf(val, pos);
|
5376 |
+
if (found == -1) break;
|
5377 |
+
pos = found + val.length;
|
5378 |
+
newBreaks.push(Pos(lineNo, found));
|
5379 |
+
}
|
5380 |
+
lineNo++;
|
5381 |
+
});
|
5382 |
+
for (var i = newBreaks.length - 1; i >= 0; i--)
|
5383 |
+
replaceRange(cm.doc, val, newBreaks[i], Pos(newBreaks[i].line, newBreaks[i].ch + val.length))
|
5384 |
+
});
|
5385 |
option("specialChars", /[\t\u0000-\u0019\u00ad\u200b-\u200f\u2028\u2029\ufeff]/g, function(cm, val, old) {
|
5386 |
cm.state.specialChars = new RegExp(val.source + (val.test("\t") ? "" : "|\t"), "g");
|
5387 |
if (old != CodeMirror.Init) cm.refresh();
|
5440 |
cm.display.disabled = true;
|
5441 |
} else {
|
5442 |
cm.display.disabled = false;
|
|
|
5443 |
}
|
5444 |
+
cm.display.input.readOnlyChanged(val)
|
5445 |
});
|
5446 |
option("disableInput", false, function(cm, val) {if (!val) cm.display.input.reset();}, true);
|
5447 |
option("dragDrop", true, dragDropChanged);
|
5448 |
+
option("allowDropFileTypes", null);
|
5449 |
|
5450 |
option("cursorBlinkRate", 530);
|
5451 |
option("cursorScrollMargin", 0);
|
5733 |
} else if (cur.line > cm.doc.first) {
|
5734 |
var prev = getLine(cm.doc, cur.line - 1).text;
|
5735 |
if (prev)
|
5736 |
+
cm.replaceRange(line.charAt(0) + cm.doc.lineSeparator() +
|
5737 |
+
prev.charAt(prev.length - 1),
|
5738 |
Pos(cur.line - 1, prev.length - 1), Pos(cur.line, 1), "+transpose");
|
5739 |
}
|
5740 |
}
|
5748 |
var len = cm.listSelections().length;
|
5749 |
for (var i = 0; i < len; i++) {
|
5750 |
var range = cm.listSelections()[i];
|
5751 |
+
cm.replaceRange(cm.doc.lineSeparator(), range.anchor, range.head, "+input");
|
5752 |
cm.indentLine(range.from().line + 1, null, true);
|
|
|
5753 |
}
|
5754 |
+
ensureCursorVisible(cm);
|
5755 |
});
|
5756 |
},
|
5757 |
toggleOverwrite: function(cm) {cm.toggleOverwrite();}
|
5838 |
for (var i = 0; i < keys.length; i++) {
|
5839 |
var val, name;
|
5840 |
if (i == keys.length - 1) {
|
5841 |
+
name = keys.join(" ");
|
5842 |
val = value;
|
5843 |
} else {
|
5844 |
name = keys.slice(0, i + 1).join(" ");
|
6679 |
parentStyle += "width: " + cm.display.wrapper.clientWidth + "px;";
|
6680 |
removeChildrenAndAdd(cm.display.measure, elt("div", [widget.node], null, parentStyle));
|
6681 |
}
|
6682 |
+
return widget.height = widget.node.parentNode.offsetHeight;
|
6683 |
}
|
6684 |
|
6685 |
function addLineWidget(doc, handle, node, options) {
|
6868 |
|
6869 |
function getLineStyles(cm, line, updateFrontier) {
|
6870 |
if (!line.styles || line.styles[0] != cm.state.modeGen) {
|
6871 |
+
var state = getStateBefore(cm, lineNo(line));
|
6872 |
+
var result = highlightLine(cm, line, line.text.length > cm.options.maxHighlightLength ? copyState(cm.doc.mode, state) : state);
|
6873 |
+
line.stateAfter = state;
|
6874 |
line.styles = result.styles;
|
6875 |
if (result.classes) line.styleClasses = result.classes;
|
6876 |
else if (line.styleClasses) line.styleClasses = null;
|
6887 |
var stream = new StringStream(text, cm.options.tabSize);
|
6888 |
stream.start = stream.pos = startAt || 0;
|
6889 |
if (text == "") callBlankLine(mode, state);
|
6890 |
+
while (!stream.eol()) {
|
6891 |
readToken(mode, stream, state);
|
6892 |
stream.start = stream.pos;
|
6893 |
}
|
6914 |
// is needed on Webkit to be able to get line-level bounding
|
6915 |
// rectangles for it (in measureChar).
|
6916 |
var content = elt("span", null, null, webkit ? "padding-right: .1px" : null);
|
6917 |
+
var builder = {pre: elt("pre", [content], "CodeMirror-line"), content: content,
|
6918 |
col: 0, pos: 0, cm: cm,
|
6919 |
splitSpaces: (ie || webkit) && cm.getOption("lineWrapping")};
|
6920 |
lineView.measure = {};
|
7004 |
txt.setAttribute("role", "presentation");
|
7005 |
txt.setAttribute("cm-text", "\t");
|
7006 |
builder.col += tabWidth;
|
7007 |
+
} else if (m[0] == "\r" || m[0] == "\n") {
|
7008 |
+
var txt = content.appendChild(elt("span", m[0] == "\r" ? "\u240d" : "\u2424", "cm-invalidchar"));
|
7009 |
+
txt.setAttribute("cm-text", m[0]);
|
7010 |
+
builder.col += 1;
|
7011 |
} else {
|
7012 |
var txt = builder.cm.options.specialCharPlaceholder(m[0]);
|
7013 |
txt.setAttribute("cm-text", m[0]);
|
7089 |
if (nextChange == pos) { // Update current marker set
|
7090 |
spanStyle = spanEndStyle = spanStartStyle = title = css = "";
|
7091 |
collapsed = null; nextChange = Infinity;
|
7092 |
+
var foundBookmarks = [], endStyles
|
7093 |
for (var j = 0; j < spans.length; ++j) {
|
7094 |
var sp = spans[j], m = sp.marker;
|
7095 |
if (m.type == "bookmark" && sp.from == pos && m.widgetNode) {
|
7100 |
spanEndStyle = "";
|
7101 |
}
|
7102 |
if (m.className) spanStyle += " " + m.className;
|
7103 |
+
if (m.css) css = (css ? css + ";" : "") + m.css;
|
7104 |
if (m.startStyle && sp.from == pos) spanStartStyle += " " + m.startStyle;
|
7105 |
+
if (m.endStyle && sp.to == nextChange) (endStyles || (endStyles = [])).push(m.endStyle, sp.to)
|
7106 |
if (m.title && !title) title = m.title;
|
7107 |
if (m.collapsed && (!collapsed || compareCollapsedMarkers(collapsed.marker, m) < 0))
|
7108 |
collapsed = sp;
|
7110 |
nextChange = sp.from;
|
7111 |
}
|
7112 |
}
|
7113 |
+
if (endStyles) for (var j = 0; j < endStyles.length; j += 2)
|
7114 |
+
if (endStyles[j + 1] == nextChange) spanEndStyle += " " + endStyles[j]
|
7115 |
+
|
7116 |
if (collapsed && (collapsed.from || 0) == pos) {
|
7117 |
buildCollapsedSpan(builder, (collapsed.to == null ? len + 1 : collapsed.to) - pos,
|
7118 |
collapsed.marker, collapsed.from == null);
|
7356 |
};
|
7357 |
|
7358 |
var nextDocId = 0;
|
7359 |
+
var Doc = CodeMirror.Doc = function(text, mode, firstLine, lineSep) {
|
7360 |
+
if (!(this instanceof Doc)) return new Doc(text, mode, firstLine, lineSep);
|
7361 |
if (firstLine == null) firstLine = 0;
|
7362 |
|
7363 |
BranchChunk.call(this, [new LeafChunk([new Line("", null)])]);
|
7371 |
this.history = new History(null);
|
7372 |
this.id = ++nextDocId;
|
7373 |
this.modeOption = mode;
|
7374 |
+
this.lineSep = lineSep;
|
7375 |
+
this.extend = false;
|
7376 |
|
7377 |
+
if (typeof text == "string") text = this.splitLines(text);
|
7378 |
updateDoc(this, {from: start, to: start, text: text});
|
7379 |
setSelection(this, simpleSelection(start), sel_dontScroll);
|
7380 |
};
|
7404 |
getValue: function(lineSep) {
|
7405 |
var lines = getLines(this, this.first, this.first + this.size);
|
7406 |
if (lineSep === false) return lines;
|
7407 |
+
return lines.join(lineSep || this.lineSeparator());
|
7408 |
},
|
7409 |
setValue: docMethodOp(function(code) {
|
7410 |
var top = Pos(this.first, 0), last = this.first + this.size - 1;
|
7411 |
makeChange(this, {from: top, to: Pos(last, getLine(this, last).text.length),
|
7412 |
+
text: this.splitLines(code), origin: "setValue", full: true}, true);
|
7413 |
setSelection(this, simpleSelection(top));
|
7414 |
}),
|
7415 |
replaceRange: function(code, from, to, origin) {
|
7420 |
getRange: function(from, to, lineSep) {
|
7421 |
var lines = getBetween(this, clipPos(this, from), clipPos(this, to));
|
7422 |
if (lineSep === false) return lines;
|
7423 |
+
return lines.join(lineSep || this.lineSeparator());
|
7424 |
},
|
7425 |
|
7426 |
getLine: function(line) {var l = this.getLineHandle(line); return l && l.text;},
|
7460 |
extendSelection(this, clipPos(this, head), other && clipPos(this, other), options);
|
7461 |
}),
|
7462 |
extendSelections: docMethodOp(function(heads, options) {
|
7463 |
+
extendSelections(this, clipPosArray(this, heads), options);
|
7464 |
}),
|
7465 |
extendSelectionsBy: docMethodOp(function(f, options) {
|
7466 |
+
var heads = map(this.sel.ranges, f);
|
7467 |
+
extendSelections(this, clipPosArray(this, heads), options);
|
7468 |
}),
|
7469 |
setSelections: docMethodOp(function(ranges, primary, options) {
|
7470 |
if (!ranges.length) return;
|
7487 |
lines = lines ? lines.concat(sel) : sel;
|
7488 |
}
|
7489 |
if (lineSep === false) return lines;
|
7490 |
+
else return lines.join(lineSep || this.lineSeparator());
|
7491 |
},
|
7492 |
getSelections: function(lineSep) {
|
7493 |
var parts = [], ranges = this.sel.ranges;
|
7494 |
for (var i = 0; i < ranges.length; i++) {
|
7495 |
var sel = getBetween(this, ranges[i].from(), ranges[i].to());
|
7496 |
+
if (lineSep !== false) sel = sel.join(lineSep || this.lineSeparator());
|
7497 |
parts[i] = sel;
|
7498 |
}
|
7499 |
return parts;
|
7508 |
var changes = [], sel = this.sel;
|
7509 |
for (var i = 0; i < sel.ranges.length; i++) {
|
7510 |
var range = sel.ranges[i];
|
7511 |
+
changes[i] = {from: range.from(), to: range.to(), text: this.splitLines(code[i]), origin: origin};
|
7512 |
}
|
7513 |
var newSel = collapse && collapse != "end" && computeReplacedSel(this, changes, collapse);
|
7514 |
for (var i = changes.length - 1; i >= 0; i--)
|
7589 |
removeLineWidget: function(widget) { widget.clear(); },
|
7590 |
|
7591 |
markText: function(from, to, options) {
|
7592 |
+
return markText(this, clipPos(this, from), clipPos(this, to), options, options && options.type || "range");
|
7593 |
},
|
7594 |
setBookmark: function(pos, options) {
|
7595 |
var realOpts = {replacedWith: options && (options.nodeType == null ? options.widget : options),
|
7658 |
},
|
7659 |
|
7660 |
copy: function(copyHistory) {
|
7661 |
+
var doc = new Doc(getLines(this, this.first, this.first + this.size),
|
7662 |
+
this.modeOption, this.first, this.lineSep);
|
7663 |
doc.scrollTop = this.scrollTop; doc.scrollLeft = this.scrollLeft;
|
7664 |
doc.sel = this.sel;
|
7665 |
doc.extend = false;
|
7675 |
var from = this.first, to = this.first + this.size;
|
7676 |
if (options.from != null && options.from > from) from = options.from;
|
7677 |
if (options.to != null && options.to < to) to = options.to;
|
7678 |
+
var copy = new Doc(getLines(this, from, to), options.mode || this.modeOption, from, this.lineSep);
|
7679 |
if (options.sharedHist) copy.history = this.history;
|
7680 |
(this.linked || (this.linked = [])).push({doc: copy, sharedHist: options.sharedHist});
|
7681 |
copy.linked = [{doc: this, isParent: true, sharedHist: options.sharedHist}];
|
7704 |
iterLinkedDocs: function(f) {linkedDocs(this, f);},
|
7705 |
|
7706 |
getMode: function() {return this.mode;},
|
7707 |
+
getEditor: function() {return this.cm;},
|
7708 |
+
|
7709 |
+
splitLines: function(str) {
|
7710 |
+
if (this.lineSep) return str.split(this.lineSep);
|
7711 |
+
return splitLinesAuto(str);
|
7712 |
+
},
|
7713 |
+
lineSeparator: function() { return this.lineSep || "\n"; }
|
7714 |
});
|
7715 |
|
7716 |
// Public alias.
|
7717 |
Doc.prototype.eachLine = Doc.prototype.iter;
|
7718 |
|
7719 |
// Set up methods on CodeMirror's prototype to redirect to the editor's document.
|
7720 |
+
var dontDelegate = "iter insert remove copy getEditor constructor".split(" ");
|
7721 |
for (var prop in Doc.prototype) if (Doc.prototype.hasOwnProperty(prop) && indexOf(dontDelegate, prop) < 0)
|
7722 |
CodeMirror.prototype[prop] = (function(method) {
|
7723 |
return function() {return method.apply(this.doc, arguments);};
|
8150 |
}
|
8151 |
};
|
8152 |
|
8153 |
+
var noHandlers = []
|
8154 |
+
function getHandlers(emitter, type, copy) {
|
8155 |
+
var arr = emitter._handlers && emitter._handlers[type]
|
8156 |
+
if (copy) return arr && arr.length > 0 ? arr.slice() : noHandlers
|
8157 |
+
else return arr || noHandlers
|
8158 |
+
}
|
8159 |
+
|
8160 |
var off = CodeMirror.off = function(emitter, type, f) {
|
8161 |
if (emitter.removeEventListener)
|
8162 |
emitter.removeEventListener(type, f, false);
|
8163 |
else if (emitter.detachEvent)
|
8164 |
emitter.detachEvent("on" + type, f);
|
8165 |
else {
|
8166 |
+
var handlers = getHandlers(emitter, type, false)
|
8167 |
+
for (var i = 0; i < handlers.length; ++i)
|
8168 |
+
if (handlers[i] == f) { handlers.splice(i, 1); break; }
|
|
|
8169 |
}
|
8170 |
};
|
8171 |
|
8172 |
var signal = CodeMirror.signal = function(emitter, type /*, values...*/) {
|
8173 |
+
var handlers = getHandlers(emitter, type, true)
|
8174 |
+
if (!handlers.length) return;
|
8175 |
var args = Array.prototype.slice.call(arguments, 2);
|
8176 |
+
for (var i = 0; i < handlers.length; ++i) handlers[i].apply(null, args);
|
8177 |
};
|
8178 |
|
8179 |
var orphanDelayedCallbacks = null;
|
8186 |
// them to be executed when the last operation ends, or, if no
|
8187 |
// operation is active, when a timeout fires.
|
8188 |
function signalLater(emitter, type /*, values...*/) {
|
8189 |
+
var arr = getHandlers(emitter, type, false)
|
8190 |
+
if (!arr.length) return;
|
8191 |
var args = Array.prototype.slice.call(arguments, 2), list;
|
8192 |
if (operationGroup) {
|
8193 |
list = operationGroup.delayedCallbacks;
|
8227 |
}
|
8228 |
|
8229 |
function hasHandler(emitter, type) {
|
8230 |
+
return getHandlers(emitter, type).length > 0
|
|
|
8231 |
}
|
8232 |
|
8233 |
// Add on and off methods to a constructor's prototype, to make
|
8274 |
|
8275 |
// The inverse of countColumn -- find the offset that corresponds to
|
8276 |
// a particular column.
|
8277 |
+
var findColumn = CodeMirror.findColumn = function(string, goal, tabSize) {
|
8278 |
for (var pos = 0, col = 0;;) {
|
8279 |
var nextTab = string.indexOf("\t", pos);
|
8280 |
if (nextTab == -1) nextTab = string.length;
|
8414 |
} while (child = child.parentNode);
|
8415 |
};
|
8416 |
|
8417 |
+
function activeElt() {
|
8418 |
+
var activeElement = document.activeElement;
|
8419 |
+
while (activeElement && activeElement.root && activeElement.root.activeElement)
|
8420 |
+
activeElement = activeElement.root.activeElement;
|
8421 |
+
return activeElement;
|
8422 |
+
}
|
8423 |
// Older versions of IE throws unspecified error when touching
|
8424 |
// document.activeElement in some cases (during loading, in iframe)
|
8425 |
if (ie && ie_version < 11) activeElt = function() {
|
8521 |
|
8522 |
// See if "".split is the broken IE version, if so, provide an
|
8523 |
// alternative way to split lines.
|
8524 |
+
var splitLinesAuto = CodeMirror.splitLines = "\n\nb".split(/\n/).length != 3 ? function(string) {
|
8525 |
var pos = 0, result = [], l = string.length;
|
8526 |
while (pos <= l) {
|
8527 |
var nl = string.indexOf("\n", pos);
|
8567 |
|
8568 |
// KEY NAMES
|
8569 |
|
8570 |
+
var keyNames = CodeMirror.keyNames = {
|
8571 |
+
3: "Enter", 8: "Backspace", 9: "Tab", 13: "Enter", 16: "Shift", 17: "Ctrl", 18: "Alt",
|
8572 |
+
19: "Pause", 20: "CapsLock", 27: "Esc", 32: "Space", 33: "PageUp", 34: "PageDown", 35: "End",
|
8573 |
+
36: "Home", 37: "Left", 38: "Up", 39: "Right", 40: "Down", 44: "PrintScrn", 45: "Insert",
|
8574 |
+
46: "Delete", 59: ";", 61: "=", 91: "Mod", 92: "Mod", 93: "Mod",
|
8575 |
+
106: "*", 107: "=", 109: "-", 110: ".", 111: "/", 127: "Delete",
|
8576 |
+
173: "-", 186: ";", 187: "=", 188: ",", 189: "-", 190: ".", 191: "/", 192: "`", 219: "[", 220: "\\",
|
8577 |
+
221: "]", 222: "'", 63232: "Up", 63233: "Down", 63234: "Left", 63235: "Right", 63272: "Delete",
|
8578 |
+
63273: "Home", 63275: "End", 63276: "PageUp", 63277: "PageDown", 63302: "Insert"
|
8579 |
+
};
|
8580 |
(function() {
|
8581 |
// Number keys
|
8582 |
for (var i = 0; i < 10; i++) keyNames[i + 48] = keyNames[i + 96] = String(i);
|
8881 |
|
8882 |
// THE END
|
8883 |
|
8884 |
+
CodeMirror.version = "5.10.0";
|
8885 |
|
8886 |
return CodeMirror;
|
8887 |
});
|
lib/codemirror/lib/codemirror.min.js
CHANGED
@@ -1,5 +1,5 @@
|
|
1 |
-
!function(e){if("object"==typeof exports&&"object"==typeof module)module.exports=e();else{if("function"==typeof define&&define.amd)return define([],e);this.CodeMirror=e()}}(function(){"use strict";function e(r,n){if(!(this instanceof e))return new e(r,n);this.options=n=n?Di(n):{},Di(Xo,n,!1),d(n);var i=n.value;"string"==typeof i&&(i=new vl(i,n.mode)),this.doc=i;var o=new e.inputStyles[n.inputStyle](this),l=this.display=new t(r,i,o);l.wrapper.CodeMirror=this,u(this),s(this),n.lineWrapping&&(this.display.wrapper.className+=" CodeMirror-wrap"),n.autofocus&&!Co&&l.input.focus(),m(this),this.state={keyMaps:[],overlays:[],modeGen:0,overwrite:!1,delayingBlurEvent:!1,focused:!1,suppressEdits:!1,pasteIncoming:!1,cutIncoming:!1,draggingText:!1,highlight:new Li,keySeq:null,specialChars:null};var a=this;fo&&11>ho&&setTimeout(function(){a.display.input.reset(!0)},20),Rt(this),Ki(),mt(this),this.curOp.forceUpdate=!0,jn(this,i),n.autofocus&&!Co||a.hasFocus()?setTimeout(Hi(fr,this),20):hr(this);for(var c in _o)_o.hasOwnProperty(c)&&_o[c](this,n[c],Yo);C(this),n.finishInit&&n.finishInit(this);for(var f=0;f<Qo.length;++f)Qo[f](this);bt(this),po&&n.lineWrapping&&"optimizelegibility"==getComputedStyle(l.lineDiv).textRendering&&(l.lineDiv.style.textRendering="auto")}function t(e,t,r){var n=this;this.input=r,n.scrollbarFiller=zi("div",null,"CodeMirror-scrollbar-filler"),n.scrollbarFiller.setAttribute("cm-not-content","true"),n.gutterFiller=zi("div",null,"CodeMirror-gutter-filler"),n.gutterFiller.setAttribute("cm-not-content","true"),n.lineDiv=zi("div",null,"CodeMirror-code"),n.selectionDiv=zi("div",null,null,"position: relative; z-index: 1"),n.cursorDiv=zi("div",null,"CodeMirror-cursors"),n.measure=zi("div",null,"CodeMirror-measure"),n.lineMeasure=zi("div",null,"CodeMirror-measure"),n.lineSpace=zi("div",[n.measure,n.lineMeasure,n.selectionDiv,n.cursorDiv,n.lineDiv],null,"position: relative; outline: none"),n.mover=zi("div",[zi("div",[n.lineSpace],"CodeMirror-lines")],null,"position: relative"),n.sizer=zi("div",[n.mover],"CodeMirror-sizer"),n.sizerWidth=null,n.heightForcer=zi("div",null,null,"position: absolute; height: "+Tl+"px; width: 1px;"),n.gutters=zi("div",null,"CodeMirror-gutters"),n.lineGutter=null,n.scroller=zi("div",[n.sizer,n.heightForcer,n.gutters],"CodeMirror-scroll"),n.scroller.setAttribute("tabIndex","-1"),n.wrapper=zi("div",[n.scrollbarFiller,n.gutterFiller,n.scroller],"CodeMirror"),fo&&8>ho&&(n.gutters.style.zIndex=-1,n.scroller.style.paddingRight=0),po||ao&&Co||(n.scroller.draggable=!0),e&&(e.appendChild?e.appendChild(n.wrapper):e(n.wrapper)),n.viewFrom=n.viewTo=t.first,n.reportedViewFrom=n.reportedViewTo=t.first,n.view=[],n.renderedView=null,n.externalMeasured=null,n.viewOffset=0,n.lastWrapHeight=n.lastWrapWidth=0,n.updateLineNumbers=null,n.nativeBarWidth=n.barHeight=n.barWidth=0,n.scrollbarsClipped=!1,n.lineNumWidth=n.lineNumInnerWidth=n.lineNumChars=null,n.alignWidgets=!1,n.cachedCharWidth=n.cachedTextHeight=n.cachedPaddingH=null,n.maxLine=null,n.maxLineLength=0,n.maxLineChanged=!1,n.wheelDX=n.wheelDY=n.wheelStartX=n.wheelStartY=null,n.shift=!1,n.selForContextMenu=null,n.activeTouch=null,r.init(n)}function r(t){t.doc.mode=e.getMode(t.options,t.doc.modeOption),n(t)}function n(e){e.doc.iter(function(e){e.stateAfter&&(e.stateAfter=null),e.styles&&(e.styles=null)}),e.doc.frontier=e.doc.first,Ee(e,100),e.state.modeGen++,e.curOp&&Dt(e)}function i(e){e.options.lineWrapping?(Ul(e.display.wrapper,"CodeMirror-wrap"),e.display.sizer.style.minWidth="",e.display.sizerWidth=null):(Gl(e.display.wrapper,"CodeMirror-wrap"),h(e)),l(e),Dt(e),it(e),setTimeout(function(){y(e)},100)}function o(e){var t=gt(e.display),r=e.options.lineWrapping,n=r&&Math.max(5,e.display.scroller.clientWidth/vt(e.display)-3);return function(i){if(mn(e.doc,i))return 0;var o=0;if(i.widgets)for(var l=0;l<i.widgets.length;l++)i.widgets[l].height&&(o+=i.widgets[l].height);return r?o+(Math.ceil(i.text.length/n)||1)*t:o+t}}function l(e){var t=e.doc,r=o(e);t.iter(function(e){var t=r(e);t!=e.height&&$n(e,t)})}function s(e){e.display.wrapper.className=e.display.wrapper.className.replace(/\s*cm-s-\S+/g,"")+e.options.theme.replace(/(^|\s)\s*/g," cm-s-"),it(e)}function a(e){u(e),Dt(e),setTimeout(function(){x(e)},20)}function u(e){var t=e.display.gutters,r=e.options.gutters;Fi(t);for(var n=0;n<r.length;++n){var i=r[n],o=t.appendChild(zi("div",null,"CodeMirror-gutter "+i));"CodeMirror-linenumbers"==i&&(e.display.lineGutter=o,o.style.width=(e.display.lineNumWidth||1)+"px")}t.style.display=n?"":"none",c(e)}function c(e){var t=e.display.gutters.offsetWidth;e.display.sizer.style.marginLeft=t+"px"}function f(e){if(0==e.height)return 0;for(var t,r=e.text.length,n=e;t=cn(n);){var i=t.find(0,!0);n=i.from.line,r+=i.from.ch-i.to.ch}for(n=e;t=fn(n);){var i=t.find(0,!0);r-=n.text.length-i.from.ch,n=i.to.line,r+=n.text.length-i.to.ch}return r}function h(e){var t=e.display,r=e.doc;t.maxLine=Xn(r,r.first),t.maxLineLength=f(t.maxLine),t.maxLineChanged=!0,r.iter(function(e){var r=f(e);r>t.maxLineLength&&(t.maxLineLength=r,t.maxLine=e)})}function d(e){var t=Ni(e.gutters,"CodeMirror-linenumbers");-1==t&&e.lineNumbers?e.gutters=e.gutters.concat(["CodeMirror-linenumbers"]):t>-1&&!e.lineNumbers&&(e.gutters=e.gutters.slice(0),e.gutters.splice(t,1))}function p(e){var t=e.display,r=t.gutters.offsetWidth,n=Math.round(e.doc.height+Ge(e.display));return{clientHeight:t.scroller.clientHeight,viewHeight:t.wrapper.clientHeight,scrollWidth:t.scroller.scrollWidth,clientWidth:t.scroller.clientWidth,viewWidth:t.wrapper.clientWidth,barLeft:e.options.fixedGutter?r:0,docHeight:n,scrollHeight:n+Ve(e)+t.barHeight,nativeBarWidth:t.nativeBarWidth,gutterWidth:r}}function g(e,t,r){this.cm=r;var n=this.vert=zi("div",[zi("div",null,null,"min-width: 1px")],"CodeMirror-vscrollbar"),i=this.horiz=zi("div",[zi("div",null,null,"height: 100%; min-height: 1px")],"CodeMirror-hscrollbar");e(n),e(i),Cl(n,"scroll",function(){n.clientHeight&&t(n.scrollTop,"vertical")}),Cl(i,"scroll",function(){i.clientWidth&&t(i.scrollLeft,"horizontal")}),this.checkedOverlay=!1,fo&&8>ho&&(this.horiz.style.minHeight=this.vert.style.minWidth="18px")}function v(){}function m(t){t.display.scrollbars&&(t.display.scrollbars.clear(),t.display.scrollbars.addClass&&Gl(t.display.wrapper,t.display.scrollbars.addClass)),t.display.scrollbars=new e.scrollbarModel[t.options.scrollbarStyle](function(e){t.display.wrapper.insertBefore(e,t.display.scrollbarFiller),Cl(e,"mousedown",function(){t.state.focused&&setTimeout(function(){t.display.input.focus()},0)}),e.setAttribute("cm-not-content","true")},function(e,r){"horizontal"==r?Jt(t,e):Qt(t,e)},t),t.display.scrollbars.addClass&&Ul(t.display.wrapper,t.display.scrollbars.addClass)}function y(e,t){t||(t=p(e));var r=e.display.barWidth,n=e.display.barHeight;b(e,t);for(var i=0;4>i&&r!=e.display.barWidth||n!=e.display.barHeight;i++)r!=e.display.barWidth&&e.options.lineWrapping&&O(e),b(e,p(e)),r=e.display.barWidth,n=e.display.barHeight}function b(e,t){var r=e.display,n=r.scrollbars.update(t);r.sizer.style.paddingRight=(r.barWidth=n.right)+"px",r.sizer.style.paddingBottom=(r.barHeight=n.bottom)+"px",n.right&&n.bottom?(r.scrollbarFiller.style.display="block",r.scrollbarFiller.style.height=n.bottom+"px",r.scrollbarFiller.style.width=n.right+"px"):r.scrollbarFiller.style.display="",n.bottom&&e.options.coverGutterNextToScrollbar&&e.options.fixedGutter?(r.gutterFiller.style.display="block",r.gutterFiller.style.height=n.bottom+"px",r.gutterFiller.style.width=t.gutterWidth+"px"):r.gutterFiller.style.display=""}function w(e,t,r){var n=r&&null!=r.top?Math.max(0,r.top):e.scroller.scrollTop;n=Math.floor(n-Be(e));var i=r&&null!=r.bottom?r.bottom:n+e.wrapper.clientHeight,o=Zn(t,n),l=Zn(t,i);if(r&&r.ensure){var s=r.ensure.from.line,a=r.ensure.to.line;o>s?(o=s,l=Zn(t,Qn(Xn(t,s))+e.wrapper.clientHeight)):Math.min(a,t.lastLine())>=l&&(o=Zn(t,Qn(Xn(t,a))-e.wrapper.clientHeight),l=a)}return{from:o,to:Math.max(l,o+1)}}function x(e){var t=e.display,r=t.view;if(t.alignWidgets||t.gutters.firstChild&&e.options.fixedGutter){for(var n=L(t)-t.scroller.scrollLeft+e.doc.scrollLeft,i=t.gutters.offsetWidth,o=n+"px",l=0;l<r.length;l++)if(!r[l].hidden){e.options.fixedGutter&&r[l].gutter&&(r[l].gutter.style.left=o);var s=r[l].alignable;if(s)for(var a=0;a<s.length;a++)s[a].style.left=o}e.options.fixedGutter&&(t.gutters.style.left=n+i+"px")}}function C(e){if(!e.options.lineNumbers)return!1;var t=e.doc,r=S(e.options,t.first+t.size-1),n=e.display;if(r.length!=n.lineNumChars){var i=n.measure.appendChild(zi("div",[zi("div",r)],"CodeMirror-linenumber CodeMirror-gutter-elt")),o=i.firstChild.offsetWidth,l=i.offsetWidth-o;return n.lineGutter.style.width="",n.lineNumInnerWidth=Math.max(o,n.lineGutter.offsetWidth-l)+1,n.lineNumWidth=n.lineNumInnerWidth+l,n.lineNumChars=n.lineNumInnerWidth?r.length:-1,n.lineGutter.style.width=n.lineNumWidth+"px",c(e),!0}return!1}function S(e,t){return String(e.lineNumberFormatter(t+e.firstLineNumber))}function L(e){return e.scroller.getBoundingClientRect().left-e.sizer.getBoundingClientRect().left}function k(e,t,r){var n=e.display;this.viewport=t,this.visible=w(n,e.doc,t),this.editorIsHidden=!n.wrapper.offsetWidth,this.wrapperHeight=n.wrapper.clientHeight,this.wrapperWidth=n.wrapper.clientWidth,this.oldDisplayWidth=Ke(e),this.force=r,this.dims=H(e),this.events=[]}function T(e){var t=e.display;!t.scrollbarsClipped&&t.scroller.offsetWidth&&(t.nativeBarWidth=t.scroller.offsetWidth-t.scroller.clientWidth,t.heightForcer.style.height=Ve(e)+"px",t.sizer.style.marginBottom=-t.nativeBarWidth+"px",t.sizer.style.borderRightWidth=Ve(e)+"px",t.scrollbarsClipped=!0)}function M(e,t){var r=e.display,n=e.doc;if(t.editorIsHidden)return It(e),!1;if(!t.force&&t.visible.from>=r.viewFrom&&t.visible.to<=r.viewTo&&(null==r.updateLineNumbers||r.updateLineNumbers>=r.viewTo)&&r.renderedView==r.view&&0==Ft(e))return!1;C(e)&&(It(e),t.dims=H(e));var i=n.first+n.size,o=Math.max(t.visible.from-e.options.viewportMargin,n.first),l=Math.min(i,t.visible.to+e.options.viewportMargin);r.viewFrom<o&&o-r.viewFrom<20&&(o=Math.max(n.first,r.viewFrom)),r.viewTo>l&&r.viewTo-l<20&&(l=Math.min(i,r.viewTo)),Ao&&(o=gn(e.doc,o),l=vn(e.doc,l));var s=o!=r.viewFrom||l!=r.viewTo||r.lastWrapHeight!=t.wrapperHeight||r.lastWrapWidth!=t.wrapperWidth;zt(e,o,l),r.viewOffset=Qn(Xn(e.doc,r.viewFrom)),e.display.mover.style.top=r.viewOffset+"px";var a=Ft(e);if(!s&&0==a&&!t.force&&r.renderedView==r.view&&(null==r.updateLineNumbers||r.updateLineNumbers>=r.viewTo))return!1;var u=Bi();return a>4&&(r.lineDiv.style.display="none"),I(e,r.updateLineNumbers,t.dims),a>4&&(r.lineDiv.style.display=""),r.renderedView=r.view,u&&Bi()!=u&&u.offsetHeight&&u.focus(),Fi(r.cursorDiv),Fi(r.selectionDiv),r.gutters.style.height=0,s&&(r.lastWrapHeight=t.wrapperHeight,r.lastWrapWidth=t.wrapperWidth,Ee(e,400)),r.updateLineNumbers=null,!0}function N(e,t){for(var r=t.force,n=t.viewport,i=!0;;i=!1){if(i&&e.options.lineWrapping&&t.oldDisplayWidth!=Ke(e))r=!0;else if(r=!1,n&&null!=n.top&&(n={top:Math.min(e.doc.height+Ge(e.display)-je(e),n.top)}),t.visible=w(e.display,e.doc,n),t.visible.from>=e.display.viewFrom&&t.visible.to<=e.display.viewTo)break;if(!M(e,t))break;O(e);var o=p(e);Oe(e),W(e,o),y(e,o)}t.signal(e,"update",e),(e.display.viewFrom!=e.display.reportedViewFrom||e.display.viewTo!=e.display.reportedViewTo)&&(t.signal(e,"viewportChange",e,e.display.viewFrom,e.display.viewTo),e.display.reportedViewFrom=e.display.viewFrom,e.display.reportedViewTo=e.display.viewTo)}function A(e,t){var r=new k(e,t);if(M(e,r)){O(e),N(e,r);var n=p(e);Oe(e),W(e,n),y(e,n),r.finish()}}function W(e,t){e.display.sizer.style.minHeight=t.docHeight+"px";var r=t.docHeight+e.display.barHeight;e.display.heightForcer.style.top=r+"px",e.display.gutters.style.height=Math.max(r+Ve(e),t.clientHeight)+"px"}function O(e){for(var t=e.display,r=t.lineDiv.offsetTop,n=0;n<t.view.length;n++){var i,o=t.view[n];if(!o.hidden){if(fo&&8>ho){var l=o.node.offsetTop+o.node.offsetHeight;i=l-r,r=l}else{var s=o.node.getBoundingClientRect();i=s.bottom-s.top}var a=o.line.height-i;if(2>i&&(i=gt(t)),(a>.001||-.001>a)&&($n(o.line,i),D(o.line),o.rest))for(var u=0;u<o.rest.length;u++)D(o.rest[u])}}}function D(e){if(e.widgets)for(var t=0;t<e.widgets.length;++t)e.widgets[t].height=e.widgets[t].node.offsetHeight}function H(e){for(var t=e.display,r={},n={},i=t.gutters.clientLeft,o=t.gutters.firstChild,l=0;o;o=o.nextSibling,++l)r[e.options.gutters[l]]=o.offsetLeft+o.clientLeft+i,n[e.options.gutters[l]]=o.clientWidth;return{fixedPos:L(t),gutterTotalWidth:t.gutters.offsetWidth,gutterLeft:r,gutterWidth:n,wrapperWidth:t.wrapper.clientWidth}}function I(e,t,r){function n(t){var r=t.nextSibling;return po&&So&&e.display.currentWheelTarget==t?t.style.display="none":t.parentNode.removeChild(t),r}for(var i=e.display,o=e.options.lineNumbers,l=i.lineDiv,s=l.firstChild,a=i.view,u=i.viewFrom,c=0;c<a.length;c++){var f=a[c];if(f.hidden);else if(f.node&&f.node.parentNode==l){for(;s!=f.node;)s=n(s);var h=o&&null!=t&&u>=t&&f.lineNumber;f.changes&&(Ni(f.changes,"gutter")>-1&&(h=!1),P(e,f,u,r)),h&&(Fi(f.lineNumber),f.lineNumber.appendChild(document.createTextNode(S(e.options,u)))),s=f.node.nextSibling}else{var d=V(e,f,u,r);l.insertBefore(d,s)}u+=f.size}for(;s;)s=n(s)}function P(e,t,r,n){for(var i=0;i<t.changes.length;i++){var o=t.changes[i];"text"==o?R(e,t):"gutter"==o?G(e,t,r,n):"class"==o?B(t):"widget"==o&&U(e,t,n)}t.changes=null}function E(e){return e.node==e.text&&(e.node=zi("div",null,null,"position: relative"),e.text.parentNode&&e.text.parentNode.replaceChild(e.node,e.text),e.node.appendChild(e.text),fo&&8>ho&&(e.node.style.zIndex=2)),e.node}function z(e){var t=e.bgClass?e.bgClass+" "+(e.line.bgClass||""):e.line.bgClass;if(t&&(t+=" CodeMirror-linebackground"),e.background)t?e.background.className=t:(e.background.parentNode.removeChild(e.background),e.background=null);else if(t){var r=E(e);e.background=r.insertBefore(zi("div",null,t),r.firstChild)}}function F(e,t){var r=e.display.externalMeasured;return r&&r.line==t.line?(e.display.externalMeasured=null,t.measure=r.measure,r.built):Hn(e,t)}function R(e,t){var r=t.text.className,n=F(e,t);t.text==t.node&&(t.node=n.pre),t.text.parentNode.replaceChild(n.pre,t.text),t.text=n.pre,n.bgClass!=t.bgClass||n.textClass!=t.textClass?(t.bgClass=n.bgClass,t.textClass=n.textClass,B(t)):r&&(t.text.className=r)}function B(e){z(e),e.line.wrapClass?E(e).className=e.line.wrapClass:e.node!=e.text&&(e.node.className="");var t=e.textClass?e.textClass+" "+(e.line.textClass||""):e.line.textClass;e.text.className=t||""}function G(e,t,r,n){t.gutter&&(t.node.removeChild(t.gutter),t.gutter=null);var i=t.line.gutterMarkers;if(e.options.lineNumbers||i){var o=E(t),l=t.gutter=zi("div",null,"CodeMirror-gutter-wrapper","left: "+(e.options.fixedGutter?n.fixedPos:-n.gutterTotalWidth)+"px; width: "+n.gutterTotalWidth+"px");if(e.display.input.setUneditable(l),o.insertBefore(l,t.text),t.line.gutterClass&&(l.className+=" "+t.line.gutterClass),!e.options.lineNumbers||i&&i["CodeMirror-linenumbers"]||(t.lineNumber=l.appendChild(zi("div",S(e.options,r),"CodeMirror-linenumber CodeMirror-gutter-elt","left: "+n.gutterLeft["CodeMirror-linenumbers"]+"px; width: "+e.display.lineNumInnerWidth+"px"))),i)for(var s=0;s<e.options.gutters.length;++s){var a=e.options.gutters[s],u=i.hasOwnProperty(a)&&i[a];u&&l.appendChild(zi("div",[u],"CodeMirror-gutter-elt","left: "+n.gutterLeft[a]+"px; width: "+n.gutterWidth[a]+"px"))}}}function U(e,t,r){t.alignable&&(t.alignable=null);for(var n,i=t.node.firstChild;i;i=n){var n=i.nextSibling;"CodeMirror-linewidget"==i.className&&t.node.removeChild(i)}K(e,t,r)}function V(e,t,r,n){var i=F(e,t);return t.text=t.node=i.pre,i.bgClass&&(t.bgClass=i.bgClass),i.textClass&&(t.textClass=i.textClass),B(t),G(e,t,r,n),K(e,t,n),t.node}function K(e,t,r){if(j(e,t.line,t,r,!0),t.rest)for(var n=0;n<t.rest.length;n++)j(e,t.rest[n],t,r,!1)}function j(e,t,r,n,i){if(t.widgets)for(var o=E(r),l=0,s=t.widgets;l<s.length;++l){var a=s[l],u=zi("div",[a.node],"CodeMirror-linewidget");a.handleMouseEvents||u.setAttribute("cm-ignore-events","true"),X(a,u,r,n),e.display.input.setUneditable(u),i&&a.above?o.insertBefore(u,r.gutter||r.text):o.appendChild(u),yi(a,"redraw")}}function X(e,t,r,n){if(e.noHScroll){(r.alignable||(r.alignable=[])).push(t);var i=n.wrapperWidth;t.style.left=n.fixedPos+"px",e.coverGutter||(i-=n.gutterTotalWidth,t.style.paddingLeft=n.gutterTotalWidth+"px"),t.style.width=i+"px"}e.coverGutter&&(t.style.zIndex=5,t.style.position="relative",e.noHScroll||(t.style.marginLeft=-n.gutterTotalWidth+"px"))}function _(e){return Wo(e.line,e.ch)}function Y(e,t){return Oo(e,t)<0?t:e}function $(e,t){return Oo(e,t)<0?e:t}function q(e){e.state.focused||(e.display.input.focus(),fr(e))}function Z(e){return e.options.readOnly||e.doc.cantEdit}function Q(e,t,r,n,i){var o=e.doc;e.display.shift=!1,n||(n=o.sel);var l=jl(t),s=null;e.state.pasteIncoming&&n.ranges.length>1&&(Do&&Do.join("\n")==t?s=n.ranges.length%Do.length==0&&Ai(Do,jl):l.length==n.ranges.length&&(s=Ai(l,function(e){return[e]})));for(var a=n.ranges.length-1;a>=0;a--){var u=n.ranges[a],c=u.from(),f=u.to();u.empty()&&(r&&r>0?c=Wo(c.line,c.ch-r):e.state.overwrite&&!e.state.pasteIncoming&&(f=Wo(f.line,Math.min(Xn(o,f.line).text.length,f.ch+Mi(l).length))));var h=e.curOp.updateInput,d={from:c,to:f,text:s?s[a%s.length]:l,origin:i||(e.state.pasteIncoming?"paste":e.state.cutIncoming?"cut":"+input")};if(wr(e.doc,d),yi(e,"inputRead",e,d),t&&!e.state.pasteIncoming&&e.options.electricChars&&e.options.smartIndent&&u.head.ch<100&&(!a||n.ranges[a-1].head.line!=u.head.line)){var p=e.getModeAt(u.head),g=jo(d),v=!1;if(p.electricChars){for(var m=0;m<p.electricChars.length;m++)if(t.indexOf(p.electricChars.charAt(m))>-1){v=Ir(e,g.line,"smart");break}}else p.electricInput&&p.electricInput.test(Xn(o,g.line).text.slice(0,g.ch))&&(v=Ir(e,g.line,"smart"));v&&yi(e,"electricInput",e,g.line)}}Dr(e),e.curOp.updateInput=h,e.curOp.typing=!0,e.state.pasteIncoming=e.state.cutIncoming=!1}function J(e){for(var t=[],r=[],n=0;n<e.doc.sel.ranges.length;n++){var i=e.doc.sel.ranges[n].head.line,o={anchor:Wo(i,0),head:Wo(i+1,0)};r.push(o),t.push(e.getRange(o.anchor,o.head))}return{text:t,ranges:r}}function ee(e){e.setAttribute("autocorrect","off"),e.setAttribute("autocapitalize","off"),e.setAttribute("spellcheck","false")}function te(e){this.cm=e,this.prevInput="",this.pollingFast=!1,this.polling=new Li,this.inaccurateSelection=!1,this.hasSelection=!1,this.composing=null}function re(){var e=zi("textarea",null,null,"position: absolute; padding: 0; width: 1px; height: 1em; outline: none"),t=zi("div",[e],null,"overflow: hidden; position: relative; width: 3px; height: 0px;");return po?e.style.width="1000px":e.setAttribute("wrap","off"),xo&&(e.style.border="1px solid black"),ee(e),t}function ne(e){this.cm=e,this.lastAnchorNode=this.lastAnchorOffset=this.lastFocusNode=this.lastFocusOffset=null,this.polling=new Li,this.gracePeriod=!1}function ie(e,t){var r=qe(e,t.line);if(!r||r.hidden)return null;var n=Xn(e.doc,t.line),i=_e(r,n,t.line),o=Jn(n),l="left";if(o){var s=io(o,t.ch);l=s%2?"right":"left"}var a=Je(i.map,t.ch,"left");return a.offset="right"==a.collapse?a.end:a.start,a}function oe(e,t){return t&&(e.bad=!0),e}function le(e,t,r){var n;if(t==e.display.lineDiv){if(n=e.display.lineDiv.childNodes[r],!n)return oe(e.clipPos(Wo(e.display.viewTo-1)),!0);t=null,r=0}else for(n=t;;n=n.parentNode){if(!n||n==e.display.lineDiv)return null;if(n.parentNode&&n.parentNode==e.display.lineDiv)break}for(var i=0;i<e.display.view.length;i++){var o=e.display.view[i];if(o.node==n)return se(o,t,r)}}function se(e,t,r){function n(t,r,n){for(var i=-1;i<(c?c.length:0);i++)for(var o=0>i?u.map:c[i],l=0;l<o.length;l+=3){var s=o[l+2];if(s==t||s==r){var a=qn(0>i?e.line:e.rest[i]),f=o[l]+n;return(0>n||s!=t)&&(f=o[l+(n?1:0)]),Wo(a,f)}}}var i=e.text.firstChild,o=!1;if(!t||!Fl(i,t))return oe(Wo(qn(e.line),0),!0);if(t==i&&(o=!0,t=i.childNodes[r],r=0,!t)){var l=e.rest?Mi(e.rest):e.line;return oe(Wo(qn(l),l.text.length),o)}var s=3==t.nodeType?t:null,a=t;for(s||1!=t.childNodes.length||3!=t.firstChild.nodeType||(s=t.firstChild,r&&(r=s.nodeValue.length));a.parentNode!=i;)a=a.parentNode;var u=e.measure,c=u.maps,f=n(s,a,r);if(f)return oe(f,o);for(var h=a.nextSibling,d=s?s.nodeValue.length-r:0;h;h=h.nextSibling){if(f=n(h,h.firstChild,0))return oe(Wo(f.line,f.ch-d),o);d+=h.textContent.length}for(var p=a.previousSibling,d=r;p;p=p.previousSibling){if(f=n(p,p.firstChild,-1))return oe(Wo(f.line,f.ch+d),o);d+=h.textContent.length}}function ae(e,t,r,n,i){function o(e){return function(t){return t.id==e}}function l(t){if(1==t.nodeType){var r=t.getAttribute("cm-text");if(null!=r)return""==r&&(r=t.textContent.replace(/\u200b/g,"")),void(s+=r);var u,c=t.getAttribute("cm-marker");if(c){var f=e.findMarks(Wo(n,0),Wo(i+1,0),o(+c));return void(f.length&&(u=f[0].find())&&(s+=_n(e.doc,u.from,u.to).join("\n")))}if("false"==t.getAttribute("contenteditable"))return;for(var h=0;h<t.childNodes.length;h++)l(t.childNodes[h]);/^(pre|div|p)$/i.test(t.nodeName)&&(a=!0)}else if(3==t.nodeType){var d=t.nodeValue;if(!d)return;a&&(s+="\n",a=!1),s+=d}}for(var s="",a=!1;l(t),t!=r;)t=t.nextSibling;return s}function ue(e,t){this.ranges=e,this.primIndex=t}function ce(e,t){this.anchor=e,this.head=t}function fe(e,t){var r=e[t];e.sort(function(e,t){return Oo(e.from(),t.from())}),t=Ni(e,r);for(var n=1;n<e.length;n++){var i=e[n],o=e[n-1];if(Oo(o.to(),i.from())>=0){var l=$(o.from(),i.from()),s=Y(o.to(),i.to()),a=o.empty()?i.from()==i.head:o.from()==o.head;t>=n&&--t,e.splice(--n,2,new ce(a?s:l,a?l:s))}}return new ue(e,t)}function he(e,t){return new ue([new ce(e,t||e)],0)}function de(e,t){return Math.max(e.first,Math.min(t,e.first+e.size-1))}function pe(e,t){if(t.line<e.first)return Wo(e.first,0);var r=e.first+e.size-1;return t.line>r?Wo(r,Xn(e,r).text.length):ge(t,Xn(e,t.line).text.length)}function ge(e,t){var r=e.ch;return null==r||r>t?Wo(e.line,t):0>r?Wo(e.line,0):e}function ve(e,t){return t>=e.first&&t<e.first+e.size}function me(e,t){for(var r=[],n=0;n<t.length;n++)r[n]=pe(e,t[n]);return r}function ye(e,t,r,n){if(e.cm&&e.cm.display.shift||e.extend){var i=t.anchor;if(n){var o=Oo(r,i)<0;o!=Oo(n,i)<0?(i=r,r=n):o!=Oo(r,n)<0&&(r=n)}return new ce(i,r)}return new ce(n||r,r)}function be(e,t,r,n){ke(e,new ue([ye(e,e.sel.primary(),t,r)],0),n)}function we(e,t,r){for(var n=[],i=0;i<e.sel.ranges.length;i++)n[i]=ye(e,e.sel.ranges[i],t[i],null);var o=fe(n,e.sel.primIndex);ke(e,o,r)}function xe(e,t,r,n){var i=e.sel.ranges.slice(0);i[t]=r,ke(e,fe(i,e.sel.primIndex),n)}function Ce(e,t,r,n){ke(e,he(t,r),n)}function Se(e,t){var r={ranges:t.ranges,update:function(t){this.ranges=[];for(var r=0;r<t.length;r++)this.ranges[r]=new ce(pe(e,t[r].anchor),pe(e,t[r].head))}};return Ll(e,"beforeSelectionChange",e,r),e.cm&&Ll(e.cm,"beforeSelectionChange",e.cm,r),r.ranges!=t.ranges?fe(r.ranges,r.ranges.length-1):t}function Le(e,t,r){var n=e.history.done,i=Mi(n);i&&i.ranges?(n[n.length-1]=t,Te(e,t,r)):ke(e,t,r)}function ke(e,t,r){Te(e,t,r),li(e,e.sel,e.cm?e.cm.curOp.id:NaN,r)}function Te(e,t,r){(Ci(e,"beforeSelectionChange")||e.cm&&Ci(e.cm,"beforeSelectionChange"))&&(t=Se(e,t));var n=r&&r.bias||(Oo(t.primary().head,e.sel.primary().head)<0?-1:1);Me(e,Ae(e,t,n,!0)),r&&r.scroll===!1||!e.cm||Dr(e.cm)}function Me(e,t){t.equals(e.sel)||(e.sel=t,e.cm&&(e.cm.curOp.updateInput=e.cm.curOp.selectionChanged=!0,xi(e.cm)),yi(e,"cursorActivity",e))}function Ne(e){Me(e,Ae(e,e.sel,null,!1),Nl)}function Ae(e,t,r,n){for(var i,o=0;o<t.ranges.length;o++){var l=t.ranges[o],s=We(e,l.anchor,r,n),a=We(e,l.head,r,n);(i||s!=l.anchor||a!=l.head)&&(i||(i=t.ranges.slice(0,o)),i[o]=new ce(s,a))}return i?fe(i,t.primIndex):t}function We(e,t,r,n){var i=!1,o=t,l=r||1;e.cantEdit=!1;e:for(;;){var s=Xn(e,o.line);if(s.markedSpans)for(var a=0;a<s.markedSpans.length;++a){var u=s.markedSpans[a],c=u.marker;if((null==u.from||(c.inclusiveLeft?u.from<=o.ch:u.from<o.ch))&&(null==u.to||(c.inclusiveRight?u.to>=o.ch:u.to>o.ch))){if(n&&(Ll(c,"beforeCursorEnter"),c.explicitlyCleared)){if(s.markedSpans){--a;continue}break}if(!c.atomic)continue;var f=c.find(0>l?-1:1);if(0==Oo(f,o)&&(f.ch+=l,f.ch<0?f=f.line>e.first?pe(e,Wo(f.line-1)):null:f.ch>s.text.length&&(f=f.line<e.first+e.size-1?Wo(f.line+1,0):null),!f)){if(i)return n?(e.cantEdit=!0,Wo(e.first,0)):We(e,t,r,!0);i=!0,f=t,l=-l}o=f;continue e}}return o}}function Oe(e){e.display.input.showSelection(e.display.input.prepareSelection())}function De(e,t){for(var r=e.doc,n={},i=n.cursors=document.createDocumentFragment(),o=n.selection=document.createDocumentFragment(),l=0;l<r.sel.ranges.length;l++)if(t!==!1||l!=r.sel.primIndex){var s=r.sel.ranges[l],a=s.empty();(a||e.options.showCursorWhenSelecting)&&He(e,s,i),a||Ie(e,s,o)}return n}function He(e,t,r){var n=ct(e,t.head,"div",null,null,!e.options.singleCursorHeightPerLine),i=r.appendChild(zi("div"," ","CodeMirror-cursor"));if(i.style.left=n.left+"px",i.style.top=n.top+"px",i.style.height=Math.max(0,n.bottom-n.top)*e.options.cursorHeight+"px",n.other){var o=r.appendChild(zi("div"," ","CodeMirror-cursor CodeMirror-secondarycursor"));o.style.display="",o.style.left=n.other.left+"px",o.style.top=n.other.top+"px",o.style.height=.85*(n.other.bottom-n.other.top)+"px"}}function Ie(e,t,r){function n(e,t,r,n){0>t&&(t=0),t=Math.round(t),n=Math.round(n),s.appendChild(zi("div",null,"CodeMirror-selected","position: absolute; left: "+e+"px; top: "+t+"px; width: "+(null==r?c-e:r)+"px; height: "+(n-t)+"px"))}function i(t,r,i){function o(r,n){return ut(e,Wo(t,r),"div",f,n)}var s,a,f=Xn(l,t),h=f.text.length;return $i(Jn(f),r||0,null==i?h:i,function(e,t,l){var f,d,p,g=o(e,"left");if(e==t)f=g,d=p=g.left;else{if(f=o(t-1,"right"),"rtl"==l){var v=g;g=f,f=v}d=g.left,p=f.right}null==r&&0==e&&(d=u),f.top-g.top>3&&(n(d,g.top,null,g.bottom),d=u,g.bottom<f.top&&n(d,g.bottom,null,f.top)),null==i&&t==h&&(p=c),(!s||g.top<s.top||g.top==s.top&&g.left<s.left)&&(s=g),(!a||f.bottom>a.bottom||f.bottom==a.bottom&&f.right>a.right)&&(a=f),u+1>d&&(d=u),n(d,f.top,p-d,f.bottom)}),{start:s,end:a}}var o=e.display,l=e.doc,s=document.createDocumentFragment(),a=Ue(e.display),u=a.left,c=Math.max(o.sizerWidth,Ke(e)-o.sizer.offsetLeft)-a.right,f=t.from(),h=t.to();if(f.line==h.line)i(f.line,f.ch,h.ch);else{var d=Xn(l,f.line),p=Xn(l,h.line),g=dn(d)==dn(p),v=i(f.line,f.ch,g?d.text.length+1:null).end,m=i(h.line,g?0:null,h.ch).start;g&&(v.top<m.top-2?(n(v.right,v.top,null,v.bottom),n(u,m.top,m.left,m.bottom)):n(v.right,v.top,m.left-v.right,v.bottom)),v.bottom<m.top&&n(u,v.bottom,null,m.top)}r.appendChild(s)}function Pe(e){if(e.state.focused){var t=e.display;clearInterval(t.blinker);var r=!0;t.cursorDiv.style.visibility="",e.options.cursorBlinkRate>0?t.blinker=setInterval(function(){t.cursorDiv.style.visibility=(r=!r)?"":"hidden"},e.options.cursorBlinkRate):e.options.cursorBlinkRate<0&&(t.cursorDiv.style.visibility="hidden")}}function Ee(e,t){e.doc.mode.startState&&e.doc.frontier<e.display.viewTo&&e.state.highlight.set(t,Hi(ze,e))}function ze(e){var t=e.doc;if(t.frontier<t.first&&(t.frontier=t.first),!(t.frontier>=e.display.viewTo)){var r=+new Date+e.options.workTime,n=el(t.mode,Re(e,t.frontier)),i=[];t.iter(t.frontier,Math.min(t.first+t.size,e.display.viewTo+500),function(o){if(t.frontier>=e.display.viewFrom){var l=o.styles,s=An(e,o,n,!0);o.styles=s.styles;var a=o.styleClasses,u=s.classes;u?o.styleClasses=u:a&&(o.styleClasses=null);for(var c=!l||l.length!=o.styles.length||a!=u&&(!a||!u||a.bgClass!=u.bgClass||a.textClass!=u.textClass),f=0;!c&&f<l.length;++f)c=l[f]!=o.styles[f];c&&i.push(t.frontier),o.stateAfter=el(t.mode,n)}else On(e,o.text,n),o.stateAfter=t.frontier%5==0?el(t.mode,n):null;return++t.frontier,+new Date>r?(Ee(e,e.options.workDelay),!0):void 0}),i.length&&Tt(e,function(){for(var t=0;t<i.length;t++)Ht(e,i[t],"text")})}}function Fe(e,t,r){for(var n,i,o=e.doc,l=r?-1:t-(e.doc.mode.innerMode?1e3:100),s=t;s>l;--s){if(s<=o.first)return o.first;var a=Xn(o,s-1);if(a.stateAfter&&(!r||s<=o.frontier))return s;var u=Ol(a.text,null,e.options.tabSize);(null==i||n>u)&&(i=s-1,n=u)}return i}function Re(e,t,r){var n=e.doc,i=e.display;if(!n.mode.startState)return!0;var o=Fe(e,t,r),l=o>n.first&&Xn(n,o-1).stateAfter;return l=l?el(n.mode,l):tl(n.mode),n.iter(o,t,function(r){On(e,r.text,l);var s=o==t-1||o%5==0||o>=i.viewFrom&&o<i.viewTo;r.stateAfter=s?el(n.mode,l):null,++o}),r&&(n.frontier=o),l}function Be(e){return e.lineSpace.offsetTop}function Ge(e){return e.mover.offsetHeight-e.lineSpace.offsetHeight}function Ue(e){if(e.cachedPaddingH)return e.cachedPaddingH;var t=Ri(e.measure,zi("pre","x")),r=window.getComputedStyle?window.getComputedStyle(t):t.currentStyle,n={left:parseInt(r.paddingLeft),right:parseInt(r.paddingRight)};return isNaN(n.left)||isNaN(n.right)||(e.cachedPaddingH=n),n}function Ve(e){return Tl-e.display.nativeBarWidth}function Ke(e){return e.display.scroller.clientWidth-Ve(e)-e.display.barWidth}function je(e){return e.display.scroller.clientHeight-Ve(e)-e.display.barHeight}function Xe(e,t,r){var n=e.options.lineWrapping,i=n&&Ke(e);if(!t.measure.heights||n&&t.measure.width!=i){var o=t.measure.heights=[];if(n){t.measure.width=i;for(var l=t.text.firstChild.getClientRects(),s=0;s<l.length-1;s++){var a=l[s],u=l[s+1];Math.abs(a.bottom-u.bottom)>2&&o.push((a.bottom+u.top)/2-r.top)}}o.push(r.bottom-r.top)}}function _e(e,t,r){if(e.line==t)return{map:e.measure.map,cache:e.measure.cache};for(var n=0;n<e.rest.length;n++)if(e.rest[n]==t)return{map:e.measure.maps[n],cache:e.measure.caches[n]};for(var n=0;n<e.rest.length;n++)if(qn(e.rest[n])>r)return{map:e.measure.maps[n],cache:e.measure.caches[n],before:!0}}function Ye(e,t){t=dn(t);var r=qn(t),n=e.display.externalMeasured=new Wt(e.doc,t,r);n.lineN=r;var i=n.built=Hn(e,n);return n.text=i.pre,Ri(e.display.lineMeasure,i.pre),n}function $e(e,t,r,n){return Qe(e,Ze(e,t),r,n)}function qe(e,t){if(t>=e.display.viewFrom&&t<e.display.viewTo)return e.display.view[Pt(e,t)];var r=e.display.externalMeasured;return r&&t>=r.lineN&&t<r.lineN+r.size?r:void 0}function Ze(e,t){var r=qn(t),n=qe(e,r);n&&!n.text?n=null:n&&n.changes&&P(e,n,r,H(e)),n||(n=Ye(e,t));var i=_e(n,t,r);return{line:t,view:n,rect:null,map:i.map,cache:i.cache,before:i.before,hasHeights:!1}}function Qe(e,t,r,n,i){t.before&&(r=-1);var o,l=r+(n||"");return t.cache.hasOwnProperty(l)?o=t.cache[l]:(t.rect||(t.rect=t.view.text.getBoundingClientRect()),t.hasHeights||(Xe(e,t.view,t.rect),t.hasHeights=!0),o=et(e,t,r,n),o.bogus||(t.cache[l]=o)),{left:o.left,right:o.right,top:i?o.rtop:o.top,bottom:i?o.rbottom:o.bottom}}function Je(e,t,r){for(var n,i,o,l,s=0;s<e.length;s+=3){var a=e[s],u=e[s+1];if(a>t?(i=0,o=1,l="left"):u>t?(i=t-a,o=i+1):(s==e.length-3||t==u&&e[s+3]>t)&&(o=u-a,i=o-1,t>=u&&(l="right")),null!=i){if(n=e[s+2],a==u&&r==(n.insertLeft?"left":"right")&&(l=r),"left"==r&&0==i)for(;s&&e[s-2]==e[s-3]&&e[s-1].insertLeft;)n=e[(s-=3)+2],l="left";if("right"==r&&i==u-a)for(;s<e.length-3&&e[s+3]==e[s+4]&&!e[s+5].insertLeft;)n=e[(s+=3)+2],l="right";break}}return{node:n,start:i,end:o,collapse:l,coverStart:a,coverEnd:u}}function et(e,t,r,n){var i,o=Je(t.map,r,n),l=o.node,s=o.start,a=o.end,u=o.collapse;if(3==l.nodeType){for(var c=0;4>c;c++){for(;s&&Ei(t.line.text.charAt(o.coverStart+s));)--s;for(;o.coverStart+a<o.coverEnd&&Ei(t.line.text.charAt(o.coverStart+a));)++a;if(fo&&9>ho&&0==s&&a==o.coverEnd-o.coverStart)i=l.parentNode.getBoundingClientRect();else if(fo&&e.options.lineWrapping){var f=Il(l,s,a).getClientRects();i=f.length?f["right"==n?f.length-1:0]:Eo}else i=Il(l,s,a).getBoundingClientRect()||Eo;if(i.left||i.right||0==s)break;a=s,s-=1,u="right"}fo&&11>ho&&(i=tt(e.display.measure,i))}else{s>0&&(u=n="right");var f;i=e.options.lineWrapping&&(f=l.getClientRects()).length>1?f["right"==n?f.length-1:0]:l.getBoundingClientRect()}if(fo&&9>ho&&!s&&(!i||!i.left&&!i.right)){var h=l.parentNode.getClientRects()[0];i=h?{left:h.left,right:h.left+vt(e.display),top:h.top,bottom:h.bottom}:Eo}for(var d=i.top-t.rect.top,p=i.bottom-t.rect.top,g=(d+p)/2,v=t.view.measure.heights,c=0;c<v.length-1&&!(g<v[c]);c++);var m=c?v[c-1]:0,y=v[c],b={left:("right"==u?i.right:i.left)-t.rect.left,
|
2 |
-
right:("left"==u?i.left:i.right)-t.rect.left,top:m,bottom:y};return i.left||i.right||(b.bogus=!0),e.options.singleCursorHeightPerLine||(b.rtop=d,b.rbottom=p),b}function tt(e,t){if(!window.screen||null==screen.logicalXDPI||screen.logicalXDPI==screen.deviceXDPI||!Yi(e))return t;var r=screen.logicalXDPI/screen.deviceXDPI,n=screen.logicalYDPI/screen.deviceYDPI;return{left:t.left*r,right:t.right*r,top:t.top*n,bottom:t.bottom*n}}function rt(e){if(e.measure&&(e.measure.cache={},e.measure.heights=null,e.rest))for(var t=0;t<e.rest.length;t++)e.measure.caches[t]={}}function nt(e){e.display.externalMeasure=null,Fi(e.display.lineMeasure);for(var t=0;t<e.display.view.length;t++)rt(e.display.view[t])}function it(e){nt(e),e.display.cachedCharWidth=e.display.cachedTextHeight=e.display.cachedPaddingH=null,e.options.lineWrapping||(e.display.maxLineChanged=!0),e.display.lineNumChars=null}function ot(){return window.pageXOffset||(document.documentElement||document.body).scrollLeft}function lt(){return window.pageYOffset||(document.documentElement||document.body).scrollTop}function st(e,t,r,n){if(t.widgets)for(var i=0;i<t.widgets.length;++i)if(t.widgets[i].above){var o=wn(t.widgets[i]);r.top+=o,r.bottom+=o}if("line"==n)return r;n||(n="local");var l=Qn(t);if("local"==n?l+=Be(e.display):l-=e.display.viewOffset,"page"==n||"window"==n){var s=e.display.lineSpace.getBoundingClientRect();l+=s.top+("window"==n?0:lt());var a=s.left+("window"==n?0:ot());r.left+=a,r.right+=a}return r.top+=l,r.bottom+=l,r}function at(e,t,r){if("div"==r)return t;var n=t.left,i=t.top;if("page"==r)n-=ot(),i-=lt();else if("local"==r||!r){var o=e.display.sizer.getBoundingClientRect();n+=o.left,i+=o.top}var l=e.display.lineSpace.getBoundingClientRect();return{left:n-l.left,top:i-l.top}}function ut(e,t,r,n,i){return n||(n=Xn(e.doc,t.line)),st(e,n,$e(e,n,t.ch,i),r)}function ct(e,t,r,n,i,o){function l(t,l){var s=Qe(e,i,t,l?"right":"left",o);return l?s.left=s.right:s.right=s.left,st(e,n,s,r)}function s(e,t){var r=a[t],n=r.level%2;return e==qi(r)&&t&&r.level<a[t-1].level?(r=a[--t],e=Zi(r)-(r.level%2?0:1),n=!0):e==Zi(r)&&t<a.length-1&&r.level<a[t+1].level&&(r=a[++t],e=qi(r)-r.level%2,n=!1),n&&e==r.to&&e>r.from?l(e-1):l(e,n)}n=n||Xn(e.doc,t.line),i||(i=Ze(e,n));var a=Jn(n),u=t.ch;if(!a)return l(u);var c=io(a,u),f=s(u,c);return null!=ql&&(f.other=s(u,ql)),f}function ft(e,t){var r=0,t=pe(e.doc,t);e.options.lineWrapping||(r=vt(e.display)*t.ch);var n=Xn(e.doc,t.line),i=Qn(n)+Be(e.display);return{left:r,right:r,top:i,bottom:i+n.height}}function ht(e,t,r,n){var i=Wo(e,t);return i.xRel=n,r&&(i.outside=!0),i}function dt(e,t,r){var n=e.doc;if(r+=e.display.viewOffset,0>r)return ht(n.first,0,!0,-1);var i=Zn(n,r),o=n.first+n.size-1;if(i>o)return ht(n.first+n.size-1,Xn(n,o).text.length,!0,1);0>t&&(t=0);for(var l=Xn(n,i);;){var s=pt(e,l,i,t,r),a=fn(l),u=a&&a.find(0,!0);if(!a||!(s.ch>u.from.ch||s.ch==u.from.ch&&s.xRel>0))return s;i=qn(l=u.to.line)}}function pt(e,t,r,n,i){function o(n){var i=ct(e,Wo(r,n),"line",t,u);return s=!0,l>i.bottom?i.left-a:l<i.top?i.left+a:(s=!1,i.left)}var l=i-Qn(t),s=!1,a=2*e.display.wrapper.clientWidth,u=Ze(e,t),c=Jn(t),f=t.text.length,h=Qi(t),d=Ji(t),p=o(h),g=s,v=o(d),m=s;if(n>v)return ht(r,d,m,1);for(;;){if(c?d==h||d==lo(t,h,1):1>=d-h){for(var y=p>n||v-n>=n-p?h:d,b=n-(y==h?p:v);Ei(t.text.charAt(y));)++y;var w=ht(r,y,y==h?g:m,-1>b?-1:b>1?1:0);return w}var x=Math.ceil(f/2),C=h+x;if(c){C=h;for(var S=0;x>S;++S)C=lo(t,C,1)}var L=o(C);L>n?(d=C,v=L,(m=s)&&(v+=1e3),f=x):(h=C,p=L,g=s,f-=x)}}function gt(e){if(null!=e.cachedTextHeight)return e.cachedTextHeight;if(null==Ho){Ho=zi("pre");for(var t=0;49>t;++t)Ho.appendChild(document.createTextNode("x")),Ho.appendChild(zi("br"));Ho.appendChild(document.createTextNode("x"))}Ri(e.measure,Ho);var r=Ho.offsetHeight/50;return r>3&&(e.cachedTextHeight=r),Fi(e.measure),r||1}function vt(e){if(null!=e.cachedCharWidth)return e.cachedCharWidth;var t=zi("span","xxxxxxxxxx"),r=zi("pre",[t]);Ri(e.measure,r);var n=t.getBoundingClientRect(),i=(n.right-n.left)/10;return i>2&&(e.cachedCharWidth=i),i||10}function mt(e){e.curOp={cm:e,viewChanged:!1,startHeight:e.doc.height,forceUpdate:!1,updateInput:null,typing:!1,changeObjs:null,cursorActivityHandlers:null,cursorActivityCalled:0,selectionChanged:!1,updateMaxLine:!1,scrollLeft:null,scrollTop:null,scrollToPos:null,focus:!1,id:++Fo},zo?zo.ops.push(e.curOp):e.curOp.ownsGroup=zo={ops:[e.curOp],delayedCallbacks:[]}}function yt(e){var t=e.delayedCallbacks,r=0;do{for(;r<t.length;r++)t[r]();for(var n=0;n<e.ops.length;n++){var i=e.ops[n];if(i.cursorActivityHandlers)for(;i.cursorActivityCalled<i.cursorActivityHandlers.length;)i.cursorActivityHandlers[i.cursorActivityCalled++](i.cm)}}while(r<t.length)}function bt(e){var t=e.curOp,r=t.ownsGroup;if(r)try{yt(r)}finally{zo=null;for(var n=0;n<r.ops.length;n++)r.ops[n].cm.curOp=null;wt(r)}}function wt(e){for(var t=e.ops,r=0;r<t.length;r++)xt(t[r]);for(var r=0;r<t.length;r++)Ct(t[r]);for(var r=0;r<t.length;r++)St(t[r]);for(var r=0;r<t.length;r++)Lt(t[r]);for(var r=0;r<t.length;r++)kt(t[r])}function xt(e){var t=e.cm,r=t.display;T(t),e.updateMaxLine&&h(t),e.mustUpdate=e.viewChanged||e.forceUpdate||null!=e.scrollTop||e.scrollToPos&&(e.scrollToPos.from.line<r.viewFrom||e.scrollToPos.to.line>=r.viewTo)||r.maxLineChanged&&t.options.lineWrapping,e.update=e.mustUpdate&&new k(t,e.mustUpdate&&{top:e.scrollTop,ensure:e.scrollToPos},e.forceUpdate)}function Ct(e){e.updatedDisplay=e.mustUpdate&&M(e.cm,e.update)}function St(e){var t=e.cm,r=t.display;e.updatedDisplay&&O(t),e.barMeasure=p(t),r.maxLineChanged&&!t.options.lineWrapping&&(e.adjustWidthTo=$e(t,r.maxLine,r.maxLine.text.length).left+3,t.display.sizerWidth=e.adjustWidthTo,e.barMeasure.scrollWidth=Math.max(r.scroller.clientWidth,r.sizer.offsetLeft+e.adjustWidthTo+Ve(t)+t.display.barWidth),e.maxScrollLeft=Math.max(0,r.sizer.offsetLeft+e.adjustWidthTo-Ke(t))),(e.updatedDisplay||e.selectionChanged)&&(e.preparedSelection=r.input.prepareSelection())}function Lt(e){var t=e.cm;null!=e.adjustWidthTo&&(t.display.sizer.style.minWidth=e.adjustWidthTo+"px",e.maxScrollLeft<t.doc.scrollLeft&&Jt(t,Math.min(t.display.scroller.scrollLeft,e.maxScrollLeft),!0),t.display.maxLineChanged=!1),e.preparedSelection&&t.display.input.showSelection(e.preparedSelection),e.updatedDisplay&&W(t,e.barMeasure),(e.updatedDisplay||e.startHeight!=t.doc.height)&&y(t,e.barMeasure),e.selectionChanged&&Pe(t),t.state.focused&&e.updateInput&&t.display.input.reset(e.typing),e.focus&&e.focus==Bi()&&q(e.cm)}function kt(e){var t=e.cm,r=t.display,n=t.doc;if(e.updatedDisplay&&N(t,e.update),null==r.wheelStartX||null==e.scrollTop&&null==e.scrollLeft&&!e.scrollToPos||(r.wheelStartX=r.wheelStartY=null),null==e.scrollTop||r.scroller.scrollTop==e.scrollTop&&!e.forceScroll||(n.scrollTop=Math.max(0,Math.min(r.scroller.scrollHeight-r.scroller.clientHeight,e.scrollTop)),r.scrollbars.setScrollTop(n.scrollTop),r.scroller.scrollTop=n.scrollTop),null==e.scrollLeft||r.scroller.scrollLeft==e.scrollLeft&&!e.forceScroll||(n.scrollLeft=Math.max(0,Math.min(r.scroller.scrollWidth-Ke(t),e.scrollLeft)),r.scrollbars.setScrollLeft(n.scrollLeft),r.scroller.scrollLeft=n.scrollLeft,x(t)),e.scrollToPos){var i=Nr(t,pe(n,e.scrollToPos.from),pe(n,e.scrollToPos.to),e.scrollToPos.margin);e.scrollToPos.isCursor&&t.state.focused&&Mr(t,i)}var o=e.maybeHiddenMarkers,l=e.maybeUnhiddenMarkers;if(o)for(var s=0;s<o.length;++s)o[s].lines.length||Ll(o[s],"hide");if(l)for(var s=0;s<l.length;++s)l[s].lines.length&&Ll(l[s],"unhide");r.wrapper.offsetHeight&&(n.scrollTop=t.display.scroller.scrollTop),e.changeObjs&&Ll(t,"changes",t,e.changeObjs),e.update&&e.update.finish()}function Tt(e,t){if(e.curOp)return t();mt(e);try{return t()}finally{bt(e)}}function Mt(e,t){return function(){if(e.curOp)return t.apply(e,arguments);mt(e);try{return t.apply(e,arguments)}finally{bt(e)}}}function Nt(e){return function(){if(this.curOp)return e.apply(this,arguments);mt(this);try{return e.apply(this,arguments)}finally{bt(this)}}}function At(e){return function(){var t=this.cm;if(!t||t.curOp)return e.apply(this,arguments);mt(t);try{return e.apply(this,arguments)}finally{bt(t)}}}function Wt(e,t,r){this.line=t,this.rest=pn(t),this.size=this.rest?qn(Mi(this.rest))-r+1:1,this.node=this.text=null,this.hidden=mn(e,t)}function Ot(e,t,r){for(var n,i=[],o=t;r>o;o=n){var l=new Wt(e.doc,Xn(e.doc,o),o);n=o+l.size,i.push(l)}return i}function Dt(e,t,r,n){null==t&&(t=e.doc.first),null==r&&(r=e.doc.first+e.doc.size),n||(n=0);var i=e.display;if(n&&r<i.viewTo&&(null==i.updateLineNumbers||i.updateLineNumbers>t)&&(i.updateLineNumbers=t),e.curOp.viewChanged=!0,t>=i.viewTo)Ao&&gn(e.doc,t)<i.viewTo&&It(e);else if(r<=i.viewFrom)Ao&&vn(e.doc,r+n)>i.viewFrom?It(e):(i.viewFrom+=n,i.viewTo+=n);else if(t<=i.viewFrom&&r>=i.viewTo)It(e);else if(t<=i.viewFrom){var o=Et(e,r,r+n,1);o?(i.view=i.view.slice(o.index),i.viewFrom=o.lineN,i.viewTo+=n):It(e)}else if(r>=i.viewTo){var o=Et(e,t,t,-1);o?(i.view=i.view.slice(0,o.index),i.viewTo=o.lineN):It(e)}else{var l=Et(e,t,t,-1),s=Et(e,r,r+n,1);l&&s?(i.view=i.view.slice(0,l.index).concat(Ot(e,l.lineN,s.lineN)).concat(i.view.slice(s.index)),i.viewTo+=n):It(e)}var a=i.externalMeasured;a&&(r<a.lineN?a.lineN+=n:t<a.lineN+a.size&&(i.externalMeasured=null))}function Ht(e,t,r){e.curOp.viewChanged=!0;var n=e.display,i=e.display.externalMeasured;if(i&&t>=i.lineN&&t<i.lineN+i.size&&(n.externalMeasured=null),!(t<n.viewFrom||t>=n.viewTo)){var o=n.view[Pt(e,t)];if(null!=o.node){var l=o.changes||(o.changes=[]);-1==Ni(l,r)&&l.push(r)}}}function It(e){e.display.viewFrom=e.display.viewTo=e.doc.first,e.display.view=[],e.display.viewOffset=0}function Pt(e,t){if(t>=e.display.viewTo)return null;if(t-=e.display.viewFrom,0>t)return null;for(var r=e.display.view,n=0;n<r.length;n++)if(t-=r[n].size,0>t)return n}function Et(e,t,r,n){var i,o=Pt(e,t),l=e.display.view;if(!Ao||r==e.doc.first+e.doc.size)return{index:o,lineN:r};for(var s=0,a=e.display.viewFrom;o>s;s++)a+=l[s].size;if(a!=t){if(n>0){if(o==l.length-1)return null;i=a+l[o].size-t,o++}else i=a-t;t+=i,r+=i}for(;gn(e.doc,r)!=r;){if(o==(0>n?0:l.length-1))return null;r+=n*l[o-(0>n?1:0)].size,o+=n}return{index:o,lineN:r}}function zt(e,t,r){var n=e.display,i=n.view;0==i.length||t>=n.viewTo||r<=n.viewFrom?(n.view=Ot(e,t,r),n.viewFrom=t):(n.viewFrom>t?n.view=Ot(e,t,n.viewFrom).concat(n.view):n.viewFrom<t&&(n.view=n.view.slice(Pt(e,t))),n.viewFrom=t,n.viewTo<r?n.view=n.view.concat(Ot(e,n.viewTo,r)):n.viewTo>r&&(n.view=n.view.slice(0,Pt(e,r)))),n.viewTo=r}function Ft(e){for(var t=e.display.view,r=0,n=0;n<t.length;n++){var i=t[n];i.hidden||i.node&&!i.changes||++r}return r}function Rt(e){function t(){i.activeTouch&&(o=setTimeout(function(){i.activeTouch=null},1e3),l=i.activeTouch,l.end=+new Date)}function r(e){if(1!=e.touches.length)return!1;var t=e.touches[0];return t.radiusX<=1&&t.radiusY<=1}function n(e,t){if(null==t.left)return!0;var r=t.left-e.left,n=t.top-e.top;return r*r+n*n>400}var i=e.display;Cl(i.scroller,"mousedown",Mt(e,Kt)),fo&&11>ho?Cl(i.scroller,"dblclick",Mt(e,function(t){if(!wi(e,t)){var r=Vt(e,t);if(r&&!$t(e,t)&&!Ut(e.display,t)){bl(t);var n=e.findWordAt(r);be(e.doc,n.anchor,n.head)}}})):Cl(i.scroller,"dblclick",function(t){wi(e,t)||bl(t)}),Mo||Cl(i.scroller,"contextmenu",function(t){dr(e,t)});var o,l={end:0};Cl(i.scroller,"touchstart",function(e){if(!r(e)){clearTimeout(o);var t=+new Date;i.activeTouch={start:t,moved:!1,prev:t-l.end<=300?l:null},1==e.touches.length&&(i.activeTouch.left=e.touches[0].pageX,i.activeTouch.top=e.touches[0].pageY)}}),Cl(i.scroller,"touchmove",function(){i.activeTouch&&(i.activeTouch.moved=!0)}),Cl(i.scroller,"touchend",function(r){var o=i.activeTouch;if(o&&!Ut(i,r)&&null!=o.left&&!o.moved&&new Date-o.start<300){var l,s=e.coordsChar(i.activeTouch,"page");l=!o.prev||n(o,o.prev)?new ce(s,s):!o.prev.prev||n(o,o.prev.prev)?e.findWordAt(s):new ce(Wo(s.line,0),pe(e.doc,Wo(s.line+1,0))),e.setSelection(l.anchor,l.head),e.focus(),bl(r)}t()}),Cl(i.scroller,"touchcancel",t),Cl(i.scroller,"scroll",function(){i.scroller.clientHeight&&(Qt(e,i.scroller.scrollTop),Jt(e,i.scroller.scrollLeft,!0),Ll(e,"scroll",e))}),Cl(i.scroller,"mousewheel",function(t){er(e,t)}),Cl(i.scroller,"DOMMouseScroll",function(t){er(e,t)}),Cl(i.wrapper,"scroll",function(){i.wrapper.scrollTop=i.wrapper.scrollLeft=0}),i.dragFunctions={simple:function(t){wi(e,t)||xl(t)},start:function(t){Zt(e,t)},drop:Mt(e,qt)};var s=i.input.getField();Cl(s,"keyup",function(t){ar.call(e,t)}),Cl(s,"keydown",Mt(e,lr)),Cl(s,"keypress",Mt(e,ur)),Cl(s,"focus",Hi(fr,e)),Cl(s,"blur",Hi(hr,e))}function Bt(t,r,n){var i=n&&n!=e.Init;if(!r!=!i){var o=t.display.dragFunctions,l=r?Cl:Sl;l(t.display.scroller,"dragstart",o.start),l(t.display.scroller,"dragenter",o.simple),l(t.display.scroller,"dragover",o.simple),l(t.display.scroller,"drop",o.drop)}}function Gt(e){var t=e.display;(t.lastWrapHeight!=t.wrapper.clientHeight||t.lastWrapWidth!=t.wrapper.clientWidth)&&(t.cachedCharWidth=t.cachedTextHeight=t.cachedPaddingH=null,t.scrollbarsClipped=!1,e.setSize())}function Ut(e,t){for(var r=vi(t);r!=e.wrapper;r=r.parentNode)if(!r||1==r.nodeType&&"true"==r.getAttribute("cm-ignore-events")||r.parentNode==e.sizer&&r!=e.mover)return!0}function Vt(e,t,r,n){var i=e.display;if(!r&&"true"==vi(t).getAttribute("cm-not-content"))return null;var o,l,s=i.lineSpace.getBoundingClientRect();try{o=t.clientX-s.left,l=t.clientY-s.top}catch(t){return null}var a,u=dt(e,o,l);if(n&&1==u.xRel&&(a=Xn(e.doc,u.line).text).length==u.ch){var c=Ol(a,a.length,e.options.tabSize)-a.length;u=Wo(u.line,Math.max(0,Math.round((o-Ue(e.display).left)/vt(e.display))-c))}return u}function Kt(e){var t=this,r=t.display;if(!(r.activeTouch&&r.input.supportsTouch()||wi(t,e))){if(r.shift=e.shiftKey,Ut(r,e))return void(po||(r.scroller.draggable=!1,setTimeout(function(){r.scroller.draggable=!0},100)));if(!$t(t,e)){var n=Vt(t,e);switch(window.focus(),mi(e)){case 1:n?jt(t,e,n):vi(e)==r.scroller&&bl(e);break;case 2:po&&(t.state.lastMiddleDown=+new Date),n&&be(t.doc,n),setTimeout(function(){r.input.focus()},20),bl(e);break;case 3:Mo?dr(t,e):cr(t)}}}}function jt(e,t,r){fo?setTimeout(Hi(q,e),0):e.curOp.focus=Bi();var n,i=+new Date;Po&&Po.time>i-400&&0==Oo(Po.pos,r)?n="triple":Io&&Io.time>i-400&&0==Oo(Io.pos,r)?(n="double",Po={time:i,pos:r}):(n="single",Io={time:i,pos:r});var o,l=e.doc.sel,s=So?t.metaKey:t.ctrlKey;e.options.dragDrop&&Kl&&!Z(e)&&"single"==n&&(o=l.contains(r))>-1&&!l.ranges[o].empty()?Xt(e,t,r,s):_t(e,t,r,n,s)}function Xt(e,t,r,n){var i=e.display,o=+new Date,l=Mt(e,function(s){po&&(i.scroller.draggable=!1),e.state.draggingText=!1,Sl(document,"mouseup",l),Sl(i.scroller,"drop",l),Math.abs(t.clientX-s.clientX)+Math.abs(t.clientY-s.clientY)<10&&(bl(s),!n&&+new Date-200<o&&be(e.doc,r),po||fo&&9==ho?setTimeout(function(){document.body.focus(),i.input.focus()},20):i.input.focus())});po&&(i.scroller.draggable=!0),e.state.draggingText=l,i.scroller.dragDrop&&i.scroller.dragDrop(),Cl(document,"mouseup",l),Cl(i.scroller,"drop",l)}function _t(e,t,r,n,i){function o(t){if(0!=Oo(v,t))if(v=t,"rect"==n){for(var i=[],o=e.options.tabSize,l=Ol(Xn(u,r.line).text,r.ch,o),s=Ol(Xn(u,t.line).text,t.ch,o),a=Math.min(l,s),d=Math.max(l,s),p=Math.min(r.line,t.line),g=Math.min(e.lastLine(),Math.max(r.line,t.line));g>=p;p++){var m=Xn(u,p).text,y=ki(m,a,o);a==d?i.push(new ce(Wo(p,y),Wo(p,y))):m.length>y&&i.push(new ce(Wo(p,y),Wo(p,ki(m,d,o))))}i.length||i.push(new ce(r,r)),ke(u,fe(h.ranges.slice(0,f).concat(i),f),{origin:"*mouse",scroll:!1}),e.scrollIntoView(t)}else{var b=c,w=b.anchor,x=t;if("single"!=n){if("double"==n)var C=e.findWordAt(t);else var C=new ce(Wo(t.line,0),pe(u,Wo(t.line+1,0)));Oo(C.anchor,w)>0?(x=C.head,w=$(b.from(),C.anchor)):(x=C.anchor,w=Y(b.to(),C.head))}var i=h.ranges.slice(0);i[f]=new ce(pe(u,w),x),ke(u,fe(i,f),Al)}}function l(t){var r=++y,i=Vt(e,t,!0,"rect"==n);if(i)if(0!=Oo(i,v)){e.curOp.focus=Bi(),o(i);var s=w(a,u);(i.line>=s.to||i.line<s.from)&&setTimeout(Mt(e,function(){y==r&&l(t)}),150)}else{var c=t.clientY<m.top?-20:t.clientY>m.bottom?20:0;c&&setTimeout(Mt(e,function(){y==r&&(a.scroller.scrollTop+=c,l(t))}),50)}}function s(e){y=1/0,bl(e),a.input.focus(),Sl(document,"mousemove",b),Sl(document,"mouseup",x),u.history.lastSelOrigin=null}var a=e.display,u=e.doc;bl(t);var c,f,h=u.sel,d=h.ranges;if(i&&!t.shiftKey?(f=u.sel.contains(r),c=f>-1?d[f]:new ce(r,r)):(c=u.sel.primary(),f=u.sel.primIndex),t.altKey)n="rect",i||(c=new ce(r,r)),r=Vt(e,t,!0,!0),f=-1;else if("double"==n){var p=e.findWordAt(r);c=e.display.shift||u.extend?ye(u,c,p.anchor,p.head):p}else if("triple"==n){var g=new ce(Wo(r.line,0),pe(u,Wo(r.line+1,0)));c=e.display.shift||u.extend?ye(u,c,g.anchor,g.head):g}else c=ye(u,c,r);i?-1==f?(f=d.length,ke(u,fe(d.concat([c]),f),{scroll:!1,origin:"*mouse"})):d.length>1&&d[f].empty()&&"single"==n&&!t.shiftKey?(ke(u,fe(d.slice(0,f).concat(d.slice(f+1)),0)),h=u.sel):xe(u,f,c,Al):(f=0,ke(u,new ue([c],0),Al),h=u.sel);var v=r,m=a.wrapper.getBoundingClientRect(),y=0,b=Mt(e,function(e){mi(e)?l(e):s(e)}),x=Mt(e,s);Cl(document,"mousemove",b),Cl(document,"mouseup",x)}function Yt(e,t,r,n,i){try{var o=t.clientX,l=t.clientY}catch(t){return!1}if(o>=Math.floor(e.display.gutters.getBoundingClientRect().right))return!1;n&&bl(t);var s=e.display,a=s.lineDiv.getBoundingClientRect();if(l>a.bottom||!Ci(e,r))return gi(t);l-=a.top-s.viewOffset;for(var u=0;u<e.options.gutters.length;++u){var c=s.gutters.childNodes[u];if(c&&c.getBoundingClientRect().right>=o){var f=Zn(e.doc,l),h=e.options.gutters[u];return i(e,r,e,f,h,t),gi(t)}}}function $t(e,t){return Yt(e,t,"gutterClick",!0,yi)}function qt(e){var t=this;if(!wi(t,e)&&!Ut(t.display,e)){bl(e),fo&&(Ro=+new Date);var r=Vt(t,e,!0),n=e.dataTransfer.files;if(r&&!Z(t))if(n&&n.length&&window.FileReader&&window.File)for(var i=n.length,o=Array(i),l=0,s=function(e,n){var s=new FileReader;s.onload=Mt(t,function(){if(o[n]=s.result,++l==i){r=pe(t.doc,r);var e={from:r,to:r,text:jl(o.join("\n")),origin:"paste"};wr(t.doc,e),Le(t.doc,he(r,jo(e)))}}),s.readAsText(e)},a=0;i>a;++a)s(n[a],a);else{if(t.state.draggingText&&t.doc.sel.contains(r)>-1)return t.state.draggingText(e),void setTimeout(function(){t.display.input.focus()},20);try{var o=e.dataTransfer.getData("Text");if(o){if(t.state.draggingText&&!(So?e.altKey:e.ctrlKey))var u=t.listSelections();if(Te(t.doc,he(r,r)),u)for(var a=0;a<u.length;++a)Tr(t.doc,"",u[a].anchor,u[a].head,"drag");t.replaceSelection(o,"around","paste"),t.display.input.focus()}}catch(e){}}}}function Zt(e,t){if(fo&&(!e.state.draggingText||+new Date-Ro<100))return void xl(t);if(!wi(e,t)&&!Ut(e.display,t)&&(t.dataTransfer.setData("Text",e.getSelection()),t.dataTransfer.setDragImage&&!yo)){var r=zi("img",null,null,"position: fixed; left: 0; top: 0;");r.src="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==",mo&&(r.width=r.height=1,e.display.wrapper.appendChild(r),r._top=r.offsetTop),t.dataTransfer.setDragImage(r,0,0),mo&&r.parentNode.removeChild(r)}}function Qt(e,t){Math.abs(e.doc.scrollTop-t)<2||(e.doc.scrollTop=t,ao||A(e,{top:t}),e.display.scroller.scrollTop!=t&&(e.display.scroller.scrollTop=t),e.display.scrollbars.setScrollTop(t),ao&&A(e),Ee(e,100))}function Jt(e,t,r){(r?t==e.doc.scrollLeft:Math.abs(e.doc.scrollLeft-t)<2)||(t=Math.min(t,e.display.scroller.scrollWidth-e.display.scroller.clientWidth),e.doc.scrollLeft=t,x(e),e.display.scroller.scrollLeft!=t&&(e.display.scroller.scrollLeft=t),e.display.scrollbars.setScrollLeft(t))}function er(e,t){var r=Uo(t),n=r.x,i=r.y,o=e.display,l=o.scroller;if(n&&l.scrollWidth>l.clientWidth||i&&l.scrollHeight>l.clientHeight){if(i&&So&&po)e:for(var s=t.target,a=o.view;s!=l;s=s.parentNode)for(var u=0;u<a.length;u++)if(a[u].node==s){e.display.currentWheelTarget=s;break e}if(n&&!ao&&!mo&&null!=Go)return i&&Qt(e,Math.max(0,Math.min(l.scrollTop+i*Go,l.scrollHeight-l.clientHeight))),Jt(e,Math.max(0,Math.min(l.scrollLeft+n*Go,l.scrollWidth-l.clientWidth))),bl(t),void(o.wheelStartX=null);if(i&&null!=Go){var c=i*Go,f=e.doc.scrollTop,h=f+o.wrapper.clientHeight;0>c?f=Math.max(0,f+c-50):h=Math.min(e.doc.height,h+c+50),A(e,{top:f,bottom:h})}20>Bo&&(null==o.wheelStartX?(o.wheelStartX=l.scrollLeft,o.wheelStartY=l.scrollTop,o.wheelDX=n,o.wheelDY=i,setTimeout(function(){if(null!=o.wheelStartX){var e=l.scrollLeft-o.wheelStartX,t=l.scrollTop-o.wheelStartY,r=t&&o.wheelDY&&t/o.wheelDY||e&&o.wheelDX&&e/o.wheelDX;o.wheelStartX=o.wheelStartY=null,r&&(Go=(Go*Bo+r)/(Bo+1),++Bo)}},200)):(o.wheelDX+=n,o.wheelDY+=i))}}function tr(e,t,r){if("string"==typeof t&&(t=rl[t],!t))return!1;e.display.input.ensurePolled();var n=e.display.shift,i=!1;try{Z(e)&&(e.state.suppressEdits=!0),r&&(e.display.shift=!1),i=t(e)!=Ml}finally{e.display.shift=n,e.state.suppressEdits=!1}return i}function rr(e,t,r){for(var n=0;n<e.state.keyMaps.length;n++){var i=il(t,e.state.keyMaps[n],r,e);if(i)return i}return e.options.extraKeys&&il(t,e.options.extraKeys,r,e)||il(t,e.options.keyMap,r,e)}function nr(e,t,r,n){var i=e.state.keySeq;if(i){if(ol(t))return"handled";Vo.set(50,function(){e.state.keySeq==i&&(e.state.keySeq=null,e.display.input.reset())}),t=i+" "+t}var o=rr(e,t,n);return"multi"==o&&(e.state.keySeq=t),"handled"==o&&yi(e,"keyHandled",e,t,r),("handled"==o||"multi"==o)&&(bl(r),Pe(e)),i&&!o&&/\'$/.test(t)?(bl(r),!0):!!o}function ir(e,t){var r=ll(t,!0);return r?t.shiftKey&&!e.state.keySeq?nr(e,"Shift-"+r,t,function(t){return tr(e,t,!0)})||nr(e,r,t,function(t){return("string"==typeof t?/^go[A-Z]/.test(t):t.motion)?tr(e,t):void 0}):nr(e,r,t,function(t){return tr(e,t)}):!1}function or(e,t,r){return nr(e,"'"+r+"'",t,function(t){return tr(e,t,!0)})}function lr(e){var t=this;if(t.curOp.focus=Bi(),!wi(t,e)){fo&&11>ho&&27==e.keyCode&&(e.returnValue=!1);var r=e.keyCode;t.display.shift=16==r||e.shiftKey;var n=ir(t,e);mo&&(Ko=n?r:null,!n&&88==r&&!_l&&(So?e.metaKey:e.ctrlKey)&&t.replaceSelection("",null,"cut")),18!=r||/\bCodeMirror-crosshair\b/.test(t.display.lineDiv.className)||sr(t)}}function sr(e){function t(e){18!=e.keyCode&&e.altKey||(Gl(r,"CodeMirror-crosshair"),Sl(document,"keyup",t),Sl(document,"mouseover",t))}var r=e.display.lineDiv;Ul(r,"CodeMirror-crosshair"),Cl(document,"keyup",t),Cl(document,"mouseover",t)}function ar(e){16==e.keyCode&&(this.doc.sel.shift=!1),wi(this,e)}function ur(e){var t=this;if(!(Ut(t.display,e)||wi(t,e)||e.ctrlKey&&!e.altKey||So&&e.metaKey)){var r=e.keyCode,n=e.charCode;if(mo&&r==Ko)return Ko=null,void bl(e);if(!mo||e.which&&!(e.which<10)||!ir(t,e)){var i=String.fromCharCode(null==n?r:n);or(t,e,i)||t.display.input.onKeyPress(e)}}}function cr(e){e.state.delayingBlurEvent=!0,setTimeout(function(){e.state.delayingBlurEvent&&(e.state.delayingBlurEvent=!1,hr(e))},100)}function fr(e){e.state.delayingBlurEvent&&(e.state.delayingBlurEvent=!1),"nocursor"!=e.options.readOnly&&(e.state.focused||(Ll(e,"focus",e),e.state.focused=!0,Ul(e.display.wrapper,"CodeMirror-focused"),e.curOp||e.display.selForContextMenu==e.doc.sel||(e.display.input.reset(),po&&setTimeout(function(){e.display.input.reset(!0)},20)),e.display.input.receivedFocus()),Pe(e))}function hr(e){e.state.delayingBlurEvent||(e.state.focused&&(Ll(e,"blur",e),e.state.focused=!1,Gl(e.display.wrapper,"CodeMirror-focused")),clearInterval(e.display.blinker),setTimeout(function(){e.state.focused||(e.display.shift=!1)},150))}function dr(e,t){Ut(e.display,t)||pr(e,t)||e.display.input.onContextMenu(t)}function pr(e,t){return Ci(e,"gutterContextMenu")?Yt(e,t,"gutterContextMenu",!1,Ll):!1}function gr(e,t){if(Oo(e,t.from)<0)return e;if(Oo(e,t.to)<=0)return jo(t);var r=e.line+t.text.length-(t.to.line-t.from.line)-1,n=e.ch;return e.line==t.to.line&&(n+=jo(t).ch-t.to.ch),Wo(r,n)}function vr(e,t){for(var r=[],n=0;n<e.sel.ranges.length;n++){var i=e.sel.ranges[n];r.push(new ce(gr(i.anchor,t),gr(i.head,t)))}return fe(r,e.sel.primIndex)}function mr(e,t,r){return e.line==t.line?Wo(r.line,e.ch-t.ch+r.ch):Wo(r.line+(e.line-t.line),e.ch)}function yr(e,t,r){for(var n=[],i=Wo(e.first,0),o=i,l=0;l<t.length;l++){var s=t[l],a=mr(s.from,i,o),u=mr(jo(s),i,o);if(i=s.to,o=u,"around"==r){var c=e.sel.ranges[l],f=Oo(c.head,c.anchor)<0;n[l]=new ce(f?u:a,f?a:u)}else n[l]=new ce(a,a)}return new ue(n,e.sel.primIndex)}function br(e,t,r){var n={canceled:!1,from:t.from,to:t.to,text:t.text,origin:t.origin,cancel:function(){this.canceled=!0}};return r&&(n.update=function(t,r,n,i){t&&(this.from=pe(e,t)),r&&(this.to=pe(e,r)),n&&(this.text=n),void 0!==i&&(this.origin=i)}),Ll(e,"beforeChange",e,n),e.cm&&Ll(e.cm,"beforeChange",e.cm,n),n.canceled?null:{from:n.from,to:n.to,text:n.text,origin:n.origin}}function wr(e,t,r){if(e.cm){if(!e.cm.curOp)return Mt(e.cm,wr)(e,t,r);if(e.cm.state.suppressEdits)return}if(!(Ci(e,"beforeChange")||e.cm&&Ci(e.cm,"beforeChange"))||(t=br(e,t,!0))){var n=No&&!r&&rn(e,t.from,t.to);if(n)for(var i=n.length-1;i>=0;--i)xr(e,{from:n[i].from,to:n[i].to,text:i?[""]:t.text});else xr(e,t)}}function xr(e,t){if(1!=t.text.length||""!=t.text[0]||0!=Oo(t.from,t.to)){var r=vr(e,t);ii(e,t,r,e.cm?e.cm.curOp.id:NaN),Lr(e,t,r,Jr(e,t));var n=[];Kn(e,function(e,r){r||-1!=Ni(n,e.history)||(pi(e.history,t),n.push(e.history)),Lr(e,t,null,Jr(e,t))})}}function Cr(e,t,r){if(!e.cm||!e.cm.state.suppressEdits){for(var n,i=e.history,o=e.sel,l="undo"==t?i.done:i.undone,s="undo"==t?i.undone:i.done,a=0;a<l.length&&(n=l[a],r?!n.ranges||n.equals(e.sel):n.ranges);a++);if(a!=l.length){for(i.lastOrigin=i.lastSelOrigin=null;n=l.pop(),n.ranges;){if(si(n,s),r&&!n.equals(e.sel))return void ke(e,n,{clearRedo:!1});o=n}var u=[];si(o,s),s.push({changes:u,generation:i.generation}),i.generation=n.generation||++i.maxGeneration;for(var c=Ci(e,"beforeChange")||e.cm&&Ci(e.cm,"beforeChange"),a=n.changes.length-1;a>=0;--a){var f=n.changes[a];if(f.origin=t,c&&!br(e,f,!1))return void(l.length=0);u.push(ti(e,f));var h=a?vr(e,f):Mi(l);Lr(e,f,h,tn(e,f)),!a&&e.cm&&e.cm.scrollIntoView({from:f.from,to:jo(f)});var d=[];Kn(e,function(e,t){t||-1!=Ni(d,e.history)||(pi(e.history,f),d.push(e.history)),Lr(e,f,null,tn(e,f))})}}}}function Sr(e,t){if(0!=t&&(e.first+=t,e.sel=new ue(Ai(e.sel.ranges,function(e){return new ce(Wo(e.anchor.line+t,e.anchor.ch),Wo(e.head.line+t,e.head.ch))}),e.sel.primIndex),e.cm)){Dt(e.cm,e.first,e.first-t,t);for(var r=e.cm.display,n=r.viewFrom;n<r.viewTo;n++)Ht(e.cm,n,"gutter")}}function Lr(e,t,r,n){if(e.cm&&!e.cm.curOp)return Mt(e.cm,Lr)(e,t,r,n);if(t.to.line<e.first)return void Sr(e,t.text.length-1-(t.to.line-t.from.line));if(!(t.from.line>e.lastLine())){if(t.from.line<e.first){var i=t.text.length-1-(e.first-t.from.line);Sr(e,i),t={from:Wo(e.first,0),to:Wo(t.to.line+i,t.to.ch),text:[Mi(t.text)],origin:t.origin}}var o=e.lastLine();t.to.line>o&&(t={from:t.from,to:Wo(o,Xn(e,o).text.length),text:[t.text[0]],origin:t.origin}),t.removed=_n(e,t.from,t.to),r||(r=vr(e,t)),e.cm?kr(e.cm,t,n):Gn(e,t,n),Te(e,r,Nl)}}function kr(e,t,r){var n=e.doc,i=e.display,l=t.from,s=t.to,a=!1,u=l.line;e.options.lineWrapping||(u=qn(dn(Xn(n,l.line))),n.iter(u,s.line+1,function(e){return e==i.maxLine?(a=!0,!0):void 0})),n.sel.contains(t.from,t.to)>-1&&xi(e),Gn(n,t,r,o(e)),e.options.lineWrapping||(n.iter(u,l.line+t.text.length,function(e){var t=f(e);t>i.maxLineLength&&(i.maxLine=e,i.maxLineLength=t,i.maxLineChanged=!0,a=!1)}),a&&(e.curOp.updateMaxLine=!0)),n.frontier=Math.min(n.frontier,l.line),Ee(e,400);var c=t.text.length-(s.line-l.line)-1;t.full?Dt(e):l.line!=s.line||1!=t.text.length||Bn(e.doc,t)?Dt(e,l.line,s.line+1,c):Ht(e,l.line,"text");var h=Ci(e,"changes"),d=Ci(e,"change");if(d||h){var p={from:l,to:s,text:t.text,removed:t.removed,origin:t.origin};d&&yi(e,"change",e,p),h&&(e.curOp.changeObjs||(e.curOp.changeObjs=[])).push(p)}e.display.selForContextMenu=null}function Tr(e,t,r,n,i){if(n||(n=r),Oo(n,r)<0){var o=n;n=r,r=o}"string"==typeof t&&(t=jl(t)),wr(e,{from:r,to:n,text:t,origin:i})}function Mr(e,t){if(!wi(e,"scrollCursorIntoView")){var r=e.display,n=r.sizer.getBoundingClientRect(),i=null;if(t.top+n.top<0?i=!0:t.bottom+n.top>(window.innerHeight||document.documentElement.clientHeight)&&(i=!1),null!=i&&!wo){var o=zi("div","",null,"position: absolute; top: "+(t.top-r.viewOffset-Be(e.display))+"px; height: "+(t.bottom-t.top+Ve(e)+r.barHeight)+"px; left: "+t.left+"px; width: 2px;");e.display.lineSpace.appendChild(o),o.scrollIntoView(i),e.display.lineSpace.removeChild(o)}}}function Nr(e,t,r,n){null==n&&(n=0);for(var i=0;5>i;i++){var o=!1,l=ct(e,t),s=r&&r!=t?ct(e,r):l,a=Wr(e,Math.min(l.left,s.left),Math.min(l.top,s.top)-n,Math.max(l.left,s.left),Math.max(l.bottom,s.bottom)+n),u=e.doc.scrollTop,c=e.doc.scrollLeft;if(null!=a.scrollTop&&(Qt(e,a.scrollTop),Math.abs(e.doc.scrollTop-u)>1&&(o=!0)),null!=a.scrollLeft&&(Jt(e,a.scrollLeft),Math.abs(e.doc.scrollLeft-c)>1&&(o=!0)),!o)break}return l}function Ar(e,t,r,n,i){var o=Wr(e,t,r,n,i);null!=o.scrollTop&&Qt(e,o.scrollTop),null!=o.scrollLeft&&Jt(e,o.scrollLeft)}function Wr(e,t,r,n,i){var o=e.display,l=gt(e.display);0>r&&(r=0);var s=e.curOp&&null!=e.curOp.scrollTop?e.curOp.scrollTop:o.scroller.scrollTop,a=je(e),u={};i-r>a&&(i=r+a);var c=e.doc.height+Ge(o),f=l>r,h=i>c-l;if(s>r)u.scrollTop=f?0:r;else if(i>s+a){var d=Math.min(r,(h?c:i)-a);d!=s&&(u.scrollTop=d)}var p=e.curOp&&null!=e.curOp.scrollLeft?e.curOp.scrollLeft:o.scroller.scrollLeft,g=Ke(e)-(e.options.fixedGutter?o.gutters.offsetWidth:0),v=n-t>g;return v&&(n=t+g),10>t?u.scrollLeft=0:p>t?u.scrollLeft=Math.max(0,t-(v?0:10)):n>g+p-3&&(u.scrollLeft=n+(v?0:10)-g),u}function Or(e,t,r){(null!=t||null!=r)&&Hr(e),null!=t&&(e.curOp.scrollLeft=(null==e.curOp.scrollLeft?e.doc.scrollLeft:e.curOp.scrollLeft)+t),null!=r&&(e.curOp.scrollTop=(null==e.curOp.scrollTop?e.doc.scrollTop:e.curOp.scrollTop)+r)}function Dr(e){Hr(e);var t=e.getCursor(),r=t,n=t;e.options.lineWrapping||(r=t.ch?Wo(t.line,t.ch-1):t,n=Wo(t.line,t.ch+1)),e.curOp.scrollToPos={from:r,to:n,margin:e.options.cursorScrollMargin,isCursor:!0}}function Hr(e){var t=e.curOp.scrollToPos;if(t){e.curOp.scrollToPos=null;var r=ft(e,t.from),n=ft(e,t.to),i=Wr(e,Math.min(r.left,n.left),Math.min(r.top,n.top)-t.margin,Math.max(r.right,n.right),Math.max(r.bottom,n.bottom)+t.margin);e.scrollTo(i.scrollLeft,i.scrollTop)}}function Ir(e,t,r,n){var i,o=e.doc;null==r&&(r="add"),"smart"==r&&(o.mode.indent?i=Re(e,t):r="prev");var l=e.options.tabSize,s=Xn(o,t),a=Ol(s.text,null,l);s.stateAfter&&(s.stateAfter=null);var u,c=s.text.match(/^\s*/)[0];if(n||/\S/.test(s.text)){if("smart"==r&&(u=o.mode.indent(i,s.text.slice(c.length),s.text),u==Ml||u>150)){if(!n)return;r="prev"}}else u=0,r="not";"prev"==r?u=t>o.first?Ol(Xn(o,t-1).text,null,l):0:"add"==r?u=a+e.options.indentUnit:"subtract"==r?u=a-e.options.indentUnit:"number"==typeof r&&(u=a+r),u=Math.max(0,u);var f="",h=0;if(e.options.indentWithTabs)for(var d=Math.floor(u/l);d;--d)h+=l,f+=" ";if(u>h&&(f+=Ti(u-h)),f!=c)return Tr(o,f,Wo(t,0),Wo(t,c.length),"+input"),s.stateAfter=null,!0;for(var d=0;d<o.sel.ranges.length;d++){var p=o.sel.ranges[d];if(p.head.line==t&&p.head.ch<c.length){var h=Wo(t,c.length);xe(o,d,new ce(h,h));break}}}function Pr(e,t,r,n){var i=t,o=t;return"number"==typeof t?o=Xn(e,de(e,t)):i=qn(t),null==i?null:(n(o,i)&&e.cm&&Ht(e.cm,i,r),o)}function Er(e,t){for(var r=e.doc.sel.ranges,n=[],i=0;i<r.length;i++){for(var o=t(r[i]);n.length&&Oo(o.from,Mi(n).to)<=0;){var l=n.pop();if(Oo(l.from,o.from)<0){o.from=l.from;break}}n.push(o)}Tt(e,function(){for(var t=n.length-1;t>=0;t--)Tr(e.doc,"",n[t].from,n[t].to,"+delete");Dr(e)})}function zr(e,t,r,n,i){function o(){var t=s+r;return t<e.first||t>=e.first+e.size?f=!1:(s=t,c=Xn(e,t))}function l(e){var t=(i?lo:so)(c,a,r,!0);if(null==t){if(e||!o())return f=!1;a=i?(0>r?Ji:Qi)(c):0>r?c.text.length:0}else a=t;return!0}var s=t.line,a=t.ch,u=r,c=Xn(e,s),f=!0;if("char"==n)l();else if("column"==n)l(!0);else if("word"==n||"group"==n)for(var h=null,d="group"==n,p=e.cm&&e.cm.getHelper(t,"wordChars"),g=!0;!(0>r)||l(!g);g=!1){var v=c.text.charAt(a)||"\n",m=Ii(v,p)?"w":d&&"\n"==v?"n":!d||/\s/.test(v)?null:"p";if(!d||g||m||(m="s"),h&&h!=m){0>r&&(r=1,l());break}if(m&&(h=m),r>0&&!l(!g))break}var y=We(e,Wo(s,a),u,!0);return f||(y.hitSide=!0),y}function Fr(e,t,r,n){var i,o=e.doc,l=t.left;if("page"==n){var s=Math.min(e.display.wrapper.clientHeight,window.innerHeight||document.documentElement.clientHeight);
|
3 |
-
i=t.top+r*(s-(0>r?1.5:.5)*gt(e.display))}else"line"==n&&(i=r>0?t.bottom+3:t.top-3);for(;;){var a=dt(e,l,i);if(!a.outside)break;if(0>r?0>=i:i>=o.height){a.hitSide=!0;break}i+=5*r}return a}function Rr(t,r,n,i){e.defaults[t]=r,n&&(_o[t]=i?function(e,t,r){r!=Yo&&n(e,t,r)}:n)}function Br(e){for(var t,r,n,i,o=e.split(/-(?!$)/),e=o[o.length-1],l=0;l<o.length-1;l++){var s=o[l];if(/^(cmd|meta|m)$/i.test(s))i=!0;else if(/^a(lt)?$/i.test(s))t=!0;else if(/^(c|ctrl|control)$/i.test(s))r=!0;else{if(!/^s(hift)$/i.test(s))throw new Error("Unrecognized modifier name: "+s);n=!0}}return t&&(e="Alt-"+e),r&&(e="Ctrl-"+e),i&&(e="Cmd-"+e),n&&(e="Shift-"+e),e}function Gr(e){return"string"==typeof e?nl[e]:e}function Ur(e,t,r,n,i){if(n&&n.shared)return Vr(e,t,r,n,i);if(e.cm&&!e.cm.curOp)return Mt(e.cm,Ur)(e,t,r,n,i);var o=new ul(e,i),l=Oo(t,r);if(n&&Di(n,o,!1),l>0||0==l&&o.clearWhenEmpty!==!1)return o;if(o.replacedWith&&(o.collapsed=!0,o.widgetNode=zi("span",[o.replacedWith],"CodeMirror-widget"),n.handleMouseEvents||o.widgetNode.setAttribute("cm-ignore-events","true"),n.insertLeft&&(o.widgetNode.insertLeft=!0)),o.collapsed){if(hn(e,t.line,t,r,o)||t.line!=r.line&&hn(e,r.line,t,r,o))throw new Error("Inserting collapsed marker partially overlapping an existing one");Ao=!0}o.addToHistory&&ii(e,{from:t,to:r,origin:"markText"},e.sel,NaN);var s,a=t.line,u=e.cm;if(e.iter(a,r.line+1,function(e){u&&o.collapsed&&!u.options.lineWrapping&&dn(e)==u.display.maxLine&&(s=!0),o.collapsed&&a!=t.line&&$n(e,0),qr(e,new _r(o,a==t.line?t.ch:null,a==r.line?r.ch:null)),++a}),o.collapsed&&e.iter(t.line,r.line+1,function(t){mn(e,t)&&$n(t,0)}),o.clearOnEnter&&Cl(o,"beforeCursorEnter",function(){o.clear()}),o.readOnly&&(No=!0,(e.history.done.length||e.history.undone.length)&&e.clearHistory()),o.collapsed&&(o.id=++al,o.atomic=!0),u){if(s&&(u.curOp.updateMaxLine=!0),o.collapsed)Dt(u,t.line,r.line+1);else if(o.className||o.title||o.startStyle||o.endStyle||o.css)for(var c=t.line;c<=r.line;c++)Ht(u,c,"text");o.atomic&&Ne(u.doc),yi(u,"markerAdded",u,o)}return o}function Vr(e,t,r,n,i){n=Di(n),n.shared=!1;var o=[Ur(e,t,r,n,i)],l=o[0],s=n.widgetNode;return Kn(e,function(e){s&&(n.widgetNode=s.cloneNode(!0)),o.push(Ur(e,pe(e,t),pe(e,r),n,i));for(var a=0;a<e.linked.length;++a)if(e.linked[a].isParent)return;l=Mi(o)}),new cl(o,l)}function Kr(e){return e.findMarks(Wo(e.first,0),e.clipPos(Wo(e.lastLine())),function(e){return e.parent})}function jr(e,t){for(var r=0;r<t.length;r++){var n=t[r],i=n.find(),o=e.clipPos(i.from),l=e.clipPos(i.to);if(Oo(o,l)){var s=Ur(e,o,l,n.primary,n.primary.type);n.markers.push(s),s.parent=n}}}function Xr(e){for(var t=0;t<e.length;t++){var r=e[t],n=[r.primary.doc];Kn(r.primary.doc,function(e){n.push(e)});for(var i=0;i<r.markers.length;i++){var o=r.markers[i];-1==Ni(n,o.doc)&&(o.parent=null,r.markers.splice(i--,1))}}}function _r(e,t,r){this.marker=e,this.from=t,this.to=r}function Yr(e,t){if(e)for(var r=0;r<e.length;++r){var n=e[r];if(n.marker==t)return n}}function $r(e,t){for(var r,n=0;n<e.length;++n)e[n]!=t&&(r||(r=[])).push(e[n]);return r}function qr(e,t){e.markedSpans=e.markedSpans?e.markedSpans.concat([t]):[t],t.marker.attachLine(e)}function Zr(e,t,r){if(e)for(var n,i=0;i<e.length;++i){var o=e[i],l=o.marker,s=null==o.from||(l.inclusiveLeft?o.from<=t:o.from<t);if(s||o.from==t&&"bookmark"==l.type&&(!r||!o.marker.insertLeft)){var a=null==o.to||(l.inclusiveRight?o.to>=t:o.to>t);(n||(n=[])).push(new _r(l,o.from,a?null:o.to))}}return n}function Qr(e,t,r){if(e)for(var n,i=0;i<e.length;++i){var o=e[i],l=o.marker,s=null==o.to||(l.inclusiveRight?o.to>=t:o.to>t);if(s||o.from==t&&"bookmark"==l.type&&(!r||o.marker.insertLeft)){var a=null==o.from||(l.inclusiveLeft?o.from<=t:o.from<t);(n||(n=[])).push(new _r(l,a?null:o.from-t,null==o.to?null:o.to-t))}}return n}function Jr(e,t){if(t.full)return null;var r=ve(e,t.from.line)&&Xn(e,t.from.line).markedSpans,n=ve(e,t.to.line)&&Xn(e,t.to.line).markedSpans;if(!r&&!n)return null;var i=t.from.ch,o=t.to.ch,l=0==Oo(t.from,t.to),s=Zr(r,i,l),a=Qr(n,o,l),u=1==t.text.length,c=Mi(t.text).length+(u?i:0);if(s)for(var f=0;f<s.length;++f){var h=s[f];if(null==h.to){var d=Yr(a,h.marker);d?u&&(h.to=null==d.to?null:d.to+c):h.to=i}}if(a)for(var f=0;f<a.length;++f){var h=a[f];if(null!=h.to&&(h.to+=c),null==h.from){var d=Yr(s,h.marker);d||(h.from=c,u&&(s||(s=[])).push(h))}else h.from+=c,u&&(s||(s=[])).push(h)}s&&(s=en(s)),a&&a!=s&&(a=en(a));var p=[s];if(!u){var g,v=t.text.length-2;if(v>0&&s)for(var f=0;f<s.length;++f)null==s[f].to&&(g||(g=[])).push(new _r(s[f].marker,null,null));for(var f=0;v>f;++f)p.push(g);p.push(a)}return p}function en(e){for(var t=0;t<e.length;++t){var r=e[t];null!=r.from&&r.from==r.to&&r.marker.clearWhenEmpty!==!1&&e.splice(t--,1)}return e.length?e:null}function tn(e,t){var r=ci(e,t),n=Jr(e,t);if(!r)return n;if(!n)return r;for(var i=0;i<r.length;++i){var o=r[i],l=n[i];if(o&&l)e:for(var s=0;s<l.length;++s){for(var a=l[s],u=0;u<o.length;++u)if(o[u].marker==a.marker)continue e;o.push(a)}else l&&(r[i]=l)}return r}function rn(e,t,r){var n=null;if(e.iter(t.line,r.line+1,function(e){if(e.markedSpans)for(var t=0;t<e.markedSpans.length;++t){var r=e.markedSpans[t].marker;!r.readOnly||n&&-1!=Ni(n,r)||(n||(n=[])).push(r)}}),!n)return null;for(var i=[{from:t,to:r}],o=0;o<n.length;++o)for(var l=n[o],s=l.find(0),a=0;a<i.length;++a){var u=i[a];if(!(Oo(u.to,s.from)<0||Oo(u.from,s.to)>0)){var c=[a,1],f=Oo(u.from,s.from),h=Oo(u.to,s.to);(0>f||!l.inclusiveLeft&&!f)&&c.push({from:u.from,to:s.from}),(h>0||!l.inclusiveRight&&!h)&&c.push({from:s.to,to:u.to}),i.splice.apply(i,c),a+=c.length-1}}return i}function nn(e){var t=e.markedSpans;if(t){for(var r=0;r<t.length;++r)t[r].marker.detachLine(e);e.markedSpans=null}}function on(e,t){if(t){for(var r=0;r<t.length;++r)t[r].marker.attachLine(e);e.markedSpans=t}}function ln(e){return e.inclusiveLeft?-1:0}function sn(e){return e.inclusiveRight?1:0}function an(e,t){var r=e.lines.length-t.lines.length;if(0!=r)return r;var n=e.find(),i=t.find(),o=Oo(n.from,i.from)||ln(e)-ln(t);if(o)return-o;var l=Oo(n.to,i.to)||sn(e)-sn(t);return l?l:t.id-e.id}function un(e,t){var r,n=Ao&&e.markedSpans;if(n)for(var i,o=0;o<n.length;++o)i=n[o],i.marker.collapsed&&null==(t?i.from:i.to)&&(!r||an(r,i.marker)<0)&&(r=i.marker);return r}function cn(e){return un(e,!0)}function fn(e){return un(e,!1)}function hn(e,t,r,n,i){var o=Xn(e,t),l=Ao&&o.markedSpans;if(l)for(var s=0;s<l.length;++s){var a=l[s];if(a.marker.collapsed){var u=a.marker.find(0),c=Oo(u.from,r)||ln(a.marker)-ln(i),f=Oo(u.to,n)||sn(a.marker)-sn(i);if(!(c>=0&&0>=f||0>=c&&f>=0)&&(0>=c&&(Oo(u.to,r)>0||a.marker.inclusiveRight&&i.inclusiveLeft)||c>=0&&(Oo(u.from,n)<0||a.marker.inclusiveLeft&&i.inclusiveRight)))return!0}}}function dn(e){for(var t;t=cn(e);)e=t.find(-1,!0).line;return e}function pn(e){for(var t,r;t=fn(e);)e=t.find(1,!0).line,(r||(r=[])).push(e);return r}function gn(e,t){var r=Xn(e,t),n=dn(r);return r==n?t:qn(n)}function vn(e,t){if(t>e.lastLine())return t;var r,n=Xn(e,t);if(!mn(e,n))return t;for(;r=fn(n);)n=r.find(1,!0).line;return qn(n)+1}function mn(e,t){var r=Ao&&t.markedSpans;if(r)for(var n,i=0;i<r.length;++i)if(n=r[i],n.marker.collapsed){if(null==n.from)return!0;if(!n.marker.widgetNode&&0==n.from&&n.marker.inclusiveLeft&&yn(e,t,n))return!0}}function yn(e,t,r){if(null==r.to){var n=r.marker.find(1,!0);return yn(e,n.line,Yr(n.line.markedSpans,r.marker))}if(r.marker.inclusiveRight&&r.to==t.text.length)return!0;for(var i,o=0;o<t.markedSpans.length;++o)if(i=t.markedSpans[o],i.marker.collapsed&&!i.marker.widgetNode&&i.from==r.to&&(null==i.to||i.to!=r.from)&&(i.marker.inclusiveLeft||r.marker.inclusiveRight)&&yn(e,t,i))return!0}function bn(e,t,r){Qn(t)<(e.curOp&&e.curOp.scrollTop||e.doc.scrollTop)&&Or(e,null,r)}function wn(e){if(null!=e.height)return e.height;var t=e.doc.cm;if(!t)return 0;if(!Fl(document.body,e.node)){var r="position: relative;";e.coverGutter&&(r+="margin-left: -"+t.display.gutters.offsetWidth+"px;"),e.noHScroll&&(r+="width: "+t.display.wrapper.clientWidth+"px;"),Ri(t.display.measure,zi("div",[e.node],null,r))}return e.height=e.node.offsetHeight}function xn(e,t,r,n){var i=new fl(e,r,n),o=e.cm;return o&&i.noHScroll&&(o.display.alignWidgets=!0),Pr(e,t,"widget",function(t){var r=t.widgets||(t.widgets=[]);if(null==i.insertAt?r.push(i):r.splice(Math.min(r.length-1,Math.max(0,i.insertAt)),0,i),i.line=t,o&&!mn(e,t)){var n=Qn(t)<e.scrollTop;$n(t,t.height+wn(i)),n&&Or(o,null,i.height),o.curOp.forceUpdate=!0}return!0}),i}function Cn(e,t,r,n){e.text=t,e.stateAfter&&(e.stateAfter=null),e.styles&&(e.styles=null),null!=e.order&&(e.order=null),nn(e),on(e,r);var i=n?n(e):1;i!=e.height&&$n(e,i)}function Sn(e){e.parent=null,nn(e)}function Ln(e,t){if(e)for(;;){var r=e.match(/(?:^|\s+)line-(background-)?(\S+)/);if(!r)break;e=e.slice(0,r.index)+e.slice(r.index+r[0].length);var n=r[1]?"bgClass":"textClass";null==t[n]?t[n]=r[2]:new RegExp("(?:^|s)"+r[2]+"(?:$|s)").test(t[n])||(t[n]+=" "+r[2])}return e}function kn(t,r){if(t.blankLine)return t.blankLine(r);if(t.innerMode){var n=e.innerMode(t,r);return n.mode.blankLine?n.mode.blankLine(n.state):void 0}}function Tn(t,r,n,i){for(var o=0;10>o;o++){i&&(i[0]=e.innerMode(t,n).mode);var l=t.token(r,n);if(r.pos>r.start)return l}throw new Error("Mode "+t.name+" failed to advance stream.")}function Mn(e,t,r,n){function i(e){return{start:f.start,end:f.pos,string:f.current(),type:o||null,state:e?el(l.mode,c):c}}var o,l=e.doc,s=l.mode;t=pe(l,t);var a,u=Xn(l,t.line),c=Re(e,t.line,r),f=new sl(u.text,e.options.tabSize);for(n&&(a=[]);(n||f.pos<t.ch)&&!f.eol();)f.start=f.pos,o=Tn(s,f,c),n&&a.push(i(!0));return n?a:i()}function Nn(e,t,r,n,i,o,l){var s=r.flattenSpans;null==s&&(s=e.options.flattenSpans);var a,u=0,c=null,f=new sl(t,e.options.tabSize),h=e.options.addModeClass&&[null];for(""==t&&Ln(kn(r,n),o);!f.eol();){if(f.pos>e.options.maxHighlightLength?(s=!1,l&&On(e,t,n,f.pos),f.pos=t.length,a=null):a=Ln(Tn(r,f,n,h),o),h){var d=h[0].name;d&&(a="m-"+(a?d+" "+a:d))}if(!s||c!=a){for(;u<f.start;)u=Math.min(f.start,u+5e4),i(u,c);c=a}f.start=f.pos}for(;u<f.pos;){var p=Math.min(f.pos,u+5e4);i(p,c),u=p}}function An(e,t,r,n){var i=[e.state.modeGen],o={};Nn(e,t.text,e.doc.mode,r,function(e,t){i.push(e,t)},o,n);for(var l=0;l<e.state.overlays.length;++l){var s=e.state.overlays[l],a=1,u=0;Nn(e,t.text,s.mode,!0,function(e,t){for(var r=a;e>u;){var n=i[a];n>e&&i.splice(a,1,e,i[a+1],n),a+=2,u=Math.min(e,n)}if(t)if(s.opaque)i.splice(r,a-r,e,"cm-overlay "+t),a=r+2;else for(;a>r;r+=2){var o=i[r+1];i[r+1]=(o?o+" ":"")+"cm-overlay "+t}},o)}return{styles:i,classes:o.bgClass||o.textClass?o:null}}function Wn(e,t,r){if(!t.styles||t.styles[0]!=e.state.modeGen){var n=An(e,t,t.stateAfter=Re(e,qn(t)));t.styles=n.styles,n.classes?t.styleClasses=n.classes:t.styleClasses&&(t.styleClasses=null),r===e.doc.frontier&&e.doc.frontier++}return t.styles}function On(e,t,r,n){var i=e.doc.mode,o=new sl(t,e.options.tabSize);for(o.start=o.pos=n||0,""==t&&kn(i,r);!o.eol()&&o.pos<=e.options.maxHighlightLength;)Tn(i,o,r),o.start=o.pos}function Dn(e,t){if(!e||/^\s*$/.test(e))return null;var r=t.addModeClass?pl:dl;return r[e]||(r[e]=e.replace(/\S+/g,"cm-$&"))}function Hn(e,t){var r=zi("span",null,null,po?"padding-right: .1px":null),n={pre:zi("pre",[r]),content:r,col:0,pos:0,cm:e,splitSpaces:(fo||po)&&e.getOption("lineWrapping")};t.measure={};for(var i=0;i<=(t.rest?t.rest.length:0);i++){var o,l=i?t.rest[i-1]:t.line;n.pos=0,n.addToken=Pn,_i(e.display.measure)&&(o=Jn(l))&&(n.addToken=zn(n.addToken,o)),n.map=[];var s=t!=e.display.externalMeasured&&qn(l);Rn(l,n,Wn(e,l,s)),l.styleClasses&&(l.styleClasses.bgClass&&(n.bgClass=Ui(l.styleClasses.bgClass,n.bgClass||"")),l.styleClasses.textClass&&(n.textClass=Ui(l.styleClasses.textClass,n.textClass||""))),0==n.map.length&&n.map.push(0,0,n.content.appendChild(Xi(e.display.measure))),0==i?(t.measure.map=n.map,t.measure.cache={}):((t.measure.maps||(t.measure.maps=[])).push(n.map),(t.measure.caches||(t.measure.caches=[])).push({}))}return po&&/\bcm-tab\b/.test(n.content.lastChild.className)&&(n.content.className="cm-tab-wrap-hack"),Ll(e,"renderLine",e,t.line,n.pre),n.pre.className&&(n.textClass=Ui(n.pre.className,n.textClass||"")),n}function In(e){var t=zi("span","•","cm-invalidchar");return t.title="\\u"+e.charCodeAt(0).toString(16),t.setAttribute("aria-label",t.title),t}function Pn(e,t,r,n,i,o,l){if(t){var s=e.splitSpaces?t.replace(/ {3,}/g,En):t,a=e.cm.state.specialChars,u=!1;if(a.test(t))for(var c=document.createDocumentFragment(),f=0;;){a.lastIndex=f;var h=a.exec(t),d=h?h.index-f:t.length-f;if(d){var p=document.createTextNode(s.slice(f,f+d));fo&&9>ho?c.appendChild(zi("span",[p])):c.appendChild(p),e.map.push(e.pos,e.pos+d,p),e.col+=d,e.pos+=d}if(!h)break;if(f+=d+1," "==h[0]){var g=e.cm.options.tabSize,v=g-e.col%g,p=c.appendChild(zi("span",Ti(v),"cm-tab"));p.setAttribute("role","presentation"),p.setAttribute("cm-text"," "),e.col+=v}else{var p=e.cm.options.specialCharPlaceholder(h[0]);p.setAttribute("cm-text",h[0]),fo&&9>ho?c.appendChild(zi("span",[p])):c.appendChild(p),e.col+=1}e.map.push(e.pos,e.pos+1,p),e.pos++}else{e.col+=t.length;var c=document.createTextNode(s);e.map.push(e.pos,e.pos+t.length,c),fo&&9>ho&&(u=!0),e.pos+=t.length}if(r||n||i||u||l){var m=r||"";n&&(m+=n),i&&(m+=i);var y=zi("span",[c],m,l);return o&&(y.title=o),e.content.appendChild(y)}e.content.appendChild(c)}}function En(e){for(var t=" ",r=0;r<e.length-2;++r)t+=r%2?" ":" ";return t+=" "}function zn(e,t){return function(r,n,i,o,l,s,a){i=i?i+" cm-force-border":"cm-force-border";for(var u=r.pos,c=u+n.length;;){for(var f=0;f<t.length;f++){var h=t[f];if(h.to>u&&h.from<=u)break}if(h.to>=c)return e(r,n,i,o,l,s,a);e(r,n.slice(0,h.to-u),i,o,null,s,a),o=null,n=n.slice(h.to-u),u=h.to}}}function Fn(e,t,r,n){var i=!n&&r.widgetNode;i&&e.map.push(e.pos,e.pos+t,i),!n&&e.cm.display.input.needsContentAttribute&&(i||(i=e.content.appendChild(document.createElement("span"))),i.setAttribute("cm-marker",r.id)),i&&(e.cm.display.input.setUneditable(i),e.content.appendChild(i)),e.pos+=t}function Rn(e,t,r){var n=e.markedSpans,i=e.text,o=0;if(n)for(var l,s,a,u,c,f,h,d=i.length,p=0,g=1,v="",m=0;;){if(m==p){a=u=c=f=s="",h=null,m=1/0;for(var y=[],b=0;b<n.length;++b){var w=n[b],x=w.marker;"bookmark"==x.type&&w.from==p&&x.widgetNode?y.push(x):w.from<=p&&(null==w.to||w.to>p||x.collapsed&&w.to==p&&w.from==p)?(null!=w.to&&w.to!=p&&m>w.to&&(m=w.to,u=""),x.className&&(a+=" "+x.className),x.css&&(s=x.css),x.startStyle&&w.from==p&&(c+=" "+x.startStyle),x.endStyle&&w.to==m&&(u+=" "+x.endStyle),x.title&&!f&&(f=x.title),x.collapsed&&(!h||an(h.marker,x)<0)&&(h=w)):w.from>p&&m>w.from&&(m=w.from)}if(h&&(h.from||0)==p){if(Fn(t,(null==h.to?d+1:h.to)-p,h.marker,null==h.from),null==h.to)return;h.to==p&&(h=!1)}if(!h&&y.length)for(var b=0;b<y.length;++b)Fn(t,0,y[b])}if(p>=d)break;for(var C=Math.min(d,m);;){if(v){var S=p+v.length;if(!h){var L=S>C?v.slice(0,C-p):v;t.addToken(t,L,l?l+a:a,c,p+L.length==m?u:"",f,s)}if(S>=C){v=v.slice(C-p),p=C;break}p=S,c=""}v=i.slice(o,o=r[g++]),l=Dn(r[g++],t.cm.options)}}else for(var g=1;g<r.length;g+=2)t.addToken(t,i.slice(o,o=r[g]),Dn(r[g+1],t.cm.options))}function Bn(e,t){return 0==t.from.ch&&0==t.to.ch&&""==Mi(t.text)&&(!e.cm||e.cm.options.wholeLineUpdateBefore)}function Gn(e,t,r,n){function i(e){return r?r[e]:null}function o(e,r,i){Cn(e,r,i,n),yi(e,"change",e,t)}function l(e,t){for(var r=e,o=[];t>r;++r)o.push(new hl(u[r],i(r),n));return o}var s=t.from,a=t.to,u=t.text,c=Xn(e,s.line),f=Xn(e,a.line),h=Mi(u),d=i(u.length-1),p=a.line-s.line;if(t.full)e.insert(0,l(0,u.length)),e.remove(u.length,e.size-u.length);else if(Bn(e,t)){var g=l(0,u.length-1);o(f,f.text,d),p&&e.remove(s.line,p),g.length&&e.insert(s.line,g)}else if(c==f)if(1==u.length)o(c,c.text.slice(0,s.ch)+h+c.text.slice(a.ch),d);else{var g=l(1,u.length-1);g.push(new hl(h+c.text.slice(a.ch),d,n)),o(c,c.text.slice(0,s.ch)+u[0],i(0)),e.insert(s.line+1,g)}else if(1==u.length)o(c,c.text.slice(0,s.ch)+u[0]+f.text.slice(a.ch),i(0)),e.remove(s.line+1,p);else{o(c,c.text.slice(0,s.ch)+u[0],i(0)),o(f,h+f.text.slice(a.ch),d);var g=l(1,u.length-1);p>1&&e.remove(s.line+1,p-1),e.insert(s.line+1,g)}yi(e,"change",e,t)}function Un(e){this.lines=e,this.parent=null;for(var t=0,r=0;t<e.length;++t)e[t].parent=this,r+=e[t].height;this.height=r}function Vn(e){this.children=e;for(var t=0,r=0,n=0;n<e.length;++n){var i=e[n];t+=i.chunkSize(),r+=i.height,i.parent=this}this.size=t,this.height=r,this.parent=null}function Kn(e,t,r){function n(e,i,o){if(e.linked)for(var l=0;l<e.linked.length;++l){var s=e.linked[l];if(s.doc!=i){var a=o&&s.sharedHist;(!r||a)&&(t(s.doc,a),n(s.doc,e,a))}}}n(e,null,!0)}function jn(e,t){if(t.cm)throw new Error("This document is already in use.");e.doc=t,t.cm=e,l(e),r(e),e.options.lineWrapping||h(e),e.options.mode=t.modeOption,Dt(e)}function Xn(e,t){if(t-=e.first,0>t||t>=e.size)throw new Error("There is no line "+(t+e.first)+" in the document.");for(var r=e;!r.lines;)for(var n=0;;++n){var i=r.children[n],o=i.chunkSize();if(o>t){r=i;break}t-=o}return r.lines[t]}function _n(e,t,r){var n=[],i=t.line;return e.iter(t.line,r.line+1,function(e){var o=e.text;i==r.line&&(o=o.slice(0,r.ch)),i==t.line&&(o=o.slice(t.ch)),n.push(o),++i}),n}function Yn(e,t,r){var n=[];return e.iter(t,r,function(e){n.push(e.text)}),n}function $n(e,t){var r=t-e.height;if(r)for(var n=e;n;n=n.parent)n.height+=r}function qn(e){if(null==e.parent)return null;for(var t=e.parent,r=Ni(t.lines,e),n=t.parent;n;t=n,n=n.parent)for(var i=0;n.children[i]!=t;++i)r+=n.children[i].chunkSize();return r+t.first}function Zn(e,t){var r=e.first;e:do{for(var n=0;n<e.children.length;++n){var i=e.children[n],o=i.height;if(o>t){e=i;continue e}t-=o,r+=i.chunkSize()}return r}while(!e.lines);for(var n=0;n<e.lines.length;++n){var l=e.lines[n],s=l.height;if(s>t)break;t-=s}return r+n}function Qn(e){e=dn(e);for(var t=0,r=e.parent,n=0;n<r.lines.length;++n){var i=r.lines[n];if(i==e)break;t+=i.height}for(var o=r.parent;o;r=o,o=r.parent)for(var n=0;n<o.children.length;++n){var l=o.children[n];if(l==r)break;t+=l.height}return t}function Jn(e){var t=e.order;return null==t&&(t=e.order=Zl(e.text)),t}function ei(e){this.done=[],this.undone=[],this.undoDepth=1/0,this.lastModTime=this.lastSelTime=0,this.lastOp=this.lastSelOp=null,this.lastOrigin=this.lastSelOrigin=null,this.generation=this.maxGeneration=e||1}function ti(e,t){var r={from:_(t.from),to:jo(t),text:_n(e,t.from,t.to)};return ai(e,r,t.from.line,t.to.line+1),Kn(e,function(e){ai(e,r,t.from.line,t.to.line+1)},!0),r}function ri(e){for(;e.length;){var t=Mi(e);if(!t.ranges)break;e.pop()}}function ni(e,t){return t?(ri(e.done),Mi(e.done)):e.done.length&&!Mi(e.done).ranges?Mi(e.done):e.done.length>1&&!e.done[e.done.length-2].ranges?(e.done.pop(),Mi(e.done)):void 0}function ii(e,t,r,n){var i=e.history;i.undone.length=0;var o,l=+new Date;if((i.lastOp==n||i.lastOrigin==t.origin&&t.origin&&("+"==t.origin.charAt(0)&&e.cm&&i.lastModTime>l-e.cm.options.historyEventDelay||"*"==t.origin.charAt(0)))&&(o=ni(i,i.lastOp==n))){var s=Mi(o.changes);0==Oo(t.from,t.to)&&0==Oo(t.from,s.to)?s.to=jo(t):o.changes.push(ti(e,t))}else{var a=Mi(i.done);for(a&&a.ranges||si(e.sel,i.done),o={changes:[ti(e,t)],generation:i.generation},i.done.push(o);i.done.length>i.undoDepth;)i.done.shift(),i.done[0].ranges||i.done.shift()}i.done.push(r),i.generation=++i.maxGeneration,i.lastModTime=i.lastSelTime=l,i.lastOp=i.lastSelOp=n,i.lastOrigin=i.lastSelOrigin=t.origin,s||Ll(e,"historyAdded")}function oi(e,t,r,n){var i=t.charAt(0);return"*"==i||"+"==i&&r.ranges.length==n.ranges.length&&r.somethingSelected()==n.somethingSelected()&&new Date-e.history.lastSelTime<=(e.cm?e.cm.options.historyEventDelay:500)}function li(e,t,r,n){var i=e.history,o=n&&n.origin;r==i.lastSelOp||o&&i.lastSelOrigin==o&&(i.lastModTime==i.lastSelTime&&i.lastOrigin==o||oi(e,o,Mi(i.done),t))?i.done[i.done.length-1]=t:si(t,i.done),i.lastSelTime=+new Date,i.lastSelOrigin=o,i.lastSelOp=r,n&&n.clearRedo!==!1&&ri(i.undone)}function si(e,t){var r=Mi(t);r&&r.ranges&&r.equals(e)||t.push(e)}function ai(e,t,r,n){var i=t["spans_"+e.id],o=0;e.iter(Math.max(e.first,r),Math.min(e.first+e.size,n),function(r){r.markedSpans&&((i||(i=t["spans_"+e.id]={}))[o]=r.markedSpans),++o})}function ui(e){if(!e)return null;for(var t,r=0;r<e.length;++r)e[r].marker.explicitlyCleared?t||(t=e.slice(0,r)):t&&t.push(e[r]);return t?t.length?t:null:e}function ci(e,t){var r=t["spans_"+e.id];if(!r)return null;for(var n=0,i=[];n<t.text.length;++n)i.push(ui(r[n]));return i}function fi(e,t,r){for(var n=0,i=[];n<e.length;++n){var o=e[n];if(o.ranges)i.push(r?ue.prototype.deepCopy.call(o):o);else{var l=o.changes,s=[];i.push({changes:s});for(var a=0;a<l.length;++a){var u,c=l[a];if(s.push({from:c.from,to:c.to,text:c.text}),t)for(var f in c)(u=f.match(/^spans_(\d+)$/))&&Ni(t,Number(u[1]))>-1&&(Mi(s)[f]=c[f],delete c[f])}}}return i}function hi(e,t,r,n){r<e.line?e.line+=n:t<e.line&&(e.line=t,e.ch=0)}function di(e,t,r,n){for(var i=0;i<e.length;++i){var o=e[i],l=!0;if(o.ranges){o.copied||(o=e[i]=o.deepCopy(),o.copied=!0);for(var s=0;s<o.ranges.length;s++)hi(o.ranges[s].anchor,t,r,n),hi(o.ranges[s].head,t,r,n)}else{for(var s=0;s<o.changes.length;++s){var a=o.changes[s];if(r<a.from.line)a.from=Wo(a.from.line+n,a.from.ch),a.to=Wo(a.to.line+n,a.to.ch);else if(t<=a.to.line){l=!1;break}}l||(e.splice(0,i+1),i=0)}}}function pi(e,t){var r=t.from.line,n=t.to.line,i=t.text.length-(n-r)-1;di(e.done,r,n,i),di(e.undone,r,n,i)}function gi(e){return null!=e.defaultPrevented?e.defaultPrevented:0==e.returnValue}function vi(e){return e.target||e.srcElement}function mi(e){var t=e.which;return null==t&&(1&e.button?t=1:2&e.button?t=3:4&e.button&&(t=2)),So&&e.ctrlKey&&1==t&&(t=3),t}function yi(e,t){function r(e){return function(){e.apply(null,o)}}var n=e._handlers&&e._handlers[t];if(n){var i,o=Array.prototype.slice.call(arguments,2);zo?i=zo.delayedCallbacks:kl?i=kl:(i=kl=[],setTimeout(bi,0));for(var l=0;l<n.length;++l)i.push(r(n[l]))}}function bi(){var e=kl;kl=null;for(var t=0;t<e.length;++t)e[t]()}function wi(e,t,r){return"string"==typeof t&&(t={type:t,preventDefault:function(){this.defaultPrevented=!0}}),Ll(e,r||t.type,e,t),gi(t)||t.codemirrorIgnore}function xi(e){var t=e._handlers&&e._handlers.cursorActivity;if(t)for(var r=e.curOp.cursorActivityHandlers||(e.curOp.cursorActivityHandlers=[]),n=0;n<t.length;++n)-1==Ni(r,t[n])&&r.push(t[n])}function Ci(e,t){var r=e._handlers&&e._handlers[t];return r&&r.length>0}function Si(e){e.prototype.on=function(e,t){Cl(this,e,t)},e.prototype.off=function(e,t){Sl(this,e,t)}}function Li(){this.id=null}function ki(e,t,r){for(var n=0,i=0;;){var o=e.indexOf(" ",n);-1==o&&(o=e.length);var l=o-n;if(o==e.length||i+l>=t)return n+Math.min(l,t-i);if(i+=o-n,i+=r-i%r,n=o+1,i>=t)return n}}function Ti(e){for(;Dl.length<=e;)Dl.push(Mi(Dl)+" ");return Dl[e]}function Mi(e){return e[e.length-1]}function Ni(e,t){for(var r=0;r<e.length;++r)if(e[r]==t)return r;return-1}function Ai(e,t){for(var r=[],n=0;n<e.length;n++)r[n]=t(e[n],n);return r}function Wi(){}function Oi(e,t){var r;return Object.create?r=Object.create(e):(Wi.prototype=e,r=new Wi),t&&Di(t,r),r}function Di(e,t,r){t||(t={});for(var n in e)!e.hasOwnProperty(n)||r===!1&&t.hasOwnProperty(n)||(t[n]=e[n]);return t}function Hi(e){var t=Array.prototype.slice.call(arguments,1);return function(){return e.apply(null,t)}}function Ii(e,t){return t?t.source.indexOf("\\w")>-1&&El(e)?!0:t.test(e):El(e)}function Pi(e){for(var t in e)if(e.hasOwnProperty(t)&&e[t])return!1;return!0}function Ei(e){return e.charCodeAt(0)>=768&&zl.test(e)}function zi(e,t,r,n){var i=document.createElement(e);if(r&&(i.className=r),n&&(i.style.cssText=n),"string"==typeof t)i.appendChild(document.createTextNode(t));else if(t)for(var o=0;o<t.length;++o)i.appendChild(t[o]);return i}function Fi(e){for(var t=e.childNodes.length;t>0;--t)e.removeChild(e.firstChild);return e}function Ri(e,t){return Fi(e).appendChild(t)}function Bi(){return document.activeElement}function Gi(e){return new RegExp("(^|\\s)"+e+"(?:$|\\s)\\s*")}function Ui(e,t){for(var r=e.split(" "),n=0;n<r.length;n++)r[n]&&!Gi(r[n]).test(t)&&(t+=" "+r[n]);return t}function Vi(e){if(document.body.getElementsByClassName)for(var t=document.body.getElementsByClassName("CodeMirror"),r=0;r<t.length;r++){var n=t[r].CodeMirror;n&&e(n)}}function Ki(){Vl||(ji(),Vl=!0)}function ji(){var e;Cl(window,"resize",function(){null==e&&(e=setTimeout(function(){e=null,Vi(Gt)},100))}),Cl(window,"blur",function(){Vi(hr)})}function Xi(e){if(null==Rl){var t=zi("span","");Ri(e,zi("span",[t,document.createTextNode("x")])),0!=e.firstChild.offsetHeight&&(Rl=t.offsetWidth<=1&&t.offsetHeight>2&&!(fo&&8>ho))}var r=Rl?zi("span",""):zi("span"," ",null,"display: inline-block; width: 1px; margin-right: -1px");return r.setAttribute("cm-text",""),r}function _i(e){if(null!=Bl)return Bl;var t=Ri(e,document.createTextNode("AخA")),r=Il(t,0,1).getBoundingClientRect();if(!r||r.left==r.right)return!1;var n=Il(t,1,2).getBoundingClientRect();return Bl=n.right-r.right<3}function Yi(e){if(null!=Yl)return Yl;var t=Ri(e,zi("span","x")),r=t.getBoundingClientRect(),n=Il(t,0,1).getBoundingClientRect();return Yl=Math.abs(r.left-n.left)>1}function $i(e,t,r,n){if(!e)return n(t,r,"ltr");for(var i=!1,o=0;o<e.length;++o){var l=e[o];(l.from<r&&l.to>t||t==r&&l.to==t)&&(n(Math.max(l.from,t),Math.min(l.to,r),1==l.level?"rtl":"ltr"),i=!0)}i||n(t,r,"ltr")}function qi(e){return e.level%2?e.to:e.from}function Zi(e){return e.level%2?e.from:e.to}function Qi(e){var t=Jn(e);return t?qi(t[0]):0}function Ji(e){var t=Jn(e);return t?Zi(Mi(t)):e.text.length}function eo(e,t){var r=Xn(e.doc,t),n=dn(r);n!=r&&(t=qn(n));var i=Jn(n),o=i?i[0].level%2?Ji(n):Qi(n):0;return Wo(t,o)}function to(e,t){for(var r,n=Xn(e.doc,t);r=fn(n);)n=r.find(1,!0).line,t=null;var i=Jn(n),o=i?i[0].level%2?Qi(n):Ji(n):n.text.length;return Wo(null==t?qn(n):t,o)}function ro(e,t){var r=eo(e,t.line),n=Xn(e.doc,r.line),i=Jn(n);if(!i||0==i[0].level){var o=Math.max(0,n.text.search(/\S/)),l=t.line==r.line&&t.ch<=o&&t.ch;return Wo(r.line,l?0:o)}return r}function no(e,t,r){var n=e[0].level;return t==n?!0:r==n?!1:r>t}function io(e,t){ql=null;for(var r,n=0;n<e.length;++n){var i=e[n];if(i.from<t&&i.to>t)return n;if(i.from==t||i.to==t){if(null!=r)return no(e,i.level,e[r].level)?(i.from!=i.to&&(ql=r),n):(i.from!=i.to&&(ql=n),r);r=n}}return r}function oo(e,t,r,n){if(!n)return t+r;do t+=r;while(t>0&&Ei(e.text.charAt(t)));return t}function lo(e,t,r,n){var i=Jn(e);if(!i)return so(e,t,r,n);for(var o=io(i,t),l=i[o],s=oo(e,t,l.level%2?-r:r,n);;){if(s>l.from&&s<l.to)return s;if(s==l.from||s==l.to)return io(i,s)==o?s:(l=i[o+=r],r>0==l.level%2?l.to:l.from);if(l=i[o+=r],!l)return null;s=r>0==l.level%2?oo(e,l.to,-1,n):oo(e,l.from,1,n)}}function so(e,t,r,n){var i=t+r;if(n)for(;i>0&&Ei(e.text.charAt(i));)i+=r;return 0>i||i>e.text.length?null:i}var ao=/gecko\/\d/i.test(navigator.userAgent),uo=/MSIE \d/.test(navigator.userAgent),co=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),fo=uo||co,ho=fo&&(uo?document.documentMode||6:co[1]),po=/WebKit\//.test(navigator.userAgent),go=po&&/Qt\/\d+\.\d+/.test(navigator.userAgent),vo=/Chrome\//.test(navigator.userAgent),mo=/Opera\//.test(navigator.userAgent),yo=/Apple Computer/.test(navigator.vendor),bo=/Mac OS X 1\d\D([8-9]|\d\d)\D/.test(navigator.userAgent),wo=/PhantomJS/.test(navigator.userAgent),xo=/AppleWebKit/.test(navigator.userAgent)&&/Mobile\/\w+/.test(navigator.userAgent),Co=xo||/Android|webOS|BlackBerry|Opera Mini|Opera Mobi|IEMobile/i.test(navigator.userAgent),So=xo||/Mac/.test(navigator.platform),Lo=/win/i.test(navigator.platform),ko=mo&&navigator.userAgent.match(/Version\/(\d*\.\d*)/);ko&&(ko=Number(ko[1])),ko&&ko>=15&&(mo=!1,po=!0);var To=So&&(go||mo&&(null==ko||12.11>ko)),Mo=ao||fo&&ho>=9,No=!1,Ao=!1;g.prototype=Di({update:function(e){var t=e.scrollWidth>e.clientWidth+1,r=e.scrollHeight>e.clientHeight+1,n=e.nativeBarWidth;if(r){this.vert.style.display="block",this.vert.style.bottom=t?n+"px":"0";var i=e.viewHeight-(t?n:0);this.vert.firstChild.style.height=Math.max(0,e.scrollHeight-e.clientHeight+i)+"px"}else this.vert.style.display="",this.vert.firstChild.style.height="0";if(t){this.horiz.style.display="block",this.horiz.style.right=r?n+"px":"0",this.horiz.style.left=e.barLeft+"px";var o=e.viewWidth-e.barLeft-(r?n:0);this.horiz.firstChild.style.width=e.scrollWidth-e.clientWidth+o+"px"}else this.horiz.style.display="",this.horiz.firstChild.style.width="0";return!this.checkedOverlay&&e.clientHeight>0&&(0==n&&this.overlayHack(),this.checkedOverlay=!0),{right:r?n:0,bottom:t?n:0}},setScrollLeft:function(e){this.horiz.scrollLeft!=e&&(this.horiz.scrollLeft=e)},setScrollTop:function(e){this.vert.scrollTop!=e&&(this.vert.scrollTop=e)},overlayHack:function(){var e=So&&!bo?"12px":"18px";this.horiz.style.minHeight=this.vert.style.minWidth=e;var t=this,r=function(e){vi(e)!=t.vert&&vi(e)!=t.horiz&&Mt(t.cm,Kt)(e)};Cl(this.vert,"mousedown",r),Cl(this.horiz,"mousedown",r)},clear:function(){var e=this.horiz.parentNode;e.removeChild(this.horiz),e.removeChild(this.vert)}},g.prototype),v.prototype=Di({update:function(){return{bottom:0,right:0}},setScrollLeft:function(){},setScrollTop:function(){},clear:function(){}},v.prototype),e.scrollbarModel={"native":g,"null":v},k.prototype.signal=function(e,t){Ci(e,t)&&this.events.push(arguments)},k.prototype.finish=function(){for(var e=0;e<this.events.length;e++)Ll.apply(null,this.events[e])};var Wo=e.Pos=function(e,t){return this instanceof Wo?(this.line=e,void(this.ch=t)):new Wo(e,t)},Oo=e.cmpPos=function(e,t){return e.line-t.line||e.ch-t.ch},Do=null;te.prototype=Di({init:function(e){function t(e){if(n.somethingSelected())Do=n.getSelections(),r.inaccurateSelection&&(r.prevInput="",r.inaccurateSelection=!1,o.value=Do.join("\n"),Hl(o));else{if(!n.options.lineWiseCopyCut)return;var t=J(n);Do=t.text,"cut"==e.type?n.setSelections(t.ranges,null,Nl):(r.prevInput="",o.value=t.text.join("\n"),Hl(o))}"cut"==e.type&&(n.state.cutIncoming=!0)}var r=this,n=this.cm,i=this.wrapper=re(),o=this.textarea=i.firstChild;e.wrapper.insertBefore(i,e.wrapper.firstChild),xo&&(o.style.width="0px"),Cl(o,"input",function(){fo&&ho>=9&&r.hasSelection&&(r.hasSelection=null),r.poll()}),Cl(o,"paste",function(){if(po&&!n.state.fakedLastChar&&!(new Date-n.state.lastMiddleDown<200)){var e=o.selectionStart,t=o.selectionEnd;o.value+="$",o.selectionEnd=t,o.selectionStart=e,n.state.fakedLastChar=!0}n.state.pasteIncoming=!0,r.fastPoll()}),Cl(o,"cut",t),Cl(o,"copy",t),Cl(e.scroller,"paste",function(t){Ut(e,t)||(n.state.pasteIncoming=!0,r.focus())}),Cl(e.lineSpace,"selectstart",function(t){Ut(e,t)||bl(t)}),Cl(o,"compositionstart",function(){var e=n.getCursor("from");r.composing={start:e,range:n.markText(e,n.getCursor("to"),{className:"CodeMirror-composing"})}}),Cl(o,"compositionend",function(){r.composing&&(r.poll(),r.composing.range.clear(),r.composing=null)})},prepareSelection:function(){var e=this.cm,t=e.display,r=e.doc,n=De(e);if(e.options.moveInputWithCursor){var i=ct(e,r.sel.primary().head,"div"),o=t.wrapper.getBoundingClientRect(),l=t.lineDiv.getBoundingClientRect();n.teTop=Math.max(0,Math.min(t.wrapper.clientHeight-10,i.top+l.top-o.top)),n.teLeft=Math.max(0,Math.min(t.wrapper.clientWidth-10,i.left+l.left-o.left))}return n},showSelection:function(e){var t=this.cm,r=t.display;Ri(r.cursorDiv,e.cursors),Ri(r.selectionDiv,e.selection),null!=e.teTop&&(this.wrapper.style.top=e.teTop+"px",this.wrapper.style.left=e.teLeft+"px")},reset:function(e){if(!this.contextMenuPending){var t,r,n=this.cm,i=n.doc;if(n.somethingSelected()){this.prevInput="";var o=i.sel.primary();t=_l&&(o.to().line-o.from().line>100||(r=n.getSelection()).length>1e3);var l=t?"-":r||n.getSelection();this.textarea.value=l,n.state.focused&&Hl(this.textarea),fo&&ho>=9&&(this.hasSelection=l)}else e||(this.prevInput=this.textarea.value="",fo&&ho>=9&&(this.hasSelection=null));this.inaccurateSelection=t}},getField:function(){return this.textarea},supportsTouch:function(){return!1},focus:function(){if("nocursor"!=this.cm.options.readOnly&&(!Co||Bi()!=this.textarea))try{this.textarea.focus()}catch(e){}},blur:function(){this.textarea.blur();
|
4 |
-
},resetPosition:function(){this.wrapper.style.top=this.wrapper.style.left=0},receivedFocus:function(){this.slowPoll()},slowPoll:function(){var e=this;e.pollingFast||e.polling.set(this.cm.options.pollInterval,function(){e.poll(),e.cm.state.focused&&e.slowPoll()})},fastPoll:function(){function e(){var n=r.poll();n||t?(r.pollingFast=!1,r.slowPoll()):(t=!0,r.polling.set(60,e))}var t=!1,r=this;r.pollingFast=!0,r.polling.set(20,e)},poll:function(){var e=this.cm,t=this.textarea,r=this.prevInput;if(!e.state.focused||Xl(t)&&!r||Z(e)||e.options.disableInput||e.state.keySeq)return!1;e.state.pasteIncoming&&e.state.fakedLastChar&&(t.value=t.value.substring(0,t.value.length-1),e.state.fakedLastChar=!1);var n=t.value;if(n==r&&!e.somethingSelected())return!1;if(fo&&ho>=9&&this.hasSelection===n||So&&/[\uf700-\uf7ff]/.test(n))return e.display.input.reset(),!1;if(e.doc.sel==e.display.selForContextMenu){var i=n.charCodeAt(0);if(8203!=i||r||(r=""),8666==i)return this.reset(),this.cm.execCommand("undo")}for(var o=0,l=Math.min(r.length,n.length);l>o&&r.charCodeAt(o)==n.charCodeAt(o);)++o;var s=this;return Tt(e,function(){Q(e,n.slice(o),r.length-o,null,s.composing?"*compose":null),n.length>1e3||n.indexOf("\n")>-1?t.value=s.prevInput="":s.prevInput=n,s.composing&&(s.composing.range.clear(),s.composing.range=e.markText(s.composing.start,e.getCursor("to"),{className:"CodeMirror-composing"}))}),!0},ensurePolled:function(){this.pollingFast&&this.poll()&&(this.pollingFast=!1)},onKeyPress:function(){fo&&ho>=9&&(this.hasSelection=null),this.fastPoll()},onContextMenu:function(e){function t(){if(null!=l.selectionStart){var e=i.somethingSelected(),t=""+(e?l.value:"");l.value="⇚",l.value=t,n.prevInput=e?"":"",l.selectionStart=1,l.selectionEnd=t.length,o.selForContextMenu=i.doc.sel}}function r(){if(n.contextMenuPending=!1,n.wrapper.style.position="relative",l.style.cssText=c,fo&&9>ho&&o.scrollbars.setScrollTop(o.scroller.scrollTop=a),null!=l.selectionStart){(!fo||fo&&9>ho)&&t();var e=0,r=function(){o.selForContextMenu==i.doc.sel&&0==l.selectionStart&&l.selectionEnd>0&&""==n.prevInput?Mt(i,rl.selectAll)(i):e++<10?o.detectingSelectAll=setTimeout(r,500):o.input.reset()};o.detectingSelectAll=setTimeout(r,200)}}var n=this,i=n.cm,o=i.display,l=n.textarea,s=Vt(i,e),a=o.scroller.scrollTop;if(s&&!mo){var u=i.options.resetSelectionOnContextMenu;u&&-1==i.doc.sel.contains(s)&&Mt(i,ke)(i.doc,he(s),Nl);var c=l.style.cssText;if(n.wrapper.style.position="absolute",l.style.cssText="position: fixed; width: 30px; height: 30px; top: "+(e.clientY-5)+"px; left: "+(e.clientX-5)+"px; z-index: 1000; background: "+(fo?"rgba(255, 255, 255, .05)":"transparent")+"; outline: none; border-width: 0; outline: none; overflow: hidden; opacity: .05; filter: alpha(opacity=5);",po)var f=window.scrollY;if(o.input.focus(),po&&window.scrollTo(null,f),o.input.reset(),i.somethingSelected()||(l.value=n.prevInput=" "),n.contextMenuPending=!0,o.selForContextMenu=i.doc.sel,clearTimeout(o.detectingSelectAll),fo&&ho>=9&&t(),Mo){xl(e);var h=function(){Sl(window,"mouseup",h),setTimeout(r,20)};Cl(window,"mouseup",h)}else setTimeout(r,50)}},setUneditable:Wi,needsContentAttribute:!1},te.prototype),ne.prototype=Di({init:function(e){function t(e){if(n.somethingSelected())Do=n.getSelections(),"cut"==e.type&&n.replaceSelection("",null,"cut");else{if(!n.options.lineWiseCopyCut)return;var t=J(n);Do=t.text,"cut"==e.type&&n.operation(function(){n.setSelections(t.ranges,0,Nl),n.replaceSelection("",null,"cut")})}if(e.clipboardData&&!xo)e.preventDefault(),e.clipboardData.clearData(),e.clipboardData.setData("text/plain",Do.join("\n"));else{var r=re(),i=r.firstChild;n.display.lineSpace.insertBefore(r,n.display.lineSpace.firstChild),i.value=Do.join("\n");var o=document.activeElement;Hl(i),setTimeout(function(){n.display.lineSpace.removeChild(r),o.focus()},50)}}var r=this,n=r.cm,i=r.div=e.lineDiv;i.contentEditable="true",ee(i),Cl(i,"paste",function(e){var t=e.clipboardData&&e.clipboardData.getData("text/plain");t&&(e.preventDefault(),n.replaceSelection(t,null,"paste"))}),Cl(i,"compositionstart",function(e){var t=e.data;if(r.composing={sel:n.doc.sel,data:t,startData:t},t){var i=n.doc.sel.primary(),o=n.getLine(i.head.line),l=o.indexOf(t,Math.max(0,i.head.ch-t.length));l>-1&&l<=i.head.ch&&(r.composing.sel=he(Wo(i.head.line,l),Wo(i.head.line,l+t.length)))}}),Cl(i,"compositionupdate",function(e){r.composing.data=e.data}),Cl(i,"compositionend",function(e){var t=r.composing;t&&(e.data==t.startData||/\u200b/.test(e.data)||(t.data=e.data),setTimeout(function(){t.handled||r.applyComposition(t),r.composing==t&&(r.composing=null)},50))}),Cl(i,"touchstart",function(){r.forceCompositionEnd()}),Cl(i,"input",function(){r.composing||r.pollContent()||Tt(r.cm,function(){Dt(n)})}),Cl(i,"copy",t),Cl(i,"cut",t)},prepareSelection:function(){var e=De(this.cm,!1);return e.focus=this.cm.state.focused,e},showSelection:function(e){e&&this.cm.display.view.length&&(e.focus&&this.showPrimarySelection(),this.showMultipleSelections(e))},showPrimarySelection:function(){var e=window.getSelection(),t=this.cm.doc.sel.primary(),r=le(this.cm,e.anchorNode,e.anchorOffset),n=le(this.cm,e.focusNode,e.focusOffset);if(!r||r.bad||!n||n.bad||0!=Oo($(r,n),t.from())||0!=Oo(Y(r,n),t.to())){var i=ie(this.cm,t.from()),o=ie(this.cm,t.to());if(i||o){var l=this.cm.display.view,s=e.rangeCount&&e.getRangeAt(0);if(i){if(!o){var a=l[l.length-1].measure,u=a.maps?a.maps[a.maps.length-1]:a.map;o={node:u[u.length-1],offset:u[u.length-2]-u[u.length-3]}}}else i={node:l[0].measure.map[2],offset:0};try{var c=Il(i.node,i.offset,o.offset,o.node)}catch(f){}c&&(e.removeAllRanges(),e.addRange(c),s&&null==e.anchorNode?e.addRange(s):ao&&this.startGracePeriod()),this.rememberSelection()}}},startGracePeriod:function(){var e=this;clearTimeout(this.gracePeriod),this.gracePeriod=setTimeout(function(){e.gracePeriod=!1,e.selectionChanged()&&e.cm.operation(function(){e.cm.curOp.selectionChanged=!0})},20)},showMultipleSelections:function(e){Ri(this.cm.display.cursorDiv,e.cursors),Ri(this.cm.display.selectionDiv,e.selection)},rememberSelection:function(){var e=window.getSelection();this.lastAnchorNode=e.anchorNode,this.lastAnchorOffset=e.anchorOffset,this.lastFocusNode=e.focusNode,this.lastFocusOffset=e.focusOffset},selectionInEditor:function(){var e=window.getSelection();if(!e.rangeCount)return!1;var t=e.getRangeAt(0).commonAncestorContainer;return Fl(this.div,t)},focus:function(){"nocursor"!=this.cm.options.readOnly&&this.div.focus()},blur:function(){this.div.blur()},getField:function(){return this.div},supportsTouch:function(){return!0},receivedFocus:function(){function e(){t.cm.state.focused&&(t.pollSelection(),t.polling.set(t.cm.options.pollInterval,e))}var t=this;this.selectionInEditor()?this.pollSelection():Tt(this.cm,function(){t.cm.curOp.selectionChanged=!0}),this.polling.set(this.cm.options.pollInterval,e)},selectionChanged:function(){var e=window.getSelection();return e.anchorNode!=this.lastAnchorNode||e.anchorOffset!=this.lastAnchorOffset||e.focusNode!=this.lastFocusNode||e.focusOffset!=this.lastFocusOffset},pollSelection:function(){if(!this.composing&&!this.gracePeriod&&this.selectionChanged()){var e=window.getSelection(),t=this.cm;this.rememberSelection();var r=le(t,e.anchorNode,e.anchorOffset),n=le(t,e.focusNode,e.focusOffset);r&&n&&Tt(t,function(){ke(t.doc,he(r,n),Nl),(r.bad||n.bad)&&(t.curOp.selectionChanged=!0)})}},pollContent:function(){var e=this.cm,t=e.display,r=e.doc.sel.primary(),n=r.from(),i=r.to();if(n.line<t.viewFrom||i.line>t.viewTo-1)return!1;var o;if(n.line==t.viewFrom||0==(o=Pt(e,n.line)))var l=qn(t.view[0].line),s=t.view[0].node;else var l=qn(t.view[o].line),s=t.view[o-1].node.nextSibling;var a=Pt(e,i.line);if(a==t.view.length-1)var u=t.viewTo-1,c=t.view[a].node;else var u=qn(t.view[a+1].line)-1,c=t.view[a+1].node.previousSibling;for(var f=jl(ae(e,s,c,l,u)),h=_n(e.doc,Wo(l,0),Wo(u,Xn(e.doc,u).text.length));f.length>1&&h.length>1;)if(Mi(f)==Mi(h))f.pop(),h.pop(),u--;else{if(f[0]!=h[0])break;f.shift(),h.shift(),l++}for(var d=0,p=0,g=f[0],v=h[0],m=Math.min(g.length,v.length);m>d&&g.charCodeAt(d)==v.charCodeAt(d);)++d;for(var y=Mi(f),b=Mi(h),w=Math.min(y.length-(1==f.length?d:0),b.length-(1==h.length?d:0));w>p&&y.charCodeAt(y.length-p-1)==b.charCodeAt(b.length-p-1);)++p;f[f.length-1]=y.slice(0,y.length-p),f[0]=f[0].slice(d);var x=Wo(l,d),C=Wo(u,h.length?Mi(h).length-p:0);return f.length>1||f[0]||Oo(x,C)?(Tr(e.doc,f,x,C,"+input"),!0):void 0},ensurePolled:function(){this.forceCompositionEnd()},reset:function(){this.forceCompositionEnd()},forceCompositionEnd:function(){this.composing&&!this.composing.handled&&(this.applyComposition(this.composing),this.composing.handled=!0,this.div.blur(),this.div.focus())},applyComposition:function(e){e.data&&e.data!=e.startData&&Mt(this.cm,Q)(this.cm,e.data,0,e.sel)},setUneditable:function(e){e.setAttribute("contenteditable","false")},onKeyPress:function(e){e.preventDefault(),Mt(this.cm,Q)(this.cm,String.fromCharCode(null==e.charCode?e.keyCode:e.charCode),0)},onContextMenu:Wi,resetPosition:Wi,needsContentAttribute:!0},ne.prototype),e.inputStyles={textarea:te,contenteditable:ne},ue.prototype={primary:function(){return this.ranges[this.primIndex]},equals:function(e){if(e==this)return!0;if(e.primIndex!=this.primIndex||e.ranges.length!=this.ranges.length)return!1;for(var t=0;t<this.ranges.length;t++){var r=this.ranges[t],n=e.ranges[t];if(0!=Oo(r.anchor,n.anchor)||0!=Oo(r.head,n.head))return!1}return!0},deepCopy:function(){for(var e=[],t=0;t<this.ranges.length;t++)e[t]=new ce(_(this.ranges[t].anchor),_(this.ranges[t].head));return new ue(e,this.primIndex)},somethingSelected:function(){for(var e=0;e<this.ranges.length;e++)if(!this.ranges[e].empty())return!0;return!1},contains:function(e,t){t||(t=e);for(var r=0;r<this.ranges.length;r++){var n=this.ranges[r];if(Oo(t,n.from())>=0&&Oo(e,n.to())<=0)return r}return-1}},ce.prototype={from:function(){return $(this.anchor,this.head)},to:function(){return Y(this.anchor,this.head)},empty:function(){return this.head.line==this.anchor.line&&this.head.ch==this.anchor.ch}};var Ho,Io,Po,Eo={left:0,right:0,top:0,bottom:0},zo=null,Fo=0,Ro=0,Bo=0,Go=null;fo?Go=-.53:ao?Go=15:vo?Go=-.7:yo&&(Go=-1/3);var Uo=function(e){var t=e.wheelDeltaX,r=e.wheelDeltaY;return null==t&&e.detail&&e.axis==e.HORIZONTAL_AXIS&&(t=e.detail),null==r&&e.detail&&e.axis==e.VERTICAL_AXIS?r=e.detail:null==r&&(r=e.wheelDelta),{x:t,y:r}};e.wheelEventPixels=function(e){var t=Uo(e);return t.x*=Go,t.y*=Go,t};var Vo=new Li,Ko=null,jo=e.changeEnd=function(e){return e.text?Wo(e.from.line+e.text.length-1,Mi(e.text).length+(1==e.text.length?e.from.ch:0)):e.to};e.prototype={constructor:e,focus:function(){window.focus(),this.display.input.focus()},setOption:function(e,t){var r=this.options,n=r[e];(r[e]!=t||"mode"==e)&&(r[e]=t,_o.hasOwnProperty(e)&&Mt(this,_o[e])(this,t,n))},getOption:function(e){return this.options[e]},getDoc:function(){return this.doc},addKeyMap:function(e,t){this.state.keyMaps[t?"push":"unshift"](Gr(e))},removeKeyMap:function(e){for(var t=this.state.keyMaps,r=0;r<t.length;++r)if(t[r]==e||t[r].name==e)return t.splice(r,1),!0},addOverlay:Nt(function(t,r){var n=t.token?t:e.getMode(this.options,t);if(n.startState)throw new Error("Overlays may not be stateful.");this.state.overlays.push({mode:n,modeSpec:t,opaque:r&&r.opaque}),this.state.modeGen++,Dt(this)}),removeOverlay:Nt(function(e){for(var t=this.state.overlays,r=0;r<t.length;++r){var n=t[r].modeSpec;if(n==e||"string"==typeof e&&n.name==e)return t.splice(r,1),this.state.modeGen++,void Dt(this)}}),indentLine:Nt(function(e,t,r){"string"!=typeof t&&"number"!=typeof t&&(t=null==t?this.options.smartIndent?"smart":"prev":t?"add":"subtract"),ve(this.doc,e)&&Ir(this,e,t,r)}),indentSelection:Nt(function(e){for(var t=this.doc.sel.ranges,r=-1,n=0;n<t.length;n++){var i=t[n];if(i.empty())i.head.line>r&&(Ir(this,i.head.line,e,!0),r=i.head.line,n==this.doc.sel.primIndex&&Dr(this));else{var o=i.from(),l=i.to(),s=Math.max(r,o.line);r=Math.min(this.lastLine(),l.line-(l.ch?0:1))+1;for(var a=s;r>a;++a)Ir(this,a,e);var u=this.doc.sel.ranges;0==o.ch&&t.length==u.length&&u[n].from().ch>0&&xe(this.doc,n,new ce(o,u[n].to()),Nl)}}}),getTokenAt:function(e,t){return Mn(this,e,t)},getLineTokens:function(e,t){return Mn(this,Wo(e),t,!0)},getTokenTypeAt:function(e){e=pe(this.doc,e);var t,r=Wn(this,Xn(this.doc,e.line)),n=0,i=(r.length-1)/2,o=e.ch;if(0==o)t=r[2];else for(;;){var l=n+i>>1;if((l?r[2*l-1]:0)>=o)i=l;else{if(!(r[2*l+1]<o)){t=r[2*l+2];break}n=l+1}}var s=t?t.indexOf("cm-overlay "):-1;return 0>s?t:0==s?null:t.slice(0,s-1)},getModeAt:function(t){var r=this.doc.mode;return r.innerMode?e.innerMode(r,this.getTokenAt(t).state).mode:r},getHelper:function(e,t){return this.getHelpers(e,t)[0]},getHelpers:function(e,t){var r=[];if(!Jo.hasOwnProperty(t))return r;var n=Jo[t],i=this.getModeAt(e);if("string"==typeof i[t])n[i[t]]&&r.push(n[i[t]]);else if(i[t])for(var o=0;o<i[t].length;o++){var l=n[i[t][o]];l&&r.push(l)}else i.helperType&&n[i.helperType]?r.push(n[i.helperType]):n[i.name]&&r.push(n[i.name]);for(var o=0;o<n._global.length;o++){var s=n._global[o];s.pred(i,this)&&-1==Ni(r,s.val)&&r.push(s.val)}return r},getStateAfter:function(e,t){var r=this.doc;return e=de(r,null==e?r.first+r.size-1:e),Re(this,e+1,t)},cursorCoords:function(e,t){var r,n=this.doc.sel.primary();return r=null==e?n.head:"object"==typeof e?pe(this.doc,e):e?n.from():n.to(),ct(this,r,t||"page")},charCoords:function(e,t){return ut(this,pe(this.doc,e),t||"page")},coordsChar:function(e,t){return e=at(this,e,t||"page"),dt(this,e.left,e.top)},lineAtHeight:function(e,t){return e=at(this,{top:e,left:0},t||"page").top,Zn(this.doc,e+this.display.viewOffset)},heightAtLine:function(e,t){var r,n=!1;if("number"==typeof e){var i=this.doc.first+this.doc.size-1;e<this.doc.first?e=this.doc.first:e>i&&(e=i,n=!0),r=Xn(this.doc,e)}else r=e;return st(this,r,{top:0,left:0},t||"page").top+(n?this.doc.height-Qn(r):0)},defaultTextHeight:function(){return gt(this.display)},defaultCharWidth:function(){return vt(this.display)},setGutterMarker:Nt(function(e,t,r){return Pr(this.doc,e,"gutter",function(e){var n=e.gutterMarkers||(e.gutterMarkers={});return n[t]=r,!r&&Pi(n)&&(e.gutterMarkers=null),!0})}),clearGutter:Nt(function(e){var t=this,r=t.doc,n=r.first;r.iter(function(r){r.gutterMarkers&&r.gutterMarkers[e]&&(r.gutterMarkers[e]=null,Ht(t,n,"gutter"),Pi(r.gutterMarkers)&&(r.gutterMarkers=null)),++n})}),lineInfo:function(e){if("number"==typeof e){if(!ve(this.doc,e))return null;var t=e;if(e=Xn(this.doc,e),!e)return null}else{var t=qn(e);if(null==t)return null}return{line:t,handle:e,text:e.text,gutterMarkers:e.gutterMarkers,textClass:e.textClass,bgClass:e.bgClass,wrapClass:e.wrapClass,widgets:e.widgets}},getViewport:function(){return{from:this.display.viewFrom,to:this.display.viewTo}},addWidget:function(e,t,r,n,i){var o=this.display;e=ct(this,pe(this.doc,e));var l=e.bottom,s=e.left;if(t.style.position="absolute",t.setAttribute("cm-ignore-events","true"),this.display.input.setUneditable(t),o.sizer.appendChild(t),"over"==n)l=e.top;else if("above"==n||"near"==n){var a=Math.max(o.wrapper.clientHeight,this.doc.height),u=Math.max(o.sizer.clientWidth,o.lineSpace.clientWidth);("above"==n||e.bottom+t.offsetHeight>a)&&e.top>t.offsetHeight?l=e.top-t.offsetHeight:e.bottom+t.offsetHeight<=a&&(l=e.bottom),s+t.offsetWidth>u&&(s=u-t.offsetWidth)}t.style.top=l+"px",t.style.left=t.style.right="","right"==i?(s=o.sizer.clientWidth-t.offsetWidth,t.style.right="0px"):("left"==i?s=0:"middle"==i&&(s=(o.sizer.clientWidth-t.offsetWidth)/2),t.style.left=s+"px"),r&&Ar(this,s,l,s+t.offsetWidth,l+t.offsetHeight)},triggerOnKeyDown:Nt(lr),triggerOnKeyPress:Nt(ur),triggerOnKeyUp:ar,execCommand:function(e){return rl.hasOwnProperty(e)?rl[e](this):void 0},findPosH:function(e,t,r,n){var i=1;0>t&&(i=-1,t=-t);for(var o=0,l=pe(this.doc,e);t>o&&(l=zr(this.doc,l,i,r,n),!l.hitSide);++o);return l},moveH:Nt(function(e,t){var r=this;r.extendSelectionsBy(function(n){return r.display.shift||r.doc.extend||n.empty()?zr(r.doc,n.head,e,t,r.options.rtlMoveVisually):0>e?n.from():n.to()},Wl)}),deleteH:Nt(function(e,t){var r=this.doc.sel,n=this.doc;r.somethingSelected()?n.replaceSelection("",null,"+delete"):Er(this,function(r){var i=zr(n,r.head,e,t,!1);return 0>e?{from:i,to:r.head}:{from:r.head,to:i}})}),findPosV:function(e,t,r,n){var i=1,o=n;0>t&&(i=-1,t=-t);for(var l=0,s=pe(this.doc,e);t>l;++l){var a=ct(this,s,"div");if(null==o?o=a.left:a.left=o,s=Fr(this,a,i,r),s.hitSide)break}return s},moveV:Nt(function(e,t){var r=this,n=this.doc,i=[],o=!r.display.shift&&!n.extend&&n.sel.somethingSelected();if(n.extendSelectionsBy(function(l){if(o)return 0>e?l.from():l.to();var s=ct(r,l.head,"div");null!=l.goalColumn&&(s.left=l.goalColumn),i.push(s.left);var a=Fr(r,s,e,t);return"page"==t&&l==n.sel.primary()&&Or(r,null,ut(r,a,"div").top-s.top),a},Wl),i.length)for(var l=0;l<n.sel.ranges.length;l++)n.sel.ranges[l].goalColumn=i[l]}),findWordAt:function(e){var t=this.doc,r=Xn(t,e.line).text,n=e.ch,i=e.ch;if(r){var o=this.getHelper(e,"wordChars");(e.xRel<0||i==r.length)&&n?--n:++i;for(var l=r.charAt(n),s=Ii(l,o)?function(e){return Ii(e,o)}:/\s/.test(l)?function(e){return/\s/.test(e)}:function(e){return!/\s/.test(e)&&!Ii(e)};n>0&&s(r.charAt(n-1));)--n;for(;i<r.length&&s(r.charAt(i));)++i}return new ce(Wo(e.line,n),Wo(e.line,i))},toggleOverwrite:function(e){(null==e||e!=this.state.overwrite)&&((this.state.overwrite=!this.state.overwrite)?Ul(this.display.cursorDiv,"CodeMirror-overwrite"):Gl(this.display.cursorDiv,"CodeMirror-overwrite"),Ll(this,"overwriteToggle",this,this.state.overwrite))},hasFocus:function(){return this.display.input.getField()==Bi()},scrollTo:Nt(function(e,t){(null!=e||null!=t)&&Hr(this),null!=e&&(this.curOp.scrollLeft=e),null!=t&&(this.curOp.scrollTop=t)}),getScrollInfo:function(){var e=this.display.scroller;return{left:e.scrollLeft,top:e.scrollTop,height:e.scrollHeight-Ve(this)-this.display.barHeight,width:e.scrollWidth-Ve(this)-this.display.barWidth,clientHeight:je(this),clientWidth:Ke(this)}},scrollIntoView:Nt(function(e,t){if(null==e?(e={from:this.doc.sel.primary().head,to:null},null==t&&(t=this.options.cursorScrollMargin)):"number"==typeof e?e={from:Wo(e,0),to:null}:null==e.from&&(e={from:e,to:null}),e.to||(e.to=e.from),e.margin=t||0,null!=e.from.line)Hr(this),this.curOp.scrollToPos=e;else{var r=Wr(this,Math.min(e.from.left,e.to.left),Math.min(e.from.top,e.to.top)-e.margin,Math.max(e.from.right,e.to.right),Math.max(e.from.bottom,e.to.bottom)+e.margin);this.scrollTo(r.scrollLeft,r.scrollTop)}}),setSize:Nt(function(e,t){function r(e){return"number"==typeof e||/^\d+$/.test(String(e))?e+"px":e}var n=this;null!=e&&(n.display.wrapper.style.width=r(e)),null!=t&&(n.display.wrapper.style.height=r(t)),n.options.lineWrapping&&nt(this);var i=n.display.viewFrom;n.doc.iter(i,n.display.viewTo,function(e){if(e.widgets)for(var t=0;t<e.widgets.length;t++)if(e.widgets[t].noHScroll){Ht(n,i,"widget");break}++i}),n.curOp.forceUpdate=!0,Ll(n,"refresh",this)}),operation:function(e){return Tt(this,e)},refresh:Nt(function(){var e=this.display.cachedTextHeight;Dt(this),this.curOp.forceUpdate=!0,it(this),this.scrollTo(this.doc.scrollLeft,this.doc.scrollTop),c(this),(null==e||Math.abs(e-gt(this.display))>.5)&&l(this),Ll(this,"refresh",this)}),swapDoc:Nt(function(e){var t=this.doc;return t.cm=null,jn(this,e),it(this),this.display.input.reset(),this.scrollTo(e.scrollLeft,e.scrollTop),this.curOp.forceScroll=!0,yi(this,"swapDoc",this,t),t}),getInputField:function(){return this.display.input.getField()},getWrapperElement:function(){return this.display.wrapper},getScrollerElement:function(){return this.display.scroller},getGutterElement:function(){return this.display.gutters}},Si(e);var Xo=e.defaults={},_o=e.optionHandlers={},Yo=e.Init={toString:function(){return"CodeMirror.Init"}};Rr("value","",function(e,t){e.setValue(t)},!0),Rr("mode",null,function(e,t){e.doc.modeOption=t,r(e)},!0),Rr("indentUnit",2,r,!0),Rr("indentWithTabs",!1),Rr("smartIndent",!0),Rr("tabSize",4,function(e){n(e),it(e),Dt(e)},!0),Rr("specialChars",/[\t\u0000-\u0019\u00ad\u200b-\u200f\u2028\u2029\ufeff]/g,function(t,r,n){t.state.specialChars=new RegExp(r.source+(r.test(" ")?"":"| "),"g"),n!=e.Init&&t.refresh()}),Rr("specialCharPlaceholder",In,function(e){e.refresh()},!0),Rr("electricChars",!0),Rr("inputStyle",Co?"contenteditable":"textarea",function(){throw new Error("inputStyle can not (yet) be changed in a running editor")},!0),Rr("rtlMoveVisually",!Lo),Rr("wholeLineUpdateBefore",!0),Rr("theme","default",function(e){s(e),a(e)},!0),Rr("keyMap","default",function(t,r,n){var i=Gr(r),o=n!=e.Init&&Gr(n);o&&o.detach&&o.detach(t,i),i.attach&&i.attach(t,o||null)}),Rr("extraKeys",null),Rr("lineWrapping",!1,i,!0),Rr("gutters",[],function(e){d(e.options),a(e)},!0),Rr("fixedGutter",!0,function(e,t){e.display.gutters.style.left=t?L(e.display)+"px":"0",e.refresh()},!0),Rr("coverGutterNextToScrollbar",!1,function(e){y(e)},!0),Rr("scrollbarStyle","native",function(e){m(e),y(e),e.display.scrollbars.setScrollTop(e.doc.scrollTop),e.display.scrollbars.setScrollLeft(e.doc.scrollLeft)},!0),Rr("lineNumbers",!1,function(e){d(e.options),a(e)},!0),Rr("firstLineNumber",1,a,!0),Rr("lineNumberFormatter",function(e){return e},a,!0),Rr("showCursorWhenSelecting",!1,Oe,!0),Rr("resetSelectionOnContextMenu",!0),Rr("lineWiseCopyCut",!0),Rr("readOnly",!1,function(e,t){"nocursor"==t?(hr(e),e.display.input.blur(),e.display.disabled=!0):(e.display.disabled=!1,t||e.display.input.reset())}),Rr("disableInput",!1,function(e,t){t||e.display.input.reset()},!0),Rr("dragDrop",!0,Bt),Rr("cursorBlinkRate",530),Rr("cursorScrollMargin",0),Rr("cursorHeight",1,Oe,!0),Rr("singleCursorHeightPerLine",!0,Oe,!0),Rr("workTime",100),Rr("workDelay",100),Rr("flattenSpans",!0,n,!0),Rr("addModeClass",!1,n,!0),Rr("pollInterval",100),Rr("undoDepth",200,function(e,t){e.doc.history.undoDepth=t}),Rr("historyEventDelay",1250),Rr("viewportMargin",10,function(e){e.refresh()},!0),Rr("maxHighlightLength",1e4,n,!0),Rr("moveInputWithCursor",!0,function(e,t){t||e.display.input.resetPosition()}),Rr("tabindex",null,function(e,t){e.display.input.getField().tabIndex=t||""}),Rr("autofocus",null);var $o=e.modes={},qo=e.mimeModes={};e.defineMode=function(t,r){e.defaults.mode||"null"==t||(e.defaults.mode=t),arguments.length>2&&(r.dependencies=Array.prototype.slice.call(arguments,2)),$o[t]=r},e.defineMIME=function(e,t){qo[e]=t},e.resolveMode=function(t){if("string"==typeof t&&qo.hasOwnProperty(t))t=qo[t];else if(t&&"string"==typeof t.name&&qo.hasOwnProperty(t.name)){var r=qo[t.name];"string"==typeof r&&(r={name:r}),t=Oi(r,t),t.name=r.name}else if("string"==typeof t&&/^[\w\-]+\/[\w\-]+\+xml$/.test(t))return e.resolveMode("application/xml");return"string"==typeof t?{name:t}:t||{name:"null"}},e.getMode=function(t,r){var r=e.resolveMode(r),n=$o[r.name];if(!n)return e.getMode(t,"text/plain");var i=n(t,r);if(Zo.hasOwnProperty(r.name)){var o=Zo[r.name];for(var l in o)o.hasOwnProperty(l)&&(i.hasOwnProperty(l)&&(i["_"+l]=i[l]),i[l]=o[l])}if(i.name=r.name,r.helperType&&(i.helperType=r.helperType),r.modeProps)for(var l in r.modeProps)i[l]=r.modeProps[l];return i},e.defineMode("null",function(){return{token:function(e){e.skipToEnd()}}}),e.defineMIME("text/plain","null");var Zo=e.modeExtensions={};e.extendMode=function(e,t){var r=Zo.hasOwnProperty(e)?Zo[e]:Zo[e]={};Di(t,r)},e.defineExtension=function(t,r){e.prototype[t]=r},e.defineDocExtension=function(e,t){vl.prototype[e]=t},e.defineOption=Rr;var Qo=[];e.defineInitHook=function(e){Qo.push(e)};var Jo=e.helpers={};e.registerHelper=function(t,r,n){Jo.hasOwnProperty(t)||(Jo[t]=e[t]={_global:[]}),Jo[t][r]=n},e.registerGlobalHelper=function(t,r,n,i){e.registerHelper(t,r,i),Jo[t]._global.push({pred:n,val:i})};var el=e.copyState=function(e,t){if(t===!0)return t;if(e.copyState)return e.copyState(t);var r={};for(var n in t){var i=t[n];i instanceof Array&&(i=i.concat([])),r[n]=i}return r},tl=e.startState=function(e,t,r){return e.startState?e.startState(t,r):!0};e.innerMode=function(e,t){for(;e.innerMode;){var r=e.innerMode(t);if(!r||r.mode==e)break;t=r.state,e=r.mode}return r||{mode:e,state:t}};var rl=e.commands={selectAll:function(e){e.setSelection(Wo(e.firstLine(),0),Wo(e.lastLine()),Nl)},singleSelection:function(e){e.setSelection(e.getCursor("anchor"),e.getCursor("head"),Nl)},killLine:function(e){Er(e,function(t){if(t.empty()){var r=Xn(e.doc,t.head.line).text.length;return t.head.ch==r&&t.head.line<e.lastLine()?{from:t.head,to:Wo(t.head.line+1,0)}:{from:t.head,to:Wo(t.head.line,r)}}return{from:t.from(),to:t.to()}})},deleteLine:function(e){Er(e,function(t){return{from:Wo(t.from().line,0),to:pe(e.doc,Wo(t.to().line+1,0))}})},delLineLeft:function(e){Er(e,function(e){return{from:Wo(e.from().line,0),to:e.from()}})},delWrappedLineLeft:function(e){Er(e,function(t){var r=e.charCoords(t.head,"div").top+5,n=e.coordsChar({left:0,top:r},"div");return{from:n,to:t.from()}})},delWrappedLineRight:function(e){Er(e,function(t){var r=e.charCoords(t.head,"div").top+5,n=e.coordsChar({left:e.display.lineDiv.offsetWidth+100,top:r},"div");return{from:t.from(),to:n}})},undo:function(e){e.undo()},redo:function(e){e.redo()},undoSelection:function(e){e.undoSelection()},redoSelection:function(e){e.redoSelection()},goDocStart:function(e){e.extendSelection(Wo(e.firstLine(),0))},goDocEnd:function(e){e.extendSelection(Wo(e.lastLine()))},goLineStart:function(e){e.extendSelectionsBy(function(t){return eo(e,t.head.line)},{origin:"+move",bias:1})},goLineStartSmart:function(e){e.extendSelectionsBy(function(t){return ro(e,t.head)},{origin:"+move",bias:1})},goLineEnd:function(e){e.extendSelectionsBy(function(t){return to(e,t.head.line)},{origin:"+move",bias:-1})},goLineRight:function(e){e.extendSelectionsBy(function(t){var r=e.charCoords(t.head,"div").top+5;return e.coordsChar({left:e.display.lineDiv.offsetWidth+100,top:r},"div")},Wl)},goLineLeft:function(e){e.extendSelectionsBy(function(t){var r=e.charCoords(t.head,"div").top+5;return e.coordsChar({left:0,top:r},"div")},Wl)},goLineLeftSmart:function(e){e.extendSelectionsBy(function(t){var r=e.charCoords(t.head,"div").top+5,n=e.coordsChar({left:0,top:r},"div");return n.ch<e.getLine(n.line).search(/\S/)?ro(e,t.head):n},Wl)},goLineUp:function(e){e.moveV(-1,"line")},goLineDown:function(e){e.moveV(1,"line")},goPageUp:function(e){e.moveV(-1,"page")},goPageDown:function(e){e.moveV(1,"page")},goCharLeft:function(e){e.moveH(-1,"char")},goCharRight:function(e){e.moveH(1,"char")},goColumnLeft:function(e){e.moveH(-1,"column")},goColumnRight:function(e){e.moveH(1,"column")},goWordLeft:function(e){e.moveH(-1,"word")},goGroupRight:function(e){e.moveH(1,"group")},goGroupLeft:function(e){e.moveH(-1,"group")},goWordRight:function(e){e.moveH(1,"word")},delCharBefore:function(e){e.deleteH(-1,"char")},delCharAfter:function(e){e.deleteH(1,"char")},delWordBefore:function(e){e.deleteH(-1,"word")},delWordAfter:function(e){e.deleteH(1,"word")},delGroupBefore:function(e){e.deleteH(-1,"group")},delGroupAfter:function(e){e.deleteH(1,"group")},indentAuto:function(e){e.indentSelection("smart")},indentMore:function(e){e.indentSelection("add")},indentLess:function(e){e.indentSelection("subtract")},insertTab:function(e){e.replaceSelection(" ")},insertSoftTab:function(e){for(var t=[],r=e.listSelections(),n=e.options.tabSize,i=0;i<r.length;i++){var o=r[i].from(),l=Ol(e.getLine(o.line),o.ch,n);t.push(new Array(n-l%n+1).join(" "))}e.replaceSelections(t)},defaultTab:function(e){e.somethingSelected()?e.indentSelection("add"):e.execCommand("insertTab")},transposeChars:function(e){Tt(e,function(){for(var t=e.listSelections(),r=[],n=0;n<t.length;n++){var i=t[n].head,o=Xn(e.doc,i.line).text;if(o)if(i.ch==o.length&&(i=new Wo(i.line,i.ch-1)),i.ch>0)i=new Wo(i.line,i.ch+1),e.replaceRange(o.charAt(i.ch-1)+o.charAt(i.ch-2),Wo(i.line,i.ch-2),i,"+transpose");else if(i.line>e.doc.first){var l=Xn(e.doc,i.line-1).text;l&&e.replaceRange(o.charAt(0)+"\n"+l.charAt(l.length-1),Wo(i.line-1,l.length-1),Wo(i.line,1),"+transpose")}r.push(new ce(i,i))}e.setSelections(r)})},newlineAndIndent:function(e){Tt(e,function(){for(var t=e.listSelections().length,r=0;t>r;r++){var n=e.listSelections()[r];e.replaceRange("\n",n.anchor,n.head,"+input"),e.indentLine(n.from().line+1,null,!0),Dr(e)}})},toggleOverwrite:function(e){e.toggleOverwrite()}},nl=e.keyMap={};nl.basic={Left:"goCharLeft",Right:"goCharRight",Up:"goLineUp",Down:"goLineDown",End:"goLineEnd",Home:"goLineStartSmart",PageUp:"goPageUp",PageDown:"goPageDown",Delete:"delCharAfter",Backspace:"delCharBefore","Shift-Backspace":"delCharBefore",Tab:"defaultTab","Shift-Tab":"indentAuto",Enter:"newlineAndIndent",Insert:"toggleOverwrite",Esc:"singleSelection"},nl.pcDefault={"Ctrl-A":"selectAll","Ctrl-D":"deleteLine","Ctrl-Z":"undo","Shift-Ctrl-Z":"redo","Ctrl-Y":"redo","Ctrl-Home":"goDocStart","Ctrl-End":"goDocEnd","Ctrl-Up":"goLineUp","Ctrl-Down":"goLineDown","Ctrl-Left":"goGroupLeft","Ctrl-Right":"goGroupRight","Alt-Left":"goLineStart","Alt-Right":"goLineEnd","Ctrl-Backspace":"delGroupBefore","Ctrl-Delete":"delGroupAfter","Ctrl-S":"save","Ctrl-F":"find","Ctrl-G":"findNext","Shift-Ctrl-G":"findPrev","Shift-Ctrl-F":"replace","Shift-Ctrl-R":"replaceAll","Ctrl-[":"indentLess","Ctrl-]":"indentMore","Ctrl-U":"undoSelection","Shift-Ctrl-U":"redoSelection","Alt-U":"redoSelection",fallthrough:"basic"},nl.emacsy={"Ctrl-F":"goCharRight","Ctrl-B":"goCharLeft","Ctrl-P":"goLineUp","Ctrl-N":"goLineDown","Alt-F":"goWordRight","Alt-B":"goWordLeft","Ctrl-A":"goLineStart","Ctrl-E":"goLineEnd","Ctrl-V":"goPageDown","Shift-Ctrl-V":"goPageUp","Ctrl-D":"delCharAfter","Ctrl-H":"delCharBefore","Alt-D":"delWordAfter","Alt-Backspace":"delWordBefore","Ctrl-K":"killLine","Ctrl-T":"transposeChars"},nl.macDefault={"Cmd-A":"selectAll","Cmd-D":"deleteLine","Cmd-Z":"undo","Shift-Cmd-Z":"redo","Cmd-Y":"redo","Cmd-Home":"goDocStart","Cmd-Up":"goDocStart","Cmd-End":"goDocEnd","Cmd-Down":"goDocEnd","Alt-Left":"goGroupLeft","Alt-Right":"goGroupRight","Cmd-Left":"goLineLeft","Cmd-Right":"goLineRight","Alt-Backspace":"delGroupBefore","Ctrl-Alt-Backspace":"delGroupAfter","Alt-Delete":"delGroupAfter","Cmd-S":"save","Cmd-F":"find","Cmd-G":"findNext","Shift-Cmd-G":"findPrev","Cmd-Alt-F":"replace","Shift-Cmd-Alt-F":"replaceAll","Cmd-[":"indentLess","Cmd-]":"indentMore","Cmd-Backspace":"delWrappedLineLeft","Cmd-Delete":"delWrappedLineRight","Cmd-U":"undoSelection","Shift-Cmd-U":"redoSelection","Ctrl-Up":"goDocStart","Ctrl-Down":"goDocEnd",fallthrough:["basic","emacsy"]},nl["default"]=So?nl.macDefault:nl.pcDefault,e.normalizeKeyMap=function(e){var t={};for(var r in e)if(e.hasOwnProperty(r)){var n=e[r];if(/^(name|fallthrough|(de|at)tach)$/.test(r))continue;if("..."==n){delete e[r];continue}for(var i=Ai(r.split(" "),Br),o=0;o<i.length;o++){var l,s;o==i.length-1?(s=r,l=n):(s=i.slice(0,o+1).join(" "),l="...");var a=t[s];if(a){if(a!=l)throw new Error("Inconsistent bindings for "+s)}else t[s]=l}delete e[r]}for(var u in t)e[u]=t[u];return e};var il=e.lookupKey=function(e,t,r,n){t=Gr(t);var i=t.call?t.call(e,n):t[e];if(i===!1)return"nothing";if("..."===i)return"multi";if(null!=i&&r(i))return"handled";if(t.fallthrough){if("[object Array]"!=Object.prototype.toString.call(t.fallthrough))return il(e,t.fallthrough,r,n);for(var o=0;o<t.fallthrough.length;o++){var l=il(e,t.fallthrough[o],r,n);if(l)return l}}},ol=e.isModifierKey=function(e){var t="string"==typeof e?e:$l[e.keyCode];return"Ctrl"==t||"Alt"==t||"Shift"==t||"Mod"==t},ll=e.keyName=function(e,t){if(mo&&34==e.keyCode&&e["char"])return!1;var r=$l[e.keyCode],n=r;return null==n||e.altGraphKey?!1:(e.altKey&&"Alt"!=r&&(n="Alt-"+n),(To?e.metaKey:e.ctrlKey)&&"Ctrl"!=r&&(n="Ctrl-"+n),(To?e.ctrlKey:e.metaKey)&&"Cmd"!=r&&(n="Cmd-"+n),!t&&e.shiftKey&&"Shift"!=r&&(n="Shift-"+n),n)};e.fromTextArea=function(t,r){function n(){t.value=u.getValue()}if(r=r?Di(r):{},r.value=t.value,!r.tabindex&&t.tabIndex&&(r.tabindex=t.tabIndex),!r.placeholder&&t.placeholder&&(r.placeholder=t.placeholder),null==r.autofocus){var i=Bi();r.autofocus=i==t||null!=t.getAttribute("autofocus")&&i==document.body;
|
5 |
-
}if(t.form&&(Cl(t.form,"submit",n),!r.leaveSubmitMethodAlone)){var o=t.form,l=o.submit;try{var s=o.submit=function(){n(),o.submit=l,o.submit(),o.submit=s}}catch(a){}}r.finishInit=function(e){e.save=n,e.getTextArea=function(){return t},e.toTextArea=function(){e.toTextArea=isNaN,n(),t.parentNode.removeChild(e.getWrapperElement()),t.style.display="",t.form&&(Sl(t.form,"submit",n),"function"==typeof t.form.submit&&(t.form.submit=l))}},t.style.display="none";var u=e(function(e){t.parentNode.insertBefore(e,t.nextSibling)},r);return u};var sl=e.StringStream=function(e,t){this.pos=this.start=0,this.string=e,this.tabSize=t||8,this.lastColumnPos=this.lastColumnValue=0,this.lineStart=0};sl.prototype={eol:function(){return this.pos>=this.string.length},sol:function(){return this.pos==this.lineStart},peek:function(){return this.string.charAt(this.pos)||void 0},next:function(){return this.pos<this.string.length?this.string.charAt(this.pos++):void 0},eat:function(e){var t=this.string.charAt(this.pos);if("string"==typeof e)var r=t==e;else var r=t&&(e.test?e.test(t):e(t));return r?(++this.pos,t):void 0},eatWhile:function(e){for(var t=this.pos;this.eat(e););return this.pos>t},eatSpace:function(){for(var e=this.pos;/[\s\u00a0]/.test(this.string.charAt(this.pos));)++this.pos;return this.pos>e},skipToEnd:function(){this.pos=this.string.length},skipTo:function(e){var t=this.string.indexOf(e,this.pos);return t>-1?(this.pos=t,!0):void 0},backUp:function(e){this.pos-=e},column:function(){return this.lastColumnPos<this.start&&(this.lastColumnValue=Ol(this.string,this.start,this.tabSize,this.lastColumnPos,this.lastColumnValue),this.lastColumnPos=this.start),this.lastColumnValue-(this.lineStart?Ol(this.string,this.lineStart,this.tabSize):0)},indentation:function(){return Ol(this.string,null,this.tabSize)-(this.lineStart?Ol(this.string,this.lineStart,this.tabSize):0)},match:function(e,t,r){if("string"!=typeof e){var n=this.string.slice(this.pos).match(e);return n&&n.index>0?null:(n&&t!==!1&&(this.pos+=n[0].length),n)}var i=function(e){return r?e.toLowerCase():e},o=this.string.substr(this.pos,e.length);return i(o)==i(e)?(t!==!1&&(this.pos+=e.length),!0):void 0},current:function(){return this.string.slice(this.start,this.pos)},hideFirstChars:function(e,t){this.lineStart+=e;try{return t()}finally{this.lineStart-=e}}};var al=0,ul=e.TextMarker=function(e,t){this.lines=[],this.type=t,this.doc=e,this.id=++al};Si(ul),ul.prototype.clear=function(){if(!this.explicitlyCleared){var e=this.doc.cm,t=e&&!e.curOp;if(t&&mt(e),Ci(this,"clear")){var r=this.find();r&&yi(this,"clear",r.from,r.to)}for(var n=null,i=null,o=0;o<this.lines.length;++o){var l=this.lines[o],s=Yr(l.markedSpans,this);e&&!this.collapsed?Ht(e,qn(l),"text"):e&&(null!=s.to&&(i=qn(l)),null!=s.from&&(n=qn(l))),l.markedSpans=$r(l.markedSpans,s),null==s.from&&this.collapsed&&!mn(this.doc,l)&&e&&$n(l,gt(e.display))}if(e&&this.collapsed&&!e.options.lineWrapping)for(var o=0;o<this.lines.length;++o){var a=dn(this.lines[o]),u=f(a);u>e.display.maxLineLength&&(e.display.maxLine=a,e.display.maxLineLength=u,e.display.maxLineChanged=!0)}null!=n&&e&&this.collapsed&&Dt(e,n,i+1),this.lines.length=0,this.explicitlyCleared=!0,this.atomic&&this.doc.cantEdit&&(this.doc.cantEdit=!1,e&&Ne(e.doc)),e&&yi(e,"markerCleared",e,this),t&&bt(e),this.parent&&this.parent.clear()}},ul.prototype.find=function(e,t){null==e&&"bookmark"==this.type&&(e=1);for(var r,n,i=0;i<this.lines.length;++i){var o=this.lines[i],l=Yr(o.markedSpans,this);if(null!=l.from&&(r=Wo(t?o:qn(o),l.from),-1==e))return r;if(null!=l.to&&(n=Wo(t?o:qn(o),l.to),1==e))return n}return r&&{from:r,to:n}},ul.prototype.changed=function(){var e=this.find(-1,!0),t=this,r=this.doc.cm;e&&r&&Tt(r,function(){var n=e.line,i=qn(e.line),o=qe(r,i);if(o&&(rt(o),r.curOp.selectionChanged=r.curOp.forceUpdate=!0),r.curOp.updateMaxLine=!0,!mn(t.doc,n)&&null!=t.height){var l=t.height;t.height=null;var s=wn(t)-l;s&&$n(n,n.height+s)}})},ul.prototype.attachLine=function(e){if(!this.lines.length&&this.doc.cm){var t=this.doc.cm.curOp;t.maybeHiddenMarkers&&-1!=Ni(t.maybeHiddenMarkers,this)||(t.maybeUnhiddenMarkers||(t.maybeUnhiddenMarkers=[])).push(this)}this.lines.push(e)},ul.prototype.detachLine=function(e){if(this.lines.splice(Ni(this.lines,e),1),!this.lines.length&&this.doc.cm){var t=this.doc.cm.curOp;(t.maybeHiddenMarkers||(t.maybeHiddenMarkers=[])).push(this)}};var al=0,cl=e.SharedTextMarker=function(e,t){this.markers=e,this.primary=t;for(var r=0;r<e.length;++r)e[r].parent=this};Si(cl),cl.prototype.clear=function(){if(!this.explicitlyCleared){this.explicitlyCleared=!0;for(var e=0;e<this.markers.length;++e)this.markers[e].clear();yi(this,"clear")}},cl.prototype.find=function(e,t){return this.primary.find(e,t)};var fl=e.LineWidget=function(e,t,r){if(r)for(var n in r)r.hasOwnProperty(n)&&(this[n]=r[n]);this.doc=e,this.node=t};Si(fl),fl.prototype.clear=function(){var e=this.doc.cm,t=this.line.widgets,r=this.line,n=qn(r);if(null!=n&&t){for(var i=0;i<t.length;++i)t[i]==this&&t.splice(i--,1);t.length||(r.widgets=null);var o=wn(this);$n(r,Math.max(0,r.height-o)),e&&Tt(e,function(){bn(e,r,-o),Ht(e,n,"widget")})}},fl.prototype.changed=function(){var e=this.height,t=this.doc.cm,r=this.line;this.height=null;var n=wn(this)-e;n&&($n(r,r.height+n),t&&Tt(t,function(){t.curOp.forceUpdate=!0,bn(t,r,n)}))};var hl=e.Line=function(e,t,r){this.text=e,on(this,t),this.height=r?r(this):1};Si(hl),hl.prototype.lineNo=function(){return qn(this)};var dl={},pl={};Un.prototype={chunkSize:function(){return this.lines.length},removeInner:function(e,t){for(var r=e,n=e+t;n>r;++r){var i=this.lines[r];this.height-=i.height,Sn(i),yi(i,"delete")}this.lines.splice(e,t)},collapse:function(e){e.push.apply(e,this.lines)},insertInner:function(e,t,r){this.height+=r,this.lines=this.lines.slice(0,e).concat(t).concat(this.lines.slice(e));for(var n=0;n<t.length;++n)t[n].parent=this},iterN:function(e,t,r){for(var n=e+t;n>e;++e)if(r(this.lines[e]))return!0}},Vn.prototype={chunkSize:function(){return this.size},removeInner:function(e,t){this.size-=t;for(var r=0;r<this.children.length;++r){var n=this.children[r],i=n.chunkSize();if(i>e){var o=Math.min(t,i-e),l=n.height;if(n.removeInner(e,o),this.height-=l-n.height,i==o&&(this.children.splice(r--,1),n.parent=null),0==(t-=o))break;e=0}else e-=i}if(this.size-t<25&&(this.children.length>1||!(this.children[0]instanceof Un))){var s=[];this.collapse(s),this.children=[new Un(s)],this.children[0].parent=this}},collapse:function(e){for(var t=0;t<this.children.length;++t)this.children[t].collapse(e)},insertInner:function(e,t,r){this.size+=t.length,this.height+=r;for(var n=0;n<this.children.length;++n){var i=this.children[n],o=i.chunkSize();if(o>=e){if(i.insertInner(e,t,r),i.lines&&i.lines.length>50){for(;i.lines.length>50;){var l=i.lines.splice(i.lines.length-25,25),s=new Un(l);i.height-=s.height,this.children.splice(n+1,0,s),s.parent=this}this.maybeSpill()}break}e-=o}},maybeSpill:function(){if(!(this.children.length<=10)){var e=this;do{var t=e.children.splice(e.children.length-5,5),r=new Vn(t);if(e.parent){e.size-=r.size,e.height-=r.height;var n=Ni(e.parent.children,e);e.parent.children.splice(n+1,0,r)}else{var i=new Vn(e.children);i.parent=e,e.children=[i,r],e=i}r.parent=e.parent}while(e.children.length>10);e.parent.maybeSpill()}},iterN:function(e,t,r){for(var n=0;n<this.children.length;++n){var i=this.children[n],o=i.chunkSize();if(o>e){var l=Math.min(t,o-e);if(i.iterN(e,l,r))return!0;if(0==(t-=l))break;e=0}else e-=o}}};var gl=0,vl=e.Doc=function(e,t,r){if(!(this instanceof vl))return new vl(e,t,r);null==r&&(r=0),Vn.call(this,[new Un([new hl("",null)])]),this.first=r,this.scrollTop=this.scrollLeft=0,this.cantEdit=!1,this.cleanGeneration=1,this.frontier=r;var n=Wo(r,0);this.sel=he(n),this.history=new ei(null),this.id=++gl,this.modeOption=t,"string"==typeof e&&(e=jl(e)),Gn(this,{from:n,to:n,text:e}),ke(this,he(n),Nl)};vl.prototype=Oi(Vn.prototype,{constructor:vl,iter:function(e,t,r){r?this.iterN(e-this.first,t-e,r):this.iterN(this.first,this.first+this.size,e)},insert:function(e,t){for(var r=0,n=0;n<t.length;++n)r+=t[n].height;this.insertInner(e-this.first,t,r)},remove:function(e,t){this.removeInner(e-this.first,t)},getValue:function(e){var t=Yn(this,this.first,this.first+this.size);return e===!1?t:t.join(e||"\n")},setValue:At(function(e){var t=Wo(this.first,0),r=this.first+this.size-1;wr(this,{from:t,to:Wo(r,Xn(this,r).text.length),text:jl(e),origin:"setValue",full:!0},!0),ke(this,he(t))}),replaceRange:function(e,t,r,n){t=pe(this,t),r=r?pe(this,r):t,Tr(this,e,t,r,n)},getRange:function(e,t,r){var n=_n(this,pe(this,e),pe(this,t));return r===!1?n:n.join(r||"\n")},getLine:function(e){var t=this.getLineHandle(e);return t&&t.text},getLineHandle:function(e){return ve(this,e)?Xn(this,e):void 0},getLineNumber:function(e){return qn(e)},getLineHandleVisualStart:function(e){return"number"==typeof e&&(e=Xn(this,e)),dn(e)},lineCount:function(){return this.size},firstLine:function(){return this.first},lastLine:function(){return this.first+this.size-1},clipPos:function(e){return pe(this,e)},getCursor:function(e){var t,r=this.sel.primary();return t=null==e||"head"==e?r.head:"anchor"==e?r.anchor:"end"==e||"to"==e||e===!1?r.to():r.from()},listSelections:function(){return this.sel.ranges},somethingSelected:function(){return this.sel.somethingSelected()},setCursor:At(function(e,t,r){Ce(this,pe(this,"number"==typeof e?Wo(e,t||0):e),null,r)}),setSelection:At(function(e,t,r){Ce(this,pe(this,e),pe(this,t||e),r)}),extendSelection:At(function(e,t,r){be(this,pe(this,e),t&&pe(this,t),r)}),extendSelections:At(function(e,t){we(this,me(this,e,t))}),extendSelectionsBy:At(function(e,t){we(this,Ai(this.sel.ranges,e),t)}),setSelections:At(function(e,t,r){if(e.length){for(var n=0,i=[];n<e.length;n++)i[n]=new ce(pe(this,e[n].anchor),pe(this,e[n].head));null==t&&(t=Math.min(e.length-1,this.sel.primIndex)),ke(this,fe(i,t),r)}}),addSelection:At(function(e,t,r){var n=this.sel.ranges.slice(0);n.push(new ce(pe(this,e),pe(this,t||e))),ke(this,fe(n,n.length-1),r)}),getSelection:function(e){for(var t,r=this.sel.ranges,n=0;n<r.length;n++){var i=_n(this,r[n].from(),r[n].to());t=t?t.concat(i):i}return e===!1?t:t.join(e||"\n")},getSelections:function(e){for(var t=[],r=this.sel.ranges,n=0;n<r.length;n++){var i=_n(this,r[n].from(),r[n].to());e!==!1&&(i=i.join(e||"\n")),t[n]=i}return t},replaceSelection:function(e,t,r){for(var n=[],i=0;i<this.sel.ranges.length;i++)n[i]=e;this.replaceSelections(n,t,r||"+input")},replaceSelections:At(function(e,t,r){for(var n=[],i=this.sel,o=0;o<i.ranges.length;o++){var l=i.ranges[o];n[o]={from:l.from(),to:l.to(),text:jl(e[o]),origin:r}}for(var s=t&&"end"!=t&&yr(this,n,t),o=n.length-1;o>=0;o--)wr(this,n[o]);s?Le(this,s):this.cm&&Dr(this.cm)}),undo:At(function(){Cr(this,"undo")}),redo:At(function(){Cr(this,"redo")}),undoSelection:At(function(){Cr(this,"undo",!0)}),redoSelection:At(function(){Cr(this,"redo",!0)}),setExtending:function(e){this.extend=e},getExtending:function(){return this.extend},historySize:function(){for(var e=this.history,t=0,r=0,n=0;n<e.done.length;n++)e.done[n].ranges||++t;for(var n=0;n<e.undone.length;n++)e.undone[n].ranges||++r;return{undo:t,redo:r}},clearHistory:function(){this.history=new ei(this.history.maxGeneration)},markClean:function(){this.cleanGeneration=this.changeGeneration(!0)},changeGeneration:function(e){return e&&(this.history.lastOp=this.history.lastSelOp=this.history.lastOrigin=null),this.history.generation},isClean:function(e){return this.history.generation==(e||this.cleanGeneration)},getHistory:function(){return{done:fi(this.history.done),undone:fi(this.history.undone)}},setHistory:function(e){var t=this.history=new ei(this.history.maxGeneration);t.done=fi(e.done.slice(0),null,!0),t.undone=fi(e.undone.slice(0),null,!0)},addLineClass:At(function(e,t,r){return Pr(this,e,"gutter"==t?"gutter":"class",function(e){var n="text"==t?"textClass":"background"==t?"bgClass":"gutter"==t?"gutterClass":"wrapClass";if(e[n]){if(Gi(r).test(e[n]))return!1;e[n]+=" "+r}else e[n]=r;return!0})}),removeLineClass:At(function(e,t,r){return Pr(this,e,"gutter"==t?"gutter":"class",function(e){var n="text"==t?"textClass":"background"==t?"bgClass":"gutter"==t?"gutterClass":"wrapClass",i=e[n];if(!i)return!1;if(null==r)e[n]=null;else{var o=i.match(Gi(r));if(!o)return!1;var l=o.index+o[0].length;e[n]=i.slice(0,o.index)+(o.index&&l!=i.length?" ":"")+i.slice(l)||null}return!0})}),addLineWidget:At(function(e,t,r){return xn(this,e,t,r)}),removeLineWidget:function(e){e.clear()},markText:function(e,t,r){return Ur(this,pe(this,e),pe(this,t),r,"range")},setBookmark:function(e,t){var r={replacedWith:t&&(null==t.nodeType?t.widget:t),insertLeft:t&&t.insertLeft,clearWhenEmpty:!1,shared:t&&t.shared,handleMouseEvents:t&&t.handleMouseEvents};return e=pe(this,e),Ur(this,e,e,r,"bookmark")},findMarksAt:function(e){e=pe(this,e);var t=[],r=Xn(this,e.line).markedSpans;if(r)for(var n=0;n<r.length;++n){var i=r[n];(null==i.from||i.from<=e.ch)&&(null==i.to||i.to>=e.ch)&&t.push(i.marker.parent||i.marker)}return t},findMarks:function(e,t,r){e=pe(this,e),t=pe(this,t);var n=[],i=e.line;return this.iter(e.line,t.line+1,function(o){var l=o.markedSpans;if(l)for(var s=0;s<l.length;s++){var a=l[s];i==e.line&&e.ch>a.to||null==a.from&&i!=e.line||i==t.line&&a.from>t.ch||r&&!r(a.marker)||n.push(a.marker.parent||a.marker)}++i}),n},getAllMarks:function(){var e=[];return this.iter(function(t){var r=t.markedSpans;if(r)for(var n=0;n<r.length;++n)null!=r[n].from&&e.push(r[n].marker)}),e},posFromIndex:function(e){var t,r=this.first;return this.iter(function(n){var i=n.text.length+1;return i>e?(t=e,!0):(e-=i,void++r)}),pe(this,Wo(r,t))},indexFromPos:function(e){e=pe(this,e);var t=e.ch;return e.line<this.first||e.ch<0?0:(this.iter(this.first,e.line,function(e){t+=e.text.length+1}),t)},copy:function(e){var t=new vl(Yn(this,this.first,this.first+this.size),this.modeOption,this.first);return t.scrollTop=this.scrollTop,t.scrollLeft=this.scrollLeft,t.sel=this.sel,t.extend=!1,e&&(t.history.undoDepth=this.history.undoDepth,t.setHistory(this.getHistory())),t},linkedDoc:function(e){e||(e={});var t=this.first,r=this.first+this.size;null!=e.from&&e.from>t&&(t=e.from),null!=e.to&&e.to<r&&(r=e.to);var n=new vl(Yn(this,t,r),e.mode||this.modeOption,t);return e.sharedHist&&(n.history=this.history),(this.linked||(this.linked=[])).push({doc:n,sharedHist:e.sharedHist}),n.linked=[{doc:this,isParent:!0,sharedHist:e.sharedHist}],jr(n,Kr(this)),n},unlinkDoc:function(t){if(t instanceof e&&(t=t.doc),this.linked)for(var r=0;r<this.linked.length;++r){var n=this.linked[r];if(n.doc==t){this.linked.splice(r,1),t.unlinkDoc(this),Xr(Kr(this));break}}if(t.history==this.history){var i=[t.id];Kn(t,function(e){i.push(e.id)},!0),t.history=new ei(null),t.history.done=fi(this.history.done,i),t.history.undone=fi(this.history.undone,i)}},iterLinkedDocs:function(e){Kn(this,e)},getMode:function(){return this.mode},getEditor:function(){return this.cm}}),vl.prototype.eachLine=vl.prototype.iter;var ml="iter insert remove copy getEditor".split(" ");for(var yl in vl.prototype)vl.prototype.hasOwnProperty(yl)&&Ni(ml,yl)<0&&(e.prototype[yl]=function(e){return function(){return e.apply(this.doc,arguments)}}(vl.prototype[yl]));Si(vl);var bl=e.e_preventDefault=function(e){e.preventDefault?e.preventDefault():e.returnValue=!1},wl=e.e_stopPropagation=function(e){e.stopPropagation?e.stopPropagation():e.cancelBubble=!0},xl=e.e_stop=function(e){bl(e),wl(e)},Cl=e.on=function(e,t,r){if(e.addEventListener)e.addEventListener(t,r,!1);else if(e.attachEvent)e.attachEvent("on"+t,r);else{var n=e._handlers||(e._handlers={}),i=n[t]||(n[t]=[]);i.push(r)}},Sl=e.off=function(e,t,r){if(e.removeEventListener)e.removeEventListener(t,r,!1);else if(e.detachEvent)e.detachEvent("on"+t,r);else{var n=e._handlers&&e._handlers[t];if(!n)return;for(var i=0;i<n.length;++i)if(n[i]==r){n.splice(i,1);break}}},Ll=e.signal=function(e,t){var r=e._handlers&&e._handlers[t];if(r)for(var n=Array.prototype.slice.call(arguments,2),i=0;i<r.length;++i)r[i].apply(null,n)},kl=null,Tl=30,Ml=e.Pass={toString:function(){return"CodeMirror.Pass"}},Nl={scroll:!1},Al={origin:"*mouse"},Wl={origin:"+move"};Li.prototype.set=function(e,t){clearTimeout(this.id),this.id=setTimeout(t,e)};var Ol=e.countColumn=function(e,t,r,n,i){null==t&&(t=e.search(/[^\s\u00a0]/),-1==t&&(t=e.length));for(var o=n||0,l=i||0;;){var s=e.indexOf(" ",o);if(0>s||s>=t)return l+(t-o);l+=s-o,l+=r-l%r,o=s+1}},Dl=[""],Hl=function(e){e.select()};xo?Hl=function(e){e.selectionStart=0,e.selectionEnd=e.value.length}:fo&&(Hl=function(e){try{e.select()}catch(t){}});var Il,Pl=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/,El=e.isWordChar=function(e){return/\w/.test(e)||e>""&&(e.toUpperCase()!=e.toLowerCase()||Pl.test(e))},zl=/[\u0300-\u036f\u0483-\u0489\u0591-\u05bd\u05bf\u05c1\u05c2\u05c4\u05c5\u05c7\u0610-\u061a\u064b-\u065e\u0670\u06d6-\u06dc\u06de-\u06e4\u06e7\u06e8\u06ea-\u06ed\u0711\u0730-\u074a\u07a6-\u07b0\u07eb-\u07f3\u0816-\u0819\u081b-\u0823\u0825-\u0827\u0829-\u082d\u0900-\u0902\u093c\u0941-\u0948\u094d\u0951-\u0955\u0962\u0963\u0981\u09bc\u09be\u09c1-\u09c4\u09cd\u09d7\u09e2\u09e3\u0a01\u0a02\u0a3c\u0a41\u0a42\u0a47\u0a48\u0a4b-\u0a4d\u0a51\u0a70\u0a71\u0a75\u0a81\u0a82\u0abc\u0ac1-\u0ac5\u0ac7\u0ac8\u0acd\u0ae2\u0ae3\u0b01\u0b3c\u0b3e\u0b3f\u0b41-\u0b44\u0b4d\u0b56\u0b57\u0b62\u0b63\u0b82\u0bbe\u0bc0\u0bcd\u0bd7\u0c3e-\u0c40\u0c46-\u0c48\u0c4a-\u0c4d\u0c55\u0c56\u0c62\u0c63\u0cbc\u0cbf\u0cc2\u0cc6\u0ccc\u0ccd\u0cd5\u0cd6\u0ce2\u0ce3\u0d3e\u0d41-\u0d44\u0d4d\u0d57\u0d62\u0d63\u0dca\u0dcf\u0dd2-\u0dd4\u0dd6\u0ddf\u0e31\u0e34-\u0e3a\u0e47-\u0e4e\u0eb1\u0eb4-\u0eb9\u0ebb\u0ebc\u0ec8-\u0ecd\u0f18\u0f19\u0f35\u0f37\u0f39\u0f71-\u0f7e\u0f80-\u0f84\u0f86\u0f87\u0f90-\u0f97\u0f99-\u0fbc\u0fc6\u102d-\u1030\u1032-\u1037\u1039\u103a\u103d\u103e\u1058\u1059\u105e-\u1060\u1071-\u1074\u1082\u1085\u1086\u108d\u109d\u135f\u1712-\u1714\u1732-\u1734\u1752\u1753\u1772\u1773\u17b7-\u17bd\u17c6\u17c9-\u17d3\u17dd\u180b-\u180d\u18a9\u1920-\u1922\u1927\u1928\u1932\u1939-\u193b\u1a17\u1a18\u1a56\u1a58-\u1a5e\u1a60\u1a62\u1a65-\u1a6c\u1a73-\u1a7c\u1a7f\u1b00-\u1b03\u1b34\u1b36-\u1b3a\u1b3c\u1b42\u1b6b-\u1b73\u1b80\u1b81\u1ba2-\u1ba5\u1ba8\u1ba9\u1c2c-\u1c33\u1c36\u1c37\u1cd0-\u1cd2\u1cd4-\u1ce0\u1ce2-\u1ce8\u1ced\u1dc0-\u1de6\u1dfd-\u1dff\u200c\u200d\u20d0-\u20f0\u2cef-\u2cf1\u2de0-\u2dff\u302a-\u302f\u3099\u309a\ua66f-\ua672\ua67c\ua67d\ua6f0\ua6f1\ua802\ua806\ua80b\ua825\ua826\ua8c4\ua8e0-\ua8f1\ua926-\ua92d\ua947-\ua951\ua980-\ua982\ua9b3\ua9b6-\ua9b9\ua9bc\uaa29-\uaa2e\uaa31\uaa32\uaa35\uaa36\uaa43\uaa4c\uaab0\uaab2-\uaab4\uaab7\uaab8\uaabe\uaabf\uaac1\uabe5\uabe8\uabed\udc00-\udfff\ufb1e\ufe00-\ufe0f\ufe20-\ufe26\uff9e\uff9f]/;Il=document.createRange?function(e,t,r,n){var i=document.createRange();return i.setEnd(n||e,r),i.setStart(e,t),i}:function(e,t,r){var n=document.body.createTextRange();try{n.moveToElementText(e.parentNode)}catch(i){return n}return n.collapse(!0),n.moveEnd("character",r),n.moveStart("character",t),n};var Fl=e.contains=function(e,t){if(3==t.nodeType&&(t=t.parentNode),e.contains)return e.contains(t);do if(11==t.nodeType&&(t=t.host),t==e)return!0;while(t=t.parentNode)};fo&&11>ho&&(Bi=function(){try{return document.activeElement}catch(e){return document.body}});var Rl,Bl,Gl=e.rmClass=function(e,t){var r=e.className,n=Gi(t).exec(r);if(n){var i=r.slice(n.index+n[0].length);e.className=r.slice(0,n.index)+(i?n[1]+i:"")}},Ul=e.addClass=function(e,t){var r=e.className;Gi(t).test(r)||(e.className+=(r?" ":"")+t)},Vl=!1,Kl=function(){if(fo&&9>ho)return!1;var e=zi("div");return"draggable"in e||"dragDrop"in e}(),jl=e.splitLines=3!="\n\nb".split(/\n/).length?function(e){for(var t=0,r=[],n=e.length;n>=t;){var i=e.indexOf("\n",t);-1==i&&(i=e.length);var o=e.slice(t,"\r"==e.charAt(i-1)?i-1:i),l=o.indexOf("\r");-1!=l?(r.push(o.slice(0,l)),t+=l+1):(r.push(o),t=i+1)}return r}:function(e){return e.split(/\r\n?|\n/)},Xl=window.getSelection?function(e){try{return e.selectionStart!=e.selectionEnd}catch(t){return!1}}:function(e){try{var t=e.ownerDocument.selection.createRange()}catch(r){}return t&&t.parentElement()==e?0!=t.compareEndPoints("StartToEnd",t):!1},_l=function(){var e=zi("div");return"oncopy"in e?!0:(e.setAttribute("oncopy","return;"),"function"==typeof e.oncopy)}(),Yl=null,$l={3:"Enter",8:"Backspace",9:"Tab",13:"Enter",16:"Shift",17:"Ctrl",18:"Alt",19:"Pause",20:"CapsLock",27:"Esc",32:"Space",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"Left",38:"Up",39:"Right",40:"Down",44:"PrintScrn",45:"Insert",46:"Delete",59:";",61:"=",91:"Mod",92:"Mod",93:"Mod",107:"=",109:"-",127:"Delete",173:"-",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'",63232:"Up",63233:"Down",63234:"Left",63235:"Right",63272:"Delete",63273:"Home",63275:"End",63276:"PageUp",63277:"PageDown",63302:"Insert"};e.keyNames=$l,function(){for(var e=0;10>e;e++)$l[e+48]=$l[e+96]=String(e);for(var e=65;90>=e;e++)$l[e]=String.fromCharCode(e);for(var e=1;12>=e;e++)$l[e+111]=$l[e+63235]="F"+e}();var ql,Zl=function(){function e(e){return 247>=e?r.charAt(e):e>=1424&&1524>=e?"R":e>=1536&&1773>=e?n.charAt(e-1536):e>=1774&&2220>=e?"r":e>=8192&&8203>=e?"w":8204==e?"b":"L"}function t(e,t,r){this.level=e,this.from=t,this.to=r}var r="bbbbbbbbbtstwsbbbbbbbbbbbbbbssstwNN%%%NNNNNN,N,N1111111111NNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNbbbbbbsbbbbbbbbbbbbbbbbbbbbbbbbbb,N%%%%NNNNLNNNNN%%11NLNNN1LNNNNNLLLLLLLLLLLLLLLLLLLLLLLNLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLN",n="rrrrrrrrrrrr,rNNmmmmmmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmmmmmmmmrrrrrrrnnnnnnnnnn%nnrrrmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmmmmmmmmmmmmmNmmmm",i=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/,o=/[stwN]/,l=/[LRr]/,s=/[Lb1n]/,a=/[1n]/,u="L";return function(r){if(!i.test(r))return!1;for(var n,c=r.length,f=[],h=0;c>h;++h)f.push(n=e(r.charCodeAt(h)));for(var h=0,d=u;c>h;++h){var n=f[h];"m"==n?f[h]=d:d=n}for(var h=0,p=u;c>h;++h){var n=f[h];"1"==n&&"r"==p?f[h]="n":l.test(n)&&(p=n,"r"==n&&(f[h]="R"))}for(var h=1,d=f[0];c-1>h;++h){var n=f[h];"+"==n&&"1"==d&&"1"==f[h+1]?f[h]="1":","!=n||d!=f[h+1]||"1"!=d&&"n"!=d||(f[h]=d),d=n}for(var h=0;c>h;++h){var n=f[h];if(","==n)f[h]="N";else if("%"==n){for(var g=h+1;c>g&&"%"==f[g];++g);for(var v=h&&"!"==f[h-1]||c>g&&"1"==f[g]?"1":"N",m=h;g>m;++m)f[m]=v;h=g-1}}for(var h=0,p=u;c>h;++h){var n=f[h];"L"==p&&"1"==n?f[h]="L":l.test(n)&&(p=n)}for(var h=0;c>h;++h)if(o.test(f[h])){for(var g=h+1;c>g&&o.test(f[g]);++g);for(var y="L"==(h?f[h-1]:u),b="L"==(c>g?f[g]:u),v=y||b?"L":"R",m=h;g>m;++m)f[m]=v;h=g-1}for(var w,x=[],h=0;c>h;)if(s.test(f[h])){var C=h;for(++h;c>h&&s.test(f[h]);++h);x.push(new t(0,C,h))}else{var S=h,L=x.length;for(++h;c>h&&"L"!=f[h];++h);for(var m=S;h>m;)if(a.test(f[m])){m>S&&x.splice(L,0,new t(1,S,m));var k=m;for(++m;h>m&&a.test(f[m]);++m);x.splice(L,0,new t(2,k,m)),S=m}else++m;h>S&&x.splice(L,0,new t(1,S,h))}return 1==x[0].level&&(w=r.match(/^\s+/))&&(x[0].from=w[0].length,x.unshift(new t(0,0,w[0].length))),1==Mi(x).level&&(w=r.match(/\s+$/))&&(Mi(x).to-=w[0].length,x.push(new t(0,c-w[0].length,c))),2==x[0].level&&x.unshift(new t(1,x[0].to,x[0].to)),x[0].level!=Mi(x).level&&x.push(new t(x[0].level,c,c)),x}}();return e.version="5.2.0",e});
|
1 |
+
!function(e){if("object"==typeof exports&&"object"==typeof module)module.exports=e();else{if("function"==typeof define&&define.amd)return define([],e);(this||window).CodeMirror=e()}}(function(){"use strict";function e(r,n){if(!(this instanceof e))return new e(r,n);this.options=n=n?zi(n):{},zi(Jo,n,!1),d(n);var i=n.value;"string"==typeof i&&(i=new Sl(i,n.mode,null,n.lineSeparator)),this.doc=i;var o=new e.inputStyles[n.inputStyle](this),l=this.display=new t(r,i,o);l.wrapper.CodeMirror=this,u(this),s(this),n.lineWrapping&&(this.display.wrapper.className+=" CodeMirror-wrap"),n.autofocus&&!Wo&&l.input.focus(),m(this),this.state={keyMaps:[],overlays:[],modeGen:0,overwrite:!1,delayingBlurEvent:!1,focused:!1,suppressEdits:!1,pasteIncoming:!1,cutIncoming:!1,selectingText:!1,draggingText:!1,highlight:new Ai,keySeq:null,specialChars:null};var a=this;bo&&11>wo&&setTimeout(function(){a.display.input.reset(!0)},20),Ut(this),$i(),wt(this),this.curOp.forceUpdate=!0,qn(this,i),n.autofocus&&!Wo||a.hasFocus()?setTimeout(Fi(vr,this),20):mr(this);for(var c in el)el.hasOwnProperty(c)&&el[c](this,n[c],tl);C(this),n.finishInit&&n.finishInit(this);for(var h=0;h<ol.length;++h)ol[h](this);Ct(this),xo&&n.lineWrapping&&"optimizelegibility"==getComputedStyle(l.lineDiv).textRendering&&(l.lineDiv.style.textRendering="auto")}function t(e,t,r){var n=this;this.input=r,n.scrollbarFiller=Ui("div",null,"CodeMirror-scrollbar-filler"),n.scrollbarFiller.setAttribute("cm-not-content","true"),n.gutterFiller=Ui("div",null,"CodeMirror-gutter-filler"),n.gutterFiller.setAttribute("cm-not-content","true"),n.lineDiv=Ui("div",null,"CodeMirror-code"),n.selectionDiv=Ui("div",null,null,"position: relative; z-index: 1"),n.cursorDiv=Ui("div",null,"CodeMirror-cursors"),n.measure=Ui("div",null,"CodeMirror-measure"),n.lineMeasure=Ui("div",null,"CodeMirror-measure"),n.lineSpace=Ui("div",[n.measure,n.lineMeasure,n.selectionDiv,n.cursorDiv,n.lineDiv],null,"position: relative; outline: none"),n.mover=Ui("div",[Ui("div",[n.lineSpace],"CodeMirror-lines")],null,"position: relative"),n.sizer=Ui("div",[n.mover],"CodeMirror-sizer"),n.sizerWidth=null,n.heightForcer=Ui("div",null,null,"position: absolute; height: "+Pl+"px; width: 1px;"),n.gutters=Ui("div",null,"CodeMirror-gutters"),n.lineGutter=null,n.scroller=Ui("div",[n.sizer,n.heightForcer,n.gutters],"CodeMirror-scroll"),n.scroller.setAttribute("tabIndex","-1"),n.wrapper=Ui("div",[n.scrollbarFiller,n.gutterFiller,n.scroller],"CodeMirror"),bo&&8>wo&&(n.gutters.style.zIndex=-1,n.scroller.style.paddingRight=0),xo||vo&&Wo||(n.scroller.draggable=!0),e&&(e.appendChild?e.appendChild(n.wrapper):e(n.wrapper)),n.viewFrom=n.viewTo=t.first,n.reportedViewFrom=n.reportedViewTo=t.first,n.view=[],n.renderedView=null,n.externalMeasured=null,n.viewOffset=0,n.lastWrapHeight=n.lastWrapWidth=0,n.updateLineNumbers=null,n.nativeBarWidth=n.barHeight=n.barWidth=0,n.scrollbarsClipped=!1,n.lineNumWidth=n.lineNumInnerWidth=n.lineNumChars=null,n.alignWidgets=!1,n.cachedCharWidth=n.cachedTextHeight=n.cachedPaddingH=null,n.maxLine=null,n.maxLineLength=0,n.maxLineChanged=!1,n.wheelDX=n.wheelDY=n.wheelStartX=n.wheelStartY=null,n.shift=!1,n.selForContextMenu=null,n.activeTouch=null,r.init(n)}function r(t){t.doc.mode=e.getMode(t.options,t.doc.modeOption),n(t)}function n(e){e.doc.iter(function(e){e.stateAfter&&(e.stateAfter=null),e.styles&&(e.styles=null)}),e.doc.frontier=e.doc.first,Re(e,100),e.state.modeGen++,e.curOp&&Et(e)}function i(e){e.options.lineWrapping?(Zl(e.display.wrapper,"CodeMirror-wrap"),e.display.sizer.style.minWidth="",e.display.sizerWidth=null):(ql(e.display.wrapper,"CodeMirror-wrap"),f(e)),l(e),Et(e),st(e),setTimeout(function(){y(e)},100)}function o(e){var t=yt(e.display),r=e.options.lineWrapping,n=r&&Math.max(5,e.display.scroller.clientWidth/bt(e.display)-3);return function(i){if(Cn(e.doc,i))return 0;var o=0;if(i.widgets)for(var l=0;l<i.widgets.length;l++)i.widgets[l].height&&(o+=i.widgets[l].height);return r?o+(Math.ceil(i.text.length/n)||1)*t:o+t}}function l(e){var t=e.doc,r=o(e);t.iter(function(e){var t=r(e);t!=e.height&&ei(e,t)})}function s(e){e.display.wrapper.className=e.display.wrapper.className.replace(/\s*cm-s-\S+/g,"")+e.options.theme.replace(/(^|\s)\s*/g," cm-s-"),st(e)}function a(e){u(e),Et(e),setTimeout(function(){x(e)},20)}function u(e){var t=e.display.gutters,r=e.options.gutters;Vi(t);for(var n=0;n<r.length;++n){var i=r[n],o=t.appendChild(Ui("div",null,"CodeMirror-gutter "+i));"CodeMirror-linenumbers"==i&&(e.display.lineGutter=o,o.style.width=(e.display.lineNumWidth||1)+"px")}t.style.display=n?"":"none",c(e)}function c(e){var t=e.display.gutters.offsetWidth;e.display.sizer.style.marginLeft=t+"px"}function h(e){if(0==e.height)return 0;for(var t,r=e.text.length,n=e;t=gn(n);){var i=t.find(0,!0);n=i.from.line,r+=i.from.ch-i.to.ch}for(n=e;t=vn(n);){var i=t.find(0,!0);r-=n.text.length-i.from.ch,n=i.to.line,r+=n.text.length-i.to.ch}return r}function f(e){var t=e.display,r=e.doc;t.maxLine=Zn(r,r.first),t.maxLineLength=h(t.maxLine),t.maxLineChanged=!0,r.iter(function(e){var r=h(e);r>t.maxLineLength&&(t.maxLineLength=r,t.maxLine=e)})}function d(e){var t=Hi(e.gutters,"CodeMirror-linenumbers");-1==t&&e.lineNumbers?e.gutters=e.gutters.concat(["CodeMirror-linenumbers"]):t>-1&&!e.lineNumbers&&(e.gutters=e.gutters.slice(0),e.gutters.splice(t,1))}function p(e){var t=e.display,r=t.gutters.offsetWidth,n=Math.round(e.doc.height+Ke(e.display));return{clientHeight:t.scroller.clientHeight,viewHeight:t.wrapper.clientHeight,scrollWidth:t.scroller.scrollWidth,clientWidth:t.scroller.clientWidth,viewWidth:t.wrapper.clientWidth,barLeft:e.options.fixedGutter?r:0,docHeight:n,scrollHeight:n+Xe(e)+t.barHeight,nativeBarWidth:t.nativeBarWidth,gutterWidth:r}}function g(e,t,r){this.cm=r;var n=this.vert=Ui("div",[Ui("div",null,null,"min-width: 1px")],"CodeMirror-vscrollbar"),i=this.horiz=Ui("div",[Ui("div",null,null,"height: 100%; min-height: 1px")],"CodeMirror-hscrollbar");e(n),e(i),Wl(n,"scroll",function(){n.clientHeight&&t(n.scrollTop,"vertical")}),Wl(i,"scroll",function(){i.clientWidth&&t(i.scrollLeft,"horizontal")}),this.checkedZeroWidth=!1,bo&&8>wo&&(this.horiz.style.minHeight=this.vert.style.minWidth="18px")}function v(){}function m(t){t.display.scrollbars&&(t.display.scrollbars.clear(),t.display.scrollbars.addClass&&ql(t.display.wrapper,t.display.scrollbars.addClass)),t.display.scrollbars=new e.scrollbarModel[t.options.scrollbarStyle](function(e){t.display.wrapper.insertBefore(e,t.display.scrollbarFiller),Wl(e,"mousedown",function(){t.state.focused&&setTimeout(function(){t.display.input.focus()},0)}),e.setAttribute("cm-not-content","true")},function(e,r){"horizontal"==r?ir(t,e):nr(t,e)},t),t.display.scrollbars.addClass&&Zl(t.display.wrapper,t.display.scrollbars.addClass)}function y(e,t){t||(t=p(e));var r=e.display.barWidth,n=e.display.barHeight;b(e,t);for(var i=0;4>i&&r!=e.display.barWidth||n!=e.display.barHeight;i++)r!=e.display.barWidth&&e.options.lineWrapping&&O(e),b(e,p(e)),r=e.display.barWidth,n=e.display.barHeight}function b(e,t){var r=e.display,n=r.scrollbars.update(t);r.sizer.style.paddingRight=(r.barWidth=n.right)+"px",r.sizer.style.paddingBottom=(r.barHeight=n.bottom)+"px",n.right&&n.bottom?(r.scrollbarFiller.style.display="block",r.scrollbarFiller.style.height=n.bottom+"px",r.scrollbarFiller.style.width=n.right+"px"):r.scrollbarFiller.style.display="",n.bottom&&e.options.coverGutterNextToScrollbar&&e.options.fixedGutter?(r.gutterFiller.style.display="block",r.gutterFiller.style.height=n.bottom+"px",r.gutterFiller.style.width=t.gutterWidth+"px"):r.gutterFiller.style.display=""}function w(e,t,r){var n=r&&null!=r.top?Math.max(0,r.top):e.scroller.scrollTop;n=Math.floor(n-Ve(e));var i=r&&null!=r.bottom?r.bottom:n+e.wrapper.clientHeight,o=ri(t,n),l=ri(t,i);if(r&&r.ensure){var s=r.ensure.from.line,a=r.ensure.to.line;o>s?(o=s,l=ri(t,ni(Zn(t,s))+e.wrapper.clientHeight)):Math.min(a,t.lastLine())>=l&&(o=ri(t,ni(Zn(t,a))-e.wrapper.clientHeight),l=a)}return{from:o,to:Math.max(l,o+1)}}function x(e){var t=e.display,r=t.view;if(t.alignWidgets||t.gutters.firstChild&&e.options.fixedGutter){for(var n=L(t)-t.scroller.scrollLeft+e.doc.scrollLeft,i=t.gutters.offsetWidth,o=n+"px",l=0;l<r.length;l++)if(!r[l].hidden){e.options.fixedGutter&&r[l].gutter&&(r[l].gutter.style.left=o);var s=r[l].alignable;if(s)for(var a=0;a<s.length;a++)s[a].style.left=o}e.options.fixedGutter&&(t.gutters.style.left=n+i+"px")}}function C(e){if(!e.options.lineNumbers)return!1;var t=e.doc,r=S(e.options,t.first+t.size-1),n=e.display;if(r.length!=n.lineNumChars){var i=n.measure.appendChild(Ui("div",[Ui("div",r)],"CodeMirror-linenumber CodeMirror-gutter-elt")),o=i.firstChild.offsetWidth,l=i.offsetWidth-o;return n.lineGutter.style.width="",n.lineNumInnerWidth=Math.max(o,n.lineGutter.offsetWidth-l)+1,n.lineNumWidth=n.lineNumInnerWidth+l,n.lineNumChars=n.lineNumInnerWidth?r.length:-1,n.lineGutter.style.width=n.lineNumWidth+"px",c(e),!0}return!1}function S(e,t){return String(e.lineNumberFormatter(t+e.firstLineNumber))}function L(e){return e.scroller.getBoundingClientRect().left-e.sizer.getBoundingClientRect().left}function T(e,t,r){var n=e.display;this.viewport=t,this.visible=w(n,e.doc,t),this.editorIsHidden=!n.wrapper.offsetWidth,this.wrapperHeight=n.wrapper.clientHeight,this.wrapperWidth=n.wrapper.clientWidth,this.oldDisplayWidth=Ye(e),this.force=r,this.dims=H(e),this.events=[]}function k(e){var t=e.display;!t.scrollbarsClipped&&t.scroller.offsetWidth&&(t.nativeBarWidth=t.scroller.offsetWidth-t.scroller.clientWidth,t.heightForcer.style.height=Xe(e)+"px",t.sizer.style.marginBottom=-t.nativeBarWidth+"px",t.sizer.style.borderRightWidth=Xe(e)+"px",t.scrollbarsClipped=!0)}function M(e,t){var r=e.display,n=e.doc;if(t.editorIsHidden)return zt(e),!1;if(!t.force&&t.visible.from>=r.viewFrom&&t.visible.to<=r.viewTo&&(null==r.updateLineNumbers||r.updateLineNumbers>=r.viewTo)&&r.renderedView==r.view&&0==Gt(e))return!1;C(e)&&(zt(e),t.dims=H(e));var i=n.first+n.size,o=Math.max(t.visible.from-e.options.viewportMargin,n.first),l=Math.min(i,t.visible.to+e.options.viewportMargin);r.viewFrom<o&&o-r.viewFrom<20&&(o=Math.max(n.first,r.viewFrom)),r.viewTo>l&&r.viewTo-l<20&&(l=Math.min(i,r.viewTo)),Io&&(o=wn(e.doc,o),l=xn(e.doc,l));var s=o!=r.viewFrom||l!=r.viewTo||r.lastWrapHeight!=t.wrapperHeight||r.lastWrapWidth!=t.wrapperWidth;Bt(e,o,l),r.viewOffset=ni(Zn(e.doc,r.viewFrom)),e.display.mover.style.top=r.viewOffset+"px";var a=Gt(e);if(!s&&0==a&&!t.force&&r.renderedView==r.view&&(null==r.updateLineNumbers||r.updateLineNumbers>=r.viewTo))return!1;var u=ji();return a>4&&(r.lineDiv.style.display="none"),P(e,r.updateLineNumbers,t.dims),a>4&&(r.lineDiv.style.display=""),r.renderedView=r.view,u&&ji()!=u&&u.offsetHeight&&u.focus(),Vi(r.cursorDiv),Vi(r.selectionDiv),r.gutters.style.height=r.sizer.style.minHeight=0,s&&(r.lastWrapHeight=t.wrapperHeight,r.lastWrapWidth=t.wrapperWidth,Re(e,400)),r.updateLineNumbers=null,!0}function N(e,t){for(var r=t.viewport,n=!0;(n&&e.options.lineWrapping&&t.oldDisplayWidth!=Ye(e)||(r&&null!=r.top&&(r={top:Math.min(e.doc.height+Ke(e.display)-_e(e),r.top)}),t.visible=w(e.display,e.doc,r),!(t.visible.from>=e.display.viewFrom&&t.visible.to<=e.display.viewTo)))&&M(e,t);n=!1){O(e);var i=p(e);Pe(e),A(e,i),y(e,i)}t.signal(e,"update",e),(e.display.viewFrom!=e.display.reportedViewFrom||e.display.viewTo!=e.display.reportedViewTo)&&(t.signal(e,"viewportChange",e,e.display.viewFrom,e.display.viewTo),e.display.reportedViewFrom=e.display.viewFrom,e.display.reportedViewTo=e.display.viewTo)}function W(e,t){var r=new T(e,t);if(M(e,r)){O(e),N(e,r);var n=p(e);Pe(e),A(e,n),y(e,n),r.finish()}}function A(e,t){e.display.sizer.style.minHeight=t.docHeight+"px";var r=t.docHeight+e.display.barHeight;e.display.heightForcer.style.top=r+"px",e.display.gutters.style.height=Math.max(r+Xe(e),t.clientHeight)+"px"}function O(e){for(var t=e.display,r=t.lineDiv.offsetTop,n=0;n<t.view.length;n++){var i,o=t.view[n];if(!o.hidden){if(bo&&8>wo){var l=o.node.offsetTop+o.node.offsetHeight;i=l-r,r=l}else{var s=o.node.getBoundingClientRect();i=s.bottom-s.top}var a=o.line.height-i;if(2>i&&(i=yt(t)),(a>.001||-.001>a)&&(ei(o.line,i),D(o.line),o.rest))for(var u=0;u<o.rest.length;u++)D(o.rest[u])}}}function D(e){if(e.widgets)for(var t=0;t<e.widgets.length;++t)e.widgets[t].height=e.widgets[t].node.parentNode.offsetHeight}function H(e){for(var t=e.display,r={},n={},i=t.gutters.clientLeft,o=t.gutters.firstChild,l=0;o;o=o.nextSibling,++l)r[e.options.gutters[l]]=o.offsetLeft+o.clientLeft+i,n[e.options.gutters[l]]=o.clientWidth;return{fixedPos:L(t),gutterTotalWidth:t.gutters.offsetWidth,gutterLeft:r,gutterWidth:n,wrapperWidth:t.wrapper.clientWidth}}function P(e,t,r){function n(t){var r=t.nextSibling;return xo&&Ao&&e.display.currentWheelTarget==t?t.style.display="none":t.parentNode.removeChild(t),r}for(var i=e.display,o=e.options.lineNumbers,l=i.lineDiv,s=l.firstChild,a=i.view,u=i.viewFrom,c=0;c<a.length;c++){var h=a[c];if(h.hidden);else if(h.node&&h.node.parentNode==l){for(;s!=h.node;)s=n(s);var f=o&&null!=t&&u>=t&&h.lineNumber;h.changes&&(Hi(h.changes,"gutter")>-1&&(f=!1),E(e,h,u,r)),f&&(Vi(h.lineNumber),h.lineNumber.appendChild(document.createTextNode(S(e.options,u)))),s=h.node.nextSibling}else{var d=V(e,h,u,r);l.insertBefore(d,s)}u+=h.size}for(;s;)s=n(s)}function E(e,t,r,n){for(var i=0;i<t.changes.length;i++){var o=t.changes[i];"text"==o?R(e,t):"gutter"==o?G(e,t,r,n):"class"==o?B(t):"widget"==o&&U(e,t,n)}t.changes=null}function I(e){return e.node==e.text&&(e.node=Ui("div",null,null,"position: relative"),e.text.parentNode&&e.text.parentNode.replaceChild(e.node,e.text),e.node.appendChild(e.text),bo&&8>wo&&(e.node.style.zIndex=2)),e.node}function z(e){var t=e.bgClass?e.bgClass+" "+(e.line.bgClass||""):e.line.bgClass;if(t&&(t+=" CodeMirror-linebackground"),e.background)t?e.background.className=t:(e.background.parentNode.removeChild(e.background),e.background=null);else if(t){var r=I(e);e.background=r.insertBefore(Ui("div",null,t),r.firstChild)}}function F(e,t){var r=e.display.externalMeasured;return r&&r.line==t.line?(e.display.externalMeasured=null,t.measure=r.measure,r.built):Fn(e,t)}function R(e,t){var r=t.text.className,n=F(e,t);t.text==t.node&&(t.node=n.pre),t.text.parentNode.replaceChild(n.pre,t.text),t.text=n.pre,n.bgClass!=t.bgClass||n.textClass!=t.textClass?(t.bgClass=n.bgClass,t.textClass=n.textClass,B(t)):r&&(t.text.className=r)}function B(e){z(e),e.line.wrapClass?I(e).className=e.line.wrapClass:e.node!=e.text&&(e.node.className="");var t=e.textClass?e.textClass+" "+(e.line.textClass||""):e.line.textClass;e.text.className=t||""}function G(e,t,r,n){if(t.gutter&&(t.node.removeChild(t.gutter),t.gutter=null),t.gutterBackground&&(t.node.removeChild(t.gutterBackground),t.gutterBackground=null),t.line.gutterClass){var i=I(t);t.gutterBackground=Ui("div",null,"CodeMirror-gutter-background "+t.line.gutterClass,"left: "+(e.options.fixedGutter?n.fixedPos:-n.gutterTotalWidth)+"px; width: "+n.gutterTotalWidth+"px"),i.insertBefore(t.gutterBackground,t.text)}var o=t.line.gutterMarkers;if(e.options.lineNumbers||o){var i=I(t),l=t.gutter=Ui("div",null,"CodeMirror-gutter-wrapper","left: "+(e.options.fixedGutter?n.fixedPos:-n.gutterTotalWidth)+"px");if(e.display.input.setUneditable(l),i.insertBefore(l,t.text),t.line.gutterClass&&(l.className+=" "+t.line.gutterClass),!e.options.lineNumbers||o&&o["CodeMirror-linenumbers"]||(t.lineNumber=l.appendChild(Ui("div",S(e.options,r),"CodeMirror-linenumber CodeMirror-gutter-elt","left: "+n.gutterLeft["CodeMirror-linenumbers"]+"px; width: "+e.display.lineNumInnerWidth+"px"))),o)for(var s=0;s<e.options.gutters.length;++s){var a=e.options.gutters[s],u=o.hasOwnProperty(a)&&o[a];u&&l.appendChild(Ui("div",[u],"CodeMirror-gutter-elt","left: "+n.gutterLeft[a]+"px; width: "+n.gutterWidth[a]+"px"))}}}function U(e,t,r){t.alignable&&(t.alignable=null);for(var n,i=t.node.firstChild;i;i=n){var n=i.nextSibling;"CodeMirror-linewidget"==i.className&&t.node.removeChild(i)}K(e,t,r)}function V(e,t,r,n){var i=F(e,t);return t.text=t.node=i.pre,i.bgClass&&(t.bgClass=i.bgClass),i.textClass&&(t.textClass=i.textClass),B(t),G(e,t,r,n),K(e,t,n),t.node}function K(e,t,r){if(j(e,t.line,t,r,!0),t.rest)for(var n=0;n<t.rest.length;n++)j(e,t.rest[n],t,r,!1)}function j(e,t,r,n,i){if(t.widgets)for(var o=I(r),l=0,s=t.widgets;l<s.length;++l){var a=s[l],u=Ui("div",[a.node],"CodeMirror-linewidget");a.handleMouseEvents||u.setAttribute("cm-ignore-events","true"),X(a,u,r,n),e.display.input.setUneditable(u),i&&a.above?o.insertBefore(u,r.gutter||r.text):o.appendChild(u),Li(a,"redraw")}}function X(e,t,r,n){if(e.noHScroll){(r.alignable||(r.alignable=[])).push(t);var i=n.wrapperWidth;t.style.left=n.fixedPos+"px",e.coverGutter||(i-=n.gutterTotalWidth,t.style.paddingLeft=n.gutterTotalWidth+"px"),t.style.width=i+"px"}e.coverGutter&&(t.style.zIndex=5,t.style.position="relative",e.noHScroll||(t.style.marginLeft=-n.gutterTotalWidth+"px"))}function Y(e){return zo(e.line,e.ch)}function _(e,t){return Fo(e,t)<0?t:e}function $(e,t){return Fo(e,t)<0?e:t}function q(e){e.state.focused||(e.display.input.focus(),vr(e))}function Z(e,t,r,n,i){var o=e.doc;e.display.shift=!1,n||(n=o.sel);var l=e.state.pasteIncoming||"paste"==i,s=o.splitLines(t),a=null;if(l&&n.ranges.length>1)if(Ro&&Ro.join("\n")==t){if(n.ranges.length%Ro.length==0){a=[];for(var u=0;u<Ro.length;u++)a.push(o.splitLines(Ro[u]))}}else s.length==n.ranges.length&&(a=Pi(s,function(e){return[e]}));for(var u=n.ranges.length-1;u>=0;u--){var c=n.ranges[u],h=c.from(),f=c.to();c.empty()&&(r&&r>0?h=zo(h.line,h.ch-r):e.state.overwrite&&!l&&(f=zo(f.line,Math.min(Zn(o,f.line).text.length,f.ch+Di(s).length))));var d=e.curOp.updateInput,p={from:h,to:f,text:a?a[u%a.length]:s,origin:i||(l?"paste":e.state.cutIncoming?"cut":"+input")};Tr(e.doc,p),Li(e,"inputRead",e,p)}t&&!l&&J(e,t),zr(e),e.curOp.updateInput=d,e.curOp.typing=!0,e.state.pasteIncoming=e.state.cutIncoming=!1}function Q(e,t){var r=e.clipboardData&&e.clipboardData.getData("text/plain");return r?(e.preventDefault(),t.isReadOnly()||t.options.disableInput||Wt(t,function(){Z(t,r,0,null,"paste")}),!0):void 0}function J(e,t){if(e.options.electricChars&&e.options.smartIndent)for(var r=e.doc.sel,n=r.ranges.length-1;n>=0;n--){var i=r.ranges[n];if(!(i.head.ch>100||n&&r.ranges[n-1].head.line==i.head.line)){var o=e.getModeAt(i.head),l=!1;if(o.electricChars){for(var s=0;s<o.electricChars.length;s++)if(t.indexOf(o.electricChars.charAt(s))>-1){l=Rr(e,i.head.line,"smart");break}}else o.electricInput&&o.electricInput.test(Zn(e.doc,i.head.line).text.slice(0,i.head.ch))&&(l=Rr(e,i.head.line,"smart"));l&&Li(e,"electricInput",e,i.head.line)}}}function ee(e){for(var t=[],r=[],n=0;n<e.doc.sel.ranges.length;n++){var i=e.doc.sel.ranges[n].head.line,o={anchor:zo(i,0),head:zo(i+1,0)};r.push(o),t.push(e.getRange(o.anchor,o.head))}return{text:t,ranges:r}}function te(e){e.setAttribute("autocorrect","off"),e.setAttribute("autocapitalize","off"),e.setAttribute("spellcheck","false")}function re(e){this.cm=e,this.prevInput="",this.pollingFast=!1,this.polling=new Ai,this.inaccurateSelection=!1,this.hasSelection=!1,this.composing=null}function ne(){var e=Ui("textarea",null,null,"position: absolute; padding: 0; width: 1px; height: 1em; outline: none"),t=Ui("div",[e],null,"overflow: hidden; position: relative; width: 3px; height: 0px;");return xo?e.style.width="1000px":e.setAttribute("wrap","off"),No&&(e.style.border="1px solid black"),te(e),t}function ie(e){this.cm=e,this.lastAnchorNode=this.lastAnchorOffset=this.lastFocusNode=this.lastFocusOffset=null,this.polling=new Ai,this.gracePeriod=!1}function oe(e,t){var r=Je(e,t.line);if(!r||r.hidden)return null;var n=Zn(e.doc,t.line),i=qe(r,n,t.line),o=ii(n),l="left";if(o){var s=uo(o,t.ch);l=s%2?"right":"left"}var a=rt(i.map,t.ch,l);return a.offset="right"==a.collapse?a.end:a.start,a}function le(e,t){return t&&(e.bad=!0),e}function se(e,t,r){var n;if(t==e.display.lineDiv){if(n=e.display.lineDiv.childNodes[r],!n)return le(e.clipPos(zo(e.display.viewTo-1)),!0);t=null,r=0}else for(n=t;;n=n.parentNode){if(!n||n==e.display.lineDiv)return null;if(n.parentNode&&n.parentNode==e.display.lineDiv)break}for(var i=0;i<e.display.view.length;i++){var o=e.display.view[i];if(o.node==n)return ae(o,t,r)}}function ae(e,t,r){function n(t,r,n){for(var i=-1;i<(c?c.length:0);i++)for(var o=0>i?u.map:c[i],l=0;l<o.length;l+=3){var s=o[l+2];if(s==t||s==r){var a=ti(0>i?e.line:e.rest[i]),h=o[l]+n;return(0>n||s!=t)&&(h=o[l+(n?1:0)]),zo(a,h)}}}var i=e.text.firstChild,o=!1;if(!t||!Yl(i,t))return le(zo(ti(e.line),0),!0);if(t==i&&(o=!0,t=i.childNodes[r],r=0,!t)){var l=e.rest?Di(e.rest):e.line;return le(zo(ti(l),l.text.length),o)}var s=3==t.nodeType?t:null,a=t;for(s||1!=t.childNodes.length||3!=t.firstChild.nodeType||(s=t.firstChild,r&&(r=s.nodeValue.length));a.parentNode!=i;)a=a.parentNode;var u=e.measure,c=u.maps,h=n(s,a,r);if(h)return le(h,o);for(var f=a.nextSibling,d=s?s.nodeValue.length-r:0;f;f=f.nextSibling){if(h=n(f,f.firstChild,0))return le(zo(h.line,h.ch-d),o);d+=f.textContent.length}for(var p=a.previousSibling,d=r;p;p=p.previousSibling){if(h=n(p,p.firstChild,-1))return le(zo(h.line,h.ch+d),o);d+=f.textContent.length}}function ue(e,t,r,n,i){function o(e){return function(t){return t.id==e}}function l(t){if(1==t.nodeType){var r=t.getAttribute("cm-text");if(null!=r)return""==r&&(r=t.textContent.replace(/\u200b/g,"")),void(s+=r);var c,h=t.getAttribute("cm-marker");if(h){var f=e.findMarks(zo(n,0),zo(i+1,0),o(+h));return void(f.length&&(c=f[0].find())&&(s+=Qn(e.doc,c.from,c.to).join(u)))}if("false"==t.getAttribute("contenteditable"))return;for(var d=0;d<t.childNodes.length;d++)l(t.childNodes[d]);/^(pre|div|p)$/i.test(t.nodeName)&&(a=!0)}else if(3==t.nodeType){var p=t.nodeValue;if(!p)return;a&&(s+=u,a=!1),s+=p}}for(var s="",a=!1,u=e.doc.lineSeparator();l(t),t!=r;)t=t.nextSibling;return s}function ce(e,t){this.ranges=e,this.primIndex=t}function he(e,t){this.anchor=e,this.head=t}function fe(e,t){var r=e[t];e.sort(function(e,t){return Fo(e.from(),t.from())}),t=Hi(e,r);for(var n=1;n<e.length;n++){var i=e[n],o=e[n-1];if(Fo(o.to(),i.from())>=0){var l=$(o.from(),i.from()),s=_(o.to(),i.to()),a=o.empty()?i.from()==i.head:o.from()==o.head;t>=n&&--t,e.splice(--n,2,new he(a?s:l,a?l:s))}}return new ce(e,t)}function de(e,t){return new ce([new he(e,t||e)],0)}function pe(e,t){return Math.max(e.first,Math.min(t,e.first+e.size-1))}function ge(e,t){if(t.line<e.first)return zo(e.first,0);var r=e.first+e.size-1;return t.line>r?zo(r,Zn(e,r).text.length):ve(t,Zn(e,t.line).text.length)}function ve(e,t){var r=e.ch;return null==r||r>t?zo(e.line,t):0>r?zo(e.line,0):e}function me(e,t){return t>=e.first&&t<e.first+e.size}function ye(e,t){for(var r=[],n=0;n<t.length;n++)r[n]=ge(e,t[n]);return r}function be(e,t,r,n){if(e.cm&&e.cm.display.shift||e.extend){var i=t.anchor;if(n){var o=Fo(r,i)<0;o!=Fo(n,i)<0?(i=r,r=n):o!=Fo(r,n)<0&&(r=n)}return new he(i,r)}return new he(n||r,r)}function we(e,t,r,n){ke(e,new ce([be(e,e.sel.primary(),t,r)],0),n)}function xe(e,t,r){for(var n=[],i=0;i<e.sel.ranges.length;i++)n[i]=be(e,e.sel.ranges[i],t[i],null);var o=fe(n,e.sel.primIndex);ke(e,o,r)}function Ce(e,t,r,n){var i=e.sel.ranges.slice(0);i[t]=r,ke(e,fe(i,e.sel.primIndex),n)}function Se(e,t,r,n){ke(e,de(t,r),n)}function Le(e,t,r){var n={ranges:t.ranges,update:function(t){this.ranges=[];for(var r=0;r<t.length;r++)this.ranges[r]=new he(ge(e,t[r].anchor),ge(e,t[r].head))},origin:r&&r.origin};return Dl(e,"beforeSelectionChange",e,n),e.cm&&Dl(e.cm,"beforeSelectionChange",e.cm,n),n.ranges!=t.ranges?fe(n.ranges,n.ranges.length-1):t}function Te(e,t,r){var n=e.history.done,i=Di(n);i&&i.ranges?(n[n.length-1]=t,Me(e,t,r)):ke(e,t,r)}function ke(e,t,r){Me(e,t,r),hi(e,e.sel,e.cm?e.cm.curOp.id:NaN,r)}function Me(e,t,r){(Ni(e,"beforeSelectionChange")||e.cm&&Ni(e.cm,"beforeSelectionChange"))&&(t=Le(e,t,r));var n=r&&r.bias||(Fo(t.primary().head,e.sel.primary().head)<0?-1:1);Ne(e,Ae(e,t,n,!0)),r&&r.scroll===!1||!e.cm||zr(e.cm)}function Ne(e,t){t.equals(e.sel)||(e.sel=t,e.cm&&(e.cm.curOp.updateInput=e.cm.curOp.selectionChanged=!0,Mi(e.cm)),Li(e,"cursorActivity",e))}function We(e){Ne(e,Ae(e,e.sel,null,!1),Il)}function Ae(e,t,r,n){for(var i,o=0;o<t.ranges.length;o++){var l=t.ranges[o],s=t.ranges.length==e.sel.ranges.length&&e.sel.ranges[o],a=De(e,l.anchor,s&&s.anchor,r,n),u=De(e,l.head,s&&s.head,r,n);(i||a!=l.anchor||u!=l.head)&&(i||(i=t.ranges.slice(0,o)),i[o]=new he(a,u))}return i?fe(i,t.primIndex):t}function Oe(e,t,r,n,i){var o=Zn(e,t.line);if(o.markedSpans)for(var l=0;l<o.markedSpans.length;++l){var s=o.markedSpans[l],a=s.marker;if((null==s.from||(a.inclusiveLeft?s.from<=t.ch:s.from<t.ch))&&(null==s.to||(a.inclusiveRight?s.to>=t.ch:s.to>t.ch))){if(i&&(Dl(a,"beforeCursorEnter"),a.explicitlyCleared)){if(o.markedSpans){--l;continue}break}if(!a.atomic)continue;if(r){var u,c=a.find(0>n?1:-1);if((0>n?a.inclusiveRight:a.inclusiveLeft)&&(c=He(e,c,-n,o)),c&&c.line==t.line&&(u=Fo(c,r))&&(0>n?0>u:u>0))return Oe(e,c,t,n,i)}var h=a.find(0>n?-1:1);return(0>n?a.inclusiveLeft:a.inclusiveRight)&&(h=He(e,h,n,o)),h?Oe(e,h,t,n,i):null}}return t}function De(e,t,r,n,i){var o=n||1,l=Oe(e,t,r,o,i)||!i&&Oe(e,t,r,o,!0)||Oe(e,t,r,-o,i)||!i&&Oe(e,t,r,-o,!0);return l?l:(e.cantEdit=!0,zo(e.first,0))}function He(e,t,r,n){return 0>r&&0==t.ch?t.line>e.first?ge(e,zo(t.line-1)):null:r>0&&t.ch==(n||Zn(e,t.line)).text.length?t.line<e.first+e.size-1?zo(t.line+1,0):null:new zo(t.line,t.ch+r)}function Pe(e){e.display.input.showSelection(e.display.input.prepareSelection())}function Ee(e,t){for(var r=e.doc,n={},i=n.cursors=document.createDocumentFragment(),o=n.selection=document.createDocumentFragment(),l=0;l<r.sel.ranges.length;l++)if(t!==!1||l!=r.sel.primIndex){var s=r.sel.ranges[l],a=s.empty();(a||e.options.showCursorWhenSelecting)&&Ie(e,s.head,i),a||ze(e,s,o)}return n}function Ie(e,t,r){var n=dt(e,t,"div",null,null,!e.options.singleCursorHeightPerLine),i=r.appendChild(Ui("div"," ","CodeMirror-cursor"));if(i.style.left=n.left+"px",i.style.top=n.top+"px",i.style.height=Math.max(0,n.bottom-n.top)*e.options.cursorHeight+"px",n.other){var o=r.appendChild(Ui("div"," ","CodeMirror-cursor CodeMirror-secondarycursor"));o.style.display="",o.style.left=n.other.left+"px",o.style.top=n.other.top+"px",o.style.height=.85*(n.other.bottom-n.other.top)+"px"}}function ze(e,t,r){function n(e,t,r,n){0>t&&(t=0),t=Math.round(t),n=Math.round(n),s.appendChild(Ui("div",null,"CodeMirror-selected","position: absolute; left: "+e+"px; top: "+t+"px; width: "+(null==r?c-e:r)+"px; height: "+(n-t)+"px"))}function i(t,r,i){function o(r,n){return ft(e,zo(t,r),"div",h,n)}var s,a,h=Zn(l,t),f=h.text.length;return eo(ii(h),r||0,null==i?f:i,function(e,t,l){var h,d,p,g=o(e,"left");if(e==t)h=g,d=p=g.left;else{if(h=o(t-1,"right"),"rtl"==l){var v=g;g=h,h=v}d=g.left,p=h.right}null==r&&0==e&&(d=u),h.top-g.top>3&&(n(d,g.top,null,g.bottom),d=u,g.bottom<h.top&&n(d,g.bottom,null,h.top)),null==i&&t==f&&(p=c),(!s||g.top<s.top||g.top==s.top&&g.left<s.left)&&(s=g),(!a||h.bottom>a.bottom||h.bottom==a.bottom&&h.right>a.right)&&(a=h),u+1>d&&(d=u),n(d,h.top,p-d,h.bottom)}),{start:s,end:a}}var o=e.display,l=e.doc,s=document.createDocumentFragment(),a=je(e.display),u=a.left,c=Math.max(o.sizerWidth,Ye(e)-o.sizer.offsetLeft)-a.right,h=t.from(),f=t.to();if(h.line==f.line)i(h.line,h.ch,f.ch);else{var d=Zn(l,h.line),p=Zn(l,f.line),g=yn(d)==yn(p),v=i(h.line,h.ch,g?d.text.length+1:null).end,m=i(f.line,g?0:null,f.ch).start;g&&(v.top<m.top-2?(n(v.right,v.top,null,v.bottom),n(u,m.top,m.left,m.bottom)):n(v.right,v.top,m.left-v.right,v.bottom)),v.bottom<m.top&&n(u,v.bottom,null,m.top)}r.appendChild(s)}function Fe(e){if(e.state.focused){var t=e.display;clearInterval(t.blinker);var r=!0;t.cursorDiv.style.visibility="",e.options.cursorBlinkRate>0?t.blinker=setInterval(function(){t.cursorDiv.style.visibility=(r=!r)?"":"hidden"},e.options.cursorBlinkRate):e.options.cursorBlinkRate<0&&(t.cursorDiv.style.visibility="hidden")}}function Re(e,t){e.doc.mode.startState&&e.doc.frontier<e.display.viewTo&&e.state.highlight.set(t,Fi(Be,e))}function Be(e){var t=e.doc;if(t.frontier<t.first&&(t.frontier=t.first),!(t.frontier>=e.display.viewTo)){var r=+new Date+e.options.workTime,n=sl(t.mode,Ue(e,t.frontier)),i=[];t.iter(t.frontier,Math.min(t.first+t.size,e.display.viewTo+500),function(o){if(t.frontier>=e.display.viewFrom){var l=o.styles,s=o.text.length>e.options.maxHighlightLength,a=Pn(e,o,s?sl(t.mode,n):n,!0);o.styles=a.styles;var u=o.styleClasses,c=a.classes;c?o.styleClasses=c:u&&(o.styleClasses=null);for(var h=!l||l.length!=o.styles.length||u!=c&&(!u||!c||u.bgClass!=c.bgClass||u.textClass!=c.textClass),f=0;!h&&f<l.length;++f)h=l[f]!=o.styles[f];h&&i.push(t.frontier),o.stateAfter=s?n:sl(t.mode,n)}else o.text.length<=e.options.maxHighlightLength&&In(e,o.text,n),o.stateAfter=t.frontier%5==0?sl(t.mode,n):null;return++t.frontier,+new Date>r?(Re(e,e.options.workDelay),!0):void 0}),i.length&&Wt(e,function(){for(var t=0;t<i.length;t++)It(e,i[t],"text")})}}function Ge(e,t,r){for(var n,i,o=e.doc,l=r?-1:t-(e.doc.mode.innerMode?1e3:100),s=t;s>l;--s){if(s<=o.first)return o.first;var a=Zn(o,s-1);if(a.stateAfter&&(!r||s<=o.frontier))return s;var u=Rl(a.text,null,e.options.tabSize);(null==i||n>u)&&(i=s-1,n=u)}return i}function Ue(e,t,r){var n=e.doc,i=e.display;if(!n.mode.startState)return!0;var o=Ge(e,t,r),l=o>n.first&&Zn(n,o-1).stateAfter;return l=l?sl(n.mode,l):al(n.mode),n.iter(o,t,function(r){In(e,r.text,l);var s=o==t-1||o%5==0||o>=i.viewFrom&&o<i.viewTo;r.stateAfter=s?sl(n.mode,l):null,++o}),r&&(n.frontier=o),l}function Ve(e){return e.lineSpace.offsetTop}function Ke(e){return e.mover.offsetHeight-e.lineSpace.offsetHeight}function je(e){if(e.cachedPaddingH)return e.cachedPaddingH;var t=Ki(e.measure,Ui("pre","x")),r=window.getComputedStyle?window.getComputedStyle(t):t.currentStyle,n={left:parseInt(r.paddingLeft),right:parseInt(r.paddingRight)};return isNaN(n.left)||isNaN(n.right)||(e.cachedPaddingH=n),n}function Xe(e){return Pl-e.display.nativeBarWidth}function Ye(e){return e.display.scroller.clientWidth-Xe(e)-e.display.barWidth}function _e(e){return e.display.scroller.clientHeight-Xe(e)-e.display.barHeight}function $e(e,t,r){var n=e.options.lineWrapping,i=n&&Ye(e);if(!t.measure.heights||n&&t.measure.width!=i){var o=t.measure.heights=[];if(n){t.measure.width=i;for(var l=t.text.firstChild.getClientRects(),s=0;s<l.length-1;s++){var a=l[s],u=l[s+1];Math.abs(a.bottom-u.bottom)>2&&o.push((a.bottom+u.top)/2-r.top)}}o.push(r.bottom-r.top)}}function qe(e,t,r){if(e.line==t)return{map:e.measure.map,cache:e.measure.cache};for(var n=0;n<e.rest.length;n++)if(e.rest[n]==t)return{map:e.measure.maps[n],cache:e.measure.caches[n]};for(var n=0;n<e.rest.length;n++)if(ti(e.rest[n])>r)return{map:e.measure.maps[n],cache:e.measure.caches[n],before:!0}}function Ze(e,t){t=yn(t);var r=ti(t),n=e.display.externalMeasured=new Ht(e.doc,t,r);n.lineN=r;var i=n.built=Fn(e,n);return n.text=i.pre,Ki(e.display.lineMeasure,i.pre),n}function Qe(e,t,r,n){return tt(e,et(e,t),r,n)}function Je(e,t){if(t>=e.display.viewFrom&&t<e.display.viewTo)return e.display.view[Ft(e,t)];var r=e.display.externalMeasured;return r&&t>=r.lineN&&t<r.lineN+r.size?r:void 0}function et(e,t){var r=ti(t),n=Je(e,r);n&&!n.text?n=null:n&&n.changes&&(E(e,n,r,H(e)),e.curOp.forceUpdate=!0),n||(n=Ze(e,t));var i=qe(n,t,r);return{line:t,view:n,rect:null,map:i.map,cache:i.cache,before:i.before,hasHeights:!1}}function tt(e,t,r,n,i){t.before&&(r=-1);var o,l=r+(n||"");return t.cache.hasOwnProperty(l)?o=t.cache[l]:(t.rect||(t.rect=t.view.text.getBoundingClientRect()),t.hasHeights||($e(e,t.view,t.rect),t.hasHeights=!0),o=nt(e,t,r,n),o.bogus||(t.cache[l]=o)),{left:o.left,right:o.right,top:i?o.rtop:o.top,bottom:i?o.rbottom:o.bottom}}function rt(e,t,r){for(var n,i,o,l,s=0;s<e.length;s+=3){var a=e[s],u=e[s+1];if(a>t?(i=0,o=1,l="left"):u>t?(i=t-a,o=i+1):(s==e.length-3||t==u&&e[s+3]>t)&&(o=u-a,i=o-1,t>=u&&(l="right")),null!=i){if(n=e[s+2],a==u&&r==(n.insertLeft?"left":"right")&&(l=r),"left"==r&&0==i)for(;s&&e[s-2]==e[s-3]&&e[s-1].insertLeft;)n=e[(s-=3)+2],l="left";if("right"==r&&i==u-a)for(;s<e.length-3&&e[s+3]==e[s+4]&&!e[s+5].insertLeft;)n=e[(s+=3)+2],
|
2 |
+
l="right";break}}return{node:n,start:i,end:o,collapse:l,coverStart:a,coverEnd:u}}function nt(e,t,r,n){var i,o=rt(t.map,r,n),l=o.node,s=o.start,a=o.end,u=o.collapse;if(3==l.nodeType){for(var c=0;4>c;c++){for(;s&&Gi(t.line.text.charAt(o.coverStart+s));)--s;for(;o.coverStart+a<o.coverEnd&&Gi(t.line.text.charAt(o.coverStart+a));)++a;if(bo&&9>wo&&0==s&&a==o.coverEnd-o.coverStart)i=l.parentNode.getBoundingClientRect();else if(bo&&e.options.lineWrapping){var h=Vl(l,s,a).getClientRects();i=h.length?h["right"==n?h.length-1:0]:Vo}else i=Vl(l,s,a).getBoundingClientRect()||Vo;if(i.left||i.right||0==s)break;a=s,s-=1,u="right"}bo&&11>wo&&(i=it(e.display.measure,i))}else{s>0&&(u=n="right");var h;i=e.options.lineWrapping&&(h=l.getClientRects()).length>1?h["right"==n?h.length-1:0]:l.getBoundingClientRect()}if(bo&&9>wo&&!s&&(!i||!i.left&&!i.right)){var f=l.parentNode.getClientRects()[0];i=f?{left:f.left,right:f.left+bt(e.display),top:f.top,bottom:f.bottom}:Vo}for(var d=i.top-t.rect.top,p=i.bottom-t.rect.top,g=(d+p)/2,v=t.view.measure.heights,c=0;c<v.length-1&&!(g<v[c]);c++);var m=c?v[c-1]:0,y=v[c],b={left:("right"==u?i.right:i.left)-t.rect.left,right:("left"==u?i.left:i.right)-t.rect.left,top:m,bottom:y};return i.left||i.right||(b.bogus=!0),e.options.singleCursorHeightPerLine||(b.rtop=d,b.rbottom=p),b}function it(e,t){if(!window.screen||null==screen.logicalXDPI||screen.logicalXDPI==screen.deviceXDPI||!Ji(e))return t;var r=screen.logicalXDPI/screen.deviceXDPI,n=screen.logicalYDPI/screen.deviceYDPI;return{left:t.left*r,right:t.right*r,top:t.top*n,bottom:t.bottom*n}}function ot(e){if(e.measure&&(e.measure.cache={},e.measure.heights=null,e.rest))for(var t=0;t<e.rest.length;t++)e.measure.caches[t]={}}function lt(e){e.display.externalMeasure=null,Vi(e.display.lineMeasure);for(var t=0;t<e.display.view.length;t++)ot(e.display.view[t])}function st(e){lt(e),e.display.cachedCharWidth=e.display.cachedTextHeight=e.display.cachedPaddingH=null,e.options.lineWrapping||(e.display.maxLineChanged=!0),e.display.lineNumChars=null}function at(){return window.pageXOffset||(document.documentElement||document.body).scrollLeft}function ut(){return window.pageYOffset||(document.documentElement||document.body).scrollTop}function ct(e,t,r,n){if(t.widgets)for(var i=0;i<t.widgets.length;++i)if(t.widgets[i].above){var o=Tn(t.widgets[i]);r.top+=o,r.bottom+=o}if("line"==n)return r;n||(n="local");var l=ni(t);if("local"==n?l+=Ve(e.display):l-=e.display.viewOffset,"page"==n||"window"==n){var s=e.display.lineSpace.getBoundingClientRect();l+=s.top+("window"==n?0:ut());var a=s.left+("window"==n?0:at());r.left+=a,r.right+=a}return r.top+=l,r.bottom+=l,r}function ht(e,t,r){if("div"==r)return t;var n=t.left,i=t.top;if("page"==r)n-=at(),i-=ut();else if("local"==r||!r){var o=e.display.sizer.getBoundingClientRect();n+=o.left,i+=o.top}var l=e.display.lineSpace.getBoundingClientRect();return{left:n-l.left,top:i-l.top}}function ft(e,t,r,n,i){return n||(n=Zn(e.doc,t.line)),ct(e,n,Qe(e,n,t.ch,i),r)}function dt(e,t,r,n,i,o){function l(t,l){var s=tt(e,i,t,l?"right":"left",o);return l?s.left=s.right:s.right=s.left,ct(e,n,s,r)}function s(e,t){var r=a[t],n=r.level%2;return e==to(r)&&t&&r.level<a[t-1].level?(r=a[--t],e=ro(r)-(r.level%2?0:1),n=!0):e==ro(r)&&t<a.length-1&&r.level<a[t+1].level&&(r=a[++t],e=to(r)-r.level%2,n=!1),n&&e==r.to&&e>r.from?l(e-1):l(e,n)}n=n||Zn(e.doc,t.line),i||(i=et(e,n));var a=ii(n),u=t.ch;if(!a)return l(u);var c=uo(a,u),h=s(u,c);return null!=os&&(h.other=s(u,os)),h}function pt(e,t){var r=0,t=ge(e.doc,t);e.options.lineWrapping||(r=bt(e.display)*t.ch);var n=Zn(e.doc,t.line),i=ni(n)+Ve(e.display);return{left:r,right:r,top:i,bottom:i+n.height}}function gt(e,t,r,n){var i=zo(e,t);return i.xRel=n,r&&(i.outside=!0),i}function vt(e,t,r){var n=e.doc;if(r+=e.display.viewOffset,0>r)return gt(n.first,0,!0,-1);var i=ri(n,r),o=n.first+n.size-1;if(i>o)return gt(n.first+n.size-1,Zn(n,o).text.length,!0,1);0>t&&(t=0);for(var l=Zn(n,i);;){var s=mt(e,l,i,t,r),a=vn(l),u=a&&a.find(0,!0);if(!a||!(s.ch>u.from.ch||s.ch==u.from.ch&&s.xRel>0))return s;i=ti(l=u.to.line)}}function mt(e,t,r,n,i){function o(n){var i=dt(e,zo(r,n),"line",t,u);return s=!0,l>i.bottom?i.left-a:l<i.top?i.left+a:(s=!1,i.left)}var l=i-ni(t),s=!1,a=2*e.display.wrapper.clientWidth,u=et(e,t),c=ii(t),h=t.text.length,f=no(t),d=io(t),p=o(f),g=s,v=o(d),m=s;if(n>v)return gt(r,d,m,1);for(;;){if(c?d==f||d==ho(t,f,1):1>=d-f){for(var y=p>n||v-n>=n-p?f:d,b=n-(y==f?p:v);Gi(t.text.charAt(y));)++y;var w=gt(r,y,y==f?g:m,-1>b?-1:b>1?1:0);return w}var x=Math.ceil(h/2),C=f+x;if(c){C=f;for(var S=0;x>S;++S)C=ho(t,C,1)}var L=o(C);L>n?(d=C,v=L,(m=s)&&(v+=1e3),h=x):(f=C,p=L,g=s,h-=x)}}function yt(e){if(null!=e.cachedTextHeight)return e.cachedTextHeight;if(null==Bo){Bo=Ui("pre");for(var t=0;49>t;++t)Bo.appendChild(document.createTextNode("x")),Bo.appendChild(Ui("br"));Bo.appendChild(document.createTextNode("x"))}Ki(e.measure,Bo);var r=Bo.offsetHeight/50;return r>3&&(e.cachedTextHeight=r),Vi(e.measure),r||1}function bt(e){if(null!=e.cachedCharWidth)return e.cachedCharWidth;var t=Ui("span","xxxxxxxxxx"),r=Ui("pre",[t]);Ki(e.measure,r);var n=t.getBoundingClientRect(),i=(n.right-n.left)/10;return i>2&&(e.cachedCharWidth=i),i||10}function wt(e){e.curOp={cm:e,viewChanged:!1,startHeight:e.doc.height,forceUpdate:!1,updateInput:null,typing:!1,changeObjs:null,cursorActivityHandlers:null,cursorActivityCalled:0,selectionChanged:!1,updateMaxLine:!1,scrollLeft:null,scrollTop:null,scrollToPos:null,focus:!1,id:++jo},Ko?Ko.ops.push(e.curOp):e.curOp.ownsGroup=Ko={ops:[e.curOp],delayedCallbacks:[]}}function xt(e){var t=e.delayedCallbacks,r=0;do{for(;r<t.length;r++)t[r].call(null);for(var n=0;n<e.ops.length;n++){var i=e.ops[n];if(i.cursorActivityHandlers)for(;i.cursorActivityCalled<i.cursorActivityHandlers.length;)i.cursorActivityHandlers[i.cursorActivityCalled++].call(null,i.cm)}}while(r<t.length)}function Ct(e){var t=e.curOp,r=t.ownsGroup;if(r)try{xt(r)}finally{Ko=null;for(var n=0;n<r.ops.length;n++)r.ops[n].cm.curOp=null;St(r)}}function St(e){for(var t=e.ops,r=0;r<t.length;r++)Lt(t[r]);for(var r=0;r<t.length;r++)Tt(t[r]);for(var r=0;r<t.length;r++)kt(t[r]);for(var r=0;r<t.length;r++)Mt(t[r]);for(var r=0;r<t.length;r++)Nt(t[r])}function Lt(e){var t=e.cm,r=t.display;k(t),e.updateMaxLine&&f(t),e.mustUpdate=e.viewChanged||e.forceUpdate||null!=e.scrollTop||e.scrollToPos&&(e.scrollToPos.from.line<r.viewFrom||e.scrollToPos.to.line>=r.viewTo)||r.maxLineChanged&&t.options.lineWrapping,e.update=e.mustUpdate&&new T(t,e.mustUpdate&&{top:e.scrollTop,ensure:e.scrollToPos},e.forceUpdate)}function Tt(e){e.updatedDisplay=e.mustUpdate&&M(e.cm,e.update)}function kt(e){var t=e.cm,r=t.display;e.updatedDisplay&&O(t),e.barMeasure=p(t),r.maxLineChanged&&!t.options.lineWrapping&&(e.adjustWidthTo=Qe(t,r.maxLine,r.maxLine.text.length).left+3,t.display.sizerWidth=e.adjustWidthTo,e.barMeasure.scrollWidth=Math.max(r.scroller.clientWidth,r.sizer.offsetLeft+e.adjustWidthTo+Xe(t)+t.display.barWidth),e.maxScrollLeft=Math.max(0,r.sizer.offsetLeft+e.adjustWidthTo-Ye(t))),(e.updatedDisplay||e.selectionChanged)&&(e.preparedSelection=r.input.prepareSelection())}function Mt(e){var t=e.cm;null!=e.adjustWidthTo&&(t.display.sizer.style.minWidth=e.adjustWidthTo+"px",e.maxScrollLeft<t.doc.scrollLeft&&ir(t,Math.min(t.display.scroller.scrollLeft,e.maxScrollLeft),!0),t.display.maxLineChanged=!1),e.preparedSelection&&t.display.input.showSelection(e.preparedSelection),e.updatedDisplay&&A(t,e.barMeasure),(e.updatedDisplay||e.startHeight!=t.doc.height)&&y(t,e.barMeasure),e.selectionChanged&&Fe(t),t.state.focused&&e.updateInput&&t.display.input.reset(e.typing),!e.focus||e.focus!=ji()||document.hasFocus&&!document.hasFocus()||q(e.cm)}function Nt(e){var t=e.cm,r=t.display,n=t.doc;if(e.updatedDisplay&&N(t,e.update),null==r.wheelStartX||null==e.scrollTop&&null==e.scrollLeft&&!e.scrollToPos||(r.wheelStartX=r.wheelStartY=null),null==e.scrollTop||r.scroller.scrollTop==e.scrollTop&&!e.forceScroll||(n.scrollTop=Math.max(0,Math.min(r.scroller.scrollHeight-r.scroller.clientHeight,e.scrollTop)),r.scrollbars.setScrollTop(n.scrollTop),r.scroller.scrollTop=n.scrollTop),null==e.scrollLeft||r.scroller.scrollLeft==e.scrollLeft&&!e.forceScroll||(n.scrollLeft=Math.max(0,Math.min(r.scroller.scrollWidth-Ye(t),e.scrollLeft)),r.scrollbars.setScrollLeft(n.scrollLeft),r.scroller.scrollLeft=n.scrollLeft,x(t)),e.scrollToPos){var i=Hr(t,ge(n,e.scrollToPos.from),ge(n,e.scrollToPos.to),e.scrollToPos.margin);e.scrollToPos.isCursor&&t.state.focused&&Dr(t,i)}var o=e.maybeHiddenMarkers,l=e.maybeUnhiddenMarkers;if(o)for(var s=0;s<o.length;++s)o[s].lines.length||Dl(o[s],"hide");if(l)for(var s=0;s<l.length;++s)l[s].lines.length&&Dl(l[s],"unhide");r.wrapper.offsetHeight&&(n.scrollTop=t.display.scroller.scrollTop),e.changeObjs&&Dl(t,"changes",t,e.changeObjs),e.update&&e.update.finish()}function Wt(e,t){if(e.curOp)return t();wt(e);try{return t()}finally{Ct(e)}}function At(e,t){return function(){if(e.curOp)return t.apply(e,arguments);wt(e);try{return t.apply(e,arguments)}finally{Ct(e)}}}function Ot(e){return function(){if(this.curOp)return e.apply(this,arguments);wt(this);try{return e.apply(this,arguments)}finally{Ct(this)}}}function Dt(e){return function(){var t=this.cm;if(!t||t.curOp)return e.apply(this,arguments);wt(t);try{return e.apply(this,arguments)}finally{Ct(t)}}}function Ht(e,t,r){this.line=t,this.rest=bn(t),this.size=this.rest?ti(Di(this.rest))-r+1:1,this.node=this.text=null,this.hidden=Cn(e,t)}function Pt(e,t,r){for(var n,i=[],o=t;r>o;o=n){var l=new Ht(e.doc,Zn(e.doc,o),o);n=o+l.size,i.push(l)}return i}function Et(e,t,r,n){null==t&&(t=e.doc.first),null==r&&(r=e.doc.first+e.doc.size),n||(n=0);var i=e.display;if(n&&r<i.viewTo&&(null==i.updateLineNumbers||i.updateLineNumbers>t)&&(i.updateLineNumbers=t),e.curOp.viewChanged=!0,t>=i.viewTo)Io&&wn(e.doc,t)<i.viewTo&&zt(e);else if(r<=i.viewFrom)Io&&xn(e.doc,r+n)>i.viewFrom?zt(e):(i.viewFrom+=n,i.viewTo+=n);else if(t<=i.viewFrom&&r>=i.viewTo)zt(e);else if(t<=i.viewFrom){var o=Rt(e,r,r+n,1);o?(i.view=i.view.slice(o.index),i.viewFrom=o.lineN,i.viewTo+=n):zt(e)}else if(r>=i.viewTo){var o=Rt(e,t,t,-1);o?(i.view=i.view.slice(0,o.index),i.viewTo=o.lineN):zt(e)}else{var l=Rt(e,t,t,-1),s=Rt(e,r,r+n,1);l&&s?(i.view=i.view.slice(0,l.index).concat(Pt(e,l.lineN,s.lineN)).concat(i.view.slice(s.index)),i.viewTo+=n):zt(e)}var a=i.externalMeasured;a&&(r<a.lineN?a.lineN+=n:t<a.lineN+a.size&&(i.externalMeasured=null))}function It(e,t,r){e.curOp.viewChanged=!0;var n=e.display,i=e.display.externalMeasured;if(i&&t>=i.lineN&&t<i.lineN+i.size&&(n.externalMeasured=null),!(t<n.viewFrom||t>=n.viewTo)){var o=n.view[Ft(e,t)];if(null!=o.node){var l=o.changes||(o.changes=[]);-1==Hi(l,r)&&l.push(r)}}}function zt(e){e.display.viewFrom=e.display.viewTo=e.doc.first,e.display.view=[],e.display.viewOffset=0}function Ft(e,t){if(t>=e.display.viewTo)return null;if(t-=e.display.viewFrom,0>t)return null;for(var r=e.display.view,n=0;n<r.length;n++)if(t-=r[n].size,0>t)return n}function Rt(e,t,r,n){var i,o=Ft(e,t),l=e.display.view;if(!Io||r==e.doc.first+e.doc.size)return{index:o,lineN:r};for(var s=0,a=e.display.viewFrom;o>s;s++)a+=l[s].size;if(a!=t){if(n>0){if(o==l.length-1)return null;i=a+l[o].size-t,o++}else i=a-t;t+=i,r+=i}for(;wn(e.doc,r)!=r;){if(o==(0>n?0:l.length-1))return null;r+=n*l[o-(0>n?1:0)].size,o+=n}return{index:o,lineN:r}}function Bt(e,t,r){var n=e.display,i=n.view;0==i.length||t>=n.viewTo||r<=n.viewFrom?(n.view=Pt(e,t,r),n.viewFrom=t):(n.viewFrom>t?n.view=Pt(e,t,n.viewFrom).concat(n.view):n.viewFrom<t&&(n.view=n.view.slice(Ft(e,t))),n.viewFrom=t,n.viewTo<r?n.view=n.view.concat(Pt(e,n.viewTo,r)):n.viewTo>r&&(n.view=n.view.slice(0,Ft(e,r)))),n.viewTo=r}function Gt(e){for(var t=e.display.view,r=0,n=0;n<t.length;n++){var i=t[n];i.hidden||i.node&&!i.changes||++r}return r}function Ut(e){function t(){i.activeTouch&&(o=setTimeout(function(){i.activeTouch=null},1e3),l=i.activeTouch,l.end=+new Date)}function r(e){if(1!=e.touches.length)return!1;var t=e.touches[0];return t.radiusX<=1&&t.radiusY<=1}function n(e,t){if(null==t.left)return!0;var r=t.left-e.left,n=t.top-e.top;return r*r+n*n>400}var i=e.display;Wl(i.scroller,"mousedown",At(e,Yt)),bo&&11>wo?Wl(i.scroller,"dblclick",At(e,function(t){if(!ki(e,t)){var r=Xt(e,t);if(r&&!Qt(e,t)&&!jt(e.display,t)){kl(t);var n=e.findWordAt(r);we(e.doc,n.anchor,n.head)}}})):Wl(i.scroller,"dblclick",function(t){ki(e,t)||kl(t)}),Po||Wl(i.scroller,"contextmenu",function(t){yr(e,t)});var o,l={end:0};Wl(i.scroller,"touchstart",function(e){if(!r(e)){clearTimeout(o);var t=+new Date;i.activeTouch={start:t,moved:!1,prev:t-l.end<=300?l:null},1==e.touches.length&&(i.activeTouch.left=e.touches[0].pageX,i.activeTouch.top=e.touches[0].pageY)}}),Wl(i.scroller,"touchmove",function(){i.activeTouch&&(i.activeTouch.moved=!0)}),Wl(i.scroller,"touchend",function(r){var o=i.activeTouch;if(o&&!jt(i,r)&&null!=o.left&&!o.moved&&new Date-o.start<300){var l,s=e.coordsChar(i.activeTouch,"page");l=!o.prev||n(o,o.prev)?new he(s,s):!o.prev.prev||n(o,o.prev.prev)?e.findWordAt(s):new he(zo(s.line,0),ge(e.doc,zo(s.line+1,0))),e.setSelection(l.anchor,l.head),e.focus(),kl(r)}t()}),Wl(i.scroller,"touchcancel",t),Wl(i.scroller,"scroll",function(){i.scroller.clientHeight&&(nr(e,i.scroller.scrollTop),ir(e,i.scroller.scrollLeft,!0),Dl(e,"scroll",e))}),Wl(i.scroller,"mousewheel",function(t){or(e,t)}),Wl(i.scroller,"DOMMouseScroll",function(t){or(e,t)}),Wl(i.wrapper,"scroll",function(){i.wrapper.scrollTop=i.wrapper.scrollLeft=0}),i.dragFunctions={enter:function(t){ki(e,t)||Nl(t)},over:function(t){ki(e,t)||(tr(e,t),Nl(t))},start:function(t){er(e,t)},drop:At(e,Jt),leave:function(){rr(e)}};var s=i.input.getField();Wl(s,"keyup",function(t){dr.call(e,t)}),Wl(s,"keydown",At(e,hr)),Wl(s,"keypress",At(e,pr)),Wl(s,"focus",Fi(vr,e)),Wl(s,"blur",Fi(mr,e))}function Vt(t,r,n){var i=n&&n!=e.Init;if(!r!=!i){var o=t.display.dragFunctions,l=r?Wl:Ol;l(t.display.scroller,"dragstart",o.start),l(t.display.scroller,"dragenter",o.enter),l(t.display.scroller,"dragover",o.over),l(t.display.scroller,"dragleave",o.leave),l(t.display.scroller,"drop",o.drop)}}function Kt(e){var t=e.display;(t.lastWrapHeight!=t.wrapper.clientHeight||t.lastWrapWidth!=t.wrapper.clientWidth)&&(t.cachedCharWidth=t.cachedTextHeight=t.cachedPaddingH=null,t.scrollbarsClipped=!1,e.setSize())}function jt(e,t){for(var r=xi(t);r!=e.wrapper;r=r.parentNode)if(!r||1==r.nodeType&&"true"==r.getAttribute("cm-ignore-events")||r.parentNode==e.sizer&&r!=e.mover)return!0}function Xt(e,t,r,n){var i=e.display;if(!r&&"true"==xi(t).getAttribute("cm-not-content"))return null;var o,l,s=i.lineSpace.getBoundingClientRect();try{o=t.clientX-s.left,l=t.clientY-s.top}catch(t){return null}var a,u=vt(e,o,l);if(n&&1==u.xRel&&(a=Zn(e.doc,u.line).text).length==u.ch){var c=Rl(a,a.length,e.options.tabSize)-a.length;u=zo(u.line,Math.max(0,Math.round((o-je(e.display).left)/bt(e.display))-c))}return u}function Yt(e){var t=this,r=t.display;if(!(r.activeTouch&&r.input.supportsTouch()||ki(t,e))){if(r.shift=e.shiftKey,jt(r,e))return void(xo||(r.scroller.draggable=!1,setTimeout(function(){r.scroller.draggable=!0},100)));if(!Qt(t,e)){var n=Xt(t,e);switch(window.focus(),Ci(e)){case 1:t.state.selectingText?t.state.selectingText(e):n?_t(t,e,n):xi(e)==r.scroller&&kl(e);break;case 2:xo&&(t.state.lastMiddleDown=+new Date),n&&we(t.doc,n),setTimeout(function(){r.input.focus()},20),kl(e);break;case 3:Po?yr(t,e):gr(t)}}}}function _t(e,t,r){bo?setTimeout(Fi(q,e),0):e.curOp.focus=ji();var n,i=+new Date;Uo&&Uo.time>i-400&&0==Fo(Uo.pos,r)?n="triple":Go&&Go.time>i-400&&0==Fo(Go.pos,r)?(n="double",Uo={time:i,pos:r}):(n="single",Go={time:i,pos:r});var o,l=e.doc.sel,s=Ao?t.metaKey:t.ctrlKey;e.options.dragDrop&&Jl&&!e.isReadOnly()&&"single"==n&&(o=l.contains(r))>-1&&(Fo((o=l.ranges[o]).from(),r)<0||r.xRel>0)&&(Fo(o.to(),r)>0||r.xRel<0)?$t(e,t,r,s):qt(e,t,r,n,s)}function $t(e,t,r,n){var i=e.display,o=+new Date,l=At(e,function(s){xo&&(i.scroller.draggable=!1),e.state.draggingText=!1,Ol(document,"mouseup",l),Ol(i.scroller,"drop",l),Math.abs(t.clientX-s.clientX)+Math.abs(t.clientY-s.clientY)<10&&(kl(s),!n&&+new Date-200<o&&we(e.doc,r),xo||bo&&9==wo?setTimeout(function(){document.body.focus(),i.input.focus()},20):i.input.focus())});xo&&(i.scroller.draggable=!0),e.state.draggingText=l,i.scroller.dragDrop&&i.scroller.dragDrop(),Wl(document,"mouseup",l),Wl(i.scroller,"drop",l)}function qt(e,t,r,n,i){function o(t){if(0!=Fo(v,t))if(v=t,"rect"==n){for(var i=[],o=e.options.tabSize,l=Rl(Zn(u,r.line).text,r.ch,o),s=Rl(Zn(u,t.line).text,t.ch,o),a=Math.min(l,s),d=Math.max(l,s),p=Math.min(r.line,t.line),g=Math.min(e.lastLine(),Math.max(r.line,t.line));g>=p;p++){var m=Zn(u,p).text,y=Bl(m,a,o);a==d?i.push(new he(zo(p,y),zo(p,y))):m.length>y&&i.push(new he(zo(p,y),zo(p,Bl(m,d,o))))}i.length||i.push(new he(r,r)),ke(u,fe(f.ranges.slice(0,h).concat(i),h),{origin:"*mouse",scroll:!1}),e.scrollIntoView(t)}else{var b=c,w=b.anchor,x=t;if("single"!=n){if("double"==n)var C=e.findWordAt(t);else var C=new he(zo(t.line,0),ge(u,zo(t.line+1,0)));Fo(C.anchor,w)>0?(x=C.head,w=$(b.from(),C.anchor)):(x=C.anchor,w=_(b.to(),C.head))}var i=f.ranges.slice(0);i[h]=new he(ge(u,w),x),ke(u,fe(i,h),zl)}}function l(t){var r=++y,i=Xt(e,t,!0,"rect"==n);if(i)if(0!=Fo(i,v)){e.curOp.focus=ji(),o(i);var s=w(a,u);(i.line>=s.to||i.line<s.from)&&setTimeout(At(e,function(){y==r&&l(t)}),150)}else{var c=t.clientY<m.top?-20:t.clientY>m.bottom?20:0;c&&setTimeout(At(e,function(){y==r&&(a.scroller.scrollTop+=c,l(t))}),50)}}function s(t){e.state.selectingText=!1,y=1/0,kl(t),a.input.focus(),Ol(document,"mousemove",b),Ol(document,"mouseup",x),u.history.lastSelOrigin=null}var a=e.display,u=e.doc;kl(t);var c,h,f=u.sel,d=f.ranges;if(i&&!t.shiftKey?(h=u.sel.contains(r),c=h>-1?d[h]:new he(r,r)):(c=u.sel.primary(),h=u.sel.primIndex),t.altKey)n="rect",i||(c=new he(r,r)),r=Xt(e,t,!0,!0),h=-1;else if("double"==n){var p=e.findWordAt(r);c=e.display.shift||u.extend?be(u,c,p.anchor,p.head):p}else if("triple"==n){var g=new he(zo(r.line,0),ge(u,zo(r.line+1,0)));c=e.display.shift||u.extend?be(u,c,g.anchor,g.head):g}else c=be(u,c,r);i?-1==h?(h=d.length,ke(u,fe(d.concat([c]),h),{scroll:!1,origin:"*mouse"})):d.length>1&&d[h].empty()&&"single"==n&&!t.shiftKey?(ke(u,fe(d.slice(0,h).concat(d.slice(h+1)),0),{scroll:!1,origin:"*mouse"}),f=u.sel):Ce(u,h,c,zl):(h=0,ke(u,new ce([c],0),zl),f=u.sel);var v=r,m=a.wrapper.getBoundingClientRect(),y=0,b=At(e,function(e){Ci(e)?l(e):s(e)}),x=At(e,s);e.state.selectingText=x,Wl(document,"mousemove",b),Wl(document,"mouseup",x)}function Zt(e,t,r,n){try{var i=t.clientX,o=t.clientY}catch(t){return!1}if(i>=Math.floor(e.display.gutters.getBoundingClientRect().right))return!1;n&&kl(t);var l=e.display,s=l.lineDiv.getBoundingClientRect();if(o>s.bottom||!Ni(e,r))return wi(t);o-=s.top-l.viewOffset;for(var a=0;a<e.options.gutters.length;++a){var u=l.gutters.childNodes[a];if(u&&u.getBoundingClientRect().right>=i){var c=ri(e.doc,o),h=e.options.gutters[a];return Dl(e,r,e,c,h,t),wi(t)}}}function Qt(e,t){return Zt(e,t,"gutterClick",!0)}function Jt(e){var t=this;if(rr(t),!ki(t,e)&&!jt(t.display,e)){kl(e),bo&&(Xo=+new Date);var r=Xt(t,e,!0),n=e.dataTransfer.files;if(r&&!t.isReadOnly())if(n&&n.length&&window.FileReader&&window.File)for(var i=n.length,o=Array(i),l=0,s=function(e,n){if(!t.options.allowDropFileTypes||-1!=Hi(t.options.allowDropFileTypes,e.type)){var s=new FileReader;s.onload=At(t,function(){var e=s.result;if(/[\x00-\x08\x0e-\x1f]{2}/.test(e)&&(e=""),o[n]=e,++l==i){r=ge(t.doc,r);var a={from:r,to:r,text:t.doc.splitLines(o.join(t.doc.lineSeparator())),origin:"paste"};Tr(t.doc,a),Te(t.doc,de(r,Qo(a)))}}),s.readAsText(e)}},a=0;i>a;++a)s(n[a],a);else{if(t.state.draggingText&&t.doc.sel.contains(r)>-1)return t.state.draggingText(e),void setTimeout(function(){t.display.input.focus()},20);try{var o=e.dataTransfer.getData("Text");if(o){if(t.state.draggingText&&!(Ao?e.altKey:e.ctrlKey))var u=t.listSelections();if(Me(t.doc,de(r,r)),u)for(var a=0;a<u.length;++a)Or(t.doc,"",u[a].anchor,u[a].head,"drag");t.replaceSelection(o,"around","paste"),t.display.input.focus()}}catch(e){}}}}function er(e,t){if(bo&&(!e.state.draggingText||+new Date-Xo<100))return void Nl(t);if(!ki(e,t)&&!jt(e.display,t)&&(t.dataTransfer.setData("Text",e.getSelection()),t.dataTransfer.setDragImage&&!To)){var r=Ui("img",null,null,"position: fixed; left: 0; top: 0;");r.src="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==",Lo&&(r.width=r.height=1,e.display.wrapper.appendChild(r),r._top=r.offsetTop),t.dataTransfer.setDragImage(r,0,0),Lo&&r.parentNode.removeChild(r)}}function tr(e,t){var r=Xt(e,t);if(r){var n=document.createDocumentFragment();Ie(e,r,n),e.display.dragCursor||(e.display.dragCursor=Ui("div",null,"CodeMirror-cursors CodeMirror-dragcursors"),e.display.lineSpace.insertBefore(e.display.dragCursor,e.display.cursorDiv)),Ki(e.display.dragCursor,n)}}function rr(e){e.display.dragCursor&&(e.display.lineSpace.removeChild(e.display.dragCursor),e.display.dragCursor=null)}function nr(e,t){Math.abs(e.doc.scrollTop-t)<2||(e.doc.scrollTop=t,vo||W(e,{top:t}),e.display.scroller.scrollTop!=t&&(e.display.scroller.scrollTop=t),e.display.scrollbars.setScrollTop(t),vo&&W(e),Re(e,100))}function ir(e,t,r){(r?t==e.doc.scrollLeft:Math.abs(e.doc.scrollLeft-t)<2)||(t=Math.min(t,e.display.scroller.scrollWidth-e.display.scroller.clientWidth),e.doc.scrollLeft=t,x(e),e.display.scroller.scrollLeft!=t&&(e.display.scroller.scrollLeft=t),e.display.scrollbars.setScrollLeft(t))}function or(e,t){var r=$o(t),n=r.x,i=r.y,o=e.display,l=o.scroller,s=l.scrollWidth>l.clientWidth,a=l.scrollHeight>l.clientHeight;if(n&&s||i&&a){if(i&&Ao&&xo)e:for(var u=t.target,c=o.view;u!=l;u=u.parentNode)for(var h=0;h<c.length;h++)if(c[h].node==u){e.display.currentWheelTarget=u;break e}if(n&&!vo&&!Lo&&null!=_o)return i&&a&&nr(e,Math.max(0,Math.min(l.scrollTop+i*_o,l.scrollHeight-l.clientHeight))),ir(e,Math.max(0,Math.min(l.scrollLeft+n*_o,l.scrollWidth-l.clientWidth))),(!i||i&&a)&&kl(t),void(o.wheelStartX=null);if(i&&null!=_o){var f=i*_o,d=e.doc.scrollTop,p=d+o.wrapper.clientHeight;0>f?d=Math.max(0,d+f-50):p=Math.min(e.doc.height,p+f+50),W(e,{top:d,bottom:p})}20>Yo&&(null==o.wheelStartX?(o.wheelStartX=l.scrollLeft,o.wheelStartY=l.scrollTop,o.wheelDX=n,o.wheelDY=i,setTimeout(function(){if(null!=o.wheelStartX){var e=l.scrollLeft-o.wheelStartX,t=l.scrollTop-o.wheelStartY,r=t&&o.wheelDY&&t/o.wheelDY||e&&o.wheelDX&&e/o.wheelDX;o.wheelStartX=o.wheelStartY=null,r&&(_o=(_o*Yo+r)/(Yo+1),++Yo)}},200)):(o.wheelDX+=n,o.wheelDY+=i))}}function lr(e,t,r){if("string"==typeof t&&(t=ul[t],!t))return!1;e.display.input.ensurePolled();var n=e.display.shift,i=!1;try{e.isReadOnly()&&(e.state.suppressEdits=!0),r&&(e.display.shift=!1),i=t(e)!=El}finally{e.display.shift=n,e.state.suppressEdits=!1}return i}function sr(e,t,r){for(var n=0;n<e.state.keyMaps.length;n++){var i=hl(t,e.state.keyMaps[n],r,e);if(i)return i}return e.options.extraKeys&&hl(t,e.options.extraKeys,r,e)||hl(t,e.options.keyMap,r,e)}function ar(e,t,r,n){var i=e.state.keySeq;if(i){if(fl(t))return"handled";qo.set(50,function(){e.state.keySeq==i&&(e.state.keySeq=null,e.display.input.reset())}),t=i+" "+t}var o=sr(e,t,n);return"multi"==o&&(e.state.keySeq=t),"handled"==o&&Li(e,"keyHandled",e,t,r),("handled"==o||"multi"==o)&&(kl(r),Fe(e)),i&&!o&&/\'$/.test(t)?(kl(r),!0):!!o}function ur(e,t){var r=dl(t,!0);return r?t.shiftKey&&!e.state.keySeq?ar(e,"Shift-"+r,t,function(t){return lr(e,t,!0)})||ar(e,r,t,function(t){return("string"==typeof t?/^go[A-Z]/.test(t):t.motion)?lr(e,t):void 0}):ar(e,r,t,function(t){return lr(e,t)}):!1}function cr(e,t,r){return ar(e,"'"+r+"'",t,function(t){return lr(e,t,!0)})}function hr(e){var t=this;if(t.curOp.focus=ji(),!ki(t,e)){bo&&11>wo&&27==e.keyCode&&(e.returnValue=!1);var r=e.keyCode;t.display.shift=16==r||e.shiftKey;var n=ur(t,e);Lo&&(Zo=n?r:null,!n&&88==r&&!rs&&(Ao?e.metaKey:e.ctrlKey)&&t.replaceSelection("",null,"cut")),18!=r||/\bCodeMirror-crosshair\b/.test(t.display.lineDiv.className)||fr(t)}}function fr(e){function t(e){18!=e.keyCode&&e.altKey||(ql(r,"CodeMirror-crosshair"),Ol(document,"keyup",t),Ol(document,"mouseover",t))}var r=e.display.lineDiv;Zl(r,"CodeMirror-crosshair"),Wl(document,"keyup",t),Wl(document,"mouseover",t)}function dr(e){16==e.keyCode&&(this.doc.sel.shift=!1),ki(this,e)}function pr(e){var t=this;if(!(jt(t.display,e)||ki(t,e)||e.ctrlKey&&!e.altKey||Ao&&e.metaKey)){var r=e.keyCode,n=e.charCode;if(Lo&&r==Zo)return Zo=null,void kl(e);if(!Lo||e.which&&!(e.which<10)||!ur(t,e)){var i=String.fromCharCode(null==n?r:n);cr(t,e,i)||t.display.input.onKeyPress(e)}}}function gr(e){e.state.delayingBlurEvent=!0,setTimeout(function(){e.state.delayingBlurEvent&&(e.state.delayingBlurEvent=!1,mr(e))},100)}function vr(e){e.state.delayingBlurEvent&&(e.state.delayingBlurEvent=!1),"nocursor"!=e.options.readOnly&&(e.state.focused||(Dl(e,"focus",e),e.state.focused=!0,Zl(e.display.wrapper,"CodeMirror-focused"),e.curOp||e.display.selForContextMenu==e.doc.sel||(e.display.input.reset(),xo&&setTimeout(function(){e.display.input.reset(!0)},20)),e.display.input.receivedFocus()),Fe(e))}function mr(e){e.state.delayingBlurEvent||(e.state.focused&&(Dl(e,"blur",e),e.state.focused=!1,ql(e.display.wrapper,"CodeMirror-focused")),clearInterval(e.display.blinker),setTimeout(function(){e.state.focused||(e.display.shift=!1)},150))}function yr(e,t){jt(e.display,t)||br(e,t)||ki(e,t,"contextmenu")||e.display.input.onContextMenu(t)}function br(e,t){return Ni(e,"gutterContextMenu")?Zt(e,t,"gutterContextMenu",!1):!1}function wr(e,t){if(Fo(e,t.from)<0)return e;if(Fo(e,t.to)<=0)return Qo(t);var r=e.line+t.text.length-(t.to.line-t.from.line)-1,n=e.ch;return e.line==t.to.line&&(n+=Qo(t).ch-t.to.ch),zo(r,n)}function xr(e,t){for(var r=[],n=0;n<e.sel.ranges.length;n++){var i=e.sel.ranges[n];r.push(new he(wr(i.anchor,t),wr(i.head,t)))}return fe(r,e.sel.primIndex)}function Cr(e,t,r){return e.line==t.line?zo(r.line,e.ch-t.ch+r.ch):zo(r.line+(e.line-t.line),e.ch)}function Sr(e,t,r){for(var n=[],i=zo(e.first,0),o=i,l=0;l<t.length;l++){var s=t[l],a=Cr(s.from,i,o),u=Cr(Qo(s),i,o);if(i=s.to,o=u,"around"==r){var c=e.sel.ranges[l],h=Fo(c.head,c.anchor)<0;n[l]=new he(h?u:a,h?a:u)}else n[l]=new he(a,a)}return new ce(n,e.sel.primIndex)}function Lr(e,t,r){var n={canceled:!1,from:t.from,to:t.to,text:t.text,origin:t.origin,cancel:function(){this.canceled=!0}};return r&&(n.update=function(t,r,n,i){t&&(this.from=ge(e,t)),r&&(this.to=ge(e,r)),n&&(this.text=n),void 0!==i&&(this.origin=i)}),Dl(e,"beforeChange",e,n),e.cm&&Dl(e.cm,"beforeChange",e.cm,n),n.canceled?null:{from:n.from,to:n.to,text:n.text,origin:n.origin}}function Tr(e,t,r){if(e.cm){if(!e.cm.curOp)return At(e.cm,Tr)(e,t,r);if(e.cm.state.suppressEdits)return}if(!(Ni(e,"beforeChange")||e.cm&&Ni(e.cm,"beforeChange"))||(t=Lr(e,t,!0))){var n=Eo&&!r&&an(e,t.from,t.to);if(n)for(var i=n.length-1;i>=0;--i)kr(e,{from:n[i].from,to:n[i].to,text:i?[""]:t.text});else kr(e,t)}}function kr(e,t){if(1!=t.text.length||""!=t.text[0]||0!=Fo(t.from,t.to)){var r=xr(e,t);ui(e,t,r,e.cm?e.cm.curOp.id:NaN),Wr(e,t,r,on(e,t));var n=[];$n(e,function(e,r){r||-1!=Hi(n,e.history)||(bi(e.history,t),n.push(e.history)),Wr(e,t,null,on(e,t))})}}function Mr(e,t,r){if(!e.cm||!e.cm.state.suppressEdits){for(var n,i=e.history,o=e.sel,l="undo"==t?i.done:i.undone,s="undo"==t?i.undone:i.done,a=0;a<l.length&&(n=l[a],r?!n.ranges||n.equals(e.sel):n.ranges);a++);if(a!=l.length){for(i.lastOrigin=i.lastSelOrigin=null;n=l.pop(),n.ranges;){if(fi(n,s),r&&!n.equals(e.sel))return void ke(e,n,{clearRedo:!1});o=n}var u=[];fi(o,s),s.push({changes:u,generation:i.generation}),i.generation=n.generation||++i.maxGeneration;for(var c=Ni(e,"beforeChange")||e.cm&&Ni(e.cm,"beforeChange"),a=n.changes.length-1;a>=0;--a){var h=n.changes[a];if(h.origin=t,c&&!Lr(e,h,!1))return void(l.length=0);u.push(li(e,h));var f=a?xr(e,h):Di(l);Wr(e,h,f,sn(e,h)),!a&&e.cm&&e.cm.scrollIntoView({from:h.from,to:Qo(h)});var d=[];$n(e,function(e,t){t||-1!=Hi(d,e.history)||(bi(e.history,h),d.push(e.history)),Wr(e,h,null,sn(e,h))})}}}}function Nr(e,t){if(0!=t&&(e.first+=t,e.sel=new ce(Pi(e.sel.ranges,function(e){return new he(zo(e.anchor.line+t,e.anchor.ch),zo(e.head.line+t,e.head.ch))}),e.sel.primIndex),e.cm)){Et(e.cm,e.first,e.first-t,t);for(var r=e.cm.display,n=r.viewFrom;n<r.viewTo;n++)It(e.cm,n,"gutter")}}function Wr(e,t,r,n){if(e.cm&&!e.cm.curOp)return At(e.cm,Wr)(e,t,r,n);if(t.to.line<e.first)return void Nr(e,t.text.length-1-(t.to.line-t.from.line));if(!(t.from.line>e.lastLine())){if(t.from.line<e.first){var i=t.text.length-1-(e.first-t.from.line);Nr(e,i),t={from:zo(e.first,0),to:zo(t.to.line+i,t.to.ch),text:[Di(t.text)],origin:t.origin}}var o=e.lastLine();t.to.line>o&&(t={from:t.from,to:zo(o,Zn(e,o).text.length),text:[t.text[0]],origin:t.origin}),t.removed=Qn(e,t.from,t.to),r||(r=xr(e,t)),e.cm?Ar(e.cm,t,n):Xn(e,t,n),Me(e,r,Il)}}function Ar(e,t,r){var n=e.doc,i=e.display,l=t.from,s=t.to,a=!1,u=l.line;e.options.lineWrapping||(u=ti(yn(Zn(n,l.line))),n.iter(u,s.line+1,function(e){return e==i.maxLine?(a=!0,!0):void 0})),n.sel.contains(t.from,t.to)>-1&&Mi(e),Xn(n,t,r,o(e)),e.options.lineWrapping||(n.iter(u,l.line+t.text.length,function(e){var t=h(e);t>i.maxLineLength&&(i.maxLine=e,i.maxLineLength=t,i.maxLineChanged=!0,a=!1)}),a&&(e.curOp.updateMaxLine=!0)),n.frontier=Math.min(n.frontier,l.line),Re(e,400);var c=t.text.length-(s.line-l.line)-1;t.full?Et(e):l.line!=s.line||1!=t.text.length||jn(e.doc,t)?Et(e,l.line,s.line+1,c):It(e,l.line,"text");var f=Ni(e,"changes"),d=Ni(e,"change");if(d||f){var p={from:l,to:s,text:t.text,removed:t.removed,origin:t.origin};d&&Li(e,"change",e,p),f&&(e.curOp.changeObjs||(e.curOp.changeObjs=[])).push(p)}e.display.selForContextMenu=null}function Or(e,t,r,n,i){if(n||(n=r),Fo(n,r)<0){var o=n;n=r,r=o}"string"==typeof t&&(t=e.splitLines(t)),Tr(e,{from:r,to:n,text:t,origin:i})}function Dr(e,t){if(!ki(e,"scrollCursorIntoView")){var r=e.display,n=r.sizer.getBoundingClientRect(),i=null;if(t.top+n.top<0?i=!0:t.bottom+n.top>(window.innerHeight||document.documentElement.clientHeight)&&(i=!1),null!=i&&!Mo){var o=Ui("div","",null,"position: absolute; top: "+(t.top-r.viewOffset-Ve(e.display))+"px; height: "+(t.bottom-t.top+Xe(e)+r.barHeight)+"px; left: "+t.left+"px; width: 2px;");e.display.lineSpace.appendChild(o),o.scrollIntoView(i),e.display.lineSpace.removeChild(o)}}}function Hr(e,t,r,n){null==n&&(n=0);for(var i=0;5>i;i++){var o=!1,l=dt(e,t),s=r&&r!=t?dt(e,r):l,a=Er(e,Math.min(l.left,s.left),Math.min(l.top,s.top)-n,Math.max(l.left,s.left),Math.max(l.bottom,s.bottom)+n),u=e.doc.scrollTop,c=e.doc.scrollLeft;if(null!=a.scrollTop&&(nr(e,a.scrollTop),Math.abs(e.doc.scrollTop-u)>1&&(o=!0)),null!=a.scrollLeft&&(ir(e,a.scrollLeft),Math.abs(e.doc.scrollLeft-c)>1&&(o=!0)),!o)break}return l}function Pr(e,t,r,n,i){var o=Er(e,t,r,n,i);null!=o.scrollTop&&nr(e,o.scrollTop),null!=o.scrollLeft&&ir(e,o.scrollLeft)}function Er(e,t,r,n,i){var o=e.display,l=yt(e.display);0>r&&(r=0);var s=e.curOp&&null!=e.curOp.scrollTop?e.curOp.scrollTop:o.scroller.scrollTop,a=_e(e),u={};i-r>a&&(i=r+a);var c=e.doc.height+Ke(o),h=l>r,f=i>c-l;if(s>r)u.scrollTop=h?0:r;else if(i>s+a){var d=Math.min(r,(f?c:i)-a);d!=s&&(u.scrollTop=d)}var p=e.curOp&&null!=e.curOp.scrollLeft?e.curOp.scrollLeft:o.scroller.scrollLeft,g=Ye(e)-(e.options.fixedGutter?o.gutters.offsetWidth:0),v=n-t>g;return v&&(n=t+g),10>t?u.scrollLeft=0:p>t?u.scrollLeft=Math.max(0,t-(v?0:10)):n>g+p-3&&(u.scrollLeft=n+(v?0:10)-g),u}function Ir(e,t,r){(null!=t||null!=r)&&Fr(e),null!=t&&(e.curOp.scrollLeft=(null==e.curOp.scrollLeft?e.doc.scrollLeft:e.curOp.scrollLeft)+t),null!=r&&(e.curOp.scrollTop=(null==e.curOp.scrollTop?e.doc.scrollTop:e.curOp.scrollTop)+r)}function zr(e){Fr(e);var t=e.getCursor(),r=t,n=t;e.options.lineWrapping||(r=t.ch?zo(t.line,t.ch-1):t,n=zo(t.line,t.ch+1)),e.curOp.scrollToPos={from:r,to:n,margin:e.options.cursorScrollMargin,isCursor:!0}}function Fr(e){var t=e.curOp.scrollToPos;if(t){e.curOp.scrollToPos=null;var r=pt(e,t.from),n=pt(e,t.to),i=Er(e,Math.min(r.left,n.left),Math.min(r.top,n.top)-t.margin,Math.max(r.right,n.right),Math.max(r.bottom,n.bottom)+t.margin);
|
3 |
+
e.scrollTo(i.scrollLeft,i.scrollTop)}}function Rr(e,t,r,n){var i,o=e.doc;null==r&&(r="add"),"smart"==r&&(o.mode.indent?i=Ue(e,t):r="prev");var l=e.options.tabSize,s=Zn(o,t),a=Rl(s.text,null,l);s.stateAfter&&(s.stateAfter=null);var u,c=s.text.match(/^\s*/)[0];if(n||/\S/.test(s.text)){if("smart"==r&&(u=o.mode.indent(i,s.text.slice(c.length),s.text),u==El||u>150)){if(!n)return;r="prev"}}else u=0,r="not";"prev"==r?u=t>o.first?Rl(Zn(o,t-1).text,null,l):0:"add"==r?u=a+e.options.indentUnit:"subtract"==r?u=a-e.options.indentUnit:"number"==typeof r&&(u=a+r),u=Math.max(0,u);var h="",f=0;if(e.options.indentWithTabs)for(var d=Math.floor(u/l);d;--d)f+=l,h+=" ";if(u>f&&(h+=Oi(u-f)),h!=c)return Or(o,h,zo(t,0),zo(t,c.length),"+input"),s.stateAfter=null,!0;for(var d=0;d<o.sel.ranges.length;d++){var p=o.sel.ranges[d];if(p.head.line==t&&p.head.ch<c.length){var f=zo(t,c.length);Ce(o,d,new he(f,f));break}}}function Br(e,t,r,n){var i=t,o=t;return"number"==typeof t?o=Zn(e,pe(e,t)):i=ti(t),null==i?null:(n(o,i)&&e.cm&&It(e.cm,i,r),o)}function Gr(e,t){for(var r=e.doc.sel.ranges,n=[],i=0;i<r.length;i++){for(var o=t(r[i]);n.length&&Fo(o.from,Di(n).to)<=0;){var l=n.pop();if(Fo(l.from,o.from)<0){o.from=l.from;break}}n.push(o)}Wt(e,function(){for(var t=n.length-1;t>=0;t--)Or(e.doc,"",n[t].from,n[t].to,"+delete");zr(e)})}function Ur(e,t,r,n,i){function o(){var t=s+r;return t<e.first||t>=e.first+e.size?h=!1:(s=t,c=Zn(e,t))}function l(e){var t=(i?ho:fo)(c,a,r,!0);if(null==t){if(e||!o())return h=!1;a=i?(0>r?io:no)(c):0>r?c.text.length:0}else a=t;return!0}var s=t.line,a=t.ch,u=r,c=Zn(e,s),h=!0;if("char"==n)l();else if("column"==n)l(!0);else if("word"==n||"group"==n)for(var f=null,d="group"==n,p=e.cm&&e.cm.getHelper(t,"wordChars"),g=!0;!(0>r)||l(!g);g=!1){var v=c.text.charAt(a)||"\n",m=Ri(v,p)?"w":d&&"\n"==v?"n":!d||/\s/.test(v)?null:"p";if(!d||g||m||(m="s"),f&&f!=m){0>r&&(r=1,l());break}if(m&&(f=m),r>0&&!l(!g))break}var y=De(e,zo(s,a),t,u,!0);return h||(y.hitSide=!0),y}function Vr(e,t,r,n){var i,o=e.doc,l=t.left;if("page"==n){var s=Math.min(e.display.wrapper.clientHeight,window.innerHeight||document.documentElement.clientHeight);i=t.top+r*(s-(0>r?1.5:.5)*yt(e.display))}else"line"==n&&(i=r>0?t.bottom+3:t.top-3);for(;;){var a=vt(e,l,i);if(!a.outside)break;if(0>r?0>=i:i>=o.height){a.hitSide=!0;break}i+=5*r}return a}function Kr(t,r,n,i){e.defaults[t]=r,n&&(el[t]=i?function(e,t,r){r!=tl&&n(e,t,r)}:n)}function jr(e){for(var t,r,n,i,o=e.split(/-(?!$)/),e=o[o.length-1],l=0;l<o.length-1;l++){var s=o[l];if(/^(cmd|meta|m)$/i.test(s))i=!0;else if(/^a(lt)?$/i.test(s))t=!0;else if(/^(c|ctrl|control)$/i.test(s))r=!0;else{if(!/^s(hift)$/i.test(s))throw new Error("Unrecognized modifier name: "+s);n=!0}}return t&&(e="Alt-"+e),r&&(e="Ctrl-"+e),i&&(e="Cmd-"+e),n&&(e="Shift-"+e),e}function Xr(e){return"string"==typeof e?cl[e]:e}function Yr(e,t,r,n,i){if(n&&n.shared)return _r(e,t,r,n,i);if(e.cm&&!e.cm.curOp)return At(e.cm,Yr)(e,t,r,n,i);var o=new vl(e,i),l=Fo(t,r);if(n&&zi(n,o,!1),l>0||0==l&&o.clearWhenEmpty!==!1)return o;if(o.replacedWith&&(o.collapsed=!0,o.widgetNode=Ui("span",[o.replacedWith],"CodeMirror-widget"),n.handleMouseEvents||o.widgetNode.setAttribute("cm-ignore-events","true"),n.insertLeft&&(o.widgetNode.insertLeft=!0)),o.collapsed){if(mn(e,t.line,t,r,o)||t.line!=r.line&&mn(e,r.line,t,r,o))throw new Error("Inserting collapsed marker partially overlapping an existing one");Io=!0}o.addToHistory&&ui(e,{from:t,to:r,origin:"markText"},e.sel,NaN);var s,a=t.line,u=e.cm;if(e.iter(a,r.line+1,function(e){u&&o.collapsed&&!u.options.lineWrapping&&yn(e)==u.display.maxLine&&(s=!0),o.collapsed&&a!=t.line&&ei(e,0),tn(e,new Qr(o,a==t.line?t.ch:null,a==r.line?r.ch:null)),++a}),o.collapsed&&e.iter(t.line,r.line+1,function(t){Cn(e,t)&&ei(t,0)}),o.clearOnEnter&&Wl(o,"beforeCursorEnter",function(){o.clear()}),o.readOnly&&(Eo=!0,(e.history.done.length||e.history.undone.length)&&e.clearHistory()),o.collapsed&&(o.id=++gl,o.atomic=!0),u){if(s&&(u.curOp.updateMaxLine=!0),o.collapsed)Et(u,t.line,r.line+1);else if(o.className||o.title||o.startStyle||o.endStyle||o.css)for(var c=t.line;c<=r.line;c++)It(u,c,"text");o.atomic&&We(u.doc),Li(u,"markerAdded",u,o)}return o}function _r(e,t,r,n,i){n=zi(n),n.shared=!1;var o=[Yr(e,t,r,n,i)],l=o[0],s=n.widgetNode;return $n(e,function(e){s&&(n.widgetNode=s.cloneNode(!0)),o.push(Yr(e,ge(e,t),ge(e,r),n,i));for(var a=0;a<e.linked.length;++a)if(e.linked[a].isParent)return;l=Di(o)}),new ml(o,l)}function $r(e){return e.findMarks(zo(e.first,0),e.clipPos(zo(e.lastLine())),function(e){return e.parent})}function qr(e,t){for(var r=0;r<t.length;r++){var n=t[r],i=n.find(),o=e.clipPos(i.from),l=e.clipPos(i.to);if(Fo(o,l)){var s=Yr(e,o,l,n.primary,n.primary.type);n.markers.push(s),s.parent=n}}}function Zr(e){for(var t=0;t<e.length;t++){var r=e[t],n=[r.primary.doc];$n(r.primary.doc,function(e){n.push(e)});for(var i=0;i<r.markers.length;i++){var o=r.markers[i];-1==Hi(n,o.doc)&&(o.parent=null,r.markers.splice(i--,1))}}}function Qr(e,t,r){this.marker=e,this.from=t,this.to=r}function Jr(e,t){if(e)for(var r=0;r<e.length;++r){var n=e[r];if(n.marker==t)return n}}function en(e,t){for(var r,n=0;n<e.length;++n)e[n]!=t&&(r||(r=[])).push(e[n]);return r}function tn(e,t){e.markedSpans=e.markedSpans?e.markedSpans.concat([t]):[t],t.marker.attachLine(e)}function rn(e,t,r){if(e)for(var n,i=0;i<e.length;++i){var o=e[i],l=o.marker,s=null==o.from||(l.inclusiveLeft?o.from<=t:o.from<t);if(s||o.from==t&&"bookmark"==l.type&&(!r||!o.marker.insertLeft)){var a=null==o.to||(l.inclusiveRight?o.to>=t:o.to>t);(n||(n=[])).push(new Qr(l,o.from,a?null:o.to))}}return n}function nn(e,t,r){if(e)for(var n,i=0;i<e.length;++i){var o=e[i],l=o.marker,s=null==o.to||(l.inclusiveRight?o.to>=t:o.to>t);if(s||o.from==t&&"bookmark"==l.type&&(!r||o.marker.insertLeft)){var a=null==o.from||(l.inclusiveLeft?o.from<=t:o.from<t);(n||(n=[])).push(new Qr(l,a?null:o.from-t,null==o.to?null:o.to-t))}}return n}function on(e,t){if(t.full)return null;var r=me(e,t.from.line)&&Zn(e,t.from.line).markedSpans,n=me(e,t.to.line)&&Zn(e,t.to.line).markedSpans;if(!r&&!n)return null;var i=t.from.ch,o=t.to.ch,l=0==Fo(t.from,t.to),s=rn(r,i,l),a=nn(n,o,l),u=1==t.text.length,c=Di(t.text).length+(u?i:0);if(s)for(var h=0;h<s.length;++h){var f=s[h];if(null==f.to){var d=Jr(a,f.marker);d?u&&(f.to=null==d.to?null:d.to+c):f.to=i}}if(a)for(var h=0;h<a.length;++h){var f=a[h];if(null!=f.to&&(f.to+=c),null==f.from){var d=Jr(s,f.marker);d||(f.from=c,u&&(s||(s=[])).push(f))}else f.from+=c,u&&(s||(s=[])).push(f)}s&&(s=ln(s)),a&&a!=s&&(a=ln(a));var p=[s];if(!u){var g,v=t.text.length-2;if(v>0&&s)for(var h=0;h<s.length;++h)null==s[h].to&&(g||(g=[])).push(new Qr(s[h].marker,null,null));for(var h=0;v>h;++h)p.push(g);p.push(a)}return p}function ln(e){for(var t=0;t<e.length;++t){var r=e[t];null!=r.from&&r.from==r.to&&r.marker.clearWhenEmpty!==!1&&e.splice(t--,1)}return e.length?e:null}function sn(e,t){var r=gi(e,t),n=on(e,t);if(!r)return n;if(!n)return r;for(var i=0;i<r.length;++i){var o=r[i],l=n[i];if(o&&l)e:for(var s=0;s<l.length;++s){for(var a=l[s],u=0;u<o.length;++u)if(o[u].marker==a.marker)continue e;o.push(a)}else l&&(r[i]=l)}return r}function an(e,t,r){var n=null;if(e.iter(t.line,r.line+1,function(e){if(e.markedSpans)for(var t=0;t<e.markedSpans.length;++t){var r=e.markedSpans[t].marker;!r.readOnly||n&&-1!=Hi(n,r)||(n||(n=[])).push(r)}}),!n)return null;for(var i=[{from:t,to:r}],o=0;o<n.length;++o)for(var l=n[o],s=l.find(0),a=0;a<i.length;++a){var u=i[a];if(!(Fo(u.to,s.from)<0||Fo(u.from,s.to)>0)){var c=[a,1],h=Fo(u.from,s.from),f=Fo(u.to,s.to);(0>h||!l.inclusiveLeft&&!h)&&c.push({from:u.from,to:s.from}),(f>0||!l.inclusiveRight&&!f)&&c.push({from:s.to,to:u.to}),i.splice.apply(i,c),a+=c.length-1}}return i}function un(e){var t=e.markedSpans;if(t){for(var r=0;r<t.length;++r)t[r].marker.detachLine(e);e.markedSpans=null}}function cn(e,t){if(t){for(var r=0;r<t.length;++r)t[r].marker.attachLine(e);e.markedSpans=t}}function hn(e){return e.inclusiveLeft?-1:0}function fn(e){return e.inclusiveRight?1:0}function dn(e,t){var r=e.lines.length-t.lines.length;if(0!=r)return r;var n=e.find(),i=t.find(),o=Fo(n.from,i.from)||hn(e)-hn(t);if(o)return-o;var l=Fo(n.to,i.to)||fn(e)-fn(t);return l?l:t.id-e.id}function pn(e,t){var r,n=Io&&e.markedSpans;if(n)for(var i,o=0;o<n.length;++o)i=n[o],i.marker.collapsed&&null==(t?i.from:i.to)&&(!r||dn(r,i.marker)<0)&&(r=i.marker);return r}function gn(e){return pn(e,!0)}function vn(e){return pn(e,!1)}function mn(e,t,r,n,i){var o=Zn(e,t),l=Io&&o.markedSpans;if(l)for(var s=0;s<l.length;++s){var a=l[s];if(a.marker.collapsed){var u=a.marker.find(0),c=Fo(u.from,r)||hn(a.marker)-hn(i),h=Fo(u.to,n)||fn(a.marker)-fn(i);if(!(c>=0&&0>=h||0>=c&&h>=0)&&(0>=c&&(Fo(u.to,r)>0||a.marker.inclusiveRight&&i.inclusiveLeft)||c>=0&&(Fo(u.from,n)<0||a.marker.inclusiveLeft&&i.inclusiveRight)))return!0}}}function yn(e){for(var t;t=gn(e);)e=t.find(-1,!0).line;return e}function bn(e){for(var t,r;t=vn(e);)e=t.find(1,!0).line,(r||(r=[])).push(e);return r}function wn(e,t){var r=Zn(e,t),n=yn(r);return r==n?t:ti(n)}function xn(e,t){if(t>e.lastLine())return t;var r,n=Zn(e,t);if(!Cn(e,n))return t;for(;r=vn(n);)n=r.find(1,!0).line;return ti(n)+1}function Cn(e,t){var r=Io&&t.markedSpans;if(r)for(var n,i=0;i<r.length;++i)if(n=r[i],n.marker.collapsed){if(null==n.from)return!0;if(!n.marker.widgetNode&&0==n.from&&n.marker.inclusiveLeft&&Sn(e,t,n))return!0}}function Sn(e,t,r){if(null==r.to){var n=r.marker.find(1,!0);return Sn(e,n.line,Jr(n.line.markedSpans,r.marker))}if(r.marker.inclusiveRight&&r.to==t.text.length)return!0;for(var i,o=0;o<t.markedSpans.length;++o)if(i=t.markedSpans[o],i.marker.collapsed&&!i.marker.widgetNode&&i.from==r.to&&(null==i.to||i.to!=r.from)&&(i.marker.inclusiveLeft||r.marker.inclusiveRight)&&Sn(e,t,i))return!0}function Ln(e,t,r){ni(t)<(e.curOp&&e.curOp.scrollTop||e.doc.scrollTop)&&Ir(e,null,r)}function Tn(e){if(null!=e.height)return e.height;var t=e.doc.cm;if(!t)return 0;if(!Yl(document.body,e.node)){var r="position: relative;";e.coverGutter&&(r+="margin-left: -"+t.display.gutters.offsetWidth+"px;"),e.noHScroll&&(r+="width: "+t.display.wrapper.clientWidth+"px;"),Ki(t.display.measure,Ui("div",[e.node],null,r))}return e.height=e.node.parentNode.offsetHeight}function kn(e,t,r,n){var i=new yl(e,r,n),o=e.cm;return o&&i.noHScroll&&(o.display.alignWidgets=!0),Br(e,t,"widget",function(t){var r=t.widgets||(t.widgets=[]);if(null==i.insertAt?r.push(i):r.splice(Math.min(r.length-1,Math.max(0,i.insertAt)),0,i),i.line=t,o&&!Cn(e,t)){var n=ni(t)<e.scrollTop;ei(t,t.height+Tn(i)),n&&Ir(o,null,i.height),o.curOp.forceUpdate=!0}return!0}),i}function Mn(e,t,r,n){e.text=t,e.stateAfter&&(e.stateAfter=null),e.styles&&(e.styles=null),null!=e.order&&(e.order=null),un(e),cn(e,r);var i=n?n(e):1;i!=e.height&&ei(e,i)}function Nn(e){e.parent=null,un(e)}function Wn(e,t){if(e)for(;;){var r=e.match(/(?:^|\s+)line-(background-)?(\S+)/);if(!r)break;e=e.slice(0,r.index)+e.slice(r.index+r[0].length);var n=r[1]?"bgClass":"textClass";null==t[n]?t[n]=r[2]:new RegExp("(?:^|s)"+r[2]+"(?:$|s)").test(t[n])||(t[n]+=" "+r[2])}return e}function An(t,r){if(t.blankLine)return t.blankLine(r);if(t.innerMode){var n=e.innerMode(t,r);return n.mode.blankLine?n.mode.blankLine(n.state):void 0}}function On(t,r,n,i){for(var o=0;10>o;o++){i&&(i[0]=e.innerMode(t,n).mode);var l=t.token(r,n);if(r.pos>r.start)return l}throw new Error("Mode "+t.name+" failed to advance stream.")}function Dn(e,t,r,n){function i(e){return{start:h.start,end:h.pos,string:h.current(),type:o||null,state:e?sl(l.mode,c):c}}var o,l=e.doc,s=l.mode;t=ge(l,t);var a,u=Zn(l,t.line),c=Ue(e,t.line,r),h=new pl(u.text,e.options.tabSize);for(n&&(a=[]);(n||h.pos<t.ch)&&!h.eol();)h.start=h.pos,o=On(s,h,c),n&&a.push(i(!0));return n?a:i()}function Hn(e,t,r,n,i,o,l){var s=r.flattenSpans;null==s&&(s=e.options.flattenSpans);var a,u=0,c=null,h=new pl(t,e.options.tabSize),f=e.options.addModeClass&&[null];for(""==t&&Wn(An(r,n),o);!h.eol();){if(h.pos>e.options.maxHighlightLength?(s=!1,l&&In(e,t,n,h.pos),h.pos=t.length,a=null):a=Wn(On(r,h,n,f),o),f){var d=f[0].name;d&&(a="m-"+(a?d+" "+a:d))}if(!s||c!=a){for(;u<h.start;)u=Math.min(h.start,u+5e4),i(u,c);c=a}h.start=h.pos}for(;u<h.pos;){var p=Math.min(h.pos,u+5e4);i(p,c),u=p}}function Pn(e,t,r,n){var i=[e.state.modeGen],o={};Hn(e,t.text,e.doc.mode,r,function(e,t){i.push(e,t)},o,n);for(var l=0;l<e.state.overlays.length;++l){var s=e.state.overlays[l],a=1,u=0;Hn(e,t.text,s.mode,!0,function(e,t){for(var r=a;e>u;){var n=i[a];n>e&&i.splice(a,1,e,i[a+1],n),a+=2,u=Math.min(e,n)}if(t)if(s.opaque)i.splice(r,a-r,e,"cm-overlay "+t),a=r+2;else for(;a>r;r+=2){var o=i[r+1];i[r+1]=(o?o+" ":"")+"cm-overlay "+t}},o)}return{styles:i,classes:o.bgClass||o.textClass?o:null}}function En(e,t,r){if(!t.styles||t.styles[0]!=e.state.modeGen){var n=Ue(e,ti(t)),i=Pn(e,t,t.text.length>e.options.maxHighlightLength?sl(e.doc.mode,n):n);t.stateAfter=n,t.styles=i.styles,i.classes?t.styleClasses=i.classes:t.styleClasses&&(t.styleClasses=null),r===e.doc.frontier&&e.doc.frontier++}return t.styles}function In(e,t,r,n){var i=e.doc.mode,o=new pl(t,e.options.tabSize);for(o.start=o.pos=n||0,""==t&&An(i,r);!o.eol();)On(i,o,r),o.start=o.pos}function zn(e,t){if(!e||/^\s*$/.test(e))return null;var r=t.addModeClass?xl:wl;return r[e]||(r[e]=e.replace(/\S+/g,"cm-$&"))}function Fn(e,t){var r=Ui("span",null,null,xo?"padding-right: .1px":null),n={pre:Ui("pre",[r],"CodeMirror-line"),content:r,col:0,pos:0,cm:e,splitSpaces:(bo||xo)&&e.getOption("lineWrapping")};t.measure={};for(var i=0;i<=(t.rest?t.rest.length:0);i++){var o,l=i?t.rest[i-1]:t.line;n.pos=0,n.addToken=Bn,Qi(e.display.measure)&&(o=ii(l))&&(n.addToken=Un(n.addToken,o)),n.map=[];var s=t!=e.display.externalMeasured&&ti(l);Kn(l,n,En(e,l,s)),l.styleClasses&&(l.styleClasses.bgClass&&(n.bgClass=Yi(l.styleClasses.bgClass,n.bgClass||"")),l.styleClasses.textClass&&(n.textClass=Yi(l.styleClasses.textClass,n.textClass||""))),0==n.map.length&&n.map.push(0,0,n.content.appendChild(Zi(e.display.measure))),0==i?(t.measure.map=n.map,t.measure.cache={}):((t.measure.maps||(t.measure.maps=[])).push(n.map),(t.measure.caches||(t.measure.caches=[])).push({}))}return xo&&/\bcm-tab\b/.test(n.content.lastChild.className)&&(n.content.className="cm-tab-wrap-hack"),Dl(e,"renderLine",e,t.line,n.pre),n.pre.className&&(n.textClass=Yi(n.pre.className,n.textClass||"")),n}function Rn(e){var t=Ui("span","•","cm-invalidchar");return t.title="\\u"+e.charCodeAt(0).toString(16),t.setAttribute("aria-label",t.title),t}function Bn(e,t,r,n,i,o,l){if(t){var s=e.splitSpaces?t.replace(/ {3,}/g,Gn):t,a=e.cm.state.specialChars,u=!1;if(a.test(t))for(var c=document.createDocumentFragment(),h=0;;){a.lastIndex=h;var f=a.exec(t),d=f?f.index-h:t.length-h;if(d){var p=document.createTextNode(s.slice(h,h+d));bo&&9>wo?c.appendChild(Ui("span",[p])):c.appendChild(p),e.map.push(e.pos,e.pos+d,p),e.col+=d,e.pos+=d}if(!f)break;if(h+=d+1," "==f[0]){var g=e.cm.options.tabSize,v=g-e.col%g,p=c.appendChild(Ui("span",Oi(v),"cm-tab"));p.setAttribute("role","presentation"),p.setAttribute("cm-text"," "),e.col+=v}else if("\r"==f[0]||"\n"==f[0]){var p=c.appendChild(Ui("span","\r"==f[0]?"␍":"","cm-invalidchar"));p.setAttribute("cm-text",f[0]),e.col+=1}else{var p=e.cm.options.specialCharPlaceholder(f[0]);p.setAttribute("cm-text",f[0]),bo&&9>wo?c.appendChild(Ui("span",[p])):c.appendChild(p),e.col+=1}e.map.push(e.pos,e.pos+1,p),e.pos++}else{e.col+=t.length;var c=document.createTextNode(s);e.map.push(e.pos,e.pos+t.length,c),bo&&9>wo&&(u=!0),e.pos+=t.length}if(r||n||i||u||l){var m=r||"";n&&(m+=n),i&&(m+=i);var y=Ui("span",[c],m,l);return o&&(y.title=o),e.content.appendChild(y)}e.content.appendChild(c)}}function Gn(e){for(var t=" ",r=0;r<e.length-2;++r)t+=r%2?" ":" ";return t+=" "}function Un(e,t){return function(r,n,i,o,l,s,a){i=i?i+" cm-force-border":"cm-force-border";for(var u=r.pos,c=u+n.length;;){for(var h=0;h<t.length;h++){var f=t[h];if(f.to>u&&f.from<=u)break}if(f.to>=c)return e(r,n,i,o,l,s,a);e(r,n.slice(0,f.to-u),i,o,null,s,a),o=null,n=n.slice(f.to-u),u=f.to}}}function Vn(e,t,r,n){var i=!n&&r.widgetNode;i&&e.map.push(e.pos,e.pos+t,i),!n&&e.cm.display.input.needsContentAttribute&&(i||(i=e.content.appendChild(document.createElement("span"))),i.setAttribute("cm-marker",r.id)),i&&(e.cm.display.input.setUneditable(i),e.content.appendChild(i)),e.pos+=t}function Kn(e,t,r){var n=e.markedSpans,i=e.text,o=0;if(n)for(var l,s,a,u,c,h,f,d=i.length,p=0,g=1,v="",m=0;;){if(m==p){a=u=c=h=s="",f=null,m=1/0;for(var y,b=[],w=0;w<n.length;++w){var x=n[w],C=x.marker;"bookmark"==C.type&&x.from==p&&C.widgetNode?b.push(C):x.from<=p&&(null==x.to||x.to>p||C.collapsed&&x.to==p&&x.from==p)?(null!=x.to&&x.to!=p&&m>x.to&&(m=x.to,u=""),C.className&&(a+=" "+C.className),C.css&&(s=(s?s+";":"")+C.css),C.startStyle&&x.from==p&&(c+=" "+C.startStyle),C.endStyle&&x.to==m&&(y||(y=[])).push(C.endStyle,x.to),C.title&&!h&&(h=C.title),C.collapsed&&(!f||dn(f.marker,C)<0)&&(f=x)):x.from>p&&m>x.from&&(m=x.from)}if(y)for(var w=0;w<y.length;w+=2)y[w+1]==m&&(u+=" "+y[w]);if(f&&(f.from||0)==p){if(Vn(t,(null==f.to?d+1:f.to)-p,f.marker,null==f.from),null==f.to)return;f.to==p&&(f=!1)}if(!f&&b.length)for(var w=0;w<b.length;++w)Vn(t,0,b[w])}if(p>=d)break;for(var S=Math.min(d,m);;){if(v){var L=p+v.length;if(!f){var T=L>S?v.slice(0,S-p):v;t.addToken(t,T,l?l+a:a,c,p+T.length==m?u:"",h,s)}if(L>=S){v=v.slice(S-p),p=S;break}p=L,c=""}v=i.slice(o,o=r[g++]),l=zn(r[g++],t.cm.options)}}else for(var g=1;g<r.length;g+=2)t.addToken(t,i.slice(o,o=r[g]),zn(r[g+1],t.cm.options))}function jn(e,t){return 0==t.from.ch&&0==t.to.ch&&""==Di(t.text)&&(!e.cm||e.cm.options.wholeLineUpdateBefore)}function Xn(e,t,r,n){function i(e){return r?r[e]:null}function o(e,r,i){Mn(e,r,i,n),Li(e,"change",e,t)}function l(e,t){for(var r=e,o=[];t>r;++r)o.push(new bl(u[r],i(r),n));return o}var s=t.from,a=t.to,u=t.text,c=Zn(e,s.line),h=Zn(e,a.line),f=Di(u),d=i(u.length-1),p=a.line-s.line;if(t.full)e.insert(0,l(0,u.length)),e.remove(u.length,e.size-u.length);else if(jn(e,t)){var g=l(0,u.length-1);o(h,h.text,d),p&&e.remove(s.line,p),g.length&&e.insert(s.line,g)}else if(c==h)if(1==u.length)o(c,c.text.slice(0,s.ch)+f+c.text.slice(a.ch),d);else{var g=l(1,u.length-1);g.push(new bl(f+c.text.slice(a.ch),d,n)),o(c,c.text.slice(0,s.ch)+u[0],i(0)),e.insert(s.line+1,g)}else if(1==u.length)o(c,c.text.slice(0,s.ch)+u[0]+h.text.slice(a.ch),i(0)),e.remove(s.line+1,p);else{o(c,c.text.slice(0,s.ch)+u[0],i(0)),o(h,f+h.text.slice(a.ch),d);var g=l(1,u.length-1);p>1&&e.remove(s.line+1,p-1),e.insert(s.line+1,g)}Li(e,"change",e,t)}function Yn(e){this.lines=e,this.parent=null;for(var t=0,r=0;t<e.length;++t)e[t].parent=this,r+=e[t].height;this.height=r}function _n(e){this.children=e;for(var t=0,r=0,n=0;n<e.length;++n){var i=e[n];t+=i.chunkSize(),r+=i.height,i.parent=this}this.size=t,this.height=r,this.parent=null}function $n(e,t,r){function n(e,i,o){if(e.linked)for(var l=0;l<e.linked.length;++l){var s=e.linked[l];if(s.doc!=i){var a=o&&s.sharedHist;(!r||a)&&(t(s.doc,a),n(s.doc,e,a))}}}n(e,null,!0)}function qn(e,t){if(t.cm)throw new Error("This document is already in use.");e.doc=t,t.cm=e,l(e),r(e),e.options.lineWrapping||f(e),e.options.mode=t.modeOption,Et(e)}function Zn(e,t){if(t-=e.first,0>t||t>=e.size)throw new Error("There is no line "+(t+e.first)+" in the document.");for(var r=e;!r.lines;)for(var n=0;;++n){var i=r.children[n],o=i.chunkSize();if(o>t){r=i;break}t-=o}return r.lines[t]}function Qn(e,t,r){var n=[],i=t.line;return e.iter(t.line,r.line+1,function(e){var o=e.text;i==r.line&&(o=o.slice(0,r.ch)),i==t.line&&(o=o.slice(t.ch)),n.push(o),++i}),n}function Jn(e,t,r){var n=[];return e.iter(t,r,function(e){n.push(e.text)}),n}function ei(e,t){var r=t-e.height;if(r)for(var n=e;n;n=n.parent)n.height+=r}function ti(e){if(null==e.parent)return null;for(var t=e.parent,r=Hi(t.lines,e),n=t.parent;n;t=n,n=n.parent)for(var i=0;n.children[i]!=t;++i)r+=n.children[i].chunkSize();return r+t.first}function ri(e,t){var r=e.first;e:do{for(var n=0;n<e.children.length;++n){var i=e.children[n],o=i.height;if(o>t){e=i;continue e}t-=o,r+=i.chunkSize()}return r}while(!e.lines);for(var n=0;n<e.lines.length;++n){var l=e.lines[n],s=l.height;if(s>t)break;t-=s}return r+n}function ni(e){e=yn(e);for(var t=0,r=e.parent,n=0;n<r.lines.length;++n){var i=r.lines[n];if(i==e)break;t+=i.height}for(var o=r.parent;o;r=o,o=r.parent)for(var n=0;n<o.children.length;++n){var l=o.children[n];if(l==r)break;t+=l.height}return t}function ii(e){var t=e.order;return null==t&&(t=e.order=ls(e.text)),t}function oi(e){this.done=[],this.undone=[],this.undoDepth=1/0,this.lastModTime=this.lastSelTime=0,this.lastOp=this.lastSelOp=null,this.lastOrigin=this.lastSelOrigin=null,this.generation=this.maxGeneration=e||1}function li(e,t){var r={from:Y(t.from),to:Qo(t),text:Qn(e,t.from,t.to)};return di(e,r,t.from.line,t.to.line+1),$n(e,function(e){di(e,r,t.from.line,t.to.line+1)},!0),r}function si(e){for(;e.length;){var t=Di(e);if(!t.ranges)break;e.pop()}}function ai(e,t){return t?(si(e.done),Di(e.done)):e.done.length&&!Di(e.done).ranges?Di(e.done):e.done.length>1&&!e.done[e.done.length-2].ranges?(e.done.pop(),Di(e.done)):void 0}function ui(e,t,r,n){var i=e.history;i.undone.length=0;var o,l=+new Date;if((i.lastOp==n||i.lastOrigin==t.origin&&t.origin&&("+"==t.origin.charAt(0)&&e.cm&&i.lastModTime>l-e.cm.options.historyEventDelay||"*"==t.origin.charAt(0)))&&(o=ai(i,i.lastOp==n))){var s=Di(o.changes);0==Fo(t.from,t.to)&&0==Fo(t.from,s.to)?s.to=Qo(t):o.changes.push(li(e,t))}else{var a=Di(i.done);for(a&&a.ranges||fi(e.sel,i.done),o={changes:[li(e,t)],generation:i.generation},i.done.push(o);i.done.length>i.undoDepth;)i.done.shift(),i.done[0].ranges||i.done.shift()}i.done.push(r),i.generation=++i.maxGeneration,i.lastModTime=i.lastSelTime=l,i.lastOp=i.lastSelOp=n,i.lastOrigin=i.lastSelOrigin=t.origin,s||Dl(e,"historyAdded")}function ci(e,t,r,n){var i=t.charAt(0);return"*"==i||"+"==i&&r.ranges.length==n.ranges.length&&r.somethingSelected()==n.somethingSelected()&&new Date-e.history.lastSelTime<=(e.cm?e.cm.options.historyEventDelay:500)}function hi(e,t,r,n){var i=e.history,o=n&&n.origin;r==i.lastSelOp||o&&i.lastSelOrigin==o&&(i.lastModTime==i.lastSelTime&&i.lastOrigin==o||ci(e,o,Di(i.done),t))?i.done[i.done.length-1]=t:fi(t,i.done),i.lastSelTime=+new Date,i.lastSelOrigin=o,i.lastSelOp=r,n&&n.clearRedo!==!1&&si(i.undone)}function fi(e,t){var r=Di(t);r&&r.ranges&&r.equals(e)||t.push(e)}function di(e,t,r,n){var i=t["spans_"+e.id],o=0;e.iter(Math.max(e.first,r),Math.min(e.first+e.size,n),function(r){r.markedSpans&&((i||(i=t["spans_"+e.id]={}))[o]=r.markedSpans),++o})}function pi(e){if(!e)return null;for(var t,r=0;r<e.length;++r)e[r].marker.explicitlyCleared?t||(t=e.slice(0,r)):t&&t.push(e[r]);return t?t.length?t:null:e}function gi(e,t){var r=t["spans_"+e.id];if(!r)return null;for(var n=0,i=[];n<t.text.length;++n)i.push(pi(r[n]));return i}function vi(e,t,r){for(var n=0,i=[];n<e.length;++n){var o=e[n];if(o.ranges)i.push(r?ce.prototype.deepCopy.call(o):o);else{var l=o.changes,s=[];i.push({changes:s});for(var a=0;a<l.length;++a){var u,c=l[a];if(s.push({from:c.from,to:c.to,text:c.text}),t)for(var h in c)(u=h.match(/^spans_(\d+)$/))&&Hi(t,Number(u[1]))>-1&&(Di(s)[h]=c[h],delete c[h])}}}return i}function mi(e,t,r,n){r<e.line?e.line+=n:t<e.line&&(e.line=t,e.ch=0)}function yi(e,t,r,n){for(var i=0;i<e.length;++i){var o=e[i],l=!0;if(o.ranges){o.copied||(o=e[i]=o.deepCopy(),o.copied=!0);for(var s=0;s<o.ranges.length;s++)mi(o.ranges[s].anchor,t,r,n),mi(o.ranges[s].head,t,r,n)}else{for(var s=0;s<o.changes.length;++s){var a=o.changes[s];if(r<a.from.line)a.from=zo(a.from.line+n,a.from.ch),a.to=zo(a.to.line+n,a.to.ch);else if(t<=a.to.line){l=!1;break}}l||(e.splice(0,i+1),i=0)}}}function bi(e,t){var r=t.from.line,n=t.to.line,i=t.text.length-(n-r)-1;yi(e.done,r,n,i),yi(e.undone,r,n,i)}function wi(e){return null!=e.defaultPrevented?e.defaultPrevented:0==e.returnValue}function xi(e){return e.target||e.srcElement}function Ci(e){var t=e.which;return null==t&&(1&e.button?t=1:2&e.button?t=3:4&e.button&&(t=2)),Ao&&e.ctrlKey&&1==t&&(t=3),t}function Si(e,t,r){var n=e._handlers&&e._handlers[t];return r?n&&n.length>0?n.slice():Al:n||Al}function Li(e,t){function r(e){return function(){e.apply(null,o)}}var n=Si(e,t,!1);if(n.length){var i,o=Array.prototype.slice.call(arguments,2);Ko?i=Ko.delayedCallbacks:Hl?i=Hl:(i=Hl=[],setTimeout(Ti,0));for(var l=0;l<n.length;++l)i.push(r(n[l]))}}function Ti(){var e=Hl;Hl=null;for(var t=0;t<e.length;++t)e[t]()}function ki(e,t,r){return"string"==typeof t&&(t={type:t,preventDefault:function(){this.defaultPrevented=!0}}),Dl(e,r||t.type,e,t),wi(t)||t.codemirrorIgnore}function Mi(e){var t=e._handlers&&e._handlers.cursorActivity;if(t)for(var r=e.curOp.cursorActivityHandlers||(e.curOp.cursorActivityHandlers=[]),n=0;n<t.length;++n)-1==Hi(r,t[n])&&r.push(t[n])}function Ni(e,t){return Si(e,t).length>0}function Wi(e){e.prototype.on=function(e,t){Wl(this,e,t)},e.prototype.off=function(e,t){Ol(this,e,t)}}function Ai(){this.id=null}function Oi(e){for(;Gl.length<=e;)Gl.push(Di(Gl)+" ");return Gl[e]}function Di(e){return e[e.length-1]}function Hi(e,t){for(var r=0;r<e.length;++r)if(e[r]==t)return r;return-1}function Pi(e,t){for(var r=[],n=0;n<e.length;n++)r[n]=t(e[n],n);return r}function Ei(){}function Ii(e,t){var r;return Object.create?r=Object.create(e):(Ei.prototype=e,r=new Ei),t&&zi(t,r),r}function zi(e,t,r){t||(t={});for(var n in e)!e.hasOwnProperty(n)||r===!1&&t.hasOwnProperty(n)||(t[n]=e[n]);return t}function Fi(e){var t=Array.prototype.slice.call(arguments,1);return function(){return e.apply(null,t)}}function Ri(e,t){return t?t.source.indexOf("\\w")>-1&&jl(e)?!0:t.test(e):jl(e)}function Bi(e){for(var t in e)if(e.hasOwnProperty(t)&&e[t])return!1;return!0}function Gi(e){return e.charCodeAt(0)>=768&&Xl.test(e)}function Ui(e,t,r,n){var i=document.createElement(e);if(r&&(i.className=r),n&&(i.style.cssText=n),"string"==typeof t)i.appendChild(document.createTextNode(t));else if(t)for(var o=0;o<t.length;++o)i.appendChild(t[o]);return i}function Vi(e){for(var t=e.childNodes.length;t>0;--t)e.removeChild(e.firstChild);return e}function Ki(e,t){return Vi(e).appendChild(t)}function ji(){for(var e=document.activeElement;e&&e.root&&e.root.activeElement;)e=e.root.activeElement;return e}function Xi(e){return new RegExp("(^|\\s)"+e+"(?:$|\\s)\\s*")}function Yi(e,t){for(var r=e.split(" "),n=0;n<r.length;n++)r[n]&&!Xi(r[n]).test(t)&&(t+=" "+r[n]);return t}function _i(e){if(document.body.getElementsByClassName)for(var t=document.body.getElementsByClassName("CodeMirror"),r=0;r<t.length;r++){var n=t[r].CodeMirror;n&&e(n)}}function $i(){Ql||(qi(),Ql=!0)}function qi(){var e;Wl(window,"resize",function(){null==e&&(e=setTimeout(function(){e=null,_i(Kt)},100))}),Wl(window,"blur",function(){_i(mr)})}function Zi(e){if(null==_l){var t=Ui("span","");Ki(e,Ui("span",[t,document.createTextNode("x")])),0!=e.firstChild.offsetHeight&&(_l=t.offsetWidth<=1&&t.offsetHeight>2&&!(bo&&8>wo))}var r=_l?Ui("span",""):Ui("span"," ",null,"display: inline-block; width: 1px; margin-right: -1px");return r.setAttribute("cm-text",""),r}function Qi(e){if(null!=$l)return $l;var t=Ki(e,document.createTextNode("AخA")),r=Vl(t,0,1).getBoundingClientRect();if(!r||r.left==r.right)return!1;var n=Vl(t,1,2).getBoundingClientRect();return $l=n.right-r.right<3}function Ji(e){if(null!=ns)return ns;var t=Ki(e,Ui("span","x")),r=t.getBoundingClientRect(),n=Vl(t,0,1).getBoundingClientRect();return ns=Math.abs(r.left-n.left)>1}function eo(e,t,r,n){if(!e)return n(t,r,"ltr");for(var i=!1,o=0;o<e.length;++o){var l=e[o];(l.from<r&&l.to>t||t==r&&l.to==t)&&(n(Math.max(l.from,t),Math.min(l.to,r),1==l.level?"rtl":"ltr"),i=!0)}i||n(t,r,"ltr")}function to(e){return e.level%2?e.to:e.from}function ro(e){return e.level%2?e.from:e.to}function no(e){var t=ii(e);return t?to(t[0]):0}function io(e){var t=ii(e);return t?ro(Di(t)):e.text.length}function oo(e,t){var r=Zn(e.doc,t),n=yn(r);n!=r&&(t=ti(n));var i=ii(n),o=i?i[0].level%2?io(n):no(n):0;return zo(t,o)}function lo(e,t){for(var r,n=Zn(e.doc,t);r=vn(n);)n=r.find(1,!0).line,t=null;var i=ii(n),o=i?i[0].level%2?no(n):io(n):n.text.length;return zo(null==t?ti(n):t,o)}function so(e,t){var r=oo(e,t.line),n=Zn(e.doc,r.line),i=ii(n);if(!i||0==i[0].level){var o=Math.max(0,n.text.search(/\S/)),l=t.line==r.line&&t.ch<=o&&t.ch;return zo(r.line,l?0:o)}return r}function ao(e,t,r){var n=e[0].level;return t==n?!0:r==n?!1:r>t}function uo(e,t){os=null;for(var r,n=0;n<e.length;++n){var i=e[n];if(i.from<t&&i.to>t)return n;if(i.from==t||i.to==t){if(null!=r)return ao(e,i.level,e[r].level)?(i.from!=i.to&&(os=r),n):(i.from!=i.to&&(os=n),r);r=n}}return r}function co(e,t,r,n){if(!n)return t+r;do t+=r;while(t>0&&Gi(e.text.charAt(t)));return t}function ho(e,t,r,n){var i=ii(e);if(!i)return fo(e,t,r,n);for(var o=uo(i,t),l=i[o],s=co(e,t,l.level%2?-r:r,n);;){if(s>l.from&&s<l.to)return s;if(s==l.from||s==l.to)return uo(i,s)==o?s:(l=i[o+=r],r>0==l.level%2?l.to:l.from);if(l=i[o+=r],!l)return null;s=r>0==l.level%2?co(e,l.to,-1,n):co(e,l.from,1,n)}}function fo(e,t,r,n){var i=t+r;if(n)for(;i>0&&Gi(e.text.charAt(i));)i+=r;return 0>i||i>e.text.length?null:i}var po=navigator.userAgent,go=navigator.platform,vo=/gecko\/\d/i.test(po),mo=/MSIE \d/.test(po),yo=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(po),bo=mo||yo,wo=bo&&(mo?document.documentMode||6:yo[1]),xo=/WebKit\//.test(po),Co=xo&&/Qt\/\d+\.\d+/.test(po),So=/Chrome\//.test(po),Lo=/Opera\//.test(po),To=/Apple Computer/.test(navigator.vendor),ko=/Mac OS X 1\d\D([8-9]|\d\d)\D/.test(po),Mo=/PhantomJS/.test(po),No=/AppleWebKit/.test(po)&&/Mobile\/\w+/.test(po),Wo=No||/Android|webOS|BlackBerry|Opera Mini|Opera Mobi|IEMobile/i.test(po),Ao=No||/Mac/.test(go),Oo=/win/i.test(go),Do=Lo&&po.match(/Version\/(\d*\.\d*)/);Do&&(Do=Number(Do[1])),Do&&Do>=15&&(Lo=!1,xo=!0);var Ho=Ao&&(Co||Lo&&(null==Do||12.11>Do)),Po=vo||bo&&wo>=9,Eo=!1,Io=!1;g.prototype=zi({update:function(e){var t=e.scrollWidth>e.clientWidth+1,r=e.scrollHeight>e.clientHeight+1,n=e.nativeBarWidth;if(r){this.vert.style.display="block",this.vert.style.bottom=t?n+"px":"0";var i=e.viewHeight-(t?n:0);this.vert.firstChild.style.height=Math.max(0,e.scrollHeight-e.clientHeight+i)+"px"}else this.vert.style.display="",this.vert.firstChild.style.height="0";if(t){this.horiz.style.display="block",this.horiz.style.right=r?n+"px":"0",this.horiz.style.left=e.barLeft+"px";var o=e.viewWidth-e.barLeft-(r?n:0);this.horiz.firstChild.style.width=e.scrollWidth-e.clientWidth+o+"px"}else this.horiz.style.display="",this.horiz.firstChild.style.width="0";return!this.checkedZeroWidth&&e.clientHeight>0&&(0==n&&this.zeroWidthHack(),this.checkedZeroWidth=!0),{right:r?n:0,bottom:t?n:0}},setScrollLeft:function(e){this.horiz.scrollLeft!=e&&(this.horiz.scrollLeft=e),this.disableHoriz&&this.enableZeroWidthBar(this.horiz,this.disableHoriz)},setScrollTop:function(e){this.vert.scrollTop!=e&&(this.vert.scrollTop=e),this.disableVert&&this.enableZeroWidthBar(this.vert,this.disableVert)},zeroWidthHack:function(){var e=Ao&&!ko?"12px":"18px";this.horiz.style.height=this.vert.style.width=e,this.horiz.style.pointerEvents=this.vert.style.pointerEvents="none",this.disableHoriz=new Ai,this.disableVert=new Ai},enableZeroWidthBar:function(e,t){function r(){var n=e.getBoundingClientRect(),i=document.elementFromPoint(n.left+1,n.bottom-1);i!=e?e.style.pointerEvents="none":t.set(1e3,r)}e.style.pointerEvents="auto",t.set(1e3,r)},clear:function(){var e=this.horiz.parentNode;e.removeChild(this.horiz),e.removeChild(this.vert)}},g.prototype),v.prototype=zi({update:function(){return{bottom:0,right:0}},setScrollLeft:function(){},setScrollTop:function(){},clear:function(){}},v.prototype),e.scrollbarModel={"native":g,"null":v},T.prototype.signal=function(e,t){Ni(e,t)&&this.events.push(arguments)},T.prototype.finish=function(){for(var e=0;e<this.events.length;e++)Dl.apply(null,this.events[e])};var zo=e.Pos=function(e,t){return this instanceof zo?(this.line=e,void(this.ch=t)):new zo(e,t)},Fo=e.cmpPos=function(e,t){return e.line-t.line||e.ch-t.ch},Ro=null;re.prototype=zi({init:function(e){function t(e){
|
4 |
+
if(n.somethingSelected())Ro=n.getSelections(),r.inaccurateSelection&&(r.prevInput="",r.inaccurateSelection=!1,o.value=Ro.join("\n"),Ul(o));else{if(!n.options.lineWiseCopyCut)return;var t=ee(n);Ro=t.text,"cut"==e.type?n.setSelections(t.ranges,null,Il):(r.prevInput="",o.value=t.text.join("\n"),Ul(o))}"cut"==e.type&&(n.state.cutIncoming=!0)}var r=this,n=this.cm,i=this.wrapper=ne(),o=this.textarea=i.firstChild;e.wrapper.insertBefore(i,e.wrapper.firstChild),No&&(o.style.width="0px"),Wl(o,"input",function(){bo&&wo>=9&&r.hasSelection&&(r.hasSelection=null),r.poll()}),Wl(o,"paste",function(e){ki(n,e)||Q(e,n)||(n.state.pasteIncoming=!0,r.fastPoll())}),Wl(o,"cut",t),Wl(o,"copy",t),Wl(e.scroller,"paste",function(t){jt(e,t)||ki(n,t)||(n.state.pasteIncoming=!0,r.focus())}),Wl(e.lineSpace,"selectstart",function(t){jt(e,t)||kl(t)}),Wl(o,"compositionstart",function(){var e=n.getCursor("from");r.composing&&r.composing.range.clear(),r.composing={start:e,range:n.markText(e,n.getCursor("to"),{className:"CodeMirror-composing"})}}),Wl(o,"compositionend",function(){r.composing&&(r.poll(),r.composing.range.clear(),r.composing=null)})},prepareSelection:function(){var e=this.cm,t=e.display,r=e.doc,n=Ee(e);if(e.options.moveInputWithCursor){var i=dt(e,r.sel.primary().head,"div"),o=t.wrapper.getBoundingClientRect(),l=t.lineDiv.getBoundingClientRect();n.teTop=Math.max(0,Math.min(t.wrapper.clientHeight-10,i.top+l.top-o.top)),n.teLeft=Math.max(0,Math.min(t.wrapper.clientWidth-10,i.left+l.left-o.left))}return n},showSelection:function(e){var t=this.cm,r=t.display;Ki(r.cursorDiv,e.cursors),Ki(r.selectionDiv,e.selection),null!=e.teTop&&(this.wrapper.style.top=e.teTop+"px",this.wrapper.style.left=e.teLeft+"px")},reset:function(e){if(!this.contextMenuPending){var t,r,n=this.cm,i=n.doc;if(n.somethingSelected()){this.prevInput="";var o=i.sel.primary();t=rs&&(o.to().line-o.from().line>100||(r=n.getSelection()).length>1e3);var l=t?"-":r||n.getSelection();this.textarea.value=l,n.state.focused&&Ul(this.textarea),bo&&wo>=9&&(this.hasSelection=l)}else e||(this.prevInput=this.textarea.value="",bo&&wo>=9&&(this.hasSelection=null));this.inaccurateSelection=t}},getField:function(){return this.textarea},supportsTouch:function(){return!1},focus:function(){if("nocursor"!=this.cm.options.readOnly&&(!Wo||ji()!=this.textarea))try{this.textarea.focus()}catch(e){}},blur:function(){this.textarea.blur()},resetPosition:function(){this.wrapper.style.top=this.wrapper.style.left=0},receivedFocus:function(){this.slowPoll()},slowPoll:function(){var e=this;e.pollingFast||e.polling.set(this.cm.options.pollInterval,function(){e.poll(),e.cm.state.focused&&e.slowPoll()})},fastPoll:function(){function e(){var n=r.poll();n||t?(r.pollingFast=!1,r.slowPoll()):(t=!0,r.polling.set(60,e))}var t=!1,r=this;r.pollingFast=!0,r.polling.set(20,e)},poll:function(){var e=this.cm,t=this.textarea,r=this.prevInput;if(this.contextMenuPending||!e.state.focused||ts(t)&&!r&&!this.composing||e.isReadOnly()||e.options.disableInput||e.state.keySeq)return!1;var n=t.value;if(n==r&&!e.somethingSelected())return!1;if(bo&&wo>=9&&this.hasSelection===n||Ao&&/[\uf700-\uf7ff]/.test(n))return e.display.input.reset(),!1;if(e.doc.sel==e.display.selForContextMenu){var i=n.charCodeAt(0);if(8203!=i||r||(r=""),8666==i)return this.reset(),this.cm.execCommand("undo")}for(var o=0,l=Math.min(r.length,n.length);l>o&&r.charCodeAt(o)==n.charCodeAt(o);)++o;var s=this;return Wt(e,function(){Z(e,n.slice(o),r.length-o,null,s.composing?"*compose":null),n.length>1e3||n.indexOf("\n")>-1?t.value=s.prevInput="":s.prevInput=n,s.composing&&(s.composing.range.clear(),s.composing.range=e.markText(s.composing.start,e.getCursor("to"),{className:"CodeMirror-composing"}))}),!0},ensurePolled:function(){this.pollingFast&&this.poll()&&(this.pollingFast=!1)},onKeyPress:function(){bo&&wo>=9&&(this.hasSelection=null),this.fastPoll()},onContextMenu:function(e){function t(){if(null!=l.selectionStart){var e=i.somethingSelected(),t=""+(e?l.value:"");l.value="⇚",l.value=t,n.prevInput=e?"":"",l.selectionStart=1,l.selectionEnd=t.length,o.selForContextMenu=i.doc.sel}}function r(){if(n.contextMenuPending=!1,n.wrapper.style.position="relative",l.style.cssText=c,bo&&9>wo&&o.scrollbars.setScrollTop(o.scroller.scrollTop=a),null!=l.selectionStart){(!bo||bo&&9>wo)&&t();var e=0,r=function(){o.selForContextMenu==i.doc.sel&&0==l.selectionStart&&l.selectionEnd>0&&""==n.prevInput?At(i,ul.selectAll)(i):e++<10?o.detectingSelectAll=setTimeout(r,500):o.input.reset()};o.detectingSelectAll=setTimeout(r,200)}}var n=this,i=n.cm,o=i.display,l=n.textarea,s=Xt(i,e),a=o.scroller.scrollTop;if(s&&!Lo){var u=i.options.resetSelectionOnContextMenu;u&&-1==i.doc.sel.contains(s)&&At(i,ke)(i.doc,de(s),Il);var c=l.style.cssText;if(n.wrapper.style.position="absolute",l.style.cssText="position: fixed; width: 30px; height: 30px; top: "+(e.clientY-5)+"px; left: "+(e.clientX-5)+"px; z-index: 1000; background: "+(bo?"rgba(255, 255, 255, .05)":"transparent")+"; outline: none; border-width: 0; outline: none; overflow: hidden; opacity: .05; filter: alpha(opacity=5);",xo)var h=window.scrollY;if(o.input.focus(),xo&&window.scrollTo(null,h),o.input.reset(),i.somethingSelected()||(l.value=n.prevInput=" "),n.contextMenuPending=!0,o.selForContextMenu=i.doc.sel,clearTimeout(o.detectingSelectAll),bo&&wo>=9&&t(),Po){Nl(e);var f=function(){Ol(window,"mouseup",f),setTimeout(r,20)};Wl(window,"mouseup",f)}else setTimeout(r,50)}},readOnlyChanged:function(e){e||this.reset()},setUneditable:Ei,needsContentAttribute:!1},re.prototype),ie.prototype=zi({init:function(e){function t(e){if(n.somethingSelected())Ro=n.getSelections(),"cut"==e.type&&n.replaceSelection("",null,"cut");else{if(!n.options.lineWiseCopyCut)return;var t=ee(n);Ro=t.text,"cut"==e.type&&n.operation(function(){n.setSelections(t.ranges,0,Il),n.replaceSelection("",null,"cut")})}if(e.clipboardData&&!No)e.preventDefault(),e.clipboardData.clearData(),e.clipboardData.setData("text/plain",Ro.join("\n"));else{var r=ne(),i=r.firstChild;n.display.lineSpace.insertBefore(r,n.display.lineSpace.firstChild),i.value=Ro.join("\n");var o=document.activeElement;Ul(i),setTimeout(function(){n.display.lineSpace.removeChild(r),o.focus()},50)}}var r=this,n=r.cm,i=r.div=e.lineDiv;te(i),Wl(i,"paste",function(e){ki(n,e)||Q(e,n)}),Wl(i,"compositionstart",function(e){var t=e.data;if(r.composing={sel:n.doc.sel,data:t,startData:t},t){var i=n.doc.sel.primary(),o=n.getLine(i.head.line),l=o.indexOf(t,Math.max(0,i.head.ch-t.length));l>-1&&l<=i.head.ch&&(r.composing.sel=de(zo(i.head.line,l),zo(i.head.line,l+t.length)))}}),Wl(i,"compositionupdate",function(e){r.composing.data=e.data}),Wl(i,"compositionend",function(e){var t=r.composing;t&&(e.data==t.startData||/\u200b/.test(e.data)||(t.data=e.data),setTimeout(function(){t.handled||r.applyComposition(t),r.composing==t&&(r.composing=null)},50))}),Wl(i,"touchstart",function(){r.forceCompositionEnd()}),Wl(i,"input",function(){r.composing||(n.isReadOnly()||!r.pollContent())&&Wt(r.cm,function(){Et(n)})}),Wl(i,"copy",t),Wl(i,"cut",t)},prepareSelection:function(){var e=Ee(this.cm,!1);return e.focus=this.cm.state.focused,e},showSelection:function(e){e&&this.cm.display.view.length&&(e.focus&&this.showPrimarySelection(),this.showMultipleSelections(e))},showPrimarySelection:function(){var e=window.getSelection(),t=this.cm.doc.sel.primary(),r=se(this.cm,e.anchorNode,e.anchorOffset),n=se(this.cm,e.focusNode,e.focusOffset);if(!r||r.bad||!n||n.bad||0!=Fo($(r,n),t.from())||0!=Fo(_(r,n),t.to())){var i=oe(this.cm,t.from()),o=oe(this.cm,t.to());if(i||o){var l=this.cm.display.view,s=e.rangeCount&&e.getRangeAt(0);if(i){if(!o){var a=l[l.length-1].measure,u=a.maps?a.maps[a.maps.length-1]:a.map;o={node:u[u.length-1],offset:u[u.length-2]-u[u.length-3]}}}else i={node:l[0].measure.map[2],offset:0};try{var c=Vl(i.node,i.offset,o.offset,o.node)}catch(h){}c&&(!vo&&this.cm.state.focused?(e.collapse(i.node,i.offset),c.collapsed||e.addRange(c)):(e.removeAllRanges(),e.addRange(c)),s&&null==e.anchorNode?e.addRange(s):vo&&this.startGracePeriod()),this.rememberSelection()}}},startGracePeriod:function(){var e=this;clearTimeout(this.gracePeriod),this.gracePeriod=setTimeout(function(){e.gracePeriod=!1,e.selectionChanged()&&e.cm.operation(function(){e.cm.curOp.selectionChanged=!0})},20)},showMultipleSelections:function(e){Ki(this.cm.display.cursorDiv,e.cursors),Ki(this.cm.display.selectionDiv,e.selection)},rememberSelection:function(){var e=window.getSelection();this.lastAnchorNode=e.anchorNode,this.lastAnchorOffset=e.anchorOffset,this.lastFocusNode=e.focusNode,this.lastFocusOffset=e.focusOffset},selectionInEditor:function(){var e=window.getSelection();if(!e.rangeCount)return!1;var t=e.getRangeAt(0).commonAncestorContainer;return Yl(this.div,t)},focus:function(){"nocursor"!=this.cm.options.readOnly&&this.div.focus()},blur:function(){this.div.blur()},getField:function(){return this.div},supportsTouch:function(){return!0},receivedFocus:function(){function e(){t.cm.state.focused&&(t.pollSelection(),t.polling.set(t.cm.options.pollInterval,e))}var t=this;this.selectionInEditor()?this.pollSelection():Wt(this.cm,function(){t.cm.curOp.selectionChanged=!0}),this.polling.set(this.cm.options.pollInterval,e)},selectionChanged:function(){var e=window.getSelection();return e.anchorNode!=this.lastAnchorNode||e.anchorOffset!=this.lastAnchorOffset||e.focusNode!=this.lastFocusNode||e.focusOffset!=this.lastFocusOffset},pollSelection:function(){if(!this.composing&&!this.gracePeriod&&this.selectionChanged()){var e=window.getSelection(),t=this.cm;this.rememberSelection();var r=se(t,e.anchorNode,e.anchorOffset),n=se(t,e.focusNode,e.focusOffset);r&&n&&Wt(t,function(){ke(t.doc,de(r,n),Il),(r.bad||n.bad)&&(t.curOp.selectionChanged=!0)})}},pollContent:function(){var e=this.cm,t=e.display,r=e.doc.sel.primary(),n=r.from(),i=r.to();if(n.line<t.viewFrom||i.line>t.viewTo-1)return!1;var o;if(n.line==t.viewFrom||0==(o=Ft(e,n.line)))var l=ti(t.view[0].line),s=t.view[0].node;else var l=ti(t.view[o].line),s=t.view[o-1].node.nextSibling;var a=Ft(e,i.line);if(a==t.view.length-1)var u=t.viewTo-1,c=t.lineDiv.lastChild;else var u=ti(t.view[a+1].line)-1,c=t.view[a+1].node.previousSibling;for(var h=e.doc.splitLines(ue(e,s,c,l,u)),f=Qn(e.doc,zo(l,0),zo(u,Zn(e.doc,u).text.length));h.length>1&&f.length>1;)if(Di(h)==Di(f))h.pop(),f.pop(),u--;else{if(h[0]!=f[0])break;h.shift(),f.shift(),l++}for(var d=0,p=0,g=h[0],v=f[0],m=Math.min(g.length,v.length);m>d&&g.charCodeAt(d)==v.charCodeAt(d);)++d;for(var y=Di(h),b=Di(f),w=Math.min(y.length-(1==h.length?d:0),b.length-(1==f.length?d:0));w>p&&y.charCodeAt(y.length-p-1)==b.charCodeAt(b.length-p-1);)++p;h[h.length-1]=y.slice(0,y.length-p),h[0]=h[0].slice(d);var x=zo(l,d),C=zo(u,f.length?Di(f).length-p:0);return h.length>1||h[0]||Fo(x,C)?(Or(e.doc,h,x,C,"+input"),!0):void 0},ensurePolled:function(){this.forceCompositionEnd()},reset:function(){this.forceCompositionEnd()},forceCompositionEnd:function(){this.composing&&!this.composing.handled&&(this.applyComposition(this.composing),this.composing.handled=!0,this.div.blur(),this.div.focus())},applyComposition:function(e){this.cm.isReadOnly()?At(this.cm,Et)(this.cm):e.data&&e.data!=e.startData&&At(this.cm,Z)(this.cm,e.data,0,e.sel)},setUneditable:function(e){e.contentEditable="false"},onKeyPress:function(e){e.preventDefault(),this.cm.isReadOnly()||At(this.cm,Z)(this.cm,String.fromCharCode(null==e.charCode?e.keyCode:e.charCode),0)},readOnlyChanged:function(e){this.div.contentEditable=String("nocursor"!=e)},onContextMenu:Ei,resetPosition:Ei,needsContentAttribute:!0},ie.prototype),e.inputStyles={textarea:re,contenteditable:ie},ce.prototype={primary:function(){return this.ranges[this.primIndex]},equals:function(e){if(e==this)return!0;if(e.primIndex!=this.primIndex||e.ranges.length!=this.ranges.length)return!1;for(var t=0;t<this.ranges.length;t++){var r=this.ranges[t],n=e.ranges[t];if(0!=Fo(r.anchor,n.anchor)||0!=Fo(r.head,n.head))return!1}return!0},deepCopy:function(){for(var e=[],t=0;t<this.ranges.length;t++)e[t]=new he(Y(this.ranges[t].anchor),Y(this.ranges[t].head));return new ce(e,this.primIndex)},somethingSelected:function(){for(var e=0;e<this.ranges.length;e++)if(!this.ranges[e].empty())return!0;return!1},contains:function(e,t){t||(t=e);for(var r=0;r<this.ranges.length;r++){var n=this.ranges[r];if(Fo(t,n.from())>=0&&Fo(e,n.to())<=0)return r}return-1}},he.prototype={from:function(){return $(this.anchor,this.head)},to:function(){return _(this.anchor,this.head)},empty:function(){return this.head.line==this.anchor.line&&this.head.ch==this.anchor.ch}};var Bo,Go,Uo,Vo={left:0,right:0,top:0,bottom:0},Ko=null,jo=0,Xo=0,Yo=0,_o=null;bo?_o=-.53:vo?_o=15:So?_o=-.7:To&&(_o=-1/3);var $o=function(e){var t=e.wheelDeltaX,r=e.wheelDeltaY;return null==t&&e.detail&&e.axis==e.HORIZONTAL_AXIS&&(t=e.detail),null==r&&e.detail&&e.axis==e.VERTICAL_AXIS?r=e.detail:null==r&&(r=e.wheelDelta),{x:t,y:r}};e.wheelEventPixels=function(e){var t=$o(e);return t.x*=_o,t.y*=_o,t};var qo=new Ai,Zo=null,Qo=e.changeEnd=function(e){return e.text?zo(e.from.line+e.text.length-1,Di(e.text).length+(1==e.text.length?e.from.ch:0)):e.to};e.prototype={constructor:e,focus:function(){window.focus(),this.display.input.focus()},setOption:function(e,t){var r=this.options,n=r[e];(r[e]!=t||"mode"==e)&&(r[e]=t,el.hasOwnProperty(e)&&At(this,el[e])(this,t,n))},getOption:function(e){return this.options[e]},getDoc:function(){return this.doc},addKeyMap:function(e,t){this.state.keyMaps[t?"push":"unshift"](Xr(e))},removeKeyMap:function(e){for(var t=this.state.keyMaps,r=0;r<t.length;++r)if(t[r]==e||t[r].name==e)return t.splice(r,1),!0},addOverlay:Ot(function(t,r){var n=t.token?t:e.getMode(this.options,t);if(n.startState)throw new Error("Overlays may not be stateful.");this.state.overlays.push({mode:n,modeSpec:t,opaque:r&&r.opaque}),this.state.modeGen++,Et(this)}),removeOverlay:Ot(function(e){for(var t=this.state.overlays,r=0;r<t.length;++r){var n=t[r].modeSpec;if(n==e||"string"==typeof e&&n.name==e)return t.splice(r,1),this.state.modeGen++,void Et(this)}}),indentLine:Ot(function(e,t,r){"string"!=typeof t&&"number"!=typeof t&&(t=null==t?this.options.smartIndent?"smart":"prev":t?"add":"subtract"),me(this.doc,e)&&Rr(this,e,t,r)}),indentSelection:Ot(function(e){for(var t=this.doc.sel.ranges,r=-1,n=0;n<t.length;n++){var i=t[n];if(i.empty())i.head.line>r&&(Rr(this,i.head.line,e,!0),r=i.head.line,n==this.doc.sel.primIndex&&zr(this));else{var o=i.from(),l=i.to(),s=Math.max(r,o.line);r=Math.min(this.lastLine(),l.line-(l.ch?0:1))+1;for(var a=s;r>a;++a)Rr(this,a,e);var u=this.doc.sel.ranges;0==o.ch&&t.length==u.length&&u[n].from().ch>0&&Ce(this.doc,n,new he(o,u[n].to()),Il)}}}),getTokenAt:function(e,t){return Dn(this,e,t)},getLineTokens:function(e,t){return Dn(this,zo(e),t,!0)},getTokenTypeAt:function(e){e=ge(this.doc,e);var t,r=En(this,Zn(this.doc,e.line)),n=0,i=(r.length-1)/2,o=e.ch;if(0==o)t=r[2];else for(;;){var l=n+i>>1;if((l?r[2*l-1]:0)>=o)i=l;else{if(!(r[2*l+1]<o)){t=r[2*l+2];break}n=l+1}}var s=t?t.indexOf("cm-overlay "):-1;return 0>s?t:0==s?null:t.slice(0,s-1)},getModeAt:function(t){var r=this.doc.mode;return r.innerMode?e.innerMode(r,this.getTokenAt(t).state).mode:r},getHelper:function(e,t){return this.getHelpers(e,t)[0]},getHelpers:function(e,t){var r=[];if(!ll.hasOwnProperty(t))return r;var n=ll[t],i=this.getModeAt(e);if("string"==typeof i[t])n[i[t]]&&r.push(n[i[t]]);else if(i[t])for(var o=0;o<i[t].length;o++){var l=n[i[t][o]];l&&r.push(l)}else i.helperType&&n[i.helperType]?r.push(n[i.helperType]):n[i.name]&&r.push(n[i.name]);for(var o=0;o<n._global.length;o++){var s=n._global[o];s.pred(i,this)&&-1==Hi(r,s.val)&&r.push(s.val)}return r},getStateAfter:function(e,t){var r=this.doc;return e=pe(r,null==e?r.first+r.size-1:e),Ue(this,e+1,t)},cursorCoords:function(e,t){var r,n=this.doc.sel.primary();return r=null==e?n.head:"object"==typeof e?ge(this.doc,e):e?n.from():n.to(),dt(this,r,t||"page")},charCoords:function(e,t){return ft(this,ge(this.doc,e),t||"page")},coordsChar:function(e,t){return e=ht(this,e,t||"page"),vt(this,e.left,e.top)},lineAtHeight:function(e,t){return e=ht(this,{top:e,left:0},t||"page").top,ri(this.doc,e+this.display.viewOffset)},heightAtLine:function(e,t){var r,n=!1;if("number"==typeof e){var i=this.doc.first+this.doc.size-1;e<this.doc.first?e=this.doc.first:e>i&&(e=i,n=!0),r=Zn(this.doc,e)}else r=e;return ct(this,r,{top:0,left:0},t||"page").top+(n?this.doc.height-ni(r):0)},defaultTextHeight:function(){return yt(this.display)},defaultCharWidth:function(){return bt(this.display)},setGutterMarker:Ot(function(e,t,r){return Br(this.doc,e,"gutter",function(e){var n=e.gutterMarkers||(e.gutterMarkers={});return n[t]=r,!r&&Bi(n)&&(e.gutterMarkers=null),!0})}),clearGutter:Ot(function(e){var t=this,r=t.doc,n=r.first;r.iter(function(r){r.gutterMarkers&&r.gutterMarkers[e]&&(r.gutterMarkers[e]=null,It(t,n,"gutter"),Bi(r.gutterMarkers)&&(r.gutterMarkers=null)),++n})}),lineInfo:function(e){if("number"==typeof e){if(!me(this.doc,e))return null;var t=e;if(e=Zn(this.doc,e),!e)return null}else{var t=ti(e);if(null==t)return null}return{line:t,handle:e,text:e.text,gutterMarkers:e.gutterMarkers,textClass:e.textClass,bgClass:e.bgClass,wrapClass:e.wrapClass,widgets:e.widgets}},getViewport:function(){return{from:this.display.viewFrom,to:this.display.viewTo}},addWidget:function(e,t,r,n,i){var o=this.display;e=dt(this,ge(this.doc,e));var l=e.bottom,s=e.left;if(t.style.position="absolute",t.setAttribute("cm-ignore-events","true"),this.display.input.setUneditable(t),o.sizer.appendChild(t),"over"==n)l=e.top;else if("above"==n||"near"==n){var a=Math.max(o.wrapper.clientHeight,this.doc.height),u=Math.max(o.sizer.clientWidth,o.lineSpace.clientWidth);("above"==n||e.bottom+t.offsetHeight>a)&&e.top>t.offsetHeight?l=e.top-t.offsetHeight:e.bottom+t.offsetHeight<=a&&(l=e.bottom),s+t.offsetWidth>u&&(s=u-t.offsetWidth)}t.style.top=l+"px",t.style.left=t.style.right="","right"==i?(s=o.sizer.clientWidth-t.offsetWidth,t.style.right="0px"):("left"==i?s=0:"middle"==i&&(s=(o.sizer.clientWidth-t.offsetWidth)/2),t.style.left=s+"px"),r&&Pr(this,s,l,s+t.offsetWidth,l+t.offsetHeight)},triggerOnKeyDown:Ot(hr),triggerOnKeyPress:Ot(pr),triggerOnKeyUp:dr,execCommand:function(e){return ul.hasOwnProperty(e)?ul[e].call(null,this):void 0},triggerElectric:Ot(function(e){J(this,e)}),findPosH:function(e,t,r,n){var i=1;0>t&&(i=-1,t=-t);for(var o=0,l=ge(this.doc,e);t>o&&(l=Ur(this.doc,l,i,r,n),!l.hitSide);++o);return l},moveH:Ot(function(e,t){var r=this;r.extendSelectionsBy(function(n){return r.display.shift||r.doc.extend||n.empty()?Ur(r.doc,n.head,e,t,r.options.rtlMoveVisually):0>e?n.from():n.to()},Fl)}),deleteH:Ot(function(e,t){var r=this.doc.sel,n=this.doc;r.somethingSelected()?n.replaceSelection("",null,"+delete"):Gr(this,function(r){var i=Ur(n,r.head,e,t,!1);return 0>e?{from:i,to:r.head}:{from:r.head,to:i}})}),findPosV:function(e,t,r,n){var i=1,o=n;0>t&&(i=-1,t=-t);for(var l=0,s=ge(this.doc,e);t>l;++l){var a=dt(this,s,"div");if(null==o?o=a.left:a.left=o,s=Vr(this,a,i,r),s.hitSide)break}return s},moveV:Ot(function(e,t){var r=this,n=this.doc,i=[],o=!r.display.shift&&!n.extend&&n.sel.somethingSelected();if(n.extendSelectionsBy(function(l){if(o)return 0>e?l.from():l.to();var s=dt(r,l.head,"div");null!=l.goalColumn&&(s.left=l.goalColumn),i.push(s.left);var a=Vr(r,s,e,t);return"page"==t&&l==n.sel.primary()&&Ir(r,null,ft(r,a,"div").top-s.top),a},Fl),i.length)for(var l=0;l<n.sel.ranges.length;l++)n.sel.ranges[l].goalColumn=i[l]}),findWordAt:function(e){var t=this.doc,r=Zn(t,e.line).text,n=e.ch,i=e.ch;if(r){var o=this.getHelper(e,"wordChars");(e.xRel<0||i==r.length)&&n?--n:++i;for(var l=r.charAt(n),s=Ri(l,o)?function(e){return Ri(e,o)}:/\s/.test(l)?function(e){return/\s/.test(e)}:function(e){return!/\s/.test(e)&&!Ri(e)};n>0&&s(r.charAt(n-1));)--n;for(;i<r.length&&s(r.charAt(i));)++i}return new he(zo(e.line,n),zo(e.line,i))},toggleOverwrite:function(e){(null==e||e!=this.state.overwrite)&&((this.state.overwrite=!this.state.overwrite)?Zl(this.display.cursorDiv,"CodeMirror-overwrite"):ql(this.display.cursorDiv,"CodeMirror-overwrite"),Dl(this,"overwriteToggle",this,this.state.overwrite))},hasFocus:function(){return this.display.input.getField()==ji()},isReadOnly:function(){return!(!this.options.readOnly&&!this.doc.cantEdit)},scrollTo:Ot(function(e,t){(null!=e||null!=t)&&Fr(this),null!=e&&(this.curOp.scrollLeft=e),null!=t&&(this.curOp.scrollTop=t)}),getScrollInfo:function(){var e=this.display.scroller;return{left:e.scrollLeft,top:e.scrollTop,height:e.scrollHeight-Xe(this)-this.display.barHeight,width:e.scrollWidth-Xe(this)-this.display.barWidth,clientHeight:_e(this),clientWidth:Ye(this)}},scrollIntoView:Ot(function(e,t){if(null==e?(e={from:this.doc.sel.primary().head,to:null},null==t&&(t=this.options.cursorScrollMargin)):"number"==typeof e?e={from:zo(e,0),to:null}:null==e.from&&(e={from:e,to:null}),e.to||(e.to=e.from),e.margin=t||0,null!=e.from.line)Fr(this),this.curOp.scrollToPos=e;else{var r=Er(this,Math.min(e.from.left,e.to.left),Math.min(e.from.top,e.to.top)-e.margin,Math.max(e.from.right,e.to.right),Math.max(e.from.bottom,e.to.bottom)+e.margin);this.scrollTo(r.scrollLeft,r.scrollTop)}}),setSize:Ot(function(e,t){function r(e){return"number"==typeof e||/^\d+$/.test(String(e))?e+"px":e}var n=this;null!=e&&(n.display.wrapper.style.width=r(e)),null!=t&&(n.display.wrapper.style.height=r(t)),n.options.lineWrapping&<(this);var i=n.display.viewFrom;n.doc.iter(i,n.display.viewTo,function(e){if(e.widgets)for(var t=0;t<e.widgets.length;t++)if(e.widgets[t].noHScroll){It(n,i,"widget");break}++i}),n.curOp.forceUpdate=!0,Dl(n,"refresh",this)}),operation:function(e){return Wt(this,e)},refresh:Ot(function(){var e=this.display.cachedTextHeight;Et(this),this.curOp.forceUpdate=!0,st(this),this.scrollTo(this.doc.scrollLeft,this.doc.scrollTop),c(this),(null==e||Math.abs(e-yt(this.display))>.5)&&l(this),Dl(this,"refresh",this)}),swapDoc:Ot(function(e){var t=this.doc;return t.cm=null,qn(this,e),st(this),this.display.input.reset(),this.scrollTo(e.scrollLeft,e.scrollTop),this.curOp.forceScroll=!0,Li(this,"swapDoc",this,t),t}),getInputField:function(){return this.display.input.getField()},getWrapperElement:function(){return this.display.wrapper},getScrollerElement:function(){return this.display.scroller},getGutterElement:function(){return this.display.gutters}},Wi(e);var Jo=e.defaults={},el=e.optionHandlers={},tl=e.Init={toString:function(){return"CodeMirror.Init"}};Kr("value","",function(e,t){e.setValue(t)},!0),Kr("mode",null,function(e,t){e.doc.modeOption=t,r(e)},!0),Kr("indentUnit",2,r,!0),Kr("indentWithTabs",!1),Kr("smartIndent",!0),Kr("tabSize",4,function(e){n(e),st(e),Et(e)},!0),Kr("lineSeparator",null,function(e,t){if(e.doc.lineSep=t,t){var r=[],n=e.doc.first;e.doc.iter(function(e){for(var i=0;;){var o=e.text.indexOf(t,i);if(-1==o)break;i=o+t.length,r.push(zo(n,o))}n++});for(var i=r.length-1;i>=0;i--)Or(e.doc,t,r[i],zo(r[i].line,r[i].ch+t.length))}}),Kr("specialChars",/[\t\u0000-\u0019\u00ad\u200b-\u200f\u2028\u2029\ufeff]/g,function(t,r,n){t.state.specialChars=new RegExp(r.source+(r.test(" ")?"":"| "),"g"),n!=e.Init&&t.refresh()}),Kr("specialCharPlaceholder",Rn,function(e){e.refresh()},!0),Kr("electricChars",!0),Kr("inputStyle",Wo?"contenteditable":"textarea",function(){throw new Error("inputStyle can not (yet) be changed in a running editor")},!0),Kr("rtlMoveVisually",!Oo),Kr("wholeLineUpdateBefore",!0),Kr("theme","default",function(e){s(e),a(e)},!0),Kr("keyMap","default",function(t,r,n){var i=Xr(r),o=n!=e.Init&&Xr(n);o&&o.detach&&o.detach(t,i),i.attach&&i.attach(t,o||null)}),Kr("extraKeys",null),Kr("lineWrapping",!1,i,!0),Kr("gutters",[],function(e){d(e.options),a(e)},!0),Kr("fixedGutter",!0,function(e,t){e.display.gutters.style.left=t?L(e.display)+"px":"0",e.refresh()},!0),Kr("coverGutterNextToScrollbar",!1,function(e){y(e)},!0),Kr("scrollbarStyle","native",function(e){m(e),y(e),e.display.scrollbars.setScrollTop(e.doc.scrollTop),e.display.scrollbars.setScrollLeft(e.doc.scrollLeft)},!0),Kr("lineNumbers",!1,function(e){d(e.options),a(e)},!0),Kr("firstLineNumber",1,a,!0),Kr("lineNumberFormatter",function(e){return e},a,!0),Kr("showCursorWhenSelecting",!1,Pe,!0),Kr("resetSelectionOnContextMenu",!0),Kr("lineWiseCopyCut",!0),Kr("readOnly",!1,function(e,t){"nocursor"==t?(mr(e),e.display.input.blur(),e.display.disabled=!0):e.display.disabled=!1,e.display.input.readOnlyChanged(t)}),Kr("disableInput",!1,function(e,t){t||e.display.input.reset()},!0),Kr("dragDrop",!0,Vt),Kr("allowDropFileTypes",null),Kr("cursorBlinkRate",530),Kr("cursorScrollMargin",0),Kr("cursorHeight",1,Pe,!0),Kr("singleCursorHeightPerLine",!0,Pe,!0),Kr("workTime",100),Kr("workDelay",100),Kr("flattenSpans",!0,n,!0),Kr("addModeClass",!1,n,!0),Kr("pollInterval",100),Kr("undoDepth",200,function(e,t){e.doc.history.undoDepth=t}),Kr("historyEventDelay",1250),Kr("viewportMargin",10,function(e){e.refresh()},!0),Kr("maxHighlightLength",1e4,n,!0),Kr("moveInputWithCursor",!0,function(e,t){t||e.display.input.resetPosition()}),Kr("tabindex",null,function(e,t){e.display.input.getField().tabIndex=t||""}),Kr("autofocus",null);var rl=e.modes={},nl=e.mimeModes={};e.defineMode=function(t,r){e.defaults.mode||"null"==t||(e.defaults.mode=t),arguments.length>2&&(r.dependencies=Array.prototype.slice.call(arguments,2)),rl[t]=r},e.defineMIME=function(e,t){nl[e]=t},e.resolveMode=function(t){if("string"==typeof t&&nl.hasOwnProperty(t))t=nl[t];else if(t&&"string"==typeof t.name&&nl.hasOwnProperty(t.name)){var r=nl[t.name];"string"==typeof r&&(r={name:r}),t=Ii(r,t),t.name=r.name}else if("string"==typeof t&&/^[\w\-]+\/[\w\-]+\+xml$/.test(t))return e.resolveMode("application/xml");return"string"==typeof t?{name:t}:t||{name:"null"}},e.getMode=function(t,r){var r=e.resolveMode(r),n=rl[r.name];if(!n)return e.getMode(t,"text/plain");var i=n(t,r);if(il.hasOwnProperty(r.name)){var o=il[r.name];for(var l in o)o.hasOwnProperty(l)&&(i.hasOwnProperty(l)&&(i["_"+l]=i[l]),i[l]=o[l])}if(i.name=r.name,r.helperType&&(i.helperType=r.helperType),r.modeProps)for(var l in r.modeProps)i[l]=r.modeProps[l];return i},e.defineMode("null",function(){return{token:function(e){e.skipToEnd()}}}),e.defineMIME("text/plain","null");var il=e.modeExtensions={};e.extendMode=function(e,t){var r=il.hasOwnProperty(e)?il[e]:il[e]={};zi(t,r)},e.defineExtension=function(t,r){e.prototype[t]=r},e.defineDocExtension=function(e,t){Sl.prototype[e]=t},e.defineOption=Kr;var ol=[];e.defineInitHook=function(e){ol.push(e)};var ll=e.helpers={};e.registerHelper=function(t,r,n){ll.hasOwnProperty(t)||(ll[t]=e[t]={_global:[]}),ll[t][r]=n},e.registerGlobalHelper=function(t,r,n,i){e.registerHelper(t,r,i),ll[t]._global.push({pred:n,val:i})};var sl=e.copyState=function(e,t){if(t===!0)return t;if(e.copyState)return e.copyState(t);var r={};for(var n in t){var i=t[n];i instanceof Array&&(i=i.concat([])),r[n]=i}return r},al=e.startState=function(e,t,r){return e.startState?e.startState(t,r):!0};e.innerMode=function(e,t){for(;e.innerMode;){var r=e.innerMode(t);if(!r||r.mode==e)break;t=r.state,e=r.mode}return r||{mode:e,state:t}};var ul=e.commands={selectAll:function(e){e.setSelection(zo(e.firstLine(),0),zo(e.lastLine()),Il)},singleSelection:function(e){e.setSelection(e.getCursor("anchor"),e.getCursor("head"),Il)},killLine:function(e){Gr(e,function(t){if(t.empty()){var r=Zn(e.doc,t.head.line).text.length;return t.head.ch==r&&t.head.line<e.lastLine()?{from:t.head,to:zo(t.head.line+1,0)}:{from:t.head,to:zo(t.head.line,r)}}return{from:t.from(),to:t.to()}})},deleteLine:function(e){Gr(e,function(t){return{from:zo(t.from().line,0),to:ge(e.doc,zo(t.to().line+1,0))}})},delLineLeft:function(e){Gr(e,function(e){return{from:zo(e.from().line,0),to:e.from()}})},delWrappedLineLeft:function(e){Gr(e,function(t){var r=e.charCoords(t.head,"div").top+5,n=e.coordsChar({left:0,top:r},"div");return{from:n,to:t.from()}})},delWrappedLineRight:function(e){Gr(e,function(t){var r=e.charCoords(t.head,"div").top+5,n=e.coordsChar({left:e.display.lineDiv.offsetWidth+100,top:r},"div");return{from:t.from(),to:n}})},undo:function(e){e.undo()},redo:function(e){e.redo()},undoSelection:function(e){e.undoSelection()},redoSelection:function(e){e.redoSelection()},goDocStart:function(e){e.extendSelection(zo(e.firstLine(),0))},goDocEnd:function(e){e.extendSelection(zo(e.lastLine()))},goLineStart:function(e){e.extendSelectionsBy(function(t){return oo(e,t.head.line)},{origin:"+move",bias:1})},goLineStartSmart:function(e){e.extendSelectionsBy(function(t){return so(e,t.head)},{origin:"+move",bias:1})},goLineEnd:function(e){e.extendSelectionsBy(function(t){return lo(e,t.head.line)},{origin:"+move",bias:-1})},goLineRight:function(e){e.extendSelectionsBy(function(t){var r=e.charCoords(t.head,"div").top+5;return e.coordsChar({left:e.display.lineDiv.offsetWidth+100,top:r},"div")},Fl)},goLineLeft:function(e){e.extendSelectionsBy(function(t){var r=e.charCoords(t.head,"div").top+5;return e.coordsChar({left:0,top:r},"div")},Fl)},goLineLeftSmart:function(e){e.extendSelectionsBy(function(t){var r=e.charCoords(t.head,"div").top+5,n=e.coordsChar({left:0,top:r},"div");return n.ch<e.getLine(n.line).search(/\S/)?so(e,t.head):n},Fl)},goLineUp:function(e){e.moveV(-1,"line")},goLineDown:function(e){e.moveV(1,"line")},goPageUp:function(e){e.moveV(-1,"page")},goPageDown:function(e){e.moveV(1,"page")},goCharLeft:function(e){e.moveH(-1,"char")},goCharRight:function(e){e.moveH(1,"char")},goColumnLeft:function(e){e.moveH(-1,"column")},goColumnRight:function(e){e.moveH(1,"column")},goWordLeft:function(e){e.moveH(-1,"word")},goGroupRight:function(e){e.moveH(1,"group")},goGroupLeft:function(e){e.moveH(-1,"group")},goWordRight:function(e){e.moveH(1,"word")},delCharBefore:function(e){e.deleteH(-1,"char")},delCharAfter:function(e){e.deleteH(1,"char")},delWordBefore:function(e){e.deleteH(-1,"word")},delWordAfter:function(e){e.deleteH(1,"word")},delGroupBefore:function(e){e.deleteH(-1,"group")},delGroupAfter:function(e){e.deleteH(1,"group")},indentAuto:function(e){e.indentSelection("smart")},indentMore:function(e){e.indentSelection("add")},indentLess:function(e){e.indentSelection("subtract")},insertTab:function(e){e.replaceSelection(" ")},insertSoftTab:function(e){for(var t=[],r=e.listSelections(),n=e.options.tabSize,i=0;i<r.length;i++){var o=r[i].from(),l=Rl(e.getLine(o.line),o.ch,n);t.push(new Array(n-l%n+1).join(" "))}e.replaceSelections(t)},defaultTab:function(e){e.somethingSelected()?e.indentSelection("add"):e.execCommand("insertTab")},transposeChars:function(e){Wt(e,function(){for(var t=e.listSelections(),r=[],n=0;n<t.length;n++){var i=t[n].head,o=Zn(e.doc,i.line).text;if(o)if(i.ch==o.length&&(i=new zo(i.line,i.ch-1)),i.ch>0)i=new zo(i.line,i.ch+1),e.replaceRange(o.charAt(i.ch-1)+o.charAt(i.ch-2),zo(i.line,i.ch-2),i,"+transpose");else if(i.line>e.doc.first){var l=Zn(e.doc,i.line-1).text;l&&e.replaceRange(o.charAt(0)+e.doc.lineSeparator()+l.charAt(l.length-1),zo(i.line-1,l.length-1),zo(i.line,1),"+transpose")}r.push(new he(i,i))}e.setSelections(r)})},newlineAndIndent:function(e){Wt(e,function(){for(var t=e.listSelections().length,r=0;t>r;r++){var n=e.listSelections()[r];e.replaceRange(e.doc.lineSeparator(),n.anchor,n.head,"+input"),e.indentLine(n.from().line+1,null,!0)}zr(e)})},toggleOverwrite:function(e){e.toggleOverwrite()}},cl=e.keyMap={};cl.basic={Left:"goCharLeft",Right:"goCharRight",Up:"goLineUp",Down:"goLineDown",End:"goLineEnd",Home:"goLineStartSmart",PageUp:"goPageUp",PageDown:"goPageDown",Delete:"delCharAfter",Backspace:"delCharBefore","Shift-Backspace":"delCharBefore",Tab:"defaultTab","Shift-Tab":"indentAuto",Enter:"newlineAndIndent",Insert:"toggleOverwrite",Esc:"singleSelection"},cl.pcDefault={"Ctrl-A":"selectAll","Ctrl-D":"deleteLine","Ctrl-Z":"undo","Shift-Ctrl-Z":"redo","Ctrl-Y":"redo","Ctrl-Home":"goDocStart","Ctrl-End":"goDocEnd","Ctrl-Up":"goLineUp","Ctrl-Down":"goLineDown","Ctrl-Left":"goGroupLeft","Ctrl-Right":"goGroupRight","Alt-Left":"goLineStart","Alt-Right":"goLineEnd","Ctrl-Backspace":"delGroupBefore","Ctrl-Delete":"delGroupAfter",
|
5 |
+
"Ctrl-S":"save","Ctrl-F":"find","Ctrl-G":"findNext","Shift-Ctrl-G":"findPrev","Shift-Ctrl-F":"replace","Shift-Ctrl-R":"replaceAll","Ctrl-[":"indentLess","Ctrl-]":"indentMore","Ctrl-U":"undoSelection","Shift-Ctrl-U":"redoSelection","Alt-U":"redoSelection",fallthrough:"basic"},cl.emacsy={"Ctrl-F":"goCharRight","Ctrl-B":"goCharLeft","Ctrl-P":"goLineUp","Ctrl-N":"goLineDown","Alt-F":"goWordRight","Alt-B":"goWordLeft","Ctrl-A":"goLineStart","Ctrl-E":"goLineEnd","Ctrl-V":"goPageDown","Shift-Ctrl-V":"goPageUp","Ctrl-D":"delCharAfter","Ctrl-H":"delCharBefore","Alt-D":"delWordAfter","Alt-Backspace":"delWordBefore","Ctrl-K":"killLine","Ctrl-T":"transposeChars"},cl.macDefault={"Cmd-A":"selectAll","Cmd-D":"deleteLine","Cmd-Z":"undo","Shift-Cmd-Z":"redo","Cmd-Y":"redo","Cmd-Home":"goDocStart","Cmd-Up":"goDocStart","Cmd-End":"goDocEnd","Cmd-Down":"goDocEnd","Alt-Left":"goGroupLeft","Alt-Right":"goGroupRight","Cmd-Left":"goLineLeft","Cmd-Right":"goLineRight","Alt-Backspace":"delGroupBefore","Ctrl-Alt-Backspace":"delGroupAfter","Alt-Delete":"delGroupAfter","Cmd-S":"save","Cmd-F":"find","Cmd-G":"findNext","Shift-Cmd-G":"findPrev","Cmd-Alt-F":"replace","Shift-Cmd-Alt-F":"replaceAll","Cmd-[":"indentLess","Cmd-]":"indentMore","Cmd-Backspace":"delWrappedLineLeft","Cmd-Delete":"delWrappedLineRight","Cmd-U":"undoSelection","Shift-Cmd-U":"redoSelection","Ctrl-Up":"goDocStart","Ctrl-Down":"goDocEnd",fallthrough:["basic","emacsy"]},cl["default"]=Ao?cl.macDefault:cl.pcDefault,e.normalizeKeyMap=function(e){var t={};for(var r in e)if(e.hasOwnProperty(r)){var n=e[r];if(/^(name|fallthrough|(de|at)tach)$/.test(r))continue;if("..."==n){delete e[r];continue}for(var i=Pi(r.split(" "),jr),o=0;o<i.length;o++){var l,s;o==i.length-1?(s=i.join(" "),l=n):(s=i.slice(0,o+1).join(" "),l="...");var a=t[s];if(a){if(a!=l)throw new Error("Inconsistent bindings for "+s)}else t[s]=l}delete e[r]}for(var u in t)e[u]=t[u];return e};var hl=e.lookupKey=function(e,t,r,n){t=Xr(t);var i=t.call?t.call(e,n):t[e];if(i===!1)return"nothing";if("..."===i)return"multi";if(null!=i&&r(i))return"handled";if(t.fallthrough){if("[object Array]"!=Object.prototype.toString.call(t.fallthrough))return hl(e,t.fallthrough,r,n);for(var o=0;o<t.fallthrough.length;o++){var l=hl(e,t.fallthrough[o],r,n);if(l)return l}}},fl=e.isModifierKey=function(e){var t="string"==typeof e?e:is[e.keyCode];return"Ctrl"==t||"Alt"==t||"Shift"==t||"Mod"==t},dl=e.keyName=function(e,t){if(Lo&&34==e.keyCode&&e["char"])return!1;var r=is[e.keyCode],n=r;return null==n||e.altGraphKey?!1:(e.altKey&&"Alt"!=r&&(n="Alt-"+n),(Ho?e.metaKey:e.ctrlKey)&&"Ctrl"!=r&&(n="Ctrl-"+n),(Ho?e.ctrlKey:e.metaKey)&&"Cmd"!=r&&(n="Cmd-"+n),!t&&e.shiftKey&&"Shift"!=r&&(n="Shift-"+n),n)};e.fromTextArea=function(t,r){function n(){t.value=u.getValue()}if(r=r?zi(r):{},r.value=t.value,!r.tabindex&&t.tabIndex&&(r.tabindex=t.tabIndex),!r.placeholder&&t.placeholder&&(r.placeholder=t.placeholder),null==r.autofocus){var i=ji();r.autofocus=i==t||null!=t.getAttribute("autofocus")&&i==document.body}if(t.form&&(Wl(t.form,"submit",n),!r.leaveSubmitMethodAlone)){var o=t.form,l=o.submit;try{var s=o.submit=function(){n(),o.submit=l,o.submit(),o.submit=s}}catch(a){}}r.finishInit=function(e){e.save=n,e.getTextArea=function(){return t},e.toTextArea=function(){e.toTextArea=isNaN,n(),t.parentNode.removeChild(e.getWrapperElement()),t.style.display="",t.form&&(Ol(t.form,"submit",n),"function"==typeof t.form.submit&&(t.form.submit=l))}},t.style.display="none";var u=e(function(e){t.parentNode.insertBefore(e,t.nextSibling)},r);return u};var pl=e.StringStream=function(e,t){this.pos=this.start=0,this.string=e,this.tabSize=t||8,this.lastColumnPos=this.lastColumnValue=0,this.lineStart=0};pl.prototype={eol:function(){return this.pos>=this.string.length},sol:function(){return this.pos==this.lineStart},peek:function(){return this.string.charAt(this.pos)||void 0},next:function(){return this.pos<this.string.length?this.string.charAt(this.pos++):void 0},eat:function(e){var t=this.string.charAt(this.pos);if("string"==typeof e)var r=t==e;else var r=t&&(e.test?e.test(t):e(t));return r?(++this.pos,t):void 0},eatWhile:function(e){for(var t=this.pos;this.eat(e););return this.pos>t},eatSpace:function(){for(var e=this.pos;/[\s\u00a0]/.test(this.string.charAt(this.pos));)++this.pos;return this.pos>e},skipToEnd:function(){this.pos=this.string.length},skipTo:function(e){var t=this.string.indexOf(e,this.pos);return t>-1?(this.pos=t,!0):void 0},backUp:function(e){this.pos-=e},column:function(){return this.lastColumnPos<this.start&&(this.lastColumnValue=Rl(this.string,this.start,this.tabSize,this.lastColumnPos,this.lastColumnValue),this.lastColumnPos=this.start),this.lastColumnValue-(this.lineStart?Rl(this.string,this.lineStart,this.tabSize):0)},indentation:function(){return Rl(this.string,null,this.tabSize)-(this.lineStart?Rl(this.string,this.lineStart,this.tabSize):0)},match:function(e,t,r){if("string"!=typeof e){var n=this.string.slice(this.pos).match(e);return n&&n.index>0?null:(n&&t!==!1&&(this.pos+=n[0].length),n)}var i=function(e){return r?e.toLowerCase():e},o=this.string.substr(this.pos,e.length);return i(o)==i(e)?(t!==!1&&(this.pos+=e.length),!0):void 0},current:function(){return this.string.slice(this.start,this.pos)},hideFirstChars:function(e,t){this.lineStart+=e;try{return t()}finally{this.lineStart-=e}}};var gl=0,vl=e.TextMarker=function(e,t){this.lines=[],this.type=t,this.doc=e,this.id=++gl};Wi(vl),vl.prototype.clear=function(){if(!this.explicitlyCleared){var e=this.doc.cm,t=e&&!e.curOp;if(t&&wt(e),Ni(this,"clear")){var r=this.find();r&&Li(this,"clear",r.from,r.to)}for(var n=null,i=null,o=0;o<this.lines.length;++o){var l=this.lines[o],s=Jr(l.markedSpans,this);e&&!this.collapsed?It(e,ti(l),"text"):e&&(null!=s.to&&(i=ti(l)),null!=s.from&&(n=ti(l))),l.markedSpans=en(l.markedSpans,s),null==s.from&&this.collapsed&&!Cn(this.doc,l)&&e&&ei(l,yt(e.display))}if(e&&this.collapsed&&!e.options.lineWrapping)for(var o=0;o<this.lines.length;++o){var a=yn(this.lines[o]),u=h(a);u>e.display.maxLineLength&&(e.display.maxLine=a,e.display.maxLineLength=u,e.display.maxLineChanged=!0)}null!=n&&e&&this.collapsed&&Et(e,n,i+1),this.lines.length=0,this.explicitlyCleared=!0,this.atomic&&this.doc.cantEdit&&(this.doc.cantEdit=!1,e&&We(e.doc)),e&&Li(e,"markerCleared",e,this),t&&Ct(e),this.parent&&this.parent.clear()}},vl.prototype.find=function(e,t){null==e&&"bookmark"==this.type&&(e=1);for(var r,n,i=0;i<this.lines.length;++i){var o=this.lines[i],l=Jr(o.markedSpans,this);if(null!=l.from&&(r=zo(t?o:ti(o),l.from),-1==e))return r;if(null!=l.to&&(n=zo(t?o:ti(o),l.to),1==e))return n}return r&&{from:r,to:n}},vl.prototype.changed=function(){var e=this.find(-1,!0),t=this,r=this.doc.cm;e&&r&&Wt(r,function(){var n=e.line,i=ti(e.line),o=Je(r,i);if(o&&(ot(o),r.curOp.selectionChanged=r.curOp.forceUpdate=!0),r.curOp.updateMaxLine=!0,!Cn(t.doc,n)&&null!=t.height){var l=t.height;t.height=null;var s=Tn(t)-l;s&&ei(n,n.height+s)}})},vl.prototype.attachLine=function(e){if(!this.lines.length&&this.doc.cm){var t=this.doc.cm.curOp;t.maybeHiddenMarkers&&-1!=Hi(t.maybeHiddenMarkers,this)||(t.maybeUnhiddenMarkers||(t.maybeUnhiddenMarkers=[])).push(this)}this.lines.push(e)},vl.prototype.detachLine=function(e){if(this.lines.splice(Hi(this.lines,e),1),!this.lines.length&&this.doc.cm){var t=this.doc.cm.curOp;(t.maybeHiddenMarkers||(t.maybeHiddenMarkers=[])).push(this)}};var gl=0,ml=e.SharedTextMarker=function(e,t){this.markers=e,this.primary=t;for(var r=0;r<e.length;++r)e[r].parent=this};Wi(ml),ml.prototype.clear=function(){if(!this.explicitlyCleared){this.explicitlyCleared=!0;for(var e=0;e<this.markers.length;++e)this.markers[e].clear();Li(this,"clear")}},ml.prototype.find=function(e,t){return this.primary.find(e,t)};var yl=e.LineWidget=function(e,t,r){if(r)for(var n in r)r.hasOwnProperty(n)&&(this[n]=r[n]);this.doc=e,this.node=t};Wi(yl),yl.prototype.clear=function(){var e=this.doc.cm,t=this.line.widgets,r=this.line,n=ti(r);if(null!=n&&t){for(var i=0;i<t.length;++i)t[i]==this&&t.splice(i--,1);t.length||(r.widgets=null);var o=Tn(this);ei(r,Math.max(0,r.height-o)),e&&Wt(e,function(){Ln(e,r,-o),It(e,n,"widget")})}},yl.prototype.changed=function(){var e=this.height,t=this.doc.cm,r=this.line;this.height=null;var n=Tn(this)-e;n&&(ei(r,r.height+n),t&&Wt(t,function(){t.curOp.forceUpdate=!0,Ln(t,r,n)}))};var bl=e.Line=function(e,t,r){this.text=e,cn(this,t),this.height=r?r(this):1};Wi(bl),bl.prototype.lineNo=function(){return ti(this)};var wl={},xl={};Yn.prototype={chunkSize:function(){return this.lines.length},removeInner:function(e,t){for(var r=e,n=e+t;n>r;++r){var i=this.lines[r];this.height-=i.height,Nn(i),Li(i,"delete")}this.lines.splice(e,t)},collapse:function(e){e.push.apply(e,this.lines)},insertInner:function(e,t,r){this.height+=r,this.lines=this.lines.slice(0,e).concat(t).concat(this.lines.slice(e));for(var n=0;n<t.length;++n)t[n].parent=this},iterN:function(e,t,r){for(var n=e+t;n>e;++e)if(r(this.lines[e]))return!0}},_n.prototype={chunkSize:function(){return this.size},removeInner:function(e,t){this.size-=t;for(var r=0;r<this.children.length;++r){var n=this.children[r],i=n.chunkSize();if(i>e){var o=Math.min(t,i-e),l=n.height;if(n.removeInner(e,o),this.height-=l-n.height,i==o&&(this.children.splice(r--,1),n.parent=null),0==(t-=o))break;e=0}else e-=i}if(this.size-t<25&&(this.children.length>1||!(this.children[0]instanceof Yn))){var s=[];this.collapse(s),this.children=[new Yn(s)],this.children[0].parent=this}},collapse:function(e){for(var t=0;t<this.children.length;++t)this.children[t].collapse(e)},insertInner:function(e,t,r){this.size+=t.length,this.height+=r;for(var n=0;n<this.children.length;++n){var i=this.children[n],o=i.chunkSize();if(o>=e){if(i.insertInner(e,t,r),i.lines&&i.lines.length>50){for(;i.lines.length>50;){var l=i.lines.splice(i.lines.length-25,25),s=new Yn(l);i.height-=s.height,this.children.splice(n+1,0,s),s.parent=this}this.maybeSpill()}break}e-=o}},maybeSpill:function(){if(!(this.children.length<=10)){var e=this;do{var t=e.children.splice(e.children.length-5,5),r=new _n(t);if(e.parent){e.size-=r.size,e.height-=r.height;var n=Hi(e.parent.children,e);e.parent.children.splice(n+1,0,r)}else{var i=new _n(e.children);i.parent=e,e.children=[i,r],e=i}r.parent=e.parent}while(e.children.length>10);e.parent.maybeSpill()}},iterN:function(e,t,r){for(var n=0;n<this.children.length;++n){var i=this.children[n],o=i.chunkSize();if(o>e){var l=Math.min(t,o-e);if(i.iterN(e,l,r))return!0;if(0==(t-=l))break;e=0}else e-=o}}};var Cl=0,Sl=e.Doc=function(e,t,r,n){if(!(this instanceof Sl))return new Sl(e,t,r,n);null==r&&(r=0),_n.call(this,[new Yn([new bl("",null)])]),this.first=r,this.scrollTop=this.scrollLeft=0,this.cantEdit=!1,this.cleanGeneration=1,this.frontier=r;var i=zo(r,0);this.sel=de(i),this.history=new oi(null),this.id=++Cl,this.modeOption=t,this.lineSep=n,this.extend=!1,"string"==typeof e&&(e=this.splitLines(e)),Xn(this,{from:i,to:i,text:e}),ke(this,de(i),Il)};Sl.prototype=Ii(_n.prototype,{constructor:Sl,iter:function(e,t,r){r?this.iterN(e-this.first,t-e,r):this.iterN(this.first,this.first+this.size,e)},insert:function(e,t){for(var r=0,n=0;n<t.length;++n)r+=t[n].height;this.insertInner(e-this.first,t,r)},remove:function(e,t){this.removeInner(e-this.first,t)},getValue:function(e){var t=Jn(this,this.first,this.first+this.size);return e===!1?t:t.join(e||this.lineSeparator())},setValue:Dt(function(e){var t=zo(this.first,0),r=this.first+this.size-1;Tr(this,{from:t,to:zo(r,Zn(this,r).text.length),text:this.splitLines(e),origin:"setValue",full:!0},!0),ke(this,de(t))}),replaceRange:function(e,t,r,n){t=ge(this,t),r=r?ge(this,r):t,Or(this,e,t,r,n)},getRange:function(e,t,r){var n=Qn(this,ge(this,e),ge(this,t));return r===!1?n:n.join(r||this.lineSeparator())},getLine:function(e){var t=this.getLineHandle(e);return t&&t.text},getLineHandle:function(e){return me(this,e)?Zn(this,e):void 0},getLineNumber:function(e){return ti(e)},getLineHandleVisualStart:function(e){return"number"==typeof e&&(e=Zn(this,e)),yn(e)},lineCount:function(){return this.size},firstLine:function(){return this.first},lastLine:function(){return this.first+this.size-1},clipPos:function(e){return ge(this,e)},getCursor:function(e){var t,r=this.sel.primary();return t=null==e||"head"==e?r.head:"anchor"==e?r.anchor:"end"==e||"to"==e||e===!1?r.to():r.from()},listSelections:function(){return this.sel.ranges},somethingSelected:function(){return this.sel.somethingSelected()},setCursor:Dt(function(e,t,r){Se(this,ge(this,"number"==typeof e?zo(e,t||0):e),null,r)}),setSelection:Dt(function(e,t,r){Se(this,ge(this,e),ge(this,t||e),r)}),extendSelection:Dt(function(e,t,r){we(this,ge(this,e),t&&ge(this,t),r)}),extendSelections:Dt(function(e,t){xe(this,ye(this,e),t)}),extendSelectionsBy:Dt(function(e,t){var r=Pi(this.sel.ranges,e);xe(this,ye(this,r),t)}),setSelections:Dt(function(e,t,r){if(e.length){for(var n=0,i=[];n<e.length;n++)i[n]=new he(ge(this,e[n].anchor),ge(this,e[n].head));null==t&&(t=Math.min(e.length-1,this.sel.primIndex)),ke(this,fe(i,t),r)}}),addSelection:Dt(function(e,t,r){var n=this.sel.ranges.slice(0);n.push(new he(ge(this,e),ge(this,t||e))),ke(this,fe(n,n.length-1),r)}),getSelection:function(e){for(var t,r=this.sel.ranges,n=0;n<r.length;n++){var i=Qn(this,r[n].from(),r[n].to());t=t?t.concat(i):i}return e===!1?t:t.join(e||this.lineSeparator())},getSelections:function(e){for(var t=[],r=this.sel.ranges,n=0;n<r.length;n++){var i=Qn(this,r[n].from(),r[n].to());e!==!1&&(i=i.join(e||this.lineSeparator())),t[n]=i}return t},replaceSelection:function(e,t,r){for(var n=[],i=0;i<this.sel.ranges.length;i++)n[i]=e;this.replaceSelections(n,t,r||"+input")},replaceSelections:Dt(function(e,t,r){for(var n=[],i=this.sel,o=0;o<i.ranges.length;o++){var l=i.ranges[o];n[o]={from:l.from(),to:l.to(),text:this.splitLines(e[o]),origin:r}}for(var s=t&&"end"!=t&&Sr(this,n,t),o=n.length-1;o>=0;o--)Tr(this,n[o]);s?Te(this,s):this.cm&&zr(this.cm)}),undo:Dt(function(){Mr(this,"undo")}),redo:Dt(function(){Mr(this,"redo")}),undoSelection:Dt(function(){Mr(this,"undo",!0)}),redoSelection:Dt(function(){Mr(this,"redo",!0)}),setExtending:function(e){this.extend=e},getExtending:function(){return this.extend},historySize:function(){for(var e=this.history,t=0,r=0,n=0;n<e.done.length;n++)e.done[n].ranges||++t;for(var n=0;n<e.undone.length;n++)e.undone[n].ranges||++r;return{undo:t,redo:r}},clearHistory:function(){this.history=new oi(this.history.maxGeneration)},markClean:function(){this.cleanGeneration=this.changeGeneration(!0)},changeGeneration:function(e){return e&&(this.history.lastOp=this.history.lastSelOp=this.history.lastOrigin=null),this.history.generation},isClean:function(e){return this.history.generation==(e||this.cleanGeneration)},getHistory:function(){return{done:vi(this.history.done),undone:vi(this.history.undone)}},setHistory:function(e){var t=this.history=new oi(this.history.maxGeneration);t.done=vi(e.done.slice(0),null,!0),t.undone=vi(e.undone.slice(0),null,!0)},addLineClass:Dt(function(e,t,r){return Br(this,e,"gutter"==t?"gutter":"class",function(e){var n="text"==t?"textClass":"background"==t?"bgClass":"gutter"==t?"gutterClass":"wrapClass";if(e[n]){if(Xi(r).test(e[n]))return!1;e[n]+=" "+r}else e[n]=r;return!0})}),removeLineClass:Dt(function(e,t,r){return Br(this,e,"gutter"==t?"gutter":"class",function(e){var n="text"==t?"textClass":"background"==t?"bgClass":"gutter"==t?"gutterClass":"wrapClass",i=e[n];if(!i)return!1;if(null==r)e[n]=null;else{var o=i.match(Xi(r));if(!o)return!1;var l=o.index+o[0].length;e[n]=i.slice(0,o.index)+(o.index&&l!=i.length?" ":"")+i.slice(l)||null}return!0})}),addLineWidget:Dt(function(e,t,r){return kn(this,e,t,r)}),removeLineWidget:function(e){e.clear()},markText:function(e,t,r){return Yr(this,ge(this,e),ge(this,t),r,r&&r.type||"range")},setBookmark:function(e,t){var r={replacedWith:t&&(null==t.nodeType?t.widget:t),insertLeft:t&&t.insertLeft,clearWhenEmpty:!1,shared:t&&t.shared,handleMouseEvents:t&&t.handleMouseEvents};return e=ge(this,e),Yr(this,e,e,r,"bookmark")},findMarksAt:function(e){e=ge(this,e);var t=[],r=Zn(this,e.line).markedSpans;if(r)for(var n=0;n<r.length;++n){var i=r[n];(null==i.from||i.from<=e.ch)&&(null==i.to||i.to>=e.ch)&&t.push(i.marker.parent||i.marker)}return t},findMarks:function(e,t,r){e=ge(this,e),t=ge(this,t);var n=[],i=e.line;return this.iter(e.line,t.line+1,function(o){var l=o.markedSpans;if(l)for(var s=0;s<l.length;s++){var a=l[s];i==e.line&&e.ch>a.to||null==a.from&&i!=e.line||i==t.line&&a.from>t.ch||r&&!r(a.marker)||n.push(a.marker.parent||a.marker)}++i}),n},getAllMarks:function(){var e=[];return this.iter(function(t){var r=t.markedSpans;if(r)for(var n=0;n<r.length;++n)null!=r[n].from&&e.push(r[n].marker)}),e},posFromIndex:function(e){var t,r=this.first;return this.iter(function(n){var i=n.text.length+1;return i>e?(t=e,!0):(e-=i,void++r)}),ge(this,zo(r,t))},indexFromPos:function(e){e=ge(this,e);var t=e.ch;return e.line<this.first||e.ch<0?0:(this.iter(this.first,e.line,function(e){t+=e.text.length+1}),t)},copy:function(e){var t=new Sl(Jn(this,this.first,this.first+this.size),this.modeOption,this.first,this.lineSep);return t.scrollTop=this.scrollTop,t.scrollLeft=this.scrollLeft,t.sel=this.sel,t.extend=!1,e&&(t.history.undoDepth=this.history.undoDepth,t.setHistory(this.getHistory())),t},linkedDoc:function(e){e||(e={});var t=this.first,r=this.first+this.size;null!=e.from&&e.from>t&&(t=e.from),null!=e.to&&e.to<r&&(r=e.to);var n=new Sl(Jn(this,t,r),e.mode||this.modeOption,t,this.lineSep);return e.sharedHist&&(n.history=this.history),(this.linked||(this.linked=[])).push({doc:n,sharedHist:e.sharedHist}),n.linked=[{doc:this,isParent:!0,sharedHist:e.sharedHist}],qr(n,$r(this)),n},unlinkDoc:function(t){if(t instanceof e&&(t=t.doc),this.linked)for(var r=0;r<this.linked.length;++r){var n=this.linked[r];if(n.doc==t){this.linked.splice(r,1),t.unlinkDoc(this),Zr($r(this));break}}if(t.history==this.history){var i=[t.id];$n(t,function(e){i.push(e.id)},!0),t.history=new oi(null),t.history.done=vi(this.history.done,i),t.history.undone=vi(this.history.undone,i)}},iterLinkedDocs:function(e){$n(this,e)},getMode:function(){return this.mode},getEditor:function(){return this.cm},splitLines:function(e){return this.lineSep?e.split(this.lineSep):es(e)},lineSeparator:function(){return this.lineSep||"\n"}}),Sl.prototype.eachLine=Sl.prototype.iter;var Ll="iter insert remove copy getEditor constructor".split(" ");for(var Tl in Sl.prototype)Sl.prototype.hasOwnProperty(Tl)&&Hi(Ll,Tl)<0&&(e.prototype[Tl]=function(e){return function(){return e.apply(this.doc,arguments)}}(Sl.prototype[Tl]));Wi(Sl);var kl=e.e_preventDefault=function(e){e.preventDefault?e.preventDefault():e.returnValue=!1},Ml=e.e_stopPropagation=function(e){e.stopPropagation?e.stopPropagation():e.cancelBubble=!0},Nl=e.e_stop=function(e){kl(e),Ml(e)},Wl=e.on=function(e,t,r){if(e.addEventListener)e.addEventListener(t,r,!1);else if(e.attachEvent)e.attachEvent("on"+t,r);else{var n=e._handlers||(e._handlers={}),i=n[t]||(n[t]=[]);i.push(r)}},Al=[],Ol=e.off=function(e,t,r){if(e.removeEventListener)e.removeEventListener(t,r,!1);else if(e.detachEvent)e.detachEvent("on"+t,r);else for(var n=Si(e,t,!1),i=0;i<n.length;++i)if(n[i]==r){n.splice(i,1);break}},Dl=e.signal=function(e,t){var r=Si(e,t,!0);if(r.length)for(var n=Array.prototype.slice.call(arguments,2),i=0;i<r.length;++i)r[i].apply(null,n)},Hl=null,Pl=30,El=e.Pass={toString:function(){return"CodeMirror.Pass"}},Il={scroll:!1},zl={origin:"*mouse"},Fl={origin:"+move"};Ai.prototype.set=function(e,t){clearTimeout(this.id),this.id=setTimeout(t,e)};var Rl=e.countColumn=function(e,t,r,n,i){null==t&&(t=e.search(/[^\s\u00a0]/),-1==t&&(t=e.length));for(var o=n||0,l=i||0;;){var s=e.indexOf(" ",o);if(0>s||s>=t)return l+(t-o);l+=s-o,l+=r-l%r,o=s+1}},Bl=e.findColumn=function(e,t,r){for(var n=0,i=0;;){var o=e.indexOf(" ",n);-1==o&&(o=e.length);var l=o-n;if(o==e.length||i+l>=t)return n+Math.min(l,t-i);if(i+=o-n,i+=r-i%r,n=o+1,i>=t)return n}},Gl=[""],Ul=function(e){e.select()};No?Ul=function(e){e.selectionStart=0,e.selectionEnd=e.value.length}:bo&&(Ul=function(e){try{e.select()}catch(t){}});var Vl,Kl=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/,jl=e.isWordChar=function(e){return/\w/.test(e)||e>""&&(e.toUpperCase()!=e.toLowerCase()||Kl.test(e))},Xl=/[\u0300-\u036f\u0483-\u0489\u0591-\u05bd\u05bf\u05c1\u05c2\u05c4\u05c5\u05c7\u0610-\u061a\u064b-\u065e\u0670\u06d6-\u06dc\u06de-\u06e4\u06e7\u06e8\u06ea-\u06ed\u0711\u0730-\u074a\u07a6-\u07b0\u07eb-\u07f3\u0816-\u0819\u081b-\u0823\u0825-\u0827\u0829-\u082d\u0900-\u0902\u093c\u0941-\u0948\u094d\u0951-\u0955\u0962\u0963\u0981\u09bc\u09be\u09c1-\u09c4\u09cd\u09d7\u09e2\u09e3\u0a01\u0a02\u0a3c\u0a41\u0a42\u0a47\u0a48\u0a4b-\u0a4d\u0a51\u0a70\u0a71\u0a75\u0a81\u0a82\u0abc\u0ac1-\u0ac5\u0ac7\u0ac8\u0acd\u0ae2\u0ae3\u0b01\u0b3c\u0b3e\u0b3f\u0b41-\u0b44\u0b4d\u0b56\u0b57\u0b62\u0b63\u0b82\u0bbe\u0bc0\u0bcd\u0bd7\u0c3e-\u0c40\u0c46-\u0c48\u0c4a-\u0c4d\u0c55\u0c56\u0c62\u0c63\u0cbc\u0cbf\u0cc2\u0cc6\u0ccc\u0ccd\u0cd5\u0cd6\u0ce2\u0ce3\u0d3e\u0d41-\u0d44\u0d4d\u0d57\u0d62\u0d63\u0dca\u0dcf\u0dd2-\u0dd4\u0dd6\u0ddf\u0e31\u0e34-\u0e3a\u0e47-\u0e4e\u0eb1\u0eb4-\u0eb9\u0ebb\u0ebc\u0ec8-\u0ecd\u0f18\u0f19\u0f35\u0f37\u0f39\u0f71-\u0f7e\u0f80-\u0f84\u0f86\u0f87\u0f90-\u0f97\u0f99-\u0fbc\u0fc6\u102d-\u1030\u1032-\u1037\u1039\u103a\u103d\u103e\u1058\u1059\u105e-\u1060\u1071-\u1074\u1082\u1085\u1086\u108d\u109d\u135f\u1712-\u1714\u1732-\u1734\u1752\u1753\u1772\u1773\u17b7-\u17bd\u17c6\u17c9-\u17d3\u17dd\u180b-\u180d\u18a9\u1920-\u1922\u1927\u1928\u1932\u1939-\u193b\u1a17\u1a18\u1a56\u1a58-\u1a5e\u1a60\u1a62\u1a65-\u1a6c\u1a73-\u1a7c\u1a7f\u1b00-\u1b03\u1b34\u1b36-\u1b3a\u1b3c\u1b42\u1b6b-\u1b73\u1b80\u1b81\u1ba2-\u1ba5\u1ba8\u1ba9\u1c2c-\u1c33\u1c36\u1c37\u1cd0-\u1cd2\u1cd4-\u1ce0\u1ce2-\u1ce8\u1ced\u1dc0-\u1de6\u1dfd-\u1dff\u200c\u200d\u20d0-\u20f0\u2cef-\u2cf1\u2de0-\u2dff\u302a-\u302f\u3099\u309a\ua66f-\ua672\ua67c\ua67d\ua6f0\ua6f1\ua802\ua806\ua80b\ua825\ua826\ua8c4\ua8e0-\ua8f1\ua926-\ua92d\ua947-\ua951\ua980-\ua982\ua9b3\ua9b6-\ua9b9\ua9bc\uaa29-\uaa2e\uaa31\uaa32\uaa35\uaa36\uaa43\uaa4c\uaab0\uaab2-\uaab4\uaab7\uaab8\uaabe\uaabf\uaac1\uabe5\uabe8\uabed\udc00-\udfff\ufb1e\ufe00-\ufe0f\ufe20-\ufe26\uff9e\uff9f]/;Vl=document.createRange?function(e,t,r,n){var i=document.createRange();return i.setEnd(n||e,r),i.setStart(e,t),i}:function(e,t,r){var n=document.body.createTextRange();try{n.moveToElementText(e.parentNode)}catch(i){return n}return n.collapse(!0),n.moveEnd("character",r),n.moveStart("character",t),n};var Yl=e.contains=function(e,t){if(3==t.nodeType&&(t=t.parentNode),e.contains)return e.contains(t);do if(11==t.nodeType&&(t=t.host),t==e)return!0;while(t=t.parentNode)};bo&&11>wo&&(ji=function(){try{return document.activeElement}catch(e){return document.body}});var _l,$l,ql=e.rmClass=function(e,t){var r=e.className,n=Xi(t).exec(r);if(n){var i=r.slice(n.index+n[0].length);e.className=r.slice(0,n.index)+(i?n[1]+i:"")}},Zl=e.addClass=function(e,t){var r=e.className;Xi(t).test(r)||(e.className+=(r?" ":"")+t)},Ql=!1,Jl=function(){if(bo&&9>wo)return!1;var e=Ui("div");return"draggable"in e||"dragDrop"in e}(),es=e.splitLines=3!="\n\nb".split(/\n/).length?function(e){for(var t=0,r=[],n=e.length;n>=t;){var i=e.indexOf("\n",t);-1==i&&(i=e.length);var o=e.slice(t,"\r"==e.charAt(i-1)?i-1:i),l=o.indexOf("\r");-1!=l?(r.push(o.slice(0,l)),t+=l+1):(r.push(o),t=i+1)}return r}:function(e){return e.split(/\r\n?|\n/)},ts=window.getSelection?function(e){try{return e.selectionStart!=e.selectionEnd}catch(t){return!1}}:function(e){try{var t=e.ownerDocument.selection.createRange()}catch(r){}return t&&t.parentElement()==e?0!=t.compareEndPoints("StartToEnd",t):!1},rs=function(){var e=Ui("div");return"oncopy"in e?!0:(e.setAttribute("oncopy","return;"),"function"==typeof e.oncopy)}(),ns=null,is=e.keyNames={3:"Enter",8:"Backspace",9:"Tab",13:"Enter",16:"Shift",17:"Ctrl",18:"Alt",19:"Pause",20:"CapsLock",27:"Esc",32:"Space",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"Left",38:"Up",39:"Right",40:"Down",44:"PrintScrn",45:"Insert",46:"Delete",59:";",61:"=",91:"Mod",92:"Mod",93:"Mod",106:"*",107:"=",109:"-",110:".",111:"/",127:"Delete",173:"-",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'",63232:"Up",63233:"Down",63234:"Left",63235:"Right",63272:"Delete",63273:"Home",63275:"End",63276:"PageUp",63277:"PageDown",63302:"Insert"};!function(){for(var e=0;10>e;e++)is[e+48]=is[e+96]=String(e);for(var e=65;90>=e;e++)is[e]=String.fromCharCode(e);for(var e=1;12>=e;e++)is[e+111]=is[e+63235]="F"+e}();var os,ls=function(){function e(e){return 247>=e?r.charAt(e):e>=1424&&1524>=e?"R":e>=1536&&1773>=e?n.charAt(e-1536):e>=1774&&2220>=e?"r":e>=8192&&8203>=e?"w":8204==e?"b":"L"}function t(e,t,r){this.level=e,this.from=t,this.to=r}var r="bbbbbbbbbtstwsbbbbbbbbbbbbbbssstwNN%%%NNNNNN,N,N1111111111NNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNbbbbbbsbbbbbbbbbbbbbbbbbbbbbbbbbb,N%%%%NNNNLNNNNN%%11NLNNN1LNNNNNLLLLLLLLLLLLLLLLLLLLLLLNLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLN",n="rrrrrrrrrrrr,rNNmmmmmmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmmmmmmmmrrrrrrrnnnnnnnnnn%nnrrrmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmmmmmmmmmmmmmNmmmm",i=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/,o=/[stwN]/,l=/[LRr]/,s=/[Lb1n]/,a=/[1n]/,u="L";return function(r){if(!i.test(r))return!1;for(var n,c=r.length,h=[],f=0;c>f;++f)h.push(n=e(r.charCodeAt(f)));for(var f=0,d=u;c>f;++f){var n=h[f];"m"==n?h[f]=d:d=n}for(var f=0,p=u;c>f;++f){var n=h[f];"1"==n&&"r"==p?h[f]="n":l.test(n)&&(p=n,"r"==n&&(h[f]="R"))}for(var f=1,d=h[0];c-1>f;++f){var n=h[f];"+"==n&&"1"==d&&"1"==h[f+1]?h[f]="1":","!=n||d!=h[f+1]||"1"!=d&&"n"!=d||(h[f]=d),d=n}for(var f=0;c>f;++f){var n=h[f];if(","==n)h[f]="N";else if("%"==n){for(var g=f+1;c>g&&"%"==h[g];++g);for(var v=f&&"!"==h[f-1]||c>g&&"1"==h[g]?"1":"N",m=f;g>m;++m)h[m]=v;f=g-1}}for(var f=0,p=u;c>f;++f){var n=h[f];"L"==p&&"1"==n?h[f]="L":l.test(n)&&(p=n)}for(var f=0;c>f;++f)if(o.test(h[f])){for(var g=f+1;c>g&&o.test(h[g]);++g);for(var y="L"==(f?h[f-1]:u),b="L"==(c>g?h[g]:u),v=y||b?"L":"R",m=f;g>m;++m)h[m]=v;f=g-1}for(var w,x=[],f=0;c>f;)if(s.test(h[f])){var C=f;for(++f;c>f&&s.test(h[f]);++f);x.push(new t(0,C,f))}else{var S=f,L=x.length;for(++f;c>f&&"L"!=h[f];++f);for(var m=S;f>m;)if(a.test(h[m])){m>S&&x.splice(L,0,new t(1,S,m));var T=m;for(++m;f>m&&a.test(h[m]);++m);x.splice(L,0,new t(2,T,m)),S=m}else++m;f>S&&x.splice(L,0,new t(1,S,f))}return 1==x[0].level&&(w=r.match(/^\s+/))&&(x[0].from=w[0].length,x.unshift(new t(0,0,w[0].length))),1==Di(x).level&&(w=r.match(/\s+$/))&&(Di(x).to-=w[0].length,x.push(new t(0,c-w[0].length,c))),2==x[0].level&&x.unshift(new t(1,x[0].to,x[0].to)),x[0].level!=Di(x).level&&x.push(new t(x[0].level,c,c)),x}}();return e.version="5.10.0",e});
|
lib/codemirror/mode/css/css.js
CHANGED
@@ -12,6 +12,7 @@
|
|
12 |
"use strict";
|
13 |
|
14 |
CodeMirror.defineMode("css", function(config, parserConfig) {
|
|
|
15 |
if (!parserConfig.propertyKeywords) parserConfig = CodeMirror.resolveMode("text/css");
|
16 |
|
17 |
var indentUnit = config.indentUnit,
|
@@ -19,13 +20,15 @@ CodeMirror.defineMode("css", function(config, parserConfig) {
|
|
19 |
documentTypes = parserConfig.documentTypes || {},
|
20 |
mediaTypes = parserConfig.mediaTypes || {},
|
21 |
mediaFeatures = parserConfig.mediaFeatures || {},
|
|
|
22 |
propertyKeywords = parserConfig.propertyKeywords || {},
|
23 |
nonStandardPropertyKeywords = parserConfig.nonStandardPropertyKeywords || {},
|
24 |
fontProperties = parserConfig.fontProperties || {},
|
25 |
counterDescriptors = parserConfig.counterDescriptors || {},
|
26 |
colorKeywords = parserConfig.colorKeywords || {},
|
27 |
valueKeywords = parserConfig.valueKeywords || {},
|
28 |
-
allowNested = parserConfig.allowNested
|
|
|
29 |
|
30 |
var type, override;
|
31 |
function ret(style, tp) { type = tp; return style; }
|
@@ -119,13 +122,14 @@ CodeMirror.defineMode("css", function(config, parserConfig) {
|
|
119 |
this.prev = prev;
|
120 |
}
|
121 |
|
122 |
-
function pushContext(state, stream, type) {
|
123 |
-
state.context = new Context(type, stream.indentation() + indentUnit, state.context);
|
124 |
return type;
|
125 |
}
|
126 |
|
127 |
function popContext(state) {
|
128 |
-
|
|
|
129 |
return state.context.type;
|
130 |
}
|
131 |
|
@@ -157,9 +161,13 @@ CodeMirror.defineMode("css", function(config, parserConfig) {
|
|
157 |
return pushContext(state, stream, "block");
|
158 |
} else if (type == "}" && state.context.prev) {
|
159 |
return popContext(state);
|
160 |
-
} else if (/@
|
|
|
|
|
|
|
|
|
161 |
return pushContext(state, stream, "atBlock");
|
162 |
-
} else if (
|
163 |
state.stateArg = type;
|
164 |
return "restricted_atBlock_before";
|
165 |
} else if (/^@(-(moz|ms|o|webkit)-)?keyframes$/.test(type)) {
|
@@ -219,7 +227,7 @@ CodeMirror.defineMode("css", function(config, parserConfig) {
|
|
219 |
if (type == "}" || type == "{") return popAndPass(type, stream, state);
|
220 |
if (type == "(") return pushContext(state, stream, "parens");
|
221 |
|
222 |
-
if (type == "hash" && !/^#([0-9a-fA-f]{3}|[0-9a-fA-f]{6})$/.test(stream.current())) {
|
223 |
override += " error";
|
224 |
} else if (type == "word") {
|
225 |
wordAsValue(stream);
|
@@ -252,33 +260,56 @@ CodeMirror.defineMode("css", function(config, parserConfig) {
|
|
252 |
return pass(type, stream, state);
|
253 |
};
|
254 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
255 |
states.atBlock = function(type, stream, state) {
|
256 |
if (type == "(") return pushContext(state, stream, "atBlock_parens");
|
257 |
-
if (type == "}") return popAndPass(type, stream, state);
|
258 |
if (type == "{") return popContext(state) && pushContext(state, stream, allowNested ? "block" : "top");
|
259 |
|
|
|
|
|
260 |
if (type == "word") {
|
261 |
var word = stream.current().toLowerCase();
|
262 |
if (word == "only" || word == "not" || word == "and" || word == "or")
|
263 |
override = "keyword";
|
264 |
-
else if (documentTypes.hasOwnProperty(word))
|
265 |
-
override = "tag";
|
266 |
else if (mediaTypes.hasOwnProperty(word))
|
267 |
override = "attribute";
|
268 |
else if (mediaFeatures.hasOwnProperty(word))
|
269 |
override = "property";
|
|
|
|
|
270 |
else if (propertyKeywords.hasOwnProperty(word))
|
271 |
override = "property";
|
272 |
else if (nonStandardPropertyKeywords.hasOwnProperty(word))
|
273 |
override = "string-2";
|
274 |
else if (valueKeywords.hasOwnProperty(word))
|
275 |
override = "atom";
|
|
|
|
|
276 |
else
|
277 |
override = "error";
|
278 |
}
|
279 |
return state.context.type;
|
280 |
};
|
281 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
282 |
states.atBlock_parens = function(type, stream, state) {
|
283 |
if (type == ")") return popContext(state);
|
284 |
if (type == "{" || type == "}") return popAndPass(type, stream, state, 2);
|
@@ -329,16 +360,16 @@ CodeMirror.defineMode("css", function(config, parserConfig) {
|
|
329 |
if (type == "}") return popContext(state);
|
330 |
if (type == "{" || type == ";") return popAndPass(type, stream, state);
|
331 |
if (type == "word") override = "variable";
|
332 |
-
else if (type != "variable") override = "error";
|
333 |
return "interpolation";
|
334 |
};
|
335 |
|
336 |
return {
|
337 |
startState: function(base) {
|
338 |
return {tokenize: null,
|
339 |
-
state: "top",
|
340 |
stateArg: null,
|
341 |
-
context: new Context("top", base || 0, null)};
|
342 |
},
|
343 |
|
344 |
token: function(stream, state) {
|
@@ -357,12 +388,18 @@ CodeMirror.defineMode("css", function(config, parserConfig) {
|
|
357 |
var cx = state.context, ch = textAfter && textAfter.charAt(0);
|
358 |
var indent = cx.indent;
|
359 |
if (cx.type == "prop" && (ch == "}" || ch == ")")) cx = cx.prev;
|
360 |
-
if (cx.prev
|
361 |
-
|
362 |
-
|
363 |
-
|
364 |
-
|
365 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
366 |
}
|
367 |
return indent;
|
368 |
},
|
@@ -399,9 +436,16 @@ CodeMirror.defineMode("css", function(config, parserConfig) {
|
|
399 |
"min-device-aspect-ratio", "max-device-aspect-ratio", "color", "min-color",
|
400 |
"max-color", "color-index", "min-color-index", "max-color-index",
|
401 |
"monochrome", "min-monochrome", "max-monochrome", "resolution",
|
402 |
-
"min-resolution", "max-resolution", "scan", "grid"
|
|
|
|
|
403 |
], mediaFeatures = keySet(mediaFeatures_);
|
404 |
|
|
|
|
|
|
|
|
|
|
|
405 |
var propertyKeywords_ = [
|
406 |
"align-content", "align-items", "align-self", "alignment-adjust",
|
407 |
"alignment-baseline", "anchor-point", "animation", "animation-delay",
|
@@ -553,7 +597,7 @@ CodeMirror.defineMode("css", function(config, parserConfig) {
|
|
553 |
"capitalize", "caps-lock-indicator", "caption", "captiontext", "caret",
|
554 |
"cell", "center", "checkbox", "circle", "cjk-decimal", "cjk-earthly-branch",
|
555 |
"cjk-heavenly-stem", "cjk-ideographic", "clear", "clip", "close-quote",
|
556 |
-
"col-resize", "collapse", "column", "compact", "condensed", "contain", "content",
|
557 |
"content-box", "context-menu", "continuous", "copy", "counter", "counters", "cover", "crop",
|
558 |
"cross", "crosshair", "currentcolor", "cursive", "cyclic", "dashed", "decimal",
|
559 |
"decimal-leading-zero", "default", "default-button", "destination-atop",
|
@@ -569,7 +613,7 @@ CodeMirror.defineMode("css", function(config, parserConfig) {
|
|
569 |
"ethiopic-halehame-sid-et", "ethiopic-halehame-so-et",
|
570 |
"ethiopic-halehame-ti-er", "ethiopic-halehame-ti-et", "ethiopic-halehame-tig",
|
571 |
"ethiopic-numeric", "ew-resize", "expanded", "extends", "extra-condensed",
|
572 |
-
"extra-expanded", "fantasy", "fast", "fill", "fixed", "flat", "flex", "footnotes",
|
573 |
"forwards", "from", "geometricPrecision", "georgian", "graytext", "groove",
|
574 |
"gujarati", "gurmukhi", "hand", "hangul", "hangul-consonant", "hebrew",
|
575 |
"help", "hidden", "hide", "higher", "highlight", "highlighttext",
|
@@ -606,7 +650,7 @@ CodeMirror.defineMode("css", function(config, parserConfig) {
|
|
606 |
"relative", "repeat", "repeating-linear-gradient",
|
607 |
"repeating-radial-gradient", "repeat-x", "repeat-y", "reset", "reverse",
|
608 |
"rgb", "rgba", "ridge", "right", "rotate", "rotate3d", "rotateX", "rotateY",
|
609 |
-
"rotateZ", "round", "row-resize", "rtl", "run-in", "running",
|
610 |
"s-resize", "sans-serif", "scale", "scale3d", "scaleX", "scaleY", "scaleZ",
|
611 |
"scroll", "scrollbar", "se-resize", "searchfield",
|
612 |
"searchfield-cancel-button", "searchfield-decoration",
|
@@ -616,7 +660,7 @@ CodeMirror.defineMode("css", function(config, parserConfig) {
|
|
616 |
"skew", "skewX", "skewY", "skip-white-space", "slide", "slider-horizontal",
|
617 |
"slider-vertical", "sliderthumb-horizontal", "sliderthumb-vertical", "slow",
|
618 |
"small", "small-caps", "small-caption", "smaller", "solid", "somali",
|
619 |
-
"source-atop", "source-in", "source-out", "source-over", "space", "spell-out", "square",
|
620 |
"square-button", "start", "static", "status-bar", "stretch", "stroke", "sub",
|
621 |
"subpixel-antialiased", "super", "sw-resize", "symbolic", "symbols", "table",
|
622 |
"table-caption", "table-cell", "table-column", "table-column-group",
|
@@ -633,12 +677,13 @@ CodeMirror.defineMode("css", function(config, parserConfig) {
|
|
633 |
"upper-latin", "upper-norwegian", "upper-roman", "uppercase", "urdu", "url",
|
634 |
"var", "vertical", "vertical-text", "visible", "visibleFill", "visiblePainted",
|
635 |
"visibleStroke", "visual", "w-resize", "wait", "wave", "wider",
|
636 |
-
"window", "windowframe", "windowtext", "words", "x-large", "x-small", "xor",
|
637 |
"xx-large", "xx-small"
|
638 |
], valueKeywords = keySet(valueKeywords_);
|
639 |
|
640 |
-
var allWords = documentTypes_.concat(mediaTypes_).concat(mediaFeatures_).concat(
|
641 |
-
.concat(
|
|
|
642 |
CodeMirror.registerHelper("hintWords", "css", allWords);
|
643 |
|
644 |
function tokenCComment(stream, state) {
|
@@ -653,20 +698,11 @@ CodeMirror.defineMode("css", function(config, parserConfig) {
|
|
653 |
return ["comment", "comment"];
|
654 |
}
|
655 |
|
656 |
-
function tokenSGMLComment(stream, state) {
|
657 |
-
if (stream.skipTo("-->")) {
|
658 |
-
stream.match("-->");
|
659 |
-
state.tokenize = null;
|
660 |
-
} else {
|
661 |
-
stream.skipToEnd();
|
662 |
-
}
|
663 |
-
return ["comment", "comment"];
|
664 |
-
}
|
665 |
-
|
666 |
CodeMirror.defineMIME("text/css", {
|
667 |
documentTypes: documentTypes,
|
668 |
mediaTypes: mediaTypes,
|
669 |
mediaFeatures: mediaFeatures,
|
|
|
670 |
propertyKeywords: propertyKeywords,
|
671 |
nonStandardPropertyKeywords: nonStandardPropertyKeywords,
|
672 |
fontProperties: fontProperties,
|
@@ -674,11 +710,6 @@ CodeMirror.defineMode("css", function(config, parserConfig) {
|
|
674 |
colorKeywords: colorKeywords,
|
675 |
valueKeywords: valueKeywords,
|
676 |
tokenHooks: {
|
677 |
-
"<": function(stream, state) {
|
678 |
-
if (!stream.match("!--")) return false;
|
679 |
-
state.tokenize = tokenSGMLComment;
|
680 |
-
return tokenSGMLComment(stream, state);
|
681 |
-
},
|
682 |
"/": function(stream, state) {
|
683 |
if (!stream.eat("*")) return false;
|
684 |
state.tokenize = tokenCComment;
|
@@ -691,6 +722,7 @@ CodeMirror.defineMode("css", function(config, parserConfig) {
|
|
691 |
CodeMirror.defineMIME("text/x-scss", {
|
692 |
mediaTypes: mediaTypes,
|
693 |
mediaFeatures: mediaFeatures,
|
|
|
694 |
propertyKeywords: propertyKeywords,
|
695 |
nonStandardPropertyKeywords: nonStandardPropertyKeywords,
|
696 |
colorKeywords: colorKeywords,
|
@@ -732,6 +764,7 @@ CodeMirror.defineMode("css", function(config, parserConfig) {
|
|
732 |
CodeMirror.defineMIME("text/x-less", {
|
733 |
mediaTypes: mediaTypes,
|
734 |
mediaFeatures: mediaFeatures,
|
|
|
735 |
propertyKeywords: propertyKeywords,
|
736 |
nonStandardPropertyKeywords: nonStandardPropertyKeywords,
|
737 |
colorKeywords: colorKeywords,
|
@@ -766,4 +799,26 @@ CodeMirror.defineMode("css", function(config, parserConfig) {
|
|
766 |
helperType: "less"
|
767 |
});
|
768 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
769 |
});
|
12 |
"use strict";
|
13 |
|
14 |
CodeMirror.defineMode("css", function(config, parserConfig) {
|
15 |
+
var inline = parserConfig.inline
|
16 |
if (!parserConfig.propertyKeywords) parserConfig = CodeMirror.resolveMode("text/css");
|
17 |
|
18 |
var indentUnit = config.indentUnit,
|
20 |
documentTypes = parserConfig.documentTypes || {},
|
21 |
mediaTypes = parserConfig.mediaTypes || {},
|
22 |
mediaFeatures = parserConfig.mediaFeatures || {},
|
23 |
+
mediaValueKeywords = parserConfig.mediaValueKeywords || {},
|
24 |
propertyKeywords = parserConfig.propertyKeywords || {},
|
25 |
nonStandardPropertyKeywords = parserConfig.nonStandardPropertyKeywords || {},
|
26 |
fontProperties = parserConfig.fontProperties || {},
|
27 |
counterDescriptors = parserConfig.counterDescriptors || {},
|
28 |
colorKeywords = parserConfig.colorKeywords || {},
|
29 |
valueKeywords = parserConfig.valueKeywords || {},
|
30 |
+
allowNested = parserConfig.allowNested,
|
31 |
+
supportsAtComponent = parserConfig.supportsAtComponent === true;
|
32 |
|
33 |
var type, override;
|
34 |
function ret(style, tp) { type = tp; return style; }
|
122 |
this.prev = prev;
|
123 |
}
|
124 |
|
125 |
+
function pushContext(state, stream, type, indent) {
|
126 |
+
state.context = new Context(type, stream.indentation() + (indent === false ? 0 : indentUnit), state.context);
|
127 |
return type;
|
128 |
}
|
129 |
|
130 |
function popContext(state) {
|
131 |
+
if (state.context.prev)
|
132 |
+
state.context = state.context.prev;
|
133 |
return state.context.type;
|
134 |
}
|
135 |
|
161 |
return pushContext(state, stream, "block");
|
162 |
} else if (type == "}" && state.context.prev) {
|
163 |
return popContext(state);
|
164 |
+
} else if (supportsAtComponent && /@component/.test(type)) {
|
165 |
+
return pushContext(state, stream, "atComponentBlock");
|
166 |
+
} else if (/^@(-moz-)?document$/.test(type)) {
|
167 |
+
return pushContext(state, stream, "documentTypes");
|
168 |
+
} else if (/^@(media|supports|(-moz-)?document|import)$/.test(type)) {
|
169 |
return pushContext(state, stream, "atBlock");
|
170 |
+
} else if (/^@(font-face|counter-style)/.test(type)) {
|
171 |
state.stateArg = type;
|
172 |
return "restricted_atBlock_before";
|
173 |
} else if (/^@(-(moz|ms|o|webkit)-)?keyframes$/.test(type)) {
|
227 |
if (type == "}" || type == "{") return popAndPass(type, stream, state);
|
228 |
if (type == "(") return pushContext(state, stream, "parens");
|
229 |
|
230 |
+
if (type == "hash" && !/^#([0-9a-fA-f]{3,4}|[0-9a-fA-f]{6}|[0-9a-fA-f]{8})$/.test(stream.current())) {
|
231 |
override += " error";
|
232 |
} else if (type == "word") {
|
233 |
wordAsValue(stream);
|
260 |
return pass(type, stream, state);
|
261 |
};
|
262 |
|
263 |
+
states.documentTypes = function(type, stream, state) {
|
264 |
+
if (type == "word" && documentTypes.hasOwnProperty(stream.current())) {
|
265 |
+
override = "tag";
|
266 |
+
return state.context.type;
|
267 |
+
} else {
|
268 |
+
return states.atBlock(type, stream, state);
|
269 |
+
}
|
270 |
+
};
|
271 |
+
|
272 |
states.atBlock = function(type, stream, state) {
|
273 |
if (type == "(") return pushContext(state, stream, "atBlock_parens");
|
274 |
+
if (type == "}" || type == ";") return popAndPass(type, stream, state);
|
275 |
if (type == "{") return popContext(state) && pushContext(state, stream, allowNested ? "block" : "top");
|
276 |
|
277 |
+
if (type == "interpolation") return pushContext(state, stream, "interpolation");
|
278 |
+
|
279 |
if (type == "word") {
|
280 |
var word = stream.current().toLowerCase();
|
281 |
if (word == "only" || word == "not" || word == "and" || word == "or")
|
282 |
override = "keyword";
|
|
|
|
|
283 |
else if (mediaTypes.hasOwnProperty(word))
|
284 |
override = "attribute";
|
285 |
else if (mediaFeatures.hasOwnProperty(word))
|
286 |
override = "property";
|
287 |
+
else if (mediaValueKeywords.hasOwnProperty(word))
|
288 |
+
override = "keyword";
|
289 |
else if (propertyKeywords.hasOwnProperty(word))
|
290 |
override = "property";
|
291 |
else if (nonStandardPropertyKeywords.hasOwnProperty(word))
|
292 |
override = "string-2";
|
293 |
else if (valueKeywords.hasOwnProperty(word))
|
294 |
override = "atom";
|
295 |
+
else if (colorKeywords.hasOwnProperty(word))
|
296 |
+
override = "keyword";
|
297 |
else
|
298 |
override = "error";
|
299 |
}
|
300 |
return state.context.type;
|
301 |
};
|
302 |
|
303 |
+
states.atComponentBlock = function(type, stream, state) {
|
304 |
+
if (type == "}")
|
305 |
+
return popAndPass(type, stream, state);
|
306 |
+
if (type == "{")
|
307 |
+
return popContext(state) && pushContext(state, stream, allowNested ? "block" : "top", false);
|
308 |
+
if (type == "word")
|
309 |
+
override = "error";
|
310 |
+
return state.context.type;
|
311 |
+
};
|
312 |
+
|
313 |
states.atBlock_parens = function(type, stream, state) {
|
314 |
if (type == ")") return popContext(state);
|
315 |
if (type == "{" || type == "}") return popAndPass(type, stream, state, 2);
|
360 |
if (type == "}") return popContext(state);
|
361 |
if (type == "{" || type == ";") return popAndPass(type, stream, state);
|
362 |
if (type == "word") override = "variable";
|
363 |
+
else if (type != "variable" && type != "(" && type != ")") override = "error";
|
364 |
return "interpolation";
|
365 |
};
|
366 |
|
367 |
return {
|
368 |
startState: function(base) {
|
369 |
return {tokenize: null,
|
370 |
+
state: inline ? "block" : "top",
|
371 |
stateArg: null,
|
372 |
+
context: new Context(inline ? "block" : "top", base || 0, null)};
|
373 |
},
|
374 |
|
375 |
token: function(stream, state) {
|
388 |
var cx = state.context, ch = textAfter && textAfter.charAt(0);
|
389 |
var indent = cx.indent;
|
390 |
if (cx.type == "prop" && (ch == "}" || ch == ")")) cx = cx.prev;
|
391 |
+
if (cx.prev) {
|
392 |
+
if (ch == "}" && (cx.type == "block" || cx.type == "top" ||
|
393 |
+
cx.type == "interpolation" || cx.type == "restricted_atBlock")) {
|
394 |
+
// Resume indentation from parent context.
|
395 |
+
cx = cx.prev;
|
396 |
+
indent = cx.indent;
|
397 |
+
} else if (ch == ")" && (cx.type == "parens" || cx.type == "atBlock_parens") ||
|
398 |
+
ch == "{" && (cx.type == "at" || cx.type == "atBlock")) {
|
399 |
+
// Dedent relative to current context.
|
400 |
+
indent = Math.max(0, cx.indent - indentUnit);
|
401 |
+
cx = cx.prev;
|
402 |
+
}
|
403 |
}
|
404 |
return indent;
|
405 |
},
|
436 |
"min-device-aspect-ratio", "max-device-aspect-ratio", "color", "min-color",
|
437 |
"max-color", "color-index", "min-color-index", "max-color-index",
|
438 |
"monochrome", "min-monochrome", "max-monochrome", "resolution",
|
439 |
+
"min-resolution", "max-resolution", "scan", "grid", "orientation",
|
440 |
+
"device-pixel-ratio", "min-device-pixel-ratio", "max-device-pixel-ratio",
|
441 |
+
"pointer", "any-pointer", "hover", "any-hover"
|
442 |
], mediaFeatures = keySet(mediaFeatures_);
|
443 |
|
444 |
+
var mediaValueKeywords_ = [
|
445 |
+
"landscape", "portrait", "none", "coarse", "fine", "on-demand", "hover",
|
446 |
+
"interlace", "progressive"
|
447 |
+
], mediaValueKeywords = keySet(mediaValueKeywords_);
|
448 |
+
|
449 |
var propertyKeywords_ = [
|
450 |
"align-content", "align-items", "align-self", "alignment-adjust",
|
451 |
"alignment-baseline", "anchor-point", "animation", "animation-delay",
|
597 |
"capitalize", "caps-lock-indicator", "caption", "captiontext", "caret",
|
598 |
"cell", "center", "checkbox", "circle", "cjk-decimal", "cjk-earthly-branch",
|
599 |
"cjk-heavenly-stem", "cjk-ideographic", "clear", "clip", "close-quote",
|
600 |
+
"col-resize", "collapse", "column", "column-reverse", "compact", "condensed", "contain", "content",
|
601 |
"content-box", "context-menu", "continuous", "copy", "counter", "counters", "cover", "crop",
|
602 |
"cross", "crosshair", "currentcolor", "cursive", "cyclic", "dashed", "decimal",
|
603 |
"decimal-leading-zero", "default", "default-button", "destination-atop",
|
613 |
"ethiopic-halehame-sid-et", "ethiopic-halehame-so-et",
|
614 |
"ethiopic-halehame-ti-er", "ethiopic-halehame-ti-et", "ethiopic-halehame-tig",
|
615 |
"ethiopic-numeric", "ew-resize", "expanded", "extends", "extra-condensed",
|
616 |
+
"extra-expanded", "fantasy", "fast", "fill", "fixed", "flat", "flex", "flex-end", "flex-start", "footnotes",
|
617 |
"forwards", "from", "geometricPrecision", "georgian", "graytext", "groove",
|
618 |
"gujarati", "gurmukhi", "hand", "hangul", "hangul-consonant", "hebrew",
|
619 |
"help", "hidden", "hide", "higher", "highlight", "highlighttext",
|
650 |
"relative", "repeat", "repeating-linear-gradient",
|
651 |
"repeating-radial-gradient", "repeat-x", "repeat-y", "reset", "reverse",
|
652 |
"rgb", "rgba", "ridge", "right", "rotate", "rotate3d", "rotateX", "rotateY",
|
653 |
+
"rotateZ", "round", "row", "row-resize", "row-reverse", "rtl", "run-in", "running",
|
654 |
"s-resize", "sans-serif", "scale", "scale3d", "scaleX", "scaleY", "scaleZ",
|
655 |
"scroll", "scrollbar", "se-resize", "searchfield",
|
656 |
"searchfield-cancel-button", "searchfield-decoration",
|
660 |
"skew", "skewX", "skewY", "skip-white-space", "slide", "slider-horizontal",
|
661 |
"slider-vertical", "sliderthumb-horizontal", "sliderthumb-vertical", "slow",
|
662 |
"small", "small-caps", "small-caption", "smaller", "solid", "somali",
|
663 |
+
"source-atop", "source-in", "source-out", "source-over", "space", "space-around", "space-between", "spell-out", "square",
|
664 |
"square-button", "start", "static", "status-bar", "stretch", "stroke", "sub",
|
665 |
"subpixel-antialiased", "super", "sw-resize", "symbolic", "symbols", "table",
|
666 |
"table-caption", "table-cell", "table-column", "table-column-group",
|
677 |
"upper-latin", "upper-norwegian", "upper-roman", "uppercase", "urdu", "url",
|
678 |
"var", "vertical", "vertical-text", "visible", "visibleFill", "visiblePainted",
|
679 |
"visibleStroke", "visual", "w-resize", "wait", "wave", "wider",
|
680 |
+
"window", "windowframe", "windowtext", "words", "wrap", "wrap-reverse", "x-large", "x-small", "xor",
|
681 |
"xx-large", "xx-small"
|
682 |
], valueKeywords = keySet(valueKeywords_);
|
683 |
|
684 |
+
var allWords = documentTypes_.concat(mediaTypes_).concat(mediaFeatures_).concat(mediaValueKeywords_)
|
685 |
+
.concat(propertyKeywords_).concat(nonStandardPropertyKeywords_).concat(colorKeywords_)
|
686 |
+
.concat(valueKeywords_);
|
687 |
CodeMirror.registerHelper("hintWords", "css", allWords);
|
688 |
|
689 |
function tokenCComment(stream, state) {
|
698 |
return ["comment", "comment"];
|
699 |
}
|
700 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
701 |
CodeMirror.defineMIME("text/css", {
|
702 |
documentTypes: documentTypes,
|
703 |
mediaTypes: mediaTypes,
|
704 |
mediaFeatures: mediaFeatures,
|
705 |
+
mediaValueKeywords: mediaValueKeywords,
|
706 |
propertyKeywords: propertyKeywords,
|
707 |
nonStandardPropertyKeywords: nonStandardPropertyKeywords,
|
708 |
fontProperties: fontProperties,
|
710 |
colorKeywords: colorKeywords,
|
711 |
valueKeywords: valueKeywords,
|
712 |
tokenHooks: {
|
|
|
|
|
|
|
|
|
|
|
713 |
"/": function(stream, state) {
|
714 |
if (!stream.eat("*")) return false;
|
715 |
state.tokenize = tokenCComment;
|
722 |
CodeMirror.defineMIME("text/x-scss", {
|
723 |
mediaTypes: mediaTypes,
|
724 |
mediaFeatures: mediaFeatures,
|
725 |
+
mediaValueKeywords: mediaValueKeywords,
|
726 |
propertyKeywords: propertyKeywords,
|
727 |
nonStandardPropertyKeywords: nonStandardPropertyKeywords,
|
728 |
colorKeywords: colorKeywords,
|
764 |
CodeMirror.defineMIME("text/x-less", {
|
765 |
mediaTypes: mediaTypes,
|
766 |
mediaFeatures: mediaFeatures,
|
767 |
+
mediaValueKeywords: mediaValueKeywords,
|
768 |
propertyKeywords: propertyKeywords,
|
769 |
nonStandardPropertyKeywords: nonStandardPropertyKeywords,
|
770 |
colorKeywords: colorKeywords,
|
799 |
helperType: "less"
|
800 |
});
|
801 |
|
802 |
+
CodeMirror.defineMIME("text/x-gss", {
|
803 |
+
documentTypes: documentTypes,
|
804 |
+
mediaTypes: mediaTypes,
|
805 |
+
mediaFeatures: mediaFeatures,
|
806 |
+
propertyKeywords: propertyKeywords,
|
807 |
+
nonStandardPropertyKeywords: nonStandardPropertyKeywords,
|
808 |
+
fontProperties: fontProperties,
|
809 |
+
counterDescriptors: counterDescriptors,
|
810 |
+
colorKeywords: colorKeywords,
|
811 |
+
valueKeywords: valueKeywords,
|
812 |
+
supportsAtComponent: true,
|
813 |
+
tokenHooks: {
|
814 |
+
"/": function(stream, state) {
|
815 |
+
if (!stream.eat("*")) return false;
|
816 |
+
state.tokenize = tokenCComment;
|
817 |
+
return tokenCComment(stream, state);
|
818 |
+
}
|
819 |
+
},
|
820 |
+
name: "css",
|
821 |
+
helperType: "gss"
|
822 |
+
});
|
823 |
+
|
824 |
});
|
lib/codemirror/mode/css/css.min.js
CHANGED
@@ -1 +1 @@
|
|
1 |
-
!function(e){"object"==typeof exports&&"object"==typeof module?e(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],e):e(CodeMirror)}(function(e){"use strict";function t(e){for(var t={},r=0;r<e.length;++r)t[e[r]]=!0;return t}function r(e,t){for(var r,o=!1;null!=(r=e.next());){if(o&&"/"==r){t.tokenize=null;break}o="*"==r}return["comment","comment"]}function o(e,t){return e.skipTo("-->")?(e.match("-->"),t.tokenize=null):e.skipToEnd(),["comment","comment"]}e.defineMode("css",function(t,r){function o(e,t){return m=t,e}function a(e,t){var r=e.next();if(g[r]){var a=g[r](e,t);if(a!==!1)return a}return"@"==r?(e.eatWhile(/[\w\\\-]/),o("def",e.current())):"="==r||("~"==r||"|"==r)&&e.eat("=")?o(null,"compare"):'"'==r||"'"==r?(t.tokenize=i(r),t.tokenize(e,t)):"#"==r?(e.eatWhile(/[\w\\\-]/),o("atom","hash")):"!"==r?(e.match(/^\s*\w*/),o("keyword","important")):/\d/.test(r)||"."==r&&e.eat(/\d/)?(e.eatWhile(/[\w.%]/),o("number","unit")):"-"!==r?/[,+>*\/]/.test(r)?o(null,"select-op"):"."==r&&e.match(/^-?[_a-z][_a-z0-9-]*/i)?o("qualifier","qualifier"):/[:;{}\[\]\(\)]/.test(r)?o(null,r):"u"==r&&e.match(/rl(-prefix)?\(/)||"d"==r&&e.match("omain(")||"r"==r&&e.match("egexp(")?(e.backUp(1),t.tokenize=n,o("property","word")):/[\w\\\-]/.test(r)?(e.eatWhile(/[\w\\\-]/),o("property","word")):o(null,null):/[\d.]/.test(e.peek())?(e.eatWhile(/[\w.%]/),o("number","unit")):e.match(/^-[\w\\\-]+/)?(e.eatWhile(/[\w\\\-]/),e.match(/^\s*:/,!1)?o("variable-2","variable-definition"):o("variable-2","variable")):e.match(/^\w+-/)?o("meta","meta"):void 0}function i(e){return function(t,r){for(var a,i=!1;null!=(a=t.next());){if(a==e&&!i){")"==e&&t.backUp(1);break}i=!i&&"\\"==a}return(a==e||!i&&")"!=e)&&(r.tokenize=null),o("string","string")}}function n(e,t){return e.next(),e.match(/\s*[\"\')]/,!1)?t.tokenize=null:t.tokenize=i(")"),o(null,"(")}function l(e,t,r){this.type=e,this.indent=t,this.prev=r}function s(e,t,r){return e.context=new l(r,t.indentation()+b,e.context),r}function c(e){return e.context=e.context.prev,e.context.type}function d(e,t,r){return K[r.context.type](e,t,r)}function u(e,t,r,o){for(var a=o||1;a>0;a--)r.context=r.context.prev;return d(e,t,r)}function p(e){var t=e.current().toLowerCase();h=j.hasOwnProperty(t)?"atom":q.hasOwnProperty(t)?"keyword":"variable"}r.propertyKeywords||(r=e.resolveMode("text/css"));var m,h,b=t.indentUnit,g=r.tokenHooks,f=r.documentTypes||{},k=r.mediaTypes||{},w=r.mediaFeatures||{},y=r.propertyKeywords||{},v=r.nonStandardPropertyKeywords||{},x=r.fontProperties||{},z=r.counterDescriptors||{},q=r.colorKeywords||{},j=r.valueKeywords||{},P=r.allowNested,K={};return K.top=function(e,t,r){if("{"==e)return s(r,t,"block");if("}"==e&&r.context.prev)return c(r);if(/@(media|supports|(-moz-)?document)/.test(e))return s(r,t,"atBlock");if(/@(font-face|counter-style)/.test(e))return r.stateArg=e,"restricted_atBlock_before";if(/^@(-(moz|ms|o|webkit)-)?keyframes$/.test(e))return"keyframes";if(e&&"@"==e.charAt(0))return s(r,t,"at");if("hash"==e)h="builtin";else if("word"==e)h="tag";else{if("variable-definition"==e)return"maybeprop";if("interpolation"==e)return s(r,t,"interpolation");if(":"==e)return"pseudo";if(P&&"("==e)return s(r,t,"parens")}return r.context.type},K.block=function(e,t,r){if("word"==e){var o=t.current().toLowerCase();return y.hasOwnProperty(o)?(h="property","maybeprop"):v.hasOwnProperty(o)?(h="string-2","maybeprop"):P?(h=t.match(/^\s*:(?:\s|$)/,!1)?"property":"tag","block"):(h+=" error","maybeprop")}return"meta"==e?"block":P||"hash"!=e&&"qualifier"!=e?K.top(e,t,r):(h="error","block")},K.maybeprop=function(e,t,r){return":"==e?s(r,t,"prop"):d(e,t,r)},K.prop=function(e,t,r){if(";"==e)return c(r);if("{"==e&&P)return s(r,t,"propBlock");if("}"==e||"{"==e)return u(e,t,r);if("("==e)return s(r,t,"parens");if("hash"!=e||/^#([0-9a-fA-f]{3}|[0-9a-fA-f]{6})$/.test(t.current())){if("word"==e)p(t);else if("interpolation"==e)return s(r,t,"interpolation")}else h+=" error";return"prop"},K.propBlock=function(e,t,r){return"}"==e?c(r):"word"==e?(h="property","maybeprop"):r.context.type},K.parens=function(e,t,r){return"{"==e||"}"==e?u(e,t,r):")"==e?c(r):"("==e?s(r,t,"parens"):"interpolation"==e?s(r,t,"interpolation"):("word"==e&&p(t),"parens")},K.pseudo=function(e,t,r){return"word"==e?(h="variable-3",r.context.type):d(e,t,r)},K.atBlock=function(e,t,r){if("("==e)return s(r,t,"atBlock_parens");if("}"==e)return u(e,t,r);if("{"==e)return c(r)&&s(r,t,P?"block":"top");if("word"==e){var o=t.current().toLowerCase();h="only"==o||"not"==o||"and"==o||"or"==o?"keyword":f.hasOwnProperty(o)?"tag":k.hasOwnProperty(o)?"attribute":w.hasOwnProperty(o)?"property":y.hasOwnProperty(o)?"property":v.hasOwnProperty(o)?"string-2":j.hasOwnProperty(o)?"atom":"error"}return r.context.type},K.atBlock_parens=function(e,t,r){return")"==e?c(r):"{"==e||"}"==e?u(e,t,r,2):K.atBlock(e,t,r)},K.restricted_atBlock_before=function(e,t,r){return"{"==e?s(r,t,"restricted_atBlock"):"word"==e&&"@counter-style"==r.stateArg?(h="variable","restricted_atBlock_before"):d(e,t,r)},K.restricted_atBlock=function(e,t,r){return"}"==e?(r.stateArg=null,c(r)):"word"==e?(h="@font-face"==r.stateArg&&!x.hasOwnProperty(t.current().toLowerCase())||"@counter-style"==r.stateArg&&!z.hasOwnProperty(t.current().toLowerCase())?"error":"property","maybeprop"):"restricted_atBlock"},K.keyframes=function(e,t,r){return"word"==e?(h="variable","keyframes"):"{"==e?s(r,t,"top"):d(e,t,r)},K.at=function(e,t,r){return";"==e?c(r):"{"==e||"}"==e?u(e,t,r):("word"==e?h="tag":"hash"==e&&(h="builtin"),"at")},K.interpolation=function(e,t,r){return"}"==e?c(r):"{"==e||";"==e?u(e,t,r):("word"==e?h="variable":"variable"!=e&&(h="error"),"interpolation")},{startState:function(e){return{tokenize:null,state:"top",stateArg:null,context:new l("top",e||0,null)}},token:function(e,t){if(!t.tokenize&&e.eatSpace())return null;var r=(t.tokenize||a)(e,t);return r&&"object"==typeof r&&(m=r[1],r=r[0]),h=r,t.state=K[t.state](m,e,t),h},indent:function(e,t){var r=e.context,o=t&&t.charAt(0),a=r.indent;return"prop"!=r.type||"}"!=o&&")"!=o||(r=r.prev),!r.prev||("}"!=o||"block"!=r.type&&"top"!=r.type&&"interpolation"!=r.type&&"restricted_atBlock"!=r.type)&&(")"!=o||"parens"!=r.type&&"atBlock_parens"!=r.type)&&("{"!=o||"at"!=r.type&&"atBlock"!=r.type)||(a=r.indent-b,r=r.prev),a},electricChars:"}",blockCommentStart:"/*",blockCommentEnd:"*/",fold:"brace"}});var a=["domain","regexp","url","url-prefix"],i=t(a),n=["all","aural","braille","handheld","print","projection","screen","tty","tv","embossed"],l=t(n),s=["width","min-width","max-width","height","min-height","max-height","device-width","min-device-width","max-device-width","device-height","min-device-height","max-device-height","aspect-ratio","min-aspect-ratio","max-aspect-ratio","device-aspect-ratio","min-device-aspect-ratio","max-device-aspect-ratio","color","min-color","max-color","color-index","min-color-index","max-color-index","monochrome","min-monochrome","max-monochrome","resolution","min-resolution","max-resolution","scan","grid"],c=t(s),d=["align-content","align-items","align-self","alignment-adjust","alignment-baseline","anchor-point","animation","animation-delay","animation-direction","animation-duration","animation-fill-mode","animation-iteration-count","animation-name","animation-play-state","animation-timing-function","appearance","azimuth","backface-visibility","background","background-attachment","background-clip","background-color","background-image","background-origin","background-position","background-repeat","background-size","baseline-shift","binding","bleed","bookmark-label","bookmark-level","bookmark-state","bookmark-target","border","border-bottom","border-bottom-color","border-bottom-left-radius","border-bottom-right-radius","border-bottom-style","border-bottom-width","border-collapse","border-color","border-image","border-image-outset","border-image-repeat","border-image-slice","border-image-source","border-image-width","border-left","border-left-color","border-left-style","border-left-width","border-radius","border-right","border-right-color","border-right-style","border-right-width","border-spacing","border-style","border-top","border-top-color","border-top-left-radius","border-top-right-radius","border-top-style","border-top-width","border-width","bottom","box-decoration-break","box-shadow","box-sizing","break-after","break-before","break-inside","caption-side","clear","clip","color","color-profile","column-count","column-fill","column-gap","column-rule","column-rule-color","column-rule-style","column-rule-width","column-span","column-width","columns","content","counter-increment","counter-reset","crop","cue","cue-after","cue-before","cursor","direction","display","dominant-baseline","drop-initial-after-adjust","drop-initial-after-align","drop-initial-before-adjust","drop-initial-before-align","drop-initial-size","drop-initial-value","elevation","empty-cells","fit","fit-position","flex","flex-basis","flex-direction","flex-flow","flex-grow","flex-shrink","flex-wrap","float","float-offset","flow-from","flow-into","font","font-feature-settings","font-family","font-kerning","font-language-override","font-size","font-size-adjust","font-stretch","font-style","font-synthesis","font-variant","font-variant-alternates","font-variant-caps","font-variant-east-asian","font-variant-ligatures","font-variant-numeric","font-variant-position","font-weight","grid","grid-area","grid-auto-columns","grid-auto-flow","grid-auto-position","grid-auto-rows","grid-column","grid-column-end","grid-column-start","grid-row","grid-row-end","grid-row-start","grid-template","grid-template-areas","grid-template-columns","grid-template-rows","hanging-punctuation","height","hyphens","icon","image-orientation","image-rendering","image-resolution","inline-box-align","justify-content","left","letter-spacing","line-break","line-height","line-stacking","line-stacking-ruby","line-stacking-shift","line-stacking-strategy","list-style","list-style-image","list-style-position","list-style-type","margin","margin-bottom","margin-left","margin-right","margin-top","marker-offset","marks","marquee-direction","marquee-loop","marquee-play-count","marquee-speed","marquee-style","max-height","max-width","min-height","min-width","move-to","nav-down","nav-index","nav-left","nav-right","nav-up","object-fit","object-position","opacity","order","orphans","outline","outline-color","outline-offset","outline-style","outline-width","overflow","overflow-style","overflow-wrap","overflow-x","overflow-y","padding","padding-bottom","padding-left","padding-right","padding-top","page","page-break-after","page-break-before","page-break-inside","page-policy","pause","pause-after","pause-before","perspective","perspective-origin","pitch","pitch-range","play-during","position","presentation-level","punctuation-trim","quotes","region-break-after","region-break-before","region-break-inside","region-fragment","rendering-intent","resize","rest","rest-after","rest-before","richness","right","rotation","rotation-point","ruby-align","ruby-overhang","ruby-position","ruby-span","shape-image-threshold","shape-inside","shape-margin","shape-outside","size","speak","speak-as","speak-header","speak-numeral","speak-punctuation","speech-rate","stress","string-set","tab-size","table-layout","target","target-name","target-new","target-position","text-align","text-align-last","text-decoration","text-decoration-color","text-decoration-line","text-decoration-skip","text-decoration-style","text-emphasis","text-emphasis-color","text-emphasis-position","text-emphasis-style","text-height","text-indent","text-justify","text-outline","text-overflow","text-shadow","text-size-adjust","text-space-collapse","text-transform","text-underline-position","text-wrap","top","transform","transform-origin","transform-style","transition","transition-delay","transition-duration","transition-property","transition-timing-function","unicode-bidi","vertical-align","visibility","voice-balance","voice-duration","voice-family","voice-pitch","voice-range","voice-rate","voice-stress","voice-volume","volume","white-space","widows","width","word-break","word-spacing","word-wrap","z-index","clip-path","clip-rule","mask","enable-background","filter","flood-color","flood-opacity","lighting-color","stop-color","stop-opacity","pointer-events","color-interpolation","color-interpolation-filters","color-rendering","fill","fill-opacity","fill-rule","image-rendering","marker","marker-end","marker-mid","marker-start","shape-rendering","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","text-rendering","baseline-shift","dominant-baseline","glyph-orientation-horizontal","glyph-orientation-vertical","text-anchor","writing-mode"],u=t(d),p=["scrollbar-arrow-color","scrollbar-base-color","scrollbar-dark-shadow-color","scrollbar-face-color","scrollbar-highlight-color","scrollbar-shadow-color","scrollbar-3d-light-color","scrollbar-track-color","shape-inside","searchfield-cancel-button","searchfield-decoration","searchfield-results-button","searchfield-results-decoration","zoom"],m=t(p),h=["font-family","src","unicode-range","font-variant","font-feature-settings","font-stretch","font-weight","font-style"],b=t(h),g=["additive-symbols","fallback","negative","pad","prefix","range","speak-as","suffix","symbols","system"],f=t(g),k=["aliceblue","antiquewhite","aqua","aquamarine","azure","beige","bisque","black","blanchedalmond","blue","blueviolet","brown","burlywood","cadetblue","chartreuse","chocolate","coral","cornflowerblue","cornsilk","crimson","cyan","darkblue","darkcyan","darkgoldenrod","darkgray","darkgreen","darkkhaki","darkmagenta","darkolivegreen","darkorange","darkorchid","darkred","darksalmon","darkseagreen","darkslateblue","darkslategray","darkturquoise","darkviolet","deeppink","deepskyblue","dimgray","dodgerblue","firebrick","floralwhite","forestgreen","fuchsia","gainsboro","ghostwhite","gold","goldenrod","gray","grey","green","greenyellow","honeydew","hotpink","indianred","indigo","ivory","khaki","lavender","lavenderblush","lawngreen","lemonchiffon","lightblue","lightcoral","lightcyan","lightgoldenrodyellow","lightgray","lightgreen","lightpink","lightsalmon","lightseagreen","lightskyblue","lightslategray","lightsteelblue","lightyellow","lime","limegreen","linen","magenta","maroon","mediumaquamarine","mediumblue","mediumorchid","mediumpurple","mediumseagreen","mediumslateblue","mediumspringgreen","mediumturquoise","mediumvioletred","midnightblue","mintcream","mistyrose","moccasin","navajowhite","navy","oldlace","olive","olivedrab","orange","orangered","orchid","palegoldenrod","palegreen","paleturquoise","palevioletred","papayawhip","peachpuff","peru","pink","plum","powderblue","purple","rebeccapurple","red","rosybrown","royalblue","saddlebrown","salmon","sandybrown","seagreen","seashell","sienna","silver","skyblue","slateblue","slategray","snow","springgreen","steelblue","tan","teal","thistle","tomato","turquoise","violet","wheat","white","whitesmoke","yellow","yellowgreen"],w=t(k),y=["above","absolute","activeborder","additive","activecaption","afar","after-white-space","ahead","alias","all","all-scroll","alphabetic","alternate","always","amharic","amharic-abegede","antialiased","appworkspace","arabic-indic","armenian","asterisks","attr","auto","avoid","avoid-column","avoid-page","avoid-region","background","backwards","baseline","below","bidi-override","binary","bengali","blink","block","block-axis","bold","bolder","border","border-box","both","bottom","break","break-all","break-word","bullets","button","button-bevel","buttonface","buttonhighlight","buttonshadow","buttontext","calc","cambodian","capitalize","caps-lock-indicator","caption","captiontext","caret","cell","center","checkbox","circle","cjk-decimal","cjk-earthly-branch","cjk-heavenly-stem","cjk-ideographic","clear","clip","close-quote","col-resize","collapse","column","compact","condensed","contain","content","content-box","context-menu","continuous","copy","counter","counters","cover","crop","cross","crosshair","currentcolor","cursive","cyclic","dashed","decimal","decimal-leading-zero","default","default-button","destination-atop","destination-in","destination-out","destination-over","devanagari","disc","discard","disclosure-closed","disclosure-open","document","dot-dash","dot-dot-dash","dotted","double","down","e-resize","ease","ease-in","ease-in-out","ease-out","element","ellipse","ellipsis","embed","end","ethiopic","ethiopic-abegede","ethiopic-abegede-am-et","ethiopic-abegede-gez","ethiopic-abegede-ti-er","ethiopic-abegede-ti-et","ethiopic-halehame-aa-er","ethiopic-halehame-aa-et","ethiopic-halehame-am-et","ethiopic-halehame-gez","ethiopic-halehame-om-et","ethiopic-halehame-sid-et","ethiopic-halehame-so-et","ethiopic-halehame-ti-er","ethiopic-halehame-ti-et","ethiopic-halehame-tig","ethiopic-numeric","ew-resize","expanded","extends","extra-condensed","extra-expanded","fantasy","fast","fill","fixed","flat","flex","footnotes","forwards","from","geometricPrecision","georgian","graytext","groove","gujarati","gurmukhi","hand","hangul","hangul-consonant","hebrew","help","hidden","hide","higher","highlight","highlighttext","hiragana","hiragana-iroha","horizontal","hsl","hsla","icon","ignore","inactiveborder","inactivecaption","inactivecaptiontext","infinite","infobackground","infotext","inherit","initial","inline","inline-axis","inline-block","inline-flex","inline-table","inset","inside","intrinsic","invert","italic","japanese-formal","japanese-informal","justify","kannada","katakana","katakana-iroha","keep-all","khmer","korean-hangul-formal","korean-hanja-formal","korean-hanja-informal","landscape","lao","large","larger","left","level","lighter","line-through","linear","linear-gradient","lines","list-item","listbox","listitem","local","logical","loud","lower","lower-alpha","lower-armenian","lower-greek","lower-hexadecimal","lower-latin","lower-norwegian","lower-roman","lowercase","ltr","malayalam","match","matrix","matrix3d","media-controls-background","media-current-time-display","media-fullscreen-button","media-mute-button","media-play-button","media-return-to-realtime-button","media-rewind-button","media-seek-back-button","media-seek-forward-button","media-slider","media-sliderthumb","media-time-remaining-display","media-volume-slider","media-volume-slider-container","media-volume-sliderthumb","medium","menu","menulist","menulist-button","menulist-text","menulist-textfield","menutext","message-box","middle","min-intrinsic","mix","mongolian","monospace","move","multiple","myanmar","n-resize","narrower","ne-resize","nesw-resize","no-close-quote","no-drop","no-open-quote","no-repeat","none","normal","not-allowed","nowrap","ns-resize","numbers","numeric","nw-resize","nwse-resize","oblique","octal","open-quote","optimizeLegibility","optimizeSpeed","oriya","oromo","outset","outside","outside-shape","overlay","overline","padding","padding-box","painted","page","paused","persian","perspective","plus-darker","plus-lighter","pointer","polygon","portrait","pre","pre-line","pre-wrap","preserve-3d","progress","push-button","radial-gradient","radio","read-only","read-write","read-write-plaintext-only","rectangle","region","relative","repeat","repeating-linear-gradient","repeating-radial-gradient","repeat-x","repeat-y","reset","reverse","rgb","rgba","ridge","right","rotate","rotate3d","rotateX","rotateY","rotateZ","round","row-resize","rtl","run-in","running","s-resize","sans-serif","scale","scale3d","scaleX","scaleY","scaleZ","scroll","scrollbar","se-resize","searchfield","searchfield-cancel-button","searchfield-decoration","searchfield-results-button","searchfield-results-decoration","semi-condensed","semi-expanded","separate","serif","show","sidama","simp-chinese-formal","simp-chinese-informal","single","skew","skewX","skewY","skip-white-space","slide","slider-horizontal","slider-vertical","sliderthumb-horizontal","sliderthumb-vertical","slow","small","small-caps","small-caption","smaller","solid","somali","source-atop","source-in","source-out","source-over","space","spell-out","square","square-button","start","static","status-bar","stretch","stroke","sub","subpixel-antialiased","super","sw-resize","symbolic","symbols","table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row","table-row-group","tamil","telugu","text","text-bottom","text-top","textarea","textfield","thai","thick","thin","threeddarkshadow","threedface","threedhighlight","threedlightshadow","threedshadow","tibetan","tigre","tigrinya-er","tigrinya-er-abegede","tigrinya-et","tigrinya-et-abegede","to","top","trad-chinese-formal","trad-chinese-informal","translate","translate3d","translateX","translateY","translateZ","transparent","ultra-condensed","ultra-expanded","underline","up","upper-alpha","upper-armenian","upper-greek","upper-hexadecimal","upper-latin","upper-norwegian","upper-roman","uppercase","urdu","url","var","vertical","vertical-text","visible","visibleFill","visiblePainted","visibleStroke","visual","w-resize","wait","wave","wider","window","windowframe","windowtext","words","x-large","x-small","xor","xx-large","xx-small"],v=t(y),x=a.concat(n).concat(s).concat(d).concat(p).concat(k).concat(y);e.registerHelper("hintWords","css",x),e.defineMIME("text/css",{documentTypes:i,mediaTypes:l,mediaFeatures:c,propertyKeywords:u,nonStandardPropertyKeywords:m,fontProperties:b,counterDescriptors:f,colorKeywords:w,valueKeywords:v,tokenHooks:{"<":function(e,t){return e.match("!--")?(t.tokenize=o,o(e,t)):!1},"/":function(e,t){return e.eat("*")?(t.tokenize=r,r(e,t)):!1}},name:"css"}),e.defineMIME("text/x-scss",{mediaTypes:l,mediaFeatures:c,propertyKeywords:u,nonStandardPropertyKeywords:m,colorKeywords:w,valueKeywords:v,fontProperties:b,allowNested:!0,tokenHooks:{"/":function(e,t){return e.eat("/")?(e.skipToEnd(),["comment","comment"]):e.eat("*")?(t.tokenize=r,r(e,t)):["operator","operator"]},":":function(e){return e.match(/\s*\{/)?[null,"{"]:!1},$:function(e){return e.match(/^[\w-]+/),e.match(/^\s*:/,!1)?["variable-2","variable-definition"]:["variable-2","variable"]},"#":function(e){return e.eat("{")?[null,"interpolation"]:!1}},name:"css",helperType:"scss"}),e.defineMIME("text/x-less",{mediaTypes:l,mediaFeatures:c,propertyKeywords:u,nonStandardPropertyKeywords:m,colorKeywords:w,valueKeywords:v,fontProperties:b,allowNested:!0,tokenHooks:{"/":function(e,t){return e.eat("/")?(e.skipToEnd(),["comment","comment"]):e.eat("*")?(t.tokenize=r,r(e,t)):["operator","operator"]},"@":function(e){return e.eat("{")?[null,"interpolation"]:e.match(/^(charset|document|font-face|import|(-(moz|ms|o|webkit)-)?keyframes|media|namespace|page|supports)\b/,!1)?!1:(e.eatWhile(/[\w\\\-]/),e.match(/^\s*:/,!1)?["variable-2","variable-definition"]:["variable-2","variable"])},"&":function(){return["atom","atom"]}},name:"css",helperType:"less"})});
|
1 |
+
!function(e){"object"==typeof exports&&"object"==typeof module?e(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],e):e(CodeMirror)}(function(e){"use strict";function t(e){for(var t={},r=0;r<e.length;++r)t[e[r]]=!0;return t}function r(e,t){for(var r,o=!1;null!=(r=e.next());){if(o&&"/"==r){t.tokenize=null;break}o="*"==r}return["comment","comment"]}e.defineMode("css",function(t,r){function o(e,t){return h=t,e}function a(e,t){var r=e.next();if(f[r]){var a=f[r](e,t);if(a!==!1)return a}return"@"==r?(e.eatWhile(/[\w\\\-]/),o("def",e.current())):"="==r||("~"==r||"|"==r)&&e.eat("=")?o(null,"compare"):'"'==r||"'"==r?(t.tokenize=i(r),t.tokenize(e,t)):"#"==r?(e.eatWhile(/[\w\\\-]/),o("atom","hash")):"!"==r?(e.match(/^\s*\w*/),o("keyword","important")):/\d/.test(r)||"."==r&&e.eat(/\d/)?(e.eatWhile(/[\w.%]/),o("number","unit")):"-"!==r?/[,+>*\/]/.test(r)?o(null,"select-op"):"."==r&&e.match(/^-?[_a-z][_a-z0-9-]*/i)?o("qualifier","qualifier"):/[:;{}\[\]\(\)]/.test(r)?o(null,r):"u"==r&&e.match(/rl(-prefix)?\(/)||"d"==r&&e.match("omain(")||"r"==r&&e.match("egexp(")?(e.backUp(1),t.tokenize=n,o("property","word")):/[\w\\\-]/.test(r)?(e.eatWhile(/[\w\\\-]/),o("property","word")):o(null,null):/[\d.]/.test(e.peek())?(e.eatWhile(/[\w.%]/),o("number","unit")):e.match(/^-[\w\\\-]+/)?(e.eatWhile(/[\w\\\-]/),e.match(/^\s*:/,!1)?o("variable-2","variable-definition"):o("variable-2","variable")):e.match(/^\w+-/)?o("meta","meta"):void 0}function i(e){return function(t,r){for(var a,i=!1;null!=(a=t.next());){if(a==e&&!i){")"==e&&t.backUp(1);break}i=!i&&"\\"==a}return(a==e||!i&&")"!=e)&&(r.tokenize=null),o("string","string")}}function n(e,t){return e.next(),e.match(/\s*[\"\')]/,!1)?t.tokenize=null:t.tokenize=i(")"),o(null,"(")}function l(e,t,r){this.type=e,this.indent=t,this.prev=r}function s(e,t,r,o){return e.context=new l(r,t.indentation()+(o===!1?0:g),e.context),r}function c(e){return e.context.prev&&(e.context=e.context.prev),e.context.type}function d(e,t,r){return _[r.context.type](e,t,r)}function p(e,t,r,o){for(var a=o||1;a>0;a--)r.context=r.context.prev;return d(e,t,r)}function u(e){var t=e.current().toLowerCase();b=K.hasOwnProperty(t)?"atom":j.hasOwnProperty(t)?"keyword":"variable"}var m=r.inline;r.propertyKeywords||(r=e.resolveMode("text/css"));var h,b,g=t.indentUnit,f=r.tokenHooks,y=r.documentTypes||{},w=r.mediaTypes||{},k=r.mediaFeatures||{},v=r.mediaValueKeywords||{},x=r.propertyKeywords||{},z=r.nonStandardPropertyKeywords||{},q=r.fontProperties||{},P=r.counterDescriptors||{},j=r.colorKeywords||{},K=r.valueKeywords||{},B=r.allowNested,T=r.supportsAtComponent===!0,_={};return _.top=function(e,t,r){if("{"==e)return s(r,t,"block");if("}"==e&&r.context.prev)return c(r);if(T&&/@component/.test(e))return s(r,t,"atComponentBlock");if(/^@(-moz-)?document$/.test(e))return s(r,t,"documentTypes");if(/^@(media|supports|(-moz-)?document|import)$/.test(e))return s(r,t,"atBlock");if(/^@(font-face|counter-style)/.test(e))return r.stateArg=e,"restricted_atBlock_before";if(/^@(-(moz|ms|o|webkit)-)?keyframes$/.test(e))return"keyframes";if(e&&"@"==e.charAt(0))return s(r,t,"at");if("hash"==e)b="builtin";else if("word"==e)b="tag";else{if("variable-definition"==e)return"maybeprop";if("interpolation"==e)return s(r,t,"interpolation");if(":"==e)return"pseudo";if(B&&"("==e)return s(r,t,"parens")}return r.context.type},_.block=function(e,t,r){if("word"==e){var o=t.current().toLowerCase();return x.hasOwnProperty(o)?(b="property","maybeprop"):z.hasOwnProperty(o)?(b="string-2","maybeprop"):B?(b=t.match(/^\s*:(?:\s|$)/,!1)?"property":"tag","block"):(b+=" error","maybeprop")}return"meta"==e?"block":B||"hash"!=e&&"qualifier"!=e?_.top(e,t,r):(b="error","block")},_.maybeprop=function(e,t,r){return":"==e?s(r,t,"prop"):d(e,t,r)},_.prop=function(e,t,r){if(";"==e)return c(r);if("{"==e&&B)return s(r,t,"propBlock");if("}"==e||"{"==e)return p(e,t,r);if("("==e)return s(r,t,"parens");if("hash"!=e||/^#([0-9a-fA-f]{3,4}|[0-9a-fA-f]{6}|[0-9a-fA-f]{8})$/.test(t.current())){if("word"==e)u(t);else if("interpolation"==e)return s(r,t,"interpolation")}else b+=" error";return"prop"},_.propBlock=function(e,t,r){return"}"==e?c(r):"word"==e?(b="property","maybeprop"):r.context.type},_.parens=function(e,t,r){return"{"==e||"}"==e?p(e,t,r):")"==e?c(r):"("==e?s(r,t,"parens"):"interpolation"==e?s(r,t,"interpolation"):("word"==e&&u(t),"parens")},_.pseudo=function(e,t,r){return"word"==e?(b="variable-3",r.context.type):d(e,t,r)},_.documentTypes=function(e,t,r){return"word"==e&&y.hasOwnProperty(t.current())?(b="tag",r.context.type):_.atBlock(e,t,r)},_.atBlock=function(e,t,r){if("("==e)return s(r,t,"atBlock_parens");if("}"==e||";"==e)return p(e,t,r);if("{"==e)return c(r)&&s(r,t,B?"block":"top");if("interpolation"==e)return s(r,t,"interpolation");if("word"==e){var o=t.current().toLowerCase();b="only"==o||"not"==o||"and"==o||"or"==o?"keyword":w.hasOwnProperty(o)?"attribute":k.hasOwnProperty(o)?"property":v.hasOwnProperty(o)?"keyword":x.hasOwnProperty(o)?"property":z.hasOwnProperty(o)?"string-2":K.hasOwnProperty(o)?"atom":j.hasOwnProperty(o)?"keyword":"error"}return r.context.type},_.atComponentBlock=function(e,t,r){return"}"==e?p(e,t,r):"{"==e?c(r)&&s(r,t,B?"block":"top",!1):("word"==e&&(b="error"),r.context.type)},_.atBlock_parens=function(e,t,r){return")"==e?c(r):"{"==e||"}"==e?p(e,t,r,2):_.atBlock(e,t,r)},_.restricted_atBlock_before=function(e,t,r){return"{"==e?s(r,t,"restricted_atBlock"):"word"==e&&"@counter-style"==r.stateArg?(b="variable","restricted_atBlock_before"):d(e,t,r)},_.restricted_atBlock=function(e,t,r){return"}"==e?(r.stateArg=null,c(r)):"word"==e?(b="@font-face"==r.stateArg&&!q.hasOwnProperty(t.current().toLowerCase())||"@counter-style"==r.stateArg&&!P.hasOwnProperty(t.current().toLowerCase())?"error":"property","maybeprop"):"restricted_atBlock"},_.keyframes=function(e,t,r){return"word"==e?(b="variable","keyframes"):"{"==e?s(r,t,"top"):d(e,t,r)},_.at=function(e,t,r){return";"==e?c(r):"{"==e||"}"==e?p(e,t,r):("word"==e?b="tag":"hash"==e&&(b="builtin"),"at")},_.interpolation=function(e,t,r){return"}"==e?c(r):"{"==e||";"==e?p(e,t,r):("word"==e?b="variable":"variable"!=e&&"("!=e&&")"!=e&&(b="error"),"interpolation")},{startState:function(e){return{tokenize:null,state:m?"block":"top",stateArg:null,context:new l(m?"block":"top",e||0,null)}},token:function(e,t){if(!t.tokenize&&e.eatSpace())return null;var r=(t.tokenize||a)(e,t);return r&&"object"==typeof r&&(h=r[1],r=r[0]),b=r,t.state=_[t.state](h,e,t),b},indent:function(e,t){var r=e.context,o=t&&t.charAt(0),a=r.indent;return"prop"!=r.type||"}"!=o&&")"!=o||(r=r.prev),r.prev&&("}"!=o||"block"!=r.type&&"top"!=r.type&&"interpolation"!=r.type&&"restricted_atBlock"!=r.type?(")"==o&&("parens"==r.type||"atBlock_parens"==r.type)||"{"==o&&("at"==r.type||"atBlock"==r.type))&&(a=Math.max(0,r.indent-g),r=r.prev):(r=r.prev,a=r.indent)),a},electricChars:"}",blockCommentStart:"/*",blockCommentEnd:"*/",fold:"brace"}});var o=["domain","regexp","url","url-prefix"],a=t(o),i=["all","aural","braille","handheld","print","projection","screen","tty","tv","embossed"],n=t(i),l=["width","min-width","max-width","height","min-height","max-height","device-width","min-device-width","max-device-width","device-height","min-device-height","max-device-height","aspect-ratio","min-aspect-ratio","max-aspect-ratio","device-aspect-ratio","min-device-aspect-ratio","max-device-aspect-ratio","color","min-color","max-color","color-index","min-color-index","max-color-index","monochrome","min-monochrome","max-monochrome","resolution","min-resolution","max-resolution","scan","grid","orientation","device-pixel-ratio","min-device-pixel-ratio","max-device-pixel-ratio","pointer","any-pointer","hover","any-hover"],s=t(l),c=["landscape","portrait","none","coarse","fine","on-demand","hover","interlace","progressive"],d=t(c),p=["align-content","align-items","align-self","alignment-adjust","alignment-baseline","anchor-point","animation","animation-delay","animation-direction","animation-duration","animation-fill-mode","animation-iteration-count","animation-name","animation-play-state","animation-timing-function","appearance","azimuth","backface-visibility","background","background-attachment","background-clip","background-color","background-image","background-origin","background-position","background-repeat","background-size","baseline-shift","binding","bleed","bookmark-label","bookmark-level","bookmark-state","bookmark-target","border","border-bottom","border-bottom-color","border-bottom-left-radius","border-bottom-right-radius","border-bottom-style","border-bottom-width","border-collapse","border-color","border-image","border-image-outset","border-image-repeat","border-image-slice","border-image-source","border-image-width","border-left","border-left-color","border-left-style","border-left-width","border-radius","border-right","border-right-color","border-right-style","border-right-width","border-spacing","border-style","border-top","border-top-color","border-top-left-radius","border-top-right-radius","border-top-style","border-top-width","border-width","bottom","box-decoration-break","box-shadow","box-sizing","break-after","break-before","break-inside","caption-side","clear","clip","color","color-profile","column-count","column-fill","column-gap","column-rule","column-rule-color","column-rule-style","column-rule-width","column-span","column-width","columns","content","counter-increment","counter-reset","crop","cue","cue-after","cue-before","cursor","direction","display","dominant-baseline","drop-initial-after-adjust","drop-initial-after-align","drop-initial-before-adjust","drop-initial-before-align","drop-initial-size","drop-initial-value","elevation","empty-cells","fit","fit-position","flex","flex-basis","flex-direction","flex-flow","flex-grow","flex-shrink","flex-wrap","float","float-offset","flow-from","flow-into","font","font-feature-settings","font-family","font-kerning","font-language-override","font-size","font-size-adjust","font-stretch","font-style","font-synthesis","font-variant","font-variant-alternates","font-variant-caps","font-variant-east-asian","font-variant-ligatures","font-variant-numeric","font-variant-position","font-weight","grid","grid-area","grid-auto-columns","grid-auto-flow","grid-auto-position","grid-auto-rows","grid-column","grid-column-end","grid-column-start","grid-row","grid-row-end","grid-row-start","grid-template","grid-template-areas","grid-template-columns","grid-template-rows","hanging-punctuation","height","hyphens","icon","image-orientation","image-rendering","image-resolution","inline-box-align","justify-content","left","letter-spacing","line-break","line-height","line-stacking","line-stacking-ruby","line-stacking-shift","line-stacking-strategy","list-style","list-style-image","list-style-position","list-style-type","margin","margin-bottom","margin-left","margin-right","margin-top","marker-offset","marks","marquee-direction","marquee-loop","marquee-play-count","marquee-speed","marquee-style","max-height","max-width","min-height","min-width","move-to","nav-down","nav-index","nav-left","nav-right","nav-up","object-fit","object-position","opacity","order","orphans","outline","outline-color","outline-offset","outline-style","outline-width","overflow","overflow-style","overflow-wrap","overflow-x","overflow-y","padding","padding-bottom","padding-left","padding-right","padding-top","page","page-break-after","page-break-before","page-break-inside","page-policy","pause","pause-after","pause-before","perspective","perspective-origin","pitch","pitch-range","play-during","position","presentation-level","punctuation-trim","quotes","region-break-after","region-break-before","region-break-inside","region-fragment","rendering-intent","resize","rest","rest-after","rest-before","richness","right","rotation","rotation-point","ruby-align","ruby-overhang","ruby-position","ruby-span","shape-image-threshold","shape-inside","shape-margin","shape-outside","size","speak","speak-as","speak-header","speak-numeral","speak-punctuation","speech-rate","stress","string-set","tab-size","table-layout","target","target-name","target-new","target-position","text-align","text-align-last","text-decoration","text-decoration-color","text-decoration-line","text-decoration-skip","text-decoration-style","text-emphasis","text-emphasis-color","text-emphasis-position","text-emphasis-style","text-height","text-indent","text-justify","text-outline","text-overflow","text-shadow","text-size-adjust","text-space-collapse","text-transform","text-underline-position","text-wrap","top","transform","transform-origin","transform-style","transition","transition-delay","transition-duration","transition-property","transition-timing-function","unicode-bidi","vertical-align","visibility","voice-balance","voice-duration","voice-family","voice-pitch","voice-range","voice-rate","voice-stress","voice-volume","volume","white-space","widows","width","word-break","word-spacing","word-wrap","z-index","clip-path","clip-rule","mask","enable-background","filter","flood-color","flood-opacity","lighting-color","stop-color","stop-opacity","pointer-events","color-interpolation","color-interpolation-filters","color-rendering","fill","fill-opacity","fill-rule","image-rendering","marker","marker-end","marker-mid","marker-start","shape-rendering","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","text-rendering","baseline-shift","dominant-baseline","glyph-orientation-horizontal","glyph-orientation-vertical","text-anchor","writing-mode"],u=t(p),m=["scrollbar-arrow-color","scrollbar-base-color","scrollbar-dark-shadow-color","scrollbar-face-color","scrollbar-highlight-color","scrollbar-shadow-color","scrollbar-3d-light-color","scrollbar-track-color","shape-inside","searchfield-cancel-button","searchfield-decoration","searchfield-results-button","searchfield-results-decoration","zoom"],h=t(m),b=["font-family","src","unicode-range","font-variant","font-feature-settings","font-stretch","font-weight","font-style"],g=t(b),f=["additive-symbols","fallback","negative","pad","prefix","range","speak-as","suffix","symbols","system"],y=t(f),w=["aliceblue","antiquewhite","aqua","aquamarine","azure","beige","bisque","black","blanchedalmond","blue","blueviolet","brown","burlywood","cadetblue","chartreuse","chocolate","coral","cornflowerblue","cornsilk","crimson","cyan","darkblue","darkcyan","darkgoldenrod","darkgray","darkgreen","darkkhaki","darkmagenta","darkolivegreen","darkorange","darkorchid","darkred","darksalmon","darkseagreen","darkslateblue","darkslategray","darkturquoise","darkviolet","deeppink","deepskyblue","dimgray","dodgerblue","firebrick","floralwhite","forestgreen","fuchsia","gainsboro","ghostwhite","gold","goldenrod","gray","grey","green","greenyellow","honeydew","hotpink","indianred","indigo","ivory","khaki","lavender","lavenderblush","lawngreen","lemonchiffon","lightblue","lightcoral","lightcyan","lightgoldenrodyellow","lightgray","lightgreen","lightpink","lightsalmon","lightseagreen","lightskyblue","lightslategray","lightsteelblue","lightyellow","lime","limegreen","linen","magenta","maroon","mediumaquamarine","mediumblue","mediumorchid","mediumpurple","mediumseagreen","mediumslateblue","mediumspringgreen","mediumturquoise","mediumvioletred","midnightblue","mintcream","mistyrose","moccasin","navajowhite","navy","oldlace","olive","olivedrab","orange","orangered","orchid","palegoldenrod","palegreen","paleturquoise","palevioletred","papayawhip","peachpuff","peru","pink","plum","powderblue","purple","rebeccapurple","red","rosybrown","royalblue","saddlebrown","salmon","sandybrown","seagreen","seashell","sienna","silver","skyblue","slateblue","slategray","snow","springgreen","steelblue","tan","teal","thistle","tomato","turquoise","violet","wheat","white","whitesmoke","yellow","yellowgreen"],k=t(w),v=["above","absolute","activeborder","additive","activecaption","afar","after-white-space","ahead","alias","all","all-scroll","alphabetic","alternate","always","amharic","amharic-abegede","antialiased","appworkspace","arabic-indic","armenian","asterisks","attr","auto","avoid","avoid-column","avoid-page","avoid-region","background","backwards","baseline","below","bidi-override","binary","bengali","blink","block","block-axis","bold","bolder","border","border-box","both","bottom","break","break-all","break-word","bullets","button","button-bevel","buttonface","buttonhighlight","buttonshadow","buttontext","calc","cambodian","capitalize","caps-lock-indicator","caption","captiontext","caret","cell","center","checkbox","circle","cjk-decimal","cjk-earthly-branch","cjk-heavenly-stem","cjk-ideographic","clear","clip","close-quote","col-resize","collapse","column","column-reverse","compact","condensed","contain","content","content-box","context-menu","continuous","copy","counter","counters","cover","crop","cross","crosshair","currentcolor","cursive","cyclic","dashed","decimal","decimal-leading-zero","default","default-button","destination-atop","destination-in","destination-out","destination-over","devanagari","disc","discard","disclosure-closed","disclosure-open","document","dot-dash","dot-dot-dash","dotted","double","down","e-resize","ease","ease-in","ease-in-out","ease-out","element","ellipse","ellipsis","embed","end","ethiopic","ethiopic-abegede","ethiopic-abegede-am-et","ethiopic-abegede-gez","ethiopic-abegede-ti-er","ethiopic-abegede-ti-et","ethiopic-halehame-aa-er","ethiopic-halehame-aa-et","ethiopic-halehame-am-et","ethiopic-halehame-gez","ethiopic-halehame-om-et","ethiopic-halehame-sid-et","ethiopic-halehame-so-et","ethiopic-halehame-ti-er","ethiopic-halehame-ti-et","ethiopic-halehame-tig","ethiopic-numeric","ew-resize","expanded","extends","extra-condensed","extra-expanded","fantasy","fast","fill","fixed","flat","flex","flex-end","flex-start","footnotes","forwards","from","geometricPrecision","georgian","graytext","groove","gujarati","gurmukhi","hand","hangul","hangul-consonant","hebrew","help","hidden","hide","higher","highlight","highlighttext","hiragana","hiragana-iroha","horizontal","hsl","hsla","icon","ignore","inactiveborder","inactivecaption","inactivecaptiontext","infinite","infobackground","infotext","inherit","initial","inline","inline-axis","inline-block","inline-flex","inline-table","inset","inside","intrinsic","invert","italic","japanese-formal","japanese-informal","justify","kannada","katakana","katakana-iroha","keep-all","khmer","korean-hangul-formal","korean-hanja-formal","korean-hanja-informal","landscape","lao","large","larger","left","level","lighter","line-through","linear","linear-gradient","lines","list-item","listbox","listitem","local","logical","loud","lower","lower-alpha","lower-armenian","lower-greek","lower-hexadecimal","lower-latin","lower-norwegian","lower-roman","lowercase","ltr","malayalam","match","matrix","matrix3d","media-controls-background","media-current-time-display","media-fullscreen-button","media-mute-button","media-play-button","media-return-to-realtime-button","media-rewind-button","media-seek-back-button","media-seek-forward-button","media-slider","media-sliderthumb","media-time-remaining-display","media-volume-slider","media-volume-slider-container","media-volume-sliderthumb","medium","menu","menulist","menulist-button","menulist-text","menulist-textfield","menutext","message-box","middle","min-intrinsic","mix","mongolian","monospace","move","multiple","myanmar","n-resize","narrower","ne-resize","nesw-resize","no-close-quote","no-drop","no-open-quote","no-repeat","none","normal","not-allowed","nowrap","ns-resize","numbers","numeric","nw-resize","nwse-resize","oblique","octal","open-quote","optimizeLegibility","optimizeSpeed","oriya","oromo","outset","outside","outside-shape","overlay","overline","padding","padding-box","painted","page","paused","persian","perspective","plus-darker","plus-lighter","pointer","polygon","portrait","pre","pre-line","pre-wrap","preserve-3d","progress","push-button","radial-gradient","radio","read-only","read-write","read-write-plaintext-only","rectangle","region","relative","repeat","repeating-linear-gradient","repeating-radial-gradient","repeat-x","repeat-y","reset","reverse","rgb","rgba","ridge","right","rotate","rotate3d","rotateX","rotateY","rotateZ","round","row","row-resize","row-reverse","rtl","run-in","running","s-resize","sans-serif","scale","scale3d","scaleX","scaleY","scaleZ","scroll","scrollbar","se-resize","searchfield","searchfield-cancel-button","searchfield-decoration","searchfield-results-button","searchfield-results-decoration","semi-condensed","semi-expanded","separate","serif","show","sidama","simp-chinese-formal","simp-chinese-informal","single","skew","skewX","skewY","skip-white-space","slide","slider-horizontal","slider-vertical","sliderthumb-horizontal","sliderthumb-vertical","slow","small","small-caps","small-caption","smaller","solid","somali","source-atop","source-in","source-out","source-over","space","space-around","space-between","spell-out","square","square-button","start","static","status-bar","stretch","stroke","sub","subpixel-antialiased","super","sw-resize","symbolic","symbols","table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row","table-row-group","tamil","telugu","text","text-bottom","text-top","textarea","textfield","thai","thick","thin","threeddarkshadow","threedface","threedhighlight","threedlightshadow","threedshadow","tibetan","tigre","tigrinya-er","tigrinya-er-abegede","tigrinya-et","tigrinya-et-abegede","to","top","trad-chinese-formal","trad-chinese-informal","translate","translate3d","translateX","translateY","translateZ","transparent","ultra-condensed","ultra-expanded","underline","up","upper-alpha","upper-armenian","upper-greek","upper-hexadecimal","upper-latin","upper-norwegian","upper-roman","uppercase","urdu","url","var","vertical","vertical-text","visible","visibleFill","visiblePainted","visibleStroke","visual","w-resize","wait","wave","wider","window","windowframe","windowtext","words","wrap","wrap-reverse","x-large","x-small","xor","xx-large","xx-small"],x=t(v),z=o.concat(i).concat(l).concat(c).concat(p).concat(m).concat(w).concat(v);e.registerHelper("hintWords","css",z),e.defineMIME("text/css",{documentTypes:a,mediaTypes:n,mediaFeatures:s,mediaValueKeywords:d,propertyKeywords:u,nonStandardPropertyKeywords:h,fontProperties:g,counterDescriptors:y,colorKeywords:k,valueKeywords:x,tokenHooks:{"/":function(e,t){return e.eat("*")?(t.tokenize=r,r(e,t)):!1}},name:"css"}),e.defineMIME("text/x-scss",{mediaTypes:n,mediaFeatures:s,mediaValueKeywords:d,propertyKeywords:u,nonStandardPropertyKeywords:h,colorKeywords:k,valueKeywords:x,fontProperties:g,allowNested:!0,tokenHooks:{"/":function(e,t){return e.eat("/")?(e.skipToEnd(),["comment","comment"]):e.eat("*")?(t.tokenize=r,r(e,t)):["operator","operator"]},":":function(e){return e.match(/\s*\{/)?[null,"{"]:!1},$:function(e){return e.match(/^[\w-]+/),e.match(/^\s*:/,!1)?["variable-2","variable-definition"]:["variable-2","variable"]},"#":function(e){return e.eat("{")?[null,"interpolation"]:!1}},name:"css",helperType:"scss"}),e.defineMIME("text/x-less",{mediaTypes:n,mediaFeatures:s,mediaValueKeywords:d,propertyKeywords:u,nonStandardPropertyKeywords:h,colorKeywords:k,valueKeywords:x,fontProperties:g,allowNested:!0,tokenHooks:{"/":function(e,t){return e.eat("/")?(e.skipToEnd(),["comment","comment"]):e.eat("*")?(t.tokenize=r,r(e,t)):["operator","operator"]},"@":function(e){return e.eat("{")?[null,"interpolation"]:e.match(/^(charset|document|font-face|import|(-(moz|ms|o|webkit)-)?keyframes|media|namespace|page|supports)\b/,!1)?!1:(e.eatWhile(/[\w\\\-]/),e.match(/^\s*:/,!1)?["variable-2","variable-definition"]:["variable-2","variable"])},"&":function(){return["atom","atom"]}},name:"css",helperType:"less"}),e.defineMIME("text/x-gss",{documentTypes:a,mediaTypes:n,mediaFeatures:s,propertyKeywords:u,nonStandardPropertyKeywords:h,fontProperties:g,counterDescriptors:y,colorKeywords:k,valueKeywords:x,supportsAtComponent:!0,tokenHooks:{"/":function(e,t){return e.eat("*")?(t.tokenize=r,r(e,t)):!1}},name:"css",helperType:"gss"})});
|
lib/codemirror/mode/css/gss.html
ADDED
@@ -0,0 +1,103 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<!doctype html>
|
2 |
+
|
3 |
+
<title>CodeMirror: Closure Stylesheets (GSS) mode</title>
|
4 |
+
<meta charset="utf-8"/>
|
5 |
+
<link rel=stylesheet href="../../doc/docs.css">
|
6 |
+
|
7 |
+
<link rel="stylesheet" href="../../lib/codemirror.css">
|
8 |
+
<link rel="stylesheet" href="../../addon/hint/show-hint.css">
|
9 |
+
<script src="../../lib/codemirror.js"></script>
|
10 |
+
<script src="css.js"></script>
|
11 |
+
<script src="../../addon/hint/show-hint.js"></script>
|
12 |
+
<script src="../../addon/hint/css-hint.js"></script>
|
13 |
+
<style>.CodeMirror {background: #f8f8f8;}</style>
|
14 |
+
<div id=nav>
|
15 |
+
<a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>
|
16 |
+
|
17 |
+
<ul>
|
18 |
+
<li><a href="../../index.html">Home</a>
|
19 |
+
<li><a href="../../doc/manual.html">Manual</a>
|
20 |
+
<li><a href="https://github.com/codemirror/codemirror">Code</a>
|
21 |
+
</ul>
|
22 |
+
<ul>
|
23 |
+
<li><a href="../index.html">Language modes</a>
|
24 |
+
<li><a class=active href="#">Closure Stylesheets (GSS)</a>
|
25 |
+
</ul>
|
26 |
+
</div>
|
27 |
+
|
28 |
+
<article>
|
29 |
+
<h2>Closure Stylesheets (GSS) mode</h2>
|
30 |
+
<form><textarea id="code" name="code">
|
31 |
+
/* Some example Closure Stylesheets */
|
32 |
+
|
33 |
+
@provide 'some.styles';
|
34 |
+
|
35 |
+
@require 'other.styles';
|
36 |
+
|
37 |
+
@component {
|
38 |
+
|
39 |
+
@def FONT_FAMILY "Times New Roman", Georgia, Serif;
|
40 |
+
@def FONT_SIZE_NORMAL 15px;
|
41 |
+
@def FONT_NORMAL normal FONT_SIZE_NORMAL FONT_FAMILY;
|
42 |
+
|
43 |
+
@def BG_COLOR rgb(235, 239, 249);
|
44 |
+
|
45 |
+
@def DIALOG_BORDER_COLOR rgb(107, 144, 218);
|
46 |
+
@def DIALOG_BG_COLOR BG_COLOR;
|
47 |
+
|
48 |
+
@def LEFT_HAND_NAV_WIDTH 180px;
|
49 |
+
@def LEFT_HAND_NAV_PADDING 3px;
|
50 |
+
|
51 |
+
@defmixin size(WIDTH, HEIGHT) {
|
52 |
+
width: WIDTH;
|
53 |
+
height: HEIGHT;
|
54 |
+
}
|
55 |
+
|
56 |
+
body {
|
57 |
+
background-color: BG_COLOR;
|
58 |
+
margin: 0;
|
59 |
+
padding: 3em 6em;
|
60 |
+
font: FONT_NORMAL;
|
61 |
+
color: #000;
|
62 |
+
}
|
63 |
+
|
64 |
+
#navigation a {
|
65 |
+
font-weight: bold;
|
66 |
+
text-decoration: none !important;
|
67 |
+
}
|
68 |
+
|
69 |
+
.dialog {
|
70 |
+
background-color: DIALOG_BG_COLOR;
|
71 |
+
border: 1px solid DIALOG_BORDER_COLOR;
|
72 |
+
}
|
73 |
+
|
74 |
+
.content {
|
75 |
+
position: absolute;
|
76 |
+
margin-left: add(LEFT_HAND_NAV_PADDING, /* padding left */
|
77 |
+
LEFT_HAND_NAV_WIDTH,
|
78 |
+
LEFT_HAND_NAV_PADDING); /* padding right */
|
79 |
+
|
80 |
+
}
|
81 |
+
|
82 |
+
.logo {
|
83 |
+
@mixin size(150px, 55px);
|
84 |
+
background-image: url('http://www.google.com/images/logo_sm.gif');
|
85 |
+
}
|
86 |
+
|
87 |
+
}
|
88 |
+
</textarea></form>
|
89 |
+
<script>
|
90 |
+
var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
|
91 |
+
extraKeys: {"Ctrl-Space": "autocomplete"},
|
92 |
+
lineNumbers: true,
|
93 |
+
matchBrackets: "text/x-less",
|
94 |
+
mode: "text/x-gss"
|
95 |
+
});
|
96 |
+
</script>
|
97 |
+
|
98 |
+
<p>A mode for <a href="https://github.com/google/closure-stylesheets">Closure Stylesheets</a> (GSS).</p>
|
99 |
+
<p><strong>MIME type defined:</strong> <code>text/x-gss</code>.</p>
|
100 |
+
|
101 |
+
<p><strong>Parsing/Highlighting Tests:</strong> <a href="../../test/index.html#gss_*">normal</a>, <a href="../../test/index.html#verbose,gss_*">verbose</a>.</p>
|
102 |
+
|
103 |
+
</article>
|
lib/codemirror/mode/css/gss_test.js
ADDED
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
2 |
+
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
3 |
+
|
4 |
+
(function() {
|
5 |
+
"use strict";
|
6 |
+
|
7 |
+
var mode = CodeMirror.getMode({indentUnit: 2}, "text/x-gss");
|
8 |
+
function MT(name) { test.mode(name, mode, Array.prototype.slice.call(arguments, 1), "gss"); }
|
9 |
+
|
10 |
+
MT("atComponent",
|
11 |
+
"[def @component] {",
|
12 |
+
"[tag foo] {",
|
13 |
+
" [property color]: [keyword black];",
|
14 |
+
"}",
|
15 |
+
"}");
|
16 |
+
|
17 |
+
})();
|
lib/codemirror/mode/css/gss_test.min.js
ADDED
@@ -0,0 +1 @@
|
|
|
1 |
+
!function(){"use strict";function t(t){test.mode(t,o,Array.prototype.slice.call(arguments,1),"gss")}var o=CodeMirror.getMode({indentUnit:2},"text/x-gss");t("atComponent","[def @component] {","[tag foo] {"," [property color]: [keyword black];","}","}")}();
|
lib/codemirror/mode/css/test.js
CHANGED
@@ -6,7 +6,7 @@
|
|
6 |
function MT(name) { test.mode(name, mode, Array.prototype.slice.call(arguments, 1)); }
|
7 |
|
8 |
// Error, because "foobarhello" is neither a known type or property, but
|
9 |
-
// property was expected (after "and"), and it should be in
|
10 |
MT("atMediaUnknownType",
|
11 |
"[def @media] [attribute screen] [keyword and] [error foobarhello] { }");
|
12 |
|
@@ -18,6 +18,12 @@
|
|
18 |
MT("atMediaMaxWidthNested",
|
19 |
"[def @media] [attribute screen] [keyword and] ([property max-width]: [number 25px]) { [tag foo] { } }");
|
20 |
|
|
|
|
|
|
|
|
|
|
|
|
|
21 |
MT("tagSelector",
|
22 |
"[tag foo] { }");
|
23 |
|
@@ -49,11 +55,17 @@
|
|
49 |
MT("tagColorHex3",
|
50 |
"[tag foo] { [property background]: [atom #fff]; }");
|
51 |
|
|
|
|
|
|
|
52 |
MT("tagColorHex6",
|
53 |
"[tag foo] { [property background]: [atom #ffffff]; }");
|
54 |
|
55 |
-
MT("
|
56 |
-
"[tag foo] { [property background]: [atom
|
|
|
|
|
|
|
57 |
|
58 |
MT("tagColorHexInvalid",
|
59 |
"[tag foo] { [property background]: [atom&error #ffg]; }");
|
@@ -76,13 +88,6 @@
|
|
76 |
MT("tagTwoPropertiesURL",
|
77 |
"[tag foo] { [property background]: [atom url]([string //example.com/foo.png]); [property padding]: [number 0]; }");
|
78 |
|
79 |
-
MT("commentSGML",
|
80 |
-
"[comment <!--comment-->]");
|
81 |
-
|
82 |
-
MT("commentSGML2",
|
83 |
-
"[comment <!--comment]",
|
84 |
-
"[comment -->] [tag div] {}");
|
85 |
-
|
86 |
MT("indent_tagSelector",
|
87 |
"[tag strong], [tag em] {",
|
88 |
" [property background]: [atom rgba](",
|
@@ -121,7 +126,7 @@
|
|
121 |
"}");
|
122 |
|
123 |
MT("empty_url",
|
124 |
-
"[def @import] [
|
125 |
|
126 |
MT("parens",
|
127 |
"[qualifier .foo] {",
|
@@ -157,7 +162,7 @@
|
|
157 |
" [tag foo] {",
|
158 |
" [property font-family]: [variable Verdana], [atom sans-serif];",
|
159 |
" }",
|
160 |
-
"
|
161 |
|
162 |
MT("document_url",
|
163 |
"[def @document] [tag url]([string http://blah]) { [qualifier .class] { } }");
|
6 |
function MT(name) { test.mode(name, mode, Array.prototype.slice.call(arguments, 1)); }
|
7 |
|
8 |
// Error, because "foobarhello" is neither a known type or property, but
|
9 |
+
// property was expected (after "and"), and it should be in parentheses.
|
10 |
MT("atMediaUnknownType",
|
11 |
"[def @media] [attribute screen] [keyword and] [error foobarhello] { }");
|
12 |
|
18 |
MT("atMediaMaxWidthNested",
|
19 |
"[def @media] [attribute screen] [keyword and] ([property max-width]: [number 25px]) { [tag foo] { } }");
|
20 |
|
21 |
+
MT("atMediaFeatureValueKeyword",
|
22 |
+
"[def @media] ([property orientation]: [keyword landscape]) { }");
|
23 |
+
|
24 |
+
MT("atMediaUnknownFeatureValueKeyword",
|
25 |
+
"[def @media] ([property orientation]: [error upsidedown]) { }");
|
26 |
+
|
27 |
MT("tagSelector",
|
28 |
"[tag foo] { }");
|
29 |
|
55 |
MT("tagColorHex3",
|
56 |
"[tag foo] { [property background]: [atom #fff]; }");
|
57 |
|
58 |
+
MT("tagColorHex4",
|
59 |
+
"[tag foo] { [property background]: [atom #ffff]; }");
|
60 |
+
|
61 |
MT("tagColorHex6",
|
62 |
"[tag foo] { [property background]: [atom #ffffff]; }");
|
63 |
|
64 |
+
MT("tagColorHex8",
|
65 |
+
"[tag foo] { [property background]: [atom #ffffffff]; }");
|
66 |
+
|
67 |
+
MT("tagColorHex5Invalid",
|
68 |
+
"[tag foo] { [property background]: [atom&error #fffff]; }");
|
69 |
|
70 |
MT("tagColorHexInvalid",
|
71 |
"[tag foo] { [property background]: [atom&error #ffg]; }");
|
88 |
MT("tagTwoPropertiesURL",
|
89 |
"[tag foo] { [property background]: [atom url]([string //example.com/foo.png]); [property padding]: [number 0]; }");
|
90 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
91 |
MT("indent_tagSelector",
|
92 |
"[tag strong], [tag em] {",
|
93 |
" [property background]: [atom rgba](",
|
126 |
"}");
|
127 |
|
128 |
MT("empty_url",
|
129 |
+
"[def @import] [atom url]() [attribute screen];");
|
130 |
|
131 |
MT("parens",
|
132 |
"[qualifier .foo] {",
|
162 |
" [tag foo] {",
|
163 |
" [property font-family]: [variable Verdana], [atom sans-serif];",
|
164 |
" }",
|
165 |
+
"}");
|
166 |
|
167 |
MT("document_url",
|
168 |
"[def @document] [tag url]([string http://blah]) { [qualifier .class] { } }");
|
lib/codemirror/mode/css/test.min.js
CHANGED
@@ -1 +1 @@
|
|
1 |
-
!function(){function r(r){test.mode(r,o,Array.prototype.slice.call(arguments,1))}var o=CodeMirror.getMode({indentUnit:2},"css");r("atMediaUnknownType","[def @media] [attribute screen] [keyword and] [error foobarhello] { }"),r("atMediaUnknownProperty","[def @media] [attribute screen] [keyword and] ([error foobarhello]) { }"),r("atMediaMaxWidthNested","[def @media] [attribute screen] [keyword and] ([property max-width]: [number 25px]) { [tag foo] { } }"),r("tagSelector","[tag foo] { }"),r("classSelector","[qualifier .foo-bar_hello] { }"),r("idSelector","[builtin #foo] { [error #foo] }"),r("tagSelectorUnclosed","[tag foo] { [property margin]: [number 0] } [tag bar] { }"),r("tagStringNoQuotes","[tag foo] { [property font-family]: [variable hello] [variable world]; }"),r("tagStringDouble",'[tag foo] { [property font-family]: [string "hello world"]; }'),r("tagStringSingle","[tag foo] { [property font-family]: [string 'hello world']; }"),r("tagColorKeyword","[tag foo] {"," [property color]: [keyword black];"," [property color]: [keyword navy];"," [property color]: [keyword yellow];","}"),r("tagColorHex3","[tag foo] { [property background]: [atom #fff]; }"),r("tagColorHex6","[tag foo] { [property background]: [atom #ffffff]; }"),r("
|
1 |
+
!function(){function r(r){test.mode(r,o,Array.prototype.slice.call(arguments,1))}var o=CodeMirror.getMode({indentUnit:2},"css");r("atMediaUnknownType","[def @media] [attribute screen] [keyword and] [error foobarhello] { }"),r("atMediaUnknownProperty","[def @media] [attribute screen] [keyword and] ([error foobarhello]) { }"),r("atMediaMaxWidthNested","[def @media] [attribute screen] [keyword and] ([property max-width]: [number 25px]) { [tag foo] { } }"),r("atMediaFeatureValueKeyword","[def @media] ([property orientation]: [keyword landscape]) { }"),r("atMediaUnknownFeatureValueKeyword","[def @media] ([property orientation]: [error upsidedown]) { }"),r("tagSelector","[tag foo] { }"),r("classSelector","[qualifier .foo-bar_hello] { }"),r("idSelector","[builtin #foo] { [error #foo] }"),r("tagSelectorUnclosed","[tag foo] { [property margin]: [number 0] } [tag bar] { }"),r("tagStringNoQuotes","[tag foo] { [property font-family]: [variable hello] [variable world]; }"),r("tagStringDouble",'[tag foo] { [property font-family]: [string "hello world"]; }'),r("tagStringSingle","[tag foo] { [property font-family]: [string 'hello world']; }"),r("tagColorKeyword","[tag foo] {"," [property color]: [keyword black];"," [property color]: [keyword navy];"," [property color]: [keyword yellow];","}"),r("tagColorHex3","[tag foo] { [property background]: [atom #fff]; }"),r("tagColorHex4","[tag foo] { [property background]: [atom #ffff]; }"),r("tagColorHex6","[tag foo] { [property background]: [atom #ffffff]; }"),r("tagColorHex8","[tag foo] { [property background]: [atom #ffffffff]; }"),r("tagColorHex5Invalid","[tag foo] { [property background]: [atom&error #fffff]; }"),r("tagColorHexInvalid","[tag foo] { [property background]: [atom&error #ffg]; }"),r("tagNegativeNumber","[tag foo] { [property margin]: [number -5px]; }"),r("tagPositiveNumber","[tag foo] { [property padding]: [number 5px]; }"),r("tagVendor","[tag foo] { [meta -foo-][property box-sizing]: [meta -foo-][atom border-box]; }"),r("tagBogusProperty","[tag foo] { [property&error barhelloworld]: [number 0]; }"),r("tagTwoProperties","[tag foo] { [property margin]: [number 0]; [property padding]: [number 0]; }"),r("tagTwoPropertiesURL","[tag foo] { [property background]: [atom url]([string //example.com/foo.png]); [property padding]: [number 0]; }"),r("indent_tagSelector","[tag strong], [tag em] {"," [property background]: [atom rgba]("," [number 255], [number 255], [number 0], [number .2]"," );","}"),r("indent_atMedia","[def @media] {"," [tag foo] {"," [property color]:"," [keyword yellow];"," }","}"),r("indent_comma","[tag foo] {"," [property font-family]: [variable verdana],"," [atom sans-serif];","}"),r("indent_parentheses","[tag foo]:[variable-3 before] {"," [property background]: [atom url](","[string blahblah]","[string etc]","[string ]) [keyword !important];","}"),r("font_face","[def @font-face] {"," [property font-family]: [string 'myfont'];"," [error nonsense]: [string 'abc'];"," [property src]: [atom url]([string http://blah]),"," [atom url]([string http://foo]);","}"),r("empty_url","[def @import] [atom url]() [attribute screen];"),r("parens","[qualifier .foo] {"," [property background-image]: [variable fade]([atom #000], [number 20%]);"," [property border-image]: [atom linear-gradient]("," [atom to] [atom bottom],"," [variable fade]([atom #000], [number 20%]) [number 0%],"," [variable fade]([atom #000], [number 20%]) [number 100%]"," );","}"),r("css_variable",":[variable-3 root] {"," [variable-2 --main-color]: [atom #06c];","}","[tag h1][builtin #foo] {"," [property color]: [atom var]([variable-2 --main-color]);","}"),r("supports","[def @supports] ([keyword not] (([property text-align-last]: [atom justify]) [keyword or] ([meta -moz-][property text-align-last]: [atom justify])) {"," [property text-align-last]: [atom justify];","}"),r("document","[def @document] [tag url]([string http://blah]),"," [tag url-prefix]([string https://]),"," [tag domain]([string blah.com]),",' [tag regexp]([string ".*blah.+"]) {'," [builtin #id] {"," [property background-color]: [keyword white];"," }"," [tag foo] {"," [property font-family]: [variable Verdana], [atom sans-serif];"," }","}"),r("document_url","[def @document] [tag url]([string http://blah]) { [qualifier .class] { } }"),r("document_urlPrefix","[def @document] [tag url-prefix]([string https://]) { [builtin #id] { } }"),r("document_domain","[def @document] [tag domain]([string blah.com]) { [tag foo] { } }"),r("document_regexp",'[def @document] [tag regexp]([string ".*blah.+"]) { [builtin #id] { } }'),r("counter-style","[def @counter-style] [variable binary] {"," [property system]: [atom numeric];"," [property symbols]: [number 0] [number 1];",' [property suffix]: [string "."];'," [property range]: [atom infinite];"," [property speak-as]: [atom numeric];","}"),r("counter-style-additive-symbols","[def @counter-style] [variable simple-roman] {"," [property system]: [atom additive];"," [property additive-symbols]: [number 10] [variable X], [number 5] [variable V], [number 1] [variable I];"," [property range]: [number 1] [number 49];","}"),r("counter-style-use","[tag ol][qualifier .roman] { [property list-style]: [variable simple-roman]; }"),r("counter-style-symbols",'[tag ol] { [property list-style]: [atom symbols]([atom cyclic] [string "*"] [string "\\2020"] [string "\\2021"] [string "\\A7"]); }')}();
|
lib/codemirror/theme/neat.css
CHANGED
@@ -5,8 +5,8 @@
|
|
5 |
.cm-s-neat span.cm-special { line-height: 1em; font-weight: bold; color: #0aa; }
|
6 |
.cm-s-neat span.cm-variable { color: black; }
|
7 |
.cm-s-neat span.cm-number, .cm-s-neat span.cm-atom { color: #3a3; }
|
8 |
-
.cm-s-neat span.cm-meta {color: #555;}
|
9 |
.cm-s-neat span.cm-link { color: #3a3; }
|
10 |
|
11 |
-
.cm-s-neat .CodeMirror-activeline-background {background: #e8f2ff
|
12 |
-
.cm-s-neat .CodeMirror-matchingbracket {outline:1px solid grey; color:black !important;}
|
5 |
.cm-s-neat span.cm-special { line-height: 1em; font-weight: bold; color: #0aa; }
|
6 |
.cm-s-neat span.cm-variable { color: black; }
|
7 |
.cm-s-neat span.cm-number, .cm-s-neat span.cm-atom { color: #3a3; }
|
8 |
+
.cm-s-neat span.cm-meta { color: #555; }
|
9 |
.cm-s-neat span.cm-link { color: #3a3; }
|
10 |
|
11 |
+
.cm-s-neat .CodeMirror-activeline-background { background: #e8f2ff; }
|
12 |
+
.cm-s-neat .CodeMirror-matchingbracket { outline:1px solid grey; color:black !important; }
|
readme.txt
CHANGED
@@ -1,8 +1,8 @@
|
|
1 |
=== SiteOrigin CSS ===
|
2 |
Tags: css, design, edit, customize
|
3 |
Requires at least: 3.9
|
4 |
-
Tested up to: 4.
|
5 |
-
Stable tag: 1.0.
|
6 |
License: GPLv2 or later
|
7 |
Contributors: gpriday
|
8 |
|
@@ -61,6 +61,9 @@ We offer free support on the [SiteOrigin support forums](https://siteorigin.com/
|
|
61 |
|
62 |
== Changelog ==
|
63 |
|
|
|
|
|
|
|
64 |
= 1.0.4 - 10 November 2015=
|
65 |
* Fixed CSS parsing when going into visual mode.
|
66 |
|
1 |
=== SiteOrigin CSS ===
|
2 |
Tags: css, design, edit, customize
|
3 |
Requires at least: 3.9
|
4 |
+
Tested up to: 4.4.1
|
5 |
+
Stable tag: 1.0.4
|
6 |
License: GPLv2 or later
|
7 |
Contributors: gpriday
|
8 |
|
61 |
|
62 |
== Changelog ==
|
63 |
|
64 |
+
= 1.0.5 - 21 January 2016=
|
65 |
+
* Updated to latest version of Code Mirror.
|
66 |
+
|
67 |
= 1.0.4 - 10 November 2015=
|
68 |
* Fixed CSS parsing when going into visual mode.
|
69 |
|
so-css.php
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
/*
|
3 |
Plugin Name: SiteOrigin CSS
|
4 |
Description: An advanced CSS editor from SiteOrigin.
|
5 |
-
Version: 1.0.
|
6 |
Author: SiteOrigin
|
7 |
Author URI: https://siteorigin.com
|
8 |
Plugin URI: https://siteorigin.com/css/
|
@@ -13,7 +13,7 @@ License URI: https://www.gnu.org/licenses/gpl-3.0.txt
|
|
13 |
// Handle the legacy CSS editor that came with SiteOrigin themes
|
14 |
include plugin_dir_path(__FILE__) . '/inc/legacy.php';
|
15 |
|
16 |
-
define('SOCSS_VERSION', '1.0.
|
17 |
define('SOCSS_JS_SUFFIX', '.min');
|
18 |
|
19 |
/**
|
2 |
/*
|
3 |
Plugin Name: SiteOrigin CSS
|
4 |
Description: An advanced CSS editor from SiteOrigin.
|
5 |
+
Version: 1.0.5
|
6 |
Author: SiteOrigin
|
7 |
Author URI: https://siteorigin.com
|
8 |
Plugin URI: https://siteorigin.com/css/
|
13 |
// Handle the legacy CSS editor that came with SiteOrigin themes
|
14 |
include plugin_dir_path(__FILE__) . '/inc/legacy.php';
|
15 |
|
16 |
+
define('SOCSS_VERSION', '1.0.5');
|
17 |
define('SOCSS_JS_SUFFIX', '.min');
|
18 |
|
19 |
/**
|