@fc-components/monaco-editor 0.1.3 → 0.1.4
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.
- package/README.md +6 -0
- package/dist/monaco-editor.cjs.development.js +12 -4
- package/dist/monaco-editor.cjs.development.js.map +1 -1
- package/dist/monaco-editor.cjs.production.min.js +1 -1
- package/dist/monaco-editor.cjs.production.min.js.map +1 -1
- package/dist/monaco-editor.esm.js +12 -4
- package/dist/monaco-editor.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/promql/index.tsx +13 -4
package/README.md
CHANGED
|
@@ -4,8 +4,12 @@
|
|
|
4
4
|
import { PromQLMonacoEditor } from '@fc-components/monaco-editor';
|
|
5
5
|
|
|
6
6
|
const App = () => {
|
|
7
|
+
const [value, setValue] = React.useState<string>();
|
|
8
|
+
|
|
7
9
|
return (
|
|
8
10
|
<PromQLMonacoEditor
|
|
11
|
+
theme='light' // or 'dark'
|
|
12
|
+
size='middle' // 'small', 'middle', or 'large'
|
|
9
13
|
placeholder='Enter your PromQL query here...'
|
|
10
14
|
variablesNames={['$job', '$instance']} // Example variable names
|
|
11
15
|
apiPrefix='/api/n9e/proxy/1/api/v1'
|
|
@@ -19,6 +23,7 @@ const App = () => {
|
|
|
19
23
|
}),
|
|
20
24
|
});
|
|
21
25
|
}}
|
|
26
|
+
value={value}
|
|
22
27
|
enableAutocomplete={true} // Enable completion
|
|
23
28
|
durationVariablesCompletion={false} // Disable duration variables completion. eg. $__interval, $__range, $__rate_interval
|
|
24
29
|
interpolateString={(query) => {
|
|
@@ -33,6 +38,7 @@ const App = () => {
|
|
|
33
38
|
}}
|
|
34
39
|
onChange={(value) => {
|
|
35
40
|
console.log('Value changed:', value);
|
|
41
|
+
setValue(value);
|
|
36
42
|
}}
|
|
37
43
|
/>
|
|
38
44
|
);
|
|
@@ -1959,7 +1959,6 @@ function isErrorBoundary(boundary) {
|
|
|
1959
1959
|
|
|
1960
1960
|
var _excluded = ["error"];
|
|
1961
1961
|
var PROMQL_LANG_ID = monacoPromql.promLanguageDefinition.id;
|
|
1962
|
-
var EDITOR_HEIGHT_OFFSET = 2;
|
|
1963
1962
|
var SIZE_MAP = {
|
|
1964
1963
|
small: {
|
|
1965
1964
|
className: 'ant-input-sm',
|
|
@@ -1978,8 +1977,8 @@ var SIZE_MAP = {
|
|
|
1978
1977
|
}
|
|
1979
1978
|
};
|
|
1980
1979
|
var themeMap = {
|
|
1981
|
-
light: '
|
|
1982
|
-
dark: '
|
|
1980
|
+
light: 'light',
|
|
1981
|
+
dark: 'n9e-dark'
|
|
1983
1982
|
};
|
|
1984
1983
|
var getStyles = function getStyles(placeholder) {
|
|
1985
1984
|
return {
|
|
@@ -2030,6 +2029,15 @@ function PromQLEditor(props) {
|
|
|
2030
2029
|
};
|
|
2031
2030
|
}, []);
|
|
2032
2031
|
var handleEditorDidMount = function handleEditorDidMount(editor) {
|
|
2032
|
+
monaco.editor.defineTheme('n9e-dark', {
|
|
2033
|
+
base: 'vs-dark',
|
|
2034
|
+
inherit: true,
|
|
2035
|
+
rules: [],
|
|
2036
|
+
colors: {
|
|
2037
|
+
'editor.background': '#00000000',
|
|
2038
|
+
focusBorder: '#00000000'
|
|
2039
|
+
}
|
|
2040
|
+
});
|
|
2033
2041
|
var isEditorFocused = editor.createContextKey('isEditorFocused' + id, false);
|
|
2034
2042
|
// we setup on-blur
|
|
2035
2043
|
editor.onDidBlurEditorWidget(function () {
|
|
@@ -2072,7 +2080,7 @@ function PromQLEditor(props) {
|
|
|
2072
2080
|
var containerDiv = containerRef.current;
|
|
2073
2081
|
if (containerDiv !== null) {
|
|
2074
2082
|
var pixelHeight = editor.getContentHeight();
|
|
2075
|
-
containerDiv.style.height = pixelHeight +
|
|
2083
|
+
containerDiv.style.height = pixelHeight + "px";
|
|
2076
2084
|
containerDiv.style.width = '100%';
|
|
2077
2085
|
var pixelWidth = containerDiv.clientWidth;
|
|
2078
2086
|
editor.layout({
|