Skip to content
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

[Console] Apply console settings to new monaco editor #178982

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion packages/shared-ux/code_editor/impl/code_editor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,11 @@ export interface CodeEditorProps {
minLines?: number;
maxLines?: number;
};

/**
* Enables the editor to get disabled when pressing ESC to resolve focus trapping for accessibility.
*/
accessibilityOverlayEnabled?: boolean;
}

export const CodeEditor: React.FC<CodeEditorProps> = ({
Expand Down Expand Up @@ -177,6 +182,7 @@ export const CodeEditor: React.FC<CodeEditorProps> = ({
defaultMessage: 'Cannot edit in read-only editor',
}),
fitToContent,
accessibilityOverlayEnabled = true,
}) => {
const { colorMode, euiTheme } = useEuiTheme();
const useDarkTheme = useDarkThemeProp ?? colorMode === 'DARK';
Expand Down Expand Up @@ -486,7 +492,7 @@ export const CodeEditor: React.FC<CodeEditorProps> = ({
data-test-subj="kibanaCodeEditor"
className="kibanaCodeEditor"
>
{renderPrompt()}
{accessibilityOverlayEnabled && renderPrompt()}

<FullScreenDisplay>
{allowFullScreen || isCopyable ? (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,29 @@ import React, { FunctionComponent, useState } from 'react';
import { CodeEditor } from '@kbn/code-editor';
import { css } from '@emotion/react';
import { CONSOLE_LANG_ID } from '@kbn/monaco';
import { useEditorReadContext } from '../../../contexts';

export const MonacoEditor: FunctionComponent = () => {
const { settings } = useEditorReadContext();

const [value, setValue] = useState('GET /.kibana/_search');
return (
<div
css={css`
width: 100%;
`}
>
<CodeEditor languageId={CONSOLE_LANG_ID} value={value} onChange={setValue} fullWidth={true} />
<CodeEditor
languageId={CONSOLE_LANG_ID}
value={value}
onChange={setValue}
fullWidth={true}
accessibilityOverlayEnabled={settings.isAccessibilityOverlayEnabled}
options={{
fontSize: settings.fontSize,
wordWrap: settings.wrapMode === true ? 'on' : 'off',
}}
/>
</div>
);
};