@wordpress/block-library 8.18.0 → 8.19.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 +2 -0
- package/README.md +1 -1
- package/build/block/edit.js +53 -2
- package/build/block/edit.js.map +1 -1
- package/build/button/edit.js +7 -4
- package/build/button/edit.js.map +1 -1
- package/build/button/index.js +11 -2
- package/build/button/index.js.map +1 -1
- package/build/button/save.js +10 -4
- package/build/button/save.js.map +1 -1
- package/build/buttons/edit.js +12 -3
- package/build/buttons/edit.js.map +1 -1
- package/build/code/edit.js +8 -2
- package/build/code/edit.js.map +1 -1
- package/build/code/index.js +7 -1
- package/build/code/index.js.map +1 -1
- package/build/column/edit.native.js +5 -5
- package/build/column/edit.native.js.map +1 -1
- package/build/column/index.js +1 -0
- package/build/column/index.js.map +1 -1
- package/build/columns/index.js +2 -0
- package/build/columns/index.js.map +1 -1
- package/build/file/edit.native.js +1 -1
- package/build/file/edit.native.js.map +1 -1
- package/build/file/index.js +2 -1
- package/build/file/index.js.map +1 -1
- package/build/file/utils/index.js +1 -15
- package/build/file/utils/index.js.map +1 -1
- package/build/file/view.js +14 -1
- package/build/file/view.js.map +1 -1
- package/build/footnotes/edit.js +14 -5
- package/build/footnotes/edit.js.map +1 -1
- package/build/gallery/edit.js +1 -1
- package/build/gallery/edit.js.map +1 -1
- package/build/group/edit.js +0 -1
- package/build/group/edit.js.map +1 -1
- package/build/group/index.js +5 -0
- package/build/group/index.js.map +1 -1
- package/build/heading/edit.js +0 -1
- package/build/heading/edit.js.map +1 -1
- package/build/heading/index.js +2 -0
- package/build/heading/index.js.map +1 -1
- package/build/heading/transforms.js +3 -6
- package/build/heading/transforms.js.map +1 -1
- package/build/image/deprecated.js +191 -7
- package/build/image/deprecated.js.map +1 -1
- package/build/image/edit.js +27 -12
- package/build/image/edit.js.map +1 -1
- package/build/image/image.js +75 -40
- package/build/image/image.js.map +1 -1
- package/build/image/index.js +7 -4
- package/build/image/index.js.map +1 -1
- package/build/image/{view-interactivity.js → view.js} +1 -1
- package/build/image/view.js.map +1 -0
- package/build/list/deprecated.js +93 -1
- package/build/list/deprecated.js.map +1 -1
- package/build/list/edit.js +10 -10
- package/build/list/edit.js.map +1 -1
- package/build/list/ordered-list-settings.js +10 -10
- package/build/list/ordered-list-settings.js.map +1 -1
- package/build/list/save.js +4 -2
- package/build/list/save.js.map +1 -1
- package/build/list/utils.js +21 -2
- package/build/list/utils.js.map +1 -1
- package/build/navigation/constants.js +1 -1
- package/build/navigation/constants.js.map +1 -1
- package/build/navigation/index.js +4 -2
- package/build/navigation/index.js.map +1 -1
- package/build/navigation/view.js +168 -82
- package/build/navigation/view.js.map +1 -1
- package/build/navigation-link/edit.js +3 -9
- package/build/navigation-link/edit.js.map +1 -1
- package/build/navigation-link/transforms.js +24 -0
- package/build/navigation-link/transforms.js.map +1 -1
- package/build/page-list/edit.js +2 -1
- package/build/page-list/edit.js.map +1 -1
- package/build/post-comments-form/edit.js +10 -2
- package/build/post-comments-form/edit.js.map +1 -1
- package/build/post-comments-form/form.js +5 -3
- package/build/post-comments-form/form.js.map +1 -1
- package/build/post-content/edit.js +8 -7
- package/build/post-content/edit.js.map +1 -1
- package/build/post-content/index.js +3 -0
- package/build/post-content/index.js.map +1 -1
- package/build/post-featured-image/overlay.js +2 -1
- package/build/post-featured-image/overlay.js.map +1 -1
- package/build/post-terms/use-post-terms.js +3 -2
- package/build/post-terms/use-post-terms.js.map +1 -1
- package/build/preformatted/edit.js +4 -1
- package/build/preformatted/edit.js.map +1 -1
- package/build/preformatted/index.js +1 -1
- package/build/preformatted/index.js.map +1 -1
- package/build/pullquote/deprecated.js +6 -7
- package/build/pullquote/deprecated.js.map +1 -1
- package/build/query/edit/enhanced-pagination-modal.js +56 -0
- package/build/query/edit/enhanced-pagination-modal.js.map +1 -0
- package/build/query/edit/inspector-controls/enhanced-pagination-control.js +42 -0
- package/build/query/edit/inspector-controls/enhanced-pagination-control.js.map +1 -0
- package/build/query/edit/inspector-controls/index.js +8 -25
- package/build/query/edit/inspector-controls/index.js.map +1 -1
- package/build/query/edit/query-content.js +8 -2
- package/build/query/edit/query-content.js.map +1 -1
- package/build/query/utils.js +19 -0
- package/build/query/utils.js.map +1 -1
- package/build/query/view.js +4 -5
- package/build/query/view.js.map +1 -1
- package/build/search/index.js +1 -0
- package/build/search/index.js.map +1 -1
- package/build/search/view.js +81 -150
- package/build/search/view.js.map +1 -1
- package/build/social-link/edit.native.js +3 -1
- package/build/social-link/edit.native.js.map +1 -1
- package/build/table/edit.js +7 -7
- package/build/table/edit.js.map +1 -1
- package/build/table-of-contents/edit.js +2 -130
- package/build/table-of-contents/edit.js.map +1 -1
- package/build/table-of-contents/hooks.js +145 -0
- package/build/table-of-contents/hooks.js.map +1 -0
- package/build/table-of-contents/index.js +2 -1
- package/build/table-of-contents/index.js.map +1 -1
- package/build/verse/edit.js +4 -1
- package/build/verse/edit.js.map +1 -1
- package/build/verse/index.js +1 -1
- package/build/verse/index.js.map +1 -1
- package/build-module/block/edit.js +54 -3
- package/build-module/block/edit.js.map +1 -1
- package/build-module/button/edit.js +7 -4
- package/build-module/button/edit.js.map +1 -1
- package/build-module/button/index.js +11 -2
- package/build-module/button/index.js.map +1 -1
- package/build-module/button/save.js +10 -4
- package/build-module/button/save.js.map +1 -1
- package/build-module/buttons/edit.js +12 -3
- package/build-module/buttons/edit.js.map +1 -1
- package/build-module/code/edit.js +8 -2
- package/build-module/code/edit.js.map +1 -1
- package/build-module/code/index.js +7 -1
- package/build-module/code/index.js.map +1 -1
- package/build-module/column/edit.native.js +5 -5
- package/build-module/column/edit.native.js.map +1 -1
- package/build-module/column/index.js +1 -0
- package/build-module/column/index.js.map +1 -1
- package/build-module/columns/index.js +2 -0
- package/build-module/columns/index.js.map +1 -1
- package/build-module/file/edit.native.js +1 -1
- package/build-module/file/edit.native.js.map +1 -1
- package/build-module/file/index.js +2 -1
- package/build-module/file/index.js.map +1 -1
- package/build-module/file/utils/index.js +0 -13
- package/build-module/file/utils/index.js.map +1 -1
- package/build-module/file/view.js +14 -2
- package/build-module/file/view.js.map +1 -1
- package/build-module/footnotes/edit.js +14 -5
- package/build-module/footnotes/edit.js.map +1 -1
- package/build-module/gallery/edit.js +1 -1
- package/build-module/gallery/edit.js.map +1 -1
- package/build-module/group/edit.js +0 -1
- package/build-module/group/edit.js.map +1 -1
- package/build-module/group/index.js +5 -0
- package/build-module/group/index.js.map +1 -1
- package/build-module/heading/edit.js +0 -1
- package/build-module/heading/edit.js.map +1 -1
- package/build-module/heading/index.js +2 -0
- package/build-module/heading/index.js.map +1 -1
- package/build-module/heading/transforms.js +3 -6
- package/build-module/heading/transforms.js.map +1 -1
- package/build-module/image/deprecated.js +191 -7
- package/build-module/image/deprecated.js.map +1 -1
- package/build-module/image/edit.js +27 -12
- package/build-module/image/edit.js.map +1 -1
- package/build-module/image/image.js +77 -42
- package/build-module/image/image.js.map +1 -1
- package/build-module/image/index.js +7 -4
- package/build-module/image/index.js.map +1 -1
- package/build-module/image/{view-interactivity.js → view.js} +1 -1
- package/build-module/image/view.js.map +1 -0
- package/build-module/list/deprecated.js +95 -3
- package/build-module/list/deprecated.js.map +1 -1
- package/build-module/list/edit.js +10 -10
- package/build-module/list/edit.js.map +1 -1
- package/build-module/list/ordered-list-settings.js +10 -10
- package/build-module/list/ordered-list-settings.js.map +1 -1
- package/build-module/list/save.js +4 -2
- package/build-module/list/save.js.map +1 -1
- package/build-module/list/utils.js +20 -2
- package/build-module/list/utils.js.map +1 -1
- package/build-module/navigation/constants.js +1 -1
- package/build-module/navigation/constants.js.map +1 -1
- package/build-module/navigation/index.js +4 -2
- package/build-module/navigation/index.js.map +1 -1
- package/build-module/navigation/view.js +168 -83
- package/build-module/navigation/view.js.map +1 -1
- package/build-module/navigation-link/edit.js +3 -9
- package/build-module/navigation-link/edit.js.map +1 -1
- package/build-module/navigation-link/transforms.js +24 -0
- package/build-module/navigation-link/transforms.js.map +1 -1
- package/build-module/page-list/edit.js +2 -1
- package/build-module/page-list/edit.js.map +1 -1
- package/build-module/post-comments-form/edit.js +10 -2
- package/build-module/post-comments-form/edit.js.map +1 -1
- package/build-module/post-comments-form/form.js +5 -3
- package/build-module/post-comments-form/form.js.map +1 -1
- package/build-module/post-content/edit.js +8 -7
- package/build-module/post-content/edit.js.map +1 -1
- package/build-module/post-content/index.js +3 -0
- package/build-module/post-content/index.js.map +1 -1
- package/build-module/post-featured-image/overlay.js +2 -1
- package/build-module/post-featured-image/overlay.js.map +1 -1
- package/build-module/post-terms/use-post-terms.js +3 -2
- package/build-module/post-terms/use-post-terms.js.map +1 -1
- package/build-module/preformatted/edit.js +4 -1
- package/build-module/preformatted/edit.js.map +1 -1
- package/build-module/preformatted/index.js +1 -1
- package/build-module/preformatted/index.js.map +1 -1
- package/build-module/pullquote/deprecated.js +6 -7
- package/build-module/pullquote/deprecated.js.map +1 -1
- package/build-module/query/edit/enhanced-pagination-modal.js +50 -0
- package/build-module/query/edit/enhanced-pagination-modal.js.map +1 -0
- package/build-module/query/edit/inspector-controls/enhanced-pagination-control.js +35 -0
- package/build-module/query/edit/inspector-controls/enhanced-pagination-control.js.map +1 -0
- package/build-module/query/edit/inspector-controls/index.js +9 -26
- package/build-module/query/edit/inspector-controls/index.js.map +1 -1
- package/build-module/query/edit/query-content.js +8 -2
- package/build-module/query/edit/query-content.js.map +1 -1
- package/build-module/query/utils.js +17 -0
- package/build-module/query/utils.js.map +1 -1
- package/build-module/query/view.js +4 -5
- package/build-module/query/view.js.map +1 -1
- package/build-module/search/index.js +1 -0
- package/build-module/search/index.js.map +1 -1
- package/build-module/search/view.js +81 -151
- package/build-module/search/view.js.map +1 -1
- package/build-module/social-link/edit.native.js +3 -1
- package/build-module/social-link/edit.native.js.map +1 -1
- package/build-module/table/edit.js +7 -7
- package/build-module/table/edit.js.map +1 -1
- package/build-module/table-of-contents/edit.js +3 -131
- package/build-module/table-of-contents/edit.js.map +1 -1
- package/build-module/table-of-contents/hooks.js +137 -0
- package/build-module/table-of-contents/hooks.js.map +1 -0
- package/build-module/table-of-contents/index.js +2 -1
- package/build-module/table-of-contents/index.js.map +1 -1
- package/build-module/verse/edit.js +4 -1
- package/build-module/verse/edit.js.map +1 -1
- package/build-module/verse/index.js +1 -1
- package/build-module/verse/index.js.map +1 -1
- package/build-style/cover/style-rtl.css +9 -0
- package/build-style/cover/style.css +9 -0
- package/build-style/editor-rtl.css +15 -9
- package/build-style/editor.css +15 -9
- package/build-style/file/style-rtl.css +5 -0
- package/build-style/file/style.css +5 -0
- package/build-style/heading/style-rtl.css +13 -0
- package/build-style/heading/style.css +13 -0
- package/build-style/navigation-link/editor-rtl.css +0 -9
- package/build-style/navigation-link/editor.css +0 -9
- package/build-style/paragraph/editor-rtl.css +5 -0
- package/build-style/paragraph/editor.css +5 -0
- package/build-style/paragraph/style-rtl.css +5 -0
- package/build-style/paragraph/style.css +5 -0
- package/build-style/post-navigation-link/style-rtl.css +3 -0
- package/build-style/post-navigation-link/style.css +3 -0
- package/build-style/query/editor-rtl.css +10 -0
- package/build-style/query/editor.css +10 -0
- package/build-style/query/style-rtl.css +1 -1
- package/build-style/query/style.css +1 -1
- package/build-style/reset-rtl.css +27 -27
- package/build-style/reset.css +27 -27
- package/build-style/style-rtl.css +35 -0
- package/build-style/style.css +35 -0
- package/package.json +32 -33
- package/src/audio/test/__snapshots__/edit.native.js.snap +78 -106
- package/src/avatar/index.php +2 -2
- package/src/block/edit.js +58 -2
- package/src/block/test/edit.native.js +2 -3
- package/src/button/block.json +11 -2
- package/src/button/edit.js +27 -11
- package/src/button/save.js +10 -4
- package/src/buttons/edit.js +13 -3
- package/src/buttons/test/edit.native.js +28 -24
- package/src/calendar/index.php +2 -2
- package/src/code/block.json +2 -1
- package/src/code/edit.js +13 -1
- package/src/code/index.js +5 -0
- package/src/column/block.json +1 -0
- package/src/column/edit.native.js +4 -4
- package/src/columns/block.json +2 -0
- package/src/columns/test/__snapshots__/edit.native.js.snap +14 -0
- package/src/columns/test/edit.native.js +47 -17
- package/src/comment-template/index.php +1 -1
- package/src/comments-pagination-next/index.php +1 -1
- package/src/comments-pagination-previous/index.php +1 -1
- package/src/cover/style.scss +12 -1
- package/src/cover/test/edit.js +7 -7
- package/src/cover/test/edit.native.js +18 -27
- package/src/embed/test/index.native.js +30 -45
- package/src/file/block.json +2 -1
- package/src/file/edit.native.js +1 -1
- package/src/file/index.php +19 -21
- package/src/file/style.scss +6 -1
- package/src/file/test/__snapshots__/edit.native.js.snap +162 -218
- package/src/file/utils/index.js +0 -15
- package/src/file/view.js +14 -5
- package/src/footnotes/edit.js +16 -2
- package/src/gallery/edit.js +1 -1
- package/src/gallery/index.php +1 -1
- package/src/group/block.json +5 -0
- package/src/group/edit.js +0 -1
- package/src/heading/block.json +2 -0
- package/src/heading/edit.js +0 -1
- package/src/heading/style.scss +4 -0
- package/src/heading/transforms.js +1 -6
- package/src/image/block.json +7 -4
- package/src/image/deprecated.js +210 -7
- package/src/image/edit.js +43 -29
- package/src/image/image.js +86 -43
- package/src/image/index.php +251 -28
- package/src/latest-posts/index.php +1 -1
- package/src/list/deprecated.js +84 -3
- package/src/list/edit.js +6 -3
- package/src/list/ordered-list-settings.js +20 -5
- package/src/list/save.js +10 -1
- package/src/list/test/edit.native.js +2 -4
- package/src/list/utils.js +22 -1
- package/src/navigation/block.json +4 -2
- package/src/navigation/constants.js +1 -0
- package/src/navigation/index.php +85 -123
- package/src/navigation/view.js +192 -96
- package/src/navigation-link/edit.js +21 -36
- package/src/navigation-link/editor.scss +0 -8
- package/src/navigation-link/transforms.js +22 -0
- package/src/page-list/edit.js +2 -1
- package/src/paragraph/editor.scss +5 -0
- package/src/paragraph/style.scss +5 -0
- package/src/pattern/index.php +2 -2
- package/src/post-comments-form/edit.js +10 -0
- package/src/post-comments-form/form.js +7 -1
- package/src/post-content/block.json +3 -0
- package/src/post-content/edit.js +14 -6
- package/src/post-excerpt/index.php +2 -2
- package/src/post-featured-image/index.php +2 -2
- package/src/post-featured-image/overlay.js +1 -0
- package/src/post-navigation-link/index.php +5 -1
- package/src/post-navigation-link/style.scss +4 -0
- package/src/post-template/index.php +1 -1
- package/src/post-terms/index.php +5 -2
- package/src/post-terms/use-post-terms.js +4 -2
- package/src/preformatted/edit.js +5 -0
- package/src/preformatted/index.js +1 -1
- package/src/pullquote/deprecated.js +8 -13
- package/src/query/edit/enhanced-pagination-modal.js +65 -0
- package/src/query/edit/inspector-controls/enhanced-pagination-control.js +49 -0
- package/src/query/edit/inspector-controls/index.js +9 -45
- package/src/query/edit/query-content.js +8 -0
- package/src/query/editor.scss +10 -0
- package/src/query/index.php +29 -16
- package/src/query/style.scss +2 -2
- package/src/query/utils.js +22 -0
- package/src/query/view.js +5 -5
- package/src/query-pagination-next/index.php +1 -1
- package/src/query-pagination-previous/index.php +1 -1
- package/src/reset.scss +1 -1
- package/src/search/block.json +1 -0
- package/src/search/index.php +45 -4
- package/src/search/test/__snapshots__/edit.native.js.snap +265 -363
- package/src/search/view.js +70 -169
- package/src/social-link/edit.native.js +1 -1
- package/src/social-link/editor.native.scss +4 -0
- package/src/table/edit.js +21 -19
- package/src/table-of-contents/block.json +2 -1
- package/src/table-of-contents/edit.js +5 -162
- package/src/table-of-contents/hooks.js +156 -0
- package/src/verse/edit.js +5 -0
- package/src/verse/index.js +1 -1
- package/src/verse/test/edit.native.js +2 -3
- package/build/file/view-interactivity.js +0 -22
- package/build/file/view-interactivity.js.map +0 -1
- package/build/image/view-interactivity.js.map +0 -1
- package/build/navigation/view-interactivity.js +0 -172
- package/build/navigation/view-interactivity.js.map +0 -1
- package/build/navigation/view-modal.js +0 -115
- package/build/navigation/view-modal.js.map +0 -1
- package/build-module/file/view-interactivity.js +0 -18
- package/build-module/file/view-interactivity.js.map +0 -1
- package/build-module/image/view-interactivity.js.map +0 -1
- package/build-module/navigation/view-interactivity.js +0 -169
- package/build-module/navigation/view-interactivity.js.map +0 -1
- package/build-module/navigation/view-modal.js +0 -112
- package/build-module/navigation/view-modal.js.map +0 -1
- package/src/file/view-interactivity.js +0 -18
- package/src/navigation/view-interactivity.js +0 -196
- package/src/navigation/view-modal.js +0 -127
- /package/src/image/{view-interactivity.js → view.js} +0 -0
package/build/verse/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_i18n","require","_icons","_initBlock","_interopRequireDefault","_deprecated","_edit","_save","_transforms","metadata","$schema","apiVersion","name","title","category","description","keywords","textdomain","attributes","content","type","source","selector","__unstablePreserveWhiteSpace","__experimentalRole","textAlign","supports","anchor","color","gradients","link","__experimentalDefaultControls","background","text","typography","fontSize","__experimentalFontFamily","lineHeight","__experimentalFontStyle","__experimentalFontWeight","__experimentalLetterSpacing","__experimentalTextTransform","__experimentalTextDecoration","fontAppearance","spacing","margin","padding","__experimentalBorder","radius","width","style","editorStyle","exports","settings","icon","example","__","transforms","deprecated","merge","attributesToMerge","edit","save","init","initBlock"],"sources":["@wordpress/block-library/src/verse/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { verse as icon } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport initBlock from '../utils/init-block';\nimport deprecated from './deprecated';\nimport edit from './edit';\nimport metadata from './block.json';\nimport save from './save';\nimport transforms from './transforms';\n\nconst { name } = metadata;\n\nexport { metadata, name };\n\nexport const settings = {\n\ticon,\n\texample: {\n\t\tattributes: {\n\t\t\t/* eslint-disable @wordpress/i18n-no-collapsible-whitespace */\n\t\t\t// translators: Sample content for the Verse block. Can be replaced with a more locale-adequate work.\n\t\t\tcontent: __(\n\t\t\t\t'WHAT was he doing, the great god Pan,\\n\tDown in the reeds by the river?\\nSpreading ruin and scattering ban,\\nSplashing and paddling with hoofs of a goat,\\nAnd breaking the golden lilies afloat\\n With the dragon-fly on the river.'\n\t\t\t),\n\t\t\t/* eslint-enable @wordpress/i18n-no-collapsible-whitespace */\n\t\t},\n\t},\n\ttransforms,\n\tdeprecated,\n\tmerge( attributes, attributesToMerge ) {\n\t\treturn {\n\t\t\tcontent: attributes.content + attributesToMerge.content,\n\t\t};\n\t},\n\tedit,\n\tsave,\n};\n\nexport const init = () => initBlock( { name, metadata, settings } );\n"],"mappings":";;;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AAKA,IAAAE,UAAA,GAAAC,sBAAA,CAAAH,OAAA;AACA,IAAAI,WAAA,GAAAD,sBAAA,CAAAH,OAAA;AACA,IAAAK,KAAA,GAAAF,sBAAA,CAAAH,OAAA;AAEA,IAAAM,KAAA,GAAAH,sBAAA,CAAAH,OAAA;AACA,IAAAO,WAAA,GAAAJ,sBAAA,CAAAH,OAAA;AAdA;AACA;AACA;AAIA;AACA;AACA;AAFA,MAAAQ,QAAA;EAAAC,OAAA;EAAAC,UAAA;EAAAC,IAAA;EAAAC,KAAA;EAAAC,QAAA;EAAAC,WAAA;EAAAC,QAAA;EAAAC,UAAA;EAAAC,UAAA;IAAAC,OAAA;MAAAC,IAAA;MAAAC,MAAA;MAAAC,QAAA;MAAA;MAAAC,4BAAA;MAAAC,kBAAA;IAAA;IAAAC,SAAA;MAAAL,IAAA;IAAA;EAAA;EAAAM,QAAA;IAAAC,MAAA;IAAAC,KAAA;MAAAC,SAAA;MAAAC,IAAA;MAAAC,6BAAA;QAAAC,UAAA;QAAAC,IAAA;MAAA;IAAA;IAAAC,UAAA;MAAAC,QAAA;MAAAC,wBAAA;MAAAC,UAAA;MAAAC,uBAAA;MAAAC,wBAAA;MAAAC,2BAAA;MAAAC,2BAAA;MAAAC,4BAAA;MAAAX,6BAAA;QAAAI,QAAA;QAAAQ,cAAA;MAAA;IAAA;IAAAC,OAAA;MAAAC,MAAA;MAAAC,OAAA;MAAAf,6BAAA;QAAAc,MAAA;QAAAC,OAAA;MAAA;IAAA;IAAAC,oBAAA;MAAAC,MAAA;MAAAC,KAAA;MAAArB,KAAA;MAAAsB,KAAA;IAAA;EAAA;EAAAA,KAAA;EAAAC,WAAA;AAAA;AAAAC,OAAA,CAAA3C,QAAA,GAAAA,QAAA;AAUA,MAAM;EAAEG;AAAK,CAAC,GAAGH,QAAQ;AAAC2C,OAAA,CAAAxC,IAAA,GAAAA,IAAA;AAInB,MAAMyC,QAAQ,GAAG;EACvBC,IAAI,EAAJA,YAAI;EACJC,OAAO,EAAE;IACRrC,UAAU,EAAE;MACX;MACA;MACAC,OAAO,EAAE,IAAAqC,QAAE,EACV,yOACD;MACA;IACD;EACD,CAAC;;EACDC,UAAU,EAAVA,mBAAU;EACVC,UAAU,EAAVA,mBAAU;EACVC,KAAKA,CAAEzC,UAAU,EAAE0C,iBAAiB,EAAG;IACtC,OAAO;MACNzC,OAAO,EAAED,UAAU,CAACC,OAAO,GAAGyC,iBAAiB,CAACzC;
|
|
1
|
+
{"version":3,"names":["_i18n","require","_icons","_initBlock","_interopRequireDefault","_deprecated","_edit","_save","_transforms","metadata","$schema","apiVersion","name","title","category","description","keywords","textdomain","attributes","content","type","source","selector","__unstablePreserveWhiteSpace","__experimentalRole","textAlign","supports","anchor","color","gradients","link","__experimentalDefaultControls","background","text","typography","fontSize","__experimentalFontFamily","lineHeight","__experimentalFontStyle","__experimentalFontWeight","__experimentalLetterSpacing","__experimentalTextTransform","__experimentalTextDecoration","fontAppearance","spacing","margin","padding","__experimentalBorder","radius","width","style","editorStyle","exports","settings","icon","example","__","transforms","deprecated","merge","attributesToMerge","edit","save","init","initBlock"],"sources":["@wordpress/block-library/src/verse/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { verse as icon } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport initBlock from '../utils/init-block';\nimport deprecated from './deprecated';\nimport edit from './edit';\nimport metadata from './block.json';\nimport save from './save';\nimport transforms from './transforms';\n\nconst { name } = metadata;\n\nexport { metadata, name };\n\nexport const settings = {\n\ticon,\n\texample: {\n\t\tattributes: {\n\t\t\t/* eslint-disable @wordpress/i18n-no-collapsible-whitespace */\n\t\t\t// translators: Sample content for the Verse block. Can be replaced with a more locale-adequate work.\n\t\t\tcontent: __(\n\t\t\t\t'WHAT was he doing, the great god Pan,\\n\tDown in the reeds by the river?\\nSpreading ruin and scattering ban,\\nSplashing and paddling with hoofs of a goat,\\nAnd breaking the golden lilies afloat\\n With the dragon-fly on the river.'\n\t\t\t),\n\t\t\t/* eslint-enable @wordpress/i18n-no-collapsible-whitespace */\n\t\t},\n\t},\n\ttransforms,\n\tdeprecated,\n\tmerge( attributes, attributesToMerge ) {\n\t\treturn {\n\t\t\tcontent: attributes.content + '\\n\\n' + attributesToMerge.content,\n\t\t};\n\t},\n\tedit,\n\tsave,\n};\n\nexport const init = () => initBlock( { name, metadata, settings } );\n"],"mappings":";;;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AAKA,IAAAE,UAAA,GAAAC,sBAAA,CAAAH,OAAA;AACA,IAAAI,WAAA,GAAAD,sBAAA,CAAAH,OAAA;AACA,IAAAK,KAAA,GAAAF,sBAAA,CAAAH,OAAA;AAEA,IAAAM,KAAA,GAAAH,sBAAA,CAAAH,OAAA;AACA,IAAAO,WAAA,GAAAJ,sBAAA,CAAAH,OAAA;AAdA;AACA;AACA;AAIA;AACA;AACA;AAFA,MAAAQ,QAAA;EAAAC,OAAA;EAAAC,UAAA;EAAAC,IAAA;EAAAC,KAAA;EAAAC,QAAA;EAAAC,WAAA;EAAAC,QAAA;EAAAC,UAAA;EAAAC,UAAA;IAAAC,OAAA;MAAAC,IAAA;MAAAC,MAAA;MAAAC,QAAA;MAAA;MAAAC,4BAAA;MAAAC,kBAAA;IAAA;IAAAC,SAAA;MAAAL,IAAA;IAAA;EAAA;EAAAM,QAAA;IAAAC,MAAA;IAAAC,KAAA;MAAAC,SAAA;MAAAC,IAAA;MAAAC,6BAAA;QAAAC,UAAA;QAAAC,IAAA;MAAA;IAAA;IAAAC,UAAA;MAAAC,QAAA;MAAAC,wBAAA;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 'classnames';
|
|
6
|
+
|
|
2
7
|
/**
|
|
3
8
|
* WordPress dependencies
|
|
4
9
|
*/
|
|
5
10
|
import { useEntityBlockEditor, useEntityProp, useEntityRecord } from '@wordpress/core-data';
|
|
6
11
|
import { Placeholder, Spinner, TextControl, PanelBody } from '@wordpress/components';
|
|
7
12
|
import { __ } from '@wordpress/i18n';
|
|
8
|
-
import { useInnerBlocksProps, __experimentalRecursionProvider as RecursionProvider, __experimentalUseHasRecursion as useHasRecursion, InnerBlocks, InspectorControls, useBlockProps, Warning } from '@wordpress/block-editor';
|
|
13
|
+
import { useInnerBlocksProps, __experimentalRecursionProvider as RecursionProvider, __experimentalUseHasRecursion as useHasRecursion, InnerBlocks, InspectorControls, useBlockProps, Warning, privateApis as blockEditorPrivateApis } from '@wordpress/block-editor';
|
|
14
|
+
import { useRef, useMemo } from '@wordpress/element';
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Internal dependencies
|
|
18
|
+
*/
|
|
19
|
+
import { unlock } from '../lock-unlock';
|
|
20
|
+
const fullAlignments = ['full', 'wide', 'left', 'right'];
|
|
21
|
+
const useInferredLayout = (blocks, parentLayout) => {
|
|
22
|
+
const initialInferredAlignmentRef = useRef();
|
|
23
|
+
return useMemo(() => {
|
|
24
|
+
// Exit early if the pattern's blocks haven't loaded yet.
|
|
25
|
+
if (!blocks?.length) {
|
|
26
|
+
return {};
|
|
27
|
+
}
|
|
28
|
+
let alignment = initialInferredAlignmentRef.current;
|
|
29
|
+
|
|
30
|
+
// Only track the initial alignment so that temporarily removed
|
|
31
|
+
// alignments can be reapplied.
|
|
32
|
+
if (alignment === undefined) {
|
|
33
|
+
const isConstrained = parentLayout?.type === 'constrained';
|
|
34
|
+
const hasFullAlignment = blocks.some(block => fullAlignments.includes(block.attributes.align));
|
|
35
|
+
alignment = isConstrained && hasFullAlignment ? 'full' : null;
|
|
36
|
+
initialInferredAlignmentRef.current = alignment;
|
|
37
|
+
}
|
|
38
|
+
const layout = alignment ? parentLayout : undefined;
|
|
39
|
+
return {
|
|
40
|
+
alignment,
|
|
41
|
+
layout
|
|
42
|
+
};
|
|
43
|
+
}, [blocks, parentLayout]);
|
|
44
|
+
};
|
|
9
45
|
export default function ReusableBlockEdit({
|
|
46
|
+
name,
|
|
10
47
|
attributes: {
|
|
11
48
|
ref
|
|
12
|
-
}
|
|
49
|
+
},
|
|
50
|
+
__unstableParentLayout: parentLayout
|
|
13
51
|
}) {
|
|
52
|
+
const {
|
|
53
|
+
useLayoutClasses
|
|
54
|
+
} = unlock(blockEditorPrivateApis);
|
|
14
55
|
const hasAlreadyRendered = useHasRecursion(ref);
|
|
15
56
|
const {
|
|
16
57
|
record,
|
|
@@ -21,11 +62,21 @@ export default function ReusableBlockEdit({
|
|
|
21
62
|
id: ref
|
|
22
63
|
});
|
|
23
64
|
const [title, setTitle] = useEntityProp('postType', 'wp_block', 'title', ref);
|
|
65
|
+
const {
|
|
66
|
+
alignment,
|
|
67
|
+
layout
|
|
68
|
+
} = useInferredLayout(blocks, parentLayout);
|
|
69
|
+
const layoutClasses = useLayoutClasses({
|
|
70
|
+
layout
|
|
71
|
+
}, name);
|
|
24
72
|
const blockProps = useBlockProps({
|
|
25
|
-
className: 'block-library-block__reusable-block-container'
|
|
73
|
+
className: classnames('block-library-block__reusable-block-container', layout && layoutClasses, {
|
|
74
|
+
[`align${alignment}`]: alignment
|
|
75
|
+
})
|
|
26
76
|
});
|
|
27
77
|
const innerBlocksProps = useInnerBlocksProps(blockProps, {
|
|
28
78
|
value: blocks,
|
|
79
|
+
layout,
|
|
29
80
|
onInput,
|
|
30
81
|
onChange,
|
|
31
82
|
renderAppender: blocks?.length ? undefined : InnerBlocks.ButtonBlockAppender
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useEntityBlockEditor","useEntityProp","useEntityRecord","Placeholder","Spinner","TextControl","PanelBody","__","useInnerBlocksProps","__experimentalRecursionProvider","RecursionProvider","__experimentalUseHasRecursion","useHasRecursion","InnerBlocks","InspectorControls","useBlockProps","Warning","
|
|
1
|
+
{"version":3,"names":["classnames","useEntityBlockEditor","useEntityProp","useEntityRecord","Placeholder","Spinner","TextControl","PanelBody","__","useInnerBlocksProps","__experimentalRecursionProvider","RecursionProvider","__experimentalUseHasRecursion","useHasRecursion","InnerBlocks","InspectorControls","useBlockProps","Warning","privateApis","blockEditorPrivateApis","useRef","useMemo","unlock","fullAlignments","useInferredLayout","blocks","parentLayout","initialInferredAlignmentRef","length","alignment","current","undefined","isConstrained","type","hasFullAlignment","some","block","includes","attributes","align","layout","ReusableBlockEdit","name","ref","__unstableParentLayout","useLayoutClasses","hasAlreadyRendered","record","hasResolved","isMissing","onInput","onChange","id","title","setTitle","layoutClasses","blockProps","className","innerBlocksProps","value","renderAppender","ButtonBlockAppender","createElement","uniqueId","__nextHasNoMarginBottom","label"],"sources":["@wordpress/block-library/src/block/edit.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tuseEntityBlockEditor,\n\tuseEntityProp,\n\tuseEntityRecord,\n} from '@wordpress/core-data';\nimport {\n\tPlaceholder,\n\tSpinner,\n\tTextControl,\n\tPanelBody,\n} from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport {\n\tuseInnerBlocksProps,\n\t__experimentalRecursionProvider as RecursionProvider,\n\t__experimentalUseHasRecursion as useHasRecursion,\n\tInnerBlocks,\n\tInspectorControls,\n\tuseBlockProps,\n\tWarning,\n\tprivateApis as blockEditorPrivateApis,\n} from '@wordpress/block-editor';\nimport { useRef, useMemo } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../lock-unlock';\n\nconst fullAlignments = [ 'full', 'wide', 'left', 'right' ];\n\nconst useInferredLayout = ( blocks, parentLayout ) => {\n\tconst initialInferredAlignmentRef = useRef();\n\n\treturn useMemo( () => {\n\t\t// Exit early if the pattern's blocks haven't loaded yet.\n\t\tif ( ! blocks?.length ) {\n\t\t\treturn {};\n\t\t}\n\n\t\tlet alignment = initialInferredAlignmentRef.current;\n\n\t\t// Only track the initial alignment so that temporarily removed\n\t\t// alignments can be reapplied.\n\t\tif ( alignment === undefined ) {\n\t\t\tconst isConstrained = parentLayout?.type === 'constrained';\n\t\t\tconst hasFullAlignment = blocks.some( ( block ) =>\n\t\t\t\tfullAlignments.includes( block.attributes.align )\n\t\t\t);\n\n\t\t\talignment = isConstrained && hasFullAlignment ? 'full' : null;\n\t\t\tinitialInferredAlignmentRef.current = alignment;\n\t\t}\n\n\t\tconst layout = alignment ? parentLayout : undefined;\n\n\t\treturn { alignment, layout };\n\t}, [ blocks, parentLayout ] );\n};\n\nexport default function ReusableBlockEdit( {\n\tname,\n\tattributes: { ref },\n\t__unstableParentLayout: parentLayout,\n} ) {\n\tconst { useLayoutClasses } = unlock( blockEditorPrivateApis );\n\tconst hasAlreadyRendered = useHasRecursion( ref );\n\tconst { record, hasResolved } = useEntityRecord(\n\t\t'postType',\n\t\t'wp_block',\n\t\tref\n\t);\n\tconst isMissing = hasResolved && ! record;\n\n\tconst [ blocks, onInput, onChange ] = useEntityBlockEditor(\n\t\t'postType',\n\t\t'wp_block',\n\t\t{ id: ref }\n\t);\n\n\tconst [ title, setTitle ] = useEntityProp(\n\t\t'postType',\n\t\t'wp_block',\n\t\t'title',\n\t\tref\n\t);\n\n\tconst { alignment, layout } = useInferredLayout( blocks, parentLayout );\n\tconst layoutClasses = useLayoutClasses( { layout }, name );\n\n\tconst blockProps = useBlockProps( {\n\t\tclassName: classnames(\n\t\t\t'block-library-block__reusable-block-container',\n\t\t\tlayout && layoutClasses,\n\t\t\t{ [ `align${ alignment }` ]: alignment }\n\t\t),\n\t} );\n\n\tconst innerBlocksProps = useInnerBlocksProps( blockProps, {\n\t\tvalue: blocks,\n\t\tlayout,\n\t\tonInput,\n\t\tonChange,\n\t\trenderAppender: blocks?.length\n\t\t\t? undefined\n\t\t\t: InnerBlocks.ButtonBlockAppender,\n\t} );\n\n\tif ( hasAlreadyRendered ) {\n\t\treturn (\n\t\t\t<div { ...blockProps }>\n\t\t\t\t<Warning>\n\t\t\t\t\t{ __( 'Block cannot be rendered inside itself.' ) }\n\t\t\t\t</Warning>\n\t\t\t</div>\n\t\t);\n\t}\n\n\tif ( isMissing ) {\n\t\treturn (\n\t\t\t<div { ...blockProps }>\n\t\t\t\t<Warning>\n\t\t\t\t\t{ __( 'Block has been deleted or is unavailable.' ) }\n\t\t\t\t</Warning>\n\t\t\t</div>\n\t\t);\n\t}\n\n\tif ( ! hasResolved ) {\n\t\treturn (\n\t\t\t<div { ...blockProps }>\n\t\t\t\t<Placeholder>\n\t\t\t\t\t<Spinner />\n\t\t\t\t</Placeholder>\n\t\t\t</div>\n\t\t);\n\t}\n\n\treturn (\n\t\t<RecursionProvider uniqueId={ ref }>\n\t\t\t<InspectorControls>\n\t\t\t\t<PanelBody>\n\t\t\t\t\t<TextControl\n\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\tlabel={ __( 'Name' ) }\n\t\t\t\t\t\tvalue={ title }\n\t\t\t\t\t\tonChange={ setTitle }\n\t\t\t\t\t/>\n\t\t\t\t</PanelBody>\n\t\t\t</InspectorControls>\n\t\t\t<div { ...innerBlocksProps } />\n\t\t</RecursionProvider>\n\t);\n}\n"],"mappings":";AAAA;AACA;AACA;AACA,OAAOA,UAAU,MAAM,YAAY;;AAEnC;AACA;AACA;AACA,SACCC,oBAAoB,EACpBC,aAAa,EACbC,eAAe,QACT,sBAAsB;AAC7B,SACCC,WAAW,EACXC,OAAO,EACPC,WAAW,EACXC,SAAS,QACH,uBAAuB;AAC9B,SAASC,EAAE,QAAQ,iBAAiB;AACpC,SACCC,mBAAmB,EACnBC,+BAA+B,IAAIC,iBAAiB,EACpDC,6BAA6B,IAAIC,eAAe,EAChDC,WAAW,EACXC,iBAAiB,EACjBC,aAAa,EACbC,OAAO,EACPC,WAAW,IAAIC,sBAAsB,QAC/B,yBAAyB;AAChC,SAASC,MA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4C,CAC1C,CACL,CAAC;EAER;EAEA,IAAK,CAAEwC,WAAW,EAAG;IACpB,OACCc,aAAA;MAAA,GAAUN;IAAU,GACnBM,aAAA,CAAC1D,WAAW,QACX0D,aAAA,CAACzD,OAAO,MAAE,CACE,CACT,CAAC;EAER;EAEA,OACCyD,aAAA,CAACnD,iBAAiB;IAACoD,QAAQ,EAAGpB;EAAK,GAClCmB,aAAA,CAAC/C,iBAAiB,QACjB+C,aAAA,CAACvD,SAAS,QACTuD,aAAA,CAACxD,WAAW;IACX0D,uBAAuB;IACvBC,KAAK,EAAGzD,EAAE,CAAE,MAAO,CAAG;IACtBmD,KAAK,EAAGN,KAAO;IACfF,QAAQ,EAAGG;EAAU,CACrB,CACS,CACO,CAAC,EACpBQ,aAAA;IAAA,GAAUJ;EAAgB,CAAI,CACZ,CAAC;AAEtB"}
|
|
@@ -53,6 +53,7 @@ function ButtonEdit(props) {
|
|
|
53
53
|
mergeBlocks
|
|
54
54
|
} = props;
|
|
55
55
|
const {
|
|
56
|
+
tagName,
|
|
56
57
|
textAlign,
|
|
57
58
|
linkTarget,
|
|
58
59
|
placeholder,
|
|
@@ -62,6 +63,7 @@ function ButtonEdit(props) {
|
|
|
62
63
|
url,
|
|
63
64
|
width
|
|
64
65
|
} = attributes;
|
|
66
|
+
const TagName = tagName || 'a';
|
|
65
67
|
function onToggleOpenInNewTab(value) {
|
|
66
68
|
const newLinkTarget = value ? '_blank' : undefined;
|
|
67
69
|
let updatedRel = rel;
|
|
@@ -105,6 +107,7 @@ function ButtonEdit(props) {
|
|
|
105
107
|
const [isEditingURL, setIsEditingURL] = useState(false);
|
|
106
108
|
const isURLSet = !!url;
|
|
107
109
|
const opensInNewTab = linkTarget === '_blank';
|
|
110
|
+
const isLinkTag = 'a' === TagName;
|
|
108
111
|
function startEditing(event) {
|
|
109
112
|
event.preventDefault();
|
|
110
113
|
setIsEditingURL(true);
|
|
@@ -169,20 +172,20 @@ function ButtonEdit(props) {
|
|
|
169
172
|
textAlign: nextAlign
|
|
170
173
|
});
|
|
171
174
|
}
|
|
172
|
-
}), !isURLSet && createElement(ToolbarButton, {
|
|
175
|
+
}), !isURLSet && isLinkTag && createElement(ToolbarButton, {
|
|
173
176
|
name: "link",
|
|
174
177
|
icon: link,
|
|
175
178
|
title: __('Link'),
|
|
176
179
|
shortcut: displayShortcut.primary('k'),
|
|
177
180
|
onClick: startEditing
|
|
178
|
-
}), isURLSet && createElement(ToolbarButton, {
|
|
181
|
+
}), isURLSet && isLinkTag && createElement(ToolbarButton, {
|
|
179
182
|
name: "link",
|
|
180
183
|
icon: linkOff,
|
|
181
184
|
title: __('Unlink'),
|
|
182
185
|
shortcut: displayShortcut.primaryShift('k'),
|
|
183
186
|
onClick: unlink,
|
|
184
187
|
isActive: true
|
|
185
|
-
})), isSelected && (isEditingURL || isURLSet) && createElement(Popover, {
|
|
188
|
+
})), isLinkTag && isSelected && (isEditingURL || isURLSet) && createElement(Popover, {
|
|
186
189
|
placement: "bottom",
|
|
187
190
|
onClose: () => {
|
|
188
191
|
setIsEditingURL(false);
|
|
@@ -215,7 +218,7 @@ function ButtonEdit(props) {
|
|
|
215
218
|
setAttributes: setAttributes
|
|
216
219
|
})), createElement(InspectorControls, {
|
|
217
220
|
group: "advanced"
|
|
218
|
-
}, createElement(TextControl, {
|
|
221
|
+
}, isLinkTag && createElement(TextControl, {
|
|
219
222
|
__nextHasNoMarginBottom: true,
|
|
220
223
|
label: __('Link rel'),
|
|
221
224
|
value: rel || '',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["classnames","__","useEffect","useState","useRef","useMemo","Button","ButtonGroup","PanelBody","TextControl","ToolbarButton","Popover","AlignmentControl","BlockControls","InspectorControls","RichText","useBlockProps","__experimentalUseBorderProps","useBorderProps","__experimentalUseColorProps","useColorProps","__experimentalGetSpacingClassesAndStyles","useSpacingProps","__experimentalLinkControl","LinkControl","__experimentalGetElementClassName","displayShortcut","isKeyboardEvent","link","linkOff","createBlock","useMergeRefs","prependHTTP","NEW_TAB_REL","WidthPanel","selectedWidth","setAttributes","handleChange","newWidth","width","undefined","createElement","title","map","widthValue","key","size","variant","onClick","ButtonEdit","props","attributes","className","isSelected","onReplace","mergeBlocks","textAlign","linkTarget","placeholder","rel","style","text","url","onToggleOpenInNewTab","value","newLinkTarget","updatedRel","setButtonText","newText","replace","onKeyDown","event","primary","startEditing","primaryShift","unlink","richTextRef","current","focus","popoverAnchor","setPopoverAnchor","borderProps","colorProps","spacingProps","ref","blockProps","isEditingURL","setIsEditingURL","isURLSet","opensInNewTab","preventDefault","linkValue","Fragment","fontSize","onChange","withoutInteractiveFormatting","border","radius","onSplit","onMerge","identifier","group","nextAlign","name","icon","shortcut","isActive","placement","onClose","anchor","focusOnMount","__unstableSlotName","shift","newURL","newOpensInNewTab","onRemove","forceIsEditingLink","__nextHasNoMarginBottom","label","newRel"],"sources":["@wordpress/block-library/src/button/edit.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { useEffect, useState, useRef, useMemo } from '@wordpress/element';\nimport {\n\tButton,\n\tButtonGroup,\n\tPanelBody,\n\tTextControl,\n\tToolbarButton,\n\tPopover,\n} from '@wordpress/components';\nimport {\n\tAlignmentControl,\n\tBlockControls,\n\tInspectorControls,\n\tRichText,\n\tuseBlockProps,\n\t__experimentalUseBorderProps as useBorderProps,\n\t__experimentalUseColorProps as useColorProps,\n\t__experimentalGetSpacingClassesAndStyles as useSpacingProps,\n\t__experimentalLinkControl as LinkControl,\n\t__experimentalGetElementClassName,\n} from '@wordpress/block-editor';\nimport { displayShortcut, isKeyboardEvent } from '@wordpress/keycodes';\nimport { link, linkOff } from '@wordpress/icons';\nimport { createBlock } from '@wordpress/blocks';\nimport { useMergeRefs } from '@wordpress/compose';\nimport { prependHTTP } from '@wordpress/url';\n\nconst NEW_TAB_REL = 'noreferrer noopener';\n\nfunction WidthPanel( { selectedWidth, setAttributes } ) {\n\tfunction handleChange( newWidth ) {\n\t\t// Check if we are toggling the width off\n\t\tconst width = selectedWidth === newWidth ? undefined : newWidth;\n\n\t\t// Update attributes.\n\t\tsetAttributes( { width } );\n\t}\n\n\treturn (\n\t\t<PanelBody title={ __( 'Width settings' ) }>\n\t\t\t<ButtonGroup aria-label={ __( 'Button width' ) }>\n\t\t\t\t{ [ 25, 50, 75, 100 ].map( ( widthValue ) => {\n\t\t\t\t\treturn (\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\tkey={ widthValue }\n\t\t\t\t\t\t\tsize=\"small\"\n\t\t\t\t\t\t\tvariant={\n\t\t\t\t\t\t\t\twidthValue === selectedWidth\n\t\t\t\t\t\t\t\t\t? 'primary'\n\t\t\t\t\t\t\t\t\t: undefined\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tonClick={ () => handleChange( widthValue ) }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ widthValue }%\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t);\n\t\t\t\t} ) }\n\t\t\t</ButtonGroup>\n\t\t</PanelBody>\n\t);\n}\n\nfunction ButtonEdit( props ) {\n\tconst {\n\t\tattributes,\n\t\tsetAttributes,\n\t\tclassName,\n\t\tisSelected,\n\t\tonReplace,\n\t\tmergeBlocks,\n\t} = props;\n\tconst { textAlign, linkTarget, placeholder, rel, style, text, url, width } =\n\t\tattributes;\n\n\tfunction onToggleOpenInNewTab( value ) {\n\t\tconst newLinkTarget = value ? '_blank' : undefined;\n\n\t\tlet updatedRel = rel;\n\t\tif ( newLinkTarget && ! rel ) {\n\t\t\tupdatedRel = NEW_TAB_REL;\n\t\t} else if ( ! newLinkTarget && rel === NEW_TAB_REL ) {\n\t\t\tupdatedRel = undefined;\n\t\t}\n\n\t\tsetAttributes( {\n\t\t\tlinkTarget: newLinkTarget,\n\t\t\trel: updatedRel,\n\t\t} );\n\t}\n\n\tfunction setButtonText( newText ) {\n\t\t// Remove anchor tags from button text content.\n\t\tsetAttributes( { text: newText.replace( /<\\/?a[^>]*>/g, '' ) } );\n\t}\n\n\tfunction onKeyDown( event ) {\n\t\tif ( isKeyboardEvent.primary( event, 'k' ) ) {\n\t\t\tstartEditing( event );\n\t\t} else if ( isKeyboardEvent.primaryShift( event, 'k' ) ) {\n\t\t\tunlink();\n\t\t\trichTextRef.current?.focus();\n\t\t}\n\t}\n\n\t// Use internal state instead of a ref to make sure that the component\n\t// re-renders when the popover's anchor updates.\n\tconst [ popoverAnchor, setPopoverAnchor ] = useState( null );\n\n\tconst borderProps = useBorderProps( attributes );\n\tconst colorProps = useColorProps( attributes );\n\tconst spacingProps = useSpacingProps( attributes );\n\tconst ref = useRef();\n\tconst richTextRef = useRef();\n\tconst blockProps = useBlockProps( {\n\t\tref: useMergeRefs( [ setPopoverAnchor, ref ] ),\n\t\tonKeyDown,\n\t} );\n\n\tconst [ isEditingURL, setIsEditingURL ] = useState( false );\n\tconst isURLSet = !! url;\n\tconst opensInNewTab = linkTarget === '_blank';\n\n\tfunction startEditing( event ) {\n\t\tevent.preventDefault();\n\t\tsetIsEditingURL( true );\n\t}\n\n\tfunction unlink() {\n\t\tsetAttributes( {\n\t\t\turl: undefined,\n\t\t\tlinkTarget: undefined,\n\t\t\trel: undefined,\n\t\t} );\n\t\tsetIsEditingURL( false );\n\t}\n\n\tuseEffect( () => {\n\t\tif ( ! isSelected ) {\n\t\t\tsetIsEditingURL( false );\n\t\t}\n\t}, [ isSelected ] );\n\n\t// Memoize link value to avoid overriding the LinkControl's internal state.\n\t// This is a temporary fix. See https://github.com/WordPress/gutenberg/issues/51256.\n\tconst linkValue = useMemo(\n\t\t() => ( { url, opensInNewTab } ),\n\t\t[ url, opensInNewTab ]\n\t);\n\n\treturn (\n\t\t<>\n\t\t\t<div\n\t\t\t\t{ ...blockProps }\n\t\t\t\tclassName={ classnames( blockProps.className, {\n\t\t\t\t\t[ `has-custom-width wp-block-button__width-${ width }` ]:\n\t\t\t\t\t\twidth,\n\t\t\t\t\t[ `has-custom-font-size` ]: blockProps.style.fontSize,\n\t\t\t\t} ) }\n\t\t\t>\n\t\t\t\t<RichText\n\t\t\t\t\tref={ richTextRef }\n\t\t\t\t\taria-label={ __( 'Button text' ) }\n\t\t\t\t\tplaceholder={ placeholder || __( 'Add text…' ) }\n\t\t\t\t\tvalue={ text }\n\t\t\t\t\tonChange={ ( value ) => setButtonText( value ) }\n\t\t\t\t\twithoutInteractiveFormatting\n\t\t\t\t\tclassName={ classnames(\n\t\t\t\t\t\tclassName,\n\t\t\t\t\t\t'wp-block-button__link',\n\t\t\t\t\t\tcolorProps.className,\n\t\t\t\t\t\tborderProps.className,\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t[ `has-text-align-${ textAlign }` ]: textAlign,\n\t\t\t\t\t\t\t// For backwards compatibility add style that isn't\n\t\t\t\t\t\t\t// provided via block support.\n\t\t\t\t\t\t\t'no-border-radius': style?.border?.radius === 0,\n\t\t\t\t\t\t},\n\t\t\t\t\t\t__experimentalGetElementClassName( 'button' )\n\t\t\t\t\t) }\n\t\t\t\t\tstyle={ {\n\t\t\t\t\t\t...borderProps.style,\n\t\t\t\t\t\t...colorProps.style,\n\t\t\t\t\t\t...spacingProps.style,\n\t\t\t\t\t} }\n\t\t\t\t\tonSplit={ ( value ) =>\n\t\t\t\t\t\tcreateBlock( 'core/button', {\n\t\t\t\t\t\t\t...attributes,\n\t\t\t\t\t\t\ttext: value,\n\t\t\t\t\t\t} )\n\t\t\t\t\t}\n\t\t\t\t\tonReplace={ onReplace }\n\t\t\t\t\tonMerge={ mergeBlocks }\n\t\t\t\t\tidentifier=\"text\"\n\t\t\t\t/>\n\t\t\t</div>\n\t\t\t<BlockControls group=\"block\">\n\t\t\t\t<AlignmentControl\n\t\t\t\t\tvalue={ textAlign }\n\t\t\t\t\tonChange={ ( nextAlign ) => {\n\t\t\t\t\t\tsetAttributes( { textAlign: nextAlign } );\n\t\t\t\t\t} }\n\t\t\t\t/>\n\t\t\t\t{ ! isURLSet && (\n\t\t\t\t\t<ToolbarButton\n\t\t\t\t\t\tname=\"link\"\n\t\t\t\t\t\ticon={ link }\n\t\t\t\t\t\ttitle={ __( 'Link' ) }\n\t\t\t\t\t\tshortcut={ displayShortcut.primary( 'k' ) }\n\t\t\t\t\t\tonClick={ startEditing }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t\t{ isURLSet && (\n\t\t\t\t\t<ToolbarButton\n\t\t\t\t\t\tname=\"link\"\n\t\t\t\t\t\ticon={ linkOff }\n\t\t\t\t\t\ttitle={ __( 'Unlink' ) }\n\t\t\t\t\t\tshortcut={ displayShortcut.primaryShift( 'k' ) }\n\t\t\t\t\t\tonClick={ unlink }\n\t\t\t\t\t\tisActive={ true }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t</BlockControls>\n\t\t\t{ isSelected && ( isEditingURL || isURLSet ) && (\n\t\t\t\t<Popover\n\t\t\t\t\tplacement=\"bottom\"\n\t\t\t\t\tonClose={ () => {\n\t\t\t\t\t\tsetIsEditingURL( false );\n\t\t\t\t\t\trichTextRef.current?.focus();\n\t\t\t\t\t} }\n\t\t\t\t\tanchor={ popoverAnchor }\n\t\t\t\t\tfocusOnMount={ isEditingURL ? 'firstElement' : false }\n\t\t\t\t\t__unstableSlotName={ '__unstable-block-tools-after' }\n\t\t\t\t\tshift\n\t\t\t\t>\n\t\t\t\t\t<LinkControl\n\t\t\t\t\t\tvalue={ linkValue }\n\t\t\t\t\t\tonChange={ ( {\n\t\t\t\t\t\t\turl: newURL = '',\n\t\t\t\t\t\t\topensInNewTab: newOpensInNewTab,\n\t\t\t\t\t\t} ) => {\n\t\t\t\t\t\t\tsetAttributes( { url: prependHTTP( newURL ) } );\n\n\t\t\t\t\t\t\tif ( opensInNewTab !== newOpensInNewTab ) {\n\t\t\t\t\t\t\t\tonToggleOpenInNewTab( newOpensInNewTab );\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} }\n\t\t\t\t\t\tonRemove={ () => {\n\t\t\t\t\t\t\tunlink();\n\t\t\t\t\t\t\trichTextRef.current?.focus();\n\t\t\t\t\t\t} }\n\t\t\t\t\t\tforceIsEditingLink={ isEditingURL }\n\t\t\t\t\t/>\n\t\t\t\t</Popover>\n\t\t\t) }\n\t\t\t<InspectorControls>\n\t\t\t\t<WidthPanel\n\t\t\t\t\tselectedWidth={ width }\n\t\t\t\t\tsetAttributes={ setAttributes }\n\t\t\t\t/>\n\t\t\t</InspectorControls>\n\t\t\t<InspectorControls group=\"advanced\">\n\t\t\t\t<TextControl\n\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\tlabel={ __( 'Link rel' ) }\n\t\t\t\t\tvalue={ rel || '' }\n\t\t\t\t\tonChange={ ( newRel ) => setAttributes( { rel: newRel } ) }\n\t\t\t\t/>\n\t\t\t</InspectorControls>\n\t\t</>\n\t);\n}\n\nexport default ButtonEdit;\n"],"mappings":";AAAA;AACA;AACA;AACA,OAAOA,UAAU,MAAM,YAAY;;AAEnC;AACA;AACA;AACA,SAASC,EAAE,QAAQ,iBAAiB;AACpC,SAASC,SAAS,EAAEC,QAAQ,EAAEC,MAAM,EAAEC,OAAO,QAAQ,oBAAoB;AACzE,SACCC,MAAM,EACNC,WAAW,EACXC,SAAS,EACTC,WAAW,EACXC,aAAa,EACbC,OAAO,QACD,uBAAuB;AAC9B,SACCC,gBAAgB,EAChBC,aAAa,EACbC,iBAAiB,EACjBC,QAAQ,EACRC,aAAa,EACbC,4BAA4B,IAAIC,cAAc,EAC9CC,2BAA2B,IAAIC,aAAa,EAC5CC,wCAAwC,IAAIC,eAAe,EAC3DC,yBAAyB,IAAIC,WAAW,EACxCC,iCAAiC,QAC3B,yBAAyB;AAChC,SAASC,eAAe,EAAEC,eAAe,QAAQ,qBAAqB;AACtE,SAASC,IAAI,EAAEC,OAAO,QAAQ,kBAAkB;AAChD,SAASC,WAAW,QAAQ,mBAAmB;AAC/C,SAASC,YAAY,QAAQ,oBAAoB;AACjD,SAASC,WAA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,KAAK,EAAC;EAAU,GAClC5D,aAAA,CAAChC,WAAW;IACX4G,uBAAuB;IACvBC,KAAK,EAAGrH,EAAE,CAAE,UAAW,CAAG;IAC1B+D,KAAK,EAAGL,GAAG,IAAI,EAAI;IACnBmC,QAAQ,EAAKyB,MAAM,IAAMnF,aAAa,CAAE;MAAEuB,GAAG,EAAE4D;IAAO,CAAE;EAAG,CAC3D,CACiB,CAClB,CAAC;AAEL;AAEA,eAAetE,UAAU"}
|
|
1
|
+
{"version":3,"names":["classnames","__","useEffect","useState","useRef","useMemo","Button","ButtonGroup","PanelBody","TextControl","ToolbarButton","Popover","AlignmentControl","BlockControls","InspectorControls","RichText","useBlockProps","__experimentalUseBorderProps","useBorderProps","__experimentalUseColorProps","useColorProps","__experimentalGetSpacingClassesAndStyles","useSpacingProps","__experimentalLinkControl","LinkControl","__experimentalGetElementClassName","displayShortcut","isKeyboardEvent","link","linkOff","createBlock","useMergeRefs","prependHTTP","NEW_TAB_REL","WidthPanel","selectedWidth","setAttributes","handleChange","newWidth","width","undefined","createElement","title","map","widthValue","key","size","variant","onClick","ButtonEdit","props","attributes","className","isSelected","onReplace","mergeBlocks","tagName","textAlign","linkTarget","placeholder","rel","style","text","url","TagName","onToggleOpenInNewTab","value","newLinkTarget","updatedRel","setButtonText","newText","replace","onKeyDown","event","primary","startEditing","primaryShift","unlink","richTextRef","current","focus","popoverAnchor","setPopoverAnchor","borderProps","colorProps","spacingProps","ref","blockProps","isEditingURL","setIsEditingURL","isURLSet","opensInNewTab","isLinkTag","preventDefault","linkValue","Fragment","fontSize","onChange","withoutInteractiveFormatting","border","radius","onSplit","onMerge","identifier","group","nextAlign","name","icon","shortcut","isActive","placement","onClose","anchor","focusOnMount","__unstableSlotName","shift","newURL","newOpensInNewTab","onRemove","forceIsEditingLink","__nextHasNoMarginBottom","label","newRel"],"sources":["@wordpress/block-library/src/button/edit.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { useEffect, useState, useRef, useMemo } from '@wordpress/element';\nimport {\n\tButton,\n\tButtonGroup,\n\tPanelBody,\n\tTextControl,\n\tToolbarButton,\n\tPopover,\n} from '@wordpress/components';\nimport {\n\tAlignmentControl,\n\tBlockControls,\n\tInspectorControls,\n\tRichText,\n\tuseBlockProps,\n\t__experimentalUseBorderProps as useBorderProps,\n\t__experimentalUseColorProps as useColorProps,\n\t__experimentalGetSpacingClassesAndStyles as useSpacingProps,\n\t__experimentalLinkControl as LinkControl,\n\t__experimentalGetElementClassName,\n} from '@wordpress/block-editor';\nimport { displayShortcut, isKeyboardEvent } from '@wordpress/keycodes';\nimport { link, linkOff } from '@wordpress/icons';\nimport { createBlock } from '@wordpress/blocks';\nimport { useMergeRefs } from '@wordpress/compose';\nimport { prependHTTP } from '@wordpress/url';\n\nconst NEW_TAB_REL = 'noreferrer noopener';\n\nfunction WidthPanel( { selectedWidth, setAttributes } ) {\n\tfunction handleChange( newWidth ) {\n\t\t// Check if we are toggling the width off\n\t\tconst width = selectedWidth === newWidth ? undefined : newWidth;\n\n\t\t// Update attributes.\n\t\tsetAttributes( { width } );\n\t}\n\n\treturn (\n\t\t<PanelBody title={ __( 'Width settings' ) }>\n\t\t\t<ButtonGroup aria-label={ __( 'Button width' ) }>\n\t\t\t\t{ [ 25, 50, 75, 100 ].map( ( widthValue ) => {\n\t\t\t\t\treturn (\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\tkey={ widthValue }\n\t\t\t\t\t\t\tsize=\"small\"\n\t\t\t\t\t\t\tvariant={\n\t\t\t\t\t\t\t\twidthValue === selectedWidth\n\t\t\t\t\t\t\t\t\t? 'primary'\n\t\t\t\t\t\t\t\t\t: undefined\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tonClick={ () => handleChange( widthValue ) }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ widthValue }%\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t);\n\t\t\t\t} ) }\n\t\t\t</ButtonGroup>\n\t\t</PanelBody>\n\t);\n}\n\nfunction ButtonEdit( props ) {\n\tconst {\n\t\tattributes,\n\t\tsetAttributes,\n\t\tclassName,\n\t\tisSelected,\n\t\tonReplace,\n\t\tmergeBlocks,\n\t} = props;\n\tconst {\n\t\ttagName,\n\t\ttextAlign,\n\t\tlinkTarget,\n\t\tplaceholder,\n\t\trel,\n\t\tstyle,\n\t\ttext,\n\t\turl,\n\t\twidth,\n\t} = attributes;\n\n\tconst TagName = tagName || 'a';\n\n\tfunction onToggleOpenInNewTab( value ) {\n\t\tconst newLinkTarget = value ? '_blank' : undefined;\n\n\t\tlet updatedRel = rel;\n\t\tif ( newLinkTarget && ! rel ) {\n\t\t\tupdatedRel = NEW_TAB_REL;\n\t\t} else if ( ! newLinkTarget && rel === NEW_TAB_REL ) {\n\t\t\tupdatedRel = undefined;\n\t\t}\n\n\t\tsetAttributes( {\n\t\t\tlinkTarget: newLinkTarget,\n\t\t\trel: updatedRel,\n\t\t} );\n\t}\n\n\tfunction setButtonText( newText ) {\n\t\t// Remove anchor tags from button text content.\n\t\tsetAttributes( { text: newText.replace( /<\\/?a[^>]*>/g, '' ) } );\n\t}\n\n\tfunction onKeyDown( event ) {\n\t\tif ( isKeyboardEvent.primary( event, 'k' ) ) {\n\t\t\tstartEditing( event );\n\t\t} else if ( isKeyboardEvent.primaryShift( event, 'k' ) ) {\n\t\t\tunlink();\n\t\t\trichTextRef.current?.focus();\n\t\t}\n\t}\n\n\t// Use internal state instead of a ref to make sure that the component\n\t// re-renders when the popover's anchor updates.\n\tconst [ popoverAnchor, setPopoverAnchor ] = useState( null );\n\n\tconst borderProps = useBorderProps( attributes );\n\tconst colorProps = useColorProps( attributes );\n\tconst spacingProps = useSpacingProps( attributes );\n\tconst ref = useRef();\n\tconst richTextRef = useRef();\n\tconst blockProps = useBlockProps( {\n\t\tref: useMergeRefs( [ setPopoverAnchor, ref ] ),\n\t\tonKeyDown,\n\t} );\n\n\tconst [ isEditingURL, setIsEditingURL ] = useState( false );\n\tconst isURLSet = !! url;\n\tconst opensInNewTab = linkTarget === '_blank';\n\tconst isLinkTag = 'a' === TagName;\n\n\tfunction startEditing( event ) {\n\t\tevent.preventDefault();\n\t\tsetIsEditingURL( true );\n\t}\n\n\tfunction unlink() {\n\t\tsetAttributes( {\n\t\t\turl: undefined,\n\t\t\tlinkTarget: undefined,\n\t\t\trel: undefined,\n\t\t} );\n\t\tsetIsEditingURL( false );\n\t}\n\n\tuseEffect( () => {\n\t\tif ( ! isSelected ) {\n\t\t\tsetIsEditingURL( false );\n\t\t}\n\t}, [ isSelected ] );\n\n\t// Memoize link value to avoid overriding the LinkControl's internal state.\n\t// This is a temporary fix. See https://github.com/WordPress/gutenberg/issues/51256.\n\tconst linkValue = useMemo(\n\t\t() => ( { url, opensInNewTab } ),\n\t\t[ url, opensInNewTab ]\n\t);\n\n\treturn (\n\t\t<>\n\t\t\t<div\n\t\t\t\t{ ...blockProps }\n\t\t\t\tclassName={ classnames( blockProps.className, {\n\t\t\t\t\t[ `has-custom-width wp-block-button__width-${ width }` ]:\n\t\t\t\t\t\twidth,\n\t\t\t\t\t[ `has-custom-font-size` ]: blockProps.style.fontSize,\n\t\t\t\t} ) }\n\t\t\t>\n\t\t\t\t<RichText\n\t\t\t\t\tref={ richTextRef }\n\t\t\t\t\taria-label={ __( 'Button text' ) }\n\t\t\t\t\tplaceholder={ placeholder || __( 'Add text…' ) }\n\t\t\t\t\tvalue={ text }\n\t\t\t\t\tonChange={ ( value ) => setButtonText( value ) }\n\t\t\t\t\twithoutInteractiveFormatting\n\t\t\t\t\tclassName={ classnames(\n\t\t\t\t\t\tclassName,\n\t\t\t\t\t\t'wp-block-button__link',\n\t\t\t\t\t\tcolorProps.className,\n\t\t\t\t\t\tborderProps.className,\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t[ `has-text-align-${ textAlign }` ]: textAlign,\n\t\t\t\t\t\t\t// For backwards compatibility add style that isn't\n\t\t\t\t\t\t\t// provided via block support.\n\t\t\t\t\t\t\t'no-border-radius': style?.border?.radius === 0,\n\t\t\t\t\t\t},\n\t\t\t\t\t\t__experimentalGetElementClassName( 'button' )\n\t\t\t\t\t) }\n\t\t\t\t\tstyle={ {\n\t\t\t\t\t\t...borderProps.style,\n\t\t\t\t\t\t...colorProps.style,\n\t\t\t\t\t\t...spacingProps.style,\n\t\t\t\t\t} }\n\t\t\t\t\tonSplit={ ( value ) =>\n\t\t\t\t\t\tcreateBlock( 'core/button', {\n\t\t\t\t\t\t\t...attributes,\n\t\t\t\t\t\t\ttext: value,\n\t\t\t\t\t\t} )\n\t\t\t\t\t}\n\t\t\t\t\tonReplace={ onReplace }\n\t\t\t\t\tonMerge={ mergeBlocks }\n\t\t\t\t\tidentifier=\"text\"\n\t\t\t\t/>\n\t\t\t</div>\n\t\t\t<BlockControls group=\"block\">\n\t\t\t\t<AlignmentControl\n\t\t\t\t\tvalue={ textAlign }\n\t\t\t\t\tonChange={ ( nextAlign ) => {\n\t\t\t\t\t\tsetAttributes( { textAlign: nextAlign } );\n\t\t\t\t\t} }\n\t\t\t\t/>\n\t\t\t\t{ ! isURLSet && isLinkTag && (\n\t\t\t\t\t<ToolbarButton\n\t\t\t\t\t\tname=\"link\"\n\t\t\t\t\t\ticon={ link }\n\t\t\t\t\t\ttitle={ __( 'Link' ) }\n\t\t\t\t\t\tshortcut={ displayShortcut.primary( 'k' ) }\n\t\t\t\t\t\tonClick={ startEditing }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t\t{ isURLSet && isLinkTag && (\n\t\t\t\t\t<ToolbarButton\n\t\t\t\t\t\tname=\"link\"\n\t\t\t\t\t\ticon={ linkOff }\n\t\t\t\t\t\ttitle={ __( 'Unlink' ) }\n\t\t\t\t\t\tshortcut={ displayShortcut.primaryShift( 'k' ) }\n\t\t\t\t\t\tonClick={ unlink }\n\t\t\t\t\t\tisActive={ true }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t</BlockControls>\n\t\t\t{ isLinkTag && isSelected && ( isEditingURL || isURLSet ) && (\n\t\t\t\t<Popover\n\t\t\t\t\tplacement=\"bottom\"\n\t\t\t\t\tonClose={ () => {\n\t\t\t\t\t\tsetIsEditingURL( false );\n\t\t\t\t\t\trichTextRef.current?.focus();\n\t\t\t\t\t} }\n\t\t\t\t\tanchor={ popoverAnchor }\n\t\t\t\t\tfocusOnMount={ isEditingURL ? 'firstElement' : false }\n\t\t\t\t\t__unstableSlotName={ '__unstable-block-tools-after' }\n\t\t\t\t\tshift\n\t\t\t\t>\n\t\t\t\t\t<LinkControl\n\t\t\t\t\t\tvalue={ linkValue }\n\t\t\t\t\t\tonChange={ ( {\n\t\t\t\t\t\t\turl: newURL = '',\n\t\t\t\t\t\t\topensInNewTab: newOpensInNewTab,\n\t\t\t\t\t\t} ) => {\n\t\t\t\t\t\t\tsetAttributes( { url: prependHTTP( newURL ) } );\n\n\t\t\t\t\t\t\tif ( opensInNewTab !== newOpensInNewTab ) {\n\t\t\t\t\t\t\t\tonToggleOpenInNewTab( newOpensInNewTab );\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} }\n\t\t\t\t\t\tonRemove={ () => {\n\t\t\t\t\t\t\tunlink();\n\t\t\t\t\t\t\trichTextRef.current?.focus();\n\t\t\t\t\t\t} }\n\t\t\t\t\t\tforceIsEditingLink={ isEditingURL }\n\t\t\t\t\t/>\n\t\t\t\t</Popover>\n\t\t\t) }\n\t\t\t<InspectorControls>\n\t\t\t\t<WidthPanel\n\t\t\t\t\tselectedWidth={ width }\n\t\t\t\t\tsetAttributes={ setAttributes }\n\t\t\t\t/>\n\t\t\t</InspectorControls>\n\t\t\t<InspectorControls group=\"advanced\">\n\t\t\t\t{ isLinkTag && (\n\t\t\t\t\t<TextControl\n\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\tlabel={ __( 'Link rel' ) }\n\t\t\t\t\t\tvalue={ rel || '' }\n\t\t\t\t\t\t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C/B,CACD,CAEgB,CAClB,CAAC;AAEL;AAEA,eAAezE,UAAU"}
|
|
@@ -21,6 +21,15 @@ const metadata = {
|
|
|
21
21
|
keywords: ["link"],
|
|
22
22
|
textdomain: "default",
|
|
23
23
|
attributes: {
|
|
24
|
+
tagName: {
|
|
25
|
+
type: "string",
|
|
26
|
+
"enum": ["a", "button"],
|
|
27
|
+
"default": "a"
|
|
28
|
+
},
|
|
29
|
+
type: {
|
|
30
|
+
type: "string",
|
|
31
|
+
"default": "button"
|
|
32
|
+
},
|
|
24
33
|
textAlign: {
|
|
25
34
|
type: "string"
|
|
26
35
|
},
|
|
@@ -34,14 +43,14 @@ const metadata = {
|
|
|
34
43
|
title: {
|
|
35
44
|
type: "string",
|
|
36
45
|
source: "attribute",
|
|
37
|
-
selector: "a",
|
|
46
|
+
selector: "a,button",
|
|
38
47
|
attribute: "title",
|
|
39
48
|
__experimentalRole: "content"
|
|
40
49
|
},
|
|
41
50
|
text: {
|
|
42
51
|
type: "string",
|
|
43
52
|
source: "html",
|
|
44
|
-
selector: "a",
|
|
53
|
+
selector: "a,button",
|
|
45
54
|
__experimentalRole: "content"
|
|
46
55
|
},
|
|
47
56
|
linkTarget: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["__","button","icon","initBlock","deprecated","edit","metadata","$schema","apiVersion","name","title","category","parent","description","keywords","textdomain","attributes","
|
|
1
|
+
{"version":3,"names":["__","button","icon","initBlock","deprecated","edit","metadata","$schema","apiVersion","name","title","category","parent","description","keywords","textdomain","attributes","tagName","type","textAlign","url","source","selector","attribute","__experimentalRole","text","linkTarget","rel","placeholder","backgroundColor","textColor","gradient","width","supports","anchor","align","alignWide","color","__experimentalSkipSerialization","gradients","__experimentalDefaultControls","background","typography","fontSize","lineHeight","__experimentalFontFamily","__experimentalFontWeight","__experimentalFontStyle","__experimentalTextTransform","__experimentalTextDecoration","__experimentalLetterSpacing","reusable","shadow","spacing","padding","__experimentalBorder","radius","style","__experimentalSelector","styles","label","isDefault","editorStyle","save","settings","example","className","merge","a","init"],"sources":["@wordpress/block-library/src/button/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { button as icon } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport initBlock from '../utils/init-block';\nimport deprecated from './deprecated';\nimport edit from './edit';\nimport metadata from './block.json';\nimport save from './save';\n\nconst { name } = metadata;\n\nexport { metadata, name };\n\nexport const settings = {\n\ticon,\n\texample: {\n\t\tattributes: {\n\t\t\tclassName: 'is-style-fill',\n\t\t\ttext: __( 'Call to Action' ),\n\t\t},\n\t},\n\tedit,\n\tsave,\n\tdeprecated,\n\tmerge: ( a, { text = '' } ) => ( {\n\t\t...a,\n\t\ttext: ( a.text || '' ) + text,\n\t} ),\n};\n\nexport const init = () => initBlock( { name, metadata, settings } );\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,EAAE,QAAQ,iBAAiB;AACpC,SAASC,MAAM,IAAIC,IAAI,QAAQ,kBAAkB;;AAEjD;AACA;AACA;AACA,OAAOC,SAAS,MAAM,qBAAqB;AAC3C,OAAOC,UAAU,MAAM,cAAc;AACrC,OAAOC,IAAI,MAAM,QAAQ;AAAC,MAAAC,QAAA;EAAAC,OAAA;EAAAC,UAAA;EAAAC,IAAA;EAAAC,KAAA;EAAAC,QAAA;EAAAC,MAAA;EAAAC,WAAA;EAAAC,QAAA;EAAAC,UAAA;EAAAC,UAAA;IAAAC,OAAA;MAAAC,IAAA;MAAA;MAAA;IAAA;IAAAA,IAAA;MAAAA,IAAA;MAAA;IAAA;IAAAC,SAAA;MAAAD,IAAA;IAAA;IAAAE,GAAA;MAAAF,IAAA;MAAAG,MAAA;MAAAC,QAAA;MAAAC,SAAA;MAAAC,kBAAA;IAAA;IAAAd,KAAA;MAAAQ,IAAA;MAAAG,MAAA;MAAAC,QAAA;MAAAC,SAAA;MAAAC,kBAAA;IAAA;IAAAC,IAAA;MAAAP,IAAA;MAAAG,M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IAAI;AAEvB,OAAO,MAAMuD,QAAQ,GAAG;EACvB9D,IAAI;EACJ+D,OAAO,EAAE;IACRjD,UAAU,EAAE;MACXkD,SAAS,EAAE,eAAe;MAC1BzC,IAAI,EAAEzB,EAAE,CAAE,gBAAiB;IAC5B;EACD,CAAC;EACDK,IAAI;EACJ0D,IAAI;EACJ3D,UAAU;EACV+D,KAAK,EAAEA,CAAEC,CAAC,EAAE;IAAE3C,IAAI,GAAG;EAAG,CAAC,MAAQ;IAChC,GAAG2C,CAAC;IACJ3C,IAAI,EAAE,CAAE2C,CAAC,CAAC3C,IAAI,IAAI,EAAE,IAAKA;EAC1B,CAAC;AACF,CAAC;AAED,OAAO,MAAM4C,IAAI,GAAGA,CAAA,KAAMlE,SAAS,CAAE;EAAEM,IAAI;EAAEH,QAAQ;EAAE0D;AAAS,CAAE,CAAC"}
|
|
@@ -13,6 +13,8 @@ export default function save({
|
|
|
13
13
|
className
|
|
14
14
|
}) {
|
|
15
15
|
const {
|
|
16
|
+
tagName,
|
|
17
|
+
type,
|
|
16
18
|
textAlign,
|
|
17
19
|
fontSize,
|
|
18
20
|
linkTarget,
|
|
@@ -26,6 +28,9 @@ export default function save({
|
|
|
26
28
|
if (!text) {
|
|
27
29
|
return null;
|
|
28
30
|
}
|
|
31
|
+
const TagName = tagName || 'a';
|
|
32
|
+
const isButtonTag = 'button' === TagName;
|
|
33
|
+
const buttonType = type || 'button';
|
|
29
34
|
const borderProps = getBorderClassesAndStyles(attributes);
|
|
30
35
|
const colorProps = getColorClassesAndStyles(attributes);
|
|
31
36
|
const spacingProps = getSpacingClassesAndStyles(attributes);
|
|
@@ -54,14 +59,15 @@ export default function save({
|
|
|
54
59
|
className: wrapperClasses
|
|
55
60
|
})
|
|
56
61
|
}, createElement(RichText.Content, {
|
|
57
|
-
tagName:
|
|
62
|
+
tagName: TagName,
|
|
63
|
+
type: isButtonTag ? buttonType : null,
|
|
58
64
|
className: buttonClasses,
|
|
59
|
-
href: url,
|
|
65
|
+
href: isButtonTag ? null : url,
|
|
60
66
|
title: title,
|
|
61
67
|
style: buttonStyle,
|
|
62
68
|
value: text,
|
|
63
|
-
target: linkTarget,
|
|
64
|
-
rel: rel
|
|
69
|
+
target: isButtonTag ? null : linkTarget,
|
|
70
|
+
rel: isButtonTag ? null : rel
|
|
65
71
|
}));
|
|
66
72
|
}
|
|
67
73
|
//# sourceMappingURL=save.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["classnames","RichText","useBlockProps","__experimentalGetBorderClassesAndStyles","getBorderClassesAndStyles","__experimentalGetColorClassesAndStyles","getColorClassesAndStyles","__experimentalGetSpacingClassesAndStyles","getSpacingClassesAndStyles","__experimentalGetElementClassName","save","attributes","className","textAlign","fontSize","linkTarget","rel","style","text","title","url","width","borderProps","colorProps","spacingProps","buttonClasses","border","radius","buttonStyle","wrapperClasses","typography","createElement","Content","
|
|
1
|
+
{"version":3,"names":["classnames","RichText","useBlockProps","__experimentalGetBorderClassesAndStyles","getBorderClassesAndStyles","__experimentalGetColorClassesAndStyles","getColorClassesAndStyles","__experimentalGetSpacingClassesAndStyles","getSpacingClassesAndStyles","__experimentalGetElementClassName","save","attributes","className","tagName","type","textAlign","fontSize","linkTarget","rel","style","text","title","url","width","TagName","isButtonTag","buttonType","borderProps","colorProps","spacingProps","buttonClasses","border","radius","buttonStyle","wrapperClasses","typography","createElement","Content","href","value","target"],"sources":["@wordpress/block-library/src/button/save.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tRichText,\n\tuseBlockProps,\n\t__experimentalGetBorderClassesAndStyles as getBorderClassesAndStyles,\n\t__experimentalGetColorClassesAndStyles as getColorClassesAndStyles,\n\t__experimentalGetSpacingClassesAndStyles as getSpacingClassesAndStyles,\n\t__experimentalGetElementClassName,\n} from '@wordpress/block-editor';\n\nexport default function save( { attributes, className } ) {\n\tconst {\n\t\ttagName,\n\t\ttype,\n\t\ttextAlign,\n\t\tfontSize,\n\t\tlinkTarget,\n\t\trel,\n\t\tstyle,\n\t\ttext,\n\t\ttitle,\n\t\turl,\n\t\twidth,\n\t} = attributes;\n\n\tif ( ! text ) {\n\t\treturn null;\n\t}\n\n\tconst TagName = tagName || 'a';\n\tconst isButtonTag = 'button' === TagName;\n\tconst buttonType = type || 'button';\n\tconst borderProps = getBorderClassesAndStyles( attributes );\n\tconst colorProps = getColorClassesAndStyles( attributes );\n\tconst spacingProps = getSpacingClassesAndStyles( attributes );\n\tconst buttonClasses = classnames(\n\t\t'wp-block-button__link',\n\t\tcolorProps.className,\n\t\tborderProps.className,\n\t\t{\n\t\t\t[ `has-text-align-${ textAlign }` ]: textAlign,\n\t\t\t// For backwards compatibility add style that isn't provided via\n\t\t\t// block support.\n\t\t\t'no-border-radius': style?.border?.radius === 0,\n\t\t},\n\t\t__experimentalGetElementClassName( 'button' )\n\t);\n\tconst buttonStyle = {\n\t\t...borderProps.style,\n\t\t...colorProps.style,\n\t\t...spacingProps.style,\n\t};\n\n\t// The use of a `title` attribute here is soft-deprecated, but still applied\n\t// if it had already been assigned, for the sake of backward-compatibility.\n\t// A title will no longer be assigned for new or updated button block links.\n\n\tconst wrapperClasses = classnames( className, {\n\t\t[ `has-custom-width wp-block-button__width-${ width }` ]: width,\n\t\t[ `has-custom-font-size` ]: fontSize || style?.typography?.fontSize,\n\t} );\n\n\treturn (\n\t\t<div { ...useBlockProps.save( { className: wrapperClasses } ) }>\n\t\t\t<RichText.Content\n\t\t\t\ttagName={ TagName }\n\t\t\t\ttype={ isButtonTag ? buttonType : null }\n\t\t\t\tclassName={ buttonClasses }\n\t\t\t\thref={ isButtonTag ? null : url }\n\t\t\t\ttitle={ title }\n\t\t\t\tstyle={ buttonStyle }\n\t\t\t\tvalue={ text }\n\t\t\t\ttarget={ isButtonTag ? null : linkTarget }\n\t\t\t\trel={ isButtonTag ? null : rel }\n\t\t\t/>\n\t\t</div>\n\t);\n}\n"],"mappings":";AAAA;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AEA,MAAMe,cAAc,GAAGlC,UAAU,CAAEY,SAAS,EAAE;IAC7C,CAAG,2CAA2CW,KAAO,EAAC,GAAIA,KAAK;IAC/D,CAAG,sBAAqB,GAAIP,QAAQ,IAAIG,KAAK,EAAEgB,UAAU,EAAEnB;EAC5D,CAAE,CAAC;EAEH,OACCoB,aAAA;IAAA,GAAUlC,aAAa,CAACQ,IAAI,CAAE;MAAEE,SAAS,EAAEsB;IAAe,CAAE;EAAC,GAC5DE,aAAA,CAACnC,QAAQ,CAACoC,OAAO;IAChBxB,OAAO,EAAGW,OAAS;IACnBV,IAAI,EAAGW,WAAW,GAAGC,UAAU,GAAG,IAAM;IACxCd,SAAS,EAAGkB,aAAe;IAC3BQ,IAAI,EAAGb,WAAW,GAAG,IAAI,GAAGH,GAAK;IACjCD,KAAK,EAAGA,KAAO;IACfF,KAAK,EAAGc,WAAa;IACrBM,KAAK,EAAGnB,IAAM;IACdoB,MAAM,EAAGf,WAAW,GAAG,IAAI,GAAGR,UAAY;IAC1CC,GAAG,EAAGO,WAAW,GAAG,IAAI,GAAGP;EAAK,CAChC,CACG,CAAC;AAER"}
|
|
@@ -9,6 +9,7 @@ import classnames from 'classnames';
|
|
|
9
9
|
*/
|
|
10
10
|
import { useBlockProps, useInnerBlocksProps, store as blockEditorStore } from '@wordpress/block-editor';
|
|
11
11
|
import { useSelect } from '@wordpress/data';
|
|
12
|
+
import { store as blocksStore } from '@wordpress/blocks';
|
|
12
13
|
|
|
13
14
|
/**
|
|
14
15
|
* Internal dependencies
|
|
@@ -34,14 +35,22 @@ function ButtonsEdit({
|
|
|
34
35
|
'has-custom-font-size': fontSize || style?.typography?.fontSize
|
|
35
36
|
})
|
|
36
37
|
});
|
|
37
|
-
const
|
|
38
|
+
const {
|
|
39
|
+
preferredStyle,
|
|
40
|
+
hasButtonVariations
|
|
41
|
+
} = useSelect(select => {
|
|
38
42
|
const preferredStyleVariations = select(blockEditorStore).getSettings().__experimentalPreferredStyleVariations;
|
|
39
|
-
|
|
43
|
+
const buttonVariations = select(blocksStore).getBlockVariations(buttonBlockName, 'inserter');
|
|
44
|
+
return {
|
|
45
|
+
preferredStyle: preferredStyleVariations?.value?.[buttonBlockName],
|
|
46
|
+
hasButtonVariations: buttonVariations.length > 0
|
|
47
|
+
};
|
|
40
48
|
}, []);
|
|
41
49
|
const innerBlocksProps = useInnerBlocksProps(blockProps, {
|
|
42
50
|
allowedBlocks: ALLOWED_BLOCKS,
|
|
43
51
|
defaultBlock: DEFAULT_BLOCK,
|
|
44
|
-
|
|
52
|
+
// This check should be handled by the `Inserter` internally to be consistent across all blocks that use it.
|
|
53
|
+
directInsert: !hasButtonVariations,
|
|
45
54
|
template: [[buttonBlockName, {
|
|
46
55
|
className: preferredStyle && `is-style-${preferredStyle}`
|
|
47
56
|
}]],
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["classnames","useBlockProps","useInnerBlocksProps","store","blockEditorStore","useSelect","name","buttonBlockName","ALLOWED_BLOCKS","DEFAULT_BLOCK","attributesToCopy","ButtonsEdit","attributes","className","_layout$orientation","fontSize","layout","style","blockProps","typography","preferredStyle","select","preferredStyleVariations","getSettings","__experimentalPreferredStyleVariations","value","innerBlocksProps","allowedBlocks","defaultBlock","directInsert","template","templateInsertUpdatesSelection","orientation","createElement"],"sources":["@wordpress/block-library/src/buttons/edit.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tuseBlockProps,\n\tuseInnerBlocksProps,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport { useSelect } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { name as buttonBlockName } from '../button';\n\nconst ALLOWED_BLOCKS = [ buttonBlockName ];\n\nconst DEFAULT_BLOCK = {\n\tname: buttonBlockName,\n\tattributesToCopy: [\n\t\t'backgroundColor',\n\t\t'border',\n\t\t'className',\n\t\t'fontFamily',\n\t\t'fontSize',\n\t\t'gradient',\n\t\t'style',\n\t\t'textColor',\n\t\t'width',\n\t],\n};\n\nfunction ButtonsEdit( { attributes, className } ) {\n\tconst { fontSize, layout, style } = attributes;\n\tconst blockProps = useBlockProps( {\n\t\tclassName: classnames( className, {\n\t\t\t'has-custom-font-size': fontSize || style?.typography?.fontSize,\n\t\t} ),\n\t} );\n\tconst preferredStyle = useSelect( ( select ) => {\n\t\tconst preferredStyleVariations =\n\t\t\tselect( blockEditorStore ).getSettings()\n\t\t\t\t.__experimentalPreferredStyleVariations;\n\t\treturn
|
|
1
|
+
{"version":3,"names":["classnames","useBlockProps","useInnerBlocksProps","store","blockEditorStore","useSelect","blocksStore","name","buttonBlockName","ALLOWED_BLOCKS","DEFAULT_BLOCK","attributesToCopy","ButtonsEdit","attributes","className","_layout$orientation","fontSize","layout","style","blockProps","typography","preferredStyle","hasButtonVariations","select","preferredStyleVariations","getSettings","__experimentalPreferredStyleVariations","buttonVariations","getBlockVariations","value","length","innerBlocksProps","allowedBlocks","defaultBlock","directInsert","template","templateInsertUpdatesSelection","orientation","createElement"],"sources":["@wordpress/block-library/src/buttons/edit.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tuseBlockProps,\n\tuseInnerBlocksProps,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport { useSelect } from '@wordpress/data';\nimport { store as blocksStore } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport { name as buttonBlockName } from '../button';\n\nconst ALLOWED_BLOCKS = [ buttonBlockName ];\n\nconst DEFAULT_BLOCK = {\n\tname: buttonBlockName,\n\tattributesToCopy: [\n\t\t'backgroundColor',\n\t\t'border',\n\t\t'className',\n\t\t'fontFamily',\n\t\t'fontSize',\n\t\t'gradient',\n\t\t'style',\n\t\t'textColor',\n\t\t'width',\n\t],\n};\n\nfunction ButtonsEdit( { attributes, className } ) {\n\tconst { fontSize, layout, style } = attributes;\n\tconst blockProps = useBlockProps( {\n\t\tclassName: classnames( className, {\n\t\t\t'has-custom-font-size': fontSize || style?.typography?.fontSize,\n\t\t} ),\n\t} );\n\tconst { preferredStyle, hasButtonVariations } = useSelect( ( select ) => {\n\t\tconst preferredStyleVariations =\n\t\t\tselect( blockEditorStore ).getSettings()\n\t\t\t\t.__experimentalPreferredStyleVariations;\n\t\tconst buttonVariations = select( blocksStore ).getBlockVariations(\n\t\t\tbuttonBlockName,\n\t\t\t'inserter'\n\t\t);\n\t\treturn {\n\t\t\tpreferredStyle:\n\t\t\t\tpreferredStyleVariations?.value?.[ buttonBlockName ],\n\t\t\thasButtonVariations: buttonVariations.length > 0,\n\t\t};\n\t}, [] );\n\n\tconst innerBlocksProps = useInnerBlocksProps( blockProps, {\n\t\tallowedBlocks: ALLOWED_BLOCKS,\n\t\tdefaultBlock: DEFAULT_BLOCK,\n\t\t// This check should be handled by the `Inserter` internally to be consistent across all blocks that use it.\n\t\tdirectInsert: ! hasButtonVariations,\n\t\ttemplate: [\n\t\t\t[\n\t\t\t\tbuttonBlockName,\n\t\t\t\t{ className: preferredStyle && `is-style-${ preferredStyle }` },\n\t\t\t],\n\t\t],\n\t\ttemplateInsertUpdatesSelection: true,\n\t\torientation: layout?.orientation ?? 'horizontal',\n\t} );\n\n\treturn <div { ...innerBlocksProps } />;\n}\n\nexport default ButtonsEdit;\n"],"mappings":";AAAA;AACA;AACA;AACA,OAAOA,UAAU,MAAM,YAAY;;AAEnC;AACA;AACA;AACA,SACCC,aAAa,EACbC,mBAAmB,EACnBC,KAAK,IAAIC,gBAAgB,QACnB,yBAAyB;AAChC,SAASC,SAAS,QAAQ,iBAAiB;AAC3C,SAASF,KAAK,IAAIG,WAAW,QAAQ,mBAAmB;;AAExD;AACA;AACA;AACA,SAASC,IAAI,IAAIC,eAAe,QAAQ,WAAW;AAEnD,MAAMC,cAAc,GAAG,CAAED,eAAe,CAAE;AAE1C,MAAME,aAAa,GAAG;EACrBH,IAAI,EAAEC,eAAe;EACrBG,gB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A,GAAEE,MAAM,EAAEoB,WAAW,cAAAtB,mBAAA,cAAAA,mBAAA,GAAI;EACrC,CAAE,CAAC;EAEH,OAAOuB,aAAA;IAAA,GAAUP;EAAgB,CAAI,CAAC;AACvC;AAEA,eAAenB,WAAW"}
|
|
@@ -4,25 +4,31 @@ import { createElement } from "@wordpress/element";
|
|
|
4
4
|
*/
|
|
5
5
|
import { __ } from '@wordpress/i18n';
|
|
6
6
|
import { RichText, useBlockProps } from '@wordpress/block-editor';
|
|
7
|
+
import { createBlock, getDefaultBlockName } from '@wordpress/blocks';
|
|
7
8
|
export default function CodeEdit({
|
|
8
9
|
attributes,
|
|
9
10
|
setAttributes,
|
|
10
|
-
onRemove
|
|
11
|
+
onRemove,
|
|
12
|
+
insertBlocksAfter,
|
|
13
|
+
mergeBlocks
|
|
11
14
|
}) {
|
|
12
15
|
const blockProps = useBlockProps();
|
|
13
16
|
return createElement("pre", {
|
|
14
17
|
...blockProps
|
|
15
18
|
}, createElement(RichText, {
|
|
16
19
|
tagName: "code",
|
|
20
|
+
identifier: "content",
|
|
17
21
|
value: attributes.content,
|
|
18
22
|
onChange: content => setAttributes({
|
|
19
23
|
content
|
|
20
24
|
}),
|
|
21
25
|
onRemove: onRemove,
|
|
26
|
+
onMerge: mergeBlocks,
|
|
22
27
|
placeholder: __('Write code…'),
|
|
23
28
|
"aria-label": __('Code'),
|
|
24
29
|
preserveWhiteSpace: true,
|
|
25
|
-
__unstablePastePlainText: true
|
|
30
|
+
__unstablePastePlainText: true,
|
|
31
|
+
__unstableOnSplitAtDoubleLineEnd: () => insertBlocksAfter(createBlock(getDefaultBlockName()))
|
|
26
32
|
}));
|
|
27
33
|
}
|
|
28
34
|
//# sourceMappingURL=edit.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["__","RichText","useBlockProps","CodeEdit","attributes","setAttributes","onRemove","blockProps","createElement","tagName","value","content","onChange","placeholder","preserveWhiteSpace","__unstablePastePlainText"],"sources":["@wordpress/block-library/src/code/edit.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { RichText, useBlockProps } from '@wordpress/block-editor';\n\nexport default function CodeEdit( {
|
|
1
|
+
{"version":3,"names":["__","RichText","useBlockProps","createBlock","getDefaultBlockName","CodeEdit","attributes","setAttributes","onRemove","insertBlocksAfter","mergeBlocks","blockProps","createElement","tagName","identifier","value","content","onChange","onMerge","placeholder","preserveWhiteSpace","__unstablePastePlainText","__unstableOnSplitAtDoubleLineEnd"],"sources":["@wordpress/block-library/src/code/edit.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { RichText, useBlockProps } from '@wordpress/block-editor';\nimport { createBlock, getDefaultBlockName } from '@wordpress/blocks';\n\nexport default function CodeEdit( {\n\tattributes,\n\tsetAttributes,\n\tonRemove,\n\tinsertBlocksAfter,\n\tmergeBlocks,\n} ) {\n\tconst blockProps = useBlockProps();\n\treturn (\n\t\t<pre { ...blockProps }>\n\t\t\t<RichText\n\t\t\t\ttagName=\"code\"\n\t\t\t\tidentifier=\"content\"\n\t\t\t\tvalue={ attributes.content }\n\t\t\t\tonChange={ ( content ) => setAttributes( { content } ) }\n\t\t\t\tonRemove={ onRemove }\n\t\t\t\tonMerge={ mergeBlocks }\n\t\t\t\tplaceholder={ __( 'Write code…' ) }\n\t\t\t\taria-label={ __( 'Code' ) }\n\t\t\t\tpreserveWhiteSpace\n\t\t\t\t__unstablePastePlainText\n\t\t\t\t__unstableOnSplitAtDoubleLineEnd={ () =>\n\t\t\t\t\tinsertBlocksAfter( createBlock( getDefaultBlockName() ) )\n\t\t\t\t}\n\t\t\t/>\n\t\t</pre>\n\t);\n}\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,EAAE,QAAQ,iBAAiB;AACpC,SAASC,QAAQ,EAAEC,aAAa,QAAQ,yBAAyB;AACjE,SAASC,WAAW,EAAEC,mBAAmB,QAAQ,mBAAmB;AAEpE,eAAe,SAASC,QAAQA,CAAE;EACjCC,UAAU;EACVC,aAAa;EACbC,QAAQ;EACRC,iBAAiB;EACjBC;AACD,CAAC,EAAG;EACH,MAAMC,UAAU,GAAGT,aAAa,CAAC,CAAC;EAClC,OACCU,aAAA;IAAA,GAAUD;EAAU,GACnBC,aAAA,CAACX,QAAQ;IACRY,OAAO,EAAC,MAAM;IACdC,UAAU,EAAC,SAAS;IACpBC,KAAK,EAAGT,UAAU,CAACU,OAAS;IAC5BC,QAAQ,EAAKD,OAAO,IAAMT,aAAa,CAAE;MAAES;IAAQ,CAAE,CAAG;IACxDR,QAAQ,EAAGA,QAAU;IACrBU,OAAO,EAAGR,WAAa;IACvBS,WAAW,EAAGnB,EAAE,CAAE,aAAc,CAAG;IACnC,cAAaA,EAAE,CAAE,MAAO,CAAG;IAC3BoB,kBAAkB;IAClBC,wBAAwB;IACxBC,gCAAgC,EAAGA,CAAA,KAClCb,iBAAiB,CAAEN,WAAW,CAAEC,mBAAmB,CAAC,CAAE,CAAE;EACxD,CACD,CACG,CAAC;AAER"}
|
|
@@ -21,7 +21,8 @@ const metadata = {
|
|
|
21
21
|
content: {
|
|
22
22
|
type: "string",
|
|
23
23
|
source: "html",
|
|
24
|
-
selector: "code"
|
|
24
|
+
selector: "code",
|
|
25
|
+
__unstablePreserveWhiteSpace: true
|
|
25
26
|
}
|
|
26
27
|
},
|
|
27
28
|
supports: {
|
|
@@ -87,6 +88,11 @@ export const settings = {
|
|
|
87
88
|
}
|
|
88
89
|
},
|
|
89
90
|
|
|
91
|
+
merge(attributes, attributesToMerge) {
|
|
92
|
+
return {
|
|
93
|
+
content: attributes.content + '\n\n' + attributesToMerge.content
|
|
94
|
+
};
|
|
95
|
+
},
|
|
90
96
|
transforms,
|
|
91
97
|
edit,
|
|
92
98
|
save
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["__","code","icon","initBlock","edit","metadata","$schema","apiVersion","name","title","category","description","textdomain","attributes","content","type","source","selector","supports","align","anchor","typography","fontSize","lineHeight","__experimentalFontFamily","__experimentalFontWeight","__experimentalFontStyle","__experimentalTextTransform","__experimentalTextDecoration","__experimentalLetterSpacing","__experimentalDefaultControls","spacing","margin","padding","__experimentalBorder","radius","color","width","style","text","background","gradients","save","transforms","settings","example","init"],"sources":["@wordpress/block-library/src/code/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { code as icon } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport initBlock from '../utils/init-block';\nimport edit from './edit';\nimport metadata from './block.json';\nimport save from './save';\nimport transforms from './transforms';\n\nconst { name } = metadata;\n\nexport { metadata, name };\n\nexport const settings = {\n\ticon,\n\texample: {\n\t\tattributes: {\n\t\t\t/* eslint-disable @wordpress/i18n-no-collapsible-whitespace */\n\t\t\t// translators: Preserve \\n markers for line breaks\n\t\t\tcontent: __(\n\t\t\t\t'// A “block” is the abstract term used\\n// to describe units of markup that\\n// when composed together, form the\\n// content or layout of a page.\\nregisterBlockType( name, settings );'\n\t\t\t),\n\t\t\t/* eslint-enable @wordpress/i18n-no-collapsible-whitespace */\n\t\t},\n\t},\n\ttransforms,\n\tedit,\n\tsave,\n};\n\nexport const init = () => initBlock( { name, metadata, settings } );\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,EAAE,QAAQ,iBAAiB;AACpC,SAASC,IAAI,IAAIC,IAAI,QAAQ,kBAAkB;;AAE/C;AACA;AACA;AACA,OAAOC,SAAS,MAAM,qBAAqB;AAC3C,OAAOC,IAAI,MAAM,QAAQ;AAAC,MAAAC,QAAA;EAAAC,OAAA;EAAAC,UAAA;EAAAC,IAAA;EAAAC,KAAA;EAAAC,QAAA;EAAAC,WAAA;EAAAC,UAAA;EAAAC,UAAA;IAAAC,OAAA;MAAAC,IAAA;MAAAC,MAAA;MAAAC,QAAA;IAAA;EAAA;EAAAC,QAAA;IAAAC,KAAA;IAAAC,MAAA;IAAAC,UAAA;MAAAC,QAAA;MAAAC,UAAA;MAAAC,wBAAA;MAAAC,wBAAA;MAAAC,uBAAA;MAAAC,2BAAA;MAAAC,4BAAA;MAAAC,2BAAA;MAAAC,6BAAA;QAAAR,QAAA;MAAA;IAAA;IAAAS,OAAA;MAAAC,MAAA;MAAAC,OAAA;MAAAH,6BAAA;QAAAE,MAAA;QAAAC,OAAA;MAAA;IAAA;IAAAC,oBAAA;MAAAC,MAAA;MAAAC,KAAA;MAAAC,KAAA;MAAAC,KAAA;MAAAR,6BAAA;QAAAO,KAAA;QAAAD,KAAA;MAAA;IAAA;IAAAA,KAAA;MAAAG,IAAA;MAAAC,UAAA;MAAAC,SAAA;MAAAX,6BAAA;QAAAU,UAAA;QAAAD,IAAA;MAAA;IAAA;EAAA;EAAAD,KAAA;AAAA;AAE1B,OAAOI,IAAI,MAAM,QAAQ;AACzB,OAAOC,UAAU,MAAM,cAAc;AAErC,MAAM;
|
|
1
|
+
{"version":3,"names":["__","code","icon","initBlock","edit","metadata","$schema","apiVersion","name","title","category","description","textdomain","attributes","content","type","source","selector","__unstablePreserveWhiteSpace","supports","align","anchor","typography","fontSize","lineHeight","__experimentalFontFamily","__experimentalFontWeight","__experimentalFontStyle","__experimentalTextTransform","__experimentalTextDecoration","__experimentalLetterSpacing","__experimentalDefaultControls","spacing","margin","padding","__experimentalBorder","radius","color","width","style","text","background","gradients","save","transforms","settings","example","merge","attributesToMerge","init"],"sources":["@wordpress/block-library/src/code/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { code as icon } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport initBlock from '../utils/init-block';\nimport edit from './edit';\nimport metadata from './block.json';\nimport save from './save';\nimport transforms from './transforms';\n\nconst { name } = metadata;\n\nexport { metadata, name };\n\nexport const settings = {\n\ticon,\n\texample: {\n\t\tattributes: {\n\t\t\t/* eslint-disable @wordpress/i18n-no-collapsible-whitespace */\n\t\t\t// translators: Preserve \\n markers for line breaks\n\t\t\tcontent: __(\n\t\t\t\t'// A “block” is the abstract term used\\n// to describe units of markup that\\n// when composed together, form the\\n// content or layout of a page.\\nregisterBlockType( name, settings );'\n\t\t\t),\n\t\t\t/* eslint-enable @wordpress/i18n-no-collapsible-whitespace */\n\t\t},\n\t},\n\tmerge( attributes, attributesToMerge ) {\n\t\treturn {\n\t\t\tcontent: attributes.content + '\\n\\n' + attributesToMerge.content,\n\t\t};\n\t},\n\ttransforms,\n\tedit,\n\tsave,\n};\n\nexport const init = () => initBlock( { name, metadata, settings } );\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,EAAE,QAAQ,iBAAiB;AACpC,SAASC,IAAI,IAAIC,IAAI,QAAQ,kBAAkB;;AAE/C;AACA;AACA;AACA,OAAOC,SAAS,MAAM,qBAAqB;AAC3C,OAAOC,IAAI,MAAM,QAAQ;AAAC,MAAAC,QAAA;EAAAC,OAAA;EAAAC,UAAA;EAAAC,IAAA;EAAAC,KAAA;EAAAC,QAAA;EAAAC,WAAA;EAAAC,UAAA;EAAAC,UAAA;IAAAC,OAAA;MAAAC,IAAA;MAAAC,MAAA;MAAAC,QAAA;MAAAC,4BAAA;IAAA;EAAA;EAAAC,QAAA;IAAAC,KAAA;IAAAC,MAAA;IAAAC,UAAA;MAAAC,QAAA;MAAAC,UAAA;MAAAC,wBAAA;MAAAC,wBAAA;MAAAC,uBAAA;MAAAC,2BAAA;MAAAC,4BAAA;MAAAC,2BAAA;MAAAC,6BAAA;QAAAR,QAAA;MAAA;IAAA;IAAAS,OAAA;MAAAC,MAAA;MAAAC,OAAA;MAAAH,6BAAA;QAAAE,MAAA;QAAAC,OAAA;MAAA;IAAA;IAAAC,oBAAA;MAAAC,MAAA;MAAAC,KAAA;MAAAC,KAAA;MAAAC,KAAA;MAAAR,6BAAA;QAAAO,KAAA;QAAAD,KAAA;MAAA;IAAA;IAAAA,KAAA;MAAAG,IAAA;MAAAC,UAAA;MAAAC,SAAA;MAAAX,6BAAA;QAAAU,UAAA;QAAAD,IAAA;MAAA;IAAA;EAAA;EAAAD,KAAA;AAAA;AAE1B,OAAOI,IAAI,MAAM,QAAQ;AACzB,OAAOC,UAAU,MAAM,cAAc;AAErC,MAAM;EAAEpC;AAAK,CAAC,GAAGH,QAAQ;AAEzB,SAASA,QAAQ,EAAEG,IAAI;AAEvB,OAAO,MAAMqC,QAAQ,GAAG;EACvB3C,IAAI;EACJ4C,OAAO,EAAE;IACRjC,UAAU,EAAE;MACX;MACA;MACAC,OAAO,EAAEd,EAAE,CACV,yLACD;MACA;IACD;EACD,CAAC;;EACD+C,KAAKA,CAAElC,UAAU,EAAEmC,iBAAiB,EAAG;IACtC,OAAO;MACNlC,OAAO,EAAED,UAAU,CAACC,OAAO,GAAG,MAAM,GAAGkC,iBAAiB,CAAClC;IAC1D,CAAC;EACF,CAAC;EACD8B,UAAU;EACVxC,IAAI;EACJuC;AACD,CAAC;AAED,OAAO,MAAMM,IAAI,GAAGA,CAAA,KAAM9C,SAAS,CAAE;EAAEK,IAAI;EAAEH,QAAQ;EAAEwC;AAAS,CAAE,CAAC"}
|
|
@@ -82,17 +82,17 @@ function ColumnEdit({
|
|
|
82
82
|
onChangeWidth(nextWidth);
|
|
83
83
|
};
|
|
84
84
|
const renderAppender = useCallback(() => {
|
|
85
|
-
const {
|
|
86
|
-
width: columnWidth
|
|
87
|
-
} = contentStyle[clientId];
|
|
88
|
-
const isFullWidth = columnWidth === screenWidth;
|
|
89
85
|
if (isSelected) {
|
|
86
|
+
const {
|
|
87
|
+
width: columnWidth
|
|
88
|
+
} = contentStyle[clientId] || {};
|
|
89
|
+
const isFullWidth = columnWidth === screenWidth;
|
|
90
90
|
return createElement(View, {
|
|
91
91
|
style: [styles.columnAppender, isFullWidth && styles.fullwidthColumnAppender, isFullWidth && hasChildren && styles.fullwidthHasInnerColumnAppender, !isFullWidth && hasChildren && styles.hasInnerColumnAppender]
|
|
92
92
|
}, createElement(InnerBlocks.ButtonBlockAppender, null));
|
|
93
93
|
}
|
|
94
94
|
return null;
|
|
95
|
-
}, [contentStyle
|
|
95
|
+
}, [contentStyle, clientId, screenWidth, isSelected, hasChildren]);
|
|
96
96
|
if (!isSelected && !hasChildren) {
|
|
97
97
|
return createElement(View, {
|
|
98
98
|
style: [getStylesFromColorScheme(styles.columnPlaceholder, styles.columnPlaceholderDark), contentStyle[clientId]]
|