@fc-components/monaco-editor 0.1.5 → 0.1.6
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/dist/monaco-editor.cjs.development.js +12 -19
- 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 +13 -20
- package/dist/monaco-editor.esm.js.map +1 -1
- package/dist/promql/index.d.ts +4 -2
- package/package.json +1 -1
- package/src/promql/index.tsx +25 -18
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, {
|
|
1
|
+
import React, { useRef, useEffect } from 'react';
|
|
2
2
|
import MonacoEditor from 'react-monaco-editor';
|
|
3
3
|
import * as monaco from 'monaco-editor';
|
|
4
4
|
import { languages, editor, KeyMod, KeyCode, Range, MarkerSeverity } from 'monaco-editor';
|
|
@@ -1984,7 +1984,7 @@ var getStyles = function getStyles(placeholder) {
|
|
|
1984
1984
|
})
|
|
1985
1985
|
};
|
|
1986
1986
|
};
|
|
1987
|
-
|
|
1987
|
+
function PromQLEditor(props) {
|
|
1988
1988
|
var id = v4();
|
|
1989
1989
|
var _props$size = props.size,
|
|
1990
1990
|
size = _props$size === void 0 ? 'middle' : _props$size,
|
|
@@ -1998,14 +1998,13 @@ var index = /*#__PURE__*/forwardRef(function PromQLEditor(props, ref) {
|
|
|
1998
1998
|
enableAutocomplete = _props$enableAutocomp === void 0 ? true : _props$enableAutocomp,
|
|
1999
1999
|
onChange = props.onChange,
|
|
2000
2000
|
onShiftEnter = props.onShiftEnter,
|
|
2001
|
-
onBlur = props.onBlur
|
|
2001
|
+
onBlur = props.onBlur,
|
|
2002
|
+
editorDidMount = props.editorDidMount;
|
|
2002
2003
|
var autocompleteDisposeFun = useRef(null);
|
|
2003
2004
|
var containerRef = useRef(null);
|
|
2004
2005
|
var dataProviderRef = useRef(null);
|
|
2005
|
-
var editorRef = useRef(null);
|
|
2006
2006
|
var styles = getStyles(placeholder);
|
|
2007
2007
|
var handleEditorDidMount = function handleEditorDidMount(editor$1) {
|
|
2008
|
-
editorRef.current = editor$1;
|
|
2009
2008
|
editor.defineTheme('n9e-dark', {
|
|
2010
2009
|
base: 'vs-dark',
|
|
2011
2010
|
inherit: true,
|
|
@@ -2113,13 +2112,8 @@ var index = /*#__PURE__*/forwardRef(function PromQLEditor(props, ref) {
|
|
|
2113
2112
|
editor.setModelMarkers(model, 'owner', markers);
|
|
2114
2113
|
}
|
|
2115
2114
|
});
|
|
2115
|
+
editorDidMount == null || editorDidMount(editor$1);
|
|
2116
2116
|
};
|
|
2117
|
-
useEffect(function () {
|
|
2118
|
-
var dataProvider = dataProviderRef.current;
|
|
2119
|
-
if (dataProvider) {
|
|
2120
|
-
dataProvider.setVariablesNames(variablesNames || []);
|
|
2121
|
-
}
|
|
2122
|
-
}, [JSON.stringify(variablesNames)]);
|
|
2123
2117
|
useEffect(function () {
|
|
2124
2118
|
// 注册 PromQL 语言
|
|
2125
2119
|
var aliases = promLanguageDefinition.aliases,
|
|
@@ -2139,13 +2133,12 @@ var index = /*#__PURE__*/forwardRef(function PromQLEditor(props, ref) {
|
|
|
2139
2133
|
autocompleteDisposeFun.current == null || autocompleteDisposeFun.current();
|
|
2140
2134
|
};
|
|
2141
2135
|
}, []);
|
|
2142
|
-
|
|
2143
|
-
|
|
2144
|
-
|
|
2145
|
-
|
|
2146
|
-
|
|
2147
|
-
|
|
2148
|
-
});
|
|
2136
|
+
useEffect(function () {
|
|
2137
|
+
var dataProvider = dataProviderRef.current;
|
|
2138
|
+
if (dataProvider) {
|
|
2139
|
+
dataProvider.setVariablesNames(variablesNames || []);
|
|
2140
|
+
}
|
|
2141
|
+
}, [JSON.stringify(variablesNames)]);
|
|
2149
2142
|
return React.createElement("div", {
|
|
2150
2143
|
className: 'ant-input' + (size ? " " + SIZE_MAP[size].className : '')
|
|
2151
2144
|
}, React.createElement("div", {
|
|
@@ -2191,7 +2184,7 @@ var index = /*#__PURE__*/forwardRef(function PromQLEditor(props, ref) {
|
|
|
2191
2184
|
wordWrap: 'on'
|
|
2192
2185
|
}
|
|
2193
2186
|
})));
|
|
2194
|
-
}
|
|
2187
|
+
}
|
|
2195
2188
|
|
|
2196
|
-
export {
|
|
2189
|
+
export { PromQLEditor as PromQLMonacoEditor };
|
|
2197
2190
|
//# sourceMappingURL=monaco-editor.esm.js.map
|