@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
|
@@ -11,21 +11,20 @@ import {
|
|
|
11
11
|
/**
|
|
12
12
|
* WordPress dependencies
|
|
13
13
|
*/
|
|
14
|
-
import {
|
|
15
|
-
requestUnsupportedBlockFallback,
|
|
16
|
-
sendActionButtonPressedAction,
|
|
17
|
-
actionButtons,
|
|
18
|
-
} from '@wordpress/react-native-bridge';
|
|
19
|
-
import { BottomSheet, Icon, TextControl } from '@wordpress/components';
|
|
14
|
+
import { Icon } from '@wordpress/components';
|
|
20
15
|
import { compose, withPreferredColorScheme } from '@wordpress/compose';
|
|
21
16
|
import { coreBlocks } from '@wordpress/block-library';
|
|
22
|
-
import { normalizeIconObject } from '@wordpress/blocks';
|
|
17
|
+
import { normalizeIconObject, rawHandler, serialize } from '@wordpress/blocks';
|
|
23
18
|
import { Component } from '@wordpress/element';
|
|
24
19
|
import { __, _x, sprintf } from '@wordpress/i18n';
|
|
25
20
|
import { help, plugins } from '@wordpress/icons';
|
|
26
21
|
import { withSelect, withDispatch } from '@wordpress/data';
|
|
27
22
|
import { applyFilters } from '@wordpress/hooks';
|
|
28
|
-
import {
|
|
23
|
+
import {
|
|
24
|
+
UnsupportedBlockDetails,
|
|
25
|
+
store as blockEditorStore,
|
|
26
|
+
} from '@wordpress/block-editor';
|
|
27
|
+
import { store as noticesStore } from '@wordpress/notices';
|
|
29
28
|
|
|
30
29
|
/**
|
|
31
30
|
* Internal dependencies
|
|
@@ -36,6 +35,8 @@ import styles from './style.scss';
|
|
|
36
35
|
const UBE_INCOMPATIBLE_BLOCKS = [ 'core/block' ];
|
|
37
36
|
const I18N_BLOCK_SCHEMA_TITLE = 'block title';
|
|
38
37
|
|
|
38
|
+
const EMPTY_ARRAY = [];
|
|
39
|
+
|
|
39
40
|
export class UnsupportedBlockEdit extends Component {
|
|
40
41
|
constructor( props ) {
|
|
41
42
|
super( props );
|
|
@@ -121,122 +122,50 @@ export class UnsupportedBlockEdit extends Component {
|
|
|
121
122
|
}
|
|
122
123
|
|
|
123
124
|
renderSheet( blockTitle, blockName ) {
|
|
124
|
-
const {
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
clientId,
|
|
128
|
-
isUnsupportedBlockEditorSupported,
|
|
129
|
-
canEnableUnsupportedBlockEditor,
|
|
130
|
-
isEditableInUnsupportedBlockEditor,
|
|
131
|
-
} = this.props;
|
|
132
|
-
const infoTextStyle = getStylesFromColorScheme(
|
|
133
|
-
styles.infoText,
|
|
134
|
-
styles.infoTextDark
|
|
135
|
-
);
|
|
136
|
-
const infoTitleStyle = getStylesFromColorScheme(
|
|
137
|
-
styles.infoTitle,
|
|
138
|
-
styles.infoTitleDark
|
|
139
|
-
);
|
|
140
|
-
const infoDescriptionStyle = getStylesFromColorScheme(
|
|
141
|
-
styles.infoDescription,
|
|
142
|
-
styles.infoDescriptionDark
|
|
143
|
-
);
|
|
144
|
-
const infoSheetIconStyle = getStylesFromColorScheme(
|
|
145
|
-
styles.infoSheetIcon,
|
|
146
|
-
styles.infoSheetIconDark
|
|
147
|
-
);
|
|
125
|
+
const { block, clientId, createSuccessNotice, replaceBlocks } =
|
|
126
|
+
this.props;
|
|
127
|
+
const { showHelp } = this.state;
|
|
148
128
|
|
|
149
129
|
/* translators: Missing block alert title. %s: The localized block name */
|
|
150
130
|
const titleFormat = __( "'%s' is not fully-supported" );
|
|
151
|
-
const
|
|
152
|
-
|
|
131
|
+
const title = sprintf( titleFormat, blockTitle );
|
|
132
|
+
let description = applyFilters(
|
|
153
133
|
'native.missing_block_detail',
|
|
154
134
|
__( 'We are working hard to add more blocks with each release.' ),
|
|
155
135
|
blockName
|
|
156
136
|
);
|
|
157
|
-
|
|
158
|
-
'native.missing_block_action_button',
|
|
159
|
-
__( 'Edit using web editor' )
|
|
160
|
-
);
|
|
137
|
+
let customActions = EMPTY_ARRAY;
|
|
161
138
|
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
139
|
+
// For Classic blocks, we offer the alternative to convert the content to blocks.
|
|
140
|
+
if ( blockName === 'core/freeform' ) {
|
|
141
|
+
description +=
|
|
142
|
+
' ' +
|
|
143
|
+
__( 'Alternatively, you can convert the content to blocks.' );
|
|
144
|
+
/* translators: displayed right after the classic block is converted to blocks. %s: The localized classic block name */
|
|
145
|
+
const successNotice = __( "'%s' block converted to blocks" );
|
|
146
|
+
customActions = [
|
|
147
|
+
{
|
|
148
|
+
label: __( 'Convert to blocks' ),
|
|
149
|
+
onPress: () => {
|
|
150
|
+
createSuccessNotice(
|
|
151
|
+
sprintf( successNotice, blockTitle )
|
|
152
|
+
);
|
|
153
|
+
replaceBlocks( block );
|
|
154
|
+
},
|
|
155
|
+
},
|
|
156
|
+
];
|
|
157
|
+
}
|
|
166
158
|
|
|
167
159
|
return (
|
|
168
|
-
<
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
// For the Classic block, the content is kept in the `content` attribute.
|
|
178
|
-
const content =
|
|
179
|
-
blockName === 'core/freeform'
|
|
180
|
-
? attributes.content
|
|
181
|
-
: attributes.originalContent;
|
|
182
|
-
requestUnsupportedBlockFallback(
|
|
183
|
-
content,
|
|
184
|
-
clientId,
|
|
185
|
-
blockName,
|
|
186
|
-
blockTitle
|
|
187
|
-
);
|
|
188
|
-
}, 100 );
|
|
189
|
-
this.setState( { sendFallbackMessage: false } );
|
|
190
|
-
} else if ( this.state.sendButtonPressMessage ) {
|
|
191
|
-
this.timeout = setTimeout( () => {
|
|
192
|
-
sendActionButtonPressedAction(
|
|
193
|
-
actionButtons.missingBlockAlertActionButton
|
|
194
|
-
);
|
|
195
|
-
}, 100 );
|
|
196
|
-
this.setState( { sendButtonPressMessage: false } );
|
|
197
|
-
}
|
|
198
|
-
} }
|
|
199
|
-
>
|
|
200
|
-
<View style={ styles.infoContainer }>
|
|
201
|
-
<Icon
|
|
202
|
-
icon={ help }
|
|
203
|
-
color={ infoSheetIconStyle.color }
|
|
204
|
-
size={ styles.infoSheetIcon.size }
|
|
205
|
-
/>
|
|
206
|
-
<Text style={ [ infoTextStyle, infoTitleStyle ] }>
|
|
207
|
-
{ infoTitle }
|
|
208
|
-
</Text>
|
|
209
|
-
{ isEditableInUnsupportedBlockEditor &&
|
|
210
|
-
missingBlockDetail && (
|
|
211
|
-
<Text
|
|
212
|
-
style={ [
|
|
213
|
-
infoTextStyle,
|
|
214
|
-
infoDescriptionStyle,
|
|
215
|
-
] }
|
|
216
|
-
>
|
|
217
|
-
{ missingBlockDetail }
|
|
218
|
-
</Text>
|
|
219
|
-
) }
|
|
220
|
-
</View>
|
|
221
|
-
{ ( isUnsupportedBlockEditorSupported ||
|
|
222
|
-
canEnableUnsupportedBlockEditor ) &&
|
|
223
|
-
isEditableInUnsupportedBlockEditor && (
|
|
224
|
-
<>
|
|
225
|
-
<TextControl
|
|
226
|
-
label={ missingBlockActionButton }
|
|
227
|
-
separatorType="topFullWidth"
|
|
228
|
-
onPress={ this.requestFallback }
|
|
229
|
-
labelStyle={ actionButtonStyle }
|
|
230
|
-
/>
|
|
231
|
-
<TextControl
|
|
232
|
-
label={ __( 'Dismiss' ) }
|
|
233
|
-
separatorType="topFullWidth"
|
|
234
|
-
onPress={ this.toggleSheet }
|
|
235
|
-
labelStyle={ actionButtonStyle }
|
|
236
|
-
/>
|
|
237
|
-
</>
|
|
238
|
-
) }
|
|
239
|
-
</BottomSheet>
|
|
160
|
+
<UnsupportedBlockDetails
|
|
161
|
+
clientId={ clientId }
|
|
162
|
+
showSheet={ showHelp }
|
|
163
|
+
onCloseSheet={ this.closeSheet }
|
|
164
|
+
customBlockTitle={ blockTitle }
|
|
165
|
+
title={ title }
|
|
166
|
+
description={ description }
|
|
167
|
+
customActions={ customActions }
|
|
168
|
+
/>
|
|
240
169
|
);
|
|
241
170
|
}
|
|
242
171
|
|
|
@@ -300,8 +229,9 @@ export class UnsupportedBlockEdit extends Component {
|
|
|
300
229
|
}
|
|
301
230
|
|
|
302
231
|
export default compose( [
|
|
303
|
-
withSelect( ( select, { attributes } ) => {
|
|
304
|
-
const {
|
|
232
|
+
withSelect( ( select, { attributes, clientId } ) => {
|
|
233
|
+
const { getBlock, getSettings } = select( blockEditorStore );
|
|
234
|
+
const { capabilities } = getSettings();
|
|
305
235
|
return {
|
|
306
236
|
isUnsupportedBlockEditorSupported:
|
|
307
237
|
capabilities?.unsupportedBlockEditor === true,
|
|
@@ -309,14 +239,23 @@ export default compose( [
|
|
|
309
239
|
capabilities?.canEnableUnsupportedBlockEditor === true,
|
|
310
240
|
isEditableInUnsupportedBlockEditor:
|
|
311
241
|
! UBE_INCOMPATIBLE_BLOCKS.includes( attributes.originalName ),
|
|
242
|
+
block: getBlock( clientId ),
|
|
312
243
|
};
|
|
313
244
|
} ),
|
|
314
245
|
withDispatch( ( dispatch, ownProps ) => {
|
|
315
|
-
const { selectBlock } = dispatch( blockEditorStore );
|
|
246
|
+
const { selectBlock, replaceBlocks } = dispatch( blockEditorStore );
|
|
247
|
+
const { createSuccessNotice } = dispatch( noticesStore );
|
|
316
248
|
return {
|
|
317
249
|
selectBlock() {
|
|
318
250
|
selectBlock( ownProps.clientId );
|
|
319
251
|
},
|
|
252
|
+
replaceBlocks( block ) {
|
|
253
|
+
replaceBlocks(
|
|
254
|
+
ownProps.clientId,
|
|
255
|
+
rawHandler( { HTML: serialize( block ) } )
|
|
256
|
+
);
|
|
257
|
+
},
|
|
258
|
+
createSuccessNotice,
|
|
320
259
|
};
|
|
321
260
|
} ),
|
|
322
261
|
withPreferredColorScheme,
|
|
@@ -1,13 +1,3 @@
|
|
|
1
|
-
/** @format */
|
|
2
|
-
.content {
|
|
3
|
-
padding-top: 8;
|
|
4
|
-
padding-bottom: 0;
|
|
5
|
-
padding-left: 24;
|
|
6
|
-
padding-right: 24;
|
|
7
|
-
align-items: center;
|
|
8
|
-
justify-content: space-evenly;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
1
|
.helpIconContainer {
|
|
12
2
|
position: absolute;
|
|
13
3
|
top: 0;
|
|
@@ -20,12 +10,6 @@
|
|
|
20
10
|
align-items: flex-end;
|
|
21
11
|
}
|
|
22
12
|
|
|
23
|
-
.infoContainer {
|
|
24
|
-
flex-direction: column;
|
|
25
|
-
align-items: center;
|
|
26
|
-
justify-content: flex-end;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
13
|
.infoIcon {
|
|
30
14
|
size: 36;
|
|
31
15
|
height: 36;
|
|
@@ -38,49 +22,6 @@
|
|
|
38
22
|
color: $dark-tertiary;
|
|
39
23
|
}
|
|
40
24
|
|
|
41
|
-
.infoSheetIcon {
|
|
42
|
-
size: 36;
|
|
43
|
-
height: 36;
|
|
44
|
-
padding-top: 8;
|
|
45
|
-
padding-bottom: 8;
|
|
46
|
-
color: $gray;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
.infoSheetIconDark {
|
|
50
|
-
color: $gray-20;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
.infoText {
|
|
54
|
-
text-align: center;
|
|
55
|
-
color: $gray-dark;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
.infoTextDark {
|
|
59
|
-
color: $white;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
.infoTitle {
|
|
63
|
-
padding-top: 8;
|
|
64
|
-
padding-bottom: 12;
|
|
65
|
-
font-size: 20;
|
|
66
|
-
font-weight: bold;
|
|
67
|
-
color: $gray-dark;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
.infoTitleDark {
|
|
71
|
-
color: $white;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
.infoDescription {
|
|
75
|
-
padding-bottom: 24;
|
|
76
|
-
font-size: 16;
|
|
77
|
-
color: $gray-darken-20;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
.infoDescriptionDark {
|
|
81
|
-
color: $gray-20;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
25
|
.unsupportedBlock {
|
|
85
26
|
height: 142;
|
|
86
27
|
background-color: #e0e0e0; // $light-dim
|
|
@@ -136,11 +77,3 @@
|
|
|
136
77
|
.unsupportedBlockSubtitleDark {
|
|
137
78
|
color: $gray-20;
|
|
138
79
|
}
|
|
139
|
-
|
|
140
|
-
.actionButton {
|
|
141
|
-
color: $blue-50;
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
.actionButtonDark {
|
|
145
|
-
color: $blue-30;
|
|
146
|
-
}
|
|
@@ -1,81 +1,167 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* External dependencies
|
|
3
3
|
*/
|
|
4
|
-
import {
|
|
4
|
+
import {
|
|
5
|
+
fireEvent,
|
|
6
|
+
getBlock,
|
|
7
|
+
initializeEditor,
|
|
8
|
+
screen,
|
|
9
|
+
setupCoreBlocks,
|
|
10
|
+
withFakeTimers,
|
|
11
|
+
within,
|
|
12
|
+
} from 'test/helpers';
|
|
13
|
+
import { Platform } from 'react-native';
|
|
5
14
|
|
|
6
15
|
/**
|
|
7
16
|
* WordPress dependencies
|
|
8
17
|
*/
|
|
9
|
-
import {
|
|
18
|
+
import { unregisterBlockType } from '@wordpress/blocks';
|
|
10
19
|
import { setLocaleData } from '@wordpress/i18n';
|
|
20
|
+
import { requestUnsupportedBlockFallback } from '@wordpress/react-native-bridge';
|
|
21
|
+
|
|
22
|
+
// Override modal mock to prevent unmounting it when is not visible.
|
|
23
|
+
// This is required to be able to trigger onClose and onDismiss events when
|
|
24
|
+
// the modal is dismissed.
|
|
25
|
+
jest.mock( 'react-native-modal', () => {
|
|
26
|
+
const mockComponent = require( 'react-native/jest/mockComponent' );
|
|
27
|
+
return mockComponent( 'react-native-modal' );
|
|
28
|
+
} );
|
|
11
29
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
30
|
+
const TABLE_BLOCK_HTML = `<!-- wp:table -->
|
|
31
|
+
<figure class="wp-block-table"><table><tbody><tr><td>1</td><td>2</td></tr><tr><td>3</td><td>4</td></tr></tbody></table></figure>
|
|
32
|
+
<!-- /wp:table -->`;
|
|
33
|
+
const MODAL_DISMISS_EVENT = Platform.OS === 'ios' ? 'onDismiss' : 'onModalHide';
|
|
16
34
|
|
|
17
|
-
|
|
18
|
-
// Mock translations.
|
|
19
|
-
setLocaleData( {
|
|
20
|
-
'block title\u0004Table': [ 'Tabla' ],
|
|
21
|
-
"'%s' is not fully-supported": [ '«%s» no es totalmente compatible' ],
|
|
22
|
-
} );
|
|
35
|
+
setupCoreBlocks();
|
|
23
36
|
|
|
24
|
-
|
|
25
|
-
|
|
37
|
+
beforeAll( () => {
|
|
38
|
+
// For the purpose of this test suite we consider Reusable blocks/Patterns as unsupported.
|
|
39
|
+
// For this reason we unregister it to force it to be rendered as an unsupported block.
|
|
40
|
+
unregisterBlockType( 'core/block' );
|
|
26
41
|
} );
|
|
27
42
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
43
|
+
describe( 'Unsupported block', () => {
|
|
44
|
+
describe( 'localized elements', () => {
|
|
45
|
+
beforeEach( () => {
|
|
46
|
+
// Mock translations.
|
|
47
|
+
setLocaleData( {
|
|
48
|
+
'block title\u0004Table': [ 'Tabla' ],
|
|
49
|
+
"'%s' is not fully-supported": [
|
|
50
|
+
'«%s» no es totalmente compatible',
|
|
51
|
+
],
|
|
52
|
+
} );
|
|
53
|
+
} );
|
|
54
|
+
|
|
55
|
+
afterEach( () => {
|
|
56
|
+
// Clean up translations.
|
|
57
|
+
setLocaleData( {} );
|
|
58
|
+
} );
|
|
59
|
+
|
|
60
|
+
it( 'requests translated block title in block placeholder', async () => {
|
|
61
|
+
await initializeEditor( {
|
|
62
|
+
initialHtml: TABLE_BLOCK_HTML,
|
|
63
|
+
} );
|
|
64
|
+
|
|
65
|
+
const missingBlock = getBlock( screen, 'Unsupported' );
|
|
66
|
+
|
|
67
|
+
const translatedTableTitle =
|
|
68
|
+
within( missingBlock ).getByText( 'Tabla' );
|
|
69
|
+
|
|
70
|
+
expect( translatedTableTitle ).toBeDefined();
|
|
71
|
+
} );
|
|
72
|
+
|
|
73
|
+
it( 'requests translated block title in bottom sheet', async () => {
|
|
74
|
+
await initializeEditor( {
|
|
75
|
+
initialHtml: TABLE_BLOCK_HTML,
|
|
76
|
+
} );
|
|
77
|
+
|
|
78
|
+
const missingBlock = getBlock( screen, 'Unsupported' );
|
|
79
|
+
|
|
80
|
+
fireEvent.press( missingBlock );
|
|
31
81
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
82
|
+
const [ helpButton ] =
|
|
83
|
+
await screen.findAllByLabelText( 'Help button' );
|
|
84
|
+
|
|
85
|
+
fireEvent.press( helpButton );
|
|
86
|
+
|
|
87
|
+
const bottomSheetTitle = await screen.findByText(
|
|
88
|
+
'«Tabla» no es totalmente compatible'
|
|
89
|
+
);
|
|
90
|
+
|
|
91
|
+
expect( bottomSheetTitle ).toBeDefined();
|
|
92
|
+
} );
|
|
35
93
|
} );
|
|
36
|
-
} );
|
|
37
94
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
95
|
+
it( 'requests web editor when UBE is available', async () => {
|
|
96
|
+
await initializeEditor( {
|
|
97
|
+
initialHtml: TABLE_BLOCK_HTML,
|
|
98
|
+
capabilities: {
|
|
99
|
+
unsupportedBlockEditor: true,
|
|
100
|
+
canEnableUnsupportedBlockEditor: true,
|
|
101
|
+
},
|
|
45
102
|
} );
|
|
46
103
|
|
|
47
|
-
const
|
|
48
|
-
|
|
49
|
-
|
|
104
|
+
const missingBlock = getBlock( screen, 'Unsupported' );
|
|
105
|
+
fireEvent.press( missingBlock );
|
|
106
|
+
|
|
107
|
+
// Tap the block to open the unsupported block details
|
|
108
|
+
fireEvent.press( within( missingBlock ).getByText( 'Unsupported' ) );
|
|
50
109
|
|
|
51
|
-
const
|
|
52
|
-
|
|
110
|
+
const actionButton = screen.getByText( 'Edit using web editor' );
|
|
111
|
+
expect( actionButton ).toBeVisible();
|
|
53
112
|
|
|
54
|
-
|
|
113
|
+
// UBE is requested after the modal hides and running a timeout
|
|
114
|
+
await withFakeTimers( async () => {
|
|
115
|
+
fireEvent.press( actionButton );
|
|
116
|
+
fireEvent(
|
|
117
|
+
screen.getByTestId( 'bottom-sheet' ),
|
|
118
|
+
MODAL_DISMISS_EVENT
|
|
119
|
+
);
|
|
120
|
+
jest.runOnlyPendingTimers();
|
|
121
|
+
} );
|
|
122
|
+
expect( requestUnsupportedBlockFallback ).toHaveBeenCalled();
|
|
55
123
|
} );
|
|
56
124
|
|
|
57
|
-
it( '
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
125
|
+
it( 'does not show web editor option when UBE is not available', async () => {
|
|
126
|
+
await initializeEditor( {
|
|
127
|
+
initialHtml: TABLE_BLOCK_HTML,
|
|
128
|
+
capabilities: {
|
|
129
|
+
unsupportedBlockEditor: false,
|
|
130
|
+
canEnableUnsupportedBlockEditor: false,
|
|
131
|
+
},
|
|
63
132
|
} );
|
|
64
133
|
|
|
65
|
-
const
|
|
66
|
-
|
|
134
|
+
const missingBlock = getBlock( screen, 'Unsupported' );
|
|
135
|
+
fireEvent.press( missingBlock );
|
|
136
|
+
|
|
137
|
+
// Tap the block to open the unsupported block details
|
|
138
|
+
fireEvent.press( within( missingBlock ).getByText( 'Unsupported' ) );
|
|
139
|
+
|
|
140
|
+
const actionButton = await screen.queryByText(
|
|
141
|
+
'Edit using web editor'
|
|
67
142
|
);
|
|
143
|
+
expect( actionButton ).toBeNull();
|
|
144
|
+
} );
|
|
68
145
|
|
|
69
|
-
|
|
146
|
+
it( 'does not show web editor option when block is incompatible with UBE', async () => {
|
|
147
|
+
await initializeEditor( {
|
|
148
|
+
// Reusable blocks/Patterns is a block type unsupported by UBE
|
|
149
|
+
initialHtml: '<!-- wp:block {"ref":7387} /-->',
|
|
150
|
+
capabilities: {
|
|
151
|
+
unsupportedBlockEditor: true,
|
|
152
|
+
canEnableUnsupportedBlockEditor: true,
|
|
153
|
+
},
|
|
154
|
+
} );
|
|
70
155
|
|
|
71
|
-
const
|
|
156
|
+
const missingBlock = getBlock( screen, 'Unsupported' );
|
|
157
|
+
fireEvent.press( missingBlock );
|
|
72
158
|
|
|
73
|
-
|
|
159
|
+
// Tap the block to open the unsupported block details
|
|
160
|
+
fireEvent.press( within( missingBlock ).getByText( 'Unsupported' ) );
|
|
74
161
|
|
|
75
|
-
const
|
|
76
|
-
'
|
|
162
|
+
const actionButton = await screen.queryByText(
|
|
163
|
+
'Edit using web editor'
|
|
77
164
|
);
|
|
78
|
-
|
|
79
|
-
expect( bottomSheetTitle ).toBeDefined();
|
|
165
|
+
expect( actionButton ).toBeNull();
|
|
80
166
|
} );
|
|
81
167
|
} );
|
|
@@ -63,47 +63,6 @@ describe( 'Missing block', () => {
|
|
|
63
63
|
"' is not fully-supported"
|
|
64
64
|
);
|
|
65
65
|
} );
|
|
66
|
-
|
|
67
|
-
describe( 'Unsupported block editor (UBE)', () => {
|
|
68
|
-
beforeEach( () => {
|
|
69
|
-
// By default we set the web editor as available.
|
|
70
|
-
storeConfig.selectors.getSettings.mockReturnValue( {
|
|
71
|
-
capabilities: { unsupportedBlockEditor: true },
|
|
72
|
-
} );
|
|
73
|
-
} );
|
|
74
|
-
|
|
75
|
-
it( 'renders edit action if UBE is available', () => {
|
|
76
|
-
const testInstance = getTestComponentWithContent();
|
|
77
|
-
const bottomSheet =
|
|
78
|
-
testInstance.UNSAFE_getByType( BottomSheet );
|
|
79
|
-
const bottomSheetCells = bottomSheet.props.children[ 1 ];
|
|
80
|
-
expect( bottomSheetCells ).toBeTruthy();
|
|
81
|
-
expect( bottomSheetCells.props.children.length ).toBe( 2 );
|
|
82
|
-
expect( bottomSheetCells.props.children[ 0 ].props.label ).toBe(
|
|
83
|
-
'Edit using web editor'
|
|
84
|
-
);
|
|
85
|
-
} );
|
|
86
|
-
|
|
87
|
-
it( 'does not render edit action if UBE is not available', () => {
|
|
88
|
-
storeConfig.selectors.getSettings.mockReturnValue( {
|
|
89
|
-
capabilities: { unsupportedBlockEditor: false },
|
|
90
|
-
} );
|
|
91
|
-
|
|
92
|
-
const testInstance = getTestComponentWithContent();
|
|
93
|
-
const bottomSheet =
|
|
94
|
-
testInstance.UNSAFE_getByType( BottomSheet );
|
|
95
|
-
expect( bottomSheet.props.children[ 1 ] ).toBeFalsy();
|
|
96
|
-
} );
|
|
97
|
-
|
|
98
|
-
it( 'does not render edit action if the block is incompatible with UBE', () => {
|
|
99
|
-
const testInstance = getTestComponentWithContent( {
|
|
100
|
-
originalName: 'core/block',
|
|
101
|
-
} );
|
|
102
|
-
const bottomSheet =
|
|
103
|
-
testInstance.UNSAFE_getByType( BottomSheet );
|
|
104
|
-
expect( bottomSheet.props.children[ 1 ] ).toBeFalsy();
|
|
105
|
-
} );
|
|
106
|
-
} );
|
|
107
66
|
} );
|
|
108
67
|
|
|
109
68
|
it( 'renders admin plugins icon', () => {
|
package/src/navigation/index.php
CHANGED
|
@@ -72,8 +72,8 @@ if ( defined( 'IS_GUTENBERG_PLUGIN' ) && IS_GUTENBERG_PLUGIN ) {
|
|
|
72
72
|
* Add Interactivity API directives to the navigation-submenu and page-list
|
|
73
73
|
* blocks markup using the Tag Processor.
|
|
74
74
|
*
|
|
75
|
-
* @param
|
|
76
|
-
* @param array
|
|
75
|
+
* @param WP_HTML_Tag_Processor $w Markup of the navigation block.
|
|
76
|
+
* @param array $block_attributes Block attributes.
|
|
77
77
|
*
|
|
78
78
|
* @return string Submenu markup with the directives injected.
|
|
79
79
|
*/
|
|
@@ -90,6 +90,13 @@ function block_core_navigation_add_directives_to_submenu( $w, $block_attributes
|
|
|
90
90
|
$w->set_attribute( 'data-wp-effect', 'effects.core.navigation.initMenu' );
|
|
91
91
|
$w->set_attribute( 'data-wp-on--focusout', 'actions.core.navigation.handleMenuFocusout' );
|
|
92
92
|
$w->set_attribute( 'data-wp-on--keydown', 'actions.core.navigation.handleMenuKeydown' );
|
|
93
|
+
|
|
94
|
+
// This is a fix for Safari. Without it, Safari doesn't change the active
|
|
95
|
+
// element when the user clicks on a button. It can be removed once we add
|
|
96
|
+
// an overlay to capture the clicks, instead of relying on the focusout
|
|
97
|
+
// event.
|
|
98
|
+
$w->set_attribute( 'tabindex', '-1' );
|
|
99
|
+
|
|
93
100
|
if ( ! isset( $block_attributes['openSubmenusOnClick'] ) || false === $block_attributes['openSubmenusOnClick'] ) {
|
|
94
101
|
$w->set_attribute( 'data-wp-on--mouseenter', 'actions.core.navigation.openMenuOnHover' );
|
|
95
102
|
$w->set_attribute( 'data-wp-on--mouseleave', 'actions.core.navigation.closeMenuOnHover' );
|
|
@@ -696,9 +703,22 @@ function render_block_core_navigation( $attributes, $content, $block ) {
|
|
|
696
703
|
$responsive_dialog_directives = '';
|
|
697
704
|
$close_button_directives = '';
|
|
698
705
|
if ( $should_load_view_script ) {
|
|
706
|
+
$nav_element_context = wp_json_encode(
|
|
707
|
+
array(
|
|
708
|
+
'core' => array(
|
|
709
|
+
'navigation' => array(
|
|
710
|
+
'overlayOpenedBy' => array(),
|
|
711
|
+
'type' => 'overlay',
|
|
712
|
+
'roleAttribute' => '',
|
|
713
|
+
'ariaLabel' => __( 'Menu' ),
|
|
714
|
+
),
|
|
715
|
+
),
|
|
716
|
+
),
|
|
717
|
+
JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_AMP
|
|
718
|
+
);
|
|
699
719
|
$nav_element_directives = '
|
|
700
720
|
data-wp-interactive
|
|
701
|
-
data-wp-context=\'
|
|
721
|
+
data-wp-context=\'' . $nav_element_context . '\'
|
|
702
722
|
';
|
|
703
723
|
$open_button_directives = '
|
|
704
724
|
data-wp-on--click="actions.core.navigation.openMenuOnClick"
|
|
@@ -714,6 +734,7 @@ function render_block_core_navigation( $attributes, $content, $block ) {
|
|
|
714
734
|
';
|
|
715
735
|
$responsive_dialog_directives = '
|
|
716
736
|
data-wp-bind--aria-modal="selectors.core.navigation.ariaModal"
|
|
737
|
+
data-wp-bind--aria-label="selectors.core.navigation.ariaLabel"
|
|
717
738
|
data-wp-bind--role="selectors.core.navigation.roleAttribute"
|
|
718
739
|
data-wp-effect="effects.core.navigation.focusFirstElement"
|
|
719
740
|
';
|
|
@@ -723,11 +744,11 @@ function render_block_core_navigation( $attributes, $content, $block ) {
|
|
|
723
744
|
}
|
|
724
745
|
|
|
725
746
|
$responsive_container_markup = sprintf(
|
|
726
|
-
'<button aria-haspopup="
|
|
727
|
-
<div class="%5$s" style="%7$s" id="%1$s" %
|
|
747
|
+
'<button aria-haspopup="dialog" %3$s class="%6$s" %10$s>%8$s</button>
|
|
748
|
+
<div class="%5$s" style="%7$s" id="%1$s" %11$s>
|
|
728
749
|
<div class="wp-block-navigation__responsive-close" tabindex="-1">
|
|
729
|
-
<div class="wp-block-navigation__responsive-dialog"
|
|
730
|
-
<button %4$s class="wp-block-navigation__responsive-container-close" %
|
|
750
|
+
<div class="wp-block-navigation__responsive-dialog" %12$s>
|
|
751
|
+
<button %4$s class="wp-block-navigation__responsive-container-close" %13$s>%9$s</button>
|
|
731
752
|
<div class="wp-block-navigation__responsive-container-content" id="%1$s-content">
|
|
732
753
|
%2$s
|
|
733
754
|
</div>
|
|
@@ -741,7 +762,6 @@ function render_block_core_navigation( $attributes, $content, $block ) {
|
|
|
741
762
|
esc_attr( implode( ' ', $responsive_container_classes ) ),
|
|
742
763
|
esc_attr( implode( ' ', $open_button_classes ) ),
|
|
743
764
|
esc_attr( safecss_filter_attr( $colors['overlay_inline_styles'] ) ),
|
|
744
|
-
__( 'Menu' ),
|
|
745
765
|
$toggle_button_content,
|
|
746
766
|
$toggle_close_button_content,
|
|
747
767
|
$open_button_directives,
|