@fc-components/monaco-editor 0.1.10 → 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.
@@ -9,6 +9,7 @@ interface PromQLEditorProps {
9
9
  enableAutocomplete?: boolean;
10
10
  durationVariablesCompletion?: boolean;
11
11
  readOnly?: boolean;
12
+ disabled?: boolean;
12
13
  interpolateString?: (query: string) => string;
13
14
  onChange?: (value: string) => void;
14
15
  onShiftEnter?: (value: string) => void;
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "0.1.10",
6
+ "version": "0.1.11",
7
7
  "license": "MIT",
8
8
  "main": "dist/index.js",
9
9
  "module": "dist/monaco-editor.esm.js",
@@ -21,6 +21,7 @@ interface PromQLEditorProps {
21
21
  enableAutocomplete?: boolean;
22
22
  durationVariablesCompletion?: boolean;
23
23
  readOnly?: boolean;
24
+ disabled?: boolean;
24
25
  interpolateString?: (query: string) => string;
25
26
  onChange?: (value: string) => void;
26
27
  onShiftEnter?: (value: string) => void;
@@ -54,10 +55,23 @@ const SIZE_MAP: Record<
54
55
  },
55
56
  };
56
57
  const themeMap: Record<string, string> = {
57
- light: 'light',
58
+ light: 'n9e-light',
58
59
  dark: 'n9e-dark',
59
60
  };
60
61
 
62
+ const containerDisabledClassName = css`
63
+ .monaco-editor {
64
+ user-select: none;
65
+ pointer-events: none;
66
+ }
67
+ `;
68
+
69
+ const containerReadOnlyClassName = css`
70
+ .monaco-editor .cursors-layer > .cursor {
71
+ opacity: 0 !important; /* 完全透明 */
72
+ }
73
+ `;
74
+
61
75
  const getStyles = (placeholder?: string) => {
62
76
  return {
63
77
  placeholder: css({
@@ -79,6 +93,7 @@ export default function PromQLEditor(props: PromQLEditorProps & DataProviderPara
79
93
  interpolateString,
80
94
  enableAutocomplete = true,
81
95
  readOnly = false,
96
+ disabled = false,
82
97
  onChange,
83
98
  onShiftEnter,
84
99
  onBlur,
@@ -92,6 +107,16 @@ export default function PromQLEditor(props: PromQLEditorProps & DataProviderPara
92
107
  const handleEditorDidMount = (editor: monacoTypes.editor.IStandaloneCodeEditor) => {
93
108
  editorRef.current = editor;
94
109
 
110
+ monaco.editor.defineTheme('n9e-light', {
111
+ base: 'vs',
112
+ inherit: true,
113
+ rules: [],
114
+ colors: {
115
+ 'editor.background': '#00000000',
116
+ focusBorder: '#00000000',
117
+ },
118
+ });
119
+
95
120
  monaco.editor.defineTheme('n9e-dark', {
96
121
  base: 'vs-dark',
97
122
  inherit: true,
@@ -279,7 +304,14 @@ export default function PromQLEditor(props: PromQLEditorProps & DataProviderPara
279
304
  ]);
280
305
 
281
306
  return (
282
- <div className={'ant-input' + (size ? ` ${SIZE_MAP[size].className}` : '')}>
307
+ <div
308
+ className={
309
+ 'ant-input' +
310
+ (size ? ` ${SIZE_MAP[size].className}` : '') +
311
+ (disabled ? ` ant-input-disabled ${containerDisabledClassName}` : '') +
312
+ (readOnly ? ` ${containerReadOnlyClassName}` : '')
313
+ }
314
+ >
283
315
  <div ref={containerRef}>
284
316
  <MonacoEditor
285
317
  width='100%'