@fc-components/monaco-editor 0.1.11 → 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.
@@ -2006,7 +2006,7 @@ function PromQLEditor(props) {
2006
2006
  _props$disabled = props.disabled,
2007
2007
  disabled = _props$disabled === void 0 ? false : _props$disabled,
2008
2008
  onChange = props.onChange,
2009
- onShiftEnter = props.onShiftEnter,
2009
+ onEnter = props.onEnter,
2010
2010
  onBlur = props.onBlur,
2011
2011
  editorDidMount = props.editorDidMount;
2012
2012
  var autocompleteDisposeFun = useRef(null);
@@ -2070,10 +2070,32 @@ function PromQLEditor(props) {
2070
2070
  keybinding: KeyMod.CtrlCmd | KeyCode.KeyF,
2071
2071
  command: null
2072
2072
  });
2073
- // handle: shift + enter
2073
+ // 设置 Shift + Enter 为在光标位置换行
2074
2074
  editor$1.addCommand(KeyMod.Shift | KeyCode.Enter, function () {
2075
- 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
+ }
2076
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);
2077
2099
  editor$1.onDidChangeModelContent(function () {
2078
2100
  var model = editor$1.getModel();
2079
2101
  if (model) {