@kong-ui-public/monaco-editor 0.4.8 → 0.4.9-pr.2694.d983d66d0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -57,7 +57,7 @@ const te = "'JetBrains Mono', Consolas, monospace", oe = "12px", ne = "500", ae
|
|
|
57
57
|
}
|
|
58
58
|
});
|
|
59
59
|
typeof WorkerGlobalScope < "u" && globalThis instanceof WorkerGlobalScope;
|
|
60
|
-
const
|
|
60
|
+
const x = () => {
|
|
61
61
|
};
|
|
62
62
|
function ie(o, t) {
|
|
63
63
|
function e(...n) {
|
|
@@ -72,9 +72,9 @@ function ie(o, t) {
|
|
|
72
72
|
return e;
|
|
73
73
|
}
|
|
74
74
|
function se(o, t = {}) {
|
|
75
|
-
let e, n, r =
|
|
75
|
+
let e, n, r = x;
|
|
76
76
|
const i = (l) => {
|
|
77
|
-
clearTimeout(l), r(), r =
|
|
77
|
+
clearTimeout(l), r(), r = x;
|
|
78
78
|
};
|
|
79
79
|
let s;
|
|
80
80
|
return (l) => {
|
|
@@ -98,9 +98,9 @@ function de(o) {
|
|
|
98
98
|
return (t = e == null ? void 0 : e.$el) !== null && t !== void 0 ? t : e;
|
|
99
99
|
}
|
|
100
100
|
let g;
|
|
101
|
-
const
|
|
101
|
+
const F = /* @__PURE__ */ new Map();
|
|
102
102
|
function ce(o) {
|
|
103
|
-
return g || (g = _), o && !
|
|
103
|
+
return g || (g = _), o && !F.get(o) && (F.set(o, !0), _.languages.getLanguages().some((t) => t.id === o) || _.languages.register({ id: o })), g;
|
|
104
104
|
}
|
|
105
105
|
function ue(o, t) {
|
|
106
106
|
let e, n = !1;
|
|
@@ -145,6 +145,7 @@ function ue(o, t) {
|
|
|
145
145
|
language: t.language,
|
|
146
146
|
theme: r.theme,
|
|
147
147
|
model: B,
|
|
148
|
+
editContext: !1,
|
|
148
149
|
...t.monacoOptions
|
|
149
150
|
}), n = !0, r.editorStatus = "ready", r.hasContent = !!t.code.value, e.onDidChangeModelContent(() => {
|
|
150
151
|
var h;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(s,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("vue"),require("@kong/icons"),require("monaco-editor"),require("@kong-ui-public/i18n")):typeof define=="function"&&define.amd?define(["exports","vue","@kong/icons","monaco-editor","@kong-ui-public/i18n"],e):(s=typeof globalThis<"u"?globalThis:s||self,e(s["kong-ui-public-monaco-editor"]={},s.Vue,s.KongIcons,s.monaco,s["kong-ui-public-i18n"]))})(this,function(s,e,S,F,O){"use strict";function N(o){const n=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(o){for(const t in o)if(t!=="default"){const r=Object.getOwnPropertyDescriptor(o,t);Object.defineProperty(n,t,r.get?r:{enumerable:!0,get:()=>o[t]})}}return n.default=o,Object.freeze(n)}const C=N(F),x=Object.freeze({autoClosingQuotes:"always",automaticLayout:!0,bracketPairColorization:{enabled:!0},hideCursorInOverviewRuler:!0,fontFamily:"'JetBrains Mono', Consolas, monospace",fontSize:Number("12px".replace("px","")),fontWeight:"500",lineHeight:Number("20px".replace("px","")),formatOnPaste:!0,formatOnType:!0,lineNumbersMinChars:3,minimap:{enabled:!1},stickyScroll:{enabled:!0},suggest:{showWords:!1},quickSuggestions:!0,suggestOnTriggerCharacters:!0,wordBasedSuggestions:"off",overviewRulerLanes:0,renderWhitespace:"boundary",scrollBeyondLastLine:!1,roundedSelection:!1,wordWrapColumn:120,colorDecorators:!0,folding:!0,fixedOverflowWidgets:!0,tabSize:2,detectIndentation:!1,insertSpaces:!0,trimAutoWhitespace:!0,wordWrap:"bounded",find:{addExtraSpaceOnTop:!1}});typeof WorkerGlobalScope<"u"&&globalThis instanceof WorkerGlobalScope;const b=()=>{};function B(o,n){function t(...r){return new Promise((i,c)=>{Promise.resolve(o(()=>n.apply(this,r),{fn:n,thisArg:this,args:r})).then(i).catch(c)})}return t}function U(o,n={}){let t,r,i=b;const c=d=>{clearTimeout(d),i(),i=b};let l;return d=>{const y=e.toValue(o),u=e.toValue(n.maxWait);return t&&c(t),y<=0||u!==void 0&&u<=0?(r&&(c(r),r=void 0),Promise.resolve(d())):new Promise((_,a)=>{i=n.rejectOnCancel?a:_,l=d,u&&!r&&(r=setTimeout(()=>{t&&c(t),r=void 0,_(l())},u)),t=setTimeout(()=>{r&&c(r),r=void 0,_(d())},y)})}}function V(o,n=200,t={}){return B(U(n,t),o)}function W(o){var n;const t=e.toValue(o);return(n=t==null?void 0:t.$el)!==null&&n!==void 0?n:t}let g;const E=new Map;function D(o){return g||(g=C),o&&!E.get(o)&&(E.set(o,!0),C.languages.getLanguages().some(n=>n.id===o)||C.languages.register({id:o})),g}function I(o,n){let t,r=!1;const i=e.reactive({editorStatus:"loading",searchBoxIsRevealed:!1,hasContent:!1,theme:n.theme||"light"}),c=a=>{!r||!t||t.setValue(a)},l=a=>t==null?void 0:t.updateOptions({readOnly:a}),m=()=>t==null?void 0:t.focus(),d=a=>{try{if(!t||!a)return;t.focus(),t.trigger("keyboard",a,null)}catch(p){console.error(`useMonacoEditor: Failed to trigger command: ${a}`,p)}},y=()=>{var a;try{if(!t)return;if(i.searchBoxIsRevealed)return(a=t.getContribution("editor.contrib.findController"))==null?void 0:a.closeFindWidget();d("actions.find")}catch(p){console.error("useMonacoEditor: Failed to close findController.",p)}},u=V(()=>g==null?void 0:g.editor.remeasureFonts(),200);return(()=>{const a=D(n.language),p=a.Uri.parse(`inmemory://model/${n.language}-${crypto.randomUUID()}`),j=a.editor.createModel(n.code.value,n.language,p);e.watch(()=>e.toValue(o),H=>{var w;const M=W(H);if(!(M instanceof HTMLElement)){r=!1;return}if(!r){t=a.editor.create(M,{...x,readOnly:n.readOnly||!1,language:n.language,theme:i.theme,model:j,...n.monacoOptions}),r=!0,i.editorStatus="ready",i.hasContent=!!n.code.value,t.onDidChangeModelContent(()=>{var h;const f=t.getValue();i.hasContent=!!f.length,(h=n.onChanged)==null||h.call(n,f)}),(w=n.onCreated)==null||w.call(n),u();try{const f=t.getContribution("editor.contrib.findController");if(f){const h=f.getState();h.onFindReplaceStateChange(()=>{i.searchBoxIsRevealed=h.isRevealed})}}catch(f){console.error("useMonacoEditor: Failed to get the state of findController",f)}}},{immediate:!0,flush:"post"})})(),e.onMounted(u),e.onActivated(u),e.onBeforeUnmount(()=>{if(!t)return;const a=t.getModel();t.dispose(),a&&a.dispose()}),{editor:t,editorStates:i,setContent:c,setReadOnly:l,focus:m,remeasureFonts:u,toggleSearchWidget:y,triggerKeyboardCommand:d}}const R={editor:{messages:{empty_message:"The editor is currently empty. Start typing to add content.",empty_title:"No content available",loading_message:"Please wait while the {type} content is loaded.",loading_title:"{type} editor"}}};function K(){const o=O.createI18n("en-us",R);return{i18n:o,i18nT:O.i18nTComponent(o)}}const L=e.defineComponent({__name:"MonacoEditorStatusOverlay",props:{title:{},message:{},icon:{}},setup(o){return(n,t)=>{const r=e.resolveComponent("KEmptyState");return e.openBlock(),e.createBlock(r,{class:"monaco-editor-status-overlay",message:o.message,title:o.title},e.createSlots({_:2},[o.icon?{name:"icon",fn:e.withCtx(()=>[(e.openBlock(),e.createBlock(e.resolveDynamicComponent(o.icon),{decorative:""}))]),key:"0"}:void 0]),1032,["message","title"])}}}),T=(o,n)=>{const t=o.__vccOpts||o;for(const[r,i]of n)t[r]=i;return t},k=T(L,[["__scopeId","data-v-062eadb5"]]),P=T(e.defineComponent({__name:"MonacoEditor",props:e.mergeModels({theme:{default:"light"},language:{default:"markdown"},options:{default:()=>{}}},{modelValue:{type:String,required:!0},modelModifiers:{}}),emits:["update:modelValue"],setup(o){const n=e.useModel(o,"modelValue"),{i18n:t}=K(),r=e.useTemplateRef("editorRef"),i=e.computed(()=>o.theme==="dark"?"dark":"light"),c=e.computed(()=>l.editorStates.editorStatus==="ready"&&!l.editorStates.hasContent),l=I(r,{language:o.language,code:n,theme:i.value,monacoOptions:o.options,onChanged:m=>{n.value=m}});return(m,d)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["monaco-editor-container",[i.value,{loading:e.unref(l).editorStates.editorStatus==="loading"}]]),"data-testid":"monaco-editor-container"},[e.createElementVNode("div",{ref_key:"editorRef",ref:r,class:"monaco-editor-target","data-testid":"monaco-editor-target"},null,512),e.renderSlot(m.$slots,"state-loading",{isLoading:e.unref(l).editorStates.editorStatus==="loading"},()=>[e.createVNode(e.Transition,{name:"fade"},{default:e.withCtx(()=>[e.unref(l).editorStates.editorStatus==="loading"?(e.openBlock(),e.createBlock(k,{key:0,"data-testid":"monaco-editor-status-overlay-loading",icon:e.unref(S.ProgressIcon),message:e.unref(t).t("editor.messages.loading_message",{type:o.language}),title:e.unref(t).t("editor.messages.loading_title",{type:o.language})},null,8,["icon","message","title"])):e.createCommentVNode("",!0)]),_:1})],!0),e.renderSlot(m.$slots,"state-empty",{isEmpty:c.value},()=>[e.createVNode(e.Transition,{name:"fade"},{default:e.withCtx(()=>[c.value?(e.openBlock(),e.createBlock(k,{key:0,"data-testid":"monaco-editor-status-overlay-empty",icon:e.unref(S.CodeblockIcon),message:e.unref(t).t("editor.messages.empty_message"),title:e.unref(t).t("editor.messages.empty_title")},null,8,["icon","message","title"])):e.createCommentVNode("",!0)]),_:1})],!0)],2))}}),[["__scopeId","data-v-c8f35a88"]]);s.MonacoEditor=P,s.useMonacoEditor=I,Object.defineProperty(s,Symbol.toStringTag,{value:"Module"})});
|
|
1
|
+
(function(s,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("vue"),require("@kong/icons"),require("monaco-editor"),require("@kong-ui-public/i18n")):typeof define=="function"&&define.amd?define(["exports","vue","@kong/icons","monaco-editor","@kong-ui-public/i18n"],e):(s=typeof globalThis<"u"?globalThis:s||self,e(s["kong-ui-public-monaco-editor"]={},s.Vue,s.KongIcons,s.monaco,s["kong-ui-public-i18n"]))})(this,function(s,e,S,F,O){"use strict";function N(o){const n=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(o){for(const t in o)if(t!=="default"){const r=Object.getOwnPropertyDescriptor(o,t);Object.defineProperty(n,t,r.get?r:{enumerable:!0,get:()=>o[t]})}}return n.default=o,Object.freeze(n)}const C=N(F),x=Object.freeze({autoClosingQuotes:"always",automaticLayout:!0,bracketPairColorization:{enabled:!0},hideCursorInOverviewRuler:!0,fontFamily:"'JetBrains Mono', Consolas, monospace",fontSize:Number("12px".replace("px","")),fontWeight:"500",lineHeight:Number("20px".replace("px","")),formatOnPaste:!0,formatOnType:!0,lineNumbersMinChars:3,minimap:{enabled:!1},stickyScroll:{enabled:!0},suggest:{showWords:!1},quickSuggestions:!0,suggestOnTriggerCharacters:!0,wordBasedSuggestions:"off",overviewRulerLanes:0,renderWhitespace:"boundary",scrollBeyondLastLine:!1,roundedSelection:!1,wordWrapColumn:120,colorDecorators:!0,folding:!0,fixedOverflowWidgets:!0,tabSize:2,detectIndentation:!1,insertSpaces:!0,trimAutoWhitespace:!0,wordWrap:"bounded",find:{addExtraSpaceOnTop:!1}});typeof WorkerGlobalScope<"u"&&globalThis instanceof WorkerGlobalScope;const b=()=>{};function B(o,n){function t(...r){return new Promise((i,c)=>{Promise.resolve(o(()=>n.apply(this,r),{fn:n,thisArg:this,args:r})).then(i).catch(c)})}return t}function U(o,n={}){let t,r,i=b;const c=d=>{clearTimeout(d),i(),i=b};let l;return d=>{const y=e.toValue(o),u=e.toValue(n.maxWait);return t&&c(t),y<=0||u!==void 0&&u<=0?(r&&(c(r),r=void 0),Promise.resolve(d())):new Promise((_,a)=>{i=n.rejectOnCancel?a:_,l=d,u&&!r&&(r=setTimeout(()=>{t&&c(t),r=void 0,_(l())},u)),t=setTimeout(()=>{r&&c(r),r=void 0,_(d())},y)})}}function V(o,n=200,t={}){return B(U(n,t),o)}function W(o){var n;const t=e.toValue(o);return(n=t==null?void 0:t.$el)!==null&&n!==void 0?n:t}let g;const E=new Map;function D(o){return g||(g=C),o&&!E.get(o)&&(E.set(o,!0),C.languages.getLanguages().some(n=>n.id===o)||C.languages.register({id:o})),g}function I(o,n){let t,r=!1;const i=e.reactive({editorStatus:"loading",searchBoxIsRevealed:!1,hasContent:!1,theme:n.theme||"light"}),c=a=>{!r||!t||t.setValue(a)},l=a=>t==null?void 0:t.updateOptions({readOnly:a}),m=()=>t==null?void 0:t.focus(),d=a=>{try{if(!t||!a)return;t.focus(),t.trigger("keyboard",a,null)}catch(p){console.error(`useMonacoEditor: Failed to trigger command: ${a}`,p)}},y=()=>{var a;try{if(!t)return;if(i.searchBoxIsRevealed)return(a=t.getContribution("editor.contrib.findController"))==null?void 0:a.closeFindWidget();d("actions.find")}catch(p){console.error("useMonacoEditor: Failed to close findController.",p)}},u=V(()=>g==null?void 0:g.editor.remeasureFonts(),200);return(()=>{const a=D(n.language),p=a.Uri.parse(`inmemory://model/${n.language}-${crypto.randomUUID()}`),j=a.editor.createModel(n.code.value,n.language,p);e.watch(()=>e.toValue(o),H=>{var w;const M=W(H);if(!(M instanceof HTMLElement)){r=!1;return}if(!r){t=a.editor.create(M,{...x,readOnly:n.readOnly||!1,language:n.language,theme:i.theme,model:j,editContext:!1,...n.monacoOptions}),r=!0,i.editorStatus="ready",i.hasContent=!!n.code.value,t.onDidChangeModelContent(()=>{var h;const f=t.getValue();i.hasContent=!!f.length,(h=n.onChanged)==null||h.call(n,f)}),(w=n.onCreated)==null||w.call(n),u();try{const f=t.getContribution("editor.contrib.findController");if(f){const h=f.getState();h.onFindReplaceStateChange(()=>{i.searchBoxIsRevealed=h.isRevealed})}}catch(f){console.error("useMonacoEditor: Failed to get the state of findController",f)}}},{immediate:!0,flush:"post"})})(),e.onMounted(u),e.onActivated(u),e.onBeforeUnmount(()=>{if(!t)return;const a=t.getModel();t.dispose(),a&&a.dispose()}),{editor:t,editorStates:i,setContent:c,setReadOnly:l,focus:m,remeasureFonts:u,toggleSearchWidget:y,triggerKeyboardCommand:d}}const R={editor:{messages:{empty_message:"The editor is currently empty. Start typing to add content.",empty_title:"No content available",loading_message:"Please wait while the {type} content is loaded.",loading_title:"{type} editor"}}};function K(){const o=O.createI18n("en-us",R);return{i18n:o,i18nT:O.i18nTComponent(o)}}const L=e.defineComponent({__name:"MonacoEditorStatusOverlay",props:{title:{},message:{},icon:{}},setup(o){return(n,t)=>{const r=e.resolveComponent("KEmptyState");return e.openBlock(),e.createBlock(r,{class:"monaco-editor-status-overlay",message:o.message,title:o.title},e.createSlots({_:2},[o.icon?{name:"icon",fn:e.withCtx(()=>[(e.openBlock(),e.createBlock(e.resolveDynamicComponent(o.icon),{decorative:""}))]),key:"0"}:void 0]),1032,["message","title"])}}}),T=(o,n)=>{const t=o.__vccOpts||o;for(const[r,i]of n)t[r]=i;return t},k=T(L,[["__scopeId","data-v-062eadb5"]]),P=T(e.defineComponent({__name:"MonacoEditor",props:e.mergeModels({theme:{default:"light"},language:{default:"markdown"},options:{default:()=>{}}},{modelValue:{type:String,required:!0},modelModifiers:{}}),emits:["update:modelValue"],setup(o){const n=e.useModel(o,"modelValue"),{i18n:t}=K(),r=e.useTemplateRef("editorRef"),i=e.computed(()=>o.theme==="dark"?"dark":"light"),c=e.computed(()=>l.editorStates.editorStatus==="ready"&&!l.editorStates.hasContent),l=I(r,{language:o.language,code:n,theme:i.value,monacoOptions:o.options,onChanged:m=>{n.value=m}});return(m,d)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["monaco-editor-container",[i.value,{loading:e.unref(l).editorStates.editorStatus==="loading"}]]),"data-testid":"monaco-editor-container"},[e.createElementVNode("div",{ref_key:"editorRef",ref:r,class:"monaco-editor-target","data-testid":"monaco-editor-target"},null,512),e.renderSlot(m.$slots,"state-loading",{isLoading:e.unref(l).editorStates.editorStatus==="loading"},()=>[e.createVNode(e.Transition,{name:"fade"},{default:e.withCtx(()=>[e.unref(l).editorStates.editorStatus==="loading"?(e.openBlock(),e.createBlock(k,{key:0,"data-testid":"monaco-editor-status-overlay-loading",icon:e.unref(S.ProgressIcon),message:e.unref(t).t("editor.messages.loading_message",{type:o.language}),title:e.unref(t).t("editor.messages.loading_title",{type:o.language})},null,8,["icon","message","title"])):e.createCommentVNode("",!0)]),_:1})],!0),e.renderSlot(m.$slots,"state-empty",{isEmpty:c.value},()=>[e.createVNode(e.Transition,{name:"fade"},{default:e.withCtx(()=>[c.value?(e.openBlock(),e.createBlock(k,{key:0,"data-testid":"monaco-editor-status-overlay-empty",icon:e.unref(S.CodeblockIcon),message:e.unref(t).t("editor.messages.empty_message"),title:e.unref(t).t("editor.messages.empty_title")},null,8,["icon","message","title"])):e.createCommentVNode("",!0)]),_:1})],!0)],2))}}),[["__scopeId","data-v-c8f35a88"]]);s.MonacoEditor=P,s.useMonacoEditor=I,Object.defineProperty(s,Symbol.toStringTag,{value:"Module"})});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useMonacoEditor.d.ts","sourceRoot":"","sources":["../../../../src/composables/useMonacoEditor.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AAIvC,OAAO,KAAK,EAAE,uBAAuB,EAAE,YAAY,EAAE,MAAM,cAAc,CAAA;AACzE,OAAO,KAAK,EAAsB,sBAAsB,EAAE,MAAM,UAAU,CAAA;AA+B1E;;;;;EAKE;AACF,wBAAgB,eAAe,CAAC,CAAC,SAAS,YAAY,EACpD,MAAM,EAAE,uBAAuB,CAAC,CAAC,CAAC,EAClC,OAAO,EAAE,sBAAsB;;;;;;;;0BAqBF,MAAM,KAAG,IAAI;4BAOX,OAAO,KAAG,IAAI;iBAG3B,IAAI;;8BAkBS,IAAI;iCAXC,MAAM,KAAG,IAAI;
|
|
1
|
+
{"version":3,"file":"useMonacoEditor.d.ts","sourceRoot":"","sources":["../../../../src/composables/useMonacoEditor.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AAIvC,OAAO,KAAK,EAAE,uBAAuB,EAAE,YAAY,EAAE,MAAM,cAAc,CAAA;AACzE,OAAO,KAAK,EAAsB,sBAAsB,EAAE,MAAM,UAAU,CAAA;AA+B1E;;;;;EAKE;AACF,wBAAgB,eAAe,CAAC,CAAC,SAAS,YAAY,EACpD,MAAM,EAAE,uBAAuB,CAAC,CAAC,CAAC,EAClC,OAAO,EAAE,sBAAsB;;;;;;;;0BAqBF,MAAM,KAAG,IAAI;4BAOX,OAAO,KAAG,IAAI;iBAG3B,IAAI;;8BAkBS,IAAI;iCAXC,MAAM,KAAG,IAAI;EAoIlD"}
|