@wordpress/block-library 8.28.3 → 8.28.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/button/edit.js +1 -1
- package/build/button/edit.js.map +1 -1
- package/build/buttons/transforms.js +16 -2
- package/build/buttons/transforms.js.map +1 -1
- package/build/code/transforms.js +17 -6
- package/build/code/transforms.js.map +1 -1
- package/build/cover/edit/block-controls.js +14 -3
- package/build/cover/edit/block-controls.js.map +1 -1
- package/build/cover/edit/inspector-controls.js +1 -1
- package/build/cover/edit/inspector-controls.js.map +1 -1
- package/build/heading/transforms.js +17 -4
- package/build/heading/transforms.js.map +1 -1
- package/build/image/edit.js +2 -1
- package/build/image/edit.js.map +1 -1
- package/build/image/image.js +11 -3
- package/build/image/image.js.map +1 -1
- package/build/post-featured-image/edit.js +8 -11
- package/build/post-featured-image/edit.js.map +1 -1
- package/build/post-title/edit.js +2 -2
- package/build/post-title/edit.js.map +1 -1
- package/build/utils/caption.js +15 -5
- package/build/utils/caption.js.map +1 -1
- package/build/utils/get-transformed-metadata.js +57 -0
- package/build/utils/get-transformed-metadata.js.map +1 -0
- package/build-module/button/edit.js +2 -2
- package/build-module/button/edit.js.map +1 -1
- package/build-module/buttons/transforms.js +16 -2
- package/build-module/buttons/transforms.js.map +1 -1
- package/build-module/code/transforms.js +17 -6
- package/build-module/code/transforms.js.map +1 -1
- package/build-module/cover/edit/block-controls.js +15 -4
- package/build-module/cover/edit/block-controls.js.map +1 -1
- package/build-module/cover/edit/inspector-controls.js +1 -1
- package/build-module/cover/edit/inspector-controls.js.map +1 -1
- package/build-module/heading/transforms.js +17 -4
- package/build-module/heading/transforms.js.map +1 -1
- package/build-module/image/edit.js +2 -1
- package/build-module/image/edit.js.map +1 -1
- package/build-module/image/image.js +12 -4
- package/build-module/image/image.js.map +1 -1
- package/build-module/post-featured-image/edit.js +9 -12
- package/build-module/post-featured-image/edit.js.map +1 -1
- package/build-module/post-title/edit.js +2 -2
- package/build-module/post-title/edit.js.map +1 -1
- package/build-module/utils/caption.js +13 -3
- package/build-module/utils/caption.js.map +1 -1
- package/build-module/utils/get-transformed-metadata.js +51 -0
- package/build-module/utils/get-transformed-metadata.js.map +1 -0
- package/build-style/cover/style-rtl.css +2 -1
- package/build-style/cover/style.css +2 -1
- package/build-style/search/style-rtl.css +2 -0
- package/build-style/search/style.css +2 -0
- package/build-style/style-rtl.css +4 -1
- package/build-style/style.css +4 -1
- package/package.json +12 -12
- package/src/button/edit.js +2 -1
- package/src/buttons/transforms.js +14 -4
- package/src/code/transforms.js +20 -5
- package/src/cover/edit/block-controls.js +16 -2
- package/src/cover/edit/inspector-controls.js +5 -1
- package/src/cover/style.scss +3 -2
- package/src/footnotes/index.php +1 -1
- package/src/heading/transforms.js +27 -8
- package/src/image/edit.js +2 -1
- package/src/image/image.js +12 -4
- package/src/navigation/index.php +7 -3
- package/src/post-featured-image/edit.js +9 -11
- package/src/post-title/edit.js +49 -43
- package/src/search/style.scss +2 -0
- package/src/utils/caption.js +10 -1
- package/src/utils/get-transformed-metadata.js +65 -0
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { getBlockType } from '@wordpress/blocks';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Transform the metadata attribute with only the values and bindings specified by each transform.
|
|
8
|
+
* Returns `undefined` if the input metadata is falsy.
|
|
9
|
+
*
|
|
10
|
+
* @param {Object} metadata Original metadata attribute from the block that is being transformed.
|
|
11
|
+
* @param {Object} newBlockName Name of the final block after the transformation.
|
|
12
|
+
* @param {Function} bindingsCallback Optional callback to transform the `bindings` property object.
|
|
13
|
+
* @return {Object|undefined} New metadata object only with the relevant properties.
|
|
14
|
+
*/
|
|
15
|
+
export function getTransformedMetadata(metadata, newBlockName, bindingsCallback) {
|
|
16
|
+
if (!metadata) {
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
const {
|
|
20
|
+
supports
|
|
21
|
+
} = getBlockType(newBlockName);
|
|
22
|
+
// Fixed until an opt-in mechanism is implemented.
|
|
23
|
+
const BLOCK_BINDINGS_SUPPORTED_BLOCKS = ['core/paragraph', 'core/heading', 'core/image', 'core/button'];
|
|
24
|
+
// The metadata properties that should be preserved after the transform.
|
|
25
|
+
const transformSupportedProps = [];
|
|
26
|
+
// If it support bindings, and there is a transform bindings callback, add the `id` and `bindings` properties.
|
|
27
|
+
if (BLOCK_BINDINGS_SUPPORTED_BLOCKS.includes(newBlockName) && bindingsCallback) {
|
|
28
|
+
transformSupportedProps.push('id', 'bindings');
|
|
29
|
+
}
|
|
30
|
+
// If it support block naming (true by default), add the `name` property.
|
|
31
|
+
if (supports.renaming !== false) {
|
|
32
|
+
transformSupportedProps.push('name');
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// Return early if no supported properties.
|
|
36
|
+
if (!transformSupportedProps.length) {
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
const newMetadata = Object.entries(metadata).reduce((obj, [prop, value]) => {
|
|
40
|
+
// If prop is not supported, don't add it to the new metadata object.
|
|
41
|
+
if (!transformSupportedProps.includes(prop)) {
|
|
42
|
+
return obj;
|
|
43
|
+
}
|
|
44
|
+
obj[prop] = prop === 'bindings' ? bindingsCallback(value) : value;
|
|
45
|
+
return obj;
|
|
46
|
+
}, {});
|
|
47
|
+
|
|
48
|
+
// Return undefined if object is empty.
|
|
49
|
+
return Object.keys(newMetadata).length ? newMetadata : undefined;
|
|
50
|
+
}
|
|
51
|
+
//# sourceMappingURL=get-transformed-metadata.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["getBlockType","getTransformedMetadata","metadata","newBlockName","bindingsCallback","supports","BLOCK_BINDINGS_SUPPORTED_BLOCKS","transformSupportedProps","includes","push","renaming","length","newMetadata","Object","entries","reduce","obj","prop","value","keys","undefined"],"sources":["@wordpress/block-library/src/utils/get-transformed-metadata.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { getBlockType } from '@wordpress/blocks';\n\n/**\n * Transform the metadata attribute with only the values and bindings specified by each transform.\n * Returns `undefined` if the input metadata is falsy.\n *\n * @param {Object} metadata Original metadata attribute from the block that is being transformed.\n * @param {Object} newBlockName Name of the final block after the transformation.\n * @param {Function} bindingsCallback Optional callback to transform the `bindings` property object.\n * @return {Object|undefined} New metadata object only with the relevant properties.\n */\nexport function getTransformedMetadata(\n\tmetadata,\n\tnewBlockName,\n\tbindingsCallback\n) {\n\tif ( ! metadata ) {\n\t\treturn;\n\t}\n\tconst { supports } = getBlockType( newBlockName );\n\t// Fixed until an opt-in mechanism is implemented.\n\tconst BLOCK_BINDINGS_SUPPORTED_BLOCKS = [\n\t\t'core/paragraph',\n\t\t'core/heading',\n\t\t'core/image',\n\t\t'core/button',\n\t];\n\t// The metadata properties that should be preserved after the transform.\n\tconst transformSupportedProps = [];\n\t// If it support bindings, and there is a transform bindings callback, add the `id` and `bindings` properties.\n\tif (\n\t\tBLOCK_BINDINGS_SUPPORTED_BLOCKS.includes( newBlockName ) &&\n\t\tbindingsCallback\n\t) {\n\t\ttransformSupportedProps.push( 'id', 'bindings' );\n\t}\n\t// If it support block naming (true by default), add the `name` property.\n\tif ( supports.renaming !== false ) {\n\t\ttransformSupportedProps.push( 'name' );\n\t}\n\n\t// Return early if no supported properties.\n\tif ( ! transformSupportedProps.length ) {\n\t\treturn;\n\t}\n\n\tconst newMetadata = Object.entries( metadata ).reduce(\n\t\t( obj, [ prop, value ] ) => {\n\t\t\t// If prop is not supported, don't add it to the new metadata object.\n\t\t\tif ( ! transformSupportedProps.includes( prop ) ) {\n\t\t\t\treturn obj;\n\t\t\t}\n\t\t\tobj[ prop ] =\n\t\t\t\tprop === 'bindings' ? bindingsCallback( value ) : value;\n\t\t\treturn obj;\n\t\t},\n\t\t{}\n\t);\n\n\t// Return undefined if object is empty.\n\treturn Object.keys( newMetadata ).length ? newMetadata : undefined;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,YAAY,QAAQ,mBAAmB;;AAEhD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,sBAAsBA,CACrCC,QAAQ,EACRC,YAAY,EACZC,gBAAgB,EACf;EACD,IAAK,CAAEF,QAAQ,EAAG;IACjB;EACD;EACA,MAAM;IAAEG;EAAS,CAAC,GAAGL,YAAY,CAAEG,YAAa,CAAC;EACjD;EACA,MAAMG,+BAA+B,GAAG,CACvC,gBAAgB,EAChB,cAAc,EACd,YAAY,EACZ,aAAa,CACb;EACD;EACA,MAAMC,uBAAuB,GAAG,EAAE;EAClC;EACA,IACCD,+BAA+B,CAACE,QAAQ,CAAEL,YAAa,CAAC,IACxDC,gBAAgB,EACf;IACDG,uBAAuB,CAACE,IAAI,CAAE,IAAI,EAAE,UAAW,CAAC;EACjD;EACA;EACA,IAAKJ,QAAQ,CAACK,QAAQ,KAAK,KAAK,EAAG;IAClCH,uBAAuB,CAACE,IAAI,CAAE,MAAO,CAAC;EACvC;;EAEA;EACA,IAAK,CAAEF,uBAAuB,CAACI,MAAM,EAAG;IACvC;EACD;EAEA,MAAMC,WAAW,GAAGC,MAAM,CAACC,OAAO,CAAEZ,QAAS,CAAC,CAACa,MAAM,CACpD,CAAEC,GAAG,EAAE,CAAEC,IAAI,EAAEC,KAAK,CAAE,KAAM;IAC3B;IACA,IAAK,CAAEX,uBAAuB,CAACC,QAAQ,CAAES,IAAK,CAAC,EAAG;MACjD,OAAOD,GAAG;IACX;IACAA,GAAG,CAAEC,IAAI,CAAE,GACVA,IAAI,KAAK,UAAU,GAAGb,gBAAgB,CAAEc,KAAM,CAAC,GAAGA,KAAK;IACxD,OAAOF,GAAG;EACX,CAAC,EACD,CAAC,CACF,CAAC;;EAED;EACA,OAAOH,MAAM,CAACM,IAAI,CAAEP,WAAY,CAAC,CAACD,MAAM,GAAGC,WAAW,GAAGQ,SAAS;AACnE"}
|
|
@@ -95,7 +95,8 @@
|
|
|
95
95
|
justify-content: center;
|
|
96
96
|
align-items: center;
|
|
97
97
|
padding: 1em;
|
|
98
|
-
overflow
|
|
98
|
+
overflow: hidden;
|
|
99
|
+
overflow: clip;
|
|
99
100
|
box-sizing: border-box; direction: ltr;
|
|
100
101
|
/**
|
|
101
102
|
* Set a default background color for has-background-dim _unless_ it includes another
|
|
@@ -613,7 +613,8 @@
|
|
|
613
613
|
justify-content: center;
|
|
614
614
|
align-items: center;
|
|
615
615
|
padding: 1em;
|
|
616
|
-
overflow
|
|
616
|
+
overflow: hidden;
|
|
617
|
+
overflow: clip;
|
|
617
618
|
box-sizing: border-box; direction: ltr;
|
|
618
619
|
/**
|
|
619
620
|
* Set a default background color for has-background-dim _unless_ it includes another
|
|
@@ -3252,6 +3253,8 @@ ul.wp-block-rss.is-grid li {
|
|
|
3252
3253
|
.wp-block-search__button svg {
|
|
3253
3254
|
min-width: 24px;
|
|
3254
3255
|
min-height: 24px;
|
|
3256
|
+
width: 1.25em;
|
|
3257
|
+
height: 1.25em;
|
|
3255
3258
|
fill: currentColor;
|
|
3256
3259
|
vertical-align: text-bottom;
|
|
3257
3260
|
}
|
package/build-style/style.css
CHANGED
|
@@ -618,7 +618,8 @@
|
|
|
618
618
|
justify-content: center;
|
|
619
619
|
align-items: center;
|
|
620
620
|
padding: 1em;
|
|
621
|
-
overflow
|
|
621
|
+
overflow: hidden;
|
|
622
|
+
overflow: clip;
|
|
622
623
|
box-sizing: border-box;
|
|
623
624
|
/*rtl:raw: direction: ltr; */
|
|
624
625
|
/**
|
|
@@ -3286,6 +3287,8 @@ ul.wp-block-rss.is-grid li {
|
|
|
3286
3287
|
.wp-block-search__button svg {
|
|
3287
3288
|
min-width: 24px;
|
|
3288
3289
|
min-height: 24px;
|
|
3290
|
+
width: 1.25em;
|
|
3291
|
+
height: 1.25em;
|
|
3289
3292
|
fill: currentColor;
|
|
3290
3293
|
vertical-align: text-bottom;
|
|
3291
3294
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wordpress/block-library",
|
|
3
|
-
"version": "8.28.
|
|
3
|
+
"version": "8.28.4",
|
|
4
4
|
"description": "Block library for the WordPress editor.",
|
|
5
5
|
"author": "The WordPress Contributors",
|
|
6
6
|
"license": "GPL-2.0-or-later",
|
|
@@ -35,11 +35,11 @@
|
|
|
35
35
|
"@wordpress/api-fetch": "^6.48.1",
|
|
36
36
|
"@wordpress/autop": "^3.51.1",
|
|
37
37
|
"@wordpress/blob": "^3.51.1",
|
|
38
|
-
"@wordpress/block-editor": "^12.19.
|
|
39
|
-
"@wordpress/blocks": "^12.28.
|
|
40
|
-
"@wordpress/components": "^26.0.
|
|
38
|
+
"@wordpress/block-editor": "^12.19.4",
|
|
39
|
+
"@wordpress/blocks": "^12.28.4",
|
|
40
|
+
"@wordpress/components": "^26.0.3",
|
|
41
41
|
"@wordpress/compose": "^6.28.1",
|
|
42
|
-
"@wordpress/core-data": "^6.28.
|
|
42
|
+
"@wordpress/core-data": "^6.28.4",
|
|
43
43
|
"@wordpress/data": "^9.21.1",
|
|
44
44
|
"@wordpress/date": "^4.51.1",
|
|
45
45
|
"@wordpress/deprecated": "^3.51.1",
|
|
@@ -49,17 +49,17 @@
|
|
|
49
49
|
"@wordpress/hooks": "^3.51.1",
|
|
50
50
|
"@wordpress/html-entities": "^3.51.1",
|
|
51
51
|
"@wordpress/i18n": "^4.51.1",
|
|
52
|
-
"@wordpress/icons": "^9.42.
|
|
53
|
-
"@wordpress/interactivity": "^5.0.
|
|
54
|
-
"@wordpress/interactivity-router": "^1.1.
|
|
52
|
+
"@wordpress/icons": "^9.42.2",
|
|
53
|
+
"@wordpress/interactivity": "^5.0.2",
|
|
54
|
+
"@wordpress/interactivity-router": "^1.1.2",
|
|
55
55
|
"@wordpress/keycodes": "^3.51.1",
|
|
56
56
|
"@wordpress/notices": "^4.19.1",
|
|
57
|
-
"@wordpress/patterns": "^1.12.
|
|
57
|
+
"@wordpress/patterns": "^1.12.4",
|
|
58
58
|
"@wordpress/primitives": "^3.49.1",
|
|
59
59
|
"@wordpress/private-apis": "^0.33.1",
|
|
60
|
-
"@wordpress/reusable-blocks": "^4.28.
|
|
60
|
+
"@wordpress/reusable-blocks": "^4.28.4",
|
|
61
61
|
"@wordpress/rich-text": "^6.28.2",
|
|
62
|
-
"@wordpress/server-side-render": "^4.28.
|
|
62
|
+
"@wordpress/server-side-render": "^4.28.4",
|
|
63
63
|
"@wordpress/url": "^3.52.1",
|
|
64
64
|
"@wordpress/viewport": "^5.28.1",
|
|
65
65
|
"@wordpress/wordcount": "^3.51.1",
|
|
@@ -80,5 +80,5 @@
|
|
|
80
80
|
"publishConfig": {
|
|
81
81
|
"access": "public"
|
|
82
82
|
},
|
|
83
|
-
"gitHead": "
|
|
83
|
+
"gitHead": "864c1c553cb284def3bd5c907998da45f5c143ea"
|
|
84
84
|
}
|
package/src/button/edit.js
CHANGED
|
@@ -45,6 +45,7 @@ import {
|
|
|
45
45
|
createBlock,
|
|
46
46
|
cloneBlock,
|
|
47
47
|
getDefaultBlockName,
|
|
48
|
+
store as blocksStore,
|
|
48
49
|
} from '@wordpress/blocks';
|
|
49
50
|
import { useMergeRefs, useRefEffect } from '@wordpress/compose';
|
|
50
51
|
import { useSelect, useDispatch } from '@wordpress/data';
|
|
@@ -239,7 +240,7 @@ function ButtonEdit( props ) {
|
|
|
239
240
|
}
|
|
240
241
|
|
|
241
242
|
const blockBindingsSource = unlock(
|
|
242
|
-
select(
|
|
243
|
+
select( blocksStore )
|
|
243
244
|
).getBlockBindingsSource( metadata?.bindings?.url?.source );
|
|
244
245
|
|
|
245
246
|
return {
|
|
@@ -4,6 +4,11 @@
|
|
|
4
4
|
import { createBlock } from '@wordpress/blocks';
|
|
5
5
|
import { __unstableCreateElement as createElement } from '@wordpress/rich-text';
|
|
6
6
|
|
|
7
|
+
/**
|
|
8
|
+
* Internal dependencies
|
|
9
|
+
*/
|
|
10
|
+
import { getTransformedMetadata } from '../utils/get-transformed-metadata';
|
|
11
|
+
|
|
7
12
|
const transforms = {
|
|
8
13
|
from: [
|
|
9
14
|
{
|
|
@@ -33,10 +38,8 @@ const transforms = {
|
|
|
33
38
|
{},
|
|
34
39
|
// Loop the selected buttons.
|
|
35
40
|
buttons.map( ( attributes ) => {
|
|
36
|
-
const
|
|
37
|
-
|
|
38
|
-
attributes.content
|
|
39
|
-
);
|
|
41
|
+
const { content, metadata } = attributes;
|
|
42
|
+
const element = createElement( document, content );
|
|
40
43
|
// Remove any HTML tags.
|
|
41
44
|
const text = element.innerText || '';
|
|
42
45
|
// Get first url.
|
|
@@ -46,6 +49,13 @@ const transforms = {
|
|
|
46
49
|
return createBlock( 'core/button', {
|
|
47
50
|
text,
|
|
48
51
|
url,
|
|
52
|
+
metadata: getTransformedMetadata(
|
|
53
|
+
metadata,
|
|
54
|
+
'core/button',
|
|
55
|
+
( { content: contentBinding } ) => ( {
|
|
56
|
+
text: contentBinding,
|
|
57
|
+
} )
|
|
58
|
+
),
|
|
49
59
|
} );
|
|
50
60
|
} )
|
|
51
61
|
),
|
package/src/code/transforms.js
CHANGED
|
@@ -4,6 +4,11 @@
|
|
|
4
4
|
import { createBlock } from '@wordpress/blocks';
|
|
5
5
|
import { create, toHTMLString } from '@wordpress/rich-text';
|
|
6
6
|
|
|
7
|
+
/**
|
|
8
|
+
* Internal dependencies
|
|
9
|
+
*/
|
|
10
|
+
import { getTransformedMetadata } from '../utils/get-transformed-metadata';
|
|
11
|
+
|
|
7
12
|
const transforms = {
|
|
8
13
|
from: [
|
|
9
14
|
{
|
|
@@ -14,17 +19,21 @@ const transforms = {
|
|
|
14
19
|
{
|
|
15
20
|
type: 'block',
|
|
16
21
|
blocks: [ 'core/paragraph' ],
|
|
17
|
-
transform: ( { content } ) =>
|
|
18
|
-
createBlock( 'core/code', {
|
|
22
|
+
transform: ( { content, metadata } ) =>
|
|
23
|
+
createBlock( 'core/code', {
|
|
24
|
+
content,
|
|
25
|
+
metadata: getTransformedMetadata( metadata, 'core/code' ),
|
|
26
|
+
} ),
|
|
19
27
|
},
|
|
20
28
|
{
|
|
21
29
|
type: 'block',
|
|
22
30
|
blocks: [ 'core/html' ],
|
|
23
|
-
transform: ( { content: text } ) => {
|
|
31
|
+
transform: ( { content: text, metadata } ) => {
|
|
24
32
|
return createBlock( 'core/code', {
|
|
25
33
|
// The HTML is plain text (with plain line breaks), so
|
|
26
34
|
// convert it to rich text.
|
|
27
35
|
content: toHTMLString( { value: create( { text } ) } ),
|
|
36
|
+
metadata: getTransformedMetadata( metadata, 'core/code' ),
|
|
28
37
|
} );
|
|
29
38
|
},
|
|
30
39
|
},
|
|
@@ -51,8 +60,14 @@ const transforms = {
|
|
|
51
60
|
{
|
|
52
61
|
type: 'block',
|
|
53
62
|
blocks: [ 'core/paragraph' ],
|
|
54
|
-
transform: ( { content } ) =>
|
|
55
|
-
createBlock( 'core/paragraph', {
|
|
63
|
+
transform: ( { content, metadata } ) =>
|
|
64
|
+
createBlock( 'core/paragraph', {
|
|
65
|
+
content,
|
|
66
|
+
metadata: getTransformedMetadata(
|
|
67
|
+
metadata,
|
|
68
|
+
'core/paragraph'
|
|
69
|
+
),
|
|
70
|
+
} ),
|
|
56
71
|
},
|
|
57
72
|
],
|
|
58
73
|
};
|
|
@@ -8,6 +8,7 @@ import {
|
|
|
8
8
|
MediaReplaceFlow,
|
|
9
9
|
__experimentalBlockAlignmentMatrixControl as BlockAlignmentMatrixControl,
|
|
10
10
|
__experimentalBlockFullHeightAligmentControl as FullHeightAlignmentControl,
|
|
11
|
+
privateApis as blockEditorPrivateApis,
|
|
11
12
|
} from '@wordpress/block-editor';
|
|
12
13
|
import { __ } from '@wordpress/i18n';
|
|
13
14
|
|
|
@@ -15,6 +16,9 @@ import { __ } from '@wordpress/i18n';
|
|
|
15
16
|
* Internal dependencies
|
|
16
17
|
*/
|
|
17
18
|
import { ALLOWED_MEDIA_TYPES } from '../shared';
|
|
19
|
+
import { unlock } from '../../lock-unlock';
|
|
20
|
+
|
|
21
|
+
const { cleanEmptyObject } = unlock( blockEditorPrivateApis );
|
|
18
22
|
|
|
19
23
|
export default function CoverBlockControls( {
|
|
20
24
|
attributes,
|
|
@@ -30,7 +34,10 @@ export default function CoverBlockControls( {
|
|
|
30
34
|
const [ prevMinHeightValue, setPrevMinHeightValue ] = useState( minHeight );
|
|
31
35
|
const [ prevMinHeightUnit, setPrevMinHeightUnit ] =
|
|
32
36
|
useState( minHeightUnit );
|
|
33
|
-
const isMinFullHeight =
|
|
37
|
+
const isMinFullHeight =
|
|
38
|
+
minHeightUnit === 'vh' &&
|
|
39
|
+
minHeight === 100 &&
|
|
40
|
+
! attributes?.style?.dimensions?.aspectRatio;
|
|
34
41
|
const toggleMinFullHeight = () => {
|
|
35
42
|
if ( isMinFullHeight ) {
|
|
36
43
|
// If there aren't previous values, take the default ones.
|
|
@@ -51,10 +58,17 @@ export default function CoverBlockControls( {
|
|
|
51
58
|
setPrevMinHeightValue( minHeight );
|
|
52
59
|
setPrevMinHeightUnit( minHeightUnit );
|
|
53
60
|
|
|
54
|
-
// Set full height.
|
|
61
|
+
// Set full height, and clear any aspect ratio value.
|
|
55
62
|
return setAttributes( {
|
|
56
63
|
minHeight: 100,
|
|
57
64
|
minHeightUnit: 'vh',
|
|
65
|
+
style: cleanEmptyObject( {
|
|
66
|
+
...attributes?.style,
|
|
67
|
+
dimensions: {
|
|
68
|
+
...attributes?.style?.dimensions,
|
|
69
|
+
aspectRatio: undefined, // Reset aspect ratio when minHeight is set.
|
|
70
|
+
},
|
|
71
|
+
} ),
|
|
58
72
|
} );
|
|
59
73
|
};
|
|
60
74
|
|
|
@@ -308,7 +308,11 @@ export default function CoverInspectorControls( {
|
|
|
308
308
|
panelId={ clientId }
|
|
309
309
|
>
|
|
310
310
|
<CoverHeightInput
|
|
311
|
-
value={
|
|
311
|
+
value={
|
|
312
|
+
attributes?.style?.dimensions?.aspectRatio
|
|
313
|
+
? ''
|
|
314
|
+
: minHeight
|
|
315
|
+
}
|
|
312
316
|
unit={ minHeightUnit }
|
|
313
317
|
onChange={ ( newMinHeight ) =>
|
|
314
318
|
setAttributes( {
|
package/src/cover/style.scss
CHANGED
|
@@ -8,9 +8,10 @@
|
|
|
8
8
|
align-items: center;
|
|
9
9
|
padding: 1em;
|
|
10
10
|
// Prevent the `wp-block-cover__background` span from overflowing the container when border-radius is applied.
|
|
11
|
+
// `overflow: hidden` is provided as a fallback for browsers that don't support `overflow: clip`.
|
|
12
|
+
overflow: hidden;
|
|
11
13
|
// Use clip instead of overflow: hidden so that sticky position works on child elements.
|
|
12
|
-
|
|
13
|
-
overflow-x: clip;
|
|
14
|
+
overflow: clip;
|
|
14
15
|
// This block has customizable padding, border-box makes that more predictable.
|
|
15
16
|
box-sizing: border-box;
|
|
16
17
|
// Keep the flex layout direction to the physical direction (LTR) in RTL languages.
|
package/src/footnotes/index.php
CHANGED
|
@@ -7,6 +7,7 @@ import { createBlock, getBlockAttributes } from '@wordpress/blocks';
|
|
|
7
7
|
* Internal dependencies
|
|
8
8
|
*/
|
|
9
9
|
import { getLevelFromHeadingNodeName } from './shared';
|
|
10
|
+
import { getTransformedMetadata } from '../utils/get-transformed-metadata';
|
|
10
11
|
|
|
11
12
|
const transforms = {
|
|
12
13
|
from: [
|
|
@@ -15,12 +16,20 @@ const transforms = {
|
|
|
15
16
|
isMultiBlock: true,
|
|
16
17
|
blocks: [ 'core/paragraph' ],
|
|
17
18
|
transform: ( attributes ) =>
|
|
18
|
-
attributes.map(
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
19
|
+
attributes.map(
|
|
20
|
+
( { content, anchor, align: textAlign, metadata } ) =>
|
|
21
|
+
createBlock( 'core/heading', {
|
|
22
|
+
content,
|
|
23
|
+
anchor,
|
|
24
|
+
textAlign,
|
|
25
|
+
metadata: getTransformedMetadata(
|
|
26
|
+
metadata,
|
|
27
|
+
'core/heading',
|
|
28
|
+
( { content: contentBinding } ) => ( {
|
|
29
|
+
content: contentBinding,
|
|
30
|
+
} )
|
|
31
|
+
),
|
|
32
|
+
} )
|
|
24
33
|
),
|
|
25
34
|
},
|
|
26
35
|
{
|
|
@@ -82,8 +91,18 @@ const transforms = {
|
|
|
82
91
|
isMultiBlock: true,
|
|
83
92
|
blocks: [ 'core/paragraph' ],
|
|
84
93
|
transform: ( attributes ) =>
|
|
85
|
-
attributes.map( ( { content, textAlign: align } ) =>
|
|
86
|
-
createBlock( 'core/paragraph', {
|
|
94
|
+
attributes.map( ( { content, textAlign: align, metadata } ) =>
|
|
95
|
+
createBlock( 'core/paragraph', {
|
|
96
|
+
content,
|
|
97
|
+
align,
|
|
98
|
+
metadata: getTransformedMetadata(
|
|
99
|
+
metadata,
|
|
100
|
+
'core/paragraph',
|
|
101
|
+
( { content: contentBinding } ) => ( {
|
|
102
|
+
content: contentBinding,
|
|
103
|
+
} )
|
|
104
|
+
),
|
|
105
|
+
} )
|
|
87
106
|
),
|
|
88
107
|
},
|
|
89
108
|
],
|
package/src/image/edit.js
CHANGED
|
@@ -7,6 +7,7 @@ import classnames from 'classnames';
|
|
|
7
7
|
* WordPress dependencies
|
|
8
8
|
*/
|
|
9
9
|
import { getBlobByURL, isBlobURL, revokeBlobURL } from '@wordpress/blob';
|
|
10
|
+
import { store as blocksStore } from '@wordpress/blocks';
|
|
10
11
|
import { Placeholder } from '@wordpress/components';
|
|
11
12
|
import { useDispatch, useSelect } from '@wordpress/data';
|
|
12
13
|
import {
|
|
@@ -342,7 +343,7 @@ export function ImageEdit( {
|
|
|
342
343
|
}
|
|
343
344
|
|
|
344
345
|
const blockBindingsSource = unlock(
|
|
345
|
-
select(
|
|
346
|
+
select( blocksStore )
|
|
346
347
|
).getBlockBindingsSource( metadata?.bindings?.url?.source );
|
|
347
348
|
|
|
348
349
|
return {
|
package/src/image/image.js
CHANGED
|
@@ -33,7 +33,7 @@ import { useEffect, useMemo, useState, useRef } from '@wordpress/element';
|
|
|
33
33
|
import { __, _x, sprintf, isRTL } from '@wordpress/i18n';
|
|
34
34
|
import { DOWN } from '@wordpress/keycodes';
|
|
35
35
|
import { getFilename } from '@wordpress/url';
|
|
36
|
-
import { switchToBlockType } from '@wordpress/blocks';
|
|
36
|
+
import { switchToBlockType, store as blocksStore } from '@wordpress/blocks';
|
|
37
37
|
import { crop, overlayText, upload } from '@wordpress/icons';
|
|
38
38
|
import { store as noticesStore } from '@wordpress/notices';
|
|
39
39
|
import { store as coreStore } from '@wordpress/core-data';
|
|
@@ -411,14 +411,16 @@ export default function Image( {
|
|
|
411
411
|
lockHrefControls = false,
|
|
412
412
|
lockAltControls = false,
|
|
413
413
|
lockTitleControls = false,
|
|
414
|
+
lockCaption = false,
|
|
414
415
|
} = useSelect(
|
|
415
416
|
( select ) => {
|
|
416
417
|
if ( ! isSingleSelected ) {
|
|
417
418
|
return {};
|
|
418
419
|
}
|
|
419
|
-
|
|
420
|
-
const {
|
|
421
|
-
|
|
420
|
+
const { getBlockBindingsSource } = unlock( select( blocksStore ) );
|
|
421
|
+
const { getBlockParentsByBlockName } = unlock(
|
|
422
|
+
select( blockEditorStore )
|
|
423
|
+
);
|
|
422
424
|
const {
|
|
423
425
|
url: urlBinding,
|
|
424
426
|
alt: altBinding,
|
|
@@ -444,6 +446,10 @@ export default function Image( {
|
|
|
444
446
|
// Disable editing the link of the URL if the image is inside a pattern instance.
|
|
445
447
|
// This is a temporary solution until we support overriding the link on the frontend.
|
|
446
448
|
hasParentPattern,
|
|
449
|
+
lockCaption:
|
|
450
|
+
// Disable editing the caption if the image is inside a pattern instance.
|
|
451
|
+
// This is a temporary solution until we support overriding the caption on the frontend.
|
|
452
|
+
hasParentPattern,
|
|
447
453
|
lockAltControls:
|
|
448
454
|
!! altBinding &&
|
|
449
455
|
( ! altBindingSource ||
|
|
@@ -907,6 +913,7 @@ export default function Image( {
|
|
|
907
913
|
which causes duplicated image upload. */ }
|
|
908
914
|
{ ! temporaryURL && controls }
|
|
909
915
|
{ img }
|
|
916
|
+
|
|
910
917
|
<Caption
|
|
911
918
|
attributes={ attributes }
|
|
912
919
|
setAttributes={ setAttributes }
|
|
@@ -914,6 +921,7 @@ export default function Image( {
|
|
|
914
921
|
insertBlocksAfter={ insertBlocksAfter }
|
|
915
922
|
label={ __( 'Image caption text' ) }
|
|
916
923
|
showToolbarButton={ isSingleSelected && hasNonContentControls }
|
|
924
|
+
disableEditing={ lockCaption }
|
|
917
925
|
/>
|
|
918
926
|
</>
|
|
919
927
|
);
|
package/src/navigation/index.php
CHANGED
|
@@ -554,14 +554,18 @@ class WP_Navigation_Block_Renderer {
|
|
|
554
554
|
// When adding to this array be mindful of security concerns.
|
|
555
555
|
$nav_element_context = data_wp_context(
|
|
556
556
|
array(
|
|
557
|
-
'overlayOpenedBy' => array(
|
|
557
|
+
'overlayOpenedBy' => array(
|
|
558
|
+
'click' => false,
|
|
559
|
+
'hover' => false,
|
|
560
|
+
'focus' => false,
|
|
561
|
+
),
|
|
558
562
|
'type' => 'overlay',
|
|
559
563
|
'roleAttribute' => '',
|
|
560
564
|
'ariaLabel' => __( 'Menu' ),
|
|
561
565
|
)
|
|
562
566
|
);
|
|
563
567
|
$nav_element_directives = '
|
|
564
|
-
data-wp-interactive="core/navigation"'
|
|
568
|
+
data-wp-interactive="core/navigation" '
|
|
565
569
|
. $nav_element_context;
|
|
566
570
|
|
|
567
571
|
return $nav_element_directives;
|
|
@@ -764,7 +768,7 @@ function block_core_navigation_add_directives_to_submenu( $tags, $block_attribut
|
|
|
764
768
|
) ) {
|
|
765
769
|
// Add directives to the parent `<li>`.
|
|
766
770
|
$tags->set_attribute( 'data-wp-interactive', 'core/navigation' );
|
|
767
|
-
$tags->set_attribute( 'data-wp-context', '{ "submenuOpenedBy": {}, "type": "submenu" }' );
|
|
771
|
+
$tags->set_attribute( 'data-wp-context', '{ "submenuOpenedBy": { "click": false, "hover": false, "focus": false }, "type": "submenu" }' );
|
|
768
772
|
$tags->set_attribute( 'data-wp-watch', 'callbacks.initMenu' );
|
|
769
773
|
$tags->set_attribute( 'data-wp-on--focusout', 'actions.handleMenuFocusout' );
|
|
770
774
|
$tags->set_attribute( 'data-wp-on--keydown', 'actions.handleMenuKeydown' );
|
|
@@ -24,6 +24,7 @@ import {
|
|
|
24
24
|
useBlockProps,
|
|
25
25
|
store as blockEditorStore,
|
|
26
26
|
__experimentalUseBorderProps as useBorderProps,
|
|
27
|
+
useBlockEditingMode,
|
|
27
28
|
} from '@wordpress/block-editor';
|
|
28
29
|
import { useMemo } from '@wordpress/element';
|
|
29
30
|
import { __, sprintf } from '@wordpress/i18n';
|
|
@@ -143,6 +144,7 @@ export default function PostFeaturedImageEdit( {
|
|
|
143
144
|
style: { width, height, aspectRatio },
|
|
144
145
|
} );
|
|
145
146
|
const borderProps = useBorderProps( attributes );
|
|
147
|
+
const blockEditingMode = useBlockEditingMode();
|
|
146
148
|
|
|
147
149
|
const placeholder = ( content ) => {
|
|
148
150
|
return (
|
|
@@ -174,8 +176,13 @@ export default function PostFeaturedImageEdit( {
|
|
|
174
176
|
createErrorNotice( message, { type: 'snackbar' } );
|
|
175
177
|
};
|
|
176
178
|
|
|
177
|
-
const controls = (
|
|
179
|
+
const controls = blockEditingMode === 'default' && (
|
|
178
180
|
<>
|
|
181
|
+
<Overlay
|
|
182
|
+
attributes={ attributes }
|
|
183
|
+
setAttributes={ setAttributes }
|
|
184
|
+
clientId={ clientId }
|
|
185
|
+
/>
|
|
179
186
|
<DimensionControls
|
|
180
187
|
clientId={ clientId }
|
|
181
188
|
attributes={ attributes }
|
|
@@ -224,6 +231,7 @@ export default function PostFeaturedImageEdit( {
|
|
|
224
231
|
</InspectorControls>
|
|
225
232
|
</>
|
|
226
233
|
);
|
|
234
|
+
|
|
227
235
|
let image;
|
|
228
236
|
|
|
229
237
|
/**
|
|
@@ -251,11 +259,6 @@ export default function PostFeaturedImageEdit( {
|
|
|
251
259
|
) : (
|
|
252
260
|
placeholder()
|
|
253
261
|
) }
|
|
254
|
-
<Overlay
|
|
255
|
-
attributes={ attributes }
|
|
256
|
-
setAttributes={ setAttributes }
|
|
257
|
-
clientId={ clientId }
|
|
258
|
-
/>
|
|
259
262
|
</div>
|
|
260
263
|
</>
|
|
261
264
|
);
|
|
@@ -360,11 +363,6 @@ export default function PostFeaturedImageEdit( {
|
|
|
360
363
|
) : (
|
|
361
364
|
image
|
|
362
365
|
) }
|
|
363
|
-
<Overlay
|
|
364
|
-
attributes={ attributes }
|
|
365
|
-
setAttributes={ setAttributes }
|
|
366
|
-
clientId={ clientId }
|
|
367
|
-
/>
|
|
368
366
|
</figure>
|
|
369
367
|
</>
|
|
370
368
|
);
|