PluginProbe ʕ •ᴥ•ʔ
GenerateBlocks / 1.1.2
GenerateBlocks v1.1.2
2.4.1 2.4.0 trunk 1.0 1.0.1 1.0.2 1.1.0 1.1.1 1.1.2 1.2.0 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 1.4.0 1.4.1 1.4.2 1.4.3 1.4.4 1.5.0 1.5.1 1.5.2 1.5.3 1.5.4 1.6.0 1.7.0 1.7.1 1.7.2 1.7.3 1.8.0 1.8.1 1.8.2 1.8.3 1.9.0 1.9.1 2.0.0 2.0.1 2.0.2 2.1.0 2.1.1 2.1.2 2.2.0 2.2.1 2.3.0
generateblocks / src / blocks / headline / markformat.js
generateblocks / src / blocks / headline Last commit date
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
79 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 {
20 withSelect,
21 } = wp.data;
22
23 const {
24 ifCondition,
25 } = wp.compose;
26
27 const {
28 compose,
29 } = wp.compose;
30
31 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>;
32 const name = 'generateblocks/mark';
33
34 const GenerateBlocksMarkHightlightButton = function( props ) {
35 const onToggle = () => props.onChange( toggleFormat( props.value, { type: name } ) );
36
37 return (
38 <Fragment>
39 <RichTextShortcut
40 type="primary"
41 character="m"
42 onUse={ onToggle }
43 />
44 <RichTextToolbarButton
45 icon={ icon }
46 title={ __( 'Highlight', 'generateblocks' ) }
47 onClick={ onToggle }
48 isActive={ props.isActive }
49 shortcutType="access"
50 shortcutCharacter="m"
51 className={ `toolbar-button-with-text toolbar-button__${ name }` }
52 />
53 </Fragment>
54 );
55 };
56
57 const ConditionalButton = compose(
58 withSelect( function( select ) {
59 return {
60 selectedBlock: select( 'core/block-editor' ).getSelectedBlock(),
61 };
62 } ),
63 ifCondition( function( props ) {
64 return (
65 props.selectedBlock &&
66 props.selectedBlock.name === 'generateblocks/headline'
67 );
68 } )
69 )( GenerateBlocksMarkHightlightButton );
70
71 const GenerateBlocksMarkHighlight = {
72 title: __( 'Highlight', 'generateblocks' ),
73 tagName: 'mark',
74 className: 'gb-highlight',
75 edit: ConditionalButton,
76 };
77
78 registerFormatType( name, GenerateBlocksMarkHighlight );
79