diff --git a/modules/backend/formwidgets/codeeditor/assets/js/build/codeeditor.bundle.js b/modules/backend/formwidgets/codeeditor/assets/js/build/codeeditor.bundle.js index 344312cbd4..d3dfb96b03 100644 --- a/modules/backend/formwidgets/codeeditor/assets/js/build/codeeditor.bundle.js +++ b/modules/backend/formwidgets/codeeditor/assets/js/build/codeeditor.bundle.js @@ -1,4 +1,4 @@ -!function(){var e,t,i={6126:function(e,t,i){"use strict";var n=i(3891),o=i(7836);var s={initWith:function(e){const t=document.createElement("div"),i=e.editor.create(t),n=i.constructor.name,o=i.getModel().constructor.name;return{isInstanceValid:function(e){return e.constructor.name===n},isModelValid:function(e){return e.constructor.name===o},isRangesValid:function(e){return!!Array.isArray(e)&&e.every((function(e){return"object"==typeof e&&"Object"===e.constructor.name&&(!!e.hasOwnProperty("range")&&(!!Array.isArray(e.range)&&(4===e.range.length&&(!!e.range.every((e=>e>0&&parseInt(e)===e))&&((!e.hasOwnProperty("allowMultiline")||"boolean"==typeof e.allowMultiline)&&((!e.hasOwnProperty("label")||"string"==typeof e.label)&&(!e.hasOwnProperty("validate")||"function"==typeof e.validate)))))))}))}}}};const r=function(e,t,i){return"The value for the "+t+" should be of type "+(Array.isArray(e)?e.join(" | "):e)+". "+(i||"")};var a=function(){const e=function(e,t){return"object"!=typeof e||null===e?this.freeze?Object.freeze(e):e:e instanceof Date?this.freeze?Object.freeze(new Date(e)):new Date(e):t.call(this,e)},t=function(t,i){const n=Object.keys(t),o=new Array(n.length);for(let s=0;s=this[i])&&(e-=this[i]),t}.bind(this),{})},t=Object.create(Object.defineProperties({},{withProto:{value:1},freeze:{value:2}}));for(let i=0;i<=3;i++)e.call(t,i);return t}(),o={withProto:i.bind(n[1]),andFreeze:i.bind(n[2]),withProtoAndFreeze:i.bind(n[3])},s=i.bind(n[0]);for(let e in o)Object.defineProperty(s,e,{enumerable:!1,writable:!1,configurable:!1,value:o[e]});return s}();var l={SINGLE_LINE_HIGHLIGHT_CLASS:"editableArea--single-line",MULTI_LINE_HIGHLIGHT_CLASS:"editableArea--multi-line"};var h=function(e,t,i){const n=i.Range,o=function(e,t){const i=e.range,n=t.range;if(i[0]n)throw new Error("Provided Start Line("+e+") is out of bounds. Max Lines in content is "+n);o[t]=e;break;case 1:{let n=e;const s=o[0],r=i[s-1].length;if(n<0){if(n=r-Math.abs(n),n<0)throw new Error("Provided Start Column("+e+") is out of bounds. Max Column in line "+s+" is "+r)}else if(n>r+1)throw new Error("Provided Start Column("+e+") is out of bounds. Max Column in line "+s+" is "+r);o[t]=n}break;case 2:{let i=e;if(i<0){if(i=n-Math.abs(e),i<0)throw new Error("Provided End Line("+e+") is out of bounds. Max Lines in content is "+n);in)throw new Error("Provided End Line("+e+") is out of bounds. Max Lines in content is "+n);o[t]=i}break;case 3:{let n=e;const s=o[2],r=i[s-1].length;if(n<0){if(n=r-Math.abs(n),n<0)throw new Error("Provided End Column("+e+") is out of bounds. Max Column in line "+s+" is "+r)}else if(n>r+1)throw new Error("Provided Start Column("+e+") is out of bounds. Max Column in line "+s+" is "+r);o[t]=n}}})),o}(e.range,i),s=o[0],r=o[1],a=o[2],l=o[3];e._originalRange=o.slice(),e.range=new n(s,r,a,l),e.index=t,e.allowMultiline||(e.allowMultiline=n.spansMultipleLines(e.range)),e.label||(e.label=`[${s},${r} -> ${a}${l}]`)}))},h=function(){return s.reduce((function(e,t){return e[t.label]={allowMultiline:t.allowMultiline||!1,index:t.index,range:Object.assign({},t.range),originalRange:t._originalRange.slice()},e}),{})},d=function(){return Promise.resolve().then((function(){e.editInRestrictedArea=!0,e.undo(),e.editInRestrictedArea=!1,e._hasHighlight&&e._oldDecorationsSource&&(e.deltaDecorations(e._oldDecorations,e._oldDecorationsSource),e._oldDecorationsSource.forEach((function(t){t.range=e.getDecorationRange(t.id)})))}))},c=function(t,i,n,o,r,a){let l=i.endLineNumber,h=i.endColumn;t.prevRange=i,t.range=i.setEndPosition(n,o);const d=s.length;let c=r.length;const u=o-h,g=n-l,p=e._currentCursorPositions||[],m=p.length;if(c!==m&&(r=r.filter((function(e){const t=e.range;for(let e=0;el)break;i.startColumn+=u,i.endColumn+=u,t.range=i}for(let e=a+1;el){rangeMap[i.toString()]=o;break}i.startColumn+=u,i.endColumn+=u,t.range=i,rangeMap[i.toString()]=o}}},u=function(){console.debug("handler for unhandled promise rejection")},g=function(e){for(let t in e){const i=e[t];i.range=i.prevRange}},p=function(e,t){return!e.allowMultiline&&t.includes("\n")},m=function(e,t,i){return e.validate&&!e.validate(t,i,e.lastInfo)},f={_isRestrictedModel:!0,_isRestrictedValueValid:!0,_editableRangeChangeListener:[],_isCursorAtCheckPoint:function(t){t.some((function(t){const i=t.lineNumber,n=t.column,o=s.length;for(let t=0;t","ranges","Please refer constrained editor documentation for proper structure"))}throw new Error(r("ICodeEditor","editorInstance","This type interface can be found in monaco editor documentation"))},removeRestrictionsIn:function(e){if(o(e)){const t=e.uri.toString(),n=i[t];return n?n.disposeRestrictions():(console.warn("Current Model is not a restricted Model"),!1)}throw new Error(r("ICodeEditor","editorInstance","This type interface can be found in monaco editor documentation"))},disposeConstrainer:function(){if(l._editorInstance){const e=l._editorInstance.getDomNode();e&&e.removeEventListener("keydown",l._listener),l._onChangeModelDisposable&&l._onChangeModelDisposable.dispose(),delete l._listener,delete l._editorInstance._isInDevMode,delete l._editorInstance._devModeAction,delete l._editorInstance,delete l._onChangeModelDisposable;for(let e in i)delete i[e];return!0}return!1},toggleDevMode:function(){l._editorInstance._isInDevMode?(l._editorInstance._isInDevMode=!1,l._editorInstance._devModeAction.dispose(),delete l._editorInstance._devModeAction):(l._editorInstance._isInDevMode=!0,l._editorInstance._devModeAction=l._editorInstance.addAction({id:"showRange",label:"Show Range in console",contextMenuGroupId:"navigation",contextMenuOrder:1.5,run:function(e){const t=e.getSelections().reduce((function(e,{startLineNumber:t,endLineNumber:i,startColumn:n,endColumn:o}){return e.push("range : "+JSON.stringify([t,n,i,o])),e}),[]).join("\n");console.log("Selected Ranges : \n"+JSON.stringify(t,null,2))}}))}};for(let e in c)Object.defineProperty(d,e,{enumerable:!1,writable:!1,configurable:!1,value:c[e]});return Object.freeze(d)};function c(e,t){var i=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),i.push.apply(i,n)}return i}function u(e){for(var t=1;t{class t extends e.PluginBase{construct(e){this.element=e,this.elementObserver=null,this.config=this.snowboard.dataConfig(this,e),this.events=this.snowboard["backend.ui.eventHandler"](this,"backend.formwidget.codeeditor"),this.alias=this.config.get("alias"),this.model=null,this.valueListener=null,this.positionListener=null,this.selectionListener=null,this.resizeListener=!1,this.visibilityListener=!1,this.editor=null,this.container=this.element.querySelector(".editor-container"),this.valueBag=this.element.querySelector("[data-value-bag]"),this.statusBar=this.element.querySelector("[data-status-bar]"),this.statusBar&&(this.language=this.statusBar.querySelector(".language"),this.position=this.statusBar.querySelector(".position")),this.fullscreen=!1,this.cachedThemes={},this.resizeThrottle=null,this.callbacks={fullScreenChange:()=>this.onFullScreenChange(),resize:()=>{clearTimeout(this.resizeThrottle),this.resizeThrottle=setTimeout((()=>this.onResize()),80)},visibilityChange:()=>this.onVisibilityChange()},this.keybindings=[],this.customLineNumbering=null,this.observeElement()}defaults(){return{alias:null,autoCloseTags:!0,bracketColors:!1,codeFolding:!0,displayIndentGuides:!0,fontSize:12,highlightActiveLine:!0,language:"html",margin:0,readOnly:!1,semanticHighlighting:!0,selectionHighlighting:!0,showColors:!0,showGutter:!0,showInvisibles:!1,showMinimap:!0,showOccurrences:!0,showPrintMargin:!1,showScrollbar:!0,showSelectionOccurrences:!0,showSuggestions:!0,tabSize:4,theme:"vs-dark",useSoftTabs:!0,wordWrap:!0}}destruct(){this.dispose(),this.elementObserver&&this.elementObserver.disconnect(),this.visibilityListener&&(document.removeEventListener("visibilitychange",this.callbacks.visibilityChange),this.visibilityListener=!1)}dispose(){this.valueListener&&(this.valueListener.dispose(),this.valueListener=null),this.positionListener&&(this.positionListener.dispose(),this.positionListener=null),this.selectionListener&&(this.selectionListener.dispose(),this.selectionListener=null),this.resizeListener&&(window.removeEventListener("resize",this.callbacks.resize),this.resizeListener=!1),this.editor&&(this.editor.dispose(),this.editor=null),this.events.fire("dispose",this,this.editor)}observeElement(){this.elementObserver=new IntersectionObserver((e=>this.onObserve(e))),this.elementObserver.observe(this.element)}onObserve(e){e[0].isIntersecting?this.createEditor():this.dispose()}createEditor(){i.p=this.snowboard.url().to("/modules/backend/formwidgets/codeeditor/assets/"),this.container.style.height=null,this.container.style.height=getComputedStyle(this.container).height,this.editor=n.editor.create(this.element.querySelector(".editor-container"),this.getConfigOptions()),this.attachListeners(),this.loadTheme(),this.updateLanguage(),this.enableStatusBarActions(),this.registerKeyBindings(),this.events.fire("create",this,this.editor)}refresh(){this.dispose(),window.requestAnimationFrame((()=>this.createEditor()))}getConfigOptions(){const e={automaticLayout:!0,colorDecorators:this.config.get("showColors"),detectIndentation:!1,folding:this.config.get("codeFolding"),fontSize:this.config.get("fontSize"),guides:{bracketPairs:this.config.get("bracketColors"),bracketPairsHorizontal:!!this.config.get("bracketColors")&&"active",indentation:this.config.get("displayIndentGuides")},insertSpaces:this.config.get("useSoftTabs"),language:this.config.get("language"),lineNumbers:this.customLineNumbering?this.customLineNumbering:this.config.get("showGutter")?"on":"off",minimap:{enabled:this.config.get("showMinimap")},occurrencesHighlight:this.config.get("showOccurrences"),quickSuggestions:this.config.get("showSuggestions"),renderLineHighlight:this.getLineHighlightOption(),renderWhitespace:this.config.get("showInvisibles")?"all":"selection",scrollbar:{horizontalHasArrows:this.config.get("showScrollbar"),horizontalScrollbarSize:this.config.get("showScrollbar")?10:0,horizontalSliderSize:this.config.get("showScrollbar")?10:6,verticalHasArrows:this.config.get("showScrollbar"),verticalScrollbarSize:this.config.get("showScrollbar")?10:0,verticalSliderSize:this.config.get("showScrollbar")?10:6,useShadows:this.config.get("showScrollbar")},scrollBeyondLastLine:!1,selectionHighlight:this.config.get("showSelectionOccurrences"),"semanticHighlighting.enabled":!!this.config.get("semanticHighlighting")&&"configuredByTheme",tabSize:this.config.get("tabSize"),theme:this.config.get("theme"),value:this.valueBag.value};return"fluid"===this.config.get("wordWrap")?e.wordWrap="on":"number"==typeof this.config.get("wordWrap")?(e.wordWrap="bounded",e.wordWrapColumn=this.config.get("wordWrap")):e.wordWrap="off",this.config.get("showPrintMargin")&&(e.rulers=[80]),e}getLineHighlightOption(){return this.config.get("highlightActiveLine")?this.config.get("showGutter")?"all":"line":"none"}getEditor(){return this.editor}getModel(){return this.model}attachListeners(){this.model=this.editor.getModel(),this.valueListener=this.model.onDidChangeContent((()=>{this.valueBag.value=this.model.getValue(),this.events.fire("input",this.valueBag.value,this,this.editor)})),this.positionListener=this.editor.onDidChangeCursorPosition((e=>{this.updatePosition(e.position),this.events.fire("position",e)})),this.selectionListener=this.editor.onDidChangeCursorSelection((e=>{this.events.fire("selection",e)})),window.addEventListener("resize",this.callbacks.resize),this.resizeListener=!0,this.visibilityListener||(document.addEventListener("visibilitychange",this.callbacks.visibilityChange),this.visibilityListener=!0)}setConfig(e,t){this.config.set(e,t),this.editor&&(["showPrintMargin","lineNumbers"].includes(e)?this.refresh():this.editor.updateOptions(this.getConfigOptions()))}getValue(){return this.model.getValue()}setValue(e){this.model.setValue(e)}focus(){this.editor.focus()}getPosition(){return this.editor.getPosition()}getSelection(){return this.editor.getSelection()}getSafeSelection(){const e=this.editor.getSelection();return new n.Selection(e.startLineNumber,e.startColumn,e.endLineNumber,e.endColumn)}getSelections(){return this.editor.getSelections()}insert(e){return this.model.pushEditOperations(this.editor.getSelections(),[{forceMoveMarkers:!0,range:this.editor.getSelection(),text:e}])}wrap(e,t){return this.editor.getSelection().isEmpty()?this.insert(`${e}${t}`):this.model.pushEditOperations(this.editor.getSelections(),[{forceMoveMarkers:!0,range:this.editor.getSelection(),text:`${e}${this.editor.getModel().getValueInRange(this.editor.getSelection())}${t}`}],(()=>[this.editor.getSelection()]))}unwrap(e,t){if(this.editor.getSelection().isEmpty())return this.editor.getSelection();let i=this.editor.getModel().getValueInRange(this.editor.getSelection());return i.startsWith(e)&&(i=i.substring(e.length)),i.endsWith(t)&&(i=i.substring(0,i.length-t.length)),this.model.pushEditOperations(this.editor.getSelections(),[{forceMoveMarkers:!0,range:this.editor.getSelection(),text:i}],(()=>[this.editor.getSelection()]))}find(e,t){return this.findAll(e,t)[0]||null}findAll(e,t){const i=e instanceof RegExp?e.source:e;return this.model.findMatches(i,!0,e instanceof RegExp,t||!1,null,!0,1)}replace(e,t,i){const o=this.find(e,i);o&&this.model.pushEditOperations(this.editor.getSelections(),[{forceMoveMarkers:!1,range:new n.Range(o.range.startLineNumber,o.range.startColumn,o.range.endLineNumber,o.range.endColumn),text:t}])}setLanguage(e){n.editor.setModelLanguage(this.model,e),this.setConfig("language",e),this.updateLanguage()}updateLanguage(){this.language&&(this.language.innerText=this.getConfigOptions().language.toUpperCase())}loadTheme(e){const t=e||this.config.get("theme"),i=t.replace(/[^a-z0-9]+/g,"");return"vs"===t?(n.editor.setTheme("vs"),this.setConfig("theme","vs"),void this.updateStatusBarColor({colors:{"editor.foreground":"#000000","editor.background":"#ffffff"}})):"vs-dark"===t?(n.editor.setTheme("vs-dark"),this.setConfig("theme","vs-dark"),void this.updateStatusBarColor({colors:{"editor.foreground":"#d4d4d4","editor.background":"#1E1E1E"}})):void(this.cachedThemes[t]?(n.editor.setTheme(i),this.setConfig("theme",i),this.updateStatusBarColor(this.cachedThemes[t])):this.snowboard.request(this.element,this.alias?`${this.alias}::onLoadTheme`:"onLoadTheme",{data:{theme:e||this.config.get("theme")},success:e=>{if(e.result){const o=this.convertTmTheme(e.result);this.cachedThemes[t]=o,n.editor.defineTheme(i,o),n.editor.setTheme(i),this.setConfig("theme",i),this.updateStatusBarColor(o)}},error:()=>{console.log(`Unable to load theme "${t}"`)}}))}convertTmTheme(e){const t=(0,o.Qc)(e),i=this.mapGlobalColors(t.settings.shift().settings),n=[{token:"",foreground:i["editor.foreground"].replace(/^#/,""),background:i["editor.background"].replace(/^#/,"")}];return t.settings.forEach((e=>{if(!e.scope)return;const t={token:e.scope};e.settings.foreground&&(t.foreground=this.parseColor(e.settings.foreground).replace(/^#/,"")),e.settings.background&&(t.background=this.parseColor(e.settings.background).replace(/^#/,"")),e.settings.fontStyle&&(t.fontStyle=e.settings.fontStyle),n.push(t)})),{base:this.isDarkTheme(i["editor.background"])?"vs-dark":"vs",inherit:!1,rules:this.populateMissingScopes(n),colors:i}}mapGlobalColors(e){const t={};return[{tm:"foreground",mn:"editor.foreground"},{tm:"background",mn:"editor.background"},{tm:"selection",mn:"editor.selectionBackground"},{tm:"inactiveSelection",mn:"editor.inactiveSelectionBackground"},{tm:"selectionHighlightColor",mn:"editor.selectionHighlightBackground"},{tm:"findMatchHighlight",mn:"editor.findMatchHighlightBackground"},{tm:"currentFindMatchHighlight",mn:"editor.findMatchBackground"},{tm:"hoverHighlight",mn:"editor.hoverHighlightBackground"},{tm:"wordHighlight",mn:"editor.wordHighlightBackground"},{tm:"wordHighlightStrong",mn:"editor.wordHighlightStrongBackground"},{tm:"findRangeHighlight",mn:"editor.findRangeHighlightBackground"},{tm:"findMatchHighlight",mn:"peekViewResult.matchHighlightBackground"},{tm:"referenceHighlight",mn:"peekViewEditor.matchHighlightBackground"},{tm:"lineHighlight",mn:"editor.lineHighlightBackground"},{tm:"rangeHighlight",mn:"editor.rangeHighlightBackground"},{tm:"guide",mn:"editorIndentGuide.background"},{tm:"activeGuide",mn:"editorIndentGuide.activeBackground"},{tm:"selectionBorder",mn:"editor.selectionHighlightBorder"}].forEach((i=>{e[i.tm]&&(t[i.mn]=this.parseColor(e[i.tm]))})),t}parseColor(e){let t=e;if(!t.length)return null;if(4===t.length&&(t=e.replace(/[a-fA-F\d]/g,"$&$&")),7===t.length)return t;if(9===e.length)return e;e.match(/^#(..)(..)(..)(..)$/)||console.error("can't parse color",e);const i=e.match(/^#(..)(..)(..)(..)$/).slice(1).map((e=>parseInt(e,16)));return i[3]=(i[3]/255).toPrecision(2),`rgba(${i.join(", ")})`}rgbColor(e){return"object"==typeof e?e:"#"===e[0]?e.match(/^#(..)(..)(..)/).slice(1).map((e=>parseInt(e,16))):e.match(/\(([^,]+),([^,]+),([^,]+)/).slice(1).map((e=>parseInt(e,10)))}isDarkTheme(e){const t=this.rgbColor(e);return(.21*t[0]+.72*t[1]+.07*t[2])/255<.5}populateMissingScopes(e){const t={};Object.entries({comment:["comment.block","comment.line"],number:["constant.numeric","constant.number","string.number"],regexp:["string.regexp"],tag:["meta.tag","entity.name.tag"],metatag:["meta.tag","declaration.tag","constant.language","entity.name.tag"],annotation:["meta.embedded","meta.annotation","string.annotation","comment.block","comment.line"],attribute:["entity.other.attribute-name","support.type.property-name"],identifier:["entity.name.function","meta.tag","declaration.tag","constant.language","entity.name.tag","support.type"],type:["support.type","support.function"],operator:["support.constant","constant.numeric","constant.number","string.number","support"],"attribute.name":["support.type","support.constant","entity.other.attribute-name","support.type.property-name"],"attribute.value.html":["string.quoted.double.html","string.quoted.single.html","string.quoted.double","string.quoted.single","string"],"attribute.value.unit":["keyword.unit","support.unit","keyword","support","number","string.number","constant.numeric","constant.number"],"attribute.value.number":["number","string.number","constant.numeric","constant.number"]}).forEach((e=>{let[i,n]=e;t[i]={scope:i,map:n,currentSettings:null,currentRank:null}})),e.forEach((e=>{if(!e.token)return;e.token.split(/, +/).forEach(((i,n)=>{i.split(/ +/).forEach(((i,o)=>{const s=Object.values(t).filter((e=>e.map.filter((e=>i.startsWith(e))).length>0));s.length&&s.forEach((s=>{const r=10-n-2*o-(s.map.includes(i)?s.map.indexOf(i):5);null!==s.currentRank&&s.currentRank>=r||(t[s.scope].currentSettings={},t[s.scope].currentRank=r,e.foreground&&(t[s.scope].currentSettings.foreground=e.foreground),e.background&&(t[s.scope].currentSettings.background=e.background),e.fontStyle&&(t[s.scope].currentSettings.fontStyle=e.fontStyle))}))}))}))})),Object.values(t).forEach((t=>{if(!t.currentSettings)return;if(e.some((e=>e.token===t.scope)))return;const i={token:t.scope};t.currentSettings.foreground&&(i.foreground=t.currentSettings.foreground),t.currentSettings.background&&(i.background=t.currentSettings.background),t.currentSettings.fontStyle&&(i.fontStyle=t.currentSettings.fontStyle),e.push(i)}));const i=[];return e.forEach((e=>{if(-1===e.token.indexOf(","))return void i.push(e);e.token.split(/, +/).forEach((t=>{i.push({token:t,foreground:e.foreground,background:e.background,fontStyle:e.fontStyle})}))})),i}updatePosition(e){this.position&&(this.position.innerText=`Line ${e.lineNumber}, Column ${e.column}`)}updateStatusBarColor(e){if(!this.statusBar)return;const t=e.colors["editor.foreground"],i=e.colors["editor.background"];this.isDarkTheme(i)?this.statusBar.classList.add("is-dark"):this.statusBar.classList.remove("is-dark"),this.statusBar.style.color=t,this.statusBar.style.backgroundColor=i}enableStatusBarActions(){if(!this.statusBar)return;const e=this.statusBar.querySelector("[data-full-screen]");e.addEventListener("click",(()=>{this.fullscreen?document.exitFullscreen():this.element.requestFullscreen({navigationUI:"hide"}).then((()=>{this.fullscreen=!0,e.classList.add("active"),this.element.addEventListener("fullscreenchange",this.callbacks.fullScreenChange),this.refresh()}))}))}onFullScreenChange(){document.fullscreenElement||(this.fullscreen=!1,this.statusBar&&this.statusBar.querySelector("[data-full-screen]").classList.remove("active"),this.element.removeEventListener("fullscreenchange",this.callbacks.fullScreenChange),this.refresh())}onResize(){this.refresh()}onVisibilityChange(){document.hidden?this.dispose():this.createEditor()}fromLine(e){if(e<=1)return void(this.customLineNumbering=null);const t=this.getModel().getFullModelRange().endLineNumber,i=this.getModel().getFullModelRange().endColumn;if(e>t)throw this.customLineNumbering=null,new Error("The line number is greater than the number of lines in the editor.");const o=new n.Range(1,1,e-1,i),s=new n.Range(e,1,t,i),r=d(n);r.initializeIn(this.editor),r.addRestrictionsTo(this.getModel(),[{range:[s.startLineNumber,s.startColumn,s.endLineNumber,s.endColumn],allowMultiline:!0}]),this.editor.setHiddenAreas([o]),this.config.get("showGutter")&&(this.customLineNumbering=t=>t>=e?String(t-e+1):"",this.editor.updateOptions(this.getConfigOptions()))}addKeyBinding(e,t){const i=this.normalizeKeyBinding(e);if(this.keybindings.push({keybinding:i,callback:t}),this.editor){const e=n.KeyCode[`Key${i.key.toUpperCase()}`];let o=0;i.shift&&(o|=n.KeyMod.Shift),i.ctrl&&(o|=n.KeyMod.CtrlCmd),i.alt&&(o|=n.KeyMod.Alt),o|=e,this.editor.addCommand(o,t)}}removeKeyBinding(e){const t=this.normalizeKeyBinding(e),i=this.keybindings.findIndex((e=>e.keybinding===t));-1!==i&&(this.keybindings[i].callback=()=>{})}normalizeKeyBinding(e){let t={key:null,ctrl:!1,alt:!1,shift:!1};return"string"==typeof e?e.startsWith("Shift+Ctrl+")?(t.key=e.replace("Shift+Ctrl+",""),t.shift=!0,t.ctrl=!0):e.startsWith("Shift+Alt+")?(t.key=e.replace("Shift+Alt+",""),t.shift=!0,t.ctrl=!0):e.startsWith("Ctrl+")?(t.key=e.replace("Ctrl+",""),t.ctrl=!0):e.startsWith("Alt+")&&(t.key=e.replace("Alt+",""),t.alt=!0):t=u(u({},t),e),t}registerKeyBindings(){0!==this.keybindings.length&&this.keybindings.forEach((e=>{const t=n.KeyCode[`Key${e.keybinding.key.toUpperCase()}`];let i=0;e.keybinding.shift&&(i|=n.KeyMod.Shift),e.keybinding.ctrl&&(i|=n.KeyMod.CtrlCmd),e.keybinding.alt&&(i|=n.KeyMod.Alt),i|=t,this.editor.addCommand(i,e.callback)}))}}e.addPlugin("backend.formwidgets.codeeditor",t),e["backend.ui.widgetHandler"]().register("codeeditor","backend.formwidgets.codeeditor")})(window.Snowboard)},2538:function(e,t){"use strict";t.byteLength=function(e){var t=a(e),i=t[0],n=t[1];return 3*(i+n)/4-n},t.toByteArray=function(e){var t,i,s=a(e),r=s[0],l=s[1],h=new o(function(e,t,i){return 3*(t+i)/4-i}(0,r,l)),d=0,c=l>0?r-4:r;for(i=0;i>16&255,h[d++]=t>>8&255,h[d++]=255&t;2===l&&(t=n[e.charCodeAt(i)]<<2|n[e.charCodeAt(i+1)]>>4,h[d++]=255&t);1===l&&(t=n[e.charCodeAt(i)]<<10|n[e.charCodeAt(i+1)]<<4|n[e.charCodeAt(i+2)]>>2,h[d++]=t>>8&255,h[d++]=255&t);return h},t.fromByteArray=function(e){for(var t,n=e.length,o=n%3,s=[],r=16383,a=0,h=n-o;ah?h:a+r));1===o?(t=e[n-1],s.push(i[t>>2]+i[t<<4&63]+"==")):2===o&&(t=(e[n-2]<<8)+e[n-1],s.push(i[t>>10]+i[t>>4&63]+i[t<<2&63]+"="));return s.join("")};for(var i=[],n=[],o="undefined"!=typeof Uint8Array?Uint8Array:Array,s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",r=0;r<64;++r)i[r]=s[r],n[s.charCodeAt(r)]=r;function a(e){var t=e.length;if(t%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var i=e.indexOf("=");return-1===i&&(i=t),[i,i===t?0:4-i%4]}function l(e,t,n){for(var o,s,r=[],a=t;a>18&63]+i[s>>12&63]+i[s>>6&63]+i[63&s]);return r.join("")}n["-".charCodeAt(0)]=62,n["_".charCodeAt(0)]=63},1104:function(e,t,i){"use strict";var n=i(2538),o=i(8494),s=i(7002); +!function(){var e,t,i={6126:function(e,t,i){"use strict";var n=i(3891),o=i(7836);var s={initWith:function(e){const t=document.createElement("div"),i=e.editor.create(t),n=i.constructor.name,o=i.getModel().constructor.name;return{isInstanceValid:function(e){return e.constructor.name===n},isModelValid:function(e){return e.constructor.name===o},isRangesValid:function(e){return!!Array.isArray(e)&&e.every((function(e){return"object"==typeof e&&"Object"===e.constructor.name&&(!!e.hasOwnProperty("range")&&(!!Array.isArray(e.range)&&(4===e.range.length&&(!!e.range.every((e=>e>0&&parseInt(e)===e))&&((!e.hasOwnProperty("allowMultiline")||"boolean"==typeof e.allowMultiline)&&((!e.hasOwnProperty("label")||"string"==typeof e.label)&&(!e.hasOwnProperty("validate")||"function"==typeof e.validate)))))))}))}}}};const r=function(e,t,i){return"The value for the "+t+" should be of type "+(Array.isArray(e)?e.join(" | "):e)+". "+(i||"")};var a=function(){const e=function(e,t){return"object"!=typeof e||null===e?this.freeze?Object.freeze(e):e:e instanceof Date?this.freeze?Object.freeze(new Date(e)):new Date(e):t.call(this,e)},t=function(t,i){const n=Object.keys(t),o=new Array(n.length);for(let s=0;s=this[i])&&(e-=this[i]),t}.bind(this),{})},t=Object.create(Object.defineProperties({},{withProto:{value:1},freeze:{value:2}}));for(let i=0;i<=3;i++)e.call(t,i);return t}(),o={withProto:i.bind(n[1]),andFreeze:i.bind(n[2]),withProtoAndFreeze:i.bind(n[3])},s=i.bind(n[0]);for(let e in o)Object.defineProperty(s,e,{enumerable:!1,writable:!1,configurable:!1,value:o[e]});return s}();var l={SINGLE_LINE_HIGHLIGHT_CLASS:"editableArea--single-line",MULTI_LINE_HIGHLIGHT_CLASS:"editableArea--multi-line"};var h=function(e,t,i){const n=i.Range,o=function(e,t){const i=e.range,n=t.range;if(i[0]n)throw new Error("Provided Start Line("+e+") is out of bounds. Max Lines in content is "+n);o[t]=e;break;case 1:{let n=e;const s=o[0],r=i[s-1].length;if(n<0){if(n=r-Math.abs(n),n<0)throw new Error("Provided Start Column("+e+") is out of bounds. Max Column in line "+s+" is "+r)}else if(n>r+1)throw new Error("Provided Start Column("+e+") is out of bounds. Max Column in line "+s+" is "+r);o[t]=n}break;case 2:{let i=e;if(i<0){if(i=n-Math.abs(e),i<0)throw new Error("Provided End Line("+e+") is out of bounds. Max Lines in content is "+n);in)throw new Error("Provided End Line("+e+") is out of bounds. Max Lines in content is "+n);o[t]=i}break;case 3:{let n=e;const s=o[2],r=i[s-1].length;if(n<0){if(n=r-Math.abs(n),n<0)throw new Error("Provided End Column("+e+") is out of bounds. Max Column in line "+s+" is "+r)}else if(n>r+1)throw new Error("Provided Start Column("+e+") is out of bounds. Max Column in line "+s+" is "+r);o[t]=n}}})),o}(e.range,i),s=o[0],r=o[1],a=o[2],l=o[3];e._originalRange=o.slice(),e.range=new n(s,r,a,l),e.index=t,e.allowMultiline||(e.allowMultiline=n.spansMultipleLines(e.range)),e.label||(e.label=`[${s},${r} -> ${a}${l}]`)}))},h=function(){return s.reduce((function(e,t){return e[t.label]={allowMultiline:t.allowMultiline||!1,index:t.index,range:Object.assign({},t.range),originalRange:t._originalRange.slice()},e}),{})},d=function(){return Promise.resolve().then((function(){e.editInRestrictedArea=!0,e.undo(),e.editInRestrictedArea=!1,e._hasHighlight&&e._oldDecorationsSource&&(e.deltaDecorations(e._oldDecorations,e._oldDecorationsSource),e._oldDecorationsSource.forEach((function(t){t.range=e.getDecorationRange(t.id)})))}))},c=function(t,i,n,o,r,a){let l=i.endLineNumber,h=i.endColumn;t.prevRange=i,t.range=i.setEndPosition(n,o);const d=s.length;let c=r.length;const u=o-h,g=n-l,p=e._currentCursorPositions||[],m=p.length;if(c!==m&&(r=r.filter((function(e){const t=e.range;for(let e=0;el)break;i.startColumn+=u,i.endColumn+=u,t.range=i}for(let e=a+1;el){rangeMap[i.toString()]=o;break}i.startColumn+=u,i.endColumn+=u,t.range=i,rangeMap[i.toString()]=o}}},u=function(){console.debug("handler for unhandled promise rejection")},g=function(e){for(let t in e){const i=e[t];i.range=i.prevRange}},p=function(e,t){return!e.allowMultiline&&t.includes("\n")},m=function(e,t,i){return e.validate&&!e.validate(t,i,e.lastInfo)},f={_isRestrictedModel:!0,_isRestrictedValueValid:!0,_editableRangeChangeListener:[],_isCursorAtCheckPoint:function(t){t.some((function(t){const i=t.lineNumber,n=t.column,o=s.length;for(let t=0;t","ranges","Please refer constrained editor documentation for proper structure"))}throw new Error(r("ICodeEditor","editorInstance","This type interface can be found in monaco editor documentation"))},removeRestrictionsIn:function(e){if(o(e)){const t=e.uri.toString(),n=i[t];return n?n.disposeRestrictions():(console.warn("Current Model is not a restricted Model"),!1)}throw new Error(r("ICodeEditor","editorInstance","This type interface can be found in monaco editor documentation"))},disposeConstrainer:function(){if(l._editorInstance){const e=l._editorInstance.getDomNode();e&&e.removeEventListener("keydown",l._listener),l._onChangeModelDisposable&&l._onChangeModelDisposable.dispose(),delete l._listener,delete l._editorInstance._isInDevMode,delete l._editorInstance._devModeAction,delete l._editorInstance,delete l._onChangeModelDisposable;for(let e in i)delete i[e];return!0}return!1},toggleDevMode:function(){l._editorInstance._isInDevMode?(l._editorInstance._isInDevMode=!1,l._editorInstance._devModeAction.dispose(),delete l._editorInstance._devModeAction):(l._editorInstance._isInDevMode=!0,l._editorInstance._devModeAction=l._editorInstance.addAction({id:"showRange",label:"Show Range in console",contextMenuGroupId:"navigation",contextMenuOrder:1.5,run:function(e){const t=e.getSelections().reduce((function(e,{startLineNumber:t,endLineNumber:i,startColumn:n,endColumn:o}){return e.push("range : "+JSON.stringify([t,n,i,o])),e}),[]).join("\n");console.log("Selected Ranges : \n"+JSON.stringify(t,null,2))}}))}};for(let e in c)Object.defineProperty(d,e,{enumerable:!1,writable:!1,configurable:!1,value:c[e]});return Object.freeze(d)};function c(e,t){var i=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),i.push.apply(i,n)}return i}function u(e){for(var t=1;t{class t extends e.PluginBase{construct(e){this.element=e,this.elementObserver=null,this.config=this.snowboard.dataConfig(this,e),this.events=this.snowboard["backend.ui.eventHandler"](this,"backend.formwidget.codeeditor"),this.alias=this.config.get("alias"),this.model=null,this.valueListener=null,this.positionListener=null,this.selectionListener=null,this.resizeListener=!1,this.visibilityListener=!1,this.editor=null,this.container=this.element.querySelector(".editor-container"),this.valueBag=this.element.querySelector("[data-value-bag]"),this.statusBar=this.element.querySelector("[data-status-bar]"),this.statusBar&&(this.language=this.statusBar.querySelector(".language"),this.position=this.statusBar.querySelector(".position")),this.fullscreen=!1,this.cachedThemes={},this.resizeThrottle=null,this.callbacks={fullScreenChange:()=>this.onFullScreenChange(),resize:()=>{clearTimeout(this.resizeThrottle),this.resizeThrottle=setTimeout((()=>this.onResize()),80)},visibilityChange:()=>this.onVisibilityChange()},this.keybindings=[],this.customLineNumbering=null,this.observeElement()}defaults(){return{alias:null,autoCloseTags:!0,bracketColors:!1,codeFolding:!0,displayIndentGuides:!0,fontSize:12,highlightActiveLine:!0,language:"html",margin:0,readOnly:!1,semanticHighlighting:!0,selectionHighlighting:!0,showColors:!0,showGutter:!0,showInvisibles:!1,showMinimap:!0,showOccurrences:!0,showPrintMargin:!1,showScrollbar:!0,showSelectionOccurrences:!0,showSuggestions:!0,tabSize:4,theme:"vs-dark",useSoftTabs:!0,wordWrap:!0}}destruct(){this.dispose(),this.elementObserver&&this.elementObserver.disconnect(),this.visibilityListener&&(document.removeEventListener("visibilitychange",this.callbacks.visibilityChange),this.visibilityListener=!1)}dispose(){this.valueListener&&(this.valueListener.dispose(),this.valueListener=null),this.positionListener&&(this.positionListener.dispose(),this.positionListener=null),this.selectionListener&&(this.selectionListener.dispose(),this.selectionListener=null),this.resizeListener&&(window.removeEventListener("resize",this.callbacks.resize),this.resizeListener=!1),this.editor&&(this.editor.dispose(),this.editor=null),this.events.fire("dispose",this,this.editor)}observeElement(){this.elementObserver=new IntersectionObserver((e=>this.onObserve(e))),this.elementObserver.observe(this.element)}onObserve(e){e[0].isIntersecting?this.createEditor():this.dispose()}createEditor(){i.p=this.snowboard.url().to("/modules/backend/formwidgets/codeeditor/assets/"),this.container.style.height=null,this.container.style.height=Math.round(Number(getComputedStyle(this.container).height.replace("px","")))+"px",this.editor=n.editor.create(this.element.querySelector(".editor-container"),this.getConfigOptions()),this.attachListeners(),this.loadTheme(),this.updateLanguage(),this.enableStatusBarActions(),this.registerKeyBindings(),this.events.fire("create",this,this.editor)}refresh(){this.dispose(),window.requestAnimationFrame((()=>this.createEditor()))}getConfigOptions(){const e={automaticLayout:!0,colorDecorators:this.config.get("showColors"),detectIndentation:!1,folding:this.config.get("codeFolding"),fontSize:this.config.get("fontSize"),guides:{bracketPairs:this.config.get("bracketColors"),bracketPairsHorizontal:!!this.config.get("bracketColors")&&"active",indentation:this.config.get("displayIndentGuides")},insertSpaces:this.config.get("useSoftTabs"),language:this.config.get("language"),lineNumbers:this.customLineNumbering?this.customLineNumbering:this.config.get("showGutter")?"on":"off",minimap:{enabled:this.config.get("showMinimap")},occurrencesHighlight:this.config.get("showOccurrences"),quickSuggestions:this.config.get("showSuggestions"),renderLineHighlight:this.getLineHighlightOption(),renderWhitespace:this.config.get("showInvisibles")?"all":"selection",scrollbar:{horizontalHasArrows:this.config.get("showScrollbar"),horizontalScrollbarSize:this.config.get("showScrollbar")?10:0,horizontalSliderSize:this.config.get("showScrollbar")?10:6,verticalHasArrows:this.config.get("showScrollbar"),verticalScrollbarSize:this.config.get("showScrollbar")?10:0,verticalSliderSize:this.config.get("showScrollbar")?10:6,useShadows:this.config.get("showScrollbar")},scrollBeyondLastLine:!1,selectionHighlight:this.config.get("showSelectionOccurrences"),"semanticHighlighting.enabled":!!this.config.get("semanticHighlighting")&&"configuredByTheme",tabSize:this.config.get("tabSize"),theme:this.config.get("theme"),value:this.valueBag.value};return"fluid"===this.config.get("wordWrap")?e.wordWrap="on":"number"==typeof this.config.get("wordWrap")?(e.wordWrap="bounded",e.wordWrapColumn=this.config.get("wordWrap")):e.wordWrap="off",this.config.get("showPrintMargin")&&(e.rulers=[80]),e}getLineHighlightOption(){return this.config.get("highlightActiveLine")?this.config.get("showGutter")?"all":"line":"none"}getEditor(){return this.editor}getModel(){return this.model}attachListeners(){this.model=this.editor.getModel(),this.valueListener=this.model.onDidChangeContent((()=>{this.valueBag.value=this.model.getValue(),this.events.fire("input",this.valueBag.value,this,this.editor)})),this.positionListener=this.editor.onDidChangeCursorPosition((e=>{this.updatePosition(e.position),this.events.fire("position",e)})),this.selectionListener=this.editor.onDidChangeCursorSelection((e=>{this.events.fire("selection",e)})),window.addEventListener("resize",this.callbacks.resize),this.resizeListener=!0,this.visibilityListener||(document.addEventListener("visibilitychange",this.callbacks.visibilityChange),this.visibilityListener=!0)}setConfig(e,t){this.config.set(e,t),this.editor&&(["showPrintMargin"].includes(e)?this.refresh():this.editor.updateOptions(this.getConfigOptions()))}getValue(){return this.model.getValue()}setValue(e){this.model.setValue(e)}focus(){this.editor.focus()}getPosition(){return this.editor.getPosition()}getSelection(){return this.editor.getSelection()}getSafeSelection(){const e=this.editor.getSelection();return new n.Selection(e.startLineNumber,e.startColumn,e.endLineNumber,e.endColumn)}getSelections(){return this.editor.getSelections()}insert(e){return this.model.pushEditOperations(this.editor.getSelections(),[{forceMoveMarkers:!0,range:this.editor.getSelection(),text:e}])}wrap(e,t){return this.editor.getSelection().isEmpty()?this.insert(`${e}${t}`):this.model.pushEditOperations(this.editor.getSelections(),[{forceMoveMarkers:!0,range:this.editor.getSelection(),text:`${e}${this.editor.getModel().getValueInRange(this.editor.getSelection())}${t}`}],(()=>[this.editor.getSelection()]))}unwrap(e,t){if(this.editor.getSelection().isEmpty())return this.editor.getSelection();let i=this.editor.getModel().getValueInRange(this.editor.getSelection());return i.startsWith(e)&&(i=i.substring(e.length)),i.endsWith(t)&&(i=i.substring(0,i.length-t.length)),this.model.pushEditOperations(this.editor.getSelections(),[{forceMoveMarkers:!0,range:this.editor.getSelection(),text:i}],(()=>[this.editor.getSelection()]))}find(e,t){return this.findAll(e,t)[0]||null}findAll(e,t){const i=e instanceof RegExp?e.source:e;return this.model.findMatches(i,!0,e instanceof RegExp,t||!1,null,!0,1)}replace(e,t,i){const o=this.find(e,i);o&&this.model.pushEditOperations(this.editor.getSelections(),[{forceMoveMarkers:!1,range:new n.Range(o.range.startLineNumber,o.range.startColumn,o.range.endLineNumber,o.range.endColumn),text:t}])}setLanguage(e){n.editor.setModelLanguage(this.model,e),this.setConfig("language",e),this.updateLanguage()}updateLanguage(){this.language&&(this.language.innerText=this.getConfigOptions().language.toUpperCase())}loadTheme(e){const t=e||this.config.get("theme"),i=t.replace(/[^a-z0-9]+/g,"");return"vs"===t?(n.editor.setTheme("vs"),this.setConfig("theme","vs"),void this.updateStatusBarColor({colors:{"editor.foreground":"#000000","editor.background":"#ffffff"}})):"vs-dark"===t?(n.editor.setTheme("vs-dark"),this.setConfig("theme","vs-dark"),void this.updateStatusBarColor({colors:{"editor.foreground":"#d4d4d4","editor.background":"#1E1E1E"}})):void(this.cachedThemes[t]?(n.editor.setTheme(i),this.setConfig("theme",i),this.updateStatusBarColor(this.cachedThemes[t])):this.snowboard.request(this.element,this.alias?`${this.alias}::onLoadTheme`:"onLoadTheme",{data:{theme:e||this.config.get("theme")},success:e=>{if(e.result){const o=this.convertTmTheme(e.result);this.cachedThemes[t]=o,n.editor.defineTheme(i,o),n.editor.setTheme(i),this.setConfig("theme",i),this.updateStatusBarColor(o)}},error:()=>{console.log(`Unable to load theme "${t}"`)}}))}convertTmTheme(e){const t=(0,o.Qc)(e),i=this.mapGlobalColors(t.settings.shift().settings),n=[{token:"",foreground:i["editor.foreground"].replace(/^#/,""),background:i["editor.background"].replace(/^#/,"")}];return t.settings.forEach((e=>{if(!e.scope)return;const t={token:e.scope};e.settings.foreground&&(t.foreground=this.parseColor(e.settings.foreground).replace(/^#/,"")),e.settings.background&&(t.background=this.parseColor(e.settings.background).replace(/^#/,"")),e.settings.fontStyle&&(t.fontStyle=e.settings.fontStyle),n.push(t)})),{base:this.isDarkTheme(i["editor.background"])?"vs-dark":"vs",inherit:!1,rules:this.populateMissingScopes(n),colors:i}}mapGlobalColors(e){const t={};return[{tm:"foreground",mn:"editor.foreground"},{tm:"background",mn:"editor.background"},{tm:"selection",mn:"editor.selectionBackground"},{tm:"inactiveSelection",mn:"editor.inactiveSelectionBackground"},{tm:"selectionHighlightColor",mn:"editor.selectionHighlightBackground"},{tm:"findMatchHighlight",mn:"editor.findMatchHighlightBackground"},{tm:"currentFindMatchHighlight",mn:"editor.findMatchBackground"},{tm:"hoverHighlight",mn:"editor.hoverHighlightBackground"},{tm:"wordHighlight",mn:"editor.wordHighlightBackground"},{tm:"wordHighlightStrong",mn:"editor.wordHighlightStrongBackground"},{tm:"findRangeHighlight",mn:"editor.findRangeHighlightBackground"},{tm:"findMatchHighlight",mn:"peekViewResult.matchHighlightBackground"},{tm:"referenceHighlight",mn:"peekViewEditor.matchHighlightBackground"},{tm:"lineHighlight",mn:"editor.lineHighlightBackground"},{tm:"rangeHighlight",mn:"editor.rangeHighlightBackground"},{tm:"guide",mn:"editorIndentGuide.background"},{tm:"activeGuide",mn:"editorIndentGuide.activeBackground"},{tm:"selectionBorder",mn:"editor.selectionHighlightBorder"}].forEach((i=>{e[i.tm]&&(t[i.mn]=this.parseColor(e[i.tm]))})),t}parseColor(e){let t=e;if(!t.length)return null;if(4===t.length&&(t=e.replace(/[a-fA-F\d]/g,"$&$&")),7===t.length)return t;if(9===e.length)return e;e.match(/^#(..)(..)(..)(..)$/)||console.error("can't parse color",e);const i=e.match(/^#(..)(..)(..)(..)$/).slice(1).map((e=>parseInt(e,16)));return i[3]=(i[3]/255).toPrecision(2),`rgba(${i.join(", ")})`}rgbColor(e){return"object"==typeof e?e:"#"===e[0]?e.match(/^#(..)(..)(..)/).slice(1).map((e=>parseInt(e,16))):e.match(/\(([^,]+),([^,]+),([^,]+)/).slice(1).map((e=>parseInt(e,10)))}isDarkTheme(e){const t=this.rgbColor(e);return(.21*t[0]+.72*t[1]+.07*t[2])/255<.5}populateMissingScopes(e){const t={};Object.entries({comment:["comment.block","comment.line"],number:["constant.numeric","constant.number","string.number"],regexp:["string.regexp"],tag:["meta.tag","entity.name.tag"],metatag:["meta.tag","declaration.tag","constant.language","entity.name.tag"],annotation:["meta.embedded","meta.annotation","string.annotation","comment.block","comment.line"],attribute:["entity.other.attribute-name","support.type.property-name"],identifier:["entity.name.function","meta.tag","declaration.tag","constant.language","entity.name.tag","support.type"],type:["support.type","support.function"],operator:["support.constant","constant.numeric","constant.number","string.number","support"],"attribute.name":["support.type","support.constant","entity.other.attribute-name","support.type.property-name"],"attribute.value.html":["string.quoted.double.html","string.quoted.single.html","string.quoted.double","string.quoted.single","string"],"attribute.value.unit":["keyword.unit","support.unit","keyword","support","number","string.number","constant.numeric","constant.number"],"attribute.value.number":["number","string.number","constant.numeric","constant.number"]}).forEach((e=>{let[i,n]=e;t[i]={scope:i,map:n,currentSettings:null,currentRank:null}})),e.forEach((e=>{if(!e.token)return;e.token.split(/, +/).forEach(((i,n)=>{i.split(/ +/).forEach(((i,o)=>{const s=Object.values(t).filter((e=>e.map.filter((e=>i.startsWith(e))).length>0));s.length&&s.forEach((s=>{const r=10-n-2*o-(s.map.includes(i)?s.map.indexOf(i):5);null!==s.currentRank&&s.currentRank>=r||(t[s.scope].currentSettings={},t[s.scope].currentRank=r,e.foreground&&(t[s.scope].currentSettings.foreground=e.foreground),e.background&&(t[s.scope].currentSettings.background=e.background),e.fontStyle&&(t[s.scope].currentSettings.fontStyle=e.fontStyle))}))}))}))})),Object.values(t).forEach((t=>{if(!t.currentSettings)return;if(e.some((e=>e.token===t.scope)))return;const i={token:t.scope};t.currentSettings.foreground&&(i.foreground=t.currentSettings.foreground),t.currentSettings.background&&(i.background=t.currentSettings.background),t.currentSettings.fontStyle&&(i.fontStyle=t.currentSettings.fontStyle),e.push(i)}));const i=[];return e.forEach((e=>{if(-1===e.token.indexOf(","))return void i.push(e);e.token.split(/, +/).forEach((t=>{i.push({token:t,foreground:e.foreground,background:e.background,fontStyle:e.fontStyle})}))})),i}updatePosition(e){this.position&&(this.position.innerText=`Line ${e.lineNumber}, Column ${e.column}`)}updateStatusBarColor(e){if(!this.statusBar)return;const t=e.colors["editor.foreground"],i=e.colors["editor.background"];this.isDarkTheme(i)?this.statusBar.classList.add("is-dark"):this.statusBar.classList.remove("is-dark"),this.statusBar.style.color=t,this.statusBar.style.backgroundColor=i}enableStatusBarActions(){if(!this.statusBar)return;const e=this.statusBar.querySelector("[data-full-screen]");e.addEventListener("click",(()=>{this.fullscreen?document.exitFullscreen():this.element.requestFullscreen({navigationUI:"hide"}).then((()=>{this.fullscreen=!0,e.classList.add("active"),this.element.addEventListener("fullscreenchange",this.callbacks.fullScreenChange),this.refresh()}))}))}onFullScreenChange(){document.fullscreenElement||(this.fullscreen=!1,this.statusBar&&this.statusBar.querySelector("[data-full-screen]").classList.remove("active"),this.element.removeEventListener("fullscreenchange",this.callbacks.fullScreenChange),this.refresh())}onResize(){this.refresh()}onVisibilityChange(){document.hidden?this.dispose():this.createEditor()}fromLine(e){if(e<=1)return void(this.customLineNumbering=null);const t=this.getModel().getFullModelRange().endLineNumber,i=this.getModel().getFullModelRange().endColumn;if(e>t)throw this.customLineNumbering=null,new Error("The line number is greater than the number of lines in the editor.");const o=new n.Range(1,1,e-1,i),s=new n.Range(e,1,t,i),r=d(n);r.initializeIn(this.editor),r.addRestrictionsTo(this.getModel(),[{range:[s.startLineNumber,s.startColumn,s.endLineNumber,s.endColumn],allowMultiline:!0}]),this.editor.setHiddenAreas([o]),this.config.get("showGutter")&&(this.customLineNumbering=t=>t>=e?String(t-e+1):"",this.editor.updateOptions(this.getConfigOptions()))}addKeyBinding(e,t){const i=this.normalizeKeyBinding(e);if(this.keybindings.push({keybinding:i,callback:t}),this.editor){const e=n.KeyCode[`Key${i.key.toUpperCase()}`];let o=0;i.shift&&(o|=n.KeyMod.Shift),i.ctrl&&(o|=n.KeyMod.CtrlCmd),i.alt&&(o|=n.KeyMod.Alt),o|=e,this.editor.addCommand(o,t)}}removeKeyBinding(e){const t=this.normalizeKeyBinding(e),i=this.keybindings.findIndex((e=>e.keybinding===t));-1!==i&&(this.keybindings[i].callback=()=>{})}normalizeKeyBinding(e){let t={key:null,ctrl:!1,alt:!1,shift:!1};return"string"==typeof e?e.startsWith("Shift+Ctrl+")?(t.key=e.replace("Shift+Ctrl+",""),t.shift=!0,t.ctrl=!0):e.startsWith("Shift+Alt+")?(t.key=e.replace("Shift+Alt+",""),t.shift=!0,t.ctrl=!0):e.startsWith("Ctrl+")?(t.key=e.replace("Ctrl+",""),t.ctrl=!0):e.startsWith("Alt+")&&(t.key=e.replace("Alt+",""),t.alt=!0):t=u(u({},t),e),t}registerKeyBindings(){0!==this.keybindings.length&&this.keybindings.forEach((e=>{const t=n.KeyCode[`Key${e.keybinding.key.toUpperCase()}`];let i=0;e.keybinding.shift&&(i|=n.KeyMod.Shift),e.keybinding.ctrl&&(i|=n.KeyMod.CtrlCmd),e.keybinding.alt&&(i|=n.KeyMod.Alt),i|=t,this.editor.addCommand(i,e.callback)}))}}e.addPlugin("backend.formwidgets.codeeditor",t),e["backend.ui.widgetHandler"]().register("codeeditor","backend.formwidgets.codeeditor")})(window.Snowboard)},2538:function(e,t){"use strict";t.byteLength=function(e){var t=a(e),i=t[0],n=t[1];return 3*(i+n)/4-n},t.toByteArray=function(e){var t,i,s=a(e),r=s[0],l=s[1],h=new o(function(e,t,i){return 3*(t+i)/4-i}(0,r,l)),d=0,c=l>0?r-4:r;for(i=0;i>16&255,h[d++]=t>>8&255,h[d++]=255&t;2===l&&(t=n[e.charCodeAt(i)]<<2|n[e.charCodeAt(i+1)]>>4,h[d++]=255&t);1===l&&(t=n[e.charCodeAt(i)]<<10|n[e.charCodeAt(i+1)]<<4|n[e.charCodeAt(i+2)]>>2,h[d++]=t>>8&255,h[d++]=255&t);return h},t.fromByteArray=function(e){for(var t,n=e.length,o=n%3,s=[],r=16383,a=0,h=n-o;ah?h:a+r));1===o?(t=e[n-1],s.push(i[t>>2]+i[t<<4&63]+"==")):2===o&&(t=(e[n-2]<<8)+e[n-1],s.push(i[t>>10]+i[t>>4&63]+i[t<<2&63]+"="));return s.join("")};for(var i=[],n=[],o="undefined"!=typeof Uint8Array?Uint8Array:Array,s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",r=0;r<64;++r)i[r]=s[r],n[s.charCodeAt(r)]=r;function a(e){var t=e.length;if(t%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var i=e.indexOf("=");return-1===i&&(i=t),[i,i===t?0:4-i%4]}function l(e,t,n){for(var o,s,r=[],a=t;a>18&63]+i[s>>12&63]+i[s>>6&63]+i[63&s]);return r.join("")}n["-".charCodeAt(0)]=62,n["_".charCodeAt(0)]=63},1104:function(e,t,i){"use strict";var n=i(2538),o=i(8494),s=i(7002); /*! * The buffer module from node.js, for the browser. * diff --git a/modules/backend/formwidgets/codeeditor/assets/js/index.js b/modules/backend/formwidgets/codeeditor/assets/js/index.js index c108ec2608..853a8050d2 100644 --- a/modules/backend/formwidgets/codeeditor/assets/js/index.js +++ b/modules/backend/formwidgets/codeeditor/assets/js/index.js @@ -206,7 +206,7 @@ import constrainedEditor from 'constrained-editor-plugin'; // Force a specific height on the container - stops Monaco from indefinitely trying // to resize if the container has a fluid height this.container.style.height = null; - this.container.style.height = getComputedStyle(this.container).height; + this.container.style.height = Math.round(Number(getComputedStyle(this.container).height.replace('px', ''))) + 'px'; this.editor = monaco.editor.create(this.element.querySelector('.editor-container'), this.getConfigOptions());