@fc-components/monaco-editor 0.1.19 → 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;
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "0.1.19",
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;
@@ -31,22 +31,26 @@ const SIZE_MAP: Record<
31
31
  className: string;
32
32
  top: number;
33
33
  bottom: number;
34
+ minHeight: number;
34
35
  }
35
36
  > = {
36
37
  small: {
37
38
  className: 'ant-input-sm',
38
39
  top: 1,
39
40
  bottom: 1,
41
+ minHeight: 24,
40
42
  },
41
43
  middle: {
42
44
  className: 'ant-input-md',
43
45
  top: 1,
44
46
  bottom: 1,
47
+ minHeight: 32,
45
48
  },
46
49
  large: {
47
50
  className: 'ant-input-lg',
48
51
  top: 3,
49
52
  bottom: 2,
53
+ minHeight: 40,
50
54
  },
51
55
  };
52
56
 
@@ -71,6 +75,8 @@ const containerReadOnlyClassName = css`
71
75
  export default function SqlEditor(props: SqlEditorProps) {
72
76
  const id = uuidv4();
73
77
  const {
78
+ maxHeight,
79
+ fontSize,
74
80
  size = 'middle',
75
81
  theme = 'light',
76
82
  value = '',
@@ -225,6 +231,12 @@ export default function SqlEditor(props: SqlEditorProps) {
225
231
  (disabled ? ` ant-input-disabled ${containerDisabledClassName}` : '') +
226
232
  (readOnly ? ` ${containerReadOnlyClassName}` : '')
227
233
  }
234
+ style={{
235
+ resize: 'vertical',
236
+ overflow: 'auto',
237
+ minHeight: SIZE_MAP[size].minHeight,
238
+ maxHeight,
239
+ }}
228
240
  >
229
241
  <div ref={containerRef}>
230
242
  <MonacoEditor
@@ -245,9 +257,11 @@ export default function SqlEditor(props: SqlEditorProps) {
245
257
  readOnly: readOnly || disabled,
246
258
  scrollBeyondLastLine: false,
247
259
  smoothScrolling: true,
260
+ fontSize,
248
261
  tabSize: 2,
249
262
  wordWrap: 'on',
250
263
  automaticLayout: true,
264
+ fixedOverflowWidgets: true,
251
265
  glyphMargin: false,
252
266
  lineNumbers: 'off',
253
267
  lineNumbersMinChars: 0,
@@ -258,6 +272,7 @@ export default function SqlEditor(props: SqlEditorProps) {
258
272
  placeholder: placeholder,
259
273
  renderLineHighlight: 'none',
260
274
  occurrencesHighlight: 'off',
275
+ scrollbar: { vertical: 'hidden', horizontal: 'hidden', alwaysConsumeMouseWheel: false },
261
276
  }}
262
277
  />
263
278
  </div>