Fixes Submission block breaking on WordPress versions previous to 5.4 #388

This commit is contained in:
mateuswetah 2020-11-10 11:27:18 -03:00
parent e6878594c2
commit 3c9699bd95
1 changed files with 66 additions and 35 deletions

View File

@ -1,8 +1,22 @@
const { registerBlockType } = wp.blocks; const { registerBlockType } = wp.blocks;
const { __ } = wp.i18n; const { __ } = wp.i18n;
const { Button, TextControl, TextareaControl, ColorPicker, BaseControl, CheckboxControl, FontSizePicker, HorizontalRule, Spinner, ToggleControl, Placeholder, PanelBody, ToolbarGroup, ToolbarButton } = wp.components; const {
Button,
TextControl,
TextareaControl,
ColorPicker,
BaseControl,
CheckboxControl,
FontSizePicker,
HorizontalRule,
Spinner,
ToggleControl,
Placeholder,
PanelBody,
ToolbarGroup,
ToolbarButton
} = wp.components;
const { InspectorControls, BlockControls } = wp.editor; const { InspectorControls, BlockControls } = wp.editor;
@ -261,6 +275,22 @@ registerBlockType('tainacan/item-submission-form', {
{ collectionId != undefined ? { collectionId != undefined ?
<BlockControls> <BlockControls>
{ tainacan_blocks.wp_version < '5.4' ?
<Button style={{ whiteSpace: 'nowrap', height: '2.3rem', alignItems: 'center', borderTop: '1px solid #b5bcc2' }} onClick={ () => openCollectionModal() }>
<p>
<svg
xmlns="http://www.w3.org/2000/svg"
viewBox="-2 -2 12 12"
height="24px"
width="24px">
<g transform="translate(227.4751,-183.8442)">
<path d="m -227.47379,191.95102 c 0.0372,-2.35931 -0.0195,-4.71936 0.0185,-7.07842 0.0356,-0.55424 0.52604,-0.99051 1.07473,-0.99702 0.80102,-0.0806 1.607,0.0149 2.41027,-0.0211 1.66482,0.0101 3.33138,-0.0202 4.99509,0.01 0.58652,0.0617 1.0108,0.60434 0.99243,1.1815 0.0416,0.76157 -0.0361,1.52426 0.008,2.28649 0.0113,1.65577 -0.006,3.31214 -0.009,4.96756 -0.0429,0.59366 -0.57833,1.06966 -1.17191,1.04765 -0.92086,0.0516 -1.84377,-0.0208 -2.7657,-0.006 -1.49072,-0.0194 -2.98293,0.0353 -4.47258,0.009 -0.60954,-0.039 -1.111,-0.56284 -1.07768,-1.17994 -0.004,-0.0728 -0.004,-0.1462 -0.002,-0.21867 z m 1.15668,0.28162 c 2.40388,0 4.80776,0 7.21164,0 0,-2.41394 0,-4.82787 0,-7.24181 -2.40388,0 -4.80776,0 -7.21164,0 0,2.41394 0,4.82787 0,7.24181 z m 0.53308,-0.53308 c 0,-0.83147 0,-1.66293 0,-2.4944 0.82476,0 1.64953,0 2.47429,0 0,0.83147 0,1.66293 0,2.4944 -0.82476,0 -1.64953,0 -2.47429,0 z m 2.45417,-6.18571 c 0,0.83482 0,1.66964 0,2.50446 -0.82141,0 -1.64282,0 -2.46423,0 0,-0.83482 0,-1.66964 0,-2.50446 0.82141,0 1.64282,0 2.46423,0 z m 1.1768,1.67969 c 0,-0.28833 0,-0.57666 0,-0.86499 0.82811,0 1.65623,0 2.48434,0 0,0.28833 0,0.57666 0,0.86499 -0.82811,0 -1.65623,0 -2.48434,0 z m 2.48434,2.76598 c 0,0.28162 0,0.56325 0,0.84487 -0.82811,0 -1.65623,0 -2.48434,0 0,-0.28162 0,-0.56325 0,-0.84487 0.82811,0 1.65623,0 2.48434,0 z m -5.64258,-2.49441 c 0.48614,0 0.97228,0 1.45842,0 0,-0.47273 0,-0.94546 0,-1.41819 -0.48614,0 -0.97228,0 -1.45842,0 0,0.47273 0,0.94546 0,1.41819 z m 0,3.68126 c 0.48949,0 0.97899,0 1.46848,0 0,-0.47273 0,-0.94546 0,-1.41819 -0.48949,0 -0.97899,0 -1.46848,0 0,0.47273 0,0.94546 0,1.41819 z"></path>
</g>
</svg>
</p>&nbsp;
{ __('Change target collection', 'tainacan') }
</Button>
:
<ToolbarGroup> <ToolbarGroup>
{ tainacan_blocks.wp_version < '5.5' ? { tainacan_blocks.wp_version < '5.5' ?
<Button style={{ whiteSpace: 'nowrap' }} onClick={ () => openCollectionModal() }> <Button style={{ whiteSpace: 'nowrap' }} onClick={ () => openCollectionModal() }>
@ -294,6 +324,7 @@ registerBlockType('tainacan/item-submission-form', {
</ToolbarButton> </ToolbarButton>
} }
</ToolbarGroup> </ToolbarGroup>
}
</BlockControls> </BlockControls>
: null } : null }