Skip to content

Commit

Permalink
Disable find action by default
Browse files Browse the repository at this point in the history
  • Loading branch information
ElenaStoeva committed Jul 16, 2024
1 parent 7f2a4bb commit 3504ed1
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
13 changes: 13 additions & 0 deletions packages/shared-ux/code_editor/impl/code_editor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,11 @@ export interface CodeEditorProps {
*/
accessibilityOverlayEnabled?: boolean;

/**
* Enables the Search bar functionality in the editor. Defaults to `false`.
*/
enableFindAction?: boolean;

dataTestSubj?: string;
}

Expand Down Expand Up @@ -188,6 +193,7 @@ export const CodeEditor: React.FC<CodeEditorProps> = ({
}),
fitToContent,
accessibilityOverlayEnabled = true,
enableFindAction = false,
dataTestSubj,
}) => {
const { colorMode, euiTheme } = useEuiTheme();
Expand Down Expand Up @@ -375,6 +381,12 @@ export const CodeEditor: React.FC<CodeEditorProps> = ({
monaco.languages.registerCodeActionProvider(languageId, codeActions);
}
});

monaco.editor.addKeybindingRule({
// eslint-disable-next-line no-bitwise
keybinding: monaco.KeyMod.CtrlCmd | monaco.KeyCode.KeyF,
command: enableFindAction ? 'actions.find' : null,
});
},
[
overrideEditorWillMount,
Expand All @@ -385,6 +397,7 @@ export const CodeEditor: React.FC<CodeEditorProps> = ({
hoverProvider,
codeActions,
languageConfiguration,
enableFindAction,
]
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ export const MonacoEditor = ({ initialTextValue }: EditorProps) => {
theme: CONSOLE_THEME_ID,
}}
suggestionProvider={suggestionProvider}
enableFindAction={true}
/>
</div>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ export const MonacoEditorOutput: FunctionComponent = () => {
fullWidth={true}
editorDidMount={editorDidMountCallback}
editorWillUnmount={editorWillUnmountCallback}
enableFindAction={true}
options={{
readOnly: true,
fontSize: readOnlySettings.fontSize,
Expand Down

0 comments on commit 3504ed1

Please sign in to comment.