Version Description
- 31 January 2017 =
- Updated CodeMirror to 2.25.2.
- Removed extra line padding.
- Better integration with WordPress.org translation.
Download this release
Release Info
Developer | gpriday |
Plugin | SiteOrigin CSS |
Version | 1.1.4 |
Comparing to | |
See all releases |
Code changes from version 1.1.3 to 1.1.4
- js/editor.js +0 -4
- js/editor.min.js +1 -1
- lang/so-css.pot +506 -0
- lib/codemirror/addon/fold/indent-fold.js +19 -15
- lib/codemirror/addon/fold/indent-fold.min.js +1 -1
- lib/codemirror/addon/fold/xml-fold.js +2 -2
- lib/codemirror/addon/fold/xml-fold.min.js +1 -1
- lib/codemirror/addon/hint/sql-hint.js +27 -11
- lib/codemirror/addon/hint/sql-hint.min.js +1 -1
- lib/codemirror/addon/lint/css-lint.js +8 -9
- lib/codemirror/addon/lint/lint.js +6 -1
- lib/codemirror/addon/lint/lint.min.js +1 -1
- lib/codemirror/addon/lint/yaml-lint.js +9 -2
- lib/codemirror/addon/lint/yaml-lint.min.js +1 -1
- lib/codemirror/addon/merge/merge.js +250 -48
- lib/codemirror/addon/merge/merge.min.js +1 -1
- lib/codemirror/lib/codemirror.css +4 -5
- lib/codemirror/lib/codemirror.js +811 -593
- lib/codemirror/lib/codemirror.min.js +6 -5
- lib/codemirror/mode/css/css.js +9 -3
- lib/codemirror/mode/css/css.min.js +1 -1
- lib/codemirror/mode/css/index.html +1 -1
- lib/codemirror/mode/sass/index.html +3 -1
- lib/codemirror/mode/sass/sass.js +67 -27
- lib/codemirror/mode/sass/sass.min.js +1 -1
- lib/codemirror/mode/sass/test.js +122 -0
- lib/codemirror/mode/sass/test.min.js +1 -0
- readme.txt +11 -4
- so-css.php +3 -3
- tpl/page.php +0 -9
js/editor.js
CHANGED
@@ -117,11 +117,7 @@
|
|
117 |
// options in context menu.
|
118 |
var newlineMatches = initValue.match(/\n/gm);
|
119 |
var lineCount = newlineMatches ? newlineMatches.length+1 : 1;
|
120 |
-
var numPadLines = 15 - lineCount;
|
121 |
var paddedValue = initValue;
|
122 |
-
for(var i = 0; i < numPadLines; i++) {
|
123 |
-
paddedValue += '\n';
|
124 |
-
}
|
125 |
$textArea.val(paddedValue);
|
126 |
this.codeMirror = CodeMirror.fromTextArea($textArea.get(0), {
|
127 |
tabSize: 2,
|
117 |
// options in context menu.
|
118 |
var newlineMatches = initValue.match(/\n/gm);
|
119 |
var lineCount = newlineMatches ? newlineMatches.length+1 : 1;
|
|
|
120 |
var paddedValue = initValue;
|
|
|
|
|
|
|
121 |
$textArea.val(paddedValue);
|
122 |
this.codeMirror = CodeMirror.fromTextArea($textArea.get(0), {
|
123 |
tabSize: 2,
|
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,r=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 r}}),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().trim()),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();for(var s=this.$("textarea.css-editor"),r=s.val(),n=r.match(/\n/gm),o=n?n.length+1:1,a=15-o,l=r,c=0;c<a;c++)l+="\n";s.val(l),this.codeMirror=CodeMirror.fromTextArea(s.get(0),{tabSize:2,lineNumbers:!0,mode:"css",theme:"neat",inputStyle:"contenteditable",gutters:["CodeMirror-lint-markers"],lint:!0}),this.$el.on("submit",function(){r=t.codeMirror.getValue().trim()}),e(window).bind("beforeunload",function(){var e=t.codeMirror.getValue().trim();if(e!==r)return i.loc.leave}),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)||d.push(t)}var r=i.getCursor(),n=i.getTokenAt(r),o=CodeMirror.innerMode(i.getMode(),n.state);if("css"===o.mode.name){if("keyword"===n.type&&0==="!important".indexOf(n.string))return{list:["!important"],from:CodeMirror.Pos(r.line,n.start),to:CodeMirror.Pos(r.line,n.end)};var a=n.start,l=r.ch,c=n.string.slice(0,l-a);/[^\w$_-]/.test(c)&&(c="",a=l=r.ch);var p=CodeMirror.resolveMode("text/css"),d=[],h=o.state.state;if("top"===h){for(var u=i.getLine(r.line).trim(),v=e.cssSelectors,f=0;f<v.length;f++)v[f].selector.indexOf(u)!==-1&&d.push(v[f].selector);if(d.length)return{list:d,from:CodeMirror.Pos(r.line,0),to:CodeMirror.Pos(r.line,l)}}else if("pseudo"===h||"variable-3"===n.type?s(t):"block"===h||"maybeprop"===h?s(p.propertyKeywords):"prop"===h||"parens"===h||"at"===h||"params"===h?(s(p.valueKeywords),s(p.colorKeywords)):"media"!==h&&"media_parens"!==h||(s(p.mediaTypes),s(p.mediaFeatures)),d.length)return{list:d,from:CodeMirror.Pos(r.line,a),to:CodeMirror.Pos(r.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 r=t.getLine(i.line),n=r.substring(0,s.end);e.preview.highlight(n)}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({completeSingle:!1})})},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(e("#template-preview-window").html()),editor:null,originalUri:null,currentUri: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).on("load",function(){var i=e(this);t.currentUri=new URI(i.contents().get(0).location.href),t.currentUri.removeQuery("so_css_preview"),t.$("#preview-navigator input").val(t.currentUri.toString()),t.currentUri.addQuery("so_css_preview",1),i.contents().find("a").each(function(){var t=e(this).attr("href");if(void 0===t)return!0;var i=t.indexOf("?")===-1?"?":"&";e(this).attr("href",t+i+"so_css_preview=1")}),t.updatePreviewCss()}).mouseleave(function(){t.clearHighlight()}),this.$("#preview-navigator input").keydown(function(i){var s=e(this);if(13==i.keyCode){i.preventDefault();var r=new URI(s.val());t.originalUri.host()!==r.host()||t.originalUri.protocol()!==r.protocol()?(s.blur(),alert(s.data("invalid-uri")),s.focus()):(r.addQuery("so_css_preview",1),t.$("#preview-iframe").attr("src",r.toString()))}}),this.originalUri=new URI(i.homeURL),this.currentUri=new URI(i.homeURL),this.currentUri.removeQuery("so_css_preview"),this.$("#preview-navigator input").val(this.currentUri.toString()),this.currentUri.addQuery("so_css_preview",1)},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().trim();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=window.css,this.editor=e.editor},render:function(){var r=this;this.$(".section-tabs").empty(),this.$(".sections").empty(),this.$(".toolbar select").off(),r.propertyControllers=[];var n=i.propertyControllers;for(var o in n){var a=(e(this.tabTemplate({id:o,icon:n[o].icon,title:n[o].title})).appendTo(this.$(".section-tabs")),e(this.sectionTemplate({id:o})).appendTo(this.$(".sections")));if(!t.isEmpty(n[o].controllers))for(var l=0;l<n[o].controllers.length;l++){var c,p=e(r.controllerTemplate({title:n[o].controllers[l].title})).appendTo(a.find("tbody")),d=n[o].controllers[l];c="undefined"==typeof s.view.properties.controllers[d.type]?new s.view.propertyController({el:p.find("td"),propertiesView:r,args:"undefined"==typeof d.args?{}:d.args}):new s.view.properties.controllers[d.type]({el:p.find("td"),propertiesView:r,args:"undefined"==typeof d.args?{}:d.args}),r.propertyControllers.push(c),c.render(),c.initChangeEvents()}}this.$(".section-tabs li").click(function(){var t=e(this),i=r.$('.sections .section[data-section="'+t.data("section")+'"]');r.$(".sections .section").not(i).hide().removeClass("active"),i.show().addClass("active"),r.$(".section-tabs li").not(t).removeClass("active"),t.addClass("active")}).eq(0).click(),this.$(".toolbar select").change(function(){r.setActivateSelector(e(this).find(":selected").data("selector"))})},setRuleValue:function(e,i){if("undefined"!=typeof this.activeSelector&&"undefined"!=typeof this.activeSelector.declarations){for(var s=this.activeSelector.declarations,r=!0,n=!1,o=0;o<s.length;o++)if(s[o].property===e){r=!1;var a=s[o];a.value!==i&&(a.value=i,n=!0),t.isEmpty(a.value)&&s.splice(s.indexOf(a));break}r&&!t.isEmpty(i)&&(s.push({property:e,value:i,type:"declaration"}),n=!0),n&&this.updateMainEditor(!1)}},addImport:function(e){var i=t.filter(this.parsed.stylesheet.rules,function(e){return"import"===e.type}),s=t.any(i,function(t){return t["import"]===e["import"]});s||(this.parsed.stylesheet.rules.unshift(e),this.updateMainEditor(!1))},findImport:function(e){return t.find(this.parsed.stylesheet.rules,function(t){return"import"===t.type&&t["import"].indexOf(e)>-1})},updateImport:function(e,t){var i=this.findImport(e);i["import"]!==t["import"]&&(i["import"]=t["import"],this.updateMainEditor(!1))},removeImport:function(e){var i=t.findIndex(this.parsed.stylesheet.rules,function(t){return"import"===t.type&&t["import"].indexOf(e)>-1});i>-1&&this.parsed.stylesheet.rules.splice(i,1)},getRuleValue:function(e){if("undefined"==typeof this.activeSelector||"undefined"==typeof this.activeSelector.declarations)return"";for(var t=this.activeSelector.declarations,i=0;i<t.length;i++)if(t[i].property===e)return t[i].value;return""},updateMainEditor:function(e){this.editor.codeMirror.setValue(this.parser.stringify(this.parsed))},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(i,s){this.css=i,this.parsed=this.parser.parse(i,{silent:!0});for(var r=this.parsed.stylesheet.rules,n=this.$(".toolbar select").empty(),o=0;o<r.length;o++){var a=r[o];if(t.contains(["rule","media"],a.type))if("media"===a.type)for(var l=0;l<a.rules.length;l++){var c="@media "+a.media,p=a.rules[l];"rule"==p.type&&n.append(e("<option>").html(c+": "+p.selectors.join(",")).attr("val",c+": "+p.selectors.join(",")).data("selector",p))}else n.append(e("<option>").html(a.selectors.join(",")).attr("val",a.selectors.join(",")).data("selector",a))}"undefined"==typeof s&&(s=n.find("option").eq(0).attr("val")),t.isEmpty(s)||n.val(s).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().trim(),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").trim()},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"),r=s.exec(e);return null===r?{value:"",unit:""}:{value:r[1],unit:void 0===r[2]?"":r[2]}},setupMeasurementField:function(i,s){var r=this,n=i.parent();s=t.extend({defaultUnit:"px"},s),i.hide(),n.addClass(this.wrapperClass).data("unit",s.defaultUnit);for(var o=e('<input type="text" class="socss-field-input"/>').appendTo(n),a=e('<span class="dashicons dashicons-arrow-down"></span>').appendTo(n),l=e('<ul class="dropdown"></ul>').appendTo(n),c=e('<span class="units"></span>').html(s.defaultUnit).appendTo(n),p=0;p<r.units.length;p++){var d=e("<li></li>").html(r.units[p]).data("unit",r.units[p]);r.units[p]===s.defaultUnit&&d.addClass("active"),l.append(d)}var h=function(){var e=r.parseUnits(o.val());""!==e.unit&&e.unit!==n.data("unit")&&(o.val(e.value),u(e.unit)),""===e.value?i.val(""):i.val(e.value+n.data("unit"))},u=function(e){c.html(e),n.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"),r=s.width();r=Math.min(r,63),s.remove(),c.css("left",r+12)}),o.on("keyup",function(e){h(),i.trigger("change")}),i.on("measurement_refresh",function(){var t=r.parseUnits(i.val());o.val(t.value);var a=""===t.unit?s.defaultUnit:t.unit;n.data("unit",a),c.html(a);var l=e('<span class="socss-hidden-placeholder"></span>').css({"font-size":"14px"}).html(t.value).appendTo("body"),p=l.width();p=Math.min(p,63),l.remove(),c.css("left",p+12)});var v=e('<div class="socss-diw"></div>').appendTo(n),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=r.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=r.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 r=i.parent();r.addClass("socss-field-number");var n=e('<div class="socss-diw"></div>').appendTo(r),o=e('<div class="dec-button socss-button">-</div>').appendTo(n);e('<div class="inc-button socss-button">+</div>').appendTo(n);return n.find("> div").click(function(t){t.preventDefault();var r=s["default"];""!==i.val()&&(r=Number(i.val())),r+=e(this).is(o)?s.decrement:s.increment,r=Math.round(100*r)/100,null!==s.max&&(r=Math.min(s.max,r)),null!==s.min&&(r=Math.max(s.min,r)),i.val(r),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 r=e(this).data("direction"),n=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"===r?a.args.propertyAll:a.args.property.replace("{dir}",r);var c=t.extend({},a.args,{property:l}),p=new s.view.properties.controllers[a.type]({el:e("<div>").appendTo(n),propertiesView:i.propertiesView,args:c});p.render(),p.initChangeEvents(),i.propertiesView.propertyControllers.push(p)}e(this).on("click",function(){i.$(".select-tab").removeClass("active"),e(this).addClass("active"),i.$(".sides .side").hide(),n.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,r=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 r}}),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().trim()),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();var s=this.$("textarea.css-editor"),r=s.val(),n=r.match(/\n/gm),o=(n?n.length+1:1,r);s.val(o),this.codeMirror=CodeMirror.fromTextArea(s.get(0),{tabSize:2,lineNumbers:!0,mode:"css",theme:"neat",inputStyle:"contenteditable",gutters:["CodeMirror-lint-markers"],lint:!0}),this.$el.on("submit",function(){r=t.codeMirror.getValue().trim()}),e(window).bind("beforeunload",function(){var e=t.codeMirror.getValue().trim();if(e!==r)return i.loc.leave}),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)||d.push(t)}var r=i.getCursor(),n=i.getTokenAt(r),o=CodeMirror.innerMode(i.getMode(),n.state);if("css"===o.mode.name){if("keyword"===n.type&&0==="!important".indexOf(n.string))return{list:["!important"],from:CodeMirror.Pos(r.line,n.start),to:CodeMirror.Pos(r.line,n.end)};var a=n.start,l=r.ch,c=n.string.slice(0,l-a);/[^\w$_-]/.test(c)&&(c="",a=l=r.ch);var p=CodeMirror.resolveMode("text/css"),d=[],h=o.state.state;if("top"===h){for(var u=i.getLine(r.line).trim(),v=e.cssSelectors,f=0;f<v.length;f++)v[f].selector.indexOf(u)!==-1&&d.push(v[f].selector);if(d.length)return{list:d,from:CodeMirror.Pos(r.line,0),to:CodeMirror.Pos(r.line,l)}}else if("pseudo"===h||"variable-3"===n.type?s(t):"block"===h||"maybeprop"===h?s(p.propertyKeywords):"prop"===h||"parens"===h||"at"===h||"params"===h?(s(p.valueKeywords),s(p.colorKeywords)):"media"!==h&&"media_parens"!==h||(s(p.mediaTypes),s(p.mediaFeatures)),d.length)return{list:d,from:CodeMirror.Pos(r.line,a),to:CodeMirror.Pos(r.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 r=t.getLine(i.line),n=r.substring(0,s.end);e.preview.highlight(n)}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({completeSingle:!1})})},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(e("#template-preview-window").html()),editor:null,originalUri:null,currentUri: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).on("load",function(){var i=e(this);t.currentUri=new URI(i.contents().get(0).location.href),t.currentUri.removeQuery("so_css_preview"),t.$("#preview-navigator input").val(t.currentUri.toString()),t.currentUri.addQuery("so_css_preview",1),i.contents().find("a").each(function(){var t=e(this).attr("href");if(void 0===t)return!0;var i=t.indexOf("?")===-1?"?":"&";e(this).attr("href",t+i+"so_css_preview=1")}),t.updatePreviewCss()}).mouseleave(function(){t.clearHighlight()}),this.$("#preview-navigator input").keydown(function(i){var s=e(this);if(13==i.keyCode){i.preventDefault();var r=new URI(s.val());t.originalUri.host()!==r.host()||t.originalUri.protocol()!==r.protocol()?(s.blur(),alert(s.data("invalid-uri")),s.focus()):(r.addQuery("so_css_preview",1),t.$("#preview-iframe").attr("src",r.toString()))}}),this.originalUri=new URI(i.homeURL),this.currentUri=new URI(i.homeURL),this.currentUri.removeQuery("so_css_preview"),this.$("#preview-navigator input").val(this.currentUri.toString()),this.currentUri.addQuery("so_css_preview",1)},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().trim();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=window.css,this.editor=e.editor},render:function(){var r=this;this.$(".section-tabs").empty(),this.$(".sections").empty(),this.$(".toolbar select").off(),r.propertyControllers=[];var n=i.propertyControllers;for(var o in n){var a=(e(this.tabTemplate({id:o,icon:n[o].icon,title:n[o].title})).appendTo(this.$(".section-tabs")),e(this.sectionTemplate({id:o})).appendTo(this.$(".sections")));if(!t.isEmpty(n[o].controllers))for(var l=0;l<n[o].controllers.length;l++){var c,p=e(r.controllerTemplate({title:n[o].controllers[l].title})).appendTo(a.find("tbody")),d=n[o].controllers[l];c="undefined"==typeof s.view.properties.controllers[d.type]?new s.view.propertyController({el:p.find("td"),propertiesView:r,args:"undefined"==typeof d.args?{}:d.args}):new s.view.properties.controllers[d.type]({el:p.find("td"),propertiesView:r,args:"undefined"==typeof d.args?{}:d.args}),r.propertyControllers.push(c),c.render(),c.initChangeEvents()}}this.$(".section-tabs li").click(function(){var t=e(this),i=r.$('.sections .section[data-section="'+t.data("section")+'"]');r.$(".sections .section").not(i).hide().removeClass("active"),i.show().addClass("active"),r.$(".section-tabs li").not(t).removeClass("active"),t.addClass("active")}).eq(0).click(),this.$(".toolbar select").change(function(){r.setActivateSelector(e(this).find(":selected").data("selector"))})},setRuleValue:function(e,i){if("undefined"!=typeof this.activeSelector&&"undefined"!=typeof this.activeSelector.declarations){for(var s=this.activeSelector.declarations,r=!0,n=!1,o=0;o<s.length;o++)if(s[o].property===e){r=!1;var a=s[o];a.value!==i&&(a.value=i,n=!0),t.isEmpty(a.value)&&s.splice(s.indexOf(a));break}r&&!t.isEmpty(i)&&(s.push({property:e,value:i,type:"declaration"}),n=!0),n&&this.updateMainEditor(!1)}},addImport:function(e){var i=t.filter(this.parsed.stylesheet.rules,function(e){return"import"===e.type}),s=t.any(i,function(t){return t["import"]===e["import"]});s||(this.parsed.stylesheet.rules.unshift(e),this.updateMainEditor(!1))},findImport:function(e){return t.find(this.parsed.stylesheet.rules,function(t){return"import"===t.type&&t["import"].indexOf(e)>-1})},updateImport:function(e,t){var i=this.findImport(e);i["import"]!==t["import"]&&(i["import"]=t["import"],this.updateMainEditor(!1))},removeImport:function(e){var i=t.findIndex(this.parsed.stylesheet.rules,function(t){return"import"===t.type&&t["import"].indexOf(e)>-1});i>-1&&this.parsed.stylesheet.rules.splice(i,1)},getRuleValue:function(e){if("undefined"==typeof this.activeSelector||"undefined"==typeof this.activeSelector.declarations)return"";for(var t=this.activeSelector.declarations,i=0;i<t.length;i++)if(t[i].property===e)return t[i].value;return""},updateMainEditor:function(e){this.editor.codeMirror.setValue(this.parser.stringify(this.parsed))},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(i,s){this.css=i,this.parsed=this.parser.parse(i,{silent:!0});for(var r=this.parsed.stylesheet.rules,n=this.$(".toolbar select").empty(),o=0;o<r.length;o++){var a=r[o];if(t.contains(["rule","media"],a.type))if("media"===a.type)for(var l=0;l<a.rules.length;l++){var c="@media "+a.media,p=a.rules[l];"rule"==p.type&&n.append(e("<option>").html(c+": "+p.selectors.join(",")).attr("val",c+": "+p.selectors.join(",")).data("selector",p))}else n.append(e("<option>").html(a.selectors.join(",")).attr("val",a.selectors.join(",")).data("selector",a))}"undefined"==typeof s&&(s=n.find("option").eq(0).attr("val")),t.isEmpty(s)||n.val(s).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().trim(),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").trim()},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"),r=s.exec(e);return null===r?{value:"",unit:""}:{value:r[1],unit:void 0===r[2]?"":r[2]}},setupMeasurementField:function(i,s){var r=this,n=i.parent();s=t.extend({defaultUnit:"px"},s),i.hide(),n.addClass(this.wrapperClass).data("unit",s.defaultUnit);for(var o=e('<input type="text" class="socss-field-input"/>').appendTo(n),a=e('<span class="dashicons dashicons-arrow-down"></span>').appendTo(n),l=e('<ul class="dropdown"></ul>').appendTo(n),c=e('<span class="units"></span>').html(s.defaultUnit).appendTo(n),p=0;p<r.units.length;p++){var d=e("<li></li>").html(r.units[p]).data("unit",r.units[p]);r.units[p]===s.defaultUnit&&d.addClass("active"),l.append(d)}var h=function(){var e=r.parseUnits(o.val());""!==e.unit&&e.unit!==n.data("unit")&&(o.val(e.value),u(e.unit)),""===e.value?i.val(""):i.val(e.value+n.data("unit"))},u=function(e){c.html(e),n.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"),r=s.width();r=Math.min(r,63),s.remove(),c.css("left",r+12)}),o.on("keyup",function(e){h(),i.trigger("change")}),i.on("measurement_refresh",function(){var t=r.parseUnits(i.val());o.val(t.value);var a=""===t.unit?s.defaultUnit:t.unit;n.data("unit",a),c.html(a);var l=e('<span class="socss-hidden-placeholder"></span>').css({"font-size":"14px"}).html(t.value).appendTo("body"),p=l.width();p=Math.min(p,63),l.remove(),c.css("left",p+12)});var v=e('<div class="socss-diw"></div>').appendTo(n),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=r.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=r.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 r=i.parent();r.addClass("socss-field-number");var n=e('<div class="socss-diw"></div>').appendTo(r),o=e('<div class="dec-button socss-button">-</div>').appendTo(n);e('<div class="inc-button socss-button">+</div>').appendTo(n);return n.find("> div").click(function(t){t.preventDefault();var r=s["default"];""!==i.val()&&(r=Number(i.val())),r+=e(this).is(o)?s.decrement:s.increment,r=Math.round(100*r)/100,null!==s.max&&(r=Math.min(s.max,r)),null!==s.min&&(r=Math.max(s.min,r)),i.val(r),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 r=e(this).data("direction"),n=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"===r?a.args.propertyAll:a.args.property.replace("{dir}",r);var c=t.extend({},a.args,{property:l}),p=new s.view.properties.controllers[a.type]({el:e("<div>").appendTo(n),propertiesView:i.propertiesView,args:c});p.render(),p.initChangeEvents(),i.propertiesView.propertyControllers.push(p)}e(this).on("click",function(){i.$(".select-tab").removeClass("active"),e(this).addClass("active"),i.$(".sides .side").hide(),n.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"))})});
|
lang/so-css.pot
ADDED
@@ -0,0 +1,506 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Copyright (C) 2017 so-css
|
2 |
+
# This file is distributed under the same license as the so-css package.
|
3 |
+
msgid ""
|
4 |
+
msgstr ""
|
5 |
+
"Project-Id-Version: so-css\n"
|
6 |
+
"Report-Msgid-Bugs-To: http://www.siteorigin.com\n"
|
7 |
+
"MIME-Version: 1.0\n"
|
8 |
+
"Content-Type: text/plain; charset=UTF-8\n"
|
9 |
+
"Content-Transfer-Encoding: 8bit\n"
|
10 |
+
"PO-Revision-Date: 2017-MO-DA HO:MI+ZONE\n"
|
11 |
+
"Last-Translator: SiteOrigin <support@siteorigin.com>\n"
|
12 |
+
"Language-Team: SiteOrigin <support@siteorigin.com>\n"
|
13 |
+
"X-Poedit-Basepath: ..\n"
|
14 |
+
"X-Poedit-SourceCharset: UTF-8\n"
|
15 |
+
"X-Poedit-KeywordsList: __;_e;_n:1,2;_x:1,2c;_ex:1,2c;_nx:4c,1,2;esc_attr__;esc_attr_e;esc_attr_x:1,2c;esc_html__;esc_html_e;esc_html_x:1,2c;_n_noop:1,2;_nx_noop:3c,1,2;__ngettext_noop:1,2\n"
|
16 |
+
"X-Poedit-SearchPath-0: .\n"
|
17 |
+
"X-Poedit-SearchPathExcluded-0: *.js\n"
|
18 |
+
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
|
19 |
+
|
20 |
+
#: tmp/inc/controller-config.php:5
|
21 |
+
msgid "Text"
|
22 |
+
msgstr ""
|
23 |
+
|
24 |
+
#: tmp/inc/controller-config.php:9
|
25 |
+
msgid "Text Color"
|
26 |
+
msgstr ""
|
27 |
+
|
28 |
+
#: tmp/inc/controller-config.php:16
|
29 |
+
msgid "Font Size"
|
30 |
+
msgstr ""
|
31 |
+
|
32 |
+
#: tmp/inc/controller-config.php:24
|
33 |
+
msgid "Line Height"
|
34 |
+
msgstr ""
|
35 |
+
|
36 |
+
#: tmp/inc/controller-config.php:32
|
37 |
+
msgid "Font Weight"
|
38 |
+
msgstr ""
|
39 |
+
|
40 |
+
#: tmp/inc/controller-config.php:37, tmp/inc/controller-config.php:60, tmp/inc/controller-config.php:93, tmp/inc/controller-config.php:164
|
41 |
+
msgid "Normal"
|
42 |
+
msgstr ""
|
43 |
+
|
44 |
+
#: tmp/inc/controller-config.php:38
|
45 |
+
msgid "Bold"
|
46 |
+
msgstr ""
|
47 |
+
|
48 |
+
#: tmp/inc/controller-config.php:39
|
49 |
+
msgid "Bolder"
|
50 |
+
msgstr ""
|
51 |
+
|
52 |
+
#: tmp/inc/controller-config.php:40
|
53 |
+
msgid "Lighter"
|
54 |
+
msgstr ""
|
55 |
+
|
56 |
+
#: tmp/inc/controller-config.php:54
|
57 |
+
msgid "Font Style"
|
58 |
+
msgstr ""
|
59 |
+
|
60 |
+
#: tmp/inc/controller-config.php:59, tmp/inc/controller-config.php:75, tmp/inc/controller-config.php:104, tmp/inc/controller-config.php:397, tmp/inc/controller-config.php:424, tmp/inc/controller-config.php:436
|
61 |
+
msgid "None"
|
62 |
+
msgstr ""
|
63 |
+
|
64 |
+
#: tmp/inc/controller-config.php:61
|
65 |
+
msgid "Italic"
|
66 |
+
msgstr ""
|
67 |
+
|
68 |
+
#: tmp/inc/controller-config.php:70
|
69 |
+
msgid "Text Decoration"
|
70 |
+
msgstr ""
|
71 |
+
|
72 |
+
#: tmp/inc/controller-config.php:76
|
73 |
+
msgid "Underline"
|
74 |
+
msgstr ""
|
75 |
+
|
76 |
+
#: tmp/inc/controller-config.php:77
|
77 |
+
msgid "Overline"
|
78 |
+
msgstr ""
|
79 |
+
|
80 |
+
#: tmp/inc/controller-config.php:78
|
81 |
+
msgid "Line Through"
|
82 |
+
msgstr ""
|
83 |
+
|
84 |
+
#: tmp/inc/controller-config.php:88
|
85 |
+
msgid "Font Variant"
|
86 |
+
msgstr ""
|
87 |
+
|
88 |
+
#: tmp/inc/controller-config.php:94
|
89 |
+
msgid "Small Caps"
|
90 |
+
msgstr ""
|
91 |
+
|
92 |
+
#: tmp/inc/controller-config.php:99
|
93 |
+
msgid "Text Transform"
|
94 |
+
msgstr ""
|
95 |
+
|
96 |
+
#: tmp/inc/controller-config.php:105
|
97 |
+
msgid "Capitalize"
|
98 |
+
msgstr ""
|
99 |
+
|
100 |
+
#: tmp/inc/controller-config.php:106
|
101 |
+
msgid "Uppercase"
|
102 |
+
msgstr ""
|
103 |
+
|
104 |
+
#: tmp/inc/controller-config.php:107
|
105 |
+
msgid "Lowercase"
|
106 |
+
msgstr ""
|
107 |
+
|
108 |
+
#: tmp/inc/controller-config.php:112
|
109 |
+
msgid "Font Family"
|
110 |
+
msgstr ""
|
111 |
+
|
112 |
+
#: tmp/inc/controller-config.php:119
|
113 |
+
msgid "Text Align"
|
114 |
+
msgstr ""
|
115 |
+
|
116 |
+
#: tmp/inc/controller-config.php:124, tmp/inc/controller-config.php:425, tmp/inc/controller-config.php:437
|
117 |
+
msgid "Left"
|
118 |
+
msgstr ""
|
119 |
+
|
120 |
+
#: tmp/inc/controller-config.php:125, tmp/inc/controller-config.php:426, tmp/inc/controller-config.php:438
|
121 |
+
msgid "Right"
|
122 |
+
msgstr ""
|
123 |
+
|
124 |
+
#: tmp/inc/controller-config.php:126
|
125 |
+
msgid "Center"
|
126 |
+
msgstr ""
|
127 |
+
|
128 |
+
#: tmp/inc/controller-config.php:127
|
129 |
+
msgid "Justify"
|
130 |
+
msgstr ""
|
131 |
+
|
132 |
+
#: tmp/inc/controller-config.php:138
|
133 |
+
msgid "Text Indent"
|
134 |
+
msgstr ""
|
135 |
+
|
136 |
+
#: tmp/inc/controller-config.php:145
|
137 |
+
msgid "Letter Spacing"
|
138 |
+
msgstr ""
|
139 |
+
|
140 |
+
#: tmp/inc/controller-config.php:152
|
141 |
+
msgid "Word Spacing"
|
142 |
+
msgstr ""
|
143 |
+
|
144 |
+
#: tmp/inc/controller-config.php:159
|
145 |
+
msgid "White Space"
|
146 |
+
msgstr ""
|
147 |
+
|
148 |
+
#: tmp/inc/controller-config.php:165
|
149 |
+
msgid "Encountered"
|
150 |
+
msgstr ""
|
151 |
+
|
152 |
+
#: tmp/inc/controller-config.php:166
|
153 |
+
msgid "Pre"
|
154 |
+
msgstr ""
|
155 |
+
|
156 |
+
#: tmp/inc/controller-config.php:167
|
157 |
+
msgid "Pre Line"
|
158 |
+
msgstr ""
|
159 |
+
|
160 |
+
#: tmp/inc/controller-config.php:168
|
161 |
+
msgid "Pre Wrap"
|
162 |
+
msgstr ""
|
163 |
+
|
164 |
+
#: tmp/inc/controller-config.php:173
|
165 |
+
msgid "Text Shadow"
|
166 |
+
msgstr ""
|
167 |
+
|
168 |
+
#: tmp/inc/controller-config.php:185
|
169 |
+
msgid "Decoration"
|
170 |
+
msgstr ""
|
171 |
+
|
172 |
+
#: tmp/inc/controller-config.php:189
|
173 |
+
msgid "Background Color"
|
174 |
+
msgstr ""
|
175 |
+
|
176 |
+
#: tmp/inc/controller-config.php:196
|
177 |
+
msgid "Background image"
|
178 |
+
msgstr ""
|
179 |
+
|
180 |
+
#: tmp/inc/controller-config.php:204
|
181 |
+
msgid "Background Position"
|
182 |
+
msgstr ""
|
183 |
+
|
184 |
+
#: tmp/inc/controller-config.php:211
|
185 |
+
msgid "Background Repeat"
|
186 |
+
msgstr ""
|
187 |
+
|
188 |
+
#: tmp/inc/controller-config.php:216
|
189 |
+
msgid "repeat"
|
190 |
+
msgstr ""
|
191 |
+
|
192 |
+
#: tmp/inc/controller-config.php:217
|
193 |
+
msgid "repeat-x"
|
194 |
+
msgstr ""
|
195 |
+
|
196 |
+
#: tmp/inc/controller-config.php:218
|
197 |
+
msgid "repeat-y"
|
198 |
+
msgstr ""
|
199 |
+
|
200 |
+
#: tmp/inc/controller-config.php:219
|
201 |
+
msgid "no-repeat"
|
202 |
+
msgstr ""
|
203 |
+
|
204 |
+
#: tmp/inc/controller-config.php:224
|
205 |
+
msgid "Background Size"
|
206 |
+
msgstr ""
|
207 |
+
|
208 |
+
#: tmp/inc/controller-config.php:229
|
209 |
+
msgid "auto"
|
210 |
+
msgstr ""
|
211 |
+
|
212 |
+
#: tmp/inc/controller-config.php:230
|
213 |
+
msgid "length"
|
214 |
+
msgstr ""
|
215 |
+
|
216 |
+
#: tmp/inc/controller-config.php:231
|
217 |
+
msgid "percentage"
|
218 |
+
msgstr ""
|
219 |
+
|
220 |
+
#: tmp/inc/controller-config.php:232
|
221 |
+
msgid "cover"
|
222 |
+
msgstr ""
|
223 |
+
|
224 |
+
#: tmp/inc/controller-config.php:233
|
225 |
+
msgid "contain"
|
226 |
+
msgstr ""
|
227 |
+
|
228 |
+
#: tmp/inc/controller-config.php:239
|
229 |
+
msgid "Box Shadow"
|
230 |
+
msgstr ""
|
231 |
+
|
232 |
+
#: tmp/inc/controller-config.php:247
|
233 |
+
msgid "Opacity"
|
234 |
+
msgstr ""
|
235 |
+
|
236 |
+
#: tmp/inc/controller-config.php:260
|
237 |
+
msgid "Borders"
|
238 |
+
msgstr ""
|
239 |
+
|
240 |
+
#: tmp/inc/controller-config.php:308
|
241 |
+
msgid "Layout"
|
242 |
+
msgstr ""
|
243 |
+
|
244 |
+
#: tmp/inc/controller-config.php:312
|
245 |
+
msgid "Margin"
|
246 |
+
msgstr ""
|
247 |
+
|
248 |
+
#: tmp/inc/controller-config.php:329
|
249 |
+
msgid "Padding"
|
250 |
+
msgstr ""
|
251 |
+
|
252 |
+
#: tmp/inc/controller-config.php:346
|
253 |
+
msgid "Position"
|
254 |
+
msgstr ""
|
255 |
+
|
256 |
+
#: tmp/inc/controller-config.php:351
|
257 |
+
msgid "Absolute"
|
258 |
+
msgstr ""
|
259 |
+
|
260 |
+
#: tmp/inc/controller-config.php:352
|
261 |
+
msgid "Fixed"
|
262 |
+
msgstr ""
|
263 |
+
|
264 |
+
#: tmp/inc/controller-config.php:353
|
265 |
+
msgid "Relative"
|
266 |
+
msgstr ""
|
267 |
+
|
268 |
+
#: tmp/inc/controller-config.php:354
|
269 |
+
msgid "Static"
|
270 |
+
msgstr ""
|
271 |
+
|
272 |
+
#: tmp/inc/controller-config.php:355
|
273 |
+
msgid "Inherit"
|
274 |
+
msgstr ""
|
275 |
+
|
276 |
+
#: tmp/inc/controller-config.php:360
|
277 |
+
msgid "Absolute Position"
|
278 |
+
msgstr ""
|
279 |
+
|
280 |
+
#: tmp/inc/controller-config.php:376
|
281 |
+
msgid "Width"
|
282 |
+
msgstr ""
|
283 |
+
|
284 |
+
#: tmp/inc/controller-config.php:384
|
285 |
+
msgid "Height"
|
286 |
+
msgstr ""
|
287 |
+
|
288 |
+
#: tmp/inc/controller-config.php:392
|
289 |
+
msgid "Display"
|
290 |
+
msgstr ""
|
291 |
+
|
292 |
+
#: tmp/inc/controller-config.php:398
|
293 |
+
msgid "Inline"
|
294 |
+
msgstr ""
|
295 |
+
|
296 |
+
#: tmp/inc/controller-config.php:399
|
297 |
+
msgid "Block"
|
298 |
+
msgstr ""
|
299 |
+
|
300 |
+
#: tmp/inc/controller-config.php:400
|
301 |
+
msgid "Flex"
|
302 |
+
msgstr ""
|
303 |
+
|
304 |
+
#: tmp/inc/controller-config.php:401
|
305 |
+
msgid "Inline Block"
|
306 |
+
msgstr ""
|
307 |
+
|
308 |
+
#: tmp/inc/controller-config.php:402
|
309 |
+
msgid "Inline Flex"
|
310 |
+
msgstr ""
|
311 |
+
|
312 |
+
#: tmp/inc/controller-config.php:403
|
313 |
+
msgid "Inline Table"
|
314 |
+
msgstr ""
|
315 |
+
|
316 |
+
#: tmp/inc/controller-config.php:404
|
317 |
+
msgid "List Item"
|
318 |
+
msgstr ""
|
319 |
+
|
320 |
+
#: tmp/inc/controller-config.php:405
|
321 |
+
msgid "Run In"
|
322 |
+
msgstr ""
|
323 |
+
|
324 |
+
#: tmp/inc/controller-config.php:406
|
325 |
+
msgid "Table"
|
326 |
+
msgstr ""
|
327 |
+
|
328 |
+
#: tmp/inc/controller-config.php:407
|
329 |
+
msgid "Table Caption"
|
330 |
+
msgstr ""
|
331 |
+
|
332 |
+
#: tmp/inc/controller-config.php:408
|
333 |
+
msgid "Table Column Group"
|
334 |
+
msgstr ""
|
335 |
+
|
336 |
+
#: tmp/inc/controller-config.php:409
|
337 |
+
msgid "Table Header Group"
|
338 |
+
msgstr ""
|
339 |
+
|
340 |
+
#: tmp/inc/controller-config.php:410
|
341 |
+
msgid "Table Footer Group"
|
342 |
+
msgstr ""
|
343 |
+
|
344 |
+
#: tmp/inc/controller-config.php:411
|
345 |
+
msgid "Table Row Group"
|
346 |
+
msgstr ""
|
347 |
+
|
348 |
+
#: tmp/inc/controller-config.php:412
|
349 |
+
msgid "Table Cell"
|
350 |
+
msgstr ""
|
351 |
+
|
352 |
+
#: tmp/inc/controller-config.php:413
|
353 |
+
msgid "Table Column"
|
354 |
+
msgstr ""
|
355 |
+
|
356 |
+
#: tmp/inc/controller-config.php:414
|
357 |
+
msgid "Table Row"
|
358 |
+
msgstr ""
|
359 |
+
|
360 |
+
#: tmp/inc/controller-config.php:419
|
361 |
+
msgid "Float"
|
362 |
+
msgstr ""
|
363 |
+
|
364 |
+
#: tmp/inc/controller-config.php:431
|
365 |
+
msgid "Clear"
|
366 |
+
msgstr ""
|
367 |
+
|
368 |
+
#: tmp/inc/controller-config.php:439
|
369 |
+
msgid "Both"
|
370 |
+
msgstr ""
|
371 |
+
|
372 |
+
#: tmp/inc/controller-config.php:444
|
373 |
+
msgid "Visibility"
|
374 |
+
msgstr ""
|
375 |
+
|
376 |
+
#: tmp/inc/controller-config.php:449, tmp/inc/controller-config.php:461, tmp/inc/controller-config.php:474, tmp/inc/controller-config.php:487
|
377 |
+
msgid "Visible"
|
378 |
+
msgstr ""
|
379 |
+
|
380 |
+
#: tmp/inc/controller-config.php:450, tmp/inc/controller-config.php:462, tmp/inc/controller-config.php:475, tmp/inc/controller-config.php:488
|
381 |
+
msgid "Hidden"
|
382 |
+
msgstr ""
|
383 |
+
|
384 |
+
#: tmp/inc/controller-config.php:451
|
385 |
+
msgid "Collapse"
|
386 |
+
msgstr ""
|
387 |
+
|
388 |
+
#: tmp/inc/controller-config.php:456
|
389 |
+
msgid "Overflow"
|
390 |
+
msgstr ""
|
391 |
+
|
392 |
+
#: tmp/inc/controller-config.php:463, tmp/inc/controller-config.php:476, tmp/inc/controller-config.php:489
|
393 |
+
msgid "Scroll"
|
394 |
+
msgstr ""
|
395 |
+
|
396 |
+
#: tmp/inc/controller-config.php:464, tmp/inc/controller-config.php:477, tmp/inc/controller-config.php:490
|
397 |
+
msgid "Auto"
|
398 |
+
msgstr ""
|
399 |
+
|
400 |
+
#: tmp/inc/controller-config.php:469
|
401 |
+
msgid "Overflow X"
|
402 |
+
msgstr ""
|
403 |
+
|
404 |
+
#: tmp/inc/controller-config.php:482
|
405 |
+
msgid "Overflow Y"
|
406 |
+
msgstr ""
|
407 |
+
|
408 |
+
#: tmp/inc/controller-config.php:495
|
409 |
+
msgid "Z-Index"
|
410 |
+
msgstr ""
|
411 |
+
|
412 |
+
#: tmp/so-css.php:96, tmp/so-css.php:96, tmp/so-css.php:138
|
413 |
+
msgid "Custom CSS"
|
414 |
+
msgstr ""
|
415 |
+
|
416 |
+
#: tmp/so-css.php:140
|
417 |
+
msgid "SiteOrigin CSS adds any custom CSS you enter here into your site's header. "
|
418 |
+
msgstr ""
|
419 |
+
|
420 |
+
#: tmp/so-css.php:141
|
421 |
+
msgid "These changes will persist across updates so it's best to make all your changes here. "
|
422 |
+
msgstr ""
|
423 |
+
|
424 |
+
#: tmp/so-css.php:195
|
425 |
+
msgid "Unchanged"
|
426 |
+
msgstr ""
|
427 |
+
|
428 |
+
#: tmp/so-css.php:196
|
429 |
+
msgid "Select"
|
430 |
+
msgstr ""
|
431 |
+
|
432 |
+
#: tmp/so-css.php:197
|
433 |
+
msgid "Select Image"
|
434 |
+
msgstr ""
|
435 |
+
|
436 |
+
#: tmp/so-css.php:198
|
437 |
+
msgid "Are you sure you want to leave without saving?"
|
438 |
+
msgstr ""
|
439 |
+
|
440 |
+
#: tmp/so-css.php:234
|
441 |
+
msgid "CSS Editor"
|
442 |
+
msgstr ""
|
443 |
+
|
444 |
+
#: tmp/so-css.php:235
|
445 |
+
msgid "Support"
|
446 |
+
msgstr ""
|
447 |
+
|
448 |
+
#: tmp/so-css.php:373
|
449 |
+
msgid "Changes apply to %s and its child themes"
|
450 |
+
msgstr ""
|
451 |
+
|
452 |
+
#: tmp/tpl/inspector-templates.php:4
|
453 |
+
msgid "Navigate To: "
|
454 |
+
msgstr ""
|
455 |
+
|
456 |
+
#: tmp/tpl/js-templates.php:8
|
457 |
+
msgid "CSS Snippets"
|
458 |
+
msgstr ""
|
459 |
+
|
460 |
+
#: tmp/tpl/js-templates.php:14
|
461 |
+
msgid "Search Snippets"
|
462 |
+
msgstr ""
|
463 |
+
|
464 |
+
#: tmp/tpl/js-templates.php:26
|
465 |
+
msgid "Insert Snippet"
|
466 |
+
msgstr ""
|
467 |
+
|
468 |
+
#: tmp/tpl/js-templates.php:51
|
469 |
+
msgid "Invalid URI. Please make sure you're using a URL from the same site."
|
470 |
+
msgstr ""
|
471 |
+
|
472 |
+
#: tmp/tpl/page.php:13
|
473 |
+
msgid "SiteOrigin CSS"
|
474 |
+
msgstr ""
|
475 |
+
|
476 |
+
#: tmp/tpl/page.php:18
|
477 |
+
msgid "Site design updated."
|
478 |
+
msgstr ""
|
479 |
+
|
480 |
+
#: tmp/tpl/page.php:23
|
481 |
+
msgid "Viewing a revision. Save CSS to keep using this revision."
|
482 |
+
msgstr ""
|
483 |
+
|
484 |
+
#: tmp/tpl/page.php:33
|
485 |
+
msgid "Getting Started Video"
|
486 |
+
msgstr ""
|
487 |
+
|
488 |
+
#: tmp/tpl/page.php:34
|
489 |
+
msgid "Dismiss"
|
490 |
+
msgstr ""
|
491 |
+
|
492 |
+
#: tmp/tpl/page.php:43
|
493 |
+
msgid "CSS Revisions"
|
494 |
+
msgstr ""
|
495 |
+
|
496 |
+
#: tmp/tpl/page.php:45
|
497 |
+
msgid "Are you sure you want to load this revision?"
|
498 |
+
msgstr ""
|
499 |
+
|
500 |
+
#: tmp/tpl/page.php:57
|
501 |
+
msgid "%d chars"
|
502 |
+
msgstr ""
|
503 |
+
|
504 |
+
#: tmp/tpl/page.php:101
|
505 |
+
msgid "Save CSS"
|
506 |
+
msgstr ""
|
lib/codemirror/addon/fold/indent-fold.js
CHANGED
@@ -11,32 +11,36 @@
|
|
11 |
})(function(CodeMirror) {
|
12 |
"use strict";
|
13 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
14 |
CodeMirror.registerHelper("fold", "indent", function(cm, start) {
|
15 |
-
var
|
16 |
-
if (
|
17 |
-
var
|
18 |
-
|
19 |
-
};
|
20 |
-
var myIndent = getIndent(firstLine);
|
21 |
-
var lastLineInFold = null;
|
22 |
// Go through lines until we find a line that definitely doesn't belong in
|
23 |
// the block we're folding, or to the end.
|
24 |
for (var i = start.line + 1, end = cm.lastLine(); i <= end; ++i) {
|
25 |
-
var
|
26 |
-
|
27 |
-
if (
|
28 |
// Lines with a greater indent are considered part of the block.
|
29 |
lastLineInFold = i;
|
30 |
-
} else if (!/\S/.test(curLine)) {
|
31 |
-
// Empty lines might be breaks within the block we're trying to fold.
|
32 |
} else {
|
33 |
-
//
|
34 |
-
// start
|
|
|
35 |
break;
|
36 |
}
|
37 |
}
|
38 |
if (lastLineInFold) return {
|
39 |
-
from: CodeMirror.Pos(start.line,
|
40 |
to: CodeMirror.Pos(lastLineInFold, cm.getLine(lastLineInFold).length)
|
41 |
};
|
42 |
});
|
11 |
})(function(CodeMirror) {
|
12 |
"use strict";
|
13 |
|
14 |
+
function lineIndent(cm, lineNo) {
|
15 |
+
var text = cm.getLine(lineNo)
|
16 |
+
var spaceTo = text.search(/\S/)
|
17 |
+
if (spaceTo == -1 || /\bcomment\b/.test(cm.getTokenTypeAt(CodeMirror.Pos(lineNo, spaceTo + 1))))
|
18 |
+
return -1
|
19 |
+
return CodeMirror.countColumn(text, null, cm.getOption("tabSize"))
|
20 |
+
}
|
21 |
+
!
|
22 |
CodeMirror.registerHelper("fold", "indent", function(cm, start) {
|
23 |
+
var myIndent = lineIndent(cm, start.line)
|
24 |
+
if (myIndent < 0) return
|
25 |
+
var lastLineInFold = null
|
26 |
+
|
|
|
|
|
|
|
27 |
// Go through lines until we find a line that definitely doesn't belong in
|
28 |
// the block we're folding, or to the end.
|
29 |
for (var i = start.line + 1, end = cm.lastLine(); i <= end; ++i) {
|
30 |
+
var indent = lineIndent(cm, i)
|
31 |
+
if (indent == -1) {
|
32 |
+
} else if (indent > myIndent) {
|
33 |
// Lines with a greater indent are considered part of the block.
|
34 |
lastLineInFold = i;
|
|
|
|
|
35 |
} else {
|
36 |
+
// If this line has non-space, non-comment content, and is
|
37 |
+
// indented less or equal to the start line, it is the start of
|
38 |
+
// another block.
|
39 |
break;
|
40 |
}
|
41 |
}
|
42 |
if (lastLineInFold) return {
|
43 |
+
from: CodeMirror.Pos(start.line, cm.getLine(start.line).length),
|
44 |
to: CodeMirror.Pos(lastLineInFold, cm.getLine(lastLineInFold).length)
|
45 |
};
|
46 |
});
|
lib/codemirror/addon/fold/indent-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","indent",function(t,
|
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 n(n,t){var i=n.getLine(t),o=i.search(/\S/);return o==-1||/\bcomment\b/.test(n.getTokenTypeAt(e.Pos(t,o+1)))?-1:e.countColumn(i,null,n.getOption("tabSize"))}!e.registerHelper("fold","indent",function(t,i){var o=n(t,i.line);if(!(o<0)){for(var r=null,l=i.line+1,f=t.lastLine();l<=f;++l){var u=n(t,l);if(u==-1);else{if(!(u>o))break;r=l}}return r?{from:e.Pos(i.line,t.getLine(i.line).length),to:e.Pos(r,t.getLine(r).length)}:void 0}})});
|
lib/codemirror/addon/fold/xml-fold.js
CHANGED
@@ -163,10 +163,10 @@
|
|
163 |
}
|
164 |
};
|
165 |
|
166 |
-
CodeMirror.findEnclosingTag = function(cm, pos, range) {
|
167 |
var iter = new Iter(cm, pos.line, pos.ch, range);
|
168 |
for (;;) {
|
169 |
-
var open = findMatchingOpen(iter);
|
170 |
if (!open) break;
|
171 |
var forward = new Iter(cm, pos.line, pos.ch, range);
|
172 |
var close = findMatchingClose(forward, open.tag);
|
163 |
}
|
164 |
};
|
165 |
|
166 |
+
CodeMirror.findEnclosingTag = function(cm, pos, range, tag) {
|
167 |
var iter = new Iter(cm, pos.line, pos.ch, range);
|
168 |
for (;;) {
|
169 |
+
var open = findMatchingOpen(iter, tag);
|
170 |
if (!open) break;
|
171 |
var forward = new Iter(cm, pos.line, pos.ch, range);
|
172 |
var close = findMatchingClose(forward, open.tag);
|
lib/codemirror/addon/fold/xml-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";function n(e,n){return e.line-n.line||e.ch-n.ch}function t(e,n,t,i){this.line=n,this.ch=t,this.cm=e,this.text=e.getLine(n),this.min=i?Math.max(i.from,e.firstLine()):e.firstLine(),this.max=i?Math.min(i.to-1,e.lastLine()):e.lastLine()}function i(e,n){var t=e.cm.getTokenTypeAt(h(e.line,n));return t&&/\btag\b/.test(t)}function r(e){if(!(e.line>=e.max))return e.ch=0,e.text=e.cm.getLine(++e.line),!0}function f(e){if(!(e.line<=e.min))return e.text=e.cm.getLine(--e.line),e.ch=e.text.length,!0}function o(e){for(;;){var n=e.text.indexOf(">",e.ch);if(n==-1){if(r(e))continue;return}{if(i(e,n+1)){var t=e.text.lastIndexOf("/",n),f=t>-1&&!/\S/.test(e.text.slice(t+1,n));return e.ch=n+1,f?"selfClose":"regular"}e.ch=n+1}}}function u(e){for(;;){var n=e.ch?e.text.lastIndexOf("<",e.ch-1):-1;if(n==-1){if(f(e))continue;return}if(i(e,n+1)){v.lastIndex=n,e.ch=n;var t=v.exec(e.text);if(t&&t.index==n)return t}else e.ch=n}}function l(e){for(;;){v.lastIndex=e.ch;var n=v.exec(e.text);if(!n){if(r(e))continue;return}{if(i(e,n.index+1))return e.ch=n.index+n[0].length,n;e.ch=n.index+1}}}function c(e){for(;;){var n=e.ch?e.text.lastIndexOf(">",e.ch-1):-1;if(n==-1){if(f(e))continue;return}{if(i(e,n+1)){var t=e.text.lastIndexOf("/",n),r=t>-1&&!/\S/.test(e.text.slice(t+1,n));return e.ch=n+1,r?"selfClose":"regular"}e.ch=n}}}function a(e,n){for(var t=[];;){var i,r=l(e),f=e.line,u=e.ch-(r?r[0].length:0);if(!r||!(i=o(e)))return;if("selfClose"!=i)if(r[1]){for(var c=t.length-1;c>=0;--c)if(t[c]==r[2]){t.length=c;break}if(c<0&&(!n||n==r[2]))return{tag:r[2],from:h(f,u),to:h(e.line,e.ch)}}else t.push(r[2])}}function s(e,n){for(var t=[];;){var i=c(e);if(!i)return;if("selfClose"!=i){var r=e.line,f=e.ch,o=u(e);if(!o)return;if(o[1])t.push(o[2]);else{for(var l=t.length-1;l>=0;--l)if(t[l]==o[2]){t.length=l;break}if(l<0&&(!n||n==o[2]))return{tag:o[2],from:h(e.line,e.ch),to:h(r,f)}}}else u(e)}}var h=e.Pos,x="A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD",g=x+"-:.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040",v=new RegExp("<(/?)(["+x+"]["+g+"]*)","g");e.registerHelper("fold","xml",function(e,n){for(var i=new t(e,n.line,0);;){var r,f=l(i);if(!f||i.line!=n.line||!(r=o(i)))return;if(!f[1]&&"selfClose"!=r){var u=h(i.line,i.ch),c=a(i,f[2]);return c&&{from:u,to:c.from}}}}),e.findMatchingTag=function(e,i,r){var f=new t(e,i.line,i.ch,r);if(f.text.indexOf(">")!=-1||f.text.indexOf("<")!=-1){var l=o(f),c=l&&h(f.line,f.ch),x=l&&u(f);if(l&&x&&!(n(f,i)>0)){var g={from:h(f.line,f.ch),to:c,tag:x[2]};return"selfClose"==l?{open:g,close:null,at:"open"}:x[1]?{open:s(f,x[2]),close:g,at:"close"}:(f=new t(e,c.line,c.ch,r),{open:g,close:a(f,x[2]),at:"open"})}}},e.findEnclosingTag=function(e,n,i){for(var
|
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 n(e,n){return e.line-n.line||e.ch-n.ch}function t(e,n,t,i){this.line=n,this.ch=t,this.cm=e,this.text=e.getLine(n),this.min=i?Math.max(i.from,e.firstLine()):e.firstLine(),this.max=i?Math.min(i.to-1,e.lastLine()):e.lastLine()}function i(e,n){var t=e.cm.getTokenTypeAt(h(e.line,n));return t&&/\btag\b/.test(t)}function r(e){if(!(e.line>=e.max))return e.ch=0,e.text=e.cm.getLine(++e.line),!0}function f(e){if(!(e.line<=e.min))return e.text=e.cm.getLine(--e.line),e.ch=e.text.length,!0}function o(e){for(;;){var n=e.text.indexOf(">",e.ch);if(n==-1){if(r(e))continue;return}{if(i(e,n+1)){var t=e.text.lastIndexOf("/",n),f=t>-1&&!/\S/.test(e.text.slice(t+1,n));return e.ch=n+1,f?"selfClose":"regular"}e.ch=n+1}}}function u(e){for(;;){var n=e.ch?e.text.lastIndexOf("<",e.ch-1):-1;if(n==-1){if(f(e))continue;return}if(i(e,n+1)){v.lastIndex=n,e.ch=n;var t=v.exec(e.text);if(t&&t.index==n)return t}else e.ch=n}}function l(e){for(;;){v.lastIndex=e.ch;var n=v.exec(e.text);if(!n){if(r(e))continue;return}{if(i(e,n.index+1))return e.ch=n.index+n[0].length,n;e.ch=n.index+1}}}function c(e){for(;;){var n=e.ch?e.text.lastIndexOf(">",e.ch-1):-1;if(n==-1){if(f(e))continue;return}{if(i(e,n+1)){var t=e.text.lastIndexOf("/",n),r=t>-1&&!/\S/.test(e.text.slice(t+1,n));return e.ch=n+1,r?"selfClose":"regular"}e.ch=n}}}function a(e,n){for(var t=[];;){var i,r=l(e),f=e.line,u=e.ch-(r?r[0].length:0);if(!r||!(i=o(e)))return;if("selfClose"!=i)if(r[1]){for(var c=t.length-1;c>=0;--c)if(t[c]==r[2]){t.length=c;break}if(c<0&&(!n||n==r[2]))return{tag:r[2],from:h(f,u),to:h(e.line,e.ch)}}else t.push(r[2])}}function s(e,n){for(var t=[];;){var i=c(e);if(!i)return;if("selfClose"!=i){var r=e.line,f=e.ch,o=u(e);if(!o)return;if(o[1])t.push(o[2]);else{for(var l=t.length-1;l>=0;--l)if(t[l]==o[2]){t.length=l;break}if(l<0&&(!n||n==o[2]))return{tag:o[2],from:h(e.line,e.ch),to:h(r,f)}}}else u(e)}}var h=e.Pos,x="A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD",g=x+"-:.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040",v=new RegExp("<(/?)(["+x+"]["+g+"]*)","g");e.registerHelper("fold","xml",function(e,n){for(var i=new t(e,n.line,0);;){var r,f=l(i);if(!f||i.line!=n.line||!(r=o(i)))return;if(!f[1]&&"selfClose"!=r){var u=h(i.line,i.ch),c=a(i,f[2]);return c&&{from:u,to:c.from}}}}),e.findMatchingTag=function(e,i,r){var f=new t(e,i.line,i.ch,r);if(f.text.indexOf(">")!=-1||f.text.indexOf("<")!=-1){var l=o(f),c=l&&h(f.line,f.ch),x=l&&u(f);if(l&&x&&!(n(f,i)>0)){var g={from:h(f.line,f.ch),to:c,tag:x[2]};return"selfClose"==l?{open:g,close:null,at:"open"}:x[1]?{open:s(f,x[2]),close:g,at:"close"}:(f=new t(e,c.line,c.ch,r),{open:g,close:a(f,x[2]),at:"open"})}}},e.findEnclosingTag=function(e,n,i,r){for(var f=new t(e,n.line,n.ch,i);;){var o=s(f,r);if(!o)break;var u=new t(e,n.line,n.ch,i),l=a(u,o.tag);if(l)return{open:o,close:l}}},e.scanForClosingTag=function(e,n,i,r){var f=new t(e,n.line,n.ch,r?{from:0,to:r}:null);return a(f,i)}});
|
lib/codemirror/addon/hint/sql-hint.js
CHANGED
@@ -14,6 +14,7 @@
|
|
14 |
var tables;
|
15 |
var defaultTable;
|
16 |
var keywords;
|
|
|
17 |
var CONS = {
|
18 |
QUERY_DIV: ";",
|
19 |
ALIAS_KEYWORD: "AS"
|
@@ -28,6 +29,12 @@
|
|
28 |
return CodeMirror.resolveMode(mode).keywords;
|
29 |
}
|
30 |
|
|
|
|
|
|
|
|
|
|
|
|
|
31 |
function getText(item) {
|
32 |
return typeof item == "string" ? item : item.text;
|
33 |
}
|
@@ -86,17 +93,25 @@
|
|
86 |
}
|
87 |
|
88 |
function cleanName(name) {
|
89 |
-
// Get rid name from
|
90 |
if (name.charAt(0) == ".") {
|
91 |
name = name.substr(1);
|
92 |
}
|
93 |
-
|
|
|
|
|
|
|
|
|
|
|
94 |
}
|
95 |
|
96 |
-
function
|
97 |
var nameParts = getText(name).split(".");
|
98 |
for (var i = 0; i < nameParts.length; i++)
|
99 |
-
nameParts[i] =
|
|
|
|
|
|
|
100 |
var escaped = nameParts.join(".");
|
101 |
if (typeof name == "string") return escaped;
|
102 |
name = shallowClone(name);
|
@@ -106,13 +121,13 @@
|
|
106 |
|
107 |
function nameCompletion(cur, token, result, editor) {
|
108 |
// Try to complete table, column names and return start position of completion
|
109 |
-
var
|
110 |
var nameParts = [];
|
111 |
var start = token.start;
|
112 |
var cont = true;
|
113 |
while (cont) {
|
114 |
cont = (token.string.charAt(0) == ".");
|
115 |
-
|
116 |
|
117 |
start = token.start;
|
118 |
nameParts.unshift(cleanName(token.string));
|
@@ -127,12 +142,12 @@
|
|
127 |
// Try to complete table names
|
128 |
var string = nameParts.join(".");
|
129 |
addMatches(result, string, tables, function(w) {
|
130 |
-
return
|
131 |
});
|
132 |
|
133 |
// Try to complete columns from defaultTable
|
134 |
addMatches(result, string, defaultTable, function(w) {
|
135 |
-
return
|
136 |
});
|
137 |
|
138 |
// Try to complete columns
|
@@ -162,7 +177,7 @@
|
|
162 |
w = shallowClone(w);
|
163 |
w.text = tableInsert + "." + w.text;
|
164 |
}
|
165 |
-
return
|
166 |
});
|
167 |
}
|
168 |
|
@@ -232,6 +247,7 @@
|
|
232 |
var disableKeywords = options && options.disableKeywords;
|
233 |
defaultTable = defaultTableName && getTable(defaultTableName);
|
234 |
keywords = getKeywords(editor);
|
|
|
235 |
|
236 |
if (defaultTableName && !defaultTable)
|
237 |
defaultTable = findTableByAlias(defaultTableName, editor);
|
@@ -249,7 +265,7 @@
|
|
249 |
token.string = token.string.slice(0, cur.ch - token.start);
|
250 |
}
|
251 |
|
252 |
-
if (token.string.match(/^[
|
253 |
search = token.string;
|
254 |
start = token.start;
|
255 |
end = token.end;
|
@@ -257,7 +273,7 @@
|
|
257 |
start = end = cur.ch;
|
258 |
search = "";
|
259 |
}
|
260 |
-
if (search.charAt(0) == "." || search.charAt(0) ==
|
261 |
start = nameCompletion(cur, token, result, editor);
|
262 |
} else {
|
263 |
addMatches(result, search, tables, function(w) {return w;});
|
14 |
var tables;
|
15 |
var defaultTable;
|
16 |
var keywords;
|
17 |
+
var identifierQuote;
|
18 |
var CONS = {
|
19 |
QUERY_DIV: ";",
|
20 |
ALIAS_KEYWORD: "AS"
|
29 |
return CodeMirror.resolveMode(mode).keywords;
|
30 |
}
|
31 |
|
32 |
+
function getIdentifierQuote(editor) {
|
33 |
+
var mode = editor.doc.modeOption;
|
34 |
+
if (mode === "sql") mode = "text/x-sql";
|
35 |
+
return CodeMirror.resolveMode(mode).identifierQuote || "`";
|
36 |
+
}
|
37 |
+
|
38 |
function getText(item) {
|
39 |
return typeof item == "string" ? item : item.text;
|
40 |
}
|
93 |
}
|
94 |
|
95 |
function cleanName(name) {
|
96 |
+
// Get rid name from identifierQuote and preceding dot(.)
|
97 |
if (name.charAt(0) == ".") {
|
98 |
name = name.substr(1);
|
99 |
}
|
100 |
+
// replace doublicated identifierQuotes with single identifierQuotes
|
101 |
+
// and remove single identifierQuotes
|
102 |
+
var nameParts = name.split(identifierQuote+identifierQuote);
|
103 |
+
for (var i = 0; i < nameParts.length; i++)
|
104 |
+
nameParts[i] = nameParts[i].replace(new RegExp(identifierQuote,"g"), "");
|
105 |
+
return nameParts.join(identifierQuote);
|
106 |
}
|
107 |
|
108 |
+
function insertIdentifierQuotes(name) {
|
109 |
var nameParts = getText(name).split(".");
|
110 |
for (var i = 0; i < nameParts.length; i++)
|
111 |
+
nameParts[i] = identifierQuote +
|
112 |
+
// doublicate identifierQuotes
|
113 |
+
nameParts[i].replace(new RegExp(identifierQuote,"g"), identifierQuote+identifierQuote) +
|
114 |
+
identifierQuote;
|
115 |
var escaped = nameParts.join(".");
|
116 |
if (typeof name == "string") return escaped;
|
117 |
name = shallowClone(name);
|
121 |
|
122 |
function nameCompletion(cur, token, result, editor) {
|
123 |
// Try to complete table, column names and return start position of completion
|
124 |
+
var useIdentifierQuotes = false;
|
125 |
var nameParts = [];
|
126 |
var start = token.start;
|
127 |
var cont = true;
|
128 |
while (cont) {
|
129 |
cont = (token.string.charAt(0) == ".");
|
130 |
+
useIdentifierQuotes = useIdentifierQuotes || (token.string.charAt(0) == identifierQuote);
|
131 |
|
132 |
start = token.start;
|
133 |
nameParts.unshift(cleanName(token.string));
|
142 |
// Try to complete table names
|
143 |
var string = nameParts.join(".");
|
144 |
addMatches(result, string, tables, function(w) {
|
145 |
+
return useIdentifierQuotes ? insertIdentifierQuotes(w) : w;
|
146 |
});
|
147 |
|
148 |
// Try to complete columns from defaultTable
|
149 |
addMatches(result, string, defaultTable, function(w) {
|
150 |
+
return useIdentifierQuotes ? insertIdentifierQuotes(w) : w;
|
151 |
});
|
152 |
|
153 |
// Try to complete columns
|
177 |
w = shallowClone(w);
|
178 |
w.text = tableInsert + "." + w.text;
|
179 |
}
|
180 |
+
return useIdentifierQuotes ? insertIdentifierQuotes(w) : w;
|
181 |
});
|
182 |
}
|
183 |
|
247 |
var disableKeywords = options && options.disableKeywords;
|
248 |
defaultTable = defaultTableName && getTable(defaultTableName);
|
249 |
keywords = getKeywords(editor);
|
250 |
+
identifierQuote = getIdentifierQuote(editor);
|
251 |
|
252 |
if (defaultTableName && !defaultTable)
|
253 |
defaultTable = findTableByAlias(defaultTableName, editor);
|
265 |
token.string = token.string.slice(0, cur.ch - token.start);
|
266 |
}
|
267 |
|
268 |
+
if (token.string.match(/^[.`"\w@]\w*$/)) {
|
269 |
search = token.string;
|
270 |
start = token.start;
|
271 |
end = token.end;
|
273 |
start = end = cur.ch;
|
274 |
search = "";
|
275 |
}
|
276 |
+
if (search.charAt(0) == "." || search.charAt(0) == identifierQuote) {
|
277 |
start = nameCompletion(cur, token, result, editor);
|
278 |
} else {
|
279 |
addMatches(result, search, tables, function(w) {return w;});
|
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
|
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 e(t){return"[object Array]"==Object.prototype.toString.call(t)}function r(e){var r=e.doc.modeOption;return"sql"===r&&(r="text/x-sql"),t.resolveMode(r).keywords}function n(e){var r=e.doc.modeOption;return"sql"===r&&(r="text/x-sql"),t.resolveMode(r).identifierQuote||"`"}function o(t){return"string"==typeof t?t:t.text}function i(t,r){return e(r)&&(r={columns:r}),r.text||(r.text=t),r}function s(t){var r={};if(e(t))for(var n=t.length-1;n>=0;n--){var s=t[n];r[o(s).toUpperCase()]=i(o(s),s)}else if(t)for(var a in t)r[a.toUpperCase()]=i(a,t[a]);return r}function a(t){return h[t.toUpperCase()]}function u(t){var e={};for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r]);return e}function l(t,e){var r=t.length,n=o(e).substr(0,r);return t.toUpperCase()===n.toUpperCase()}function f(t,r,n,o){if(e(n))for(var i=0;i<n.length;i++)l(r,n[i])&&t.push(o(n[i]));else for(var s in n)if(n.hasOwnProperty(s)){var a=n[s];a=a&&a!==!0?a.displayText?{text:a.text,displayText:a.displayText}:a.text:s,l(r,a)&&t.push(o(a))}}function c(t){"."==t.charAt(0)&&(t=t.substr(1));for(var e=t.split(y+y),r=0;r<e.length;r++)e[r]=e[r].replace(new RegExp(y,"g"),"");return e.join(y)}function p(t){for(var e=o(t).split("."),r=0;r<e.length;r++)e[r]=y+e[r].replace(new RegExp(y,"g"),y+y)+y;var n=e.join(".");return"string"==typeof t?n:(t=u(t),t.text=n,t)}function g(t,e,r,n){for(var o=!1,i=[],s=e.start,l=!0;l;)l="."==e.string.charAt(0),o=o||e.string.charAt(0)==y,s=e.start,i.unshift(c(e.string)),e=n.getTokenAt(b(t.line,e.start)),"."==e.string&&(l=!0,e=n.getTokenAt(b(t.line,e.start)));var g=i.join(".");f(r,g,h,function(t){return o?p(t):t}),f(r,g,x,function(t){return o?p(t):t}),g=i.pop();var d=i.join("."),m=!1,A=d;if(!a(d)){var q=d;d=v(d,n),d!==q&&(m=!0)}var C=a(d);return C&&C.columns&&(C=C.columns),C&&f(r,g,C,function(t){var e=d;return 1==m&&(e=A),"string"==typeof t?t=e+"."+t:(t=u(t),t.text=e+"."+t.text),o?p(t):t}),s}function d(t,e){if(t)for(var r=/[,;]/g,n=t.split(" "),o=0;o<n.length;o++)e(n[o]?n[o].replace(r,""):"")}function v(t,e){for(var r=e.doc,n=r.getValue(),o=t.toUpperCase(),i="",s="",u=[],l={start:b(0,0),end:b(e.lastLine(),e.getLineHandle(e.lastLine()).length)},f=n.indexOf(A.QUERY_DIV);f!=-1;)u.push(r.posFromIndex(f)),f=n.indexOf(A.QUERY_DIV,f+1);u.unshift(b(0,0)),u.push(b(e.lastLine(),e.getLineHandle(e.lastLine()).text.length));for(var c=null,p=e.getCursor(),g=0;g<u.length;g++){if((null==c||q(p,c)>0)&&q(p,u[g])<=0){l={start:c,end:u[g]};break}c=u[g]}for(var v=r.getRange(l.start,l.end,!1),g=0;g<v.length;g++){var h=v[g];if(d(h,function(t){var e=t.toUpperCase();e===o&&a(i)&&(s=i),e!==A.ALIAS_KEYWORD&&(i=t)}),s)break}return s}var h,x,m,y,A={QUERY_DIV:";",ALIAS_KEYWORD:"AS"},b=t.Pos,q=t.cmpPos;t.registerHelper("hint","sql",function(t,e){h=s(e&&e.tables);var o=e&&e.defaultTable,i=e&&e.disableKeywords;x=o&&a(o),m=r(t),y=n(t),o&&!x&&(x=v(o,t)),x=x||[],x.columns&&(x=x.columns);var u,l,c,p=t.getCursor(),d=[],A=t.getTokenAt(p);return A.end>p.ch&&(A.end=p.ch,A.string=A.string.slice(0,p.ch-A.start)),A.string.match(/^[.`"\w@]\w*$/)?(c=A.string,u=A.start,l=A.end):(u=l=p.ch,c=""),"."==c.charAt(0)||c.charAt(0)==y?u=g(p,A,d,t):(f(d,c,h,function(t){return t}),f(d,c,x,function(t){return t}),i||f(d,c,m,function(t){return t.toUpperCase()})),{list:d,from:b(p.line,u),to:b(p.line,l)}})});
|
lib/codemirror/addon/lint/css-lint.js
CHANGED
@@ -18,15 +18,14 @@
|
|
18 |
CodeMirror.registerHelper("lint", "css", function(text) {
|
19 |
var found = [];
|
20 |
if (!window.CSSLint) return found;
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
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 |
+
// This has been modified to only display certain errors
|
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 |
for ( var i = 0; i < messages.length; i++) {
|
30 |
message = messages[i];
|
31 |
var startLine = message.line -1, endLine = message.line -1, startCol = message.col -1, endCol = message.col;
|
lib/codemirror/addon/lint/lint.js
CHANGED
@@ -140,7 +140,12 @@
|
|
140 |
if (options.async || getAnnotations.async) {
|
141 |
lintAsync(cm, getAnnotations, passOptions)
|
142 |
} else {
|
143 |
-
|
|
|
|
|
|
|
|
|
|
|
144 |
}
|
145 |
}
|
146 |
|
140 |
if (options.async || getAnnotations.async) {
|
141 |
lintAsync(cm, getAnnotations, passOptions)
|
142 |
} else {
|
143 |
+
var annotations = getAnnotations(cm.getValue(), passOptions, cm);
|
144 |
+
if (!annotations) return;
|
145 |
+
if (annotations.then) annotations.then(function(issues) {
|
146 |
+
updateLinting(cm, issues);
|
147 |
+
});
|
148 |
+
else updateLinting(cm, annotations);
|
149 |
}
|
150 |
}
|
151 |
|
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),l&&(o(l),l=null)}var l=e(n,r),
|
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),u=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}}if(!l)return clearInterval(u)},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 u(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 s(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");if(i)if(o.async||i.async)m(e,i,r);else{var a=i(e.getValue(),r,e);if(!a)return;a.then?a.then(function(t){p(e,t)}):p(e,a)}}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 h=a[p],v=h.severity;v||(v="error"),m=s(m,v),o.formatAnnotation&&(h=o.formatAnnotation(h)),n.hasGutter&&d.appendChild(f(h)),h.to&&n.marked.push(t.markText(h.from,h.to,{className:"CodeMirror-lint-mark-"+v,__annotation:h}))}n.hasGutter&&t.setGutterMarker(i,y,u(d,m,a.length>1,n.options.tooltips))}}o.onUpdateLinting&&o.onUpdateLinting(e,r,t)}function h(t){var e=t.state.lint;e&&(clearTimeout(e.timeout),e.timeout=setTimeout(function(){d(t)},e.options.delay||500))}function v(t,e){for(var n=e.target||e.srcElement,o=document.createDocumentFragment(),i=0;i<t.length;i++){var a=t[i];o.appendChild(f(a))}r(e,o,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=[],u=0;u<a.length;++u){var s=a[u].__annotation;s&&l.push(s)}l.length&&v(l,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",h),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"),u=!1,s=0;s<r.length;++s)r[s]==y&&(u=!0);var c=e.state.lint=new i(e,a(e,n),u);c.options.lintOnChange!==!1&&e.on("change",h),0!=c.options.tooltips&&"gutter"!=c.options.tooltips&&t.on(e.getWrapperElement(),"mouseover",c.onMouseOver),d(e)}}),t.defineExtension("performLint",function(){this.state.lint&&d(this)})});
|
lib/codemirror/addon/lint/yaml-lint.js
CHANGED
@@ -19,8 +19,15 @@ CodeMirror.registerHelper("lint", "yaml", function(text) {
|
|
19 |
var found = [];
|
20 |
try { jsyaml.load(text); }
|
21 |
catch(e) {
|
22 |
-
var loc = e.mark
|
23 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
24 |
}
|
25 |
return found;
|
26 |
});
|
19 |
var found = [];
|
20 |
try { jsyaml.load(text); }
|
21 |
catch(e) {
|
22 |
+
var loc = e.mark,
|
23 |
+
// js-yaml YAMLException doesn't always provide an accurate lineno
|
24 |
+
// e.g., when there are multiple yaml docs
|
25 |
+
// ---
|
26 |
+
// ---
|
27 |
+
// foo:bar
|
28 |
+
from = loc ? CodeMirror.Pos(loc.line, loc.column) : CodeMirror.Pos(0, 0),
|
29 |
+
to = from;
|
30 |
+
found.push({ from: from, to: to, message: e.message });
|
31 |
}
|
32 |
return found;
|
33 |
});
|
lib/codemirror/addon/lint/yaml-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","yaml",function(o){var r=[];try{jsyaml.load(o)}catch(
|
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","yaml",function(o){var r=[];try{jsyaml.load(o)}catch(t){var i=t.mark,n=i?e.Pos(i.line,i.column):e.Pos(0,0),c=n;r.push({from:n,to:c,message:t.message})}return r})});
|
lib/codemirror/addon/merge/merge.js
CHANGED
@@ -37,23 +37,29 @@
|
|
37 |
constructor: DiffView,
|
38 |
init: function(pane, orig, options) {
|
39 |
this.edit = this.mv.edit;
|
40 |
-
(this.edit.state.diffViews || (this.edit.state.diffViews = [])).push(this);
|
41 |
this.orig = CodeMirror(pane, copyObj({value: orig, readOnly: !this.mv.options.allowEditingOriginals}, copyObj(options)));
|
|
|
|
|
|
|
|
|
|
|
42 |
this.orig.state.diffViews = [this];
|
43 |
var classLocation = options.chunkClassLocation || "background";
|
44 |
if (Object.prototype.toString.call(classLocation) != "[object Array]") classLocation = [classLocation]
|
45 |
this.classes.classLocation = classLocation
|
46 |
|
47 |
-
this.diff = getDiff(asString(orig), asString(options.value));
|
48 |
this.chunks = getChunks(this.diff);
|
49 |
this.diffOutOfDate = this.dealigned = false;
|
|
|
50 |
|
51 |
this.showDifferences = options.showDifferences !== false;
|
52 |
},
|
53 |
-
registerEvents: function() {
|
54 |
this.forceUpdate = registerUpdate(this);
|
55 |
setScrollLock(this, true, false);
|
56 |
-
registerScroll(this);
|
57 |
},
|
58 |
setShowDifferences: function(val) {
|
59 |
val = val !== false;
|
@@ -66,7 +72,7 @@
|
|
66 |
|
67 |
function ensureDiff(dv) {
|
68 |
if (dv.diffOutOfDate) {
|
69 |
-
dv.diff = getDiff(dv.orig.getValue(), dv.edit.getValue());
|
70 |
dv.chunks = getChunks(dv.diff);
|
71 |
dv.diffOutOfDate = false;
|
72 |
CodeMirror.signal(dv.edit, "updateDiff", dv.diff);
|
@@ -97,6 +103,7 @@
|
|
97 |
if (dv.mv.options.connect == "align")
|
98 |
alignChunks(dv);
|
99 |
makeConnections(dv);
|
|
|
100 |
|
101 |
updating = false;
|
102 |
}
|
@@ -121,41 +128,47 @@
|
|
121 |
}
|
122 |
function swapDoc() {
|
123 |
dv.diffOutOfDate = true;
|
|
|
124 |
update("full");
|
125 |
}
|
126 |
dv.edit.on("change", change);
|
127 |
dv.orig.on("change", change);
|
128 |
dv.edit.on("swapDoc", swapDoc);
|
129 |
dv.orig.on("swapDoc", swapDoc);
|
130 |
-
dv.
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
dv.edit.on("viewportChange", function() { set(false); });
|
135 |
dv.orig.on("viewportChange", function() { set(false); });
|
136 |
update();
|
137 |
return update;
|
138 |
}
|
139 |
|
140 |
-
function registerScroll(dv) {
|
141 |
dv.edit.on("scroll", function() {
|
142 |
-
syncScroll(dv,
|
143 |
});
|
144 |
dv.orig.on("scroll", function() {
|
145 |
-
syncScroll(dv,
|
|
|
146 |
});
|
147 |
}
|
148 |
|
149 |
-
function syncScroll(dv,
|
150 |
// Change handler will do a refresh after a timeout when diff is out of date
|
151 |
-
if (dv.diffOutOfDate)
|
|
|
|
|
|
|
|
|
152 |
if (!dv.lockScroll) return true;
|
153 |
var editor, other, now = +new Date;
|
154 |
-
if (
|
155 |
else { editor = dv.orig; other = dv.edit; }
|
156 |
// Don't take action if the position of this editor was recently set
|
157 |
// (to prevent feedback loops)
|
158 |
-
if (editor.state.scrollSetBy == dv && (editor.state.scrollSetAt || 0) +
|
159 |
|
160 |
var sInfo = editor.getScrollInfo();
|
161 |
if (dv.mv.options.connect == "align") {
|
@@ -163,9 +176,9 @@
|
|
163 |
} else {
|
164 |
var halfScreen = .5 * sInfo.clientHeight, midY = sInfo.top + halfScreen;
|
165 |
var mid = editor.lineAtHeight(midY, "local");
|
166 |
-
var around = chunkBoundariesAround(dv.chunks, mid,
|
167 |
-
var off = getOffsets(editor,
|
168 |
-
var offOther = getOffsets(other,
|
169 |
var ratio = (midY - off.top) / (off.bot - off.top);
|
170 |
var targetPos = (offOther.top - halfScreen) + ratio * (offOther.bot - offOther.top);
|
171 |
|
@@ -271,7 +284,7 @@
|
|
271 |
}
|
272 |
}
|
273 |
|
274 |
-
var chunkStart = 0;
|
275 |
for (var i = 0; i < diff.length; ++i) {
|
276 |
var part = diff[i], tp = part[0], str = part[1];
|
277 |
if (tp == DIFF_EQUAL) {
|
@@ -279,10 +292,11 @@
|
|
279 |
moveOver(pos, str);
|
280 |
var cleanTo = pos.line + (endOfLineClean(diff, i) ? 1 : 0);
|
281 |
if (cleanTo > cleanFrom) {
|
282 |
-
if (
|
283 |
chunkStart = cleanTo;
|
284 |
}
|
285 |
} else {
|
|
|
286 |
if (tp == type) {
|
287 |
var end = moveOver(pos, str, true);
|
288 |
var a = posMax(top, pos), b = posMin(bot, end);
|
@@ -292,7 +306,7 @@
|
|
292 |
}
|
293 |
}
|
294 |
}
|
295 |
-
if (
|
296 |
}
|
297 |
|
298 |
// Updating the gap between editor and original
|
@@ -331,24 +345,81 @@
|
|
331 |
return origStart + (editLine - editStart);
|
332 |
}
|
333 |
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
|
338 |
-
|
339 |
-
|
340 |
-
|
341 |
-
|
342 |
-
|
343 |
-
|
344 |
-
|
345 |
-
|
346 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
347 |
}
|
348 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
349 |
}
|
350 |
}
|
351 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
352 |
}
|
353 |
|
354 |
function alignChunks(dv, force) {
|
@@ -371,7 +442,7 @@
|
|
371 |
aligners[i].clear();
|
372 |
aligners.length = 0;
|
373 |
|
374 |
-
var cm = [dv.
|
375 |
if (other) cm.push(other.orig);
|
376 |
for (var i = 0; i < cm.length; i++)
|
377 |
scroll.push(cm[i].getScrollInfo().top);
|
@@ -406,7 +477,7 @@
|
|
406 |
var elt = document.createElement("div");
|
407 |
elt.className = "CodeMirror-merge-spacer";
|
408 |
elt.style.height = size + "px"; elt.style.minWidth = "1px";
|
409 |
-
return cm.addLineWidget(line, elt, {height: size, above: above});
|
410 |
}
|
411 |
|
412 |
function drawConnectorsForChunk(dv, chunk, sTopOrig, sTopEdit, w) {
|
@@ -448,9 +519,15 @@
|
|
448 |
|
449 |
function copyChunk(dv, to, from, chunk) {
|
450 |
if (dv.diffOutOfDate) return;
|
451 |
-
var editStart = chunk.editTo > to.lastLine() ? Pos(chunk.editFrom - 1) : Pos(chunk.editFrom, 0)
|
452 |
var origStart = chunk.origTo > from.lastLine() ? Pos(chunk.origFrom - 1) : Pos(chunk.origFrom, 0)
|
453 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
454 |
}
|
455 |
|
456 |
// Merge view, containing 0, 1, or 2 diff views.
|
@@ -500,8 +577,8 @@
|
|
500 |
this.aligners = [];
|
501 |
alignChunks(this.left || this.right, true);
|
502 |
}
|
503 |
-
if (left) left.registerEvents()
|
504 |
-
if (right) right.registerEvents()
|
505 |
|
506 |
|
507 |
var onResize = function() {
|
@@ -569,12 +646,12 @@
|
|
569 |
// Operations on diffs
|
570 |
|
571 |
var dmp = new diff_match_patch();
|
572 |
-
function getDiff(a, b) {
|
573 |
var diff = dmp.diff_main(a, b);
|
574 |
// The library sometimes leaves in empty parts, which confuse the algorithm
|
575 |
for (var i = 0; i < diff.length; ++i) {
|
576 |
var part = diff[i];
|
577 |
-
if (!part[1]) {
|
578 |
diff.splice(i--, 1);
|
579 |
} else if (i && diff[i - 1][0] == part[0]) {
|
580 |
diff.splice(i--, 1);
|
@@ -591,7 +668,7 @@
|
|
591 |
for (var i = 0; i < diff.length; ++i) {
|
592 |
var part = diff[i], tp = part[0];
|
593 |
if (tp == DIFF_EQUAL) {
|
594 |
-
var startOff = startOfLineClean(diff, i) ?
|
595 |
var cleanFromEdit = edit.line + startOff, cleanFromOrig = orig.line + startOff;
|
596 |
moveOver(edit, part[1], null, orig);
|
597 |
var endOff = endOfLineClean(diff, i) ? 1 : 0;
|
@@ -614,10 +691,10 @@
|
|
614 |
function endOfLineClean(diff, i) {
|
615 |
if (i == diff.length - 1) return true;
|
616 |
var next = diff[i + 1][1];
|
617 |
-
if (next.length == 1 || next.charCodeAt(0) != 10) return false;
|
618 |
if (i == diff.length - 2) return true;
|
619 |
next = diff[i + 2][1];
|
620 |
-
return next.length > 1 && next.charCodeAt(0) == 10;
|
621 |
}
|
622 |
|
623 |
function startOfLineClean(diff, i) {
|
@@ -751,6 +828,131 @@
|
|
751 |
return out;
|
752 |
}
|
753 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
754 |
function posMin(a, b) { return (a.line - b.line || a.ch - b.ch) < 0 ? a : b; }
|
755 |
function posMax(a, b) { return (a.line - b.line || a.ch - b.ch) > 0 ? a : b; }
|
756 |
function posEq(a, b) { return a.line == b.line && a.ch == b.ch; }
|
37 |
constructor: DiffView,
|
38 |
init: function(pane, orig, options) {
|
39 |
this.edit = this.mv.edit;
|
40 |
+
;(this.edit.state.diffViews || (this.edit.state.diffViews = [])).push(this);
|
41 |
this.orig = CodeMirror(pane, copyObj({value: orig, readOnly: !this.mv.options.allowEditingOriginals}, copyObj(options)));
|
42 |
+
if (this.mv.options.connect == "align") {
|
43 |
+
if (!this.edit.state.trackAlignable) this.edit.state.trackAlignable = new TrackAlignable(this.edit)
|
44 |
+
this.orig.state.trackAlignable = new TrackAlignable(this.orig)
|
45 |
+
}
|
46 |
+
|
47 |
this.orig.state.diffViews = [this];
|
48 |
var classLocation = options.chunkClassLocation || "background";
|
49 |
if (Object.prototype.toString.call(classLocation) != "[object Array]") classLocation = [classLocation]
|
50 |
this.classes.classLocation = classLocation
|
51 |
|
52 |
+
this.diff = getDiff(asString(orig), asString(options.value), this.mv.options.ignoreWhitespace);
|
53 |
this.chunks = getChunks(this.diff);
|
54 |
this.diffOutOfDate = this.dealigned = false;
|
55 |
+
this.needsScrollSync = null
|
56 |
|
57 |
this.showDifferences = options.showDifferences !== false;
|
58 |
},
|
59 |
+
registerEvents: function(otherDv) {
|
60 |
this.forceUpdate = registerUpdate(this);
|
61 |
setScrollLock(this, true, false);
|
62 |
+
registerScroll(this, otherDv);
|
63 |
},
|
64 |
setShowDifferences: function(val) {
|
65 |
val = val !== false;
|
72 |
|
73 |
function ensureDiff(dv) {
|
74 |
if (dv.diffOutOfDate) {
|
75 |
+
dv.diff = getDiff(dv.orig.getValue(), dv.edit.getValue(), dv.mv.options.ignoreWhitespace);
|
76 |
dv.chunks = getChunks(dv.diff);
|
77 |
dv.diffOutOfDate = false;
|
78 |
CodeMirror.signal(dv.edit, "updateDiff", dv.diff);
|
103 |
if (dv.mv.options.connect == "align")
|
104 |
alignChunks(dv);
|
105 |
makeConnections(dv);
|
106 |
+
if (dv.needsScrollSync != null) syncScroll(dv, dv.needsScrollSync)
|
107 |
|
108 |
updating = false;
|
109 |
}
|
128 |
}
|
129 |
function swapDoc() {
|
130 |
dv.diffOutOfDate = true;
|
131 |
+
dv.dealigned = true;
|
132 |
update("full");
|
133 |
}
|
134 |
dv.edit.on("change", change);
|
135 |
dv.orig.on("change", change);
|
136 |
dv.edit.on("swapDoc", swapDoc);
|
137 |
dv.orig.on("swapDoc", swapDoc);
|
138 |
+
if (dv.mv.options.connect == "align") {
|
139 |
+
CodeMirror.on(dv.edit.state.trackAlignable, "realign", setDealign)
|
140 |
+
CodeMirror.on(dv.orig.state.trackAlignable, "realign", setDealign)
|
141 |
+
}
|
142 |
dv.edit.on("viewportChange", function() { set(false); });
|
143 |
dv.orig.on("viewportChange", function() { set(false); });
|
144 |
update();
|
145 |
return update;
|
146 |
}
|
147 |
|
148 |
+
function registerScroll(dv, otherDv) {
|
149 |
dv.edit.on("scroll", function() {
|
150 |
+
syncScroll(dv, true) && makeConnections(dv);
|
151 |
});
|
152 |
dv.orig.on("scroll", function() {
|
153 |
+
syncScroll(dv, false) && makeConnections(dv);
|
154 |
+
if (otherDv) syncScroll(otherDv, true) && makeConnections(otherDv);
|
155 |
});
|
156 |
}
|
157 |
|
158 |
+
function syncScroll(dv, toOrig) {
|
159 |
// Change handler will do a refresh after a timeout when diff is out of date
|
160 |
+
if (dv.diffOutOfDate) {
|
161 |
+
if (dv.lockScroll && dv.needsScrollSync == null) dv.needsScrollSync = toOrig
|
162 |
+
return false
|
163 |
+
}
|
164 |
+
dv.needsScrollSync = null
|
165 |
if (!dv.lockScroll) return true;
|
166 |
var editor, other, now = +new Date;
|
167 |
+
if (toOrig) { editor = dv.edit; other = dv.orig; }
|
168 |
else { editor = dv.orig; other = dv.edit; }
|
169 |
// Don't take action if the position of this editor was recently set
|
170 |
// (to prevent feedback loops)
|
171 |
+
if (editor.state.scrollSetBy == dv && (editor.state.scrollSetAt || 0) + 250 > now) return false;
|
172 |
|
173 |
var sInfo = editor.getScrollInfo();
|
174 |
if (dv.mv.options.connect == "align") {
|
176 |
} else {
|
177 |
var halfScreen = .5 * sInfo.clientHeight, midY = sInfo.top + halfScreen;
|
178 |
var mid = editor.lineAtHeight(midY, "local");
|
179 |
+
var around = chunkBoundariesAround(dv.chunks, mid, toOrig);
|
180 |
+
var off = getOffsets(editor, toOrig ? around.edit : around.orig);
|
181 |
+
var offOther = getOffsets(other, toOrig ? around.orig : around.edit);
|
182 |
var ratio = (midY - off.top) / (off.bot - off.top);
|
183 |
var targetPos = (offOther.top - halfScreen) + ratio * (offOther.bot - offOther.top);
|
184 |
|
284 |
}
|
285 |
}
|
286 |
|
287 |
+
var chunkStart = 0, pending = false;
|
288 |
for (var i = 0; i < diff.length; ++i) {
|
289 |
var part = diff[i], tp = part[0], str = part[1];
|
290 |
if (tp == DIFF_EQUAL) {
|
292 |
moveOver(pos, str);
|
293 |
var cleanTo = pos.line + (endOfLineClean(diff, i) ? 1 : 0);
|
294 |
if (cleanTo > cleanFrom) {
|
295 |
+
if (pending) { markChunk(chunkStart, cleanFrom); pending = false }
|
296 |
chunkStart = cleanTo;
|
297 |
}
|
298 |
} else {
|
299 |
+
pending = true
|
300 |
if (tp == type) {
|
301 |
var end = moveOver(pos, str, true);
|
302 |
var a = posMax(top, pos), b = posMin(bot, end);
|
306 |
}
|
307 |
}
|
308 |
}
|
309 |
+
if (pending) markChunk(chunkStart, pos.line + 1);
|
310 |
}
|
311 |
|
312 |
// Updating the gap between editor and original
|
345 |
return origStart + (editLine - editStart);
|
346 |
}
|
347 |
|
348 |
+
// Combines information about chunks and widgets/markers to return
|
349 |
+
// an array of lines, in a single editor, that probably need to be
|
350 |
+
// aligned with their counterparts in the editor next to it.
|
351 |
+
function alignableFor(cm, chunks, isOrig) {
|
352 |
+
var tracker = cm.state.trackAlignable
|
353 |
+
var start = cm.firstLine(), trackI = 0
|
354 |
+
var result = []
|
355 |
+
for (var i = 0;; i++) {
|
356 |
+
var chunk = chunks[i]
|
357 |
+
var chunkStart = !chunk ? 1e9 : isOrig ? chunk.origFrom : chunk.editFrom
|
358 |
+
for (; trackI < tracker.alignable.length; trackI += 2) {
|
359 |
+
var n = tracker.alignable[trackI] + 1
|
360 |
+
if (n <= start) continue
|
361 |
+
if (n <= chunkStart) result.push(n)
|
362 |
+
else break
|
363 |
+
}
|
364 |
+
if (!chunk) break
|
365 |
+
result.push(start = isOrig ? chunk.origTo : chunk.editTo)
|
366 |
+
}
|
367 |
+
return result
|
368 |
+
}
|
369 |
+
|
370 |
+
// Given information about alignable lines in two editors, fill in
|
371 |
+
// the result (an array of three-element arrays) to reflect the
|
372 |
+
// lines that need to be aligned with each other.
|
373 |
+
function mergeAlignable(result, origAlignable, chunks, setIndex) {
|
374 |
+
var rI = 0, origI = 0, chunkI = 0, diff = 0
|
375 |
+
outer: for (;; rI++) {
|
376 |
+
var nextR = result[rI], nextO = origAlignable[origI]
|
377 |
+
if (!nextR && nextO == null) break
|
378 |
+
|
379 |
+
var rLine = nextR ? nextR[0] : 1e9, oLine = nextO == null ? 1e9 : nextO
|
380 |
+
while (chunkI < chunks.length) {
|
381 |
+
var chunk = chunks[chunkI]
|
382 |
+
if (chunk.origFrom <= oLine && chunk.origTo > oLine) {
|
383 |
+
origI++
|
384 |
+
rI--
|
385 |
+
continue outer;
|
386 |
+
}
|
387 |
+
if (chunk.editTo > rLine) {
|
388 |
+
if (chunk.editFrom <= rLine) continue outer;
|
389 |
+
break
|
390 |
}
|
391 |
+
diff += (chunk.origTo - chunk.origFrom) - (chunk.editTo - chunk.editFrom)
|
392 |
+
chunkI++
|
393 |
+
}
|
394 |
+
if (rLine == oLine - diff) {
|
395 |
+
nextR[setIndex] = oLine
|
396 |
+
origI++
|
397 |
+
} else if (rLine < oLine - diff) {
|
398 |
+
nextR[setIndex] = rLine + diff
|
399 |
+
} else {
|
400 |
+
var record = [oLine - diff, null, null]
|
401 |
+
record[setIndex] = oLine
|
402 |
+
result.splice(rI, 0, record)
|
403 |
+
origI++
|
404 |
}
|
405 |
}
|
406 |
+
}
|
407 |
+
|
408 |
+
function findAlignedLines(dv, other) {
|
409 |
+
var alignable = alignableFor(dv.edit, dv.chunks, false), result = []
|
410 |
+
if (other) for (var i = 0, j = 0; i < other.chunks.length; i++) {
|
411 |
+
var n = other.chunks[i].editTo
|
412 |
+
while (j < alignable.length && alignable[j] < n) j++
|
413 |
+
if (j == alignable.length || alignable[j] != n) alignable.splice(j++, 0, n)
|
414 |
+
}
|
415 |
+
for (var i = 0; i < alignable.length; i++)
|
416 |
+
result.push([alignable[i], null, null])
|
417 |
+
|
418 |
+
mergeAlignable(result, alignableFor(dv.orig, dv.chunks, true), dv.chunks, 1)
|
419 |
+
if (other)
|
420 |
+
mergeAlignable(result, alignableFor(other.orig, other.chunks, true), other.chunks, 2)
|
421 |
+
|
422 |
+
return result
|
423 |
}
|
424 |
|
425 |
function alignChunks(dv, force) {
|
442 |
aligners[i].clear();
|
443 |
aligners.length = 0;
|
444 |
|
445 |
+
var cm = [dv.edit, dv.orig], scroll = [];
|
446 |
if (other) cm.push(other.orig);
|
447 |
for (var i = 0; i < cm.length; i++)
|
448 |
scroll.push(cm[i].getScrollInfo().top);
|
477 |
var elt = document.createElement("div");
|
478 |
elt.className = "CodeMirror-merge-spacer";
|
479 |
elt.style.height = size + "px"; elt.style.minWidth = "1px";
|
480 |
+
return cm.addLineWidget(line, elt, {height: size, above: above, mergeSpacer: true, handleMouseEvents: true});
|
481 |
}
|
482 |
|
483 |
function drawConnectorsForChunk(dv, chunk, sTopOrig, sTopEdit, w) {
|
519 |
|
520 |
function copyChunk(dv, to, from, chunk) {
|
521 |
if (dv.diffOutOfDate) return;
|
|
|
522 |
var origStart = chunk.origTo > from.lastLine() ? Pos(chunk.origFrom - 1) : Pos(chunk.origFrom, 0)
|
523 |
+
var origEnd = Pos(chunk.origTo, 0)
|
524 |
+
var editStart = chunk.editTo > to.lastLine() ? Pos(chunk.editFrom - 1) : Pos(chunk.editFrom, 0)
|
525 |
+
var editEnd = Pos(chunk.editTo, 0)
|
526 |
+
var handler = dv.mv.options.revertChunk
|
527 |
+
if (handler)
|
528 |
+
handler(dv.mv, from, origStart, origEnd, to, editStart, editEnd)
|
529 |
+
else
|
530 |
+
to.replaceRange(from.getRange(origStart, origEnd), editStart, editEnd)
|
531 |
}
|
532 |
|
533 |
// Merge view, containing 0, 1, or 2 diff views.
|
577 |
this.aligners = [];
|
578 |
alignChunks(this.left || this.right, true);
|
579 |
}
|
580 |
+
if (left) left.registerEvents(right)
|
581 |
+
if (right) right.registerEvents(left)
|
582 |
|
583 |
|
584 |
var onResize = function() {
|
646 |
// Operations on diffs
|
647 |
|
648 |
var dmp = new diff_match_patch();
|
649 |
+
function getDiff(a, b, ignoreWhitespace) {
|
650 |
var diff = dmp.diff_main(a, b);
|
651 |
// The library sometimes leaves in empty parts, which confuse the algorithm
|
652 |
for (var i = 0; i < diff.length; ++i) {
|
653 |
var part = diff[i];
|
654 |
+
if (ignoreWhitespace ? !/[^ \t]/.test(part[1]) : !part[1]) {
|
655 |
diff.splice(i--, 1);
|
656 |
} else if (i && diff[i - 1][0] == part[0]) {
|
657 |
diff.splice(i--, 1);
|
668 |
for (var i = 0; i < diff.length; ++i) {
|
669 |
var part = diff[i], tp = part[0];
|
670 |
if (tp == DIFF_EQUAL) {
|
671 |
+
var startOff = !startOfLineClean(diff, i) || edit.line < startEdit || orig.line < startOrig ? 1 : 0;
|
672 |
var cleanFromEdit = edit.line + startOff, cleanFromOrig = orig.line + startOff;
|
673 |
moveOver(edit, part[1], null, orig);
|
674 |
var endOff = endOfLineClean(diff, i) ? 1 : 0;
|
691 |
function endOfLineClean(diff, i) {
|
692 |
if (i == diff.length - 1) return true;
|
693 |
var next = diff[i + 1][1];
|
694 |
+
if ((next.length == 1 && i < diff.length - 2) || next.charCodeAt(0) != 10) return false;
|
695 |
if (i == diff.length - 2) return true;
|
696 |
next = diff[i + 2][1];
|
697 |
+
return (next.length > 1 || i == diff.length - 3) && next.charCodeAt(0) == 10;
|
698 |
}
|
699 |
|
700 |
function startOfLineClean(diff, i) {
|
828 |
return out;
|
829 |
}
|
830 |
|
831 |
+
// Tracks collapsed markers and line widgets, in order to be able to
|
832 |
+
// accurately align the content of two editors.
|
833 |
+
|
834 |
+
var F_WIDGET = 1, F_WIDGET_BELOW = 2, F_MARKER = 4
|
835 |
+
|
836 |
+
function TrackAlignable(cm) {
|
837 |
+
this.cm = cm
|
838 |
+
this.alignable = []
|
839 |
+
this.height = cm.doc.height
|
840 |
+
var self = this
|
841 |
+
cm.on("markerAdded", function(_, marker) {
|
842 |
+
if (!marker.collapsed) return
|
843 |
+
var found = marker.find(1)
|
844 |
+
if (found != null) self.set(found.line, F_MARKER)
|
845 |
+
})
|
846 |
+
cm.on("markerCleared", function(_, marker, _min, max) {
|
847 |
+
if (max != null && marker.collapsed)
|
848 |
+
self.check(max, F_MARKER, self.hasMarker)
|
849 |
+
})
|
850 |
+
cm.on("markerChanged", this.signal.bind(this))
|
851 |
+
cm.on("lineWidgetAdded", function(_, widget, lineNo) {
|
852 |
+
if (widget.mergeSpacer) return
|
853 |
+
if (widget.above) self.set(lineNo - 1, F_WIDGET_BELOW)
|
854 |
+
else self.set(lineNo, F_WIDGET)
|
855 |
+
})
|
856 |
+
cm.on("lineWidgetCleared", function(_, widget, lineNo) {
|
857 |
+
if (widget.mergeSpacer) return
|
858 |
+
if (widget.above) self.check(lineNo - 1, F_WIDGET_BELOW, self.hasWidgetBelow)
|
859 |
+
else self.check(lineNo, F_WIDGET, self.hasWidget)
|
860 |
+
})
|
861 |
+
cm.on("lineWidgetChanged", this.signal.bind(this))
|
862 |
+
cm.on("change", function(_, change) {
|
863 |
+
var start = change.from.line, nBefore = change.to.line - change.from.line
|
864 |
+
var nAfter = change.text.length - 1, end = start + nAfter
|
865 |
+
if (nBefore || nAfter) self.map(start, nBefore, nAfter)
|
866 |
+
self.check(end, F_MARKER, self.hasMarker)
|
867 |
+
if (nBefore || nAfter) self.check(change.from.line, F_MARKER, self.hasMarker)
|
868 |
+
})
|
869 |
+
cm.on("viewportChange", function() {
|
870 |
+
if (self.cm.doc.height != self.height) self.signal()
|
871 |
+
})
|
872 |
+
}
|
873 |
+
|
874 |
+
TrackAlignable.prototype = {
|
875 |
+
signal: function() {
|
876 |
+
CodeMirror.signal(this, "realign")
|
877 |
+
this.height = this.cm.doc.height
|
878 |
+
},
|
879 |
+
|
880 |
+
set: function(n, flags) {
|
881 |
+
var pos = -1
|
882 |
+
for (; pos < this.alignable.length; pos += 2) {
|
883 |
+
var diff = this.alignable[pos] - n
|
884 |
+
if (diff == 0) {
|
885 |
+
if ((this.alignable[pos + 1] & flags) == flags) return
|
886 |
+
this.alignable[pos + 1] |= flags
|
887 |
+
this.signal()
|
888 |
+
return
|
889 |
+
}
|
890 |
+
if (diff > 0) break
|
891 |
+
}
|
892 |
+
this.signal()
|
893 |
+
this.alignable.splice(pos, 0, n, flags)
|
894 |
+
},
|
895 |
+
|
896 |
+
find: function(n) {
|
897 |
+
for (var i = 0; i < this.alignable.length; i += 2)
|
898 |
+
if (this.alignable[i] == n) return i
|
899 |
+
return -1
|
900 |
+
},
|
901 |
+
|
902 |
+
check: function(n, flag, pred) {
|
903 |
+
var found = this.find(n)
|
904 |
+
if (found == -1 || !(this.alignable[found + 1] & flag)) return
|
905 |
+
if (!pred.call(this, n)) {
|
906 |
+
this.signal()
|
907 |
+
var flags = this.alignable[found + 1] & ~flag
|
908 |
+
if (flags) this.alignable[found + 1] = flags
|
909 |
+
else this.alignable.splice(found, 2)
|
910 |
+
}
|
911 |
+
},
|
912 |
+
|
913 |
+
hasMarker: function(n) {
|
914 |
+
var handle = this.cm.getLineHandle(n)
|
915 |
+
if (handle.markedSpans) for (var i = 0; i < handle.markedSpans.length; i++)
|
916 |
+
if (handle.markedSpans[i].mark.collapsed && handle.markedSpans[i].to != null)
|
917 |
+
return true
|
918 |
+
return false
|
919 |
+
},
|
920 |
+
|
921 |
+
hasWidget: function(n) {
|
922 |
+
var handle = this.cm.getLineHandle(n)
|
923 |
+
if (handle.widgets) for (var i = 0; i < handle.widgets.length; i++)
|
924 |
+
if (!handle.widgets[i].above && !handle.widgets[i].mergeSpacer) return true
|
925 |
+
return false
|
926 |
+
},
|
927 |
+
|
928 |
+
hasWidgetBelow: function(n) {
|
929 |
+
if (n == this.cm.lastLine()) return false
|
930 |
+
var handle = this.cm.getLineHandle(n + 1)
|
931 |
+
if (handle.widgets) for (var i = 0; i < handle.widgets.length; i++)
|
932 |
+
if (handle.widgets[i].above && !handle.widgets[i].mergeSpacer) return true
|
933 |
+
return false
|
934 |
+
},
|
935 |
+
|
936 |
+
map: function(from, nBefore, nAfter) {
|
937 |
+
var diff = nAfter - nBefore, to = from + nBefore, widgetFrom = -1, widgetTo = -1
|
938 |
+
for (var i = 0; i < this.alignable.length; i += 2) {
|
939 |
+
var n = this.alignable[i]
|
940 |
+
if (n == from && (this.alignable[i + 1] & F_WIDGET_BELOW)) widgetFrom = i
|
941 |
+
if (n == to && (this.alignable[i + 1] & F_WIDGET_BELOW)) widgetTo = i
|
942 |
+
if (n <= from) continue
|
943 |
+
else if (n < to) this.alignable.splice(i--, 2)
|
944 |
+
else this.alignable[i] += diff
|
945 |
+
}
|
946 |
+
if (widgetFrom > -1) {
|
947 |
+
var flags = this.alignable[widgetFrom + 1]
|
948 |
+
if (flags == F_WIDGET_BELOW) this.alignable.splice(widgetFrom, 2)
|
949 |
+
else this.alignable[widgetFrom + 1] = flags & ~F_WIDGET_BELOW
|
950 |
+
}
|
951 |
+
if (widgetTo > -1 && nAfter)
|
952 |
+
this.set(from + nAfter, F_WIDGET_BELOW)
|
953 |
+
}
|
954 |
+
}
|
955 |
+
|
956 |
function posMin(a, b) { return (a.line - b.line || a.ch - b.ch) < 0 ? a : b; }
|
957 |
function posMax(a, b) { return (a.line - b.line || a.ch - b.ch) > 0 ? a : b; }
|
958 |
function posEq(a, b) { return a.line == b.line && a.ch == b.ch; }
|
lib/codemirror/addon/merge/merge.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","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=y(t.orig.getValue(),t.edit.getValue()),t.chunks=D(t.diff),t.diffOutOfDate=!1,e.signal(t.edit,"updateDiff",t.diff))}function i(e){function t(t){Q=!0,g=!1,"full"==t&&(e.svg&&N(e.svg),e.copyButtons&&N(e.copyButtons),c(e.edit,s.marked,e.classes),c(e.orig,h.marked,e.classes),s.from=s.to=h.from=h.to=0),r(e),e.showDifferences&&(f(e.edit,e.diff,s,DIFF_INSERT,e.classes),f(e.orig,e.diff,h,DIFF_DELETE,e.classes)),"align"==e.mv.options.connect&&v(e),d(e),Q=!1}function i(t){Q||(e.dealigned=!0,o(t))}function o(e){Q||g||(clearTimeout(a),e===!0&&(g=!0),a=setTimeout(t,e===!0?20:250))}function n(t,r){e.diffOutOfDate||(e.diffOutOfDate=!0,s.from=s.to=h.from=h.to=0),i(r.text.length-1!=r.to.line-r.from.line)}function l(){e.diffOutOfDate=!0,t("full")}var a,s={from:0,to:0,marked:[]},h={from:0,to:0,marked:[]},g=!1;return e.edit.on("change",n),e.orig.on("change",n),e.edit.on("swapDoc",l),e.orig.on("swapDoc",l),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)&&d(e)}),e.orig.on("scroll",function(){n(e,DIFF_DELETE)&&d(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)v=n.top;else{var a,s,c=.5*n.clientHeight,f=n.top+c,h=r.lineAtHeight(f,"local"),g=E(e.chunks,h,t==DIFF_INSERT),d=l(r,t==DIFF_INSERT?g.edit:g.orig),u=l(i,t==DIFF_INSERT?g.orig:g.edit),m=(f-d.top)/(d.bot-d.top),v=u.top-c+m*(u.bot-u.top);if(v>n.top&&(s=n.top/c)<1)v=v*s+n.top*(1-s);else if((a=n.height-n.clientHeight-n.top)<c){var p=i.getScrollInfo(),k=p.height-p.clientHeight-v;k>a&&(s=a/c)<1&&(v=v*s+(p.height-p.clientHeight-a)*(1-s))}}return i.scrollTo(n.left,v),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)&&d(e),e.lockButton.innerHTML=t?"⇛⇚":"⇛ ⇚"}function s(e,t,r){for(var i=r.classLocation,o=0;o<i.length;o++)e.removeLineClass(t,i[o],r.chunk),e.removeLineClass(t,i[o],r.start),e.removeLineClass(t,i[o],r.end)}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&&s(t,n,i)}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),g(e,t,i,r.marked,n.from,n.to,o),r.from=n.from,r.to=n.to):(n.from<r.from&&(g(e,t,i,r.marked,n.from,r.from,o),r.from=n.from),n.to>r.to&&(g(e,t,i,r.marked,r.to,n.to,o),r.to=n.to))})}function h(e,t,r,i,o,n){for(var l=r.classLocation,a=e.getLineHandle(t),s=0;s<l.length;s++)i&&e.addLineClass(a,l[s],r.chunk),o&&e.addLineClass(a,l[s],r.start),n&&e.addLineClass(a,l[s],r.end);return a}function g(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;c<s;++c)i.push(h(e,c,l,!0,c==t,c==r-1));t==r&&a==r&&s==r&&(a?i.push(h(e,a-1,l,!1,!1,!0)):i.push(h(e,a,l,!1,!0,!1)))}for(var s=W(0,0),c=W(o,0),f=e.clipPos(W(n-1)),g=r==DIFF_DELETE?l.del:l.insert,d=0,u=0;u<t.length;++u){var m=t[u],v=m[0],p=m[1];if(v==DIFF_EQUAL){var k=s.line+(L(t,u)?0:1);R(s,p);var C=s.line+(M(t,u)?1:0);C>k&&(u&&a(d,k),d=C)}else if(v==r){var T=R(s,p,!0),F=V(c,s),w=_(f,T);H(F,w)||i.push(e.markText(F,w,{className:g})),s=T}}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;x(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.mv.wrap.getBoundingClientRect().top,n=o-e.edit.getScrollerElement().getBoundingClientRect().top+e.edit.getScrollInfo().top,l=o-e.orig.getScrollerElement().getBoundingClientRect().top+e.orig.getScrollInfo().top,a=0;a<e.chunks.length;a++){var s=e.chunks[a];s.editFrom<=r.to&&s.editTo>=r.from&&s.origFrom<=i.to&&s.origTo>=i.from&&C(e,s,l,n,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 m(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)e: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][1]-o.editTo;if(0==l)continue e;if(l>0)break}r.splice(n,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 i=e.mv.left==e?e.mv.right:e.mv.left;i&&(r(i),i.dealigned=!1);for(var o=m(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++)p(a,o[c],n);for(var l=0;l<a.length;l++)a[l].scrollTo(null,s[l])}}function p(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(k(e[n],t[n],a))}}function k(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 C(e,t,r,i,o){var n="left"==e.type,l=e.orig.heightAtLine(t.origFrom,"local",!0)-r;if(e.svg){var a=l,s=e.edit.heightAtLine(t.editFrom,"local",!0)-i;if(n){var c=a;a=s,s=c}var f=e.orig.heightAtLine(t.origTo,"local",!0)-r,h=e.edit.heightAtLine(t.editTo,"local",!0)-i;if(n){var c=f;f=h,h=c}var g=" C "+o/2+" "+s+" "+o/2+" "+a+" "+(o+2)+" "+a,d=" C "+o/2+" "+f+" "+o/2+" "+h+" -1 "+h;x(e.svg.appendChild(document.createElementNS(z,"path")),"d","M -1 "+s+g+" L "+(o+2)+" "+f+d+" z","class",e.classes.connect)}if(e.copyButtons){var u=e.copyButtons.appendChild(A("div","left"==e.type?"⇝":"⇜","CodeMirror-merge-copy")),m=e.mv.options.allowEditingOriginals;if(u.title=m?"Push to left":"Revert chunk",u.chunk=t,u.style.top=(t.origTo>t.origFrom?l:e.edit.heightAtLine(t.editFrom,"local")-i)+"px",m){var v=e.edit.heightAtLine(t.editFrom,"local")-i,p=e.copyButtons.appendChild(A("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=v+"px","right"==e.type?p.style.left="2px":p.style.right="2px"}}}function T(e,t,r,i){if(!e.diffOutOfDate){var o=i.editTo>t.lastLine()?W(i.editFrom-1):W(i.editFrom,0),n=i.origTo>r.lastLine()?W(i.origFrom-1):W(i.origFrom,0);t.replaceRange(r.getRange(n,W(i.origTo,0)),o,W(i.editTo,0))}}function F(t){var r=t.lockButton=A("div",null,"CodeMirror-merge-scrolllock");r.title="Toggle locked scrolling";var i=A("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=A("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 T(t,t.orig,t.edit,r.chunk):void T(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=A("div",o,"CodeMirror-merge-gap")}function w(e){return"string"==typeof e?e:e.getValue()}function y(e,t){for(var r=G.diff_main(e,t),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 D(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=L(e,l)?0:1,f=o.line+c,h=n.line+c;R(o,a[1],null,n);var g=M(e,l)?1:0,d=o.line+g,u=n.line+g;d>f&&(l&&t.push({origFrom:i,origTo:h,editFrom:r,editTo:f}),r=d,i=u)}else R(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 M(e,t){if(t==e.length-1)return!0;var r=e[t+1][1];return 1!=r.length&&10==r.charCodeAt(0)&&(t==e.length-2||(r=e[t+2][1],r.length>1&&10==r.charCodeAt(0)))}function L(e,t){if(0==t)return!0;var r=e[t-1][1];return 10==r.charCodeAt(r.length-1)&&(1==t||(r=e[t-2][1],10==r.charCodeAt(r.length-1)))}function E(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)),f<=t?(i=s.editTo,n=s.origTo):c<=t&&(i=s.editFrom,n=s.origFrom)}return{edit:{before:i,after:o},orig:{before:n,after:l}}}function I(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(W(r,0),W(i-1),{inclusiveLeft:!0,inclusiveRight:!0,replacedWith:n,clearOnEnter:!0});return e.on(n,"click",o),{mark:l,clear:o}}function S(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 O(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 b(e,t){"number"!=typeof t&&(t=2);for(var r=[],i=e.editor(),o=i.firstLine(),n=o,l=i.lastLine();n<=l;n++)r.push(!0);e.left&&O(e.left,t,o,r),e.right&&O(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=S(c,f);e.options.onCollapse&&e.options.onCollapse(e,s,c,h)}}}function A(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 x(e){for(var t=1;t<arguments.length;t+=2)e.setAttribute(arguments[t],arguments[t+1])}function B(e,t){t||(t={});for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r]);return t}function R(e,t,r,i){for(var o=r?W(e.line,e.ch):e,n=0;;){var l=t.indexOf("\n",n);if(l==-1)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 V(e,t){return(e.line-t.line||e.ch-t.ch)>0?e:t}function H(e,t){return e.line==t.line&&e.ch==t.ch}function P(e,t,r){for(var i=e.length-1;i>=0;i--){var o=e[i],n=(r?o.origTo:o.editTo)-1;if(n<t)return n}}function j(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,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=i<0?P(s.chunks,l,c):j(s.chunks,l,c);null==f||null!=o&&!(i<0?f>o:f<o)||(o=f)}return null==o?e.Pass:void t.setCursor(o,0)}var W=e.Pos,z="http://www.w3.org/2000/svg";t.prototype={constructor:t,init:function(t,r,i){this.edit=this.mv.edit,(this.edit.state.diffViews||(this.edit.state.diffViews=[])).push(this),this.orig=e(t,B({value:r,readOnly:!this.mv.options.allowEditingOriginals},B(i))),this.orig.state.diffViews=[this];var o=i.chunkClassLocation||"background";"[object Array]"!=Object.prototype.toString.call(o)&&(o=[o]),this.classes.classLocation=o,this.diff=y(w(r),w(i.value)),this.chunks=D(this.diff),this.diffOutOfDate=this.dealigned=!1,this.showDifferences=i.showDifferences!==!1},registerEvents:function(){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 Q=!1,q=e.MergeView=function(r,i){if(!(this instanceof q))return new q(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,h=this.right=null,g=this;if(l){f=this.left=new t(this,"left");var u=A("div",null,"CodeMirror-merge-pane CodeMirror-merge-left");c.push(u),c.push(F(f))}var m=A("div",null,"CodeMirror-merge-pane CodeMirror-merge-editor");if(c.push(m),a){h=this.right=new t(this,"right"),c.push(F(h));var p=A("div",null,"CodeMirror-merge-pane CodeMirror-merge-right");c.push(p)}(a?p:m).className+=" CodeMirror-merge-pane-rightmost",c.push(A("div",null,null,"height: 0; clear: both;"));var k=this.wrap=r.appendChild(A("div",c,"CodeMirror-merge CodeMirror-merge-"+s+"pane"));this.edit=e(m,B(i)),f&&f.init(u,o,i),h&&h.init(p,n,i),i.collapseIdentical&&this.editor().operation(function(){b(g,i.collapseIdentical)}),"align"==i.connect&&(this.aligners=[],v(this.left||this.right,!0)),f&&f.registerEvents(),h&&h.registerEvents();var C=function(){f&&d(f),h&&d(h)};e.on(window,"resize",C);var T=setInterval(function(){for(var t=k.parentNode;t&&t!=document.body;t=t.parentNode);t||(clearInterval(T),e.off(window,"resize",C))},5e3)};q.prototype={constructor: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(){if(this.right)return r(this.right),this.right.chunks},leftChunks:function(){if(this.left)return r(this.left),this.left.chunks}};var G=new diff_match_patch;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 i(t){t.diffOutOfDate&&(t.diff=S(t.orig.getValue(),t.edit.getValue(),t.mv.options.ignoreWhitespace),t.chunks=M(t.diff),t.diffOutOfDate=!1,e.signal(t.edit,"updateDiff",t.diff))}function r(t){function r(e){J=!0,v=!1,"full"==e&&(t.svg&&N(t.svg),t.copyButtons&&N(t.copyButtons),c(t.edit,g.marked,t.classes),c(t.orig,u.marked,t.classes),g.from=g.to=u.from=u.to=0),i(t),t.showDifferences&&(h(t.edit,t.diff,g,DIFF_INSERT,t.classes),h(t.orig,t.diff,u,DIFF_DELETE,t.classes)),"align"==t.mv.options.connect&&k(t),d(t),null!=t.needsScrollSync&&o(t,t.needsScrollSync),J=!1}function n(e){J||(t.dealigned=!0,l(e))}function l(e){J||v||(clearTimeout(f),e===!0&&(v=!0),f=setTimeout(r,e===!0?20:250))}function a(e,i){t.diffOutOfDate||(t.diffOutOfDate=!0,g.from=g.to=u.from=u.to=0),n(i.text.length-1!=i.to.line-i.from.line)}function s(){t.diffOutOfDate=!0,t.dealigned=!0,r("full")}var f,g={from:0,to:0,marked:[]},u={from:0,to:0,marked:[]},v=!1;return t.edit.on("change",a),t.orig.on("change",a),t.edit.on("swapDoc",s),t.orig.on("swapDoc",s),"align"==t.mv.options.connect&&(e.on(t.edit.state.trackAlignable,"realign",n),e.on(t.orig.state.trackAlignable,"realign",n)),t.edit.on("viewportChange",function(){l(!1)}),t.orig.on("viewportChange",function(){l(!1)}),r(),r}function n(e,t){e.edit.on("scroll",function(){o(e,!0)&&d(e)}),e.orig.on("scroll",function(){o(e,!1)&&d(e),t&&o(t,!0)&&d(t)})}function o(e,t){if(e.diffOutOfDate)return e.lockScroll&&null==e.needsScrollSync&&(e.needsScrollSync=t),!1;if(e.needsScrollSync=null,!e.lockScroll)return!0;var i,r,n=+new Date;if(t?(i=e.edit,r=e.orig):(i=e.orig,r=e.edit),i.state.scrollSetBy==e&&(i.state.scrollSetAt||0)+250>n)return!1;var o=i.getScrollInfo();if("align"==e.mv.options.connect)m=o.top;else{var a,s,c=.5*o.clientHeight,h=o.top+c,f=i.lineAtHeight(h,"local"),g=A(e.chunks,f,t),d=l(i,t?g.edit:g.orig),u=l(r,t?g.orig:g.edit),v=(h-d.top)/(d.bot-d.top),m=u.top-c+v*(u.bot-u.top);if(m>o.top&&(s=o.top/c)<1)m=m*s+o.top*(1-s);else if((a=o.height-o.clientHeight-o.top)<c){var p=r.getScrollInfo(),k=p.height-p.clientHeight-m;k>a&&(s=a/c)<1&&(m=m*s+(p.height-p.clientHeight-a)*(1-s))}}return r.scrollTo(o.left,m),r.state.scrollSetAt=n,r.state.scrollSetBy=e,!0}function l(e,t){var i=t.after;return null==i&&(i=e.lastLine()+1),{top:e.heightAtLine(t.before||0,"local"),bot:e.heightAtLine(i,"local")}}function a(e,t,i){e.lockScroll=t,t&&0!=i&&o(e,DIFF_INSERT)&&d(e),e.lockButton.innerHTML=t?"⇛⇚":"⇛ ⇚"}function s(e,t,i){for(var r=i.classLocation,n=0;n<r.length;n++)e.removeLineClass(t,r[n],i.chunk),e.removeLineClass(t,r[n],i.start),e.removeLineClass(t,r[n],i.end)}function c(t,i,r){for(var n=0;n<i.length;++n){var o=i[n];o instanceof e.TextMarker?o.clear():o.parent&&s(t,o,r)}i.length=0}function h(e,t,i,r,n){var o=e.getViewport();e.operation(function(){i.from==i.to||o.from-i.to>20||i.from-o.to>20?(c(e,i.marked,n),g(e,t,r,i.marked,o.from,o.to,n),i.from=o.from,i.to=o.to):(o.from<i.from&&(g(e,t,r,i.marked,o.from,i.from,n),i.from=o.from),o.to>i.to&&(g(e,t,r,i.marked,i.to,o.to,n),i.to=o.to))})}function f(e,t,i,r,n,o){for(var l=i.classLocation,a=e.getLineHandle(t),s=0;s<l.length;s++)r&&e.addLineClass(a,l[s],i.chunk),n&&e.addLineClass(a,l[s],i.start),o&&e.addLineClass(a,l[s],i.end);return a}function g(e,t,i,r,n,o,l){function a(t,i){for(var a=Math.max(n,t),s=Math.min(o,i),c=a;c<s;++c)r.push(f(e,c,l,!0,c==t,c==i-1));t==i&&a==i&&s==i&&(a?r.push(f(e,a-1,l,!1,!1,!0)):r.push(f(e,a,l,!1,!0,!1)))}for(var s=q(0,0),c=q(n,0),h=e.clipPos(q(o-1)),g=i==DIFF_DELETE?l.del:l.insert,d=0,u=!1,v=0;v<t.length;++v){var m=t[v],p=m[0],k=m[1];if(p==DIFF_EQUAL){var C=s.line+(D(t,v)?0:1);V(s,k);var b=s.line+(L(t,v)?1:0);b>C&&(u&&(a(d,C),u=!1),d=b)}else if(u=!0,p==i){var w=V(s,k,!0),T=P(c,s),F=H(h,w);j(T,F)||r.push(e.markText(T,F,{className:g})),s=w}}u&&a(d,s.line+1)}function d(e){if(e.showDifferences){if(e.svg){N(e.svg);var t=e.gap.offsetWidth;R(e.svg,"width",t,"height",e.gap.offsetHeight)}e.copyButtons&&N(e.copyButtons);for(var i=e.edit.getViewport(),r=e.orig.getViewport(),n=e.mv.wrap.getBoundingClientRect().top,o=n-e.edit.getScrollerElement().getBoundingClientRect().top+e.edit.getScrollInfo().top,l=n-e.orig.getScrollerElement().getBoundingClientRect().top+e.orig.getScrollInfo().top,a=0;a<e.chunks.length;a++){var s=e.chunks[a];s.editFrom<=i.to&&s.editTo>=i.from&&s.origFrom<=r.to&&s.origTo>=r.from&&w(e,s,l,o,t)}}}function u(e,t){for(var i=0,r=0,n=0;n<t.length;n++){var o=t[n];if(o.editTo>e&&o.editFrom<=e)return null;if(o.editFrom>e)break;i=o.editTo,r=o.origTo}return r+(e-i)}function v(e,t,i){for(var r=e.state.trackAlignable,n=e.firstLine(),o=0,l=[],a=0;;a++){for(var s=t[a],c=s?i?s.origFrom:s.editFrom:1e9;o<r.alignable.length;o+=2){var h=r.alignable[o]+1;if(!(h<=n)){if(!(h<=c))break;l.push(h)}}if(!s)break;l.push(n=i?s.origTo:s.editTo)}return l}function m(e,t,i,r){var n=0,o=0,l=0,a=0;e:for(;;n++){var s=e[n],c=t[o];if(!s&&null==c)break;for(var h=s?s[0]:1e9,f=null==c?1e9:c;l<i.length;){var g=i[l];if(g.origFrom<=f&&g.origTo>f){o++,n--;continue e}if(g.editTo>h){if(g.editFrom<=h)continue e;break}a+=g.origTo-g.origFrom-(g.editTo-g.editFrom),l++}if(h==f-a)s[r]=f,o++;else if(h<f-a)s[r]=h+a;else{var d=[f-a,null,null];d[r]=f,e.splice(n,0,d),o++}}}function p(e,t){var i=v(e.edit,e.chunks,!1),r=[];if(t)for(var n=0,o=0;n<t.chunks.length;n++){for(var l=t.chunks[n].editTo;o<i.length&&i[o]<l;)o++;o!=i.length&&i[o]==l||i.splice(o++,0,l)}for(var n=0;n<i.length;n++)r.push([i[n],null,null]);return m(r,v(e.orig,e.chunks,!0),e.chunks,1),t&&m(r,v(t.orig,t.chunks,!0),t.chunks,2),r}function k(e,t){if(e.dealigned||t){if(!e.orig.curOp)return e.orig.operation(function(){k(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 n=p(e,r),o=e.mv.aligners,l=0;l<o.length;l++)o[l].clear();o.length=0;var a=[e.edit,e.orig],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<n.length;c++)C(a,n[c],o);for(var l=0;l<a.length;l++)a[l].scrollTo(null,s[l])}}function C(e,t,i){for(var r=0,n=[],o=0;o<e.length;o++)if(null!=t[o]){var l=e[o].heightAtLine(t[o],"local");n[o]=l,r=Math.max(r,l)}for(var o=0;o<e.length;o++)if(null!=t[o]){var a=r-n[o];a>1&&i.push(b(e[o],t[o],a))}}function b(e,t,i){var r=!0;t>e.lastLine()&&(t--,r=!1);var n=document.createElement("div");return n.className="CodeMirror-merge-spacer",n.style.height=i+"px",n.style.minWidth="1px",e.addLineWidget(t,n,{height:i,above:r,mergeSpacer:!0,handleMouseEvents:!0})}function w(e,t,i,r,n){var o="left"==e.type,l=e.orig.heightAtLine(t.origFrom,"local",!0)-i;if(e.svg){var a=l,s=e.edit.heightAtLine(t.editFrom,"local",!0)-r;if(o){var c=a;a=s,s=c}var h=e.orig.heightAtLine(t.origTo,"local",!0)-i,f=e.edit.heightAtLine(t.editTo,"local",!0)-r;if(o){var c=h;h=f,f=c}var g=" C "+n/2+" "+s+" "+n/2+" "+a+" "+(n+2)+" "+a,d=" C "+n/2+" "+h+" "+n/2+" "+f+" -1 "+f;R(e.svg.appendChild(document.createElementNS(G,"path")),"d","M -1 "+s+g+" L "+(n+2)+" "+h+d+" z","class",e.classes.connect)}if(e.copyButtons){var u=e.copyButtons.appendChild(I("div","left"==e.type?"⇝":"⇜","CodeMirror-merge-copy")),v=e.mv.options.allowEditingOriginals;if(u.title=v?"Push to left":"Revert chunk",u.chunk=t,u.style.top=(t.origTo>t.origFrom?l:e.edit.heightAtLine(t.editFrom,"local")-r)+"px",v){var m=e.edit.heightAtLine(t.editFrom,"local")-r,p=e.copyButtons.appendChild(I("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 T(e,t,i,r){if(!e.diffOutOfDate){var n=r.origTo>i.lastLine()?q(r.origFrom-1):q(r.origFrom,0),o=q(r.origTo,0),l=r.editTo>t.lastLine()?q(r.editFrom-1):q(r.editFrom,0),a=q(r.editTo,0),s=e.mv.options.revertChunk;s?s(e.mv,i,n,o,t,l,a):t.replaceRange(i.getRange(n,o),l,a)}}function F(t){var i=t.lockButton=I("div",null,"CodeMirror-merge-scrolllock");i.title="Toggle locked scrolling";var r=I("div",[i],"CodeMirror-merge-scrolllock-wrap");e.on(i,"click",function(){a(t,!t.lockScroll)});var n=[r];if(t.mv.options.revertButtons!==!1&&(t.copyButtons=I("div",null,"CodeMirror-merge-copybuttons-"+t.type),e.on(t.copyButtons,"click",function(e){var i=e.target||e.srcElement;if(i.chunk)return"CodeMirror-merge-copy-reverse"==i.className?void T(t,t.orig,t.edit,i.chunk):void T(t,t.edit,t.orig,i.chunk)}),n.unshift(t.copyButtons)),"align"!=t.mv.options.connect){var o=document.createElementNS&&document.createElementNS(G,"svg");o&&!o.createSVGRect&&(o=null),t.svg=o,o&&n.push(o)}return t.gap=I("div",n,"CodeMirror-merge-gap")}function y(e){return"string"==typeof e?e:e.getValue()}function S(e,t,i){for(var r=X.diff_main(e,t),n=0;n<r.length;++n){var o=r[n];(i?/[^ \t]/.test(o[1]):o[1])?n&&r[n-1][0]==o[0]&&(r.splice(n--,1),r[n][1]+=o[1]):r.splice(n--,1)}return r}function M(e){for(var t=[],i=0,r=0,n=q(0,0),o=q(0,0),l=0;l<e.length;++l){var a=e[l],s=a[0];if(s==DIFF_EQUAL){var c=!D(e,l)||n.line<i||o.line<r?1:0,h=n.line+c,f=o.line+c;V(n,a[1],null,o);var g=L(e,l)?1:0,d=n.line+g,u=o.line+g;d>h&&(l&&t.push({origFrom:r,origTo:f,editFrom:i,editTo:h}),i=d,r=u)}else V(s==DIFF_INSERT?n:o,a[1])}return(i<=n.line||r<=o.line)&&t.push({origFrom:r,origTo:o.line+1,editFrom:i,editTo:n.line+1}),t}function L(e,t){if(t==e.length-1)return!0;var i=e[t+1][1];return!(1==i.length&&t<e.length-2||10!=i.charCodeAt(0))&&(t==e.length-2||(i=e[t+2][1],(i.length>1||t==e.length-3)&&10==i.charCodeAt(0)))}function D(e,t){if(0==t)return!0;var i=e[t-1][1];return 10==i.charCodeAt(i.length-1)&&(1==t||(i=e[t-2][1],10==i.charCodeAt(i.length-1)))}function A(e,t,i){for(var r,n,o,l,a=0;a<e.length;a++){var s=e[a],c=i?s.editFrom:s.origFrom,h=i?s.editTo:s.origTo;null==n&&(c>t?(n=s.editFrom,l=s.origFrom):h>t&&(n=s.editTo,l=s.origTo)),h<=t?(r=s.editTo,o=s.origTo):c<=t&&(r=s.editFrom,o=s.origFrom)}return{edit:{before:r,after:n},orig:{before:o,after:l}}}function E(t,i,r){function n(){l.clear(),t.removeLineClass(i,"wrap","CodeMirror-merge-collapsed-line")}t.addLineClass(i,"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 l=t.markText(q(i,0),q(r-1),{inclusiveLeft:!0,inclusiveRight:!0,replacedWith:o,clearOnEnter:!0});return e.on(o,"click",n),{mark:l,clear:n}}function O(e,t){function i(){for(var e=0;e<r.length;e++)r[e].clear()}for(var r=[],n=0;n<t.length;n++){var o=t[n],l=E(o.cm,o.line,o.line+e);r.push(l),l.mark.on("clear",i)}return r[0].mark}function x(e,t,i,r){for(var n=0;n<e.chunks.length;n++)for(var o=e.chunks[n],l=o.editFrom-t;l<o.editTo+t;l++){var a=l+i;a>=0&&a<r.length&&(r[a]=!1)}}function B(e,t){"number"!=typeof t&&(t=2);for(var i=[],r=e.editor(),n=r.firstLine(),o=n,l=r.lastLine();o<=l;o++)i.push(!0);e.left&&x(e.left,t,n,i),e.right&&x(e.right,t,n,i);for(var a=0;a<i.length;a++)if(i[a]){for(var s=a+n,c=1;a<i.length-1&&i[a+1];a++,c++);if(c>t){var h=[{line:s,cm:r}];e.left&&h.push({line:u(s,e.left.chunks),cm:e.left.orig}),e.right&&h.push({line:u(s,e.right.chunks),cm:e.right.orig});var f=O(c,h);e.options.onCollapse&&e.options.onCollapse(e,s,c,f)}}}function I(e,t,i,r){var n=document.createElement(e);if(i&&(n.className=i),r&&(n.style.cssText=r),"string"==typeof t)n.appendChild(document.createTextNode(t));else if(t)for(var o=0;o<t.length;++o)n.appendChild(t[o]);return n}function N(e){for(var t=e.childNodes.length;t>0;--t)e.removeChild(e.firstChild)}function R(e){for(var t=1;t<arguments.length;t+=2)e.setAttribute(arguments[t],arguments[t+1])}function W(e,t){t||(t={});for(var i in e)e.hasOwnProperty(i)&&(t[i]=e[i]);return t}function V(e,t,i,r){for(var n=i?q(e.line,e.ch):e,o=0;;){var l=t.indexOf("\n",o);if(l==-1)break;++n.line,r&&++r.line,o=l+1}return n.ch=(o?0:n.ch)+(t.length-o),r&&(r.ch=(o?0:r.ch)+(t.length-o)),n}function _(e){this.cm=e,this.alignable=[],this.height=e.doc.height;var t=this;e.on("markerAdded",function(e,i){if(i.collapsed){var r=i.find(1);null!=r&&t.set(r.line,$)}}),e.on("markerCleared",function(e,i,r,n){null!=n&&i.collapsed&&t.check(n,$,t.hasMarker)}),e.on("markerChanged",this.signal.bind(this)),e.on("lineWidgetAdded",function(e,i,r){i.mergeSpacer||(i.above?t.set(r-1,Z):t.set(r,Y))}),e.on("lineWidgetCleared",function(e,i,r){i.mergeSpacer||(i.above?t.check(r-1,Z,t.hasWidgetBelow):t.check(r,Y,t.hasWidget))}),e.on("lineWidgetChanged",this.signal.bind(this)),e.on("change",function(e,i){var r=i.from.line,n=i.to.line-i.from.line,o=i.text.length-1,l=r+o;(n||o)&&t.map(r,n,o),t.check(l,$,t.hasMarker),(n||o)&&t.check(i.from.line,$,t.hasMarker)}),e.on("viewportChange",function(){t.cm.doc.height!=t.height&&t.signal()})}function H(e,t){return(e.line-t.line||e.ch-t.ch)<0?e:t}function P(e,t){return(e.line-t.line||e.ch-t.ch)>0?e:t}function j(e,t){return e.line==t.line&&e.ch==t.ch}function U(e,t,i){for(var r=e.length-1;r>=0;r--){var n=e[r],o=(i?n.origTo:n.editTo)-1;if(o<t)return o}}function z(e,t,i){for(var r=0;r<e.length;r++){var n=e[r],o=i?n.origFrom:n.editFrom;if(o>t)return o}}function Q(t,r){var n=null,o=t.state.diffViews,l=t.getCursor().line;if(o)for(var a=0;a<o.length;a++){var s=o[a],c=t==s.orig;i(s);var h=r<0?U(s.chunks,l,c):z(s.chunks,l,c);null==h||null!=n&&!(r<0?h>n:h<n)||(n=h)}return null==n?e.Pass:void t.setCursor(n,0)}var q=e.Pos,G="http://www.w3.org/2000/svg";t.prototype={constructor:t,init:function(t,i,r){this.edit=this.mv.edit,(this.edit.state.diffViews||(this.edit.state.diffViews=[])).push(this),this.orig=e(t,W({value:i,readOnly:!this.mv.options.allowEditingOriginals},W(r))),"align"==this.mv.options.connect&&(this.edit.state.trackAlignable||(this.edit.state.trackAlignable=new _(this.edit)),this.orig.state.trackAlignable=new _(this.orig)),this.orig.state.diffViews=[this];var n=r.chunkClassLocation||"background";"[object Array]"!=Object.prototype.toString.call(n)&&(n=[n]),this.classes.classLocation=n,this.diff=S(y(i),y(r.value),this.mv.options.ignoreWhitespace),this.chunks=M(this.diff),this.diffOutOfDate=this.dealigned=!1,this.needsScrollSync=null,this.showDifferences=r.showDifferences!==!1},registerEvents:function(e){this.forceUpdate=r(this),a(this,!0,!1),n(this,e)},setShowDifferences:function(e){e=e!==!1,e!=this.showDifferences&&(this.showDifferences=e,this.forceUpdate("full"))}};var J=!1,K=e.MergeView=function(i,r){if(!(this instanceof K))return new K(i,r);this.options=r;var n=r.origLeft,o=null==r.origRight?r.orig:r.origRight,l=null!=n,a=null!=o,s=1+(l?1:0)+(a?1:0),c=[],h=this.left=null,f=this.right=null,g=this;if(l){h=this.left=new t(this,"left");var u=I("div",null,"CodeMirror-merge-pane CodeMirror-merge-left");c.push(u),c.push(F(h))}var v=I("div",null,"CodeMirror-merge-pane CodeMirror-merge-editor");if(c.push(v),a){f=this.right=new t(this,"right"),c.push(F(f));var m=I("div",null,"CodeMirror-merge-pane CodeMirror-merge-right");c.push(m)}(a?m:v).className+=" CodeMirror-merge-pane-rightmost",c.push(I("div",null,null,"height: 0; clear: both;"));var p=this.wrap=i.appendChild(I("div",c,"CodeMirror-merge CodeMirror-merge-"+s+"pane"));this.edit=e(v,W(r)),h&&h.init(u,n,r),f&&f.init(m,o,r),r.collapseIdentical&&this.editor().operation(function(){B(g,r.collapseIdentical)}),"align"==r.connect&&(this.aligners=[],k(this.left||this.right,!0)),h&&h.registerEvents(f),f&&f.registerEvents(h);var C=function(){h&&d(h),f&&d(f)};e.on(window,"resize",C);var b=setInterval(function(){for(var t=p.parentNode;t&&t!=document.body;t=t.parentNode);t||(clearInterval(b),e.off(window,"resize",C))},5e3)};K.prototype={constructor:K,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(){if(this.right)return i(this.right),this.right.chunks},leftChunks:function(){if(this.left)return i(this.left),this.left.chunks}};var X=new diff_match_patch,Y=1,Z=2,$=4;_.prototype={signal:function(){e.signal(this,"realign"),this.height=this.cm.doc.height},set:function(e,t){for(var i=-1;i<this.alignable.length;i+=2){var r=this.alignable[i]-e;if(0==r){if((this.alignable[i+1]&t)==t)return;return this.alignable[i+1]|=t,void this.signal()}if(r>0)break}this.signal(),this.alignable.splice(i,0,e,t)},find:function(e){for(var t=0;t<this.alignable.length;t+=2)if(this.alignable[t]==e)return t;return-1},check:function(e,t,i){var r=this.find(e);if(r!=-1&&this.alignable[r+1]&t&&!i.call(this,e)){this.signal();var n=this.alignable[r+1]&~t;n?this.alignable[r+1]=n:this.alignable.splice(r,2)}},hasMarker:function(e){var t=this.cm.getLineHandle(e);if(t.markedSpans)for(var i=0;i<t.markedSpans.length;i++)if(t.markedSpans[i].mark.collapsed&&null!=t.markedSpans[i].to)return!0;return!1},hasWidget:function(e){var t=this.cm.getLineHandle(e);if(t.widgets)for(var i=0;i<t.widgets.length;i++)if(!t.widgets[i].above&&!t.widgets[i].mergeSpacer)return!0;return!1},hasWidgetBelow:function(e){if(e==this.cm.lastLine())return!1;var t=this.cm.getLineHandle(e+1);if(t.widgets)for(var i=0;i<t.widgets.length;i++)if(t.widgets[i].above&&!t.widgets[i].mergeSpacer)return!0;return!1},map:function(e,t,i){for(var r=i-t,n=e+t,o=-1,l=-1,a=0;a<this.alignable.length;a+=2){var s=this.alignable[a];s==e&&this.alignable[a+1]&Z&&(o=a),s==n&&this.alignable[a+1]&Z&&(l=a),s<=e||(s<n?this.alignable.splice(a--,2):this.alignable[a]+=r)}if(o>-1){var c=this.alignable[o+1];c==Z?this.alignable.splice(o,2):this.alignable[o+1]=c&~Z}l>-1&&i&&this.set(e+i,Z)}},e.commands.goNextDiff=function(e){return Q(e,1)},e.commands.goPrevDiff=function(e){return Q(e,-1)}});
|
lib/codemirror/lib/codemirror.css
CHANGED
@@ -223,11 +223,8 @@ div.CodeMirror span.CodeMirror-nonmatchingbracket {color: #f22;}
|
|
223 |
cursor: default;
|
224 |
z-index: 4;
|
225 |
}
|
226 |
-
.CodeMirror-gutter-wrapper {
|
227 |
-
|
228 |
-
-moz-user-select: none;
|
229 |
-
user-select: none;
|
230 |
-
}
|
231 |
|
232 |
.CodeMirror-lines {
|
233 |
cursor: text;
|
@@ -272,6 +269,8 @@ div.CodeMirror span.CodeMirror-nonmatchingbracket {color: #f22;}
|
|
272 |
|
273 |
.CodeMirror-widget {}
|
274 |
|
|
|
|
|
275 |
.CodeMirror-code {
|
276 |
outline: none;
|
277 |
}
|
223 |
cursor: default;
|
224 |
z-index: 4;
|
225 |
}
|
226 |
+
.CodeMirror-gutter-wrapper ::selection { background-color: transparent }
|
227 |
+
.CodeMirror-gutter-wrapper ::-moz-selection { background-color: transparent }
|
|
|
|
|
|
|
228 |
|
229 |
.CodeMirror-lines {
|
230 |
cursor: text;
|
269 |
|
270 |
.CodeMirror-widget {}
|
271 |
|
272 |
+
.CodeMirror-rtl pre { direction: rtl; }
|
273 |
+
|
274 |
.CodeMirror-code {
|
275 |
outline: none;
|
276 |
}
|
lib/codemirror/lib/codemirror.js
CHANGED
@@ -21,19 +21,21 @@ var platform = navigator.platform
|
|
21 |
var gecko = /gecko\/\d/i.test(userAgent)
|
22 |
var ie_upto10 = /MSIE \d/.test(userAgent)
|
23 |
var ie_11up = /Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(userAgent)
|
24 |
-
var
|
25 |
-
var
|
26 |
-
var
|
|
|
27 |
var qtwebkit = webkit && /Qt\/\d+\.\d+/.test(userAgent)
|
28 |
-
var chrome = /Chrome\//.test(userAgent)
|
29 |
var presto = /Opera\//.test(userAgent)
|
30 |
var safari = /Apple Computer/.test(navigator.vendor)
|
31 |
var mac_geMountainLion = /Mac OS X 1\d\D([8-9]|\d\d)\D/.test(userAgent)
|
32 |
var phantom = /PhantomJS/.test(userAgent)
|
33 |
|
34 |
-
var ios = /AppleWebKit/.test(userAgent) && /Mobile\/\w+/.test(userAgent)
|
|
|
35 |
// This is woefully incomplete. Suggestions for alternative methods welcome.
|
36 |
-
var mobile = ios || /
|
37 |
var mac = ios || /Mac/.test(platform)
|
38 |
var chromeOS = /\bCrOS\b/.test(userAgent)
|
39 |
var windows = /win/i.test(platform)
|
@@ -74,6 +76,12 @@ function elt(tag, content, className, style) {
|
|
74 |
else if (content) { for (var i = 0; i < content.length; ++i) { e.appendChild(content[i]) } }
|
75 |
return e
|
76 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
77 |
|
78 |
var range
|
79 |
if (document.createRange) { range = function(node, start, end, endNode) {
|
@@ -113,8 +121,8 @@ function activeElt() {
|
|
113 |
} catch(e) {
|
114 |
activeElement = document.body || null
|
115 |
}
|
116 |
-
while (activeElement && activeElement.
|
117 |
-
{ activeElement = activeElement.
|
118 |
return activeElement
|
119 |
}
|
120 |
|
@@ -165,11 +173,11 @@ function countColumn(string, end, tabSize, startIndex, startValue) {
|
|
165 |
}
|
166 |
}
|
167 |
|
168 |
-
|
169 |
-
Delayed.prototype.set = function(ms, f) {
|
170 |
clearTimeout(this.id)
|
171 |
this.id = setTimeout(f, ms)
|
172 |
-
}
|
173 |
|
174 |
function indexOf(array, elt) {
|
175 |
for (var i = 0; i < array.length; ++i)
|
@@ -263,6 +271,23 @@ function isEmpty(obj) {
|
|
263 |
var extendingChars = /[\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]/
|
264 |
function isExtendingChar(ch) { return ch.charCodeAt(0) >= 768 && extendingChars.test(ch) }
|
265 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
266 |
// The display handles the DOM integration, both for input reading
|
267 |
// and content drawing. It holds references to DOM nodes and
|
268 |
// display-related state.
|
@@ -279,7 +304,7 @@ function Display(place, doc, input) {
|
|
279 |
d.gutterFiller = elt("div", null, "CodeMirror-gutter-filler")
|
280 |
d.gutterFiller.setAttribute("cm-not-content", "true")
|
281 |
// Will contain the actual code, positioned to cover the viewport.
|
282 |
-
d.lineDiv =
|
283 |
// Elements are added to these to represent selection and cursors.
|
284 |
d.selectionDiv = elt("div", null, null, "position: relative; z-index: 1")
|
285 |
d.cursorDiv = elt("div", null, "CodeMirror-cursors")
|
@@ -288,10 +313,11 @@ function Display(place, doc, input) {
|
|
288 |
// When lines outside of the viewport are measured, they are drawn in this.
|
289 |
d.lineMeasure = elt("div", null, "CodeMirror-measure")
|
290 |
// Wraps everything that needs to exist inside the vertically-padded coordinate system
|
291 |
-
d.lineSpace =
|
292 |
null, "position: relative; outline: none")
|
|
|
293 |
// Moved around its parent to cover visible view.
|
294 |
-
d.mover = elt("div", [
|
295 |
// Set to the height of the document, allowing scrolling.
|
296 |
d.sizer = elt("div", [d.mover], "CodeMirror-sizer")
|
297 |
d.sizerWidth = null
|
@@ -450,15 +476,21 @@ function lineNumberFor(options, i) {
|
|
450 |
}
|
451 |
|
452 |
// A Pos instance represents a position within the text.
|
453 |
-
function Pos
|
454 |
-
if (
|
455 |
-
|
|
|
|
|
|
|
|
|
456 |
}
|
457 |
|
458 |
// Compare two positions, return 0 if they are the same, a negative
|
459 |
// number when a is less, and a positive number otherwise.
|
460 |
function cmp(a, b) { return a.line - b.line || a.ch - b.ch }
|
461 |
|
|
|
|
|
462 |
function copyPos(x) {return Pos(x.line, x.ch)}
|
463 |
function maxPos(a, b) { return cmp(a, b) < 0 ? b : a }
|
464 |
function minPos(a, b) { return cmp(a, b) < 0 ? a : b }
|
@@ -654,7 +686,7 @@ function removeReadOnlyRanges(doc, from, to) {
|
|
654 |
if (dto > 0 || !mk.inclusiveRight && !dto)
|
655 |
{ newParts.push({from: m.to, to: p.to}) }
|
656 |
parts.splice.apply(parts, newParts)
|
657 |
-
j += newParts.length -
|
658 |
}
|
659 |
}
|
660 |
return parts
|
@@ -739,6 +771,13 @@ function visualLine(line) {
|
|
739 |
return line
|
740 |
}
|
741 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
742 |
// Returns an array of logical lines that continue the visual line
|
743 |
// started by the argument, or undefined if there are no such lines.
|
744 |
function visualLineContinued(line) {
|
@@ -870,84 +909,23 @@ function iterateBidiSections(order, from, to, f) {
|
|
870 |
if (!found) { f(from, to, "ltr") }
|
871 |
}
|
872 |
|
873 |
-
function bidiLeft(part) { return part.level % 2 ? part.to : part.from }
|
874 |
-
function bidiRight(part) { return part.level % 2 ? part.from : part.to }
|
875 |
-
|
876 |
-
function lineLeft(line) { var order = getOrder(line); return order ? bidiLeft(order[0]) : 0 }
|
877 |
-
function lineRight(line) {
|
878 |
-
var order = getOrder(line)
|
879 |
-
if (!order) { return line.text.length }
|
880 |
-
return bidiRight(lst(order))
|
881 |
-
}
|
882 |
-
|
883 |
-
function compareBidiLevel(order, a, b) {
|
884 |
-
var linedir = order[0].level
|
885 |
-
if (a == linedir) { return true }
|
886 |
-
if (b == linedir) { return false }
|
887 |
-
return a < b
|
888 |
-
}
|
889 |
-
|
890 |
var bidiOther = null
|
891 |
-
function getBidiPartAt(order,
|
892 |
var found
|
893 |
bidiOther = null
|
894 |
for (var i = 0; i < order.length; ++i) {
|
895 |
var cur = order[i]
|
896 |
-
if (cur.from <
|
897 |
-
if (
|
898 |
-
if (
|
899 |
-
|
900 |
-
} else if (compareBidiLevel(order, cur.level, order[found].level)) {
|
901 |
-
if (cur.from != cur.to) { bidiOther = found }
|
902 |
-
return i
|
903 |
-
} else {
|
904 |
-
if (cur.from != cur.to) { bidiOther = i }
|
905 |
-
return found
|
906 |
-
}
|
907 |
}
|
908 |
-
|
909 |
-
|
910 |
-
}
|
911 |
-
|
912 |
-
function moveInLine(line, pos, dir, byUnit) {
|
913 |
-
if (!byUnit) { return pos + dir }
|
914 |
-
do { pos += dir }
|
915 |
-
while (pos > 0 && isExtendingChar(line.text.charAt(pos)))
|
916 |
-
return pos
|
917 |
-
}
|
918 |
-
|
919 |
-
// This is needed in order to move 'visually' through bi-directional
|
920 |
-
// text -- i.e., pressing left should make the cursor go left, even
|
921 |
-
// when in RTL text. The tricky part is the 'jumps', where RTL and
|
922 |
-
// LTR text touch each other. This often requires the cursor offset
|
923 |
-
// to move more than one unit, in order to visually move one unit.
|
924 |
-
function moveVisually(line, start, dir, byUnit) {
|
925 |
-
var bidi = getOrder(line)
|
926 |
-
if (!bidi) { return moveLogically(line, start, dir, byUnit) }
|
927 |
-
var pos = getBidiPartAt(bidi, start), part = bidi[pos]
|
928 |
-
var target = moveInLine(line, start, part.level % 2 ? -dir : dir, byUnit)
|
929 |
-
|
930 |
-
for (;;) {
|
931 |
-
if (target > part.from && target < part.to) { return target }
|
932 |
-
if (target == part.from || target == part.to) {
|
933 |
-
if (getBidiPartAt(bidi, target) == pos) { return target }
|
934 |
-
part = bidi[pos += dir]
|
935 |
-
return (dir > 0) == part.level % 2 ? part.to : part.from
|
936 |
-
} else {
|
937 |
-
part = bidi[pos += dir]
|
938 |
-
if (!part) { return null }
|
939 |
-
if ((dir > 0) == part.level % 2)
|
940 |
-
{ target = moveInLine(line, part.to, -1, byUnit) }
|
941 |
-
else
|
942 |
-
{ target = moveInLine(line, part.from, 1, byUnit) }
|
943 |
}
|
944 |
}
|
945 |
-
|
946 |
-
|
947 |
-
function moveLogically(line, start, dir, byUnit) {
|
948 |
-
var target = start + dir
|
949 |
-
if (byUnit) { while (target > 0 && isExtendingChar(line.text.charAt(target))) { target += dir } }
|
950 |
-
return target < 0 || target > line.text.length ? null : target
|
951 |
}
|
952 |
|
953 |
// Bidirectional ordering algorithm
|
@@ -990,16 +968,16 @@ var bidiOrdering = (function() {
|
|
990 |
|
991 |
var bidiRE = /[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/
|
992 |
var isNeutral = /[stwN]/, isStrong = /[LRr]/, countsAsLeft = /[Lb1n]/, countsAsNum = /[1n]/
|
993 |
-
// Browsers seem to always treat the boundaries of block elements as being L.
|
994 |
-
var outerType = "L"
|
995 |
|
996 |
function BidiSpan(level, from, to) {
|
997 |
this.level = level
|
998 |
this.from = from; this.to = to
|
999 |
}
|
1000 |
|
1001 |
-
return function(str) {
|
1002 |
-
|
|
|
|
|
1003 |
var len = str.length, types = []
|
1004 |
for (var i = 0; i < len; ++i)
|
1005 |
{ types.push(charType(str.charCodeAt(i))) }
|
@@ -1073,7 +1051,7 @@ var bidiOrdering = (function() {
|
|
1073 |
for (end$1 = i$6 + 1; end$1 < len && isNeutral.test(types[end$1]); ++end$1) {}
|
1074 |
var before = (i$6 ? types[i$6-1] : outerType) == "L"
|
1075 |
var after = (end$1 < len ? types[end$1] : outerType) == "L"
|
1076 |
-
var replace$1 = before
|
1077 |
for (var j$1 = i$6; j$1 < end$1; ++j$1) { types[j$1] = replace$1 }
|
1078 |
i$6 = end$1 - 1
|
1079 |
}
|
@@ -1113,24 +1091,126 @@ var bidiOrdering = (function() {
|
|
1113 |
lst(order).to -= m[0].length
|
1114 |
order.push(new BidiSpan(0, len - m[0].length, len))
|
1115 |
}
|
1116 |
-
if (order[0].level == 2)
|
1117 |
-
{ order.unshift(new BidiSpan(1, order[0].to, order[0].to)) }
|
1118 |
-
if (order[0].level != lst(order).level)
|
1119 |
-
{ order.push(new BidiSpan(order[0].level, len, len)) }
|
1120 |
|
1121 |
-
return order
|
1122 |
}
|
1123 |
})()
|
1124 |
|
1125 |
// Get the bidi ordering for the given line (and cache it). Returns
|
1126 |
// false for lines that are fully left-to-right, and an array of
|
1127 |
// BidiSpan objects otherwise.
|
1128 |
-
function getOrder(line) {
|
1129 |
var order = line.order
|
1130 |
-
if (order == null) { order = line.order = bidiOrdering(line.text) }
|
1131 |
return order
|
1132 |
}
|
1133 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1134 |
// EVENT HANDLING
|
1135 |
|
1136 |
// Lightweight event framework. on/off also work on DOM nodes,
|
@@ -1419,74 +1499,72 @@ var StringStream = function(string, tabSize) {
|
|
1419 |
this.tabSize = tabSize || 8
|
1420 |
this.lastColumnPos = this.lastColumnValue = 0
|
1421 |
this.lineStart = 0
|
1422 |
-
}
|
1423 |
|
1424 |
-
StringStream.prototype = {
|
1425 |
-
|
1426 |
-
|
1427 |
-
|
1428 |
-
|
1429 |
-
|
1430 |
-
|
1431 |
-
|
1432 |
-
|
1433 |
-
|
1434 |
-
|
1435 |
-
|
1436 |
-
|
1437 |
-
|
1438 |
-
|
1439 |
-
|
1440 |
-
|
1441 |
-
|
1442 |
-
|
1443 |
-
|
1444 |
-
eatSpace: function() {
|
1445 |
var this$1 = this;
|
1446 |
|
1447 |
-
|
1448 |
-
|
1449 |
-
|
1450 |
-
|
1451 |
-
|
1452 |
-
|
1453 |
-
|
1454 |
-
|
1455 |
-
|
1456 |
-
|
1457 |
-
|
1458 |
-
|
1459 |
-
|
1460 |
-
|
1461 |
-
|
1462 |
-
|
1463 |
-
|
1464 |
-
|
1465 |
-
|
1466 |
-
|
1467 |
-
|
1468 |
-
|
1469 |
-
|
1470 |
-
|
1471 |
-
|
1472 |
-
|
1473 |
-
|
1474 |
-
|
1475 |
-
}
|
1476 |
-
} else {
|
1477 |
-
var match = this.string.slice(this.pos).match(pattern)
|
1478 |
-
if (match && match.index > 0) { return null }
|
1479 |
-
if (match && consume !== false) { this.pos += match[0].length }
|
1480 |
-
return match
|
1481 |
}
|
1482 |
-
}
|
1483 |
-
|
1484 |
-
|
1485 |
-
this.
|
1486 |
-
|
1487 |
-
finally { this.lineStart -= n }
|
1488 |
}
|
1489 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
1490 |
|
1491 |
// Compute a style array (an array starting with a mode generation
|
1492 |
// -- for invalidation -- followed by pairs of end positions and
|
@@ -1691,13 +1769,14 @@ function findStartLine(cm, n, precise) {
|
|
1691 |
|
1692 |
// Line objects. These hold state related to a line, including
|
1693 |
// highlighting info (the styles array).
|
1694 |
-
|
1695 |
this.text = text
|
1696 |
attachMarkedSpans(this, markedSpans)
|
1697 |
this.height = estimateHeight ? estimateHeight(this) : 1
|
1698 |
-
}
|
|
|
|
|
1699 |
eventMixin(Line)
|
1700 |
-
Line.prototype.lineNo = function() { return lineNo(this) }
|
1701 |
|
1702 |
// Change the content (text, markers) of a line. Automatically
|
1703 |
// invalidates cached information and tries to re-estimate the
|
@@ -1740,14 +1819,11 @@ function buildLineContent(cm, lineView) {
|
|
1740 |
// The padding-right forces the element to have a 'border', which
|
1741 |
// is needed on Webkit to be able to get line-level bounding
|
1742 |
// rectangles for it (in measureChar).
|
1743 |
-
var content =
|
1744 |
-
var builder = {pre:
|
1745 |
col: 0, pos: 0, cm: cm,
|
1746 |
trailingSpace: false,
|
1747 |
splitSpaces: (ie || webkit) && cm.getOption("lineWrapping")}
|
1748 |
-
// hide from accessibility tree
|
1749 |
-
content.setAttribute("role", "presentation")
|
1750 |
-
builder.pre.setAttribute("role", "presentation")
|
1751 |
lineView.measure = {}
|
1752 |
|
1753 |
// Iterate over the logical lines that make up this visual line.
|
@@ -1757,7 +1833,7 @@ function buildLineContent(cm, lineView) {
|
|
1757 |
builder.addToken = buildToken
|
1758 |
// Optionally wire in some hacks into the token-rendering
|
1759 |
// algorithm, to deal with browser quirks.
|
1760 |
-
if (hasBadBidiRects(cm.display.measure) && (order = getOrder(line)))
|
1761 |
{ builder.addToken = buildTokenBadBidi(builder.addToken, order) }
|
1762 |
builder.map = []
|
1763 |
var allowFrontierUpdate = lineView != cm.display.externalMeasured && lineNo(line)
|
@@ -2098,7 +2174,7 @@ function updateLineForChanges(cm, lineView, lineN, dims) {
|
|
2098 |
var type = lineView.changes[j]
|
2099 |
if (type == "text") { updateLineText(cm, lineView) }
|
2100 |
else if (type == "gutter") { updateLineGutter(cm, lineView, lineN, dims) }
|
2101 |
-
else if (type == "class") { updateLineClasses(lineView) }
|
2102 |
else if (type == "widget") { updateLineWidgets(cm, lineView, dims) }
|
2103 |
}
|
2104 |
lineView.changes = null
|
@@ -2117,7 +2193,7 @@ function ensureLineWrapped(lineView) {
|
|
2117 |
return lineView.node
|
2118 |
}
|
2119 |
|
2120 |
-
function updateLineBackground(lineView) {
|
2121 |
var cls = lineView.bgClass ? lineView.bgClass + " " + (lineView.line.bgClass || "") : lineView.line.bgClass
|
2122 |
if (cls) { cls += " CodeMirror-linebackground" }
|
2123 |
if (lineView.background) {
|
@@ -2126,6 +2202,7 @@ function updateLineBackground(lineView) {
|
|
2126 |
} else if (cls) {
|
2127 |
var wrap = ensureLineWrapped(lineView)
|
2128 |
lineView.background = wrap.insertBefore(elt("div", null, cls), wrap.firstChild)
|
|
|
2129 |
}
|
2130 |
}
|
2131 |
|
@@ -2153,14 +2230,14 @@ function updateLineText(cm, lineView) {
|
|
2153 |
if (built.bgClass != lineView.bgClass || built.textClass != lineView.textClass) {
|
2154 |
lineView.bgClass = built.bgClass
|
2155 |
lineView.textClass = built.textClass
|
2156 |
-
updateLineClasses(lineView)
|
2157 |
} else if (cls) {
|
2158 |
lineView.text.className = cls
|
2159 |
}
|
2160 |
}
|
2161 |
|
2162 |
-
function updateLineClasses(lineView) {
|
2163 |
-
updateLineBackground(lineView)
|
2164 |
if (lineView.line.wrapClass)
|
2165 |
{ ensureLineWrapped(lineView).className = lineView.line.wrapClass }
|
2166 |
else if (lineView.node != lineView.text)
|
@@ -2182,6 +2259,7 @@ function updateLineGutter(cm, lineView, lineN, dims) {
|
|
2182 |
var wrap = ensureLineWrapped(lineView)
|
2183 |
lineView.gutterBackground = elt("div", null, "CodeMirror-gutter-background " + lineView.line.gutterClass,
|
2184 |
("left: " + (cm.options.fixedGutter ? dims.fixedPos : -dims.gutterTotalWidth) + "px; width: " + (dims.gutterTotalWidth) + "px"))
|
|
|
2185 |
wrap.insertBefore(lineView.gutterBackground, lineView.text)
|
2186 |
}
|
2187 |
var markers = lineView.line.gutterMarkers
|
@@ -2223,7 +2301,7 @@ function buildLineElement(cm, lineView, lineN, dims) {
|
|
2223 |
if (built.bgClass) { lineView.bgClass = built.bgClass }
|
2224 |
if (built.textClass) { lineView.textClass = built.textClass }
|
2225 |
|
2226 |
-
updateLineClasses(lineView)
|
2227 |
updateLineGutter(cm, lineView, lineN, dims)
|
2228 |
insertLineWidgets(cm, lineView, dims)
|
2229 |
return lineView.node
|
@@ -2563,8 +2641,17 @@ function clearCaches(cm) {
|
|
2563 |
cm.display.lineNumChars = null
|
2564 |
}
|
2565 |
|
2566 |
-
function pageScrollX() {
|
2567 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2568 |
|
2569 |
// Converts a {top, bottom, left, right} box from line-local
|
2570 |
// coordinates into another coordinate system. Context may be one of
|
@@ -2617,6 +2704,19 @@ function charCoords(cm, pos, context, lineObj, bias) {
|
|
2617 |
// Returns a box for a given cursor position, which may have an
|
2618 |
// 'other' property containing the position of the secondary cursor
|
2619 |
// on a bidi boundary.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2620 |
function cursorCoords(cm, pos, context, lineObj, preparedMeasure, varHeight) {
|
2621 |
lineObj = lineObj || getLine(cm.doc, pos.line)
|
2622 |
if (!preparedMeasure) { preparedMeasure = prepareMeasureForLine(cm, lineObj) }
|
@@ -2625,25 +2725,24 @@ function cursorCoords(cm, pos, context, lineObj, preparedMeasure, varHeight) {
|
|
2625 |
if (right) { m.left = m.right; } else { m.right = m.left }
|
2626 |
return intoCoordSystem(cm, lineObj, m, context)
|
2627 |
}
|
2628 |
-
|
2629 |
-
|
2630 |
-
|
2631 |
-
|
2632 |
-
|
2633 |
-
|
2634 |
-
|
2635 |
-
|
2636 |
-
|
2637 |
-
|
2638 |
-
|
2639 |
-
|
2640 |
-
return get(ch, right)
|
2641 |
-
}
|
2642 |
-
var
|
2643 |
-
|
2644 |
-
var
|
2645 |
-
|
2646 |
-
if (bidiOther != null) { val.other = getBidi(ch, bidiOther) }
|
2647 |
return val
|
2648 |
}
|
2649 |
|
@@ -2664,8 +2763,8 @@ function estimateCoords(cm, pos) {
|
|
2664 |
// the right of the character position, for example). When outside
|
2665 |
// is true, that means the coordinates lie outside the line's
|
2666 |
// vertical range.
|
2667 |
-
function PosWithInfo(line, ch, outside, xRel) {
|
2668 |
-
var pos = Pos(line, ch)
|
2669 |
pos.xRel = xRel
|
2670 |
if (outside) { pos.outside = true }
|
2671 |
return pos
|
@@ -2676,10 +2775,10 @@ function PosWithInfo(line, ch, outside, xRel) {
|
|
2676 |
function coordsChar(cm, x, y) {
|
2677 |
var doc = cm.doc
|
2678 |
y += cm.display.viewOffset
|
2679 |
-
if (y < 0) { return PosWithInfo(doc.first, 0, true, -1) }
|
2680 |
var lineN = lineAtHeight(doc, y), last = doc.first + doc.size - 1
|
2681 |
if (lineN > last)
|
2682 |
-
{ return PosWithInfo(doc.first + doc.size - 1, getLine(doc, last).text.length, true, 1) }
|
2683 |
if (x < 0) { x = 0 }
|
2684 |
|
2685 |
var lineObj = getLine(doc, lineN)
|
@@ -2694,57 +2793,68 @@ function coordsChar(cm, x, y) {
|
|
2694 |
}
|
2695 |
}
|
2696 |
|
2697 |
-
function
|
2698 |
-
var
|
2699 |
-
var
|
2700 |
-
var
|
2701 |
-
|
2702 |
-
|
2703 |
-
|
2704 |
-
wrongLine = true
|
2705 |
-
if (innerOff > sp.bottom) { return sp.left - adjust }
|
2706 |
-
else if (innerOff < sp.top) { return sp.left + adjust }
|
2707 |
-
else { wrongLine = false }
|
2708 |
-
return sp.left
|
2709 |
-
}
|
2710 |
|
2711 |
-
|
2712 |
-
var
|
2713 |
-
|
|
|
2714 |
|
2715 |
-
|
2716 |
-
|
2717 |
-
|
2718 |
-
|
2719 |
-
|
2720 |
-
|
2721 |
-
|
2722 |
-
|
2723 |
-
|
2724 |
-
|
2725 |
-
|
2726 |
-
|
2727 |
-
|
2728 |
-
|
2729 |
-
|
2730 |
-
|
2731 |
-
|
2732 |
-
|
2733 |
-
|
|
|
|
|
|
|
2734 |
}
|
2735 |
-
|
2736 |
-
|
2737 |
-
|
2738 |
-
|
2739 |
-
|
2740 |
-
if (bidi) {
|
2741 |
-
middle = from
|
2742 |
-
for (var i = 0; i < step; ++i) { middle = moveVisually(lineObj, middle, 1) }
|
2743 |
}
|
2744 |
-
|
2745 |
-
|
2746 |
-
|
2747 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2748 |
}
|
2749 |
|
2750 |
var measureText
|
@@ -2928,7 +3038,7 @@ function drawSelectionRange(cm, range, output) {
|
|
2928 |
return charCoords(cm, Pos(line, ch), "div", lineObj, bias)
|
2929 |
}
|
2930 |
|
2931 |
-
iterateBidiSections(getOrder(lineObj), fromArg || 0, toArg == null ? lineLen : toArg, function (from, to, dir) {
|
2932 |
var leftPos = coords(from, "left"), rightPos, left, right
|
2933 |
if (from == to) {
|
2934 |
rightPos = leftPos
|
@@ -3331,7 +3441,7 @@ NativeScrollbars.prototype.update = function (measure) {
|
|
3331 |
this.horiz.style.left = measure.barLeft + "px"
|
3332 |
var totalWidth = measure.viewWidth - measure.barLeft - (needsV ? sWidth : 0)
|
3333 |
this.horiz.firstChild.style.width =
|
3334 |
-
(measure.scrollWidth - measure.clientWidth + totalWidth) + "px"
|
3335 |
} else {
|
3336 |
this.horiz.style.display = ""
|
3337 |
this.horiz.firstChild.style.width = "0"
|
@@ -3347,12 +3457,12 @@ NativeScrollbars.prototype.update = function (measure) {
|
|
3347 |
|
3348 |
NativeScrollbars.prototype.setScrollLeft = function (pos) {
|
3349 |
if (this.horiz.scrollLeft != pos) { this.horiz.scrollLeft = pos }
|
3350 |
-
if (this.disableHoriz) { this.enableZeroWidthBar(this.horiz, this.disableHoriz) }
|
3351 |
};
|
3352 |
|
3353 |
NativeScrollbars.prototype.setScrollTop = function (pos) {
|
3354 |
if (this.vert.scrollTop != pos) { this.vert.scrollTop = pos }
|
3355 |
-
if (this.disableVert) { this.enableZeroWidthBar(this.vert, this.disableVert) }
|
3356 |
};
|
3357 |
|
3358 |
NativeScrollbars.prototype.zeroWidthHack = function () {
|
@@ -3363,17 +3473,18 @@ NativeScrollbars.prototype.zeroWidthHack = function () {
|
|
3363 |
this.disableVert = new Delayed
|
3364 |
};
|
3365 |
|
3366 |
-
NativeScrollbars.prototype.enableZeroWidthBar = function (bar, delay) {
|
3367 |
bar.style.pointerEvents = "auto"
|
3368 |
function maybeDisable() {
|
3369 |
// To find out whether the scrollbar is still visible, we
|
3370 |
// check whether the element under the pixel in the bottom
|
3371 |
-
//
|
3372 |
// itself (when the bar is still visible) or its filler child
|
3373 |
// (when the bar is hidden). If it is still visible, we keep
|
3374 |
// it enabled, if it's hidden, we disable pointer events.
|
3375 |
var box = bar.getBoundingClientRect()
|
3376 |
-
var elt = document.elementFromPoint(box.
|
|
|
3377 |
if (elt != bar) { bar.style.pointerEvents = "none" }
|
3378 |
else { delay.set(1000, maybeDisable) }
|
3379 |
}
|
@@ -3455,14 +3566,14 @@ function initScrollbars(cm) {
|
|
3455 |
|
3456 |
// If an editor sits on the top or bottom of the window, partially
|
3457 |
// scrolled out of view, this ensures that the cursor is visible.
|
3458 |
-
function maybeScrollWindow(cm,
|
3459 |
if (signalDOMEvent(cm, "scrollCursorIntoView")) { return }
|
3460 |
|
3461 |
var display = cm.display, box = display.sizer.getBoundingClientRect(), doScroll = null
|
3462 |
-
if (
|
3463 |
-
else if (
|
3464 |
if (doScroll != null && !phantom) {
|
3465 |
-
var scrollNode = elt("div", "\u200b", null, ("position: absolute;\n top: " + (
|
3466 |
cm.display.lineSpace.appendChild(scrollNode)
|
3467 |
scrollNode.scrollIntoView(doScroll)
|
3468 |
cm.display.lineSpace.removeChild(scrollNode)
|
@@ -3474,15 +3585,16 @@ function maybeScrollWindow(cm, coords) {
|
|
3474 |
// measured, the position of something may 'drift' during drawing).
|
3475 |
function scrollPosIntoView(cm, pos, end, margin) {
|
3476 |
if (margin == null) { margin = 0 }
|
3477 |
-
var
|
3478 |
for (var limit = 0; limit < 5; limit++) {
|
3479 |
var changed = false
|
3480 |
-
coords = cursorCoords(cm, pos)
|
3481 |
var endCoords = !end || end == pos ? coords : cursorCoords(cm, end)
|
3482 |
-
|
3483 |
-
|
3484 |
-
|
3485 |
-
|
|
|
3486 |
var startTop = cm.doc.scrollTop, startLeft = cm.doc.scrollLeft
|
3487 |
if (scrollPos.scrollTop != null) {
|
3488 |
setScrollTop(cm, scrollPos.scrollTop)
|
@@ -3494,12 +3606,12 @@ function scrollPosIntoView(cm, pos, end, margin) {
|
|
3494 |
}
|
3495 |
if (!changed) { break }
|
3496 |
}
|
3497 |
-
return
|
3498 |
}
|
3499 |
|
3500 |
// Scroll a given set of coordinates into view (immediately).
|
3501 |
-
function scrollIntoView(cm,
|
3502 |
-
var scrollPos = calculateScrollPos(cm,
|
3503 |
if (scrollPos.scrollTop != null) { setScrollTop(cm, scrollPos.scrollTop) }
|
3504 |
if (scrollPos.scrollLeft != null) { setScrollLeft(cm, scrollPos.scrollLeft) }
|
3505 |
}
|
@@ -3508,31 +3620,31 @@ function scrollIntoView(cm, x1, y1, x2, y2) {
|
|
3508 |
// rectangle into view. Returns an object with scrollTop and
|
3509 |
// scrollLeft properties. When these are undefined, the
|
3510 |
// vertical/horizontal position does not need to be adjusted.
|
3511 |
-
function calculateScrollPos(cm,
|
3512 |
var display = cm.display, snapMargin = textHeight(cm.display)
|
3513 |
-
if (
|
3514 |
var screentop = cm.curOp && cm.curOp.scrollTop != null ? cm.curOp.scrollTop : display.scroller.scrollTop
|
3515 |
var screen = displayHeight(cm), result = {}
|
3516 |
-
if (
|
3517 |
var docBottom = cm.doc.height + paddingVert(display)
|
3518 |
-
var atTop =
|
3519 |
-
if (
|
3520 |
-
result.scrollTop = atTop ? 0 :
|
3521 |
-
} else if (
|
3522 |
-
var newTop = Math.min(
|
3523 |
if (newTop != screentop) { result.scrollTop = newTop }
|
3524 |
}
|
3525 |
|
3526 |
var screenleft = cm.curOp && cm.curOp.scrollLeft != null ? cm.curOp.scrollLeft : display.scroller.scrollLeft
|
3527 |
var screenw = displayWidth(cm) - (cm.options.fixedGutter ? display.gutters.offsetWidth : 0)
|
3528 |
-
var tooWide =
|
3529 |
-
if (tooWide) {
|
3530 |
-
if (
|
3531 |
{ result.scrollLeft = 0 }
|
3532 |
-
else if (
|
3533 |
-
{ result.scrollLeft = Math.max(0,
|
3534 |
-
else if (
|
3535 |
-
{ result.scrollLeft =
|
3536 |
return result
|
3537 |
}
|
3538 |
|
@@ -3555,7 +3667,7 @@ function ensureCursorVisible(cm) {
|
|
3555 |
from = cur.ch ? Pos(cur.line, cur.ch - 1) : cur
|
3556 |
to = Pos(cur.line, cur.ch + 1)
|
3557 |
}
|
3558 |
-
cm.curOp.scrollToPos = {from: from, to: to, margin: cm.options.cursorScrollMargin
|
3559 |
}
|
3560 |
|
3561 |
// When an operation has its scrollToPos property set, and another
|
@@ -3567,10 +3679,12 @@ function resolveScrollToPos(cm) {
|
|
3567 |
if (range) {
|
3568 |
cm.curOp.scrollToPos = null
|
3569 |
var from = estimateCoords(cm, range.from), to = estimateCoords(cm, range.to)
|
3570 |
-
var sPos = calculateScrollPos(cm,
|
3571 |
-
|
3572 |
-
|
3573 |
-
|
|
|
|
|
3574 |
cm.scrollTo(sPos.scrollLeft, sPos.scrollTop)
|
3575 |
}
|
3576 |
}
|
@@ -3716,9 +3830,9 @@ function endOperation_finish(op) {
|
|
3716 |
}
|
3717 |
// If we need to scroll a specific position into view, do so.
|
3718 |
if (op.scrollToPos) {
|
3719 |
-
var
|
3720 |
-
|
3721 |
-
|
3722 |
}
|
3723 |
|
3724 |
// Fire events for markers that are hidden/unidden by editing or
|
@@ -4216,63 +4330,61 @@ function setGuttersForLineNumbers(options) {
|
|
4216 |
// (and non-touching) ranges, sorted, and an integer that indicates
|
4217 |
// which one is the primary selection (the one that's scrolled into
|
4218 |
// view, that getCursor returns, etc).
|
4219 |
-
|
4220 |
this.ranges = ranges
|
4221 |
this.primIndex = primIndex
|
4222 |
-
}
|
|
|
|
|
4223 |
|
4224 |
-
Selection.prototype = {
|
4225 |
-
primary: function() { return this.ranges[this.primIndex] },
|
4226 |
-
equals: function(other) {
|
4227 |
var this$1 = this;
|
4228 |
|
4229 |
-
|
4230 |
-
|
4231 |
-
|
4232 |
-
|
4233 |
-
|
4234 |
-
|
4235 |
-
|
4236 |
-
|
4237 |
-
|
|
|
4238 |
var this$1 = this;
|
4239 |
|
4240 |
-
|
4241 |
-
|
4242 |
-
|
4243 |
-
|
4244 |
-
|
4245 |
-
|
|
|
4246 |
var this$1 = this;
|
4247 |
|
4248 |
-
|
4249 |
-
|
4250 |
-
|
4251 |
-
|
4252 |
-
|
|
|
4253 |
var this$1 = this;
|
4254 |
|
4255 |
-
|
4256 |
-
|
4257 |
-
|
4258 |
-
|
4259 |
-
|
4260 |
-
}
|
4261 |
-
return -1
|
4262 |
}
|
4263 |
-
|
|
|
4264 |
|
4265 |
-
|
4266 |
this.anchor = anchor; this.head = head
|
4267 |
-
}
|
4268 |
|
4269 |
-
Range.prototype = {
|
4270 |
-
|
4271 |
-
|
4272 |
-
empty: function() {
|
4273 |
-
return this.head.line == this.anchor.line && this.head.ch == this.anchor.ch
|
4274 |
-
}
|
4275 |
-
}
|
4276 |
|
4277 |
// Take an unsorted, potentially overlapping set of ranges, and
|
4278 |
// build a selection out of it. 'Consumes' ranges array (modifying
|
@@ -4456,11 +4568,23 @@ function attachDoc(cm, doc) {
|
|
4456 |
doc.cm = cm
|
4457 |
estimateLineHeights(cm)
|
4458 |
loadMode(cm)
|
|
|
4459 |
if (!cm.options.lineWrapping) { findMaxLine(cm) }
|
4460 |
cm.options.mode = doc.modeOption
|
4461 |
regChange(cm)
|
4462 |
}
|
4463 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
4464 |
function History(startGen) {
|
4465 |
// Arrays of change events and selections. Doing something adds an
|
4466 |
// event to done and clears undo. Undoing moves events from done
|
@@ -5211,7 +5335,7 @@ function changeLine(doc, handle, changeType, op) {
|
|
5211 |
//
|
5212 |
// See also http://marijnhaverbeke.nl/blog/codemirror-line-tree.html
|
5213 |
|
5214 |
-
|
5215 |
var this$1 = this;
|
5216 |
|
5217 |
this.lines = lines
|
@@ -5222,45 +5346,47 @@ function LeafChunk(lines) {
|
|
5222 |
height += lines[i].height
|
5223 |
}
|
5224 |
this.height = height
|
5225 |
-
}
|
|
|
|
|
5226 |
|
5227 |
-
|
5228 |
-
|
5229 |
-
// Remove the n lines at offset 'at'.
|
5230 |
-
removeInner: function(at, n) {
|
5231 |
var this$1 = this;
|
5232 |
|
5233 |
-
|
5234 |
-
|
5235 |
-
|
5236 |
-
|
5237 |
-
|
5238 |
-
|
5239 |
-
|
5240 |
-
|
5241 |
-
|
5242 |
-
|
5243 |
-
|
5244 |
-
|
5245 |
-
|
5246 |
-
|
5247 |
-
|
|
|
|
|
5248 |
var this$1 = this;
|
5249 |
|
5250 |
-
|
5251 |
-
|
5252 |
-
|
5253 |
-
|
5254 |
-
|
5255 |
-
|
|
|
5256 |
var this$1 = this;
|
5257 |
|
5258 |
-
|
5259 |
-
|
5260 |
-
|
5261 |
-
}
|
5262 |
|
5263 |
-
|
5264 |
var this$1 = this;
|
5265 |
|
5266 |
this.children = children
|
@@ -5273,123 +5399,120 @@ function BranchChunk(children) {
|
|
5273 |
this.size = size
|
5274 |
this.height = height
|
5275 |
this.parent = null
|
5276 |
-
}
|
5277 |
|
5278 |
-
BranchChunk.prototype = {
|
5279 |
-
|
5280 |
-
|
5281 |
var this$1 = this;
|
5282 |
|
5283 |
-
|
5284 |
-
|
5285 |
-
|
5286 |
-
|
5287 |
-
|
5288 |
-
|
5289 |
-
|
5290 |
-
|
5291 |
-
|
5292 |
-
|
5293 |
-
|
5294 |
-
|
5295 |
-
|
5296 |
-
|
5297 |
-
|
5298 |
-
|
5299 |
-
|
5300 |
-
|
5301 |
-
|
5302 |
-
|
5303 |
-
|
5304 |
-
|
5305 |
-
|
|
|
5306 |
var this$1 = this;
|
5307 |
|
5308 |
-
|
5309 |
-
|
5310 |
-
|
|
|
5311 |
var this$1 = this;
|
5312 |
|
5313 |
-
|
5314 |
-
|
5315 |
-
|
5316 |
-
|
5317 |
-
|
5318 |
-
|
5319 |
-
|
5320 |
-
|
5321 |
-
|
5322 |
-
|
5323 |
-
|
5324 |
-
|
5325 |
-
|
5326 |
-
|
5327 |
-
|
5328 |
-
}
|
5329 |
-
child.lines = child.lines.slice(0, remaining)
|
5330 |
-
this$1.maybeSpill()
|
5331 |
}
|
5332 |
-
|
|
|
5333 |
}
|
5334 |
-
|
5335 |
}
|
5336 |
-
|
5337 |
-
|
5338 |
-
|
5339 |
-
|
5340 |
-
|
5341 |
-
|
5342 |
-
|
5343 |
-
|
5344 |
-
|
5345 |
-
|
5346 |
-
|
5347 |
-
|
5348 |
-
|
5349 |
-
|
5350 |
-
|
5351 |
-
|
5352 |
-
|
5353 |
-
|
5354 |
-
|
5355 |
-
|
5356 |
-
|
5357 |
-
|
5358 |
-
|
5359 |
-
|
|
|
|
|
|
|
|
|
5360 |
var this$1 = this;
|
5361 |
|
5362 |
-
|
5363 |
-
|
5364 |
-
|
5365 |
-
|
5366 |
-
|
5367 |
-
|
5368 |
-
|
5369 |
-
|
5370 |
-
}
|
5371 |
}
|
5372 |
-
}
|
5373 |
|
5374 |
// Line widgets are block elements displayed above or below a line.
|
5375 |
|
5376 |
-
|
5377 |
var this$1 = this;
|
5378 |
|
5379 |
if (options) { for (var opt in options) { if (options.hasOwnProperty(opt))
|
5380 |
{ this$1[opt] = options[opt] } } }
|
5381 |
this.doc = doc
|
5382 |
this.node = node
|
5383 |
-
}
|
5384 |
-
eventMixin(LineWidget)
|
5385 |
-
|
5386 |
-
function adjustScrollWhenAboveVisible(cm, line, diff) {
|
5387 |
-
if (heightAtLine(line) < ((cm.curOp && cm.curOp.scrollTop) || cm.doc.scrollTop))
|
5388 |
-
{ addToScrollPos(cm, null, diff) }
|
5389 |
-
}
|
5390 |
|
5391 |
-
LineWidget.prototype.clear = function() {
|
5392 |
-
|
5393 |
|
5394 |
var cm = this.doc.cm, ws = this.line.widgets, line = this.line, no = lineNo(line)
|
5395 |
if (no == null || !ws) { return }
|
@@ -5397,21 +5520,36 @@ LineWidget.prototype.clear = function() {
|
|
5397 |
if (!ws.length) { line.widgets = null }
|
5398 |
var height = widgetHeight(this)
|
5399 |
updateLineHeight(line, Math.max(0, line.height - height))
|
5400 |
-
if (cm) {
|
5401 |
-
|
5402 |
-
|
5403 |
-
|
5404 |
-
}
|
5405 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
5406 |
var oldH = this.height, cm = this.doc.cm, line = this.line
|
5407 |
this.height = null
|
5408 |
var diff = widgetHeight(this) - oldH
|
5409 |
if (!diff) { return }
|
5410 |
updateLineHeight(line, line.height + diff)
|
5411 |
-
if (cm) {
|
5412 |
-
cm
|
5413 |
-
|
5414 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5415 |
}
|
5416 |
|
5417 |
function addLineWidget(doc, handle, node, options) {
|
@@ -5431,6 +5569,7 @@ function addLineWidget(doc, handle, node, options) {
|
|
5431 |
}
|
5432 |
return true
|
5433 |
})
|
|
|
5434 |
return widget
|
5435 |
}
|
5436 |
|
@@ -5451,17 +5590,16 @@ function addLineWidget(doc, handle, node, options) {
|
|
5451 |
// when they overlap (they may nest, but not partially overlap).
|
5452 |
var nextMarkerId = 0
|
5453 |
|
5454 |
-
|
5455 |
this.lines = []
|
5456 |
this.type = type
|
5457 |
this.doc = doc
|
5458 |
this.id = ++nextMarkerId
|
5459 |
-
}
|
5460 |
-
eventMixin(TextMarker)
|
5461 |
|
5462 |
// Clear the marker.
|
5463 |
-
TextMarker.prototype.clear = function() {
|
5464 |
-
|
5465 |
|
5466 |
if (this.explicitlyCleared) { return }
|
5467 |
var cm = this.doc.cm, withOp = cm && !cm.curOp
|
@@ -5499,18 +5637,18 @@ TextMarker.prototype.clear = function() {
|
|
5499 |
this.doc.cantEdit = false
|
5500 |
if (cm) { reCheckSelection(cm.doc) }
|
5501 |
}
|
5502 |
-
if (cm) { signalLater(cm, "markerCleared", cm, this) }
|
5503 |
if (withOp) { endOperation(cm) }
|
5504 |
if (this.parent) { this.parent.clear() }
|
5505 |
-
}
|
5506 |
|
5507 |
// Find the position of the marker in the document. Returns a {from,
|
5508 |
// to} object by default. Side can be passed to get a specific side
|
5509 |
// -- 0 (both), -1 (left), or 1 (right). When lineObj is true, the
|
5510 |
// Pos objects returned contain a line object, rather than a line
|
5511 |
// number (used to prevent looking up the same line twice).
|
5512 |
-
TextMarker.prototype.find = function(side, lineObj) {
|
5513 |
-
|
5514 |
|
5515 |
if (side == null && this.type == "bookmark") { side = 1 }
|
5516 |
var from, to
|
@@ -5527,11 +5665,13 @@ TextMarker.prototype.find = function(side, lineObj) {
|
|
5527 |
}
|
5528 |
}
|
5529 |
return from && {from: from, to: to}
|
5530 |
-
}
|
5531 |
|
5532 |
// Signals that the marker's widget changed, and surrounding layout
|
5533 |
// should be recomputed.
|
5534 |
-
TextMarker.prototype.changed = function() {
|
|
|
|
|
5535 |
var pos = this.find(-1, true), widget = this, cm = this.doc.cm
|
5536 |
if (!pos || !cm) { return }
|
5537 |
runInOp(cm, function () {
|
@@ -5549,24 +5689,27 @@ TextMarker.prototype.changed = function() {
|
|
5549 |
if (dHeight)
|
5550 |
{ updateLineHeight(line, line.height + dHeight) }
|
5551 |
}
|
|
|
5552 |
})
|
5553 |
-
}
|
5554 |
|
5555 |
-
TextMarker.prototype.attachLine = function(line) {
|
5556 |
if (!this.lines.length && this.doc.cm) {
|
5557 |
var op = this.doc.cm.curOp
|
5558 |
if (!op.maybeHiddenMarkers || indexOf(op.maybeHiddenMarkers, this) == -1)
|
5559 |
{ (op.maybeUnhiddenMarkers || (op.maybeUnhiddenMarkers = [])).push(this) }
|
5560 |
}
|
5561 |
this.lines.push(line)
|
5562 |
-
}
|
5563 |
-
|
|
|
5564 |
this.lines.splice(indexOf(this.lines, line), 1)
|
5565 |
if (!this.lines.length && this.doc.cm) {
|
5566 |
var op = this.doc.cm.curOp
|
5567 |
;(op.maybeHiddenMarkers || (op.maybeHiddenMarkers = [])).push(this)
|
5568 |
}
|
5569 |
-
}
|
|
|
5570 |
|
5571 |
// Create a marker, wire it up to the right lines, and
|
5572 |
function markText(doc, from, to, options, type) {
|
@@ -5585,8 +5728,7 @@ function markText(doc, from, to, options, type) {
|
|
5585 |
if (marker.replacedWith) {
|
5586 |
// Showing up as a widget implies collapsed (widget replaces text)
|
5587 |
marker.collapsed = true
|
5588 |
-
marker.widgetNode =
|
5589 |
-
marker.widgetNode.setAttribute("role", "presentation") // hide from accessibility tree
|
5590 |
if (!options.handleMouseEvents) { marker.widgetNode.setAttribute("cm-ignore-events", "true") }
|
5591 |
if (options.insertLeft) { marker.widgetNode.insertLeft = true }
|
5592 |
}
|
@@ -5644,28 +5786,29 @@ function markText(doc, from, to, options, type) {
|
|
5644 |
// A shared marker spans multiple linked documents. It is
|
5645 |
// implemented as a meta-marker-object controlling multiple normal
|
5646 |
// markers.
|
5647 |
-
|
5648 |
var this$1 = this;
|
5649 |
|
5650 |
this.markers = markers
|
5651 |
this.primary = primary
|
5652 |
for (var i = 0; i < markers.length; ++i)
|
5653 |
{ markers[i].parent = this$1 }
|
5654 |
-
}
|
5655 |
-
eventMixin(SharedTextMarker)
|
5656 |
|
5657 |
-
SharedTextMarker.prototype.clear = function() {
|
5658 |
-
|
5659 |
|
5660 |
if (this.explicitlyCleared) { return }
|
5661 |
this.explicitlyCleared = true
|
5662 |
for (var i = 0; i < this.markers.length; ++i)
|
5663 |
{ this$1.markers[i].clear() }
|
5664 |
signalLater(this, "clear")
|
5665 |
-
}
|
5666 |
-
|
|
|
5667 |
return this.primary.find(side, lineObj)
|
5668 |
-
}
|
|
|
5669 |
|
5670 |
function markTextShared(doc, from, to, options, type) {
|
5671 |
options = copyObj(options)
|
@@ -5715,8 +5858,8 @@ function detachSharedMarkers(markers) {
|
|
5715 |
}
|
5716 |
|
5717 |
var nextDocId = 0
|
5718 |
-
var Doc = function(text, mode, firstLine, lineSep) {
|
5719 |
-
if (!(this instanceof Doc)) { return new Doc(text, mode, firstLine, lineSep) }
|
5720 |
if (firstLine == null) { firstLine = 0 }
|
5721 |
|
5722 |
BranchChunk.call(this, [new LeafChunk([new Line("", null)])])
|
@@ -5731,6 +5874,7 @@ var Doc = function(text, mode, firstLine, lineSep) {
|
|
5731 |
this.id = ++nextDocId
|
5732 |
this.modeOption = mode
|
5733 |
this.lineSep = lineSep
|
|
|
5734 |
this.extend = false
|
5735 |
|
5736 |
if (typeof text == "string") { text = this.splitLines(text) }
|
@@ -5769,7 +5913,8 @@ Doc.prototype = createObj(BranchChunk.prototype, {
|
|
5769 |
var top = Pos(this.first, 0), last = this.first + this.size - 1
|
5770 |
makeChange(this, {from: top, to: Pos(last, getLine(this, last).text.length),
|
5771 |
text: this.splitLines(code), origin: "setValue", full: true}, true)
|
5772 |
-
|
|
|
5773 |
}),
|
5774 |
replaceRange: function(code, from, to, origin) {
|
5775 |
from = clipPos(this, from)
|
@@ -6067,7 +6212,7 @@ Doc.prototype = createObj(BranchChunk.prototype, {
|
|
6067 |
|
6068 |
copy: function(copyHistory) {
|
6069 |
var doc = new Doc(getLines(this, this.first, this.first + this.size),
|
6070 |
-
this.modeOption, this.first, this.lineSep)
|
6071 |
doc.scrollTop = this.scrollTop; doc.scrollLeft = this.scrollLeft
|
6072 |
doc.sel = this.sel
|
6073 |
doc.extend = false
|
@@ -6083,7 +6228,7 @@ Doc.prototype = createObj(BranchChunk.prototype, {
|
|
6083 |
var from = this.first, to = this.first + this.size
|
6084 |
if (options.from != null && options.from > from) { from = options.from }
|
6085 |
if (options.to != null && options.to < to) { to = options.to }
|
6086 |
-
var copy = new Doc(getLines(this, from, to), options.mode || this.modeOption, from, this.lineSep)
|
6087 |
if (options.sharedHist) { copy.history = this.history
|
6088 |
; }(this.linked || (this.linked = [])).push({doc: copy, sharedHist: options.sharedHist})
|
6089 |
copy.linked = [{doc: this, isParent: true, sharedHist: options.sharedHist}]
|
@@ -6120,7 +6265,15 @@ Doc.prototype = createObj(BranchChunk.prototype, {
|
|
6120 |
if (this.lineSep) { return str.split(this.lineSep) }
|
6121 |
return splitLinesAuto(str)
|
6122 |
},
|
6123 |
-
lineSeparator: function() { return this.lineSep || "\n" }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
6124 |
})
|
6125 |
|
6126 |
// Public alias.
|
@@ -6600,28 +6753,22 @@ function lineStart(cm, lineN) {
|
|
6600 |
var line = getLine(cm.doc, lineN)
|
6601 |
var visual = visualLine(line)
|
6602 |
if (visual != line) { lineN = lineNo(visual) }
|
6603 |
-
|
6604 |
-
var ch = !order ? 0 : order[0].level % 2 ? lineRight(visual) : lineLeft(visual)
|
6605 |
-
return Pos(lineN, ch)
|
6606 |
}
|
6607 |
function lineEnd(cm, lineN) {
|
6608 |
-
var
|
6609 |
-
|
6610 |
-
|
6611 |
-
|
6612 |
-
}
|
6613 |
-
var order = getOrder(line)
|
6614 |
-
var ch = !order ? line.text.length : order[0].level % 2 ? lineLeft(line) : lineRight(line)
|
6615 |
-
return Pos(lineN == null ? lineNo(line) : lineN, ch)
|
6616 |
}
|
6617 |
function lineStartSmart(cm, pos) {
|
6618 |
var start = lineStart(cm, pos.line)
|
6619 |
var line = getLine(cm.doc, start.line)
|
6620 |
-
var order = getOrder(line)
|
6621 |
if (!order || order[0].level == 0) {
|
6622 |
var firstNonWS = Math.max(0, line.text.search(/\S/))
|
6623 |
var inWS = pos.line == start.line && pos.ch <= firstNonWS && pos.ch
|
6624 |
-
return Pos(start.line, inWS ? 0 : firstNonWS)
|
6625 |
}
|
6626 |
return start
|
6627 |
}
|
@@ -6844,15 +6991,17 @@ function leftButtonDown(cm, e, start) {
|
|
6844 |
// Start a text drag. When it ends, see if any dragging actually
|
6845 |
// happen, and treat as a click if it didn't.
|
6846 |
function leftButtonStartDrag(cm, e, start, modifier) {
|
6847 |
-
var display = cm.display,
|
6848 |
-
var dragEnd = operation(cm, function (
|
6849 |
if (webkit) { display.scroller.draggable = false }
|
6850 |
cm.state.draggingText = false
|
6851 |
off(document, "mouseup", dragEnd)
|
|
|
|
|
6852 |
off(display.scroller, "drop", dragEnd)
|
6853 |
-
if (
|
6854 |
-
e_preventDefault(
|
6855 |
-
if (!modifier
|
6856 |
{ extendSelection(cm.doc, start) }
|
6857 |
// Work around unexplainable focus problem in IE9 (#2127) and Chrome (#3081)
|
6858 |
if (webkit || ie && ie_version == 9)
|
@@ -6861,6 +7010,10 @@ function leftButtonStartDrag(cm, e, start, modifier) {
|
|
6861 |
{ display.input.focus() }
|
6862 |
}
|
6863 |
})
|
|
|
|
|
|
|
|
|
6864 |
// Let the drag handler handle this.
|
6865 |
if (webkit) { display.scroller.draggable = true }
|
6866 |
cm.state.draggingText = dragEnd
|
@@ -6868,7 +7021,12 @@ function leftButtonStartDrag(cm, e, start, modifier) {
|
|
6868 |
// IE's approach to draggable
|
6869 |
if (display.scroller.dragDrop) { display.scroller.dragDrop() }
|
6870 |
on(document, "mouseup", dragEnd)
|
|
|
|
|
6871 |
on(display.scroller, "drop", dragEnd)
|
|
|
|
|
|
|
6872 |
}
|
6873 |
|
6874 |
// Normal selection, as opposed to text dragging.
|
@@ -7121,7 +7279,7 @@ function defineOptions(CodeMirror) {
|
|
7121 |
for (var i = newBreaks.length - 1; i >= 0; i--)
|
7122 |
{ replaceRange(cm.doc, val, newBreaks[i], Pos(newBreaks[i].line, newBreaks[i].ch + val.length)) }
|
7123 |
})
|
7124 |
-
option("specialChars", /[\u0000-\u001f\u007f\u00ad\u061c\u200b-\u200f\u2028\u2029\ufeff]/g, function (cm, val, old) {
|
7125 |
cm.state.specialChars = new RegExp(val.source + (val.test("\t") ? "" : "|\t"), "g")
|
7126 |
if (old != Init) { cm.refresh() }
|
7127 |
})
|
@@ -7206,6 +7364,7 @@ function defineOptions(CodeMirror) {
|
|
7206 |
|
7207 |
option("tabindex", null, function (cm, val) { return cm.display.input.getField().tabIndex = val || ""; })
|
7208 |
option("autofocus", null)
|
|
|
7209 |
}
|
7210 |
|
7211 |
function guttersChanged(cm) {
|
@@ -7256,7 +7415,7 @@ function CodeMirror(place, options) {
|
|
7256 |
setGuttersForLineNumbers(options)
|
7257 |
|
7258 |
var doc = options.value
|
7259 |
-
if (typeof doc == "string") { doc = new Doc(doc, options.mode, null, options.lineSeparator) }
|
7260 |
this.doc = doc
|
7261 |
|
7262 |
var input = new CodeMirror.inputStyles[options.inputStyle](this)
|
@@ -7813,7 +7972,7 @@ function addEditorMethods(CodeMirror) {
|
|
7813 |
} else {
|
7814 |
lineObj = line
|
7815 |
}
|
7816 |
-
return intoCoordSystem(this, lineObj, {top: 0, left: 0}, mode || "page", includeWidgets).top +
|
7817 |
(end ? this.doc.height - heightAtLine(lineObj) : 0)
|
7818 |
},
|
7819 |
|
@@ -7854,7 +8013,7 @@ function addEditorMethods(CodeMirror) {
|
|
7854 |
node.style.left = left + "px"
|
7855 |
}
|
7856 |
if (scroll)
|
7857 |
-
{ scrollIntoView(this, left, top, left + node.offsetWidth, top + node.offsetHeight) }
|
7858 |
},
|
7859 |
|
7860 |
triggerOnKeyDown: methodOp(onKeyDown),
|
@@ -7945,7 +8104,7 @@ function addEditorMethods(CodeMirror) {
|
|
7945 |
var start = pos.ch, end = pos.ch
|
7946 |
if (line) {
|
7947 |
var helper = this.getHelper(pos, "wordChars")
|
7948 |
-
if ((pos.
|
7949 |
var startChar = line.charAt(start)
|
7950 |
var check = isWordChar(startChar, helper)
|
7951 |
? function (ch) { return isWordChar(ch, helper); }
|
@@ -7998,10 +8157,12 @@ function addEditorMethods(CodeMirror) {
|
|
7998 |
resolveScrollToPos(this)
|
7999 |
this.curOp.scrollToPos = range
|
8000 |
} else {
|
8001 |
-
var sPos = calculateScrollPos(this,
|
8002 |
-
|
8003 |
-
|
8004 |
-
|
|
|
|
|
8005 |
this.scrollTo(sPos.scrollLeft, sPos.scrollTop)
|
8006 |
}
|
8007 |
}),
|
@@ -8076,22 +8237,30 @@ function addEditorMethods(CodeMirror) {
|
|
8076 |
// position. The resulting position will have a hitSide=true
|
8077 |
// property if it reached the end of the document.
|
8078 |
function findPosH(doc, pos, dir, unit, visually) {
|
8079 |
-
var
|
8080 |
-
var
|
|
|
8081 |
function findNextLine() {
|
8082 |
-
var l = line + dir
|
8083 |
if (l < doc.first || l >= doc.first + doc.size) { return false }
|
8084 |
-
|
8085 |
return lineObj = getLine(doc, l)
|
8086 |
}
|
8087 |
function moveOnce(boundToLine) {
|
8088 |
-
var next
|
|
|
|
|
|
|
|
|
|
|
8089 |
if (next == null) {
|
8090 |
-
if (!boundToLine && findNextLine())
|
8091 |
-
|
8092 |
-
|
8093 |
-
|
8094 |
-
} else {
|
|
|
|
|
8095 |
return true
|
8096 |
}
|
8097 |
|
@@ -8104,14 +8273,14 @@ function findPosH(doc, pos, dir, unit, visually) {
|
|
8104 |
var helper = doc.cm && doc.cm.getHelper(pos, "wordChars")
|
8105 |
for (var first = true;; first = false) {
|
8106 |
if (dir < 0 && !moveOnce(!first)) { break }
|
8107 |
-
var cur = lineObj.text.charAt(ch) || "\n"
|
8108 |
var type = isWordChar(cur, helper) ? "w"
|
8109 |
: group && cur == "\n" ? "n"
|
8110 |
: !group || /\s/.test(cur) ? null
|
8111 |
: "p"
|
8112 |
if (group && !first && !type) { type = "s" }
|
8113 |
if (sawType && sawType != type) {
|
8114 |
-
if (dir < 0) {dir = 1; moveOnce()}
|
8115 |
break
|
8116 |
}
|
8117 |
|
@@ -8119,8 +8288,8 @@ function findPosH(doc, pos, dir, unit, visually) {
|
|
8119 |
if (dir > 0 && !moveOnce(!first)) { break }
|
8120 |
}
|
8121 |
}
|
8122 |
-
var result = skipAtomic(doc,
|
8123 |
-
if (
|
8124 |
return result
|
8125 |
}
|
8126 |
|
@@ -8168,9 +8337,7 @@ ContentEditableInput.prototype.init = function (display) {
|
|
8168 |
on(div, "paste", function (e) {
|
8169 |
if (signalDOMEvent(cm, e) || handlePaste(e, cm)) { return }
|
8170 |
// IE doesn't fire input events, so we schedule a read for the pasted content in this way
|
8171 |
-
if (ie_version <= 11) { setTimeout(operation(cm, function () {
|
8172 |
-
if (!input.pollContent()) { regChange(cm) }
|
8173 |
-
}), 20) }
|
8174 |
})
|
8175 |
|
8176 |
on(div, "compositionstart", function (e) {
|
@@ -8248,33 +8415,41 @@ ContentEditableInput.prototype.showSelection = function (info, takeFocus) {
|
|
8248 |
};
|
8249 |
|
8250 |
ContentEditableInput.prototype.showPrimarySelection = function () {
|
8251 |
-
var sel = window.getSelection(),
|
8252 |
-
var
|
8253 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
8254 |
if (curAnchor && !curAnchor.bad && curFocus && !curFocus.bad &&
|
8255 |
-
cmp(minPos(curAnchor, curFocus),
|
8256 |
-
cmp(maxPos(curAnchor, curFocus),
|
8257 |
{ return }
|
8258 |
|
8259 |
-
var
|
8260 |
-
var
|
8261 |
-
|
8262 |
-
|
8263 |
-
|
8264 |
-
var old = sel.rangeCount && sel.getRangeAt(0)
|
8265 |
-
if (!start) {
|
8266 |
-
start = {node: view[0].measure.map[2], offset: 0}
|
8267 |
-
} else if (!end) { // FIXME dangerously hacky
|
8268 |
var measure = view[view.length - 1].measure
|
8269 |
var map = measure.maps ? measure.maps[measure.maps.length - 1] : measure.map
|
8270 |
end = {node: map[map.length - 1], offset: map[map.length - 2] - map[map.length - 3]}
|
8271 |
}
|
8272 |
|
8273 |
-
|
|
|
|
|
|
|
|
|
|
|
8274 |
try { rng = range(start.node, start.offset, end.offset, end.node) }
|
8275 |
catch(e) {} // Our model of the DOM might be outdated, in which case the range we try to set can be impossible
|
8276 |
if (rng) {
|
8277 |
-
if (!gecko &&
|
8278 |
sel.collapse(start.node, start.offset)
|
8279 |
if (!rng.collapsed) {
|
8280 |
sel.removeAllRanges()
|
@@ -8354,16 +8529,28 @@ ContentEditableInput.prototype.selectionChanged = function () {
|
|
8354 |
};
|
8355 |
|
8356 |
ContentEditableInput.prototype.pollSelection = function () {
|
8357 |
-
if (
|
8358 |
-
|
8359 |
-
|
8360 |
-
|
8361 |
-
|
8362 |
-
|
8363 |
-
|
8364 |
-
|
8365 |
-
|
|
|
|
|
|
|
|
|
8366 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
8367 |
};
|
8368 |
|
8369 |
ContentEditableInput.prototype.pollContent = function () {
|
@@ -8417,6 +8604,14 @@ ContentEditableInput.prototype.pollContent = function () {
|
|
8417 |
while (cutEnd < maxCutEnd &&
|
8418 |
newBot.charCodeAt(newBot.length - cutEnd - 1) == oldBot.charCodeAt(oldBot.length - cutEnd - 1))
|
8419 |
{ ++cutEnd }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
8420 |
|
8421 |
newText[newText.length - 1] = newBot.slice(0, newBot.length - cutEnd).replace(/^\u200b+/, "")
|
8422 |
newText[0] = newText[0].slice(cutFront).replace(/\u200b+$/, "")
|
@@ -8439,7 +8634,7 @@ ContentEditableInput.prototype.forceCompositionEnd = function () {
|
|
8439 |
if (!this.composing) { return }
|
8440 |
clearTimeout(this.readDOMTimeout)
|
8441 |
this.composing = null
|
8442 |
-
|
8443 |
this.div.blur()
|
8444 |
this.div.focus()
|
8445 |
};
|
@@ -8453,16 +8648,23 @@ ContentEditableInput.prototype.readFromDOMSoon = function () {
|
|
8453 |
if (this$1.composing.done) { this$1.composing = null }
|
8454 |
else { return }
|
8455 |
}
|
8456 |
-
|
8457 |
-
{ runInOp(this$1.cm, function () { return regChange(this$1.cm); }) }
|
8458 |
}, 80)
|
8459 |
};
|
8460 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
8461 |
ContentEditableInput.prototype.setUneditable = function (node) {
|
8462 |
node.contentEditable = "false"
|
8463 |
};
|
8464 |
|
8465 |
ContentEditableInput.prototype.onKeyPress = function (e) {
|
|
|
8466 |
e.preventDefault()
|
8467 |
if (!this.cm.isReadOnly())
|
8468 |
{ operation(this.cm, applyTextInput)(this.cm, String.fromCharCode(e.charCode == null ? e.keyCode : e.charCode), 0) }
|
@@ -8483,7 +8685,7 @@ function posToDOM(cm, pos) {
|
|
8483 |
var line = getLine(cm.doc, pos.line)
|
8484 |
var info = mapFromLineView(view, line, pos.line)
|
8485 |
|
8486 |
-
var order = getOrder(line), side = "left"
|
8487 |
if (order) {
|
8488 |
var partPos = getBidiPartAt(order, pos.ch)
|
8489 |
side = partPos % 2 ? "right" : "left"
|
@@ -8493,39 +8695,51 @@ function posToDOM(cm, pos) {
|
|
8493 |
return result
|
8494 |
}
|
8495 |
|
|
|
|
|
|
|
|
|
|
|
|
|
8496 |
function badPos(pos, bad) { if (bad) { pos.bad = true; } return pos }
|
8497 |
|
8498 |
function domTextBetween(cm, from, to, fromLine, toLine) {
|
8499 |
var text = "", closing = false, lineSep = cm.doc.lineSeparator()
|
8500 |
function recognizeMarker(id) { return function (marker) { return marker.id == id; } }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
8501 |
function walk(node) {
|
8502 |
if (node.nodeType == 1) {
|
8503 |
var cmText = node.getAttribute("cm-text")
|
8504 |
if (cmText != null) {
|
8505 |
-
|
8506 |
-
else { text += cmText }
|
8507 |
return
|
8508 |
}
|
8509 |
var markerID = node.getAttribute("cm-marker"), range
|
8510 |
if (markerID) {
|
8511 |
var found = cm.findMarks(Pos(fromLine, 0), Pos(toLine + 1, 0), recognizeMarker(+markerID))
|
8512 |
if (found.length && (range = found[0].find()))
|
8513 |
-
{
|
8514 |
return
|
8515 |
}
|
8516 |
if (node.getAttribute("contenteditable") == "false") { return }
|
|
|
|
|
8517 |
for (var i = 0; i < node.childNodes.length; i++)
|
8518 |
{ walk(node.childNodes[i]) }
|
8519 |
-
if (
|
8520 |
-
{ closing = true }
|
8521 |
} else if (node.nodeType == 3) {
|
8522 |
-
|
8523 |
-
if (!val) { return }
|
8524 |
-
if (closing) {
|
8525 |
-
text += lineSep
|
8526 |
-
closing = false
|
8527 |
-
}
|
8528 |
-
text += val
|
8529 |
}
|
8530 |
}
|
8531 |
for (;;) {
|
@@ -8927,10 +9141,14 @@ TextareaInput.prototype.onContextMenu = function (e) {
|
|
8927 |
if (!ie || (ie && ie_version < 9)) { prepareSelectAllHack() }
|
8928 |
var i = 0, poll = function () {
|
8929 |
if (display.selForContextMenu == cm.doc.sel && te.selectionStart == 0 &&
|
8930 |
-
te.selectionEnd > 0 && input.prevInput == "\u200b")
|
8931 |
-
|
8932 |
-
else if (i++ < 10) {
|
8933 |
-
|
|
|
|
|
|
|
|
|
8934 |
}
|
8935 |
display.detectingSelectAll = setTimeout(poll, 200)
|
8936 |
}
|
@@ -9106,7 +9324,7 @@ CodeMirror.fromTextArea = fromTextArea
|
|
9106 |
|
9107 |
addLegacyProps(CodeMirror)
|
9108 |
|
9109 |
-
CodeMirror.version = "5.
|
9110 |
|
9111 |
return CodeMirror;
|
9112 |
|
21 |
var gecko = /gecko\/\d/i.test(userAgent)
|
22 |
var ie_upto10 = /MSIE \d/.test(userAgent)
|
23 |
var ie_11up = /Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(userAgent)
|
24 |
+
var edge = /Edge\/(\d+)/.exec(userAgent)
|
25 |
+
var ie = ie_upto10 || ie_11up || edge
|
26 |
+
var ie_version = ie && (ie_upto10 ? document.documentMode || 6 : +(edge || ie_11up)[1])
|
27 |
+
var webkit = !edge && /WebKit\//.test(userAgent)
|
28 |
var qtwebkit = webkit && /Qt\/\d+\.\d+/.test(userAgent)
|
29 |
+
var chrome = !edge && /Chrome\//.test(userAgent)
|
30 |
var presto = /Opera\//.test(userAgent)
|
31 |
var safari = /Apple Computer/.test(navigator.vendor)
|
32 |
var mac_geMountainLion = /Mac OS X 1\d\D([8-9]|\d\d)\D/.test(userAgent)
|
33 |
var phantom = /PhantomJS/.test(userAgent)
|
34 |
|
35 |
+
var ios = !edge && /AppleWebKit/.test(userAgent) && /Mobile\/\w+/.test(userAgent)
|
36 |
+
var android = /Android/.test(userAgent)
|
37 |
// This is woefully incomplete. Suggestions for alternative methods welcome.
|
38 |
+
var mobile = ios || android || /webOS|BlackBerry|Opera Mini|Opera Mobi|IEMobile/i.test(userAgent)
|
39 |
var mac = ios || /Mac/.test(platform)
|
40 |
var chromeOS = /\bCrOS\b/.test(userAgent)
|
41 |
var windows = /win/i.test(platform)
|
76 |
else if (content) { for (var i = 0; i < content.length; ++i) { e.appendChild(content[i]) } }
|
77 |
return e
|
78 |
}
|
79 |
+
// wrapper for elt, which removes the elt from the accessibility tree
|
80 |
+
function eltP(tag, content, className, style) {
|
81 |
+
var e = elt(tag, content, className, style)
|
82 |
+
e.setAttribute("role", "presentation")
|
83 |
+
return e
|
84 |
+
}
|
85 |
|
86 |
var range
|
87 |
if (document.createRange) { range = function(node, start, end, endNode) {
|
121 |
} catch(e) {
|
122 |
activeElement = document.body || null
|
123 |
}
|
124 |
+
while (activeElement && activeElement.shadowRoot && activeElement.shadowRoot.activeElement)
|
125 |
+
{ activeElement = activeElement.shadowRoot.activeElement }
|
126 |
return activeElement
|
127 |
}
|
128 |
|
173 |
}
|
174 |
}
|
175 |
|
176 |
+
var Delayed = function() {this.id = null};
|
177 |
+
Delayed.prototype.set = function (ms, f) {
|
178 |
clearTimeout(this.id)
|
179 |
this.id = setTimeout(f, ms)
|
180 |
+
};
|
181 |
|
182 |
function indexOf(array, elt) {
|
183 |
for (var i = 0; i < array.length; ++i)
|
271 |
var extendingChars = /[\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]/
|
272 |
function isExtendingChar(ch) { return ch.charCodeAt(0) >= 768 && extendingChars.test(ch) }
|
273 |
|
274 |
+
// Returns a number from the range [`0`; `str.length`] unless `pos` is outside that range.
|
275 |
+
function skipExtendingChars(str, pos, dir) {
|
276 |
+
while ((dir < 0 ? pos > 0 : pos < str.length) && isExtendingChar(str.charAt(pos))) { pos += dir }
|
277 |
+
return pos
|
278 |
+
}
|
279 |
+
|
280 |
+
// Returns the value from the range [`from`; `to`] that satisfies
|
281 |
+
// `pred` and is closest to `from`. Assumes that at least `to` satisfies `pred`.
|
282 |
+
function findFirst(pred, from, to) {
|
283 |
+
for (;;) {
|
284 |
+
if (Math.abs(from - to) <= 1) { return pred(from) ? from : to }
|
285 |
+
var mid = Math.floor((from + to) / 2)
|
286 |
+
if (pred(mid)) { to = mid }
|
287 |
+
else { from = mid }
|
288 |
+
}
|
289 |
+
}
|
290 |
+
|
291 |
// The display handles the DOM integration, both for input reading
|
292 |
// and content drawing. It holds references to DOM nodes and
|
293 |
// display-related state.
|
304 |
d.gutterFiller = elt("div", null, "CodeMirror-gutter-filler")
|
305 |
d.gutterFiller.setAttribute("cm-not-content", "true")
|
306 |
// Will contain the actual code, positioned to cover the viewport.
|
307 |
+
d.lineDiv = eltP("div", null, "CodeMirror-code")
|
308 |
// Elements are added to these to represent selection and cursors.
|
309 |
d.selectionDiv = elt("div", null, null, "position: relative; z-index: 1")
|
310 |
d.cursorDiv = elt("div", null, "CodeMirror-cursors")
|
313 |
// When lines outside of the viewport are measured, they are drawn in this.
|
314 |
d.lineMeasure = elt("div", null, "CodeMirror-measure")
|
315 |
// Wraps everything that needs to exist inside the vertically-padded coordinate system
|
316 |
+
d.lineSpace = eltP("div", [d.measure, d.lineMeasure, d.selectionDiv, d.cursorDiv, d.lineDiv],
|
317 |
null, "position: relative; outline: none")
|
318 |
+
var lines = eltP("div", [d.lineSpace], "CodeMirror-lines")
|
319 |
// Moved around its parent to cover visible view.
|
320 |
+
d.mover = elt("div", [lines], null, "position: relative")
|
321 |
// Set to the height of the document, allowing scrolling.
|
322 |
d.sizer = elt("div", [d.mover], "CodeMirror-sizer")
|
323 |
d.sizerWidth = null
|
476 |
}
|
477 |
|
478 |
// A Pos instance represents a position within the text.
|
479 |
+
function Pos(line, ch, sticky) {
|
480 |
+
if ( sticky === void 0 ) sticky = null;
|
481 |
+
|
482 |
+
if (!(this instanceof Pos)) { return new Pos(line, ch, sticky) }
|
483 |
+
this.line = line
|
484 |
+
this.ch = ch
|
485 |
+
this.sticky = sticky
|
486 |
}
|
487 |
|
488 |
// Compare two positions, return 0 if they are the same, a negative
|
489 |
// number when a is less, and a positive number otherwise.
|
490 |
function cmp(a, b) { return a.line - b.line || a.ch - b.ch }
|
491 |
|
492 |
+
function equalCursorPos(a, b) { return a.sticky == b.sticky && cmp(a, b) == 0 }
|
493 |
+
|
494 |
function copyPos(x) {return Pos(x.line, x.ch)}
|
495 |
function maxPos(a, b) { return cmp(a, b) < 0 ? b : a }
|
496 |
function minPos(a, b) { return cmp(a, b) < 0 ? a : b }
|
686 |
if (dto > 0 || !mk.inclusiveRight && !dto)
|
687 |
{ newParts.push({from: m.to, to: p.to}) }
|
688 |
parts.splice.apply(parts, newParts)
|
689 |
+
j += newParts.length - 3
|
690 |
}
|
691 |
}
|
692 |
return parts
|
771 |
return line
|
772 |
}
|
773 |
|
774 |
+
function visualLineEnd(line) {
|
775 |
+
var merged
|
776 |
+
while (merged = collapsedSpanAtEnd(line))
|
777 |
+
{ line = merged.find(1, true).line }
|
778 |
+
return line
|
779 |
+
}
|
780 |
+
|
781 |
// Returns an array of logical lines that continue the visual line
|
782 |
// started by the argument, or undefined if there are no such lines.
|
783 |
function visualLineContinued(line) {
|
909 |
if (!found) { f(from, to, "ltr") }
|
910 |
}
|
911 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
912 |
var bidiOther = null
|
913 |
+
function getBidiPartAt(order, ch, sticky) {
|
914 |
var found
|
915 |
bidiOther = null
|
916 |
for (var i = 0; i < order.length; ++i) {
|
917 |
var cur = order[i]
|
918 |
+
if (cur.from < ch && cur.to > ch) { return i }
|
919 |
+
if (cur.to == ch) {
|
920 |
+
if (cur.from != cur.to && sticky == "before") { found = i }
|
921 |
+
else { bidiOther = i }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
922 |
}
|
923 |
+
if (cur.from == ch) {
|
924 |
+
if (cur.from != cur.to && sticky != "before") { found = i }
|
925 |
+
else { bidiOther = i }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
926 |
}
|
927 |
}
|
928 |
+
return found != null ? found : bidiOther
|
|
|
|
|
|
|
|
|
|
|
929 |
}
|
930 |
|
931 |
// Bidirectional ordering algorithm
|
968 |
|
969 |
var bidiRE = /[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/
|
970 |
var isNeutral = /[stwN]/, isStrong = /[LRr]/, countsAsLeft = /[Lb1n]/, countsAsNum = /[1n]/
|
|
|
|
|
971 |
|
972 |
function BidiSpan(level, from, to) {
|
973 |
this.level = level
|
974 |
this.from = from; this.to = to
|
975 |
}
|
976 |
|
977 |
+
return function(str, direction) {
|
978 |
+
var outerType = direction == "ltr" ? "L" : "R"
|
979 |
+
|
980 |
+
if (str.length == 0 || direction == "ltr" && !bidiRE.test(str)) { return false }
|
981 |
var len = str.length, types = []
|
982 |
for (var i = 0; i < len; ++i)
|
983 |
{ types.push(charType(str.charCodeAt(i))) }
|
1051 |
for (end$1 = i$6 + 1; end$1 < len && isNeutral.test(types[end$1]); ++end$1) {}
|
1052 |
var before = (i$6 ? types[i$6-1] : outerType) == "L"
|
1053 |
var after = (end$1 < len ? types[end$1] : outerType) == "L"
|
1054 |
+
var replace$1 = before == after ? (before ? "L" : "R") : outerType
|
1055 |
for (var j$1 = i$6; j$1 < end$1; ++j$1) { types[j$1] = replace$1 }
|
1056 |
i$6 = end$1 - 1
|
1057 |
}
|
1091 |
lst(order).to -= m[0].length
|
1092 |
order.push(new BidiSpan(0, len - m[0].length, len))
|
1093 |
}
|
|
|
|
|
|
|
|
|
1094 |
|
1095 |
+
return direction == "rtl" ? order.reverse() : order
|
1096 |
}
|
1097 |
})()
|
1098 |
|
1099 |
// Get the bidi ordering for the given line (and cache it). Returns
|
1100 |
// false for lines that are fully left-to-right, and an array of
|
1101 |
// BidiSpan objects otherwise.
|
1102 |
+
function getOrder(line, direction) {
|
1103 |
var order = line.order
|
1104 |
+
if (order == null) { order = line.order = bidiOrdering(line.text, direction) }
|
1105 |
return order
|
1106 |
}
|
1107 |
|
1108 |
+
function moveCharLogically(line, ch, dir) {
|
1109 |
+
var target = skipExtendingChars(line.text, ch + dir, dir)
|
1110 |
+
return target < 0 || target > line.text.length ? null : target
|
1111 |
+
}
|
1112 |
+
|
1113 |
+
function moveLogically(line, start, dir) {
|
1114 |
+
var ch = moveCharLogically(line, start.ch, dir)
|
1115 |
+
return ch == null ? null : new Pos(start.line, ch, dir < 0 ? "after" : "before")
|
1116 |
+
}
|
1117 |
+
|
1118 |
+
function endOfLine(visually, cm, lineObj, lineNo, dir) {
|
1119 |
+
if (visually) {
|
1120 |
+
var order = getOrder(lineObj, cm.doc.direction)
|
1121 |
+
if (order) {
|
1122 |
+
var part = dir < 0 ? lst(order) : order[0]
|
1123 |
+
var moveInStorageOrder = (dir < 0) == (part.level == 1)
|
1124 |
+
var sticky = moveInStorageOrder ? "after" : "before"
|
1125 |
+
var ch
|
1126 |
+
// With a wrapped rtl chunk (possibly spanning multiple bidi parts),
|
1127 |
+
// it could be that the last bidi part is not on the last visual line,
|
1128 |
+
// since visual lines contain content order-consecutive chunks.
|
1129 |
+
// Thus, in rtl, we are looking for the first (content-order) character
|
1130 |
+
// in the rtl chunk that is on the last line (that is, the same line
|
1131 |
+
// as the last (content-order) character).
|
1132 |
+
if (part.level > 0) {
|
1133 |
+
var prep = prepareMeasureForLine(cm, lineObj)
|
1134 |
+
ch = dir < 0 ? lineObj.text.length - 1 : 0
|
1135 |
+
var targetTop = measureCharPrepared(cm, prep, ch).top
|
1136 |
+
ch = findFirst(function (ch) { return measureCharPrepared(cm, prep, ch).top == targetTop; }, (dir < 0) == (part.level == 1) ? part.from : part.to - 1, ch)
|
1137 |
+
if (sticky == "before") { ch = moveCharLogically(lineObj, ch, 1, true) }
|
1138 |
+
} else { ch = dir < 0 ? part.to : part.from }
|
1139 |
+
return new Pos(lineNo, ch, sticky)
|
1140 |
+
}
|
1141 |
+
}
|
1142 |
+
return new Pos(lineNo, dir < 0 ? lineObj.text.length : 0, dir < 0 ? "before" : "after")
|
1143 |
+
}
|
1144 |
+
|
1145 |
+
function moveVisually(cm, line, start, dir) {
|
1146 |
+
var bidi = getOrder(line, cm.doc.direction)
|
1147 |
+
if (!bidi) { return moveLogically(line, start, dir) }
|
1148 |
+
if (start.ch >= line.text.length) {
|
1149 |
+
start.ch = line.text.length
|
1150 |
+
start.sticky = "before"
|
1151 |
+
} else if (start.ch <= 0) {
|
1152 |
+
start.ch = 0
|
1153 |
+
start.sticky = "after"
|
1154 |
+
}
|
1155 |
+
var partPos = getBidiPartAt(bidi, start.ch, start.sticky), part = bidi[partPos]
|
1156 |
+
if (cm.doc.direction == "ltr" && part.level % 2 == 0 && (dir > 0 ? part.to > start.ch : part.from < start.ch)) {
|
1157 |
+
// Case 1: We move within an ltr part in an ltr editor. Even with wrapped lines,
|
1158 |
+
// nothing interesting happens.
|
1159 |
+
return moveLogically(line, start, dir)
|
1160 |
+
}
|
1161 |
+
|
1162 |
+
var mv = function (pos, dir) { return moveCharLogically(line, pos instanceof Pos ? pos.ch : pos, dir); }
|
1163 |
+
var prep
|
1164 |
+
var getWrappedLineExtent = function (ch) {
|
1165 |
+
if (!cm.options.lineWrapping) { return {begin: 0, end: line.text.length} }
|
1166 |
+
prep = prep || prepareMeasureForLine(cm, line)
|
1167 |
+
return wrappedLineExtentChar(cm, line, prep, ch)
|
1168 |
+
}
|
1169 |
+
var wrappedLineExtent = getWrappedLineExtent(start.sticky == "before" ? mv(start, -1) : start.ch)
|
1170 |
+
|
1171 |
+
if (cm.doc.direction == "rtl" || part.level == 1) {
|
1172 |
+
var moveInStorageOrder = (part.level == 1) == (dir < 0)
|
1173 |
+
var ch = mv(start, moveInStorageOrder ? 1 : -1)
|
1174 |
+
if (ch != null && (!moveInStorageOrder ? ch >= part.from && ch >= wrappedLineExtent.begin : ch <= part.to && ch <= wrappedLineExtent.end)) {
|
1175 |
+
// Case 2: We move within an rtl part or in an rtl editor on the same visual line
|
1176 |
+
var sticky = moveInStorageOrder ? "before" : "after"
|
1177 |
+
return new Pos(start.line, ch, sticky)
|
1178 |
+
}
|
1179 |
+
}
|
1180 |
+
|
1181 |
+
// Case 3: Could not move within this bidi part in this visual line, so leave
|
1182 |
+
// the current bidi part
|
1183 |
+
|
1184 |
+
var searchInVisualLine = function (partPos, dir, wrappedLineExtent) {
|
1185 |
+
var getRes = function (ch, moveInStorageOrder) { return moveInStorageOrder
|
1186 |
+
? new Pos(start.line, mv(ch, 1), "before")
|
1187 |
+
: new Pos(start.line, ch, "after"); }
|
1188 |
+
|
1189 |
+
for (; partPos >= 0 && partPos < bidi.length; partPos += dir) {
|
1190 |
+
var part = bidi[partPos]
|
1191 |
+
var moveInStorageOrder = (dir > 0) == (part.level != 1)
|
1192 |
+
var ch = moveInStorageOrder ? wrappedLineExtent.begin : mv(wrappedLineExtent.end, -1)
|
1193 |
+
if (part.from <= ch && ch < part.to) { return getRes(ch, moveInStorageOrder) }
|
1194 |
+
ch = moveInStorageOrder ? part.from : mv(part.to, -1)
|
1195 |
+
if (wrappedLineExtent.begin <= ch && ch < wrappedLineExtent.end) { return getRes(ch, moveInStorageOrder) }
|
1196 |
+
}
|
1197 |
+
}
|
1198 |
+
|
1199 |
+
// Case 3a: Look for other bidi parts on the same visual line
|
1200 |
+
var res = searchInVisualLine(partPos + dir, dir, wrappedLineExtent)
|
1201 |
+
if (res) { return res }
|
1202 |
+
|
1203 |
+
// Case 3b: Look for other bidi parts on the next visual line
|
1204 |
+
var nextCh = dir > 0 ? wrappedLineExtent.end : mv(wrappedLineExtent.begin, -1)
|
1205 |
+
if (nextCh != null && !(dir > 0 && nextCh == line.text.length)) {
|
1206 |
+
res = searchInVisualLine(dir > 0 ? 0 : bidi.length - 1, dir, getWrappedLineExtent(nextCh))
|
1207 |
+
if (res) { return res }
|
1208 |
+
}
|
1209 |
+
|
1210 |
+
// Case 4: Nowhere to move
|
1211 |
+
return null
|
1212 |
+
}
|
1213 |
+
|
1214 |
// EVENT HANDLING
|
1215 |
|
1216 |
// Lightweight event framework. on/off also work on DOM nodes,
|
1499 |
this.tabSize = tabSize || 8
|
1500 |
this.lastColumnPos = this.lastColumnValue = 0
|
1501 |
this.lineStart = 0
|
1502 |
+
};
|
1503 |
|
1504 |
+
StringStream.prototype.eol = function () {return this.pos >= this.string.length};
|
1505 |
+
StringStream.prototype.sol = function () {return this.pos == this.lineStart};
|
1506 |
+
StringStream.prototype.peek = function () {return this.string.charAt(this.pos) || undefined};
|
1507 |
+
StringStream.prototype.next = function () {
|
1508 |
+
if (this.pos < this.string.length)
|
1509 |
+
{ return this.string.charAt(this.pos++) }
|
1510 |
+
};
|
1511 |
+
StringStream.prototype.eat = function (match) {
|
1512 |
+
var ch = this.string.charAt(this.pos)
|
1513 |
+
var ok
|
1514 |
+
if (typeof match == "string") { ok = ch == match }
|
1515 |
+
else { ok = ch && (match.test ? match.test(ch) : match(ch)) }
|
1516 |
+
if (ok) {++this.pos; return ch}
|
1517 |
+
};
|
1518 |
+
StringStream.prototype.eatWhile = function (match) {
|
1519 |
+
var start = this.pos
|
1520 |
+
while (this.eat(match)){}
|
1521 |
+
return this.pos > start
|
1522 |
+
};
|
1523 |
+
StringStream.prototype.eatSpace = function () {
|
|
|
1524 |
var this$1 = this;
|
1525 |
|
1526 |
+
var start = this.pos
|
1527 |
+
while (/[\s\u00a0]/.test(this.string.charAt(this.pos))) { ++this$1.pos }
|
1528 |
+
return this.pos > start
|
1529 |
+
};
|
1530 |
+
StringStream.prototype.skipToEnd = function () {this.pos = this.string.length};
|
1531 |
+
StringStream.prototype.skipTo = function (ch) {
|
1532 |
+
var found = this.string.indexOf(ch, this.pos)
|
1533 |
+
if (found > -1) {this.pos = found; return true}
|
1534 |
+
};
|
1535 |
+
StringStream.prototype.backUp = function (n) {this.pos -= n};
|
1536 |
+
StringStream.prototype.column = function () {
|
1537 |
+
if (this.lastColumnPos < this.start) {
|
1538 |
+
this.lastColumnValue = countColumn(this.string, this.start, this.tabSize, this.lastColumnPos, this.lastColumnValue)
|
1539 |
+
this.lastColumnPos = this.start
|
1540 |
+
}
|
1541 |
+
return this.lastColumnValue - (this.lineStart ? countColumn(this.string, this.lineStart, this.tabSize) : 0)
|
1542 |
+
};
|
1543 |
+
StringStream.prototype.indentation = function () {
|
1544 |
+
return countColumn(this.string, null, this.tabSize) -
|
1545 |
+
(this.lineStart ? countColumn(this.string, this.lineStart, this.tabSize) : 0)
|
1546 |
+
};
|
1547 |
+
StringStream.prototype.match = function (pattern, consume, caseInsensitive) {
|
1548 |
+
if (typeof pattern == "string") {
|
1549 |
+
var cased = function (str) { return caseInsensitive ? str.toLowerCase() : str; }
|
1550 |
+
var substr = this.string.substr(this.pos, pattern.length)
|
1551 |
+
if (cased(substr) == cased(pattern)) {
|
1552 |
+
if (consume !== false) { this.pos += pattern.length }
|
1553 |
+
return true
|
|
|
|
|
|
|
|
|
|
|
|
|
1554 |
}
|
1555 |
+
} else {
|
1556 |
+
var match = this.string.slice(this.pos).match(pattern)
|
1557 |
+
if (match && match.index > 0) { return null }
|
1558 |
+
if (match && consume !== false) { this.pos += match[0].length }
|
1559 |
+
return match
|
|
|
1560 |
}
|
1561 |
+
};
|
1562 |
+
StringStream.prototype.current = function (){return this.string.slice(this.start, this.pos)};
|
1563 |
+
StringStream.prototype.hideFirstChars = function (n, inner) {
|
1564 |
+
this.lineStart += n
|
1565 |
+
try { return inner() }
|
1566 |
+
finally { this.lineStart -= n }
|
1567 |
+
};
|
1568 |
|
1569 |
// Compute a style array (an array starting with a mode generation
|
1570 |
// -- for invalidation -- followed by pairs of end positions and
|
1769 |
|
1770 |
// Line objects. These hold state related to a line, including
|
1771 |
// highlighting info (the styles array).
|
1772 |
+
var Line = function(text, markedSpans, estimateHeight) {
|
1773 |
this.text = text
|
1774 |
attachMarkedSpans(this, markedSpans)
|
1775 |
this.height = estimateHeight ? estimateHeight(this) : 1
|
1776 |
+
};
|
1777 |
+
|
1778 |
+
Line.prototype.lineNo = function () { return lineNo(this) };
|
1779 |
eventMixin(Line)
|
|
|
1780 |
|
1781 |
// Change the content (text, markers) of a line. Automatically
|
1782 |
// invalidates cached information and tries to re-estimate the
|
1819 |
// The padding-right forces the element to have a 'border', which
|
1820 |
// is needed on Webkit to be able to get line-level bounding
|
1821 |
// rectangles for it (in measureChar).
|
1822 |
+
var content = eltP("span", null, null, webkit ? "padding-right: .1px" : null)
|
1823 |
+
var builder = {pre: eltP("pre", [content], "CodeMirror-line"), content: content,
|
1824 |
col: 0, pos: 0, cm: cm,
|
1825 |
trailingSpace: false,
|
1826 |
splitSpaces: (ie || webkit) && cm.getOption("lineWrapping")}
|
|
|
|
|
|
|
1827 |
lineView.measure = {}
|
1828 |
|
1829 |
// Iterate over the logical lines that make up this visual line.
|
1833 |
builder.addToken = buildToken
|
1834 |
// Optionally wire in some hacks into the token-rendering
|
1835 |
// algorithm, to deal with browser quirks.
|
1836 |
+
if (hasBadBidiRects(cm.display.measure) && (order = getOrder(line, cm.doc.direction)))
|
1837 |
{ builder.addToken = buildTokenBadBidi(builder.addToken, order) }
|
1838 |
builder.map = []
|
1839 |
var allowFrontierUpdate = lineView != cm.display.externalMeasured && lineNo(line)
|
2174 |
var type = lineView.changes[j]
|
2175 |
if (type == "text") { updateLineText(cm, lineView) }
|
2176 |
else if (type == "gutter") { updateLineGutter(cm, lineView, lineN, dims) }
|
2177 |
+
else if (type == "class") { updateLineClasses(cm, lineView) }
|
2178 |
else if (type == "widget") { updateLineWidgets(cm, lineView, dims) }
|
2179 |
}
|
2180 |
lineView.changes = null
|
2193 |
return lineView.node
|
2194 |
}
|
2195 |
|
2196 |
+
function updateLineBackground(cm, lineView) {
|
2197 |
var cls = lineView.bgClass ? lineView.bgClass + " " + (lineView.line.bgClass || "") : lineView.line.bgClass
|
2198 |
if (cls) { cls += " CodeMirror-linebackground" }
|
2199 |
if (lineView.background) {
|
2202 |
} else if (cls) {
|
2203 |
var wrap = ensureLineWrapped(lineView)
|
2204 |
lineView.background = wrap.insertBefore(elt("div", null, cls), wrap.firstChild)
|
2205 |
+
cm.display.input.setUneditable(lineView.background)
|
2206 |
}
|
2207 |
}
|
2208 |
|
2230 |
if (built.bgClass != lineView.bgClass || built.textClass != lineView.textClass) {
|
2231 |
lineView.bgClass = built.bgClass
|
2232 |
lineView.textClass = built.textClass
|
2233 |
+
updateLineClasses(cm, lineView)
|
2234 |
} else if (cls) {
|
2235 |
lineView.text.className = cls
|
2236 |
}
|
2237 |
}
|
2238 |
|
2239 |
+
function updateLineClasses(cm, lineView) {
|
2240 |
+
updateLineBackground(cm, lineView)
|
2241 |
if (lineView.line.wrapClass)
|
2242 |
{ ensureLineWrapped(lineView).className = lineView.line.wrapClass }
|
2243 |
else if (lineView.node != lineView.text)
|
2259 |
var wrap = ensureLineWrapped(lineView)
|
2260 |
lineView.gutterBackground = elt("div", null, "CodeMirror-gutter-background " + lineView.line.gutterClass,
|
2261 |
("left: " + (cm.options.fixedGutter ? dims.fixedPos : -dims.gutterTotalWidth) + "px; width: " + (dims.gutterTotalWidth) + "px"))
|
2262 |
+
cm.display.input.setUneditable(lineView.gutterBackground)
|
2263 |
wrap.insertBefore(lineView.gutterBackground, lineView.text)
|
2264 |
}
|
2265 |
var markers = lineView.line.gutterMarkers
|
2301 |
if (built.bgClass) { lineView.bgClass = built.bgClass }
|
2302 |
if (built.textClass) { lineView.textClass = built.textClass }
|
2303 |
|
2304 |
+
updateLineClasses(cm, lineView)
|
2305 |
updateLineGutter(cm, lineView, lineN, dims)
|
2306 |
insertLineWidgets(cm, lineView, dims)
|
2307 |
return lineView.node
|
2641 |
cm.display.lineNumChars = null
|
2642 |
}
|
2643 |
|
2644 |
+
function pageScrollX() {
|
2645 |
+
// Work around https://bugs.chromium.org/p/chromium/issues/detail?id=489206
|
2646 |
+
// which causes page_Offset and bounding client rects to use
|
2647 |
+
// different reference viewports and invalidate our calculations.
|
2648 |
+
if (chrome && android) { return -(document.body.getBoundingClientRect().left - parseInt(getComputedStyle(document.body).marginLeft)) }
|
2649 |
+
return window.pageXOffset || (document.documentElement || document.body).scrollLeft
|
2650 |
+
}
|
2651 |
+
function pageScrollY() {
|
2652 |
+
if (chrome && android) { return -(document.body.getBoundingClientRect().top - parseInt(getComputedStyle(document.body).marginTop)) }
|
2653 |
+
return window.pageYOffset || (document.documentElement || document.body).scrollTop
|
2654 |
+
}
|
2655 |
|
2656 |
// Converts a {top, bottom, left, right} box from line-local
|
2657 |
// coordinates into another coordinate system. Context may be one of
|
2704 |
// Returns a box for a given cursor position, which may have an
|
2705 |
// 'other' property containing the position of the secondary cursor
|
2706 |
// on a bidi boundary.
|
2707 |
+
// A cursor Pos(line, char, "before") is on the same visual line as `char - 1`
|
2708 |
+
// and after `char - 1` in writing order of `char - 1`
|
2709 |
+
// A cursor Pos(line, char, "after") is on the same visual line as `char`
|
2710 |
+
// and before `char` in writing order of `char`
|
2711 |
+
// Examples (upper-case letters are RTL, lower-case are LTR):
|
2712 |
+
// Pos(0, 1, ...)
|
2713 |
+
// before after
|
2714 |
+
// ab a|b a|b
|
2715 |
+
// aB a|B aB|
|
2716 |
+
// Ab |Ab A|b
|
2717 |
+
// AB B|A B|A
|
2718 |
+
// Every position after the last character on a line is considered to stick
|
2719 |
+
// to the last character on the line.
|
2720 |
function cursorCoords(cm, pos, context, lineObj, preparedMeasure, varHeight) {
|
2721 |
lineObj = lineObj || getLine(cm.doc, pos.line)
|
2722 |
if (!preparedMeasure) { preparedMeasure = prepareMeasureForLine(cm, lineObj) }
|
2725 |
if (right) { m.left = m.right; } else { m.right = m.left }
|
2726 |
return intoCoordSystem(cm, lineObj, m, context)
|
2727 |
}
|
2728 |
+
var order = getOrder(lineObj, cm.doc.direction), ch = pos.ch, sticky = pos.sticky
|
2729 |
+
if (ch >= lineObj.text.length) {
|
2730 |
+
ch = lineObj.text.length
|
2731 |
+
sticky = "before"
|
2732 |
+
} else if (ch <= 0) {
|
2733 |
+
ch = 0
|
2734 |
+
sticky = "after"
|
2735 |
+
}
|
2736 |
+
if (!order) { return get(sticky == "before" ? ch - 1 : ch, sticky == "before") }
|
2737 |
+
|
2738 |
+
function getBidi(ch, partPos, invert) {
|
2739 |
+
var part = order[partPos], right = (part.level % 2) != 0
|
2740 |
+
return get(invert ? ch - 1 : ch, right != invert)
|
2741 |
+
}
|
2742 |
+
var partPos = getBidiPartAt(order, ch, sticky)
|
2743 |
+
var other = bidiOther
|
2744 |
+
var val = getBidi(ch, partPos, sticky == "before")
|
2745 |
+
if (other != null) { val.other = getBidi(ch, other, sticky != "before") }
|
|
|
2746 |
return val
|
2747 |
}
|
2748 |
|
2763 |
// the right of the character position, for example). When outside
|
2764 |
// is true, that means the coordinates lie outside the line's
|
2765 |
// vertical range.
|
2766 |
+
function PosWithInfo(line, ch, sticky, outside, xRel) {
|
2767 |
+
var pos = Pos(line, ch, sticky)
|
2768 |
pos.xRel = xRel
|
2769 |
if (outside) { pos.outside = true }
|
2770 |
return pos
|
2775 |
function coordsChar(cm, x, y) {
|
2776 |
var doc = cm.doc
|
2777 |
y += cm.display.viewOffset
|
2778 |
+
if (y < 0) { return PosWithInfo(doc.first, 0, null, true, -1) }
|
2779 |
var lineN = lineAtHeight(doc, y), last = doc.first + doc.size - 1
|
2780 |
if (lineN > last)
|
2781 |
+
{ return PosWithInfo(doc.first + doc.size - 1, getLine(doc, last).text.length, null, true, 1) }
|
2782 |
if (x < 0) { x = 0 }
|
2783 |
|
2784 |
var lineObj = getLine(doc, lineN)
|
2793 |
}
|
2794 |
}
|
2795 |
|
2796 |
+
function wrappedLineExtent(cm, lineObj, preparedMeasure, y) {
|
2797 |
+
var measure = function (ch) { return intoCoordSystem(cm, lineObj, measureCharPrepared(cm, preparedMeasure, ch), "line"); }
|
2798 |
+
var end = lineObj.text.length
|
2799 |
+
var begin = findFirst(function (ch) { return measure(ch - 1).bottom <= y; }, end, 0)
|
2800 |
+
end = findFirst(function (ch) { return measure(ch).top > y; }, begin, end)
|
2801 |
+
return {begin: begin, end: end}
|
2802 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2803 |
|
2804 |
+
function wrappedLineExtentChar(cm, lineObj, preparedMeasure, target) {
|
2805 |
+
var targetTop = intoCoordSystem(cm, lineObj, measureCharPrepared(cm, preparedMeasure, target), "line").top
|
2806 |
+
return wrappedLineExtent(cm, lineObj, preparedMeasure, targetTop)
|
2807 |
+
}
|
2808 |
|
2809 |
+
function coordsCharInner(cm, lineObj, lineNo, x, y) {
|
2810 |
+
y -= heightAtLine(lineObj)
|
2811 |
+
var begin = 0, end = lineObj.text.length
|
2812 |
+
var preparedMeasure = prepareMeasureForLine(cm, lineObj)
|
2813 |
+
var pos
|
2814 |
+
var order = getOrder(lineObj, cm.doc.direction)
|
2815 |
+
if (order) {
|
2816 |
+
if (cm.options.lineWrapping) {
|
2817 |
+
;var assign;
|
2818 |
+
((assign = wrappedLineExtent(cm, lineObj, preparedMeasure, y), begin = assign.begin, end = assign.end, assign))
|
2819 |
+
}
|
2820 |
+
pos = new Pos(lineNo, begin)
|
2821 |
+
var beginLeft = cursorCoords(cm, pos, "line", lineObj, preparedMeasure).left
|
2822 |
+
var dir = beginLeft < x ? 1 : -1
|
2823 |
+
var prevDiff, diff = beginLeft - x, prevPos
|
2824 |
+
do {
|
2825 |
+
prevDiff = diff
|
2826 |
+
prevPos = pos
|
2827 |
+
pos = moveVisually(cm, lineObj, pos, dir)
|
2828 |
+
if (pos == null || pos.ch < begin || end <= (pos.sticky == "before" ? pos.ch - 1 : pos.ch)) {
|
2829 |
+
pos = prevPos
|
2830 |
+
break
|
2831 |
}
|
2832 |
+
diff = cursorCoords(cm, pos, "line", lineObj, preparedMeasure).left - x
|
2833 |
+
} while ((dir < 0) != (diff < 0) && (Math.abs(diff) <= Math.abs(prevDiff)))
|
2834 |
+
if (Math.abs(diff) > Math.abs(prevDiff)) {
|
2835 |
+
if ((diff < 0) == (prevDiff < 0)) { throw new Error("Broke out of infinite loop in coordsCharInner") }
|
2836 |
+
pos = prevPos
|
|
|
|
|
|
|
2837 |
}
|
2838 |
+
} else {
|
2839 |
+
var ch = findFirst(function (ch) {
|
2840 |
+
var box = intoCoordSystem(cm, lineObj, measureCharPrepared(cm, preparedMeasure, ch), "line")
|
2841 |
+
if (box.top > y) {
|
2842 |
+
// For the cursor stickiness
|
2843 |
+
end = Math.min(ch, end)
|
2844 |
+
return true
|
2845 |
+
}
|
2846 |
+
else if (box.bottom <= y) { return false }
|
2847 |
+
else if (box.left > x) { return true }
|
2848 |
+
else if (box.right < x) { return false }
|
2849 |
+
else { return (x - box.left < box.right - x) }
|
2850 |
+
}, begin, end)
|
2851 |
+
ch = skipExtendingChars(lineObj.text, ch, 1)
|
2852 |
+
pos = new Pos(lineNo, ch, ch == end ? "before" : "after")
|
2853 |
+
}
|
2854 |
+
var coords = cursorCoords(cm, pos, "line", lineObj, preparedMeasure)
|
2855 |
+
if (y < coords.top || coords.bottom < y) { pos.outside = true }
|
2856 |
+
pos.xRel = x < coords.left ? -1 : (x > coords.right ? 1 : 0)
|
2857 |
+
return pos
|
2858 |
}
|
2859 |
|
2860 |
var measureText
|
3038 |
return charCoords(cm, Pos(line, ch), "div", lineObj, bias)
|
3039 |
}
|
3040 |
|
3041 |
+
iterateBidiSections(getOrder(lineObj, doc.direction), fromArg || 0, toArg == null ? lineLen : toArg, function (from, to, dir) {
|
3042 |
var leftPos = coords(from, "left"), rightPos, left, right
|
3043 |
if (from == to) {
|
3044 |
rightPos = leftPos
|
3441 |
this.horiz.style.left = measure.barLeft + "px"
|
3442 |
var totalWidth = measure.viewWidth - measure.barLeft - (needsV ? sWidth : 0)
|
3443 |
this.horiz.firstChild.style.width =
|
3444 |
+
Math.max(0, measure.scrollWidth - measure.clientWidth + totalWidth) + "px"
|
3445 |
} else {
|
3446 |
this.horiz.style.display = ""
|
3447 |
this.horiz.firstChild.style.width = "0"
|
3457 |
|
3458 |
NativeScrollbars.prototype.setScrollLeft = function (pos) {
|
3459 |
if (this.horiz.scrollLeft != pos) { this.horiz.scrollLeft = pos }
|
3460 |
+
if (this.disableHoriz) { this.enableZeroWidthBar(this.horiz, this.disableHoriz, "horiz") }
|
3461 |
};
|
3462 |
|
3463 |
NativeScrollbars.prototype.setScrollTop = function (pos) {
|
3464 |
if (this.vert.scrollTop != pos) { this.vert.scrollTop = pos }
|
3465 |
+
if (this.disableVert) { this.enableZeroWidthBar(this.vert, this.disableVert, "vert") }
|
3466 |
};
|
3467 |
|
3468 |
NativeScrollbars.prototype.zeroWidthHack = function () {
|
3473 |
this.disableVert = new Delayed
|
3474 |
};
|
3475 |
|
3476 |
+
NativeScrollbars.prototype.enableZeroWidthBar = function (bar, delay, type) {
|
3477 |
bar.style.pointerEvents = "auto"
|
3478 |
function maybeDisable() {
|
3479 |
// To find out whether the scrollbar is still visible, we
|
3480 |
// check whether the element under the pixel in the bottom
|
3481 |
+
// right corner of the scrollbar box is the scrollbar box
|
3482 |
// itself (when the bar is still visible) or its filler child
|
3483 |
// (when the bar is hidden). If it is still visible, we keep
|
3484 |
// it enabled, if it's hidden, we disable pointer events.
|
3485 |
var box = bar.getBoundingClientRect()
|
3486 |
+
var elt = type == "vert" ? document.elementFromPoint(box.right - 1, (box.top + box.bottom) / 2)
|
3487 |
+
: document.elementFromPoint((box.right + box.left) / 2, box.bottom - 1)
|
3488 |
if (elt != bar) { bar.style.pointerEvents = "none" }
|
3489 |
else { delay.set(1000, maybeDisable) }
|
3490 |
}
|
3566 |
|
3567 |
// If an editor sits on the top or bottom of the window, partially
|
3568 |
// scrolled out of view, this ensures that the cursor is visible.
|
3569 |
+
function maybeScrollWindow(cm, rect) {
|
3570 |
if (signalDOMEvent(cm, "scrollCursorIntoView")) { return }
|
3571 |
|
3572 |
var display = cm.display, box = display.sizer.getBoundingClientRect(), doScroll = null
|
3573 |
+
if (rect.top + box.top < 0) { doScroll = true }
|
3574 |
+
else if (rect.bottom + box.top > (window.innerHeight || document.documentElement.clientHeight)) { doScroll = false }
|
3575 |
if (doScroll != null && !phantom) {
|
3576 |
+
var scrollNode = elt("div", "\u200b", null, ("position: absolute;\n top: " + (rect.top - display.viewOffset - paddingTop(cm.display)) + "px;\n height: " + (rect.bottom - rect.top + scrollGap(cm) + display.barHeight) + "px;\n left: " + (rect.left) + "px; width: " + (Math.max(2, rect.right - rect.left)) + "px;"))
|
3577 |
cm.display.lineSpace.appendChild(scrollNode)
|
3578 |
scrollNode.scrollIntoView(doScroll)
|
3579 |
cm.display.lineSpace.removeChild(scrollNode)
|
3585 |
// measured, the position of something may 'drift' during drawing).
|
3586 |
function scrollPosIntoView(cm, pos, end, margin) {
|
3587 |
if (margin == null) { margin = 0 }
|
3588 |
+
var rect
|
3589 |
for (var limit = 0; limit < 5; limit++) {
|
3590 |
var changed = false
|
3591 |
+
var coords = cursorCoords(cm, pos)
|
3592 |
var endCoords = !end || end == pos ? coords : cursorCoords(cm, end)
|
3593 |
+
rect = {left: Math.min(coords.left, endCoords.left),
|
3594 |
+
top: Math.min(coords.top, endCoords.top) - margin,
|
3595 |
+
right: Math.max(coords.left, endCoords.left),
|
3596 |
+
bottom: Math.max(coords.bottom, endCoords.bottom) + margin}
|
3597 |
+
var scrollPos = calculateScrollPos(cm, rect)
|
3598 |
var startTop = cm.doc.scrollTop, startLeft = cm.doc.scrollLeft
|
3599 |
if (scrollPos.scrollTop != null) {
|
3600 |
setScrollTop(cm, scrollPos.scrollTop)
|
3606 |
}
|
3607 |
if (!changed) { break }
|
3608 |
}
|
3609 |
+
return rect
|
3610 |
}
|
3611 |
|
3612 |
// Scroll a given set of coordinates into view (immediately).
|
3613 |
+
function scrollIntoView(cm, rect) {
|
3614 |
+
var scrollPos = calculateScrollPos(cm, rect)
|
3615 |
if (scrollPos.scrollTop != null) { setScrollTop(cm, scrollPos.scrollTop) }
|
3616 |
if (scrollPos.scrollLeft != null) { setScrollLeft(cm, scrollPos.scrollLeft) }
|
3617 |
}
|
3620 |
// rectangle into view. Returns an object with scrollTop and
|
3621 |
// scrollLeft properties. When these are undefined, the
|
3622 |
// vertical/horizontal position does not need to be adjusted.
|
3623 |
+
function calculateScrollPos(cm, rect) {
|
3624 |
var display = cm.display, snapMargin = textHeight(cm.display)
|
3625 |
+
if (rect.top < 0) { rect.top = 0 }
|
3626 |
var screentop = cm.curOp && cm.curOp.scrollTop != null ? cm.curOp.scrollTop : display.scroller.scrollTop
|
3627 |
var screen = displayHeight(cm), result = {}
|
3628 |
+
if (rect.bottom - rect.top > screen) { rect.bottom = rect.top + screen }
|
3629 |
var docBottom = cm.doc.height + paddingVert(display)
|
3630 |
+
var atTop = rect.top < snapMargin, atBottom = rect.bottom > docBottom - snapMargin
|
3631 |
+
if (rect.top < screentop) {
|
3632 |
+
result.scrollTop = atTop ? 0 : rect.top
|
3633 |
+
} else if (rect.bottom > screentop + screen) {
|
3634 |
+
var newTop = Math.min(rect.top, (atBottom ? docBottom : rect.bottom) - screen)
|
3635 |
if (newTop != screentop) { result.scrollTop = newTop }
|
3636 |
}
|
3637 |
|
3638 |
var screenleft = cm.curOp && cm.curOp.scrollLeft != null ? cm.curOp.scrollLeft : display.scroller.scrollLeft
|
3639 |
var screenw = displayWidth(cm) - (cm.options.fixedGutter ? display.gutters.offsetWidth : 0)
|
3640 |
+
var tooWide = rect.right - rect.left > screenw
|
3641 |
+
if (tooWide) { rect.right = rect.left + screenw }
|
3642 |
+
if (rect.left < 10)
|
3643 |
{ result.scrollLeft = 0 }
|
3644 |
+
else if (rect.left < screenleft)
|
3645 |
+
{ result.scrollLeft = Math.max(0, rect.left - (tooWide ? 0 : 10)) }
|
3646 |
+
else if (rect.right > screenw + screenleft - 3)
|
3647 |
+
{ result.scrollLeft = rect.right + (tooWide ? 0 : 10) - screenw }
|
3648 |
return result
|
3649 |
}
|
3650 |
|
3667 |
from = cur.ch ? Pos(cur.line, cur.ch - 1) : cur
|
3668 |
to = Pos(cur.line, cur.ch + 1)
|
3669 |
}
|
3670 |
+
cm.curOp.scrollToPos = {from: from, to: to, margin: cm.options.cursorScrollMargin}
|
3671 |
}
|
3672 |
|
3673 |
// When an operation has its scrollToPos property set, and another
|
3679 |
if (range) {
|
3680 |
cm.curOp.scrollToPos = null
|
3681 |
var from = estimateCoords(cm, range.from), to = estimateCoords(cm, range.to)
|
3682 |
+
var sPos = calculateScrollPos(cm, {
|
3683 |
+
left: Math.min(from.left, to.left),
|
3684 |
+
top: Math.min(from.top, to.top) - range.margin,
|
3685 |
+
right: Math.max(from.right, to.right),
|
3686 |
+
bottom: Math.max(from.bottom, to.bottom) + range.margin
|
3687 |
+
})
|
3688 |
cm.scrollTo(sPos.scrollLeft, sPos.scrollTop)
|
3689 |
}
|
3690 |
}
|
3830 |
}
|
3831 |
// If we need to scroll a specific position into view, do so.
|
3832 |
if (op.scrollToPos) {
|
3833 |
+
var rect = scrollPosIntoView(cm, clipPos(doc, op.scrollToPos.from),
|
3834 |
+
clipPos(doc, op.scrollToPos.to), op.scrollToPos.margin)
|
3835 |
+
maybeScrollWindow(cm, rect)
|
3836 |
}
|
3837 |
|
3838 |
// Fire events for markers that are hidden/unidden by editing or
|
4330 |
// (and non-touching) ranges, sorted, and an integer that indicates
|
4331 |
// which one is the primary selection (the one that's scrolled into
|
4332 |
// view, that getCursor returns, etc).
|
4333 |
+
var Selection = function(ranges, primIndex) {
|
4334 |
this.ranges = ranges
|
4335 |
this.primIndex = primIndex
|
4336 |
+
};
|
4337 |
+
|
4338 |
+
Selection.prototype.primary = function () { return this.ranges[this.primIndex] };
|
4339 |
|
4340 |
+
Selection.prototype.equals = function (other) {
|
|
|
|
|
4341 |
var this$1 = this;
|
4342 |
|
4343 |
+
if (other == this) { return true }
|
4344 |
+
if (other.primIndex != this.primIndex || other.ranges.length != this.ranges.length) { return false }
|
4345 |
+
for (var i = 0; i < this.ranges.length; i++) {
|
4346 |
+
var here = this$1.ranges[i], there = other.ranges[i]
|
4347 |
+
if (!equalCursorPos(here.anchor, there.anchor) || !equalCursorPos(here.head, there.head)) { return false }
|
4348 |
+
}
|
4349 |
+
return true
|
4350 |
+
};
|
4351 |
+
|
4352 |
+
Selection.prototype.deepCopy = function () {
|
4353 |
var this$1 = this;
|
4354 |
|
4355 |
+
var out = []
|
4356 |
+
for (var i = 0; i < this.ranges.length; i++)
|
4357 |
+
{ out[i] = new Range(copyPos(this$1.ranges[i].anchor), copyPos(this$1.ranges[i].head)) }
|
4358 |
+
return new Selection(out, this.primIndex)
|
4359 |
+
};
|
4360 |
+
|
4361 |
+
Selection.prototype.somethingSelected = function () {
|
4362 |
var this$1 = this;
|
4363 |
|
4364 |
+
for (var i = 0; i < this.ranges.length; i++)
|
4365 |
+
{ if (!this$1.ranges[i].empty()) { return true } }
|
4366 |
+
return false
|
4367 |
+
};
|
4368 |
+
|
4369 |
+
Selection.prototype.contains = function (pos, end) {
|
4370 |
var this$1 = this;
|
4371 |
|
4372 |
+
if (!end) { end = pos }
|
4373 |
+
for (var i = 0; i < this.ranges.length; i++) {
|
4374 |
+
var range = this$1.ranges[i]
|
4375 |
+
if (cmp(end, range.from()) >= 0 && cmp(pos, range.to()) <= 0)
|
4376 |
+
{ return i }
|
|
|
|
|
4377 |
}
|
4378 |
+
return -1
|
4379 |
+
};
|
4380 |
|
4381 |
+
var Range = function(anchor, head) {
|
4382 |
this.anchor = anchor; this.head = head
|
4383 |
+
};
|
4384 |
|
4385 |
+
Range.prototype.from = function () { return minPos(this.anchor, this.head) };
|
4386 |
+
Range.prototype.to = function () { return maxPos(this.anchor, this.head) };
|
4387 |
+
Range.prototype.empty = function () { return this.head.line == this.anchor.line && this.head.ch == this.anchor.ch };
|
|
|
|
|
|
|
|
|
4388 |
|
4389 |
// Take an unsorted, potentially overlapping set of ranges, and
|
4390 |
// build a selection out of it. 'Consumes' ranges array (modifying
|
4568 |
doc.cm = cm
|
4569 |
estimateLineHeights(cm)
|
4570 |
loadMode(cm)
|
4571 |
+
setDirectionClass(cm)
|
4572 |
if (!cm.options.lineWrapping) { findMaxLine(cm) }
|
4573 |
cm.options.mode = doc.modeOption
|
4574 |
regChange(cm)
|
4575 |
}
|
4576 |
|
4577 |
+
function setDirectionClass(cm) {
|
4578 |
+
;(cm.doc.direction == "rtl" ? addClass : rmClass)(cm.display.lineDiv, "CodeMirror-rtl")
|
4579 |
+
}
|
4580 |
+
|
4581 |
+
function directionChanged(cm) {
|
4582 |
+
runInOp(cm, function () {
|
4583 |
+
setDirectionClass(cm)
|
4584 |
+
regChange(cm)
|
4585 |
+
})
|
4586 |
+
}
|
4587 |
+
|
4588 |
function History(startGen) {
|
4589 |
// Arrays of change events and selections. Doing something adds an
|
4590 |
// event to done and clears undo. Undoing moves events from done
|
5335 |
//
|
5336 |
// See also http://marijnhaverbeke.nl/blog/codemirror-line-tree.html
|
5337 |
|
5338 |
+
var LeafChunk = function(lines) {
|
5339 |
var this$1 = this;
|
5340 |
|
5341 |
this.lines = lines
|
5346 |
height += lines[i].height
|
5347 |
}
|
5348 |
this.height = height
|
5349 |
+
};
|
5350 |
+
|
5351 |
+
LeafChunk.prototype.chunkSize = function () { return this.lines.length };
|
5352 |
|
5353 |
+
// Remove the n lines at offset 'at'.
|
5354 |
+
LeafChunk.prototype.removeInner = function (at, n) {
|
|
|
|
|
5355 |
var this$1 = this;
|
5356 |
|
5357 |
+
for (var i = at, e = at + n; i < e; ++i) {
|
5358 |
+
var line = this$1.lines[i]
|
5359 |
+
this$1.height -= line.height
|
5360 |
+
cleanUpLine(line)
|
5361 |
+
signalLater(line, "delete")
|
5362 |
+
}
|
5363 |
+
this.lines.splice(at, n)
|
5364 |
+
};
|
5365 |
+
|
5366 |
+
// Helper used to collapse a small branch into a single leaf.
|
5367 |
+
LeafChunk.prototype.collapse = function (lines) {
|
5368 |
+
lines.push.apply(lines, this.lines)
|
5369 |
+
};
|
5370 |
+
|
5371 |
+
// Insert the given array of lines at offset 'at', count them as
|
5372 |
+
// having the given height.
|
5373 |
+
LeafChunk.prototype.insertInner = function (at, lines, height) {
|
5374 |
var this$1 = this;
|
5375 |
|
5376 |
+
this.height += height
|
5377 |
+
this.lines = this.lines.slice(0, at).concat(lines).concat(this.lines.slice(at))
|
5378 |
+
for (var i = 0; i < lines.length; ++i) { lines[i].parent = this$1 }
|
5379 |
+
};
|
5380 |
+
|
5381 |
+
// Used to iterate over a part of the tree.
|
5382 |
+
LeafChunk.prototype.iterN = function (at, n, op) {
|
5383 |
var this$1 = this;
|
5384 |
|
5385 |
+
for (var e = at + n; at < e; ++at)
|
5386 |
+
{ if (op(this$1.lines[at])) { return true } }
|
5387 |
+
};
|
|
|
5388 |
|
5389 |
+
var BranchChunk = function(children) {
|
5390 |
var this$1 = this;
|
5391 |
|
5392 |
this.children = children
|
5399 |
this.size = size
|
5400 |
this.height = height
|
5401 |
this.parent = null
|
5402 |
+
};
|
5403 |
|
5404 |
+
BranchChunk.prototype.chunkSize = function () { return this.size };
|
5405 |
+
|
5406 |
+
BranchChunk.prototype.removeInner = function (at, n) {
|
5407 |
var this$1 = this;
|
5408 |
|
5409 |
+
this.size -= n
|
5410 |
+
for (var i = 0; i < this.children.length; ++i) {
|
5411 |
+
var child = this$1.children[i], sz = child.chunkSize()
|
5412 |
+
if (at < sz) {
|
5413 |
+
var rm = Math.min(n, sz - at), oldHeight = child.height
|
5414 |
+
child.removeInner(at, rm)
|
5415 |
+
this$1.height -= oldHeight - child.height
|
5416 |
+
if (sz == rm) { this$1.children.splice(i--, 1); child.parent = null }
|
5417 |
+
if ((n -= rm) == 0) { break }
|
5418 |
+
at = 0
|
5419 |
+
} else { at -= sz }
|
5420 |
+
}
|
5421 |
+
// If the result is smaller than 25 lines, ensure that it is a
|
5422 |
+
// single leaf node.
|
5423 |
+
if (this.size - n < 25 &&
|
5424 |
+
(this.children.length > 1 || !(this.children[0] instanceof LeafChunk))) {
|
5425 |
+
var lines = []
|
5426 |
+
this.collapse(lines)
|
5427 |
+
this.children = [new LeafChunk(lines)]
|
5428 |
+
this.children[0].parent = this
|
5429 |
+
}
|
5430 |
+
};
|
5431 |
+
|
5432 |
+
BranchChunk.prototype.collapse = function (lines) {
|
5433 |
var this$1 = this;
|
5434 |
|
5435 |
+
for (var i = 0; i < this.children.length; ++i) { this$1.children[i].collapse(lines) }
|
5436 |
+
};
|
5437 |
+
|
5438 |
+
BranchChunk.prototype.insertInner = function (at, lines, height) {
|
5439 |
var this$1 = this;
|
5440 |
|
5441 |
+
this.size += lines.length
|
5442 |
+
this.height += height
|
5443 |
+
for (var i = 0; i < this.children.length; ++i) {
|
5444 |
+
var child = this$1.children[i], sz = child.chunkSize()
|
5445 |
+
if (at <= sz) {
|
5446 |
+
child.insertInner(at, lines, height)
|
5447 |
+
if (child.lines && child.lines.length > 50) {
|
5448 |
+
// To avoid memory thrashing when child.lines is huge (e.g. first view of a large file), it's never spliced.
|
5449 |
+
// Instead, small slices are taken. They're taken in order because sequential memory accesses are fastest.
|
5450 |
+
var remaining = child.lines.length % 25 + 25
|
5451 |
+
for (var pos = remaining; pos < child.lines.length;) {
|
5452 |
+
var leaf = new LeafChunk(child.lines.slice(pos, pos += 25))
|
5453 |
+
child.height -= leaf.height
|
5454 |
+
this$1.children.splice(++i, 0, leaf)
|
5455 |
+
leaf.parent = this$1
|
|
|
|
|
|
|
5456 |
}
|
5457 |
+
child.lines = child.lines.slice(0, remaining)
|
5458 |
+
this$1.maybeSpill()
|
5459 |
}
|
5460 |
+
break
|
5461 |
}
|
5462 |
+
at -= sz
|
5463 |
+
}
|
5464 |
+
};
|
5465 |
+
|
5466 |
+
// When a node has grown, check whether it should be split.
|
5467 |
+
BranchChunk.prototype.maybeSpill = function () {
|
5468 |
+
if (this.children.length <= 10) { return }
|
5469 |
+
var me = this
|
5470 |
+
do {
|
5471 |
+
var spilled = me.children.splice(me.children.length - 5, 5)
|
5472 |
+
var sibling = new BranchChunk(spilled)
|
5473 |
+
if (!me.parent) { // Become the parent node
|
5474 |
+
var copy = new BranchChunk(me.children)
|
5475 |
+
copy.parent = me
|
5476 |
+
me.children = [copy, sibling]
|
5477 |
+
me = copy
|
5478 |
+
} else {
|
5479 |
+
me.size -= sibling.size
|
5480 |
+
me.height -= sibling.height
|
5481 |
+
var myIndex = indexOf(me.parent.children, me)
|
5482 |
+
me.parent.children.splice(myIndex + 1, 0, sibling)
|
5483 |
+
}
|
5484 |
+
sibling.parent = me.parent
|
5485 |
+
} while (me.children.length > 10)
|
5486 |
+
me.parent.maybeSpill()
|
5487 |
+
};
|
5488 |
+
|
5489 |
+
BranchChunk.prototype.iterN = function (at, n, op) {
|
5490 |
var this$1 = this;
|
5491 |
|
5492 |
+
for (var i = 0; i < this.children.length; ++i) {
|
5493 |
+
var child = this$1.children[i], sz = child.chunkSize()
|
5494 |
+
if (at < sz) {
|
5495 |
+
var used = Math.min(n, sz - at)
|
5496 |
+
if (child.iterN(at, used, op)) { return true }
|
5497 |
+
if ((n -= used) == 0) { break }
|
5498 |
+
at = 0
|
5499 |
+
} else { at -= sz }
|
|
|
5500 |
}
|
5501 |
+
};
|
5502 |
|
5503 |
// Line widgets are block elements displayed above or below a line.
|
5504 |
|
5505 |
+
var LineWidget = function(doc, node, options) {
|
5506 |
var this$1 = this;
|
5507 |
|
5508 |
if (options) { for (var opt in options) { if (options.hasOwnProperty(opt))
|
5509 |
{ this$1[opt] = options[opt] } } }
|
5510 |
this.doc = doc
|
5511 |
this.node = node
|
5512 |
+
};
|
|
|
|
|
|
|
|
|
|
|
|
|
5513 |
|
5514 |
+
LineWidget.prototype.clear = function () {
|
5515 |
+
var this$1 = this;
|
5516 |
|
5517 |
var cm = this.doc.cm, ws = this.line.widgets, line = this.line, no = lineNo(line)
|
5518 |
if (no == null || !ws) { return }
|
5520 |
if (!ws.length) { line.widgets = null }
|
5521 |
var height = widgetHeight(this)
|
5522 |
updateLineHeight(line, Math.max(0, line.height - height))
|
5523 |
+
if (cm) {
|
5524 |
+
runInOp(cm, function () {
|
5525 |
+
adjustScrollWhenAboveVisible(cm, line, -height)
|
5526 |
+
regLineChange(cm, no, "widget")
|
5527 |
+
})
|
5528 |
+
signalLater(cm, "lineWidgetCleared", cm, this, no)
|
5529 |
+
}
|
5530 |
+
};
|
5531 |
+
|
5532 |
+
LineWidget.prototype.changed = function () {
|
5533 |
+
var this$1 = this;
|
5534 |
+
|
5535 |
var oldH = this.height, cm = this.doc.cm, line = this.line
|
5536 |
this.height = null
|
5537 |
var diff = widgetHeight(this) - oldH
|
5538 |
if (!diff) { return }
|
5539 |
updateLineHeight(line, line.height + diff)
|
5540 |
+
if (cm) {
|
5541 |
+
runInOp(cm, function () {
|
5542 |
+
cm.curOp.forceUpdate = true
|
5543 |
+
adjustScrollWhenAboveVisible(cm, line, diff)
|
5544 |
+
signalLater(cm, "lineWidgetChanged", cm, this$1, lineNo(line))
|
5545 |
+
})
|
5546 |
+
}
|
5547 |
+
};
|
5548 |
+
eventMixin(LineWidget)
|
5549 |
+
|
5550 |
+
function adjustScrollWhenAboveVisible(cm, line, diff) {
|
5551 |
+
if (heightAtLine(line) < ((cm.curOp && cm.curOp.scrollTop) || cm.doc.scrollTop))
|
5552 |
+
{ addToScrollPos(cm, null, diff) }
|
5553 |
}
|
5554 |
|
5555 |
function addLineWidget(doc, handle, node, options) {
|
5569 |
}
|
5570 |
return true
|
5571 |
})
|
5572 |
+
signalLater(cm, "lineWidgetAdded", cm, widget, typeof handle == "number" ? handle : lineNo(handle))
|
5573 |
return widget
|
5574 |
}
|
5575 |
|
5590 |
// when they overlap (they may nest, but not partially overlap).
|
5591 |
var nextMarkerId = 0
|
5592 |
|
5593 |
+
var TextMarker = function(doc, type) {
|
5594 |
this.lines = []
|
5595 |
this.type = type
|
5596 |
this.doc = doc
|
5597 |
this.id = ++nextMarkerId
|
5598 |
+
};
|
|
|
5599 |
|
5600 |
// Clear the marker.
|
5601 |
+
TextMarker.prototype.clear = function () {
|
5602 |
+
var this$1 = this;
|
5603 |
|
5604 |
if (this.explicitlyCleared) { return }
|
5605 |
var cm = this.doc.cm, withOp = cm && !cm.curOp
|
5637 |
this.doc.cantEdit = false
|
5638 |
if (cm) { reCheckSelection(cm.doc) }
|
5639 |
}
|
5640 |
+
if (cm) { signalLater(cm, "markerCleared", cm, this, min, max) }
|
5641 |
if (withOp) { endOperation(cm) }
|
5642 |
if (this.parent) { this.parent.clear() }
|
5643 |
+
};
|
5644 |
|
5645 |
// Find the position of the marker in the document. Returns a {from,
|
5646 |
// to} object by default. Side can be passed to get a specific side
|
5647 |
// -- 0 (both), -1 (left), or 1 (right). When lineObj is true, the
|
5648 |
// Pos objects returned contain a line object, rather than a line
|
5649 |
// number (used to prevent looking up the same line twice).
|
5650 |
+
TextMarker.prototype.find = function (side, lineObj) {
|
5651 |
+
var this$1 = this;
|
5652 |
|
5653 |
if (side == null && this.type == "bookmark") { side = 1 }
|
5654 |
var from, to
|
5665 |
}
|
5666 |
}
|
5667 |
return from && {from: from, to: to}
|
5668 |
+
};
|
5669 |
|
5670 |
// Signals that the marker's widget changed, and surrounding layout
|
5671 |
// should be recomputed.
|
5672 |
+
TextMarker.prototype.changed = function () {
|
5673 |
+
var this$1 = this;
|
5674 |
+
|
5675 |
var pos = this.find(-1, true), widget = this, cm = this.doc.cm
|
5676 |
if (!pos || !cm) { return }
|
5677 |
runInOp(cm, function () {
|
5689 |
if (dHeight)
|
5690 |
{ updateLineHeight(line, line.height + dHeight) }
|
5691 |
}
|
5692 |
+
signalLater(cm, "markerChanged", cm, this$1)
|
5693 |
})
|
5694 |
+
};
|
5695 |
|
5696 |
+
TextMarker.prototype.attachLine = function (line) {
|
5697 |
if (!this.lines.length && this.doc.cm) {
|
5698 |
var op = this.doc.cm.curOp
|
5699 |
if (!op.maybeHiddenMarkers || indexOf(op.maybeHiddenMarkers, this) == -1)
|
5700 |
{ (op.maybeUnhiddenMarkers || (op.maybeUnhiddenMarkers = [])).push(this) }
|
5701 |
}
|
5702 |
this.lines.push(line)
|
5703 |
+
};
|
5704 |
+
|
5705 |
+
TextMarker.prototype.detachLine = function (line) {
|
5706 |
this.lines.splice(indexOf(this.lines, line), 1)
|
5707 |
if (!this.lines.length && this.doc.cm) {
|
5708 |
var op = this.doc.cm.curOp
|
5709 |
;(op.maybeHiddenMarkers || (op.maybeHiddenMarkers = [])).push(this)
|
5710 |
}
|
5711 |
+
};
|
5712 |
+
eventMixin(TextMarker)
|
5713 |
|
5714 |
// Create a marker, wire it up to the right lines, and
|
5715 |
function markText(doc, from, to, options, type) {
|
5728 |
if (marker.replacedWith) {
|
5729 |
// Showing up as a widget implies collapsed (widget replaces text)
|
5730 |
marker.collapsed = true
|
5731 |
+
marker.widgetNode = eltP("span", [marker.replacedWith], "CodeMirror-widget")
|
|
|
5732 |
if (!options.handleMouseEvents) { marker.widgetNode.setAttribute("cm-ignore-events", "true") }
|
5733 |
if (options.insertLeft) { marker.widgetNode.insertLeft = true }
|
5734 |
}
|
5786 |
// A shared marker spans multiple linked documents. It is
|
5787 |
// implemented as a meta-marker-object controlling multiple normal
|
5788 |
// markers.
|
5789 |
+
var SharedTextMarker = function(markers, primary) {
|
5790 |
var this$1 = this;
|
5791 |
|
5792 |
this.markers = markers
|
5793 |
this.primary = primary
|
5794 |
for (var i = 0; i < markers.length; ++i)
|
5795 |
{ markers[i].parent = this$1 }
|
5796 |
+
};
|
|
|
5797 |
|
5798 |
+
SharedTextMarker.prototype.clear = function () {
|
5799 |
+
var this$1 = this;
|
5800 |
|
5801 |
if (this.explicitlyCleared) { return }
|
5802 |
this.explicitlyCleared = true
|
5803 |
for (var i = 0; i < this.markers.length; ++i)
|
5804 |
{ this$1.markers[i].clear() }
|
5805 |
signalLater(this, "clear")
|
5806 |
+
};
|
5807 |
+
|
5808 |
+
SharedTextMarker.prototype.find = function (side, lineObj) {
|
5809 |
return this.primary.find(side, lineObj)
|
5810 |
+
};
|
5811 |
+
eventMixin(SharedTextMarker)
|
5812 |
|
5813 |
function markTextShared(doc, from, to, options, type) {
|
5814 |
options = copyObj(options)
|
5858 |
}
|
5859 |
|
5860 |
var nextDocId = 0
|
5861 |
+
var Doc = function(text, mode, firstLine, lineSep, direction) {
|
5862 |
+
if (!(this instanceof Doc)) { return new Doc(text, mode, firstLine, lineSep, direction) }
|
5863 |
if (firstLine == null) { firstLine = 0 }
|
5864 |
|
5865 |
BranchChunk.call(this, [new LeafChunk([new Line("", null)])])
|
5874 |
this.id = ++nextDocId
|
5875 |
this.modeOption = mode
|
5876 |
this.lineSep = lineSep
|
5877 |
+
this.direction = (direction == "rtl") ? "rtl" : "ltr"
|
5878 |
this.extend = false
|
5879 |
|
5880 |
if (typeof text == "string") { text = this.splitLines(text) }
|
5913 |
var top = Pos(this.first, 0), last = this.first + this.size - 1
|
5914 |
makeChange(this, {from: top, to: Pos(last, getLine(this, last).text.length),
|
5915 |
text: this.splitLines(code), origin: "setValue", full: true}, true)
|
5916 |
+
if (this.cm) { this.cm.scrollTo(0, 0) }
|
5917 |
+
setSelection(this, simpleSelection(top), sel_dontScroll)
|
5918 |
}),
|
5919 |
replaceRange: function(code, from, to, origin) {
|
5920 |
from = clipPos(this, from)
|
6212 |
|
6213 |
copy: function(copyHistory) {
|
6214 |
var doc = new Doc(getLines(this, this.first, this.first + this.size),
|
6215 |
+
this.modeOption, this.first, this.lineSep, this.direction)
|
6216 |
doc.scrollTop = this.scrollTop; doc.scrollLeft = this.scrollLeft
|
6217 |
doc.sel = this.sel
|
6218 |
doc.extend = false
|
6228 |
var from = this.first, to = this.first + this.size
|
6229 |
if (options.from != null && options.from > from) { from = options.from }
|
6230 |
if (options.to != null && options.to < to) { to = options.to }
|
6231 |
+
var copy = new Doc(getLines(this, from, to), options.mode || this.modeOption, from, this.lineSep, this.direction)
|
6232 |
if (options.sharedHist) { copy.history = this.history
|
6233 |
; }(this.linked || (this.linked = [])).push({doc: copy, sharedHist: options.sharedHist})
|
6234 |
copy.linked = [{doc: this, isParent: true, sharedHist: options.sharedHist}]
|
6265 |
if (this.lineSep) { return str.split(this.lineSep) }
|
6266 |
return splitLinesAuto(str)
|
6267 |
},
|
6268 |
+
lineSeparator: function() { return this.lineSep || "\n" },
|
6269 |
+
|
6270 |
+
setDirection: docMethodOp(function (dir) {
|
6271 |
+
if (dir != "rtl") { dir = "ltr" }
|
6272 |
+
if (dir == this.direction) { return }
|
6273 |
+
this.direction = dir
|
6274 |
+
this.iter(function (line) { return line.order = null; })
|
6275 |
+
if (this.cm) { directionChanged(this.cm) }
|
6276 |
+
})
|
6277 |
})
|
6278 |
|
6279 |
// Public alias.
|
6753 |
var line = getLine(cm.doc, lineN)
|
6754 |
var visual = visualLine(line)
|
6755 |
if (visual != line) { lineN = lineNo(visual) }
|
6756 |
+
return endOfLine(true, cm, visual, lineN, 1)
|
|
|
|
|
6757 |
}
|
6758 |
function lineEnd(cm, lineN) {
|
6759 |
+
var line = getLine(cm.doc, lineN)
|
6760 |
+
var visual = visualLineEnd(line)
|
6761 |
+
if (visual != line) { lineN = lineNo(visual) }
|
6762 |
+
return endOfLine(true, cm, line, lineN, -1)
|
|
|
|
|
|
|
|
|
6763 |
}
|
6764 |
function lineStartSmart(cm, pos) {
|
6765 |
var start = lineStart(cm, pos.line)
|
6766 |
var line = getLine(cm.doc, start.line)
|
6767 |
+
var order = getOrder(line, cm.doc.direction)
|
6768 |
if (!order || order[0].level == 0) {
|
6769 |
var firstNonWS = Math.max(0, line.text.search(/\S/))
|
6770 |
var inWS = pos.line == start.line && pos.ch <= firstNonWS && pos.ch
|
6771 |
+
return Pos(start.line, inWS ? 0 : firstNonWS, start.sticky)
|
6772 |
}
|
6773 |
return start
|
6774 |
}
|
6991 |
// Start a text drag. When it ends, see if any dragging actually
|
6992 |
// happen, and treat as a click if it didn't.
|
6993 |
function leftButtonStartDrag(cm, e, start, modifier) {
|
6994 |
+
var display = cm.display, moved = false
|
6995 |
+
var dragEnd = operation(cm, function (e) {
|
6996 |
if (webkit) { display.scroller.draggable = false }
|
6997 |
cm.state.draggingText = false
|
6998 |
off(document, "mouseup", dragEnd)
|
6999 |
+
off(document, "mousemove", mouseMove)
|
7000 |
+
off(display.scroller, "dragstart", dragStart)
|
7001 |
off(display.scroller, "drop", dragEnd)
|
7002 |
+
if (!moved) {
|
7003 |
+
e_preventDefault(e)
|
7004 |
+
if (!modifier)
|
7005 |
{ extendSelection(cm.doc, start) }
|
7006 |
// Work around unexplainable focus problem in IE9 (#2127) and Chrome (#3081)
|
7007 |
if (webkit || ie && ie_version == 9)
|
7010 |
{ display.input.focus() }
|
7011 |
}
|
7012 |
})
|
7013 |
+
var mouseMove = function(e2) {
|
7014 |
+
moved = moved || Math.abs(e.clientX - e2.clientX) + Math.abs(e.clientY - e2.clientY) >= 10
|
7015 |
+
}
|
7016 |
+
var dragStart = function () { return moved = true; }
|
7017 |
// Let the drag handler handle this.
|
7018 |
if (webkit) { display.scroller.draggable = true }
|
7019 |
cm.state.draggingText = dragEnd
|
7021 |
// IE's approach to draggable
|
7022 |
if (display.scroller.dragDrop) { display.scroller.dragDrop() }
|
7023 |
on(document, "mouseup", dragEnd)
|
7024 |
+
on(document, "mousemove", mouseMove)
|
7025 |
+
on(display.scroller, "dragstart", dragStart)
|
7026 |
on(display.scroller, "drop", dragEnd)
|
7027 |
+
|
7028 |
+
delayBlurEvent(cm)
|
7029 |
+
setTimeout(function () { return display.input.focus(); }, 20)
|
7030 |
}
|
7031 |
|
7032 |
// Normal selection, as opposed to text dragging.
|
7279 |
for (var i = newBreaks.length - 1; i >= 0; i--)
|
7280 |
{ replaceRange(cm.doc, val, newBreaks[i], Pos(newBreaks[i].line, newBreaks[i].ch + val.length)) }
|
7281 |
})
|
7282 |
+
option("specialChars", /[\u0000-\u001f\u007f-\u009f\u00ad\u061c\u200b-\u200f\u2028\u2029\ufeff]/g, function (cm, val, old) {
|
7283 |
cm.state.specialChars = new RegExp(val.source + (val.test("\t") ? "" : "|\t"), "g")
|
7284 |
if (old != Init) { cm.refresh() }
|
7285 |
})
|
7364 |
|
7365 |
option("tabindex", null, function (cm, val) { return cm.display.input.getField().tabIndex = val || ""; })
|
7366 |
option("autofocus", null)
|
7367 |
+
option("direction", "ltr", function (cm, val) { return cm.doc.setDirection(val); }, true)
|
7368 |
}
|
7369 |
|
7370 |
function guttersChanged(cm) {
|
7415 |
setGuttersForLineNumbers(options)
|
7416 |
|
7417 |
var doc = options.value
|
7418 |
+
if (typeof doc == "string") { doc = new Doc(doc, options.mode, null, options.lineSeparator, options.direction) }
|
7419 |
this.doc = doc
|
7420 |
|
7421 |
var input = new CodeMirror.inputStyles[options.inputStyle](this)
|
7972 |
} else {
|
7973 |
lineObj = line
|
7974 |
}
|
7975 |
+
return intoCoordSystem(this, lineObj, {top: 0, left: 0}, mode || "page", includeWidgets || end).top +
|
7976 |
(end ? this.doc.height - heightAtLine(lineObj) : 0)
|
7977 |
},
|
7978 |
|
8013 |
node.style.left = left + "px"
|
8014 |
}
|
8015 |
if (scroll)
|
8016 |
+
{ scrollIntoView(this, {left: left, top: top, right: left + node.offsetWidth, bottom: top + node.offsetHeight}) }
|
8017 |
},
|
8018 |
|
8019 |
triggerOnKeyDown: methodOp(onKeyDown),
|
8104 |
var start = pos.ch, end = pos.ch
|
8105 |
if (line) {
|
8106 |
var helper = this.getHelper(pos, "wordChars")
|
8107 |
+
if ((pos.sticky == "before" || end == line.length) && start) { --start; } else { ++end }
|
8108 |
var startChar = line.charAt(start)
|
8109 |
var check = isWordChar(startChar, helper)
|
8110 |
? function (ch) { return isWordChar(ch, helper); }
|
8157 |
resolveScrollToPos(this)
|
8158 |
this.curOp.scrollToPos = range
|
8159 |
} else {
|
8160 |
+
var sPos = calculateScrollPos(this, {
|
8161 |
+
left: Math.min(range.from.left, range.to.left),
|
8162 |
+
top: Math.min(range.from.top, range.to.top) - range.margin,
|
8163 |
+
right: Math.max(range.from.right, range.to.right),
|
8164 |
+
bottom: Math.max(range.from.bottom, range.to.bottom) + range.margin
|
8165 |
+
})
|
8166 |
this.scrollTo(sPos.scrollLeft, sPos.scrollTop)
|
8167 |
}
|
8168 |
}),
|
8237 |
// position. The resulting position will have a hitSide=true
|
8238 |
// property if it reached the end of the document.
|
8239 |
function findPosH(doc, pos, dir, unit, visually) {
|
8240 |
+
var oldPos = pos
|
8241 |
+
var origDir = dir
|
8242 |
+
var lineObj = getLine(doc, pos.line)
|
8243 |
function findNextLine() {
|
8244 |
+
var l = pos.line + dir
|
8245 |
if (l < doc.first || l >= doc.first + doc.size) { return false }
|
8246 |
+
pos = new Pos(l, pos.ch, pos.sticky)
|
8247 |
return lineObj = getLine(doc, l)
|
8248 |
}
|
8249 |
function moveOnce(boundToLine) {
|
8250 |
+
var next
|
8251 |
+
if (visually) {
|
8252 |
+
next = moveVisually(doc.cm, lineObj, pos, dir)
|
8253 |
+
} else {
|
8254 |
+
next = moveLogically(lineObj, pos, dir)
|
8255 |
+
}
|
8256 |
if (next == null) {
|
8257 |
+
if (!boundToLine && findNextLine())
|
8258 |
+
{ pos = endOfLine(visually, doc.cm, lineObj, pos.line, dir) }
|
8259 |
+
else
|
8260 |
+
{ return false }
|
8261 |
+
} else {
|
8262 |
+
pos = next
|
8263 |
+
}
|
8264 |
return true
|
8265 |
}
|
8266 |
|
8273 |
var helper = doc.cm && doc.cm.getHelper(pos, "wordChars")
|
8274 |
for (var first = true;; first = false) {
|
8275 |
if (dir < 0 && !moveOnce(!first)) { break }
|
8276 |
+
var cur = lineObj.text.charAt(pos.ch) || "\n"
|
8277 |
var type = isWordChar(cur, helper) ? "w"
|
8278 |
: group && cur == "\n" ? "n"
|
8279 |
: !group || /\s/.test(cur) ? null
|
8280 |
: "p"
|
8281 |
if (group && !first && !type) { type = "s" }
|
8282 |
if (sawType && sawType != type) {
|
8283 |
+
if (dir < 0) {dir = 1; moveOnce(); pos.sticky = "after"}
|
8284 |
break
|
8285 |
}
|
8286 |
|
8288 |
if (dir > 0 && !moveOnce(!first)) { break }
|
8289 |
}
|
8290 |
}
|
8291 |
+
var result = skipAtomic(doc, pos, oldPos, origDir, true)
|
8292 |
+
if (equalCursorPos(oldPos, result)) { result.hitSide = true }
|
8293 |
return result
|
8294 |
}
|
8295 |
|
8337 |
on(div, "paste", function (e) {
|
8338 |
if (signalDOMEvent(cm, e) || handlePaste(e, cm)) { return }
|
8339 |
// IE doesn't fire input events, so we schedule a read for the pasted content in this way
|
8340 |
+
if (ie_version <= 11) { setTimeout(operation(cm, function () { return this$1.updateFromDOM(); }), 20) }
|
|
|
|
|
8341 |
})
|
8342 |
|
8343 |
on(div, "compositionstart", function (e) {
|
8415 |
};
|
8416 |
|
8417 |
ContentEditableInput.prototype.showPrimarySelection = function () {
|
8418 |
+
var sel = window.getSelection(), cm = this.cm, prim = cm.doc.sel.primary()
|
8419 |
+
var from = prim.from(), to = prim.to()
|
8420 |
+
|
8421 |
+
if (cm.display.viewTo == cm.display.viewFrom || from.line >= cm.display.viewTo || to.line < cm.display.viewFrom) {
|
8422 |
+
sel.removeAllRanges()
|
8423 |
+
return
|
8424 |
+
}
|
8425 |
+
|
8426 |
+
var curAnchor = domToPos(cm, sel.anchorNode, sel.anchorOffset)
|
8427 |
+
var curFocus = domToPos(cm, sel.focusNode, sel.focusOffset)
|
8428 |
if (curAnchor && !curAnchor.bad && curFocus && !curFocus.bad &&
|
8429 |
+
cmp(minPos(curAnchor, curFocus), from) == 0 &&
|
8430 |
+
cmp(maxPos(curAnchor, curFocus), to) == 0)
|
8431 |
{ return }
|
8432 |
|
8433 |
+
var view = cm.display.view
|
8434 |
+
var start = (from.line >= cm.display.viewFrom && posToDOM(cm, from)) ||
|
8435 |
+
{node: view[0].measure.map[2], offset: 0}
|
8436 |
+
var end = to.line < cm.display.viewTo && posToDOM(cm, to)
|
8437 |
+
if (!end) {
|
|
|
|
|
|
|
|
|
8438 |
var measure = view[view.length - 1].measure
|
8439 |
var map = measure.maps ? measure.maps[measure.maps.length - 1] : measure.map
|
8440 |
end = {node: map[map.length - 1], offset: map[map.length - 2] - map[map.length - 3]}
|
8441 |
}
|
8442 |
|
8443 |
+
if (!start || !end) {
|
8444 |
+
sel.removeAllRanges()
|
8445 |
+
return
|
8446 |
+
}
|
8447 |
+
|
8448 |
+
var old = sel.rangeCount && sel.getRangeAt(0), rng
|
8449 |
try { rng = range(start.node, start.offset, end.offset, end.node) }
|
8450 |
catch(e) {} // Our model of the DOM might be outdated, in which case the range we try to set can be impossible
|
8451 |
if (rng) {
|
8452 |
+
if (!gecko && cm.state.focused) {
|
8453 |
sel.collapse(start.node, start.offset)
|
8454 |
if (!rng.collapsed) {
|
8455 |
sel.removeAllRanges()
|
8529 |
};
|
8530 |
|
8531 |
ContentEditableInput.prototype.pollSelection = function () {
|
8532 |
+
if (this.readDOMTimeout != null || this.gracePeriod || !this.selectionChanged()) { return }
|
8533 |
+
var sel = window.getSelection(), cm = this.cm
|
8534 |
+
// On Android Chrome (version 56, at least), backspacing into an
|
8535 |
+
// uneditable block element will put the cursor in that element,
|
8536 |
+
// and then, because it's not editable, hide the virtual keyboard.
|
8537 |
+
// Because Android doesn't allow us to actually detect backspace
|
8538 |
+
// presses in a sane way, this code checks for when that happens
|
8539 |
+
// and simulates a backspace press in this case.
|
8540 |
+
if (android && chrome && this.cm.options.gutters.length && isInGutter(sel.anchorNode)) {
|
8541 |
+
this.cm.triggerOnKeyDown({type: "keydown", keyCode: 8, preventDefault: Math.abs})
|
8542 |
+
this.blur()
|
8543 |
+
this.focus()
|
8544 |
+
return
|
8545 |
}
|
8546 |
+
if (this.composing) { return }
|
8547 |
+
this.rememberSelection()
|
8548 |
+
var anchor = domToPos(cm, sel.anchorNode, sel.anchorOffset)
|
8549 |
+
var head = domToPos(cm, sel.focusNode, sel.focusOffset)
|
8550 |
+
if (anchor && head) { runInOp(cm, function () {
|
8551 |
+
setSelection(cm.doc, simpleSelection(anchor, head), sel_dontScroll)
|
8552 |
+
if (anchor.bad || head.bad) { cm.curOp.selectionChanged = true }
|
8553 |
+
}) }
|
8554 |
};
|
8555 |
|
8556 |
ContentEditableInput.prototype.pollContent = function () {
|
8604 |
while (cutEnd < maxCutEnd &&
|
8605 |
newBot.charCodeAt(newBot.length - cutEnd - 1) == oldBot.charCodeAt(oldBot.length - cutEnd - 1))
|
8606 |
{ ++cutEnd }
|
8607 |
+
// Try to move start of change to start of selection if ambiguous
|
8608 |
+
if (newText.length == 1 && oldText.length == 1 && fromLine == from.line) {
|
8609 |
+
while (cutFront && cutFront > from.ch &&
|
8610 |
+
newBot.charCodeAt(newBot.length - cutEnd - 1) == oldBot.charCodeAt(oldBot.length - cutEnd - 1)) {
|
8611 |
+
cutFront--
|
8612 |
+
cutEnd++
|
8613 |
+
}
|
8614 |
+
}
|
8615 |
|
8616 |
newText[newText.length - 1] = newBot.slice(0, newBot.length - cutEnd).replace(/^\u200b+/, "")
|
8617 |
newText[0] = newText[0].slice(cutFront).replace(/\u200b+$/, "")
|
8634 |
if (!this.composing) { return }
|
8635 |
clearTimeout(this.readDOMTimeout)
|
8636 |
this.composing = null
|
8637 |
+
this.updateFromDOM()
|
8638 |
this.div.blur()
|
8639 |
this.div.focus()
|
8640 |
};
|
8648 |
if (this$1.composing.done) { this$1.composing = null }
|
8649 |
else { return }
|
8650 |
}
|
8651 |
+
this$1.updateFromDOM()
|
|
|
8652 |
}, 80)
|
8653 |
};
|
8654 |
|
8655 |
+
ContentEditableInput.prototype.updateFromDOM = function () {
|
8656 |
+
var this$1 = this;
|
8657 |
+
|
8658 |
+
if (this.cm.isReadOnly() || !this.pollContent())
|
8659 |
+
{ runInOp(this.cm, function () { return regChange(this$1.cm); }) }
|
8660 |
+
};
|
8661 |
+
|
8662 |
ContentEditableInput.prototype.setUneditable = function (node) {
|
8663 |
node.contentEditable = "false"
|
8664 |
};
|
8665 |
|
8666 |
ContentEditableInput.prototype.onKeyPress = function (e) {
|
8667 |
+
if (e.charCode == 0) { return }
|
8668 |
e.preventDefault()
|
8669 |
if (!this.cm.isReadOnly())
|
8670 |
{ operation(this.cm, applyTextInput)(this.cm, String.fromCharCode(e.charCode == null ? e.keyCode : e.charCode), 0) }
|
8685 |
var line = getLine(cm.doc, pos.line)
|
8686 |
var info = mapFromLineView(view, line, pos.line)
|
8687 |
|
8688 |
+
var order = getOrder(line, cm.doc.direction), side = "left"
|
8689 |
if (order) {
|
8690 |
var partPos = getBidiPartAt(order, pos.ch)
|
8691 |
side = partPos % 2 ? "right" : "left"
|
8695 |
return result
|
8696 |
}
|
8697 |
|
8698 |
+
function isInGutter(node) {
|
8699 |
+
for (var scan = node; scan; scan = scan.parentNode)
|
8700 |
+
{ if (/CodeMirror-gutter-wrapper/.test(scan.className)) { return true } }
|
8701 |
+
return false
|
8702 |
+
}
|
8703 |
+
|
8704 |
function badPos(pos, bad) { if (bad) { pos.bad = true; } return pos }
|
8705 |
|
8706 |
function domTextBetween(cm, from, to, fromLine, toLine) {
|
8707 |
var text = "", closing = false, lineSep = cm.doc.lineSeparator()
|
8708 |
function recognizeMarker(id) { return function (marker) { return marker.id == id; } }
|
8709 |
+
function close() {
|
8710 |
+
if (closing) {
|
8711 |
+
text += lineSep
|
8712 |
+
closing = false
|
8713 |
+
}
|
8714 |
+
}
|
8715 |
+
function addText(str) {
|
8716 |
+
if (str) {
|
8717 |
+
close()
|
8718 |
+
text += str
|
8719 |
+
}
|
8720 |
+
}
|
8721 |
function walk(node) {
|
8722 |
if (node.nodeType == 1) {
|
8723 |
var cmText = node.getAttribute("cm-text")
|
8724 |
if (cmText != null) {
|
8725 |
+
addText(cmText || node.textContent.replace(/\u200b/g, ""))
|
|
|
8726 |
return
|
8727 |
}
|
8728 |
var markerID = node.getAttribute("cm-marker"), range
|
8729 |
if (markerID) {
|
8730 |
var found = cm.findMarks(Pos(fromLine, 0), Pos(toLine + 1, 0), recognizeMarker(+markerID))
|
8731 |
if (found.length && (range = found[0].find()))
|
8732 |
+
{ addText(getBetween(cm.doc, range.from, range.to).join(lineSep)) }
|
8733 |
return
|
8734 |
}
|
8735 |
if (node.getAttribute("contenteditable") == "false") { return }
|
8736 |
+
var isBlock = /^(pre|div|p)$/i.test(node.nodeName)
|
8737 |
+
if (isBlock) { close() }
|
8738 |
for (var i = 0; i < node.childNodes.length; i++)
|
8739 |
{ walk(node.childNodes[i]) }
|
8740 |
+
if (isBlock) { closing = true }
|
|
|
8741 |
} else if (node.nodeType == 3) {
|
8742 |
+
addText(node.nodeValue)
|
|
|
|
|
|
|
|
|
|
|
|
|
8743 |
}
|
8744 |
}
|
8745 |
for (;;) {
|
9141 |
if (!ie || (ie && ie_version < 9)) { prepareSelectAllHack() }
|
9142 |
var i = 0, poll = function () {
|
9143 |
if (display.selForContextMenu == cm.doc.sel && te.selectionStart == 0 &&
|
9144 |
+
te.selectionEnd > 0 && input.prevInput == "\u200b") {
|
9145 |
+
operation(cm, selectAll)(cm)
|
9146 |
+
} else if (i++ < 10) {
|
9147 |
+
display.detectingSelectAll = setTimeout(poll, 500)
|
9148 |
+
} else {
|
9149 |
+
display.selForContextMenu = null
|
9150 |
+
display.input.reset()
|
9151 |
+
}
|
9152 |
}
|
9153 |
display.detectingSelectAll = setTimeout(poll, 200)
|
9154 |
}
|
9324 |
|
9325 |
addLegacyProps(CodeMirror)
|
9326 |
|
9327 |
+
CodeMirror.version = "5.25.2"
|
9328 |
|
9329 |
return CodeMirror;
|
9330 |
|
lib/codemirror/lib/codemirror.min.js
CHANGED
@@ -1,5 +1,6 @@
|
|
1 |
-
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):e.CodeMirror=t()}(this,function(){"use strict";function e(e){return new RegExp("(^|\\s)"+e+"(?:$|\\s)\\s*")}function t(e){for(var t=e.childNodes.length;t>0;--t)e.removeChild(e.firstChild);return e}function r(e,r){return t(e).appendChild(r)}function n(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 i(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)}function o(){var e;try{e=document.activeElement}catch(t){e=document.body||null}for(;e&&e.root&&e.root.activeElement;)e=e.root.activeElement;return e}function l(t,r){var n=t.className;e(r).test(n)||(t.className+=(n?" ":"")+r)}function s(t,r){for(var n=t.split(" "),i=0;i<n.length;i++)n[i]&&!e(n[i]).test(r)&&(r+=" "+n[i]);return r}function a(e){var t=Array.prototype.slice.call(arguments,1);return function(){return e.apply(null,t)}}function u(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 c(e,t,r,n,i){null==t&&(t=e.search(/[^\s\u00a0]/),t==-1&&(t=e.length));for(var o=n||0,l=i||0;;){var s=e.indexOf("\t",o);if(s<0||s>=t)return l+(t-o);l+=s-o,l+=r-l%r,o=s+1}}function f(){this.id=null}function h(e,t){for(var r=0;r<e.length;++r)if(e[r]==t)return r;return-1}function d(e,t,r){for(var n=0,i=0;;){var o=e.indexOf("\t",n);o==-1&&(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 p(e){for(;Al.length<=e;)Al.push(g(Al)+" ");return Al[e]}function g(e){return e[e.length-1]}function v(e,t){for(var r=[],n=0;n<e.length;n++)r[n]=t(e[n],n);return r}function m(e,t,r){for(var n=0,i=r(t);n<e.length&&r(e[n])<=i;)n++;e.splice(n,0,t)}function y(){}function b(e,t){var r;return Object.create?r=Object.create(e):(y.prototype=e,r=new y),t&&u(t,r),r}function w(e){return/\w/.test(e)||e>""&&(e.toUpperCase()!=e.toLowerCase()||Ol.test(e))}function x(e,t){return t?!!(t.source.indexOf("\\w")>-1&&w(e))||t.test(e):w(e)}function C(e){for(var t in e)if(e.hasOwnProperty(t)&&e[t])return!1;return!0}function S(e){return e.charCodeAt(0)>=768&&Wl.test(e)}function L(e,t,r){var i=this;this.input=r,i.scrollbarFiller=n("div",null,"CodeMirror-scrollbar-filler"),i.scrollbarFiller.setAttribute("cm-not-content","true"),i.gutterFiller=n("div",null,"CodeMirror-gutter-filler"),i.gutterFiller.setAttribute("cm-not-content","true"),i.lineDiv=n("div",null,"CodeMirror-code"),i.selectionDiv=n("div",null,null,"position: relative; z-index: 1"),i.cursorDiv=n("div",null,"CodeMirror-cursors"),i.measure=n("div",null,"CodeMirror-measure"),i.lineMeasure=n("div",null,"CodeMirror-measure"),i.lineSpace=n("div",[i.measure,i.lineMeasure,i.selectionDiv,i.cursorDiv,i.lineDiv],null,"position: relative; outline: none"),i.mover=n("div",[n("div",[i.lineSpace],"CodeMirror-lines")],null,"position: relative"),i.sizer=n("div",[i.mover],"CodeMirror-sizer"),i.sizerWidth=null,i.heightForcer=n("div",null,null,"position: absolute; height: "+Ll+"px; width: 1px;"),i.gutters=n("div",null,"CodeMirror-gutters"),i.lineGutter=null,i.scroller=n("div",[i.sizer,i.heightForcer,i.gutters],"CodeMirror-scroll"),i.scroller.setAttribute("tabIndex","-1"),i.wrapper=n("div",[i.scrollbarFiller,i.gutterFiller,i.scroller],"CodeMirror"),rl&&nl<8&&(i.gutters.style.zIndex=-1,i.scroller.style.paddingRight=0),il||Jo&&hl||(i.scroller.draggable=!0),e&&(e.appendChild?e.appendChild(i.wrapper):e(i.wrapper)),i.viewFrom=i.viewTo=t.first,i.reportedViewFrom=i.reportedViewTo=t.first,i.view=[],i.renderedView=null,i.externalMeasured=null,i.viewOffset=0,i.lastWrapHeight=i.lastWrapWidth=0,i.updateLineNumbers=null,i.nativeBarWidth=i.barHeight=i.barWidth=0,i.scrollbarsClipped=!1,i.lineNumWidth=i.lineNumInnerWidth=i.lineNumChars=null,i.alignWidgets=!1,i.cachedCharWidth=i.cachedTextHeight=i.cachedPaddingH=null,i.maxLine=null,i.maxLineLength=0,i.maxLineChanged=!1,i.wheelDX=i.wheelDY=i.wheelStartX=i.wheelStartY=null,i.shift=!1,i.selForContextMenu=null,i.activeTouch=null,r.init(i)}function T(e,t){if(t-=e.first,t<0||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(t<o){r=i;break}t-=o}return r.lines[t]}function M(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 k(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 A(e){if(null==e.parent)return null;for(var t=e.parent,r=h(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 O(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(t<o){e=i;continue e}t-=o,r+=i.chunkSize()}return r}while(!e.lines);for(var l=0;l<e.lines.length;++l){var s=e.lines[l],a=s.height;if(t<a)break;t-=a}return r+l}function W(e,t){return t>=e.first&&t<e.first+e.size}function D(e,t){return String(e.lineNumberFormatter(t+e.firstLineNumber))}function H(e,t){return this instanceof H?(this.line=e,void(this.ch=t)):new H(e,t)}function P(e,t){return e.line-t.line||e.ch-t.ch}function E(e){return H(e.line,e.ch)}function I(e,t){return P(e,t)<0?t:e}function z(e,t){return P(e,t)<0?e:t}function F(e,t){return Math.max(e.first,Math.min(t,e.first+e.size-1))}function R(e,t){if(t.line<e.first)return H(e.first,0);var r=e.first+e.size-1;return t.line>r?H(r,T(e,r).text.length):B(t,T(e,t.line).text.length)}function B(e,t){var r=e.ch;return null==r||r>t?H(e.line,t):r<0?H(e.line,0):e}function G(e,t){for(var r=[],n=0;n<t.length;n++)r[n]=R(e,t[n]);return r}function U(){Dl=!0}function V(){Hl=!0}function K(e,t,r){this.marker=e,this.from=t,this.to=r}function j(e,t){if(e)for(var r=0;r<e.length;++r){var n=e[r];if(n.marker==t)return n}}function X(e,t){for(var r,n=0;n<e.length;++n)e[n]!=t&&(r||(r=[])).push(e[n]);return r}function Y(e,t){e.markedSpans=e.markedSpans?e.markedSpans.concat([t]):[t],t.marker.attachLine(e)}function _(e,t,r){var n;if(e)for(var 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 K(l,o.from,a?null:o.to))}}return n}function $(e,t,r){var n;if(e)for(var 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 K(l,a?null:o.from-t,null==o.to?null:o.to-t))}}return n}function q(e,t){if(t.full)return null;var r=W(e,t.from.line)&&T(e,t.from.line).markedSpans,n=W(e,t.to.line)&&T(e,t.to.line).markedSpans;if(!r&&!n)return null;var i=t.from.ch,o=t.to.ch,l=0==P(t.from,t.to),s=_(r,i,l),a=$(n,o,l),u=1==t.text.length,c=g(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=j(a,h.marker);d?u&&(h.to=null==d.to?null:d.to+c):h.to=i}}if(a)for(var p=0;p<a.length;++p){var v=a[p];if(null!=v.to&&(v.to+=c),null==v.from){var m=j(s,v.marker);m||(v.from=c,u&&(s||(s=[])).push(v))}else v.from+=c,u&&(s||(s=[])).push(v)}s&&(s=Z(s)),a&&a!=s&&(a=Z(a));var y=[s];if(!u){var b,w=t.text.length-2;if(w>0&&s)for(var x=0;x<s.length;++x)null==s[x].to&&(b||(b=[])).push(new K(s[x].marker,null,null));for(var C=0;C<w;++C)y.push(b);y.push(a)}return y}function Z(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 Q(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&&h(n,r)!=-1||(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(!(P(u.to,s.from)<0||P(u.from,s.to)>0)){var c=[a,1],f=P(u.from,s.from),d=P(u.to,s.to);(f<0||!l.inclusiveLeft&&!f)&&c.push({from:u.from,to:s.from}),(d>0||!l.inclusiveRight&&!d)&&c.push({from:s.to,to:u.to}),i.splice.apply(i,c),a+=c.length-1}}return i}function J(e){var t=e.markedSpans;if(t){for(var r=0;r<t.length;++r)t[r].marker.detachLine(e);e.markedSpans=null}}function ee(e,t){if(t){for(var r=0;r<t.length;++r)t[r].marker.attachLine(e);e.markedSpans=t}}function te(e){return e.inclusiveLeft?-1:0}function re(e){return e.inclusiveRight?1:0}function ne(e,t){var r=e.lines.length-t.lines.length;if(0!=r)return r;var n=e.find(),i=t.find(),o=P(n.from,i.from)||te(e)-te(t);if(o)return-o;var l=P(n.to,i.to)||re(e)-re(t);return l?l:t.id-e.id}function ie(e,t){var r,n=Hl&&e.markedSpans;if(n)for(var i=void 0,o=0;o<n.length;++o)i=n[o],i.marker.collapsed&&null==(t?i.from:i.to)&&(!r||ne(r,i.marker)<0)&&(r=i.marker);return r}function oe(e){return ie(e,!0)}function le(e){return ie(e,!1)}function se(e,t,r,n,i){var o=T(e,t),l=Hl&&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=P(u.from,r)||te(a.marker)-te(i),f=P(u.to,n)||re(a.marker)-re(i);if(!(c>=0&&f<=0||c<=0&&f>=0)&&(c<=0&&(a.marker.inclusiveRight&&i.inclusiveLeft?P(u.to,r)>=0:P(u.to,r)>0)||c>=0&&(a.marker.inclusiveRight&&i.inclusiveLeft?P(u.from,n)<=0:P(u.from,n)<0)))return!0}}}function ae(e){for(var t;t=oe(e);)e=t.find(-1,!0).line;return e}function ue(e){for(var t,r;t=le(e);)e=t.find(1,!0).line,(r||(r=[])).push(e);return r}function ce(e,t){var r=T(e,t),n=ae(r);return r==n?t:A(n)}function fe(e,t){if(t>e.lastLine())return t;var r,n=T(e,t);if(!he(e,n))return t;for(;r=le(n);)n=r.find(1,!0).line;return A(n)+1}function he(e,t){var r=Hl&&t.markedSpans;if(r)for(var n=void 0,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&&de(e,t,n))return!0}}function de(e,t,r){if(null==r.to){var n=r.marker.find(1,!0);return de(e,n.line,j(n.line.markedSpans,r.marker))}if(r.marker.inclusiveRight&&r.to==t.text.length)return!0;for(var i=void 0,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)&&de(e,t,i))return!0}function pe(e){e=ae(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 l=0;l<o.children.length;++l){var s=o.children[l];if(s==r)break;t+=s.height}return t}function ge(e){if(0==e.height)return 0;for(var t,r=e.text.length,n=e;t=oe(n);){var i=t.find(0,!0);n=i.from.line,r+=i.from.ch-i.to.ch}for(n=e;t=le(n);){var o=t.find(0,!0);r-=n.text.length-o.from.ch,n=o.to.line,r+=n.text.length-o.to.ch}return r}function ve(e){var t=e.display,r=e.doc;t.maxLine=T(r,r.first),t.maxLineLength=ge(t.maxLine),t.maxLineChanged=!0,r.iter(function(e){var r=ge(e);r>t.maxLineLength&&(t.maxLineLength=r,t.maxLine=e)})}function me(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 ye(e){return e.level%2?e.to:e.from}function be(e){return e.level%2?e.from:e.to}function we(e){var t=ke(e);return t?ye(t[0]):0}function xe(e){var t=ke(e);return t?be(g(t)):e.text.length}function Ce(e,t,r){var n=e[0].level;return t==n||r!=n&&t<r}function Se(e,t){var r;Pl=null;for(var 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 Ce(e,i.level,e[r].level)?(i.from!=i.to&&(Pl=r),n):(i.from!=i.to&&(Pl=n),r);r=n}}return r}function Le(e,t,r,n){if(!n)return t+r;do t+=r;while(t>0&&S(e.text.charAt(t)));return t}function Te(e,t,r,n){var i=ke(e);if(!i)return Me(e,t,r,n);for(var o=Se(i,t),l=i[o],s=Le(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 Se(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?Le(e,l.to,-1,n):Le(e,l.from,1,n)}}function Me(e,t,r,n){var i=t+r;if(n)for(;i>0&&S(e.text.charAt(i));)i+=r;return i<0||i>e.text.length?null:i}function ke(e){var t=e.order;return null==t&&(t=e.order=El(e.text)),t}function Ne(e,t){return e._handlers&&e._handlers[t]||Il}function Ae(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,i=n&&n[t];if(i){var o=h(i,r);o>-1&&(n[t]=i.slice(0,o).concat(i.slice(o+1)))}}}function Oe(e,t){var r=Ne(e,t);if(r.length)for(var n=Array.prototype.slice.call(arguments,2),i=0;i<r.length;++i)r[i].apply(null,n)}function We(e,t,r){return"string"==typeof t&&(t={type:t,preventDefault:function(){this.defaultPrevented=!0}}),Oe(e,r||t.type,e,t),ze(t)||t.codemirrorIgnore}function De(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)h(r,t[n])==-1&&r.push(t[n])}function He(e,t){return Ne(e,t).length>0}function Pe(e){e.prototype.on=function(e,t){zl(this,e,t)},e.prototype.off=function(e,t){Ae(this,e,t)}}function Ee(e){e.preventDefault?e.preventDefault():e.returnValue=!1}function Ie(e){e.stopPropagation?e.stopPropagation():e.cancelBubble=!0}function ze(e){return null!=e.defaultPrevented?e.defaultPrevented:0==e.returnValue}function Fe(e){Ee(e),Ie(e)}function Re(e){return e.target||e.srcElement}function Be(e){var t=e.which;return null==t&&(1&e.button?t=1:2&e.button?t=3:4&e.button&&(t=2)),dl&&e.ctrlKey&&1==t&&(t=3),t}function Ge(e){if(null==Cl){var t=n("span","");r(e,n("span",[t,document.createTextNode("x")])),0!=e.firstChild.offsetHeight&&(Cl=t.offsetWidth<=1&&t.offsetHeight>2&&!(rl&&nl<8))}var i=Cl?n("span",""):n("span"," ",null,"display: inline-block; width: 1px; margin-right: -1px");return i.setAttribute("cm-text",""),i}function Ue(e){if(null!=Sl)return Sl;var n=r(e,document.createTextNode("AخA")),i=ml(n,0,1).getBoundingClientRect(),o=ml(n,1,2).getBoundingClientRect();return t(e),!(!i||i.left==i.right)&&(Sl=o.right-i.right<3)}function Ve(e){if(null!=Ul)return Ul;var t=r(e,n("span","x")),i=t.getBoundingClientRect(),o=ml(t,0,1).getBoundingClientRect();return Ul=Math.abs(i.left-o.left)>1}function Ke(e,t){arguments.length>2&&(t.dependencies=Array.prototype.slice.call(arguments,2)),Vl[e]=t}function je(e,t){Kl[e]=t}function Xe(e){if("string"==typeof e&&Kl.hasOwnProperty(e))e=Kl[e];else if(e&&"string"==typeof e.name&&Kl.hasOwnProperty(e.name)){var t=Kl[e.name];"string"==typeof t&&(t={name:t}),e=b(t,e),e.name=t.name}else{if("string"==typeof e&&/^[\w\-]+\/[\w\-]+\+xml$/.test(e))return Xe("application/xml");if("string"==typeof e&&/^[\w\-]+\/[\w\-]+\+json$/.test(e))return Xe("application/json")}return"string"==typeof e?{name:e}:e||{name:"null"}}function Ye(e,t){t=Xe(t);var r=Vl[t.name];if(!r)return Ye(e,"text/plain");var n=r(e,t);if(jl.hasOwnProperty(t.name)){var i=jl[t.name];for(var o in i)i.hasOwnProperty(o)&&(n.hasOwnProperty(o)&&(n["_"+o]=n[o]),n[o]=i[o])}if(n.name=t.name,t.helperType&&(n.helperType=t.helperType),t.modeProps)for(var l in t.modeProps)n[l]=t.modeProps[l];return n}function _e(e,t){var r=jl.hasOwnProperty(e)?jl[e]:jl[e]={};u(t,r)}function $e(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}function qe(e,t){for(var r;e.innerMode&&(r=e.innerMode(t),r&&r.mode!=e);)t=r.state,e=r.mode;return r||{mode:e,state:t}}function Ze(e,t,r){return!e.startState||e.startState(t,r)}function Qe(e,t,r,n){var i=[e.state.modeGen],o={};lt(e,t.text,e.doc.mode,r,function(e,t){return i.push(e,t)},o,n);for(var l=function(r){var n=e.state.overlays[r],l=1,s=0;lt(e,t.text,n.mode,!0,function(e,t){for(var r=l;s<e;){var o=i[l];o>e&&i.splice(l,1,e,i[l+1],o),l+=2,s=Math.min(e,o)}if(t)if(n.opaque)i.splice(r,l-r,e,"overlay "+t),l=r+2;else for(;r<l;r+=2){var a=i[r+1];i[r+1]=(a?a+" ":"")+"overlay "+t}},o)},s=0;s<e.state.overlays.length;++s)l(s);return{styles:i,classes:o.bgClass||o.textClass?o:null}}function Je(e,t,r){if(!t.styles||t.styles[0]!=e.state.modeGen){var n=et(e,A(t)),i=Qe(e,t,t.text.length>e.options.maxHighlightLength?$e(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 et(e,t,r){var n=e.doc,i=e.display;if(!n.mode.startState)return!0;var o=st(e,t,r),l=o>n.first&&T(n,o-1).stateAfter;return l=l?$e(n.mode,l):Ze(n.mode),n.iter(o,t,function(r){tt(e,r.text,l);var s=o==t-1||o%5==0||o>=i.viewFrom&&o<i.viewTo;r.stateAfter=s?$e(n.mode,l):null,++o}),r&&(n.frontier=o),l}function tt(e,t,r,n){var i=e.doc.mode,o=new Xl(t,e.options.tabSize);for(o.start=o.pos=n||0,""==t&&rt(i,r);!o.eol();)nt(i,o,r),o.start=o.pos}function rt(e,t){if(e.blankLine)return e.blankLine(t);if(e.innerMode){var r=qe(e,t);return r.mode.blankLine?r.mode.blankLine(r.state):void 0}}function nt(e,t,r,n){for(var i=0;i<10;i++){n&&(n[0]=qe(e,r).mode);var o=e.token(t,r);if(t.pos>t.start)return o}throw new Error("Mode "+e.name+" failed to advance stream.")}function it(e,t,r,n){var i,o=function(e){return{start:f.start,end:f.pos,string:f.current(),type:i||null,state:e?$e(l.mode,c):c}},l=e.doc,s=l.mode;t=R(l,t);var a,u=T(l,t.line),c=et(e,t.line,r),f=new Xl(u.text,e.options.tabSize);for(n&&(a=[]);(n||f.pos<t.ch)&&!f.eol();)f.start=f.pos,i=nt(s,f,c),n&&a.push(o(!0));return n?a:o()}function ot(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 lt(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 Xl(t,e.options.tabSize),h=e.options.addModeClass&&[null];for(""==t&&ot(rt(r,n),o);!f.eol();){if(f.pos>e.options.maxHighlightLength?(s=!1,l&&tt(e,t,n,f.pos),f.pos=t.length,a=null):a=ot(nt(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+5e3),i(u,c);c=a}f.start=f.pos}for(;u<f.pos;){var p=Math.min(f.pos,u+5e3);i(p,c),u=p}}function st(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=T(o,s-1);if(a.stateAfter&&(!r||s<=o.frontier))return s;var u=c(a.text,null,e.options.tabSize);(null==i||n>u)&&(i=s-1,n=u)}return i}function at(e,t,r){this.text=e,ee(this,t),this.height=r?r(this):1}function ut(e,t,r,n){e.text=t,e.stateAfter&&(e.stateAfter=null),e.styles&&(e.styles=null),null!=e.order&&(e.order=null),J(e),ee(e,r);var i=n?n(e):1;i!=e.height&&N(e,i)}function ct(e){e.parent=null,J(e)}function ft(e,t){if(!e||/^\s*$/.test(e))return null;var r=t.addModeClass?$l:_l;return r[e]||(r[e]=e.replace(/\S+/g,"cm-$&"))}function ht(e,t){var r=n("span",null,null,il?"padding-right: .1px":null),i={pre:n("pre",[r],"CodeMirror-line"),content:r,col:0,pos:0,cm:e,trailingSpace:!1,splitSpaces:(rl||il)&&e.getOption("lineWrapping")};r.setAttribute("role","presentation"),i.pre.setAttribute("role","presentation"),t.measure={};for(var o=0;o<=(t.rest?t.rest.length:0);o++){var l=o?t.rest[o-1]:t.line,a=void 0;i.pos=0,i.addToken=pt,Ue(e.display.measure)&&(a=ke(l))&&(i.addToken=vt(i.addToken,a)),i.map=[];var u=t!=e.display.externalMeasured&&A(l);yt(l,i,Je(e,l,u)),l.styleClasses&&(l.styleClasses.bgClass&&(i.bgClass=s(l.styleClasses.bgClass,i.bgClass||"")),l.styleClasses.textClass&&(i.textClass=s(l.styleClasses.textClass,i.textClass||""))),0==i.map.length&&i.map.push(0,0,i.content.appendChild(Ge(e.display.measure))),0==o?(t.measure.map=i.map,t.measure.cache={}):((t.measure.maps||(t.measure.maps=[])).push(i.map),(t.measure.caches||(t.measure.caches=[])).push({}))}if(il){var c=i.content.lastChild;(/\bcm-tab\b/.test(c.className)||c.querySelector&&c.querySelector(".cm-tab"))&&(i.content.className="cm-tab-wrap-hack")}return Oe(e,"renderLine",e,t.line,i.pre),i.pre.className&&(i.textClass=s(i.pre.className,i.textClass||"")),i}function dt(e){var t=n("span","•","cm-invalidchar");return t.title="\\u"+e.charCodeAt(0).toString(16),t.setAttribute("aria-label",t.title),t}function pt(e,t,r,i,o,l,s){if(t){var a,u=e.splitSpaces?gt(t,e.trailingSpace):t,c=e.cm.state.specialChars,f=!1;if(c.test(t)){a=document.createDocumentFragment();for(var h=0;;){c.lastIndex=h;var d=c.exec(t),g=d?d.index-h:t.length-h;if(g){var v=document.createTextNode(u.slice(h,h+g));rl&&nl<9?a.appendChild(n("span",[v])):a.appendChild(v),e.map.push(e.pos,e.pos+g,v),e.col+=g,e.pos+=g}if(!d)break;h+=g+1;var m=void 0;if("\t"==d[0]){var y=e.cm.options.tabSize,b=y-e.col%y;m=a.appendChild(n("span",p(b),"cm-tab")),m.setAttribute("role","presentation"),m.setAttribute("cm-text","\t"),e.col+=b}else"\r"==d[0]||"\n"==d[0]?(m=a.appendChild(n("span","\r"==d[0]?"␍":"","cm-invalidchar")),m.setAttribute("cm-text",d[0]),e.col+=1):(m=e.cm.options.specialCharPlaceholder(d[0]),m.setAttribute("cm-text",d[0]),rl&&nl<9?a.appendChild(n("span",[m])):a.appendChild(m),e.col+=1);e.map.push(e.pos,e.pos+1,m),e.pos++}}else e.col+=t.length,a=document.createTextNode(u),e.map.push(e.pos,e.pos+t.length,a),rl&&nl<9&&(f=!0),e.pos+=t.length;if(e.trailingSpace=32==u.charCodeAt(t.length-1),r||i||o||f||s){var w=r||"";i&&(w+=i),o&&(w+=o);var x=n("span",[a],w,s);return l&&(x.title=l),e.content.appendChild(x)}e.content.appendChild(a)}}function gt(e,t){if(e.length>1&&!/ /.test(e))return e;for(var r=t,n="",i=0;i<e.length;i++){var o=e.charAt(i);" "!=o||!r||i!=e.length-1&&32!=e.charCodeAt(i+1)||(o=" "),n+=o,r=" "==o}return n}function vt(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=void 0,h=0;h<t.length&&(f=t[h],!(f.to>u&&f.from<=u));h++);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 mt(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,e.trailingSpace=!1}function yt(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=void 0,w=0;w<n.length;++w){var x=n[w],C=x.marker;"bookmark"==C.type&&x.from==p&&C.widgetNode?y.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&&(b||(b=[])).push(C.endStyle,x.to),C.title&&!f&&(f=C.title),C.collapsed&&(!h||ne(h.marker,C)<0)&&(h=x)):x.from>p&&m>x.from&&(m=x.from)}if(b)for(var S=0;S<b.length;S+=2)b[S+1]==m&&(u+=" "+b[S]);if(!h||h.from==p)for(var L=0;L<y.length;++L)mt(t,0,y[L]);if(h&&(h.from||0)==p){if(mt(t,(null==h.to?d+1:h.to)-p,h.marker,null==h.from),null==h.to)return;h.to==p&&(h=!1)}}if(p>=d)break;for(var T=Math.min(d,m);;){if(v){var M=p+v.length;if(!h){var k=M>T?v.slice(0,T-p):v;t.addToken(t,k,l?l+a:a,c,p+k.length==m?u:"",f,s)}if(M>=T){v=v.slice(T-p),p=T;break}p=M,c=""}v=i.slice(o,o=r[g++]),l=ft(r[g++],t.cm.options)}}else for(var N=1;N<r.length;N+=2)t.addToken(t,i.slice(o,o=r[N]),ft(r[N+1],t.cm.options))}function bt(e,t,r){this.line=t,this.rest=ue(t),this.size=this.rest?A(g(this.rest))-r+1:1,this.node=this.text=null,this.hidden=he(e,t)}function wt(e,t,r){for(var n,i=[],o=t;o<r;o=n){var l=new bt(e.doc,T(e.doc,o),o);n=o+l.size,i.push(l)}return i}function xt(e){ql?ql.ops.push(e):e.ownsGroup=ql={ops:[e],delayedCallbacks:[]}}function Ct(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 St(e,t){var r=e.ownsGroup;if(r)try{Ct(r)}finally{ql=null,t(r)}}function Lt(e,t){var r=Ne(e,t);if(r.length){var n,i=Array.prototype.slice.call(arguments,2);ql?n=ql.delayedCallbacks:Zl?n=Zl:(n=Zl=[],setTimeout(Tt,0));for(var o=function(e){n.push(function(){return r[e].apply(null,i)})},l=0;l<r.length;++l)o(l)}}function Tt(){var e=Zl;Zl=null;for(var t=0;t<e.length;++t)e[t]()}function Mt(e,t,r,n){for(var i=0;i<t.changes.length;i++){var o=t.changes[i];"text"==o?Ot(e,t):"gutter"==o?Dt(e,t,r,n):"class"==o?Wt(t):"widget"==o&&Ht(e,t,n)}t.changes=null}function kt(e){return e.node==e.text&&(e.node=n("div",null,null,"position: relative"),e.text.parentNode&&e.text.parentNode.replaceChild(e.node,e.text),e.node.appendChild(e.text),rl&&nl<8&&(e.node.style.zIndex=2)),e.node}function Nt(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=kt(e);e.background=r.insertBefore(n("div",null,t),r.firstChild)}}function At(e,t){var r=e.display.externalMeasured;return r&&r.line==t.line?(e.display.externalMeasured=null,t.measure=r.measure,r.built):ht(e,t)}function Ot(e,t){var r=t.text.className,n=At(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,Wt(t)):r&&(t.text.className=r)}function Wt(e){Nt(e),e.line.wrapClass?kt(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 Dt(e,t,r,i){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 o=kt(t);t.gutterBackground=n("div",null,"CodeMirror-gutter-background "+t.line.gutterClass,"left: "+(e.options.fixedGutter?i.fixedPos:-i.gutterTotalWidth)+"px; width: "+i.gutterTotalWidth+"px"),o.insertBefore(t.gutterBackground,t.text)}var l=t.line.gutterMarkers;if(e.options.lineNumbers||l){var s=kt(t),a=t.gutter=n("div",null,"CodeMirror-gutter-wrapper","left: "+(e.options.fixedGutter?i.fixedPos:-i.gutterTotalWidth)+"px");if(e.display.input.setUneditable(a),s.insertBefore(a,t.text),t.line.gutterClass&&(a.className+=" "+t.line.gutterClass),!e.options.lineNumbers||l&&l["CodeMirror-linenumbers"]||(t.lineNumber=a.appendChild(n("div",D(e.options,r),"CodeMirror-linenumber CodeMirror-gutter-elt","left: "+i.gutterLeft["CodeMirror-linenumbers"]+"px; width: "+e.display.lineNumInnerWidth+"px"))),l)for(var u=0;u<e.options.gutters.length;++u){var c=e.options.gutters[u],f=l.hasOwnProperty(c)&&l[c];f&&a.appendChild(n("div",[f],"CodeMirror-gutter-elt","left: "+i.gutterLeft[c]+"px; width: "+i.gutterWidth[c]+"px"))}}}function Ht(e,t,r){t.alignable&&(t.alignable=null);for(var n=t.node.firstChild,i=void 0;n;n=i)i=n.nextSibling,"CodeMirror-linewidget"==n.className&&t.node.removeChild(n);Et(e,t,r)}function Pt(e,t,r,n){var i=At(e,t);return t.text=t.node=i.pre,i.bgClass&&(t.bgClass=i.bgClass),i.textClass&&(t.textClass=i.textClass),Wt(t),Dt(e,t,r,n),Et(e,t,n),t.node}function Et(e,t,r){if(It(e,t.line,t,r,!0),t.rest)for(var n=0;n<t.rest.length;n++)It(e,t.rest[n],t,r,!1)}function It(e,t,r,i,o){if(t.widgets)for(var l=kt(r),s=0,a=t.widgets;s<a.length;++s){var u=a[s],c=n("div",[u.node],"CodeMirror-linewidget");u.handleMouseEvents||c.setAttribute("cm-ignore-events","true"),zt(u,c,r,i),e.display.input.setUneditable(c),o&&u.above?l.insertBefore(c,r.gutter||r.text):l.appendChild(c),Lt(u,"redraw")}}function zt(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 Ft(e){if(null!=e.height)return e.height;var t=e.doc.cm;if(!t)return 0;if(!i(document.body,e.node)){var o="position: relative;";e.coverGutter&&(o+="margin-left: -"+t.display.gutters.offsetWidth+"px;"),e.noHScroll&&(o+="width: "+t.display.wrapper.clientWidth+"px;"),r(t.display.measure,n("div",[e.node],null,o))}return e.height=e.node.parentNode.offsetHeight}function Rt(e,t){for(var r=Re(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 Bt(e){return e.lineSpace.offsetTop}function Gt(e){return e.mover.offsetHeight-e.lineSpace.offsetHeight}function Ut(e){if(e.cachedPaddingH)return e.cachedPaddingH;var t=r(e.measure,n("pre","x")),i=window.getComputedStyle?window.getComputedStyle(t):t.currentStyle,o={left:parseInt(i.paddingLeft),right:parseInt(i.paddingRight)};return isNaN(o.left)||isNaN(o.right)||(e.cachedPaddingH=o),o}function Vt(e){return Ll-e.display.nativeBarWidth}function Kt(e){return e.display.scroller.clientWidth-Vt(e)-e.display.barWidth}function jt(e){return e.display.scroller.clientHeight-Vt(e)-e.display.barHeight}function Xt(e,t,r){var n=e.options.lineWrapping,i=n&&Kt(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 Yt(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 i=0;i<e.rest.length;i++)if(A(e.rest[i])>r)return{map:e.measure.maps[i],cache:e.measure.caches[i],before:!0}}function _t(e,t){t=ae(t);var n=A(t),i=e.display.externalMeasured=new bt(e.doc,t,n);i.lineN=n;var o=i.built=ht(e,i);return i.text=o.pre,r(e.display.lineMeasure,o.pre),i}function $t(e,t,r,n){return Qt(e,Zt(e,t),r,n)}function qt(e,t){if(t>=e.display.viewFrom&&t<e.display.viewTo)return e.display.view[Sr(e,t)];var r=e.display.externalMeasured;return r&&t>=r.lineN&&t<r.lineN+r.size?r:void 0}function Zt(e,t){var r=A(t),n=qt(e,r);n&&!n.text?n=null:n&&n.changes&&(Mt(e,n,r,yr(e)),e.curOp.forceUpdate=!0),n||(n=_t(e,t));var i=Yt(n,t,r);return{line:t,view:n,rect:null,map:i.map,cache:i.cache,before:i.before,hasHeights:!1}}function Qt(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||(Xt(e,t.view,t.rect),t.hasHeights=!0),o=tr(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 Jt(e,t,r){for(var n,i,o,l,s,a,u=0;u<e.length;u+=3)if(s=e[u],a=e[u+1],t<s?(i=0,o=1,l="left"):t<a?(i=t-s,o=i+1):(u==e.length-3||t==a&&e[u+3]>t)&&(o=a-s,i=o-1,t>=a&&(l="right")),null!=i){if(n=e[u+2],s==a&&r==(n.insertLeft?"left":"right")&&(l=r),"left"==r&&0==i)for(;u&&e[u-2]==e[u-3]&&e[u-1].insertLeft;)n=e[(u-=3)+2],l="left";if("right"==r&&i==a-s)for(;u<e.length-3&&e[u+3]==e[u+4]&&!e[u+5].insertLeft;)n=e[(u+=3)+2],l="right";break}return{node:n,start:i,end:o,collapse:l,coverStart:s,coverEnd:a}}function er(e,t){var r=Ql;if("left"==t)for(var n=0;n<e.length&&(r=e[n]).left==r.right;n++);else for(var i=e.length-1;i>=0&&(r=e[i]).left==r.right;i--);return r}function tr(e,t,r,n){var i,o=Jt(t.map,r,n),l=o.node,s=o.start,a=o.end,u=o.collapse;if(3==l.nodeType){for(var c=0;c<4;c++){for(;s&&S(t.line.text.charAt(o.coverStart+s));)--s;for(;o.coverStart+a<o.coverEnd&&S(t.line.text.charAt(o.coverStart+a));)++a;if(i=rl&&nl<9&&0==s&&a==o.coverEnd-o.coverStart?l.parentNode.getBoundingClientRect():er(ml(l,s,a).getClientRects(),n),
|
2 |
-
i.left||i.right||0==s)break;a=s,s-=1,u="right"}rl&&nl<11&&(i=rr(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(rl&&nl<9&&!s&&(!i||!i.left&&!i.right)){var h=l.parentNode.getClientRects()[0];i=h?{left:h.left,right:h.left+mr(e.display),top:h.top,bottom:h.bottom}:Ql}for(var d=i.top-t.rect.top,p=i.bottom-t.rect.top,g=(d+p)/2,v=t.view.measure.heights,m=0;m<v.length-1&&!(g<v[m]);m++);var y=m?v[m-1]:0,b=v[m],w={left:("right"==u?i.right:i.left)-t.rect.left,right:("left"==u?i.left:i.right)-t.rect.left,top:y,bottom:b};return i.left||i.right||(w.bogus=!0),e.options.singleCursorHeightPerLine||(w.rtop=d,w.rbottom=p),w}function rr(e,t){if(!window.screen||null==screen.logicalXDPI||screen.logicalXDPI==screen.deviceXDPI||!Ve(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 nr(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 ir(e){e.display.externalMeasure=null,t(e.display.lineMeasure);for(var r=0;r<e.display.view.length;r++)nr(e.display.view[r])}function or(e){ir(e),e.display.cachedCharWidth=e.display.cachedTextHeight=e.display.cachedPaddingH=null,e.options.lineWrapping||(e.display.maxLineChanged=!0),e.display.lineNumChars=null}function lr(){return window.pageXOffset||(document.documentElement||document.body).scrollLeft}function sr(){return window.pageYOffset||(document.documentElement||document.body).scrollTop}function ar(e,t,r,n,i){if(!i&&t.widgets)for(var o=0;o<t.widgets.length;++o)if(t.widgets[o].above){var l=Ft(t.widgets[o]);r.top+=l,r.bottom+=l}if("line"==n)return r;n||(n="local");var s=pe(t);if("local"==n?s+=Bt(e.display):s-=e.display.viewOffset,"page"==n||"window"==n){var a=e.display.lineSpace.getBoundingClientRect();s+=a.top+("window"==n?0:sr());var u=a.left+("window"==n?0:lr());r.left+=u,r.right+=u}return r.top+=s,r.bottom+=s,r}function ur(e,t,r){if("div"==r)return t;var n=t.left,i=t.top;if("page"==r)n-=lr(),i-=sr();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 cr(e,t,r,n,i){return n||(n=T(e.doc,t.line)),ar(e,n,$t(e,n,t.ch,i),r)}function fr(e,t,r,n,i,o){function l(t,l){var s=Qt(e,i,t,l?"right":"left",o);return l?s.left=s.right:s.right=s.left,ar(e,n,s,r)}function s(e,t){var r=a[t],n=r.level%2;return e==ye(r)&&t&&r.level<a[t-1].level?(r=a[--t],e=be(r)-(r.level%2?0:1),n=!0):e==be(r)&&t<a.length-1&&r.level<a[t+1].level&&(r=a[++t],e=ye(r)-r.level%2,n=!1),n&&e==r.to&&e>r.from?l(e-1):l(e,n)}n=n||T(e.doc,t.line),i||(i=Zt(e,n));var a=ke(n),u=t.ch;if(!a)return l(u);var c=Se(a,u),f=s(u,c);return null!=Pl&&(f.other=s(u,Pl)),f}function hr(e,t){var r=0;t=R(e.doc,t),e.options.lineWrapping||(r=mr(e.display)*t.ch);var n=T(e.doc,t.line),i=pe(n)+Bt(e.display);return{left:r,right:r,top:i,bottom:i+n.height}}function dr(e,t,r,n){var i=H(e,t);return i.xRel=n,r&&(i.outside=!0),i}function pr(e,t,r){var n=e.doc;if(r+=e.display.viewOffset,r<0)return dr(n.first,0,!0,-1);var i=O(n,r),o=n.first+n.size-1;if(i>o)return dr(n.first+n.size-1,T(n,o).text.length,!0,1);t<0&&(t=0);for(var l=T(n,i);;){var s=gr(e,l,i,t,r),a=le(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=A(l=u.to.line)}}function gr(e,t,r,n,i){function o(n){var i=fr(e,H(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-pe(t),s=!1,a=2*e.display.wrapper.clientWidth,u=Zt(e,t),c=ke(t),f=t.text.length,h=we(t),d=xe(t),p=o(h),g=s,v=o(d),m=s;if(n>v)return dr(r,d,m,1);for(;;){if(c?d==h||d==Te(t,h,1):d-h<=1){var y=n<p||n-p<=v-n?h:d,b=y==h?g:m,w=n-(y==h?p:v);if(m&&!c&&!/\s/.test(t.text.charAt(y))&&w>0&&y<t.text.length&&u.view.measure.heights.length>1){var x=Qt(e,u,y,"right");l<=x.bottom&&l>=x.top&&Math.abs(n-x.right)<w&&(b=!1,y++,w=n-x.right)}for(;S(t.text.charAt(y));)++y;var C=dr(r,y,b,w<-1?-1:w>1?1:0);return C}var L=Math.ceil(f/2),T=h+L;if(c){T=h;for(var M=0;M<L;++M)T=Te(t,T,1)}var k=o(T);k>n?(d=T,v=k,(m=s)&&(v+=1e3),f=L):(h=T,p=k,g=s,f-=L)}}function vr(e){if(null!=e.cachedTextHeight)return e.cachedTextHeight;if(null==Yl){Yl=n("pre");for(var i=0;i<49;++i)Yl.appendChild(document.createTextNode("x")),Yl.appendChild(n("br"));Yl.appendChild(document.createTextNode("x"))}r(e.measure,Yl);var o=Yl.offsetHeight/50;return o>3&&(e.cachedTextHeight=o),t(e.measure),o||1}function mr(e){if(null!=e.cachedCharWidth)return e.cachedCharWidth;var t=n("span","xxxxxxxxxx"),i=n("pre",[t]);r(e.measure,i);var o=t.getBoundingClientRect(),l=(o.right-o.left)/10;return l>2&&(e.cachedCharWidth=l),l||10}function yr(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:br(t),gutterTotalWidth:t.gutters.offsetWidth,gutterLeft:r,gutterWidth:n,wrapperWidth:t.wrapper.clientWidth}}function br(e){return e.scroller.getBoundingClientRect().left-e.sizer.getBoundingClientRect().left}function wr(e){var t=vr(e.display),r=e.options.lineWrapping,n=r&&Math.max(5,e.display.scroller.clientWidth/mr(e.display)-3);return function(i){if(he(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 xr(e){var t=e.doc,r=wr(e);t.iter(function(e){var t=r(e);t!=e.height&&N(e,t)})}function Cr(e,t,r,n){var i=e.display;if(!r&&"true"==Re(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=pr(e,o,l);if(n&&1==u.xRel&&(a=T(e.doc,u.line).text).length==u.ch){var f=c(a,a.length,e.options.tabSize)-a.length;u=H(u.line,Math.max(0,Math.round((o-Ut(e.display).left)/mr(e.display))-f))}return u}function Sr(e,t){if(t>=e.display.viewTo)return null;if(t-=e.display.viewFrom,t<0)return null;for(var r=e.display.view,n=0;n<r.length;n++)if(t-=r[n].size,t<0)return n}function Lr(e){e.display.input.showSelection(e.display.input.prepareSelection())}function Tr(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];if(!(s.from().line>=e.display.viewTo||s.to().line<e.display.viewFrom)){var a=s.empty();(a||e.options.showCursorWhenSelecting)&&Mr(e,s.head,i),a||kr(e,s,o)}}return n}function Mr(e,t,r){var i=fr(e,t,"div",null,null,!e.options.singleCursorHeightPerLine),o=r.appendChild(n("div"," ","CodeMirror-cursor"));if(o.style.left=i.left+"px",o.style.top=i.top+"px",o.style.height=Math.max(0,i.bottom-i.top)*e.options.cursorHeight+"px",i.other){var l=r.appendChild(n("div"," ","CodeMirror-cursor CodeMirror-secondarycursor"));l.style.display="",l.style.left=i.other.left+"px",l.style.top=i.other.top+"px",l.style.height=.85*(i.other.bottom-i.other.top)+"px"}}function kr(e,t,r){function i(e,t,r,i){t<0&&(t=0),t=Math.round(t),i=Math.round(i),a.appendChild(n("div",null,"CodeMirror-selected","position: absolute; left: "+e+"px;\n top: "+t+"px; width: "+(null==r?f-e:r)+"px;\n height: "+(i-t)+"px"))}function o(t,r,n){function o(r,n){return cr(e,H(t,r),"div",u,n)}var l,a,u=T(s,t),h=u.text.length;return me(ke(u),r||0,null==n?h:n,function(e,t,s){var u,d,p,g=o(e,"left");if(e==t)u=g,d=p=g.left;else{if(u=o(t-1,"right"),"rtl"==s){var v=g;g=u,u=v}d=g.left,p=u.right}null==r&&0==e&&(d=c),u.top-g.top>3&&(i(d,g.top,null,g.bottom),d=c,g.bottom<u.top&&i(d,g.bottom,null,u.top)),null==n&&t==h&&(p=f),(!l||g.top<l.top||g.top==l.top&&g.left<l.left)&&(l=g),(!a||u.bottom>a.bottom||u.bottom==a.bottom&&u.right>a.right)&&(a=u),d<c+1&&(d=c),i(d,u.top,p-d,u.bottom)}),{start:l,end:a}}var l=e.display,s=e.doc,a=document.createDocumentFragment(),u=Ut(e.display),c=u.left,f=Math.max(l.sizerWidth,Kt(e)-l.sizer.offsetLeft)-u.right,h=t.from(),d=t.to();if(h.line==d.line)o(h.line,h.ch,d.ch);else{var p=T(s,h.line),g=T(s,d.line),v=ae(p)==ae(g),m=o(h.line,h.ch,v?p.text.length+1:null).end,y=o(d.line,v?0:null,d.ch).start;v&&(m.top<y.top-2?(i(m.right,m.top,null,m.bottom),i(c,y.top,y.left,y.bottom)):i(m.right,m.top,y.left-m.right,m.bottom)),m.bottom<y.top&&i(c,m.bottom,null,y.top)}r.appendChild(a)}function Nr(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(){return t.cursorDiv.style.visibility=(r=!r)?"":"hidden"},e.options.cursorBlinkRate):e.options.cursorBlinkRate<0&&(t.cursorDiv.style.visibility="hidden")}}function Ar(e){e.state.focused||(e.display.input.focus(),Wr(e))}function Or(e){e.state.delayingBlurEvent=!0,setTimeout(function(){e.state.delayingBlurEvent&&(e.state.delayingBlurEvent=!1,Dr(e))},100)}function Wr(e,t){e.state.delayingBlurEvent&&(e.state.delayingBlurEvent=!1),"nocursor"!=e.options.readOnly&&(e.state.focused||(Oe(e,"focus",e,t),e.state.focused=!0,l(e.display.wrapper,"CodeMirror-focused"),e.curOp||e.display.selForContextMenu==e.doc.sel||(e.display.input.reset(),il&&setTimeout(function(){return e.display.input.reset(!0)},20)),e.display.input.receivedFocus()),Nr(e))}function Dr(e,t){e.state.delayingBlurEvent||(e.state.focused&&(Oe(e,"blur",e,t),e.state.focused=!1,wl(e.display.wrapper,"CodeMirror-focused")),clearInterval(e.display.blinker),setTimeout(function(){e.state.focused||(e.display.shift=!1)},150))}function Hr(e){var t=e.display,r=t.view;if(t.alignWidgets||t.gutters.firstChild&&e.options.fixedGutter){for(var n=br(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),r[l].gutterBackground&&(r[l].gutterBackground.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 Pr(e){if(!e.options.lineNumbers)return!1;var t=e.doc,r=D(e.options,t.first+t.size-1),i=e.display;if(r.length!=i.lineNumChars){var o=i.measure.appendChild(n("div",[n("div",r)],"CodeMirror-linenumber CodeMirror-gutter-elt")),l=o.firstChild.offsetWidth,s=o.offsetWidth-l;return i.lineGutter.style.width="",i.lineNumInnerWidth=Math.max(l,i.lineGutter.offsetWidth-s)+1,i.lineNumWidth=i.lineNumInnerWidth+s,i.lineNumChars=i.lineNumInnerWidth?r.length:-1,i.lineGutter.style.width=i.lineNumWidth+"px",Mn(e),!0}return!1}function Er(e){for(var t=e.display,r=t.lineDiv.offsetTop,n=0;n<t.view.length;n++){var i=t.view[n],o=void 0;if(!i.hidden){if(rl&&nl<8){var l=i.node.offsetTop+i.node.offsetHeight;o=l-r,r=l}else{var s=i.node.getBoundingClientRect();o=s.bottom-s.top}var a=i.line.height-o;if(o<2&&(o=vr(t)),(a>.001||a<-.001)&&(N(i.line,o),Ir(i.line),i.rest))for(var u=0;u<i.rest.length;u++)Ir(i.rest[u])}}}function Ir(e){if(e.widgets)for(var t=0;t<e.widgets.length;++t)e.widgets[t].height=e.widgets[t].node.parentNode.offsetHeight}function zr(e,t,r){var n=r&&null!=r.top?Math.max(0,r.top):e.scroller.scrollTop;n=Math.floor(n-Bt(e));var i=r&&null!=r.bottom?r.bottom:n+e.wrapper.clientHeight,o=O(t,n),l=O(t,i);if(r&&r.ensure){var s=r.ensure.from.line,a=r.ensure.to.line;s<o?(o=s,l=O(t,pe(T(t,s))+e.wrapper.clientHeight)):Math.min(a,t.lastLine())>=l&&(o=O(t,pe(T(t,a))-e.wrapper.clientHeight),l=a)}return{from:o,to:Math.max(l,o+1)}}function Fr(e,t){Math.abs(e.doc.scrollTop-t)<2||(e.doc.scrollTop=t,Jo||Ln(e,{top:t}),e.display.scroller.scrollTop!=t&&(e.display.scroller.scrollTop=t),e.display.scrollbars.setScrollTop(t),Jo&&Ln(e),bn(e,100))}function Rr(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,Hr(e),e.display.scroller.scrollLeft!=t&&(e.display.scroller.scrollLeft=t),e.display.scrollbars.setScrollLeft(t))}function Br(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}}function Gr(e){var t=Br(e);return t.x*=es,t.y*=es,t}function Ur(e,t){var r=Br(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&&dl&&il)e:for(var u=t.target,c=o.view;u!=l;u=u.parentNode)for(var f=0;f<c.length;f++)if(c[f].node==u){e.display.currentWheelTarget=u;break e}if(n&&!Jo&&!sl&&null!=es)return i&&a&&Fr(e,Math.max(0,Math.min(l.scrollTop+i*es,l.scrollHeight-l.clientHeight))),Rr(e,Math.max(0,Math.min(l.scrollLeft+n*es,l.scrollWidth-l.clientWidth))),(!i||i&&a)&&Ee(t),void(o.wheelStartX=null);if(i&&null!=es){var h=i*es,d=e.doc.scrollTop,p=d+o.wrapper.clientHeight;h<0?d=Math.max(0,d+h-50):p=Math.min(e.doc.height,p+h+50),Ln(e,{top:d,bottom:p})}Jl<20&&(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&&(es=(es*Jl+r)/(Jl+1),++Jl)}},200)):(o.wheelDX+=n,o.wheelDY+=i))}}function Vr(e){var t=e.display,r=t.gutters.offsetWidth,n=Math.round(e.doc.height+Gt(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+Vt(e)+t.barHeight,nativeBarWidth:t.nativeBarWidth,gutterWidth:r}}function Kr(e,t){t||(t=Vr(e));var r=e.display.barWidth,n=e.display.barHeight;jr(e,t);for(var i=0;i<4&&r!=e.display.barWidth||n!=e.display.barHeight;i++)r!=e.display.barWidth&&e.options.lineWrapping&&Er(e),jr(e,Vr(e)),r=e.display.barWidth,n=e.display.barHeight}function jr(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",r.heightForcer.style.borderBottom=n.bottom+"px solid transparent",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 Xr(e){e.display.scrollbars&&(e.display.scrollbars.clear(),e.display.scrollbars.addClass&&wl(e.display.wrapper,e.display.scrollbars.addClass)),e.display.scrollbars=new ns[e.options.scrollbarStyle](function(t){e.display.wrapper.insertBefore(t,e.display.scrollbarFiller),zl(t,"mousedown",function(){e.state.focused&&setTimeout(function(){return e.display.input.focus()},0)}),t.setAttribute("cm-not-content","true")},function(t,r){"horizontal"==r?Rr(e,t):Fr(e,t)},e),e.display.scrollbars.addClass&&l(e.display.wrapper,e.display.scrollbars.addClass)}function Yr(e,t){if(!We(e,"scrollCursorIntoView")){var r=e.display,i=r.sizer.getBoundingClientRect(),o=null;if(t.top+i.top<0?o=!0:t.bottom+i.top>(window.innerHeight||document.documentElement.clientHeight)&&(o=!1),null!=o&&!cl){var l=n("div","",null,"position: absolute;\n top: "+(t.top-r.viewOffset-Bt(e.display))+"px;\n height: "+(t.bottom-t.top+Vt(e)+r.barHeight)+"px;\n left: "+t.left+"px; width: 2px;");e.display.lineSpace.appendChild(l),l.scrollIntoView(o),e.display.lineSpace.removeChild(l)}}}function _r(e,t,r,n){null==n&&(n=0);for(var i,o=0;o<5;o++){var l=!1;i=fr(e,t);var s=r&&r!=t?fr(e,r):i,a=qr(e,Math.min(i.left,s.left),Math.min(i.top,s.top)-n,Math.max(i.left,s.left),Math.max(i.bottom,s.bottom)+n),u=e.doc.scrollTop,c=e.doc.scrollLeft;if(null!=a.scrollTop&&(Fr(e,a.scrollTop),Math.abs(e.doc.scrollTop-u)>1&&(l=!0)),null!=a.scrollLeft&&(Rr(e,a.scrollLeft),Math.abs(e.doc.scrollLeft-c)>1&&(l=!0)),!l)break}return i}function $r(e,t,r,n,i){var o=qr(e,t,r,n,i);null!=o.scrollTop&&Fr(e,o.scrollTop),null!=o.scrollLeft&&Rr(e,o.scrollLeft)}function qr(e,t,r,n,i){var o=e.display,l=vr(e.display);r<0&&(r=0);var s=e.curOp&&null!=e.curOp.scrollTop?e.curOp.scrollTop:o.scroller.scrollTop,a=jt(e),u={};i-r>a&&(i=r+a);var c=e.doc.height+Gt(o),f=r<l,h=i>c-l;if(r<s)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=Kt(e)-(e.options.fixedGutter?o.gutters.offsetWidth:0),v=n-t>g;return v&&(n=t+g),t<10?u.scrollLeft=0:t<p?u.scrollLeft=Math.max(0,t-(v?0:10)):n>g+p-3&&(u.scrollLeft=n+(v?0:10)-g),u}function Zr(e,t,r){null==t&&null==r||Jr(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 Qr(e){Jr(e);var t=e.getCursor(),r=t,n=t;e.options.lineWrapping||(r=t.ch?H(t.line,t.ch-1):t,n=H(t.line,t.ch+1)),e.curOp.scrollToPos={from:r,to:n,margin:e.options.cursorScrollMargin,isCursor:!0}}function Jr(e){var t=e.curOp.scrollToPos;if(t){e.curOp.scrollToPos=null;var r=hr(e,t.from),n=hr(e,t.to),i=qr(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 en(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:++is},xt(e.curOp)}function tn(e){var t=e.curOp;St(t,function(e){for(var t=0;t<e.ops.length;t++)e.ops[t].cm.curOp=null;rn(e)})}function rn(e){for(var t=e.ops,r=0;r<t.length;r++)nn(t[r]);for(var n=0;n<t.length;n++)on(t[n]);for(var i=0;i<t.length;i++)ln(t[i]);for(var o=0;o<t.length;o++)sn(t[o]);for(var l=0;l<t.length;l++)an(t[l])}function nn(e){var t=e.cm,r=t.display;xn(t),e.updateMaxLine&&ve(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 os(t,e.mustUpdate&&{top:e.scrollTop,ensure:e.scrollToPos},e.forceUpdate)}function on(e){e.updatedDisplay=e.mustUpdate&&Cn(e.cm,e.update)}function ln(e){var t=e.cm,r=t.display;e.updatedDisplay&&Er(t),e.barMeasure=Vr(t),r.maxLineChanged&&!t.options.lineWrapping&&(e.adjustWidthTo=$t(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+Vt(t)+t.display.barWidth),e.maxScrollLeft=Math.max(0,r.sizer.offsetLeft+e.adjustWidthTo-Kt(t))),(e.updatedDisplay||e.selectionChanged)&&(e.preparedSelection=r.input.prepareSelection(e.focus))}function sn(e){var t=e.cm;null!=e.adjustWidthTo&&(t.display.sizer.style.minWidth=e.adjustWidthTo+"px",e.maxScrollLeft<t.doc.scrollLeft&&Rr(t,Math.min(t.display.scroller.scrollLeft,e.maxScrollLeft),!0),t.display.maxLineChanged=!1);var r=e.focus&&e.focus==o()&&(!document.hasFocus||document.hasFocus());e.preparedSelection&&t.display.input.showSelection(e.preparedSelection,r),(e.updatedDisplay||e.startHeight!=t.doc.height)&&Kr(t,e.barMeasure),e.updatedDisplay&&kn(t,e.barMeasure),e.selectionChanged&&Nr(t),t.state.focused&&e.updateInput&&t.display.input.reset(e.typing),r&&Ar(e.cm)}function an(e){var t=e.cm,r=t.display,n=t.doc;if(e.updatedDisplay&&Sn(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-r.scroller.clientWidth,e.scrollLeft)),r.scrollbars.setScrollLeft(n.scrollLeft),r.scroller.scrollLeft=n.scrollLeft,Hr(t)),e.scrollToPos){var i=_r(t,R(n,e.scrollToPos.from),R(n,e.scrollToPos.to),e.scrollToPos.margin);e.scrollToPos.isCursor&&t.state.focused&&Yr(t,i)}var o=e.maybeHiddenMarkers,l=e.maybeUnhiddenMarkers;if(o)for(var s=0;s<o.length;++s)o[s].lines.length||Oe(o[s],"hide");if(l)for(var a=0;a<l.length;++a)l[a].lines.length&&Oe(l[a],"unhide");r.wrapper.offsetHeight&&(n.scrollTop=t.display.scroller.scrollTop),e.changeObjs&&Oe(t,"changes",t,e.changeObjs),e.update&&e.update.finish()}function un(e,t){if(e.curOp)return t();en(e);try{return t()}finally{tn(e)}}function cn(e,t){return function(){if(e.curOp)return t.apply(e,arguments);en(e);try{return t.apply(e,arguments)}finally{tn(e)}}}function fn(e){return function(){if(this.curOp)return e.apply(this,arguments);en(this);try{return e.apply(this,arguments)}finally{tn(this)}}}function hn(e){return function(){var t=this.cm;if(!t||t.curOp)return e.apply(this,arguments);en(t);try{return e.apply(this,arguments)}finally{tn(t)}}}function dn(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)Hl&&ce(e.doc,t)<i.viewTo&&gn(e);else if(r<=i.viewFrom)Hl&&fe(e.doc,r+n)>i.viewFrom?gn(e):(i.viewFrom+=n,i.viewTo+=n);else if(t<=i.viewFrom&&r>=i.viewTo)gn(e);else if(t<=i.viewFrom){var o=vn(e,r,r+n,1);o?(i.view=i.view.slice(o.index),i.viewFrom=o.lineN,i.viewTo+=n):gn(e)}else if(r>=i.viewTo){var l=vn(e,t,t,-1);l?(i.view=i.view.slice(0,l.index),i.viewTo=l.lineN):gn(e)}else{var s=vn(e,t,t,-1),a=vn(e,r,r+n,1);s&&a?(i.view=i.view.slice(0,s.index).concat(wt(e,s.lineN,a.lineN)).concat(i.view.slice(a.index)),i.viewTo+=n):gn(e)}var u=i.externalMeasured;u&&(r<u.lineN?u.lineN+=n:t<u.lineN+u.size&&(i.externalMeasured=null))}function pn(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[Sr(e,t)];if(null!=o.node){var l=o.changes||(o.changes=[]);h(l,r)==-1&&l.push(r)}}}function gn(e){e.display.viewFrom=e.display.viewTo=e.doc.first,e.display.view=[],e.display.viewOffset=0}function vn(e,t,r,n){var i,o=Sr(e,t),l=e.display.view;if(!Hl||r==e.doc.first+e.doc.size)return{index:o,lineN:r};for(var s=e.display.viewFrom,a=0;a<o;a++)s+=l[a].size;if(s!=t){if(n>0){if(o==l.length-1)return null;i=s+l[o].size-t,o++}else i=s-t;t+=i,r+=i}for(;ce(e.doc,r)!=r;){if(o==(n<0?0:l.length-1))return null;r+=n*l[o-(n<0?1:0)].size,o+=n}return{index:o,lineN:r}}function mn(e,t,r){var n=e.display,i=n.view;0==i.length||t>=n.viewTo||r<=n.viewFrom?(n.view=wt(e,t,r),n.viewFrom=t):(n.viewFrom>t?n.view=wt(e,t,n.viewFrom).concat(n.view):n.viewFrom<t&&(n.view=n.view.slice(Sr(e,t))),n.viewFrom=t,n.viewTo<r?n.view=n.view.concat(wt(e,n.viewTo,r)):n.viewTo>r&&(n.view=n.view.slice(0,Sr(e,r)))),n.viewTo=r}function yn(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 bn(e,t){e.doc.mode.startState&&e.doc.frontier<e.display.viewTo&&e.state.highlight.set(t,a(wn,e))}function wn(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=$e(t.mode,et(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=Qe(e,o,s?$e(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 f=!l||l.length!=o.styles.length||u!=c&&(!u||!c||u.bgClass!=c.bgClass||u.textClass!=c.textClass),h=0;!f&&h<l.length;++h)f=l[h]!=o.styles[h];f&&i.push(t.frontier),o.stateAfter=s?n:$e(t.mode,n)}else o.text.length<=e.options.maxHighlightLength&&tt(e,o.text,n),o.stateAfter=t.frontier%5==0?$e(t.mode,n):null;if(++t.frontier,+new Date>r)return bn(e,e.options.workDelay),!0}),i.length&&un(e,function(){for(var t=0;t<i.length;t++)pn(e,i[t],"text")})}}function xn(e){var t=e.display;!t.scrollbarsClipped&&t.scroller.offsetWidth&&(t.nativeBarWidth=t.scroller.offsetWidth-t.scroller.clientWidth,t.heightForcer.style.height=Vt(e)+"px",t.sizer.style.marginBottom=-t.nativeBarWidth+"px",t.sizer.style.borderRightWidth=Vt(e)+"px",t.scrollbarsClipped=!0)}function Cn(e,r){var n=e.display,i=e.doc;if(r.editorIsHidden)return gn(e),!1;if(!r.force&&r.visible.from>=n.viewFrom&&r.visible.to<=n.viewTo&&(null==n.updateLineNumbers||n.updateLineNumbers>=n.viewTo)&&n.renderedView==n.view&&0==yn(e))return!1;Pr(e)&&(gn(e),r.dims=yr(e));var l=i.first+i.size,s=Math.max(r.visible.from-e.options.viewportMargin,i.first),a=Math.min(l,r.visible.to+e.options.viewportMargin);n.viewFrom<s&&s-n.viewFrom<20&&(s=Math.max(i.first,n.viewFrom)),n.viewTo>a&&n.viewTo-a<20&&(a=Math.min(l,n.viewTo)),Hl&&(s=ce(e.doc,s),a=fe(e.doc,a));var u=s!=n.viewFrom||a!=n.viewTo||n.lastWrapHeight!=r.wrapperHeight||n.lastWrapWidth!=r.wrapperWidth;mn(e,s,a),n.viewOffset=pe(T(e.doc,n.viewFrom)),e.display.mover.style.top=n.viewOffset+"px";var c=yn(e);if(!u&&0==c&&!r.force&&n.renderedView==n.view&&(null==n.updateLineNumbers||n.updateLineNumbers>=n.viewTo))return!1;var f=o();return c>4&&(n.lineDiv.style.display="none"),Tn(e,n.updateLineNumbers,r.dims),c>4&&(n.lineDiv.style.display=""),n.renderedView=n.view,f&&o()!=f&&f.offsetHeight&&f.focus(),t(n.cursorDiv),t(n.selectionDiv),n.gutters.style.height=n.sizer.style.minHeight=0,u&&(n.lastWrapHeight=r.wrapperHeight,n.lastWrapWidth=r.wrapperWidth,bn(e,400)),n.updateLineNumbers=null,!0}function Sn(e,t){for(var r=t.viewport,n=!0;(n&&e.options.lineWrapping&&t.oldDisplayWidth!=Kt(e)||(r&&null!=r.top&&(r={top:Math.min(e.doc.height+Gt(e.display)-jt(e),r.top)}),t.visible=zr(e.display,e.doc,r),!(t.visible.from>=e.display.viewFrom&&t.visible.to<=e.display.viewTo)))&&Cn(e,t);n=!1){Er(e);var i=Vr(e);Lr(e),Kr(e,i),kn(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 Ln(e,t){var r=new os(e,t);if(Cn(e,r)){Er(e),Sn(e,r);var n=Vr(e);Lr(e),Kr(e,n),kn(e,n),r.finish()}}function Tn(e,r,n){function i(t){var r=t.nextSibling;return il&&dl&&e.display.currentWheelTarget==t?t.style.display="none":t.parentNode.removeChild(t),r}for(var o=e.display,l=e.options.lineNumbers,s=o.lineDiv,a=s.firstChild,u=o.view,c=o.viewFrom,f=0;f<u.length;f++){var d=u[f];if(d.hidden);else if(d.node&&d.node.parentNode==s){for(;a!=d.node;)a=i(a);var p=l&&null!=r&&r<=c&&d.lineNumber;d.changes&&(h(d.changes,"gutter")>-1&&(p=!1),Mt(e,d,c,n)),p&&(t(d.lineNumber),d.lineNumber.appendChild(document.createTextNode(D(e.options,c)))),a=d.node.nextSibling}else{var g=Pt(e,d,c,n);s.insertBefore(g,a)}c+=d.size}for(;a;)a=i(a)}function Mn(e){var t=e.display.gutters.offsetWidth;e.display.sizer.style.marginLeft=t+"px"}function kn(e,t){e.display.sizer.style.minHeight=t.docHeight+"px",e.display.heightForcer.style.top=t.docHeight+"px",e.display.gutters.style.height=t.docHeight+e.display.barHeight+Vt(e)+"px"}function Nn(e){var r=e.display.gutters,i=e.options.gutters;t(r);for(var o=0;o<i.length;++o){var l=i[o],s=r.appendChild(n("div",null,"CodeMirror-gutter "+l));"CodeMirror-linenumbers"==l&&(e.display.lineGutter=s,s.style.width=(e.display.lineNumWidth||1)+"px")}r.style.display=o?"":"none",Mn(e)}function An(e){var t=h(e.gutters,"CodeMirror-linenumbers");t==-1&&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 On(e,t){this.ranges=e,this.primIndex=t}function Wn(e,t){this.anchor=e,this.head=t}function Dn(e,t){var r=e[t];e.sort(function(e,t){return P(e.from(),t.from())}),t=h(e,r);for(var n=1;n<e.length;n++){var i=e[n],o=e[n-1];if(P(o.to(),i.from())>=0){var l=z(o.from(),i.from()),s=I(o.to(),i.to()),a=o.empty()?i.from()==i.head:o.from()==o.head;n<=t&&--t,e.splice(--n,2,new Wn(a?s:l,a?l:s))}}return new On(e,t)}function Hn(e,t){return new On([new Wn(e,t||e)],0)}function Pn(e){return e.text?H(e.from.line+e.text.length-1,g(e.text).length+(1==e.text.length?e.from.ch:0)):e.to}function En(e,t){if(P(e,t.from)<0)return e;if(P(e,t.to)<=0)return Pn(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+=Pn(t).ch-t.to.ch),H(r,n)}function In(e,t){for(var r=[],n=0;n<e.sel.ranges.length;n++){var i=e.sel.ranges[n];r.push(new Wn(En(i.anchor,t),En(i.head,t)))}return Dn(r,e.sel.primIndex)}function zn(e,t,r){return e.line==t.line?H(r.line,e.ch-t.ch+r.ch):H(r.line+(e.line-t.line),e.ch)}function Fn(e,t,r){for(var n=[],i=H(e.first,0),o=i,l=0;l<t.length;l++){var s=t[l],a=zn(s.from,i,o),u=zn(Pn(s),i,o);if(i=s.to,o=u,"around"==r){var c=e.sel.ranges[l],f=P(c.head,c.anchor)<0;n[l]=new Wn(f?u:a,f?a:u)}else n[l]=new Wn(a,a)}return new On(n,e.sel.primIndex)}function Rn(e){e.doc.mode=Ye(e.options,e.doc.modeOption),Bn(e)}function Bn(e){e.doc.iter(function(e){e.stateAfter&&(e.stateAfter=null),e.styles&&(e.styles=null)}),e.doc.frontier=e.doc.first,bn(e,100),e.state.modeGen++,e.curOp&&dn(e)}function Gn(e,t){return 0==t.from.ch&&0==t.to.ch&&""==g(t.text)&&(!e.cm||e.cm.options.wholeLineUpdateBefore)}function Un(e,t,r,n){function i(e){return r?r[e]:null}function o(e,r,i){ut(e,r,i,n),Lt(e,"change",e,t)}function l(e,t){for(var r=[],o=e;o<t;++o)r.push(new at(u[o],i(o),n));return r}var s=t.from,a=t.to,u=t.text,c=T(e,s.line),f=T(e,a.line),h=g(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(Gn(e,t)){var v=l(0,u.length-1);o(f,f.text,d),p&&e.remove(s.line,p),v.length&&e.insert(s.line,v)}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 m=l(1,u.length-1);m.push(new at(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,m)}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 y=l(1,u.length-1);p>1&&e.remove(s.line+1,p-1),e.insert(s.line+1,y)}Lt(e,"change",e,t)}function Vn(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 Kn(e,t){if(t.cm)throw new Error("This document is already in use.");e.doc=t,t.cm=e,xr(e),Rn(e),e.options.lineWrapping||ve(e),e.options.mode=t.modeOption,dn(e)}function jn(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 Xn(e,t){var r={from:E(t.from),to:Pn(t),text:M(e,t.from,t.to)};return Jn(e,r,t.from.line,t.to.line+1),Vn(e,function(e){return Jn(e,r,t.from.line,t.to.line+1)},!0),r}function Yn(e){for(;e.length;){var t=g(e);if(!t.ranges)break;e.pop()}}function _n(e,t){return t?(Yn(e.done),g(e.done)):e.done.length&&!g(e.done).ranges?g(e.done):e.done.length>1&&!e.done[e.done.length-2].ranges?(e.done.pop(),g(e.done)):void 0}function $n(e,t,r,n){var i=e.history;i.undone.length=0;var o,l,s=+new Date;if((i.lastOp==n||i.lastOrigin==t.origin&&t.origin&&("+"==t.origin.charAt(0)&&e.cm&&i.lastModTime>s-e.cm.options.historyEventDelay||"*"==t.origin.charAt(0)))&&(o=_n(i,i.lastOp==n)))l=g(o.changes),0==P(t.from,t.to)&&0==P(t.from,l.to)?l.to=Pn(t):o.changes.push(Xn(e,t));else{var a=g(i.done);for(a&&a.ranges||Qn(e.sel,i.done),
|
3 |
-
o={changes:[Xn(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=s,i.lastOp=i.lastSelOp=n,i.lastOrigin=i.lastSelOrigin=t.origin,l||Oe(e,"historyAdded")}function qn(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 Zn(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||qn(e,o,g(i.done),t))?i.done[i.done.length-1]=t:Qn(t,i.done),i.lastSelTime=+new Date,i.lastSelOrigin=o,i.lastSelOp=r,n&&n.clearRedo!==!1&&Yn(i.undone)}function Qn(e,t){var r=g(t);r&&r.ranges&&r.equals(e)||t.push(e)}function Jn(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 ei(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 ti(e,t){var r=t["spans_"+e.id];if(!r)return null;for(var n=[],i=0;i<t.text.length;++i)n.push(ei(r[i]));return n}function ri(e,t){var r=ti(e,t),n=q(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 ni(e,t,r){for(var n=[],i=0;i<e.length;++i){var o=e[i];if(o.ranges)n.push(r?On.prototype.deepCopy.call(o):o);else{var l=o.changes,s=[];n.push({changes:s});for(var a=0;a<l.length;++a){var u=l[a],c=void 0;if(s.push({from:u.from,to:u.to,text:u.text}),t)for(var f in u)(c=f.match(/^spans_(\d+)$/))&&h(t,Number(c[1]))>-1&&(g(s)[f]=u[f],delete u[f])}}}return n}function ii(e,t,r,n){if(e.cm&&e.cm.display.shift||e.extend){var i=t.anchor;if(n){var o=P(r,i)<0;o!=P(n,i)<0?(i=r,r=n):o!=P(r,n)<0&&(r=n)}return new Wn(i,r)}return new Wn(n||r,r)}function oi(e,t,r,n){fi(e,new On([ii(e,e.sel.primary(),t,r)],0),n)}function li(e,t,r){for(var n=[],i=0;i<e.sel.ranges.length;i++)n[i]=ii(e,e.sel.ranges[i],t[i],null);var o=Dn(n,e.sel.primIndex);fi(e,o,r)}function si(e,t,r,n){var i=e.sel.ranges.slice(0);i[t]=r,fi(e,Dn(i,e.sel.primIndex),n)}function ai(e,t,r,n){fi(e,Hn(t,r),n)}function ui(e,t,r){var n={ranges:t.ranges,update:function(t){var r=this;this.ranges=[];for(var n=0;n<t.length;n++)r.ranges[n]=new Wn(R(e,t[n].anchor),R(e,t[n].head))},origin:r&&r.origin};return Oe(e,"beforeSelectionChange",e,n),e.cm&&Oe(e.cm,"beforeSelectionChange",e.cm,n),n.ranges!=t.ranges?Dn(n.ranges,n.ranges.length-1):t}function ci(e,t,r){var n=e.history.done,i=g(n);i&&i.ranges?(n[n.length-1]=t,hi(e,t,r)):fi(e,t,r)}function fi(e,t,r){hi(e,t,r),Zn(e,e.sel,e.cm?e.cm.curOp.id:NaN,r)}function hi(e,t,r){(He(e,"beforeSelectionChange")||e.cm&&He(e.cm,"beforeSelectionChange"))&&(t=ui(e,t,r));var n=r&&r.bias||(P(t.primary().head,e.sel.primary().head)<0?-1:1);di(e,gi(e,t,n,!0)),r&&r.scroll===!1||!e.cm||Qr(e.cm)}function di(e,t){t.equals(e.sel)||(e.sel=t,e.cm&&(e.cm.curOp.updateInput=e.cm.curOp.selectionChanged=!0,De(e.cm)),Lt(e,"cursorActivity",e))}function pi(e){di(e,gi(e,e.sel,null,!1),Ml)}function gi(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=mi(e,l.anchor,s&&s.anchor,r,n),u=mi(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 Wn(a,u))}return i?Dn(i,t.primIndex):t}function vi(e,t,r,n,i){var o=T(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&&(Oe(a,"beforeCursorEnter"),a.explicitlyCleared)){if(o.markedSpans){--l;continue}break}if(!a.atomic)continue;if(r){var u=a.find(n<0?1:-1),c=void 0;if((n<0?a.inclusiveRight:a.inclusiveLeft)&&(u=yi(e,u,-n,u&&u.line==t.line?o:null)),u&&u.line==t.line&&(c=P(u,r))&&(n<0?c<0:c>0))return vi(e,u,t,n,i)}var f=a.find(n<0?-1:1);return(n<0?a.inclusiveLeft:a.inclusiveRight)&&(f=yi(e,f,n,f.line==t.line?o:null)),f?vi(e,f,t,n,i):null}}return t}function mi(e,t,r,n,i){var o=n||1,l=vi(e,t,r,o,i)||!i&&vi(e,t,r,o,!0)||vi(e,t,r,-o,i)||!i&&vi(e,t,r,-o,!0);return l?l:(e.cantEdit=!0,H(e.first,0))}function yi(e,t,r,n){return r<0&&0==t.ch?t.line>e.first?R(e,H(t.line-1)):null:r>0&&t.ch==(n||T(e,t.line)).text.length?t.line<e.first+e.size-1?H(t.line+1,0):null:new H(t.line,t.ch+r)}function bi(e){e.setSelection(H(e.firstLine(),0),H(e.lastLine()),Ml)}function wi(e,t,r){var n={canceled:!1,from:t.from,to:t.to,text:t.text,origin:t.origin,cancel:function(){return n.canceled=!0}};return r&&(n.update=function(t,r,i,o){t&&(n.from=R(e,t)),r&&(n.to=R(e,r)),i&&(n.text=i),void 0!==o&&(n.origin=o)}),Oe(e,"beforeChange",e,n),e.cm&&Oe(e.cm,"beforeChange",e.cm,n),n.canceled?null:{from:n.from,to:n.to,text:n.text,origin:n.origin}}function xi(e,t,r){if(e.cm){if(!e.cm.curOp)return cn(e.cm,xi)(e,t,r);if(e.cm.state.suppressEdits)return}if(!(He(e,"beforeChange")||e.cm&&He(e.cm,"beforeChange"))||(t=wi(e,t,!0))){var n=Dl&&!r&&Q(e,t.from,t.to);if(n)for(var i=n.length-1;i>=0;--i)Ci(e,{from:n[i].from,to:n[i].to,text:i?[""]:t.text});else Ci(e,t)}}function Ci(e,t){if(1!=t.text.length||""!=t.text[0]||0!=P(t.from,t.to)){var r=In(e,t);$n(e,t,r,e.cm?e.cm.curOp.id:NaN),Ti(e,t,r,q(e,t));var n=[];Vn(e,function(e,r){r||h(n,e.history)!=-1||(Oi(e.history,t),n.push(e.history)),Ti(e,t,null,q(e,t))})}}function Si(e,t,r){if(!e.cm||!e.cm.state.suppressEdits||r){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(Qn(n,s),r&&!n.equals(e.sel))return void fi(e,n,{clearRedo:!1});o=n}var u=[];Qn(o,s),s.push({changes:u,generation:i.generation}),i.generation=n.generation||++i.maxGeneration;for(var c=He(e,"beforeChange")||e.cm&&He(e.cm,"beforeChange"),f=function(r){var i=n.changes[r];if(i.origin=t,c&&!wi(e,i,!1))return l.length=0,{};u.push(Xn(e,i));var o=r?In(e,i):g(l);Ti(e,i,o,ri(e,i)),!r&&e.cm&&e.cm.scrollIntoView({from:i.from,to:Pn(i)});var s=[];Vn(e,function(e,t){t||h(s,e.history)!=-1||(Oi(e.history,i),s.push(e.history)),Ti(e,i,null,ri(e,i))})},d=n.changes.length-1;d>=0;--d){var p=f(d);if(p)return p.v}}}}function Li(e,t){if(0!=t&&(e.first+=t,e.sel=new On(v(e.sel.ranges,function(e){return new Wn(H(e.anchor.line+t,e.anchor.ch),H(e.head.line+t,e.head.ch))}),e.sel.primIndex),e.cm)){dn(e.cm,e.first,e.first-t,t);for(var r=e.cm.display,n=r.viewFrom;n<r.viewTo;n++)pn(e.cm,n,"gutter")}}function Ti(e,t,r,n){if(e.cm&&!e.cm.curOp)return cn(e.cm,Ti)(e,t,r,n);if(t.to.line<e.first)return void Li(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);Li(e,i),t={from:H(e.first,0),to:H(t.to.line+i,t.to.ch),text:[g(t.text)],origin:t.origin}}var o=e.lastLine();t.to.line>o&&(t={from:t.from,to:H(o,T(e,o).text.length),text:[t.text[0]],origin:t.origin}),t.removed=M(e,t.from,t.to),r||(r=In(e,t)),e.cm?Mi(e.cm,t,n):Un(e,t,n),hi(e,r,Ml)}}function Mi(e,t,r){var n=e.doc,i=e.display,o=t.from,l=t.to,s=!1,a=o.line;e.options.lineWrapping||(a=A(ae(T(n,o.line))),n.iter(a,l.line+1,function(e){if(e==i.maxLine)return s=!0,!0})),n.sel.contains(t.from,t.to)>-1&&De(e),Un(n,t,r,wr(e)),e.options.lineWrapping||(n.iter(a,o.line+t.text.length,function(e){var t=ge(e);t>i.maxLineLength&&(i.maxLine=e,i.maxLineLength=t,i.maxLineChanged=!0,s=!1)}),s&&(e.curOp.updateMaxLine=!0)),n.frontier=Math.min(n.frontier,o.line),bn(e,400);var u=t.text.length-(l.line-o.line)-1;t.full?dn(e):o.line!=l.line||1!=t.text.length||Gn(e.doc,t)?dn(e,o.line,l.line+1,u):pn(e,o.line,"text");var c=He(e,"changes"),f=He(e,"change");if(f||c){var h={from:o,to:l,text:t.text,removed:t.removed,origin:t.origin};f&&Lt(e,"change",e,h),c&&(e.curOp.changeObjs||(e.curOp.changeObjs=[])).push(h)}e.display.selForContextMenu=null}function ki(e,t,r,n,i){if(n||(n=r),P(n,r)<0){var o=n;n=r,r=o}"string"==typeof t&&(t=e.splitLines(t)),xi(e,{from:r,to:n,text:t,origin:i})}function Ni(e,t,r,n){r<e.line?e.line+=n:t<e.line&&(e.line=t,e.ch=0)}function Ai(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++)Ni(o.ranges[s].anchor,t,r,n),Ni(o.ranges[s].head,t,r,n)}else{for(var a=0;a<o.changes.length;++a){var u=o.changes[a];if(r<u.from.line)u.from=H(u.from.line+n,u.from.ch),u.to=H(u.to.line+n,u.to.ch);else if(t<=u.to.line){l=!1;break}}l||(e.splice(0,i+1),i=0)}}}function Oi(e,t){var r=t.from.line,n=t.to.line,i=t.text.length-(n-r)-1;Ai(e.done,r,n,i),Ai(e.undone,r,n,i)}function Wi(e,t,r,n){var i=t,o=t;return"number"==typeof t?o=T(e,F(e,t)):i=A(t),null==i?null:(n(o,i)&&e.cm&&pn(e.cm,i,r),o)}function Di(e){var t=this;this.lines=e,this.parent=null;for(var r=0,n=0;n<e.length;++n)e[n].parent=t,r+=e[n].height;this.height=r}function Hi(e){var t=this;this.children=e;for(var r=0,n=0,i=0;i<e.length;++i){var o=e[i];r+=o.chunkSize(),n+=o.height,o.parent=t}this.size=r,this.height=n,this.parent=null}function Pi(e,t,r){var n=this;if(r)for(var i in r)r.hasOwnProperty(i)&&(n[i]=r[i]);this.doc=e,this.node=t}function Ei(e,t,r){pe(t)<(e.curOp&&e.curOp.scrollTop||e.doc.scrollTop)&&Zr(e,null,r)}function Ii(e,t,r,n){var i=new Pi(e,r,n),o=e.cm;return o&&i.noHScroll&&(o.display.alignWidgets=!0),Wi(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&&!he(e,t)){var n=pe(t)<e.scrollTop;N(t,t.height+Ft(i)),n&&Zr(o,null,i.height),o.curOp.forceUpdate=!0}return!0}),i}function zi(e,t){this.lines=[],this.type=t,this.doc=e,this.id=++ls}function Fi(e,t,r,i,o){if(i&&i.shared)return Bi(e,t,r,i,o);if(e.cm&&!e.cm.curOp)return cn(e.cm,Fi)(e,t,r,i,o);var l=new zi(e,o),s=P(t,r);if(i&&u(i,l,!1),s>0||0==s&&l.clearWhenEmpty!==!1)return l;if(l.replacedWith&&(l.collapsed=!0,l.widgetNode=n("span",[l.replacedWith],"CodeMirror-widget"),l.widgetNode.setAttribute("role","presentation"),i.handleMouseEvents||l.widgetNode.setAttribute("cm-ignore-events","true"),i.insertLeft&&(l.widgetNode.insertLeft=!0)),l.collapsed){if(se(e,t.line,t,r,l)||t.line!=r.line&&se(e,r.line,t,r,l))throw new Error("Inserting collapsed marker partially overlapping an existing one");V()}l.addToHistory&&$n(e,{from:t,to:r,origin:"markText"},e.sel,NaN);var a,c=t.line,f=e.cm;if(e.iter(c,r.line+1,function(e){f&&l.collapsed&&!f.options.lineWrapping&&ae(e)==f.display.maxLine&&(a=!0),l.collapsed&&c!=t.line&&N(e,0),Y(e,new K(l,c==t.line?t.ch:null,c==r.line?r.ch:null)),++c}),l.collapsed&&e.iter(t.line,r.line+1,function(t){he(e,t)&&N(t,0)}),l.clearOnEnter&&zl(l,"beforeCursorEnter",function(){return l.clear()}),l.readOnly&&(U(),(e.history.done.length||e.history.undone.length)&&e.clearHistory()),l.collapsed&&(l.id=++ls,l.atomic=!0),f){if(a&&(f.curOp.updateMaxLine=!0),l.collapsed)dn(f,t.line,r.line+1);else if(l.className||l.title||l.startStyle||l.endStyle||l.css)for(var h=t.line;h<=r.line;h++)pn(f,h,"text");l.atomic&&pi(f.doc),Lt(f,"markerAdded",f,l)}return l}function Ri(e,t){var r=this;this.markers=e,this.primary=t;for(var n=0;n<e.length;++n)e[n].parent=r}function Bi(e,t,r,n,i){n=u(n),n.shared=!1;var o=[Fi(e,t,r,n,i)],l=o[0],s=n.widgetNode;return Vn(e,function(e){s&&(n.widgetNode=s.cloneNode(!0)),o.push(Fi(e,R(e,t),R(e,r),n,i));for(var a=0;a<e.linked.length;++a)if(e.linked[a].isParent)return;l=g(o)}),new Ri(o,l)}function Gi(e){return e.findMarks(H(e.first,0),e.clipPos(H(e.lastLine())),function(e){return e.parent})}function Ui(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(P(o,l)){var s=Fi(e,o,l,n.primary,n.primary.type);n.markers.push(s),s.parent=n}}}function Vi(e){for(var t=function(t){var r=e[t],n=[r.primary.doc];Vn(r.primary.doc,function(e){return n.push(e)});for(var i=0;i<r.markers.length;i++){var o=r.markers[i];h(n,o.doc)==-1&&(o.parent=null,r.markers.splice(i--,1))}},r=0;r<e.length;r++)t(r)}function Ki(e){var t=this;if(Yi(t),!We(t,e)&&!Rt(t.display,e)){Ee(e),rl&&(us=+new Date);var r=Cr(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||h(t.options.allowDropFileTypes,e.type)!=-1){var s=new FileReader;s.onload=cn(t,function(){var e=s.result;if(/[\x00-\x08\x0e-\x1f]{2}/.test(e)&&(e=""),o[n]=e,++l==i){r=R(t.doc,r);var a={from:r,to:r,text:t.doc.splitLines(o.join(t.doc.lineSeparator())),origin:"paste"};xi(t.doc,a),ci(t.doc,Hn(r,Pn(a)))}}),s.readAsText(e)}},a=0;a<i;++a)s(n[a],a);else{if(t.state.draggingText&&t.doc.sel.contains(r)>-1)return t.state.draggingText(e),void setTimeout(function(){return t.display.input.focus()},20);try{var u=e.dataTransfer.getData("Text");if(u){var c;if(t.state.draggingText&&!t.state.draggingText.copy&&(c=t.listSelections()),hi(t.doc,Hn(r,r)),c)for(var f=0;f<c.length;++f)ki(t.doc,"",c[f].anchor,c[f].head,"drag");t.replaceSelection(u,"around","paste"),t.display.input.focus()}}catch(e){}}}}function ji(e,t){if(rl&&(!e.state.draggingText||+new Date-us<100))return void Fe(t);if(!We(e,t)&&!Rt(e.display,t)&&(t.dataTransfer.setData("Text",e.getSelection()),t.dataTransfer.effectAllowed="copyMove",t.dataTransfer.setDragImage&&!al)){var r=n("img",null,null,"position: fixed; left: 0; top: 0;");r.src="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==",sl&&(r.width=r.height=1,e.display.wrapper.appendChild(r),r._top=r.offsetTop),t.dataTransfer.setDragImage(r,0,0),sl&&r.parentNode.removeChild(r)}}function Xi(e,t){var i=Cr(e,t);if(i){var o=document.createDocumentFragment();Mr(e,i,o),e.display.dragCursor||(e.display.dragCursor=n("div",null,"CodeMirror-cursors CodeMirror-dragcursors"),e.display.lineSpace.insertBefore(e.display.dragCursor,e.display.cursorDiv)),r(e.display.dragCursor,o)}}function Yi(e){e.display.dragCursor&&(e.display.lineSpace.removeChild(e.display.dragCursor),e.display.dragCursor=null)}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(){cs||(qi(),cs=!0)}function qi(){var e;zl(window,"resize",function(){null==e&&(e=setTimeout(function(){e=null,_i(Zi)},100))}),zl(window,"blur",function(){return _i(Dr)})}function Zi(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 Qi(e){var t=e.split(/-(?!$)/);e=t[t.length-1];for(var r,n,i,o,l=0;l<t.length-1;l++){var s=t[l];if(/^(cmd|meta|m)$/i.test(s))o=!0;else if(/^a(lt)?$/i.test(s))r=!0;else if(/^(c|ctrl|control)$/i.test(s))n=!0;else{if(!/^s(hift)?$/i.test(s))throw new Error("Unrecognized modifier name: "+s);i=!0}}return r&&(e="Alt-"+e),n&&(e="Ctrl-"+e),o&&(e="Cmd-"+e),i&&(e="Shift-"+e),e}function Ji(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=v(r.split(" "),Qi),o=0;o<i.length;o++){var l=void 0,s=void 0;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}function eo(e,t,r,n){t=no(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 eo(e,t.fallthrough,r,n);for(var o=0;o<t.fallthrough.length;o++){var l=eo(e,t.fallthrough[o],r,n);if(l)return l}}}function to(e){var t="string"==typeof e?e:fs[e.keyCode];return"Ctrl"==t||"Alt"==t||"Shift"==t||"Mod"==t}function ro(e,t){if(sl&&34==e.keyCode&&e["char"])return!1;var r=fs[e.keyCode],n=r;return null!=n&&!e.altGraphKey&&(e.altKey&&"Alt"!=r&&(n="Alt-"+n),(yl?e.metaKey:e.ctrlKey)&&"Ctrl"!=r&&(n="Ctrl-"+n),(yl?e.ctrlKey:e.metaKey)&&"Cmd"!=r&&(n="Cmd-"+n),!t&&e.shiftKey&&"Shift"!=r&&(n="Shift-"+n),n)}function no(e){return"string"==typeof e?gs[e]:e}function io(e,t){for(var r=e.doc.sel.ranges,n=[],i=0;i<r.length;i++){for(var o=t(r[i]);n.length&&P(o.from,g(n).to)<=0;){var l=n.pop();if(P(l.from,o.from)<0){o.from=l.from;break}}n.push(o)}un(e,function(){for(var t=n.length-1;t>=0;t--)ki(e.doc,"",n[t].from,n[t].to,"+delete");Qr(e)})}function oo(e,t){var r=T(e.doc,t),n=ae(r);n!=r&&(t=A(n));var i=ke(n),o=i?i[0].level%2?xe(n):we(n):0;return H(t,o)}function lo(e,t){for(var r,n=T(e.doc,t);r=le(n);)n=r.find(1,!0).line,t=null;var i=ke(n),o=i?i[0].level%2?we(n):xe(n):n.text.length;return H(null==t?A(n):t,o)}function so(e,t){var r=oo(e,t.line),n=T(e.doc,r.line),i=ke(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 H(r.line,l?0:o)}return r}function ao(e,t,r){if("string"==typeof t&&(t=ys[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)!=Tl}finally{e.display.shift=n,e.state.suppressEdits=!1}return i}function uo(e,t,r){for(var n=0;n<e.state.keyMaps.length;n++){var i=eo(t,e.state.keyMaps[n],r,e);if(i)return i}return e.options.extraKeys&&eo(t,e.options.extraKeys,r,e)||eo(t,e.options.keyMap,r,e)}function co(e,t,r,n){var i=e.state.keySeq;if(i){if(to(t))return"handled";bs.set(50,function(){e.state.keySeq==i&&(e.state.keySeq=null,e.display.input.reset())}),t=i+" "+t}var o=uo(e,t,n);return"multi"==o&&(e.state.keySeq=t),"handled"==o&&Lt(e,"keyHandled",e,t,r),"handled"!=o&&"multi"!=o||(Ee(r),Nr(e)),i&&!o&&/\'$/.test(t)?(Ee(r),!0):!!o}function fo(e,t){var r=ro(t,!0);return!!r&&(t.shiftKey&&!e.state.keySeq?co(e,"Shift-"+r,t,function(t){return ao(e,t,!0)})||co(e,r,t,function(t){if("string"==typeof t?/^go[A-Z]/.test(t):t.motion)return ao(e,t)}):co(e,r,t,function(t){return ao(e,t)}))}function ho(e,t,r){return co(e,"'"+r+"'",t,function(t){return ao(e,t,!0)})}function po(e){var t=this;if(t.curOp.focus=o(),!We(t,e)){rl&&nl<11&&27==e.keyCode&&(e.returnValue=!1);var r=e.keyCode;t.display.shift=16==r||e.shiftKey;var n=fo(t,e);sl&&(ws=n?r:null,!n&&88==r&&!Gl&&(dl?e.metaKey:e.ctrlKey)&&t.replaceSelection("",null,"cut")),18!=r||/\bCodeMirror-crosshair\b/.test(t.display.lineDiv.className)||go(t)}}function go(e){function t(e){18!=e.keyCode&&e.altKey||(wl(r,"CodeMirror-crosshair"),Ae(document,"keyup",t),Ae(document,"mouseover",t))}var r=e.display.lineDiv;l(r,"CodeMirror-crosshair"),zl(document,"keyup",t),zl(document,"mouseover",t)}function vo(e){16==e.keyCode&&(this.doc.sel.shift=!1),We(this,e)}function mo(e){var t=this;if(!(Rt(t.display,e)||We(t,e)||e.ctrlKey&&!e.altKey||dl&&e.metaKey)){var r=e.keyCode,n=e.charCode;if(sl&&r==ws)return ws=null,void Ee(e);if(!sl||e.which&&!(e.which<10)||!fo(t,e)){var i=String.fromCharCode(null==n?r:n);"\b"!=i&&(ho(t,e,i)||t.display.input.onKeyPress(e))}}}function yo(e){var t=this,r=t.display;if(!(We(t,e)||r.activeTouch&&r.input.supportsTouch())){if(r.input.ensurePolled(),r.shift=e.shiftKey,Rt(r,e))return void(il||(r.scroller.draggable=!1,setTimeout(function(){return r.scroller.draggable=!0},100)));if(!So(t,e)){var n=Cr(t,e);switch(window.focus(),Be(e)){case 1:t.state.selectingText?t.state.selectingText(e):n?bo(t,e,n):Re(e)==r.scroller&&Ee(e);break;case 2:il&&(t.state.lastMiddleDown=+new Date),n&&oi(t.doc,n),setTimeout(function(){return r.input.focus()},20),Ee(e);break;case 3:bl?Lo(t,e):Or(t)}}}}function bo(e,t,r){rl?setTimeout(a(Ar,e),0):e.curOp.focus=o();var n,i=+new Date;ms&&ms.time>i-400&&0==P(ms.pos,r)?n="triple":vs&&vs.time>i-400&&0==P(vs.pos,r)?(n="double",ms={time:i,pos:r}):(n="single",vs={time:i,pos:r});var l,s=e.doc.sel,u=dl?t.metaKey:t.ctrlKey;e.options.dragDrop&&Fl&&!e.isReadOnly()&&"single"==n&&(l=s.contains(r))>-1&&(P((l=s.ranges[l]).from(),r)<0||r.xRel>0)&&(P(l.to(),r)>0||r.xRel<0)?wo(e,t,r,u):xo(e,t,r,n,u)}function wo(e,t,r,n){var i=e.display,o=+new Date,l=cn(e,function(s){il&&(i.scroller.draggable=!1),e.state.draggingText=!1,Ae(document,"mouseup",l),Ae(i.scroller,"drop",l),Math.abs(t.clientX-s.clientX)+Math.abs(t.clientY-s.clientY)<10&&(Ee(s),!n&&+new Date-200<o&&oi(e.doc,r),il||rl&&9==nl?setTimeout(function(){document.body.focus(),i.input.focus()},20):i.input.focus())});il&&(i.scroller.draggable=!0),e.state.draggingText=l,l.copy=dl?t.altKey:t.ctrlKey,i.scroller.dragDrop&&i.scroller.dragDrop(),zl(document,"mouseup",l),zl(i.scroller,"drop",l)}function xo(e,t,r,n,i){function l(t){if(0!=P(b,t))if(b=t,"rect"==n){for(var i=[],o=e.options.tabSize,l=c(T(f,r.line).text,r.ch,o),s=c(T(f,t.line).text,t.ch,o),a=Math.min(l,s),u=Math.max(l,s),v=Math.min(r.line,t.line),m=Math.min(e.lastLine(),Math.max(r.line,t.line));v<=m;v++){var y=T(f,v).text,w=d(y,a,o);a==u?i.push(new Wn(H(v,w),H(v,w))):y.length>w&&i.push(new Wn(H(v,w),H(v,d(y,u,o))))}i.length||i.push(new Wn(r,r)),fi(f,Dn(g.ranges.slice(0,p).concat(i),p),{origin:"*mouse",scroll:!1}),e.scrollIntoView(t)}else{var x=h,C=x.anchor,S=t;if("single"!=n){var L;L="double"==n?e.findWordAt(t):new Wn(H(t.line,0),R(f,H(t.line+1,0))),P(L.anchor,C)>0?(S=L.head,C=z(x.from(),L.anchor)):(S=L.anchor,C=I(x.to(),L.head))}var M=g.ranges.slice(0);M[p]=new Wn(R(f,C),S),fi(f,Dn(M,p),kl)}}function s(t){var r=++x,i=Cr(e,t,!0,"rect"==n);if(i)if(0!=P(i,b)){e.curOp.focus=o(),l(i);var a=zr(u,f);(i.line>=a.to||i.line<a.from)&&setTimeout(cn(e,function(){x==r&&s(t)}),150)}else{var c=t.clientY<w.top?-20:t.clientY>w.bottom?20:0;c&&setTimeout(cn(e,function(){x==r&&(u.scroller.scrollTop+=c,s(t))}),50)}}function a(t){e.state.selectingText=!1,x=1/0,Ee(t),u.input.focus(),Ae(document,"mousemove",C),Ae(document,"mouseup",S),f.history.lastSelOrigin=null}var u=e.display,f=e.doc;Ee(t);var h,p,g=f.sel,v=g.ranges;if(i&&!t.shiftKey?(p=f.sel.contains(r),h=p>-1?v[p]:new Wn(r,r)):(h=f.sel.primary(),p=f.sel.primIndex),pl?t.shiftKey&&t.metaKey:t.altKey)n="rect",i||(h=new Wn(r,r)),r=Cr(e,t,!0,!0),p=-1;else if("double"==n){var m=e.findWordAt(r);h=e.display.shift||f.extend?ii(f,h,m.anchor,m.head):m}else if("triple"==n){var y=new Wn(H(r.line,0),R(f,H(r.line+1,0)));h=e.display.shift||f.extend?ii(f,h,y.anchor,y.head):y}else h=ii(f,h,r);i?p==-1?(p=v.length,fi(f,Dn(v.concat([h]),p),{scroll:!1,origin:"*mouse"})):v.length>1&&v[p].empty()&&"single"==n&&!t.shiftKey?(fi(f,Dn(v.slice(0,p).concat(v.slice(p+1)),0),{scroll:!1,origin:"*mouse"}),g=f.sel):si(f,p,h,kl):(p=0,fi(f,new On([h],0),kl),g=f.sel);var b=r,w=u.wrapper.getBoundingClientRect(),x=0,C=cn(e,function(e){Be(e)?s(e):a(e)}),S=cn(e,a);e.state.selectingText=S,zl(document,"mousemove",C),zl(document,"mouseup",S)}function Co(e,t,r,n){var i,o;try{i=t.clientX,o=t.clientY}catch(t){return!1}if(i>=Math.floor(e.display.gutters.getBoundingClientRect().right))return!1;n&&Ee(t);var l=e.display,s=l.lineDiv.getBoundingClientRect();if(o>s.bottom||!He(e,r))return ze(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=O(e.doc,o),f=e.options.gutters[a];return Oe(e,r,e,c,f,t),ze(t)}}}function So(e,t){return Co(e,t,"gutterClick",!0)}function Lo(e,t){Rt(e.display,t)||To(e,t)||We(e,t,"contextmenu")||e.display.input.onContextMenu(t)}function To(e,t){return!!He(e,"gutterContextMenu")&&Co(e,t,"gutterContextMenu",!1)}function Mo(e){e.display.wrapper.className=e.display.wrapper.className.replace(/\s*cm-s-\S+/g,"")+e.options.theme.replace(/(^|\s)\s*/g," cm-s-"),or(e)}function ko(e){function t(t,n,i,o){e.defaults[t]=n,i&&(r[t]=o?function(e,t,r){r!=xs&&i(e,t,r)}:i)}var r=e.optionHandlers;e.defineOption=t,e.Init=xs,t("value","",function(e,t){return e.setValue(t)},!0),t("mode",null,function(e,t){e.doc.modeOption=t,Rn(e)},!0),t("indentUnit",2,Rn,!0),t("indentWithTabs",!1),t("smartIndent",!0),t("tabSize",4,function(e){Bn(e),or(e),dn(e)},!0),t("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(o==-1)break;i=o+t.length,r.push(H(n,o))}n++});for(var i=r.length-1;i>=0;i--)ki(e.doc,t,r[i],H(r[i].line,r[i].ch+t.length))}}),t("specialChars",/[\u0000-\u001f\u007f\u00ad\u061c\u200b-\u200f\u2028\u2029\ufeff]/g,function(e,t,r){e.state.specialChars=new RegExp(t.source+(t.test("\t")?"":"|\t"),"g"),r!=xs&&e.refresh()}),t("specialCharPlaceholder",dt,function(e){return e.refresh()},!0),t("electricChars",!0),t("inputStyle",hl?"contenteditable":"textarea",function(){throw new Error("inputStyle can not (yet) be changed in a running editor")},!0),t("spellcheck",!1,function(e,t){return e.getInputField().spellcheck=t},!0),t("rtlMoveVisually",!gl),t("wholeLineUpdateBefore",!0),t("theme","default",function(e){Mo(e),No(e)},!0),t("keyMap","default",function(e,t,r){var n=no(t),i=r!=xs&&no(r);i&&i.detach&&i.detach(e,n),n.attach&&n.attach(e,i||null)}),t("extraKeys",null),t("lineWrapping",!1,Oo,!0),t("gutters",[],function(e){An(e.options),No(e)},!0),t("fixedGutter",!0,function(e,t){e.display.gutters.style.left=t?br(e.display)+"px":"0",e.refresh()},!0),t("coverGutterNextToScrollbar",!1,function(e){return Kr(e)},!0),t("scrollbarStyle","native",function(e){Xr(e),Kr(e),e.display.scrollbars.setScrollTop(e.doc.scrollTop),e.display.scrollbars.setScrollLeft(e.doc.scrollLeft)},!0),t("lineNumbers",!1,function(e){An(e.options),No(e)},!0),t("firstLineNumber",1,No,!0),t("lineNumberFormatter",function(e){return e},No,!0),t("showCursorWhenSelecting",!1,Lr,!0),t("resetSelectionOnContextMenu",!0),t("lineWiseCopyCut",!0),t("readOnly",!1,function(e,t){"nocursor"==t?(Dr(e),e.display.input.blur(),e.display.disabled=!0):e.display.disabled=!1,e.display.input.readOnlyChanged(t)}),t("disableInput",!1,function(e,t){t||e.display.input.reset()},!0),t("dragDrop",!0,Ao),t("allowDropFileTypes",null),t("cursorBlinkRate",530),t("cursorScrollMargin",0),t("cursorHeight",1,Lr,!0),t("singleCursorHeightPerLine",!0,Lr,!0),t("workTime",100),t("workDelay",100),t("flattenSpans",!0,Bn,!0),t("addModeClass",!1,Bn,!0),t("pollInterval",100),t("undoDepth",200,function(e,t){return e.doc.history.undoDepth=t}),t("historyEventDelay",1250),t("viewportMargin",10,function(e){return e.refresh()},!0),t("maxHighlightLength",1e4,Bn,!0),t("moveInputWithCursor",!0,function(e,t){t||e.display.input.resetPosition()}),t("tabindex",null,function(e,t){return e.display.input.getField().tabIndex=t||""}),t("autofocus",null)}function No(e){Nn(e),dn(e),Hr(e)}function Ao(e,t,r){var n=r&&r!=xs;if(!t!=!n){var i=e.display.dragFunctions,o=t?zl:Ae;o(e.display.scroller,"dragstart",i.start),o(e.display.scroller,"dragenter",i.enter),o(e.display.scroller,"dragover",i.over),o(e.display.scroller,"dragleave",i.leave),o(e.display.scroller,"drop",i.drop)}}function Oo(e){e.options.lineWrapping?(l(e.display.wrapper,"CodeMirror-wrap"),e.display.sizer.style.minWidth="",e.display.sizerWidth=null):(wl(e.display.wrapper,"CodeMirror-wrap"),ve(e)),xr(e),dn(e),or(e),setTimeout(function(){return Kr(e)},100)}function Wo(e,t){var r=this;if(!(this instanceof Wo))return new Wo(e,t);this.options=t=t?u(t):{},u(Cs,t,!1),An(t);var n=t.value;"string"==typeof n&&(n=new as(n,t.mode,null,t.lineSeparator)),this.doc=n;var i=new Wo.inputStyles[t.inputStyle](this),o=this.display=new L(e,n,i);o.wrapper.CodeMirror=this,Nn(this),Mo(this),t.lineWrapping&&(this.display.wrapper.className+=" CodeMirror-wrap"),Xr(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 f,keySeq:null,specialChars:null},t.autofocus&&!hl&&o.input.focus(),rl&&nl<11&&setTimeout(function(){return r.display.input.reset(!0)},20),Do(this),$i(),en(this),this.curOp.forceUpdate=!0,Kn(this,n),t.autofocus&&!hl||this.hasFocus()?setTimeout(a(Wr,this),20):Dr(this);for(var l in Ss)Ss.hasOwnProperty(l)&&Ss[l](r,t[l],xs);Pr(this),t.finishInit&&t.finishInit(this);for(var s=0;s<Ls.length;++s)Ls[s](r);tn(this),il&&t.lineWrapping&&"optimizelegibility"==getComputedStyle(o.lineDiv).textRendering&&(o.lineDiv.style.textRendering="auto")}function Do(e){function t(){i.activeTouch&&(o=setTimeout(function(){return 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;zl(i.scroller,"mousedown",cn(e,yo)),rl&&nl<11?zl(i.scroller,"dblclick",cn(e,function(t){if(!We(e,t)){var r=Cr(e,t);if(r&&!So(e,t)&&!Rt(e.display,t)){Ee(t);var n=e.findWordAt(r);oi(e.doc,n.anchor,n.head)}}})):zl(i.scroller,"dblclick",function(t){return We(e,t)||Ee(t)}),bl||zl(i.scroller,"contextmenu",function(t){return Lo(e,t)});var o,l={end:0};zl(i.scroller,"touchstart",function(t){if(!We(e,t)&&!r(t)){i.input.ensurePolled(),clearTimeout(o);var n=+new Date;i.activeTouch={start:n,moved:!1,prev:n-l.end<=300?l:null},1==t.touches.length&&(i.activeTouch.left=t.touches[0].pageX,i.activeTouch.top=t.touches[0].pageY)}}),zl(i.scroller,"touchmove",function(){i.activeTouch&&(i.activeTouch.moved=!0)}),zl(i.scroller,"touchend",function(r){var o=i.activeTouch;if(o&&!Rt(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 Wn(s,s):!o.prev.prev||n(o,o.prev.prev)?e.findWordAt(s):new Wn(H(s.line,0),R(e.doc,H(s.line+1,0))),e.setSelection(l.anchor,l.head),e.focus(),Ee(r)}t()}),zl(i.scroller,"touchcancel",t),zl(i.scroller,"scroll",function(){i.scroller.clientHeight&&(Fr(e,i.scroller.scrollTop),Rr(e,i.scroller.scrollLeft,!0),Oe(e,"scroll",e))}),zl(i.scroller,"mousewheel",function(t){return Ur(e,t)}),zl(i.scroller,"DOMMouseScroll",function(t){return Ur(e,t)}),zl(i.wrapper,"scroll",function(){return i.wrapper.scrollTop=i.wrapper.scrollLeft=0}),i.dragFunctions={enter:function(t){We(e,t)||Fe(t)},over:function(t){We(e,t)||(Xi(e,t),Fe(t))},start:function(t){return ji(e,t)},drop:cn(e,Ki),leave:function(t){We(e,t)||Yi(e)}};var s=i.input.getField();zl(s,"keyup",function(t){return vo.call(e,t)}),zl(s,"keydown",cn(e,po)),zl(s,"keypress",cn(e,mo)),zl(s,"focus",function(t){return Wr(e,t)}),zl(s,"blur",function(t){return Dr(e,t)})}function Ho(e,t,r,n){var i,o=e.doc;null==r&&(r="add"),"smart"==r&&(o.mode.indent?i=et(e,t):r="prev");var l=e.options.tabSize,s=T(o,t),a=c(s.text,null,l);s.stateAfter&&(s.stateAfter=null);var u,f=s.text.match(/^\s*/)[0];if(n||/\S/.test(s.text)){if("smart"==r&&(u=o.mode.indent(i,s.text.slice(f.length),s.text),u==Tl||u>150)){if(!n)return;r="prev"}}else u=0,r="not";"prev"==r?u=t>o.first?c(T(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="",d=0;if(e.options.indentWithTabs)for(var g=Math.floor(u/l);g;--g)d+=l,h+="\t";if(d<u&&(h+=p(u-d)),h!=f)return ki(o,h,H(t,0),H(t,f.length),"+input"),s.stateAfter=null,!0;for(var v=0;v<o.sel.ranges.length;v++){var m=o.sel.ranges[v];if(m.head.line==t&&m.head.ch<f.length){var y=H(t,f.length);si(o,v,new Wn(y,y));break}}}function Po(e){Ts=e}function Eo(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=Rl(t),a=null;if(l&&n.ranges.length>1)if(Ts&&Ts.text.join("\n")==t){if(n.ranges.length%Ts.text.length==0){a=[];for(var u=0;u<Ts.text.length;u++)a.push(o.splitLines(Ts.text[u]))}}else s.length==n.ranges.length&&(a=v(s,function(e){return[e]}));for(var c,f=n.ranges.length-1;f>=0;f--){var h=n.ranges[f],d=h.from(),p=h.to();h.empty()&&(r&&r>0?d=H(d.line,d.ch-r):e.state.overwrite&&!l?p=H(p.line,Math.min(T(o,p.line).text.length,p.ch+g(s).length)):Ts&&Ts.lineWise&&Ts.text.join("\n")==t&&(d=p=H(d.line,0))),c=e.curOp.updateInput;var m={from:d,to:p,
|
4 |
-
text:a?a[f%a.length]:s,origin:i||(l?"paste":e.state.cutIncoming?"cut":"+input")};xi(e.doc,m),Lt(e,"inputRead",e,m)}t&&!l&&zo(e,t),Qr(e),e.curOp.updateInput=c,e.curOp.typing=!0,e.state.pasteIncoming=e.state.cutIncoming=!1}function Io(e,t){var r=e.clipboardData&&e.clipboardData.getData("Text");if(r)return e.preventDefault(),t.isReadOnly()||t.options.disableInput||un(t,function(){return Eo(t,r,0,null,"paste")}),!0}function zo(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=Ho(e,i.head.line,"smart");break}}else o.electricInput&&o.electricInput.test(T(e.doc,i.head.line).text.slice(0,i.head.ch))&&(l=Ho(e,i.head.line,"smart"));l&&Lt(e,"electricInput",e,i.head.line)}}}function Fo(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:H(i,0),head:H(i+1,0)};r.push(o),t.push(e.getRange(o.anchor,o.head))}return{text:t,ranges:r}}function Ro(e,t){e.setAttribute("autocorrect","off"),e.setAttribute("autocapitalize","off"),e.setAttribute("spellcheck",!!t)}function Bo(){var e=n("textarea",null,null,"position: absolute; bottom: -1em; padding: 0; width: 1px; height: 1em; outline: none"),t=n("div",[e],null,"overflow: hidden; position: relative; width: 3px; height: 0px;");return il?e.style.width="1000px":e.setAttribute("wrap","off"),fl&&(e.style.border="1px solid black"),Ro(e),t}function Go(e){var t=e.optionHandlers,r=e.helpers={};e.prototype={constructor:e,focus:function(){window.focus(),this.display.input.focus()},setOption:function(e,r){var n=this.options,i=n[e];n[e]==r&&"mode"!=e||(n[e]=r,t.hasOwnProperty(e)&&cn(this,t[e])(this,r,i),Oe(this,"optionChange",this,e))},getOption:function(e){return this.options[e]},getDoc:function(){return this.doc},addKeyMap:function(e,t){this.state.keyMaps[t?"push":"unshift"](no(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:fn(function(t,r){var n=t.token?t:e.getMode(this.options,t);if(n.startState)throw new Error("Overlays may not be stateful.");m(this.state.overlays,{mode:n,modeSpec:t,opaque:r&&r.opaque,priority:r&&r.priority||0},function(e){return e.priority}),this.state.modeGen++,dn(this)}),removeOverlay:fn(function(e){for(var t=this,r=this.state.overlays,n=0;n<r.length;++n){var i=r[n].modeSpec;if(i==e||"string"==typeof e&&i.name==e)return r.splice(n,1),t.state.modeGen++,void dn(t)}}),indentLine:fn(function(e,t,r){"string"!=typeof t&&"number"!=typeof t&&(t=null==t?this.options.smartIndent?"smart":"prev":t?"add":"subtract"),W(this.doc,e)&&Ho(this,e,t,r)}),indentSelection:fn(function(e){for(var t=this,r=this.doc.sel.ranges,n=-1,i=0;i<r.length;i++){var o=r[i];if(o.empty())o.head.line>n&&(Ho(t,o.head.line,e,!0),n=o.head.line,i==t.doc.sel.primIndex&&Qr(t));else{var l=o.from(),s=o.to(),a=Math.max(n,l.line);n=Math.min(t.lastLine(),s.line-(s.ch?0:1))+1;for(var u=a;u<n;++u)Ho(t,u,e);var c=t.doc.sel.ranges;0==l.ch&&r.length==c.length&&c[i].from().ch>0&&si(t.doc,i,new Wn(l,c[i].to()),Ml)}}}),getTokenAt:function(e,t){return it(this,e,t)},getLineTokens:function(e,t){return it(this,H(e),t,!0)},getTokenTypeAt:function(e){e=R(this.doc,e);var t,r=Je(this,T(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("overlay "):-1;return s<0?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 n=this,i=[];if(!r.hasOwnProperty(t))return i;var o=r[t],l=this.getModeAt(e);if("string"==typeof l[t])o[l[t]]&&i.push(o[l[t]]);else if(l[t])for(var s=0;s<l[t].length;s++){var a=o[l[t][s]];a&&i.push(a)}else l.helperType&&o[l.helperType]?i.push(o[l.helperType]):o[l.name]&&i.push(o[l.name]);for(var u=0;u<o._global.length;u++){var c=o._global[u];c.pred(l,n)&&h(i,c.val)==-1&&i.push(c.val)}return i},getStateAfter:function(e,t){var r=this.doc;return e=F(r,null==e?r.first+r.size-1:e),et(this,e+1,t)},cursorCoords:function(e,t){var r,n=this.doc.sel.primary();return r=null==e?n.head:"object"==typeof e?R(this.doc,e):e?n.from():n.to(),fr(this,r,t||"page")},charCoords:function(e,t){return cr(this,R(this.doc,e),t||"page")},coordsChar:function(e,t){return e=ur(this,e,t||"page"),pr(this,e.left,e.top)},lineAtHeight:function(e,t){return e=ur(this,{top:e,left:0},t||"page").top,O(this.doc,e+this.display.viewOffset)},heightAtLine:function(e,t,r){var n,i=!1;if("number"==typeof e){var o=this.doc.first+this.doc.size-1;e<this.doc.first?e=this.doc.first:e>o&&(e=o,i=!0),n=T(this.doc,e)}else n=e;return ar(this,n,{top:0,left:0},t||"page",r).top+(i?this.doc.height-pe(n):0)},defaultTextHeight:function(){return vr(this.display)},defaultCharWidth:function(){return mr(this.display)},getViewport:function(){return{from:this.display.viewFrom,to:this.display.viewTo}},addWidget:function(e,t,r,n,i){var o=this.display;e=fr(this,R(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&&$r(this,s,l,s+t.offsetWidth,l+t.offsetHeight)},triggerOnKeyDown:fn(po),triggerOnKeyPress:fn(mo),triggerOnKeyUp:vo,execCommand:function(e){if(ys.hasOwnProperty(e))return ys[e].call(null,this)},triggerElectric:fn(function(e){zo(this,e)}),findPosH:function(e,t,r,n){var i=this,o=1;t<0&&(o=-1,t=-t);for(var l=R(this.doc,e),s=0;s<t&&(l=Uo(i.doc,l,o,r,n),!l.hitSide);++s);return l},moveH:fn(function(e,t){var r=this;this.extendSelectionsBy(function(n){return r.display.shift||r.doc.extend||n.empty()?Uo(r.doc,n.head,e,t,r.options.rtlMoveVisually):e<0?n.from():n.to()},Nl)}),deleteH:fn(function(e,t){var r=this.doc.sel,n=this.doc;r.somethingSelected()?n.replaceSelection("",null,"+delete"):io(this,function(r){var i=Uo(n,r.head,e,t,!1);return e<0?{from:i,to:r.head}:{from:r.head,to:i}})}),findPosV:function(e,t,r,n){var i=this,o=1,l=n;t<0&&(o=-1,t=-t);for(var s=R(this.doc,e),a=0;a<t;++a){var u=fr(i,s,"div");if(null==l?l=u.left:u.left=l,s=Vo(i,u,o,r),s.hitSide)break}return s},moveV:fn(function(e,t){var r=this,n=this.doc,i=[],o=!this.display.shift&&!n.extend&&n.sel.somethingSelected();if(n.extendSelectionsBy(function(l){if(o)return e<0?l.from():l.to();var s=fr(r,l.head,"div");null!=l.goalColumn&&(s.left=l.goalColumn),i.push(s.left);var a=Vo(r,s,e,t);return"page"==t&&l==n.sel.primary()&&Zr(r,null,cr(r,a,"div").top-s.top),a},Nl),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=T(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=x(l,o)?function(e){return x(e,o)}:/\s/.test(l)?function(e){return/\s/.test(e)}:function(e){return!/\s/.test(e)&&!x(e)};n>0&&s(r.charAt(n-1));)--n;for(;i<r.length&&s(r.charAt(i));)++i}return new Wn(H(e.line,n),H(e.line,i))},toggleOverwrite:function(e){null!=e&&e==this.state.overwrite||((this.state.overwrite=!this.state.overwrite)?l(this.display.cursorDiv,"CodeMirror-overwrite"):wl(this.display.cursorDiv,"CodeMirror-overwrite"),Oe(this,"overwriteToggle",this,this.state.overwrite))},hasFocus:function(){return this.display.input.getField()==o()},isReadOnly:function(){return!(!this.options.readOnly&&!this.doc.cantEdit)},scrollTo:fn(function(e,t){null==e&&null==t||Jr(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-Vt(this)-this.display.barHeight,width:e.scrollWidth-Vt(this)-this.display.barWidth,clientHeight:jt(this),clientWidth:Kt(this)}},scrollIntoView:fn(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:H(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)Jr(this),this.curOp.scrollToPos=e;else{var r=qr(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:fn(function(e,t){var r=this,n=function(e){return"number"==typeof e||/^\d+$/.test(String(e))?e+"px":e};null!=e&&(this.display.wrapper.style.width=n(e)),null!=t&&(this.display.wrapper.style.height=n(t)),this.options.lineWrapping&&ir(this);var i=this.display.viewFrom;this.doc.iter(i,this.display.viewTo,function(e){if(e.widgets)for(var t=0;t<e.widgets.length;t++)if(e.widgets[t].noHScroll){pn(r,i,"widget");break}++i}),this.curOp.forceUpdate=!0,Oe(this,"refresh",this)}),operation:function(e){return un(this,e)},refresh:fn(function(){var e=this.display.cachedTextHeight;dn(this),this.curOp.forceUpdate=!0,or(this),this.scrollTo(this.doc.scrollLeft,this.doc.scrollTop),Mn(this),(null==e||Math.abs(e-vr(this.display))>.5)&&xr(this),Oe(this,"refresh",this)}),swapDoc:fn(function(e){var t=this.doc;return t.cm=null,Kn(this,e),or(this),this.display.input.reset(),this.scrollTo(e.scrollLeft,e.scrollTop),this.curOp.forceScroll=!0,Lt(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}},Pe(e),e.registerHelper=function(t,n,i){r.hasOwnProperty(t)||(r[t]=e[t]={_global:[]}),r[t][n]=i},e.registerGlobalHelper=function(t,n,i,o){e.registerHelper(t,n,o),r[t]._global.push({pred:i,val:o})}}function Uo(e,t,r,n,i){function o(){var t=s+r;return!(t<e.first||t>=e.first+e.size)&&(s=t,c=T(e,t))}function l(e){var t=(i?Te:Me)(c,a,r,!0);if(null==t){if(e||!o())return!1;a=i?(r<0?xe:we)(c):r<0?c.text.length:0}else a=t;return!0}var s=t.line,a=t.ch,u=r,c=T(e,s);if("char"==n)l();else if("column"==n)l(!0);else if("word"==n||"group"==n)for(var f=null,h="group"==n,d=e.cm&&e.cm.getHelper(t,"wordChars"),p=!0;!(r<0)||l(!p);p=!1){var g=c.text.charAt(a)||"\n",v=x(g,d)?"w":h&&"\n"==g?"n":!h||/\s/.test(g)?null:"p";if(!h||p||v||(v="s"),f&&f!=v){r<0&&(r=1,l());break}if(v&&(f=v),r>0&&!l(!p))break}var m=mi(e,H(s,a),t,u,!0);return P(t,m)||(m.hitSide=!0),m}function Vo(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),a=Math.max(s-.5*vr(e.display),3);i=(r>0?t.bottom:t.top)+r*a}else"line"==n&&(i=r>0?t.bottom+3:t.top-3);for(var u;u=pr(e,l,i),u.outside;){if(r<0?i<=0:i>=o.height){u.hitSide=!0;break}i+=5*r}return u}function Ko(e,t){var r=qt(e,t.line);if(!r||r.hidden)return null;var n=T(e.doc,t.line),i=Yt(r,n,t.line),o=ke(n),l="left";if(o){var s=Se(o,t.ch);l=s%2?"right":"left"}var a=Jt(i.map,t.ch,l);return a.offset="right"==a.collapse?a.end:a.start,a}function jo(e,t){return t&&(e.bad=!0),e}function Xo(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 void(s+=""==r?t.textContent.replace(/\u200b/g,""):r);var c,f=t.getAttribute("cm-marker");if(f){var h=e.findMarks(H(n,0),H(i+1,0),o(+f));return void(h.length&&(c=h[0].find())&&(s+=M(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 Yo(e,t,r){var n;if(t==e.display.lineDiv){if(n=e.display.lineDiv.childNodes[r],!n)return jo(e.clipPos(H(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 _o(o,t,r)}}function _o(e,t,r){function n(t,r,n){for(var i=-1;i<(f?f.length:0);i++)for(var o=i<0?c.map:f[i],l=0;l<o.length;l+=3){var s=o[l+2];if(s==t||s==r){var a=A(i<0?e.line:e.rest[i]),u=o[l]+n;return(n<0||s!=t)&&(u=o[l+(n?1:0)]),H(a,u)}}}var o=e.text.firstChild,l=!1;if(!t||!i(o,t))return jo(H(A(e.line),0),!0);if(t==o&&(l=!0,t=o.childNodes[r],r=0,!t)){var s=e.rest?g(e.rest):e.line;return jo(H(A(s),s.text.length),l)}var a=3==t.nodeType?t:null,u=t;for(a||1!=t.childNodes.length||3!=t.firstChild.nodeType||(a=t.firstChild,r&&(r=a.nodeValue.length));u.parentNode!=o;)u=u.parentNode;var c=e.measure,f=c.maps,h=n(a,u,r);if(h)return jo(h,l);for(var d=u.nextSibling,p=a?a.nodeValue.length-r:0;d;d=d.nextSibling){if(h=n(d,d.firstChild,0))return jo(H(h.line,h.ch-p),l);p+=d.textContent.length}for(var v=u.previousSibling,m=r;v;v=v.previousSibling){if(h=n(v,v.firstChild,-1))return jo(H(h.line,h.ch+m),l);m+=v.textContent.length}}function $o(e,t){function r(){e.value=c.getValue()}if(t=t?u(t):{},t.value=e.value,!t.tabindex&&e.tabIndex&&(t.tabindex=e.tabIndex),!t.placeholder&&e.placeholder&&(t.placeholder=e.placeholder),null==t.autofocus){var n=o();t.autofocus=n==e||null!=e.getAttribute("autofocus")&&n==document.body}var i;if(e.form&&(zl(e.form,"submit",r),!t.leaveSubmitMethodAlone)){var l=e.form;i=l.submit;try{var s=l.submit=function(){r(),l.submit=i,l.submit(),l.submit=s}}catch(a){}}t.finishInit=function(t){t.save=r,t.getTextArea=function(){return e},t.toTextArea=function(){t.toTextArea=isNaN,r(),e.parentNode.removeChild(t.getWrapperElement()),e.style.display="",e.form&&(Ae(e.form,"submit",r),"function"==typeof e.form.submit&&(e.form.submit=i))}},e.style.display="none";var c=Wo(function(t){return e.parentNode.insertBefore(t,e.nextSibling)},t);return c}function qo(e){e.off=Ae,e.on=zl,e.wheelEventPixels=Gr,e.Doc=as,e.splitLines=Rl,e.countColumn=c,e.findColumn=d,e.isWordChar=w,e.Pass=Tl,e.signal=Oe,e.Line=at,e.changeEnd=Pn,e.scrollbarModel=ns,e.Pos=H,e.cmpPos=P,e.modes=Vl,e.mimeModes=Kl,e.resolveMode=Xe,e.getMode=Ye,e.modeExtensions=jl,e.extendMode=_e,e.copyState=$e,e.startState=Ze,e.innerMode=qe,e.commands=ys,e.keyMap=gs,e.keyName=ro,e.isModifierKey=to,e.lookupKey=eo,e.normalizeKeyMap=Ji,e.StringStream=Xl,e.SharedTextMarker=Ri,e.TextMarker=zi,e.LineWidget=Pi,e.e_preventDefault=Ee,e.e_stopPropagation=Ie,e.e_stop=Fe,e.addClass=l,e.contains=i,e.rmClass=wl,e.keyNames=fs}var Zo=navigator.userAgent,Qo=navigator.platform,Jo=/gecko\/\d/i.test(Zo),el=/MSIE \d/.test(Zo),tl=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(Zo),rl=el||tl,nl=rl&&(el?document.documentMode||6:tl[1]),il=/WebKit\//.test(Zo),ol=il&&/Qt\/\d+\.\d+/.test(Zo),ll=/Chrome\//.test(Zo),sl=/Opera\//.test(Zo),al=/Apple Computer/.test(navigator.vendor),ul=/Mac OS X 1\d\D([8-9]|\d\d)\D/.test(Zo),cl=/PhantomJS/.test(Zo),fl=/AppleWebKit/.test(Zo)&&/Mobile\/\w+/.test(Zo),hl=fl||/Android|webOS|BlackBerry|Opera Mini|Opera Mobi|IEMobile/i.test(Zo),dl=fl||/Mac/.test(Qo),pl=/\bCrOS\b/.test(Zo),gl=/win/i.test(Qo),vl=sl&&Zo.match(/Version\/(\d*\.\d*)/);vl&&(vl=Number(vl[1])),vl&&vl>=15&&(sl=!1,il=!0);var ml,yl=dl&&(ol||sl&&(null==vl||vl<12.11)),bl=Jo||rl&&nl>=9,wl=function(t,r){var n=t.className,i=e(r).exec(n);if(i){var o=n.slice(i.index+i[0].length);t.className=n.slice(0,i.index)+(o?i[1]+o:"")}};ml=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 xl=function(e){e.select()};fl?xl=function(e){e.selectionStart=0,e.selectionEnd=e.value.length}:rl&&(xl=function(e){try{e.select()}catch(t){}}),f.prototype.set=function(e,t){clearTimeout(this.id),this.id=setTimeout(t,e)};var Cl,Sl,Ll=30,Tl={toString:function(){return"CodeMirror.Pass"}},Ml={scroll:!1},kl={origin:"*mouse"},Nl={origin:"+move"},Al=[""],Ol=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/,Wl=/[\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]/,Dl=!1,Hl=!1,Pl=null,El=function(){function e(e){return e<=247?r.charAt(e):1424<=e&&e<=1524?"R":1536<=e&&e<=1785?n.charAt(e-1536):1774<=e&&e<=2220?"r":8192<=e&&e<=8203?"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="nnnnnnNNr%%r,rNNmmmmmmmmmmmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmmmmmmmmmmmmmmmnnnnnnnnnn%nnrrrmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmnNmmmmmmrrmmNmmmmrr1111111111",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=r.length,c=[],f=0;f<n;++f)c.push(e(r.charCodeAt(f)));for(var h=0,d=u;h<n;++h){var p=c[h];"m"==p?c[h]=d:d=p}for(var v=0,m=u;v<n;++v){var y=c[v];"1"==y&&"r"==m?c[v]="n":l.test(y)&&(m=y,"r"==y&&(c[v]="R"))}for(var b=1,w=c[0];b<n-1;++b){var x=c[b];"+"==x&&"1"==w&&"1"==c[b+1]?c[b]="1":","!=x||w!=c[b+1]||"1"!=w&&"n"!=w||(c[b]=w),w=x}for(var C=0;C<n;++C){var S=c[C];if(","==S)c[C]="N";else if("%"==S){var L=void 0;for(L=C+1;L<n&&"%"==c[L];++L);for(var T=C&&"!"==c[C-1]||L<n&&"1"==c[L]?"1":"N",M=C;M<L;++M)c[M]=T;C=L-1}}for(var k=0,N=u;k<n;++k){var A=c[k];"L"==N&&"1"==A?c[k]="L":l.test(A)&&(N=A)}for(var O=0;O<n;++O)if(o.test(c[O])){var W=void 0;for(W=O+1;W<n&&o.test(c[W]);++W);for(var D="L"==(O?c[O-1]:u),H="L"==(W<n?c[W]:u),P=D||H?"L":"R",E=O;E<W;++E)c[E]=P;O=W-1}for(var I,z=[],F=0;F<n;)if(s.test(c[F])){var R=F;for(++F;F<n&&s.test(c[F]);++F);z.push(new t(0,R,F))}else{var B=F,G=z.length;for(++F;F<n&&"L"!=c[F];++F);for(var U=B;U<F;)if(a.test(c[U])){B<U&&z.splice(G,0,new t(1,B,U));var V=U;for(++U;U<F&&a.test(c[U]);++U);z.splice(G,0,new t(2,V,U)),B=U}else++U;B<F&&z.splice(G,0,new t(1,B,F))}return 1==z[0].level&&(I=r.match(/^\s+/))&&(z[0].from=I[0].length,z.unshift(new t(0,0,I[0].length))),1==g(z).level&&(I=r.match(/\s+$/))&&(g(z).to-=I[0].length,z.push(new t(0,n-I[0].length,n))),2==z[0].level&&z.unshift(new t(1,z[0].to,z[0].to)),z[0].level!=g(z).level&&z.push(new t(z[0].level,n,n)),z}}(),Il=[],zl=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={});n[t]=(n[t]||Il).concat(r)}},Fl=function(){if(rl&&nl<9)return!1;var e=n("div");return"draggable"in e||"dragDrop"in e}(),Rl=3!="\n\nb".split(/\n/).length?function(e){for(var t=0,r=[],n=e.length;t<=n;){var i=e.indexOf("\n",t);i==-1&&(i=e.length);var o=e.slice(t,"\r"==e.charAt(i-1)?i-1:i),l=o.indexOf("\r");l!=-1?(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/)},Bl=window.getSelection?function(e){try{return e.selectionStart!=e.selectionEnd}catch(t){return!1}}:function(e){var t;try{t=e.ownerDocument.selection.createRange()}catch(r){}return!(!t||t.parentElement()!=e)&&0!=t.compareEndPoints("StartToEnd",t)},Gl=function(){var e=n("div");return"oncopy"in e||(e.setAttribute("oncopy","return;"),"function"==typeof e.oncopy)}(),Ul=null,Vl={},Kl={},jl={},Xl=function(e,t){this.pos=this.start=0,this.string=e,this.tabSize=t||8,this.lastColumnPos=this.lastColumnValue=0,this.lineStart=0};Xl.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(){if(this.pos<this.string.length)return this.string.charAt(this.pos++)},eat:function(e){var t,r=this.string.charAt(this.pos);if(t="string"==typeof e?r==e:r&&(e.test?e.test(r):e(r)))return++this.pos,r},eatWhile:function(e){for(var t=this.pos;this.eat(e););return this.pos>t},eatSpace:function(){for(var e=this,t=this.pos;/[\s\u00a0]/.test(this.string.charAt(this.pos));)++e.pos;return this.pos>t},skipToEnd:function(){this.pos=this.string.length},skipTo:function(e){var t=this.string.indexOf(e,this.pos);if(t>-1)return this.pos=t,!0},backUp:function(e){this.pos-=e},column:function(){return this.lastColumnPos<this.start&&(this.lastColumnValue=c(this.string,this.start,this.tabSize,this.lastColumnPos,this.lastColumnValue),this.lastColumnPos=this.start),this.lastColumnValue-(this.lineStart?c(this.string,this.lineStart,this.tabSize):0)},indentation:function(){return c(this.string,null,this.tabSize)-(this.lineStart?c(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);if(i(o)==i(e))return t!==!1&&(this.pos+=e.length),!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}}},Pe(at),at.prototype.lineNo=function(){return A(this)};var Yl,_l={},$l={},ql=null,Zl=null,Ql={left:0,right:0,top:0,bottom:0},Jl=0,es=null;rl?es=-.53:Jo?es=15:ll?es=-.7:al&&(es=-1/3);var ts=function(e,t,r){this.cm=r;var i=this.vert=n("div",[n("div",null,null,"min-width: 1px")],"CodeMirror-vscrollbar"),o=this.horiz=n("div",[n("div",null,null,"height: 100%; min-height: 1px")],"CodeMirror-hscrollbar");e(i),e(o),zl(i,"scroll",function(){i.clientHeight&&t(i.scrollTop,"vertical")}),zl(o,"scroll",function(){o.clientWidth&&t(o.scrollLeft,"horizontal")}),this.checkedZeroWidth=!1,rl&&nl<8&&(this.horiz.style.minHeight=this.vert.style.minWidth="18px")};ts.prototype.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}},ts.prototype.setScrollLeft=function(e){this.horiz.scrollLeft!=e&&(this.horiz.scrollLeft=e),this.disableHoriz&&this.enableZeroWidthBar(this.horiz,this.disableHoriz)},ts.prototype.setScrollTop=function(e){this.vert.scrollTop!=e&&(this.vert.scrollTop=e),this.disableVert&&this.enableZeroWidthBar(this.vert,this.disableVert)},ts.prototype.zeroWidthHack=function(){var e=dl&&!ul?"12px":"18px";this.horiz.style.height=this.vert.style.width=e,this.horiz.style.pointerEvents=this.vert.style.pointerEvents="none",this.disableHoriz=new f,this.disableVert=new f},ts.prototype.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)},ts.prototype.clear=function(){var e=this.horiz.parentNode;e.removeChild(this.horiz),e.removeChild(this.vert)};var rs=function(){};rs.prototype.update=function(){return{bottom:0,right:0}},rs.prototype.setScrollLeft=function(){},rs.prototype.setScrollTop=function(){},rs.prototype.clear=function(){};var ns={"native":ts,"null":rs},is=0,os=function(e,t,r){var n=e.display;this.viewport=t,this.visible=zr(n,e.doc,t),this.editorIsHidden=!n.wrapper.offsetWidth,this.wrapperHeight=n.wrapper.clientHeight,this.wrapperWidth=n.wrapper.clientWidth,this.oldDisplayWidth=Kt(e),this.force=r,this.dims=yr(e),this.events=[]};os.prototype.signal=function(e,t){He(e,t)&&this.events.push(arguments)},os.prototype.finish=function(){for(var e=this,t=0;t<this.events.length;t++)Oe.apply(null,e.events[t])},On.prototype={primary:function(){return this.ranges[this.primIndex]},equals:function(e){var t=this;if(e==this)return!0;if(e.primIndex!=this.primIndex||e.ranges.length!=this.ranges.length)return!1;for(var r=0;r<this.ranges.length;r++){var n=t.ranges[r],i=e.ranges[r];if(0!=P(n.anchor,i.anchor)||0!=P(n.head,i.head))return!1}return!0},deepCopy:function(){for(var e=this,t=[],r=0;r<this.ranges.length;r++)t[r]=new Wn(E(e.ranges[r].anchor),E(e.ranges[r].head));return new On(t,this.primIndex)},somethingSelected:function(){for(var e=this,t=0;t<this.ranges.length;t++)if(!e.ranges[t].empty())return!0;return!1},contains:function(e,t){var r=this;t||(t=e);for(var n=0;n<this.ranges.length;n++){var i=r.ranges[n];if(P(t,i.from())>=0&&P(e,i.to())<=0)return n}return-1}},Wn.prototype={from:function(){return z(this.anchor,this.head)},to:function(){return I(this.anchor,this.head)},empty:function(){return this.head.line==this.anchor.line&&this.head.ch==this.anchor.ch}},Di.prototype={chunkSize:function(){return this.lines.length},removeInner:function(e,t){for(var r=this,n=e,i=e+t;n<i;++n){var o=r.lines[n];r.height-=o.height,ct(o),Lt(o,"delete")}this.lines.splice(e,t)},collapse:function(e){e.push.apply(e,this.lines)},insertInner:function(e,t,r){var n=this;this.height+=r,this.lines=this.lines.slice(0,e).concat(t).concat(this.lines.slice(e));for(var i=0;i<t.length;++i)t[i].parent=n},iterN:function(e,t,r){for(var n=this,i=e+t;e<i;++e)if(r(n.lines[e]))return!0}},Hi.prototype={chunkSize:function(){return this.size},removeInner:function(e,t){var r=this;this.size-=t;for(var n=0;n<this.children.length;++n){var i=r.children[n],o=i.chunkSize();if(e<o){var l=Math.min(t,o-e),s=i.height;if(i.removeInner(e,l),r.height-=s-i.height,o==l&&(r.children.splice(n--,1),i.parent=null),0==(t-=l))break;e=0}else e-=o}if(this.size-t<25&&(this.children.length>1||!(this.children[0]instanceof Di))){var a=[];this.collapse(a),this.children=[new Di(a)],this.children[0].parent=this}},collapse:function(e){for(var t=this,r=0;r<this.children.length;++r)t.children[r].collapse(e)},insertInner:function(e,t,r){var n=this;this.size+=t.length,this.height+=r;for(var i=0;i<this.children.length;++i){var o=n.children[i],l=o.chunkSize();if(e<=l){if(o.insertInner(e,t,r),o.lines&&o.lines.length>50){for(var s=o.lines.length%25+25,a=s;a<o.lines.length;){var u=new Di(o.lines.slice(a,a+=25));o.height-=u.height,n.children.splice(++i,0,u),u.parent=n}o.lines=o.lines.slice(0,s),n.maybeSpill()}break}e-=l}},maybeSpill:function(){if(!(this.children.length<=10)){var e=this;do{var t=e.children.splice(e.children.length-5,5),r=new Hi(t);if(e.parent){e.size-=r.size,e.height-=r.height;var n=h(e.parent.children,e);e.parent.children.splice(n+1,0,r)}else{var i=new Hi(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=this,i=0;i<this.children.length;++i){var o=n.children[i],l=o.chunkSize();if(e<l){var s=Math.min(t,l-e);if(o.iterN(e,s,r))return!0;if(0==(t-=s))break;e=0}else e-=l}}},Pe(Pi),Pi.prototype.clear=function(){var e=this,t=this.doc.cm,r=this.line.widgets,n=this.line,i=A(n);if(null!=i&&r){for(var o=0;o<r.length;++o)r[o]==e&&r.splice(o--,1);r.length||(n.widgets=null);var l=Ft(this);N(n,Math.max(0,n.height-l)),t&&un(t,function(){Ei(t,n,-l),pn(t,i,"widget")})}},Pi.prototype.changed=function(){var e=this.height,t=this.doc.cm,r=this.line;this.height=null;var n=Ft(this)-e;n&&(N(r,r.height+n),t&&un(t,function(){t.curOp.forceUpdate=!0,Ei(t,r,n)}))};var ls=0;Pe(zi),zi.prototype.clear=function(){var e=this;if(!this.explicitlyCleared){var t=this.doc.cm,r=t&&!t.curOp;if(r&&en(t),He(this,"clear")){var n=this.find();n&&Lt(this,"clear",n.from,n.to)}for(var i=null,o=null,l=0;l<this.lines.length;++l){var s=e.lines[l],a=j(s.markedSpans,e);t&&!e.collapsed?pn(t,A(s),"text"):t&&(null!=a.to&&(o=A(s)),null!=a.from&&(i=A(s))),s.markedSpans=X(s.markedSpans,a),null==a.from&&e.collapsed&&!he(e.doc,s)&&t&&N(s,vr(t.display))}if(t&&this.collapsed&&!t.options.lineWrapping)for(var u=0;u<this.lines.length;++u){var c=ae(e.lines[u]),f=ge(c);f>t.display.maxLineLength&&(t.display.maxLine=c,t.display.maxLineLength=f,t.display.maxLineChanged=!0)}null!=i&&t&&this.collapsed&&dn(t,i,o+1),this.lines.length=0,this.explicitlyCleared=!0,this.atomic&&this.doc.cantEdit&&(this.doc.cantEdit=!1,t&&pi(t.doc)),t&&Lt(t,"markerCleared",t,this),r&&tn(t),this.parent&&this.parent.clear()}},zi.prototype.find=function(e,t){var r=this;null==e&&"bookmark"==this.type&&(e=1);for(var n,i,o=0;o<this.lines.length;++o){var l=r.lines[o],s=j(l.markedSpans,r);if(null!=s.from&&(n=H(t?l:A(l),s.from),e==-1))return n;if(null!=s.to&&(i=H(t?l:A(l),s.to),1==e))return i}return n&&{from:n,to:i}},zi.prototype.changed=function(){var e=this.find(-1,!0),t=this,r=this.doc.cm;e&&r&&un(r,function(){var n=e.line,i=A(e.line),o=qt(r,i);if(o&&(nr(o),r.curOp.selectionChanged=r.curOp.forceUpdate=!0),r.curOp.updateMaxLine=!0,!he(t.doc,n)&&null!=t.height){var l=t.height;t.height=null;var s=Ft(t)-l;s&&N(n,n.height+s)}})},zi.prototype.attachLine=function(e){if(!this.lines.length&&this.doc.cm){var t=this.doc.cm.curOp;t.maybeHiddenMarkers&&h(t.maybeHiddenMarkers,this)!=-1||(t.maybeUnhiddenMarkers||(t.maybeUnhiddenMarkers=[])).push(this)}this.lines.push(e)},zi.prototype.detachLine=function(e){
|
5 |
-
if(this.lines.splice(h(this.lines,e),1),!this.lines.length&&this.doc.cm){var t=this.doc.cm.curOp;(t.maybeHiddenMarkers||(t.maybeHiddenMarkers=[])).push(this)}},Pe(Ri),Ri.prototype.clear=function(){var e=this;if(!this.explicitlyCleared){this.explicitlyCleared=!0;for(var t=0;t<this.markers.length;++t)e.markers[t].clear();Lt(this,"clear")}},Ri.prototype.find=function(e,t){return this.primary.find(e,t)};var ss=0,as=function(e,t,r,n){if(!(this instanceof as))return new as(e,t,r,n);null==r&&(r=0),Hi.call(this,[new Di([new at("",null)])]),this.first=r,this.scrollTop=this.scrollLeft=0,this.cantEdit=!1,this.cleanGeneration=1,this.frontier=r;var i=H(r,0);this.sel=Hn(i),this.history=new jn(null),this.id=++ss,this.modeOption=t,this.lineSep=n,this.extend=!1,"string"==typeof e&&(e=this.splitLines(e)),Un(this,{from:i,to:i,text:e}),fi(this,Hn(i),Ml)};as.prototype=b(Hi.prototype,{constructor:as,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=k(this,this.first,this.first+this.size);return e===!1?t:t.join(e||this.lineSeparator())},setValue:hn(function(e){var t=H(this.first,0),r=this.first+this.size-1;xi(this,{from:t,to:H(r,T(this,r).text.length),text:this.splitLines(e),origin:"setValue",full:!0},!0),fi(this,Hn(t))}),replaceRange:function(e,t,r,n){t=R(this,t),r=r?R(this,r):t,ki(this,e,t,r,n)},getRange:function(e,t,r){var n=M(this,R(this,e),R(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){if(W(this,e))return T(this,e)},getLineNumber:function(e){return A(e)},getLineHandleVisualStart:function(e){return"number"==typeof e&&(e=T(this,e)),ae(e)},lineCount:function(){return this.size},firstLine:function(){return this.first},lastLine:function(){return this.first+this.size-1},clipPos:function(e){return R(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:hn(function(e,t,r){ai(this,R(this,"number"==typeof e?H(e,t||0):e),null,r)}),setSelection:hn(function(e,t,r){ai(this,R(this,e),R(this,t||e),r)}),extendSelection:hn(function(e,t,r){oi(this,R(this,e),t&&R(this,t),r)}),extendSelections:hn(function(e,t){li(this,G(this,e),t)}),extendSelectionsBy:hn(function(e,t){var r=v(this.sel.ranges,e);li(this,G(this,r),t)}),setSelections:hn(function(e,t,r){var n=this;if(e.length){for(var i=[],o=0;o<e.length;o++)i[o]=new Wn(R(n,e[o].anchor),R(n,e[o].head));null==t&&(t=Math.min(e.length-1,this.sel.primIndex)),fi(this,Dn(i,t),r)}}),addSelection:hn(function(e,t,r){var n=this.sel.ranges.slice(0);n.push(new Wn(R(this,e),R(this,t||e))),fi(this,Dn(n,n.length-1),r)}),getSelection:function(e){for(var t,r=this,n=this.sel.ranges,i=0;i<n.length;i++){var o=M(r,n[i].from(),n[i].to());t=t?t.concat(o):o}return e===!1?t:t.join(e||this.lineSeparator())},getSelections:function(e){for(var t=this,r=[],n=this.sel.ranges,i=0;i<n.length;i++){var o=M(t,n[i].from(),n[i].to());e!==!1&&(o=o.join(e||t.lineSeparator())),r[i]=o}return r},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:hn(function(e,t,r){for(var n=this,i=[],o=this.sel,l=0;l<o.ranges.length;l++){var s=o.ranges[l];i[l]={from:s.from(),to:s.to(),text:n.splitLines(e[l]),origin:r}}for(var a=t&&"end"!=t&&Fn(this,i,t),u=i.length-1;u>=0;u--)xi(n,i[u]);a?ci(this,a):this.cm&&Qr(this.cm)}),undo:hn(function(){Si(this,"undo")}),redo:hn(function(){Si(this,"redo")}),undoSelection:hn(function(){Si(this,"undo",!0)}),redoSelection:hn(function(){Si(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 i=0;i<e.undone.length;i++)e.undone[i].ranges||++r;return{undo:t,redo:r}},clearHistory:function(){this.history=new jn(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:ni(this.history.done),undone:ni(this.history.undone)}},setHistory:function(e){var t=this.history=new jn(this.history.maxGeneration);t.done=ni(e.done.slice(0),null,!0),t.undone=ni(e.undone.slice(0),null,!0)},setGutterMarker:hn(function(e,t,r){return Wi(this,e,"gutter",function(e){var n=e.gutterMarkers||(e.gutterMarkers={});return n[t]=r,!r&&C(n)&&(e.gutterMarkers=null),!0})}),clearGutter:hn(function(e){var t=this;this.iter(function(r){r.gutterMarkers&&r.gutterMarkers[e]&&Wi(t,r,"gutter",function(){return r.gutterMarkers[e]=null,C(r.gutterMarkers)&&(r.gutterMarkers=null),!0})})}),lineInfo:function(e){var t;if("number"==typeof e){if(!W(this,e))return null;if(t=e,e=T(this,e),!e)return null}else if(t=A(e),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}},addLineClass:hn(function(t,r,n){return Wi(this,t,"gutter"==r?"gutter":"class",function(t){var i="text"==r?"textClass":"background"==r?"bgClass":"gutter"==r?"gutterClass":"wrapClass";if(t[i]){if(e(n).test(t[i]))return!1;t[i]+=" "+n}else t[i]=n;return!0})}),removeLineClass:hn(function(t,r,n){return Wi(this,t,"gutter"==r?"gutter":"class",function(t){var i="text"==r?"textClass":"background"==r?"bgClass":"gutter"==r?"gutterClass":"wrapClass",o=t[i];if(!o)return!1;if(null==n)t[i]=null;else{var l=o.match(e(n));if(!l)return!1;var s=l.index+l[0].length;t[i]=o.slice(0,l.index)+(l.index&&s!=o.length?" ":"")+o.slice(s)||null}return!0})}),addLineWidget:hn(function(e,t,r){return Ii(this,e,t,r)}),removeLineWidget:function(e){e.clear()},markText:function(e,t,r){return Fi(this,R(this,e),R(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=R(this,e),Fi(this,e,e,r,"bookmark")},findMarksAt:function(e){e=R(this,e);var t=[],r=T(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=R(this,e),t=R(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];null!=a.to&&i==e.line&&e.ch>=a.to||null==a.from&&i!=e.line||null!=a.from&&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,n=this.lineSeparator().length;return this.iter(function(i){var o=i.text.length+n;return o>e?(t=e,!0):(e-=o,void++r)}),R(this,H(r,t))},indexFromPos:function(e){e=R(this,e);var t=e.ch;if(e.line<this.first||e.ch<0)return 0;var r=this.lineSeparator().length;return this.iter(this.first,e.line,function(e){t+=e.text.length+r}),t},copy:function(e){var t=new as(k(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 as(k(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}],Ui(n,Gi(this)),n},unlinkDoc:function(e){var t=this;if(e instanceof Wo&&(e=e.doc),this.linked)for(var r=0;r<this.linked.length;++r){var n=t.linked[r];if(n.doc==e){t.linked.splice(r,1),e.unlinkDoc(t),Vi(Gi(t));break}}if(e.history==this.history){var i=[e.id];Vn(e,function(e){return i.push(e.id)},!0),e.history=new jn(null),e.history.done=ni(this.history.done,i),e.history.undone=ni(this.history.undone,i)}},iterLinkedDocs:function(e){Vn(this,e)},getMode:function(){return this.mode},getEditor:function(){return this.cm},splitLines:function(e){return this.lineSep?e.split(this.lineSep):Rl(e)},lineSeparator:function(){return this.lineSep||"\n"}}),as.prototype.eachLine=as.prototype.iter;for(var us=0,cs=!1,fs={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"},hs=0;hs<10;hs++)fs[hs+48]=fs[hs+96]=String(hs);for(var ds=65;ds<=90;ds++)fs[ds]=String.fromCharCode(ds);for(var ps=1;ps<=12;ps++)fs[ps+111]=fs[ps+63235]="F"+ps;var gs={};gs.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"},gs.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"},gs.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","Ctrl-O":"openLine"},gs.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"]},gs["default"]=dl?gs.macDefault:gs.pcDefault;var vs,ms,ys={selectAll:bi,singleSelection:function(e){return e.setSelection(e.getCursor("anchor"),e.getCursor("head"),Ml)},killLine:function(e){return io(e,function(t){if(t.empty()){var r=T(e.doc,t.head.line).text.length;return t.head.ch==r&&t.head.line<e.lastLine()?{from:t.head,to:H(t.head.line+1,0)}:{from:t.head,to:H(t.head.line,r)}}return{from:t.from(),to:t.to()}})},deleteLine:function(e){return io(e,function(t){return{from:H(t.from().line,0),to:R(e.doc,H(t.to().line+1,0))}})},delLineLeft:function(e){return io(e,function(e){return{from:H(e.from().line,0),to:e.from()}})},delWrappedLineLeft:function(e){return io(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){return io(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){return e.undo()},redo:function(e){return e.redo()},undoSelection:function(e){return e.undoSelection()},redoSelection:function(e){return e.redoSelection()},goDocStart:function(e){return e.extendSelection(H(e.firstLine(),0))},goDocEnd:function(e){return e.extendSelection(H(e.lastLine()))},goLineStart:function(e){return e.extendSelectionsBy(function(t){return oo(e,t.head.line)},{origin:"+move",bias:1})},goLineStartSmart:function(e){return e.extendSelectionsBy(function(t){return so(e,t.head)},{origin:"+move",bias:1})},goLineEnd:function(e){return e.extendSelectionsBy(function(t){return lo(e,t.head.line)},{origin:"+move",bias:-1})},goLineRight:function(e){return 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")},Nl)},goLineLeft:function(e){return e.extendSelectionsBy(function(t){var r=e.charCoords(t.head,"div").top+5;return e.coordsChar({left:0,top:r},"div")},Nl)},goLineLeftSmart:function(e){return 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},Nl)},goLineUp:function(e){return e.moveV(-1,"line")},goLineDown:function(e){return e.moveV(1,"line")},goPageUp:function(e){return e.moveV(-1,"page")},goPageDown:function(e){return e.moveV(1,"page")},goCharLeft:function(e){return e.moveH(-1,"char")},goCharRight:function(e){return e.moveH(1,"char")},goColumnLeft:function(e){return e.moveH(-1,"column")},goColumnRight:function(e){return e.moveH(1,"column")},goWordLeft:function(e){return e.moveH(-1,"word")},goGroupRight:function(e){return e.moveH(1,"group")},goGroupLeft:function(e){return e.moveH(-1,"group")},goWordRight:function(e){return e.moveH(1,"word")},delCharBefore:function(e){return e.deleteH(-1,"char")},delCharAfter:function(e){return e.deleteH(1,"char")},delWordBefore:function(e){return e.deleteH(-1,"word")},delWordAfter:function(e){return e.deleteH(1,"word")},delGroupBefore:function(e){return e.deleteH(-1,"group")},delGroupAfter:function(e){return e.deleteH(1,"group")},indentAuto:function(e){return e.indentSelection("smart")},indentMore:function(e){return e.indentSelection("add")},indentLess:function(e){return e.indentSelection("subtract")},insertTab:function(e){return e.replaceSelection("\t")},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=c(e.getLine(o.line),o.ch,n);t.push(p(n-l%n))}e.replaceSelections(t)},defaultTab:function(e){e.somethingSelected()?e.indentSelection("add"):e.execCommand("insertTab")},transposeChars:function(e){return un(e,function(){for(var t=e.listSelections(),r=[],n=0;n<t.length;n++)if(t[n].empty()){var i=t[n].head,o=T(e.doc,i.line).text;if(o)if(i.ch==o.length&&(i=new H(i.line,i.ch-1)),i.ch>0)i=new H(i.line,i.ch+1),e.replaceRange(o.charAt(i.ch-1)+o.charAt(i.ch-2),H(i.line,i.ch-2),i,"+transpose");else if(i.line>e.doc.first){var l=T(e.doc,i.line-1).text;l&&(i=new H(i.line,1),e.replaceRange(o.charAt(0)+e.doc.lineSeparator()+l.charAt(l.length-1),H(i.line-1,l.length-1),i,"+transpose"))}r.push(new Wn(i,i))}e.setSelections(r)})},newlineAndIndent:function(e){return un(e,function(){for(var t=e.listSelections(),r=t.length-1;r>=0;r--)e.replaceRange(e.doc.lineSeparator(),t[r].anchor,t[r].head,"+input");t=e.listSelections();for(var n=0;n<t.length;n++)e.indentLine(t[n].from().line,null,!0);Qr(e)})},openLine:function(e){return e.replaceSelection("\n","start")},toggleOverwrite:function(e){return e.toggleOverwrite()}},bs=new f,ws=null,xs={toString:function(){return"CodeMirror.Init"}},Cs={},Ss={};Wo.defaults=Cs,Wo.optionHandlers=Ss;var Ls=[];Wo.defineInitHook=function(e){return Ls.push(e)};var Ts=null,Ms=function(e){this.cm=e,this.lastAnchorNode=this.lastAnchorOffset=this.lastFocusNode=this.lastFocusOffset=null,this.polling=new f,this.composing=null,this.gracePeriod=!1,this.readDOMTimeout=null};Ms.prototype.init=function(e){function t(e){if(!We(i,e)){if(i.somethingSelected())Po({lineWise:!1,text:i.getSelections()}),"cut"==e.type&&i.replaceSelection("",null,"cut");else{if(!i.options.lineWiseCopyCut)return;var t=Fo(i);Po({lineWise:!0,text:t.text}),"cut"==e.type&&i.operation(function(){i.setSelections(t.ranges,0,Ml),i.replaceSelection("",null,"cut")})}if(e.clipboardData){e.clipboardData.clearData();var r=Ts.text.join("\n");if(e.clipboardData.setData("Text",r),e.clipboardData.getData("Text")==r)return void e.preventDefault()}var l=Bo(),s=l.firstChild;i.display.lineSpace.insertBefore(l,i.display.lineSpace.firstChild),s.value=Ts.text.join("\n");var a=document.activeElement;xl(s),setTimeout(function(){i.display.lineSpace.removeChild(l),a.focus(),a==o&&n.showPrimarySelection()},50)}}var r=this,n=this,i=n.cm,o=n.div=e.lineDiv;Ro(o,i.options.spellcheck),zl(o,"paste",function(e){We(i,e)||Io(e,i)||nl<=11&&setTimeout(cn(i,function(){n.pollContent()||dn(i)}),20)}),zl(o,"compositionstart",function(e){r.composing={data:e.data,done:!1}}),zl(o,"compositionupdate",function(e){r.composing||(r.composing={data:e.data,done:!1})}),zl(o,"compositionend",function(e){r.composing&&(e.data!=r.composing.data&&r.readFromDOMSoon(),r.composing.done=!0)}),zl(o,"touchstart",function(){return n.forceCompositionEnd()}),zl(o,"input",function(){r.composing||r.readFromDOMSoon()}),zl(o,"copy",t),zl(o,"cut",t)},Ms.prototype.prepareSelection=function(){var e=Tr(this.cm,!1);return e.focus=this.cm.state.focused,e},Ms.prototype.showSelection=function(e,t){e&&this.cm.display.view.length&&((e.focus||t)&&this.showPrimarySelection(),this.showMultipleSelections(e))},Ms.prototype.showPrimarySelection=function(){var e=window.getSelection(),t=this.cm.doc.sel.primary(),r=Yo(this.cm,e.anchorNode,e.anchorOffset),n=Yo(this.cm,e.focusNode,e.focusOffset);if(!r||r.bad||!n||n.bad||0!=P(z(r,n),t.from())||0!=P(I(r,n),t.to())){var i=Ko(this.cm,t.from()),o=Ko(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};var c;try{c=ml(i.node,i.offset,o.offset,o.node)}catch(f){}c&&(!Jo&&this.cm.state.focused?(e.collapse(i.node,i.offset),c.collapsed||(e.removeAllRanges(),e.addRange(c))):(e.removeAllRanges(),e.addRange(c)),s&&null==e.anchorNode?e.addRange(s):Jo&&this.startGracePeriod()),this.rememberSelection()}}},Ms.prototype.startGracePeriod=function(){var e=this;clearTimeout(this.gracePeriod),this.gracePeriod=setTimeout(function(){e.gracePeriod=!1,e.selectionChanged()&&e.cm.operation(function(){return e.cm.curOp.selectionChanged=!0})},20)},Ms.prototype.showMultipleSelections=function(e){r(this.cm.display.cursorDiv,e.cursors),r(this.cm.display.selectionDiv,e.selection)},Ms.prototype.rememberSelection=function(){var e=window.getSelection();this.lastAnchorNode=e.anchorNode,this.lastAnchorOffset=e.anchorOffset,this.lastFocusNode=e.focusNode,this.lastFocusOffset=e.focusOffset},Ms.prototype.selectionInEditor=function(){var e=window.getSelection();if(!e.rangeCount)return!1;var t=e.getRangeAt(0).commonAncestorContainer;return i(this.div,t)},Ms.prototype.focus=function(){"nocursor"!=this.cm.options.readOnly&&(this.selectionInEditor()||this.showSelection(this.prepareSelection(),!0),this.div.focus())},Ms.prototype.blur=function(){this.div.blur()},Ms.prototype.getField=function(){return this.div},Ms.prototype.supportsTouch=function(){return!0},Ms.prototype.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():un(this.cm,function(){return t.cm.curOp.selectionChanged=!0}),this.polling.set(this.cm.options.pollInterval,e)},Ms.prototype.selectionChanged=function(){var e=window.getSelection();return e.anchorNode!=this.lastAnchorNode||e.anchorOffset!=this.lastAnchorOffset||e.focusNode!=this.lastFocusNode||e.focusOffset!=this.lastFocusOffset},Ms.prototype.pollSelection=function(){if(!this.composing&&null==this.readDOMTimeout&&!this.gracePeriod&&this.selectionChanged()){var e=window.getSelection(),t=this.cm;this.rememberSelection();var r=Yo(t,e.anchorNode,e.anchorOffset),n=Yo(t,e.focusNode,e.focusOffset);r&&n&&un(t,function(){fi(t.doc,Hn(r,n),Ml),(r.bad||n.bad)&&(t.curOp.selectionChanged=!0)})}},Ms.prototype.pollContent=function(){null!=this.readDOMTimeout&&(clearTimeout(this.readDOMTimeout),this.readDOMTimeout=null);var e=this.cm,t=e.display,r=e.doc.sel.primary(),n=r.from(),i=r.to();if(0==n.ch&&n.line>e.firstLine()&&(n=H(n.line-1,T(e.doc,n.line-1).length)),i.ch==T(e.doc,i.line).text.length&&i.line<e.lastLine()&&(i=H(i.line+1,0)),n.line<t.viewFrom||i.line>t.viewTo-1)return!1;var o,l,s;n.line==t.viewFrom||0==(o=Sr(e,n.line))?(l=A(t.view[0].line),s=t.view[0].node):(l=A(t.view[o].line),s=t.view[o-1].node.nextSibling);var a,u,c=Sr(e,i.line);if(c==t.view.length-1?(a=t.viewTo-1,u=t.lineDiv.lastChild):(a=A(t.view[c+1].line)-1,u=t.view[c+1].node.previousSibling),!s)return!1;for(var f=e.doc.splitLines(Xo(e,s,u,l,a)),h=M(e.doc,H(l,0),H(a,T(e.doc,a).text.length));f.length>1&&h.length>1;)if(g(f)==g(h))f.pop(),h.pop(),a--;else{if(f[0]!=h[0])break;f.shift(),h.shift(),l++}for(var d=0,p=0,v=f[0],m=h[0],y=Math.min(v.length,m.length);d<y&&v.charCodeAt(d)==m.charCodeAt(d);)++d;for(var b=g(f),w=g(h),x=Math.min(b.length-(1==f.length?d:0),w.length-(1==h.length?d:0));p<x&&b.charCodeAt(b.length-p-1)==w.charCodeAt(w.length-p-1);)++p;f[f.length-1]=b.slice(0,b.length-p).replace(/^\u200b+/,""),f[0]=f[0].slice(d).replace(/\u200b+$/,"");var C=H(l,d),S=H(a,h.length?g(h).length-p:0);return f.length>1||f[0]||P(C,S)?(ki(e.doc,f,C,S,"+input"),!0):void 0},Ms.prototype.ensurePolled=function(){this.forceCompositionEnd()},Ms.prototype.reset=function(){this.forceCompositionEnd()},Ms.prototype.forceCompositionEnd=function(){this.composing&&(clearTimeout(this.readDOMTimeout),this.composing=null,this.pollContent()||dn(this.cm),this.div.blur(),this.div.focus())},Ms.prototype.readFromDOMSoon=function(){var e=this;null==this.readDOMTimeout&&(this.readDOMTimeout=setTimeout(function(){if(e.readDOMTimeout=null,e.composing){if(!e.composing.done)return;e.composing=null}!e.cm.isReadOnly()&&e.pollContent()||un(e.cm,function(){return dn(e.cm)})},80))},Ms.prototype.setUneditable=function(e){e.contentEditable="false"},Ms.prototype.onKeyPress=function(e){e.preventDefault(),this.cm.isReadOnly()||cn(this.cm,Eo)(this.cm,String.fromCharCode(null==e.charCode?e.keyCode:e.charCode),0)},Ms.prototype.readOnlyChanged=function(e){this.div.contentEditable=String("nocursor"!=e)},Ms.prototype.onContextMenu=function(){},Ms.prototype.resetPosition=function(){},Ms.prototype.needsContentAttribute=!0;var ks=function(e){this.cm=e,this.prevInput="",this.pollingFast=!1,this.polling=new f,this.inaccurateSelection=!1,this.hasSelection=!1,this.composing=null};ks.prototype.init=function(e){function t(e){if(!We(i,e)){if(i.somethingSelected())Po({lineWise:!1,text:i.getSelections()}),n.inaccurateSelection&&(n.prevInput="",n.inaccurateSelection=!1,l.value=Ts.text.join("\n"),xl(l));else{if(!i.options.lineWiseCopyCut)return;var t=Fo(i);Po({lineWise:!0,text:t.text}),"cut"==e.type?i.setSelections(t.ranges,null,Ml):(n.prevInput="",l.value=t.text.join("\n"),xl(l))}"cut"==e.type&&(i.state.cutIncoming=!0)}}var r=this,n=this,i=this.cm,o=this.wrapper=Bo(),l=this.textarea=o.firstChild;e.wrapper.insertBefore(o,e.wrapper.firstChild),fl&&(l.style.width="0px"),zl(l,"input",function(){rl&&nl>=9&&r.hasSelection&&(r.hasSelection=null),n.poll()}),zl(l,"paste",function(e){We(i,e)||Io(e,i)||(i.state.pasteIncoming=!0,n.fastPoll())}),zl(l,"cut",t),zl(l,"copy",t),zl(e.scroller,"paste",function(t){Rt(e,t)||We(i,t)||(i.state.pasteIncoming=!0,n.focus())}),zl(e.lineSpace,"selectstart",function(t){Rt(e,t)||Ee(t)}),zl(l,"compositionstart",function(){var e=i.getCursor("from");n.composing&&n.composing.range.clear(),n.composing={start:e,range:i.markText(e,i.getCursor("to"),{className:"CodeMirror-composing"})}}),zl(l,"compositionend",function(){n.composing&&(n.poll(),n.composing.range.clear(),n.composing=null)})},ks.prototype.prepareSelection=function(){var e=this.cm,t=e.display,r=e.doc,n=Tr(e);if(e.options.moveInputWithCursor){var i=fr(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},ks.prototype.showSelection=function(e){var t=this.cm,n=t.display;r(n.cursorDiv,e.cursors),r(n.selectionDiv,e.selection),null!=e.teTop&&(this.wrapper.style.top=e.teTop+"px",this.wrapper.style.left=e.teLeft+"px")},ks.prototype.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=Gl&&(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&&xl(this.textarea),rl&&nl>=9&&(this.hasSelection=l)}else e||(this.prevInput=this.textarea.value="",rl&&nl>=9&&(this.hasSelection=null));this.inaccurateSelection=t}},ks.prototype.getField=function(){return this.textarea},ks.prototype.supportsTouch=function(){return!1},ks.prototype.focus=function(){if("nocursor"!=this.cm.options.readOnly&&(!hl||o()!=this.textarea))try{this.textarea.focus()}catch(e){}},ks.prototype.blur=function(){this.textarea.blur()},ks.prototype.resetPosition=function(){this.wrapper.style.top=this.wrapper.style.left=0},ks.prototype.receivedFocus=function(){this.slowPoll()},ks.prototype.slowPoll=function(){var e=this;this.pollingFast||this.polling.set(this.cm.options.pollInterval,function(){e.poll(),e.cm.state.focused&&e.slowPoll()})},ks.prototype.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)},ks.prototype.poll=function(){var e=this,t=this.cm,r=this.textarea,n=this.prevInput;if(this.contextMenuPending||!t.state.focused||Bl(r)&&!n&&!this.composing||t.isReadOnly()||t.options.disableInput||t.state.keySeq)return!1;var i=r.value;if(i==n&&!t.somethingSelected())return!1;if(rl&&nl>=9&&this.hasSelection===i||dl&&/[\uf700-\uf7ff]/.test(i))return t.display.input.reset(),!1;if(t.doc.sel==t.display.selForContextMenu){var o=i.charCodeAt(0);if(8203!=o||n||(n=""),8666==o)return this.reset(),this.cm.execCommand("undo")}for(var l=0,s=Math.min(n.length,i.length);l<s&&n.charCodeAt(l)==i.charCodeAt(l);)++l;return un(t,function(){Eo(t,i.slice(l),n.length-l,null,e.composing?"*compose":null),i.length>1e3||i.indexOf("\n")>-1?r.value=e.prevInput="":e.prevInput=i,e.composing&&(e.composing.range.clear(),e.composing.range=t.markText(e.composing.start,t.getCursor("to"),{className:"CodeMirror-composing"}))}),!0},ks.prototype.ensurePolled=function(){this.pollingFast&&this.poll()&&(this.pollingFast=!1)},ks.prototype.onKeyPress=function(){rl&&nl>=9&&(this.hasSelection=null),this.fastPoll()},ks.prototype.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.cssText=f,l.style.cssText=c,rl&&nl<9&&o.scrollbars.setScrollTop(o.scroller.scrollTop=a),null!=l.selectionStart){(!rl||rl&&nl<9)&&t();var e=0,r=function(){o.selForContextMenu==i.doc.sel&&0==l.selectionStart&&l.selectionEnd>0&&""==n.prevInput?cn(i,bi)(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=Cr(i,e),a=o.scroller.scrollTop;if(s&&!sl){var u=i.options.resetSelectionOnContextMenu;u&&i.doc.sel.contains(s)==-1&&cn(i,fi)(i.doc,Hn(s),Ml);var c=l.style.cssText,f=n.wrapper.style.cssText;n.wrapper.style.cssText="position: absolute";var h=n.wrapper.getBoundingClientRect();l.style.cssText="position: absolute; width: 30px; height: 30px;\n top: "+(e.clientY-h.top-5)+"px; left: "+(e.clientX-h.left-5)+"px;\n z-index: 1000; background: "+(rl?"rgba(255, 255, 255, .05)":"transparent")+";\n outline: none; border-width: 0; outline: none; overflow: hidden; opacity: .05; filter: alpha(opacity=5);";var d;if(il&&(d=window.scrollY),o.input.focus(),il&&window.scrollTo(null,d),o.input.reset(),i.somethingSelected()||(l.value=n.prevInput=" "),n.contextMenuPending=!0,o.selForContextMenu=i.doc.sel,clearTimeout(o.detectingSelectAll),rl&&nl>=9&&t(),bl){Fe(e);var p=function(){Ae(window,"mouseup",p),setTimeout(r,20)};zl(window,"mouseup",p)}else setTimeout(r,50)}},ks.prototype.readOnlyChanged=function(e){e||this.reset()},ks.prototype.setUneditable=function(){},ks.prototype.needsContentAttribute=!1,ko(Wo),Go(Wo);var Ns="iter insert remove copy getEditor constructor".split(" ");for(var As in as.prototype)as.prototype.hasOwnProperty(As)&&h(Ns,As)<0&&(Wo.prototype[As]=function(e){return function(){return e.apply(this.doc,arguments)}}(as.prototype[As]));return Pe(as),Wo.inputStyles={textarea:ks,contenteditable:Ms},Wo.defineMode=function(e){Wo.defaults.mode||"null"==e||(Wo.defaults.mode=e),Ke.apply(this,arguments)},Wo.defineMIME=je,Wo.defineMode("null",function(){return{token:function(e){return e.skipToEnd()}}}),Wo.defineMIME("text/plain","null"),Wo.defineExtension=function(e,t){Wo.prototype[e]=t},Wo.defineDocExtension=function(e,t){as.prototype[e]=t},Wo.fromTextArea=$o,qo(Wo),Wo.version="5.23.0",Wo});
|
|
1 |
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):e.CodeMirror=t()}(this,function(){"use strict";function e(e){return new RegExp("(^|\\s)"+e+"(?:$|\\s)\\s*")}function t(e){for(var t=e.childNodes.length;t>0;--t)e.removeChild(e.firstChild);return e}function r(e,r){return t(e).appendChild(r)}function n(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 i(e,t,r,i){var o=n(e,t,r,i);return o.setAttribute("role","presentation"),o}function o(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)}function l(){var e;try{e=document.activeElement}catch(t){e=document.body||null}for(;e&&e.shadowRoot&&e.shadowRoot.activeElement;)e=e.shadowRoot.activeElement;return e}function s(t,r){var n=t.className;e(r).test(n)||(t.className+=(n?" ":"")+r)}function a(t,r){for(var n=t.split(" "),i=0;i<n.length;i++)n[i]&&!e(n[i]).test(r)&&(r+=" "+n[i]);return r}function u(e){var t=Array.prototype.slice.call(arguments,1);return function(){return e.apply(null,t)}}function c(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 f(e,t,r,n,i){null==t&&(t=e.search(/[^\s\u00a0]/),t==-1&&(t=e.length));for(var o=n||0,l=i||0;;){var s=e.indexOf("\t",o);if(s<0||s>=t)return l+(t-o);l+=s-o,l+=r-l%r,o=s+1}}function h(e,t){for(var r=0;r<e.length;++r)if(e[r]==t)return r;return-1}function d(e,t,r){for(var n=0,i=0;;){var o=e.indexOf("\t",n);o==-1&&(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 p(e){for(;Ol.length<=e;)Ol.push(g(Ol)+" ");return Ol[e]}function g(e){return e[e.length-1]}function v(e,t){for(var r=[],n=0;n<e.length;n++)r[n]=t(e[n],n);return r}function m(e,t,r){for(var n=0,i=r(t);n<e.length&&r(e[n])<=i;)n++;e.splice(n,0,t)}function y(){}function b(e,t){var r;return Object.create?r=Object.create(e):(y.prototype=e,r=new y),t&&c(t,r),r}function w(e){return/\w/.test(e)||e>""&&(e.toUpperCase()!=e.toLowerCase()||Wl.test(e))}function x(e,t){return t?!!(t.source.indexOf("\\w")>-1&&w(e))||t.test(e):w(e)}function C(e){for(var t in e)if(e.hasOwnProperty(t)&&e[t])return!1;return!0}function S(e){return e.charCodeAt(0)>=768&&Al.test(e)}function L(e,t,r){for(;(r<0?t>0:t<e.length)&&S(e.charAt(t));)t+=r;return t}function T(e,t,r){for(;;){if(Math.abs(t-r)<=1)return e(t)?t:r;var n=Math.floor((t+r)/2);e(n)?r=n:t=n}}function k(e,t,r){var o=this;this.input=r,o.scrollbarFiller=n("div",null,"CodeMirror-scrollbar-filler"),o.scrollbarFiller.setAttribute("cm-not-content","true"),o.gutterFiller=n("div",null,"CodeMirror-gutter-filler"),o.gutterFiller.setAttribute("cm-not-content","true"),o.lineDiv=i("div",null,"CodeMirror-code"),o.selectionDiv=n("div",null,null,"position: relative; z-index: 1"),o.cursorDiv=n("div",null,"CodeMirror-cursors"),o.measure=n("div",null,"CodeMirror-measure"),o.lineMeasure=n("div",null,"CodeMirror-measure"),o.lineSpace=i("div",[o.measure,o.lineMeasure,o.selectionDiv,o.cursorDiv,o.lineDiv],null,"position: relative; outline: none");var l=i("div",[o.lineSpace],"CodeMirror-lines");o.mover=n("div",[l],null,"position: relative"),o.sizer=n("div",[o.mover],"CodeMirror-sizer"),o.sizerWidth=null,o.heightForcer=n("div",null,null,"position: absolute; height: "+Ll+"px; width: 1px;"),o.gutters=n("div",null,"CodeMirror-gutters"),o.lineGutter=null,o.scroller=n("div",[o.sizer,o.heightForcer,o.gutters],"CodeMirror-scroll"),o.scroller.setAttribute("tabIndex","-1"),o.wrapper=n("div",[o.scrollbarFiller,o.gutterFiller,o.scroller],"CodeMirror"),el&&tl<8&&(o.gutters.style.zIndex=-1,o.scroller.style.paddingRight=0),rl||qo&&fl||(o.scroller.draggable=!0),e&&(e.appendChild?e.appendChild(o.wrapper):e(o.wrapper)),o.viewFrom=o.viewTo=t.first,o.reportedViewFrom=o.reportedViewTo=t.first,o.view=[],o.renderedView=null,o.externalMeasured=null,o.viewOffset=0,o.lastWrapHeight=o.lastWrapWidth=0,o.updateLineNumbers=null,o.nativeBarWidth=o.barHeight=o.barWidth=0,o.scrollbarsClipped=!1,o.lineNumWidth=o.lineNumInnerWidth=o.lineNumChars=null,o.alignWidgets=!1,o.cachedCharWidth=o.cachedTextHeight=o.cachedPaddingH=null,o.maxLine=null,o.maxLineLength=0,o.maxLineChanged=!1,o.wheelDX=o.wheelDY=o.wheelStartX=o.wheelStartY=null,o.shift=!1,o.selForContextMenu=null,o.activeTouch=null,r.init(o)}function M(e,t){if(t-=e.first,t<0||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(t<o){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 O(e,t,r){var n=[];return e.iter(t,r,function(e){n.push(e.text)}),n}function W(e,t){var r=t-e.height;if(r)for(var n=e;n;n=n.parent)n.height+=r}function A(e){if(null==e.parent)return null;for(var t=e.parent,r=h(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 D(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(t<o){e=i;continue e}t-=o,r+=i.chunkSize()}return r}while(!e.lines);for(var l=0;l<e.lines.length;++l){var s=e.lines[l],a=s.height;if(t<a)break;t-=a}return r+l}function H(e,t){return t>=e.first&&t<e.first+e.size}function P(e,t){return String(e.lineNumberFormatter(t+e.firstLineNumber))}function E(e,t,r){return void 0===r&&(r=null),this instanceof E?(this.line=e,this.ch=t,void(this.sticky=r)):new E(e,t,r)}function F(e,t){return e.line-t.line||e.ch-t.ch}function I(e,t){return e.sticky==t.sticky&&0==F(e,t)}function z(e){return E(e.line,e.ch)}function R(e,t){return F(e,t)<0?t:e}function B(e,t){return F(e,t)<0?e:t}function G(e,t){return Math.max(e.first,Math.min(t,e.first+e.size-1))}function U(e,t){if(t.line<e.first)return E(e.first,0);var r=e.first+e.size-1;return t.line>r?E(r,M(e,r).text.length):V(t,M(e,t.line).text.length)}function V(e,t){var r=e.ch;return null==r||r>t?E(e.line,t):r<0?E(e.line,0):e}function K(e,t){for(var r=[],n=0;n<t.length;n++)r[n]=U(e,t[n]);return r}function j(){Dl=!0}function X(){Hl=!0}function Y(e,t,r){this.marker=e,this.from=t,this.to=r}function _(e,t){if(e)for(var r=0;r<e.length;++r){var n=e[r];if(n.marker==t)return n}}function $(e,t){for(var r,n=0;n<e.length;++n)e[n]!=t&&(r||(r=[])).push(e[n]);return r}function q(e,t){e.markedSpans=e.markedSpans?e.markedSpans.concat([t]):[t],t.marker.attachLine(e)}function Z(e,t,r){var n;if(e)for(var 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 Y(l,o.from,a?null:o.to))}}return n}function Q(e,t,r){var n;if(e)for(var 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 Y(l,a?null:o.from-t,null==o.to?null:o.to-t))}}return n}function J(e,t){if(t.full)return null;var r=H(e,t.from.line)&&M(e,t.from.line).markedSpans,n=H(e,t.to.line)&&M(e,t.to.line).markedSpans;if(!r&&!n)return null;var i=t.from.ch,o=t.to.ch,l=0==F(t.from,t.to),s=Z(r,i,l),a=Q(n,o,l),u=1==t.text.length,c=g(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=_(a,h.marker);d?u&&(h.to=null==d.to?null:d.to+c):h.to=i}}if(a)for(var p=0;p<a.length;++p){var v=a[p];if(null!=v.to&&(v.to+=c),null==v.from){var m=_(s,v.marker);m||(v.from=c,u&&(s||(s=[])).push(v))}else v.from+=c,u&&(s||(s=[])).push(v)}s&&(s=ee(s)),a&&a!=s&&(a=ee(a));var y=[s];if(!u){var b,w=t.text.length-2;if(w>0&&s)for(var x=0;x<s.length;++x)null==s[x].to&&(b||(b=[])).push(new Y(s[x].marker,null,null));for(var C=0;C<w;++C)y.push(b);y.push(a)}return y}function ee(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 te(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&&h(n,r)!=-1||(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(!(F(u.to,s.from)<0||F(u.from,s.to)>0)){var c=[a,1],f=F(u.from,s.from),d=F(u.to,s.to);(f<0||!l.inclusiveLeft&&!f)&&c.push({from:u.from,to:s.from}),(d>0||!l.inclusiveRight&&!d)&&c.push({from:s.to,to:u.to}),i.splice.apply(i,c),a+=c.length-3}}return i}function re(e){var t=e.markedSpans;if(t){for(var r=0;r<t.length;++r)t[r].marker.detachLine(e);e.markedSpans=null}}function ne(e,t){if(t){for(var r=0;r<t.length;++r)t[r].marker.attachLine(e);e.markedSpans=t}}function ie(e){return e.inclusiveLeft?-1:0}function oe(e){return e.inclusiveRight?1:0}function le(e,t){var r=e.lines.length-t.lines.length;if(0!=r)return r;var n=e.find(),i=t.find(),o=F(n.from,i.from)||ie(e)-ie(t);if(o)return-o;var l=F(n.to,i.to)||oe(e)-oe(t);return l?l:t.id-e.id}function se(e,t){var r,n=Hl&&e.markedSpans;if(n)for(var i=void 0,o=0;o<n.length;++o)i=n[o],i.marker.collapsed&&null==(t?i.from:i.to)&&(!r||le(r,i.marker)<0)&&(r=i.marker);return r}function ae(e){return se(e,!0)}function ue(e){return se(e,!1)}function ce(e,t,r,n,i){var o=M(e,t),l=Hl&&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=F(u.from,r)||ie(a.marker)-ie(i),f=F(u.to,n)||oe(a.marker)-oe(i);if(!(c>=0&&f<=0||c<=0&&f>=0)&&(c<=0&&(a.marker.inclusiveRight&&i.inclusiveLeft?F(u.to,r)>=0:F(u.to,r)>0)||c>=0&&(a.marker.inclusiveRight&&i.inclusiveLeft?F(u.from,n)<=0:F(u.from,n)<0)))return!0}}}function fe(e){for(var t;t=ae(e);)e=t.find(-1,!0).line;return e}function he(e){for(var t;t=ue(e);)e=t.find(1,!0).line;return e}function de(e){for(var t,r;t=ue(e);)e=t.find(1,!0).line,(r||(r=[])).push(e);return r}function pe(e,t){var r=M(e,t),n=fe(r);return r==n?t:A(n)}function ge(e,t){if(t>e.lastLine())return t;var r,n=M(e,t);if(!ve(e,n))return t;for(;r=ue(n);)n=r.find(1,!0).line;return A(n)+1}function ve(e,t){var r=Hl&&t.markedSpans;if(r)for(var n=void 0,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&&me(e,t,n))return!0}}function me(e,t,r){if(null==r.to){var n=r.marker.find(1,!0);return me(e,n.line,_(n.line.markedSpans,r.marker))}if(r.marker.inclusiveRight&&r.to==t.text.length)return!0;for(var i=void 0,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)&&me(e,t,i))return!0}function ye(e){e=fe(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 l=0;l<o.children.length;++l){var s=o.children[l];if(s==r)break;t+=s.height}return t}function be(e){if(0==e.height)return 0;for(var t,r=e.text.length,n=e;t=ae(n);){var i=t.find(0,!0);n=i.from.line,r+=i.from.ch-i.to.ch}for(n=e;t=ue(n);){var o=t.find(0,!0);r-=n.text.length-o.from.ch,n=o.to.line,r+=n.text.length-o.to.ch}return r}function we(e){var t=e.display,r=e.doc;t.maxLine=M(r,r.first),t.maxLineLength=be(t.maxLine),t.maxLineChanged=!0,r.iter(function(e){var r=be(e);r>t.maxLineLength&&(t.maxLineLength=r,t.maxLine=e)})}function xe(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 Ce(e,t,r){var n;Pl=null;for(var i=0;i<e.length;++i){var o=e[i];if(o.from<t&&o.to>t)return i;o.to==t&&(o.from!=o.to&&"before"==r?n=i:Pl=i),o.from==t&&(o.from!=o.to&&"before"!=r?n=i:Pl=i)}return null!=n?n:Pl}function Se(e,t){var r=e.order;return null==r&&(r=e.order=El(e.text,t)),r}function Le(e,t,r){var n=L(e.text,t+r,r);return n<0||n>e.text.length?null:n}function Te(e,t,r){var n=Le(e,t.ch,r);return null==n?null:new E(t.line,n,r<0?"after":"before")}function ke(e,t,r,n,i){if(e){var o=Se(r,t.doc.direction);if(o){var l,s=i<0?g(o):o[0],a=i<0==(1==s.level),u=a?"after":"before";if(s.level>0){var c=qt(t,r);l=i<0?r.text.length-1:0;var f=Zt(t,c,l).top;l=T(function(e){return Zt(t,c,e).top==f},i<0==(1==s.level)?s.from:s.to-1,l),"before"==u&&(l=Le(r,l,1,!0))}else l=i<0?s.to:s.from;return new E(n,l,u)}}return new E(n,i<0?r.text.length:0,i<0?"before":"after")}function Me(e,t,r,n){var i=Se(t,e.doc.direction);if(!i)return Te(t,r,n);r.ch>=t.text.length?(r.ch=t.text.length,r.sticky="before"):r.ch<=0&&(r.ch=0,r.sticky="after");var o=Ce(i,r.ch,r.sticky),l=i[o];if("ltr"==e.doc.direction&&l.level%2==0&&(n>0?l.to>r.ch:l.from<r.ch))return Te(t,r,n);var s,a=function(e,r){return Le(t,e instanceof E?e.ch:e,r)},u=function(r){return e.options.lineWrapping?(s=s||qt(e,t),gr(e,t,s,r)):{begin:0,end:t.text.length}},c=u("before"==r.sticky?a(r,-1):r.ch);if("rtl"==e.doc.direction||1==l.level){var f=1==l.level==n<0,h=a(r,f?1:-1);if(null!=h&&(f?h<=l.to&&h<=c.end:h>=l.from&&h>=c.begin)){var d=f?"before":"after";return new E(r.line,h,d)}}var p=function(e,t,n){for(var o=function(e,t){return t?new E(r.line,a(e,1),"before"):new E(r.line,e,"after")};e>=0&&e<i.length;e+=t){var l=i[e],s=t>0==(1!=l.level),u=s?n.begin:a(n.end,-1);if(l.from<=u&&u<l.to)return o(u,s);if(u=s?l.from:a(l.to,-1),n.begin<=u&&u<n.end)return o(u,s)}},g=p(o+n,n,c);if(g)return g;var v=n>0?c.end:a(c.begin,-1);return null==v||n>0&&v==t.text.length||!(g=p(n>0?0:i.length-1,n,u(v)))?null:g}function Ne(e,t){return e._handlers&&e._handlers[t]||Fl}function Oe(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,i=n&&n[t];if(i){var o=h(i,r);o>-1&&(n[t]=i.slice(0,o).concat(i.slice(o+1)))}}}function We(e,t){var r=Ne(e,t);if(r.length)for(var n=Array.prototype.slice.call(arguments,2),i=0;i<r.length;++i)r[i].apply(null,n)}function Ae(e,t,r){return"string"==typeof t&&(t={type:t,preventDefault:function(){this.defaultPrevented=!0}}),We(e,r||t.type,e,t),Ie(t)||t.codemirrorIgnore}function De(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)h(r,t[n])==-1&&r.push(t[n])}function He(e,t){return Ne(e,t).length>0}function Pe(e){e.prototype.on=function(e,t){Il(this,e,t)},e.prototype.off=function(e,t){Oe(this,e,t)}}function Ee(e){e.preventDefault?e.preventDefault():e.returnValue=!1}function Fe(e){e.stopPropagation?e.stopPropagation():e.cancelBubble=!0}function Ie(e){return null!=e.defaultPrevented?e.defaultPrevented:0==e.returnValue}function ze(e){Ee(e),Fe(e)}function Re(e){return e.target||e.srcElement}function Be(e){var t=e.which;return null==t&&(1&e.button?t=1:2&e.button?t=3:4&e.button&&(t=2)),hl&&e.ctrlKey&&1==t&&(t=3),t}function Ge(e){if(null==Cl){var t=n("span","");r(e,n("span",[t,document.createTextNode("x")])),0!=e.firstChild.offsetHeight&&(Cl=t.offsetWidth<=1&&t.offsetHeight>2&&!(el&&tl<8))}var i=Cl?n("span",""):n("span"," ",null,"display: inline-block; width: 1px; margin-right: -1px");return i.setAttribute("cm-text",""),i}function Ue(e){if(null!=Sl)return Sl;var n=r(e,document.createTextNode("AخA")),i=vl(n,0,1).getBoundingClientRect(),o=vl(n,1,2).getBoundingClientRect();return t(e),!(!i||i.left==i.right)&&(Sl=o.right-i.right<3)}function Ve(e){if(null!=Ul)return Ul;var t=r(e,n("span","x")),i=t.getBoundingClientRect(),o=vl(t,0,1).getBoundingClientRect();return Ul=Math.abs(i.left-o.left)>1}function Ke(e,t){arguments.length>2&&(t.dependencies=Array.prototype.slice.call(arguments,2)),Vl[e]=t}function je(e,t){Kl[e]=t}function Xe(e){if("string"==typeof e&&Kl.hasOwnProperty(e))e=Kl[e];else if(e&&"string"==typeof e.name&&Kl.hasOwnProperty(e.name)){var t=Kl[e.name];"string"==typeof t&&(t={name:t}),e=b(t,e),e.name=t.name}else{if("string"==typeof e&&/^[\w\-]+\/[\w\-]+\+xml$/.test(e))return Xe("application/xml");if("string"==typeof e&&/^[\w\-]+\/[\w\-]+\+json$/.test(e))return Xe("application/json")}return"string"==typeof e?{name:e}:e||{name:"null"}}function Ye(e,t){t=Xe(t);var r=Vl[t.name];if(!r)return Ye(e,"text/plain");var n=r(e,t);if(jl.hasOwnProperty(t.name)){var i=jl[t.name];for(var o in i)i.hasOwnProperty(o)&&(n.hasOwnProperty(o)&&(n["_"+o]=n[o]),n[o]=i[o])}if(n.name=t.name,t.helperType&&(n.helperType=t.helperType),t.modeProps)for(var l in t.modeProps)n[l]=t.modeProps[l];return n}function _e(e,t){var r=jl.hasOwnProperty(e)?jl[e]:jl[e]={};c(t,r)}function $e(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}function qe(e,t){for(var r;e.innerMode&&(r=e.innerMode(t),r&&r.mode!=e);)t=r.state,e=r.mode;return r||{mode:e,state:t}}function Ze(e,t,r){return!e.startState||e.startState(t,r)}function Qe(e,t,r,n){var i=[e.state.modeGen],o={};lt(e,t.text,e.doc.mode,r,function(e,t){return i.push(e,t)},o,n);for(var l=function(r){var n=e.state.overlays[r],l=1,s=0;lt(e,t.text,n.mode,!0,function(e,t){for(var r=l;s<e;){var o=i[l];o>e&&i.splice(l,1,e,i[l+1],o),l+=2,s=Math.min(e,o)}if(t)if(n.opaque)i.splice(r,l-r,e,"overlay "+t),l=r+2;else for(;r<l;r+=2){var a=i[r+1];i[r+1]=(a?a+" ":"")+"overlay "+t}},o)},s=0;s<e.state.overlays.length;++s)l(s);return{styles:i,classes:o.bgClass||o.textClass?o:null}}function Je(e,t,r){if(!t.styles||t.styles[0]!=e.state.modeGen){var n=et(e,A(t)),i=Qe(e,t,t.text.length>e.options.maxHighlightLength?$e(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 et(e,t,r){var n=e.doc,i=e.display;if(!n.mode.startState)return!0;var o=st(e,t,r),l=o>n.first&&M(n,o-1).stateAfter;return l=l?$e(n.mode,l):Ze(n.mode),n.iter(o,t,function(r){tt(e,r.text,l);var s=o==t-1||o%5==0||o>=i.viewFrom&&o<i.viewTo;r.stateAfter=s?$e(n.mode,l):null,++o}),r&&(n.frontier=o),l}function tt(e,t,r,n){var i=e.doc.mode,o=new Xl(t,e.options.tabSize);for(o.start=o.pos=n||0,""==t&&rt(i,r);!o.eol();)nt(i,o,r),o.start=o.pos}function rt(e,t){if(e.blankLine)return e.blankLine(t);if(e.innerMode){var r=qe(e,t);return r.mode.blankLine?r.mode.blankLine(r.state):void 0}}function nt(e,t,r,n){for(var i=0;i<10;i++){n&&(n[0]=qe(e,r).mode);var o=e.token(t,r);if(t.pos>t.start)return o}throw new Error("Mode "+e.name+" failed to advance stream.")}function it(e,t,r,n){var i,o=function(e){return{start:f.start,end:f.pos,string:f.current(),type:i||null,state:e?$e(l.mode,c):c}},l=e.doc,s=l.mode;t=U(l,t);var a,u=M(l,t.line),c=et(e,t.line,r),f=new Xl(u.text,e.options.tabSize);for(n&&(a=[]);(n||f.pos<t.ch)&&!f.eol();)f.start=f.pos,i=nt(s,f,c),n&&a.push(o(!0));return n?a:o()}function ot(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 lt(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 Xl(t,e.options.tabSize),h=e.options.addModeClass&&[null];for(""==t&&ot(rt(r,n),o);!f.eol();){if(f.pos>e.options.maxHighlightLength?(s=!1,l&&tt(e,t,n,f.pos),f.pos=t.length,a=null):a=ot(nt(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+5e3),i(u,c);c=a}f.start=f.pos}for(;u<f.pos;){var p=Math.min(f.pos,u+5e3);i(p,c),u=p}}function st(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=M(o,s-1);if(a.stateAfter&&(!r||s<=o.frontier))return s;var u=f(a.text,null,e.options.tabSize);(null==i||n>u)&&(i=s-1,n=u)}return i}function at(e,t,r,n){e.text=t,e.stateAfter&&(e.stateAfter=null),e.styles&&(e.styles=null),null!=e.order&&(e.order=null),re(e),ne(e,r);var i=n?n(e):1;i!=e.height&&W(e,i)}function ut(e){e.parent=null,re(e)}function ct(e,t){if(!e||/^\s*$/.test(e))return null;var r=t.addModeClass?ql:$l;return r[e]||(r[e]=e.replace(/\S+/g,"cm-$&"))}function ft(e,t){var r=i("span",null,null,rl?"padding-right: .1px":null),n={pre:i("pre",[r],"CodeMirror-line"),content:r,col:0,pos:0,cm:e,trailingSpace:!1,splitSpaces:(el||rl)&&e.getOption("lineWrapping")};t.measure={};for(var o=0;o<=(t.rest?t.rest.length:0);o++){var l=o?t.rest[o-1]:t.line,s=void 0;n.pos=0,n.addToken=dt,Ue(e.display.measure)&&(s=Se(l,e.doc.direction))&&(n.addToken=gt(n.addToken,s)),n.map=[];var u=t!=e.display.externalMeasured&&A(l);mt(l,n,Je(e,l,u)),l.styleClasses&&(l.styleClasses.bgClass&&(n.bgClass=a(l.styleClasses.bgClass,n.bgClass||"")),l.styleClasses.textClass&&(n.textClass=a(l.styleClasses.textClass,n.textClass||""))),0==n.map.length&&n.map.push(0,0,n.content.appendChild(Ge(e.display.measure))),0==o?(t.measure.map=n.map,t.measure.cache={}):((t.measure.maps||(t.measure.maps=[])).push(n.map),(t.measure.caches||(t.measure.caches=[])).push({}))}if(rl){var c=n.content.lastChild;(/\bcm-tab\b/.test(c.className)||c.querySelector&&c.querySelector(".cm-tab"))&&(n.content.className="cm-tab-wrap-hack")}return We(e,"renderLine",e,t.line,n.pre),n.pre.className&&(n.textClass=a(n.pre.className,n.textClass||"")),n}function ht(e){var t=n("span","•","cm-invalidchar");return t.title="\\u"+e.charCodeAt(0).toString(16),t.setAttribute("aria-label",t.title),t}function dt(e,t,r,i,o,l,s){if(t){var a,u=e.splitSpaces?pt(t,e.trailingSpace):t,c=e.cm.state.specialChars,f=!1;if(c.test(t)){a=document.createDocumentFragment();for(var h=0;;){c.lastIndex=h;var d=c.exec(t),g=d?d.index-h:t.length-h;if(g){var v=document.createTextNode(u.slice(h,h+g));el&&tl<9?a.appendChild(n("span",[v])):a.appendChild(v),e.map.push(e.pos,e.pos+g,v),e.col+=g,e.pos+=g}if(!d)break;h+=g+1;var m=void 0;if("\t"==d[0]){var y=e.cm.options.tabSize,b=y-e.col%y;m=a.appendChild(n("span",p(b),"cm-tab")),m.setAttribute("role","presentation"),m.setAttribute("cm-text","\t"),e.col+=b}else"\r"==d[0]||"\n"==d[0]?(m=a.appendChild(n("span","\r"==d[0]?"␍":"","cm-invalidchar")),m.setAttribute("cm-text",d[0]),e.col+=1):(m=e.cm.options.specialCharPlaceholder(d[0]),m.setAttribute("cm-text",d[0]),el&&tl<9?a.appendChild(n("span",[m])):a.appendChild(m),e.col+=1);e.map.push(e.pos,e.pos+1,m),e.pos++}}else e.col+=t.length,a=document.createTextNode(u),e.map.push(e.pos,e.pos+t.length,a),el&&tl<9&&(f=!0),e.pos+=t.length;if(e.trailingSpace=32==u.charCodeAt(t.length-1),r||i||o||f||s){var w=r||"";i&&(w+=i),o&&(w+=o);var x=n("span",[a],w,s);return l&&(x.title=l),e.content.appendChild(x)}e.content.appendChild(a)}}function pt(e,t){if(e.length>1&&!/ /.test(e))return e;for(var r=t,n="",i=0;i<e.length;i++){var o=e.charAt(i);" "!=o||!r||i!=e.length-1&&32!=e.charCodeAt(i+1)||(o=" "),n+=o,r=" "==o}return n}function gt(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=void 0,h=0;h<t.length&&(f=t[h],!(f.to>u&&f.from<=u));h++);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 vt(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,e.trailingSpace=!1}function mt(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=void 0,w=0;w<n.length;++w){var x=n[w],C=x.marker;"bookmark"==C.type&&x.from==p&&C.widgetNode?y.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&&(b||(b=[])).push(C.endStyle,x.to),C.title&&!f&&(f=C.title),C.collapsed&&(!h||le(h.marker,C)<0)&&(h=x)):x.from>p&&m>x.from&&(m=x.from)}if(b)for(var S=0;S<b.length;S+=2)b[S+1]==m&&(u+=" "+b[S]);if(!h||h.from==p)for(var L=0;L<y.length;++L)vt(t,0,y[L]);if(h&&(h.from||0)==p){if(vt(t,(null==h.to?d+1:h.to)-p,h.marker,null==h.from),null==h.to)return;h.to==p&&(h=!1)}}if(p>=d)break;for(var T=Math.min(d,m);;){if(v){var k=p+v.length;if(!h){var M=k>T?v.slice(0,T-p):v;t.addToken(t,M,l?l+a:a,c,p+M.length==m?u:"",f,s)}if(k>=T){v=v.slice(T-p),p=T;break}p=k,c=""}v=i.slice(o,o=r[g++]),l=ct(r[g++],t.cm.options)}}else for(var N=1;N<r.length;N+=2)t.addToken(t,i.slice(o,o=r[N]),ct(r[N+1],t.cm.options))}function yt(e,t,r){this.line=t,this.rest=de(t),this.size=this.rest?A(g(this.rest))-r+1:1,this.node=this.text=null,this.hidden=ve(e,t)}function bt(e,t,r){for(var n,i=[],o=t;o<r;o=n){var l=new yt(e.doc,M(e.doc,o),o);n=o+l.size,i.push(l)}return i}function wt(e){Zl?Zl.ops.push(e):e.ownsGroup=Zl={ops:[e],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,t){var r=e.ownsGroup;if(r)try{xt(r)}finally{Zl=null,t(r)}}function St(e,t){var r=Ne(e,t);if(r.length){var n,i=Array.prototype.slice.call(arguments,2);Zl?n=Zl.delayedCallbacks:Ql?n=Ql:(n=Ql=[],setTimeout(Lt,0));for(var o=function(e){n.push(function(){return r[e].apply(null,i)})},l=0;l<r.length;++l)o(l)}}function Lt(){var e=Ql;Ql=null;for(var t=0;t<e.length;++t)e[t]()}function Tt(e,t,r,n){for(var i=0;i<t.changes.length;i++){var o=t.changes[i];"text"==o?Ot(e,t):"gutter"==o?At(e,t,r,n):"class"==o?Wt(e,t):"widget"==o&&Dt(e,t,n)}t.changes=null}function kt(e){return e.node==e.text&&(e.node=n("div",null,null,"position: relative"),e.text.parentNode&&e.text.parentNode.replaceChild(e.node,e.text),e.node.appendChild(e.text),el&&tl<8&&(e.node.style.zIndex=2)),e.node}function Mt(e,t){var r=t.bgClass?t.bgClass+" "+(t.line.bgClass||""):t.line.bgClass;if(r&&(r+=" CodeMirror-linebackground"),t.background)r?t.background.className=r:(t.background.parentNode.removeChild(t.background),t.background=null);else if(r){var i=kt(t);t.background=i.insertBefore(n("div",null,r),i.firstChild),e.display.input.setUneditable(t.background)}}function Nt(e,t){var r=e.display.externalMeasured;return r&&r.line==t.line?(e.display.externalMeasured=null,t.measure=r.measure,r.built):ft(e,t)}function Ot(e,t){var r=t.text.className,n=Nt(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,Wt(e,t)):r&&(t.text.className=r)}function Wt(e,t){Mt(e,t),t.line.wrapClass?kt(t).className=t.line.wrapClass:t.node!=t.text&&(t.node.className="");var r=t.textClass?t.textClass+" "+(t.line.textClass||""):t.line.textClass;t.text.className=r||""}function At(e,t,r,i){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 o=kt(t);t.gutterBackground=n("div",null,"CodeMirror-gutter-background "+t.line.gutterClass,"left: "+(e.options.fixedGutter?i.fixedPos:-i.gutterTotalWidth)+"px; width: "+i.gutterTotalWidth+"px"),e.display.input.setUneditable(t.gutterBackground),o.insertBefore(t.gutterBackground,t.text)}var l=t.line.gutterMarkers;if(e.options.lineNumbers||l){var s=kt(t),a=t.gutter=n("div",null,"CodeMirror-gutter-wrapper","left: "+(e.options.fixedGutter?i.fixedPos:-i.gutterTotalWidth)+"px");if(e.display.input.setUneditable(a),s.insertBefore(a,t.text),t.line.gutterClass&&(a.className+=" "+t.line.gutterClass),!e.options.lineNumbers||l&&l["CodeMirror-linenumbers"]||(t.lineNumber=a.appendChild(n("div",P(e.options,r),"CodeMirror-linenumber CodeMirror-gutter-elt","left: "+i.gutterLeft["CodeMirror-linenumbers"]+"px; width: "+e.display.lineNumInnerWidth+"px"))),l)for(var u=0;u<e.options.gutters.length;++u){var c=e.options.gutters[u],f=l.hasOwnProperty(c)&&l[c];f&&a.appendChild(n("div",[f],"CodeMirror-gutter-elt","left: "+i.gutterLeft[c]+"px; width: "+i.gutterWidth[c]+"px"))}}}function Dt(e,t,r){t.alignable&&(t.alignable=null);for(var n=t.node.firstChild,i=void 0;n;n=i)i=n.nextSibling,"CodeMirror-linewidget"==n.className&&t.node.removeChild(n);Pt(e,t,r)}function Ht(e,t,r,n){var i=Nt(e,t);return t.text=t.node=i.pre,i.bgClass&&(t.bgClass=i.bgClass),i.textClass&&(t.textClass=i.textClass),Wt(e,t),At(e,t,r,n),Pt(e,t,n),t.node}function Pt(e,t,r){if(Et(e,t.line,t,r,!0),t.rest)for(var n=0;n<t.rest.length;n++)Et(e,t.rest[n],t,r,!1)}function Et(e,t,r,i,o){if(t.widgets)for(var l=kt(r),s=0,a=t.widgets;s<a.length;++s){var u=a[s],c=n("div",[u.node],"CodeMirror-linewidget");u.handleMouseEvents||c.setAttribute("cm-ignore-events","true"),Ft(u,c,r,i),e.display.input.setUneditable(c),o&&u.above?l.insertBefore(c,r.gutter||r.text):l.appendChild(c),St(u,"redraw")}}function Ft(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 It(e){if(null!=e.height)return e.height;var t=e.doc.cm;if(!t)return 0;if(!o(document.body,e.node)){var i="position: relative;";e.coverGutter&&(i+="margin-left: -"+t.display.gutters.offsetWidth+"px;"),e.noHScroll&&(i+="width: "+t.display.wrapper.clientWidth+"px;"),r(t.display.measure,n("div",[e.node],null,i))}return e.height=e.node.parentNode.offsetHeight}function zt(e,t){for(var r=Re(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 Rt(e){return e.lineSpace.offsetTop}function Bt(e){return e.mover.offsetHeight-e.lineSpace.offsetHeight}function Gt(e){if(e.cachedPaddingH)return e.cachedPaddingH;var t=r(e.measure,n("pre","x")),i=window.getComputedStyle?window.getComputedStyle(t):t.currentStyle,o={left:parseInt(i.paddingLeft),right:parseInt(i.paddingRight)};return isNaN(o.left)||isNaN(o.right)||(e.cachedPaddingH=o),o}function Ut(e){return Ll-e.display.nativeBarWidth}function Vt(e){return e.display.scroller.clientWidth-Ut(e)-e.display.barWidth}function Kt(e){return e.display.scroller.clientHeight-Ut(e)-e.display.barHeight}function jt(e,t,r){var n=e.options.lineWrapping,i=n&&Vt(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 Xt(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 i=0;i<e.rest.length;i++)if(A(e.rest[i])>r)return{map:e.measure.maps[i],cache:e.measure.caches[i],before:!0}}function Yt(e,t){t=fe(t);var n=A(t),i=e.display.externalMeasured=new yt(e.doc,t,n);i.lineN=n;var o=i.built=ft(e,i);return i.text=o.pre,r(e.display.lineMeasure,o.pre),i}function _t(e,t,r,n){return Zt(e,qt(e,t),r,n)}function $t(e,t){if(t>=e.display.viewFrom&&t<e.display.viewTo)return e.display.view[Lr(e,t)];var r=e.display.externalMeasured;return r&&t>=r.lineN&&t<r.lineN+r.size?r:void 0}function qt(e,t){var r=A(t),n=$t(e,r);n&&!n.text?n=null:n&&n.changes&&(Tt(e,n,r,br(e)),e.curOp.forceUpdate=!0),n||(n=Yt(e,t));var i=Xt(n,t,r);return{line:t,view:n,rect:null,map:i.map,
|
2 |
+
cache:i.cache,before:i.before,hasHeights:!1}}function Zt(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||(jt(e,t.view,t.rect),t.hasHeights=!0),o=er(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 Qt(e,t,r){for(var n,i,o,l,s,a,u=0;u<e.length;u+=3)if(s=e[u],a=e[u+1],t<s?(i=0,o=1,l="left"):t<a?(i=t-s,o=i+1):(u==e.length-3||t==a&&e[u+3]>t)&&(o=a-s,i=o-1,t>=a&&(l="right")),null!=i){if(n=e[u+2],s==a&&r==(n.insertLeft?"left":"right")&&(l=r),"left"==r&&0==i)for(;u&&e[u-2]==e[u-3]&&e[u-1].insertLeft;)n=e[(u-=3)+2],l="left";if("right"==r&&i==a-s)for(;u<e.length-3&&e[u+3]==e[u+4]&&!e[u+5].insertLeft;)n=e[(u+=3)+2],l="right";break}return{node:n,start:i,end:o,collapse:l,coverStart:s,coverEnd:a}}function Jt(e,t){var r=Jl;if("left"==t)for(var n=0;n<e.length&&(r=e[n]).left==r.right;n++);else for(var i=e.length-1;i>=0&&(r=e[i]).left==r.right;i--);return r}function er(e,t,r,n){var i,o=Qt(t.map,r,n),l=o.node,s=o.start,a=o.end,u=o.collapse;if(3==l.nodeType){for(var c=0;c<4;c++){for(;s&&S(t.line.text.charAt(o.coverStart+s));)--s;for(;o.coverStart+a<o.coverEnd&&S(t.line.text.charAt(o.coverStart+a));)++a;if(i=el&&tl<9&&0==s&&a==o.coverEnd-o.coverStart?l.parentNode.getBoundingClientRect():Jt(vl(l,s,a).getClientRects(),n),i.left||i.right||0==s)break;a=s,s-=1,u="right"}el&&tl<11&&(i=tr(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(el&&tl<9&&!s&&(!i||!i.left&&!i.right)){var h=l.parentNode.getClientRects()[0];i=h?{left:h.left,right:h.left+yr(e.display),top:h.top,bottom:h.bottom}:Jl}for(var d=i.top-t.rect.top,p=i.bottom-t.rect.top,g=(d+p)/2,v=t.view.measure.heights,m=0;m<v.length-1&&!(g<v[m]);m++);var y=m?v[m-1]:0,b=v[m],w={left:("right"==u?i.right:i.left)-t.rect.left,right:("left"==u?i.left:i.right)-t.rect.left,top:y,bottom:b};return i.left||i.right||(w.bogus=!0),e.options.singleCursorHeightPerLine||(w.rtop=d,w.rbottom=p),w}function tr(e,t){if(!window.screen||null==screen.logicalXDPI||screen.logicalXDPI==screen.deviceXDPI||!Ve(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 rr(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 nr(e){e.display.externalMeasure=null,t(e.display.lineMeasure);for(var r=0;r<e.display.view.length;r++)rr(e.display.view[r])}function ir(e){nr(e),e.display.cachedCharWidth=e.display.cachedTextHeight=e.display.cachedPaddingH=null,e.options.lineWrapping||(e.display.maxLineChanged=!0),e.display.lineNumChars=null}function or(){return il&&cl?-(document.body.getBoundingClientRect().left-parseInt(getComputedStyle(document.body).marginLeft)):window.pageXOffset||(document.documentElement||document.body).scrollLeft}function lr(){return il&&cl?-(document.body.getBoundingClientRect().top-parseInt(getComputedStyle(document.body).marginTop)):window.pageYOffset||(document.documentElement||document.body).scrollTop}function sr(e,t,r,n,i){if(!i&&t.widgets)for(var o=0;o<t.widgets.length;++o)if(t.widgets[o].above){var l=It(t.widgets[o]);r.top+=l,r.bottom+=l}if("line"==n)return r;n||(n="local");var s=ye(t);if("local"==n?s+=Rt(e.display):s-=e.display.viewOffset,"page"==n||"window"==n){var a=e.display.lineSpace.getBoundingClientRect();s+=a.top+("window"==n?0:lr());var u=a.left+("window"==n?0:or());r.left+=u,r.right+=u}return r.top+=s,r.bottom+=s,r}function ar(e,t,r){if("div"==r)return t;var n=t.left,i=t.top;if("page"==r)n-=or(),i-=lr();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 ur(e,t,r,n,i){return n||(n=M(e.doc,t.line)),sr(e,n,_t(e,n,t.ch,i),r)}function cr(e,t,r,n,i,o){function l(t,l){var s=Zt(e,i,t,l?"right":"left",o);return l?s.left=s.right:s.right=s.left,sr(e,n,s,r)}function s(e,t,r){var n=a[t],i=n.level%2!=0;return l(r?e-1:e,i!=r)}n=n||M(e.doc,t.line),i||(i=qt(e,n));var a=Se(n,e.doc.direction),u=t.ch,c=t.sticky;if(u>=n.text.length?(u=n.text.length,c="before"):u<=0&&(u=0,c="after"),!a)return l("before"==c?u-1:u,"before"==c);var f=Ce(a,u,c),h=Pl,d=s(u,f,"before"==c);return null!=h&&(d.other=s(u,h,"before"!=c)),d}function fr(e,t){var r=0;t=U(e.doc,t),e.options.lineWrapping||(r=yr(e.display)*t.ch);var n=M(e.doc,t.line),i=ye(n)+Rt(e.display);return{left:r,right:r,top:i,bottom:i+n.height}}function hr(e,t,r,n,i){var o=E(e,t,r);return o.xRel=i,n&&(o.outside=!0),o}function dr(e,t,r){var n=e.doc;if(r+=e.display.viewOffset,r<0)return hr(n.first,0,null,!0,-1);var i=D(n,r),o=n.first+n.size-1;if(i>o)return hr(n.first+n.size-1,M(n,o).text.length,null,!0,1);t<0&&(t=0);for(var l=M(n,i);;){var s=vr(e,l,i,t,r),a=ue(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=A(l=u.to.line)}}function pr(e,t,r,n){var i=function(n){return sr(e,t,Zt(e,r,n),"line")},o=t.text.length,l=T(function(e){return i(e-1).bottom<=n},o,0);return o=T(function(e){return i(e).top>n},l,o),{begin:l,end:o}}function gr(e,t,r,n){var i=sr(e,t,Zt(e,r,n),"line").top;return pr(e,t,r,i)}function vr(e,t,r,n,i){i-=ye(t);var o,l=0,s=t.text.length,a=qt(e,t),u=Se(t,e.doc.direction);if(u){if(e.options.lineWrapping){var c;c=pr(e,t,a,i),l=c.begin,s=c.end,c}o=new E(r,l);var f,h,d=cr(e,o,"line",t,a).left,p=d<n?1:-1,g=d-n;do{if(f=g,h=o,o=Me(e,t,o,p),null==o||o.ch<l||s<=("before"==o.sticky?o.ch-1:o.ch)){o=h;break}g=cr(e,o,"line",t,a).left-n}while(p<0!=g<0&&Math.abs(g)<=Math.abs(f));if(Math.abs(g)>Math.abs(f)){if(g<0==f<0)throw new Error("Broke out of infinite loop in coordsCharInner");o=h}}else{var v=T(function(r){var o=sr(e,t,Zt(e,a,r),"line");return o.top>i?(s=Math.min(r,s),!0):!(o.bottom<=i)&&(o.left>n||!(o.right<n)&&n-o.left<o.right-n)},l,s);v=L(t.text,v,1),o=new E(r,v,v==s?"before":"after")}var m=cr(e,o,"line",t,a);return(i<m.top||m.bottom<i)&&(o.outside=!0),o.xRel=n<m.left?-1:n>m.right?1:0,o}function mr(e){if(null!=e.cachedTextHeight)return e.cachedTextHeight;if(null==_l){_l=n("pre");for(var i=0;i<49;++i)_l.appendChild(document.createTextNode("x")),_l.appendChild(n("br"));_l.appendChild(document.createTextNode("x"))}r(e.measure,_l);var o=_l.offsetHeight/50;return o>3&&(e.cachedTextHeight=o),t(e.measure),o||1}function yr(e){if(null!=e.cachedCharWidth)return e.cachedCharWidth;var t=n("span","xxxxxxxxxx"),i=n("pre",[t]);r(e.measure,i);var o=t.getBoundingClientRect(),l=(o.right-o.left)/10;return l>2&&(e.cachedCharWidth=l),l||10}function br(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:wr(t),gutterTotalWidth:t.gutters.offsetWidth,gutterLeft:r,gutterWidth:n,wrapperWidth:t.wrapper.clientWidth}}function wr(e){return e.scroller.getBoundingClientRect().left-e.sizer.getBoundingClientRect().left}function xr(e){var t=mr(e.display),r=e.options.lineWrapping,n=r&&Math.max(5,e.display.scroller.clientWidth/yr(e.display)-3);return function(i){if(ve(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 Cr(e){var t=e.doc,r=xr(e);t.iter(function(e){var t=r(e);t!=e.height&&W(e,t)})}function Sr(e,t,r,n){var i=e.display;if(!r&&"true"==Re(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=dr(e,o,l);if(n&&1==u.xRel&&(a=M(e.doc,u.line).text).length==u.ch){var c=f(a,a.length,e.options.tabSize)-a.length;u=E(u.line,Math.max(0,Math.round((o-Gt(e.display).left)/yr(e.display))-c))}return u}function Lr(e,t){if(t>=e.display.viewTo)return null;if(t-=e.display.viewFrom,t<0)return null;for(var r=e.display.view,n=0;n<r.length;n++)if(t-=r[n].size,t<0)return n}function Tr(e){e.display.input.showSelection(e.display.input.prepareSelection())}function kr(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];if(!(s.from().line>=e.display.viewTo||s.to().line<e.display.viewFrom)){var a=s.empty();(a||e.options.showCursorWhenSelecting)&&Mr(e,s.head,i),a||Nr(e,s,o)}}return n}function Mr(e,t,r){var i=cr(e,t,"div",null,null,!e.options.singleCursorHeightPerLine),o=r.appendChild(n("div"," ","CodeMirror-cursor"));if(o.style.left=i.left+"px",o.style.top=i.top+"px",o.style.height=Math.max(0,i.bottom-i.top)*e.options.cursorHeight+"px",i.other){var l=r.appendChild(n("div"," ","CodeMirror-cursor CodeMirror-secondarycursor"));l.style.display="",l.style.left=i.other.left+"px",l.style.top=i.other.top+"px",l.style.height=.85*(i.other.bottom-i.other.top)+"px"}}function Nr(e,t,r){function i(e,t,r,i){t<0&&(t=0),t=Math.round(t),i=Math.round(i),a.appendChild(n("div",null,"CodeMirror-selected","position: absolute; left: "+e+"px;\n top: "+t+"px; width: "+(null==r?f-e:r)+"px;\n height: "+(i-t)+"px"))}function o(t,r,n){function o(r,n){return ur(e,E(t,r),"div",u,n)}var l,a,u=M(s,t),h=u.text.length;return xe(Se(u,s.direction),r||0,null==n?h:n,function(e,t,s){var u,d,p,g=o(e,"left");if(e==t)u=g,d=p=g.left;else{if(u=o(t-1,"right"),"rtl"==s){var v=g;g=u,u=v}d=g.left,p=u.right}null==r&&0==e&&(d=c),u.top-g.top>3&&(i(d,g.top,null,g.bottom),d=c,g.bottom<u.top&&i(d,g.bottom,null,u.top)),null==n&&t==h&&(p=f),(!l||g.top<l.top||g.top==l.top&&g.left<l.left)&&(l=g),(!a||u.bottom>a.bottom||u.bottom==a.bottom&&u.right>a.right)&&(a=u),d<c+1&&(d=c),i(d,u.top,p-d,u.bottom)}),{start:l,end:a}}var l=e.display,s=e.doc,a=document.createDocumentFragment(),u=Gt(e.display),c=u.left,f=Math.max(l.sizerWidth,Vt(e)-l.sizer.offsetLeft)-u.right,h=t.from(),d=t.to();if(h.line==d.line)o(h.line,h.ch,d.ch);else{var p=M(s,h.line),g=M(s,d.line),v=fe(p)==fe(g),m=o(h.line,h.ch,v?p.text.length+1:null).end,y=o(d.line,v?0:null,d.ch).start;v&&(m.top<y.top-2?(i(m.right,m.top,null,m.bottom),i(c,y.top,y.left,y.bottom)):i(m.right,m.top,y.left-m.right,m.bottom)),m.bottom<y.top&&i(c,m.bottom,null,y.top)}r.appendChild(a)}function Or(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(){return t.cursorDiv.style.visibility=(r=!r)?"":"hidden"},e.options.cursorBlinkRate):e.options.cursorBlinkRate<0&&(t.cursorDiv.style.visibility="hidden")}}function Wr(e){e.state.focused||(e.display.input.focus(),Dr(e))}function Ar(e){e.state.delayingBlurEvent=!0,setTimeout(function(){e.state.delayingBlurEvent&&(e.state.delayingBlurEvent=!1,Hr(e))},100)}function Dr(e,t){e.state.delayingBlurEvent&&(e.state.delayingBlurEvent=!1),"nocursor"!=e.options.readOnly&&(e.state.focused||(We(e,"focus",e,t),e.state.focused=!0,s(e.display.wrapper,"CodeMirror-focused"),e.curOp||e.display.selForContextMenu==e.doc.sel||(e.display.input.reset(),rl&&setTimeout(function(){return e.display.input.reset(!0)},20)),e.display.input.receivedFocus()),Or(e))}function Hr(e,t){e.state.delayingBlurEvent||(e.state.focused&&(We(e,"blur",e,t),e.state.focused=!1,bl(e.display.wrapper,"CodeMirror-focused")),clearInterval(e.display.blinker),setTimeout(function(){e.state.focused||(e.display.shift=!1)},150))}function Pr(e){var t=e.display,r=t.view;if(t.alignWidgets||t.gutters.firstChild&&e.options.fixedGutter){for(var n=wr(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),r[l].gutterBackground&&(r[l].gutterBackground.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 Er(e){if(!e.options.lineNumbers)return!1;var t=e.doc,r=P(e.options,t.first+t.size-1),i=e.display;if(r.length!=i.lineNumChars){var o=i.measure.appendChild(n("div",[n("div",r)],"CodeMirror-linenumber CodeMirror-gutter-elt")),l=o.firstChild.offsetWidth,s=o.offsetWidth-l;return i.lineGutter.style.width="",i.lineNumInnerWidth=Math.max(l,i.lineGutter.offsetWidth-s)+1,i.lineNumWidth=i.lineNumInnerWidth+s,i.lineNumChars=i.lineNumInnerWidth?r.length:-1,i.lineGutter.style.width=i.lineNumWidth+"px",Mn(e),!0}return!1}function Fr(e){for(var t=e.display,r=t.lineDiv.offsetTop,n=0;n<t.view.length;n++){var i=t.view[n],o=void 0;if(!i.hidden){if(el&&tl<8){var l=i.node.offsetTop+i.node.offsetHeight;o=l-r,r=l}else{var s=i.node.getBoundingClientRect();o=s.bottom-s.top}var a=i.line.height-o;if(o<2&&(o=mr(t)),(a>.001||a<-.001)&&(W(i.line,o),Ir(i.line),i.rest))for(var u=0;u<i.rest.length;u++)Ir(i.rest[u])}}}function Ir(e){if(e.widgets)for(var t=0;t<e.widgets.length;++t)e.widgets[t].height=e.widgets[t].node.parentNode.offsetHeight}function zr(e,t,r){var n=r&&null!=r.top?Math.max(0,r.top):e.scroller.scrollTop;n=Math.floor(n-Rt(e));var i=r&&null!=r.bottom?r.bottom:n+e.wrapper.clientHeight,o=D(t,n),l=D(t,i);if(r&&r.ensure){var s=r.ensure.from.line,a=r.ensure.to.line;s<o?(o=s,l=D(t,ye(M(t,s))+e.wrapper.clientHeight)):Math.min(a,t.lastLine())>=l&&(o=D(t,ye(M(t,a))-e.wrapper.clientHeight),l=a)}return{from:o,to:Math.max(l,o+1)}}function Rr(e,t){Math.abs(e.doc.scrollTop-t)<2||(e.doc.scrollTop=t,qo||Tn(e,{top:t}),e.display.scroller.scrollTop!=t&&(e.display.scroller.scrollTop=t),e.display.scrollbars.setScrollTop(t),qo&&Tn(e),wn(e,100))}function Br(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,Pr(e),e.display.scroller.scrollLeft!=t&&(e.display.scroller.scrollLeft=t),e.display.scrollbars.setScrollLeft(t))}function Gr(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}}function Ur(e){var t=Gr(e);return t.x*=ts,t.y*=ts,t}function Vr(e,t){var r=Gr(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&&hl&&rl)e:for(var u=t.target,c=o.view;u!=l;u=u.parentNode)for(var f=0;f<c.length;f++)if(c[f].node==u){e.display.currentWheelTarget=u;break e}if(n&&!qo&&!ol&&null!=ts)return i&&a&&Rr(e,Math.max(0,Math.min(l.scrollTop+i*ts,l.scrollHeight-l.clientHeight))),Br(e,Math.max(0,Math.min(l.scrollLeft+n*ts,l.scrollWidth-l.clientWidth))),(!i||i&&a)&&Ee(t),void(o.wheelStartX=null);if(i&&null!=ts){var h=i*ts,d=e.doc.scrollTop,p=d+o.wrapper.clientHeight;h<0?d=Math.max(0,d+h-50):p=Math.min(e.doc.height,p+h+50),Tn(e,{top:d,bottom:p})}es<20&&(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&&(ts=(ts*es+r)/(es+1),++es)}},200)):(o.wheelDX+=n,o.wheelDY+=i))}}function Kr(e){var t=e.display,r=t.gutters.offsetWidth,n=Math.round(e.doc.height+Bt(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+Ut(e)+t.barHeight,nativeBarWidth:t.nativeBarWidth,gutterWidth:r}}function jr(e,t){t||(t=Kr(e));var r=e.display.barWidth,n=e.display.barHeight;Xr(e,t);for(var i=0;i<4&&r!=e.display.barWidth||n!=e.display.barHeight;i++)r!=e.display.barWidth&&e.options.lineWrapping&&Fr(e),Xr(e,Kr(e)),r=e.display.barWidth,n=e.display.barHeight}function Xr(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",r.heightForcer.style.borderBottom=n.bottom+"px solid transparent",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 Yr(e){e.display.scrollbars&&(e.display.scrollbars.clear(),e.display.scrollbars.addClass&&bl(e.display.wrapper,e.display.scrollbars.addClass)),e.display.scrollbars=new is[e.options.scrollbarStyle](function(t){e.display.wrapper.insertBefore(t,e.display.scrollbarFiller),Il(t,"mousedown",function(){e.state.focused&&setTimeout(function(){return e.display.input.focus()},0)}),t.setAttribute("cm-not-content","true")},function(t,r){"horizontal"==r?Br(e,t):Rr(e,t)},e),e.display.scrollbars.addClass&&s(e.display.wrapper,e.display.scrollbars.addClass)}function _r(e,t){if(!Ae(e,"scrollCursorIntoView")){var r=e.display,i=r.sizer.getBoundingClientRect(),o=null;if(t.top+i.top<0?o=!0:t.bottom+i.top>(window.innerHeight||document.documentElement.clientHeight)&&(o=!1),null!=o&&!al){var l=n("div","",null,"position: absolute;\n top: "+(t.top-r.viewOffset-Rt(e.display))+"px;\n height: "+(t.bottom-t.top+Ut(e)+r.barHeight)+"px;\n left: "+t.left+"px; width: "+Math.max(2,t.right-t.left)+"px;");e.display.lineSpace.appendChild(l),l.scrollIntoView(o),e.display.lineSpace.removeChild(l)}}}function $r(e,t,r,n){null==n&&(n=0);for(var i,o=0;o<5;o++){var l=!1,s=cr(e,t),a=r&&r!=t?cr(e,r):s;i={left:Math.min(s.left,a.left),top:Math.min(s.top,a.top)-n,right:Math.max(s.left,a.left),bottom:Math.max(s.bottom,a.bottom)+n};var u=Zr(e,i),c=e.doc.scrollTop,f=e.doc.scrollLeft;if(null!=u.scrollTop&&(Rr(e,u.scrollTop),Math.abs(e.doc.scrollTop-c)>1&&(l=!0)),null!=u.scrollLeft&&(Br(e,u.scrollLeft),Math.abs(e.doc.scrollLeft-f)>1&&(l=!0)),!l)break}return i}function qr(e,t){var r=Zr(e,t);null!=r.scrollTop&&Rr(e,r.scrollTop),null!=r.scrollLeft&&Br(e,r.scrollLeft)}function Zr(e,t){var r=e.display,n=mr(e.display);t.top<0&&(t.top=0);var i=e.curOp&&null!=e.curOp.scrollTop?e.curOp.scrollTop:r.scroller.scrollTop,o=Kt(e),l={};t.bottom-t.top>o&&(t.bottom=t.top+o);var s=e.doc.height+Bt(r),a=t.top<n,u=t.bottom>s-n;if(t.top<i)l.scrollTop=a?0:t.top;else if(t.bottom>i+o){var c=Math.min(t.top,(u?s:t.bottom)-o);c!=i&&(l.scrollTop=c)}var f=e.curOp&&null!=e.curOp.scrollLeft?e.curOp.scrollLeft:r.scroller.scrollLeft,h=Vt(e)-(e.options.fixedGutter?r.gutters.offsetWidth:0),d=t.right-t.left>h;return d&&(t.right=t.left+h),t.left<10?l.scrollLeft=0:t.left<f?l.scrollLeft=Math.max(0,t.left-(d?0:10)):t.right>h+f-3&&(l.scrollLeft=t.right+(d?0:10)-h),l}function Qr(e,t,r){null==t&&null==r||en(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 Jr(e){en(e);var t=e.getCursor(),r=t,n=t;e.options.lineWrapping||(r=t.ch?E(t.line,t.ch-1):t,n=E(t.line,t.ch+1)),e.curOp.scrollToPos={from:r,to:n,margin:e.options.cursorScrollMargin}}function en(e){var t=e.curOp.scrollToPos;if(t){e.curOp.scrollToPos=null;var r=fr(e,t.from),n=fr(e,t.to),i=Zr(e,{left:Math.min(r.left,n.left),top:Math.min(r.top,n.top)-t.margin,right:Math.max(r.right,n.right),bottom:Math.max(r.bottom,n.bottom)+t.margin});e.scrollTo(i.scrollLeft,i.scrollTop)}}function tn(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:++os},wt(e.curOp)}function rn(e){var t=e.curOp;Ct(t,function(e){for(var t=0;t<e.ops.length;t++)e.ops[t].cm.curOp=null;nn(e)})}function nn(e){for(var t=e.ops,r=0;r<t.length;r++)on(t[r]);for(var n=0;n<t.length;n++)ln(t[n]);for(var i=0;i<t.length;i++)sn(t[i]);for(var o=0;o<t.length;o++)an(t[o]);for(var l=0;l<t.length;l++)un(t[l])}function on(e){var t=e.cm,r=t.display;Cn(t),e.updateMaxLine&&we(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 ls(t,e.mustUpdate&&{top:e.scrollTop,ensure:e.scrollToPos},e.forceUpdate)}function ln(e){e.updatedDisplay=e.mustUpdate&&Sn(e.cm,e.update)}function sn(e){var t=e.cm,r=t.display;e.updatedDisplay&&Fr(t),e.barMeasure=Kr(t),r.maxLineChanged&&!t.options.lineWrapping&&(e.adjustWidthTo=_t(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+Ut(t)+t.display.barWidth),e.maxScrollLeft=Math.max(0,r.sizer.offsetLeft+e.adjustWidthTo-Vt(t))),(e.updatedDisplay||e.selectionChanged)&&(e.preparedSelection=r.input.prepareSelection(e.focus))}function an(e){var t=e.cm;null!=e.adjustWidthTo&&(t.display.sizer.style.minWidth=e.adjustWidthTo+"px",e.maxScrollLeft<t.doc.scrollLeft&&Br(t,Math.min(t.display.scroller.scrollLeft,e.maxScrollLeft),!0),t.display.maxLineChanged=!1);var r=e.focus&&e.focus==l()&&(!document.hasFocus||document.hasFocus());e.preparedSelection&&t.display.input.showSelection(e.preparedSelection,r),(e.updatedDisplay||e.startHeight!=t.doc.height)&&jr(t,e.barMeasure),e.updatedDisplay&&Nn(t,e.barMeasure),e.selectionChanged&&Or(t),t.state.focused&&e.updateInput&&t.display.input.reset(e.typing),r&&Wr(e.cm)}function un(e){var t=e.cm,r=t.display,n=t.doc;if(e.updatedDisplay&&Ln(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-r.scroller.clientWidth,e.scrollLeft)),r.scrollbars.setScrollLeft(n.scrollLeft),r.scroller.scrollLeft=n.scrollLeft,Pr(t)),e.scrollToPos){var i=$r(t,U(n,e.scrollToPos.from),U(n,e.scrollToPos.to),e.scrollToPos.margin);_r(t,i)}var o=e.maybeHiddenMarkers,l=e.maybeUnhiddenMarkers;if(o)for(var s=0;s<o.length;++s)o[s].lines.length||We(o[s],"hide");if(l)for(var a=0;a<l.length;++a)l[a].lines.length&&We(l[a],"unhide");r.wrapper.offsetHeight&&(n.scrollTop=t.display.scroller.scrollTop),e.changeObjs&&We(t,"changes",t,e.changeObjs),e.update&&e.update.finish()}function cn(e,t){if(e.curOp)return t();tn(e);try{return t()}finally{rn(e)}}function fn(e,t){return function(){if(e.curOp)return t.apply(e,arguments);tn(e);try{return t.apply(e,arguments)}finally{rn(e)}}}function hn(e){return function(){if(this.curOp)return e.apply(this,arguments);tn(this);try{return e.apply(this,arguments)}finally{rn(this)}}}function dn(e){return function(){var t=this.cm;if(!t||t.curOp)return e.apply(this,arguments);tn(t);try{return e.apply(this,arguments)}finally{rn(t)}}}function pn(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)Hl&&pe(e.doc,t)<i.viewTo&&vn(e);else if(r<=i.viewFrom)Hl&&ge(e.doc,r+n)>i.viewFrom?vn(e):(i.viewFrom+=n,i.viewTo+=n);else if(t<=i.viewFrom&&r>=i.viewTo)vn(e);else if(t<=i.viewFrom){var o=mn(e,r,r+n,1);o?(i.view=i.view.slice(o.index),i.viewFrom=o.lineN,i.viewTo+=n):vn(e)}else if(r>=i.viewTo){var l=mn(e,t,t,-1);l?(i.view=i.view.slice(0,l.index),i.viewTo=l.lineN):vn(e)}else{var s=mn(e,t,t,-1),a=mn(e,r,r+n,1);s&&a?(i.view=i.view.slice(0,s.index).concat(bt(e,s.lineN,a.lineN)).concat(i.view.slice(a.index)),i.viewTo+=n):vn(e)}var u=i.externalMeasured;u&&(r<u.lineN?u.lineN+=n:t<u.lineN+u.size&&(i.externalMeasured=null))}function gn(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[Lr(e,t)];if(null!=o.node){var l=o.changes||(o.changes=[]);h(l,r)==-1&&l.push(r)}}}function vn(e){e.display.viewFrom=e.display.viewTo=e.doc.first,e.display.view=[],e.display.viewOffset=0}function mn(e,t,r,n){var i,o=Lr(e,t),l=e.display.view;if(!Hl||r==e.doc.first+e.doc.size)return{index:o,lineN:r};for(var s=e.display.viewFrom,a=0;a<o;a++)s+=l[a].size;if(s!=t){if(n>0){if(o==l.length-1)return null;i=s+l[o].size-t,o++}else i=s-t;t+=i,r+=i}for(;pe(e.doc,r)!=r;){if(o==(n<0?0:l.length-1))return null;r+=n*l[o-(n<0?1:0)].size,o+=n}return{index:o,lineN:r}}function yn(e,t,r){var n=e.display,i=n.view;0==i.length||t>=n.viewTo||r<=n.viewFrom?(n.view=bt(e,t,r),n.viewFrom=t):(n.viewFrom>t?n.view=bt(e,t,n.viewFrom).concat(n.view):n.viewFrom<t&&(n.view=n.view.slice(Lr(e,t))),n.viewFrom=t,n.viewTo<r?n.view=n.view.concat(bt(e,n.viewTo,r)):n.viewTo>r&&(n.view=n.view.slice(0,Lr(e,r)))),n.viewTo=r}function bn(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 wn(e,t){e.doc.mode.startState&&e.doc.frontier<e.display.viewTo&&e.state.highlight.set(t,u(xn,e))}function xn(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=$e(t.mode,et(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=Qe(e,o,s?$e(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 f=!l||l.length!=o.styles.length||u!=c&&(!u||!c||u.bgClass!=c.bgClass||u.textClass!=c.textClass),h=0;!f&&h<l.length;++h)f=l[h]!=o.styles[h];f&&i.push(t.frontier),o.stateAfter=s?n:$e(t.mode,n)}else o.text.length<=e.options.maxHighlightLength&&tt(e,o.text,n),o.stateAfter=t.frontier%5==0?$e(t.mode,n):null;if(++t.frontier,+new Date>r)return wn(e,e.options.workDelay),!0}),i.length&&cn(e,function(){for(var t=0;t<i.length;t++)gn(e,i[t],"text")})}}function Cn(e){var t=e.display;!t.scrollbarsClipped&&t.scroller.offsetWidth&&(t.nativeBarWidth=t.scroller.offsetWidth-t.scroller.clientWidth,t.heightForcer.style.height=Ut(e)+"px",t.sizer.style.marginBottom=-t.nativeBarWidth+"px",t.sizer.style.borderRightWidth=Ut(e)+"px",t.scrollbarsClipped=!0)}function Sn(e,r){var n=e.display,i=e.doc;if(r.editorIsHidden)return vn(e),!1;if(!r.force&&r.visible.from>=n.viewFrom&&r.visible.to<=n.viewTo&&(null==n.updateLineNumbers||n.updateLineNumbers>=n.viewTo)&&n.renderedView==n.view&&0==bn(e))return!1;Er(e)&&(vn(e),r.dims=br(e));var o=i.first+i.size,s=Math.max(r.visible.from-e.options.viewportMargin,i.first),a=Math.min(o,r.visible.to+e.options.viewportMargin);n.viewFrom<s&&s-n.viewFrom<20&&(s=Math.max(i.first,n.viewFrom)),n.viewTo>a&&n.viewTo-a<20&&(a=Math.min(o,n.viewTo)),Hl&&(s=pe(e.doc,s),a=ge(e.doc,a));var u=s!=n.viewFrom||a!=n.viewTo||n.lastWrapHeight!=r.wrapperHeight||n.lastWrapWidth!=r.wrapperWidth;yn(e,s,a),n.viewOffset=ye(M(e.doc,n.viewFrom)),e.display.mover.style.top=n.viewOffset+"px";var c=bn(e);if(!u&&0==c&&!r.force&&n.renderedView==n.view&&(null==n.updateLineNumbers||n.updateLineNumbers>=n.viewTo))return!1;var f=l();return c>4&&(n.lineDiv.style.display="none"),kn(e,n.updateLineNumbers,r.dims),c>4&&(n.lineDiv.style.display=""),n.renderedView=n.view,f&&l()!=f&&f.offsetHeight&&f.focus(),t(n.cursorDiv),t(n.selectionDiv),n.gutters.style.height=n.sizer.style.minHeight=0,u&&(n.lastWrapHeight=r.wrapperHeight,n.lastWrapWidth=r.wrapperWidth,wn(e,400)),n.updateLineNumbers=null,!0}function Ln(e,t){for(var r=t.viewport,n=!0;(n&&e.options.lineWrapping&&t.oldDisplayWidth!=Vt(e)||(r&&null!=r.top&&(r={top:Math.min(e.doc.height+Bt(e.display)-Kt(e),r.top)}),t.visible=zr(e.display,e.doc,r),!(t.visible.from>=e.display.viewFrom&&t.visible.to<=e.display.viewTo)))&&Sn(e,t);n=!1){Fr(e);var i=Kr(e);Tr(e),jr(e,i),Nn(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 Tn(e,t){var r=new ls(e,t);if(Sn(e,r)){Fr(e),Ln(e,r);var n=Kr(e);Tr(e),jr(e,n),Nn(e,n),r.finish()}}function kn(e,r,n){function i(t){var r=t.nextSibling;return rl&&hl&&e.display.currentWheelTarget==t?t.style.display="none":t.parentNode.removeChild(t),r}for(var o=e.display,l=e.options.lineNumbers,s=o.lineDiv,a=s.firstChild,u=o.view,c=o.viewFrom,f=0;f<u.length;f++){var d=u[f];if(d.hidden);else if(d.node&&d.node.parentNode==s){for(;a!=d.node;)a=i(a);var p=l&&null!=r&&r<=c&&d.lineNumber;d.changes&&(h(d.changes,"gutter")>-1&&(p=!1),Tt(e,d,c,n)),p&&(t(d.lineNumber),d.lineNumber.appendChild(document.createTextNode(P(e.options,c)))),a=d.node.nextSibling}else{var g=Ht(e,d,c,n);s.insertBefore(g,a)}c+=d.size}for(;a;)a=i(a)}function Mn(e){var t=e.display.gutters.offsetWidth;e.display.sizer.style.marginLeft=t+"px"}function Nn(e,t){e.display.sizer.style.minHeight=t.docHeight+"px",e.display.heightForcer.style.top=t.docHeight+"px",e.display.gutters.style.height=t.docHeight+e.display.barHeight+Ut(e)+"px"}function On(e){var r=e.display.gutters,i=e.options.gutters;t(r);for(var o=0;o<i.length;++o){var l=i[o],s=r.appendChild(n("div",null,"CodeMirror-gutter "+l));"CodeMirror-linenumbers"==l&&(e.display.lineGutter=s,s.style.width=(e.display.lineNumWidth||1)+"px")}r.style.display=o?"":"none",Mn(e)}function Wn(e){var t=h(e.gutters,"CodeMirror-linenumbers");t==-1&&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 An(e,t){var r=e[t];e.sort(function(e,t){return F(e.from(),t.from())}),t=h(e,r);for(var n=1;n<e.length;n++){var i=e[n],o=e[n-1];if(F(o.to(),i.from())>=0){var l=B(o.from(),i.from()),s=R(o.to(),i.to()),a=o.empty()?i.from()==i.head:o.from()==o.head;n<=t&&--t,e.splice(--n,2,new as(a?s:l,a?l:s))}}return new ss(e,t)}function Dn(e,t){return new ss([new as(e,t||e)],0)}function Hn(e){return e.text?E(e.from.line+e.text.length-1,g(e.text).length+(1==e.text.length?e.from.ch:0)):e.to}function Pn(e,t){if(F(e,t.from)<0)return e;if(F(e,t.to)<=0)return Hn(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+=Hn(t).ch-t.to.ch),E(r,n)}function En(e,t){for(var r=[],n=0;n<e.sel.ranges.length;n++){var i=e.sel.ranges[n];r.push(new as(Pn(i.anchor,t),Pn(i.head,t)))}return An(r,e.sel.primIndex)}function Fn(e,t,r){return e.line==t.line?E(r.line,e.ch-t.ch+r.ch):E(r.line+(e.line-t.line),e.ch)}function In(e,t,r){for(var n=[],i=E(e.first,0),o=i,l=0;l<t.length;l++){var s=t[l],a=Fn(s.from,i,o),u=Fn(Hn(s),i,o);if(i=s.to,o=u,"around"==r){var c=e.sel.ranges[l],f=F(c.head,c.anchor)<0;n[l]=new as(f?u:a,f?a:u)}else n[l]=new as(a,a)}return new ss(n,e.sel.primIndex)}function zn(e){e.doc.mode=Ye(e.options,e.doc.modeOption),Rn(e)}function Rn(e){e.doc.iter(function(e){e.stateAfter&&(e.stateAfter=null),e.styles&&(e.styles=null)}),e.doc.frontier=e.doc.first,wn(e,100),e.state.modeGen++,e.curOp&&pn(e)}function Bn(e,t){return 0==t.from.ch&&0==t.to.ch&&""==g(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){at(e,r,i,n),St(e,"change",e,t)}function l(e,t){for(var r=[],o=e;o<t;++o)r.push(new Yl(u[o],i(o),n));return r}var s=t.from,a=t.to,u=t.text,c=M(e,s.line),f=M(e,a.line),h=g(u),d=i(u.length-1),p=a.line-s.line;if(t.full)e.insert(0,l(0,u.length)),
|
3 |
+
e.remove(u.length,e.size-u.length);else if(Bn(e,t)){var v=l(0,u.length-1);o(f,f.text,d),p&&e.remove(s.line,p),v.length&&e.insert(s.line,v)}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 m=l(1,u.length-1);m.push(new Yl(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,m)}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 y=l(1,u.length-1);p>1&&e.remove(s.line+1,p-1),e.insert(s.line+1,y)}St(e,"change",e,t)}function Un(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 Vn(e,t){if(t.cm)throw new Error("This document is already in use.");e.doc=t,t.cm=e,Cr(e),zn(e),Kn(e),e.options.lineWrapping||we(e),e.options.mode=t.modeOption,pn(e)}function Kn(e){("rtl"==e.doc.direction?s:bl)(e.display.lineDiv,"CodeMirror-rtl")}function jn(e){cn(e,function(){Kn(e),pn(e)})}function Xn(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 Yn(e,t){var r={from:z(t.from),to:Hn(t),text:N(e,t.from,t.to)};return ei(e,r,t.from.line,t.to.line+1),Un(e,function(e){return ei(e,r,t.from.line,t.to.line+1)},!0),r}function _n(e){for(;e.length;){var t=g(e);if(!t.ranges)break;e.pop()}}function $n(e,t){return t?(_n(e.done),g(e.done)):e.done.length&&!g(e.done).ranges?g(e.done):e.done.length>1&&!e.done[e.done.length-2].ranges?(e.done.pop(),g(e.done)):void 0}function qn(e,t,r,n){var i=e.history;i.undone.length=0;var o,l,s=+new Date;if((i.lastOp==n||i.lastOrigin==t.origin&&t.origin&&("+"==t.origin.charAt(0)&&e.cm&&i.lastModTime>s-e.cm.options.historyEventDelay||"*"==t.origin.charAt(0)))&&(o=$n(i,i.lastOp==n)))l=g(o.changes),0==F(t.from,t.to)&&0==F(t.from,l.to)?l.to=Hn(t):o.changes.push(Yn(e,t));else{var a=g(i.done);for(a&&a.ranges||Jn(e.sel,i.done),o={changes:[Yn(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=s,i.lastOp=i.lastSelOp=n,i.lastOrigin=i.lastSelOrigin=t.origin,l||We(e,"historyAdded")}function Zn(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 Qn(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||Zn(e,o,g(i.done),t))?i.done[i.done.length-1]=t:Jn(t,i.done),i.lastSelTime=+new Date,i.lastSelOrigin=o,i.lastSelOp=r,n&&n.clearRedo!==!1&&_n(i.undone)}function Jn(e,t){var r=g(t);r&&r.ranges&&r.equals(e)||t.push(e)}function ei(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 ti(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 ri(e,t){var r=t["spans_"+e.id];if(!r)return null;for(var n=[],i=0;i<t.text.length;++i)n.push(ti(r[i]));return n}function ni(e,t){var r=ri(e,t),n=J(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 ii(e,t,r){for(var n=[],i=0;i<e.length;++i){var o=e[i];if(o.ranges)n.push(r?ss.prototype.deepCopy.call(o):o);else{var l=o.changes,s=[];n.push({changes:s});for(var a=0;a<l.length;++a){var u=l[a],c=void 0;if(s.push({from:u.from,to:u.to,text:u.text}),t)for(var f in u)(c=f.match(/^spans_(\d+)$/))&&h(t,Number(c[1]))>-1&&(g(s)[f]=u[f],delete u[f])}}}return n}function oi(e,t,r,n){if(e.cm&&e.cm.display.shift||e.extend){var i=t.anchor;if(n){var o=F(r,i)<0;o!=F(n,i)<0?(i=r,r=n):o!=F(r,n)<0&&(r=n)}return new as(i,r)}return new as(n||r,r)}function li(e,t,r,n){hi(e,new ss([oi(e,e.sel.primary(),t,r)],0),n)}function si(e,t,r){for(var n=[],i=0;i<e.sel.ranges.length;i++)n[i]=oi(e,e.sel.ranges[i],t[i],null);var o=An(n,e.sel.primIndex);hi(e,o,r)}function ai(e,t,r,n){var i=e.sel.ranges.slice(0);i[t]=r,hi(e,An(i,e.sel.primIndex),n)}function ui(e,t,r,n){hi(e,Dn(t,r),n)}function ci(e,t,r){var n={ranges:t.ranges,update:function(t){var r=this;this.ranges=[];for(var n=0;n<t.length;n++)r.ranges[n]=new as(U(e,t[n].anchor),U(e,t[n].head))},origin:r&&r.origin};return We(e,"beforeSelectionChange",e,n),e.cm&&We(e.cm,"beforeSelectionChange",e.cm,n),n.ranges!=t.ranges?An(n.ranges,n.ranges.length-1):t}function fi(e,t,r){var n=e.history.done,i=g(n);i&&i.ranges?(n[n.length-1]=t,di(e,t,r)):hi(e,t,r)}function hi(e,t,r){di(e,t,r),Qn(e,e.sel,e.cm?e.cm.curOp.id:NaN,r)}function di(e,t,r){(He(e,"beforeSelectionChange")||e.cm&&He(e.cm,"beforeSelectionChange"))&&(t=ci(e,t,r));var n=r&&r.bias||(F(t.primary().head,e.sel.primary().head)<0?-1:1);pi(e,vi(e,t,n,!0)),r&&r.scroll===!1||!e.cm||Jr(e.cm)}function pi(e,t){t.equals(e.sel)||(e.sel=t,e.cm&&(e.cm.curOp.updateInput=e.cm.curOp.selectionChanged=!0,De(e.cm)),St(e,"cursorActivity",e))}function gi(e){pi(e,vi(e,e.sel,null,!1),kl)}function vi(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=yi(e,l.anchor,s&&s.anchor,r,n),u=yi(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 as(a,u))}return i?An(i,t.primIndex):t}function mi(e,t,r,n,i){var o=M(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&&(We(a,"beforeCursorEnter"),a.explicitlyCleared)){if(o.markedSpans){--l;continue}break}if(!a.atomic)continue;if(r){var u=a.find(n<0?1:-1),c=void 0;if((n<0?a.inclusiveRight:a.inclusiveLeft)&&(u=bi(e,u,-n,u&&u.line==t.line?o:null)),u&&u.line==t.line&&(c=F(u,r))&&(n<0?c<0:c>0))return mi(e,u,t,n,i)}var f=a.find(n<0?-1:1);return(n<0?a.inclusiveLeft:a.inclusiveRight)&&(f=bi(e,f,n,f.line==t.line?o:null)),f?mi(e,f,t,n,i):null}}return t}function yi(e,t,r,n,i){var o=n||1,l=mi(e,t,r,o,i)||!i&&mi(e,t,r,o,!0)||mi(e,t,r,-o,i)||!i&&mi(e,t,r,-o,!0);return l?l:(e.cantEdit=!0,E(e.first,0))}function bi(e,t,r,n){return r<0&&0==t.ch?t.line>e.first?U(e,E(t.line-1)):null:r>0&&t.ch==(n||M(e,t.line)).text.length?t.line<e.first+e.size-1?E(t.line+1,0):null:new E(t.line,t.ch+r)}function wi(e){e.setSelection(E(e.firstLine(),0),E(e.lastLine()),kl)}function xi(e,t,r){var n={canceled:!1,from:t.from,to:t.to,text:t.text,origin:t.origin,cancel:function(){return n.canceled=!0}};return r&&(n.update=function(t,r,i,o){t&&(n.from=U(e,t)),r&&(n.to=U(e,r)),i&&(n.text=i),void 0!==o&&(n.origin=o)}),We(e,"beforeChange",e,n),e.cm&&We(e.cm,"beforeChange",e.cm,n),n.canceled?null:{from:n.from,to:n.to,text:n.text,origin:n.origin}}function Ci(e,t,r){if(e.cm){if(!e.cm.curOp)return fn(e.cm,Ci)(e,t,r);if(e.cm.state.suppressEdits)return}if(!(He(e,"beforeChange")||e.cm&&He(e.cm,"beforeChange"))||(t=xi(e,t,!0))){var n=Dl&&!r&&te(e,t.from,t.to);if(n)for(var i=n.length-1;i>=0;--i)Si(e,{from:n[i].from,to:n[i].to,text:i?[""]:t.text});else Si(e,t)}}function Si(e,t){if(1!=t.text.length||""!=t.text[0]||0!=F(t.from,t.to)){var r=En(e,t);qn(e,t,r,e.cm?e.cm.curOp.id:NaN),ki(e,t,r,J(e,t));var n=[];Un(e,function(e,r){r||h(n,e.history)!=-1||(Ai(e.history,t),n.push(e.history)),ki(e,t,null,J(e,t))})}}function Li(e,t,r){if(!e.cm||!e.cm.state.suppressEdits||r){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(Jn(n,s),r&&!n.equals(e.sel))return void hi(e,n,{clearRedo:!1});o=n}var u=[];Jn(o,s),s.push({changes:u,generation:i.generation}),i.generation=n.generation||++i.maxGeneration;for(var c=He(e,"beforeChange")||e.cm&&He(e.cm,"beforeChange"),f=function(r){var i=n.changes[r];if(i.origin=t,c&&!xi(e,i,!1))return l.length=0,{};u.push(Yn(e,i));var o=r?En(e,i):g(l);ki(e,i,o,ni(e,i)),!r&&e.cm&&e.cm.scrollIntoView({from:i.from,to:Hn(i)});var s=[];Un(e,function(e,t){t||h(s,e.history)!=-1||(Ai(e.history,i),s.push(e.history)),ki(e,i,null,ni(e,i))})},d=n.changes.length-1;d>=0;--d){var p=f(d);if(p)return p.v}}}}function Ti(e,t){if(0!=t&&(e.first+=t,e.sel=new ss(v(e.sel.ranges,function(e){return new as(E(e.anchor.line+t,e.anchor.ch),E(e.head.line+t,e.head.ch))}),e.sel.primIndex),e.cm)){pn(e.cm,e.first,e.first-t,t);for(var r=e.cm.display,n=r.viewFrom;n<r.viewTo;n++)gn(e.cm,n,"gutter")}}function ki(e,t,r,n){if(e.cm&&!e.cm.curOp)return fn(e.cm,ki)(e,t,r,n);if(t.to.line<e.first)return void Ti(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);Ti(e,i),t={from:E(e.first,0),to:E(t.to.line+i,t.to.ch),text:[g(t.text)],origin:t.origin}}var o=e.lastLine();t.to.line>o&&(t={from:t.from,to:E(o,M(e,o).text.length),text:[t.text[0]],origin:t.origin}),t.removed=N(e,t.from,t.to),r||(r=En(e,t)),e.cm?Mi(e.cm,t,n):Gn(e,t,n),di(e,r,kl)}}function Mi(e,t,r){var n=e.doc,i=e.display,o=t.from,l=t.to,s=!1,a=o.line;e.options.lineWrapping||(a=A(fe(M(n,o.line))),n.iter(a,l.line+1,function(e){if(e==i.maxLine)return s=!0,!0})),n.sel.contains(t.from,t.to)>-1&&De(e),Gn(n,t,r,xr(e)),e.options.lineWrapping||(n.iter(a,o.line+t.text.length,function(e){var t=be(e);t>i.maxLineLength&&(i.maxLine=e,i.maxLineLength=t,i.maxLineChanged=!0,s=!1)}),s&&(e.curOp.updateMaxLine=!0)),n.frontier=Math.min(n.frontier,o.line),wn(e,400);var u=t.text.length-(l.line-o.line)-1;t.full?pn(e):o.line!=l.line||1!=t.text.length||Bn(e.doc,t)?pn(e,o.line,l.line+1,u):gn(e,o.line,"text");var c=He(e,"changes"),f=He(e,"change");if(f||c){var h={from:o,to:l,text:t.text,removed:t.removed,origin:t.origin};f&&St(e,"change",e,h),c&&(e.curOp.changeObjs||(e.curOp.changeObjs=[])).push(h)}e.display.selForContextMenu=null}function Ni(e,t,r,n,i){if(n||(n=r),F(n,r)<0){var o=n;n=r,r=o}"string"==typeof t&&(t=e.splitLines(t)),Ci(e,{from:r,to:n,text:t,origin:i})}function Oi(e,t,r,n){r<e.line?e.line+=n:t<e.line&&(e.line=t,e.ch=0)}function Wi(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++)Oi(o.ranges[s].anchor,t,r,n),Oi(o.ranges[s].head,t,r,n)}else{for(var a=0;a<o.changes.length;++a){var u=o.changes[a];if(r<u.from.line)u.from=E(u.from.line+n,u.from.ch),u.to=E(u.to.line+n,u.to.ch);else if(t<=u.to.line){l=!1;break}}l||(e.splice(0,i+1),i=0)}}}function Ai(e,t){var r=t.from.line,n=t.to.line,i=t.text.length-(n-r)-1;Wi(e.done,r,n,i),Wi(e.undone,r,n,i)}function Di(e,t,r,n){var i=t,o=t;return"number"==typeof t?o=M(e,G(e,t)):i=A(t),null==i?null:(n(o,i)&&e.cm&&gn(e.cm,i,r),o)}function Hi(e,t,r){ye(t)<(e.curOp&&e.curOp.scrollTop||e.doc.scrollTop)&&Qr(e,null,r)}function Pi(e,t,r,n){var i=new fs(e,r,n),o=e.cm;return o&&i.noHScroll&&(o.display.alignWidgets=!0),Di(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&&!ve(e,t)){var n=ye(t)<e.scrollTop;W(t,t.height+It(i)),n&&Qr(o,null,i.height),o.curOp.forceUpdate=!0}return!0}),St(o,"lineWidgetAdded",o,i,"number"==typeof t?t:A(t)),i}function Ei(e,t,r,n,o){if(n&&n.shared)return Fi(e,t,r,n,o);if(e.cm&&!e.cm.curOp)return fn(e.cm,Ei)(e,t,r,n,o);var l=new ds(e,o),s=F(t,r);if(n&&c(n,l,!1),s>0||0==s&&l.clearWhenEmpty!==!1)return l;if(l.replacedWith&&(l.collapsed=!0,l.widgetNode=i("span",[l.replacedWith],"CodeMirror-widget"),n.handleMouseEvents||l.widgetNode.setAttribute("cm-ignore-events","true"),n.insertLeft&&(l.widgetNode.insertLeft=!0)),l.collapsed){if(ce(e,t.line,t,r,l)||t.line!=r.line&&ce(e,r.line,t,r,l))throw new Error("Inserting collapsed marker partially overlapping an existing one");X()}l.addToHistory&&qn(e,{from:t,to:r,origin:"markText"},e.sel,NaN);var a,u=t.line,f=e.cm;if(e.iter(u,r.line+1,function(e){f&&l.collapsed&&!f.options.lineWrapping&&fe(e)==f.display.maxLine&&(a=!0),l.collapsed&&u!=t.line&&W(e,0),q(e,new Y(l,u==t.line?t.ch:null,u==r.line?r.ch:null)),++u}),l.collapsed&&e.iter(t.line,r.line+1,function(t){ve(e,t)&&W(t,0)}),l.clearOnEnter&&Il(l,"beforeCursorEnter",function(){return l.clear()}),l.readOnly&&(j(),(e.history.done.length||e.history.undone.length)&&e.clearHistory()),l.collapsed&&(l.id=++hs,l.atomic=!0),f){if(a&&(f.curOp.updateMaxLine=!0),l.collapsed)pn(f,t.line,r.line+1);else if(l.className||l.title||l.startStyle||l.endStyle||l.css)for(var h=t.line;h<=r.line;h++)gn(f,h,"text");l.atomic&&gi(f.doc),St(f,"markerAdded",f,l)}return l}function Fi(e,t,r,n,i){n=c(n),n.shared=!1;var o=[Ei(e,t,r,n,i)],l=o[0],s=n.widgetNode;return Un(e,function(e){s&&(n.widgetNode=s.cloneNode(!0)),o.push(Ei(e,U(e,t),U(e,r),n,i));for(var a=0;a<e.linked.length;++a)if(e.linked[a].isParent)return;l=g(o)}),new ps(o,l)}function Ii(e){return e.findMarks(E(e.first,0),e.clipPos(E(e.lastLine())),function(e){return e.parent})}function zi(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(F(o,l)){var s=Ei(e,o,l,n.primary,n.primary.type);n.markers.push(s),s.parent=n}}}function Ri(e){for(var t=function(t){var r=e[t],n=[r.primary.doc];Un(r.primary.doc,function(e){return n.push(e)});for(var i=0;i<r.markers.length;i++){var o=r.markers[i];h(n,o.doc)==-1&&(o.parent=null,r.markers.splice(i--,1))}},r=0;r<e.length;r++)t(r)}function Bi(e){var t=this;if(Vi(t),!Ae(t,e)&&!zt(t.display,e)){Ee(e),el&&(ms=+new Date);var r=Sr(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||h(t.options.allowDropFileTypes,e.type)!=-1){var s=new FileReader;s.onload=fn(t,function(){var e=s.result;if(/[\x00-\x08\x0e-\x1f]{2}/.test(e)&&(e=""),o[n]=e,++l==i){r=U(t.doc,r);var a={from:r,to:r,text:t.doc.splitLines(o.join(t.doc.lineSeparator())),origin:"paste"};Ci(t.doc,a),fi(t.doc,Dn(r,Hn(a)))}}),s.readAsText(e)}},a=0;a<i;++a)s(n[a],a);else{if(t.state.draggingText&&t.doc.sel.contains(r)>-1)return t.state.draggingText(e),void setTimeout(function(){return t.display.input.focus()},20);try{var u=e.dataTransfer.getData("Text");if(u){var c;if(t.state.draggingText&&!t.state.draggingText.copy&&(c=t.listSelections()),di(t.doc,Dn(r,r)),c)for(var f=0;f<c.length;++f)Ni(t.doc,"",c[f].anchor,c[f].head,"drag");t.replaceSelection(u,"around","paste"),t.display.input.focus()}}catch(e){}}}}function Gi(e,t){if(el&&(!e.state.draggingText||+new Date-ms<100))return void ze(t);if(!Ae(e,t)&&!zt(e.display,t)&&(t.dataTransfer.setData("Text",e.getSelection()),t.dataTransfer.effectAllowed="copyMove",t.dataTransfer.setDragImage&&!ll)){var r=n("img",null,null,"position: fixed; left: 0; top: 0;");r.src="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==",ol&&(r.width=r.height=1,e.display.wrapper.appendChild(r),r._top=r.offsetTop),t.dataTransfer.setDragImage(r,0,0),ol&&r.parentNode.removeChild(r)}}function Ui(e,t){var i=Sr(e,t);if(i){var o=document.createDocumentFragment();Mr(e,i,o),e.display.dragCursor||(e.display.dragCursor=n("div",null,"CodeMirror-cursors CodeMirror-dragcursors"),e.display.lineSpace.insertBefore(e.display.dragCursor,e.display.cursorDiv)),r(e.display.dragCursor,o)}}function Vi(e){e.display.dragCursor&&(e.display.lineSpace.removeChild(e.display.dragCursor),e.display.dragCursor=null)}function Ki(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 ji(){ys||(Xi(),ys=!0)}function Xi(){var e;Il(window,"resize",function(){null==e&&(e=setTimeout(function(){e=null,Ki(Yi)},100))}),Il(window,"blur",function(){return Ki(Hr)})}function Yi(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 _i(e){var t=e.split(/-(?!$)/);e=t[t.length-1];for(var r,n,i,o,l=0;l<t.length-1;l++){var s=t[l];if(/^(cmd|meta|m)$/i.test(s))o=!0;else if(/^a(lt)?$/i.test(s))r=!0;else if(/^(c|ctrl|control)$/i.test(s))n=!0;else{if(!/^s(hift)?$/i.test(s))throw new Error("Unrecognized modifier name: "+s);i=!0}}return r&&(e="Alt-"+e),n&&(e="Ctrl-"+e),o&&(e="Cmd-"+e),i&&(e="Shift-"+e),e}function $i(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=v(r.split(" "),_i),o=0;o<i.length;o++){var l=void 0,s=void 0;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}function qi(e,t,r,n){t=Ji(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 qi(e,t.fallthrough,r,n);for(var o=0;o<t.fallthrough.length;o++){var l=qi(e,t.fallthrough[o],r,n);if(l)return l}}}function Zi(e){var t="string"==typeof e?e:bs[e.keyCode];return"Ctrl"==t||"Alt"==t||"Shift"==t||"Mod"==t}function Qi(e,t){if(ol&&34==e.keyCode&&e["char"])return!1;var r=bs[e.keyCode],n=r;return null!=n&&!e.altGraphKey&&(e.altKey&&"Alt"!=r&&(n="Alt-"+n),(ml?e.metaKey:e.ctrlKey)&&"Ctrl"!=r&&(n="Ctrl-"+n),(ml?e.ctrlKey:e.metaKey)&&"Cmd"!=r&&(n="Cmd-"+n),!t&&e.shiftKey&&"Shift"!=r&&(n="Shift-"+n),n)}function Ji(e){return"string"==typeof e?Ss[e]:e}function eo(e,t){for(var r=e.doc.sel.ranges,n=[],i=0;i<r.length;i++){for(var o=t(r[i]);n.length&&F(o.from,g(n).to)<=0;){var l=n.pop();if(F(l.from,o.from)<0){o.from=l.from;break}}n.push(o)}cn(e,function(){for(var t=n.length-1;t>=0;t--)Ni(e.doc,"",n[t].from,n[t].to,"+delete");Jr(e)})}function to(e,t){var r=M(e.doc,t),n=fe(r);return n!=r&&(t=A(n)),ke(!0,e,n,t,1)}function ro(e,t){var r=M(e.doc,t),n=he(r);return n!=r&&(t=A(n)),ke(!0,e,r,t,-1)}function no(e,t){var r=to(e,t.line),n=M(e.doc,r.line),i=Se(n,e.doc.direction);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 E(r.line,l?0:o,r.sticky)}return r}function io(e,t,r){if("string"==typeof t&&(t=ks[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)!=Tl}finally{e.display.shift=n,e.state.suppressEdits=!1}return i}function oo(e,t,r){for(var n=0;n<e.state.keyMaps.length;n++){var i=qi(t,e.state.keyMaps[n],r,e);if(i)return i}return e.options.extraKeys&&qi(t,e.options.extraKeys,r,e)||qi(t,e.options.keyMap,r,e)}function lo(e,t,r,n){var i=e.state.keySeq;if(i){if(Zi(t))return"handled";Ms.set(50,function(){e.state.keySeq==i&&(e.state.keySeq=null,e.display.input.reset())}),t=i+" "+t}var o=oo(e,t,n);return"multi"==o&&(e.state.keySeq=t),"handled"==o&&St(e,"keyHandled",e,t,r),"handled"!=o&&"multi"!=o||(Ee(r),Or(e)),i&&!o&&/\'$/.test(t)?(Ee(r),!0):!!o}function so(e,t){var r=Qi(t,!0);return!!r&&(t.shiftKey&&!e.state.keySeq?lo(e,"Shift-"+r,t,function(t){return io(e,t,!0)})||lo(e,r,t,function(t){if("string"==typeof t?/^go[A-Z]/.test(t):t.motion)return io(e,t)}):lo(e,r,t,function(t){return io(e,t)}))}function ao(e,t,r){return lo(e,"'"+r+"'",t,function(t){return io(e,t,!0)})}function uo(e){var t=this;if(t.curOp.focus=l(),!Ae(t,e)){el&&tl<11&&27==e.keyCode&&(e.returnValue=!1);var r=e.keyCode;t.display.shift=16==r||e.shiftKey;var n=so(t,e);ol&&(Ns=n?r:null,!n&&88==r&&!Gl&&(hl?e.metaKey:e.ctrlKey)&&t.replaceSelection("",null,"cut")),18!=r||/\bCodeMirror-crosshair\b/.test(t.display.lineDiv.className)||co(t)}}function co(e){function t(e){18!=e.keyCode&&e.altKey||(bl(r,"CodeMirror-crosshair"),Oe(document,"keyup",t),Oe(document,"mouseover",t))}var r=e.display.lineDiv;s(r,"CodeMirror-crosshair"),Il(document,"keyup",t),Il(document,"mouseover",t)}function fo(e){16==e.keyCode&&(this.doc.sel.shift=!1),Ae(this,e)}function ho(e){var t=this;if(!(zt(t.display,e)||Ae(t,e)||e.ctrlKey&&!e.altKey||hl&&e.metaKey)){var r=e.keyCode,n=e.charCode;if(ol&&r==Ns)return Ns=null,void Ee(e);if(!ol||e.which&&!(e.which<10)||!so(t,e)){var i=String.fromCharCode(null==n?r:n);"\b"!=i&&(ao(t,e,i)||t.display.input.onKeyPress(e))}}}function po(e){var t=this,r=t.display;if(!(Ae(t,e)||r.activeTouch&&r.input.supportsTouch())){if(r.input.ensurePolled(),r.shift=e.shiftKey,zt(r,e))return void(rl||(r.scroller.draggable=!1,setTimeout(function(){return r.scroller.draggable=!0},100)));if(!bo(t,e)){var n=Sr(t,e);switch(window.focus(),Be(e)){case 1:t.state.selectingText?t.state.selectingText(e):n?go(t,e,n):Re(e)==r.scroller&&Ee(e);break;case 2:rl&&(t.state.lastMiddleDown=+new Date),n&&li(t.doc,n),setTimeout(function(){return r.input.focus()},20),Ee(e);break;case 3:yl?wo(t,e):Ar(t)}}}}function go(e,t,r){el?setTimeout(u(Wr,e),0):e.curOp.focus=l();var n,i=+new Date;Ts&&Ts.time>i-400&&0==F(Ts.pos,r)?n="triple":Ls&&Ls.time>i-400&&0==F(Ls.pos,r)?(n="double",Ts={time:i,pos:r}):(n="single",Ls={time:i,pos:r});var o,s=e.doc.sel,a=hl?t.metaKey:t.ctrlKey;e.options.dragDrop&&zl&&!e.isReadOnly()&&"single"==n&&(o=s.contains(r))>-1&&(F((o=s.ranges[o]).from(),r)<0||r.xRel>0)&&(F(o.to(),r)>0||r.xRel<0)?vo(e,t,r,a):mo(e,t,r,n,a)}function vo(e,t,r,n){var i=e.display,o=!1,l=fn(e,function(t){rl&&(i.scroller.draggable=!1),e.state.draggingText=!1,Oe(document,"mouseup",l),Oe(document,"mousemove",s),Oe(i.scroller,"dragstart",a),Oe(i.scroller,"drop",l),o||(Ee(t),n||li(e.doc,r),rl||el&&9==tl?setTimeout(function(){document.body.focus(),i.input.focus()},20):i.input.focus())}),s=function(e){o=o||Math.abs(t.clientX-e.clientX)+Math.abs(t.clientY-e.clientY)>=10},a=function(){return o=!0};rl&&(i.scroller.draggable=!0),e.state.draggingText=l,l.copy=hl?t.altKey:t.ctrlKey,i.scroller.dragDrop&&i.scroller.dragDrop(),Il(document,"mouseup",l),Il(document,"mousemove",s),Il(i.scroller,"dragstart",a),Il(i.scroller,"drop",l),Ar(e),setTimeout(function(){return i.input.focus()},20)}function mo(e,t,r,n,i){function o(t){if(0!=F(b,t))if(b=t,"rect"==n){for(var i=[],o=e.options.tabSize,l=f(M(c,r.line).text,r.ch,o),s=f(M(c,t.line).text,t.ch,o),a=Math.min(l,s),u=Math.max(l,s),v=Math.min(r.line,t.line),m=Math.min(e.lastLine(),Math.max(r.line,t.line));v<=m;v++){var y=M(c,v).text,w=d(y,a,o);a==u?i.push(new as(E(v,w),E(v,w))):y.length>w&&i.push(new as(E(v,w),E(v,d(y,u,o))))}i.length||i.push(new as(r,r)),hi(c,An(g.ranges.slice(0,p).concat(i),p),{origin:"*mouse",scroll:!1}),e.scrollIntoView(t)}else{var x=h,C=x.anchor,S=t;if("single"!=n){var L;L="double"==n?e.findWordAt(t):new as(E(t.line,0),U(c,E(t.line+1,0))),F(L.anchor,C)>0?(S=L.head,C=B(x.from(),L.anchor)):(S=L.anchor,C=R(x.to(),L.head))}var T=g.ranges.slice(0);T[p]=new as(U(c,C),S),hi(c,An(T,p),Ml)}}function s(t){var r=++x,i=Sr(e,t,!0,"rect"==n);if(i)if(0!=F(i,b)){e.curOp.focus=l(),o(i);var a=zr(u,c);(i.line>=a.to||i.line<a.from)&&setTimeout(fn(e,function(){x==r&&s(t)}),150)}else{var f=t.clientY<w.top?-20:t.clientY>w.bottom?20:0;f&&setTimeout(fn(e,function(){x==r&&(u.scroller.scrollTop+=f,s(t))}),50)}}function a(t){e.state.selectingText=!1,x=1/0,Ee(t),u.input.focus(),Oe(document,"mousemove",C),Oe(document,"mouseup",S),c.history.lastSelOrigin=null}var u=e.display,c=e.doc;Ee(t);var h,p,g=c.sel,v=g.ranges;if(i&&!t.shiftKey?(p=c.sel.contains(r),h=p>-1?v[p]:new as(r,r)):(h=c.sel.primary(),p=c.sel.primIndex),dl?t.shiftKey&&t.metaKey:t.altKey)n="rect",i||(h=new as(r,r)),r=Sr(e,t,!0,!0),p=-1;else if("double"==n){var m=e.findWordAt(r);h=e.display.shift||c.extend?oi(c,h,m.anchor,m.head):m}else if("triple"==n){var y=new as(E(r.line,0),U(c,E(r.line+1,0)));h=e.display.shift||c.extend?oi(c,h,y.anchor,y.head):y}else h=oi(c,h,r);i?p==-1?(p=v.length,hi(c,An(v.concat([h]),p),{scroll:!1,origin:"*mouse"})):v.length>1&&v[p].empty()&&"single"==n&&!t.shiftKey?(hi(c,An(v.slice(0,p).concat(v.slice(p+1)),0),{scroll:!1,origin:"*mouse"}),g=c.sel):ai(c,p,h,Ml):(p=0,hi(c,new ss([h],0),Ml),g=c.sel);var b=r,w=u.wrapper.getBoundingClientRect(),x=0,C=fn(e,function(e){Be(e)?s(e):a(e)}),S=fn(e,a);e.state.selectingText=S,Il(document,"mousemove",C),Il(document,"mouseup",S)}function yo(e,t,r,n){var i,o;try{i=t.clientX,o=t.clientY}catch(t){return!1}if(i>=Math.floor(e.display.gutters.getBoundingClientRect().right))return!1;n&&Ee(t);var l=e.display,s=l.lineDiv.getBoundingClientRect();if(o>s.bottom||!He(e,r))return Ie(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=D(e.doc,o),f=e.options.gutters[a];return We(e,r,e,c,f,t),Ie(t)}}}function bo(e,t){return yo(e,t,"gutterClick",!0)}function wo(e,t){zt(e.display,t)||xo(e,t)||Ae(e,t,"contextmenu")||e.display.input.onContextMenu(t)}function xo(e,t){return!!He(e,"gutterContextMenu")&&yo(e,t,"gutterContextMenu",!1)}function Co(e){e.display.wrapper.className=e.display.wrapper.className.replace(/\s*cm-s-\S+/g,"")+e.options.theme.replace(/(^|\s)\s*/g," cm-s-"),ir(e)}function So(e){function t(t,n,i,o){e.defaults[t]=n,i&&(r[t]=o?function(e,t,r){r!=Os&&i(e,t,r)}:i)}var r=e.optionHandlers;e.defineOption=t,e.Init=Os,t("value","",function(e,t){return e.setValue(t)},!0),t("mode",null,function(e,t){e.doc.modeOption=t,zn(e)},!0),t("indentUnit",2,zn,!0),t("indentWithTabs",!1),t("smartIndent",!0),t("tabSize",4,function(e){Rn(e),ir(e),pn(e)},!0),t("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(o==-1)break;i=o+t.length,r.push(E(n,o))}n++});for(var i=r.length-1;i>=0;i--)Ni(e.doc,t,r[i],E(r[i].line,r[i].ch+t.length))}}),t("specialChars",/[\u0000-\u001f\u007f-\u009f\u00ad\u061c\u200b-\u200f\u2028\u2029\ufeff]/g,function(e,t,r){e.state.specialChars=new RegExp(t.source+(t.test("\t")?"":"|\t"),"g"),r!=Os&&e.refresh()}),t("specialCharPlaceholder",ht,function(e){return e.refresh()},!0),t("electricChars",!0),t("inputStyle",fl?"contenteditable":"textarea",function(){throw new Error("inputStyle can not (yet) be changed in a running editor")},!0),t("spellcheck",!1,function(e,t){return e.getInputField().spellcheck=t},!0),t("rtlMoveVisually",!pl),t("wholeLineUpdateBefore",!0),t("theme","default",function(e){Co(e),Lo(e)},!0),t("keyMap","default",function(e,t,r){var n=Ji(t),i=r!=Os&&Ji(r);i&&i.detach&&i.detach(e,n),n.attach&&n.attach(e,i||null)}),t("extraKeys",null),t("lineWrapping",!1,ko,!0),t("gutters",[],function(e){Wn(e.options),Lo(e)},!0),t("fixedGutter",!0,function(e,t){e.display.gutters.style.left=t?wr(e.display)+"px":"0",e.refresh()},!0),t("coverGutterNextToScrollbar",!1,function(e){return jr(e)},!0),t("scrollbarStyle","native",function(e){Yr(e),jr(e),e.display.scrollbars.setScrollTop(e.doc.scrollTop),e.display.scrollbars.setScrollLeft(e.doc.scrollLeft)},!0),t("lineNumbers",!1,function(e){Wn(e.options),Lo(e)},!0),t("firstLineNumber",1,Lo,!0),t("lineNumberFormatter",function(e){return e},Lo,!0),t("showCursorWhenSelecting",!1,Tr,!0),t("resetSelectionOnContextMenu",!0),t("lineWiseCopyCut",!0),t("readOnly",!1,function(e,t){"nocursor"==t?(Hr(e),e.display.input.blur(),e.display.disabled=!0):e.display.disabled=!1,e.display.input.readOnlyChanged(t)}),t("disableInput",!1,function(e,t){t||e.display.input.reset()},!0),t("dragDrop",!0,To),t("allowDropFileTypes",null),t("cursorBlinkRate",530),t("cursorScrollMargin",0),t("cursorHeight",1,Tr,!0),t("singleCursorHeightPerLine",!0,Tr,!0),t("workTime",100),t("workDelay",100),t("flattenSpans",!0,Rn,!0),t("addModeClass",!1,Rn,!0),t("pollInterval",100),t("undoDepth",200,function(e,t){return e.doc.history.undoDepth=t}),t("historyEventDelay",1250),t("viewportMargin",10,function(e){return e.refresh()},!0),t("maxHighlightLength",1e4,Rn,!0),t("moveInputWithCursor",!0,function(e,t){t||e.display.input.resetPosition()}),t("tabindex",null,function(e,t){return e.display.input.getField().tabIndex=t||""}),t("autofocus",null),t("direction","ltr",function(e,t){return e.doc.setDirection(t)},!0)}function Lo(e){On(e),pn(e),Pr(e)}function To(e,t,r){var n=r&&r!=Os;if(!t!=!n){var i=e.display.dragFunctions,o=t?Il:Oe;o(e.display.scroller,"dragstart",i.start),o(e.display.scroller,"dragenter",i.enter),o(e.display.scroller,"dragover",i.over),o(e.display.scroller,"dragleave",i.leave),o(e.display.scroller,"drop",i.drop)}}function ko(e){e.options.lineWrapping?(s(e.display.wrapper,"CodeMirror-wrap"),e.display.sizer.style.minWidth="",e.display.sizerWidth=null):(bl(e.display.wrapper,"CodeMirror-wrap"),we(e)),Cr(e),pn(e),ir(e),setTimeout(function(){return jr(e)},100)}function Mo(e,t){var r=this;if(!(this instanceof Mo))return new Mo(e,t);this.options=t=t?c(t):{},c(Ws,t,!1),Wn(t);var n=t.value;"string"==typeof n&&(n=new vs(n,t.mode,null,t.lineSeparator,t.direction)),this.doc=n;var i=new Mo.inputStyles[t.inputStyle](this),o=this.display=new k(e,n,i);o.wrapper.CodeMirror=this,On(this),Co(this),t.lineWrapping&&(this.display.wrapper.className+=" CodeMirror-wrap"),Yr(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 xl,keySeq:null,specialChars:null},t.autofocus&&!fl&&o.input.focus(),el&&tl<11&&setTimeout(function(){return r.display.input.reset(!0)},20),No(this),ji(),tn(this),this.curOp.forceUpdate=!0,Vn(this,n),t.autofocus&&!fl||this.hasFocus()?setTimeout(u(Dr,this),20):Hr(this);for(var l in As)As.hasOwnProperty(l)&&As[l](r,t[l],Os);Er(this),t.finishInit&&t.finishInit(this);for(var s=0;s<Ds.length;++s)Ds[s](r);rn(this),rl&&t.lineWrapping&&"optimizelegibility"==getComputedStyle(o.lineDiv).textRendering&&(o.lineDiv.style.textRendering="auto")}function No(e){function t(){i.activeTouch&&(o=setTimeout(function(){return 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;Il(i.scroller,"mousedown",fn(e,po)),el&&tl<11?Il(i.scroller,"dblclick",fn(e,function(t){if(!Ae(e,t)){var r=Sr(e,t);if(r&&!bo(e,t)&&!zt(e.display,t)){Ee(t);var n=e.findWordAt(r);li(e.doc,n.anchor,n.head)}}})):Il(i.scroller,"dblclick",function(t){return Ae(e,t)||Ee(t)}),yl||Il(i.scroller,"contextmenu",function(t){return wo(e,t)});var o,l={end:0};Il(i.scroller,"touchstart",function(t){if(!Ae(e,t)&&!r(t)){i.input.ensurePolled(),clearTimeout(o);var n=+new Date;i.activeTouch={start:n,moved:!1,prev:n-l.end<=300?l:null},1==t.touches.length&&(i.activeTouch.left=t.touches[0].pageX,i.activeTouch.top=t.touches[0].pageY)}}),Il(i.scroller,"touchmove",function(){i.activeTouch&&(i.activeTouch.moved=!0)}),Il(i.scroller,"touchend",function(r){var o=i.activeTouch;if(o&&!zt(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 as(s,s):!o.prev.prev||n(o,o.prev.prev)?e.findWordAt(s):new as(E(s.line,0),U(e.doc,E(s.line+1,0))),e.setSelection(l.anchor,l.head),e.focus(),Ee(r)}t()}),Il(i.scroller,"touchcancel",t),Il(i.scroller,"scroll",function(){i.scroller.clientHeight&&(Rr(e,i.scroller.scrollTop),Br(e,i.scroller.scrollLeft,!0),We(e,"scroll",e))}),Il(i.scroller,"mousewheel",function(t){return Vr(e,t)}),Il(i.scroller,"DOMMouseScroll",function(t){return Vr(e,t)}),Il(i.wrapper,"scroll",function(){return i.wrapper.scrollTop=i.wrapper.scrollLeft=0}),i.dragFunctions={enter:function(t){Ae(e,t)||ze(t)},over:function(t){Ae(e,t)||(Ui(e,t),ze(t))},start:function(t){return Gi(e,t)},drop:fn(e,Bi),leave:function(t){Ae(e,t)||Vi(e)}};var s=i.input.getField();
|
4 |
+
Il(s,"keyup",function(t){return fo.call(e,t)}),Il(s,"keydown",fn(e,uo)),Il(s,"keypress",fn(e,ho)),Il(s,"focus",function(t){return Dr(e,t)}),Il(s,"blur",function(t){return Hr(e,t)})}function Oo(e,t,r,n){var i,o=e.doc;null==r&&(r="add"),"smart"==r&&(o.mode.indent?i=et(e,t):r="prev");var l=e.options.tabSize,s=M(o,t),a=f(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==Tl||u>150)){if(!n)return;r="prev"}}else u=0,r="not";"prev"==r?u=t>o.first?f(M(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="",d=0;if(e.options.indentWithTabs)for(var g=Math.floor(u/l);g;--g)d+=l,h+="\t";if(d<u&&(h+=p(u-d)),h!=c)return Ni(o,h,E(t,0),E(t,c.length),"+input"),s.stateAfter=null,!0;for(var v=0;v<o.sel.ranges.length;v++){var m=o.sel.ranges[v];if(m.head.line==t&&m.head.ch<c.length){var y=E(t,c.length);ai(o,v,new as(y,y));break}}}function Wo(e){Hs=e}function Ao(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=Rl(t),a=null;if(l&&n.ranges.length>1)if(Hs&&Hs.text.join("\n")==t){if(n.ranges.length%Hs.text.length==0){a=[];for(var u=0;u<Hs.text.length;u++)a.push(o.splitLines(Hs.text[u]))}}else s.length==n.ranges.length&&(a=v(s,function(e){return[e]}));for(var c,f=n.ranges.length-1;f>=0;f--){var h=n.ranges[f],d=h.from(),p=h.to();h.empty()&&(r&&r>0?d=E(d.line,d.ch-r):e.state.overwrite&&!l?p=E(p.line,Math.min(M(o,p.line).text.length,p.ch+g(s).length)):Hs&&Hs.lineWise&&Hs.text.join("\n")==t&&(d=p=E(d.line,0))),c=e.curOp.updateInput;var m={from:d,to:p,text:a?a[f%a.length]:s,origin:i||(l?"paste":e.state.cutIncoming?"cut":"+input")};Ci(e.doc,m),St(e,"inputRead",e,m)}t&&!l&&Ho(e,t),Jr(e),e.curOp.updateInput=c,e.curOp.typing=!0,e.state.pasteIncoming=e.state.cutIncoming=!1}function Do(e,t){var r=e.clipboardData&&e.clipboardData.getData("Text");if(r)return e.preventDefault(),t.isReadOnly()||t.options.disableInput||cn(t,function(){return Ao(t,r,0,null,"paste")}),!0}function Ho(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=Oo(e,i.head.line,"smart");break}}else o.electricInput&&o.electricInput.test(M(e.doc,i.head.line).text.slice(0,i.head.ch))&&(l=Oo(e,i.head.line,"smart"));l&&St(e,"electricInput",e,i.head.line)}}}function Po(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:E(i,0),head:E(i+1,0)};r.push(o),t.push(e.getRange(o.anchor,o.head))}return{text:t,ranges:r}}function Eo(e,t){e.setAttribute("autocorrect","off"),e.setAttribute("autocapitalize","off"),e.setAttribute("spellcheck",!!t)}function Fo(){var e=n("textarea",null,null,"position: absolute; bottom: -1em; padding: 0; width: 1px; height: 1em; outline: none"),t=n("div",[e],null,"overflow: hidden; position: relative; width: 3px; height: 0px;");return rl?e.style.width="1000px":e.setAttribute("wrap","off"),ul&&(e.style.border="1px solid black"),Eo(e),t}function Io(e){var t=e.optionHandlers,r=e.helpers={};e.prototype={constructor:e,focus:function(){window.focus(),this.display.input.focus()},setOption:function(e,r){var n=this.options,i=n[e];n[e]==r&&"mode"!=e||(n[e]=r,t.hasOwnProperty(e)&&fn(this,t[e])(this,r,i),We(this,"optionChange",this,e))},getOption:function(e){return this.options[e]},getDoc:function(){return this.doc},addKeyMap:function(e,t){this.state.keyMaps[t?"push":"unshift"](Ji(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:hn(function(t,r){var n=t.token?t:e.getMode(this.options,t);if(n.startState)throw new Error("Overlays may not be stateful.");m(this.state.overlays,{mode:n,modeSpec:t,opaque:r&&r.opaque,priority:r&&r.priority||0},function(e){return e.priority}),this.state.modeGen++,pn(this)}),removeOverlay:hn(function(e){for(var t=this,r=this.state.overlays,n=0;n<r.length;++n){var i=r[n].modeSpec;if(i==e||"string"==typeof e&&i.name==e)return r.splice(n,1),t.state.modeGen++,void pn(t)}}),indentLine:hn(function(e,t,r){"string"!=typeof t&&"number"!=typeof t&&(t=null==t?this.options.smartIndent?"smart":"prev":t?"add":"subtract"),H(this.doc,e)&&Oo(this,e,t,r)}),indentSelection:hn(function(e){for(var t=this,r=this.doc.sel.ranges,n=-1,i=0;i<r.length;i++){var o=r[i];if(o.empty())o.head.line>n&&(Oo(t,o.head.line,e,!0),n=o.head.line,i==t.doc.sel.primIndex&&Jr(t));else{var l=o.from(),s=o.to(),a=Math.max(n,l.line);n=Math.min(t.lastLine(),s.line-(s.ch?0:1))+1;for(var u=a;u<n;++u)Oo(t,u,e);var c=t.doc.sel.ranges;0==l.ch&&r.length==c.length&&c[i].from().ch>0&&ai(t.doc,i,new as(l,c[i].to()),kl)}}}),getTokenAt:function(e,t){return it(this,e,t)},getLineTokens:function(e,t){return it(this,E(e),t,!0)},getTokenTypeAt:function(e){e=U(this.doc,e);var t,r=Je(this,M(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("overlay "):-1;return s<0?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 n=this,i=[];if(!r.hasOwnProperty(t))return i;var o=r[t],l=this.getModeAt(e);if("string"==typeof l[t])o[l[t]]&&i.push(o[l[t]]);else if(l[t])for(var s=0;s<l[t].length;s++){var a=o[l[t][s]];a&&i.push(a)}else l.helperType&&o[l.helperType]?i.push(o[l.helperType]):o[l.name]&&i.push(o[l.name]);for(var u=0;u<o._global.length;u++){var c=o._global[u];c.pred(l,n)&&h(i,c.val)==-1&&i.push(c.val)}return i},getStateAfter:function(e,t){var r=this.doc;return e=G(r,null==e?r.first+r.size-1:e),et(this,e+1,t)},cursorCoords:function(e,t){var r,n=this.doc.sel.primary();return r=null==e?n.head:"object"==typeof e?U(this.doc,e):e?n.from():n.to(),cr(this,r,t||"page")},charCoords:function(e,t){return ur(this,U(this.doc,e),t||"page")},coordsChar:function(e,t){return e=ar(this,e,t||"page"),dr(this,e.left,e.top)},lineAtHeight:function(e,t){return e=ar(this,{top:e,left:0},t||"page").top,D(this.doc,e+this.display.viewOffset)},heightAtLine:function(e,t,r){var n,i=!1;if("number"==typeof e){var o=this.doc.first+this.doc.size-1;e<this.doc.first?e=this.doc.first:e>o&&(e=o,i=!0),n=M(this.doc,e)}else n=e;return sr(this,n,{top:0,left:0},t||"page",r||i).top+(i?this.doc.height-ye(n):0)},defaultTextHeight:function(){return mr(this.display)},defaultCharWidth:function(){return yr(this.display)},getViewport:function(){return{from:this.display.viewFrom,to:this.display.viewTo}},addWidget:function(e,t,r,n,i){var o=this.display;e=cr(this,U(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&&qr(this,{left:s,top:l,right:s+t.offsetWidth,bottom:l+t.offsetHeight})},triggerOnKeyDown:hn(uo),triggerOnKeyPress:hn(ho),triggerOnKeyUp:fo,execCommand:function(e){if(ks.hasOwnProperty(e))return ks[e].call(null,this)},triggerElectric:hn(function(e){Ho(this,e)}),findPosH:function(e,t,r,n){var i=this,o=1;t<0&&(o=-1,t=-t);for(var l=U(this.doc,e),s=0;s<t&&(l=zo(i.doc,l,o,r,n),!l.hitSide);++s);return l},moveH:hn(function(e,t){var r=this;this.extendSelectionsBy(function(n){return r.display.shift||r.doc.extend||n.empty()?zo(r.doc,n.head,e,t,r.options.rtlMoveVisually):e<0?n.from():n.to()},Nl)}),deleteH:hn(function(e,t){var r=this.doc.sel,n=this.doc;r.somethingSelected()?n.replaceSelection("",null,"+delete"):eo(this,function(r){var i=zo(n,r.head,e,t,!1);return e<0?{from:i,to:r.head}:{from:r.head,to:i}})}),findPosV:function(e,t,r,n){var i=this,o=1,l=n;t<0&&(o=-1,t=-t);for(var s=U(this.doc,e),a=0;a<t;++a){var u=cr(i,s,"div");if(null==l?l=u.left:u.left=l,s=Ro(i,u,o,r),s.hitSide)break}return s},moveV:hn(function(e,t){var r=this,n=this.doc,i=[],o=!this.display.shift&&!n.extend&&n.sel.somethingSelected();if(n.extendSelectionsBy(function(l){if(o)return e<0?l.from():l.to();var s=cr(r,l.head,"div");null!=l.goalColumn&&(s.left=l.goalColumn),i.push(s.left);var a=Ro(r,s,e,t);return"page"==t&&l==n.sel.primary()&&Qr(r,null,ur(r,a,"div").top-s.top),a},Nl),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=M(t,e.line).text,n=e.ch,i=e.ch;if(r){var o=this.getHelper(e,"wordChars");"before"!=e.sticky&&i!=r.length||!n?++i:--n;for(var l=r.charAt(n),s=x(l,o)?function(e){return x(e,o)}:/\s/.test(l)?function(e){return/\s/.test(e)}:function(e){return!/\s/.test(e)&&!x(e)};n>0&&s(r.charAt(n-1));)--n;for(;i<r.length&&s(r.charAt(i));)++i}return new as(E(e.line,n),E(e.line,i))},toggleOverwrite:function(e){null!=e&&e==this.state.overwrite||((this.state.overwrite=!this.state.overwrite)?s(this.display.cursorDiv,"CodeMirror-overwrite"):bl(this.display.cursorDiv,"CodeMirror-overwrite"),We(this,"overwriteToggle",this,this.state.overwrite))},hasFocus:function(){return this.display.input.getField()==l()},isReadOnly:function(){return!(!this.options.readOnly&&!this.doc.cantEdit)},scrollTo:hn(function(e,t){null==e&&null==t||en(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-Ut(this)-this.display.barHeight,width:e.scrollWidth-Ut(this)-this.display.barWidth,clientHeight:Kt(this),clientWidth:Vt(this)}},scrollIntoView:hn(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:E(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)en(this),this.curOp.scrollToPos=e;else{var r=Zr(this,{left:Math.min(e.from.left,e.to.left),top:Math.min(e.from.top,e.to.top)-e.margin,right:Math.max(e.from.right,e.to.right),bottom:Math.max(e.from.bottom,e.to.bottom)+e.margin});this.scrollTo(r.scrollLeft,r.scrollTop)}}),setSize:hn(function(e,t){var r=this,n=function(e){return"number"==typeof e||/^\d+$/.test(String(e))?e+"px":e};null!=e&&(this.display.wrapper.style.width=n(e)),null!=t&&(this.display.wrapper.style.height=n(t)),this.options.lineWrapping&&nr(this);var i=this.display.viewFrom;this.doc.iter(i,this.display.viewTo,function(e){if(e.widgets)for(var t=0;t<e.widgets.length;t++)if(e.widgets[t].noHScroll){gn(r,i,"widget");break}++i}),this.curOp.forceUpdate=!0,We(this,"refresh",this)}),operation:function(e){return cn(this,e)},refresh:hn(function(){var e=this.display.cachedTextHeight;pn(this),this.curOp.forceUpdate=!0,ir(this),this.scrollTo(this.doc.scrollLeft,this.doc.scrollTop),Mn(this),(null==e||Math.abs(e-mr(this.display))>.5)&&Cr(this),We(this,"refresh",this)}),swapDoc:hn(function(e){var t=this.doc;return t.cm=null,Vn(this,e),ir(this),this.display.input.reset(),this.scrollTo(e.scrollLeft,e.scrollTop),this.curOp.forceScroll=!0,St(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}},Pe(e),e.registerHelper=function(t,n,i){r.hasOwnProperty(t)||(r[t]=e[t]={_global:[]}),r[t][n]=i},e.registerGlobalHelper=function(t,n,i,o){e.registerHelper(t,n,o),r[t]._global.push({pred:i,val:o})}}function zo(e,t,r,n,i){function o(){var n=t.line+r;return!(n<e.first||n>=e.first+e.size)&&(t=new E(n,t.ch,t.sticky),u=M(e,n))}function l(n){var l;if(l=i?Me(e.cm,u,t,r):Te(u,t,r),null==l){if(n||!o())return!1;t=ke(i,e.cm,u,t.line,r)}else t=l;return!0}var s=t,a=r,u=M(e,t.line);if("char"==n)l();else if("column"==n)l(!0);else if("word"==n||"group"==n)for(var c=null,f="group"==n,h=e.cm&&e.cm.getHelper(t,"wordChars"),d=!0;!(r<0)||l(!d);d=!1){var p=u.text.charAt(t.ch)||"\n",g=x(p,h)?"w":f&&"\n"==p?"n":!f||/\s/.test(p)?null:"p";if(!f||d||g||(g="s"),c&&c!=g){r<0&&(r=1,l(),t.sticky="after");break}if(g&&(c=g),r>0&&!l(!d))break}var v=yi(e,t,s,a,!0);return I(s,v)&&(v.hitSide=!0),v}function Ro(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),a=Math.max(s-.5*mr(e.display),3);i=(r>0?t.bottom:t.top)+r*a}else"line"==n&&(i=r>0?t.bottom+3:t.top-3);for(var u;u=dr(e,l,i),u.outside;){if(r<0?i<=0:i>=o.height){u.hitSide=!0;break}i+=5*r}return u}function Bo(e,t){var r=$t(e,t.line);if(!r||r.hidden)return null;var n=M(e.doc,t.line),i=Xt(r,n,t.line),o=Se(n,e.doc.direction),l="left";if(o){var s=Ce(o,t.ch);l=s%2?"right":"left"}var a=Qt(i.map,t.ch,l);return a.offset="right"==a.collapse?a.end:a.start,a}function Go(e){for(var t=e;t;t=t.parentNode)if(/CodeMirror-gutter-wrapper/.test(t.className))return!0;return!1}function Uo(e,t){return t&&(e.bad=!0),e}function Vo(e,t,r,n,i){function o(e){return function(t){return t.id==e}}function l(){c&&(u+=f,c=!1)}function s(e){e&&(l(),u+=e)}function a(t){if(1==t.nodeType){var r=t.getAttribute("cm-text");if(null!=r)return void s(r||t.textContent.replace(/\u200b/g,""));var u,h=t.getAttribute("cm-marker");if(h){var d=e.findMarks(E(n,0),E(i+1,0),o(+h));return void(d.length&&(u=d[0].find())&&s(N(e.doc,u.from,u.to).join(f)))}if("false"==t.getAttribute("contenteditable"))return;var p=/^(pre|div|p)$/i.test(t.nodeName);p&&l();for(var g=0;g<t.childNodes.length;g++)a(t.childNodes[g]);p&&(c=!0)}else 3==t.nodeType&&s(t.nodeValue)}for(var u="",c=!1,f=e.doc.lineSeparator();a(t),t!=r;)t=t.nextSibling;return u}function Ko(e,t,r){var n;if(t==e.display.lineDiv){if(n=e.display.lineDiv.childNodes[r],!n)return Uo(e.clipPos(E(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 jo(o,t,r)}}function jo(e,t,r){function n(t,r,n){for(var i=-1;i<(f?f.length:0);i++)for(var o=i<0?c.map:f[i],l=0;l<o.length;l+=3){var s=o[l+2];if(s==t||s==r){var a=A(i<0?e.line:e.rest[i]),u=o[l]+n;return(n<0||s!=t)&&(u=o[l+(n?1:0)]),E(a,u)}}}var i=e.text.firstChild,l=!1;if(!t||!o(i,t))return Uo(E(A(e.line),0),!0);if(t==i&&(l=!0,t=i.childNodes[r],r=0,!t)){var s=e.rest?g(e.rest):e.line;return Uo(E(A(s),s.text.length),l)}var a=3==t.nodeType?t:null,u=t;for(a||1!=t.childNodes.length||3!=t.firstChild.nodeType||(a=t.firstChild,r&&(r=a.nodeValue.length));u.parentNode!=i;)u=u.parentNode;var c=e.measure,f=c.maps,h=n(a,u,r);if(h)return Uo(h,l);for(var d=u.nextSibling,p=a?a.nodeValue.length-r:0;d;d=d.nextSibling){if(h=n(d,d.firstChild,0))return Uo(E(h.line,h.ch-p),l);p+=d.textContent.length}for(var v=u.previousSibling,m=r;v;v=v.previousSibling){if(h=n(v,v.firstChild,-1))return Uo(E(h.line,h.ch+m),l);m+=v.textContent.length}}function Xo(e,t){function r(){e.value=u.getValue()}if(t=t?c(t):{},t.value=e.value,!t.tabindex&&e.tabIndex&&(t.tabindex=e.tabIndex),!t.placeholder&&e.placeholder&&(t.placeholder=e.placeholder),null==t.autofocus){var n=l();t.autofocus=n==e||null!=e.getAttribute("autofocus")&&n==document.body}var i;if(e.form&&(Il(e.form,"submit",r),!t.leaveSubmitMethodAlone)){var o=e.form;i=o.submit;try{var s=o.submit=function(){r(),o.submit=i,o.submit(),o.submit=s}}catch(a){}}t.finishInit=function(t){t.save=r,t.getTextArea=function(){return e},t.toTextArea=function(){t.toTextArea=isNaN,r(),e.parentNode.removeChild(t.getWrapperElement()),e.style.display="",e.form&&(Oe(e.form,"submit",r),"function"==typeof e.form.submit&&(e.form.submit=i))}},e.style.display="none";var u=Mo(function(t){return e.parentNode.insertBefore(t,e.nextSibling)},t);return u}function Yo(e){e.off=Oe,e.on=Il,e.wheelEventPixels=Ur,e.Doc=vs,e.splitLines=Rl,e.countColumn=f,e.findColumn=d,e.isWordChar=w,e.Pass=Tl,e.signal=We,e.Line=Yl,e.changeEnd=Hn,e.scrollbarModel=is,e.Pos=E,e.cmpPos=F,e.modes=Vl,e.mimeModes=Kl,e.resolveMode=Xe,e.getMode=Ye,e.modeExtensions=jl,e.extendMode=_e,e.copyState=$e,e.startState=Ze,e.innerMode=qe,e.commands=ks,e.keyMap=Ss,e.keyName=Qi,e.isModifierKey=Zi,e.lookupKey=qi,e.normalizeKeyMap=$i,e.StringStream=Xl,e.SharedTextMarker=ps,e.TextMarker=ds,e.LineWidget=fs,e.e_preventDefault=Ee,e.e_stopPropagation=Fe,e.e_stop=ze,e.addClass=s,e.contains=o,e.rmClass=bl,e.keyNames=bs}var _o=navigator.userAgent,$o=navigator.platform,qo=/gecko\/\d/i.test(_o),Zo=/MSIE \d/.test(_o),Qo=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(_o),Jo=/Edge\/(\d+)/.exec(_o),el=Zo||Qo||Jo,tl=el&&(Zo?document.documentMode||6:+(Jo||Qo)[1]),rl=!Jo&&/WebKit\//.test(_o),nl=rl&&/Qt\/\d+\.\d+/.test(_o),il=!Jo&&/Chrome\//.test(_o),ol=/Opera\//.test(_o),ll=/Apple Computer/.test(navigator.vendor),sl=/Mac OS X 1\d\D([8-9]|\d\d)\D/.test(_o),al=/PhantomJS/.test(_o),ul=!Jo&&/AppleWebKit/.test(_o)&&/Mobile\/\w+/.test(_o),cl=/Android/.test(_o),fl=ul||cl||/webOS|BlackBerry|Opera Mini|Opera Mobi|IEMobile/i.test(_o),hl=ul||/Mac/.test($o),dl=/\bCrOS\b/.test(_o),pl=/win/i.test($o),gl=ol&&_o.match(/Version\/(\d*\.\d*)/);gl&&(gl=Number(gl[1])),gl&&gl>=15&&(ol=!1,rl=!0);var vl,ml=hl&&(nl||ol&&(null==gl||gl<12.11)),yl=qo||el&&tl>=9,bl=function(t,r){var n=t.className,i=e(r).exec(n);if(i){var o=n.slice(i.index+i[0].length);t.className=n.slice(0,i.index)+(o?i[1]+o:"")}};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 wl=function(e){e.select()};ul?wl=function(e){e.selectionStart=0,e.selectionEnd=e.value.length}:el&&(wl=function(e){try{e.select()}catch(t){}});var xl=function(){this.id=null};xl.prototype.set=function(e,t){clearTimeout(this.id),this.id=setTimeout(t,e)};var Cl,Sl,Ll=30,Tl={toString:function(){return"CodeMirror.Pass"}},kl={scroll:!1},Ml={origin:"*mouse"},Nl={origin:"+move"},Ol=[""],Wl=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/,Al=/[\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]/,Dl=!1,Hl=!1,Pl=null,El=function(){function e(e){return e<=247?r.charAt(e):1424<=e&&e<=1524?"R":1536<=e&&e<=1785?n.charAt(e-1536):1774<=e&&e<=2220?"r":8192<=e&&e<=8203?"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="nnnnnnNNr%%r,rNNmmmmmmmmmmmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmmmmmmmmmmmmmmmnnnnnnnnnn%nnrrrmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmnNmmmmmmrrmmNmmmmrr1111111111",i=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/,o=/[stwN]/,l=/[LRr]/,s=/[Lb1n]/,a=/[1n]/;return function(r,n){var u="ltr"==n?"L":"R";if(0==r.length||"ltr"==n&&!i.test(r))return!1;for(var c=r.length,f=[],h=0;h<c;++h)f.push(e(r.charCodeAt(h)));for(var d=0,p=u;d<c;++d){var v=f[d];"m"==v?f[d]=p:p=v}for(var m=0,y=u;m<c;++m){var b=f[m];"1"==b&&"r"==y?f[m]="n":l.test(b)&&(y=b,"r"==b&&(f[m]="R"))}for(var w=1,x=f[0];w<c-1;++w){var C=f[w];"+"==C&&"1"==x&&"1"==f[w+1]?f[w]="1":","!=C||x!=f[w+1]||"1"!=x&&"n"!=x||(f[w]=x),x=C}for(var S=0;S<c;++S){var L=f[S];if(","==L)f[S]="N";else if("%"==L){var T=void 0;for(T=S+1;T<c&&"%"==f[T];++T);for(var k=S&&"!"==f[S-1]||T<c&&"1"==f[T]?"1":"N",M=S;M<T;++M)f[M]=k;S=T-1}}for(var N=0,O=u;N<c;++N){var W=f[N];"L"==O&&"1"==W?f[N]="L":l.test(W)&&(O=W)}for(var A=0;A<c;++A)if(o.test(f[A])){var D=void 0;for(D=A+1;D<c&&o.test(f[D]);++D);for(var H="L"==(A?f[A-1]:u),P="L"==(D<c?f[D]:u),E=H==P?H?"L":"R":u,F=A;F<D;++F)f[F]=E;A=D-1}for(var I,z=[],R=0;R<c;)if(s.test(f[R])){var B=R;for(++R;R<c&&s.test(f[R]);++R);z.push(new t(0,B,R))}else{var G=R,U=z.length;for(++R;R<c&&"L"!=f[R];++R);for(var V=G;V<R;)if(a.test(f[V])){G<V&&z.splice(U,0,new t(1,G,V));var K=V;for(++V;V<R&&a.test(f[V]);++V);z.splice(U,0,new t(2,K,V)),G=V}else++V;G<R&&z.splice(U,0,new t(1,G,R))}return 1==z[0].level&&(I=r.match(/^\s+/))&&(z[0].from=I[0].length,z.unshift(new t(0,0,I[0].length))),1==g(z).level&&(I=r.match(/\s+$/))&&(g(z).to-=I[0].length,z.push(new t(0,c-I[0].length,c))),"rtl"==n?z.reverse():z}}(),Fl=[],Il=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={});n[t]=(n[t]||Fl).concat(r)}},zl=function(){if(el&&tl<9)return!1;var e=n("div");return"draggable"in e||"dragDrop"in e}(),Rl=3!="\n\nb".split(/\n/).length?function(e){for(var t=0,r=[],n=e.length;t<=n;){var i=e.indexOf("\n",t);i==-1&&(i=e.length);var o=e.slice(t,"\r"==e.charAt(i-1)?i-1:i),l=o.indexOf("\r");l!=-1?(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/)},Bl=window.getSelection?function(e){try{return e.selectionStart!=e.selectionEnd}catch(t){return!1}}:function(e){var t;try{t=e.ownerDocument.selection.createRange()}catch(r){}return!(!t||t.parentElement()!=e)&&0!=t.compareEndPoints("StartToEnd",t)},Gl=function(){var e=n("div");return"oncopy"in e||(e.setAttribute("oncopy","return;"),"function"==typeof e.oncopy)}(),Ul=null,Vl={},Kl={},jl={},Xl=function(e,t){this.pos=this.start=0,this.string=e,this.tabSize=t||8,this.lastColumnPos=this.lastColumnValue=0,this.lineStart=0};Xl.prototype.eol=function(){return this.pos>=this.string.length},Xl.prototype.sol=function(){return this.pos==this.lineStart},Xl.prototype.peek=function(){return this.string.charAt(this.pos)||void 0},Xl.prototype.next=function(){if(this.pos<this.string.length)return this.string.charAt(this.pos++)},Xl.prototype.eat=function(e){var t,r=this.string.charAt(this.pos);if(t="string"==typeof e?r==e:r&&(e.test?e.test(r):e(r)))return++this.pos,r},Xl.prototype.eatWhile=function(e){for(var t=this.pos;this.eat(e););return this.pos>t},Xl.prototype.eatSpace=function(){for(var e=this,t=this.pos;/[\s\u00a0]/.test(this.string.charAt(this.pos));)++e.pos;return this.pos>t},Xl.prototype.skipToEnd=function(){this.pos=this.string.length},Xl.prototype.skipTo=function(e){var t=this.string.indexOf(e,this.pos);if(t>-1)return this.pos=t,!0},Xl.prototype.backUp=function(e){this.pos-=e},Xl.prototype.column=function(){return this.lastColumnPos<this.start&&(this.lastColumnValue=f(this.string,this.start,this.tabSize,this.lastColumnPos,this.lastColumnValue),this.lastColumnPos=this.start),this.lastColumnValue-(this.lineStart?f(this.string,this.lineStart,this.tabSize):0)},Xl.prototype.indentation=function(){return f(this.string,null,this.tabSize)-(this.lineStart?f(this.string,this.lineStart,this.tabSize):0)},Xl.prototype.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);if(i(o)==i(e))return t!==!1&&(this.pos+=e.length),!0},Xl.prototype.current=function(){return this.string.slice(this.start,this.pos)},Xl.prototype.hideFirstChars=function(e,t){this.lineStart+=e;try{return t()}finally{this.lineStart-=e}};var Yl=function(e,t,r){this.text=e,ne(this,t),this.height=r?r(this):1};Yl.prototype.lineNo=function(){return A(this)},Pe(Yl);var _l,$l={},ql={},Zl=null,Ql=null,Jl={left:0,right:0,top:0,bottom:0},es=0,ts=null;el?ts=-.53:qo?ts=15:il?ts=-.7:ll&&(ts=-1/3);var rs=function(e,t,r){this.cm=r;var i=this.vert=n("div",[n("div",null,null,"min-width: 1px")],"CodeMirror-vscrollbar"),o=this.horiz=n("div",[n("div",null,null,"height: 100%; min-height: 1px")],"CodeMirror-hscrollbar");e(i),e(o),Il(i,"scroll",function(){i.clientHeight&&t(i.scrollTop,"vertical")}),Il(o,"scroll",function(){o.clientWidth&&t(o.scrollLeft,"horizontal")}),this.checkedZeroWidth=!1,el&&tl<8&&(this.horiz.style.minHeight=this.vert.style.minWidth="18px")};rs.prototype.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=Math.max(0,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}},rs.prototype.setScrollLeft=function(e){this.horiz.scrollLeft!=e&&(this.horiz.scrollLeft=e),this.disableHoriz&&this.enableZeroWidthBar(this.horiz,this.disableHoriz,"horiz")},rs.prototype.setScrollTop=function(e){this.vert.scrollTop!=e&&(this.vert.scrollTop=e),this.disableVert&&this.enableZeroWidthBar(this.vert,this.disableVert,"vert")},rs.prototype.zeroWidthHack=function(){var e=hl&&!sl?"12px":"18px";this.horiz.style.height=this.vert.style.width=e,this.horiz.style.pointerEvents=this.vert.style.pointerEvents="none",this.disableHoriz=new xl,this.disableVert=new xl},rs.prototype.enableZeroWidthBar=function(e,t,r){function n(){var i=e.getBoundingClientRect(),o="vert"==r?document.elementFromPoint(i.right-1,(i.top+i.bottom)/2):document.elementFromPoint((i.right+i.left)/2,i.bottom-1);o!=e?e.style.pointerEvents="none":t.set(1e3,n)}e.style.pointerEvents="auto",t.set(1e3,n)},rs.prototype.clear=function(){var e=this.horiz.parentNode;e.removeChild(this.horiz),e.removeChild(this.vert)};var ns=function(){};ns.prototype.update=function(){return{bottom:0,right:0}},ns.prototype.setScrollLeft=function(){},ns.prototype.setScrollTop=function(){},ns.prototype.clear=function(){};var is={"native":rs,"null":ns},os=0,ls=function(e,t,r){var n=e.display;this.viewport=t,this.visible=zr(n,e.doc,t),this.editorIsHidden=!n.wrapper.offsetWidth,this.wrapperHeight=n.wrapper.clientHeight,this.wrapperWidth=n.wrapper.clientWidth,this.oldDisplayWidth=Vt(e),this.force=r,this.dims=br(e),this.events=[]};ls.prototype.signal=function(e,t){He(e,t)&&this.events.push(arguments)},ls.prototype.finish=function(){for(var e=this,t=0;t<this.events.length;t++)We.apply(null,e.events[t])};var ss=function(e,t){this.ranges=e,this.primIndex=t};ss.prototype.primary=function(){return this.ranges[this.primIndex]},ss.prototype.equals=function(e){var t=this;if(e==this)return!0;if(e.primIndex!=this.primIndex||e.ranges.length!=this.ranges.length)return!1;for(var r=0;r<this.ranges.length;r++){var n=t.ranges[r],i=e.ranges[r];if(!I(n.anchor,i.anchor)||!I(n.head,i.head))return!1}return!0},ss.prototype.deepCopy=function(){for(var e=this,t=[],r=0;r<this.ranges.length;r++)t[r]=new as(z(e.ranges[r].anchor),z(e.ranges[r].head));return new ss(t,this.primIndex)},ss.prototype.somethingSelected=function(){for(var e=this,t=0;t<this.ranges.length;t++)if(!e.ranges[t].empty())return!0;return!1},ss.prototype.contains=function(e,t){var r=this;t||(t=e);for(var n=0;n<this.ranges.length;n++){var i=r.ranges[n];if(F(t,i.from())>=0&&F(e,i.to())<=0)return n}return-1};var as=function(e,t){this.anchor=e,this.head=t};as.prototype.from=function(){return B(this.anchor,this.head)},as.prototype.to=function(){return R(this.anchor,this.head)},as.prototype.empty=function(){return this.head.line==this.anchor.line&&this.head.ch==this.anchor.ch};var us=function(e){var t=this;this.lines=e,this.parent=null;for(var r=0,n=0;n<e.length;++n)e[n].parent=t,r+=e[n].height;this.height=r};us.prototype.chunkSize=function(){return this.lines.length},us.prototype.removeInner=function(e,t){for(var r=this,n=e,i=e+t;n<i;++n){var o=r.lines[n];r.height-=o.height,ut(o),St(o,"delete")}this.lines.splice(e,t)},us.prototype.collapse=function(e){e.push.apply(e,this.lines)},us.prototype.insertInner=function(e,t,r){var n=this;this.height+=r,this.lines=this.lines.slice(0,e).concat(t).concat(this.lines.slice(e));for(var i=0;i<t.length;++i)t[i].parent=n},us.prototype.iterN=function(e,t,r){for(var n=this,i=e+t;e<i;++e)if(r(n.lines[e]))return!0};var cs=function(e){var t=this;this.children=e;for(var r=0,n=0,i=0;i<e.length;++i){var o=e[i];r+=o.chunkSize(),n+=o.height,o.parent=t}this.size=r,this.height=n,this.parent=null};cs.prototype.chunkSize=function(){return this.size},cs.prototype.removeInner=function(e,t){var r=this;this.size-=t;for(var n=0;n<this.children.length;++n){var i=r.children[n],o=i.chunkSize();if(e<o){var l=Math.min(t,o-e),s=i.height;if(i.removeInner(e,l),r.height-=s-i.height,o==l&&(r.children.splice(n--,1),i.parent=null),0==(t-=l))break;e=0}else e-=o}if(this.size-t<25&&(this.children.length>1||!(this.children[0]instanceof us))){var a=[];this.collapse(a),this.children=[new us(a)],this.children[0].parent=this}},cs.prototype.collapse=function(e){for(var t=this,r=0;r<this.children.length;++r)t.children[r].collapse(e)},cs.prototype.insertInner=function(e,t,r){var n=this;this.size+=t.length,this.height+=r;for(var i=0;i<this.children.length;++i){var o=n.children[i],l=o.chunkSize();if(e<=l){if(o.insertInner(e,t,r),o.lines&&o.lines.length>50){for(var s=o.lines.length%25+25,a=s;a<o.lines.length;){var u=new us(o.lines.slice(a,a+=25));
|
5 |
+
o.height-=u.height,n.children.splice(++i,0,u),u.parent=n}o.lines=o.lines.slice(0,s),n.maybeSpill()}break}e-=l}},cs.prototype.maybeSpill=function(){if(!(this.children.length<=10)){var e=this;do{var t=e.children.splice(e.children.length-5,5),r=new cs(t);if(e.parent){e.size-=r.size,e.height-=r.height;var n=h(e.parent.children,e);e.parent.children.splice(n+1,0,r)}else{var i=new cs(e.children);i.parent=e,e.children=[i,r],e=i}r.parent=e.parent}while(e.children.length>10);e.parent.maybeSpill()}},cs.prototype.iterN=function(e,t,r){for(var n=this,i=0;i<this.children.length;++i){var o=n.children[i],l=o.chunkSize();if(e<l){var s=Math.min(t,l-e);if(o.iterN(e,s,r))return!0;if(0==(t-=s))break;e=0}else e-=l}};var fs=function(e,t,r){var n=this;if(r)for(var i in r)r.hasOwnProperty(i)&&(n[i]=r[i]);this.doc=e,this.node=t};fs.prototype.clear=function(){var e=this,t=this.doc.cm,r=this.line.widgets,n=this.line,i=A(n);if(null!=i&&r){for(var o=0;o<r.length;++o)r[o]==e&&r.splice(o--,1);r.length||(n.widgets=null);var l=It(this);W(n,Math.max(0,n.height-l)),t&&(cn(t,function(){Hi(t,n,-l),gn(t,i,"widget")}),St(t,"lineWidgetCleared",t,this,i))}},fs.prototype.changed=function(){var e=this,t=this.height,r=this.doc.cm,n=this.line;this.height=null;var i=It(this)-t;i&&(W(n,n.height+i),r&&cn(r,function(){r.curOp.forceUpdate=!0,Hi(r,n,i),St(r,"lineWidgetChanged",r,e,A(n))}))},Pe(fs);var hs=0,ds=function(e,t){this.lines=[],this.type=t,this.doc=e,this.id=++hs};ds.prototype.clear=function(){var e=this;if(!this.explicitlyCleared){var t=this.doc.cm,r=t&&!t.curOp;if(r&&tn(t),He(this,"clear")){var n=this.find();n&&St(this,"clear",n.from,n.to)}for(var i=null,o=null,l=0;l<this.lines.length;++l){var s=e.lines[l],a=_(s.markedSpans,e);t&&!e.collapsed?gn(t,A(s),"text"):t&&(null!=a.to&&(o=A(s)),null!=a.from&&(i=A(s))),s.markedSpans=$(s.markedSpans,a),null==a.from&&e.collapsed&&!ve(e.doc,s)&&t&&W(s,mr(t.display))}if(t&&this.collapsed&&!t.options.lineWrapping)for(var u=0;u<this.lines.length;++u){var c=fe(e.lines[u]),f=be(c);f>t.display.maxLineLength&&(t.display.maxLine=c,t.display.maxLineLength=f,t.display.maxLineChanged=!0)}null!=i&&t&&this.collapsed&&pn(t,i,o+1),this.lines.length=0,this.explicitlyCleared=!0,this.atomic&&this.doc.cantEdit&&(this.doc.cantEdit=!1,t&&gi(t.doc)),t&&St(t,"markerCleared",t,this,i,o),r&&rn(t),this.parent&&this.parent.clear()}},ds.prototype.find=function(e,t){var r=this;null==e&&"bookmark"==this.type&&(e=1);for(var n,i,o=0;o<this.lines.length;++o){var l=r.lines[o],s=_(l.markedSpans,r);if(null!=s.from&&(n=E(t?l:A(l),s.from),e==-1))return n;if(null!=s.to&&(i=E(t?l:A(l),s.to),1==e))return i}return n&&{from:n,to:i}},ds.prototype.changed=function(){var e=this,t=this.find(-1,!0),r=this,n=this.doc.cm;t&&n&&cn(n,function(){var i=t.line,o=A(t.line),l=$t(n,o);if(l&&(rr(l),n.curOp.selectionChanged=n.curOp.forceUpdate=!0),n.curOp.updateMaxLine=!0,!ve(r.doc,i)&&null!=r.height){var s=r.height;r.height=null;var a=It(r)-s;a&&W(i,i.height+a)}St(n,"markerChanged",n,e)})},ds.prototype.attachLine=function(e){if(!this.lines.length&&this.doc.cm){var t=this.doc.cm.curOp;t.maybeHiddenMarkers&&h(t.maybeHiddenMarkers,this)!=-1||(t.maybeUnhiddenMarkers||(t.maybeUnhiddenMarkers=[])).push(this)}this.lines.push(e)},ds.prototype.detachLine=function(e){if(this.lines.splice(h(this.lines,e),1),!this.lines.length&&this.doc.cm){var t=this.doc.cm.curOp;(t.maybeHiddenMarkers||(t.maybeHiddenMarkers=[])).push(this)}},Pe(ds);var ps=function(e,t){var r=this;this.markers=e,this.primary=t;for(var n=0;n<e.length;++n)e[n].parent=r};ps.prototype.clear=function(){var e=this;if(!this.explicitlyCleared){this.explicitlyCleared=!0;for(var t=0;t<this.markers.length;++t)e.markers[t].clear();St(this,"clear")}},ps.prototype.find=function(e,t){return this.primary.find(e,t)},Pe(ps);var gs=0,vs=function(e,t,r,n,i){if(!(this instanceof vs))return new vs(e,t,r,n,i);null==r&&(r=0),cs.call(this,[new us([new Yl("",null)])]),this.first=r,this.scrollTop=this.scrollLeft=0,this.cantEdit=!1,this.cleanGeneration=1,this.frontier=r;var o=E(r,0);this.sel=Dn(o),this.history=new Xn(null),this.id=++gs,this.modeOption=t,this.lineSep=n,this.direction="rtl"==i?"rtl":"ltr",this.extend=!1,"string"==typeof e&&(e=this.splitLines(e)),Gn(this,{from:o,to:o,text:e}),hi(this,Dn(o),kl)};vs.prototype=b(cs.prototype,{constructor:vs,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=O(this,this.first,this.first+this.size);return e===!1?t:t.join(e||this.lineSeparator())},setValue:dn(function(e){var t=E(this.first,0),r=this.first+this.size-1;Ci(this,{from:t,to:E(r,M(this,r).text.length),text:this.splitLines(e),origin:"setValue",full:!0},!0),this.cm&&this.cm.scrollTo(0,0),hi(this,Dn(t),kl)}),replaceRange:function(e,t,r,n){t=U(this,t),r=r?U(this,r):t,Ni(this,e,t,r,n)},getRange:function(e,t,r){var n=N(this,U(this,e),U(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){if(H(this,e))return M(this,e)},getLineNumber:function(e){return A(e)},getLineHandleVisualStart:function(e){return"number"==typeof e&&(e=M(this,e)),fe(e)},lineCount:function(){return this.size},firstLine:function(){return this.first},lastLine:function(){return this.first+this.size-1},clipPos:function(e){return U(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:dn(function(e,t,r){ui(this,U(this,"number"==typeof e?E(e,t||0):e),null,r)}),setSelection:dn(function(e,t,r){ui(this,U(this,e),U(this,t||e),r)}),extendSelection:dn(function(e,t,r){li(this,U(this,e),t&&U(this,t),r)}),extendSelections:dn(function(e,t){si(this,K(this,e),t)}),extendSelectionsBy:dn(function(e,t){var r=v(this.sel.ranges,e);si(this,K(this,r),t)}),setSelections:dn(function(e,t,r){var n=this;if(e.length){for(var i=[],o=0;o<e.length;o++)i[o]=new as(U(n,e[o].anchor),U(n,e[o].head));null==t&&(t=Math.min(e.length-1,this.sel.primIndex)),hi(this,An(i,t),r)}}),addSelection:dn(function(e,t,r){var n=this.sel.ranges.slice(0);n.push(new as(U(this,e),U(this,t||e))),hi(this,An(n,n.length-1),r)}),getSelection:function(e){for(var t,r=this,n=this.sel.ranges,i=0;i<n.length;i++){var o=N(r,n[i].from(),n[i].to());t=t?t.concat(o):o}return e===!1?t:t.join(e||this.lineSeparator())},getSelections:function(e){for(var t=this,r=[],n=this.sel.ranges,i=0;i<n.length;i++){var o=N(t,n[i].from(),n[i].to());e!==!1&&(o=o.join(e||t.lineSeparator())),r[i]=o}return r},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:dn(function(e,t,r){for(var n=this,i=[],o=this.sel,l=0;l<o.ranges.length;l++){var s=o.ranges[l];i[l]={from:s.from(),to:s.to(),text:n.splitLines(e[l]),origin:r}}for(var a=t&&"end"!=t&&In(this,i,t),u=i.length-1;u>=0;u--)Ci(n,i[u]);a?fi(this,a):this.cm&&Jr(this.cm)}),undo:dn(function(){Li(this,"undo")}),redo:dn(function(){Li(this,"redo")}),undoSelection:dn(function(){Li(this,"undo",!0)}),redoSelection:dn(function(){Li(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 i=0;i<e.undone.length;i++)e.undone[i].ranges||++r;return{undo:t,redo:r}},clearHistory:function(){this.history=new Xn(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:ii(this.history.done),undone:ii(this.history.undone)}},setHistory:function(e){var t=this.history=new Xn(this.history.maxGeneration);t.done=ii(e.done.slice(0),null,!0),t.undone=ii(e.undone.slice(0),null,!0)},setGutterMarker:dn(function(e,t,r){return Di(this,e,"gutter",function(e){var n=e.gutterMarkers||(e.gutterMarkers={});return n[t]=r,!r&&C(n)&&(e.gutterMarkers=null),!0})}),clearGutter:dn(function(e){var t=this;this.iter(function(r){r.gutterMarkers&&r.gutterMarkers[e]&&Di(t,r,"gutter",function(){return r.gutterMarkers[e]=null,C(r.gutterMarkers)&&(r.gutterMarkers=null),!0})})}),lineInfo:function(e){var t;if("number"==typeof e){if(!H(this,e))return null;if(t=e,e=M(this,e),!e)return null}else if(t=A(e),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}},addLineClass:dn(function(t,r,n){return Di(this,t,"gutter"==r?"gutter":"class",function(t){var i="text"==r?"textClass":"background"==r?"bgClass":"gutter"==r?"gutterClass":"wrapClass";if(t[i]){if(e(n).test(t[i]))return!1;t[i]+=" "+n}else t[i]=n;return!0})}),removeLineClass:dn(function(t,r,n){return Di(this,t,"gutter"==r?"gutter":"class",function(t){var i="text"==r?"textClass":"background"==r?"bgClass":"gutter"==r?"gutterClass":"wrapClass",o=t[i];if(!o)return!1;if(null==n)t[i]=null;else{var l=o.match(e(n));if(!l)return!1;var s=l.index+l[0].length;t[i]=o.slice(0,l.index)+(l.index&&s!=o.length?" ":"")+o.slice(s)||null}return!0})}),addLineWidget:dn(function(e,t,r){return Pi(this,e,t,r)}),removeLineWidget:function(e){e.clear()},markText:function(e,t,r){return Ei(this,U(this,e),U(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=U(this,e),Ei(this,e,e,r,"bookmark")},findMarksAt:function(e){e=U(this,e);var t=[],r=M(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=U(this,e),t=U(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];null!=a.to&&i==e.line&&e.ch>=a.to||null==a.from&&i!=e.line||null!=a.from&&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,n=this.lineSeparator().length;return this.iter(function(i){var o=i.text.length+n;return o>e?(t=e,!0):(e-=o,void++r)}),U(this,E(r,t))},indexFromPos:function(e){e=U(this,e);var t=e.ch;if(e.line<this.first||e.ch<0)return 0;var r=this.lineSeparator().length;return this.iter(this.first,e.line,function(e){t+=e.text.length+r}),t},copy:function(e){var t=new vs(O(this,this.first,this.first+this.size),this.modeOption,this.first,this.lineSep,this.direction);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 vs(O(this,t,r),e.mode||this.modeOption,t,this.lineSep,this.direction);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}],zi(n,Ii(this)),n},unlinkDoc:function(e){var t=this;if(e instanceof Mo&&(e=e.doc),this.linked)for(var r=0;r<this.linked.length;++r){var n=t.linked[r];if(n.doc==e){t.linked.splice(r,1),e.unlinkDoc(t),Ri(Ii(t));break}}if(e.history==this.history){var i=[e.id];Un(e,function(e){return i.push(e.id)},!0),e.history=new Xn(null),e.history.done=ii(this.history.done,i),e.history.undone=ii(this.history.undone,i)}},iterLinkedDocs:function(e){Un(this,e)},getMode:function(){return this.mode},getEditor:function(){return this.cm},splitLines:function(e){return this.lineSep?e.split(this.lineSep):Rl(e)},lineSeparator:function(){return this.lineSep||"\n"},setDirection:dn(function(e){"rtl"!=e&&(e="ltr"),e!=this.direction&&(this.direction=e,this.iter(function(e){return e.order=null}),this.cm&&jn(this.cm))})}),vs.prototype.eachLine=vs.prototype.iter;for(var ms=0,ys=!1,bs={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"},ws=0;ws<10;ws++)bs[ws+48]=bs[ws+96]=String(ws);for(var xs=65;xs<=90;xs++)bs[xs]=String.fromCharCode(xs);for(var Cs=1;Cs<=12;Cs++)bs[Cs+111]=bs[Cs+63235]="F"+Cs;var Ss={};Ss.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"},Ss.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"},Ss.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","Ctrl-O":"openLine"},Ss.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"]},Ss["default"]=hl?Ss.macDefault:Ss.pcDefault;var Ls,Ts,ks={selectAll:wi,singleSelection:function(e){return e.setSelection(e.getCursor("anchor"),e.getCursor("head"),kl)},killLine:function(e){return eo(e,function(t){if(t.empty()){var r=M(e.doc,t.head.line).text.length;return t.head.ch==r&&t.head.line<e.lastLine()?{from:t.head,to:E(t.head.line+1,0)}:{from:t.head,to:E(t.head.line,r)}}return{from:t.from(),to:t.to()}})},deleteLine:function(e){return eo(e,function(t){return{from:E(t.from().line,0),to:U(e.doc,E(t.to().line+1,0))}})},delLineLeft:function(e){return eo(e,function(e){return{from:E(e.from().line,0),to:e.from()}})},delWrappedLineLeft:function(e){return eo(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){return eo(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){return e.undo()},redo:function(e){return e.redo()},undoSelection:function(e){return e.undoSelection()},redoSelection:function(e){return e.redoSelection()},goDocStart:function(e){return e.extendSelection(E(e.firstLine(),0))},goDocEnd:function(e){return e.extendSelection(E(e.lastLine()))},goLineStart:function(e){return e.extendSelectionsBy(function(t){return to(e,t.head.line)},{origin:"+move",bias:1})},goLineStartSmart:function(e){return e.extendSelectionsBy(function(t){return no(e,t.head)},{origin:"+move",bias:1})},goLineEnd:function(e){return e.extendSelectionsBy(function(t){return ro(e,t.head.line)},{origin:"+move",bias:-1})},goLineRight:function(e){return 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")},Nl)},goLineLeft:function(e){return e.extendSelectionsBy(function(t){var r=e.charCoords(t.head,"div").top+5;return e.coordsChar({left:0,top:r},"div")},Nl)},goLineLeftSmart:function(e){return 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/)?no(e,t.head):n},Nl)},goLineUp:function(e){return e.moveV(-1,"line")},goLineDown:function(e){return e.moveV(1,"line")},goPageUp:function(e){return e.moveV(-1,"page")},goPageDown:function(e){return e.moveV(1,"page")},goCharLeft:function(e){return e.moveH(-1,"char")},goCharRight:function(e){return e.moveH(1,"char")},goColumnLeft:function(e){return e.moveH(-1,"column")},goColumnRight:function(e){return e.moveH(1,"column")},goWordLeft:function(e){return e.moveH(-1,"word")},goGroupRight:function(e){return e.moveH(1,"group")},goGroupLeft:function(e){return e.moveH(-1,"group")},goWordRight:function(e){return e.moveH(1,"word")},delCharBefore:function(e){return e.deleteH(-1,"char")},delCharAfter:function(e){return e.deleteH(1,"char")},delWordBefore:function(e){return e.deleteH(-1,"word")},delWordAfter:function(e){return e.deleteH(1,"word")},delGroupBefore:function(e){return e.deleteH(-1,"group")},delGroupAfter:function(e){return e.deleteH(1,"group")},indentAuto:function(e){return e.indentSelection("smart")},indentMore:function(e){return e.indentSelection("add")},indentLess:function(e){return e.indentSelection("subtract")},insertTab:function(e){return e.replaceSelection("\t")},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=f(e.getLine(o.line),o.ch,n);t.push(p(n-l%n))}e.replaceSelections(t)},defaultTab:function(e){e.somethingSelected()?e.indentSelection("add"):e.execCommand("insertTab")},transposeChars:function(e){return cn(e,function(){for(var t=e.listSelections(),r=[],n=0;n<t.length;n++)if(t[n].empty()){var i=t[n].head,o=M(e.doc,i.line).text;if(o)if(i.ch==o.length&&(i=new E(i.line,i.ch-1)),i.ch>0)i=new E(i.line,i.ch+1),e.replaceRange(o.charAt(i.ch-1)+o.charAt(i.ch-2),E(i.line,i.ch-2),i,"+transpose");else if(i.line>e.doc.first){var l=M(e.doc,i.line-1).text;l&&(i=new E(i.line,1),e.replaceRange(o.charAt(0)+e.doc.lineSeparator()+l.charAt(l.length-1),E(i.line-1,l.length-1),i,"+transpose"))}r.push(new as(i,i))}e.setSelections(r)})},newlineAndIndent:function(e){return cn(e,function(){for(var t=e.listSelections(),r=t.length-1;r>=0;r--)e.replaceRange(e.doc.lineSeparator(),t[r].anchor,t[r].head,"+input");t=e.listSelections();for(var n=0;n<t.length;n++)e.indentLine(t[n].from().line,null,!0);Jr(e)})},openLine:function(e){return e.replaceSelection("\n","start")},toggleOverwrite:function(e){return e.toggleOverwrite()}},Ms=new xl,Ns=null,Os={toString:function(){return"CodeMirror.Init"}},Ws={},As={};Mo.defaults=Ws,Mo.optionHandlers=As;var Ds=[];Mo.defineInitHook=function(e){return Ds.push(e)};var Hs=null,Ps=function(e){this.cm=e,this.lastAnchorNode=this.lastAnchorOffset=this.lastFocusNode=this.lastFocusOffset=null,this.polling=new xl,this.composing=null,this.gracePeriod=!1,this.readDOMTimeout=null};Ps.prototype.init=function(e){function t(e){if(!Ae(i,e)){if(i.somethingSelected())Wo({lineWise:!1,text:i.getSelections()}),"cut"==e.type&&i.replaceSelection("",null,"cut");else{if(!i.options.lineWiseCopyCut)return;var t=Po(i);Wo({lineWise:!0,text:t.text}),"cut"==e.type&&i.operation(function(){i.setSelections(t.ranges,0,kl),i.replaceSelection("",null,"cut")})}if(e.clipboardData){e.clipboardData.clearData();var r=Hs.text.join("\n");if(e.clipboardData.setData("Text",r),e.clipboardData.getData("Text")==r)return void e.preventDefault()}var l=Fo(),s=l.firstChild;i.display.lineSpace.insertBefore(l,i.display.lineSpace.firstChild),s.value=Hs.text.join("\n");var a=document.activeElement;wl(s),setTimeout(function(){i.display.lineSpace.removeChild(l),a.focus(),a==o&&n.showPrimarySelection()},50)}}var r=this,n=this,i=n.cm,o=n.div=e.lineDiv;Eo(o,i.options.spellcheck),Il(o,"paste",function(e){Ae(i,e)||Do(e,i)||tl<=11&&setTimeout(fn(i,function(){return r.updateFromDOM()}),20)}),Il(o,"compositionstart",function(e){r.composing={data:e.data,done:!1}}),Il(o,"compositionupdate",function(e){r.composing||(r.composing={data:e.data,done:!1})}),Il(o,"compositionend",function(e){r.composing&&(e.data!=r.composing.data&&r.readFromDOMSoon(),r.composing.done=!0)}),Il(o,"touchstart",function(){return n.forceCompositionEnd()}),Il(o,"input",function(){r.composing||r.readFromDOMSoon()}),Il(o,"copy",t),Il(o,"cut",t)},Ps.prototype.prepareSelection=function(){var e=kr(this.cm,!1);return e.focus=this.cm.state.focused,e},Ps.prototype.showSelection=function(e,t){e&&this.cm.display.view.length&&((e.focus||t)&&this.showPrimarySelection(),this.showMultipleSelections(e))},Ps.prototype.showPrimarySelection=function(){var e=window.getSelection(),t=this.cm,r=t.doc.sel.primary(),n=r.from(),i=r.to();if(t.display.viewTo==t.display.viewFrom||n.line>=t.display.viewTo||i.line<t.display.viewFrom)return void e.removeAllRanges();var o=Ko(t,e.anchorNode,e.anchorOffset),l=Ko(t,e.focusNode,e.focusOffset);if(!o||o.bad||!l||l.bad||0!=F(B(o,l),n)||0!=F(R(o,l),i)){var s=t.display.view,a=n.line>=t.display.viewFrom&&Bo(t,n)||{node:s[0].measure.map[2],offset:0},u=i.line<t.display.viewTo&&Bo(t,i);if(!u){var c=s[s.length-1].measure,f=c.maps?c.maps[c.maps.length-1]:c.map;u={node:f[f.length-1],offset:f[f.length-2]-f[f.length-3]}}if(!a||!u)return void e.removeAllRanges();var h,d=e.rangeCount&&e.getRangeAt(0);try{h=vl(a.node,a.offset,u.offset,u.node)}catch(p){}h&&(!qo&&t.state.focused?(e.collapse(a.node,a.offset),h.collapsed||(e.removeAllRanges(),e.addRange(h))):(e.removeAllRanges(),e.addRange(h)),d&&null==e.anchorNode?e.addRange(d):qo&&this.startGracePeriod()),this.rememberSelection()}},Ps.prototype.startGracePeriod=function(){var e=this;clearTimeout(this.gracePeriod),this.gracePeriod=setTimeout(function(){e.gracePeriod=!1,e.selectionChanged()&&e.cm.operation(function(){return e.cm.curOp.selectionChanged=!0})},20)},Ps.prototype.showMultipleSelections=function(e){r(this.cm.display.cursorDiv,e.cursors),r(this.cm.display.selectionDiv,e.selection)},Ps.prototype.rememberSelection=function(){var e=window.getSelection();this.lastAnchorNode=e.anchorNode,this.lastAnchorOffset=e.anchorOffset,this.lastFocusNode=e.focusNode,this.lastFocusOffset=e.focusOffset},Ps.prototype.selectionInEditor=function(){var e=window.getSelection();if(!e.rangeCount)return!1;var t=e.getRangeAt(0).commonAncestorContainer;return o(this.div,t)},Ps.prototype.focus=function(){"nocursor"!=this.cm.options.readOnly&&(this.selectionInEditor()||this.showSelection(this.prepareSelection(),!0),this.div.focus())},Ps.prototype.blur=function(){this.div.blur()},Ps.prototype.getField=function(){return this.div},Ps.prototype.supportsTouch=function(){return!0},Ps.prototype.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():cn(this.cm,function(){return t.cm.curOp.selectionChanged=!0}),this.polling.set(this.cm.options.pollInterval,e)},Ps.prototype.selectionChanged=function(){var e=window.getSelection();return e.anchorNode!=this.lastAnchorNode||e.anchorOffset!=this.lastAnchorOffset||e.focusNode!=this.lastFocusNode||e.focusOffset!=this.lastFocusOffset},Ps.prototype.pollSelection=function(){if(null==this.readDOMTimeout&&!this.gracePeriod&&this.selectionChanged()){var e=window.getSelection(),t=this.cm;if(cl&&il&&this.cm.options.gutters.length&&Go(e.anchorNode))return this.cm.triggerOnKeyDown({type:"keydown",keyCode:8,preventDefault:Math.abs}),this.blur(),void this.focus();if(!this.composing){this.rememberSelection();var r=Ko(t,e.anchorNode,e.anchorOffset),n=Ko(t,e.focusNode,e.focusOffset);r&&n&&cn(t,function(){hi(t.doc,Dn(r,n),kl),(r.bad||n.bad)&&(t.curOp.selectionChanged=!0)})}}},Ps.prototype.pollContent=function(){null!=this.readDOMTimeout&&(clearTimeout(this.readDOMTimeout),this.readDOMTimeout=null);var e=this.cm,t=e.display,r=e.doc.sel.primary(),n=r.from(),i=r.to();if(0==n.ch&&n.line>e.firstLine()&&(n=E(n.line-1,M(e.doc,n.line-1).length)),i.ch==M(e.doc,i.line).text.length&&i.line<e.lastLine()&&(i=E(i.line+1,0)),n.line<t.viewFrom||i.line>t.viewTo-1)return!1;var o,l,s;n.line==t.viewFrom||0==(o=Lr(e,n.line))?(l=A(t.view[0].line),s=t.view[0].node):(l=A(t.view[o].line),s=t.view[o-1].node.nextSibling);var a,u,c=Lr(e,i.line);if(c==t.view.length-1?(a=t.viewTo-1,u=t.lineDiv.lastChild):(a=A(t.view[c+1].line)-1,u=t.view[c+1].node.previousSibling),!s)return!1;for(var f=e.doc.splitLines(Vo(e,s,u,l,a)),h=N(e.doc,E(l,0),E(a,M(e.doc,a).text.length));f.length>1&&h.length>1;)if(g(f)==g(h))f.pop(),h.pop(),a--;else{if(f[0]!=h[0])break;f.shift(),h.shift(),l++}for(var d=0,p=0,v=f[0],m=h[0],y=Math.min(v.length,m.length);d<y&&v.charCodeAt(d)==m.charCodeAt(d);)++d;for(var b=g(f),w=g(h),x=Math.min(b.length-(1==f.length?d:0),w.length-(1==h.length?d:0));p<x&&b.charCodeAt(b.length-p-1)==w.charCodeAt(w.length-p-1);)++p;if(1==f.length&&1==h.length&&l==n.line)for(;d&&d>n.ch&&b.charCodeAt(b.length-p-1)==w.charCodeAt(w.length-p-1);)d--,p++;f[f.length-1]=b.slice(0,b.length-p).replace(/^\u200b+/,""),f[0]=f[0].slice(d).replace(/\u200b+$/,"");var C=E(l,d),S=E(a,h.length?g(h).length-p:0);return f.length>1||f[0]||F(C,S)?(Ni(e.doc,f,C,S,"+input"),!0):void 0},Ps.prototype.ensurePolled=function(){this.forceCompositionEnd()},Ps.prototype.reset=function(){this.forceCompositionEnd()},Ps.prototype.forceCompositionEnd=function(){this.composing&&(clearTimeout(this.readDOMTimeout),this.composing=null,this.updateFromDOM(),this.div.blur(),this.div.focus())},Ps.prototype.readFromDOMSoon=function(){var e=this;null==this.readDOMTimeout&&(this.readDOMTimeout=setTimeout(function(){if(e.readDOMTimeout=null,e.composing){if(!e.composing.done)return;e.composing=null}e.updateFromDOM()},80))},Ps.prototype.updateFromDOM=function(){var e=this;!this.cm.isReadOnly()&&this.pollContent()||cn(this.cm,function(){return pn(e.cm)})},Ps.prototype.setUneditable=function(e){e.contentEditable="false"},Ps.prototype.onKeyPress=function(e){0!=e.charCode&&(e.preventDefault(),this.cm.isReadOnly()||fn(this.cm,Ao)(this.cm,String.fromCharCode(null==e.charCode?e.keyCode:e.charCode),0))},Ps.prototype.readOnlyChanged=function(e){this.div.contentEditable=String("nocursor"!=e)},Ps.prototype.onContextMenu=function(){},Ps.prototype.resetPosition=function(){},Ps.prototype.needsContentAttribute=!0;var Es=function(e){this.cm=e,this.prevInput="",this.pollingFast=!1,this.polling=new xl,this.inaccurateSelection=!1,this.hasSelection=!1,this.composing=null};Es.prototype.init=function(e){function t(e){if(!Ae(i,e)){if(i.somethingSelected())Wo({lineWise:!1,text:i.getSelections()}),n.inaccurateSelection&&(n.prevInput="",n.inaccurateSelection=!1,l.value=Hs.text.join("\n"),wl(l));else{if(!i.options.lineWiseCopyCut)return;var t=Po(i);Wo({lineWise:!0,text:t.text}),"cut"==e.type?i.setSelections(t.ranges,null,kl):(n.prevInput="",l.value=t.text.join("\n"),wl(l))}"cut"==e.type&&(i.state.cutIncoming=!0)}}var r=this,n=this,i=this.cm,o=this.wrapper=Fo(),l=this.textarea=o.firstChild;e.wrapper.insertBefore(o,e.wrapper.firstChild),ul&&(l.style.width="0px"),Il(l,"input",function(){el&&tl>=9&&r.hasSelection&&(r.hasSelection=null),n.poll()}),Il(l,"paste",function(e){Ae(i,e)||Do(e,i)||(i.state.pasteIncoming=!0,n.fastPoll())}),Il(l,"cut",t),Il(l,"copy",t),Il(e.scroller,"paste",function(t){zt(e,t)||Ae(i,t)||(i.state.pasteIncoming=!0,n.focus())}),Il(e.lineSpace,"selectstart",function(t){zt(e,t)||Ee(t)}),Il(l,"compositionstart",function(){var e=i.getCursor("from");n.composing&&n.composing.range.clear(),n.composing={start:e,range:i.markText(e,i.getCursor("to"),{className:"CodeMirror-composing"})}}),Il(l,"compositionend",function(){n.composing&&(n.poll(),n.composing.range.clear(),n.composing=null)})},Es.prototype.prepareSelection=function(){var e=this.cm,t=e.display,r=e.doc,n=kr(e);if(e.options.moveInputWithCursor){var i=cr(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},Es.prototype.showSelection=function(e){var t=this.cm,n=t.display;r(n.cursorDiv,e.cursors),r(n.selectionDiv,e.selection),null!=e.teTop&&(this.wrapper.style.top=e.teTop+"px",this.wrapper.style.left=e.teLeft+"px")},Es.prototype.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=Gl&&(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&&wl(this.textarea),el&&tl>=9&&(this.hasSelection=l)}else e||(this.prevInput=this.textarea.value="",el&&tl>=9&&(this.hasSelection=null));this.inaccurateSelection=t}},Es.prototype.getField=function(){return this.textarea},Es.prototype.supportsTouch=function(){return!1},Es.prototype.focus=function(){if("nocursor"!=this.cm.options.readOnly&&(!fl||l()!=this.textarea))try{this.textarea.focus()}catch(e){}},Es.prototype.blur=function(){this.textarea.blur()},Es.prototype.resetPosition=function(){this.wrapper.style.top=this.wrapper.style.left=0},Es.prototype.receivedFocus=function(){this.slowPoll()},Es.prototype.slowPoll=function(){var e=this;this.pollingFast||this.polling.set(this.cm.options.pollInterval,function(){e.poll(),e.cm.state.focused&&e.slowPoll()})},Es.prototype.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)},Es.prototype.poll=function(){var e=this,t=this.cm,r=this.textarea,n=this.prevInput;if(this.contextMenuPending||!t.state.focused||Bl(r)&&!n&&!this.composing||t.isReadOnly()||t.options.disableInput||t.state.keySeq)return!1;var i=r.value;if(i==n&&!t.somethingSelected())return!1;if(el&&tl>=9&&this.hasSelection===i||hl&&/[\uf700-\uf7ff]/.test(i))return t.display.input.reset(),!1;if(t.doc.sel==t.display.selForContextMenu){var o=i.charCodeAt(0);if(8203!=o||n||(n=""),8666==o)return this.reset(),this.cm.execCommand("undo")}for(var l=0,s=Math.min(n.length,i.length);l<s&&n.charCodeAt(l)==i.charCodeAt(l);)++l;return cn(t,function(){Ao(t,i.slice(l),n.length-l,null,e.composing?"*compose":null),i.length>1e3||i.indexOf("\n")>-1?r.value=e.prevInput="":e.prevInput=i,e.composing&&(e.composing.range.clear(),e.composing.range=t.markText(e.composing.start,t.getCursor("to"),{className:"CodeMirror-composing"}))}),!0},Es.prototype.ensurePolled=function(){this.pollingFast&&this.poll()&&(this.pollingFast=!1);
|
6 |
+
},Es.prototype.onKeyPress=function(){el&&tl>=9&&(this.hasSelection=null),this.fastPoll()},Es.prototype.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.cssText=f,l.style.cssText=c,el&&tl<9&&o.scrollbars.setScrollTop(o.scroller.scrollTop=a),null!=l.selectionStart){(!el||el&&tl<9)&&t();var e=0,r=function(){o.selForContextMenu==i.doc.sel&&0==l.selectionStart&&l.selectionEnd>0&&""==n.prevInput?fn(i,wi)(i):e++<10?o.detectingSelectAll=setTimeout(r,500):(o.selForContextMenu=null,o.input.reset())};o.detectingSelectAll=setTimeout(r,200)}}var n=this,i=n.cm,o=i.display,l=n.textarea,s=Sr(i,e),a=o.scroller.scrollTop;if(s&&!ol){var u=i.options.resetSelectionOnContextMenu;u&&i.doc.sel.contains(s)==-1&&fn(i,hi)(i.doc,Dn(s),kl);var c=l.style.cssText,f=n.wrapper.style.cssText;n.wrapper.style.cssText="position: absolute";var h=n.wrapper.getBoundingClientRect();l.style.cssText="position: absolute; width: 30px; height: 30px;\n top: "+(e.clientY-h.top-5)+"px; left: "+(e.clientX-h.left-5)+"px;\n z-index: 1000; background: "+(el?"rgba(255, 255, 255, .05)":"transparent")+";\n outline: none; border-width: 0; outline: none; overflow: hidden; opacity: .05; filter: alpha(opacity=5);";var d;if(rl&&(d=window.scrollY),o.input.focus(),rl&&window.scrollTo(null,d),o.input.reset(),i.somethingSelected()||(l.value=n.prevInput=" "),n.contextMenuPending=!0,o.selForContextMenu=i.doc.sel,clearTimeout(o.detectingSelectAll),el&&tl>=9&&t(),yl){ze(e);var p=function(){Oe(window,"mouseup",p),setTimeout(r,20)};Il(window,"mouseup",p)}else setTimeout(r,50)}},Es.prototype.readOnlyChanged=function(e){e||this.reset()},Es.prototype.setUneditable=function(){},Es.prototype.needsContentAttribute=!1,So(Mo),Io(Mo);var Fs="iter insert remove copy getEditor constructor".split(" ");for(var Is in vs.prototype)vs.prototype.hasOwnProperty(Is)&&h(Fs,Is)<0&&(Mo.prototype[Is]=function(e){return function(){return e.apply(this.doc,arguments)}}(vs.prototype[Is]));return Pe(vs),Mo.inputStyles={textarea:Es,contenteditable:Ps},Mo.defineMode=function(e){Mo.defaults.mode||"null"==e||(Mo.defaults.mode=e),Ke.apply(this,arguments)},Mo.defineMIME=je,Mo.defineMode("null",function(){return{token:function(e){return e.skipToEnd()}}}),Mo.defineMIME("text/plain","null"),Mo.defineExtension=function(e,t){Mo.prototype[e]=t},Mo.defineDocExtension=function(e,t){vs.prototype[e]=t},Mo.fromTextArea=Xo,Yo(Mo),Mo.version="5.25.2",Mo});
|
lib/codemirror/mode/css/css.js
CHANGED
@@ -28,6 +28,7 @@ CodeMirror.defineMode("css", function(config, parserConfig) {
|
|
28 |
colorKeywords = parserConfig.colorKeywords || {},
|
29 |
valueKeywords = parserConfig.valueKeywords || {},
|
30 |
allowNested = parserConfig.allowNested,
|
|
|
31 |
supportsAtComponent = parserConfig.supportsAtComponent === true;
|
32 |
|
33 |
var type, override;
|
@@ -253,6 +254,8 @@ CodeMirror.defineMode("css", function(config, parserConfig) {
|
|
253 |
};
|
254 |
|
255 |
states.pseudo = function(type, stream, state) {
|
|
|
|
|
256 |
if (type == "word") {
|
257 |
override = "variable-3";
|
258 |
return state.context.type;
|
@@ -407,6 +410,7 @@ CodeMirror.defineMode("css", function(config, parserConfig) {
|
|
407 |
electricChars: "}",
|
408 |
blockCommentStart: "/*",
|
409 |
blockCommentEnd: "*/",
|
|
|
410 |
fold: "brace"
|
411 |
};
|
412 |
});
|
@@ -663,7 +667,7 @@ CodeMirror.defineMode("css", function(config, parserConfig) {
|
|
663 |
"small", "small-caps", "small-caption", "smaller", "soft-light", "solid", "somali",
|
664 |
"source-atop", "source-in", "source-out", "source-over", "space", "space-around", "space-between", "spell-out", "square",
|
665 |
"square-button", "start", "static", "status-bar", "stretch", "stroke", "sub",
|
666 |
-
"subpixel-antialiased", "super", "sw-resize", "symbolic", "symbols", "table",
|
667 |
"table-caption", "table-cell", "table-column", "table-column-group",
|
668 |
"table-footer-group", "table-header-group", "table-row", "table-row-group",
|
669 |
"tamil",
|
@@ -730,6 +734,7 @@ CodeMirror.defineMode("css", function(config, parserConfig) {
|
|
730 |
valueKeywords: valueKeywords,
|
731 |
fontProperties: fontProperties,
|
732 |
allowNested: true,
|
|
|
733 |
tokenHooks: {
|
734 |
"/": function(stream, state) {
|
735 |
if (stream.eat("/")) {
|
@@ -743,8 +748,8 @@ CodeMirror.defineMode("css", function(config, parserConfig) {
|
|
743 |
}
|
744 |
},
|
745 |
":": function(stream) {
|
746 |
-
if (stream.match(/\s*\{
|
747 |
-
return [null,
|
748 |
return false;
|
749 |
},
|
750 |
"$": function(stream) {
|
@@ -772,6 +777,7 @@ CodeMirror.defineMode("css", function(config, parserConfig) {
|
|
772 |
valueKeywords: valueKeywords,
|
773 |
fontProperties: fontProperties,
|
774 |
allowNested: true,
|
|
|
775 |
tokenHooks: {
|
776 |
"/": function(stream, state) {
|
777 |
if (stream.eat("/")) {
|
28 |
colorKeywords = parserConfig.colorKeywords || {},
|
29 |
valueKeywords = parserConfig.valueKeywords || {},
|
30 |
allowNested = parserConfig.allowNested,
|
31 |
+
lineComment = parserConfig.lineComment,
|
32 |
supportsAtComponent = parserConfig.supportsAtComponent === true;
|
33 |
|
34 |
var type, override;
|
254 |
};
|
255 |
|
256 |
states.pseudo = function(type, stream, state) {
|
257 |
+
if (type == "meta") return "pseudo";
|
258 |
+
|
259 |
if (type == "word") {
|
260 |
override = "variable-3";
|
261 |
return state.context.type;
|
410 |
electricChars: "}",
|
411 |
blockCommentStart: "/*",
|
412 |
blockCommentEnd: "*/",
|
413 |
+
lineComment: lineComment,
|
414 |
fold: "brace"
|
415 |
};
|
416 |
});
|
667 |
"small", "small-caps", "small-caption", "smaller", "soft-light", "solid", "somali",
|
668 |
"source-atop", "source-in", "source-out", "source-over", "space", "space-around", "space-between", "spell-out", "square",
|
669 |
"square-button", "start", "static", "status-bar", "stretch", "stroke", "sub",
|
670 |
+
"subpixel-antialiased", "super", "sw-resize", "symbolic", "symbols", "system-ui", "table",
|
671 |
"table-caption", "table-cell", "table-column", "table-column-group",
|
672 |
"table-footer-group", "table-header-group", "table-row", "table-row-group",
|
673 |
"tamil",
|
734 |
valueKeywords: valueKeywords,
|
735 |
fontProperties: fontProperties,
|
736 |
allowNested: true,
|
737 |
+
lineComment: "//",
|
738 |
tokenHooks: {
|
739 |
"/": function(stream, state) {
|
740 |
if (stream.eat("/")) {
|
748 |
}
|
749 |
},
|
750 |
":": function(stream) {
|
751 |
+
if (stream.match(/\s*\{/, false))
|
752 |
+
return [null, null]
|
753 |
return false;
|
754 |
},
|
755 |
"$": function(stream) {
|
777 |
valueKeywords: valueKeywords,
|
778 |
fontProperties: fontProperties,
|
779 |
allowNested: true,
|
780 |
+
lineComment: "//",
|
781 |
tokenHooks: {
|
782 |
"/": function(stream, state) {
|
783 |
if (stream.eat("/")) {
|
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].toLowerCase()]=!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:b),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();g=K.hasOwnProperty(t)?"atom":j.hasOwnProperty(t)?"keyword":"variable"}var m=r.inline;r.propertyKeywords||(r=e.resolveMode("text/css"));var h,g,b=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)g="builtin";else if("word"==e)g="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)?(g="property","maybeprop"):z.hasOwnProperty(o)?(g="string-2","maybeprop"):B?(g=t.match(/^\s*:(?:\s|$)/,!1)?"property":"tag","block"):(g+=" error","maybeprop")}return"meta"==e?"block":B||"hash"!=e&&"qualifier"!=e?_.top(e,t,r):(g="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 g+=" error";return"prop"},_.propBlock=function(e,t,r){return"}"==e?c(r):"word"==e?(g="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?(g="variable-3",r.context.type):d(e,t,r)},_.documentTypes=function(e,t,r){return"word"==e&&y.hasOwnProperty(t.current())?(g="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();g="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&&(g="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?(g="variable","restricted_atBlock_before"):d(e,t,r)},_.restricted_atBlock=function(e,t,r){return"}"==e?(r.stateArg=null,c(r)):"word"==e?(g="@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?(g="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?g="tag":"hash"==e&&(g="builtin"),"at")},_.interpolation=function(e,t,r){return"}"==e?c(r):"{"==e||";"==e?p(e,t,r):("word"==e?g="variable":"variable"!=e&&"("!=e&&")"!=e&&(g="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]),g=r,t.state=_[t.state](h,e,t),g},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-b),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-blend-mode","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-rows","grid-column","grid-column-end","grid-column-gap","grid-column-start","grid-gap","grid-row","grid-row-end","grid-row-gap","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","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","user-select","vertical-align","visibility","voice-balance","voice-duration","voice-family","voice-pitch","voice-range","voice-rate","voice-stress","voice-volume","volume","white-space","widows","width","will-change","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),g=["font-family","src","unicode-range","font-variant","font-feature-settings","font-stretch","font-weight","font-style"],b=t(g),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","auto-flow","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","color","color-burn","color-dodge","column","column-reverse","compact","condensed","contain","content","contents","content-box","context-menu","continuous","copy","counter","counters","cover","crop","cross","crosshair","currentcolor","cursive","cyclic","darken","dashed","decimal","decimal-leading-zero","default","default-button","dense","destination-atop","destination-in","destination-out","destination-over","devanagari","difference","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","exclusion","expanded","extends","extra-condensed","extra-expanded","fantasy","fast","fill","fixed","flat","flex","flex-end","flex-start","footnotes","forwards","from","geometricPrecision","georgian","graytext","grid","groove","gujarati","gurmukhi","hand","hangul","hangul-consonant","hard-light","hebrew","help","hidden","hide","higher","highlight","highlighttext","hiragana","hiragana-iroha","horizontal","hsl","hsla","hue","icon","ignore","inactiveborder","inactivecaption","inactivecaptiontext","infinite","infobackground","infotext","inherit","initial","inline","inline-axis","inline-block","inline-flex","inline-grid","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","lighten","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","luminosity","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","multiply","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","opacity","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","saturation","scale","scale3d","scaleX","scaleY","scaleZ","screen","scroll","scrollbar","scroll-position","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","soft-light","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","transform","translate","translate3d","translateX","translateY","translateZ","transparent","ultra-condensed","ultra-expanded","underline","unset","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:b,counterDescriptors:y,colorKeywords:k,valueKeywords:x,tokenHooks:{"/":function(e,t){return!!e.eat("*")&&(t.tokenize=r,r(e,t))}},name:"css"}),e.defineMIME("text/x-scss",{mediaTypes:n,mediaFeatures:s,mediaValueKeywords:d,propertyKeywords:u,nonStandardPropertyKeywords:h,colorKeywords:k,valueKeywords:x,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,"{"]},$:function(e){return e.match(/^[\w-]+/),e.match(/^\s*:/,!1)?["variable-2","variable-definition"]:["variable-2","variable"]},"#":function(e){return!!e.eat("{")&&[null,"interpolation"]}},name:"css",helperType:"scss"}),e.defineMIME("text/x-less",{mediaTypes:n,mediaFeatures:s,mediaValueKeywords:d,propertyKeywords:u,nonStandardPropertyKeywords:h,colorKeywords:k,valueKeywords:x,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)&&(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:b,counterDescriptors:y,colorKeywords:k,valueKeywords:x,supportsAtComponent:!0,tokenHooks:{"/":function(e,t){return!!e.eat("*")&&(t.tokenize=r,r(e,t))}},name:"css",helperType:"gss"})});
|
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].toLowerCase()]=!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:b),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();g=K.hasOwnProperty(t)?"atom":j.hasOwnProperty(t)?"keyword":"variable"}var m=r.inline;r.propertyKeywords||(r=e.resolveMode("text/css"));var h,g,b=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,C=r.lineComment,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)g="builtin";else if("word"==e)g="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)?(g="property","maybeprop"):z.hasOwnProperty(o)?(g="string-2","maybeprop"):B?(g=t.match(/^\s*:(?:\s|$)/,!1)?"property":"tag","block"):(g+=" error","maybeprop")}return"meta"==e?"block":B||"hash"!=e&&"qualifier"!=e?_.top(e,t,r):(g="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 g+=" error";return"prop"},_.propBlock=function(e,t,r){return"}"==e?c(r):"word"==e?(g="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"meta"==e?"pseudo":"word"==e?(g="variable-3",r.context.type):d(e,t,r)},_.documentTypes=function(e,t,r){return"word"==e&&y.hasOwnProperty(t.current())?(g="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();g="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&&(g="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?(g="variable","restricted_atBlock_before"):d(e,t,r)},_.restricted_atBlock=function(e,t,r){return"}"==e?(r.stateArg=null,c(r)):"word"==e?(g="@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?(g="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?g="tag":"hash"==e&&(g="builtin"),"at")},_.interpolation=function(e,t,r){return"}"==e?c(r):"{"==e||";"==e?p(e,t,r):("word"==e?g="variable":"variable"!=e&&"("!=e&&")"!=e&&(g="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]),g=r,t.state=_[t.state](h,e,t),g},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-b),r=r.prev):(r=r.prev,a=r.indent)),a},electricChars:"}",blockCommentStart:"/*",blockCommentEnd:"*/",lineComment:C,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-blend-mode","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-rows","grid-column","grid-column-end","grid-column-gap","grid-column-start","grid-gap","grid-row","grid-row-end","grid-row-gap","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","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","user-select","vertical-align","visibility","voice-balance","voice-duration","voice-family","voice-pitch","voice-range","voice-rate","voice-stress","voice-volume","volume","white-space","widows","width","will-change","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),g=["font-family","src","unicode-range","font-variant","font-feature-settings","font-stretch","font-weight","font-style"],b=t(g),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","auto-flow","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","color","color-burn","color-dodge","column","column-reverse","compact","condensed","contain","content","contents","content-box","context-menu","continuous","copy","counter","counters","cover","crop","cross","crosshair","currentcolor","cursive","cyclic","darken","dashed","decimal","decimal-leading-zero","default","default-button","dense","destination-atop","destination-in","destination-out","destination-over","devanagari","difference","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","exclusion","expanded","extends","extra-condensed","extra-expanded","fantasy","fast","fill","fixed","flat","flex","flex-end","flex-start","footnotes","forwards","from","geometricPrecision","georgian","graytext","grid","groove","gujarati","gurmukhi","hand","hangul","hangul-consonant","hard-light","hebrew","help","hidden","hide","higher","highlight","highlighttext","hiragana","hiragana-iroha","horizontal","hsl","hsla","hue","icon","ignore","inactiveborder","inactivecaption","inactivecaptiontext","infinite","infobackground","infotext","inherit","initial","inline","inline-axis","inline-block","inline-flex","inline-grid","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","lighten","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","luminosity","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","multiply","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","opacity","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","saturation","scale","scale3d","scaleX","scaleY","scaleZ","screen","scroll","scrollbar","scroll-position","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","soft-light","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","system-ui","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","transform","translate","translate3d","translateX","translateY","translateZ","transparent","ultra-condensed","ultra-expanded","underline","unset","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:b,counterDescriptors:y,colorKeywords:k,valueKeywords:x,tokenHooks:{"/":function(e,t){return!!e.eat("*")&&(t.tokenize=r,r(e,t))}},name:"css"}),e.defineMIME("text/x-scss",{mediaTypes:n,mediaFeatures:s,mediaValueKeywords:d,propertyKeywords:u,nonStandardPropertyKeywords:h,colorKeywords:k,valueKeywords:x,fontProperties:b,allowNested:!0,lineComment:"//",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*\{/,!1)&&[null,null]},$:function(e){return e.match(/^[\w-]+/),e.match(/^\s*:/,!1)?["variable-2","variable-definition"]:["variable-2","variable"]},"#":function(e){return!!e.eat("{")&&[null,"interpolation"]}},name:"css",helperType:"scss"}),e.defineMIME("text/x-less",{mediaTypes:n,mediaFeatures:s,mediaValueKeywords:d,propertyKeywords:u,nonStandardPropertyKeywords:h,colorKeywords:k,valueKeywords:x,fontProperties:b,allowNested:!0,lineComment:"//",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)&&(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:b,counterDescriptors:y,colorKeywords:k,valueKeywords:x,supportsAtComponent:!0,tokenHooks:{"/":function(e,t){return!!e.eat("*")&&(t.tokenize=r,r(e,t))}},name:"css",helperType:"gss"})});
|
lib/codemirror/mode/css/index.html
CHANGED
@@ -64,7 +64,7 @@ code {
|
|
64 |
</textarea></form>
|
65 |
<script>
|
66 |
var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
|
67 |
-
extraKeys: {"Ctrl-Space": "autocomplete"}
|
68 |
});
|
69 |
</script>
|
70 |
|
64 |
</textarea></form>
|
65 |
<script>
|
66 |
var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
|
67 |
+
extraKeys: {"Ctrl-Space": "autocomplete"}
|
68 |
});
|
69 |
</script>
|
70 |
|
lib/codemirror/mode/sass/index.html
CHANGED
@@ -7,6 +7,7 @@
|
|
7 |
<link rel="stylesheet" href="../../lib/codemirror.css">
|
8 |
<script src="../../lib/codemirror.js"></script>
|
9 |
<script src="../../addon/edit/matchbrackets.js"></script>
|
|
|
10 |
<script src="sass.js"></script>
|
11 |
<style>.CodeMirror {border: 1px solid #ddd; font-size:12px; height: 400px}</style>
|
12 |
<div id=nav>
|
@@ -58,7 +59,8 @@ body
|
|
58 |
<script>
|
59 |
var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
|
60 |
lineNumbers : true,
|
61 |
-
matchBrackets : true
|
|
|
62 |
});
|
63 |
</script>
|
64 |
|
7 |
<link rel="stylesheet" href="../../lib/codemirror.css">
|
8 |
<script src="../../lib/codemirror.js"></script>
|
9 |
<script src="../../addon/edit/matchbrackets.js"></script>
|
10 |
+
<script src="../css/css.js"></script>
|
11 |
<script src="sass.js"></script>
|
12 |
<style>.CodeMirror {border: 1px solid #ddd; font-size:12px; height: 400px}</style>
|
13 |
<div id=nav>
|
59 |
<script>
|
60 |
var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
|
61 |
lineNumbers : true,
|
62 |
+
matchBrackets : true,
|
63 |
+
mode: "sass"
|
64 |
});
|
65 |
</script>
|
66 |
|
lib/codemirror/mode/sass/sass.js
CHANGED
@@ -3,15 +3,21 @@
|
|
3 |
|
4 |
(function(mod) {
|
5 |
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
6 |
-
mod(require("../../lib/codemirror"));
|
7 |
else if (typeof define == "function" && define.amd) // AMD
|
8 |
-
define(["../../lib/codemirror"], mod);
|
9 |
else // Plain browser env
|
10 |
mod(CodeMirror);
|
11 |
})(function(CodeMirror) {
|
12 |
"use strict";
|
13 |
|
14 |
CodeMirror.defineMode("sass", function(config) {
|
|
|
|
|
|
|
|
|
|
|
|
|
15 |
function tokenRegexp(words) {
|
16 |
return new RegExp("^" + words.join("|"));
|
17 |
}
|
@@ -25,6 +31,12 @@ CodeMirror.defineMode("sass", function(config) {
|
|
25 |
|
26 |
var pseudoElementsRegexp = /^::?[a-zA-Z_][\w\-]*/;
|
27 |
|
|
|
|
|
|
|
|
|
|
|
|
|
28 |
function urlTokens(stream, state) {
|
29 |
var ch = stream.peek();
|
30 |
|
@@ -76,6 +88,9 @@ CodeMirror.defineMode("sass", function(config) {
|
|
76 |
|
77 |
if (endingString) {
|
78 |
if (nextChar !== quote && greedy) { stream.next(); }
|
|
|
|
|
|
|
79 |
state.tokenizer = tokenBase;
|
80 |
return "string";
|
81 |
} else if (nextChar === "#" && peekChar === "{") {
|
@@ -147,14 +162,20 @@ CodeMirror.defineMode("sass", function(config) {
|
|
147 |
// first half i.e. before : for key-value pairs
|
148 |
// including selectors
|
149 |
|
|
|
|
|
|
|
|
|
|
|
|
|
150 |
if (ch === ".") {
|
151 |
stream.next();
|
152 |
if (stream.match(/^[\w-]+/)) {
|
153 |
indent(state);
|
154 |
-
return "
|
155 |
} else if (stream.peek() === "#") {
|
156 |
indent(state);
|
157 |
-
return "
|
158 |
}
|
159 |
}
|
160 |
|
@@ -163,11 +184,11 @@ CodeMirror.defineMode("sass", function(config) {
|
|
163 |
// ID selectors
|
164 |
if (stream.match(/^[\w-]+/)) {
|
165 |
indent(state);
|
166 |
-
return "
|
167 |
}
|
168 |
if (stream.peek() === "#") {
|
169 |
indent(state);
|
170 |
-
return "
|
171 |
}
|
172 |
}
|
173 |
|
@@ -220,37 +241,48 @@ CodeMirror.defineMode("sass", function(config) {
|
|
220 |
// Indent Directives
|
221 |
if (stream.match(/^@(else if|if|media|else|for|each|while|mixin|function)/)) {
|
222 |
indent(state);
|
223 |
-
return "
|
224 |
}
|
225 |
|
226 |
// Other Directives
|
227 |
if (ch === "@") {
|
228 |
stream.next();
|
229 |
stream.eatWhile(/[\w-]/);
|
230 |
-
return "
|
231 |
}
|
232 |
|
233 |
if (stream.eatWhile(/[\w-]/)){
|
234 |
if(stream.match(/ *: *[\w-\+\$#!\("']/,false)){
|
235 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
236 |
}
|
237 |
else if(stream.match(/ *:/,false)){
|
238 |
indent(state);
|
239 |
state.cursorHalf = 1;
|
240 |
-
|
|
|
241 |
}
|
242 |
else if(stream.match(/ *,/,false)){
|
243 |
-
return "
|
244 |
}
|
245 |
else{
|
246 |
indent(state);
|
247 |
-
return "
|
248 |
}
|
249 |
}
|
250 |
|
251 |
if(ch === ":"){
|
252 |
if (stream.match(pseudoElementsRegexp)){ // could be a pseudo-element
|
253 |
-
return "
|
254 |
}
|
255 |
stream.next();
|
256 |
state.cursorHalf=1;
|
@@ -264,7 +296,7 @@ CodeMirror.defineMode("sass", function(config) {
|
|
264 |
stream.next();
|
265 |
// Hex numbers
|
266 |
if (stream.match(/[0-9a-fA-F]{6}|[0-9a-fA-F]{3}/)){
|
267 |
-
if(
|
268 |
state.cursorHalf = 0;
|
269 |
}
|
270 |
return "number";
|
@@ -273,7 +305,7 @@ CodeMirror.defineMode("sass", function(config) {
|
|
273 |
|
274 |
// Numbers
|
275 |
if (stream.match(/^-?[0-9\.]+/)){
|
276 |
-
if(
|
277 |
state.cursorHalf = 0;
|
278 |
}
|
279 |
return "number";
|
@@ -281,14 +313,14 @@ CodeMirror.defineMode("sass", function(config) {
|
|
281 |
|
282 |
// Units
|
283 |
if (stream.match(/^(px|em|in)\b/)){
|
284 |
-
if(
|
285 |
state.cursorHalf = 0;
|
286 |
}
|
287 |
return "unit";
|
288 |
}
|
289 |
|
290 |
if (stream.match(keywordsRegexp)){
|
291 |
-
if(
|
292 |
state.cursorHalf = 0;
|
293 |
}
|
294 |
return "keyword";
|
@@ -296,7 +328,7 @@ CodeMirror.defineMode("sass", function(config) {
|
|
296 |
|
297 |
if (stream.match(/^url/) && stream.peek() === "(") {
|
298 |
state.tokenizer = urlTokens;
|
299 |
-
if(
|
300 |
state.cursorHalf = 0;
|
301 |
}
|
302 |
return "atom";
|
@@ -306,23 +338,21 @@ CodeMirror.defineMode("sass", function(config) {
|
|
306 |
if (ch === "$") {
|
307 |
stream.next();
|
308 |
stream.eatWhile(/[\w-]/);
|
309 |
-
if(
|
310 |
state.cursorHalf = 0;
|
311 |
}
|
312 |
-
return "variable-
|
313 |
}
|
314 |
|
315 |
// bang character for !important, !default, etc.
|
316 |
if (ch === "!") {
|
317 |
stream.next();
|
318 |
-
|
319 |
-
state.cursorHalf = 0;
|
320 |
-
}
|
321 |
return stream.match(/^[\w]+/) ? "keyword": "operator";
|
322 |
}
|
323 |
|
324 |
if (stream.match(opRegexp)){
|
325 |
-
if(
|
326 |
state.cursorHalf = 0;
|
327 |
}
|
328 |
return "operator";
|
@@ -330,14 +360,24 @@ CodeMirror.defineMode("sass", function(config) {
|
|
330 |
|
331 |
// attributes
|
332 |
if (stream.eatWhile(/[\w-]/)) {
|
333 |
-
if(
|
334 |
state.cursorHalf = 0;
|
335 |
}
|
336 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
337 |
}
|
338 |
|
339 |
//stream.eatSpace();
|
340 |
-
if(
|
341 |
state.cursorHalf = 0;
|
342 |
return null;
|
343 |
}
|
3 |
|
4 |
(function(mod) {
|
5 |
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
6 |
+
mod(require("../../lib/codemirror"), require("../css/css"));
|
7 |
else if (typeof define == "function" && define.amd) // AMD
|
8 |
+
define(["../../lib/codemirror", "../css/css"], mod);
|
9 |
else // Plain browser env
|
10 |
mod(CodeMirror);
|
11 |
})(function(CodeMirror) {
|
12 |
"use strict";
|
13 |
|
14 |
CodeMirror.defineMode("sass", function(config) {
|
15 |
+
var cssMode = CodeMirror.mimeModes["text/css"];
|
16 |
+
var propertyKeywords = cssMode.propertyKeywords || {},
|
17 |
+
colorKeywords = cssMode.colorKeywords || {},
|
18 |
+
valueKeywords = cssMode.valueKeywords || {},
|
19 |
+
fontProperties = cssMode.fontProperties || {};
|
20 |
+
|
21 |
function tokenRegexp(words) {
|
22 |
return new RegExp("^" + words.join("|"));
|
23 |
}
|
31 |
|
32 |
var pseudoElementsRegexp = /^::?[a-zA-Z_][\w\-]*/;
|
33 |
|
34 |
+
var word;
|
35 |
+
|
36 |
+
function isEndLine(stream) {
|
37 |
+
return !stream.peek() || stream.match(/\s+$/, false);
|
38 |
+
}
|
39 |
+
|
40 |
function urlTokens(stream, state) {
|
41 |
var ch = stream.peek();
|
42 |
|
88 |
|
89 |
if (endingString) {
|
90 |
if (nextChar !== quote && greedy) { stream.next(); }
|
91 |
+
if (isEndLine(stream)) {
|
92 |
+
state.cursorHalf = 0;
|
93 |
+
}
|
94 |
state.tokenizer = tokenBase;
|
95 |
return "string";
|
96 |
} else if (nextChar === "#" && peekChar === "{") {
|
162 |
// first half i.e. before : for key-value pairs
|
163 |
// including selectors
|
164 |
|
165 |
+
if (ch === "-") {
|
166 |
+
if (stream.match(/^-\w+-/)) {
|
167 |
+
return "meta";
|
168 |
+
}
|
169 |
+
}
|
170 |
+
|
171 |
if (ch === ".") {
|
172 |
stream.next();
|
173 |
if (stream.match(/^[\w-]+/)) {
|
174 |
indent(state);
|
175 |
+
return "qualifier";
|
176 |
} else if (stream.peek() === "#") {
|
177 |
indent(state);
|
178 |
+
return "tag";
|
179 |
}
|
180 |
}
|
181 |
|
184 |
// ID selectors
|
185 |
if (stream.match(/^[\w-]+/)) {
|
186 |
indent(state);
|
187 |
+
return "builtin";
|
188 |
}
|
189 |
if (stream.peek() === "#") {
|
190 |
indent(state);
|
191 |
+
return "tag";
|
192 |
}
|
193 |
}
|
194 |
|
241 |
// Indent Directives
|
242 |
if (stream.match(/^@(else if|if|media|else|for|each|while|mixin|function)/)) {
|
243 |
indent(state);
|
244 |
+
return "def";
|
245 |
}
|
246 |
|
247 |
// Other Directives
|
248 |
if (ch === "@") {
|
249 |
stream.next();
|
250 |
stream.eatWhile(/[\w-]/);
|
251 |
+
return "def";
|
252 |
}
|
253 |
|
254 |
if (stream.eatWhile(/[\w-]/)){
|
255 |
if(stream.match(/ *: *[\w-\+\$#!\("']/,false)){
|
256 |
+
word = stream.current().toLowerCase();
|
257 |
+
var prop = state.prevProp + "-" + word;
|
258 |
+
if (propertyKeywords.hasOwnProperty(prop)) {
|
259 |
+
return "property";
|
260 |
+
} else if (propertyKeywords.hasOwnProperty(word)) {
|
261 |
+
state.prevProp = word;
|
262 |
+
return "property";
|
263 |
+
} else if (fontProperties.hasOwnProperty(word)) {
|
264 |
+
return "property";
|
265 |
+
}
|
266 |
+
return "tag";
|
267 |
}
|
268 |
else if(stream.match(/ *:/,false)){
|
269 |
indent(state);
|
270 |
state.cursorHalf = 1;
|
271 |
+
state.prevProp = stream.current().toLowerCase();
|
272 |
+
return "property";
|
273 |
}
|
274 |
else if(stream.match(/ *,/,false)){
|
275 |
+
return "tag";
|
276 |
}
|
277 |
else{
|
278 |
indent(state);
|
279 |
+
return "tag";
|
280 |
}
|
281 |
}
|
282 |
|
283 |
if(ch === ":"){
|
284 |
if (stream.match(pseudoElementsRegexp)){ // could be a pseudo-element
|
285 |
+
return "variable-3";
|
286 |
}
|
287 |
stream.next();
|
288 |
state.cursorHalf=1;
|
296 |
stream.next();
|
297 |
// Hex numbers
|
298 |
if (stream.match(/[0-9a-fA-F]{6}|[0-9a-fA-F]{3}/)){
|
299 |
+
if (isEndLine(stream)) {
|
300 |
state.cursorHalf = 0;
|
301 |
}
|
302 |
return "number";
|
305 |
|
306 |
// Numbers
|
307 |
if (stream.match(/^-?[0-9\.]+/)){
|
308 |
+
if (isEndLine(stream)) {
|
309 |
state.cursorHalf = 0;
|
310 |
}
|
311 |
return "number";
|
313 |
|
314 |
// Units
|
315 |
if (stream.match(/^(px|em|in)\b/)){
|
316 |
+
if (isEndLine(stream)) {
|
317 |
state.cursorHalf = 0;
|
318 |
}
|
319 |
return "unit";
|
320 |
}
|
321 |
|
322 |
if (stream.match(keywordsRegexp)){
|
323 |
+
if (isEndLine(stream)) {
|
324 |
state.cursorHalf = 0;
|
325 |
}
|
326 |
return "keyword";
|
328 |
|
329 |
if (stream.match(/^url/) && stream.peek() === "(") {
|
330 |
state.tokenizer = urlTokens;
|
331 |
+
if (isEndLine(stream)) {
|
332 |
state.cursorHalf = 0;
|
333 |
}
|
334 |
return "atom";
|
338 |
if (ch === "$") {
|
339 |
stream.next();
|
340 |
stream.eatWhile(/[\w-]/);
|
341 |
+
if (isEndLine(stream)) {
|
342 |
state.cursorHalf = 0;
|
343 |
}
|
344 |
+
return "variable-2";
|
345 |
}
|
346 |
|
347 |
// bang character for !important, !default, etc.
|
348 |
if (ch === "!") {
|
349 |
stream.next();
|
350 |
+
state.cursorHalf = 0;
|
|
|
|
|
351 |
return stream.match(/^[\w]+/) ? "keyword": "operator";
|
352 |
}
|
353 |
|
354 |
if (stream.match(opRegexp)){
|
355 |
+
if (isEndLine(stream)) {
|
356 |
state.cursorHalf = 0;
|
357 |
}
|
358 |
return "operator";
|
360 |
|
361 |
// attributes
|
362 |
if (stream.eatWhile(/[\w-]/)) {
|
363 |
+
if (isEndLine(stream)) {
|
364 |
state.cursorHalf = 0;
|
365 |
}
|
366 |
+
word = stream.current().toLowerCase();
|
367 |
+
if (valueKeywords.hasOwnProperty(word)) {
|
368 |
+
return "atom";
|
369 |
+
} else if (colorKeywords.hasOwnProperty(word)) {
|
370 |
+
return "keyword";
|
371 |
+
} else if (propertyKeywords.hasOwnProperty(word)) {
|
372 |
+
state.prevProp = stream.current().toLowerCase();
|
373 |
+
return "property";
|
374 |
+
} else {
|
375 |
+
return "tag";
|
376 |
+
}
|
377 |
}
|
378 |
|
379 |
//stream.eatSpace();
|
380 |
+
if (isEndLine(stream)) {
|
381 |
state.cursorHalf = 0;
|
382 |
return null;
|
383 |
}
|
lib/codemirror/mode/sass/sass.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.defineMode("sass",function(
|
1 |
+
!function(e){"object"==typeof exports&&"object"==typeof module?e(require("../../lib/codemirror"),require("../css/css")):"function"==typeof define&&define.amd?define(["../../lib/codemirror","../css/css"],e):e(CodeMirror)}(function(e){"use strict";e.defineMode("sass",function(r){function t(e){return new RegExp("^"+e.join("|"))}function n(e){return!e.peek()||e.match(/\s+$/,!1)}function o(e,r){var t=e.peek();return")"===t?(e.next(),r.tokenizer=c,"operator"):"("===t?(e.next(),e.eatSpace(),"operator"):"'"===t||'"'===t?(r.tokenizer=a(e.next()),"string"):(r.tokenizer=a(")",!1),"string")}function i(e,r){return function(t,n){return t.sol()&&t.indentation()<=e?(n.tokenizer=c,c(t,n)):(r&&t.skipTo("*/")?(t.next(),t.next(),n.tokenizer=c):t.skipToEnd(),"comment")}}function a(e,r){function t(o,i){var a=o.next(),f=o.peek(),s=o.string.charAt(o.pos-2),p="\\"!==a&&f===e||a===e&&"\\"!==s;return p?(a!==e&&r&&o.next(),n(o)&&(i.cursorHalf=0),i.tokenizer=c,"string"):"#"===a&&"{"===f?(i.tokenizer=u(t),o.next(),"operator"):"string"}return null==r&&(r=!0),t}function u(e){return function(r,t){return"}"===r.peek()?(r.next(),t.tokenizer=e,"operator"):c(r,t)}}function f(e){if(0==e.indentCount){e.indentCount++;var t=e.scopes[0].offset,n=t+r.indentUnit;e.scopes.unshift({offset:n})}}function s(e){1!=e.scopes.length&&e.scopes.shift()}function c(e,r){var t=e.peek();if(e.match("/*"))return r.tokenizer=i(e.indentation(),!0),r.tokenizer(e,r);if(e.match("//"))return r.tokenizer=i(e.indentation(),!1),r.tokenizer(e,r);if(e.match("#{"))return r.tokenizer=u(c),"operator";if('"'===t||"'"===t)return e.next(),r.tokenizer=a(t),"string";if(r.cursorHalf){if("#"===t&&(e.next(),e.match(/[0-9a-fA-F]{6}|[0-9a-fA-F]{3}/)))return n(e)&&(r.cursorHalf=0),"number";if(e.match(/^-?[0-9\.]+/))return n(e)&&(r.cursorHalf=0),"number";if(e.match(/^(px|em|in)\b/))return n(e)&&(r.cursorHalf=0),"unit";if(e.match(y))return n(e)&&(r.cursorHalf=0),"keyword";if(e.match(/^url/)&&"("===e.peek())return r.tokenizer=o,n(e)&&(r.cursorHalf=0),"atom";if("$"===t)return e.next(),e.eatWhile(/[\w-]/),n(e)&&(r.cursorHalf=0),"variable-2";if("!"===t)return e.next(),r.cursorHalf=0,e.match(/^[\w]+/)?"keyword":"operator";if(e.match(z))return n(e)&&(r.cursorHalf=0),"operator";if(e.eatWhile(/[\w-]/))return n(e)&&(r.cursorHalf=0),l=e.current().toLowerCase(),k.hasOwnProperty(l)?"atom":d.hasOwnProperty(l)?"keyword":m.hasOwnProperty(l)?(r.prevProp=e.current().toLowerCase(),"property"):"tag";if(n(e))return r.cursorHalf=0,null}else{if("-"===t&&e.match(/^-\w+-/))return"meta";if("."===t){if(e.next(),e.match(/^[\w-]+/))return f(r),"qualifier";if("#"===e.peek())return f(r),"tag"}if("#"===t){if(e.next(),e.match(/^[\w-]+/))return f(r),"builtin";if("#"===e.peek())return f(r),"tag"}if("$"===t)return e.next(),e.eatWhile(/[\w-]/),"variable-2";if(e.match(/^-?[0-9\.]+/))return"number";if(e.match(/^(px|em|in)\b/))return"unit";if(e.match(y))return"keyword";if(e.match(/^url/)&&"("===e.peek())return r.tokenizer=o,"atom";if("="===t&&e.match(/^=[\w-]+/))return f(r),"meta";if("+"===t&&e.match(/^\+[\w-]+/))return"variable-3";if("@"===t&&e.match(/@extend/)&&(e.match(/\s*[\w]/)||s(r)),e.match(/^@(else if|if|media|else|for|each|while|mixin|function)/))return f(r),"def";if("@"===t)return e.next(),e.eatWhile(/[\w-]/),"def";if(e.eatWhile(/[\w-]/)){if(e.match(/ *: *[\w-\+\$#!\("']/,!1)){l=e.current().toLowerCase();var p=r.prevProp+"-"+l;return m.hasOwnProperty(p)?"property":m.hasOwnProperty(l)?(r.prevProp=l,"property"):w.hasOwnProperty(l)?"property":"tag"}return e.match(/ *:/,!1)?(f(r),r.cursorHalf=1,r.prevProp=e.current().toLowerCase(),"property"):e.match(/ *,/,!1)?"tag":(f(r),"tag")}if(":"===t)return e.match(g)?"variable-3":(e.next(),r.cursorHalf=1,"operator")}return e.match(z)?"operator":(e.next(),null)}function p(e,t){e.sol()&&(t.indentCount=0);var n=t.tokenizer(e,t),o=e.current();if("@return"!==o&&"}"!==o||s(t),null!==n){for(var i=e.pos-o.length,a=i+r.indentUnit*t.indentCount,u=[],f=0;f<t.scopes.length;f++){var c=t.scopes[f];c.offset<=a&&u.push(c)}t.scopes=u}return n}var l,h=e.mimeModes["text/css"],m=h.propertyKeywords||{},d=h.colorKeywords||{},k=h.valueKeywords||{},w=h.fontProperties||{},x=["true","false","null","auto"],y=new RegExp("^"+x.join("|")),v=["\\(","\\)","=",">","<","==",">=","<=","\\+","-","\\!=","/","\\*","%","and","or","not",";","\\{","\\}",":"],z=t(v),g=/^::?[a-zA-Z_][\w\-]*/;return{startState:function(){return{tokenizer:c,scopes:[{offset:0,type:"sass"}],indentCount:0,cursorHalf:0,definedVars:[],definedMixins:[]}},token:function(e,r){var t=p(e,r);return r.lastToken={style:t,content:e.current()},t},indent:function(e){return e.scopes[0].offset}}}),e.defineMIME("text/x-sass","sass")});
|
lib/codemirror/mode/sass/test.js
ADDED
@@ -0,0 +1,122 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
2 |
+
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
3 |
+
|
4 |
+
(function() {
|
5 |
+
var mode = CodeMirror.getMode({indentUnit: 2}, "sass");
|
6 |
+
// Since Sass has an indent-based syntax, is almost impossible to test correctly the indentation in all cases.
|
7 |
+
// So disable it for tests.
|
8 |
+
mode.indent = undefined;
|
9 |
+
function MT(name) { test.mode(name, mode, Array.prototype.slice.call(arguments, 1)); }
|
10 |
+
|
11 |
+
MT("comment",
|
12 |
+
"[comment // this is a comment]",
|
13 |
+
"[comment also this is a comment]")
|
14 |
+
|
15 |
+
MT("comment_multiline",
|
16 |
+
"[comment /* this is a comment]",
|
17 |
+
"[comment also this is a comment]")
|
18 |
+
|
19 |
+
MT("variable",
|
20 |
+
"[variable-2 $page-width][operator :] [number 800][unit px]")
|
21 |
+
|
22 |
+
MT("global_attributes",
|
23 |
+
"[tag body]",
|
24 |
+
" [property font][operator :]",
|
25 |
+
" [property family][operator :] [atom sans-serif]",
|
26 |
+
" [property size][operator :] [number 30][unit em]",
|
27 |
+
" [property weight][operator :] [atom bold]")
|
28 |
+
|
29 |
+
MT("scoped_styles",
|
30 |
+
"[builtin #contents]",
|
31 |
+
" [property width][operator :] [variable-2 $page-width]",
|
32 |
+
" [builtin #sidebar]",
|
33 |
+
" [property float][operator :] [atom right]",
|
34 |
+
" [property width][operator :] [variable-2 $sidebar-width]",
|
35 |
+
" [builtin #main]",
|
36 |
+
" [property width][operator :] [variable-2 $page-width] [operator -] [variable-2 $sidebar-width]",
|
37 |
+
" [property background][operator :] [variable-2 $primary-color]",
|
38 |
+
" [tag h2]",
|
39 |
+
" [property color][operator :] [keyword blue]")
|
40 |
+
|
41 |
+
// Sass allows to write the colon as first char instead of a "separator".
|
42 |
+
// :color red
|
43 |
+
// Not supported
|
44 |
+
// MT("property_syntax",
|
45 |
+
// "[qualifier .foo]",
|
46 |
+
// " [operator :][property color] [keyword red]")
|
47 |
+
|
48 |
+
MT("import",
|
49 |
+
"[def @import] [string \"sass/variables\"]",
|
50 |
+
// Probably it should parsed as above: as a string even without the " or '
|
51 |
+
// "[def @import] [string sass/baz]"
|
52 |
+
"[def @import] [tag sass][operator /][tag baz]")
|
53 |
+
|
54 |
+
MT("def",
|
55 |
+
"[def @if] [variable-2 $foo] [def @else]")
|
56 |
+
|
57 |
+
MT("tag_on_more_lines",
|
58 |
+
"[tag td],",
|
59 |
+
"[tag th]",
|
60 |
+
" [property font-family][operator :] [string \"Arial\"], [atom serif]")
|
61 |
+
|
62 |
+
MT("important",
|
63 |
+
"[qualifier .foo]",
|
64 |
+
" [property text-decoration][operator :] [atom none] [keyword !important]",
|
65 |
+
"[tag h1]",
|
66 |
+
" [property font-size][operator :] [number 2.5][unit em]")
|
67 |
+
|
68 |
+
MT("selector",
|
69 |
+
// SCSS doesn't highlight the :
|
70 |
+
// "[tag h1]:[variable-3 before],",
|
71 |
+
// "[tag h2]:[variable-3 before]",
|
72 |
+
"[tag h1][variable-3 :before],",
|
73 |
+
"[tag h2][variable-3 :before]",
|
74 |
+
" [property content][operator :] [string \"::\"]")
|
75 |
+
|
76 |
+
MT("definition_mixin_equal",
|
77 |
+
"[variable-2 $defined-bs-type][operator :] [atom border-box] [keyword !default]",
|
78 |
+
"[meta =bs][operator (][variable-2 $bs-type][operator :] [variable-2 $defined-bs-type][operator )]",
|
79 |
+
" [meta -webkit-][property box-sizing][operator :] [variable-2 $bs-type]",
|
80 |
+
" [property box-sizing][operator :] [variable-2 $bs-type]")
|
81 |
+
|
82 |
+
MT("definition_mixin_with_space",
|
83 |
+
"[variable-2 $defined-bs-type][operator :] [atom border-box] [keyword !default]",
|
84 |
+
"[def @mixin] [tag bs][operator (][variable-2 $bs-type][operator :] [variable-2 $defined-bs-type][operator )] ",
|
85 |
+
" [meta -moz-][property box-sizing][operator :] [variable-2 $bs-type]",
|
86 |
+
" [property box-sizing][operator :] [variable-2 $bs-type]")
|
87 |
+
|
88 |
+
MT("numbers_start_dot_include_plus",
|
89 |
+
// The % is not highlighted correctly
|
90 |
+
// "[meta =button-links][operator (][variable-2 $button-base][operator :] [atom darken][operator (][variable-2 $color11], [number 10][unit %][operator )][operator )]",
|
91 |
+
"[meta =button-links][operator (][variable-2 $button-base][operator :] [atom darken][operator (][variable-2 $color11], [number 10][operator %))]",
|
92 |
+
" [property padding][operator :] [number .3][unit em] [number .6][unit em]",
|
93 |
+
" [variable-3 +border-radius][operator (][number 8][unit px][operator )]",
|
94 |
+
" [property background-color][operator :] [variable-2 $button-base]")
|
95 |
+
|
96 |
+
MT("include",
|
97 |
+
"[qualifier .bar]",
|
98 |
+
" [def @include] [tag border-radius][operator (][number 8][unit px][operator )]")
|
99 |
+
|
100 |
+
MT("reference_parent",
|
101 |
+
"[qualifier .col]",
|
102 |
+
" [property clear][operator :] [atom both]",
|
103 |
+
// SCSS doesn't highlight the :
|
104 |
+
// " &:[variable-3 after]",
|
105 |
+
" &[variable-3 :after]",
|
106 |
+
" [property content][operator :] [string '']",
|
107 |
+
" [property clear][operator :] [atom both]")
|
108 |
+
|
109 |
+
MT("reference_parent_with_spaces",
|
110 |
+
"[tag section]",
|
111 |
+
" [property border-left][operator :] [number 20][unit px] [atom transparent] [atom solid] ",
|
112 |
+
" &[qualifier .section3]",
|
113 |
+
" [qualifier .title]",
|
114 |
+
" [property color][operator :] [keyword white] ",
|
115 |
+
" [qualifier .vermas]",
|
116 |
+
" [property display][operator :] [atom none]")
|
117 |
+
|
118 |
+
MT("font_face",
|
119 |
+
"[def @font-face]",
|
120 |
+
" [property font-family][operator :] [string 'icomoon']",
|
121 |
+
" [property src][operator :] [atom url][operator (][string fonts/icomoon.ttf][operator )]")
|
122 |
+
})();
|
lib/codemirror/mode/sass/test.min.js
ADDED
@@ -0,0 +1 @@
|
|
|
1 |
+
!function(){function r(r){test.mode(r,e,Array.prototype.slice.call(arguments,1))}var e=CodeMirror.getMode({indentUnit:2},"sass");e.indent=void 0,r("comment","[comment // this is a comment]","[comment also this is a comment]"),r("comment_multiline","[comment /* this is a comment]","[comment also this is a comment]"),r("variable","[variable-2 $page-width][operator :] [number 800][unit px]"),r("global_attributes","[tag body]"," [property font][operator :]"," [property family][operator :] [atom sans-serif]"," [property size][operator :] [number 30][unit em]"," [property weight][operator :] [atom bold]"),r("scoped_styles","[builtin #contents]"," [property width][operator :] [variable-2 $page-width]"," [builtin #sidebar]"," [property float][operator :] [atom right]"," [property width][operator :] [variable-2 $sidebar-width]"," [builtin #main]"," [property width][operator :] [variable-2 $page-width] [operator -] [variable-2 $sidebar-width]"," [property background][operator :] [variable-2 $primary-color]"," [tag h2]"," [property color][operator :] [keyword blue]"),r("import",'[def @import] [string "sass/variables"]',"[def @import] [tag sass][operator /][tag baz]"),r("def","[def @if] [variable-2 $foo] [def @else]"),r("tag_on_more_lines","[tag td],","[tag th]",' [property font-family][operator :] [string "Arial"], [atom serif]'),r("important","[qualifier .foo]"," [property text-decoration][operator :] [atom none] [keyword !important]","[tag h1]"," [property font-size][operator :] [number 2.5][unit em]"),r("selector","[tag h1][variable-3 :before],","[tag h2][variable-3 :before]",' [property content][operator :] [string "::"]'),r("definition_mixin_equal","[variable-2 $defined-bs-type][operator :] [atom border-box] [keyword !default]","[meta =bs][operator (][variable-2 $bs-type][operator :] [variable-2 $defined-bs-type][operator )]"," [meta -webkit-][property box-sizing][operator :] [variable-2 $bs-type]"," [property box-sizing][operator :] [variable-2 $bs-type]"),r("definition_mixin_with_space","[variable-2 $defined-bs-type][operator :] [atom border-box] [keyword !default]","[def @mixin] [tag bs][operator (][variable-2 $bs-type][operator :] [variable-2 $defined-bs-type][operator )] "," [meta -moz-][property box-sizing][operator :] [variable-2 $bs-type]"," [property box-sizing][operator :] [variable-2 $bs-type]"),r("numbers_start_dot_include_plus","[meta =button-links][operator (][variable-2 $button-base][operator :] [atom darken][operator (][variable-2 $color11], [number 10][operator %))]"," [property padding][operator :] [number .3][unit em] [number .6][unit em]"," [variable-3 +border-radius][operator (][number 8][unit px][operator )]"," [property background-color][operator :] [variable-2 $button-base]"),r("include","[qualifier .bar]"," [def @include] [tag border-radius][operator (][number 8][unit px][operator )]"),r("reference_parent","[qualifier .col]"," [property clear][operator :] [atom both]"," &[variable-3 :after]"," [property content][operator :] [string '']"," [property clear][operator :] [atom both]"),r("reference_parent_with_spaces","[tag section]"," [property border-left][operator :] [number 20][unit px] [atom transparent] [atom solid] "," &[qualifier .section3]"," [qualifier .title]"," [property color][operator :] [keyword white] "," [qualifier .vermas]"," [property display][operator :] [atom none]"),r("font_face","[def @font-face]"," [property font-family][operator :] [string 'icomoon']"," [property src][operator :] [atom url][operator (][string fonts/icomoon.ttf][operator )]")}();
|
readme.txt
CHANGED
@@ -1,21 +1,23 @@
|
|
1 |
=== SiteOrigin CSS ===
|
2 |
Tags: css, design, edit, customize
|
3 |
Requires at least: 3.9
|
4 |
-
Tested up to: 4.
|
5 |
Stable tag: 1.1.3
|
6 |
-
Build time: 2017-
|
7 |
License: GPLv2 or later
|
8 |
Contributors: gpriday
|
9 |
Donate link: https://siteorigin.com/downloads/contribution/
|
10 |
|
11 |
-
|
12 |
|
13 |
-
|
14 |
|
15 |
SiteOrigin CSS is the simple, yet powerful CSS editor for WordPress. It gives you visual controls that let you edit the look and feel of your site in real-time.
|
16 |
|
17 |
We've created a site editing experience that will suit both beginners and advanced users alike. Beginners will love the simple visual controls and real-time preview. Advanced users will love the code autocompletion that makes writing CSS faster than ever.
|
18 |
|
|
|
|
|
19 |
= Inspector =
|
20 |
|
21 |
The hardest part of editing your site's design using CSS is usually finding the correct selector to use. The powerful inspector that comes with SiteOrigin CSS makes this easy. While viewing a full preview of your site, just click on an element and it'll help you identify the best selector to use to target that element.
|
@@ -63,6 +65,11 @@ We offer free support on the [SiteOrigin support forums](https://siteorigin.com/
|
|
63 |
|
64 |
== Changelog ==
|
65 |
|
|
|
|
|
|
|
|
|
|
|
66 |
= 1.1.3 - 31 January 2017 =
|
67 |
* Removed leading slash in paths after plugin_dir_url().
|
68 |
* Updated to latest CodeMirror.
|
1 |
=== SiteOrigin CSS ===
|
2 |
Tags: css, design, edit, customize
|
3 |
Requires at least: 3.9
|
4 |
+
Tested up to: 4.8
|
5 |
Stable tag: 1.1.3
|
6 |
+
Build time: 2017-04-30T20:55:22+02:00
|
7 |
License: GPLv2 or later
|
8 |
Contributors: gpriday
|
9 |
Donate link: https://siteorigin.com/downloads/contribution/
|
10 |
|
11 |
+
SiteOrigin CSS is the simple, yet powerful CSS editor for WordPress. It gives you visual controls that let you edit the look and feel of your site in real-time.
|
12 |
|
13 |
+
== Description ==
|
14 |
|
15 |
SiteOrigin CSS is the simple, yet powerful CSS editor for WordPress. It gives you visual controls that let you edit the look and feel of your site in real-time.
|
16 |
|
17 |
We've created a site editing experience that will suit both beginners and advanced users alike. Beginners will love the simple visual controls and real-time preview. Advanced users will love the code autocompletion that makes writing CSS faster than ever.
|
18 |
|
19 |
+
[vimeo https://vimeo.com/129660380]
|
20 |
+
|
21 |
= Inspector =
|
22 |
|
23 |
The hardest part of editing your site's design using CSS is usually finding the correct selector to use. The powerful inspector that comes with SiteOrigin CSS makes this easy. While viewing a full preview of your site, just click on an element and it'll help you identify the best selector to use to target that element.
|
65 |
|
66 |
== Changelog ==
|
67 |
|
68 |
+
= 1.1.4 - 31 January 2017 =
|
69 |
+
* Updated CodeMirror to 2.25.2.
|
70 |
+
* Removed extra line padding.
|
71 |
+
* Better integration with WordPress.org translation.
|
72 |
+
|
73 |
= 1.1.3 - 31 January 2017 =
|
74 |
* Removed leading slash in paths after plugin_dir_url().
|
75 |
* Updated to latest CodeMirror.
|
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.1.
|
6 |
Author: SiteOrigin
|
7 |
Author URI: https://siteorigin.com
|
8 |
Plugin URI: https://siteorigin.com/css/
|
@@ -14,7 +14,7 @@ Text Domain: so-css
|
|
14 |
// Handle the legacy CSS editor that came with SiteOrigin themes
|
15 |
include plugin_dir_path( __FILE__ ) . 'inc/legacy.php';
|
16 |
|
17 |
-
define('SOCSS_VERSION', '1.1.
|
18 |
define('SOCSS_JS_SUFFIX', '.min');
|
19 |
|
20 |
/**
|
@@ -86,7 +86,7 @@ class SiteOrigin_CSS {
|
|
86 |
}
|
87 |
|
88 |
function set_plugin_textdomain(){
|
89 |
-
load_plugin_textdomain( 'so-css', false, plugin_dir_path( __FILE__ ) . '
|
90 |
}
|
91 |
|
92 |
/**
|
2 |
/*
|
3 |
Plugin Name: SiteOrigin CSS
|
4 |
Description: An advanced CSS editor from SiteOrigin.
|
5 |
+
Version: 1.1.4
|
6 |
Author: SiteOrigin
|
7 |
Author URI: https://siteorigin.com
|
8 |
Plugin URI: https://siteorigin.com/css/
|
14 |
// Handle the legacy CSS editor that came with SiteOrigin themes
|
15 |
include plugin_dir_path( __FILE__ ) . 'inc/legacy.php';
|
16 |
|
17 |
+
define('SOCSS_VERSION', '1.1.4');
|
18 |
define('SOCSS_JS_SUFFIX', '.min');
|
19 |
|
20 |
/**
|
86 |
}
|
87 |
|
88 |
function set_plugin_textdomain(){
|
89 |
+
load_plugin_textdomain( 'so-css', false, plugin_dir_path( __FILE__ ) . 'lang/' );
|
90 |
}
|
91 |
|
92 |
/**
|
tpl/page.php
CHANGED
@@ -27,15 +27,6 @@ $user = wp_get_current_user();
|
|
27 |
<div id="poststuff">
|
28 |
<div id="so-custom-css-info">
|
29 |
|
30 |
-
<?php if( $this->display_teaser() ) : ?>
|
31 |
-
<div class="postbox">
|
32 |
-
<h3 class="hndle"><span><?php _e('Get The Full Experience', 'so-css') ?></span></h3>
|
33 |
-
<div class="inside">
|
34 |
-
<?php printf( __( '%sSiteOrigin Premium%s adds a <strong>Google Web Font</strong> selector to SiteOrigin CSS so you can easily change any font.', 'so-css' ) , '<a href="https://siteorigin.com/downloads/premium/?featured_addon=plugins/web-font-selector" target="_blank">', '</a>' ); ?>
|
35 |
-
</div>
|
36 |
-
</div>
|
37 |
-
<?php endif; ?>
|
38 |
-
|
39 |
<?php if( !get_user_meta( $user->ID, 'socss_hide_gs' ) ) : ?>
|
40 |
<div class="postbox" id="so-custom-css-getting-started">
|
41 |
<h3 class="hndle">
|
27 |
<div id="poststuff">
|
28 |
<div id="so-custom-css-info">
|
29 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
30 |
<?php if( !get_user_meta( $user->ID, 'socss_hide_gs' ) ) : ?>
|
31 |
<div class="postbox" id="so-custom-css-getting-started">
|
32 |
<h3 class="hndle">
|