From 11f1361895080b6990b1a9c1b6e92a0cdc4326d6 Mon Sep 17 00:00:00 2001 From: Viicos <65306057+Viicos@users.noreply.github.com> Date: Tue, 30 Apr 2024 17:51:20 +0200 Subject: [PATCH] Add an option to disable line numbers --- src/jsonEditor.tsx | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/jsonEditor.tsx b/src/jsonEditor.tsx index 793e401..4edf986 100644 --- a/src/jsonEditor.tsx +++ b/src/jsonEditor.tsx @@ -9,6 +9,7 @@ interface JSONEditorProps { value?: any; onChange: (value: any) => void; readOnly?: boolean; + showLines?: boolean; } type AvailableEditorProps = Pick; @@ -17,6 +18,7 @@ const JSONEditor: React.FC = ({ value = '', onChange, readOnly = false, + showLines = true, ...props }) => { const monacoOnChange: OnChange = value => { @@ -43,6 +45,9 @@ const JSONEditor: React.FC = ({ const jsonData = JSON.stringify(value, null, 2); + const extraOptions: EditorProps['options'] = {readOnly}; + if (!showLines) extraOptions.lineNumbers = 'off'; + return ( = ({ minimap: {enabled: false}, contextmenu: false, renderWhitespace: 'trailing', - readOnly, + ...extraOptions, }} value={jsonData} onChange={monacoOnChange}