diff --git a/packages/netlify-cms-ui-default/src/Icon/images/_index.js b/packages/netlify-cms-ui-default/src/Icon/images/_index.js index ffd8edf7..450d656f 100644 --- a/packages/netlify-cms-ui-default/src/Icon/images/_index.js +++ b/packages/netlify-cms-ui-default/src/Icon/images/_index.js @@ -18,6 +18,7 @@ import iconGitlab from './gitlab.svg'; import iconGrid from './grid.svg'; import iconH1 from './h1.svg'; import iconH2 from './h2.svg'; +import iconHOptions from './h-options.svg'; import iconHome from './home.svg'; import iconImage from './image.svg'; import iconItalic from './italic.svg'; @@ -66,6 +67,7 @@ const images = { grid: iconGrid, h1: iconH1, h2: iconH2, + hOptions: iconHOptions, home: iconHome, image: iconImage, italic: iconItalic, diff --git a/packages/netlify-cms-ui-default/src/Icon/images/h-options.svg b/packages/netlify-cms-ui-default/src/Icon/images/h-options.svg new file mode 100644 index 00000000..77785e12 --- /dev/null +++ b/packages/netlify-cms-ui-default/src/Icon/images/h-options.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/packages/netlify-cms-ui-default/src/styles.js b/packages/netlify-cms-ui-default/src/styles.js index b019578a..c8645d29 100644 --- a/packages/netlify-cms-ui-default/src/styles.js +++ b/packages/netlify-cms-ui-default/src/styles.js @@ -312,11 +312,13 @@ const components = { display: flex; justify-content: space-between; align-items: center; + white-space: nowrap; &:last-of-type { border-bottom: 0; } + &.active, &:hover, &:active, &:focus { diff --git a/packages/netlify-cms-widget-markdown/src/MarkdownControl/Toolbar.js b/packages/netlify-cms-widget-markdown/src/MarkdownControl/Toolbar.js index 569860ec..b5a86bbc 100644 --- a/packages/netlify-cms-widget-markdown/src/MarkdownControl/Toolbar.js +++ b/packages/netlify-cms-widget-markdown/src/MarkdownControl/Toolbar.js @@ -58,6 +58,15 @@ const ToolbarToggleLabel = styled.span` `}; `; +const headingOptions = { + 'heading-one': 'Heading 1', + 'heading-two': 'Heading 2', + 'heading-three': 'Heading 3', + 'heading-four': 'Heading 4', + 'heading-five': 'Heading 5', + 'heading-six': 'Heading 6', +}; + export default class Toolbar extends React.Component { static propTypes = { buttons: ImmutablePropTypes.list, @@ -135,24 +144,45 @@ export default class Toolbar extends React.Component { isHidden={this.isHidden('link')} disabled={disabled} /> - - + {/* Show dropdown if at least one heading is not hidden */} + {Object.keys(headingOptions).some(optionKey => { + return !this.isHidden(optionKey); + }) && ( + + ( + + + !disabled && + Object.keys(headingOptions).some(optionKey => { + return selectionHasBlock(optionKey); + }) + } + /> + + )} + > + {!disabled && + Object.keys(headingOptions).map( + (optionKey, idx) => + !this.isHidden(optionKey) && ( + onBlockClick(undefined, optionKey)} + /> + ), + )} + + + )} { - event.preventDefault(); + if (event) { + event.preventDefault(); + } let { value } = this.state; const { document: doc } = value; const { unwrapList, wrapInList } = EditListConfigured.changes; diff --git a/website/content/docs/widgets/markdown.md b/website/content/docs/widgets/markdown.md index 9b5346e4..31af6e0d 100644 --- a/website/content/docs/widgets/markdown.md +++ b/website/content/docs/widgets/markdown.md @@ -1,5 +1,5 @@ --- -label: "Markdown" +label: 'Markdown' title: markdown --- @@ -12,7 +12,7 @@ _Please note:_ If you want to use your markdown editor to fill a markdown file c - **Data type:** markdown - **Options:** - `default`: accepts markdown content - - `buttons`: an array of strings representing the formatting buttons to display, all buttons shown by default. Buttons include: `bold`, `italic`, `code`, `link`, `heading-one`, `heading-two`, `quote`, `code-block`, `bulleted-list`, and `numbered-list`. + - `buttons`: an array of strings representing the formatting buttons to display, all buttons shown by default. Buttons include: `bold`, `italic`, `code`, `link`, `heading-one`, `heading-two`, `heading-three`, `heading-four`, `heading-five`, `heading-six`, `quote`, `code-block`, `bulleted-list`, and `numbered-list`. - **Example:** ```yaml