@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,24 @@
|
|
|
1
|
+
.wp-block-form-input {
|
|
2
|
+
.is-input-hidden {
|
|
3
|
+
font-size: 0.85em;
|
|
4
|
+
opacity: 0.3;
|
|
5
|
+
border: 1px dashed;
|
|
6
|
+
padding: 0.5em;
|
|
7
|
+
box-sizing: border-box;
|
|
8
|
+
background: repeating-linear-gradient(45deg, transparent, transparent 5px, currentColor 5px, currentColor 6px);
|
|
9
|
+
|
|
10
|
+
input[type="text"] {
|
|
11
|
+
background: transparent;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
&.is-selected {
|
|
15
|
+
.is-input-hidden {
|
|
16
|
+
opacity: 1;
|
|
17
|
+
background: none;
|
|
18
|
+
|
|
19
|
+
input[type="text"] {
|
|
20
|
+
background: unset;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Internal dependencies
|
|
3
|
+
*/
|
|
4
|
+
import initBlock from '../utils/init-block';
|
|
5
|
+
import edit from './edit';
|
|
6
|
+
import metadata from './block.json';
|
|
7
|
+
import save from './save';
|
|
8
|
+
import variations from './variations';
|
|
9
|
+
|
|
10
|
+
const { name } = metadata;
|
|
11
|
+
|
|
12
|
+
export { metadata, name };
|
|
13
|
+
|
|
14
|
+
export const settings = {
|
|
15
|
+
edit,
|
|
16
|
+
save,
|
|
17
|
+
variations,
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export const init = () => initBlock( { name, metadata, settings } );
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
<?php
|
|
2
|
+
/**
|
|
3
|
+
* Server-side rendering of the `core/form-input` block.
|
|
4
|
+
*
|
|
5
|
+
* @package WordPress
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Renders the `core/form-input` block on server.
|
|
10
|
+
*
|
|
11
|
+
* @param array $attributes The block attributes.
|
|
12
|
+
* @param string $content The saved content.
|
|
13
|
+
*
|
|
14
|
+
* @return string The content of the block being rendered.
|
|
15
|
+
*/
|
|
16
|
+
function render_block_core_form_input( $attributes, $content ) {
|
|
17
|
+
$visibility_permissions = 'all';
|
|
18
|
+
if ( isset( $attributes['visibilityPermissions'] ) ) {
|
|
19
|
+
$visibility_permissions = $attributes['visibilityPermissions'];
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
if ( 'logged-in' === $visibility_permissions && ! is_user_logged_in() ) {
|
|
23
|
+
return '';
|
|
24
|
+
}
|
|
25
|
+
if ( 'logged-out' === $visibility_permissions && is_user_logged_in() ) {
|
|
26
|
+
return '';
|
|
27
|
+
}
|
|
28
|
+
return $content;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Registers the `core/form-input` block on server.
|
|
33
|
+
*/
|
|
34
|
+
function register_block_core_form_input() {
|
|
35
|
+
if ( ! gutenberg_is_experiment_enabled( 'gutenberg-form-blocks' ) ) {
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
register_block_type_from_metadata(
|
|
39
|
+
__DIR__ . '/form-input',
|
|
40
|
+
array(
|
|
41
|
+
'render_callback' => 'render_block_core_form_input',
|
|
42
|
+
)
|
|
43
|
+
);
|
|
44
|
+
}
|
|
45
|
+
add_action( 'init', 'register_block_core_form_input' );
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* External dependencies
|
|
3
|
+
*/
|
|
4
|
+
import classNames from 'classnames';
|
|
5
|
+
import removeAccents from 'remove-accents';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* WordPress dependencies
|
|
9
|
+
*/
|
|
10
|
+
import {
|
|
11
|
+
RichText,
|
|
12
|
+
__experimentalGetBorderClassesAndStyles as getBorderClassesAndStyles,
|
|
13
|
+
__experimentalGetColorClassesAndStyles as getColorClassesAndStyles,
|
|
14
|
+
} from '@wordpress/block-editor';
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Get the name attribute from a content string.
|
|
18
|
+
*
|
|
19
|
+
* @param {string} content The block content.
|
|
20
|
+
*
|
|
21
|
+
* @return {string} Returns the slug.
|
|
22
|
+
*/
|
|
23
|
+
const getNameFromLabel = ( content ) => {
|
|
24
|
+
const dummyElement = document.createElement( 'div' );
|
|
25
|
+
dummyElement.innerHTML = content;
|
|
26
|
+
// Get the slug.
|
|
27
|
+
return (
|
|
28
|
+
removeAccents( dummyElement.innerText )
|
|
29
|
+
// Convert anything that's not a letter or number to a hyphen.
|
|
30
|
+
.replace( /[^\p{L}\p{N}]+/gu, '-' )
|
|
31
|
+
// Convert to lowercase
|
|
32
|
+
.toLowerCase()
|
|
33
|
+
// Remove any remaining leading or trailing hyphens.
|
|
34
|
+
.replace( /(^-+)|(-+$)/g, '' )
|
|
35
|
+
);
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
export default function save( { attributes } ) {
|
|
39
|
+
const { type, name, label, inlineLabel, required, placeholder, value } =
|
|
40
|
+
attributes;
|
|
41
|
+
|
|
42
|
+
const borderProps = getBorderClassesAndStyles( attributes );
|
|
43
|
+
const colorProps = getColorClassesAndStyles( attributes );
|
|
44
|
+
|
|
45
|
+
const inputStyle = {
|
|
46
|
+
...borderProps.style,
|
|
47
|
+
...colorProps.style,
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
const inputClasses = classNames(
|
|
51
|
+
'wp-block-form-input__input',
|
|
52
|
+
colorProps.className,
|
|
53
|
+
borderProps.className
|
|
54
|
+
);
|
|
55
|
+
const TagName = type === 'textarea' ? 'textarea' : 'input';
|
|
56
|
+
|
|
57
|
+
if ( 'hidden' === type ) {
|
|
58
|
+
return <input type={ type } name={ name } value={ value } />;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/* eslint-disable jsx-a11y/label-has-associated-control */
|
|
62
|
+
return (
|
|
63
|
+
<label
|
|
64
|
+
className={ classNames( 'wp-block-form-input__label', {
|
|
65
|
+
'is-label-inline': inlineLabel,
|
|
66
|
+
} ) }
|
|
67
|
+
>
|
|
68
|
+
<span className="wp-block-form-input__label-content">
|
|
69
|
+
<RichText.Content value={ label } />
|
|
70
|
+
</span>
|
|
71
|
+
<TagName
|
|
72
|
+
className={ inputClasses }
|
|
73
|
+
type={ 'textarea' === type ? undefined : type }
|
|
74
|
+
name={ name || getNameFromLabel( label ) }
|
|
75
|
+
required={ required }
|
|
76
|
+
aria-required={ required }
|
|
77
|
+
placeholder={ placeholder || undefined }
|
|
78
|
+
style={ inputStyle }
|
|
79
|
+
/>
|
|
80
|
+
</label>
|
|
81
|
+
);
|
|
82
|
+
/* eslint-enable jsx-a11y/label-has-associated-control */
|
|
83
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
.wp-block-form-input__label {
|
|
2
|
+
width: 100%;
|
|
3
|
+
display: flex;
|
|
4
|
+
flex-direction: column;
|
|
5
|
+
gap: 0.25em;
|
|
6
|
+
margin-bottom: 0.5em;
|
|
7
|
+
|
|
8
|
+
&.is-label-inline {
|
|
9
|
+
flex-direction: row;
|
|
10
|
+
gap: 0.5em;
|
|
11
|
+
align-items: center;
|
|
12
|
+
|
|
13
|
+
.wp-block-form-input__label-content {
|
|
14
|
+
margin-bottom: 0.5em;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/*
|
|
19
|
+
Small tweak to left-align the checkbox.
|
|
20
|
+
Even though `:has` is not currently supported in Firefox, this is a small tweak
|
|
21
|
+
and does not affect the functionality of the block or the user's experience.
|
|
22
|
+
There will be a minor inconsistency between browsers. However, it's more important to provide
|
|
23
|
+
a better experience for 80+% of users, until Firefox catches up and supports `:has`.
|
|
24
|
+
*/
|
|
25
|
+
&:has(input[type="checkbox"]) {
|
|
26
|
+
width: fit-content;
|
|
27
|
+
flex-direction: row-reverse;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
.wp-block-form-input__label-content {
|
|
32
|
+
width: fit-content;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
.wp-block-form-input__input {
|
|
36
|
+
padding: 0 0.5em;
|
|
37
|
+
font-size: 1em;
|
|
38
|
+
margin-bottom: 0.5em;
|
|
39
|
+
|
|
40
|
+
&[type="text"],
|
|
41
|
+
&[type="password"],
|
|
42
|
+
&[type="date"],
|
|
43
|
+
&[type="datetime"],
|
|
44
|
+
&[type="datetime-local"],
|
|
45
|
+
&[type="email"],
|
|
46
|
+
&[type="month"],
|
|
47
|
+
&[type="number"],
|
|
48
|
+
&[type="search"],
|
|
49
|
+
&[type="tel"],
|
|
50
|
+
&[type="time"],
|
|
51
|
+
&[type="url"],
|
|
52
|
+
&[type="week"] {
|
|
53
|
+
min-height: 2em;
|
|
54
|
+
line-height: 2;
|
|
55
|
+
border: 1px solid;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
textarea.wp-block-form-input__input {
|
|
60
|
+
min-height: 10em;
|
|
61
|
+
}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { __ } from '@wordpress/i18n';
|
|
5
|
+
|
|
6
|
+
const variations = [
|
|
7
|
+
{
|
|
8
|
+
name: 'text',
|
|
9
|
+
title: __( 'Text Input' ),
|
|
10
|
+
icon: 'edit-page',
|
|
11
|
+
description: __( 'A generic text input.' ),
|
|
12
|
+
attributes: { type: 'text' },
|
|
13
|
+
isDefault: true,
|
|
14
|
+
scope: [ 'inserter', 'transform' ],
|
|
15
|
+
isActive: ( blockAttributes ) =>
|
|
16
|
+
! blockAttributes?.type || blockAttributes?.type === 'text',
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
name: 'textarea',
|
|
20
|
+
title: __( 'Textarea Input' ),
|
|
21
|
+
icon: 'testimonial',
|
|
22
|
+
description: __(
|
|
23
|
+
'A textarea input to allow entering multiple lines of text.'
|
|
24
|
+
),
|
|
25
|
+
attributes: { type: 'textarea' },
|
|
26
|
+
isDefault: true,
|
|
27
|
+
scope: [ 'inserter', 'transform' ],
|
|
28
|
+
isActive: ( blockAttributes ) => blockAttributes?.type === 'textarea',
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
name: 'checkbox',
|
|
32
|
+
title: __( 'Checkbox Input' ),
|
|
33
|
+
description: __( 'A simple checkbox input.' ),
|
|
34
|
+
icon: 'forms',
|
|
35
|
+
attributes: { type: 'checkbox', inlineLabel: true },
|
|
36
|
+
isDefault: true,
|
|
37
|
+
scope: [ 'inserter', 'transform' ],
|
|
38
|
+
isActive: ( blockAttributes ) => blockAttributes?.type === 'checkbox',
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
name: 'email',
|
|
42
|
+
title: __( 'Email Input' ),
|
|
43
|
+
icon: 'email',
|
|
44
|
+
description: __( 'Used for email addresses.' ),
|
|
45
|
+
attributes: { type: 'email' },
|
|
46
|
+
isDefault: true,
|
|
47
|
+
scope: [ 'inserter', 'transform' ],
|
|
48
|
+
isActive: ( blockAttributes ) => blockAttributes?.type === 'email',
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
name: 'url',
|
|
52
|
+
title: __( 'URL Input' ),
|
|
53
|
+
icon: 'admin-site',
|
|
54
|
+
description: __( 'Used for URLs.' ),
|
|
55
|
+
attributes: { type: 'url' },
|
|
56
|
+
isDefault: true,
|
|
57
|
+
scope: [ 'inserter', 'transform' ],
|
|
58
|
+
isActive: ( blockAttributes ) => blockAttributes?.type === 'url',
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
name: 'tel',
|
|
62
|
+
title: __( 'Telephone Input' ),
|
|
63
|
+
icon: 'phone',
|
|
64
|
+
description: __( 'Used for phone numbers.' ),
|
|
65
|
+
attributes: { type: 'tel' },
|
|
66
|
+
isDefault: true,
|
|
67
|
+
scope: [ 'inserter', 'transform' ],
|
|
68
|
+
isActive: ( blockAttributes ) => blockAttributes?.type === 'tel',
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
name: 'number',
|
|
72
|
+
title: __( 'Number Input' ),
|
|
73
|
+
icon: 'edit-page',
|
|
74
|
+
description: __( 'A numeric input.' ),
|
|
75
|
+
attributes: { type: 'number' },
|
|
76
|
+
isDefault: true,
|
|
77
|
+
scope: [ 'inserter', 'transform' ],
|
|
78
|
+
isActive: ( blockAttributes ) => blockAttributes?.type === 'number',
|
|
79
|
+
},
|
|
80
|
+
];
|
|
81
|
+
|
|
82
|
+
export default variations;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://schemas.wp.org/trunk/block.json",
|
|
3
|
+
"apiVersion": 3,
|
|
4
|
+
"__experimental": true,
|
|
5
|
+
"name": "core/form-submission-notification",
|
|
6
|
+
"title": "Form Submission Notification",
|
|
7
|
+
"category": "common",
|
|
8
|
+
"parent": [ "core/form" ],
|
|
9
|
+
"description": "Provide a notification message after the form has been submitted.",
|
|
10
|
+
"keywords": [ "form", "feedback", "notification", "message" ],
|
|
11
|
+
"textdomain": "default",
|
|
12
|
+
"icon": "feedback",
|
|
13
|
+
"attributes": {
|
|
14
|
+
"type": {
|
|
15
|
+
"type": "string",
|
|
16
|
+
"default": "success"
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { __ } from '@wordpress/i18n';
|
|
5
|
+
import {
|
|
6
|
+
InnerBlocks,
|
|
7
|
+
useBlockProps,
|
|
8
|
+
useInnerBlocksProps,
|
|
9
|
+
store as blockEditorStore,
|
|
10
|
+
} from '@wordpress/block-editor';
|
|
11
|
+
import { useSelect } from '@wordpress/data';
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* External dependencies
|
|
15
|
+
*/
|
|
16
|
+
import classnames from 'classnames';
|
|
17
|
+
|
|
18
|
+
const TEMPLATE = [
|
|
19
|
+
[
|
|
20
|
+
'core/paragraph',
|
|
21
|
+
{
|
|
22
|
+
content: __(
|
|
23
|
+
"Enter the message you wish displayed for form submission error/success, and select the type of the message (success/error) from the block's options."
|
|
24
|
+
),
|
|
25
|
+
},
|
|
26
|
+
],
|
|
27
|
+
];
|
|
28
|
+
|
|
29
|
+
const Edit = ( { attributes, clientId } ) => {
|
|
30
|
+
const { type } = attributes;
|
|
31
|
+
const blockProps = useBlockProps( {
|
|
32
|
+
className: classnames( 'wp-block-form-submission-notification', {
|
|
33
|
+
[ `form-notification-type-${ type }` ]: type,
|
|
34
|
+
} ),
|
|
35
|
+
} );
|
|
36
|
+
|
|
37
|
+
const { hasInnerBlocks } = useSelect(
|
|
38
|
+
( select ) => {
|
|
39
|
+
const { getBlock } = select( blockEditorStore );
|
|
40
|
+
const block = getBlock( clientId );
|
|
41
|
+
return {
|
|
42
|
+
hasInnerBlocks: !! ( block && block.innerBlocks.length ),
|
|
43
|
+
};
|
|
44
|
+
},
|
|
45
|
+
[ clientId ]
|
|
46
|
+
);
|
|
47
|
+
|
|
48
|
+
const innerBlocksProps = useInnerBlocksProps( blockProps, {
|
|
49
|
+
template: TEMPLATE,
|
|
50
|
+
renderAppender: hasInnerBlocks
|
|
51
|
+
? undefined
|
|
52
|
+
: InnerBlocks.ButtonBlockAppender,
|
|
53
|
+
} );
|
|
54
|
+
|
|
55
|
+
return (
|
|
56
|
+
<div
|
|
57
|
+
{ ...innerBlocksProps }
|
|
58
|
+
data-message-success={ __( 'Submission success notification' ) }
|
|
59
|
+
data-message-error={ __( 'Submission error notification' ) }
|
|
60
|
+
/>
|
|
61
|
+
);
|
|
62
|
+
};
|
|
63
|
+
export default Edit;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
.wp-block-form-submission-notification {
|
|
2
|
+
> * {
|
|
3
|
+
opacity: 0.25;
|
|
4
|
+
border: 1px dashed;
|
|
5
|
+
box-sizing: border-box;
|
|
6
|
+
background: repeating-linear-gradient(45deg, transparent, transparent 5px, currentColor 5px, currentColor 6px);
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
&.is-selected,
|
|
10
|
+
&:has(.is-selected) {
|
|
11
|
+
> * {
|
|
12
|
+
opacity: 1;
|
|
13
|
+
background: none;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
&::after {
|
|
17
|
+
display: none !important;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
&::after {
|
|
22
|
+
display: flex;
|
|
23
|
+
position: absolute;
|
|
24
|
+
width: 100%;
|
|
25
|
+
height: 100%;
|
|
26
|
+
top: 0;
|
|
27
|
+
left: 0;
|
|
28
|
+
justify-content: center;
|
|
29
|
+
align-items: center;
|
|
30
|
+
font-size: 1.1em;
|
|
31
|
+
// font-weight: bold;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
&.form-notification-type-success {
|
|
35
|
+
&::after {
|
|
36
|
+
content: attr(data-message-success);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
&.form-notification-type-error {
|
|
41
|
+
&::after {
|
|
42
|
+
content: attr(data-message-error);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { group as icon } from '@wordpress/icons';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Internal dependencies
|
|
8
|
+
*/
|
|
9
|
+
import initBlock from '../utils/init-block';
|
|
10
|
+
import edit from './edit';
|
|
11
|
+
import metadata from './block.json';
|
|
12
|
+
import save from './save';
|
|
13
|
+
import variations from './variations';
|
|
14
|
+
|
|
15
|
+
const { name } = metadata;
|
|
16
|
+
|
|
17
|
+
export { metadata, name };
|
|
18
|
+
|
|
19
|
+
export const settings = {
|
|
20
|
+
icon,
|
|
21
|
+
edit,
|
|
22
|
+
save,
|
|
23
|
+
variations,
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export const init = () => initBlock( { name, metadata, settings } );
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
<?php
|
|
2
|
+
/**
|
|
3
|
+
* Server-side rendering of the `core/form-submission-notification` block.
|
|
4
|
+
*
|
|
5
|
+
* @package WordPress
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Renders the `core/form-submission-notification` block on server.
|
|
10
|
+
*
|
|
11
|
+
* @param array $attributes The block attributes.
|
|
12
|
+
* @param string $content The saved content.
|
|
13
|
+
*
|
|
14
|
+
* @return string The content of the block being rendered.
|
|
15
|
+
*/
|
|
16
|
+
function render_block_core_form_submission_notification( $attributes, $content ) {
|
|
17
|
+
$show = isset( $_GET['wp-form-result'] ) && sanitize_text_field( wp_unslash( $_GET['wp-form-result'] ) ) === $attributes['type'];
|
|
18
|
+
/**
|
|
19
|
+
* Filters whether to show the form submission notification block.
|
|
20
|
+
*
|
|
21
|
+
* @param bool $show Whether to show the form submission notification block.
|
|
22
|
+
* @param array $attributes The block attributes.
|
|
23
|
+
* @param string $content The saved content.
|
|
24
|
+
*
|
|
25
|
+
* @return bool Whether to show the form submission notification block.
|
|
26
|
+
*/
|
|
27
|
+
$show = apply_filters( 'show_form_submission_notification_block', $show, $attributes, $content );
|
|
28
|
+
if ( ! $show ) {
|
|
29
|
+
return '';
|
|
30
|
+
}
|
|
31
|
+
return $content;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Registers the `core/form-submission-notification` block on server.
|
|
36
|
+
*/
|
|
37
|
+
function register_block_core_form_submission_notification() {
|
|
38
|
+
if ( ! gutenberg_is_experiment_enabled( 'gutenberg-form-blocks' ) ) {
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
register_block_type_from_metadata(
|
|
42
|
+
__DIR__ . '/form-submission-notification',
|
|
43
|
+
array(
|
|
44
|
+
'render_callback' => 'render_block_core_form_submission_notification',
|
|
45
|
+
)
|
|
46
|
+
);
|
|
47
|
+
}
|
|
48
|
+
add_action( 'init', 'register_block_core_form_submission_notification' );
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { useInnerBlocksProps, useBlockProps } from '@wordpress/block-editor';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* External dependencies
|
|
8
|
+
*/
|
|
9
|
+
import classnames from 'classnames';
|
|
10
|
+
|
|
11
|
+
export default function save( { attributes } ) {
|
|
12
|
+
const { type } = attributes;
|
|
13
|
+
|
|
14
|
+
return (
|
|
15
|
+
<div
|
|
16
|
+
{ ...useInnerBlocksProps.save(
|
|
17
|
+
useBlockProps.save( {
|
|
18
|
+
className: classnames(
|
|
19
|
+
'wp-block-form-submission-notification',
|
|
20
|
+
{
|
|
21
|
+
[ `form-notification-type-${ type }` ]: type,
|
|
22
|
+
}
|
|
23
|
+
),
|
|
24
|
+
} )
|
|
25
|
+
) }
|
|
26
|
+
/>
|
|
27
|
+
);
|
|
28
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { __ } from '@wordpress/i18n';
|
|
5
|
+
|
|
6
|
+
const variations = [
|
|
7
|
+
{
|
|
8
|
+
name: 'form-submission-success',
|
|
9
|
+
title: __( 'Form Submission Success' ),
|
|
10
|
+
description: __( 'Success message for form submissions.' ),
|
|
11
|
+
attributes: {
|
|
12
|
+
type: 'success',
|
|
13
|
+
},
|
|
14
|
+
isDefault: true,
|
|
15
|
+
innerBlocks: [
|
|
16
|
+
[
|
|
17
|
+
'core/paragraph',
|
|
18
|
+
{
|
|
19
|
+
content: __( 'Your form has been submitted successfully.' ),
|
|
20
|
+
backgroundColor: '#00D084',
|
|
21
|
+
textColor: '#000000',
|
|
22
|
+
style: {
|
|
23
|
+
elements: { link: { color: { text: '#000000' } } },
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
],
|
|
27
|
+
],
|
|
28
|
+
scope: [ 'inserter', 'transform' ],
|
|
29
|
+
isActive: ( blockAttributes ) =>
|
|
30
|
+
! blockAttributes?.type || blockAttributes?.type === 'success',
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
name: 'form-submission-error',
|
|
34
|
+
title: __( 'Form Submission Error' ),
|
|
35
|
+
description: __( 'Error/failure message for form submissions.' ),
|
|
36
|
+
attributes: {
|
|
37
|
+
type: 'error',
|
|
38
|
+
},
|
|
39
|
+
isDefault: false,
|
|
40
|
+
innerBlocks: [
|
|
41
|
+
[
|
|
42
|
+
'core/paragraph',
|
|
43
|
+
{
|
|
44
|
+
content: __( 'There was an error submitting your form.' ),
|
|
45
|
+
backgroundColor: '#CF2E2E',
|
|
46
|
+
textColor: '#FFFFFF',
|
|
47
|
+
style: {
|
|
48
|
+
elements: { link: { color: { text: '#FFFFFF' } } },
|
|
49
|
+
},
|
|
50
|
+
},
|
|
51
|
+
],
|
|
52
|
+
],
|
|
53
|
+
scope: [ 'inserter', 'transform' ],
|
|
54
|
+
isActive: ( blockAttributes ) =>
|
|
55
|
+
! blockAttributes?.type || blockAttributes?.type === 'error',
|
|
56
|
+
},
|
|
57
|
+
];
|
|
58
|
+
|
|
59
|
+
export default variations;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://schemas.wp.org/trunk/block.json",
|
|
3
|
+
"apiVersion": 3,
|
|
4
|
+
"__experimental": true,
|
|
5
|
+
"name": "core/form-submit-button",
|
|
6
|
+
"title": "Form Submit Button",
|
|
7
|
+
"category": "common",
|
|
8
|
+
"icon": "button",
|
|
9
|
+
"parent": [ "core/form" ],
|
|
10
|
+
"description": "A submission button for forms.",
|
|
11
|
+
"keywords": [ "submit", "button", "form" ],
|
|
12
|
+
"textdomain": "default",
|
|
13
|
+
"style": [ "wp-block-form-submit-button" ]
|
|
14
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { __ } from '@wordpress/i18n';
|
|
5
|
+
import { useBlockProps, useInnerBlocksProps } from '@wordpress/block-editor';
|
|
6
|
+
|
|
7
|
+
const TEMPLATE = [
|
|
8
|
+
[
|
|
9
|
+
'core/buttons',
|
|
10
|
+
{},
|
|
11
|
+
[
|
|
12
|
+
[
|
|
13
|
+
'core/button',
|
|
14
|
+
{
|
|
15
|
+
text: __( 'Submit' ),
|
|
16
|
+
tagName: 'button',
|
|
17
|
+
},
|
|
18
|
+
],
|
|
19
|
+
],
|
|
20
|
+
],
|
|
21
|
+
];
|
|
22
|
+
const Edit = () => {
|
|
23
|
+
const blockProps = useBlockProps();
|
|
24
|
+
const innerBlocksProps = useInnerBlocksProps( blockProps, {
|
|
25
|
+
allowedBlocks: TEMPLATE,
|
|
26
|
+
template: TEMPLATE,
|
|
27
|
+
templateLock: 'all',
|
|
28
|
+
} );
|
|
29
|
+
return (
|
|
30
|
+
<div className="wp-block-form-submit-wrapper" { ...innerBlocksProps } />
|
|
31
|
+
);
|
|
32
|
+
};
|
|
33
|
+
export default Edit;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Internal dependencies
|
|
3
|
+
*/
|
|
4
|
+
import initBlock from '../utils/init-block';
|
|
5
|
+
import edit from './edit';
|
|
6
|
+
import metadata from './block.json';
|
|
7
|
+
import save from './save';
|
|
8
|
+
|
|
9
|
+
const { name } = metadata;
|
|
10
|
+
|
|
11
|
+
export { metadata, name };
|
|
12
|
+
|
|
13
|
+
export const settings = {
|
|
14
|
+
edit,
|
|
15
|
+
save,
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export const init = () => initBlock( { name, metadata, settings } );
|