Skip to content
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
1 change: 1 addition & 0 deletions packages/eui/changelogs/upcoming/9349.md
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ragini-pandey this filename needs to be: 9349.md, same as your PR number! 😄

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ohk Thanks. I thought it was an issue number.
Renamed!

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Added `className` support to `EuiMarkdownEditor`'s `toolbarProps` for custom toolbar styling
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,20 @@ describe('EuiMarkdownEditor', () => {
screen.getByRole('button', { name: 'Editor' })
).toBeInTheDocument();
});

it('applies custom className to toolbar when passed', () => {
render(
<EuiMarkdownEditor
onChange={() => null}
value="markdown test"
{...requiredProps}
toolbarProps={{ className: 'customToolbarClass' }}
/>
);
const toolbar = screen.getByTestSubject('euiMarkdownEditorToolbar');
expect(toolbar).toHaveClass('euiMarkdownEditorToolbar');
expect(toolbar).toHaveClass('customToolbarClass');
});
});
it('should show footer by default and hide when showFooter is false', () => {
render(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ type CommonMarkdownEditorProps = Omit<
* Props to customize the toolbar. `right` replaces the default preview/editor toggle with custom content.
*/
toolbarProps?: {
className?: EuiMarkdownEditorToolbarProps['className'];
right?: EuiMarkdownEditorToolbarProps['right'];
};
/** Controls whether the footer is shown */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import React, {
forwardRef,
Ref,
} from 'react';
import classNames from 'classnames';

import { useEuiMemoizedStyles } from '../../services';
import { CommonProps } from '../common';
Expand Down Expand Up @@ -140,6 +141,7 @@ export const EuiMarkdownEditorToolbar = forwardRef<
>(
(
{
className,
markdownActions,
viewMode,
onClickPreview,
Expand All @@ -151,6 +153,8 @@ export const EuiMarkdownEditorToolbar = forwardRef<
) => {
const { openPluginEditor, readOnly } = useContext(EuiMarkdownContext);

const classes = classNames('euiMarkdownEditorToolbar', className);

const handleMdButtonClick = (mdButtonId: string) => {
const actionResult = markdownActions.do(mdButtonId);
if (actionResult !== true) openPluginEditor(actionResult);
Expand All @@ -166,7 +170,7 @@ export const EuiMarkdownEditorToolbar = forwardRef<
<div
ref={ref}
css={styles.euiMarkdownEditorToolbar}
className="euiMarkdownEditorToolbar"
className={classes}
data-test-subj="euiMarkdownEditorToolbar"
>
<div
Expand Down