File tree Expand file tree Collapse file tree 6 files changed +34
-0
lines changed
decap-cms-ui-default/src/Icon/images
decap-cms-widget-markdown/src Expand file tree Collapse file tree 6 files changed +34
-0
lines changed Original file line number Diff line number Diff line change @@ -166,6 +166,7 @@ const en = {
166166 quote : 'Quote' ,
167167 bulletedList : 'Bulleted List' ,
168168 numberedList : 'Numbered List' ,
169+ horizontalRule : 'Horizontal Rule' ,
169170 addComponent : 'Add Component' ,
170171 richText : 'Rich Text' ,
171172 markdown : 'Markdown' ,
Original file line number Diff line number Diff line change @@ -22,6 +22,7 @@ import iconH1 from './h1.svg';
2222import iconH2 from './h2.svg' ;
2323import iconHOptions from './h-options.svg' ;
2424import iconHome from './home.svg' ;
25+ import iconHorizontalRule from './horizontal-rule.svg' ;
2526import iconImage from './image.svg' ;
2627import iconInfoCircle from './info-circle.svg' ;
2728import iconItalic from './italic.svg' ;
@@ -75,6 +76,7 @@ const images = {
7576 h2 : iconH2 ,
7677 hOptions : iconHOptions ,
7778 home : iconHome ,
79+ 'horizontal-rule' : iconHorizontalRule ,
7880 image : iconImage ,
7981 'info-circle' : iconInfoCircle ,
8082 italic : iconItalic ,
Original file line number Diff line number Diff line change @@ -74,6 +74,7 @@ export default class Toolbar extends React.Component {
7474 onMarkClick : PropTypes . func ,
7575 onBlockClick : PropTypes . func ,
7676 onLinkClick : PropTypes . func ,
77+ onInsertHorizontalRule : PropTypes . func ,
7778 hasMark : PropTypes . func ,
7879 hasInline : PropTypes . func ,
7980 hasBlock : PropTypes . func ,
@@ -97,6 +98,13 @@ export default class Toolbar extends React.Component {
9798 this . props . onBlockClick ( type ) ;
9899 } ;
99100
101+ handleHorizontalRuleClick = event => {
102+ if ( event ) {
103+ event . preventDefault ( ) ;
104+ }
105+ this . props . onInsertHorizontalRule ( ) ;
106+ } ;
107+
100108 handleMarkClick = ( event , type ) => {
101109 event . preventDefault ( ) ;
102110 this . props . onMarkClick ( type ) ;
@@ -263,6 +271,16 @@ export default class Toolbar extends React.Component {
263271 disabled = { disabled }
264272 />
265273 ) }
274+ { isVisible ( 'horizontal-rule' ) && (
275+ < ToolbarButton
276+ type = "thematic-break"
277+ label = { t ( 'editor.editorWidgets.markdown.horizontalRule' ) }
278+ icon = "horizontal-rule"
279+ onClick = { this . handleHorizontalRuleClick }
280+ isActive = { false }
281+ disabled = { disabled }
282+ />
283+ ) }
266284 { showEditorComponents && (
267285 < ToolbarDropdownWrapper >
268286 < Dropdown
Original file line number Diff line number Diff line change @@ -167,6 +167,14 @@ function Editor(props) {
167167 insertShortcode ( editor , pluginConfig ) ;
168168 }
169169
170+ function handleInsertHorizontalRule ( ) {
171+ Transforms . insertNodes ( editor , {
172+ type : 'thematic-break' ,
173+ children : [ { text : '' } ] ,
174+ } ) ;
175+ ReactEditor . focus ( editor ) ;
176+ }
177+
170178 function handleKeyDown ( event ) {
171179 for ( const handler of editor . keyDownHandlers || [ ] ) {
172180 if ( handler ( event , editor ) === false ) {
@@ -231,6 +239,7 @@ function Editor(props) {
231239 onMarkClick = { handleMarkClick }
232240 onBlockClick = { handleBlockClick }
233241 onLinkClick = { handleLinkClick }
242+ onInsertHorizontalRule = { handleInsertHorizontalRule }
234243 onToggleMode = { handleToggleMode }
235244 plugins = { editorComponents }
236245 onSubmit = { handleInsertShortcode }
Original file line number Diff line number Diff line change @@ -21,6 +21,7 @@ export default {
2121 'quote' ,
2222 'bulleted-list' ,
2323 'numbered-list' ,
24+ 'horizontal-rule' ,
2425 ] ,
2526 } ,
2627 } ,
You can’t perform that action at this time.
0 commit comments