-
Notifications
You must be signed in to change notification settings - Fork 8.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Monaco Editor] Add Search functionality #188337
Changes from 2 commits
7f2a4bb
3504ed1
bab9b40
76b5618
7c1537d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -156,6 +156,11 @@ export interface CodeEditorProps { | |
*/ | ||
accessibilityOverlayEnabled?: boolean; | ||
|
||
/** | ||
* Enables the Search bar functionality in the editor. Defaults to `false`. | ||
*/ | ||
enableFindAction?: boolean; | ||
|
||
dataTestSubj?: string; | ||
} | ||
|
||
|
@@ -188,6 +193,7 @@ export const CodeEditor: React.FC<CodeEditorProps> = ({ | |
}), | ||
fitToContent, | ||
accessibilityOverlayEnabled = true, | ||
enableFindAction = false, | ||
dataTestSubj, | ||
}) => { | ||
const { colorMode, euiTheme } = useEuiTheme(); | ||
|
@@ -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, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: instead of registering the keybindings with a null action, I think we could only register the key binding if the find action is enabled There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since we added the find action import in |
||
}); | ||
}, | ||
[ | ||
overrideEditorWillMount, | ||
|
@@ -385,6 +397,7 @@ export const CodeEditor: React.FC<CodeEditorProps> = ({ | |
hoverProvider, | ||
codeActions, | ||
languageConfiguration, | ||
enableFindAction, | ||
] | ||
); | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: we don't actually need to specify false, undefined is also a falsy value.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, that makes sense. Changed with bab9b40.