@wordpress/block-library 8.20.1 → 8.21.1-next.f8d8eceb.0
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 +7 -0
- package/README.md +12 -0
- package/build/avatar/index.js +5 -1
- package/build/avatar/index.js.map +1 -1
- package/build/block/edit-title.native.js +11 -3
- package/build/block/edit-title.native.js.map +1 -1
- package/build/block/index.js +2 -1
- package/build/block/index.js.map +1 -1
- package/build/code/edit.native.js +8 -2
- package/build/code/edit.native.js.map +1 -1
- package/build/column/edit.js +2 -1
- package/build/column/edit.js.map +1 -1
- package/build/column/edit.native.js +2 -1
- package/build/column/edit.native.js.map +1 -1
- package/build/columns/edit.native.js +2 -1
- package/build/columns/edit.native.js.map +1 -1
- package/build/cover/controls.native.js +2 -1
- package/build/cover/controls.native.js.map +1 -1
- package/build/cover/deprecated.js +110 -1
- package/build/cover/deprecated.js.map +1 -1
- package/build/cover/edit/index.js +11 -4
- package/build/cover/edit/index.js.map +1 -1
- package/build/cover/edit/inspector-controls.js +3 -3
- package/build/cover/edit/inspector-controls.js.map +1 -1
- package/build/cover/index.js +0 -3
- package/build/cover/index.js.map +1 -1
- package/build/cover/save.js +2 -1
- package/build/cover/save.js.map +1 -1
- package/build/cover/shared.js +1 -1
- package/build/cover/shared.js.map +1 -1
- package/build/file/view.js +1 -1
- package/build/file/view.js.map +1 -1
- package/build/footnotes/index.js +1 -0
- package/build/footnotes/index.js.map +1 -1
- package/build/form/edit.js +138 -0
- package/build/form/edit.js.map +1 -0
- package/build/form/index.js +92 -0
- package/build/form/index.js.map +1 -0
- package/build/form/init.js +13 -0
- package/build/form/init.js.map +1 -0
- package/build/form/save.js +28 -0
- package/build/form/save.js.map +1 -0
- package/build/form/utils.js +24 -0
- package/build/form/utils.js.map +1 -0
- package/build/form/variations.js +95 -0
- package/build/form/variations.js.map +1 -0
- package/build/form/view.js +42 -0
- package/build/form/view.js.map +1 -0
- package/build/form-input/edit.js +124 -0
- package/build/form-input/edit.js.map +1 -0
- package/build/form-input/index.js +105 -0
- package/build/form-input/index.js.map +1 -0
- package/build/form-input/init.js +13 -0
- package/build/form-input/init.js.map +1 -0
- package/build/form-input/save.js +87 -0
- package/build/form-input/save.js.map +1 -0
- package/build/form-input/variations.js +93 -0
- package/build/form-input/variations.js.map +1 -0
- package/build/form-submission-notification/edit.js +59 -0
- package/build/form-submission-notification/edit.js.map +1 -0
- package/build/form-submission-notification/index.js +56 -0
- package/build/form-submission-notification/index.js.map +1 -0
- package/build/form-submission-notification/init.js +13 -0
- package/build/form-submission-notification/init.js.map +1 -0
- package/build/form-submission-notification/save.js +33 -0
- package/build/form-submission-notification/save.js.map +1 -0
- package/build/form-submission-notification/variations.js +63 -0
- package/build/form-submission-notification/variations.js.map +1 -0
- package/build/form-submit-button/edit.js +32 -0
- package/build/form-submit-button/edit.js.map +1 -0
- package/build/form-submit-button/index.js +44 -0
- package/build/form-submit-button/index.js.map +1 -0
- package/build/form-submit-button/init.js +13 -0
- package/build/form-submit-button/init.js.map +1 -0
- package/build/form-submit-button/save.js +22 -0
- package/build/form-submit-button/save.js.map +1 -0
- package/build/group/edit.js +2 -11
- package/build/group/edit.js.map +1 -1
- package/build/group/index.js +0 -1
- package/build/group/index.js.map +1 -1
- package/build/heading/index.js +3 -2
- package/build/heading/index.js.map +1 -1
- package/build/html/preview.js +2 -4
- package/build/html/preview.js.map +1 -1
- package/build/image/image.js +15 -6
- package/build/image/image.js.map +1 -1
- package/build/image/view.js +71 -39
- package/build/image/view.js.map +1 -1
- package/build/index.js +10 -0
- package/build/index.js.map +1 -1
- package/build/latest-posts/edit.js +6 -2
- package/build/latest-posts/edit.js.map +1 -1
- package/build/list-item/hooks/use-merge.js +15 -15
- package/build/list-item/hooks/use-merge.js.map +1 -1
- package/build/lock-unlock.js +1 -1
- package/build/lock-unlock.js.map +1 -1
- package/build/missing/edit.native.js +54 -64
- package/build/missing/edit.native.js.map +1 -1
- package/build/navigation/edit/index.js +0 -1
- package/build/navigation/edit/index.js.map +1 -1
- package/build/navigation/index.js +2 -1
- package/build/navigation/index.js.map +1 -1
- package/build/navigation/view.js +27 -5
- package/build/navigation/view.js.map +1 -1
- package/build/page-list-item/edit.js +3 -1
- package/build/page-list-item/edit.js.map +1 -1
- package/build/paragraph/edit.js +1 -1
- package/build/paragraph/edit.js.map +1 -1
- package/build/paragraph/index.js +7 -0
- package/build/paragraph/index.js.map +1 -1
- package/build/pattern/index.js +2 -1
- package/build/pattern/index.js.map +1 -1
- package/build/post-featured-image/dimension-controls.js +2 -2
- package/build/post-featured-image/dimension-controls.js.map +1 -1
- package/build/query/edit/enhanced-pagination-modal.js +27 -13
- package/build/query/edit/enhanced-pagination-modal.js.map +1 -1
- package/build/query/edit/inspector-controls/enhanced-pagination-control.js +15 -12
- package/build/query/edit/inspector-controls/enhanced-pagination-control.js.map +1 -1
- package/build/query/utils.js +29 -8
- package/build/query/utils.js.map +1 -1
- package/build/query/view.js +4 -2
- package/build/query/view.js.map +1 -1
- package/build/search/edit.js +1 -2
- package/build/search/edit.js.map +1 -1
- package/build/social-link/edit.native.js +7 -19
- package/build/social-link/edit.native.js.map +1 -1
- package/build/spacer/controls.js +3 -3
- package/build/spacer/controls.js.map +1 -1
- package/build/spacer/controls.native.js +2 -1
- package/build/spacer/controls.native.js.map +1 -1
- package/build/spacer/edit.js +1 -1
- package/build/spacer/edit.js.map +1 -1
- package/build/spacer/edit.native.js +5 -1
- package/build/spacer/edit.native.js.map +1 -1
- package/build/tag-cloud/edit.js +2 -1
- package/build/tag-cloud/edit.js.map +1 -1
- package/build/template-part/edit/inner-blocks.js +2 -2
- package/build/template-part/edit/inner-blocks.js.map +1 -1
- package/build/template-part/index.js +2 -1
- package/build/template-part/index.js.map +1 -1
- package/build/term-description/index.js +0 -1
- package/build/term-description/index.js.map +1 -1
- package/build-module/avatar/index.js +5 -1
- package/build-module/avatar/index.js.map +1 -1
- package/build-module/block/edit-title.native.js +12 -4
- package/build-module/block/edit-title.native.js.map +1 -1
- package/build-module/block/index.js +2 -1
- package/build-module/block/index.js.map +1 -1
- package/build-module/code/edit.native.js +8 -2
- package/build-module/code/edit.native.js.map +1 -1
- package/build-module/column/edit.js +3 -2
- package/build-module/column/edit.js.map +1 -1
- package/build-module/column/edit.native.js +3 -2
- package/build-module/column/edit.native.js.map +1 -1
- package/build-module/columns/edit.native.js +3 -2
- package/build-module/columns/edit.native.js.map +1 -1
- package/build-module/cover/controls.native.js +3 -2
- package/build-module/cover/controls.native.js.map +1 -1
- package/build-module/cover/deprecated.js +110 -1
- package/build-module/cover/deprecated.js.map +1 -1
- package/build-module/cover/edit/index.js +12 -5
- package/build-module/cover/edit/index.js.map +1 -1
- package/build-module/cover/edit/inspector-controls.js +4 -4
- package/build-module/cover/edit/inspector-controls.js.map +1 -1
- package/build-module/cover/index.js +0 -3
- package/build-module/cover/index.js.map +1 -1
- package/build-module/cover/save.js +2 -1
- package/build-module/cover/save.js.map +1 -1
- package/build-module/cover/shared.js +1 -1
- package/build-module/cover/shared.js.map +1 -1
- package/build-module/file/view.js +2 -2
- package/build-module/file/view.js.map +1 -1
- package/build-module/footnotes/index.js +1 -0
- package/build-module/footnotes/index.js.map +1 -1
- package/build-module/form/edit.js +130 -0
- package/build-module/form/edit.js.map +1 -0
- package/build-module/form/index.js +82 -0
- package/build-module/form/index.js.map +1 -0
- package/build-module/form/init.js +6 -0
- package/build-module/form/init.js.map +1 -0
- package/build-module/form/save.js +20 -0
- package/build-module/form/save.js.map +1 -0
- package/build-module/form/utils.js +15 -0
- package/build-module/form/utils.js.map +1 -0
- package/build-module/form/variations.js +86 -0
- package/build-module/form/variations.js.map +1 -0
- package/build-module/form/view.js +40 -0
- package/build-module/form/view.js.map +1 -0
- package/build-module/form-input/edit.js +115 -0
- package/build-module/form-input/edit.js.map +1 -0
- package/build-module/form-input/index.js +95 -0
- package/build-module/form-input/index.js.map +1 -0
- package/build-module/form-input/init.js +6 -0
- package/build-module/form-input/init.js.map +1 -0
- package/build-module/form-input/save.js +80 -0
- package/build-module/form-input/save.js.map +1 -0
- package/build-module/form-input/variations.js +85 -0
- package/build-module/form-input/variations.js.map +1 -0
- package/build-module/form-submission-notification/edit.js +50 -0
- package/build-module/form-submission-notification/edit.js.map +1 -0
- package/build-module/form-submission-notification/index.js +47 -0
- package/build-module/form-submission-notification/index.js.map +1 -0
- package/build-module/form-submission-notification/init.js +6 -0
- package/build-module/form-submission-notification/init.js.map +1 -0
- package/build-module/form-submission-notification/save.js +25 -0
- package/build-module/form-submission-notification/save.js.map +1 -0
- package/build-module/form-submission-notification/variations.js +55 -0
- package/build-module/form-submission-notification/variations.js.map +1 -0
- package/build-module/form-submit-button/edit.js +24 -0
- package/build-module/form-submit-button/edit.js.map +1 -0
- package/build-module/form-submit-button/index.js +34 -0
- package/build-module/form-submit-button/index.js.map +1 -0
- package/build-module/form-submit-button/init.js +6 -0
- package/build-module/form-submit-button/init.js.map +1 -0
- package/build-module/form-submit-button/save.js +14 -0
- package/build-module/form-submit-button/save.js.map +1 -0
- package/build-module/group/edit.js +3 -12
- package/build-module/group/edit.js.map +1 -1
- package/build-module/group/index.js +0 -1
- package/build-module/group/index.js.map +1 -1
- package/build-module/heading/index.js +3 -2
- package/build-module/heading/index.js.map +1 -1
- package/build-module/html/preview.js +2 -4
- package/build-module/html/preview.js.map +1 -1
- package/build-module/image/image.js +16 -7
- package/build-module/image/image.js.map +1 -1
- package/build-module/image/view.js +71 -39
- package/build-module/image/view.js.map +1 -1
- package/build-module/index.js +10 -0
- package/build-module/index.js.map +1 -1
- package/build-module/latest-posts/edit.js +6 -2
- package/build-module/latest-posts/edit.js.map +1 -1
- package/build-module/list-item/hooks/use-merge.js +15 -15
- package/build-module/list-item/hooks/use-merge.js.map +1 -1
- package/build-module/lock-unlock.js +1 -1
- package/build-module/lock-unlock.js.map +1 -1
- package/build-module/missing/edit.native.js +58 -68
- package/build-module/missing/edit.native.js.map +1 -1
- package/build-module/navigation/edit/index.js +0 -1
- package/build-module/navigation/edit/index.js.map +1 -1
- package/build-module/navigation/index.js +2 -1
- package/build-module/navigation/index.js.map +1 -1
- package/build-module/navigation/view.js +27 -5
- package/build-module/navigation/view.js.map +1 -1
- package/build-module/page-list-item/edit.js +3 -1
- package/build-module/page-list-item/edit.js.map +1 -1
- package/build-module/paragraph/edit.js +2 -2
- package/build-module/paragraph/edit.js.map +1 -1
- package/build-module/paragraph/index.js +7 -0
- package/build-module/paragraph/index.js.map +1 -1
- package/build-module/pattern/index.js +2 -1
- package/build-module/pattern/index.js.map +1 -1
- package/build-module/post-featured-image/dimension-controls.js +3 -3
- package/build-module/post-featured-image/dimension-controls.js.map +1 -1
- package/build-module/query/edit/enhanced-pagination-modal.js +28 -14
- package/build-module/query/edit/enhanced-pagination-modal.js.map +1 -1
- package/build-module/query/edit/inspector-controls/enhanced-pagination-control.js +17 -14
- package/build-module/query/edit/inspector-controls/enhanced-pagination-control.js.map +1 -1
- package/build-module/query/utils.js +27 -5
- package/build-module/query/utils.js.map +1 -1
- package/build-module/query/view.js +4 -2
- package/build-module/query/view.js.map +1 -1
- package/build-module/search/edit.js +2 -3
- package/build-module/search/edit.js.map +1 -1
- package/build-module/social-link/edit.native.js +8 -20
- package/build-module/social-link/edit.native.js.map +1 -1
- package/build-module/spacer/controls.js +4 -4
- package/build-module/spacer/controls.js.map +1 -1
- package/build-module/spacer/controls.native.js +3 -2
- package/build-module/spacer/controls.native.js.map +1 -1
- package/build-module/spacer/edit.js +2 -2
- package/build-module/spacer/edit.js.map +1 -1
- package/build-module/spacer/edit.native.js +6 -2
- package/build-module/spacer/edit.native.js.map +1 -1
- package/build-module/tag-cloud/edit.js +3 -2
- package/build-module/tag-cloud/edit.js.map +1 -1
- package/build-module/template-part/edit/inner-blocks.js +3 -3
- package/build-module/template-part/edit/inner-blocks.js.map +1 -1
- package/build-module/template-part/index.js +2 -1
- package/build-module/template-part/index.js.map +1 -1
- package/build-module/term-description/index.js +0 -1
- package/build-module/term-description/index.js.map +1 -1
- package/build-style/editor-rtl.css +50 -0
- package/build-style/editor.css +50 -0
- package/build-style/file/style-rtl.css +0 -5
- package/build-style/file/style.css +0 -5
- package/build-style/form-input/editor-rtl.css +106 -0
- package/build-style/form-input/editor.css +106 -0
- package/build-style/form-input/style-rtl.css +135 -0
- package/build-style/form-input/style.css +135 -0
- package/build-style/form-submission-notification/editor-rtl.css +118 -0
- package/build-style/form-submission-notification/editor.css +118 -0
- package/build-style/form-submit-button/style-rtl.css +91 -0
- package/build-style/form-submit-button/style.css +91 -0
- package/build-style/image/style-rtl.css +39 -5
- package/build-style/image/style.css +39 -5
- package/build-style/navigation/style-rtl.css +5 -0
- package/build-style/navigation/style.css +5 -0
- package/build-style/query/style-rtl.css +0 -10
- package/build-style/query/style.css +0 -10
- package/build-style/style-rtl.css +92 -10
- package/build-style/style.css +92 -10
- package/package.json +32 -32
- package/src/avatar/block.json +5 -1
- package/src/block/block.json +2 -1
- package/src/block/edit-title.native.js +16 -13
- package/src/calendar/index.php +2 -6
- package/src/code/edit.native.js +15 -1
- package/src/column/edit.js +3 -8
- package/src/column/edit.native.js +3 -8
- package/src/columns/edit.native.js +3 -8
- package/src/comment-author-avatar/index.php +1 -1
- package/src/cover/block.json +0 -3
- package/src/cover/controls.native.js +3 -8
- package/src/cover/deprecated.js +151 -1
- package/src/cover/edit/index.js +15 -5
- package/src/cover/edit/inspector-controls.js +22 -33
- package/src/cover/save.js +2 -1
- package/src/cover/shared.js +1 -1
- package/src/editor.scss +2 -0
- package/src/file/index.php +2 -1
- package/src/file/style.scss +0 -6
- package/src/file/view.js +2 -2
- package/src/footnotes/block.json +1 -0
- package/src/form/block.json +60 -0
- package/src/form/edit.js +179 -0
- package/src/form/index.js +20 -0
- package/src/form/index.php +214 -0
- package/src/form/init.js +6 -0
- package/src/form/save.js +20 -0
- package/src/form/utils.js +39 -0
- package/src/form/variations.js +139 -0
- package/src/form/view.js +41 -0
- package/src/form-input/block.json +73 -0
- package/src/form-input/edit.js +151 -0
- package/src/form-input/editor.scss +24 -0
- package/src/form-input/index.js +20 -0
- package/src/form-input/index.php +45 -0
- package/src/form-input/init.js +6 -0
- package/src/form-input/save.js +83 -0
- package/src/form-input/style.scss +61 -0
- package/src/form-input/variations.js +82 -0
- package/src/form-submission-notification/block.json +19 -0
- package/src/form-submission-notification/edit.js +63 -0
- package/src/form-submission-notification/editor.scss +45 -0
- package/src/form-submission-notification/index.js +26 -0
- package/src/form-submission-notification/index.php +48 -0
- package/src/form-submission-notification/init.js +6 -0
- package/src/form-submission-notification/save.js +28 -0
- package/src/form-submission-notification/variations.js +59 -0
- package/src/form-submit-button/block.json +14 -0
- package/src/form-submit-button/edit.js +33 -0
- package/src/form-submit-button/index.js +18 -0
- package/src/form-submit-button/init.js +6 -0
- package/src/form-submit-button/save.js +14 -0
- package/src/form-submit-button/style.scss +3 -0
- package/src/freeform/test/__snapshots__/index.native.js.snap +7 -0
- package/src/freeform/test/index.native.js +57 -0
- package/src/group/block.json +0 -1
- package/src/group/edit.js +2 -7
- package/src/heading/index.js +4 -2
- package/src/html/preview.js +9 -4
- package/src/image/image.js +27 -6
- package/src/image/index.php +128 -83
- package/src/image/style.scss +49 -5
- package/src/image/view.js +93 -51
- package/src/index.js +10 -0
- package/src/latest-posts/edit.js +11 -2
- package/src/latest-posts/index.php +17 -8
- package/src/list-item/hooks/use-merge.js +20 -23
- package/src/lock-unlock.js +1 -1
- package/src/missing/edit.native.js +56 -117
- package/src/missing/style.native.scss +0 -67
- package/src/missing/test/edit-integration.native.js +135 -49
- package/src/missing/test/edit.native.js +0 -41
- package/src/navigation/block.json +2 -1
- package/src/navigation/edit/index.js +0 -1
- package/src/navigation/index.php +28 -8
- package/src/navigation/style.scss +6 -1
- package/src/navigation/view.js +25 -6
- package/src/page-list-item/edit.js +2 -0
- package/src/paragraph/edit.js +2 -2
- package/src/paragraph/index.js +10 -0
- package/src/pattern/block.json +2 -1
- package/src/pattern/index.php +0 -3
- package/src/post-featured-image/dimension-controls.js +3 -3
- package/src/post-navigation-link/index.php +2 -1
- package/src/preformatted/test/edit.native.js +38 -0
- package/src/query/edit/enhanced-pagination-modal.js +37 -21
- package/src/query/edit/inspector-controls/enhanced-pagination-control.js +18 -22
- package/src/query/index.php +100 -10
- package/src/query/style.scss +0 -11
- package/src/query/utils.js +29 -8
- package/src/query/view.js +11 -2
- package/src/query-pagination-next/index.php +1 -1
- package/src/query-pagination-previous/index.php +1 -1
- package/src/search/edit.js +5 -3
- package/src/search/index.php +0 -4
- package/src/social-link/edit.native.js +12 -26
- package/src/social-link/editor.native.scss +0 -9
- package/src/social-link/index.php +2 -2
- package/src/spacer/controls.js +9 -12
- package/src/spacer/controls.native.js +3 -8
- package/src/spacer/edit.js +2 -2
- package/src/spacer/edit.native.js +6 -5
- package/src/style.scss +1 -0
- package/src/tag-cloud/edit.js +3 -7
- package/src/template-part/block.json +2 -1
- package/src/template-part/edit/inner-blocks.js +3 -3
- package/src/template-part/index.php +4 -7
- package/src/term-description/block.json +0 -1
- package/src/verse/test/edit.native.js +37 -0
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { useBlockProps, InnerBlocks } from '@wordpress/block-editor';
|
|
5
|
+
|
|
6
|
+
const Save = () => {
|
|
7
|
+
const blockProps = useBlockProps.save();
|
|
8
|
+
return (
|
|
9
|
+
<div className="wp-block-form-submit-wrapper" { ...blockProps }>
|
|
10
|
+
<InnerBlocks.Content />
|
|
11
|
+
</div>
|
|
12
|
+
);
|
|
13
|
+
};
|
|
14
|
+
export default Save;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* External dependencies
|
|
3
|
+
*/
|
|
4
|
+
import {
|
|
5
|
+
fireEvent,
|
|
6
|
+
getBlock,
|
|
7
|
+
getEditorHtml,
|
|
8
|
+
initializeEditor,
|
|
9
|
+
screen,
|
|
10
|
+
setupCoreBlocks,
|
|
11
|
+
within,
|
|
12
|
+
} from 'test/helpers';
|
|
13
|
+
|
|
14
|
+
const CLASSIC_BLOCK_HTML = `<p>I'm classic!</p>`;
|
|
15
|
+
const DEFAULT_EDITOR_CAPABILITIES = {
|
|
16
|
+
unsupportedBlockEditor: true,
|
|
17
|
+
canEnableUnsupportedBlockEditor: true,
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
setupCoreBlocks();
|
|
21
|
+
|
|
22
|
+
describe( 'Classic block', () => {
|
|
23
|
+
it( 'displays option to edit using web editor', async () => {
|
|
24
|
+
await initializeEditor( {
|
|
25
|
+
initialHtml: CLASSIC_BLOCK_HTML,
|
|
26
|
+
capabilities: DEFAULT_EDITOR_CAPABILITIES,
|
|
27
|
+
} );
|
|
28
|
+
|
|
29
|
+
const block = getBlock( screen, 'Classic' );
|
|
30
|
+
fireEvent.press( block );
|
|
31
|
+
|
|
32
|
+
// Tap the block to open the unsupported block details
|
|
33
|
+
fireEvent.press( within( block ).getByText( 'Unsupported' ) );
|
|
34
|
+
|
|
35
|
+
const actionButton = screen.getByText( 'Edit using web editor' );
|
|
36
|
+
expect( actionButton ).toBeVisible();
|
|
37
|
+
} );
|
|
38
|
+
|
|
39
|
+
it( 'converts content into blocks', async () => {
|
|
40
|
+
await initializeEditor( {
|
|
41
|
+
initialHtml: CLASSIC_BLOCK_HTML,
|
|
42
|
+
capabilities: DEFAULT_EDITOR_CAPABILITIES,
|
|
43
|
+
} );
|
|
44
|
+
|
|
45
|
+
const block = getBlock( screen, 'Classic' );
|
|
46
|
+
fireEvent.press( block );
|
|
47
|
+
|
|
48
|
+
// Tap the block to open the unsupported block details
|
|
49
|
+
fireEvent.press( within( block ).getByText( 'Unsupported' ) );
|
|
50
|
+
|
|
51
|
+
const actionButton = screen.getByText( 'Convert to blocks' );
|
|
52
|
+
expect( actionButton ).toBeVisible();
|
|
53
|
+
|
|
54
|
+
fireEvent.press( actionButton );
|
|
55
|
+
expect( getEditorHtml() ).toMatchSnapshot();
|
|
56
|
+
} );
|
|
57
|
+
} );
|
package/src/group/block.json
CHANGED
package/src/group/edit.js
CHANGED
|
@@ -7,7 +7,6 @@ import {
|
|
|
7
7
|
useBlockProps,
|
|
8
8
|
InspectorControls,
|
|
9
9
|
useInnerBlocksProps,
|
|
10
|
-
useSetting,
|
|
11
10
|
store as blockEditorStore,
|
|
12
11
|
} from '@wordpress/block-editor';
|
|
13
12
|
import { SelectControl } from '@wordpress/components';
|
|
@@ -98,11 +97,7 @@ function GroupEdit( {
|
|
|
98
97
|
} = attributes;
|
|
99
98
|
|
|
100
99
|
// Layout settings.
|
|
101
|
-
const
|
|
102
|
-
const usedLayout = ! layout?.type
|
|
103
|
-
? { ...defaultLayout, ...layout, type: 'default' }
|
|
104
|
-
: { ...defaultLayout, ...layout };
|
|
105
|
-
const { type = 'default' } = usedLayout;
|
|
100
|
+
const { type = 'default' } = layout;
|
|
106
101
|
const layoutSupportEnabled =
|
|
107
102
|
themeSupportsLayout || type === 'flex' || type === 'grid';
|
|
108
103
|
|
|
@@ -112,7 +107,7 @@ function GroupEdit( {
|
|
|
112
107
|
} );
|
|
113
108
|
const [ showPlaceholder, setShowPlaceholder ] = useShouldShowPlaceHolder( {
|
|
114
109
|
attributes,
|
|
115
|
-
usedLayoutType:
|
|
110
|
+
usedLayoutType: type,
|
|
116
111
|
hasInnerBlocks,
|
|
117
112
|
} );
|
|
118
113
|
|
package/src/heading/index.js
CHANGED
|
@@ -29,10 +29,12 @@ export const settings = {
|
|
|
29
29
|
__experimentalLabel( attributes, { context } ) {
|
|
30
30
|
const { content, level } = attributes;
|
|
31
31
|
|
|
32
|
+
const customName = attributes?.metadata?.name;
|
|
33
|
+
|
|
32
34
|
// In the list view, use the block's content as the label.
|
|
33
35
|
// If the content is empty, fall back to the default label.
|
|
34
|
-
if ( context === 'list-view' && content ) {
|
|
35
|
-
return content;
|
|
36
|
+
if ( context === 'list-view' && ( customName || content ) ) {
|
|
37
|
+
return attributes?.metadata?.name || content;
|
|
36
38
|
}
|
|
37
39
|
|
|
38
40
|
if ( context === 'accessibility' ) {
|
package/src/html/preview.js
CHANGED
|
@@ -22,12 +22,17 @@ const DEFAULT_STYLES = `
|
|
|
22
22
|
`;
|
|
23
23
|
|
|
24
24
|
export default function HTMLEditPreview( { content, isSelected } ) {
|
|
25
|
-
const settingStyles = useSelect(
|
|
26
|
-
|
|
27
|
-
|
|
25
|
+
const settingStyles = useSelect(
|
|
26
|
+
( select ) => select( blockEditorStore ).getSettings().styles
|
|
27
|
+
);
|
|
28
28
|
|
|
29
29
|
const styles = useMemo(
|
|
30
|
-
() => [
|
|
30
|
+
() => [
|
|
31
|
+
DEFAULT_STYLES,
|
|
32
|
+
...transformStyles(
|
|
33
|
+
settingStyles.filter( ( style ) => style.css )
|
|
34
|
+
),
|
|
35
|
+
],
|
|
31
36
|
[ settingStyles ]
|
|
32
37
|
);
|
|
33
38
|
|
package/src/image/image.js
CHANGED
|
@@ -24,7 +24,7 @@ import {
|
|
|
24
24
|
__experimentalImageURLInputUI as ImageURLInputUI,
|
|
25
25
|
MediaReplaceFlow,
|
|
26
26
|
store as blockEditorStore,
|
|
27
|
-
|
|
27
|
+
useSettings,
|
|
28
28
|
BlockAlignmentControl,
|
|
29
29
|
__experimentalImageEditor as ImageEditor,
|
|
30
30
|
__experimentalGetElementClassName,
|
|
@@ -83,6 +83,11 @@ const scaleOptions = [
|
|
|
83
83
|
},
|
|
84
84
|
];
|
|
85
85
|
|
|
86
|
+
const disabledClickProps = {
|
|
87
|
+
onClick: ( event ) => event.preventDefault(),
|
|
88
|
+
'aria-disabled': true,
|
|
89
|
+
};
|
|
90
|
+
|
|
86
91
|
export default function Image( {
|
|
87
92
|
temporaryURL,
|
|
88
93
|
attributes,
|
|
@@ -369,7 +374,7 @@ export default function Image( {
|
|
|
369
374
|
availableUnits: [ 'px' ],
|
|
370
375
|
} );
|
|
371
376
|
|
|
372
|
-
const lightboxSetting =
|
|
377
|
+
const [ lightboxSetting ] = useSettings( 'lightbox' );
|
|
373
378
|
|
|
374
379
|
const showLightboxToggle =
|
|
375
380
|
!! lightbox || lightboxSetting?.allowEditing === true;
|
|
@@ -377,6 +382,8 @@ export default function Image( {
|
|
|
377
382
|
const lightboxChecked =
|
|
378
383
|
!! lightbox?.enabled || ( ! lightbox && !! lightboxSetting?.enabled );
|
|
379
384
|
|
|
385
|
+
const lightboxToggleDisabled = linkDestination !== 'none';
|
|
386
|
+
|
|
380
387
|
const dimensionsControl = (
|
|
381
388
|
<DimensionsTool
|
|
382
389
|
value={ { width, height, scale, aspectRatio } }
|
|
@@ -541,20 +548,28 @@ export default function Image( {
|
|
|
541
548
|
{ showLightboxToggle && (
|
|
542
549
|
<ToolsPanelItem
|
|
543
550
|
hasValue={ () => !! lightbox }
|
|
544
|
-
label={ __( 'Expand on
|
|
551
|
+
label={ __( 'Expand on click' ) }
|
|
545
552
|
onDeselect={ () => {
|
|
546
553
|
setAttributes( { lightbox: undefined } );
|
|
547
554
|
} }
|
|
548
555
|
isShownByDefault={ true }
|
|
549
556
|
>
|
|
550
557
|
<ToggleControl
|
|
551
|
-
label={ __( 'Expand on
|
|
558
|
+
label={ __( 'Expand on click' ) }
|
|
552
559
|
checked={ lightboxChecked }
|
|
553
560
|
onChange={ ( newValue ) => {
|
|
554
561
|
setAttributes( {
|
|
555
562
|
lightbox: { enabled: newValue },
|
|
556
563
|
} );
|
|
557
564
|
} }
|
|
565
|
+
disabled={ lightboxToggleDisabled }
|
|
566
|
+
help={
|
|
567
|
+
lightboxToggleDisabled
|
|
568
|
+
? __(
|
|
569
|
+
'“Expand on click” scales the image up, and can’t be combined with a link.'
|
|
570
|
+
)
|
|
571
|
+
: ''
|
|
572
|
+
}
|
|
558
573
|
/>
|
|
559
574
|
</ToolsPanelItem>
|
|
560
575
|
) }
|
|
@@ -715,7 +730,6 @@ export default function Image( {
|
|
|
715
730
|
}
|
|
716
731
|
}
|
|
717
732
|
/* eslint-enable no-lonely-if */
|
|
718
|
-
|
|
719
733
|
img = (
|
|
720
734
|
<ResizableBox
|
|
721
735
|
style={ {
|
|
@@ -774,7 +788,14 @@ export default function Image( {
|
|
|
774
788
|
{ /* Hide controls during upload to avoid component remount,
|
|
775
789
|
which causes duplicated image upload. */ }
|
|
776
790
|
{ ! temporaryURL && controls }
|
|
777
|
-
{
|
|
791
|
+
{ /* If the image has a href, wrap in an <a /> tag to trigger any inherited link element styles */ }
|
|
792
|
+
{ !! href ? (
|
|
793
|
+
<a href={ href } { ...disabledClickProps }>
|
|
794
|
+
{ img }
|
|
795
|
+
</a>
|
|
796
|
+
) : (
|
|
797
|
+
img
|
|
798
|
+
) }
|
|
778
799
|
{ showCaption &&
|
|
779
800
|
( ! RichText.isEmpty( caption ) || isSelected ) && (
|
|
780
801
|
<RichText
|
package/src/image/index.php
CHANGED
|
@@ -9,17 +9,20 @@
|
|
|
9
9
|
* Renders the `core/image` block on the server,
|
|
10
10
|
* adding a data-id attribute to the element if core/gallery has added on pre-render.
|
|
11
11
|
*
|
|
12
|
-
* @param
|
|
13
|
-
* @param
|
|
14
|
-
* @param
|
|
15
|
-
*
|
|
12
|
+
* @param array $attributes The block attributes.
|
|
13
|
+
* @param string $content The block content.
|
|
14
|
+
* @param WP_Block $block The block object.
|
|
15
|
+
*
|
|
16
|
+
* @return string The block content with the data-id attribute added.
|
|
16
17
|
*/
|
|
17
18
|
function render_block_core_image( $attributes, $content, $block ) {
|
|
19
|
+
if ( false === stripos( $content, '<img' ) ) {
|
|
20
|
+
return '';
|
|
21
|
+
}
|
|
18
22
|
|
|
19
23
|
$processor = new WP_HTML_Tag_Processor( $content );
|
|
20
|
-
$processor->next_tag( 'img' );
|
|
21
24
|
|
|
22
|
-
if ( $processor->
|
|
25
|
+
if ( ! $processor->next_tag( 'img' ) || null === $processor->get_attribute( 'src' ) ) {
|
|
23
26
|
return '';
|
|
24
27
|
}
|
|
25
28
|
|
|
@@ -31,57 +34,60 @@ function render_block_core_image( $attributes, $content, $block ) {
|
|
|
31
34
|
$processor->set_attribute( 'data-id', $attributes['data-id'] );
|
|
32
35
|
}
|
|
33
36
|
|
|
34
|
-
$lightbox_enabled = false;
|
|
35
37
|
$link_destination = isset( $attributes['linkDestination'] ) ? $attributes['linkDestination'] : 'none';
|
|
36
38
|
$lightbox_settings = block_core_image_get_lightbox_settings( $block->parsed_block );
|
|
37
39
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
+
$view_js_file_handle = 'wp-block-image-view';
|
|
41
|
+
$script_handles = $block->block_type->view_script_handles;
|
|
40
42
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
43
|
+
/*
|
|
44
|
+
* If the lightbox is enabled and the image is not linked, add the filter
|
|
45
|
+
* and the JavaScript view file.
|
|
46
|
+
*/
|
|
47
|
+
if (
|
|
48
|
+
isset( $lightbox_settings ) &&
|
|
49
|
+
'none' === $link_destination &&
|
|
50
|
+
isset( $lightbox_settings['enabled'] ) &&
|
|
51
|
+
true === $lightbox_settings['enabled']
|
|
52
|
+
) {
|
|
48
53
|
$block->block_type->supports['interactivity'] = true;
|
|
49
|
-
}
|
|
50
54
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
if ( ! wp_script_is( $view_js_file ) ) {
|
|
54
|
-
$script_handles = $block->block_type->view_script_handles;
|
|
55
|
-
|
|
56
|
-
// If the script is not needed, and it is still in the `view_script_handles`, remove it.
|
|
57
|
-
if ( ! $lightbox_enabled && in_array( $view_js_file, $script_handles, true ) ) {
|
|
58
|
-
$block->block_type->view_script_handles = array_diff( $script_handles, array( $view_js_file ) );
|
|
55
|
+
if ( ! in_array( $view_js_file_handle, $script_handles, true ) ) {
|
|
56
|
+
$block->block_type->view_script_handles = array_merge( $script_handles, array( $view_js_file_handle ) );
|
|
59
57
|
}
|
|
60
|
-
// If the script is needed, but it was previously removed, add it again.
|
|
61
|
-
if ( $lightbox_enabled && ! in_array( $view_js_file, $script_handles, true ) ) {
|
|
62
|
-
$block->block_type->view_script_handles = array_merge( $script_handles, array( $view_js_file ) );
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
58
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
59
|
+
/*
|
|
60
|
+
* This render needs to happen in a filter with priority 15 to ensure
|
|
61
|
+
* that it runs after the duotone filter and that duotone styles are
|
|
62
|
+
* applied to the image in the lightbox. We also need to ensure that the
|
|
63
|
+
* lightbox works with any plugins that might use filters as well. We
|
|
64
|
+
* can consider removing this in the future if the way the blocks are
|
|
65
|
+
* rendered changes, or if a new kind of filter is introduced.
|
|
66
|
+
*/
|
|
72
67
|
add_filter( 'render_block_core/image', 'block_core_image_render_lightbox', 15, 2 );
|
|
68
|
+
} else {
|
|
69
|
+
/*
|
|
70
|
+
* Remove the filter and the JavaScript view file if previously added by
|
|
71
|
+
* other Image blocks.
|
|
72
|
+
*/
|
|
73
|
+
remove_filter( 'render_block_core/image', 'block_core_image_render_lightbox', 15 );
|
|
74
|
+
// If the script is not needed, and it is still in the `view_script_handles`, remove it.
|
|
75
|
+
if ( in_array( $view_js_file_handle, $script_handles, true ) ) {
|
|
76
|
+
$block->block_type->view_script_handles = array_diff( $script_handles, array( $view_js_file_handle ) );
|
|
77
|
+
}
|
|
73
78
|
}
|
|
74
79
|
|
|
75
80
|
return $processor->get_updated_html();
|
|
76
81
|
}
|
|
77
82
|
|
|
78
83
|
/**
|
|
79
|
-
*
|
|
84
|
+
* Adds the lightboxEnabled flag to the block data.
|
|
80
85
|
*
|
|
81
86
|
* This is used to determine whether the lightbox should be rendered or not.
|
|
82
87
|
*
|
|
83
|
-
* @param
|
|
84
|
-
*
|
|
88
|
+
* @param array $block Block data.
|
|
89
|
+
*
|
|
90
|
+
* @return array Filtered block data.
|
|
85
91
|
*/
|
|
86
92
|
function block_core_image_get_lightbox_settings( $block ) {
|
|
87
93
|
// Get the lightbox setting from the block attributes.
|
|
@@ -113,43 +119,61 @@ function block_core_image_get_lightbox_settings( $block ) {
|
|
|
113
119
|
}
|
|
114
120
|
|
|
115
121
|
/**
|
|
116
|
-
*
|
|
122
|
+
* Adds the directives and layout needed for the lightbox behavior.
|
|
123
|
+
*
|
|
124
|
+
* @param string $block_content Rendered block content.
|
|
125
|
+
* @param array $block Block object.
|
|
117
126
|
*
|
|
118
|
-
* @
|
|
119
|
-
* @param array $block Block object.
|
|
120
|
-
* @return string Filtered block content.
|
|
127
|
+
* @return string Filtered block content.
|
|
121
128
|
*/
|
|
122
129
|
function block_core_image_render_lightbox( $block_content, $block ) {
|
|
130
|
+
/*
|
|
131
|
+
* If it's not possible that an IMG element exists then return the given
|
|
132
|
+
* block content as-is. It may be that there's no actual image in the block
|
|
133
|
+
* or it could be that another plugin already modified this HTML.
|
|
134
|
+
*/
|
|
135
|
+
if ( false === stripos( $block_content, '<img' ) ) {
|
|
136
|
+
return $block_content;
|
|
137
|
+
}
|
|
138
|
+
|
|
123
139
|
$processor = new WP_HTML_Tag_Processor( $block_content );
|
|
124
140
|
|
|
125
141
|
$aria_label = __( 'Enlarge image' );
|
|
126
142
|
|
|
143
|
+
/*
|
|
144
|
+
* If there's definitely no IMG element in the block then return the given
|
|
145
|
+
* block content as-is. There's nothing that this code can knowingly modify
|
|
146
|
+
* to add the lightbox behavior.
|
|
147
|
+
*/
|
|
148
|
+
if ( ! $processor->next_tag( 'img' ) ) {
|
|
149
|
+
return $block_content;
|
|
150
|
+
}
|
|
151
|
+
|
|
127
152
|
$alt_attribute = $processor->get_attribute( 'alt' );
|
|
128
153
|
|
|
129
|
-
|
|
154
|
+
// An empty alt attribute `alt=""` is valid for decorative images.
|
|
155
|
+
if ( is_string( $alt_attribute ) ) {
|
|
130
156
|
$alt_attribute = trim( $alt_attribute );
|
|
131
157
|
}
|
|
132
158
|
|
|
159
|
+
// It only makes sense to append the alt text to the button aria-label when the alt text is non-empty.
|
|
133
160
|
if ( $alt_attribute ) {
|
|
134
161
|
/* translators: %s: Image alt text. */
|
|
135
162
|
$aria_label = sprintf( __( 'Enlarge image: %s' ), $alt_attribute );
|
|
136
163
|
}
|
|
137
|
-
$content = $processor->get_updated_html();
|
|
138
164
|
|
|
139
165
|
// Currently, we are only enabling the zoom animation.
|
|
140
166
|
$lightbox_animation = 'zoom';
|
|
141
167
|
|
|
142
|
-
// We want to store the src in the context so we
|
|
143
|
-
|
|
144
|
-
$z->next_tag( 'img' );
|
|
145
|
-
|
|
168
|
+
// Note: We want to store the `src` in the context so we
|
|
169
|
+
// can set it dynamically when the lightbox is opened.
|
|
146
170
|
if ( isset( $block['attrs']['id'] ) ) {
|
|
147
171
|
$img_uploaded_src = wp_get_attachment_url( $block['attrs']['id'] );
|
|
148
172
|
$img_metadata = wp_get_attachment_metadata( $block['attrs']['id'] );
|
|
149
|
-
$img_width = $img_metadata['width'];
|
|
150
|
-
$img_height = $img_metadata['height'];
|
|
173
|
+
$img_width = $img_metadata['width'] ?? 'none';
|
|
174
|
+
$img_height = $img_metadata['height'] ?? 'none';
|
|
151
175
|
} else {
|
|
152
|
-
$img_uploaded_src = $
|
|
176
|
+
$img_uploaded_src = $processor->get_attribute( 'src' );
|
|
153
177
|
$img_width = 'none';
|
|
154
178
|
$img_height = 'none';
|
|
155
179
|
}
|
|
@@ -160,7 +184,7 @@ function block_core_image_render_lightbox( $block_content, $block ) {
|
|
|
160
184
|
$scale_attr = false;
|
|
161
185
|
}
|
|
162
186
|
|
|
163
|
-
$w = new WP_HTML_Tag_Processor( $
|
|
187
|
+
$w = new WP_HTML_Tag_Processor( $block_content );
|
|
164
188
|
$w->next_tag( 'figure' );
|
|
165
189
|
$w->add_class( 'wp-lightbox-container' );
|
|
166
190
|
$w->set_attribute( 'data-wp-interactive', true );
|
|
@@ -180,7 +204,8 @@ function block_core_image_render_lightbox( $block_content, $block ) {
|
|
|
180
204
|
"imageCurrentSrc": "",
|
|
181
205
|
"targetWidth": "%s",
|
|
182
206
|
"targetHeight": "%s",
|
|
183
|
-
"scaleAttr": "%s"
|
|
207
|
+
"scaleAttr": "%s",
|
|
208
|
+
"dialogLabel": "%s"
|
|
184
209
|
}
|
|
185
210
|
}
|
|
186
211
|
}',
|
|
@@ -188,31 +213,42 @@ function block_core_image_render_lightbox( $block_content, $block ) {
|
|
|
188
213
|
$img_uploaded_src,
|
|
189
214
|
$img_width,
|
|
190
215
|
$img_height,
|
|
191
|
-
$scale_attr
|
|
216
|
+
$scale_attr,
|
|
217
|
+
__( 'Enlarged image' )
|
|
192
218
|
)
|
|
193
219
|
);
|
|
194
220
|
$w->next_tag( 'img' );
|
|
195
|
-
$w->set_attribute( 'data-wp-init', 'effects.core.image.
|
|
221
|
+
$w->set_attribute( 'data-wp-init', 'effects.core.image.initOriginImage' );
|
|
196
222
|
$w->set_attribute( 'data-wp-on--load', 'actions.core.image.handleLoad' );
|
|
197
223
|
$w->set_attribute( 'data-wp-effect', 'effects.core.image.setButtonStyles' );
|
|
224
|
+
// We need to set an event callback on the `img` specifically
|
|
225
|
+
// because the `figure` element can also contain a caption, and
|
|
226
|
+
// we don't want to trigger the lightbox when the caption is clicked.
|
|
227
|
+
$w->set_attribute( 'data-wp-on--click', 'actions.core.image.showLightbox' );
|
|
228
|
+
$w->set_attribute( 'data-wp-effect--setStylesOnResize', 'effects.core.image.setStylesOnResize' );
|
|
198
229
|
$body_content = $w->get_updated_html();
|
|
199
230
|
|
|
200
|
-
//
|
|
231
|
+
// Add a button alongside image in the body content.
|
|
201
232
|
$img = null;
|
|
202
233
|
preg_match( '/<img[^>]+>/', $body_content, $img );
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
234
|
+
|
|
235
|
+
$button =
|
|
236
|
+
$img[0]
|
|
237
|
+
. '<button
|
|
238
|
+
class="lightbox-trigger"
|
|
239
|
+
type="button"
|
|
240
|
+
aria-haspopup="dialog"
|
|
241
|
+
aria-label="' . esc_attr( $aria_label ) . '"
|
|
242
|
+
data-wp-on--click="actions.core.image.showLightbox"
|
|
243
|
+
data-wp-style--right="context.core.image.imageButtonRight"
|
|
244
|
+
data-wp-style--top="context.core.image.imageButtonTop"
|
|
245
|
+
style="background: #000"
|
|
246
|
+
>
|
|
247
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" aria-hidden="true" focusable="false">
|
|
248
|
+
<Path stroke="#FFFFFF" d="M6 4a2 2 0 0 0-2 2v3h1.5V6a.5.5 0 0 1 .5-.5h3V4H6Zm3 14.5H6a.5.5 0 0 1-.5-.5v-3H4v3a2 2 0 0 0 2 2h3v-1.5Zm6 1.5v-1.5h3a.5.5 0 0 0 .5-.5v-3H20v3a2 2 0 0 1-2 2h-3Zm3-16a2 2 0 0 1 2 2v3h-1.5V6a.5.5 0 0 0-.5-.5h-3V4h3Z" />
|
|
249
|
+
</svg>
|
|
250
|
+
</button>';
|
|
251
|
+
|
|
216
252
|
$body_content = preg_replace( '/<img[^>]+>/', $button, $body_content );
|
|
217
253
|
|
|
218
254
|
// We need both a responsive image and an enlarged image to animate
|
|
@@ -220,7 +256,7 @@ function block_core_image_render_lightbox( $block_content, $block ) {
|
|
|
220
256
|
// image is a copy of the one in the body, which animates immediately
|
|
221
257
|
// as the lightbox is opened, while the enlarged one is a full-sized
|
|
222
258
|
// version that will likely still be loading as the animation begins.
|
|
223
|
-
$m = new WP_HTML_Tag_Processor( $
|
|
259
|
+
$m = new WP_HTML_Tag_Processor( $block_content );
|
|
224
260
|
$m->next_tag( 'figure' );
|
|
225
261
|
$m->add_class( 'responsive-image' );
|
|
226
262
|
$m->next_tag( 'img' );
|
|
@@ -236,7 +272,7 @@ function block_core_image_render_lightbox( $block_content, $block ) {
|
|
|
236
272
|
$m->set_attribute( 'data-wp-style--object-fit', 'selectors.core.image.lightboxObjectFit' );
|
|
237
273
|
$initial_image_content = $m->get_updated_html();
|
|
238
274
|
|
|
239
|
-
$q = new WP_HTML_Tag_Processor( $
|
|
275
|
+
$q = new WP_HTML_Tag_Processor( $block_content );
|
|
240
276
|
$q->next_tag( 'figure' );
|
|
241
277
|
$q->add_class( 'enlarged-image' );
|
|
242
278
|
$q->next_tag( 'img' );
|
|
@@ -252,37 +288,46 @@ function block_core_image_render_lightbox( $block_content, $block ) {
|
|
|
252
288
|
$q->set_attribute( 'data-wp-style--object-fit', 'selectors.core.image.lightboxObjectFit' );
|
|
253
289
|
$enlarged_image_content = $q->get_updated_html();
|
|
254
290
|
|
|
255
|
-
|
|
291
|
+
// If the current theme does NOT have a `theme.json`, or the colors are not defined,
|
|
292
|
+
// we need to set the background color & close button color to some default values
|
|
293
|
+
// because we can't get them from the Global Styles.
|
|
294
|
+
$background_color = '#fff';
|
|
295
|
+
$close_button_color = '#000';
|
|
296
|
+
if ( wp_theme_has_theme_json() ) {
|
|
297
|
+
$global_styles_color = wp_get_global_styles( array( 'color' ) );
|
|
298
|
+
if ( ! empty( $global_styles_color['background'] ) ) {
|
|
299
|
+
$background_color = esc_attr( $global_styles_color['background'] );
|
|
300
|
+
}
|
|
301
|
+
if ( ! empty( $global_styles_color['text'] ) ) {
|
|
302
|
+
$close_button_color = esc_attr( $global_styles_color['text'] );
|
|
303
|
+
}
|
|
304
|
+
}
|
|
256
305
|
|
|
257
306
|
$close_button_icon = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="15" height="15" aria-hidden="true" focusable="false"><path d="M13 11.8l6.1-6.3-1-1-6.1 6.2-6.1-6.2-1 1 6.1 6.3-6.5 6.7 1 1 6.5-6.6 6.5 6.6 1-1z"></path></svg>';
|
|
258
|
-
$close_button_color = esc_attr( wp_get_global_styles( array( 'color', 'text' ) ) );
|
|
259
|
-
$dialog_label = $alt_attribute ? esc_attr( $alt_attribute ) : esc_attr__( 'Image' );
|
|
260
307
|
$close_button_label = esc_attr__( 'Close' );
|
|
261
308
|
|
|
262
309
|
$lightbox_html = <<<HTML
|
|
263
310
|
<div data-wp-body="" class="wp-lightbox-overlay $lightbox_animation"
|
|
264
311
|
data-wp-bind--role="selectors.core.image.roleAttribute"
|
|
265
|
-
aria-label="
|
|
312
|
+
data-wp-bind--aria-label="selectors.core.image.dialogLabel"
|
|
266
313
|
data-wp-class--initialized="context.core.image.initialized"
|
|
267
314
|
data-wp-class--active="context.core.image.lightboxEnabled"
|
|
268
315
|
data-wp-class--hideAnimationEnabled="context.core.image.hideAnimationEnabled"
|
|
269
|
-
data-wp-bind--aria-
|
|
270
|
-
aria-hidden="true"
|
|
271
|
-
data-wp-bind--aria-modal="context.core.image.lightboxEnabled"
|
|
272
|
-
aria-modal="false"
|
|
316
|
+
data-wp-bind--aria-modal="selectors.core.image.ariaModal"
|
|
273
317
|
data-wp-effect="effects.core.image.initLightbox"
|
|
274
318
|
data-wp-on--keydown="actions.core.image.handleKeydown"
|
|
275
319
|
data-wp-on--touchstart="actions.core.image.handleTouchStart"
|
|
276
320
|
data-wp-on--touchmove="actions.core.image.handleTouchMove"
|
|
277
321
|
data-wp-on--touchend="actions.core.image.handleTouchEnd"
|
|
278
322
|
data-wp-on--click="actions.core.image.hideLightbox"
|
|
323
|
+
tabindex="-1"
|
|
279
324
|
>
|
|
280
325
|
<button type="button" aria-label="$close_button_label" style="fill: $close_button_color" class="close-button" data-wp-on--click="actions.core.image.hideLightbox">
|
|
281
326
|
$close_button_icon
|
|
282
327
|
</button>
|
|
283
328
|
<div class="lightbox-image-container">$initial_image_content</div>
|
|
284
|
-
|
|
285
|
-
<div class="scrim" style="background-color: $background_color"></div>
|
|
329
|
+
<div class="lightbox-image-container">$enlarged_image_content</div>
|
|
330
|
+
<div class="scrim" style="background-color: $background_color" aria-hidden="true"></div>
|
|
286
331
|
</div>
|
|
287
332
|
HTML;
|
|
288
333
|
|
|
@@ -290,7 +335,7 @@ HTML;
|
|
|
290
335
|
}
|
|
291
336
|
|
|
292
337
|
/**
|
|
293
|
-
*
|
|
338
|
+
* Ensures that the view script has the `wp-interactivity` dependency.
|
|
294
339
|
*
|
|
295
340
|
* @since 6.4.0
|
|
296
341
|
*
|