@fc-components/monaco-editor 0.1.9 → 0.1.11
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 +68 -8
- package/dist/monaco-editor.cjs.development.js +30 -3
- 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 +31 -4
- package/dist/monaco-editor.esm.js.map +1 -1
- package/dist/promql/index.d.ts +2 -0
- package/package.json +1 -1
- package/src/promql/index.tsx +57 -3
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React, { useRef, useEffect } from 'react';
|
|
2
2
|
import MonacoEditor from 'react-monaco-editor';
|
|
3
3
|
import * as monaco from 'monaco-editor';
|
|
4
|
-
import { languages, Range, editor, KeyMod, KeyCode, MarkerSeverity } from 'monaco-editor';
|
|
4
|
+
import { languages, Range, editor, Selection, KeyMod, KeyCode, MarkerSeverity } from 'monaco-editor';
|
|
5
5
|
import { promLanguageDefinition } from 'monaco-promql';
|
|
6
6
|
import { parser, LabelMatchers, VectorSelector, PromQL, FunctionCallBody, StringLiteral, UnquotedLabelMatcher, BinaryExpr, NumberDurationLiteralInDurationContext, MatrixSelector, GroupingLabels, AggregateModifier, AggregateExpr, Identifier, LabelName, MatchOp, EqlSingle, EqlRegex, Neq, NeqRegex } from '@fc-components/lezer-metricsql';
|
|
7
7
|
import { v4 } from 'uuid';
|
|
@@ -229,6 +229,9 @@ function _setPrototypeOf(t, e) {
|
|
|
229
229
|
return t.__proto__ = e, t;
|
|
230
230
|
}, _setPrototypeOf(t, e);
|
|
231
231
|
}
|
|
232
|
+
function _taggedTemplateLiteralLoose(e, t) {
|
|
233
|
+
return t || (t = e.slice(0)), e.raw = t, e;
|
|
234
|
+
}
|
|
232
235
|
function _toPrimitive(t, r) {
|
|
233
236
|
if ("object" != typeof t || !t) return t;
|
|
234
237
|
var e = t[Symbol.toPrimitive];
|
|
@@ -1952,6 +1955,7 @@ function isErrorBoundary(boundary) {
|
|
|
1952
1955
|
}
|
|
1953
1956
|
|
|
1954
1957
|
var _excluded = ["error"];
|
|
1958
|
+
var _templateObject, _templateObject2;
|
|
1955
1959
|
var PROMQL_LANG_ID = promLanguageDefinition.id;
|
|
1956
1960
|
var SIZE_MAP = {
|
|
1957
1961
|
small: {
|
|
@@ -1971,9 +1975,11 @@ var SIZE_MAP = {
|
|
|
1971
1975
|
}
|
|
1972
1976
|
};
|
|
1973
1977
|
var themeMap = {
|
|
1974
|
-
light: 'light',
|
|
1978
|
+
light: 'n9e-light',
|
|
1975
1979
|
dark: 'n9e-dark'
|
|
1976
1980
|
};
|
|
1981
|
+
var containerDisabledClassName = /*#__PURE__*/css(_templateObject || (_templateObject = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n .monaco-editor {\n user-select: none;\n pointer-events: none;\n }\n"])));
|
|
1982
|
+
var containerReadOnlyClassName = /*#__PURE__*/css(_templateObject2 || (_templateObject2 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n .monaco-editor .cursors-layer > .cursor {\n opacity: 0 !important; /* \u5B8C\u5168\u900F\u660E */\n }\n"])));
|
|
1977
1983
|
var getStyles = function getStyles(placeholder) {
|
|
1978
1984
|
return {
|
|
1979
1985
|
placeholder: css({
|
|
@@ -1995,6 +2001,10 @@ function PromQLEditor(props) {
|
|
|
1995
2001
|
interpolateString = props.interpolateString,
|
|
1996
2002
|
_props$enableAutocomp = props.enableAutocomplete,
|
|
1997
2003
|
enableAutocomplete = _props$enableAutocomp === void 0 ? true : _props$enableAutocomp,
|
|
2004
|
+
_props$readOnly = props.readOnly,
|
|
2005
|
+
readOnly = _props$readOnly === void 0 ? false : _props$readOnly,
|
|
2006
|
+
_props$disabled = props.disabled,
|
|
2007
|
+
disabled = _props$disabled === void 0 ? false : _props$disabled,
|
|
1998
2008
|
onChange = props.onChange,
|
|
1999
2009
|
onShiftEnter = props.onShiftEnter,
|
|
2000
2010
|
onBlur = props.onBlur,
|
|
@@ -2006,6 +2016,15 @@ function PromQLEditor(props) {
|
|
|
2006
2016
|
var styles = getStyles(placeholder);
|
|
2007
2017
|
var handleEditorDidMount = function handleEditorDidMount(editor$1) {
|
|
2008
2018
|
editorRef.current = editor$1;
|
|
2019
|
+
editor.defineTheme('n9e-light', {
|
|
2020
|
+
base: 'vs',
|
|
2021
|
+
inherit: true,
|
|
2022
|
+
rules: [],
|
|
2023
|
+
colors: {
|
|
2024
|
+
'editor.background': '#00000000',
|
|
2025
|
+
focusBorder: '#00000000'
|
|
2026
|
+
}
|
|
2027
|
+
});
|
|
2009
2028
|
editor.defineTheme('n9e-dark', {
|
|
2010
2029
|
base: 'vs-dark',
|
|
2011
2030
|
inherit: true,
|
|
@@ -2020,6 +2039,12 @@ function PromQLEditor(props) {
|
|
|
2020
2039
|
editor$1.onDidBlurEditorWidget(function () {
|
|
2021
2040
|
isEditorFocused.set(false);
|
|
2022
2041
|
onBlur == null || onBlur(editor$1.getValue());
|
|
2042
|
+
// reset the selection to the current position
|
|
2043
|
+
var position = editor$1.getPosition();
|
|
2044
|
+
if (position) {
|
|
2045
|
+
var newSelection = new Selection(position.lineNumber, position.column, position.lineNumber, position.column);
|
|
2046
|
+
editor$1.setSelection(newSelection);
|
|
2047
|
+
}
|
|
2023
2048
|
});
|
|
2024
2049
|
editor$1.onDidFocusEditorText(function () {
|
|
2025
2050
|
isEditorFocused.set(true);
|
|
@@ -2155,7 +2180,7 @@ function PromQLEditor(props) {
|
|
|
2155
2180
|
}
|
|
2156
2181
|
}, [enableAutocomplete, props.url, props.lookbackInterval, JSON.stringify(props.variablesNames), props.durationVariablesCompletion, props.httpMethod, props.apiPrefix, placeholder]);
|
|
2157
2182
|
return React.createElement("div", {
|
|
2158
|
-
className: 'ant-input' + (size ? " " + SIZE_MAP[size].className : '')
|
|
2183
|
+
className: 'ant-input' + (size ? " " + SIZE_MAP[size].className : '') + (disabled ? " ant-input-disabled " + containerDisabledClassName : '') + (readOnly ? " " + containerReadOnlyClassName : '')
|
|
2159
2184
|
}, React.createElement("div", {
|
|
2160
2185
|
ref: containerRef
|
|
2161
2186
|
}, React.createElement(MonacoEditor, {
|
|
@@ -2167,6 +2192,7 @@ function PromQLEditor(props) {
|
|
|
2167
2192
|
onChange: onChange,
|
|
2168
2193
|
editorDidMount: handleEditorDidMount,
|
|
2169
2194
|
options: {
|
|
2195
|
+
readOnly: readOnly,
|
|
2170
2196
|
codeLens: false,
|
|
2171
2197
|
contextmenu: false,
|
|
2172
2198
|
fixedOverflowWidgets: true,
|
|
@@ -2197,7 +2223,8 @@ function PromQLEditor(props) {
|
|
|
2197
2223
|
},
|
|
2198
2224
|
suggestFontSize: 12,
|
|
2199
2225
|
wordWrap: 'on',
|
|
2200
|
-
automaticLayout: true
|
|
2226
|
+
automaticLayout: true,
|
|
2227
|
+
occurrencesHighlight: 'off'
|
|
2201
2228
|
}
|
|
2202
2229
|
})));
|
|
2203
2230
|
}
|