From e189570eaea1738d4a2243a1d8e84948c357e056 Mon Sep 17 00:00:00 2001 From: Christian Dinkel Date: Thu, 1 Jul 2021 11:16:15 +0200 Subject: [PATCH 1/7] test: update snapshots --- __snapshots__/open-scd.md | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/__snapshots__/open-scd.md b/__snapshots__/open-scd.md index 3b8d21ad1..1154a7305 100644 --- a/__snapshots__/open-scd.md +++ b/__snapshots__/open-scd.md @@ -54,9 +54,8 @@ + +
+ Save project +
+
- + Date: Wed, 23 Jun 2021 15:08:37 +0200 Subject: [PATCH 2/7] feat(wizard-dialog): add code editor to wizards --- package-lock.json | 5 + package.json | 1 + public/ace/ext-searchbox.js | 8 ++ public/ace/mode-xml.js | 8 ++ public/ace/theme-solarized_dark.js | 8 ++ public/ace/theme-solarized_light.js | 8 ++ public/ace/worker-xml.js | 1 + .../communication/connectedap-editor.ts | 1 + .../communication/subnetwork-editor.ts | 6 +- src/editors/substation/bay-editor.ts | 47 +++++----- .../substation/conducting-equipment-editor.ts | 4 + src/editors/substation/lnodewizard.ts | 2 + src/editors/substation/substation-editor.ts | 4 + .../substation/voltage-level-editor.ts | 6 +- src/editors/templates/datype-wizards.ts | 2 + src/editors/templates/dotype-wizards.ts | 3 + src/editors/templates/enumtype-wizard.ts | 4 +- src/editors/templates/lnodetype-wizard.ts | 2 + src/foundation.ts | 26 +++++- src/menu/NewProject.ts | 2 +- src/wizard-dialog.ts | 92 +++++++++++++++++-- 21 files changed, 201 insertions(+), 39 deletions(-) create mode 100644 public/ace/ext-searchbox.js create mode 100644 public/ace/mode-xml.js create mode 100644 public/ace/theme-solarized_dark.js create mode 100644 public/ace/theme-solarized_light.js create mode 100644 public/ace/worker-xml.js diff --git a/package-lock.json b/package-lock.json index 45f5459ce..4bc4207df 100644 --- a/package-lock.json +++ b/package-lock.json @@ -5466,6 +5466,11 @@ "negotiator": "0.6.2" } }, + "ace-custom-element": { + "version": "1.6.5", + "resolved": "https://registry.npmjs.org/ace-custom-element/-/ace-custom-element-1.6.5.tgz", + "integrity": "sha512-xU/9r94WKwjwEOjdfs6oVk2Dqc6X63eF2ECvKIMm/JCK1PDbXXdBYi5sQx110tR2sY4f96iXxyvscfT9qeI1RQ==" + }, "acorn": { "version": "7.4.1", "resolved": "https://registry.npmjs.org/acorn/-/acorn-7.4.1.tgz", diff --git a/package.json b/package.json index c623fbbc4..6423a3cf2 100644 --- a/package.json +++ b/package.json @@ -35,6 +35,7 @@ "@material/mwc-tab-bar": "^0.21.0", "@material/mwc-textfield": "^0.21.0", "@material/mwc-top-app-bar-fixed": "^0.21.0", + "ace-custom-element": "^1.6.5", "carehtml": "^0.1.3", "lit-element": "2.4.0", "lit-html": "1.3.0", diff --git a/public/ace/ext-searchbox.js b/public/ace/ext-searchbox.js new file mode 100644 index 000000000..fda92f100 --- /dev/null +++ b/public/ace/ext-searchbox.js @@ -0,0 +1,8 @@ +ace.define("ace/ext/searchbox",["require","exports","module","ace/lib/dom","ace/lib/lang","ace/lib/event","ace/keyboard/hash_handler","ace/lib/keys"],function(e,t,n){"use strict";var r=e("../lib/dom"),i=e("../lib/lang"),s=e("../lib/event"),o='.ace_search {background-color: #ddd;color: #666;border: 1px solid #cbcbcb;border-top: 0 none;overflow: hidden;margin: 0;padding: 4px 6px 0 4px;position: absolute;top: 0;z-index: 99;white-space: normal;}.ace_search.left {border-left: 0 none;border-radius: 0px 0px 5px 0px;left: 0;}.ace_search.right {border-radius: 0px 0px 0px 5px;border-right: 0 none;right: 0;}.ace_search_form, .ace_replace_form {margin: 0 20px 4px 0;overflow: hidden;line-height: 1.9;}.ace_replace_form {margin-right: 0;}.ace_search_form.ace_nomatch {outline: 1px solid red;}.ace_search_field {border-radius: 3px 0 0 3px;background-color: white;color: black;border: 1px solid #cbcbcb;border-right: 0 none;outline: 0;padding: 0;font-size: inherit;margin: 0;line-height: inherit;padding: 0 6px;min-width: 17em;vertical-align: top;min-height: 1.8em;box-sizing: content-box;}.ace_searchbtn {border: 1px solid #cbcbcb;line-height: inherit;display: inline-block;padding: 0 6px;background: #fff;border-right: 0 none;border-left: 1px solid #dcdcdc;cursor: pointer;margin: 0;position: relative;color: #666;}.ace_searchbtn:last-child {border-radius: 0 3px 3px 0;border-right: 1px solid #cbcbcb;}.ace_searchbtn:disabled {background: none;cursor: default;}.ace_searchbtn:hover {background-color: #eef1f6;}.ace_searchbtn.prev, .ace_searchbtn.next {padding: 0px 0.7em}.ace_searchbtn.prev:after, .ace_searchbtn.next:after {content: "";border: solid 2px #888;width: 0.5em;height: 0.5em;border-width: 2px 0 0 2px;display:inline-block;transform: rotate(-45deg);}.ace_searchbtn.next:after {border-width: 0 2px 2px 0 ;}.ace_searchbtn_close {background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA4AAAAcCAYAAABRVo5BAAAAZ0lEQVR42u2SUQrAMAhDvazn8OjZBilCkYVVxiis8H4CT0VrAJb4WHT3C5xU2a2IQZXJjiQIRMdkEoJ5Q2yMqpfDIo+XY4k6h+YXOyKqTIj5REaxloNAd0xiKmAtsTHqW8sR2W5f7gCu5nWFUpVjZwAAAABJRU5ErkJggg==) no-repeat 50% 0;border-radius: 50%;border: 0 none;color: #656565;cursor: pointer;font: 16px/16px Arial;padding: 0;height: 14px;width: 14px;top: 9px;right: 7px;position: absolute;}.ace_searchbtn_close:hover {background-color: #656565;background-position: 50% 100%;color: white;}.ace_button {margin-left: 2px;cursor: pointer;-webkit-user-select: none;-moz-user-select: none;-o-user-select: none;-ms-user-select: none;user-select: none;overflow: hidden;opacity: 0.7;border: 1px solid rgba(100,100,100,0.23);padding: 1px;box-sizing: border-box!important;color: black;}.ace_button:hover {background-color: #eee;opacity:1;}.ace_button:active {background-color: #ddd;}.ace_button.checked {border-color: #3399ff;opacity:1;}.ace_search_options{margin-bottom: 3px;text-align: right;-webkit-user-select: none;-moz-user-select: none;-o-user-select: none;-ms-user-select: none;user-select: none;clear: both;}.ace_search_counter {float: left;font-family: arial;padding: 0 8px;}',u=e("../keyboard/hash_handler").HashHandler,a=e("../lib/keys"),f=999;r.importCssString(o,"ace_searchbox");var l=function(e,t,n){var i=r.createElement("div");r.buildDom(["div",{"class":"ace_search right"},["span",{action:"hide","class":"ace_searchbtn_close"}],["div",{"class":"ace_search_form"},["input",{"class":"ace_search_field",placeholder:"Search for",spellcheck:"false"}],["span",{action:"findPrev","class":"ace_searchbtn prev"},"\u200b"],["span",{action:"findNext","class":"ace_searchbtn next"},"\u200b"],["span",{action:"findAll","class":"ace_searchbtn",title:"Alt-Enter"},"All"]],["div",{"class":"ace_replace_form"},["input",{"class":"ace_search_field",placeholder:"Replace with",spellcheck:"false"}],["span",{action:"replaceAndFindNext","class":"ace_searchbtn"},"Replace"],["span",{action:"replaceAll","class":"ace_searchbtn"},"All"]],["div",{"class":"ace_search_options"},["span",{action:"toggleReplace","class":"ace_button",title:"Toggle Replace mode",style:"float:left;margin-top:-2px;padding:0 5px;"},"+"],["span",{"class":"ace_search_counter"}],["span",{action:"toggleRegexpMode","class":"ace_button",title:"RegExp Search"},".*"],["span",{action:"toggleCaseSensitive","class":"ace_button",title:"CaseSensitive Search"},"Aa"],["span",{action:"toggleWholeWords","class":"ace_button",title:"Whole Word Search"},"\\b"],["span",{action:"searchInSelection","class":"ace_button",title:"Search In Selection"},"S"]]],i),this.element=i.firstChild,this.setSession=this.setSession.bind(this),this.$init(),this.setEditor(e),r.importCssString(o,"ace_searchbox",e.container)};(function(){this.setEditor=function(e){e.searchBox=this,e.renderer.scroller.appendChild(this.element),this.editor=e},this.setSession=function(e){this.searchRange=null,this.$syncOptions(!0)},this.$initElements=function(e){this.searchBox=e.querySelector(".ace_search_form"),this.replaceBox=e.querySelector(".ace_replace_form"),this.searchOption=e.querySelector("[action=searchInSelection]"),this.replaceOption=e.querySelector("[action=toggleReplace]"),this.regExpOption=e.querySelector("[action=toggleRegexpMode]"),this.caseSensitiveOption=e.querySelector("[action=toggleCaseSensitive]"),this.wholeWordOption=e.querySelector("[action=toggleWholeWords]"),this.searchInput=this.searchBox.querySelector(".ace_search_field"),this.replaceInput=this.replaceBox.querySelector(".ace_search_field"),this.searchCounter=e.querySelector(".ace_search_counter")},this.$init=function(){var e=this.element;this.$initElements(e);var t=this;s.addListener(e,"mousedown",function(e){setTimeout(function(){t.activeInput.focus()},0),s.stopPropagation(e)}),s.addListener(e,"click",function(e){var n=e.target||e.srcElement,r=n.getAttribute("action");r&&t[r]?t[r]():t.$searchBarKb.commands[r]&&t.$searchBarKb.commands[r].exec(t),s.stopPropagation(e)}),s.addCommandKeyListener(e,function(e,n,r){var i=a.keyCodeToString(r),o=t.$searchBarKb.findKeyCommand(n,i);o&&o.exec&&(o.exec(t),s.stopEvent(e))}),this.$onChange=i.delayedCall(function(){t.find(!1,!1)}),s.addListener(this.searchInput,"input",function(){t.$onChange.schedule(20)}),s.addListener(this.searchInput,"focus",function(){t.activeInput=t.searchInput,t.searchInput.value&&t.highlight()}),s.addListener(this.replaceInput,"focus",function(){t.activeInput=t.replaceInput,t.searchInput.value&&t.highlight()})},this.$closeSearchBarKb=new u([{bindKey:"Esc",name:"closeSearchBar",exec:function(e){e.searchBox.hide()}}]),this.$searchBarKb=new u,this.$searchBarKb.bindKeys({"Ctrl-f|Command-f":function(e){var t=e.isReplace=!e.isReplace;e.replaceBox.style.display=t?"":"none",e.replaceOption.checked=!1,e.$syncOptions(),e.searchInput.focus()},"Ctrl-H|Command-Option-F":function(e){if(e.editor.getReadOnly())return;e.replaceOption.checked=!0,e.$syncOptions(),e.replaceInput.focus()},"Ctrl-G|Command-G":function(e){e.findNext()},"Ctrl-Shift-G|Command-Shift-G":function(e){e.findPrev()},esc:function(e){setTimeout(function(){e.hide()})},Return:function(e){e.activeInput==e.replaceInput&&e.replace(),e.findNext()},"Shift-Return":function(e){e.activeInput==e.replaceInput&&e.replace(),e.findPrev()},"Alt-Return":function(e){e.activeInput==e.replaceInput&&e.replaceAll(),e.findAll()},Tab:function(e){(e.activeInput==e.replaceInput?e.searchInput:e.replaceInput).focus()}}),this.$searchBarKb.addCommands([{name:"toggleRegexpMode",bindKey:{win:"Alt-R|Alt-/",mac:"Ctrl-Alt-R|Ctrl-Alt-/"},exec:function(e){e.regExpOption.checked=!e.regExpOption.checked,e.$syncOptions()}},{name:"toggleCaseSensitive",bindKey:{win:"Alt-C|Alt-I",mac:"Ctrl-Alt-R|Ctrl-Alt-I"},exec:function(e){e.caseSensitiveOption.checked=!e.caseSensitiveOption.checked,e.$syncOptions()}},{name:"toggleWholeWords",bindKey:{win:"Alt-B|Alt-W",mac:"Ctrl-Alt-B|Ctrl-Alt-W"},exec:function(e){e.wholeWordOption.checked=!e.wholeWordOption.checked,e.$syncOptions()}},{name:"toggleReplace",exec:function(e){e.replaceOption.checked=!e.replaceOption.checked,e.$syncOptions()}},{name:"searchInSelection",exec:function(e){e.searchOption.checked=!e.searchRange,e.setSearchRange(e.searchOption.checked&&e.editor.getSelectionRange()),e.$syncOptions()}}]),this.setSearchRange=function(e){this.searchRange=e,e?this.searchRangeMarker=this.editor.session.addMarker(e,"ace_active-line"):this.searchRangeMarker&&(this.editor.session.removeMarker(this.searchRangeMarker),this.searchRangeMarker=null)},this.$syncOptions=function(e){r.setCssClass(this.replaceOption,"checked",this.searchRange),r.setCssClass(this.searchOption,"checked",this.searchOption.checked),this.replaceOption.textContent=this.replaceOption.checked?"-":"+",r.setCssClass(this.regExpOption,"checked",this.regExpOption.checked),r.setCssClass(this.wholeWordOption,"checked",this.wholeWordOption.checked),r.setCssClass(this.caseSensitiveOption,"checked",this.caseSensitiveOption.checked);var t=this.editor.getReadOnly();this.replaceOption.style.display=t?"none":"",this.replaceBox.style.display=this.replaceOption.checked&&!t?"":"none",this.find(!1,!1,e)},this.highlight=function(e){this.editor.session.highlight(e||this.editor.$search.$options.re),this.editor.renderer.updateBackMarkers()},this.find=function(e,t,n){var i=this.editor.find(this.searchInput.value,{skipCurrent:e,backwards:t,wrap:!0,regExp:this.regExpOption.checked,caseSensitive:this.caseSensitiveOption.checked,wholeWord:this.wholeWordOption.checked,preventScroll:n,range:this.searchRange}),s=!i&&this.searchInput.value;r.setCssClass(this.searchBox,"ace_nomatch",s),this.editor._emit("findSearchBox",{match:!s}),this.highlight(),this.updateCounter()},this.updateCounter=function(){var e=this.editor,t=e.$search.$options.re,n=0,r=0;if(t){var i=this.searchRange?e.session.getTextRange(this.searchRange):e.getValue(),s=e.session.doc.positionToIndex(e.selection.anchor);this.searchRange&&(s-=e.session.doc.positionToIndex(this.searchRange.start));var o=t.lastIndex=0,u;while(u=t.exec(i)){n++,o=u.index,o<=s&&r++;if(n>f)break;if(!u[0]){t.lastIndex=o+=1;if(o>=i.length)break}}}this.searchCounter.textContent=r+" of "+(n>f?f+"+":n)},this.findNext=function(){this.find(!0,!1)},this.findPrev=function(){this.find(!0,!0)},this.findAll=function(){var e=this.editor.findAll(this.searchInput.value,{regExp:this.regExpOption.checked,caseSensitive:this.caseSensitiveOption.checked,wholeWord:this.wholeWordOption.checked}),t=!e&&this.searchInput.value;r.setCssClass(this.searchBox,"ace_nomatch",t),this.editor._emit("findSearchBox",{match:!t}),this.highlight(),this.hide()},this.replace=function(){this.editor.getReadOnly()||this.editor.replace(this.replaceInput.value)},this.replaceAndFindNext=function(){this.editor.getReadOnly()||(this.editor.replace(this.replaceInput.value),this.findNext())},this.replaceAll=function(){this.editor.getReadOnly()||this.editor.replaceAll(this.replaceInput.value)},this.hide=function(){this.active=!1,this.setSearchRange(null),this.editor.off("changeSession",this.setSession),this.element.style.display="none",this.editor.keyBinding.removeKeyboardHandler(this.$closeSearchBarKb),this.editor.focus()},this.show=function(e,t){this.active=!0,this.editor.on("changeSession",this.setSession),this.element.style.display="",this.replaceOption.checked=t,e&&(this.searchInput.value=e),this.searchInput.focus(),this.searchInput.select(),this.editor.keyBinding.addKeyboardHandler(this.$closeSearchBarKb),this.$syncOptions(!0)},this.isFocused=function(){var e=document.activeElement;return e==this.searchInput||e==this.replaceInput}}).call(l.prototype),t.SearchBox=l,t.Search=function(e,t){var n=e.searchBox||new l(e);n.show(e.session.getTextRange(),t)}}); (function() { + ace.require(["ace/ext/searchbox"], function(m) { + if (typeof module == "object" && typeof exports == "object" && module) { + module.exports = m; + } + }); + })(); + \ No newline at end of file diff --git a/public/ace/mode-xml.js b/public/ace/mode-xml.js new file mode 100644 index 000000000..709c38bf5 --- /dev/null +++ b/public/ace/mode-xml.js @@ -0,0 +1,8 @@ +ace.define("ace/mode/xml_highlight_rules",["require","exports","module","ace/lib/oop","ace/mode/text_highlight_rules"],function(e,t,n){"use strict";var r=e("../lib/oop"),i=e("./text_highlight_rules").TextHighlightRules,s=function(e){var t="[_:a-zA-Z\u00c0-\uffff][-_:.a-zA-Z0-9\u00c0-\uffff]*";this.$rules={start:[{token:"string.cdata.xml",regex:"<\\!\\[CDATA\\[",next:"cdata"},{token:["punctuation.instruction.xml","keyword.instruction.xml"],regex:"(<\\?)("+t+")",next:"processing_instruction"},{token:"comment.start.xml",regex:"<\\!--",next:"comment"},{token:["xml-pe.doctype.xml","xml-pe.doctype.xml"],regex:"(<\\!)(DOCTYPE)(?=[\\s])",next:"doctype",caseInsensitive:!0},{include:"tag"},{token:"text.end-tag-open.xml",regex:"",next:"start"}],doctype:[{include:"whitespace"},{include:"string"},{token:"xml-pe.doctype.xml",regex:">",next:"start"},{token:"xml-pe.xml",regex:"[-_a-zA-Z0-9:]+"},{token:"punctuation.int-subset",regex:"\\[",push:"int_subset"}],int_subset:[{token:"text.xml",regex:"\\s+"},{token:"punctuation.int-subset.xml",regex:"]",next:"pop"},{token:["punctuation.markup-decl.xml","keyword.markup-decl.xml"],regex:"(<\\!)("+t+")",push:[{token:"text",regex:"\\s+"},{token:"punctuation.markup-decl.xml",regex:">",next:"pop"},{include:"string"}]}],cdata:[{token:"string.cdata.xml",regex:"\\]\\]>",next:"start"},{token:"text.xml",regex:"\\s+"},{token:"text.xml",regex:"(?:[^\\]]|\\](?!\\]>))+"}],comment:[{token:"comment.end.xml",regex:"-->",next:"start"},{defaultToken:"comment.xml"}],reference:[{token:"constant.language.escape.reference.xml",regex:"(?:&#[0-9]+;)|(?:&#x[0-9a-fA-F]+;)|(?:&[a-zA-Z0-9_:\\.-]+;)"}],attr_reference:[{token:"constant.language.escape.reference.attribute-value.xml",regex:"(?:&#[0-9]+;)|(?:&#x[0-9a-fA-F]+;)|(?:&[a-zA-Z0-9_:\\.-]+;)"}],tag:[{token:["meta.tag.punctuation.tag-open.xml","meta.tag.punctuation.end-tag-open.xml","meta.tag.tag-name.xml"],regex:"(?:(<)|(",next:"start"}]}],tag_whitespace:[{token:"text.tag-whitespace.xml",regex:"\\s+"}],whitespace:[{token:"text.whitespace.xml",regex:"\\s+"}],string:[{token:"string.xml",regex:"'",push:[{token:"string.xml",regex:"'",next:"pop"},{defaultToken:"string.xml"}]},{token:"string.xml",regex:'"',push:[{token:"string.xml",regex:'"',next:"pop"},{defaultToken:"string.xml"}]}],attributes:[{token:"entity.other.attribute-name.xml",regex:t},{token:"keyword.operator.attribute-equals.xml",regex:"="},{include:"tag_whitespace"},{include:"attribute_value"}],attribute_value:[{token:"string.attribute-value.xml",regex:"'",push:[{token:"string.attribute-value.xml",regex:"'",next:"pop"},{include:"attr_reference"},{defaultToken:"string.attribute-value.xml"}]},{token:"string.attribute-value.xml",regex:'"',push:[{token:"string.attribute-value.xml",regex:'"',next:"pop"},{include:"attr_reference"},{defaultToken:"string.attribute-value.xml"}]}]},this.constructor===s&&this.normalizeRules()};(function(){this.embedTagRules=function(e,t,n){this.$rules.tag.unshift({token:["meta.tag.punctuation.tag-open.xml","meta.tag."+n+".tag-name.xml"],regex:"(<)("+n+"(?=\\s|>|$))",next:[{include:"attributes"},{token:"meta.tag.punctuation.tag-close.xml",regex:"/?>",next:t+"start"}]}),this.$rules[n+"-end"]=[{include:"attributes"},{token:"meta.tag.punctuation.tag-close.xml",regex:"/?>",next:"start",onMatch:function(e,t,n){return n.splice(0),this.token}}],this.embedRules(e,t,[{token:["meta.tag.punctuation.end-tag-open.xml","meta.tag."+n+".tag-name.xml"],regex:"(|$))",next:n+"-end"},{token:"string.cdata.xml",regex:"<\\!\\[CDATA\\["},{token:"string.cdata.xml",regex:"\\]\\]>"}])}}).call(i.prototype),r.inherits(s,i),t.XmlHighlightRules=s}),ace.define("ace/mode/behaviour/xml",["require","exports","module","ace/lib/oop","ace/mode/behaviour","ace/token_iterator","ace/lib/lang"],function(e,t,n){"use strict";function u(e,t){return e&&e.type.lastIndexOf(t+".xml")>-1}var r=e("../../lib/oop"),i=e("../behaviour").Behaviour,s=e("../../token_iterator").TokenIterator,o=e("../../lib/lang"),a=function(){this.add("string_dquotes","insertion",function(e,t,n,r,i){if(i=='"'||i=="'"){var o=i,a=r.doc.getTextRange(n.getSelectionRange());if(a!==""&&a!=="'"&&a!='"'&&n.getWrapBehavioursEnabled())return{text:o+a+o,selection:!1};var f=n.getCursorPosition(),l=r.doc.getLine(f.row),c=l.substring(f.column,f.column+1),h=new s(r,f.row,f.column),p=h.getCurrentToken();if(c==o&&(u(p,"attribute-value")||u(p,"string")))return{text:"",selection:[1,1]};p||(p=h.stepBackward());if(!p)return;while(u(p,"tag-whitespace")||u(p,"whitespace"))p=h.stepBackward();var d=!c||c.match(/\s/);if(u(p,"attribute-equals")&&(d||c==">")||u(p,"decl-attribute-equals")&&(d||c=="?"))return{text:o+o,selection:[1,1]}}}),this.add("string_dquotes","deletion",function(e,t,n,r,i){var s=r.doc.getTextRange(i);if(!i.isMultiLine()&&(s=='"'||s=="'")){var o=r.doc.getLine(i.start.row),u=o.substring(i.start.column+1,i.start.column+2);if(u==s)return i.end.column++,i}}),this.add("autoclosing","insertion",function(e,t,n,r,i){if(i==">"){var o=n.getSelectionRange().start,a=new s(r,o.row,o.column),f=a.getCurrentToken()||a.stepBackward();if(!f||!(u(f,"tag-name")||u(f,"tag-whitespace")||u(f,"attribute-name")||u(f,"attribute-equals")||u(f,"attribute-value")))return;if(u(f,"reference.attribute-value"))return;if(u(f,"attribute-value")){var l=a.getCurrentTokenColumn()+f.value.length;if(o.column/.test(r.getLine(o.row).slice(o.column)))return;while(!u(f,"tag-name")){f=a.stepBackward();if(f.value=="<"){f=a.stepForward();break}}var h=a.getCurrentTokenRow(),p=a.getCurrentTokenColumn();if(u(a.stepBackward(),"end-tag-open"))return;var d=f.value;h==o.row&&(d=d.substring(0,o.column-p));if(this.voidElements.hasOwnProperty(d.toLowerCase()))return;return{text:">",selection:[1,1]}}}),this.add("autoindent","insertion",function(e,t,n,r,i){if(i=="\n"){var o=n.getCursorPosition(),u=r.getLine(o.row),a=new s(r,o.row,o.column),f=a.getCurrentToken();if(f&&f.type.indexOf("tag-close")!==-1){if(f.value=="/>")return;while(f&&f.type.indexOf("tag-name")===-1)f=a.stepBackward();if(!f)return;var l=f.value,c=a.getCurrentTokenRow();f=a.stepBackward();if(!f||f.type.indexOf("end-tag")!==-1)return;if(this.voidElements&&!this.voidElements[l]){var h=r.getTokenAt(o.row,o.column+1),u=r.getLine(c),p=this.$getIndent(u),d=p+r.getTabString();return h&&h.value==="-1}var r=e("../../lib/oop"),i=e("../../lib/lang"),s=e("../../range").Range,o=e("./fold_mode").FoldMode,u=e("../../token_iterator").TokenIterator,a=t.FoldMode=function(e,t){o.call(this),this.voidElements=e||{},this.optionalEndTags=r.mixin({},this.voidElements),t&&r.mixin(this.optionalEndTags,t)};r.inherits(a,o);var f=function(){this.tagName="",this.closing=!1,this.selfClosing=!1,this.start={row:0,column:0},this.end={row:0,column:0}};(function(){this.getFoldWidget=function(e,t,n){var r=this._getFirstTagInLine(e,n);return r?r.closing||!r.tagName&&r.selfClosing?t=="markbeginend"?"end":"":!r.tagName||r.selfClosing||this.voidElements.hasOwnProperty(r.tagName.toLowerCase())?"":this._findEndTagInLine(e,n,r.tagName,r.end.column)?"":"start":this.getCommentFoldWidget(e,n)},this.getCommentFoldWidget=function(e,t){return/comment/.test(e.getState(t))&&/";break}}return r}if(l(s,"tag-close"))return r.selfClosing=s.value=="/>",r;r.start.column+=s.value.length}return null},this._findEndTagInLine=function(e,t,n,r){var i=e.getTokens(t),s=0;for(var o=0;o",n.end.row=e.getCurrentTokenRow(),n.end.column=e.getCurrentTokenColumn()+t.value.length,e.stepForward(),n;while(t=e.stepForward());return null},this._readTagBackward=function(e){var t=e.getCurrentToken();if(!t)return null;var n=new f;do{if(l(t,"tag-open"))return n.closing=l(t,"end-tag-open"),n.start.row=e.getCurrentTokenRow(),n.start.column=e.getCurrentTokenColumn(),e.stepBackward(),n;l(t,"tag-name")?n.tagName=t.value:l(t,"tag-close")&&(n.selfClosing=t.value=="/>",n.end.row=e.getCurrentTokenRow(),n.end.column=e.getCurrentTokenColumn()+t.value.length)}while(t=e.stepBackward());return null},this._pop=function(e,t){while(e.length){var n=e[e.length-1];if(!t||n.tagName==t.tagName)return e.pop();if(this.optionalEndTags.hasOwnProperty(n.tagName)){e.pop();continue}return null}},this.getFoldWidgetRange=function(e,t,n){var r=this._getFirstTagInLine(e,n);if(!r)return this.getCommentFoldWidget(e,n)&&e.getCommentFoldRange(n,e.getLine(n).length);var i=r.closing||r.selfClosing,o=[],a;if(!i){var f=new u(e,n,r.start.column),l={row:n,column:r.start.column+r.tagName.length+2};r.start.row==r.end.row&&(l.column=r.end.column);while(a=this._readTagForward(f)){if(a.selfClosing){if(!o.length)return a.start.column+=a.tagName.length+2,a.end.column-=2,s.fromPoints(a.start,a.end);continue}if(a.closing){this._pop(o,a);if(o.length==0)return s.fromPoints(l,a.start)}else o.push(a)}}else{var f=new u(e,n,r.end.column),c={row:n,column:r.start.column};while(a=this._readTagBackward(f)){if(a.selfClosing){if(!o.length)return a.start.column+=a.tagName.length+2,a.end.column-=2,s.fromPoints(a.start,a.end);continue}if(!a.closing){this._pop(o,a);if(o.length==0)return a.start.column+=a.tagName.length+2,a.start.row==a.end.row&&a.start.column"},this.createWorker=function(e){var t=new f(["ace"],"ace/mode/xml_worker","Worker");return t.attachToDocument(e.getDocument()),t.on("error",function(t){e.setAnnotations(t.data)}),t.on("terminate",function(){e.clearAnnotations()}),t},this.$id="ace/mode/xml"}.call(l.prototype),t.Mode=l}); (function() { + ace.require(["ace/mode/xml"], function(m) { + if (typeof module == "object" && typeof exports == "object" && module) { + module.exports = m; + } + }); + })(); + \ No newline at end of file diff --git a/public/ace/theme-solarized_dark.js b/public/ace/theme-solarized_dark.js new file mode 100644 index 000000000..ee1ac318f --- /dev/null +++ b/public/ace/theme-solarized_dark.js @@ -0,0 +1,8 @@ +ace.define("ace/theme/solarized_dark",["require","exports","module","ace/lib/dom"],function(e,t,n){t.isDark=!0,t.cssClass="ace-solarized-dark",t.cssText=".ace-solarized-dark .ace_gutter {background: #01313f;color: #d0edf7}.ace-solarized-dark .ace_print-margin {width: 1px;background: #33555E}.ace-solarized-dark {background-color: #002B36;color: #93A1A1}.ace-solarized-dark .ace_entity.ace_other.ace_attribute-name,.ace-solarized-dark .ace_storage {color: #93A1A1}.ace-solarized-dark .ace_cursor,.ace-solarized-dark .ace_string.ace_regexp {color: #D30102}.ace-solarized-dark .ace_marker-layer .ace_active-line,.ace-solarized-dark .ace_marker-layer .ace_selection {background: rgba(255, 255, 255, 0.1)}.ace-solarized-dark.ace_multiselect .ace_selection.ace_start {box-shadow: 0 0 3px 0px #002B36;}.ace-solarized-dark .ace_marker-layer .ace_step {background: rgb(102, 82, 0)}.ace-solarized-dark .ace_marker-layer .ace_bracket {margin: -1px 0 0 -1px;border: 1px solid rgba(147, 161, 161, 0.50)}.ace-solarized-dark .ace_gutter-active-line {background-color: #0d3440}.ace-solarized-dark .ace_marker-layer .ace_selected-word {border: 1px solid #073642}.ace-solarized-dark .ace_invisible {color: rgba(147, 161, 161, 0.50)}.ace-solarized-dark .ace_keyword,.ace-solarized-dark .ace_meta,.ace-solarized-dark .ace_support.ace_class,.ace-solarized-dark .ace_support.ace_type {color: #859900}.ace-solarized-dark .ace_constant.ace_character,.ace-solarized-dark .ace_constant.ace_other {color: #CB4B16}.ace-solarized-dark .ace_constant.ace_language {color: #B58900}.ace-solarized-dark .ace_constant.ace_numeric {color: #D33682}.ace-solarized-dark .ace_fold {background-color: #268BD2;border-color: #93A1A1}.ace-solarized-dark .ace_entity.ace_name.ace_function,.ace-solarized-dark .ace_entity.ace_name.ace_tag,.ace-solarized-dark .ace_support.ace_function,.ace-solarized-dark .ace_variable,.ace-solarized-dark .ace_variable.ace_language {color: #268BD2}.ace-solarized-dark .ace_string {color: #2AA198}.ace-solarized-dark .ace_comment {font-style: italic;color: #657B83}.ace-solarized-dark .ace_indent-guide {background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAACCAYAAACZgbYnAAAAEklEQVQImWNg0Db1ZVCxc/sPAAd4AlUHlLenAAAAAElFTkSuQmCC) right repeat-y}";var r=e("../lib/dom");r.importCssString(t.cssText,t.cssClass)}); (function() { + ace.require(["ace/theme/solarized_dark"], function(m) { + if (typeof module == "object" && typeof exports == "object" && module) { + module.exports = m; + } + }); + })(); + \ No newline at end of file diff --git a/public/ace/theme-solarized_light.js b/public/ace/theme-solarized_light.js new file mode 100644 index 000000000..a66ca4c6a --- /dev/null +++ b/public/ace/theme-solarized_light.js @@ -0,0 +1,8 @@ +ace.define("ace/theme/solarized_light",["require","exports","module","ace/lib/dom"],function(e,t,n){t.isDark=!1,t.cssClass="ace-solarized-light",t.cssText=".ace-solarized-light .ace_gutter {background: #fbf1d3;color: #333}.ace-solarized-light .ace_print-margin {width: 1px;background: #e8e8e8}.ace-solarized-light {background-color: #FDF6E3;color: #586E75}.ace-solarized-light .ace_cursor {color: #000000}.ace-solarized-light .ace_marker-layer .ace_selection {background: rgba(7, 54, 67, 0.09)}.ace-solarized-light.ace_multiselect .ace_selection.ace_start {box-shadow: 0 0 3px 0px #FDF6E3;}.ace-solarized-light .ace_marker-layer .ace_step {background: rgb(255, 255, 0)}.ace-solarized-light .ace_marker-layer .ace_bracket {margin: -1px 0 0 -1px;border: 1px solid rgba(147, 161, 161, 0.50)}.ace-solarized-light .ace_marker-layer .ace_active-line {background: #EEE8D5}.ace-solarized-light .ace_gutter-active-line {background-color : #EDE5C1}.ace-solarized-light .ace_marker-layer .ace_selected-word {border: 1px solid #7f9390}.ace-solarized-light .ace_invisible {color: rgba(147, 161, 161, 0.50)}.ace-solarized-light .ace_keyword,.ace-solarized-light .ace_meta,.ace-solarized-light .ace_support.ace_class,.ace-solarized-light .ace_support.ace_type {color: #859900}.ace-solarized-light .ace_constant.ace_character,.ace-solarized-light .ace_constant.ace_other {color: #CB4B16}.ace-solarized-light .ace_constant.ace_language {color: #B58900}.ace-solarized-light .ace_constant.ace_numeric {color: #D33682}.ace-solarized-light .ace_fold {background-color: #268BD2;border-color: #586E75}.ace-solarized-light .ace_entity.ace_name.ace_function,.ace-solarized-light .ace_entity.ace_name.ace_tag,.ace-solarized-light .ace_support.ace_function,.ace-solarized-light .ace_variable,.ace-solarized-light .ace_variable.ace_language {color: #268BD2}.ace-solarized-light .ace_storage {color: #073642}.ace-solarized-light .ace_string {color: #2AA198}.ace-solarized-light .ace_string.ace_regexp {color: #D30102}.ace-solarized-light .ace_comment,.ace-solarized-light .ace_entity.ace_other.ace_attribute-name {color: #93A1A1}.ace-solarized-light .ace_indent-guide {background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAACCAYAAACZgbYnAAAAEklEQVQImWNgYGBgYHjy8NJ/AAjgA5fzQUmBAAAAAElFTkSuQmCC) right repeat-y}";var r=e("../lib/dom");r.importCssString(t.cssText,t.cssClass)}); (function() { + ace.require(["ace/theme/solarized_light"], function(m) { + if (typeof module == "object" && typeof exports == "object" && module) { + module.exports = m; + } + }); + })(); + \ No newline at end of file diff --git a/public/ace/worker-xml.js b/public/ace/worker-xml.js new file mode 100644 index 000000000..e3ad3018e --- /dev/null +++ b/public/ace/worker-xml.js @@ -0,0 +1 @@ +"no use strict";!function(e){function t(e,t){var n=e,r="";while(n){var i=t[n];if(typeof i=="string")return i+r;if(i)return i.location.replace(/\/*$/,"/")+(r||i.main||i.name);if(i===!1)return"";var s=n.lastIndexOf("/");if(s===-1)break;r=n.substr(s)+r,n=n.slice(0,s)}return e}if(typeof e.window!="undefined"&&e.document)return;if(e.require&&e.define)return;e.console||(e.console=function(){var e=Array.prototype.slice.call(arguments,0);postMessage({type:"log",data:e})},e.console.error=e.console.warn=e.console.log=e.console.trace=e.console),e.window=e,e.ace=e,e.onerror=function(e,t,n,r,i){postMessage({type:"error",data:{message:e,data:i.data,file:t,line:n,col:r,stack:i.stack}})},e.normalizeModule=function(t,n){if(n.indexOf("!")!==-1){var r=n.split("!");return e.normalizeModule(t,r[0])+"!"+e.normalizeModule(t,r[1])}if(n.charAt(0)=="."){var i=t.split("/").slice(0,-1).join("/");n=(i?i+"/":"")+n;while(n.indexOf(".")!==-1&&s!=n){var s=n;n=n.replace(/^\.\//,"").replace(/\/\.\//,"/").replace(/[^\/]+\/\.\.\//,"")}}return n},e.require=function(r,i){i||(i=r,r=null);if(!i.charAt)throw new Error("worker.js require() accepts only (parentId, id) as arguments");i=e.normalizeModule(r,i);var s=e.require.modules[i];if(s)return s.initialized||(s.initialized=!0,s.exports=s.factory().exports),s.exports;if(!e.require.tlns)return console.log("unable to load "+i);var o=t(i,e.require.tlns);return o.slice(-3)!=".js"&&(o+=".js"),e.require.id=i,e.require.modules[i]={},importScripts(o),e.require(r,i)},e.require.modules={},e.require.tlns={},e.define=function(t,n,r){arguments.length==2?(r=n,typeof t!="string"&&(n=t,t=e.require.id)):arguments.length==1&&(r=t,n=[],t=e.require.id);if(typeof r!="function"){e.require.modules[t]={exports:r,initialized:!0};return}n.length||(n=["require","exports","module"]);var i=function(n){return e.require(t,n)};e.require.modules[t]={exports:{},factory:function(){var e=this,t=r.apply(this,n.slice(0,r.length).map(function(t){switch(t){case"require":return i;case"exports":return e.exports;case"module":return e;default:return i(t)}}));return t&&(e.exports=t),e}}},e.define.amd={},require.tlns={},e.initBaseUrls=function(t){for(var n in t)require.tlns[n]=t[n]},e.initSender=function(){var n=e.require("ace/lib/event_emitter").EventEmitter,r=e.require("ace/lib/oop"),i=function(){};return function(){r.implement(this,n),this.callback=function(e,t){postMessage({type:"call",id:t,data:e})},this.emit=function(e,t){postMessage({type:"event",name:e,data:t})}}.call(i.prototype),new i};var n=e.main=null,r=e.sender=null;e.onmessage=function(t){var i=t.data;if(i.event&&r)r._signal(i.event,i.data);else if(i.command)if(n[i.command])n[i.command].apply(n,i.args);else{if(!e[i.command])throw new Error("Unknown command:"+i.command);e[i.command].apply(e,i.args)}else if(i.init){e.initBaseUrls(i.tlns),r=e.sender=e.initSender();var s=require(i.module)[i.classname];n=e.main=new s(r)}}}(this),ace.define("ace/lib/oop",[],function(e,t,n){"use strict";t.inherits=function(e,t){e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}})},t.mixin=function(e,t){for(var n in t)e[n]=t[n];return e},t.implement=function(e,n){t.mixin(e,n)}}),ace.define("ace/lib/lang",[],function(e,t,n){"use strict";t.last=function(e){return e[e.length-1]},t.stringReverse=function(e){return e.split("").reverse().join("")},t.stringRepeat=function(e,t){var n="";while(t>0){t&1&&(n+=e);if(t>>=1)e+=e}return n};var r=/^\s\s*/,i=/\s\s*$/;t.stringTrimLeft=function(e){return e.replace(r,"")},t.stringTrimRight=function(e){return e.replace(i,"")},t.copyObject=function(e){var t={};for(var n in e)t[n]=e[n];return t},t.copyArray=function(e){var t=[];for(var n=0,r=e.length;n ["+this.end.row+"/"+this.end.column+"]"},this.contains=function(e,t){return this.compare(e,t)==0},this.compareRange=function(e){var t,n=e.end,r=e.start;return t=this.compare(n.row,n.column),t==1?(t=this.compare(r.row,r.column),t==1?2:t==0?1:0):t==-1?-2:(t=this.compare(r.row,r.column),t==-1?-1:t==1?42:0)},this.comparePoint=function(e){return this.compare(e.row,e.column)},this.containsRange=function(e){return this.comparePoint(e.start)==0&&this.comparePoint(e.end)==0},this.intersects=function(e){var t=this.compareRange(e);return t==-1||t==0||t==1},this.isEnd=function(e,t){return this.end.row==e&&this.end.column==t},this.isStart=function(e,t){return this.start.row==e&&this.start.column==t},this.setStart=function(e,t){typeof e=="object"?(this.start.column=e.column,this.start.row=e.row):(this.start.row=e,this.start.column=t)},this.setEnd=function(e,t){typeof e=="object"?(this.end.column=e.column,this.end.row=e.row):(this.end.row=e,this.end.column=t)},this.inside=function(e,t){return this.compare(e,t)==0?this.isEnd(e,t)||this.isStart(e,t)?!1:!0:!1},this.insideStart=function(e,t){return this.compare(e,t)==0?this.isEnd(e,t)?!1:!0:!1},this.insideEnd=function(e,t){return this.compare(e,t)==0?this.isStart(e,t)?!1:!0:!1},this.compare=function(e,t){return!this.isMultiLine()&&e===this.start.row?tthis.end.column?1:0:ethis.end.row?1:this.start.row===e?t>=this.start.column?0:-1:this.end.row===e?t<=this.end.column?0:1:0},this.compareStart=function(e,t){return this.start.row==e&&this.start.column==t?-1:this.compare(e,t)},this.compareEnd=function(e,t){return this.end.row==e&&this.end.column==t?1:this.compare(e,t)},this.compareInside=function(e,t){return this.end.row==e&&this.end.column==t?1:this.start.row==e&&this.start.column==t?-1:this.compare(e,t)},this.clipRows=function(e,t){if(this.end.row>t)var n={row:t+1,column:0};else if(this.end.rowt)var r={row:t+1,column:0};else if(this.start.row=0&&t.row=0&&t.column<=e[t.row].length}function s(e,t){t.action!="insert"&&t.action!="remove"&&r(t,"delta.action must be 'insert' or 'remove'"),t.lines instanceof Array||r(t,"delta.lines must be an Array"),(!t.start||!t.end)&&r(t,"delta.start/end must be an present");var n=t.start;i(e,t.start)||r(t,"delta.start must be contained in document");var s=t.end;t.action=="remove"&&!i(e,s)&&r(t,"delta.end must contained in document for 'remove' actions");var o=s.row-n.row,u=s.column-(o==0?n.column:0);(o!=t.lines.length-1||t.lines[o].length!=u)&&r(t,"delta.range must match delta lines")}t.applyDelta=function(e,t,n){var r=t.start.row,i=t.start.column,s=e[r]||"";switch(t.action){case"insert":var o=t.lines;if(o.length===1)e[r]=s.substring(0,i)+t.lines[0]+s.substring(i);else{var u=[r,1].concat(t.lines);e.splice.apply(e,u),e[r]=s.substring(0,i)+e[r],e[r+t.lines.length-1]+=s.substring(i)}break;case"remove":var a=t.end.column,f=t.end.row;r===f?e[r]=s.substring(0,i)+s.substring(a):e.splice(r,f-r+1,s.substring(0,i)+e[f].substring(a))}}}),ace.define("ace/lib/event_emitter",[],function(e,t,n){"use strict";var r={},i=function(){this.propagationStopped=!0},s=function(){this.defaultPrevented=!0};r._emit=r._dispatchEvent=function(e,t){this._eventRegistry||(this._eventRegistry={}),this._defaultHandlers||(this._defaultHandlers={});var n=this._eventRegistry[e]||[],r=this._defaultHandlers[e];if(!n.length&&!r)return;if(typeof t!="object"||!t)t={};t.type||(t.type=e),t.stopPropagation||(t.stopPropagation=i),t.preventDefault||(t.preventDefault=s),n=n.slice();for(var o=0;othis.row)return;var n=t(e,{row:this.row,column:this.column},this.$insertRight);this.setPosition(n.row,n.column,!0)},this.setPosition=function(e,t,n){var r;n?r={row:e,column:t}:r=this.$clipPositionToDocument(e,t);if(this.row==r.row&&this.column==r.column)return;var i={row:this.row,column:this.column};this.row=r.row,this.column=r.column,this._signal("change",{old:i,value:r})},this.detach=function(){this.document.off("change",this.$onChange)},this.attach=function(e){this.document=e||this.document,this.document.on("change",this.$onChange)},this.$clipPositionToDocument=function(e,t){var n={};return e>=this.document.getLength()?(n.row=Math.max(0,this.document.getLength()-1),n.column=this.document.getLine(n.row).length):e<0?(n.row=0,n.column=0):(n.row=e,n.column=Math.min(this.document.getLine(n.row).length,Math.max(0,t))),t<0&&(n.column=0),n}}).call(s.prototype)}),ace.define("ace/document",[],function(e,t,n){"use strict";var r=e("./lib/oop"),i=e("./apply_delta").applyDelta,s=e("./lib/event_emitter").EventEmitter,o=e("./range").Range,u=e("./anchor").Anchor,a=function(e){this.$lines=[""],e.length===0?this.$lines=[""]:Array.isArray(e)?this.insertMergedLines({row:0,column:0},e):this.insert({row:0,column:0},e)};(function(){r.implement(this,s),this.setValue=function(e){var t=this.getLength()-1;this.remove(new o(0,0,t,this.getLine(t).length)),this.insert({row:0,column:0},e)},this.getValue=function(){return this.getAllLines().join(this.getNewLineCharacter())},this.createAnchor=function(e,t){return new u(this,e,t)},"aaa".split(/a/).length===0?this.$split=function(e){return e.replace(/\r\n|\r/g,"\n").split("\n")}:this.$split=function(e){return e.split(/\r\n|\r|\n/)},this.$detectNewLine=function(e){var t=e.match(/^.*?(\r\n|\r|\n)/m);this.$autoNewLine=t?t[1]:"\n",this._signal("changeNewLineMode")},this.getNewLineCharacter=function(){switch(this.$newLineMode){case"windows":return"\r\n";case"unix":return"\n";default:return this.$autoNewLine||"\n"}},this.$autoNewLine="",this.$newLineMode="auto",this.setNewLineMode=function(e){if(this.$newLineMode===e)return;this.$newLineMode=e,this._signal("changeNewLineMode")},this.getNewLineMode=function(){return this.$newLineMode},this.isNewLine=function(e){return e=="\r\n"||e=="\r"||e=="\n"},this.getLine=function(e){return this.$lines[e]||""},this.getLines=function(e,t){return this.$lines.slice(e,t+1)},this.getAllLines=function(){return this.getLines(0,this.getLength())},this.getLength=function(){return this.$lines.length},this.getTextRange=function(e){return this.getLinesForRange(e).join(this.getNewLineCharacter())},this.getLinesForRange=function(e){var t;if(e.start.row===e.end.row)t=[this.getLine(e.start.row).substring(e.start.column,e.end.column)];else{t=this.getLines(e.start.row,e.end.row),t[0]=(t[0]||"").substring(e.start.column);var n=t.length-1;e.end.row-e.start.row==n&&(t[n]=t[n].substring(0,e.end.column))}return t},this.insertLines=function(e,t){return console.warn("Use of document.insertLines is deprecated. Use the insertFullLines method instead."),this.insertFullLines(e,t)},this.removeLines=function(e,t){return console.warn("Use of document.removeLines is deprecated. Use the removeFullLines method instead."),this.removeFullLines(e,t)},this.insertNewLine=function(e){return console.warn("Use of document.insertNewLine is deprecated. Use insertMergedLines(position, ['', '']) instead."),this.insertMergedLines(e,["",""])},this.insert=function(e,t){return this.getLength()<=1&&this.$detectNewLine(t),this.insertMergedLines(e,this.$split(t))},this.insertInLine=function(e,t){var n=this.clippedPos(e.row,e.column),r=this.pos(e.row,e.column+t.length);return this.applyDelta({start:n,end:r,action:"insert",lines:[t]},!0),this.clonePos(r)},this.clippedPos=function(e,t){var n=this.getLength();e===undefined?e=n:e<0?e=0:e>=n&&(e=n-1,t=undefined);var r=this.getLine(e);return t==undefined&&(t=r.length),t=Math.min(Math.max(t,0),r.length),{row:e,column:t}},this.clonePos=function(e){return{row:e.row,column:e.column}},this.pos=function(e,t){return{row:e,column:t}},this.$clipPosition=function(e){var t=this.getLength();return e.row>=t?(e.row=Math.max(0,t-1),e.column=this.getLine(t-1).length):(e.row=Math.max(0,e.row),e.column=Math.min(Math.max(e.column,0),this.getLine(e.row).length)),e},this.insertFullLines=function(e,t){e=Math.min(Math.max(e,0),this.getLength());var n=0;e0,r=t=0&&this.applyDelta({start:this.pos(e,this.getLine(e).length),end:this.pos(e+1,0),action:"remove",lines:["",""]})},this.replace=function(e,t){e instanceof o||(e=o.fromPoints(e.start,e.end));if(t.length===0&&e.isEmpty())return e.start;if(t==this.getTextRange(e))return e.end;this.remove(e);var n;return t?n=this.insert(e.start,t):n=e.start,n},this.applyDeltas=function(e){for(var t=0;t=0;t--)this.revertDelta(e[t])},this.applyDelta=function(e,t){var n=e.action=="insert";if(n?e.lines.length<=1&&!e.lines[0]:!o.comparePoints(e.start,e.end))return;n&&e.lines.length>2e4?this.$splitAndapplyLargeDelta(e,2e4):(i(this.$lines,e,t),this._signal("change",e))},this.$safeApplyDelta=function(e){var t=this.$lines.length;(e.action=="remove"&&e.start.row65535){e-=65536;var t=55296+(e>>10),n=56320+(e&1023);return String.fromCharCode(t,n)}return String.fromCharCode(e)}function o(e){var t=e.slice(1,-1);return t in n?n[t]:t.charAt(0)==="#"?s(parseInt(t.substr(1).replace("x","0x"))):(i.error("entity not found:"+e),e)}function u(t){var n=e.substring(v,t).replace(/&#?\w+;/g,o);h&&a(v),r.characters(n,0,t-v),v=t}function a(t,n){while(t>=l&&(n=c.exec(e)))f=n.index,l=f+n[0].length,h.lineNumber++;h.columnNumber=t-f+1}var f=0,l=0,c=/.+(?:\r\n?|\n)|.*$/g,h=r.locator,p=[{currentNSMap:t}],d={},v=0;for(;;){var E=e.indexOf("<",v);if(E<0){if(!e.substr(v).match(/^\s*$/)){var N=r.document,C=N.createTextNode(e.substr(v));N.appendChild(C),r.currentElement=C}return}E>v&&u(E);switch(e.charAt(E+1)){case"/":var k=e.indexOf(">",E+3),L=e.substring(E+2,k),A;if(!(p.length>1)){i.fatalError("end tag name not found for: "+L);break}A=p.pop();var O=A.localNSMap;A.tagName!=L&&i.fatalError("end tag name: "+L+" does not match the current start tagName: "+A.tagName),r.endElement(A.uri,A.localName,L);if(O)for(var M in O)r.endPrefixMapping(M);k++;break;case"?":h&&a(E),k=x(e,E,r);break;case"!":h&&a(E),k=S(e,E,r,i);break;default:try{h&&a(E);var _=new T,k=g(e,E,_,o,i),D=_.length;if(D&&h){var P=m(h,{});for(var E=0;E0))throw new Error("attribute value no end '"+g+"' match");d=e.slice(t,v).replace(/&#?\w+;/g,r),n.add(s,d,t-1),m=c}else{if(m!=l)throw new Error('attribute value must after "="');d=e.slice(t,v).replace(/&#?\w+;/g,r),n.add(s,d,t),i.warning('attribute "'+s+'" missed start quot('+g+")!!"),t=v+1,m=c}break;case"/":switch(m){case o:n.setTagName(e.slice(t,v));case c:case h:case p:m=p,n.closed=!0;case l:case u:case a:break;default:throw new Error("attribute invalid close char('/')")}break;case"":i.error("unexpected end of input");case">":switch(m){case o:n.setTagName(e.slice(t,v));case c:case h:case p:break;case l:case u:d=e.slice(t,v),d.slice(-1)==="/"&&(n.closed=!0,d=d.slice(0,-1));case a:m===a&&(d=s),m==l?(i.warning('attribute "'+d+'" missed quot(")!!'),n.add(s,d.replace(/&#?\w+;/g,r),t)):(i.warning('attribute "'+d+'" missed value!! "'+d+'" instead!!'),n.add(d,d,t));break;case f:throw new Error("attribute value missed!!")}return v;case"\u0080":g=" ";default:if(g<=" ")switch(m){case o:n.setTagName(e.slice(t,v)),m=h;break;case u:s=e.slice(t,v),m=a;break;case l:var d=e.slice(t,v).replace(/&#?\w+;/g,r);i.warning('attribute "'+d+'" missed quot(")!!'),n.add(s,d,t);case c:m=h}else switch(m){case a:i.warning('attribute "'+s+'" missed value!! "'+s+'" instead!!'),n.add(s,s,t),t=v,m=u;break;case c:i.warning('attribute space is required"'+s+'"!!');case h:m=u,t=v;break;case f:m=l,t=v;break;case p:throw new Error("elements closed character '/' and '>' must be connected to")}}v++}}function y(e,t,n){var r=e.tagName,i=null,s=n[n.length-1].currentNSMap,o=e.length;while(o--){var u=e[o],a=u.qName,f=u.value,l=a.indexOf(":");if(l>0)var c=u.prefix=a.slice(0,l),h=a.slice(l+1),p=c==="xmlns"&&h;else h=a,c=null,p=a==="xmlns"&&"";u.localName=h,p!==!1&&(i==null&&(i={},E(s,s={})),s[p]=i[p]=f,u.uri="http://www.w3.org/2000/xmlns/",t.startPrefixMapping(p,f))}var o=e.length;while(o--){u=e[o];var c=u.prefix;c&&(c==="xml"&&(u.uri="http://www.w3.org/XML/1998/namespace"),c!=="xmlns"&&(u.uri=s[c]))}var l=r.indexOf(":");l>0?(c=e.prefix=r.slice(0,l),h=e.localName=r.slice(l+1)):(c=null,h=e.localName=r);var d=e.uri=s[c||""];t.startElement(d,h,r,e);if(e.closed){t.endElement(d,h,r);if(i)for(c in i)t.endPrefixMapping(c)}else e.currentNSMap=s,e.localNSMap=i,n.push(e)}function b(e,t,n,r,i){if(/^(?:script|textarea)$/i.test(n)){var s=e.indexOf("",t),o=e.substring(t+1,s);if(/[&<]/.test(o))return/^script$/i.test(n)?(i.characters(o,0,o.length),s):(o=o.replace(/&#?\w+;/g,r),i.characters(o,0,o.length),s)}return t+1}function w(e,t,n,r){var i=r[n];return i==null&&(i=r[n]=e.lastIndexOf("")),i",t+4);return s>t?(n.comment(e,t+4,s-t-4),s+3):(r.error("Unclosed comment"),-1)}return-1;default:if(e.substr(t+3,6)=="CDATA["){var s=e.indexOf("]]>",t+9);return s>t?(n.startCDATA(),n.characters(e,t+9,s-t-9),n.endCDATA(),s+3):(r.error("Unclosed CDATA"),-1)}var o=C(e,t),u=o.length;if(u>1&&/!doctype/i.test(o[0][0])){var a=o[1][0],f=u>3&&/^public$/i.test(o[2][0])&&o[3][0],l=u>4&&o[4][0],c=o[u-1];return n.startDTD(a,f&&f.replace(/^(['"])(.*?)\1$/,"$2"),l&&l.replace(/^(['"])(.*?)\1$/,"$2")),n.endDTD(),c.index+c[0].length}}return-1}function x(e,t,n){var r=e.indexOf("?>",t);if(r){var i=e.substring(t,r).match(/^<\?(\S*)\s*([\s\S]*?)\s*$/);if(i){var s=i[0].length;return n.processingInstruction(i[1],i[2]),r+2}return-1}return-1}function T(e){}function N(e,t){return e.__proto__=t,e}function C(e,t){var n,r=[],i=/'[^']+'|"[^"]+"|[^\s<>\/=]+=?|(\/?\s*>|<)/g;i.lastIndex=t,i.exec(e);while(n=i.exec(e)){r.push(n);if(n[1])return r}}var r=/[A-Z_a-z\xC0-\xD6\xD8-\xF6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]/,i=new RegExp("[\\-\\.0-9"+r.source.slice(1,-1)+"\u00b7\u0300-\u036f\\ux203F-\u2040]"),s=new RegExp("^"+r.source+i.source+"*(?::"+r.source+i.source+"*)?$"),o=0,u=1,a=2,f=3,l=4,c=5,h=6,p=7;return d.prototype={parse:function(e,t,n){var r=this.domBuilder;r.startDocument(),E(t,t={}),v(e,t,n,r,this.errorHandler),r.endDocument()}},T.prototype={setTagName:function(e){if(!s.test(e))throw new Error("invalid tagName:"+e);this.tagName=e},add:function(e,t,n){if(!s.test(e))throw new Error("invalid attribute:"+e);this[this.length++]={qName:e,value:t,offset:n}},length:0,getLocalName:function(e){return this[e].localName},getOffset:function(e){return this[e].offset},getQName:function(e){return this[e].qName},getURI:function(e){return this[e].uri},getValue:function(e){return this[e].value}},N({},N.prototype)instanceof N||(N=function(e,t){function n(){}n.prototype=t,n=new n;for(t in e)n[t]=e[t];return n}),d}),ace.define("ace/mode/xml/dom",[],function(e,t,n){function r(e,t){for(var n in e)t[n]=e[n]}function i(e,t){var n=function(){},i=e.prototype;if(Object.create){var s=Object.create(t.prototype);i.__proto__=s}i instanceof t||(n.prototype=t.prototype,n=new n,r(i,n),e.prototype=i=n),i.constructor!=e&&(typeof e!="function"&&console.error("unknown Class:"+e),i.constructor=e)}function B(e,t){if(t instanceof Error)var n=t;else n=this,Error.call(this,w[e]),this.message=w[e],Error.captureStackTrace&&Error.captureStackTrace(this,B);return n.code=e,t&&(this.message=this.message+": "+t),n}function j(){}function F(e,t){this._node=e,this._refresh=t,I(this)}function I(e){var t=e._node._inc||e._node.ownerDocument._inc;if(e._inc!=t){var n=e._refresh(e._node);gt(e,"length",n.length),r(n,e),e._inc=t}}function q(){}function R(e,t){var n=e.length;while(n--)if(e[n]===t)return n}function U(e,t,n,r){r?t[R(t,r)]=n:t[t.length++]=n;if(e){n.ownerElement=e;var i=e.ownerDocument;i&&(r&&Q(i,e,r),K(i,e,n))}}function z(e,t,n){var r=R(t,n);if(!(r>=0))throw new B(L,new Error);var i=t.length-1;while(r"&&">"||e=="&"&&"&"||e=='"'&&"""||"&#"+e.charCodeAt()+";"}function $(e,t){if(t(e))return!0;if(e=e.firstChild)do if($(e,t))return!0;while(e=e.nextSibling)}function J(){}function K(e,t,n){e&&e._inc++;var r=n.namespaceURI;r=="http://www.w3.org/2000/xmlns/"&&(t._nsMap[n.prefix?n.localName:""]=n.value)}function Q(e,t,n,r){e&&e._inc++;var i=n.namespaceURI;i=="http://www.w3.org/2000/xmlns/"&&delete t._nsMap[n.prefix?n.localName:""]}function G(e,t,n){if(e&&e._inc){e._inc++;var r=t.childNodes;if(n)r[r.length++]=n;else{var i=t.firstChild,s=0;while(i)r[s++]=i,i=i.nextSibling;r.length=s}}}function Y(e,t){var n=t.previousSibling,r=t.nextSibling;return n?n.nextSibling=r:e.firstChild=r,r?r.previousSibling=n:e.lastChild=n,G(e.ownerDocument,e),t}function Z(e,t,n){var r=t.parentNode;r&&r.removeChild(t);if(t.nodeType===g){var i=t.firstChild;if(i==null)return t;var s=t.lastChild}else i=s=t;var o=n?n.previousSibling:e.lastChild;i.previousSibling=o,s.nextSibling=n,o?o.nextSibling=i:e.firstChild=i,n==null?e.lastChild=s:n.previousSibling=s;do i.parentNode=e;while(i!==s&&(i=i.nextSibling));return G(e.ownerDocument||e,e),t.nodeType==g&&(t.firstChild=t.lastChild=null),t}function et(e,t){var n=t.parentNode;if(n){var r=e.lastChild;n.removeChild(t);var r=e.lastChild}var r=e.lastChild;return t.parentNode=e,t.previousSibling=r,t.nextSibling=null,r?r.nextSibling=t:e.firstChild=t,e.lastChild=t,G(e.ownerDocument,e,t),t}function tt(){this._nsMap={}}function nt(){}function rt(){}function it(){}function st(){}function ot(){}function ut(){}function at(){}function ft(){}function lt(){}function ct(){}function ht(){}function pt(){}function dt(e,t){switch(e.nodeType){case u:var n=e.attributes,r=n.length,i=e.firstChild,o=e.tagName,h=s===e.namespaceURI;t.push("<",o);for(var y=0;y");if(h&&/^script$/i.test(o))i&&t.push(i.data);else while(i)dt(i,t),i=i.nextSibling;t.push("")}else t.push("/>");return;case v:case g:var i=e.firstChild;while(i)dt(i,t),i=i.nextSibling;return;case a:return t.push(" ",e.name,'="',e.value.replace(/[<&"]/g,V),'"');case f:return t.push(e.data.replace(/[<&]/g,V));case l:return t.push("");case d:return t.push("");case m:var b=e.publicId,w=e.systemId;t.push("');else if(w&&w!=".")t.push(' SYSTEM "',w,'">');else{var E=e.internalSubset;E&&t.push(" [",E,"]"),t.push(">")}return;case p:return t.push("");case c:return t.push("&",e.nodeName,";");default:t.push("??",e.nodeName)}}function vt(e,t,n){var r;switch(t.nodeType){case u:r=t.cloneNode(!1),r.ownerDocument=e;case g:break;case a:n=!0}r||(r=t.cloneNode(!1)),r.ownerDocument=e,r.parentNode=null;if(n){var i=t.firstChild;while(i)r.appendChild(vt(e,i,n)),i=i.nextSibling}return r}function mt(e,t,n){var r=new t.constructor;for(var i in t){var s=t[i];typeof s!="object"&&s!=r[i]&&(r[i]=s)}t.childNodes&&(r.childNodes=new j),r.ownerDocument=e;switch(r.nodeType){case u:var o=t.attributes,f=r.attributes=new q,l=o.length;f._ownerElement=r;for(var c=0;c0},lookupPrefix:function(e){var t=this;while(t){var n=t._nsMap;if(n)for(var r in n)if(n[r]==e)return r;t=t.nodeType==2?t.ownerDocument:t.parentNode}return null},lookupNamespaceURI:function(e){var t=this;while(t){var n=t._nsMap;if(n&&e in n)return n[e];t=t.nodeType==2?t.ownerDocument:t.parentNode}return null},isDefaultNamespace:function(e){var t=this.lookupPrefix(e);return t==null}},r(o,X),r(o,X.prototype),J.prototype={nodeName:"#document",nodeType:v,doctype:null,documentElement:null,_inc:1,insertBefore:function(e,t){if(e.nodeType==g){var n=e.firstChild;while(n){var r=n.nextSibling;this.insertBefore(n,t),n=r}return e}return this.documentElement==null&&e.nodeType==1&&(this.documentElement=e),Z(this,e,t),e.ownerDocument=this,e},removeChild:function(e){return this.documentElement==e&&(this.documentElement=null),Y(this,e)},importNode:function(e,t){return vt(this,e,t)},getElementById:function(e){var t=null;return $(this.documentElement,function(n){if(n.nodeType==1&&n.getAttribute("id")==e)return t=n,!0}),t},createElement:function(e){var t=new tt;t.ownerDocument=this,t.nodeName=e,t.tagName=e,t.childNodes=new j;var n=t.attributes=new q;return n._ownerElement=t,t},createDocumentFragment:function(){var e=new ct;return e.ownerDocument=this,e.childNodes=new j,e},createTextNode:function(e){var t=new it;return t.ownerDocument=this,t.appendData(e),t},createComment:function(e){var t=new st;return t.ownerDocument=this,t.appendData(e),t},createCDATASection:function(e){var t=new ot;return t.ownerDocument=this,t.appendData(e),t},createProcessingInstruction:function(e,t){var n=new ht;return n.ownerDocument=this,n.tagName=n.target=e,n.nodeValue=n.data=t,n},createAttribute:function(e){var t=new nt;return t.ownerDocument=this,t.name=e,t.nodeName=e,t.localName=e,t.specified=!0,t},createEntityReference:function(e){var t=new lt;return t.ownerDocument=this,t.nodeName=e,t},createElementNS:function(e,t){var n=new tt,r=t.split(":"),i=n.attributes=new q;return n.childNodes=new j,n.ownerDocument=this,n.nodeName=t,n.tagName=t,n.namespaceURI=e,r.length==2?(n.prefix=r[0],n.localName=r[1]):n.localName=t,i._ownerElement=n,n},createAttributeNS:function(e,t){var n=new nt,r=t.split(":");return n.ownerDocument=this,n.nodeName=t,n.name=t,n.namespaceURI=e,n.specified=!0,r.length==2?(n.prefix=r[0],n.localName=r[1]):n.localName=t,n}},i(J,X),tt.prototype={nodeType:u,hasAttribute:function(e){return this.getAttributeNode(e)!=null},getAttribute:function(e){var t=this.getAttributeNode(e);return t&&t.value||""},getAttributeNode:function(e){return this.attributes.getNamedItem(e)},setAttribute:function(e,t){var n=this.ownerDocument.createAttribute(e);n.value=n.nodeValue=""+t,this.setAttributeNode(n)},removeAttribute:function(e){var t=this.getAttributeNode(e);t&&this.removeAttributeNode(t)},appendChild:function(e){return e.nodeType===g?this.insertBefore(e,null):et(this,e)},setAttributeNode:function(e){return this.attributes.setNamedItem(e)},setAttributeNodeNS:function(e){return this.attributes.setNamedItemNS(e)},removeAttributeNode:function(e){return this.attributes.removeNamedItem(e.nodeName)},removeAttributeNS:function(e,t){var n=this.getAttributeNodeNS(e,t);n&&this.removeAttributeNode(n)},hasAttributeNS:function(e,t){return this.getAttributeNodeNS(e,t)!=null},getAttributeNS:function(e,t){var n=this.getAttributeNodeNS(e,t);return n&&n.value||""},setAttributeNS:function(e,t,n){var r=this.ownerDocument.createAttributeNS(e,t);r.value=r.nodeValue=""+n,this.setAttributeNode(r)},getAttributeNodeNS:function(e,t){return this.attributes.getNamedItemNS(e,t)},getElementsByTagName:function(e){return new F(this,function(t){var n=[];return $(t,function(r){r!==t&&r.nodeType==u&&(e==="*"||r.tagName==e)&&n.push(r)}),n})},getElementsByTagNameNS:function(e,t){return new F(this,function(n){var r=[];return $(n,function(i){i!==n&&i.nodeType===u&&(e==="*"||i.namespaceURI===e)&&(t==="*"||i.localName==t)&&r.push(i)}),r})}},J.prototype.getElementsByTagName=tt.prototype.getElementsByTagName,J.prototype.getElementsByTagNameNS=tt.prototype.getElementsByTagNameNS,i(tt,X),nt.prototype.nodeType=a,i(nt,X),rt.prototype={data:"",substringData:function(e,t){return this.data.substring(e,e+t)},appendData:function(e){e=this.data+e,this.nodeValue=this.data=e,this.length=e.length},insertData:function(e,t){this.replaceData(e,0,t)},appendChild:function(e){throw new Error(w[3])},deleteData:function(e,t){this.replaceData(e,t,"")},replaceData:function(e,t,n){var r=this.data.substring(0,e),i=this.data.substring(e+t);n=r+n+i,this.nodeValue=this.data=n,this.length=n.length}},i(rt,X),it.prototype={nodeName:"#text",nodeType:f,splitText:function(e){var t=this.data,n=t.substring(e);t=t.substring(0,e),this.data=this.nodeValue=t,this.length=t.length;var r=this.ownerDocument.createTextNode(n);return this.parentNode&&this.parentNode.insertBefore(r,this.nextSibling),r}},i(it,rt),st.prototype={nodeName:"#comment",nodeType:d},i(st,rt),ot.prototype={nodeName:"#cdata-section",nodeType:l},i(ot,rt),ut.prototype.nodeType=m,i(ut,X),at.prototype.nodeType=y,i(at,X),ft.prototype.nodeType=h,i(ft,X),lt.prototype.nodeType=c,i(lt,X),ct.prototype.nodeName="#document-fragment",ct.prototype.nodeType=g,i(ct,X),ht.prototype.nodeType=p,i(ht,X),pt.prototype.serializeToString=function(e){var t=[];return dt(e,t),t.join("")},X.prototype.toString=function(){return pt.prototype.serializeToString(this)};try{Object.defineProperty&&(Object.defineProperty(F.prototype,"length",{get:function(){return I(this),this.$$length}}),Object.defineProperty(X.prototype,"textContent",{get:function(){return yt(this)},set:function(e){switch(this.nodeType){case 1:case 11:while(this.firstChild)this.removeChild(this.firstChild);(e||String(e))&&this.appendChild(this.ownerDocument.createTextNode(e));break;default:this.data=e,this.value=value,this.nodeValue=e}}}),gt=function(e,t,n){e["$$"+t]=n})}catch(bt){}return W}),ace.define("ace/mode/xml/dom-parser",[],function(e,t,n){"use strict";function s(e){this.options=e||{locator:{}}}function o(e,t,n){function s(t){var s=e[t];if(!s)if(i)s=e.length==2?function(n){e(t,n)}:e;else{var o=arguments.length;while(--o)if(s=e[arguments[o]])break}r[t]=s&&function(e){s(e+f(n),e,n)}||function(){}}if(!e){if(t instanceof u)return t;e=t}var r={},i=e instanceof Function;return n=n||{},s("warning","warn"),s("error","warn","warning"),s("fatalError","warn","warning","error"),r}function u(){this.cdata=!1}function a(e,t){t.lineNumber=e.lineNumber,t.columnNumber=e.columnNumber}function f(e){if(e)return"\n@"+(e.systemId||"")+"#[line:"+e.lineNumber+",col:"+e.columnNumber+"]"}function l(e,t,n){return typeof e=="string"?e.substr(t,n):e.length>=t+n||t?new java.lang.String(e,t,n)+"":e}function c(e,t){e.currentElement?e.currentElement.appendChild(t):e.document.appendChild(t)}var r=e("./sax"),i=e("./dom");return s.prototype.parseFromString=function(e,t){var n=this.options,i=new r,s=n.domBuilder||new u,a=n.errorHandler,f=n.locator,l=n.xmlns||{},c={lt:"<",gt:">",amp:"&",quot:'"',apos:"'"};return f&&s.setDocumentLocator(f),i.errorHandler=o(a,s,f),i.domBuilder=n.domBuilder||s,/\/x?html?$/.test(t)&&(c.nbsp="\u00a0",c.copy="\u00a9",l[""]="http://www.w3.org/1999/xhtml"),e?i.parse(e,l,c):i.errorHandler.error("invalid document source"),s.document},u.prototype={startDocument:function(){this.document=(new i).createDocument(null,null,null),this.locator&&(this.document.documentURI=this.locator.systemId)},startElement:function(e,t,n,r){var i=this.document,s=i.createElementNS(e,n||t),o=r.length;c(this,s),this.currentElement=s,this.locator&&a(this.locator,s);for(var u=0;u { - const name = inputs.find(i => i.label === 'name')!.value; + const name = inputs.find(i => i.label === 'name')!.value!; const desc = getValue(inputs.find(i => i.label === 'desc')!); const type = getValue(inputs.find(i => i.label === 'type')!); const BitRate = getValue(inputs.find(i => i.label === 'BitRate')!); @@ -173,6 +173,7 @@ export function subNetworkWizard(options: WizardOptions): Wizard { type, BitRate, multiplier, + element, ] = isCreateOptions(options) ? [ get('subnetwork.wizard.title.add'), @@ -184,6 +185,7 @@ export function subNetworkWizard(options: WizardOptions): Wizard { initial.type, initial.bitrate, initial.multiplier, + undefined, ] : [ get('subnetwork.wizard.title.edit'), @@ -199,11 +201,13 @@ export function subNetworkWizard(options: WizardOptions): Wizard { options.element .querySelector('SubNetwork > BitRate') ?.getAttribute('multiplier') ?? null, + options.element, ]; return [ { title: heading, + element, primary: { icon: actionIcon, label: actionName, diff --git a/src/editors/substation/bay-editor.ts b/src/editors/substation/bay-editor.ts index e881f06b2..dcf1172e1 100644 --- a/src/editors/substation/bay-editor.ts +++ b/src/editors/substation/bay-editor.ts @@ -36,7 +36,7 @@ import { VoltageLevelEditor } from './voltage-level-editor.js'; /** [[`SubstationEditor`]] subeditor for a `Bay` element. */ @customElement('bay-editor') export class BayEditor extends LitElement { - @property() + @property({ attribute: false }) element!: Element; @property({ type: String }) @@ -163,34 +163,31 @@ export class BayEditor extends LitElement { } static wizard(options: WizardOptions): Wizard { - const [ - heading, - actionName, - actionIcon, - action, - name, - desc, - ] = isCreateOptions(options) - ? [ - get('bay.wizard.title.add'), - get('add'), - 'add', - BayEditor.createAction(options.parent), - '', - '', - ] - : [ - get('bay.wizard.title.edit'), - get('save'), - 'edit', - updateNamingAction(options.element), - options.element.getAttribute('name'), - options.element.getAttribute('desc'), - ]; + const [heading, actionName, actionIcon, action, name, desc, element] = + isCreateOptions(options) + ? [ + get('bay.wizard.title.add'), + get('add'), + 'add', + BayEditor.createAction(options.parent), + '', + '', + undefined, + ] + : [ + get('bay.wizard.title.edit'), + get('save'), + 'edit', + updateNamingAction(options.element), + options.element.getAttribute('name'), + options.element.getAttribute('desc'), + options.element, + ]; return [ { title: heading, + element, primary: { icon: actionIcon, label: actionName, diff --git a/src/editors/substation/conducting-equipment-editor.ts b/src/editors/substation/conducting-equipment-editor.ts index c714095e7..6d1fd4233 100644 --- a/src/editors/substation/conducting-equipment-editor.ts +++ b/src/editors/substation/conducting-equipment-editor.ts @@ -147,6 +147,7 @@ export class ConductingEquipmentEditor extends LitElement { name, desc, reservedNames, + element, ] = isCreateOptions(options) ? [ get('conductingequipment.wizard.title.add'), @@ -158,6 +159,7 @@ export class ConductingEquipmentEditor extends LitElement { Array.from( options.parent.querySelectorAll(selectors.ConductingEquipment) ).map(condEq => condEq.getAttribute('name') ?? ''), + undefined, ] : [ get('conductingequipment.wizard.title.edit'), @@ -173,11 +175,13 @@ export class ConductingEquipmentEditor extends LitElement { ) .map(condEq => condEq.getAttribute('name') ?? '') .filter(name => name !== options.element.getAttribute('name')), + options.element, ]; return [ { title: heading, + element, primary: { icon: actionIcon, label: actionName, diff --git a/src/editors/substation/lnodewizard.ts b/src/editors/substation/lnodewizard.ts index d3434925e..83f429b35 100644 --- a/src/editors/substation/lnodewizard.ts +++ b/src/editors/substation/lnodewizard.ts @@ -268,6 +268,7 @@ export function editlNode(element: Element): Wizard { return [ { title: get('lnode.wizard.title.selectIEDs'), + element, content: [renderIEDPage(element)], }, { @@ -275,6 +276,7 @@ export function editlNode(element: Element): Wizard { child => child.tagName === 'LNode' ), title: get('lnode.wizard.title.selectLNs'), + element, primary: { icon: 'save', label: get('save'), diff --git a/src/editors/substation/substation-editor.ts b/src/editors/substation/substation-editor.ts index 43a08c8b8..7b308f20a 100644 --- a/src/editors/substation/substation-editor.ts +++ b/src/editors/substation/substation-editor.ts @@ -167,6 +167,7 @@ export class SubstationEditor extends LitElement { name, desc, guessable, + element, ] = isCreateOptions(options) ? [ get('substation.wizard.title.add'), @@ -176,6 +177,7 @@ export class SubstationEditor extends LitElement { '', '', options.parent.querySelector(':root > IED'), + undefined, ] : [ get('substation.wizard.title.edit'), @@ -185,11 +187,13 @@ export class SubstationEditor extends LitElement { options.element.getAttribute('name'), options.element.getAttribute('desc'), false, + options.element, ]; return [ { title: heading, + element, primary: { icon: actionIcon, label: actionName, diff --git a/src/editors/substation/voltage-level-editor.ts b/src/editors/substation/voltage-level-editor.ts index 2e9778c62..1749a760f 100644 --- a/src/editors/substation/voltage-level-editor.ts +++ b/src/editors/substation/voltage-level-editor.ts @@ -195,7 +195,7 @@ export class VoltageLevelEditor extends LitElement { static updateAction(element: Element): WizardActor { return (inputs: WizardInput[]): EditorAction[] => { - const name = inputs.find(i => i.label === 'name')!.value; + const name = inputs.find(i => i.label === 'name')!.value!; const desc = getValue(inputs.find(i => i.label === 'desc')!); const nomFreq = getValue(inputs.find(i => i.label === 'nomFreq')!); const numPhases = getValue(inputs.find(i => i.label === 'numPhases')!); @@ -304,6 +304,7 @@ export class VoltageLevelEditor extends LitElement { numPhases, Voltage, multiplier, + element, ] = isCreateOptions(options) ? [ get('voltagelevel.wizard.title.add'), @@ -316,6 +317,7 @@ export class VoltageLevelEditor extends LitElement { initial.numPhases, initial.Voltage, initial.multiplier, + undefined, ] : [ get('voltagelevel.wizard.title.edit'), @@ -332,11 +334,13 @@ export class VoltageLevelEditor extends LitElement { options.element .querySelector('VoltageLevel > Voltage') ?.getAttribute('multiplier') ?? null, + options.element, ]; return [ { title: heading, + element, primary: { icon: actionIcon, label: actionName, diff --git a/src/editors/templates/datype-wizards.ts b/src/editors/templates/datype-wizards.ts index 4af7003a1..6a230cb04 100644 --- a/src/editors/templates/datype-wizards.ts +++ b/src/editors/templates/datype-wizards.ts @@ -213,6 +213,7 @@ function bDAWizard(options: WizardOptions): Wizard | undefined { return [ { title, + element: bda ?? undefined, primary: { icon: '', label: get('save'), action: action }, content: [ deleteButton, @@ -314,6 +315,7 @@ export function dATypeWizard( return [ { title: get('datype.wizard.title.edit'), + element: datype ?? undefined, primary: { icon: '', label: get('save'), diff --git a/src/editors/templates/dotype-wizards.ts b/src/editors/templates/dotype-wizards.ts index 9126240de..47b13624d 100644 --- a/src/editors/templates/dotype-wizards.ts +++ b/src/editors/templates/dotype-wizards.ts @@ -147,6 +147,7 @@ function sDOWizard(options: WizardOptions): Wizard | undefined { return [ { title, + element: sdo ?? undefined, primary: { icon: '', label: get('save'), action }, content: [ deleteButton, @@ -366,6 +367,7 @@ function dAWizard(options: WizardOptions): Wizard | undefined { return [ { title, + element: da ?? undefined, primary: { icon: '', label: get('save'), action: action }, content: [ deleteButton, @@ -600,6 +602,7 @@ export function dOTypeWizard( return [ { title: get('dotype.wizard.title.edit'), + element: dotype, primary: { icon: '', label: get('save'), diff --git a/src/editors/templates/enumtype-wizard.ts b/src/editors/templates/enumtype-wizard.ts index d77c23cd5..27c19345a 100644 --- a/src/editors/templates/enumtype-wizard.ts +++ b/src/editors/templates/enumtype-wizard.ts @@ -138,7 +138,8 @@ function eNumValWizard(options: WizardOptions): Wizard { return [ { - title: title, + title, + element: enumval ?? undefined, primary: { icon: '', label: 'Save', @@ -267,6 +268,7 @@ export function eNumTypeEditWizard( return [ { title: get('enum.wizard.title.edit'), + element: enumtype, primary: { icon: '', label: get('save'), diff --git a/src/editors/templates/lnodetype-wizard.ts b/src/editors/templates/lnodetype-wizard.ts index 7b7e49512..e939f00dc 100644 --- a/src/editors/templates/lnodetype-wizard.ts +++ b/src/editors/templates/lnodetype-wizard.ts @@ -178,6 +178,7 @@ function dOWizard(options: WizardOptions): Wizard | undefined { return [ { title, + element: DO ?? undefined, primary: { icon: '', label: get('save'), action }, content: [ deleteButton, @@ -364,6 +365,7 @@ export function lNodeTypeWizard( return [ { title: get('lnodetype.wizard.title.edit'), + element: lnodetype, primary: { icon: '', label: get('save'), diff --git a/src/foundation.ts b/src/foundation.ts index 1a730d479..701c5c077 100644 --- a/src/foundation.ts +++ b/src/foundation.ts @@ -3,6 +3,7 @@ import { directive, Part } from 'lit-html'; import { List } from '@material/mwc-list'; import { Select } from '@material/mwc-select'; +import AceEditor from 'ace-custom-element'; import { WizardTextField } from './wizard-textfield.js'; @@ -133,8 +134,12 @@ export function newActionEvent( }); } -export const wizardInputSelector = 'wizard-textfield, mwc-select'; -export type WizardInput = WizardTextField | Select; +export const wizardInputSelector = 'wizard-textfield, ace-editor, mwc-select'; +export type WizardInput = + | WizardTextField + | (AceEditor & { checkValidity: () => boolean; label: string }) + // TODO(c-dinkel): extend component + | Select; export type WizardAction = EditorAction | (() => Wizard); @@ -151,10 +156,24 @@ export function isWizard( return typeof wizardAction === 'function'; } +/** @returns the validity of `input` depending on type. */ +export function checkValidity(input: WizardInput): boolean { + if (input instanceof WizardTextField || input instanceof Select) + return input.checkValidity(); + else return true; +} + +/** reports the validity of `input` depending on type. */ +export function reportValidity(input: WizardInput): boolean { + if (input instanceof WizardTextField || input instanceof Select) + return input.reportValidity(); + else return true; +} + /** @returns the `value` or `maybeValue` of `input` depending on type. */ export function getValue(input: WizardInput): string | null { if (input instanceof WizardTextField) return input.maybeValue; - else return input.value; + else return input.value ?? null; } /** @returns the `multiplier` of `input` if available. */ @@ -179,6 +198,7 @@ export interface WizardPage { action: WizardActor; }; initial?: boolean; + element?: Element; } export type Wizard = WizardPage[]; diff --git a/src/menu/NewProject.ts b/src/menu/NewProject.ts index c52c2c8b1..9e4233350 100644 --- a/src/menu/NewProject.ts +++ b/src/menu/NewProject.ts @@ -17,7 +17,7 @@ export default class NewProjectPlugin extends LitElement { inputs: WizardInput[], wizard: Element ): EditorAction[] { - const docName = inputs[0].value.match(/\.s[sc]d$/i) + const docName = inputs[0].value?.match(/\.s[sc]d$/i) ? inputs[0].value : inputs[0].value + '.scd'; const version = ( diff --git a/src/wizard-dialog.ts b/src/wizard-dialog.ts index d8de93e12..4e10b291c 100644 --- a/src/wizard-dialog.ts +++ b/src/wizard-dialog.ts @@ -8,11 +8,12 @@ import { TemplateResult, html, } from 'lit-element'; -import { translate } from 'lit-translate'; +import { get, translate } from 'lit-translate'; import { Dialog } from '@material/mwc-dialog'; import { List } from '@material/mwc-list'; +import 'ace-custom-element'; import './wizard-textfield.js'; import { newActionEvent, @@ -23,6 +24,11 @@ import { WizardActor, wizardInputSelector, isWizard, + checkValidity, + reportValidity, + Delete, + Create, + identity, } from './foundation.js'; function dialogInputs(dialog?: Dialog): WizardInput[] { @@ -30,7 +36,37 @@ function dialogInputs(dialog?: Dialog): WizardInput[] { } function dialogValid(dialog?: Dialog): boolean { - return dialogInputs(dialog).every(wi => wi.checkValidity()); + return dialogInputs(dialog).every(checkValidity); +} + +function codeAction(element: Element): WizardActor { + return inputs => { + const text = inputs[0].value!; + if (!text || !element.parentElement) return []; + const desc = { + parent: element.parentElement!, + reference: element.nextElementSibling, + element, + }; + const del: Delete = { + old: desc, + }; + const cre: Create = { + new: { + ...desc, + element: new DOMParser().parseFromString(text, 'application/xml') + .documentElement, + }, + }; + return [ + { + actions: [del, cre], + title: get('code.log', { + id: identity(element), + }), + }, + ]; + }; } /** A wizard style dialog consisting of several pages commiting some @@ -54,9 +90,13 @@ export class WizardDialog extends LitElement { return this.dialogs[this.pageIndex]; } + get code(): boolean { + return this.dialog?.querySelector('mwc-icon-button-toggle')?.on ?? false; + } + /** Checks the inputs of all [[`WizardPage`]]s for validity. */ checkValidity(): boolean { - return Array.from(this.inputs).every(wi => wi.checkValidity()); + return Array.from(this.inputs).every(checkValidity); } private get firstInvalidPage(): number { @@ -72,7 +112,7 @@ export class WizardDialog extends LitElement { } else { this.dialog?.show(); await this.dialog?.updateComplete; - dialogInputs(this.dialog).map(wi => wi.reportValidity()); + dialogInputs(this.dialog).map(reportValidity); } } @@ -85,7 +125,7 @@ export class WizardDialog extends LitElement { ); if (!this.checkValidity()) { this.pageIndex = this.firstInvalidPage; - wizardInputs.map(wi => wi.reportValidity()); + wizardInputs.map(reportValidity); return false; } @@ -143,7 +183,26 @@ export class WizardDialog extends LitElement { heading=${page.title} @closed=${this.onClosed} > -
${page.content}
+ ${page.element + ? html` this.requestUpdate()} + >` + : ''} +
+ ${this.code && page.element + ? html`` + : page.content} +
${index > 0 ? html``} - ${page.primary + ${this.code && page.element + ? html` this.act(codeAction(page.element!))} + icon="code" + label="${translate('save')}" + trailingIcon + dialogInitialFocus + >` + : page.primary ? html` this.act(page.primary?.action)} @@ -195,6 +263,16 @@ export class WizardDialog extends LitElement { --mdc-dialog-max-width: 92vw; } + mwc-dialog > mwc-icon-button-toggle { + position: absolute; + top: 8px; + right: 14px; + } + + mwc-dialog > mwc-icon-button-toggle[on] { + color: var(--mdc-theme-primary); + } + #wizard-content { display: flex; flex-direction: column; From cdee4faeab5247aa5bccb847ee4c209fa9480b42 Mon Sep 17 00:00:00 2001 From: Christian Dinkel Date: Thu, 1 Jul 2021 10:06:08 +0200 Subject: [PATCH 3/7] feat(wizard-dialog): require pro mode for code editor --- src/Setting.ts | 23 +++++++++++++++++++++-- src/open-scd.ts | 2 +- src/translations/de.ts | 1 + src/translations/en.ts | 1 + src/wizard-dialog.ts | 8 ++++++-- src/wizards.ts | 3 +++ 6 files changed, 33 insertions(+), 5 deletions(-) diff --git a/src/Setting.ts b/src/Setting.ts index 9f065e2cf..74c3de4fe 100644 --- a/src/Setting.ts +++ b/src/Setting.ts @@ -7,12 +7,18 @@ import { Switch } from '@material/mwc-switch'; import { ifImplemented, LitElementConstructor, Mixin } from './foundation.js'; import { Language, languages, loader } from './translations/loader.js'; +import { WizardDialog } from './wizard-dialog.js'; export type Settings = { language: Language; theme: 'light' | 'dark'; + mode: 'safe' | 'pro'; +}; +export const defaults: Settings = { + language: 'en', + theme: 'light', + mode: 'safe', }; -export const defaults: Settings = { language: 'en', theme: 'light' }; /** Mixin that saves [[`Settings`]] to `localStorage`, reflecting them in the * `settings` property, setting them through `setSetting(setting, value)`. */ @@ -26,6 +32,7 @@ export function Setting(Base: TBase) { return { language: this.getSetting('language'), theme: this.getSetting('theme'), + mode: this.getSetting('mode'), }; } @@ -35,6 +42,8 @@ export function Setting(Base: TBase) { languageUI!: Select; @query('#dark') darkThemeUI!: Switch; + @query('#mode') + modeUI!: Switch; private getSetting(setting: T): Settings[T] { return ( @@ -44,6 +53,9 @@ export function Setting(Base: TBase) { /** Update the `value` of `setting`, storing to `localStorage`. */ setSetting(setting: T, value: Settings[T]): void { localStorage.setItem(setting, (value)); + this.shadowRoot + ?.querySelector('wizard-dialog') + ?.requestUpdate(); this.requestUpdate(); } @@ -56,6 +68,7 @@ export function Setting(Base: TBase) { } else if (ae.detail?.action === 'save') { this.setSetting('language', this.languageUI.value); this.setSetting('theme', this.darkThemeUI.checked ? 'dark' : 'light'); + this.setSetting('mode', this.modeUI.checked ? 'pro' : 'safe'); this.requestUpdate('settings'); } } @@ -81,7 +94,7 @@ export function Setting(Base: TBase) { >
(Base: TBase) { ?checked=${this.settings.theme === 'dark'} > + + + ${translate('cancel')} diff --git a/src/open-scd.ts b/src/open-scd.ts index b463e0678..582234a76 100644 --- a/src/open-scd.ts +++ b/src/open-scd.ts @@ -124,7 +124,7 @@ export class OpenSCD extends Hosting( } mwc-dialog { - --mdc-dialog-max-width: 92vw; + --mdc-dialog-max-width: 98vw; } mwc-dialog > form { diff --git a/src/translations/de.ts b/src/translations/de.ts index 94e25f511..fa20244e9 100644 --- a/src/translations/de.ts +++ b/src/translations/de.ts @@ -32,6 +32,7 @@ export const de: Translations = { language: 'Sprache', languages: { de: 'Deutsch', en: 'Englisch (English)' }, dark: 'Dunkles Design', + mode: 'Profimodus', }, menu: { title: 'Menü', diff --git a/src/translations/en.ts b/src/translations/en.ts index 99a55eb9a..7d1644022 100644 --- a/src/translations/en.ts +++ b/src/translations/en.ts @@ -30,6 +30,7 @@ export const en = { language: 'Language', languages: { de: 'German (Deutsch)', en: 'English' }, dark: 'Dark theme', + mode: 'Pro mode', }, menu: { title: 'Menu', diff --git a/src/wizard-dialog.ts b/src/wizard-dialog.ts index 4e10b291c..3b214903b 100644 --- a/src/wizard-dialog.ts +++ b/src/wizard-dialog.ts @@ -91,7 +91,10 @@ export class WizardDialog extends LitElement { } get code(): boolean { - return this.dialog?.querySelector('mwc-icon-button-toggle')?.on ?? false; + return ( + (this.dialog?.querySelector('mwc-icon-button-toggle')?.on ?? false) && + localStorage.getItem('mode') === 'pro' + ); } /** Checks the inputs of all [[`WizardPage`]]s for validity. */ @@ -183,7 +186,7 @@ export class WizardDialog extends LitElement { heading=${page.title} @closed=${this.onClosed} > - ${page.element + ${page.element && localStorage.getItem('mode') === 'pro' ? html` mwc-icon-button-toggle[on] { diff --git a/src/wizards.ts b/src/wizards.ts index 9ae5fe7cd..ff2396156 100644 --- a/src/wizards.ts +++ b/src/wizards.ts @@ -4,6 +4,8 @@ import { repeat } from 'lit-html/directives/repeat'; import { get, translate } from 'lit-translate'; import { + Create, + Delete, EditorAction, identity, isEqual, @@ -13,6 +15,7 @@ import { Wizard, WizardActor, } from './foundation.js'; +import { WizardDialog } from './wizard-dialog.js'; interface MergeOptions { title?: string; From f40692d67279b8f953950bb97d9c31271a975036 Mon Sep 17 00:00:00 2001 From: Christian Dinkel Date: Fri, 2 Jul 2021 10:59:44 +0200 Subject: [PATCH 4/7] test(open-scd): update snapshot --- __snapshots__/open-scd.md | 37 +++++++++++++++++++++---------------- 1 file changed, 21 insertions(+), 16 deletions(-) diff --git a/__snapshots__/open-scd.md b/__snapshots__/open-scd.md index 1154a7305..b5c4276ae 100644 --- a/__snapshots__/open-scd.md +++ b/__snapshots__/open-scd.md @@ -54,8 +54,9 @@
- -
- Save project -
-
- +
+ + + + Date: Fri, 2 Jul 2021 12:01:32 +0200 Subject: [PATCH 5/7] test(wizard-dialog): test code editor mode --- __snapshots__/wizard-dialog.md | 22 ++++ .../validators/ValidateSchema.test.ts | 2 +- test/unit/wizard-dialog.test.ts | 110 ++++++++++++------ 3 files changed, 95 insertions(+), 39 deletions(-) create mode 100644 __snapshots__/wizard-dialog.md diff --git a/__snapshots__/wizard-dialog.md b/__snapshots__/wizard-dialog.md new file mode 100644 index 000000000..2ba60e6a3 --- /dev/null +++ b/__snapshots__/wizard-dialog.md @@ -0,0 +1,22 @@ +# `wizard-dialog` + +## `with a nonempty wizard property` + +## `in pro mode` + +#### `looks like its snapshot` + +```html + + + +``` + +#### `switches to code editor view on code toggle button click` + +```html + + + +``` + diff --git a/test/integration/validators/ValidateSchema.test.ts b/test/integration/validators/ValidateSchema.test.ts index 8b07ad73f..2aac809fd 100644 --- a/test/integration/validators/ValidateSchema.test.ts +++ b/test/integration/validators/ValidateSchema.test.ts @@ -43,7 +43,7 @@ describe('ValidateSchema plugin', () => { const lastEntry = parent.history.pop(); expect(lastEntry.kind).to.equal('info'); expect(lastEntry.title).to.contain('validation successful'); - }).timeout(5000); + }).timeout(15000); }); describe('for invalid SCL files', () => { diff --git a/test/unit/wizard-dialog.test.ts b/test/unit/wizard-dialog.test.ts index e434f4b3a..99508063a 100644 --- a/test/unit/wizard-dialog.test.ts +++ b/test/unit/wizard-dialog.test.ts @@ -1,14 +1,13 @@ import { html, fixture, expect } from '@open-wc/testing'; +import { Button } from '@material/mwc-button'; + import '../../src/wizard-textfield.js'; import '../../src/wizard-dialog.js'; import { WizardDialog } from '../../src/wizard-dialog.js'; -import { - EditorAction, - Wizard, - WizardActor, - WizardInput, -} from '../../src/foundation.js'; +import { EditorAction, WizardInput } from '../../src/foundation.js'; + +import './mock-editor.js'; describe('wizard-dialog', () => { let element: WizardDialog; @@ -62,7 +61,7 @@ describe('wizard-dialog', () => { }); it('advances to the second page on next button click', async () => { - await (( + (( element.shadowRoot!.querySelector('mwc-button[dialogaction="next"]') )).click(); await new Promise(resolve => setTimeout(resolve, 100)); // await animation @@ -74,7 +73,7 @@ describe('wizard-dialog', () => { element.next(); await element.updateComplete; expect(element.dialog).to.have.property('heading', 'Page 2'); - await (( + (( element.shadowRoot!.querySelector('mwc-button[dialogaction="prev"]') )).click(); await new Promise(resolve => setTimeout(resolve, 100)); // await animation @@ -82,30 +81,6 @@ describe('wizard-dialog', () => { expect(element.dialog).to.have.property('heading', 'Page 1'); }); - it('executes the secondary action on secondary button click', done => { - element.wizard[0].secondary!.action = () => { - done(); - return []; - }; - (( - element.dialog!.querySelector('mwc-button[slot="secondaryAction"]') - )).click(); - }); - - it('executes the primary action on primary button click', done => { - element.wizard[2].primary!.action = () => { - done(); - return []; - }; - element.next(); - element.next(); - element.updateComplete.then(() => - (( - element.dialog!.querySelector('mwc-button[slot="primaryAction"]') - )).click() - ); - }); - describe('with invalid inputs', () => { beforeEach(async () => { element.dialogs[1].querySelector( @@ -180,10 +155,7 @@ describe('wizard-dialog', () => { content: [], primary: { icon: 'anchor', - action: ( - inputs: WizardInput[], - wizard: Element - ): EditorAction[] => { + action: (): EditorAction[] => { return [ { new: { @@ -199,7 +171,7 @@ describe('wizard-dialog', () => { }, ]; await element.updateComplete; - await (( + (( element.shadowRoot!.querySelector('mwc-button[slot="primaryAction"]') )).click(); expect(element.wizard[0].primary).to.not.exist; @@ -217,10 +189,72 @@ describe('wizard-dialog', () => { }, ]; await element.updateComplete; - await (( + (( element.shadowRoot!.querySelector('mwc-button[slot="primaryAction"]') )).click(); expect(element.wizard[0].primary).to.exist; }); + + describe('in pro mode', () => { + let host: Element; + + beforeEach(async () => { + element = await fixture( + html`` + ).then(elm => elm.querySelector('wizard-dialog')!); + localStorage.setItem('mode', 'pro'); + element.requestUpdate(); + await element.updateComplete; + host = new DOMParser().parseFromString( + '', + 'application/xml' + ).documentElement; + element.wizard = [ + { + title: 'Page 1', + element: host.firstElementChild!, + content: [], + primary: { + icon: 'anchor', + action: () => [], + label: 'Test primary', + }, + }, + ]; + }); + + it('looks like its snapshot', () => expect(element).to.equalSnapshot()); + + it('switches to code editor view on code toggle button click', async () => { + element.dialog!.querySelector('mwc-icon-button-toggle')!.on = true; + element.requestUpdate(); + await element.updateComplete; + await element.dialog?.updateComplete; + expect(element).to.equalSnapshot(); + }); + + describe('in code editor mode', () => { + beforeEach(async () => { + element.dialog!.querySelector('mwc-icon-button-toggle')!.on = true; + element.requestUpdate(); + await element.updateComplete; + await element.dialog?.updateComplete; + }); + + it('commits the code action on primary button click', async () => { + element.dialog + ?.querySelector('ace-editor') + ?.setAttribute('value', ''); + await element.updateComplete; + element.dialog + ?.querySelector