@fc-components/monaco-editor 0.1.18 → 0.1.20

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.
@@ -1,6 +1,8 @@
1
1
  import React from 'react';
2
2
  import type * as monacoTypes from 'monaco-editor/esm/vs/editor/editor.api';
3
3
  interface SqlEditorProps {
4
+ maxHeight?: number | string;
5
+ fontSize?: number;
4
6
  size?: 'small' | 'middle' | 'large';
5
7
  theme?: 'light' | 'dark';
6
8
  value?: string;
@@ -11,6 +13,7 @@ interface SqlEditorProps {
11
13
  onChange?: (value: string) => void;
12
14
  onEnter?: (value: string) => void;
13
15
  onBlur?: (value: string) => void;
16
+ onFocus?: (value: string) => void;
14
17
  editorDidMount?: (editor: monacoTypes.editor.IStandaloneCodeEditor) => void;
15
18
  }
16
19
  export default function SqlEditor(props: SqlEditorProps): React.JSX.Element;
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "0.1.18",
6
+ "version": "0.1.20",
7
7
  "license": "MIT",
8
8
  "main": "dist/index.js",
9
9
  "module": "dist/monaco-editor.esm.js",
package/src/sql/index.tsx CHANGED
@@ -4,12 +4,12 @@ import * as monaco from 'monaco-editor';
4
4
  import type * as monacoTypes from 'monaco-editor/esm/vs/editor/editor.api';
5
5
  import { v4 as uuidv4 } from 'uuid';
6
6
  import { css } from '@emotion/css';
7
-
8
7
  import { language, languageConfiguration } from './sql';
9
8
  import { getSqlCompletionProvider } from './completion/getCompletionProvider';
10
- // import { validateSql } from './validation';
11
9
 
12
10
  interface SqlEditorProps {
11
+ maxHeight?: number | string;
12
+ fontSize?: number;
13
13
  size?: 'small' | 'middle' | 'large';
14
14
  theme?: 'light' | 'dark';
15
15
  value?: string;
@@ -20,6 +20,7 @@ interface SqlEditorProps {
20
20
  onChange?: (value: string) => void;
21
21
  onEnter?: (value: string) => void;
22
22
  onBlur?: (value: string) => void;
23
+ onFocus?: (value: string) => void;
23
24
  editorDidMount?: (editor: monacoTypes.editor.IStandaloneCodeEditor) => void;
24
25
  }
25
26
 
@@ -30,22 +31,26 @@ const SIZE_MAP: Record<
30
31
  className: string;
31
32
  top: number;
32
33
  bottom: number;
34
+ minHeight: number;
33
35
  }
34
36
  > = {
35
37
  small: {
36
38
  className: 'ant-input-sm',
37
39
  top: 1,
38
40
  bottom: 1,
41
+ minHeight: 24,
39
42
  },
40
43
  middle: {
41
44
  className: 'ant-input-md',
42
45
  top: 1,
43
46
  bottom: 1,
47
+ minHeight: 32,
44
48
  },
45
49
  large: {
46
50
  className: 'ant-input-lg',
47
51
  top: 3,
48
52
  bottom: 2,
53
+ minHeight: 40,
49
54
  },
50
55
  };
51
56
 
@@ -70,6 +75,8 @@ const containerReadOnlyClassName = css`
70
75
  export default function SqlEditor(props: SqlEditorProps) {
71
76
  const id = uuidv4();
72
77
  const {
78
+ maxHeight,
79
+ fontSize,
73
80
  size = 'middle',
74
81
  theme = 'light',
75
82
  value = '',
@@ -80,6 +87,7 @@ export default function SqlEditor(props: SqlEditorProps) {
80
87
  onChange,
81
88
  onEnter,
82
89
  onBlur,
90
+ onFocus,
83
91
  editorDidMount,
84
92
  } = props;
85
93
 
@@ -147,6 +155,7 @@ export default function SqlEditor(props: SqlEditorProps) {
147
155
 
148
156
  editor.onDidFocusEditorText(() => {
149
157
  isEditorFocused.set(true);
158
+ onFocus?.(editor.getValue());
150
159
  });
151
160
 
152
161
  // set the height of the editor container
@@ -222,6 +231,12 @@ export default function SqlEditor(props: SqlEditorProps) {
222
231
  (disabled ? ` ant-input-disabled ${containerDisabledClassName}` : '') +
223
232
  (readOnly ? ` ${containerReadOnlyClassName}` : '')
224
233
  }
234
+ style={{
235
+ resize: 'vertical',
236
+ overflow: 'auto',
237
+ minHeight: SIZE_MAP[size].minHeight,
238
+ maxHeight,
239
+ }}
225
240
  >
226
241
  <div ref={containerRef}>
227
242
  <MonacoEditor
@@ -242,9 +257,11 @@ export default function SqlEditor(props: SqlEditorProps) {
242
257
  readOnly: readOnly || disabled,
243
258
  scrollBeyondLastLine: false,
244
259
  smoothScrolling: true,
260
+ fontSize,
245
261
  tabSize: 2,
246
262
  wordWrap: 'on',
247
263
  automaticLayout: true,
264
+ fixedOverflowWidgets: true,
248
265
  glyphMargin: false,
249
266
  lineNumbers: 'off',
250
267
  lineNumbersMinChars: 0,
@@ -255,6 +272,7 @@ export default function SqlEditor(props: SqlEditorProps) {
255
272
  placeholder: placeholder,
256
273
  renderLineHighlight: 'none',
257
274
  occurrencesHighlight: 'off',
275
+ scrollbar: { vertical: 'hidden', horizontal: 'hidden', alwaysConsumeMouseWheel: false },
258
276
  }}
259
277
  />
260
278
  </div>