@fc-components/monaco-editor 0.1.10 → 0.1.12

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.
@@ -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({
@@ -1997,8 +2003,10 @@ function PromQLEditor(props) {
1997
2003
  enableAutocomplete = _props$enableAutocomp === void 0 ? true : _props$enableAutocomp,
1998
2004
  _props$readOnly = props.readOnly,
1999
2005
  readOnly = _props$readOnly === void 0 ? false : _props$readOnly,
2006
+ _props$disabled = props.disabled,
2007
+ disabled = _props$disabled === void 0 ? false : _props$disabled,
2000
2008
  onChange = props.onChange,
2001
- onShiftEnter = props.onShiftEnter,
2009
+ onEnter = props.onEnter,
2002
2010
  onBlur = props.onBlur,
2003
2011
  editorDidMount = props.editorDidMount;
2004
2012
  var autocompleteDisposeFun = useRef(null);
@@ -2008,6 +2016,15 @@ function PromQLEditor(props) {
2008
2016
  var styles = getStyles(placeholder);
2009
2017
  var handleEditorDidMount = function handleEditorDidMount(editor$1) {
2010
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
+ });
2011
2028
  editor.defineTheme('n9e-dark', {
2012
2029
  base: 'vs-dark',
2013
2030
  inherit: true,
@@ -2053,10 +2070,32 @@ function PromQLEditor(props) {
2053
2070
  keybinding: KeyMod.CtrlCmd | KeyCode.KeyF,
2054
2071
  command: null
2055
2072
  });
2056
- // handle: shift + enter
2073
+ // 设置 Shift + Enter 为在光标位置换行
2057
2074
  editor$1.addCommand(KeyMod.Shift | KeyCode.Enter, function () {
2058
- onShiftEnter == null || onShiftEnter(editor$1.getValue());
2075
+ // 在光标位置插入换行符
2076
+ var position = editor$1.getPosition();
2077
+ if (position) {
2078
+ editor$1.executeEdits('shift-enter', [{
2079
+ range: new Range(position.lineNumber, position.column, position.lineNumber, position.column),
2080
+ text: '\n'
2081
+ }]);
2082
+ // 将光标移动到新行
2083
+ editor$1.setPosition({
2084
+ lineNumber: position.lineNumber + 1,
2085
+ column: 1
2086
+ });
2087
+ }
2059
2088
  }, 'isEditorFocused' + id);
2089
+ // 完全阻止 Enter 键的默认行为(包括换行)
2090
+ editor.addKeybindingRule({
2091
+ keybinding: KeyCode.Enter,
2092
+ command: '-',
2093
+ when: '!suggestWidgetVisible'
2094
+ });
2095
+ // handle: enter - 只有在没有建议窗口时才执行自定义行为
2096
+ editor$1.addCommand(KeyCode.Enter, function () {
2097
+ onEnter == null || onEnter(editor$1.getValue());
2098
+ }, '!suggestWidgetVisible && isEditorFocused' + id);
2060
2099
  editor$1.onDidChangeModelContent(function () {
2061
2100
  var model = editor$1.getModel();
2062
2101
  if (model) {
@@ -2163,7 +2202,7 @@ function PromQLEditor(props) {
2163
2202
  }
2164
2203
  }, [enableAutocomplete, props.url, props.lookbackInterval, JSON.stringify(props.variablesNames), props.durationVariablesCompletion, props.httpMethod, props.apiPrefix, placeholder]);
2165
2204
  return React.createElement("div", {
2166
- className: 'ant-input' + (size ? " " + SIZE_MAP[size].className : '')
2205
+ className: 'ant-input' + (size ? " " + SIZE_MAP[size].className : '') + (disabled ? " ant-input-disabled " + containerDisabledClassName : '') + (readOnly ? " " + containerReadOnlyClassName : '')
2167
2206
  }, React.createElement("div", {
2168
2207
  ref: containerRef
2169
2208
  }, React.createElement(MonacoEditor, {