css
6 years ago
attributes.js
6 years ago
block.js
6 years ago
deprecated.js
6 years ago
edit.js
6 years ago
editor.scss
6 years ago
markformat.js
6 years ago
save.js
6 years ago
transforms.js
6 years ago
markformat.js
51 lines
| 1 | const { |
| 2 | __, |
| 3 | } = wp.i18n; |
| 4 | |
| 5 | const { |
| 6 | Fragment, |
| 7 | } = wp.element; |
| 8 | |
| 9 | const { |
| 10 | toggleFormat, |
| 11 | registerFormatType, |
| 12 | } = wp.richText; |
| 13 | |
| 14 | const { |
| 15 | RichTextToolbarButton, |
| 16 | RichTextShortcut, |
| 17 | } = wp.blockEditor; |
| 18 | |
| 19 | const icon = <svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" fillRule="evenodd" clipRule="evenodd" strokeLinejoin="round" strokeMiterlimit="1.414"><path d="M4.331,15.598l2.193,1.693c0,0 -0.813,1.215 -0.992,1.215c-1.129,0.003 -1.424,0.008 -2.603,-0.001c-0.741,-0.006 -0.04,-0.955 0.187,-1.269c0.502,-0.694 1.215,-1.638 1.215,-1.638Zm7.632,-14.107c0.364,-0.061 5.412,3.896 5.439,4.272c0.031,0.438 -4.887,8.469 -5.635,9.648c-0.251,0.397 -1.185,0.206 -2.064,0.472c-0.801,0.243 -1.89,1.336 -2.193,1.105c-1.047,-0.796 -2.217,-1.646 -3.117,-2.49c-0.367,-0.343 0.388,-1.241 0.405,-2.188c0.015,-0.811 -0.644,-2.029 -0.196,-2.575c0.836,-1.019 6.931,-8.172 7.361,-8.244Zm0.144,1.454l3.95,3.105l-4.972,8.1l-5.197,-4.053l6.219,-7.152Z" /></svg>; |
| 20 | const name = 'generateblocks/mark'; |
| 21 | |
| 22 | const GenerateBlocksMarkHighlight = { |
| 23 | title: __( 'Highlight', 'generateblocks' ), |
| 24 | tagName: 'mark', |
| 25 | className: 'gb-highlight', |
| 26 | edit( { isActive, value, onChange } ) { |
| 27 | const onToggle = () => onChange( toggleFormat( value, { type: name } ) ); |
| 28 | |
| 29 | return ( |
| 30 | <Fragment> |
| 31 | <RichTextShortcut |
| 32 | type="primary" |
| 33 | character="m" |
| 34 | onUse={ onToggle } |
| 35 | /> |
| 36 | <RichTextToolbarButton |
| 37 | icon={ icon } |
| 38 | title={ __( 'Highlight' ) } |
| 39 | onClick={ onToggle } |
| 40 | isActive={ isActive } |
| 41 | shortcutType="access" |
| 42 | shortcutCharacter="m" |
| 43 | className={ `toolbar-button-with-text toolbar-button__${ name }` } |
| 44 | /> |
| 45 | </Fragment> |
| 46 | ); |
| 47 | }, |
| 48 | }; |
| 49 | |
| 50 | registerFormatType( name, GenerateBlocksMarkHighlight ); |
| 51 |