@wordpress/block-library 8.26.0 → 8.27.1
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/CHANGELOG.md +2 -0
- package/build/avatar/edit.js +2 -2
- package/build/avatar/edit.js.map +1 -1
- package/build/block/edit.js +76 -13
- package/build/block/edit.js.map +1 -1
- package/build/block/{v1/edit.native.js → edit.native.js} +4 -4
- package/build/block/edit.native.js.map +1 -0
- package/build/block/index.js +5 -3
- package/build/block/index.js.map +1 -1
- package/build/button/edit.js +24 -6
- package/build/button/edit.js.map +1 -1
- package/build/button/index.js +1 -0
- package/build/button/index.js.map +1 -1
- package/build/button/save.js +3 -1
- package/build/button/save.js.map +1 -1
- package/build/cover/edit/index.js +2 -1
- package/build/cover/edit/index.js.map +1 -1
- package/build/cover/edit/inspector-controls.js +13 -1
- package/build/cover/edit/inspector-controls.js.map +1 -1
- package/build/cover/edit.native.js +1 -0
- package/build/cover/edit.native.js.map +1 -1
- package/build/cover/index.js +3 -0
- package/build/cover/index.js.map +1 -1
- package/build/embed/edit.js +3 -2
- package/build/embed/edit.js.map +1 -1
- package/build/file/index.js +0 -1
- package/build/file/index.js.map +1 -1
- package/build/footnotes/edit.js +2 -1
- package/build/footnotes/edit.js.map +1 -1
- package/build/footnotes/format.js +17 -19
- package/build/footnotes/format.js.map +1 -1
- package/build/group/index.js +1 -0
- package/build/group/index.js.map +1 -1
- package/build/heading/edit.js +2 -1
- package/build/heading/edit.js.map +1 -1
- package/build/heading/edit.native.js +141 -0
- package/build/heading/edit.native.js.map +1 -0
- package/build/heading/index.js +1 -0
- package/build/heading/index.js.map +1 -1
- package/build/image/edit.js +8 -4
- package/build/image/edit.js.map +1 -1
- package/build/image/image.js +33 -7
- package/build/image/image.js.map +1 -1
- package/build/image/index.js +6 -3
- package/build/image/index.js.map +1 -1
- package/build/more/index.js +4 -0
- package/build/more/index.js.map +1 -1
- package/build/navigation/edit/index.js +2 -2
- package/build/navigation/edit/index.js.map +1 -1
- package/build/navigation/index.js +0 -1
- package/build/navigation/index.js.map +1 -1
- package/build/paragraph/edit.js +2 -1
- package/build/paragraph/edit.js.map +1 -1
- package/build/paragraph/index.js +1 -2
- package/build/paragraph/index.js.map +1 -1
- package/build/paragraph/transforms.js +1 -2
- package/build/paragraph/transforms.js.map +1 -1
- package/build/post-content/edit.js +2 -2
- package/build/post-content/edit.js.map +1 -1
- package/build/post-date/edit.js +1 -1
- package/build/post-date/edit.js.map +1 -1
- package/build/post-navigation-link/edit.js +43 -2
- package/build/post-navigation-link/edit.js.map +1 -1
- package/build/post-navigation-link/index.js +8 -0
- package/build/post-navigation-link/index.js.map +1 -1
- package/build/pullquote/index.js +4 -0
- package/build/pullquote/index.js.map +1 -1
- package/build/query/edit/inspector-controls/index.js +3 -3
- package/build/query/edit/inspector-controls/index.js.map +1 -1
- package/build/query/edit/query-content.js +2 -2
- package/build/query/edit/query-content.js.map +1 -1
- package/build/query/edit/query-placeholder.js +6 -7
- package/build/query/edit/query-placeholder.js.map +1 -1
- package/build/query/index.js +1 -2
- package/build/query/index.js.map +1 -1
- package/build/query/variations.js +8 -1
- package/build/query/variations.js.map +1 -1
- package/build/query/view.js +31 -12
- package/build/query/view.js.map +1 -1
- package/build/search/index.js +0 -1
- package/build/search/index.js.map +1 -1
- package/build/table-of-contents/hooks.js +2 -2
- package/build/table-of-contents/hooks.js.map +1 -1
- package/build/template-part/edit/advanced-controls.js +1 -4
- package/build/template-part/edit/advanced-controls.js.map +1 -1
- package/build/template-part/edit/index.js +39 -17
- package/build/template-part/edit/index.js.map +1 -1
- package/build/video/edit.native.js +7 -2
- package/build/video/edit.native.js.map +1 -1
- package/build/video/transforms.js +17 -0
- package/build/video/transforms.js.map +1 -1
- package/build-module/avatar/edit.js +2 -2
- package/build-module/avatar/edit.js.map +1 -1
- package/build-module/block/edit.js +76 -13
- package/build-module/block/edit.js.map +1 -1
- package/build-module/block/{v1/edit.native.js → edit.native.js} +3 -3
- package/build-module/block/edit.native.js.map +1 -0
- package/build-module/block/index.js +5 -3
- package/build-module/block/index.js.map +1 -1
- package/build-module/button/edit.js +25 -7
- package/build-module/button/edit.js.map +1 -1
- package/build-module/button/index.js +1 -0
- package/build-module/button/index.js.map +1 -1
- package/build-module/button/save.js +4 -2
- package/build-module/button/save.js.map +1 -1
- package/build-module/cover/edit/index.js +2 -1
- package/build-module/cover/edit/index.js.map +1 -1
- package/build-module/cover/edit/inspector-controls.js +14 -2
- package/build-module/cover/edit/inspector-controls.js.map +1 -1
- package/build-module/cover/edit.native.js +1 -0
- package/build-module/cover/edit.native.js.map +1 -1
- package/build-module/cover/index.js +3 -0
- package/build-module/cover/index.js.map +1 -1
- package/build-module/embed/edit.js +3 -2
- package/build-module/embed/edit.js.map +1 -1
- package/build-module/file/index.js +0 -1
- package/build-module/file/index.js.map +1 -1
- package/build-module/footnotes/edit.js +2 -1
- package/build-module/footnotes/edit.js.map +1 -1
- package/build-module/footnotes/format.js +17 -19
- package/build-module/footnotes/format.js.map +1 -1
- package/build-module/group/index.js +1 -0
- package/build-module/group/index.js.map +1 -1
- package/build-module/heading/edit.js +3 -2
- package/build-module/heading/edit.js.map +1 -1
- package/build-module/heading/edit.native.js +132 -0
- package/build-module/heading/edit.native.js.map +1 -0
- package/build-module/heading/index.js +1 -0
- package/build-module/heading/index.js.map +1 -1
- package/build-module/image/edit.js +9 -5
- package/build-module/image/edit.js.map +1 -1
- package/build-module/image/image.js +33 -7
- package/build-module/image/image.js.map +1 -1
- package/build-module/image/index.js +6 -3
- package/build-module/image/index.js.map +1 -1
- package/build-module/more/index.js +4 -0
- package/build-module/more/index.js.map +1 -1
- package/build-module/navigation/edit/index.js +1 -1
- package/build-module/navigation/edit/index.js.map +1 -1
- package/build-module/navigation/index.js +0 -1
- package/build-module/navigation/index.js.map +1 -1
- package/build-module/paragraph/edit.js +3 -2
- package/build-module/paragraph/edit.js.map +1 -1
- package/build-module/paragraph/index.js +1 -2
- package/build-module/paragraph/index.js.map +1 -1
- package/build-module/paragraph/transforms.js +1 -2
- package/build-module/paragraph/transforms.js.map +1 -1
- package/build-module/post-content/edit.js +1 -1
- package/build-module/post-content/edit.js.map +1 -1
- package/build-module/post-date/edit.js +1 -1
- package/build-module/post-date/edit.js.map +1 -1
- package/build-module/post-navigation-link/edit.js +44 -3
- package/build-module/post-navigation-link/edit.js.map +1 -1
- package/build-module/post-navigation-link/index.js +8 -0
- package/build-module/post-navigation-link/index.js.map +1 -1
- package/build-module/pullquote/index.js +4 -0
- package/build-module/pullquote/index.js.map +1 -1
- package/build-module/query/edit/inspector-controls/index.js +4 -4
- package/build-module/query/edit/inspector-controls/index.js.map +1 -1
- package/build-module/query/edit/query-content.js +2 -2
- package/build-module/query/edit/query-content.js.map +1 -1
- package/build-module/query/edit/query-placeholder.js +7 -8
- package/build-module/query/edit/query-placeholder.js.map +1 -1
- package/build-module/query/index.js +1 -2
- package/build-module/query/index.js.map +1 -1
- package/build-module/query/variations.js +8 -1
- package/build-module/query/variations.js.map +1 -1
- package/build-module/query/view.js +30 -9
- package/build-module/query/view.js.map +1 -1
- package/build-module/search/index.js +0 -1
- package/build-module/search/index.js.map +1 -1
- package/build-module/table-of-contents/hooks.js +2 -2
- package/build-module/table-of-contents/hooks.js.map +1 -1
- package/build-module/template-part/edit/advanced-controls.js +1 -4
- package/build-module/template-part/edit/advanced-controls.js.map +1 -1
- package/build-module/template-part/edit/index.js +38 -16
- package/build-module/template-part/edit/index.js.map +1 -1
- package/build-module/video/edit.native.js +7 -2
- package/build-module/video/edit.native.js.map +1 -1
- package/build-module/video/transforms.js +17 -0
- package/build-module/video/transforms.js.map +1 -1
- package/build-style/common-rtl.css +4 -2
- package/build-style/common.css +4 -2
- package/build-style/cover/style-rtl.css +2 -4
- package/build-style/cover/style.css +2 -4
- package/build-style/editor-rtl.css +6 -4
- package/build-style/editor.css +6 -4
- package/build-style/gallery/style-rtl.css +2 -4
- package/build-style/gallery/style.css +2 -4
- package/build-style/image/editor-rtl.css +6 -0
- package/build-style/image/editor.css +6 -0
- package/build-style/page-list/editor-rtl.css +0 -4
- package/build-style/page-list/editor.css +0 -4
- package/build-style/pullquote/style-rtl.css +10 -1
- package/build-style/pullquote/style.css +10 -1
- package/build-style/search/style-rtl.css +2 -1
- package/build-style/search/style.css +2 -1
- package/build-style/style-rtl.css +20 -13
- package/build-style/style.css +20 -13
- package/build-style/video/style-rtl.css +1 -2
- package/build-style/video/style.css +1 -2
- package/package.json +34 -32
- package/src/avatar/edit.js +16 -18
- package/src/block/block.json +3 -0
- package/src/block/edit.js +102 -20
- package/src/block/{v1/edit.native.js → edit.native.js} +4 -4
- package/src/block/index.js +2 -3
- package/src/block/index.php +3 -31
- package/src/button/block.json +1 -0
- package/src/button/edit.js +76 -43
- package/src/button/save.js +3 -0
- package/src/buttons/test/__snapshots__/edit.native.js.snap +6 -0
- package/src/buttons/test/edit.native.js +49 -0
- package/src/cover/block.json +3 -0
- package/src/cover/edit/index.js +2 -1
- package/src/cover/edit/inspector-controls.js +14 -1
- package/src/cover/edit.native.js +1 -0
- package/src/cover/style.scss +2 -3
- package/src/embed/edit.js +3 -2
- package/src/file/block.json +0 -1
- package/src/file/index.php +11 -57
- package/src/footnotes/edit.js +2 -1
- package/src/footnotes/format.js +34 -31
- package/src/footnotes/index.php +20 -11
- package/src/gallery/index.php +0 -3
- package/src/group/block.json +1 -0
- package/src/heading/block.json +1 -0
- package/src/heading/edit.js +18 -14
- package/src/heading/edit.native.js +144 -0
- package/src/image/block.json +7 -3
- package/src/image/edit.js +19 -6
- package/src/image/editor.scss +6 -1
- package/src/image/image.js +101 -42
- package/src/image/index.js +6 -0
- package/src/image/index.php +14 -51
- package/src/more/index.js +6 -0
- package/src/navigation/block.json +0 -1
- package/src/navigation/edit/index.js +2 -2
- package/src/navigation/index.php +777 -28
- package/src/navigation-link/index.php +78 -16
- package/src/page-list/editor.scss +0 -4
- package/src/paragraph/block.json +1 -2
- package/src/paragraph/edit.js +23 -19
- package/src/post-content/edit.js +2 -2
- package/src/post-date/edit.js +38 -33
- package/src/post-navigation-link/block.json +8 -0
- package/src/post-navigation-link/edit.js +63 -1
- package/src/post-navigation-link/index.php +17 -3
- package/src/post-terms/index.php +13 -4
- package/src/pullquote/block.json +4 -0
- package/src/pullquote/style.scss +13 -1
- package/src/query/block.json +1 -2
- package/src/query/edit/inspector-controls/index.js +137 -146
- package/src/query/edit/query-content.js +9 -7
- package/src/query/edit/query-placeholder.js +11 -11
- package/src/query/index.php +33 -71
- package/src/query/variations.js +4 -0
- package/src/query/view.js +24 -19
- package/src/search/block.json +0 -1
- package/src/search/index.php +18 -36
- package/src/table-of-contents/hooks.js +2 -2
- package/src/template-part/edit/advanced-controls.js +2 -3
- package/src/template-part/edit/index.js +77 -50
- package/src/template-part/index.php +2 -2
- package/src/video/edit.native.js +5 -2
- package/src/video/test/edit.native.js +38 -0
- package/src/video/transforms.js +32 -0
- package/tsconfig.json +1 -0
- package/build/block/v1/edit.js +0 -116
- package/build/block/v1/edit.js.map +0 -1
- package/build/block/v1/edit.native.js.map +0 -1
- package/build-module/block/v1/edit.js +0 -108
- package/build-module/block/v1/edit.js.map +0 -1
- package/build-module/block/v1/edit.native.js.map +0 -1
- package/src/block/v1/edit.js +0 -163
package/CHANGELOG.md
CHANGED
package/build/avatar/edit.js
CHANGED
|
@@ -161,7 +161,7 @@ const UserEdit = ({
|
|
|
161
161
|
attributes: attributes,
|
|
162
162
|
avatar: avatar,
|
|
163
163
|
setAttributes: setAttributes
|
|
164
|
-
}),
|
|
164
|
+
}), attributes.isLink ? (0, _react.createElement)("a", {
|
|
165
165
|
href: "#avatar-pseudo-link",
|
|
166
166
|
className: "wp-block-avatar__link",
|
|
167
167
|
onClick: event => event.preventDefault()
|
|
@@ -177,7 +177,7 @@ const UserEdit = ({
|
|
|
177
177
|
blockProps: blockProps,
|
|
178
178
|
isSelected: isSelected,
|
|
179
179
|
setAttributes: setAttributes
|
|
180
|
-
}))
|
|
180
|
+
}));
|
|
181
181
|
};
|
|
182
182
|
function Edit(props) {
|
|
183
183
|
// Don't show the Comment Edit controls if we have a comment ID set, or if we're in the Site Editor (where it is `null`).
|
package/build/avatar/edit.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_classnames","_interopRequireDefault","require","_blockEditor","_components","_i18n","_url","_hooks","_userControl","AvatarInspectorControls","setAttributes","avatar","attributes","selectUser","_react","createElement","InspectorControls","PanelBody","title","__","RangeControl","__nextHasNoMarginBottom","__next40pxDefaultSize","label","onChange","newSize","size","min","minSize","max","maxSize","initialPosition","value","ToggleControl","isLink","checked","linkTarget","default","userId","ResizableAvatar","blockProps","isSelected","borderProps","useBorderProps","doubledSizedSrc","addQueryArgs","removeQueryArgs","src","s","ResizableBox","width","height","showHandle","onResizeStop","event","direction","elt","delta","parseInt","lockAspectRatio","enable","top","right","isRTL","bottom","left","minWidth","maxWidth","alt","className","classnames","style","CommentEdit","context","commentId","useBlockProps","useCommentAvatar","Fragment","href","onClick","preventDefault","UserEdit","postId","postType","useUserAvatar","Edit","props"],"sources":["@wordpress/block-library/src/avatar/edit.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tInspectorControls,\n\tuseBlockProps,\n\t__experimentalUseBorderProps as useBorderProps,\n} from '@wordpress/block-editor';\nimport {\n\tPanelBody,\n\tRangeControl,\n\tResizableBox,\n\tToggleControl,\n} from '@wordpress/components';\nimport { __, isRTL } from '@wordpress/i18n';\nimport { addQueryArgs, removeQueryArgs } from '@wordpress/url';\n\n/**\n * Internal dependencies\n */\nimport { useUserAvatar, useCommentAvatar } from './hooks';\nimport UserControl from './user-control';\n\nconst AvatarInspectorControls = ( {\n\tsetAttributes,\n\tavatar,\n\tattributes,\n\tselectUser,\n} ) => (\n\t<InspectorControls>\n\t\t<PanelBody title={ __( 'Settings' ) }>\n\t\t\t<RangeControl\n\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t__next40pxDefaultSize\n\t\t\t\tlabel={ __( 'Image size' ) }\n\t\t\t\tonChange={ ( newSize ) =>\n\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\tsize: newSize,\n\t\t\t\t\t} )\n\t\t\t\t}\n\t\t\t\tmin={ avatar.minSize }\n\t\t\t\tmax={ avatar.maxSize }\n\t\t\t\tinitialPosition={ attributes?.size }\n\t\t\t\tvalue={ attributes?.size }\n\t\t\t/>\n\t\t\t<ToggleControl\n\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\tlabel={ __( 'Link to user profile' ) }\n\t\t\t\tonChange={ () =>\n\t\t\t\t\tsetAttributes( { isLink: ! attributes.isLink } )\n\t\t\t\t}\n\t\t\t\tchecked={ attributes.isLink }\n\t\t\t/>\n\t\t\t{ attributes.isLink && (\n\t\t\t\t<ToggleControl\n\t\t\t\t\tlabel={ __( 'Open in new tab' ) }\n\t\t\t\t\tonChange={ ( value ) =>\n\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\tlinkTarget: value ? '_blank' : '_self',\n\t\t\t\t\t\t} )\n\t\t\t\t\t}\n\t\t\t\t\tchecked={ attributes.linkTarget === '_blank' }\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t{ selectUser && (\n\t\t\t\t<UserControl\n\t\t\t\t\tvalue={ attributes?.userId }\n\t\t\t\t\tonChange={ ( value ) => {\n\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\tuserId: value,\n\t\t\t\t\t\t} );\n\t\t\t\t\t} }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</PanelBody>\n\t</InspectorControls>\n);\n\nconst ResizableAvatar = ( {\n\tsetAttributes,\n\tattributes,\n\tavatar,\n\tblockProps,\n\tisSelected,\n} ) => {\n\tconst borderProps = useBorderProps( attributes );\n\tconst doubledSizedSrc = addQueryArgs(\n\t\tremoveQueryArgs( avatar?.src, [ 's' ] ),\n\t\t{\n\t\t\ts: attributes?.size * 2,\n\t\t}\n\t);\n\treturn (\n\t\t<div { ...blockProps }>\n\t\t\t<ResizableBox\n\t\t\t\tsize={ {\n\t\t\t\t\twidth: attributes.size,\n\t\t\t\t\theight: attributes.size,\n\t\t\t\t} }\n\t\t\t\tshowHandle={ isSelected }\n\t\t\t\tonResizeStop={ ( event, direction, elt, delta ) => {\n\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\tsize: parseInt(\n\t\t\t\t\t\t\tattributes.size + ( delta.height || delta.width ),\n\t\t\t\t\t\t\t10\n\t\t\t\t\t\t),\n\t\t\t\t\t} );\n\t\t\t\t} }\n\t\t\t\tlockAspectRatio\n\t\t\t\tenable={ {\n\t\t\t\t\ttop: false,\n\t\t\t\t\tright: ! isRTL(),\n\t\t\t\t\tbottom: true,\n\t\t\t\t\tleft: isRTL(),\n\t\t\t\t} }\n\t\t\t\tminWidth={ avatar.minSize }\n\t\t\t\tmaxWidth={ avatar.maxSize }\n\t\t\t>\n\t\t\t\t<img\n\t\t\t\t\tsrc={ doubledSizedSrc }\n\t\t\t\t\talt={ avatar.alt }\n\t\t\t\t\tclassName={ classnames(\n\t\t\t\t\t\t'avatar',\n\t\t\t\t\t\t'avatar-' + attributes.size,\n\t\t\t\t\t\t'photo',\n\t\t\t\t\t\t'wp-block-avatar__image',\n\t\t\t\t\t\tborderProps.className\n\t\t\t\t\t) }\n\t\t\t\t\tstyle={ borderProps.style }\n\t\t\t\t/>\n\t\t\t</ResizableBox>\n\t\t</div>\n\t);\n};\nconst CommentEdit = ( { attributes, context, setAttributes, isSelected } ) => {\n\tconst { commentId } = context;\n\tconst blockProps = useBlockProps();\n\tconst avatar = useCommentAvatar( { commentId } );\n\treturn (\n\t\t<>\n\t\t\t<AvatarInspectorControls\n\t\t\t\tavatar={ avatar }\n\t\t\t\tsetAttributes={ setAttributes }\n\t\t\t\tattributes={ attributes }\n\t\t\t\tselectUser={ false }\n\t\t\t/>\n\t\t\t{ attributes.isLink ? (\n\t\t\t\t<a\n\t\t\t\t\thref=\"#avatar-pseudo-link\"\n\t\t\t\t\tclassName=\"wp-block-avatar__link\"\n\t\t\t\t\tonClick={ ( event ) => event.preventDefault() }\n\t\t\t\t>\n\t\t\t\t\t<ResizableAvatar\n\t\t\t\t\t\tattributes={ attributes }\n\t\t\t\t\t\tavatar={ avatar }\n\t\t\t\t\t\tblockProps={ blockProps }\n\t\t\t\t\t\tisSelected={ isSelected }\n\t\t\t\t\t\tsetAttributes={ setAttributes }\n\t\t\t\t\t/>\n\t\t\t\t</a>\n\t\t\t) : (\n\t\t\t\t<ResizableAvatar\n\t\t\t\t\tattributes={ attributes }\n\t\t\t\t\tavatar={ avatar }\n\t\t\t\t\tblockProps={ blockProps }\n\t\t\t\t\tisSelected={ isSelected }\n\t\t\t\t\tsetAttributes={ setAttributes }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</>\n\t);\n};\n\nconst UserEdit = ( { attributes, context, setAttributes, isSelected } ) => {\n\tconst { postId, postType } = context;\n\tconst avatar = useUserAvatar( {\n\t\tuserId: attributes?.userId,\n\t\tpostId,\n\t\tpostType,\n\t} );\n\tconst blockProps = useBlockProps();\n\treturn (\n\t\t<>\n\t\t\t<AvatarInspectorControls\n\t\t\t\tselectUser={ true }\n\t\t\t\tattributes={ attributes }\n\t\t\t\tavatar={ avatar }\n\t\t\t\tsetAttributes={ setAttributes }\n\t\t\t/>\n\t\t\t<div>\n\t\t\t\t{ attributes.isLink ? (\n\t\t\t\t\t<a\n\t\t\t\t\t\thref=\"#avatar-pseudo-link\"\n\t\t\t\t\t\tclassName=\"wp-block-avatar__link\"\n\t\t\t\t\t\tonClick={ ( event ) => event.preventDefault() }\n\t\t\t\t\t>\n\t\t\t\t\t\t<ResizableAvatar\n\t\t\t\t\t\t\tattributes={ attributes }\n\t\t\t\t\t\t\tavatar={ avatar }\n\t\t\t\t\t\t\tblockProps={ blockProps }\n\t\t\t\t\t\t\tisSelected={ isSelected }\n\t\t\t\t\t\t\tsetAttributes={ setAttributes }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</a>\n\t\t\t\t) : (\n\t\t\t\t\t<ResizableAvatar\n\t\t\t\t\t\tattributes={ attributes }\n\t\t\t\t\t\tavatar={ avatar }\n\t\t\t\t\t\tblockProps={ blockProps }\n\t\t\t\t\t\tisSelected={ isSelected }\n\t\t\t\t\t\tsetAttributes={ setAttributes }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t</div>\n\t\t</>\n\t);\n};\n\nexport default function Edit( props ) {\n\t// Don't show the Comment Edit controls if we have a comment ID set, or if we're in the Site Editor (where it is `null`).\n\tif ( props?.context?.commentId || props?.context?.commentId === null ) {\n\t\treturn <CommentEdit { ...props } />;\n\t}\n\treturn <UserEdit { ...props } />;\n}\n"],"mappings":";;;;;;;;AAGA,IAAAA,WAAA,GAAAC,sBAAA,CAAAC,OAAA;AAKA,IAAAC,YAAA,GAAAD,OAAA;AAKA,IAAAE,WAAA,GAAAF,OAAA;AAMA,IAAAG,KAAA,GAAAH,OAAA;AACA,IAAAI,IAAA,GAAAJ,OAAA;AAKA,IAAAK,MAAA,GAAAL,OAAA;AACA,IAAAM,YAAA,GAAAP,sBAAA,CAAAC,OAAA;AA1BA;AACA;AACA;;AAGA;AACA;AACA;;AAeA;AACA;AACA;;AAIA,MAAMO,uBAAuB,GAAGA,CAAE;EACjCC,aAAa;EACbC,MAAM;EACNC,UAAU;EACVC;AACD,CAAC,KACA,IAAAC,MAAA,CAAAC,aAAA,EAACZ,YAAA,CAAAa,iBAAiB,QACjB,IAAAF,MAAA,CAAAC,aAAA,EAACX,WAAA,CAAAa,SAAS;EAACC,KAAK,EAAG,IAAAC,QAAE,EAAE,UAAW;AAAG,GACpC,IAAAL,MAAA,CAAAC,aAAA,EAACX,WAAA,CAAAgB,YAAY;EACZC,uBAAuB;EACvBC,qBAAqB;EACrBC,KAAK,EAAG,IAAAJ,QAAE,EAAE,YAAa,CAAG;EAC5BK,QAAQ,EAAKC,OAAO,IACnBf,aAAa,CAAE;IACdgB,IAAI,EAAED;EACP,CAAE,CACF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,EAAG;IACtE,OAAO,IAAA5D,MAAA,CAAAC,aAAA,EAACyD,WAAW;MAAA,GAAMc;IAAK,CAAI,CAAC;EACpC;EACA,OAAO,IAAAxE,MAAA,CAAAC,aAAA,EAACkE,QAAQ;IAAA,GAAMK;EAAK,CAAI,CAAC;AACjC"}
|
|
1
|
+
{"version":3,"names":["_classnames","_interopRequireDefault","require","_blockEditor","_components","_i18n","_url","_hooks","_userControl","AvatarInspectorControls","setAttributes","avatar","attributes","selectUser","_react","createElement","InspectorControls","PanelBody","title","__","RangeControl","__nextHasNoMarginBottom","__next40pxDefaultSize","label","onChange","newSize","size","min","minSize","max","maxSize","initialPosition","value","ToggleControl","isLink","checked","linkTarget","default","userId","ResizableAvatar","blockProps","isSelected","borderProps","useBorderProps","doubledSizedSrc","addQueryArgs","removeQueryArgs","src","s","ResizableBox","width","height","showHandle","onResizeStop","event","direction","elt","delta","parseInt","lockAspectRatio","enable","top","right","isRTL","bottom","left","minWidth","maxWidth","alt","className","classnames","style","CommentEdit","context","commentId","useBlockProps","useCommentAvatar","Fragment","href","onClick","preventDefault","UserEdit","postId","postType","useUserAvatar","Edit","props"],"sources":["@wordpress/block-library/src/avatar/edit.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tInspectorControls,\n\tuseBlockProps,\n\t__experimentalUseBorderProps as useBorderProps,\n} from '@wordpress/block-editor';\nimport {\n\tPanelBody,\n\tRangeControl,\n\tResizableBox,\n\tToggleControl,\n} from '@wordpress/components';\nimport { __, isRTL } from '@wordpress/i18n';\nimport { addQueryArgs, removeQueryArgs } from '@wordpress/url';\n\n/**\n * Internal dependencies\n */\nimport { useUserAvatar, useCommentAvatar } from './hooks';\nimport UserControl from './user-control';\n\nconst AvatarInspectorControls = ( {\n\tsetAttributes,\n\tavatar,\n\tattributes,\n\tselectUser,\n} ) => (\n\t<InspectorControls>\n\t\t<PanelBody title={ __( 'Settings' ) }>\n\t\t\t<RangeControl\n\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t__next40pxDefaultSize\n\t\t\t\tlabel={ __( 'Image size' ) }\n\t\t\t\tonChange={ ( newSize ) =>\n\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\tsize: newSize,\n\t\t\t\t\t} )\n\t\t\t\t}\n\t\t\t\tmin={ avatar.minSize }\n\t\t\t\tmax={ avatar.maxSize }\n\t\t\t\tinitialPosition={ attributes?.size }\n\t\t\t\tvalue={ attributes?.size }\n\t\t\t/>\n\t\t\t<ToggleControl\n\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\tlabel={ __( 'Link to user profile' ) }\n\t\t\t\tonChange={ () =>\n\t\t\t\t\tsetAttributes( { isLink: ! attributes.isLink } )\n\t\t\t\t}\n\t\t\t\tchecked={ attributes.isLink }\n\t\t\t/>\n\t\t\t{ attributes.isLink && (\n\t\t\t\t<ToggleControl\n\t\t\t\t\tlabel={ __( 'Open in new tab' ) }\n\t\t\t\t\tonChange={ ( value ) =>\n\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\tlinkTarget: value ? '_blank' : '_self',\n\t\t\t\t\t\t} )\n\t\t\t\t\t}\n\t\t\t\t\tchecked={ attributes.linkTarget === '_blank' }\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t{ selectUser && (\n\t\t\t\t<UserControl\n\t\t\t\t\tvalue={ attributes?.userId }\n\t\t\t\t\tonChange={ ( value ) => {\n\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\tuserId: value,\n\t\t\t\t\t\t} );\n\t\t\t\t\t} }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</PanelBody>\n\t</InspectorControls>\n);\n\nconst ResizableAvatar = ( {\n\tsetAttributes,\n\tattributes,\n\tavatar,\n\tblockProps,\n\tisSelected,\n} ) => {\n\tconst borderProps = useBorderProps( attributes );\n\tconst doubledSizedSrc = addQueryArgs(\n\t\tremoveQueryArgs( avatar?.src, [ 's' ] ),\n\t\t{\n\t\t\ts: attributes?.size * 2,\n\t\t}\n\t);\n\treturn (\n\t\t<div { ...blockProps }>\n\t\t\t<ResizableBox\n\t\t\t\tsize={ {\n\t\t\t\t\twidth: attributes.size,\n\t\t\t\t\theight: attributes.size,\n\t\t\t\t} }\n\t\t\t\tshowHandle={ isSelected }\n\t\t\t\tonResizeStop={ ( event, direction, elt, delta ) => {\n\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\tsize: parseInt(\n\t\t\t\t\t\t\tattributes.size + ( delta.height || delta.width ),\n\t\t\t\t\t\t\t10\n\t\t\t\t\t\t),\n\t\t\t\t\t} );\n\t\t\t\t} }\n\t\t\t\tlockAspectRatio\n\t\t\t\tenable={ {\n\t\t\t\t\ttop: false,\n\t\t\t\t\tright: ! isRTL(),\n\t\t\t\t\tbottom: true,\n\t\t\t\t\tleft: isRTL(),\n\t\t\t\t} }\n\t\t\t\tminWidth={ avatar.minSize }\n\t\t\t\tmaxWidth={ avatar.maxSize }\n\t\t\t>\n\t\t\t\t<img\n\t\t\t\t\tsrc={ doubledSizedSrc }\n\t\t\t\t\talt={ avatar.alt }\n\t\t\t\t\tclassName={ classnames(\n\t\t\t\t\t\t'avatar',\n\t\t\t\t\t\t'avatar-' + attributes.size,\n\t\t\t\t\t\t'photo',\n\t\t\t\t\t\t'wp-block-avatar__image',\n\t\t\t\t\t\tborderProps.className\n\t\t\t\t\t) }\n\t\t\t\t\tstyle={ borderProps.style }\n\t\t\t\t/>\n\t\t\t</ResizableBox>\n\t\t</div>\n\t);\n};\nconst CommentEdit = ( { attributes, context, setAttributes, isSelected } ) => {\n\tconst { commentId } = context;\n\tconst blockProps = useBlockProps();\n\tconst avatar = useCommentAvatar( { commentId } );\n\treturn (\n\t\t<>\n\t\t\t<AvatarInspectorControls\n\t\t\t\tavatar={ avatar }\n\t\t\t\tsetAttributes={ setAttributes }\n\t\t\t\tattributes={ attributes }\n\t\t\t\tselectUser={ false }\n\t\t\t/>\n\t\t\t{ attributes.isLink ? (\n\t\t\t\t<a\n\t\t\t\t\thref=\"#avatar-pseudo-link\"\n\t\t\t\t\tclassName=\"wp-block-avatar__link\"\n\t\t\t\t\tonClick={ ( event ) => event.preventDefault() }\n\t\t\t\t>\n\t\t\t\t\t<ResizableAvatar\n\t\t\t\t\t\tattributes={ attributes }\n\t\t\t\t\t\tavatar={ avatar }\n\t\t\t\t\t\tblockProps={ blockProps }\n\t\t\t\t\t\tisSelected={ isSelected }\n\t\t\t\t\t\tsetAttributes={ setAttributes }\n\t\t\t\t\t/>\n\t\t\t\t</a>\n\t\t\t) : (\n\t\t\t\t<ResizableAvatar\n\t\t\t\t\tattributes={ attributes }\n\t\t\t\t\tavatar={ avatar }\n\t\t\t\t\tblockProps={ blockProps }\n\t\t\t\t\tisSelected={ isSelected }\n\t\t\t\t\tsetAttributes={ setAttributes }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</>\n\t);\n};\n\nconst UserEdit = ( { attributes, context, setAttributes, isSelected } ) => {\n\tconst { postId, postType } = context;\n\tconst avatar = useUserAvatar( {\n\t\tuserId: attributes?.userId,\n\t\tpostId,\n\t\tpostType,\n\t} );\n\tconst blockProps = useBlockProps();\n\treturn (\n\t\t<>\n\t\t\t<AvatarInspectorControls\n\t\t\t\tselectUser={ true }\n\t\t\t\tattributes={ attributes }\n\t\t\t\tavatar={ avatar }\n\t\t\t\tsetAttributes={ setAttributes }\n\t\t\t/>\n\t\t\t{ attributes.isLink ? (\n\t\t\t\t<a\n\t\t\t\t\thref=\"#avatar-pseudo-link\"\n\t\t\t\t\tclassName=\"wp-block-avatar__link\"\n\t\t\t\t\tonClick={ ( event ) => event.preventDefault() }\n\t\t\t\t>\n\t\t\t\t\t<ResizableAvatar\n\t\t\t\t\t\tattributes={ attributes }\n\t\t\t\t\t\tavatar={ avatar }\n\t\t\t\t\t\tblockProps={ blockProps }\n\t\t\t\t\t\tisSelected={ isSelected }\n\t\t\t\t\t\tsetAttributes={ setAttributes }\n\t\t\t\t\t/>\n\t\t\t\t</a>\n\t\t\t) : (\n\t\t\t\t<ResizableAvatar\n\t\t\t\t\tattributes={ attributes }\n\t\t\t\t\tavatar={ avatar }\n\t\t\t\t\tblockProps={ blockProps }\n\t\t\t\t\tisSelected={ isSelected }\n\t\t\t\t\tsetAttributes={ setAttributes }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</>\n\t);\n};\n\nexport default function Edit( props ) {\n\t// Don't show the Comment Edit controls if we have a comment ID set, or if we're in the Site Editor (where it is `null`).\n\tif ( props?.context?.commentId || props?.context?.commentId === null ) {\n\t\treturn <CommentEdit { ...props } />;\n\t}\n\treturn <UserEdit { ...props } />;\n}\n"],"mappings":";;;;;;;;AAGA,IAAAA,WAAA,GAAAC,sBAAA,CAAAC,OAAA;AAKA,IAAAC,YAAA,GAAAD,OAAA;AAKA,IAAAE,WAAA,GAAAF,OAAA;AAMA,IAAAG,KAAA,GAAAH,OAAA;AACA,IAAAI,IAAA,GAAAJ,OAAA;AAKA,IAAAK,MAAA,GAAAL,OAAA;AACA,IAAAM,YAAA,GAAAP,sBAAA,CAAAC,OAAA;AA1BA;AACA;AACA;;AAGA;AACA;AACA;;AAeA;AACA;AACA;;AAIA,MAAMO,uBAAuB,GAAGA,CAAE;EACjCC,aAAa;EACbC,MAAM;EACNC,UAAU;EACVC;AACD,CAAC,KACA,IAAAC,MAAA,CAAAC,aAAA,EAACZ,YAAA,CAAAa,iBAAiB,QACjB,IAAAF,MAAA,CAAAC,aAAA,EAACX,WAAA,CAAAa,SAAS;EAACC,KAAK,EAAG,IAAAC,QAAE,EAAE,UAAW;AAAG,GACpC,IAAAL,MAAA,CAAAC,aAAA,EAACX,WAAA,CAAAgB,YAAY;EACZC,uBAAuB;EACvBC,qBAAqB;EACrBC,KAAK,EAAG,IAAAJ,QAAE,EAAE,YAAa,CAAG;EAC5BK,QAAQ,EAAKC,OAAO,IACnBf,aAAa,CAAE;IACdgB,IAAI,EAAED;EACP,CAAE,CACF;EACDE,GAAG,EAAGhB,MA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AA,GAAMc;IAAK,CAAI,CAAC;EACpC;EACA,OAAO,IAAAxE,MAAA,CAAAC,aAAA,EAACkE,QAAQ;IAAA,GAAMK;EAAK,CAAI,CAAC;AACjC"}
|
package/build/block/edit.js
CHANGED
|
@@ -13,6 +13,7 @@ var _coreData = require("@wordpress/core-data");
|
|
|
13
13
|
var _components = require("@wordpress/components");
|
|
14
14
|
var _i18n = require("@wordpress/i18n");
|
|
15
15
|
var _blockEditor = require("@wordpress/block-editor");
|
|
16
|
+
var _patterns = require("@wordpress/patterns");
|
|
16
17
|
var _blocks = require("@wordpress/blocks");
|
|
17
18
|
var _lockUnlock = require("../lock-unlock");
|
|
18
19
|
/**
|
|
@@ -30,11 +31,14 @@ var _lockUnlock = require("../lock-unlock");
|
|
|
30
31
|
const {
|
|
31
32
|
useLayoutClasses
|
|
32
33
|
} = (0, _lockUnlock.unlock)(_blockEditor.privateApis);
|
|
34
|
+
const {
|
|
35
|
+
PARTIAL_SYNCING_SUPPORTED_BLOCKS
|
|
36
|
+
} = (0, _lockUnlock.unlock)(_patterns.privateApis);
|
|
33
37
|
function isPartiallySynced(block) {
|
|
34
|
-
return
|
|
38
|
+
return Object.keys(PARTIAL_SYNCING_SUPPORTED_BLOCKS).includes(block.name) && !!block.attributes.metadata?.bindings && Object.values(block.attributes.metadata.bindings).some(binding => binding.source.name === 'pattern_attributes');
|
|
35
39
|
}
|
|
36
40
|
function getPartiallySyncedAttributes(block) {
|
|
37
|
-
return Object.entries(block.attributes.
|
|
41
|
+
return Object.entries(block.attributes.metadata.bindings).filter(([, binding]) => binding.source.name === 'pattern_attributes').map(([attributeKey]) => attributeKey);
|
|
38
42
|
}
|
|
39
43
|
const fullAlignments = ['full', 'wide', 'left', 'right'];
|
|
40
44
|
const useInferredLayout = (blocks, parentLayout) => {
|
|
@@ -61,6 +65,27 @@ const useInferredLayout = (blocks, parentLayout) => {
|
|
|
61
65
|
};
|
|
62
66
|
}, [blocks, parentLayout]);
|
|
63
67
|
};
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Enum for patch operations.
|
|
71
|
+
* We use integers here to minimize the size of the serialized data.
|
|
72
|
+
* This has to be deserialized accordingly on the server side.
|
|
73
|
+
* See block-bindings/sources/pattern.php
|
|
74
|
+
*/
|
|
75
|
+
const PATCH_OPERATIONS = {
|
|
76
|
+
/** @type {0} */
|
|
77
|
+
Remove: 0,
|
|
78
|
+
/** @type {1} */
|
|
79
|
+
Replace: 1
|
|
80
|
+
// Other operations are reserved for future use. (e.g. Add)
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* @typedef {[typeof PATCH_OPERATIONS.Remove]} RemovePatch
|
|
85
|
+
* @typedef {[typeof PATCH_OPERATIONS.Replace, unknown]} ReplacePatch
|
|
86
|
+
* @typedef {RemovePatch | ReplacePatch} OverridePatch
|
|
87
|
+
*/
|
|
88
|
+
|
|
64
89
|
function applyInitialOverrides(blocks, overrides = {}, defaultValues) {
|
|
65
90
|
return blocks.map(block => {
|
|
66
91
|
const innerBlocks = applyInitialOverrides(block.innerBlocks, overrides, defaultValues);
|
|
@@ -77,8 +102,15 @@ function applyInitialOverrides(blocks, overrides = {}, defaultValues) {
|
|
|
77
102
|
var _defaultValues$blockI;
|
|
78
103
|
(_defaultValues$blockI = defaultValues[blockId]) !== null && _defaultValues$blockI !== void 0 ? _defaultValues$blockI : defaultValues[blockId] = {};
|
|
79
104
|
defaultValues[blockId][attributeKey] = block.attributes[attributeKey];
|
|
80
|
-
|
|
81
|
-
|
|
105
|
+
/** @type {OverridePatch} */
|
|
106
|
+
const overrideAttribute = overrides[blockId]?.[attributeKey];
|
|
107
|
+
if (!overrideAttribute) {
|
|
108
|
+
continue;
|
|
109
|
+
}
|
|
110
|
+
if (overrideAttribute[0] === PATCH_OPERATIONS.Remove) {
|
|
111
|
+
delete newAttributes[attributeKey];
|
|
112
|
+
} else if (overrideAttribute[0] === PATCH_OPERATIONS.Replace) {
|
|
113
|
+
newAttributes[attributeKey] = overrideAttribute[1];
|
|
82
114
|
}
|
|
83
115
|
}
|
|
84
116
|
return {
|
|
@@ -89,10 +121,11 @@ function applyInitialOverrides(blocks, overrides = {}, defaultValues) {
|
|
|
89
121
|
});
|
|
90
122
|
}
|
|
91
123
|
function getOverridesFromBlocks(blocks, defaultValues) {
|
|
92
|
-
/** @type {Record<string, Record<string,
|
|
124
|
+
/** @type {Record<string, Record<string, OverridePatch>>} */
|
|
93
125
|
const overrides = {};
|
|
94
126
|
for (const block of blocks) {
|
|
95
127
|
Object.assign(overrides, getOverridesFromBlocks(block.innerBlocks, defaultValues));
|
|
128
|
+
/** @type {string} */
|
|
96
129
|
const blockId = block.attributes.metadata?.id;
|
|
97
130
|
if (!isPartiallySynced(block) || !blockId) continue;
|
|
98
131
|
const attributes = getPartiallySyncedAttributes(block);
|
|
@@ -100,7 +133,18 @@ function getOverridesFromBlocks(blocks, defaultValues) {
|
|
|
100
133
|
if (block.attributes[attributeKey] !== defaultValues[blockId][attributeKey]) {
|
|
101
134
|
var _overrides$blockId;
|
|
102
135
|
(_overrides$blockId = overrides[blockId]) !== null && _overrides$blockId !== void 0 ? _overrides$blockId : overrides[blockId] = {};
|
|
103
|
-
|
|
136
|
+
/**
|
|
137
|
+
* Create a patch operation for the binding attribute.
|
|
138
|
+
* We use a tuple here to minimize the size of the serialized data.
|
|
139
|
+
* The first item is the operation type, the second item is the value if any.
|
|
140
|
+
*/
|
|
141
|
+
if (block.attributes[attributeKey] === undefined) {
|
|
142
|
+
/** @type {RemovePatch} */
|
|
143
|
+
overrides[blockId][attributeKey] = [PATCH_OPERATIONS.Remove];
|
|
144
|
+
} else {
|
|
145
|
+
/** @type {ReplacePatch} */
|
|
146
|
+
overrides[blockId][attributeKey] = [PATCH_OPERATIONS.Replace, block.attributes[attributeKey]];
|
|
147
|
+
}
|
|
104
148
|
}
|
|
105
149
|
}
|
|
106
150
|
}
|
|
@@ -113,6 +157,12 @@ function setBlockEditMode(setEditMode, blocks, mode) {
|
|
|
113
157
|
setBlockEditMode(setEditMode, block.innerBlocks, mode);
|
|
114
158
|
});
|
|
115
159
|
}
|
|
160
|
+
function getHasOverridableBlocks(blocks) {
|
|
161
|
+
return blocks.some(block => {
|
|
162
|
+
if (isPartiallySynced(block)) return true;
|
|
163
|
+
return getHasOverridableBlocks(block.innerBlocks);
|
|
164
|
+
});
|
|
165
|
+
}
|
|
116
166
|
function ReusableBlockEdit({
|
|
117
167
|
name,
|
|
118
168
|
attributes: {
|
|
@@ -124,7 +174,7 @@ function ReusableBlockEdit({
|
|
|
124
174
|
setAttributes
|
|
125
175
|
}) {
|
|
126
176
|
const registry = (0, _data.useRegistry)();
|
|
127
|
-
const hasAlreadyRendered = (0, _blockEditor.
|
|
177
|
+
const hasAlreadyRendered = (0, _blockEditor.useHasRecursion)(ref);
|
|
128
178
|
const {
|
|
129
179
|
record,
|
|
130
180
|
editedRecord,
|
|
@@ -172,12 +222,16 @@ function ReusableBlockEdit({
|
|
|
172
222
|
canvas: 'edit'
|
|
173
223
|
}) : {};
|
|
174
224
|
(0, _element.useEffect)(() => setBlockEditMode(setBlockEditingMode, innerBlocks), [innerBlocks, setBlockEditingMode]);
|
|
225
|
+
const hasOverridableBlocks = (0, _element.useMemo)(() => getHasOverridableBlocks(innerBlocks), [innerBlocks]);
|
|
226
|
+
const initialBlocks = (0, _element.useMemo)(() => {
|
|
227
|
+
var _editedRecord$blocks$;
|
|
228
|
+
return (// Clone the blocks to generate new client IDs.
|
|
229
|
+
(_editedRecord$blocks$ = editedRecord.blocks?.map(block => (0, _blocks.cloneBlock)(block))) !== null && _editedRecord$blocks$ !== void 0 ? _editedRecord$blocks$ : editedRecord.content && typeof editedRecord.content !== 'function' ? (0, _blocks.parse)(editedRecord.content) : []
|
|
230
|
+
);
|
|
231
|
+
}, [editedRecord.blocks, editedRecord.content]);
|
|
175
232
|
|
|
176
233
|
// Apply the initial overrides from the pattern block to the inner blocks.
|
|
177
234
|
(0, _element.useEffect)(() => {
|
|
178
|
-
var _editedRecord$blocks$;
|
|
179
|
-
const initialBlocks = // Clone the blocks to generate new client IDs.
|
|
180
|
-
(_editedRecord$blocks$ = editedRecord.blocks?.map(block => (0, _blocks.cloneBlock)(block))) !== null && _editedRecord$blocks$ !== void 0 ? _editedRecord$blocks$ : editedRecord.content && typeof editedRecord.content !== 'function' ? (0, _blocks.parse)(editedRecord.content) : [];
|
|
181
235
|
defaultValuesRef.current = {};
|
|
182
236
|
const editingMode = getBlockEditingMode(patternClientId);
|
|
183
237
|
// Replace the contents of the blocks with the overrides.
|
|
@@ -188,7 +242,7 @@ function ReusableBlockEdit({
|
|
|
188
242
|
});
|
|
189
243
|
setBlockEditingMode(patternClientId, editingMode);
|
|
190
244
|
});
|
|
191
|
-
}, [__unstableMarkNextChangeAsNotPersistent, patternClientId,
|
|
245
|
+
}, [__unstableMarkNextChangeAsNotPersistent, patternClientId, initialBlocks, replaceInnerBlocks, registry, getBlockEditingMode, setBlockEditingMode, syncDerivedUpdates]);
|
|
192
246
|
const {
|
|
193
247
|
alignment,
|
|
194
248
|
layout
|
|
@@ -230,6 +284,11 @@ function ReusableBlockEdit({
|
|
|
230
284
|
setBlockEditMode(setBlockEditingMode, innerBlocks, 'default');
|
|
231
285
|
editOriginalProps.onClick(event);
|
|
232
286
|
};
|
|
287
|
+
const resetOverrides = () => {
|
|
288
|
+
if (overrides) {
|
|
289
|
+
replaceInnerBlocks(patternClientId, initialBlocks);
|
|
290
|
+
}
|
|
291
|
+
};
|
|
233
292
|
let children = null;
|
|
234
293
|
if (hasAlreadyRendered) {
|
|
235
294
|
children = (0, _react.createElement)(_blockEditor.Warning, null, (0, _i18n.__)('Block cannot be rendered inside itself.'));
|
|
@@ -240,12 +299,16 @@ function ReusableBlockEdit({
|
|
|
240
299
|
if (!hasResolved) {
|
|
241
300
|
children = (0, _react.createElement)(_components.Placeholder, null, (0, _react.createElement)(_components.Spinner, null));
|
|
242
301
|
}
|
|
243
|
-
return (0, _react.createElement)(_blockEditor.
|
|
302
|
+
return (0, _react.createElement)(_blockEditor.RecursionProvider, {
|
|
244
303
|
uniqueId: ref
|
|
245
304
|
}, userCanEdit && editOriginalProps && (0, _react.createElement)(_blockEditor.BlockControls, null, (0, _react.createElement)(_components.ToolbarGroup, null, (0, _react.createElement)(_components.ToolbarButton, {
|
|
246
305
|
href: editOriginalProps.href,
|
|
247
306
|
onClick: handleEditOriginal
|
|
248
|
-
}, (0, _i18n.__)('Edit original')))),
|
|
307
|
+
}, (0, _i18n.__)('Edit original')))), hasOverridableBlocks && (0, _react.createElement)(_blockEditor.BlockControls, null, (0, _react.createElement)(_components.ToolbarGroup, null, (0, _react.createElement)(_components.ToolbarButton, {
|
|
308
|
+
onClick: resetOverrides,
|
|
309
|
+
disabled: !overrides,
|
|
310
|
+
__experimentalIsFocusable: true
|
|
311
|
+
}, (0, _i18n.__)('Reset to original')))), children === null ? (0, _react.createElement)("div", {
|
|
249
312
|
...innerBlocksProps
|
|
250
313
|
}) : (0, _react.createElement)("div", {
|
|
251
314
|
...blockProps
|
package/build/block/edit.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_classnames","_interopRequireDefault","require","_data","_element","_coreData","_components","_i18n","_blockEditor","_blocks","_lockUnlock","useLayoutClasses","unlock","blockEditorPrivateApis","isPartiallySynced","block","getBlockSupport","name","attributes","connections","Object","values","some","connection","source","getPartiallySyncedAttributes","entries","filter","map","attributeKey","fullAlignments","useInferredLayout","blocks","parentLayout","initialInferredAlignmentRef","useRef","useMemo","length","alignment","current","undefined","isConstrained","type","hasFullAlignment","includes","align","layout","applyInitialOverrides","overrides","defaultValues","innerBlocks","blockId","metadata","id","newAttributes","_defaultValues$blockI","getOverridesFromBlocks","assign","_overrides$blockId","keys","setBlockEditMode","setEditMode","mode","forEach","editMode","clientId","ReusableBlockEdit","ref","__unstableParentLayout","patternClientId","setAttributes","registry","useRegistry","hasAlreadyRendered","useHasRecursion","record","editedRecord","hasResolved","useEntityRecord","isMissing","initialOverrides","defaultValuesRef","replaceInnerBlocks","__unstableMarkNextChangeAsNotPersistent","setBlockEditingMode","useDispatch","blockEditorStore","syncDerivedUpdates","userCanEdit","getBlockEditingMode","getPostLinkProps","useSelect","select","canUser","coreStore","getBlocks","editingMode","getSettings","canEdit","editOriginalProps","postId","postType","canvas","useEffect","_editedRecord$blocks$","initialBlocks","cloneBlock","content","parse","batch","layoutClasses","blockProps","useBlockProps","className","classnames","innerBlocksProps","useInnerBlocksProps","templateLock","renderAppender","InnerBlocks","ButtonBlockAppender","prevBlocks","subscribe","handleEditOriginal","event","onClick","children","_react","createElement","Warning","__","Placeholder","Spinner","__experimentalRecursionProvider","uniqueId","BlockControls","ToolbarGroup","ToolbarButton","href"],"sources":["@wordpress/block-library/src/block/edit.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { useRegistry, useSelect, useDispatch } from '@wordpress/data';\nimport { useRef, useMemo, useEffect } from '@wordpress/element';\nimport { useEntityRecord, store as coreStore } from '@wordpress/core-data';\nimport {\n\tPlaceholder,\n\tSpinner,\n\tToolbarButton,\n\tToolbarGroup,\n} from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport {\n\tuseInnerBlocksProps,\n\t__experimentalRecursionProvider as RecursionProvider,\n\t__experimentalUseHasRecursion as useHasRecursion,\n\tInnerBlocks,\n\tuseBlockProps,\n\tWarning,\n\tprivateApis as blockEditorPrivateApis,\n\tstore as blockEditorStore,\n\tBlockControls,\n} from '@wordpress/block-editor';\nimport { getBlockSupport, parse, cloneBlock } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../lock-unlock';\n\nconst { useLayoutClasses } = unlock( blockEditorPrivateApis );\n\nfunction isPartiallySynced( block ) {\n\treturn (\n\t\t!! getBlockSupport( block.name, '__experimentalConnections', false ) &&\n\t\t!! block.attributes.connections?.attributes &&\n\t\tObject.values( block.attributes.connections.attributes ).some(\n\t\t\t( connection ) => connection.source === 'pattern_attributes'\n\t\t)\n\t);\n}\nfunction getPartiallySyncedAttributes( block ) {\n\treturn Object.entries( block.attributes.connections.attributes )\n\t\t.filter(\n\t\t\t( [ , connection ] ) => connection.source === 'pattern_attributes'\n\t\t)\n\t\t.map( ( [ attributeKey ] ) => attributeKey );\n}\n\nconst fullAlignments = [ 'full', 'wide', 'left', 'right' ];\n\nconst useInferredLayout = ( blocks, parentLayout ) => {\n\tconst initialInferredAlignmentRef = useRef();\n\n\treturn useMemo( () => {\n\t\t// Exit early if the pattern's blocks haven't loaded yet.\n\t\tif ( ! blocks?.length ) {\n\t\t\treturn {};\n\t\t}\n\n\t\tlet alignment = initialInferredAlignmentRef.current;\n\n\t\t// Only track the initial alignment so that temporarily removed\n\t\t// alignments can be reapplied.\n\t\tif ( alignment === undefined ) {\n\t\t\tconst isConstrained = parentLayout?.type === 'constrained';\n\t\t\tconst hasFullAlignment = blocks.some( ( block ) =>\n\t\t\t\tfullAlignments.includes( block.attributes.align )\n\t\t\t);\n\n\t\t\talignment = isConstrained && hasFullAlignment ? 'full' : null;\n\t\t\tinitialInferredAlignmentRef.current = alignment;\n\t\t}\n\n\t\tconst layout = alignment ? parentLayout : undefined;\n\n\t\treturn { alignment, layout };\n\t}, [ blocks, parentLayout ] );\n};\n\nfunction applyInitialOverrides( blocks, overrides = {}, defaultValues ) {\n\treturn blocks.map( ( block ) => {\n\t\tconst innerBlocks = applyInitialOverrides(\n\t\t\tblock.innerBlocks,\n\t\t\toverrides,\n\t\t\tdefaultValues\n\t\t);\n\t\tconst blockId = block.attributes.metadata?.id;\n\t\tif ( ! isPartiallySynced( block ) || ! blockId )\n\t\t\treturn { ...block, innerBlocks };\n\t\tconst attributes = getPartiallySyncedAttributes( block );\n\t\tconst newAttributes = { ...block.attributes };\n\t\tfor ( const attributeKey of attributes ) {\n\t\t\tdefaultValues[ blockId ] ??= {};\n\t\t\tdefaultValues[ blockId ][ attributeKey ] =\n\t\t\t\tblock.attributes[ attributeKey ];\n\t\t\tif ( overrides[ blockId ] ) {\n\t\t\t\tnewAttributes[ attributeKey ] =\n\t\t\t\t\toverrides[ blockId ][ attributeKey ];\n\t\t\t}\n\t\t}\n\t\treturn {\n\t\t\t...block,\n\t\t\tattributes: newAttributes,\n\t\t\tinnerBlocks,\n\t\t};\n\t} );\n}\n\nfunction getOverridesFromBlocks( blocks, defaultValues ) {\n\t/** @type {Record<string, Record<string, unknown>>} */\n\tconst overrides = {};\n\tfor ( const block of blocks ) {\n\t\tObject.assign(\n\t\t\toverrides,\n\t\t\tgetOverridesFromBlocks( block.innerBlocks, defaultValues )\n\t\t);\n\t\tconst blockId = block.attributes.metadata?.id;\n\t\tif ( ! isPartiallySynced( block ) || ! blockId ) continue;\n\t\tconst attributes = getPartiallySyncedAttributes( block );\n\t\tfor ( const attributeKey of attributes ) {\n\t\t\tif (\n\t\t\t\tblock.attributes[ attributeKey ] !==\n\t\t\t\tdefaultValues[ blockId ][ attributeKey ]\n\t\t\t) {\n\t\t\t\toverrides[ blockId ] ??= {};\n\t\t\t\toverrides[ blockId ][ attributeKey ] =\n\t\t\t\t\tblock.attributes[ attributeKey ];\n\t\t\t}\n\t\t}\n\t}\n\treturn Object.keys( overrides ).length > 0 ? overrides : undefined;\n}\n\nfunction setBlockEditMode( setEditMode, blocks, mode ) {\n\tblocks.forEach( ( block ) => {\n\t\tconst editMode =\n\t\t\tmode || ( isPartiallySynced( block ) ? 'contentOnly' : 'disabled' );\n\t\tsetEditMode( block.clientId, editMode );\n\t\tsetBlockEditMode( setEditMode, block.innerBlocks, mode );\n\t} );\n}\n\nexport default function ReusableBlockEdit( {\n\tname,\n\tattributes: { ref, overrides },\n\t__unstableParentLayout: parentLayout,\n\tclientId: patternClientId,\n\tsetAttributes,\n} ) {\n\tconst registry = useRegistry();\n\tconst hasAlreadyRendered = useHasRecursion( ref );\n\tconst { record, editedRecord, hasResolved } = useEntityRecord(\n\t\t'postType',\n\t\t'wp_block',\n\t\tref\n\t);\n\tconst isMissing = hasResolved && ! record;\n\tconst initialOverrides = useRef( overrides );\n\tconst defaultValuesRef = useRef( {} );\n\n\tconst {\n\t\treplaceInnerBlocks,\n\t\t__unstableMarkNextChangeAsNotPersistent,\n\t\tsetBlockEditingMode,\n\t} = useDispatch( blockEditorStore );\n\tconst { syncDerivedUpdates } = unlock( useDispatch( blockEditorStore ) );\n\n\tconst { innerBlocks, userCanEdit, getBlockEditingMode, getPostLinkProps } =\n\t\tuseSelect(\n\t\t\t( select ) => {\n\t\t\t\tconst { canUser } = select( coreStore );\n\t\t\t\tconst {\n\t\t\t\t\tgetBlocks,\n\t\t\t\t\tgetBlockEditingMode: editingMode,\n\t\t\t\t\tgetSettings,\n\t\t\t\t} = select( blockEditorStore );\n\t\t\t\tconst blocks = getBlocks( patternClientId );\n\t\t\t\tconst canEdit = canUser( 'update', 'blocks', ref );\n\n\t\t\t\t// For editing link to the site editor if the theme and user permissions support it.\n\t\t\t\treturn {\n\t\t\t\t\tinnerBlocks: blocks,\n\t\t\t\t\tuserCanEdit: canEdit,\n\t\t\t\t\tgetBlockEditingMode: editingMode,\n\t\t\t\t\tgetPostLinkProps: getSettings().getPostLinkProps,\n\t\t\t\t};\n\t\t\t},\n\t\t\t[ patternClientId, ref ]\n\t\t);\n\n\tconst editOriginalProps = getPostLinkProps\n\t\t? getPostLinkProps( {\n\t\t\t\tpostId: ref,\n\t\t\t\tpostType: 'wp_block',\n\t\t\t\tcanvas: 'edit',\n\t\t } )\n\t\t: {};\n\n\tuseEffect(\n\t\t() => setBlockEditMode( setBlockEditingMode, innerBlocks ),\n\t\t[ innerBlocks, setBlockEditingMode ]\n\t);\n\n\t// Apply the initial overrides from the pattern block to the inner blocks.\n\tuseEffect( () => {\n\t\tconst initialBlocks =\n\t\t\t// Clone the blocks to generate new client IDs.\n\t\t\teditedRecord.blocks?.map( ( block ) => cloneBlock( block ) ) ??\n\t\t\t( editedRecord.content && typeof editedRecord.content !== 'function'\n\t\t\t\t? parse( editedRecord.content )\n\t\t\t\t: [] );\n\n\t\tdefaultValuesRef.current = {};\n\t\tconst editingMode = getBlockEditingMode( patternClientId );\n\t\t// Replace the contents of the blocks with the overrides.\n\t\tregistry.batch( () => {\n\t\t\tsetBlockEditingMode( patternClientId, 'default' );\n\t\t\tsyncDerivedUpdates( () => {\n\t\t\t\treplaceInnerBlocks(\n\t\t\t\t\tpatternClientId,\n\t\t\t\t\tapplyInitialOverrides(\n\t\t\t\t\t\tinitialBlocks,\n\t\t\t\t\t\tinitialOverrides.current,\n\t\t\t\t\t\tdefaultValuesRef.current\n\t\t\t\t\t)\n\t\t\t\t);\n\t\t\t} );\n\t\t\tsetBlockEditingMode( patternClientId, editingMode );\n\t\t} );\n\t}, [\n\t\t__unstableMarkNextChangeAsNotPersistent,\n\t\tpatternClientId,\n\t\teditedRecord,\n\t\treplaceInnerBlocks,\n\t\tregistry,\n\t\tgetBlockEditingMode,\n\t\tsetBlockEditingMode,\n\t\tsyncDerivedUpdates,\n\t] );\n\n\tconst { alignment, layout } = useInferredLayout(\n\t\tinnerBlocks,\n\t\tparentLayout\n\t);\n\tconst layoutClasses = useLayoutClasses( { layout }, name );\n\n\tconst blockProps = useBlockProps( {\n\t\tclassName: classnames(\n\t\t\t'block-library-block__reusable-block-container',\n\t\t\tlayout && layoutClasses,\n\t\t\t{ [ `align${ alignment }` ]: alignment }\n\t\t),\n\t} );\n\n\tconst innerBlocksProps = useInnerBlocksProps( blockProps, {\n\t\ttemplateLock: 'all',\n\t\tlayout,\n\t\trenderAppender: innerBlocks?.length\n\t\t\t? undefined\n\t\t\t: InnerBlocks.ButtonBlockAppender,\n\t} );\n\n\t// Sync the `overrides` attribute from the updated blocks to the pattern block.\n\t// `syncDerivedUpdates` is used here to avoid creating an additional undo level.\n\tuseEffect( () => {\n\t\tconst { getBlocks } = registry.select( blockEditorStore );\n\t\tlet prevBlocks = getBlocks( patternClientId );\n\t\treturn registry.subscribe( () => {\n\t\t\tconst blocks = getBlocks( patternClientId );\n\t\t\tif ( blocks !== prevBlocks ) {\n\t\t\t\tprevBlocks = blocks;\n\t\t\t\tsyncDerivedUpdates( () => {\n\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\toverrides: getOverridesFromBlocks(\n\t\t\t\t\t\t\tblocks,\n\t\t\t\t\t\t\tdefaultValuesRef.current\n\t\t\t\t\t\t),\n\t\t\t\t\t} );\n\t\t\t\t} );\n\t\t\t}\n\t\t}, blockEditorStore );\n\t}, [ syncDerivedUpdates, patternClientId, registry, setAttributes ] );\n\n\tconst handleEditOriginal = ( event ) => {\n\t\tsetBlockEditMode( setBlockEditingMode, innerBlocks, 'default' );\n\t\teditOriginalProps.onClick( event );\n\t};\n\n\tlet children = null;\n\n\tif ( hasAlreadyRendered ) {\n\t\tchildren = (\n\t\t\t<Warning>\n\t\t\t\t{ __( 'Block cannot be rendered inside itself.' ) }\n\t\t\t</Warning>\n\t\t);\n\t}\n\n\tif ( isMissing ) {\n\t\tchildren = (\n\t\t\t<Warning>\n\t\t\t\t{ __( 'Block has been deleted or is unavailable.' ) }\n\t\t\t</Warning>\n\t\t);\n\t}\n\n\tif ( ! hasResolved ) {\n\t\tchildren = (\n\t\t\t<Placeholder>\n\t\t\t\t<Spinner />\n\t\t\t</Placeholder>\n\t\t);\n\t}\n\n\treturn (\n\t\t<RecursionProvider uniqueId={ ref }>\n\t\t\t{ userCanEdit && editOriginalProps && (\n\t\t\t\t<BlockControls>\n\t\t\t\t\t<ToolbarGroup>\n\t\t\t\t\t\t<ToolbarButton\n\t\t\t\t\t\t\thref={ editOriginalProps.href }\n\t\t\t\t\t\t\tonClick={ handleEditOriginal }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Edit original' ) }\n\t\t\t\t\t\t</ToolbarButton>\n\t\t\t\t\t</ToolbarGroup>\n\t\t\t\t</BlockControls>\n\t\t\t) }\n\t\t\t{ children === null ? (\n\t\t\t\t<div { ...innerBlocksProps } />\n\t\t\t) : (\n\t\t\t\t<div { ...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,GAAG,IAAI;EAEnB,IAAKrD,kBAAkB,EAAG;IACzBqD,QAAQ,GACP,IAAAC,MAAA,CAAAC,aAAA,EAACxH,YAAA,CAAAyH,OAAO,QACL,IAAAC,QAAE,EAAE,yCAA0C,CACxC,CACT;EACF;EAEA,IAAKnD,SAAS,EAAG;IAChB+C,QAAQ,GACP,IAAAC,MAAA,CAAAC,aAAA,EAACxH,YAAA,CAAAyH,OAAO,QACL,IAAAC,QAAE,EAAE,2CAA4C,CAC1C,CACT;EACF;EAEA,IAAK,CAAErD,WAAW,EAAG;IACpBiD,QAAQ,GACP,IAAAC,MAAA,CAAAC,aAAA,EAAC1H,WAAA,CAAA6H,WAAW,QACX,IAAAJ,MAAA,CAAAC,aAAA,EAAC1H,WAAA,CAAA8H,OAAO,MAAE,CACE,CACb;EACF;EAEA,OACC,IAAAL,MAAA,CAAAC,aAAA,EAACxH,YAAA,CAAA6H,+BAAiB;IAACC,QAAQ,EAAGnE;EAAK,GAChCqB,WAAW,IAAIW,iBAAiB,IACjC,IAAA4B,MAAA,CAAAC,aAAA,EAACxH,YAAA,CAAA+H,aAAa,QACb,IAAAR,MAAA,CAAAC,aAAA,EAAC1H,WAAA,CAAAkI,YAAY,QACZ,IAAAT,MAAA,CAAAC,aAAA,EAAC1H,WAAA,CAAAmI,aAAa;IACbC,IAAI,EAAGvC,iBAAiB,CAACuC,IAAM;IAC/Bb,OAAO,EAAGF;EAAoB,GAE5B,IAAAO,QAAE,EAAE,eAAgB,CACR,CACF,CACA,CACf,EACCJ,QAAQ,KAAK,IAAI,GAClB,IAAAC,MAAA,CAAAC,aAAA;IAAA,GAAUb;EAAgB,CAAI,CAAC,GAE/B,IAAAY,MAAA,CAAAC,aAAA;IAAA,GAAUjB;EAAU,GAAKe,QAAe,CAEvB,CAAC;AAEtB"}
|
|
1
|
+
{"version":3,"names":["_classnames","_interopRequireDefault","require","_data","_element","_coreData","_components","_i18n","_blockEditor","_patterns","_blocks","_lockUnlock","useLayoutClasses","unlock","blockEditorPrivateApis","PARTIAL_SYNCING_SUPPORTED_BLOCKS","patternsPrivateApis","isPartiallySynced","block","Object","keys","includes","name","attributes","metadata","bindings","values","some","binding","source","getPartiallySyncedAttributes","entries","filter","map","attributeKey","fullAlignments","useInferredLayout","blocks","parentLayout","initialInferredAlignmentRef","useRef","useMemo","length","alignment","current","undefined","isConstrained","type","hasFullAlignment","align","layout","PATCH_OPERATIONS","Remove","Replace","applyInitialOverrides","overrides","defaultValues","innerBlocks","blockId","id","newAttributes","_defaultValues$blockI","overrideAttribute","getOverridesFromBlocks","assign","_overrides$blockId","setBlockEditMode","setEditMode","mode","forEach","editMode","clientId","getHasOverridableBlocks","ReusableBlockEdit","ref","__unstableParentLayout","patternClientId","setAttributes","registry","useRegistry","hasAlreadyRendered","useHasRecursion","record","editedRecord","hasResolved","useEntityRecord","isMissing","initialOverrides","defaultValuesRef","replaceInnerBlocks","__unstableMarkNextChangeAsNotPersistent","setBlockEditingMode","useDispatch","blockEditorStore","syncDerivedUpdates","userCanEdit","getBlockEditingMode","getPostLinkProps","useSelect","select","canUser","coreStore","getBlocks","editingMode","getSettings","canEdit","editOriginalProps","postId","postType","canvas","useEffect","hasOverridableBlocks","initialBlocks","_editedRecord$blocks$","cloneBlock","content","parse","batch","layoutClasses","blockProps","useBlockProps","className","classnames","innerBlocksProps","useInnerBlocksProps","templateLock","renderAppender","InnerBlocks","ButtonBlockAppender","prevBlocks","subscribe","handleEditOriginal","event","onClick","resetOverrides","children","_react","createElement","Warning","__","Placeholder","Spinner","RecursionProvider","uniqueId","BlockControls","ToolbarGroup","ToolbarButton","href","disabled","__experimentalIsFocusable"],"sources":["@wordpress/block-library/src/block/edit.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { useRegistry, useSelect, useDispatch } from '@wordpress/data';\nimport { useRef, useMemo, useEffect } from '@wordpress/element';\nimport { useEntityRecord, store as coreStore } from '@wordpress/core-data';\nimport {\n\tPlaceholder,\n\tSpinner,\n\tToolbarButton,\n\tToolbarGroup,\n} from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport {\n\tuseInnerBlocksProps,\n\tRecursionProvider,\n\tuseHasRecursion,\n\tInnerBlocks,\n\tuseBlockProps,\n\tWarning,\n\tprivateApis as blockEditorPrivateApis,\n\tstore as blockEditorStore,\n\tBlockControls,\n} from '@wordpress/block-editor';\nimport { privateApis as patternsPrivateApis } from '@wordpress/patterns';\nimport { parse, cloneBlock } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../lock-unlock';\n\nconst { useLayoutClasses } = unlock( blockEditorPrivateApis );\nconst { PARTIAL_SYNCING_SUPPORTED_BLOCKS } = unlock( patternsPrivateApis );\n\nfunction isPartiallySynced( block ) {\n\treturn (\n\t\tObject.keys( PARTIAL_SYNCING_SUPPORTED_BLOCKS ).includes(\n\t\t\tblock.name\n\t\t) &&\n\t\t!! block.attributes.metadata?.bindings &&\n\t\tObject.values( block.attributes.metadata.bindings ).some(\n\t\t\t( binding ) => binding.source.name === 'pattern_attributes'\n\t\t)\n\t);\n}\nfunction getPartiallySyncedAttributes( block ) {\n\treturn Object.entries( block.attributes.metadata.bindings )\n\t\t.filter(\n\t\t\t( [ , binding ] ) => binding.source.name === 'pattern_attributes'\n\t\t)\n\t\t.map( ( [ attributeKey ] ) => attributeKey );\n}\n\nconst fullAlignments = [ 'full', 'wide', 'left', 'right' ];\n\nconst useInferredLayout = ( blocks, parentLayout ) => {\n\tconst initialInferredAlignmentRef = useRef();\n\n\treturn useMemo( () => {\n\t\t// Exit early if the pattern's blocks haven't loaded yet.\n\t\tif ( ! blocks?.length ) {\n\t\t\treturn {};\n\t\t}\n\n\t\tlet alignment = initialInferredAlignmentRef.current;\n\n\t\t// Only track the initial alignment so that temporarily removed\n\t\t// alignments can be reapplied.\n\t\tif ( alignment === undefined ) {\n\t\t\tconst isConstrained = parentLayout?.type === 'constrained';\n\t\t\tconst hasFullAlignment = blocks.some( ( block ) =>\n\t\t\t\tfullAlignments.includes( block.attributes.align )\n\t\t\t);\n\n\t\t\talignment = isConstrained && hasFullAlignment ? 'full' : null;\n\t\t\tinitialInferredAlignmentRef.current = alignment;\n\t\t}\n\n\t\tconst layout = alignment ? parentLayout : undefined;\n\n\t\treturn { alignment, layout };\n\t}, [ blocks, parentLayout ] );\n};\n\n/**\n * Enum for patch operations.\n * We use integers here to minimize the size of the serialized data.\n * This has to be deserialized accordingly on the server side.\n * See block-bindings/sources/pattern.php\n */\nconst PATCH_OPERATIONS = {\n\t/** @type {0} */\n\tRemove: 0,\n\t/** @type {1} */\n\tReplace: 1,\n\t// Other operations are reserved for future use. (e.g. Add)\n};\n\n/**\n * @typedef {[typeof PATCH_OPERATIONS.Remove]} RemovePatch\n * @typedef {[typeof PATCH_OPERATIONS.Replace, unknown]} ReplacePatch\n * @typedef {RemovePatch | ReplacePatch} OverridePatch\n */\n\nfunction applyInitialOverrides( blocks, overrides = {}, defaultValues ) {\n\treturn blocks.map( ( block ) => {\n\t\tconst innerBlocks = applyInitialOverrides(\n\t\t\tblock.innerBlocks,\n\t\t\toverrides,\n\t\t\tdefaultValues\n\t\t);\n\t\tconst blockId = block.attributes.metadata?.id;\n\t\tif ( ! isPartiallySynced( block ) || ! blockId )\n\t\t\treturn { ...block, innerBlocks };\n\t\tconst attributes = getPartiallySyncedAttributes( block );\n\t\tconst newAttributes = { ...block.attributes };\n\t\tfor ( const attributeKey of attributes ) {\n\t\t\tdefaultValues[ blockId ] ??= {};\n\t\t\tdefaultValues[ blockId ][ attributeKey ] =\n\t\t\t\tblock.attributes[ attributeKey ];\n\t\t\t/** @type {OverridePatch} */\n\t\t\tconst overrideAttribute = overrides[ blockId ]?.[ attributeKey ];\n\t\t\tif ( ! overrideAttribute ) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif ( overrideAttribute[ 0 ] === PATCH_OPERATIONS.Remove ) {\n\t\t\t\tdelete newAttributes[ attributeKey ];\n\t\t\t} else if ( overrideAttribute[ 0 ] === PATCH_OPERATIONS.Replace ) {\n\t\t\t\tnewAttributes[ attributeKey ] = overrideAttribute[ 1 ];\n\t\t\t}\n\t\t}\n\t\treturn {\n\t\t\t...block,\n\t\t\tattributes: newAttributes,\n\t\t\tinnerBlocks,\n\t\t};\n\t} );\n}\n\nfunction getOverridesFromBlocks( blocks, defaultValues ) {\n\t/** @type {Record<string, Record<string, OverridePatch>>} */\n\tconst overrides = {};\n\tfor ( const block of blocks ) {\n\t\tObject.assign(\n\t\t\toverrides,\n\t\t\tgetOverridesFromBlocks( block.innerBlocks, defaultValues )\n\t\t);\n\t\t/** @type {string} */\n\t\tconst blockId = block.attributes.metadata?.id;\n\t\tif ( ! isPartiallySynced( block ) || ! blockId ) continue;\n\t\tconst attributes = getPartiallySyncedAttributes( block );\n\t\tfor ( const attributeKey of attributes ) {\n\t\t\tif (\n\t\t\t\tblock.attributes[ attributeKey ] !==\n\t\t\t\tdefaultValues[ blockId ][ attributeKey ]\n\t\t\t) {\n\t\t\t\toverrides[ blockId ] ??= {};\n\t\t\t\t/**\n\t\t\t\t * Create a patch operation for the binding attribute.\n\t\t\t\t * We use a tuple here to minimize the size of the serialized data.\n\t\t\t\t * The first item is the operation type, the second item is the value if any.\n\t\t\t\t */\n\t\t\t\tif ( block.attributes[ attributeKey ] === undefined ) {\n\t\t\t\t\t/** @type {RemovePatch} */\n\t\t\t\t\toverrides[ blockId ][ attributeKey ] = [\n\t\t\t\t\t\tPATCH_OPERATIONS.Remove,\n\t\t\t\t\t];\n\t\t\t\t} else {\n\t\t\t\t\t/** @type {ReplacePatch} */\n\t\t\t\t\toverrides[ blockId ][ attributeKey ] = [\n\t\t\t\t\t\tPATCH_OPERATIONS.Replace,\n\t\t\t\t\t\tblock.attributes[ attributeKey ],\n\t\t\t\t\t];\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn Object.keys( overrides ).length > 0 ? overrides : undefined;\n}\n\nfunction setBlockEditMode( setEditMode, blocks, mode ) {\n\tblocks.forEach( ( block ) => {\n\t\tconst editMode =\n\t\t\tmode || ( isPartiallySynced( block ) ? 'contentOnly' : 'disabled' );\n\t\tsetEditMode( block.clientId, editMode );\n\t\tsetBlockEditMode( setEditMode, block.innerBlocks, mode );\n\t} );\n}\n\nfunction getHasOverridableBlocks( blocks ) {\n\treturn blocks.some( ( block ) => {\n\t\tif ( isPartiallySynced( block ) ) return true;\n\t\treturn getHasOverridableBlocks( block.innerBlocks );\n\t} );\n}\n\nexport default function ReusableBlockEdit( {\n\tname,\n\tattributes: { ref, overrides },\n\t__unstableParentLayout: parentLayout,\n\tclientId: patternClientId,\n\tsetAttributes,\n} ) {\n\tconst registry = useRegistry();\n\tconst hasAlreadyRendered = useHasRecursion( ref );\n\tconst { record, editedRecord, hasResolved } = useEntityRecord(\n\t\t'postType',\n\t\t'wp_block',\n\t\tref\n\t);\n\tconst isMissing = hasResolved && ! record;\n\tconst initialOverrides = useRef( overrides );\n\tconst defaultValuesRef = useRef( {} );\n\n\tconst {\n\t\treplaceInnerBlocks,\n\t\t__unstableMarkNextChangeAsNotPersistent,\n\t\tsetBlockEditingMode,\n\t} = useDispatch( blockEditorStore );\n\tconst { syncDerivedUpdates } = unlock( useDispatch( blockEditorStore ) );\n\n\tconst { innerBlocks, userCanEdit, getBlockEditingMode, getPostLinkProps } =\n\t\tuseSelect(\n\t\t\t( select ) => {\n\t\t\t\tconst { canUser } = select( coreStore );\n\t\t\t\tconst {\n\t\t\t\t\tgetBlocks,\n\t\t\t\t\tgetBlockEditingMode: editingMode,\n\t\t\t\t\tgetSettings,\n\t\t\t\t} = select( blockEditorStore );\n\t\t\t\tconst blocks = getBlocks( patternClientId );\n\t\t\t\tconst canEdit = canUser( 'update', 'blocks', ref );\n\n\t\t\t\t// For editing link to the site editor if the theme and user permissions support it.\n\t\t\t\treturn {\n\t\t\t\t\tinnerBlocks: blocks,\n\t\t\t\t\tuserCanEdit: canEdit,\n\t\t\t\t\tgetBlockEditingMode: editingMode,\n\t\t\t\t\tgetPostLinkProps: getSettings().getPostLinkProps,\n\t\t\t\t};\n\t\t\t},\n\t\t\t[ patternClientId, ref ]\n\t\t);\n\n\tconst editOriginalProps = getPostLinkProps\n\t\t? getPostLinkProps( {\n\t\t\t\tpostId: ref,\n\t\t\t\tpostType: 'wp_block',\n\t\t\t\tcanvas: 'edit',\n\t\t } )\n\t\t: {};\n\n\tuseEffect(\n\t\t() => setBlockEditMode( setBlockEditingMode, innerBlocks ),\n\t\t[ innerBlocks, setBlockEditingMode ]\n\t);\n\n\tconst hasOverridableBlocks = useMemo(\n\t\t() => getHasOverridableBlocks( innerBlocks ),\n\t\t[ innerBlocks ]\n\t);\n\n\tconst initialBlocks = useMemo(\n\t\t() =>\n\t\t\t// Clone the blocks to generate new client IDs.\n\t\t\teditedRecord.blocks?.map( ( block ) => cloneBlock( block ) ) ??\n\t\t\t( editedRecord.content && typeof editedRecord.content !== 'function'\n\t\t\t\t? parse( editedRecord.content )\n\t\t\t\t: [] ),\n\t\t[ editedRecord.blocks, editedRecord.content ]\n\t);\n\n\t// Apply the initial overrides from the pattern block to the inner blocks.\n\tuseEffect( () => {\n\t\tdefaultValuesRef.current = {};\n\t\tconst editingMode = getBlockEditingMode( patternClientId );\n\t\t// Replace the contents of the blocks with the overrides.\n\t\tregistry.batch( () => {\n\t\t\tsetBlockEditingMode( patternClientId, 'default' );\n\t\t\tsyncDerivedUpdates( () => {\n\t\t\t\treplaceInnerBlocks(\n\t\t\t\t\tpatternClientId,\n\t\t\t\t\tapplyInitialOverrides(\n\t\t\t\t\t\tinitialBlocks,\n\t\t\t\t\t\tinitialOverrides.current,\n\t\t\t\t\t\tdefaultValuesRef.current\n\t\t\t\t\t)\n\t\t\t\t);\n\t\t\t} );\n\t\t\tsetBlockEditingMode( patternClientId, editingMode );\n\t\t} );\n\t}, [\n\t\t__unstableMarkNextChangeAsNotPersistent,\n\t\tpatternClientId,\n\t\tinitialBlocks,\n\t\treplaceInnerBlocks,\n\t\tregistry,\n\t\tgetBlockEditingMode,\n\t\tsetBlockEditingMode,\n\t\tsyncDerivedUpdates,\n\t] );\n\n\tconst { alignment, layout } = useInferredLayout(\n\t\tinnerBlocks,\n\t\tparentLayout\n\t);\n\tconst layoutClasses = useLayoutClasses( { layout }, name );\n\n\tconst blockProps = useBlockProps( {\n\t\tclassName: classnames(\n\t\t\t'block-library-block__reusable-block-container',\n\t\t\tlayout && layoutClasses,\n\t\t\t{ [ `align${ alignment }` ]: alignment }\n\t\t),\n\t} );\n\n\tconst innerBlocksProps = useInnerBlocksProps( blockProps, {\n\t\ttemplateLock: 'all',\n\t\tlayout,\n\t\trenderAppender: innerBlocks?.length\n\t\t\t? undefined\n\t\t\t: InnerBlocks.ButtonBlockAppender,\n\t} );\n\n\t// Sync the `overrides` attribute from the updated blocks to the pattern block.\n\t// `syncDerivedUpdates` is used here to avoid creating an additional undo level.\n\tuseEffect( () => {\n\t\tconst { getBlocks } = registry.select( blockEditorStore );\n\t\tlet prevBlocks = getBlocks( patternClientId );\n\t\treturn registry.subscribe( () => {\n\t\t\tconst blocks = getBlocks( patternClientId );\n\t\t\tif ( blocks !== prevBlocks ) {\n\t\t\t\tprevBlocks = blocks;\n\t\t\t\tsyncDerivedUpdates( () => {\n\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\toverrides: getOverridesFromBlocks(\n\t\t\t\t\t\t\tblocks,\n\t\t\t\t\t\t\tdefaultValuesRef.current\n\t\t\t\t\t\t),\n\t\t\t\t\t} );\n\t\t\t\t} );\n\t\t\t}\n\t\t}, blockEditorStore );\n\t}, [ syncDerivedUpdates, patternClientId, registry, setAttributes ] );\n\n\tconst handleEditOriginal = ( event ) => {\n\t\tsetBlockEditMode( setBlockEditingMode, innerBlocks, 'default' );\n\t\teditOriginalProps.onClick( event );\n\t};\n\n\tconst resetOverrides = () => {\n\t\tif ( overrides ) {\n\t\t\treplaceInnerBlocks( patternClientId, initialBlocks );\n\t\t}\n\t};\n\n\tlet children = null;\n\n\tif ( hasAlreadyRendered ) {\n\t\tchildren = (\n\t\t\t<Warning>\n\t\t\t\t{ __( 'Block cannot be rendered inside itself.' ) }\n\t\t\t</Warning>\n\t\t);\n\t}\n\n\tif ( isMissing ) {\n\t\tchildren = (\n\t\t\t<Warning>\n\t\t\t\t{ __( 'Block has been deleted or is unavailable.' ) }\n\t\t\t</Warning>\n\t\t);\n\t}\n\n\tif ( ! hasResolved ) {\n\t\tchildren = (\n\t\t\t<Placeholder>\n\t\t\t\t<Spinner />\n\t\t\t</Placeholder>\n\t\t);\n\t}\n\n\treturn (\n\t\t<RecursionProvider uniqueId={ ref }>\n\t\t\t{ userCanEdit && editOriginalProps && (\n\t\t\t\t<BlockControls>\n\t\t\t\t\t<ToolbarGroup>\n\t\t\t\t\t\t<ToolbarButton\n\t\t\t\t\t\t\thref={ editOriginalProps.href }\n\t\t\t\t\t\t\tonClick={ handleEditOriginal }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Edit original' ) }\n\t\t\t\t\t\t</ToolbarButton>\n\t\t\t\t\t</ToolbarGroup>\n\t\t\t\t</BlockControls>\n\t\t\t) }\n\n\t\t\t{ hasOverridableBlocks && (\n\t\t\t\t<BlockControls>\n\t\t\t\t\t<ToolbarGroup>\n\t\t\t\t\t\t<ToolbarButton\n\t\t\t\t\t\t\tonClick={ resetOverrides }\n\t\t\t\t\t\t\tdisabled={ ! overrides }\n\t\t\t\t\t\t\t__experimentalIsFocusable\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Reset to original' ) }\n\t\t\t\t\t\t</ToolbarButton>\n\t\t\t\t\t</ToolbarGroup>\n\t\t\t\t</BlockControls>\n\t\t\t) }\n\n\t\t\t{ children === null ? (\n\t\t\t\t<div { ...innerBlocksProps } />\n\t\t\t) : (\n\t\t\t\t<div { ...blockProps }>{ children }</div>\n\t\t\t) }\n\t\t</RecursionProvider>\n\t);\n}\n"],"mappings":";;;;;;;;AAGA,IAAA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;IACbb,OAAO,EAAGC,cAAgB;IAC1Bc,QAAQ,EAAG,CAAE7F,SAAW;IACxB8F,yBAAyB;EAAA,GAEvB,IAAAV,QAAE,EAAE,mBAAoB,CACZ,CACF,CACA,CACf,EAECJ,QAAQ,KAAK,IAAI,GAClB,IAAAC,MAAA,CAAAC,aAAA;IAAA,GAAUd;EAAgB,CAAI,CAAC,GAE/B,IAAAa,MAAA,CAAAC,aAAA;IAAA,GAAUlB;EAAU,GAAKgB,QAAe,CAEvB,CAAC;AAEtB"}
|
|
@@ -18,8 +18,8 @@ var _icons = require("@wordpress/icons");
|
|
|
18
18
|
var _reusableBlocks = require("@wordpress/reusable-blocks");
|
|
19
19
|
var _editor = require("@wordpress/editor");
|
|
20
20
|
var _notices = require("@wordpress/notices");
|
|
21
|
-
var _editor2 = _interopRequireDefault(require("
|
|
22
|
-
var _editTitle = _interopRequireDefault(require("
|
|
21
|
+
var _editor2 = _interopRequireDefault(require("./editor.scss"));
|
|
22
|
+
var _editTitle = _interopRequireDefault(require("./edit-title"));
|
|
23
23
|
/**
|
|
24
24
|
* External dependencies
|
|
25
25
|
*/
|
|
@@ -39,7 +39,7 @@ function ReusableBlockEdit({
|
|
|
39
39
|
clientId,
|
|
40
40
|
isSelected
|
|
41
41
|
}) {
|
|
42
|
-
const hasAlreadyRendered = (0, _blockEditor.
|
|
42
|
+
const hasAlreadyRendered = (0, _blockEditor.useHasRecursion)(ref);
|
|
43
43
|
const [showHelp, setShowHelp] = (0, _element.useState)(false);
|
|
44
44
|
const infoTextStyle = (0, _compose.usePreferredColorSchemeStyle)(_editor2.default.infoText, _editor2.default.infoTextDark);
|
|
45
45
|
const infoTitleStyle = (0, _compose.usePreferredColorSchemeStyle)(_editor2.default.infoTitle, _editor2.default.infoTitleDark);
|
|
@@ -143,7 +143,7 @@ function ReusableBlockEdit({
|
|
|
143
143
|
if (!isEditing) {
|
|
144
144
|
element = (0, _react.createElement)(_components.Disabled, null, element);
|
|
145
145
|
}
|
|
146
|
-
return (0, _react.createElement)(_blockEditor.
|
|
146
|
+
return (0, _react.createElement)(_blockEditor.RecursionProvider, {
|
|
147
147
|
uniqueId: ref
|
|
148
148
|
}, (0, _react.createElement)(_reactNative.TouchableWithoutFeedback, {
|
|
149
149
|
disabled: !isSelected,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_reactNative","require","_element","_coreData","_components","_data","_i18n","_blockEditor","_compose","_icons","_reusableBlocks","_editor","_notices","_editor2","_interopRequireDefault","_editTitle","ReusableBlockEdit","attributes","ref","clientId","isSelected","hasAlreadyRendered","useHasRecursion","showHelp","setShowHelp","useState","infoTextStyle","usePreferredColorSchemeStyle","styles","infoText","infoTextDark","infoTitleStyle","infoTitle","infoTitleDark","infoSheetIconStyle","infoSheetIcon","infoSheetIconDark","infoDescriptionStyle","infoDescription","infoDescriptionDark","actionButtonStyle","actionButton","actionButtonDark","spinnerStyle","spinner","spinnerDark","hasResolved","isEditing","isMissing","useSelect","select","persistedBlock","coreStore","getEntityRecord","hasResolvedBlock","hasFinishedResolution","getBlockCount","blockEditorStore","reusableBlocksStore","__experimentalIsEditingReusableBlock","innerBlockCount","hostAppNamespace","editorStore","getEditorSettings","createSuccessNotice","useDispatch","noticesStore","__experimentalConvertBlockToStatic","convertBlockToStatic","clearSelectedBlock","blocks","onInput","onChange","useEntityBlockEditor","id","title","useEntityProp","openSheet","closeSheet","onConvertToRegularBlocks","useCallback","successNotice","__","sprintf","setImmediate","renderSheet","Platform","OS","_react","createElement","BottomSheet","isVisible","hideHeader","onClose","View","style","infoContainer","Icon","icon","help","color","size","Text","TextControl","label","separatorType","onPress","labelStyle","Warning","message","ActivityIndicator","animating","element","InnerBlocks","value","Disabled","RecursionProvider","uniqueId","TouchableWithoutFeedback","disabled","accessibilityLabel","accessibilityRole","accessibilityHint","default"],"sources":["@wordpress/block-library/src/block/edit.native.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport {\n\tActivityIndicator,\n\tPlatform,\n\tText,\n\tTouchableWithoutFeedback,\n\tView,\n} from 'react-native';\n\n/**\n * WordPress dependencies\n */\nimport { useState, useCallback } from '@wordpress/element';\nimport {\n\tuseEntityBlockEditor,\n\tuseEntityProp,\n\tstore as coreStore,\n} from '@wordpress/core-data';\nimport {\n\tBottomSheet,\n\tIcon,\n\tDisabled,\n\tTextControl,\n} from '@wordpress/components';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { __, sprintf } from '@wordpress/i18n';\nimport {\n\tRecursionProvider,\n\tuseHasRecursion,\n\tInnerBlocks,\n\tWarning,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport { usePreferredColorSchemeStyle } from '@wordpress/compose';\nimport { help } from '@wordpress/icons';\nimport { store as reusableBlocksStore } from '@wordpress/reusable-blocks';\nimport { store as editorStore } from '@wordpress/editor';\nimport { store as noticesStore } from '@wordpress/notices';\n\n/**\n * Internal dependencies\n */\nimport styles from './editor.scss';\nimport EditTitle from './edit-title';\n\nexport default function ReusableBlockEdit( {\n\tattributes: { ref },\n\tclientId,\n\tisSelected,\n} ) {\n\tconst hasAlreadyRendered = useHasRecursion( ref );\n\n\tconst [ showHelp, setShowHelp ] = useState( false );\n\tconst infoTextStyle = usePreferredColorSchemeStyle(\n\t\tstyles.infoText,\n\t\tstyles.infoTextDark\n\t);\n\tconst infoTitleStyle = usePreferredColorSchemeStyle(\n\t\tstyles.infoTitle,\n\t\tstyles.infoTitleDark\n\t);\n\tconst infoSheetIconStyle = usePreferredColorSchemeStyle(\n\t\tstyles.infoSheetIcon,\n\t\tstyles.infoSheetIconDark\n\t);\n\tconst infoDescriptionStyle = usePreferredColorSchemeStyle(\n\t\tstyles.infoDescription,\n\t\tstyles.infoDescriptionDark\n\t);\n\tconst actionButtonStyle = usePreferredColorSchemeStyle(\n\t\tstyles.actionButton,\n\t\tstyles.actionButtonDark\n\t);\n\tconst spinnerStyle = usePreferredColorSchemeStyle(\n\t\tstyles.spinner,\n\t\tstyles.spinnerDark\n\t);\n\n\tconst { hasResolved, isEditing, isMissing } = useSelect(\n\t\t( select ) => {\n\t\t\tconst persistedBlock = select( coreStore ).getEntityRecord(\n\t\t\t\t'postType',\n\t\t\t\t'wp_block',\n\t\t\t\tref\n\t\t\t);\n\t\t\tconst hasResolvedBlock = select( coreStore ).hasFinishedResolution(\n\t\t\t\t'getEntityRecord',\n\t\t\t\t[ 'postType', 'wp_block', ref ]\n\t\t\t);\n\n\t\t\tconst { getBlockCount } = select( blockEditorStore );\n\n\t\t\treturn {\n\t\t\t\thasResolved: hasResolvedBlock,\n\t\t\t\tisEditing:\n\t\t\t\t\tselect(\n\t\t\t\t\t\treusableBlocksStore\n\t\t\t\t\t).__experimentalIsEditingReusableBlock( clientId ),\n\t\t\t\tisMissing: hasResolvedBlock && ! persistedBlock,\n\t\t\t\tinnerBlockCount: getBlockCount( clientId ),\n\t\t\t};\n\t\t},\n\t\t[ ref, clientId ]\n\t);\n\tconst hostAppNamespace = useSelect(\n\t\t( select ) =>\n\t\t\tselect( editorStore ).getEditorSettings().hostAppNamespace,\n\t\t[]\n\t);\n\n\tconst { createSuccessNotice } = useDispatch( noticesStore );\n\tconst { __experimentalConvertBlockToStatic: convertBlockToStatic } =\n\t\tuseDispatch( reusableBlocksStore );\n\tconst { clearSelectedBlock } = useDispatch( blockEditorStore );\n\n\tconst [ blocks, onInput, onChange ] = useEntityBlockEditor(\n\t\t'postType',\n\t\t'wp_block',\n\t\t{ id: ref }\n\t);\n\n\tconst [ title ] = useEntityProp( 'postType', 'wp_block', 'title', ref );\n\n\tfunction openSheet() {\n\t\tsetShowHelp( true );\n\t}\n\n\tfunction closeSheet() {\n\t\tsetShowHelp( false );\n\t}\n\n\tconst onConvertToRegularBlocks = useCallback( () => {\n\t\t/* translators: %s: name of the synced block */\n\t\tconst successNotice = __( '%s detached' );\n\t\tcreateSuccessNotice( sprintf( successNotice, title ) );\n\n\t\tclearSelectedBlock();\n\t\t// Convert action is executed at the end of the current JavaScript execution block\n\t\t// to prevent issues related to undo/redo actions.\n\t\tsetImmediate( () => convertBlockToStatic( clientId ) );\n\t}, [ title, clientId ] );\n\n\tfunction renderSheet() {\n\t\tconst infoTitle =\n\t\t\tPlatform.OS === 'android'\n\t\t\t\t? sprintf(\n\t\t\t\t\t\t/* translators: %s: name of the host app (e.g. WordPress) */\n\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t'Editing synced patterns is not yet supported on %s for Android'\n\t\t\t\t\t\t),\n\t\t\t\t\t\thostAppNamespace\n\t\t\t\t )\n\t\t\t\t: sprintf(\n\t\t\t\t\t\t/* translators: %s: name of the host app (e.g. WordPress) */\n\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t'Editing synced patterns is not yet supported on %s for iOS'\n\t\t\t\t\t\t),\n\t\t\t\t\t\thostAppNamespace\n\t\t\t\t );\n\n\t\treturn (\n\t\t\t<BottomSheet\n\t\t\t\tisVisible={ showHelp }\n\t\t\t\thideHeader\n\t\t\t\tonClose={ closeSheet }\n\t\t\t>\n\t\t\t\t<View style={ styles.infoContainer }>\n\t\t\t\t\t<Icon\n\t\t\t\t\t\ticon={ help }\n\t\t\t\t\t\tcolor={ infoSheetIconStyle.color }\n\t\t\t\t\t\tsize={ styles.infoSheetIcon.size }\n\t\t\t\t\t/>\n\t\t\t\t\t<Text style={ [ infoTextStyle, infoTitleStyle ] }>\n\t\t\t\t\t\t{ infoTitle }\n\t\t\t\t\t</Text>\n\t\t\t\t\t<Text style={ [ infoTextStyle, infoDescriptionStyle ] }>\n\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t'Alternatively, you can detach and edit this block separately by tapping “Detach”.'\n\t\t\t\t\t\t) }\n\t\t\t\t\t</Text>\n\t\t\t\t\t<TextControl\n\t\t\t\t\t\tlabel={ __( 'Detach' ) }\n\t\t\t\t\t\tseparatorType=\"topFullWidth\"\n\t\t\t\t\t\tonPress={ onConvertToRegularBlocks }\n\t\t\t\t\t\tlabelStyle={ actionButtonStyle }\n\t\t\t\t\t/>\n\t\t\t\t</View>\n\t\t\t</BottomSheet>\n\t\t);\n\t}\n\n\tif ( hasAlreadyRendered ) {\n\t\treturn (\n\t\t\t<Warning\n\t\t\t\tmessage={ __( 'Block cannot be rendered inside itself.' ) }\n\t\t\t/>\n\t\t);\n\t}\n\n\tif ( isMissing ) {\n\t\treturn (\n\t\t\t<Warning\n\t\t\t\tmessage={ __( 'Block has been deleted or is unavailable.' ) }\n\t\t\t/>\n\t\t);\n\t}\n\n\tif ( ! hasResolved ) {\n\t\treturn (\n\t\t\t<View style={ spinnerStyle }>\n\t\t\t\t<ActivityIndicator animating />\n\t\t\t</View>\n\t\t);\n\t}\n\n\tlet element = (\n\t\t<InnerBlocks\n\t\t\tvalue={ blocks }\n\t\t\tonChange={ onChange }\n\t\t\tonInput={ onInput }\n\t\t/>\n\t);\n\n\tif ( ! isEditing ) {\n\t\telement = <Disabled>{ element }</Disabled>;\n\t}\n\n\treturn (\n\t\t<RecursionProvider uniqueId={ ref }>\n\t\t\t<TouchableWithoutFeedback\n\t\t\t\tdisabled={ ! isSelected }\n\t\t\t\taccessibilityLabel={ __( 'Help button' ) }\n\t\t\t\taccessibilityRole={ 'button' }\n\t\t\t\taccessibilityHint={ __( 'Tap here to show help' ) }\n\t\t\t\tonPress={ openSheet }\n\t\t\t>\n\t\t\t\t<View>\n\t\t\t\t\t{ isSelected && <EditTitle title={ title } /> }\n\t\t\t\t\t{ element }\n\t\t\t\t\t{ renderSheet() }\n\t\t\t\t</View>\n\t\t\t</TouchableWithoutFeedback>\n\t\t</RecursionProvider>\n\t);\n}\n"],"mappings":";;;;;;;;AAGA,IAAAA,YAAA,GAAAC,OAAA;AAWA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,SAAA,GAAAF,OAAA;AAKA,IAAAG,WAAA,GAAAH,OAAA;AAMA,IAAAI,KAAA,GAAAJ,OAAA;AACA,IAAAK,KAAA,GAAAL,OAAA;AACA,IAAAM,YAAA,GAAAN,OAAA;AAOA,IAAAO,QAAA,GAA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AAG,IAAAxB,MAAA,CAAAC,aAAA,EAACrF,WAAA,CAAA+G,QAAQ,QAAGH,OAAmB,CAAC;EAC3C;EAEA,OACC,IAAAxB,MAAA,CAAAC,aAAA,EAAClF,YAAA,CAAA6G,iBAAiB;IAACC,QAAQ,EAAGnG;EAAK,GAClC,IAAAsE,MAAA,CAAAC,aAAA,EAACzF,YAAA,CAAAsH,wBAAwB;IACxBC,QAAQ,EAAG,CAAEnG,UAAY;IACzBoG,kBAAkB,EAAG,IAAAtC,QAAE,EAAE,aAAc,CAAG;IAC1CuC,iBAAiB,EAAG,QAAU;IAC9BC,iBAAiB,EAAG,IAAAxC,QAAE,EAAE,uBAAwB,CAAG;IACnDwB,OAAO,EAAG7B;EAAW,GAErB,IAAAW,MAAA,CAAAC,aAAA,EAACzF,YAAA,CAAA8F,IAAI,QACF1E,UAAU,IAAI,IAAAoE,MAAA,CAAAC,aAAA,EAAC1E,UAAA,CAAA4G,OAAS;IAAChD,KAAK,EAAGA;EAAO,CAAE,CAAC,EAC3CqC,OAAO,EACP3B,WAAW,CAAC,CACT,CACmB,CACR,CAAC;AAEtB"}
|
package/build/block/index.js
CHANGED
|
@@ -7,8 +7,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
exports.settings = exports.name = exports.metadata = exports.init = void 0;
|
|
8
8
|
var _icons = require("@wordpress/icons");
|
|
9
9
|
var _initBlock = _interopRequireDefault(require("../utils/init-block"));
|
|
10
|
-
var _edit = _interopRequireDefault(require("./
|
|
11
|
-
var _edit2 = _interopRequireDefault(require("./edit"));
|
|
10
|
+
var _edit = _interopRequireDefault(require("./edit"));
|
|
12
11
|
/**
|
|
13
12
|
* WordPress dependencies
|
|
14
13
|
*/
|
|
@@ -27,6 +26,9 @@ const metadata = {
|
|
|
27
26
|
attributes: {
|
|
28
27
|
ref: {
|
|
29
28
|
type: "number"
|
|
29
|
+
},
|
|
30
|
+
overrides: {
|
|
31
|
+
type: "object"
|
|
30
32
|
}
|
|
31
33
|
},
|
|
32
34
|
supports: {
|
|
@@ -42,7 +44,7 @@ const {
|
|
|
42
44
|
} = metadata;
|
|
43
45
|
exports.name = name;
|
|
44
46
|
const settings = {
|
|
45
|
-
edit:
|
|
47
|
+
edit: _edit.default,
|
|
46
48
|
icon: _icons.symbol
|
|
47
49
|
};
|
|
48
50
|
exports.settings = settings;
|
package/build/block/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_icons","require","_initBlock","_interopRequireDefault","_edit","
|
|
1
|
+
{"version":3,"names":["_icons","require","_initBlock","_interopRequireDefault","_edit","metadata","$schema","apiVersion","name","title","category","description","keywords","textdomain","attributes","ref","type","overrides","supports","customClassName","html","inserter","renaming","exports","settings","edit","icon","init","initBlock"],"sources":["@wordpress/block-library/src/block/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { symbol as icon } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport initBlock from '../utils/init-block';\nimport metadata from './block.json';\nimport edit from './edit';\n\nconst { name } = metadata;\n\nexport { metadata, name };\n\nexport const settings = {\n\tedit,\n\ticon,\n};\n\nexport const init = () => initBlock( { name, metadata, settings } );\n"],"mappings":";;;;;;;AAGA,IAAAA,MAAA,GAAAC,OAAA;AAKA,IAAAC,UAAA,GAAAC,sBAAA,CAAAF,OAAA;AAEA,IAAAG,KAAA,GAAAD,sBAAA,CAAAF,OAAA;AAVA;AACA;AACA;AAGA;AACA;AACA;AAFA,MAAAI,QAAA;EAAAC,OAAA;EAAAC,UAAA;EAAAC,IAAA;EAAAC,KAAA;EAAAC,QAAA;EAAAC,WAAA;EAAAC,QAAA;EAAAC,UAAA;EAAAC,UAAA;IAAAC,GAAA;MAAAC,IAAA;IAAA;IAAAC,SAAA;MAAAD,IAAA;IAAA;EAAA;EAAAE,QAAA;IAAAC,eAAA;IAAAC,IAAA;IAAAC,QAAA;IAAAC,QAAA;EAAA;AAAA;AAAAC,OAAA,CAAAlB,QAAA,GAAAA,QAAA;AAOA,MAAM;EAAEG;AAAK,CAAC,GAAGH,QAAQ;AAACkB,OAAA,CAAAf,IAAA,GAAAA,IAAA;AAInB,MAAMgB,QAAQ,GAAG;EACvBC,IAAI,EAAJA,aAAI;EACJC,IAAI,EAAJA;AACD,CAAC;AAACH,OAAA,CAAAC,QAAA,GAAAA,QAAA;AAEK,MAAMG,IAAI,GAAGA,CAAA,KAAM,IAAAC,kBAAS,EAAE;EAAEpB,IAAI;EAAEH,QAAQ;EAAEmB;AAAS,CAAE,CAAC;AAACD,OAAA,CAAAI,IAAA,GAAAA,IAAA"}
|
package/build/button/edit.js
CHANGED
|
@@ -10,6 +10,7 @@ var _classnames = _interopRequireDefault(require("classnames"));
|
|
|
10
10
|
var _constants = require("./constants");
|
|
11
11
|
var _getUpdatedLinkAttributes = require("./get-updated-link-attributes");
|
|
12
12
|
var _removeAnchorTag = _interopRequireDefault(require("../utils/remove-anchor-tag"));
|
|
13
|
+
var _lockUnlock = require("../lock-unlock");
|
|
13
14
|
var _i18n = require("@wordpress/i18n");
|
|
14
15
|
var _element = require("@wordpress/element");
|
|
15
16
|
var _components = require("@wordpress/components");
|
|
@@ -128,7 +129,8 @@ function ButtonEdit(props) {
|
|
|
128
129
|
style,
|
|
129
130
|
text,
|
|
130
131
|
url,
|
|
131
|
-
width
|
|
132
|
+
width,
|
|
133
|
+
metadata
|
|
132
134
|
} = attributes;
|
|
133
135
|
const TagName = tagName || 'a';
|
|
134
136
|
function onKeyDown(event) {
|
|
@@ -146,12 +148,14 @@ function ButtonEdit(props) {
|
|
|
146
148
|
const borderProps = (0, _blockEditor.__experimentalUseBorderProps)(attributes);
|
|
147
149
|
const colorProps = (0, _blockEditor.__experimentalUseColorProps)(attributes);
|
|
148
150
|
const spacingProps = (0, _blockEditor.__experimentalGetSpacingClassesAndStyles)(attributes);
|
|
151
|
+
const shadowProps = (0, _blockEditor.__experimentalUseShadowProps)(attributes);
|
|
149
152
|
const ref = (0, _element.useRef)();
|
|
150
153
|
const richTextRef = (0, _element.useRef)();
|
|
151
154
|
const blockProps = (0, _blockEditor.useBlockProps)({
|
|
152
155
|
ref: (0, _compose.useMergeRefs)([setPopoverAnchor, ref]),
|
|
153
156
|
onKeyDown
|
|
154
157
|
});
|
|
158
|
+
const blockEditingMode = (0, _blockEditor.useBlockEditingMode)();
|
|
155
159
|
const [isEditingURL, setIsEditingURL] = (0, _element.useState)(false);
|
|
156
160
|
const isURLSet = !!url;
|
|
157
161
|
const opensInNewTab = linkTarget === _constants.NEW_TAB_TARGET;
|
|
@@ -187,6 +191,19 @@ function ButtonEdit(props) {
|
|
|
187
191
|
clientId
|
|
188
192
|
});
|
|
189
193
|
const mergedRef = (0, _compose.useMergeRefs)([useEnterRef, richTextRef]);
|
|
194
|
+
const {
|
|
195
|
+
lockUrlControls = false
|
|
196
|
+
} = (0, _data.useSelect)(select => {
|
|
197
|
+
if (!isSelected) {
|
|
198
|
+
return {};
|
|
199
|
+
}
|
|
200
|
+
const {
|
|
201
|
+
getBlockBindingsSource
|
|
202
|
+
} = (0, _lockUnlock.unlock)(select(_blockEditor.store));
|
|
203
|
+
return {
|
|
204
|
+
lockUrlControls: !!metadata?.bindings?.url && getBlockBindingsSource(metadata?.bindings?.url?.source?.name)?.lockAttributesEditing === true
|
|
205
|
+
};
|
|
206
|
+
}, [isSelected]);
|
|
190
207
|
return (0, _react.createElement)(_react.Fragment, null, (0, _react.createElement)("div", {
|
|
191
208
|
...blockProps,
|
|
192
209
|
className: (0, _classnames.default)(blockProps.className, {
|
|
@@ -211,7 +228,8 @@ function ButtonEdit(props) {
|
|
|
211
228
|
style: {
|
|
212
229
|
...borderProps.style,
|
|
213
230
|
...colorProps.style,
|
|
214
|
-
...spacingProps.style
|
|
231
|
+
...spacingProps.style,
|
|
232
|
+
...shadowProps.style
|
|
215
233
|
},
|
|
216
234
|
onSplit: value => (0, _blocks.createBlock)('core/button', {
|
|
217
235
|
...attributes,
|
|
@@ -222,27 +240,27 @@ function ButtonEdit(props) {
|
|
|
222
240
|
identifier: "text"
|
|
223
241
|
})), (0, _react.createElement)(_blockEditor.BlockControls, {
|
|
224
242
|
group: "block"
|
|
225
|
-
}, (0, _react.createElement)(_blockEditor.AlignmentControl, {
|
|
243
|
+
}, blockEditingMode === 'default' && (0, _react.createElement)(_blockEditor.AlignmentControl, {
|
|
226
244
|
value: textAlign,
|
|
227
245
|
onChange: nextAlign => {
|
|
228
246
|
setAttributes({
|
|
229
247
|
textAlign: nextAlign
|
|
230
248
|
});
|
|
231
249
|
}
|
|
232
|
-
}), !isURLSet && isLinkTag && (0, _react.createElement)(_components.ToolbarButton, {
|
|
250
|
+
}), !isURLSet && isLinkTag && !lockUrlControls && (0, _react.createElement)(_components.ToolbarButton, {
|
|
233
251
|
name: "link",
|
|
234
252
|
icon: _icons.link,
|
|
235
253
|
title: (0, _i18n.__)('Link'),
|
|
236
254
|
shortcut: _keycodes.displayShortcut.primary('k'),
|
|
237
255
|
onClick: startEditing
|
|
238
|
-
}), isURLSet && isLinkTag && (0, _react.createElement)(_components.ToolbarButton, {
|
|
256
|
+
}), isURLSet && isLinkTag && !lockUrlControls && (0, _react.createElement)(_components.ToolbarButton, {
|
|
239
257
|
name: "link",
|
|
240
258
|
icon: _icons.linkOff,
|
|
241
259
|
title: (0, _i18n.__)('Unlink'),
|
|
242
260
|
shortcut: _keycodes.displayShortcut.primaryShift('k'),
|
|
243
261
|
onClick: unlink,
|
|
244
262
|
isActive: true
|
|
245
|
-
})), isLinkTag && isSelected && (isEditingURL || isURLSet) && (0, _react.createElement)(_components.Popover, {
|
|
263
|
+
})), isLinkTag && isSelected && (isEditingURL || isURLSet) && !lockUrlControls && (0, _react.createElement)(_components.Popover, {
|
|
246
264
|
placement: "bottom",
|
|
247
265
|
onClose: () => {
|
|
248
266
|
setIsEditingURL(false);
|