Skip to content

Commit 546740a

Browse files
authored
Merge pull request #9 from BeAPI/fix/double-wpautop
Fix double wpautop
2 parents 8b0137b + 7f11c25 commit 546740a

File tree

8 files changed

+18404
-17611
lines changed

8 files changed

+18404
-17611
lines changed

includes/Rest/RenderBlockRestController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ public function get_item( $request ) {
100100
$this->setup_block_support_styles_capture();
101101

102102
/** This filter is documented in wp-includes/post-template.php */
103-
$block_render = apply_filters( 'the_content', render_block( $shared_block_data ) );
103+
$block_render = apply_filters( 'the_content', serialize_block( $shared_block_data ) );
104104

105105
// Get list of block types used while rendering the shared block.
106106
$use_block_types = $this->capture_use_block_types();

package-lock.json

Lines changed: 18357 additions & 17559 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -24,24 +24,23 @@
2424
"license": "GPL-2.0-or-later",
2525
"dependencies": {
2626
"react-infinite-scroll-component": "^6.1.0",
27-
"use-constant": "^1.1.0",
28-
"uuid": "^8.3.2"
27+
"use-constant": "^1.1.1",
28+
"uuid": "^9.0.1"
2929
},
3030
"devDependencies": {
31-
"@wordpress/block-editor": "^9.7.0",
32-
"@wordpress/blocks": "^11.14.0",
33-
"@wordpress/components": "^19.17.0",
34-
"@wordpress/compose": "^5.13.0",
35-
"@wordpress/core-data": "^4.13.0",
36-
"@wordpress/data": "^6.15.0",
37-
"@wordpress/element": "^4.13.0",
38-
"@wordpress/env": "^5.2.0",
39-
"@wordpress/hooks": "^3.15.0",
40-
"@wordpress/i18n": "^4.15.0",
41-
"@wordpress/primitives": "^3.16.0",
42-
"@wordpress/scripts": "^23.7.2",
43-
"@wordpress/wordcount": "^3.15.0",
44-
"lodash": "^4.17.21"
31+
"@wordpress/block-editor": "^12.14.0",
32+
"@wordpress/blocks": "^12.23.0",
33+
"@wordpress/components": "^25.12.0",
34+
"@wordpress/compose": "^6.23.0",
35+
"@wordpress/core-data": "^6.23.0",
36+
"@wordpress/data": "^9.16.0",
37+
"@wordpress/element": "^5.23.0",
38+
"@wordpress/env": "^8.12.0",
39+
"@wordpress/hooks": "^3.46.0",
40+
"@wordpress/i18n": "^4.46.0",
41+
"@wordpress/primitives": "^3.44.0",
42+
"@wordpress/scripts": "^26.17.0",
43+
"@wordpress/wordcount": "^3.46.0"
4544
},
4645
"volta": {
4746
"node": "16.19.0"

src/blocks/shared-block/edit.js

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,3 @@
1-
/**
2-
* External dependencies
3-
*/
4-
import { isEmpty } from 'lodash';
5-
61
/**
72
* WordPress dependencies
83
*/
@@ -26,6 +21,7 @@ import './editor.scss';
2621

2722
export default function Edit( { attributes, setAttributes } ) {
2823
const { blockId, blockTitle, display } = attributes;
24+
const hasBlockId = blockId && blockId.length > 0 ? true : false;
2925

3026
const [ isEditing, setIsEditing ] = useState( false );
3127

@@ -98,9 +94,9 @@ export default function Edit( { attributes, setAttributes } ) {
9894
</ButtonGroup>
9995
</PanelBody>
10096
</InspectorControls>
101-
{ isEmpty( blockId ) || isEditing ? (
97+
{ ! hasBlockId || isEditing ? (
10298
<div className={ 'shared-block-selector-wrapper' }>
103-
{ false === isEmpty( blockId ) && (
99+
{ hasBlockId && (
104100
<div
105101
className={
106102
'shared-block-selector-wrapper__cancel'
@@ -142,9 +138,9 @@ export default function Edit( { attributes, setAttributes } ) {
142138
<Placeholder
143139
icon={ BlockIcon }
144140
label={ __( 'Shared Block', 'multisite-shared-blocks' ) }
145-
instructions={ getPlaceholderLabel( display ) }
146141
className={ 'shared-block-placeholder' }
147142
>
143+
{ getPlaceholderLabel( display ) }
148144
<Button
149145
variant="primary"
150146
onClick={ () => setIsEditing( true ) }

src/blocks/shared-block/icon.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ const MultisiteSharedBlockIcon = (
1313
>
1414
<Path
1515
fill="#000"
16-
fill-rule="evenodd"
16+
fillRule="evenodd"
1717
d="M14.247 0H9.753c-.715 0-1.327.647-1.327 1.402V4.8c0 .755.612 1.402 1.327 1.402h1.736v2.034c-1.599.242-2.857 1.601-3.04 3.306h-1.3v-1.295c0-.755-.613-1.402-1.328-1.402H1.328C.613 8.845 0 9.492 0 10.247v3.398c0 .755.613 1.402 1.328 1.402H5.82c.715 0 1.328-.647 1.328-1.402V12.62h1.329c.262 1.602 1.48 2.859 3.011 3.09v2.088H9.753c-.715 0-1.327.647-1.327 1.402v3.398c0 .755.612 1.402 1.327 1.402h4.494c.715 0 1.328-.647 1.328-1.402V19.2c0-.809-.613-1.402-1.328-1.402H12.51V15.71c1.53-.231 2.75-1.488 3.011-3.09h1.329v1.025c0 .755.613 1.402 1.328 1.402h4.493c.715 0 1.328-.647 1.328-1.402v-3.398c0-.755-.613-1.402-1.328-1.402H18.18c-.715 0-1.328.647-1.328 1.402v1.295h-1.3c-.183-1.705-1.441-3.064-3.04-3.306V6.202h1.736c.715 0 1.328-.647 1.328-1.402V1.402C15.575.593 14.962 0 14.247 0Zm.306 4.746c0 .162-.153.324-.306.324H9.753c-.153 0-.306-.162-.306-.324V1.402c0-.162.153-.323.306-.323h4.494c.153 0 .306.108.306.323v3.344ZM12 9.276c-1.41 0-2.553 1.208-2.553 2.697 0 1.49 1.143 2.697 2.553 2.697s2.553-1.208 2.553-2.697c0-1.49-1.143-2.697-2.553-2.697Zm10.979 4.369c0 .162-.153.324-.307.324H18.18c-.153 0-.307-.162-.307-.324v-3.398c0-.162.154-.323.307-.323h4.493c.154 0 .307.161.307.323v3.398Zm-17.158.324c.153 0 .307-.162.307-.324v-3.398c0-.162-.154-.323-.307-.323H1.328c-.154 0-.307.161-.307.323v3.398c0 .162.153.324.307.324H5.82Zm8.426 8.898c.153 0 .306-.161.306-.323v-3.398c0-.162-.153-.323-.306-.323H9.753c-.153 0-.306.161-.306.323v3.398c0 .162.153.323.306.323h4.494Z"
18-
clip-rule="evenodd"
18+
clipRule="evenodd"
1919
/>
2020
</SVG>
2121
);

src/blocks/shared-block/sharedBlocksSelector.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
/* global multisiteSharedBlocksEditorData */
2+
/* eslint-disable jsdoc/check-line-alignment */
23

34
/**
45
* External dependencies

src/hooks/registerSharedBlockAttributes.js

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,3 @@
1-
/**
2-
* External dependencies
3-
*/
4-
import { assign, isEmpty } from 'lodash';
5-
61
/**
72
* Internal dependencies
83
*/
@@ -21,13 +16,20 @@ import { blockSupportSharing, getBlockSharingAttributes } from './helper';
2116
const registerSharedBlockAttributes = ( settings, name ) => {
2217
const sharedBlockAttributes = getBlockSharingAttributes();
2318

24-
if ( ! blockSupportSharing( name ) || isEmpty( sharedBlockAttributes ) ) {
19+
if (
20+
! blockSupportSharing( name ) ||
21+
Object.keys( sharedBlockAttributes ).length === 0
22+
) {
2523
return settings;
2624
}
2725

28-
return assign( {}, settings, {
29-
attributes: assign( {}, settings.attributes, sharedBlockAttributes ),
30-
} );
26+
return {
27+
...settings,
28+
attributes: {
29+
...settings.attributes,
30+
...sharedBlockAttributes,
31+
},
32+
};
3133
};
3234

3335
export default registerSharedBlockAttributes;

src/hooks/sharedBlockIdControls.js

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,3 @@
1-
/**
2-
* External dependencies
3-
*/
4-
import { isEmpty } from 'lodash';
5-
61
/**
72
* WordPress dependencies
83
*/
@@ -27,6 +22,10 @@ const sharedBlockIdControls = createHigherOrderComponent( ( BlockEdit ) => {
2722
const { name, attributes, setAttributes } = props;
2823
const { sharedBlockId, sharedBlockIsShared, sharedBlockShareTitle } =
2924
attributes;
25+
const hasShareTitle =
26+
sharedBlockShareTitle && sharedBlockShareTitle.length > 0
27+
? true
28+
: false;
3029

3130
const getEmptySharedBlockTitle = () => {
3231
return sprintf(
@@ -45,15 +44,11 @@ const sharedBlockIdControls = createHigherOrderComponent( ( BlockEdit ) => {
4544
};
4645

4746
const getTitleCharCount = ( title ) => {
48-
if ( isEmpty( title ) ) {
49-
return '0';
47+
if ( title && title.length > 0 ) {
48+
return count( title, 'characters_including_spaces', {} );
5049
}
5150

52-
return count(
53-
sharedBlockShareTitle,
54-
'characters_including_spaces',
55-
{}
56-
);
51+
return 0;
5752
};
5853

5954
if ( ! blockSupportSharing( name ) ) {
@@ -94,9 +89,11 @@ const sharedBlockIdControls = createHigherOrderComponent( ( BlockEdit ) => {
9489
'Public title for the shared block (%d/200)',
9590
'multisite-shared-blocks'
9691
),
97-
getTitleCharCount(
98-
sharedBlockShareTitle
99-
)
92+
hasShareTitle
93+
? getTitleCharCount(
94+
sharedBlockShareTitle
95+
)
96+
: 0
10097
) }
10198
value={ sharedBlockShareTitle }
10299
onChange={ ( value ) => setTitle( value ) }
@@ -105,7 +102,7 @@ const sharedBlockIdControls = createHigherOrderComponent( ( BlockEdit ) => {
105102
'multisite-shared-blocks'
106103
) }
107104
/>
108-
{ isEmpty( sharedBlockShareTitle ) && (
105+
{ ! hasShareTitle && (
109106
<p>
110107
<small>
111108
{ createInterpolateElement(

0 commit comments

Comments
 (0)