@wordpress/block-library 9.24.0 → 9.26.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 +4 -0
- package/build/avatar/edit.js +84 -39
- package/build/avatar/edit.js.map +1 -1
- package/build/avatar/user-control.js +32 -17
- package/build/avatar/user-control.js.map +1 -1
- package/build/button/edit.js +29 -17
- package/build/button/edit.js.map +1 -1
- package/build/columns/edit.js +18 -22
- package/build/columns/edit.js.map +1 -1
- package/build/comment-author-name/edit.js +41 -12
- package/build/comment-author-name/edit.js.map +1 -1
- package/build/comment-date/edit.js +41 -12
- package/build/comment-date/edit.js.map +1 -1
- package/build/comment-edit-link/edit.js +27 -7
- package/build/comment-edit-link/edit.js.map +1 -1
- package/build/comments/edit/comments-inspector-controls.js +1 -3
- package/build/comments/edit/comments-inspector-controls.js.map +1 -1
- package/build/comments-pagination/edit.js +23 -9
- package/build/comments-pagination/edit.js.map +1 -1
- package/build/comments-title/edit.js +41 -12
- package/build/comments-title/edit.js.map +1 -1
- package/build/details/edit.js +27 -3
- package/build/details/edit.js.map +1 -1
- package/build/embed/edit.js +2 -4
- package/build/embed/edit.js.map +1 -1
- package/build/embed/embed-controls.js +41 -22
- package/build/embed/embed-controls.js.map +1 -1
- package/build/embed/variations.js +0 -10
- package/build/embed/variations.js.map +1 -1
- package/build/file/inspector.js +73 -30
- package/build/file/inspector.js.map +1 -1
- package/build/form/edit.js +67 -38
- package/build/form/edit.js.map +1 -1
- package/build/form/index.js +3 -3
- package/build/form/index.js.map +1 -1
- package/build/form-input/edit.js +47 -18
- package/build/form-input/edit.js.map +1 -1
- package/build/form-input/index.js +2 -1
- package/build/form-input/index.js.map +1 -1
- package/build/form-submission-notification/index.js +2 -1
- package/build/form-submission-notification/index.js.map +1 -1
- package/build/form-submit-button/index.js +2 -1
- package/build/form-submit-button/index.js.map +1 -1
- package/build/image/image.js +1 -0
- package/build/image/image.js.map +1 -1
- package/build/image/view.js +0 -3
- package/build/image/view.js.map +1 -1
- package/build/latest-posts/edit.js +154 -82
- package/build/latest-posts/edit.js.map +1 -1
- package/build/list/ordered-list-settings.js +131 -52
- package/build/list/ordered-list-settings.js.map +1 -1
- package/build/navigation/edit/index.js +93 -51
- package/build/navigation/edit/index.js.map +1 -1
- package/build/navigation/edit/overlay-menu-preview.js +43 -27
- package/build/navigation/edit/overlay-menu-preview.js.map +1 -1
- package/build/navigation-link/edit.js +11 -0
- package/build/navigation-link/edit.js.map +1 -1
- package/build/navigation-link/index.js +3 -0
- package/build/navigation-link/index.js.map +1 -1
- package/build/navigation-link/transforms.js +2 -0
- package/build/navigation-link/transforms.js.map +1 -1
- package/build/navigation-link/update-attributes.js +1 -0
- package/build/navigation-link/update-attributes.js.map +1 -1
- package/build/navigation-submenu/index.js +3 -0
- package/build/navigation-submenu/index.js.map +1 -1
- package/build/post-author/edit.js +75 -18
- package/build/post-author/edit.js.map +1 -1
- package/build/post-comments-count/index.js +3 -1
- package/build/post-comments-count/index.js.map +1 -1
- package/build/post-comments-count/transforms.js +26 -0
- package/build/post-comments-count/transforms.js.map +1 -0
- package/build/post-comments-link/index.js +3 -1
- package/build/post-comments-link/index.js.map +1 -1
- package/build/post-comments-link/transforms.js +26 -0
- package/build/post-comments-link/transforms.js.map +1 -0
- package/build/post-navigation-link/edit.js +72 -33
- package/build/post-navigation-link/edit.js.map +1 -1
- package/build/post-title/edit.js +56 -18
- package/build/post-title/edit.js.map +1 -1
- package/build/query/edit/enhanced-pagination-modal.js +1 -1
- package/build/query/edit/enhanced-pagination-modal.js.map +1 -1
- package/build/query/edit/inspector-controls/enhanced-pagination-control.js +3 -6
- package/build/query/edit/inspector-controls/enhanced-pagination-control.js.map +1 -1
- package/build/rss/edit.js +120 -46
- package/build/rss/edit.js.map +1 -1
- package/build/separator/edit.js +52 -20
- package/build/separator/edit.js.map +1 -1
- package/build/shortcode/index.js +2 -1
- package/build/shortcode/index.js.map +1 -1
- package/build/site-logo/edit.js +53 -19
- package/build/site-logo/edit.js.map +1 -1
- package/build/social-link/edit.js +21 -5
- package/build/social-link/edit.js.map +1 -1
- package/build/social-link/edit.native.js +13 -5
- package/build/social-link/edit.native.js.map +1 -1
- package/build/social-link/social-list.js +17 -25
- package/build/social-link/social-list.js.map +1 -1
- package/build/social-link/variations.js +53 -48
- package/build/social-link/variations.js.map +1 -1
- package/build/social-links/edit.js +38 -45
- package/build/social-links/edit.js.map +1 -1
- package/build/video/tracks-editor.js +63 -21
- package/build/video/tracks-editor.js.map +1 -1
- package/build-module/avatar/edit.js +83 -38
- package/build-module/avatar/edit.js.map +1 -1
- package/build-module/avatar/user-control.js +33 -18
- package/build-module/avatar/user-control.js.map +1 -1
- package/build-module/button/edit.js +30 -18
- package/build-module/button/edit.js.map +1 -1
- package/build-module/columns/edit.js +18 -22
- package/build-module/columns/edit.js.map +1 -1
- package/build-module/comment-author-name/edit.js +42 -13
- package/build-module/comment-author-name/edit.js.map +1 -1
- package/build-module/comment-date/edit.js +42 -13
- package/build-module/comment-date/edit.js.map +1 -1
- package/build-module/comment-edit-link/edit.js +28 -8
- package/build-module/comment-edit-link/edit.js.map +1 -1
- package/build-module/comments/edit/comments-inspector-controls.js +1 -3
- package/build-module/comments/edit/comments-inspector-controls.js.map +1 -1
- package/build-module/comments-pagination/edit.js +24 -10
- package/build-module/comments-pagination/edit.js.map +1 -1
- package/build-module/comments-title/edit.js +42 -13
- package/build-module/comments-title/edit.js.map +1 -1
- package/build-module/details/edit.js +29 -5
- package/build-module/details/edit.js.map +1 -1
- package/build-module/embed/edit.js +2 -4
- package/build-module/embed/edit.js.map +1 -1
- package/build-module/embed/embed-controls.js +42 -23
- package/build-module/embed/embed-controls.js.map +1 -1
- package/build-module/embed/variations.js +0 -10
- package/build-module/embed/variations.js.map +1 -1
- package/build-module/file/inspector.js +74 -31
- package/build-module/file/inspector.js.map +1 -1
- package/build-module/form/edit.js +68 -39
- package/build-module/form/edit.js.map +1 -1
- package/build-module/form/index.js +3 -3
- package/build-module/form/index.js.map +1 -1
- package/build-module/form-input/edit.js +48 -19
- package/build-module/form-input/edit.js.map +1 -1
- package/build-module/form-input/index.js +2 -1
- package/build-module/form-input/index.js.map +1 -1
- package/build-module/form-submission-notification/index.js +2 -1
- package/build-module/form-submission-notification/index.js.map +1 -1
- package/build-module/form-submit-button/index.js +2 -1
- package/build-module/form-submit-button/index.js.map +1 -1
- package/build-module/image/image.js +1 -0
- package/build-module/image/image.js.map +1 -1
- package/build-module/image/view.js +0 -3
- package/build-module/image/view.js.map +1 -1
- package/build-module/latest-posts/edit.js +155 -83
- package/build-module/latest-posts/edit.js.map +1 -1
- package/build-module/list/ordered-list-settings.js +132 -53
- package/build-module/list/ordered-list-settings.js.map +1 -1
- package/build-module/navigation/edit/index.js +94 -52
- package/build-module/navigation/edit/index.js.map +1 -1
- package/build-module/navigation/edit/overlay-menu-preview.js +44 -28
- package/build-module/navigation/edit/overlay-menu-preview.js.map +1 -1
- package/build-module/navigation-link/edit.js +11 -0
- package/build-module/navigation-link/edit.js.map +1 -1
- package/build-module/navigation-link/index.js +3 -0
- package/build-module/navigation-link/index.js.map +1 -1
- package/build-module/navigation-link/transforms.js +2 -0
- package/build-module/navigation-link/transforms.js.map +1 -1
- package/build-module/navigation-link/update-attributes.js +1 -0
- package/build-module/navigation-link/update-attributes.js.map +1 -1
- package/build-module/navigation-submenu/index.js +3 -0
- package/build-module/navigation-submenu/index.js.map +1 -1
- package/build-module/post-author/edit.js +76 -19
- package/build-module/post-author/edit.js.map +1 -1
- package/build-module/post-comments-count/index.js +3 -1
- package/build-module/post-comments-count/index.js.map +1 -1
- package/build-module/post-comments-count/transforms.js +19 -0
- package/build-module/post-comments-count/transforms.js.map +1 -0
- package/build-module/post-comments-link/index.js +3 -1
- package/build-module/post-comments-link/index.js.map +1 -1
- package/build-module/post-comments-link/transforms.js +19 -0
- package/build-module/post-comments-link/transforms.js.map +1 -0
- package/build-module/post-navigation-link/edit.js +73 -34
- package/build-module/post-navigation-link/edit.js.map +1 -1
- package/build-module/post-title/edit.js +57 -19
- package/build-module/post-title/edit.js.map +1 -1
- package/build-module/query/edit/enhanced-pagination-modal.js +1 -1
- package/build-module/query/edit/enhanced-pagination-modal.js.map +1 -1
- package/build-module/query/edit/inspector-controls/enhanced-pagination-control.js +3 -6
- package/build-module/query/edit/inspector-controls/enhanced-pagination-control.js.map +1 -1
- package/build-module/rss/edit.js +121 -47
- package/build-module/rss/edit.js.map +1 -1
- package/build-module/separator/edit.js +54 -22
- package/build-module/separator/edit.js.map +1 -1
- package/build-module/shortcode/index.js +2 -1
- package/build-module/shortcode/index.js.map +1 -1
- package/build-module/site-logo/edit.js +54 -20
- package/build-module/site-logo/edit.js.map +1 -1
- package/build-module/social-link/edit.js +24 -8
- package/build-module/social-link/edit.js.map +1 -1
- package/build-module/social-link/edit.native.js +15 -6
- package/build-module/social-link/edit.native.js.map +1 -1
- package/build-module/social-link/social-list.js +16 -21
- package/build-module/social-link/social-list.js.map +1 -1
- package/build-module/social-link/variations.js +53 -48
- package/build-module/social-link/variations.js.map +1 -1
- package/build-module/social-links/edit.js +40 -47
- package/build-module/social-links/edit.js.map +1 -1
- package/build-module/video/tracks-editor.js +65 -23
- package/build-module/video/tracks-editor.js.map +1 -1
- package/build-style/calendar/style-rtl.css +7 -7
- package/build-style/calendar/style.css +7 -7
- package/build-style/comments-pagination/editor-rtl.css +0 -12
- package/build-style/comments-pagination/editor.css +0 -14
- package/build-style/comments-pagination/style-rtl.css +0 -7
- package/build-style/comments-pagination/style.css +0 -9
- package/build-style/editor-rtl.css +9 -21
- package/build-style/editor.css +9 -23
- package/build-style/gallery/style-rtl.css +1 -0
- package/build-style/gallery/style.css +1 -0
- package/build-style/navigation/editor-rtl.css +8 -3
- package/build-style/navigation/editor.css +8 -3
- package/build-style/navigation/style-rtl.css +4 -0
- package/build-style/navigation/style.css +4 -0
- package/build-style/pullquote/editor-rtl.css +1 -1
- package/build-style/pullquote/editor.css +1 -1
- package/build-style/pullquote/style-rtl.css +2 -3
- package/build-style/pullquote/style.css +2 -3
- package/build-style/pullquote/theme-rtl.css +2 -2
- package/build-style/pullquote/theme.css +2 -2
- package/build-style/style-rtl.css +14 -17
- package/build-style/style.css +14 -19
- package/build-style/theme-rtl.css +2 -2
- package/build-style/theme.css +2 -2
- package/package.json +35 -35
- package/src/avatar/edit.js +99 -51
- package/src/avatar/user-control.js +34 -29
- package/src/button/edit.js +44 -29
- package/src/calendar/style.scss +10 -10
- package/src/columns/edit.js +20 -31
- package/src/comment-author-name/edit.js +54 -13
- package/src/comment-date/edit.js +50 -15
- package/src/comment-edit-link/edit.js +39 -11
- package/src/comments/edit/comments-inspector-controls.js +0 -2
- package/src/comments-pagination/edit.js +29 -9
- package/src/comments-pagination/editor.scss +0 -15
- package/src/comments-pagination/style.scss +0 -8
- package/src/comments-title/edit.js +53 -15
- package/src/details/edit.js +36 -4
- package/src/editor.scss +0 -1
- package/src/embed/edit.js +3 -5
- package/src/embed/embed-controls.js +55 -33
- package/src/embed/variations.js +0 -8
- package/src/file/inspector.js +99 -45
- package/src/form/block.json +1 -2
- package/src/form/edit.js +91 -47
- package/src/form/index.js +1 -0
- package/src/form-input/edit.js +56 -18
- package/src/form-input/index.js +1 -0
- package/src/form-submission-notification/index.js +1 -0
- package/src/form-submit-button/index.js +1 -0
- package/src/gallery/style.scss +1 -0
- package/src/image/image.js +1 -0
- package/src/image/index.php +4 -1
- package/src/image/view.js +0 -3
- package/src/latest-posts/edit.js +206 -98
- package/src/list/ordered-list-settings.js +172 -62
- package/src/navigation/edit/index.js +127 -64
- package/src/navigation/edit/overlay-menu-preview.js +43 -26
- package/src/navigation/editor.scss +8 -4
- package/src/navigation/style.scss +8 -0
- package/src/navigation-link/block.json +3 -0
- package/src/navigation-link/edit.js +14 -1
- package/src/navigation-link/index.php +4 -0
- package/src/navigation-link/transforms.js +2 -1
- package/src/navigation-link/update-attributes.js +1 -0
- package/src/navigation-submenu/block.json +3 -0
- package/src/navigation-submenu/index.php +4 -0
- package/src/post-author/edit.js +91 -27
- package/src/post-comments-count/index.js +2 -0
- package/src/post-comments-count/transforms.js +20 -0
- package/src/post-comments-link/index.js +2 -0
- package/src/post-comments-link/transforms.js +20 -0
- package/src/post-navigation-link/edit.js +96 -51
- package/src/post-title/edit.js +76 -24
- package/src/pullquote/editor.scss +1 -1
- package/src/pullquote/style.scss +2 -3
- package/src/pullquote/theme.scss +2 -2
- package/src/query/edit/enhanced-pagination-modal.js +1 -5
- package/src/query/edit/inspector-controls/enhanced-pagination-control.js +3 -13
- package/src/rss/edit.js +141 -55
- package/src/separator/edit.js +66 -21
- package/src/shortcode/block.json +2 -1
- package/src/site-logo/edit.js +69 -26
- package/src/site-title/index.php +1 -1
- package/src/social-link/edit.js +18 -7
- package/src/social-link/edit.native.js +10 -4
- package/src/social-link/index.php +62 -49
- package/src/social-link/social-list.js +15 -20
- package/src/social-link/variations.js +53 -48
- package/src/social-links/edit.js +38 -60
- package/src/video/tracks-editor.js +75 -22
- package/build-style/post-author/editor-rtl.css +0 -140
- package/build-style/post-author/editor.css +0 -140
- package/src/post-author/editor.scss +0 -7
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_i18n","require","_blockEditor","_data","_components","_commentsPaginationArrowControls","_jsxRuntime","TEMPLATE","QueryPaginationEdit","attributes","paginationArrow","setAttributes","clientId","hasNextPreviousBlocks","useSelect","select","getBlocks","blockEditorStore","innerBlocks","find","innerBlock","includes","name","blockProps","useBlockProps","innerBlocksProps","useInnerBlocksProps","template","pageComments","getSettings","__experimentalDiscussionSettings","jsx","Warning","children","__","jsxs","Fragment","InspectorControls","
|
|
1
|
+
{"version":3,"names":["_i18n","require","_blockEditor","_data","_components","_commentsPaginationArrowControls","_hooks","_jsxRuntime","TEMPLATE","QueryPaginationEdit","attributes","paginationArrow","setAttributes","clientId","hasNextPreviousBlocks","useSelect","select","getBlocks","blockEditorStore","innerBlocks","find","innerBlock","includes","name","blockProps","useBlockProps","dropdownMenuProps","useToolsPanelDropdownMenuProps","innerBlocksProps","useInnerBlocksProps","template","pageComments","getSettings","__experimentalDiscussionSettings","jsx","Warning","children","__","jsxs","Fragment","InspectorControls","__experimentalToolsPanel","label","resetAll","__experimentalToolsPanelItem","hasValue","onDeselect","isShownByDefault","CommentsPaginationArrowControls","value","onChange"],"sources":["@wordpress/block-library/src/comments-pagination/edit.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport {\n\tInspectorControls,\n\tuseBlockProps,\n\tuseInnerBlocksProps,\n\tstore as blockEditorStore,\n\tWarning,\n} from '@wordpress/block-editor';\nimport { useSelect } from '@wordpress/data';\nimport {\n\t__experimentalToolsPanel as ToolsPanel,\n\t__experimentalToolsPanelItem as ToolsPanelItem,\n} from '@wordpress/components';\n\n/**\n * Internal dependencies\n */\nimport { CommentsPaginationArrowControls } from './comments-pagination-arrow-controls';\nimport { useToolsPanelDropdownMenuProps } from '../utils/hooks';\n\nconst TEMPLATE = [\n\t[ 'core/comments-pagination-previous' ],\n\t[ 'core/comments-pagination-numbers' ],\n\t[ 'core/comments-pagination-next' ],\n];\n\nexport default function QueryPaginationEdit( {\n\tattributes: { paginationArrow },\n\tsetAttributes,\n\tclientId,\n} ) {\n\tconst hasNextPreviousBlocks = useSelect( ( select ) => {\n\t\tconst { getBlocks } = select( blockEditorStore );\n\t\tconst innerBlocks = getBlocks( clientId );\n\t\t/**\n\t\t * Show the `paginationArrow` control only if a\n\t\t * Comments Pagination Next or Comments Pagination Previous\n\t\t * block exists.\n\t\t */\n\t\treturn innerBlocks?.find( ( innerBlock ) => {\n\t\t\treturn [\n\t\t\t\t'core/comments-pagination-previous',\n\t\t\t\t'core/comments-pagination-next',\n\t\t\t].includes( innerBlock.name );\n\t\t} );\n\t}, [] );\n\n\tconst blockProps = useBlockProps();\n\tconst dropdownMenuProps = useToolsPanelDropdownMenuProps();\n\tconst innerBlocksProps = useInnerBlocksProps( blockProps, {\n\t\ttemplate: TEMPLATE,\n\t} );\n\n\t// Get the Discussion settings\n\tconst pageComments = useSelect( ( select ) => {\n\t\tconst { getSettings } = select( blockEditorStore );\n\t\tconst { __experimentalDiscussionSettings } = getSettings();\n\t\treturn __experimentalDiscussionSettings?.pageComments;\n\t}, [] );\n\n\t// If paging comments is not enabled in the Discussion Settings then hide the pagination\n\t// controls. We don't want to remove them from the template so that when the user enables\n\t// paging comments, the controls will be visible.\n\tif ( ! pageComments ) {\n\t\treturn (\n\t\t\t<Warning>\n\t\t\t\t{ __(\n\t\t\t\t\t'Comments Pagination block: paging comments is disabled in the Discussion Settings'\n\t\t\t\t) }\n\t\t\t</Warning>\n\t\t);\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t{ hasNextPreviousBlocks && (\n\t\t\t\t<InspectorControls>\n\t\t\t\t\t<ToolsPanel\n\t\t\t\t\t\tlabel={ __( 'Settings' ) }\n\t\t\t\t\t\tdropdownMenuProps={ dropdownMenuProps }\n\t\t\t\t\t\tresetAll={ () =>\n\t\t\t\t\t\t\tsetAttributes( { paginationArrow: 'none' } )\n\t\t\t\t\t\t}\n\t\t\t\t\t>\n\t\t\t\t\t\t<ToolsPanelItem\n\t\t\t\t\t\t\tlabel={ __( 'Arrow' ) }\n\t\t\t\t\t\t\thasValue={ () => paginationArrow !== 'none' }\n\t\t\t\t\t\t\tonDeselect={ () =>\n\t\t\t\t\t\t\t\tsetAttributes( { paginationArrow: 'none' } )\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tisShownByDefault\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<CommentsPaginationArrowControls\n\t\t\t\t\t\t\t\tvalue={ paginationArrow }\n\t\t\t\t\t\t\t\tonChange={ ( value ) => {\n\t\t\t\t\t\t\t\t\tsetAttributes( { paginationArrow: value } );\n\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</ToolsPanelItem>\n\t\t\t\t\t</ToolsPanel>\n\t\t\t\t</InspectorControls>\n\t\t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AED,eAAe,EAAEsC;cAAM,CAAE,CAAC;YAC5C;UAAG,CACH;QAAC,CACa;MAAC,CACN;IAAC,CACK,CACnB,eACD,IAAA1C,WAAA,CAAA2B,GAAA;MAAA,GAAUN;IAAgB,CAAI,CAAC;EAAA,CAC9B,CAAC;AAEL","ignoreList":[]}
|
|
@@ -14,6 +14,7 @@ var _element = require("@wordpress/element");
|
|
|
14
14
|
var _data = require("@wordpress/data");
|
|
15
15
|
var _apiFetch = _interopRequireDefault(require("@wordpress/api-fetch"));
|
|
16
16
|
var _url = require("@wordpress/url");
|
|
17
|
+
var _hooks = require("../utils/hooks");
|
|
17
18
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
18
19
|
/**
|
|
19
20
|
* External dependencies
|
|
@@ -23,6 +24,10 @@ var _jsxRuntime = require("react/jsx-runtime");
|
|
|
23
24
|
* WordPress dependencies
|
|
24
25
|
*/
|
|
25
26
|
|
|
27
|
+
/**
|
|
28
|
+
* Internal dependencies
|
|
29
|
+
*/
|
|
30
|
+
|
|
26
31
|
function Edit({
|
|
27
32
|
attributes: {
|
|
28
33
|
textAlign,
|
|
@@ -57,6 +62,7 @@ function Edit({
|
|
|
57
62
|
} = select(_blockEditor.store);
|
|
58
63
|
return getSettings().__experimentalDiscussionSettings;
|
|
59
64
|
});
|
|
65
|
+
const dropdownMenuProps = (0, _hooks.useToolsPanelDropdownMenuProps)();
|
|
60
66
|
(0, _element.useEffect)(() => {
|
|
61
67
|
if (isSiteEditor) {
|
|
62
68
|
// Match the number of comments that will be shown in the comment-template/edit.js placeholder
|
|
@@ -100,21 +106,44 @@ function Edit({
|
|
|
100
106
|
})]
|
|
101
107
|
});
|
|
102
108
|
const inspectorControls = /*#__PURE__*/(0, _jsxRuntime.jsx)(_blockEditor.InspectorControls, {
|
|
103
|
-
children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_components.
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
109
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_components.__experimentalToolsPanel, {
|
|
110
|
+
label: (0, _i18n.__)('Settings'),
|
|
111
|
+
resetAll: () => {
|
|
112
|
+
setAttributes({
|
|
113
|
+
showPostTitle: true,
|
|
114
|
+
showCommentsCount: true
|
|
115
|
+
});
|
|
116
|
+
},
|
|
117
|
+
dropdownMenuProps: dropdownMenuProps,
|
|
118
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_components.__experimentalToolsPanelItem, {
|
|
107
119
|
label: (0, _i18n.__)('Show post title'),
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
120
|
+
isShownByDefault: true,
|
|
121
|
+
hasValue: () => !showPostTitle,
|
|
122
|
+
onDeselect: () => setAttributes({
|
|
123
|
+
showPostTitle: true
|
|
124
|
+
}),
|
|
125
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.ToggleControl, {
|
|
126
|
+
__nextHasNoMarginBottom: true,
|
|
127
|
+
label: (0, _i18n.__)('Show post title'),
|
|
128
|
+
checked: showPostTitle,
|
|
129
|
+
onChange: value => setAttributes({
|
|
130
|
+
showPostTitle: value
|
|
131
|
+
})
|
|
111
132
|
})
|
|
112
|
-
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.
|
|
113
|
-
__nextHasNoMarginBottom: true,
|
|
133
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.__experimentalToolsPanelItem, {
|
|
114
134
|
label: (0, _i18n.__)('Show comments count'),
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
135
|
+
isShownByDefault: true,
|
|
136
|
+
hasValue: () => !showCommentsCount,
|
|
137
|
+
onDeselect: () => setAttributes({
|
|
138
|
+
showCommentsCount: true
|
|
139
|
+
}),
|
|
140
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.ToggleControl, {
|
|
141
|
+
__nextHasNoMarginBottom: true,
|
|
142
|
+
label: (0, _i18n.__)('Show comments count'),
|
|
143
|
+
checked: showCommentsCount,
|
|
144
|
+
onChange: value => setAttributes({
|
|
145
|
+
showCommentsCount: value
|
|
146
|
+
})
|
|
118
147
|
})
|
|
119
148
|
})]
|
|
120
149
|
})
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_clsx","_interopRequireDefault","require","_blockEditor","_i18n","_coreData","_components","_element","_data","_apiFetch","_url","_jsxRuntime","Edit","attributes","textAlign","showPostTitle","showCommentsCount","level","levelOptions","setAttributes","context","postType","postId","TagName","commentsCount","setCommentsCount","useState","rawTitle","useEntityProp","isSiteEditor","blockProps","useBlockProps","className","clsx","threadCommentsDepth","threadComments","commentsPerPage","pageComments","useSelect","select","getSettings","blockEditorStore","__experimentalDiscussionSettings","useEffect","nestedCommentsNumber","Math","min","topLevelCommentsNumber","commentsNumber","parseInt","currentPostId","apiFetch","path","addQueryArgs","post","_fields","method","parse","then","res","headers","get","catch","blockControls","jsxs","BlockControls","group","children","jsx","AlignmentControl","value","onChange","newAlign","HeadingLevelDropdown","options","newLevel","inspectorControls","InspectorControls","PanelBody","title","__","ToggleControl","__nextHasNoMarginBottom","label","checked","postTitle","placeholder","undefined","sprintf","_n","Fragment"],"sources":["@wordpress/block-library/src/comments-title/edit.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tAlignmentControl,\n\tBlockControls,\n\tuseBlockProps,\n\tInspectorControls,\n\tstore as blockEditorStore,\n\tHeadingLevelDropdown,\n} from '@wordpress/block-editor';\nimport { __, _n, sprintf } from '@wordpress/i18n';\nimport { useEntityProp } from '@wordpress/core-data';\nimport { PanelBody, ToggleControl } from '@wordpress/components';\nimport { useState, useEffect } from '@wordpress/element';\nimport { useSelect } from '@wordpress/data';\nimport apiFetch from '@wordpress/api-fetch';\nimport { addQueryArgs } from '@wordpress/url';\n\nexport default function Edit( {\n\tattributes: {\n\t\ttextAlign,\n\t\tshowPostTitle,\n\t\tshowCommentsCount,\n\t\tlevel,\n\t\tlevelOptions,\n\t},\n\tsetAttributes,\n\tcontext: { postType, postId },\n} ) {\n\tconst TagName = 'h' + level;\n\tconst [ commentsCount, setCommentsCount ] = useState();\n\tconst [ rawTitle ] = useEntityProp( 'postType', postType, 'title', postId );\n\tconst isSiteEditor = typeof postId === 'undefined';\n\tconst blockProps = useBlockProps( {\n\t\tclassName: clsx( {\n\t\t\t[ `has-text-align-${ textAlign }` ]: textAlign,\n\t\t} ),\n\t} );\n\n\tconst {\n\t\tthreadCommentsDepth,\n\t\tthreadComments,\n\t\tcommentsPerPage,\n\t\tpageComments,\n\t} = useSelect( ( select ) => {\n\t\tconst { getSettings } = select( blockEditorStore );\n\t\treturn getSettings().__experimentalDiscussionSettings;\n\t} );\n\n\tuseEffect( () => {\n\t\tif ( isSiteEditor ) {\n\t\t\t// Match the number of comments that will be shown in the comment-template/edit.js placeholder\n\n\t\t\tconst nestedCommentsNumber = threadComments\n\t\t\t\t? Math.min( threadCommentsDepth, 3 ) - 1\n\t\t\t\t: 0;\n\t\t\tconst topLevelCommentsNumber = pageComments ? commentsPerPage : 3;\n\n\t\t\tconst commentsNumber =\n\t\t\t\tparseInt( nestedCommentsNumber ) +\n\t\t\t\tparseInt( topLevelCommentsNumber );\n\n\t\t\tsetCommentsCount( Math.min( commentsNumber, 3 ) );\n\t\t\treturn;\n\t\t}\n\t\tconst currentPostId = postId;\n\t\tapiFetch( {\n\t\t\tpath: addQueryArgs( '/wp/v2/comments', {\n\t\t\t\tpost: postId,\n\t\t\t\t_fields: 'id',\n\t\t\t} ),\n\t\t\tmethod: 'HEAD',\n\t\t\tparse: false,\n\t\t} )\n\t\t\t.then( ( res ) => {\n\t\t\t\t// Stale requests will have the `currentPostId` of an older closure.\n\t\t\t\tif ( currentPostId === postId ) {\n\t\t\t\t\tsetCommentsCount(\n\t\t\t\t\t\tparseInt( res.headers.get( 'X-WP-Total' ) )\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t} )\n\t\t\t.catch( () => {\n\t\t\t\tsetCommentsCount( 0 );\n\t\t\t} );\n\t}, [ postId ] );\n\n\tconst blockControls = (\n\t\t<BlockControls group=\"block\">\n\t\t\t<AlignmentControl\n\t\t\t\tvalue={ textAlign }\n\t\t\t\tonChange={ ( newAlign ) =>\n\t\t\t\t\tsetAttributes( { textAlign: newAlign } )\n\t\t\t\t}\n\t\t\t/>\n\t\t\t<HeadingLevelDropdown\n\t\t\t\tvalue={ level }\n\t\t\t\toptions={ levelOptions }\n\t\t\t\tonChange={ ( newLevel ) =>\n\t\t\t\t\tsetAttributes( { level: newLevel } )\n\t\t\t\t}\n\t\t\t/>\n\t\t</BlockControls>\n\t);\n\n\tconst inspectorControls = (\n\t\t<InspectorControls>\n\t\t\t<PanelBody title={ __( 'Settings' ) }>\n\t\t\t\t<ToggleControl\n\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\tlabel={ __( 'Show post title' ) }\n\t\t\t\t\tchecked={ showPostTitle }\n\t\t\t\t\tonChange={ ( value ) =>\n\t\t\t\t\t\tsetAttributes( { showPostTitle: value } )\n\t\t\t\t\t}\n\t\t\t\t/>\n\t\t\t\t<ToggleControl\n\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\tlabel={ __( 'Show comments count' ) }\n\t\t\t\t\tchecked={ showCommentsCount }\n\t\t\t\t\tonChange={ ( value ) =>\n\t\t\t\t\t\tsetAttributes( { showCommentsCount: value } )\n\t\t\t\t\t}\n\t\t\t\t/>\n\t\t\t</PanelBody>\n\t\t</InspectorControls>\n\t);\n\n\tconst postTitle = isSiteEditor ? __( '“Post Title”' ) : `\"${ rawTitle }\"`;\n\n\tlet placeholder;\n\tif ( showCommentsCount && commentsCount !== undefined ) {\n\t\tif ( showPostTitle ) {\n\t\t\tif ( commentsCount === 1 ) {\n\t\t\t\t/* translators: %s: Post title. */\n\t\t\t\tplaceholder = sprintf( __( 'One response to %s' ), postTitle );\n\t\t\t} else {\n\t\t\t\tplaceholder = sprintf(\n\t\t\t\t\t/* translators: 1: Number of comments, 2: Post title. */\n\t\t\t\t\t_n(\n\t\t\t\t\t\t'%1$s response to %2$s',\n\t\t\t\t\t\t'%1$s responses to %2$s',\n\t\t\t\t\t\tcommentsCount\n\t\t\t\t\t),\n\t\t\t\t\tcommentsCount,\n\t\t\t\t\tpostTitle\n\t\t\t\t);\n\t\t\t}\n\t\t} else if ( commentsCount === 1 ) {\n\t\t\tplaceholder = __( 'One response' );\n\t\t} else {\n\t\t\tplaceholder = sprintf(\n\t\t\t\t/* translators: %s: Number of comments. */\n\t\t\t\t_n( '%s response', '%s responses', commentsCount ),\n\t\t\t\tcommentsCount\n\t\t\t);\n\t\t}\n\t} else if ( showPostTitle ) {\n\t\tif ( commentsCount === 1 ) {\n\t\t\t/* translators: %s: Post title. */\n\t\t\tplaceholder = sprintf( __( 'Response to %s' ), postTitle );\n\t\t} else {\n\t\t\t/* translators: %s: Post title. */\n\t\t\tplaceholder = sprintf( __( 'Responses to %s' ), postTitle );\n\t\t}\n\t} else if ( commentsCount === 1 ) {\n\t\tplaceholder = __( 'Response' );\n\t} else {\n\t\tplaceholder = __( 'Responses' );\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t{ blockControls }\n\t\t\t{ inspectorControls }\n\t\t\t<TagName { ...blockProps }>{ placeholder }</TagName>\n\t\t</>\n\t);\n}\n"],"mappings":";;;;;;;AAGA,IAAAA,KAAA,GAAAC,sBAAA,CAAAC,OAAA;AAKA,IAAAC,YAAA,GAAAD,OAAA;AAQA,IAAAE,KAAA,GAAAF,OAAA;AACA,IAAAG,SAAA,GAAAH,OAAA;AACA,IAAAI,WAAA,GAAAJ,OAAA;AACA,IAAAK,QAAA,GAAAL,OAAA;AACA,IAAAM,KAAA,GAAAN,OAAA;AACA,IAAAO,SAAA,GAAAR,sBAAA,CAAAC,OAAA;AACA,IAAAQ,IAAA,GAAAR,OAAA;AAA8C,IAAAS,WAAA,GAAAT,OAAA;AAtB9C;AACA;AACA;;AAGA;AACA;AACA;;AAiBe,S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AAK7D,aAAa,KAAK,CAAC,EAAG;MACjC8D,WAAW,GAAG,IAAAN,QAAE,EAAE,cAAe,CAAC;IACnC,CAAC,MAAM;MACNM,WAAW,GAAG,IAAAE,aAAO,EACpB;MACA,IAAAC,QAAE,EAAE,aAAa,EAAE,cAAc,EAAEjE,aAAc,CAAC,EAClDA,aACD,CAAC;IACF;EACD,CAAC,MAAM,IAAKT,aAAa,EAAG;IAC3B,IAAKS,aAAa,KAAK,CAAC,EAAG;MAC1B;MACA8D,WAAW,GAAG,IAAAE,aAAO,EAAE,IAAAR,QAAE,EAAE,gBAAiB,CAAC,EAAEK,SAAU,CAAC;IAC3D,CAAC,MAAM;MACN;MACAC,WAAW,GAAG,IAAAE,aAAO,EAAE,IAAAR,QAAE,EAAE,iBAAkB,CAAC,EAAEK,SAAU,CAAC;IAC5D;EACD,CAAC,MAAM,IAAK7D,aAAa,KAAK,CAAC,EAAG;IACjC8D,WAAW,GAAG,IAAAN,QAAE,EAAE,UAAW,CAAC;EAC/B,CAAC,MAAM;IACNM,WAAW,GAAG,IAAAN,QAAE,EAAE,WAAY,CAAC;EAChC;EAEA,oBACC,IAAArE,WAAA,CAAAqD,IAAA,EAAArD,WAAA,CAAA+E,QAAA;IAAAvB,QAAA,GACGJ,aAAa,EACba,iBAAiB,eACnB,IAAAjE,WAAA,CAAAyD,GAAA,EAAC7C,OAAO;MAAA,GAAMO,UAAU;MAAAqC,QAAA,EAAKmB;IAAW,CAAW,CAAC;EAAA,CACnD,CAAC;AAEL","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["_clsx","_interopRequireDefault","require","_blockEditor","_i18n","_coreData","_components","_element","_data","_apiFetch","_url","_hooks","_jsxRuntime","Edit","attributes","textAlign","showPostTitle","showCommentsCount","level","levelOptions","setAttributes","context","postType","postId","TagName","commentsCount","setCommentsCount","useState","rawTitle","useEntityProp","isSiteEditor","blockProps","useBlockProps","className","clsx","threadCommentsDepth","threadComments","commentsPerPage","pageComments","useSelect","select","getSettings","blockEditorStore","__experimentalDiscussionSettings","dropdownMenuProps","useToolsPanelDropdownMenuProps","useEffect","nestedCommentsNumber","Math","min","topLevelCommentsNumber","commentsNumber","parseInt","currentPostId","apiFetch","path","addQueryArgs","post","_fields","method","parse","then","res","headers","get","catch","blockControls","jsxs","BlockControls","group","children","jsx","AlignmentControl","value","onChange","newAlign","HeadingLevelDropdown","options","newLevel","inspectorControls","InspectorControls","__experimentalToolsPanel","label","__","resetAll","__experimentalToolsPanelItem","isShownByDefault","hasValue","onDeselect","ToggleControl","__nextHasNoMarginBottom","checked","postTitle","placeholder","undefined","sprintf","_n","Fragment"],"sources":["@wordpress/block-library/src/comments-title/edit.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tAlignmentControl,\n\tBlockControls,\n\tuseBlockProps,\n\tInspectorControls,\n\tstore as blockEditorStore,\n\tHeadingLevelDropdown,\n} from '@wordpress/block-editor';\nimport { __, _n, sprintf } from '@wordpress/i18n';\nimport { useEntityProp } from '@wordpress/core-data';\nimport {\n\tToggleControl,\n\t__experimentalToolsPanel as ToolsPanel,\n\t__experimentalToolsPanelItem as ToolsPanelItem,\n} from '@wordpress/components';\nimport { useState, useEffect } from '@wordpress/element';\nimport { useSelect } from '@wordpress/data';\nimport apiFetch from '@wordpress/api-fetch';\nimport { addQueryArgs } from '@wordpress/url';\n\n/**\n * Internal dependencies\n */\nimport { useToolsPanelDropdownMenuProps } from '../utils/hooks';\n\nexport default function Edit( {\n\tattributes: {\n\t\ttextAlign,\n\t\tshowPostTitle,\n\t\tshowCommentsCount,\n\t\tlevel,\n\t\tlevelOptions,\n\t},\n\tsetAttributes,\n\tcontext: { postType, postId },\n} ) {\n\tconst TagName = 'h' + level;\n\tconst [ commentsCount, setCommentsCount ] = useState();\n\tconst [ rawTitle ] = useEntityProp( 'postType', postType, 'title', postId );\n\tconst isSiteEditor = typeof postId === 'undefined';\n\tconst blockProps = useBlockProps( {\n\t\tclassName: clsx( {\n\t\t\t[ `has-text-align-${ textAlign }` ]: textAlign,\n\t\t} ),\n\t} );\n\n\tconst {\n\t\tthreadCommentsDepth,\n\t\tthreadComments,\n\t\tcommentsPerPage,\n\t\tpageComments,\n\t} = useSelect( ( select ) => {\n\t\tconst { getSettings } = select( blockEditorStore );\n\t\treturn getSettings().__experimentalDiscussionSettings;\n\t} );\n\n\tconst dropdownMenuProps = useToolsPanelDropdownMenuProps();\n\n\tuseEffect( () => {\n\t\tif ( isSiteEditor ) {\n\t\t\t// Match the number of comments that will be shown in the comment-template/edit.js placeholder\n\n\t\t\tconst nestedCommentsNumber = threadComments\n\t\t\t\t? Math.min( threadCommentsDepth, 3 ) - 1\n\t\t\t\t: 0;\n\t\t\tconst topLevelCommentsNumber = pageComments ? commentsPerPage : 3;\n\n\t\t\tconst commentsNumber =\n\t\t\t\tparseInt( nestedCommentsNumber ) +\n\t\t\t\tparseInt( topLevelCommentsNumber );\n\n\t\t\tsetCommentsCount( Math.min( commentsNumber, 3 ) );\n\t\t\treturn;\n\t\t}\n\t\tconst currentPostId = postId;\n\t\tapiFetch( {\n\t\t\tpath: addQueryArgs( '/wp/v2/comments', {\n\t\t\t\tpost: postId,\n\t\t\t\t_fields: 'id',\n\t\t\t} ),\n\t\t\tmethod: 'HEAD',\n\t\t\tparse: false,\n\t\t} )\n\t\t\t.then( ( res ) => {\n\t\t\t\t// Stale requests will have the `currentPostId` of an older closure.\n\t\t\t\tif ( currentPostId === postId ) {\n\t\t\t\t\tsetCommentsCount(\n\t\t\t\t\t\tparseInt( res.headers.get( 'X-WP-Total' ) )\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t} )\n\t\t\t.catch( () => {\n\t\t\t\tsetCommentsCount( 0 );\n\t\t\t} );\n\t}, [ postId ] );\n\n\tconst blockControls = (\n\t\t<BlockControls group=\"block\">\n\t\t\t<AlignmentControl\n\t\t\t\tvalue={ textAlign }\n\t\t\t\tonChange={ ( newAlign ) =>\n\t\t\t\t\tsetAttributes( { textAlign: newAlign } )\n\t\t\t\t}\n\t\t\t/>\n\t\t\t<HeadingLevelDropdown\n\t\t\t\tvalue={ level }\n\t\t\t\toptions={ levelOptions }\n\t\t\t\tonChange={ ( newLevel ) =>\n\t\t\t\t\tsetAttributes( { level: newLevel } )\n\t\t\t\t}\n\t\t\t/>\n\t\t</BlockControls>\n\t);\n\n\tconst inspectorControls = (\n\t\t<InspectorControls>\n\t\t\t<ToolsPanel\n\t\t\t\tlabel={ __( 'Settings' ) }\n\t\t\t\tresetAll={ () => {\n\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\tshowPostTitle: true,\n\t\t\t\t\t\tshowCommentsCount: true,\n\t\t\t\t\t} );\n\t\t\t\t} }\n\t\t\t\tdropdownMenuProps={ dropdownMenuProps }\n\t\t\t>\n\t\t\t\t<ToolsPanelItem\n\t\t\t\t\tlabel={ __( 'Show post title' ) }\n\t\t\t\t\tisShownByDefault\n\t\t\t\t\thasValue={ () => ! showPostTitle }\n\t\t\t\t\tonDeselect={ () =>\n\t\t\t\t\t\tsetAttributes( { showPostTitle: true } )\n\t\t\t\t\t}\n\t\t\t\t>\n\t\t\t\t\t<ToggleControl\n\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\tlabel={ __( 'Show post title' ) }\n\t\t\t\t\t\tchecked={ showPostTitle }\n\t\t\t\t\t\tonChange={ ( value ) =>\n\t\t\t\t\t\t\tsetAttributes( { showPostTitle: value } )\n\t\t\t\t\t\t}\n\t\t\t\t\t/>\n\t\t\t\t</ToolsPanelItem>\n\t\t\t\t<ToolsPanelItem\n\t\t\t\t\tlabel={ __( 'Show comments count' ) }\n\t\t\t\t\tisShownByDefault\n\t\t\t\t\thasValue={ () => ! showCommentsCount }\n\t\t\t\t\tonDeselect={ () =>\n\t\t\t\t\t\tsetAttributes( { showCommentsCount: true } )\n\t\t\t\t\t}\n\t\t\t\t>\n\t\t\t\t\t<ToggleControl\n\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\tlabel={ __( 'Show comments count' ) }\n\t\t\t\t\t\tchecked={ showCommentsCount }\n\t\t\t\t\t\tonChange={ ( value ) =>\n\t\t\t\t\t\t\tsetAttributes( { showCommentsCount: value } )\n\t\t\t\t\t\t}\n\t\t\t\t\t/>\n\t\t\t\t</ToolsPanelItem>\n\t\t\t</ToolsPanel>\n\t\t</InspectorControls>\n\t);\n\n\tconst postTitle = isSiteEditor ? __( '“Post Title”' ) : `\"${ rawTitle }\"`;\n\n\tlet placeholder;\n\tif ( showCommentsCount && commentsCount !== undefined ) {\n\t\tif ( showPostTitle ) {\n\t\t\tif ( commentsCount === 1 ) {\n\t\t\t\t/* translators: %s: Post title. */\n\t\t\t\tplaceholder = sprintf( __( 'One response to %s' ), postTitle );\n\t\t\t} else {\n\t\t\t\tplaceholder = sprintf(\n\t\t\t\t\t/* translators: 1: Number of comments, 2: Post title. */\n\t\t\t\t\t_n(\n\t\t\t\t\t\t'%1$s response to %2$s',\n\t\t\t\t\t\t'%1$s responses to %2$s',\n\t\t\t\t\t\tcommentsCount\n\t\t\t\t\t),\n\t\t\t\t\tcommentsCount,\n\t\t\t\t\tpostTitle\n\t\t\t\t);\n\t\t\t}\n\t\t} else if ( commentsCount === 1 ) {\n\t\t\tplaceholder = __( 'One response' );\n\t\t} else {\n\t\t\tplaceholder = sprintf(\n\t\t\t\t/* translators: %s: Number of comments. */\n\t\t\t\t_n( '%s response', '%s responses', commentsCount ),\n\t\t\t\tcommentsCount\n\t\t\t);\n\t\t}\n\t} else if ( showPostTitle ) {\n\t\tif ( commentsCount === 1 ) {\n\t\t\t/* translators: %s: Post title. */\n\t\t\tplaceholder = sprintf( __( 'Response to %s' ), postTitle );\n\t\t} else {\n\t\t\t/* translators: %s: Post title. */\n\t\t\tplaceholder = sprintf( __( 'Responses to %s' ), postTitle );\n\t\t}\n\t} else if ( commentsCount === 1 ) {\n\t\tplaceholder = __( 'Response' );\n\t} else {\n\t\tplaceholder = __(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MAC/D,CAAC,MAAM;QACNC,WAAW,GAAG,IAAAE,aAAO,EACpB;QACA,IAAAC,QAAE,EACD,uBAAuB,EACvB,wBAAwB,EACxBvE,aACD,CAAC,EACDA,aAAa,EACbmE,SACD,CAAC;MACF;IACD,CAAC,MAAM,IAAKnE,aAAa,KAAK,CAAC,EAAG;MACjCoE,WAAW,GAAG,IAAAV,QAAE,EAAE,cAAe,CAAC;IACnC,CAAC,MAAM;MACNU,WAAW,GAAG,IAAAE,aAAO,EACpB;MACA,IAAAC,QAAE,EAAE,aAAa,EAAE,cAAc,EAAEvE,aAAc,CAAC,EAClDA,aACD,CAAC;IACF;EACD,CAAC,MAAM,IAAKT,aAAa,EAAG;IAC3B,IAAKS,aAAa,KAAK,CAAC,EAAG;MAC1B;MACAoE,WAAW,GAAG,IAAAE,aAAO,EAAE,IAAAZ,QAAE,EAAE,gBAAiB,CAAC,EAAES,SAAU,CAAC;IAC3D,CAAC,MAAM;MACN;MACAC,WAAW,GAAG,IAAAE,aAAO,EAAE,IAAAZ,QAAE,EAAE,iBAAkB,CAAC,EAAES,SAAU,CAAC;IAC5D;EACD,CAAC,MAAM,IAAKnE,aAAa,KAAK,CAAC,EAAG;IACjCoE,WAAW,GAAG,IAAAV,QAAE,EAAE,UAAW,CAAC;EAC/B,CAAC,MAAM;IACNU,WAAW,GAAG,IAAAV,QAAE,EAAE,WAAY,CAAC;EAChC;EAEA,oBACC,IAAAvE,WAAA,CAAAuD,IAAA,EAAAvD,WAAA,CAAAqF,QAAA;IAAA3B,QAAA,GACGJ,aAAa,EACba,iBAAiB,eACnB,IAAAnE,WAAA,CAAA2D,GAAA,EAAC/C,OAAO;MAAA,GAAMO,UAAU;MAAAuC,QAAA,EAAKuB;IAAW,CAAW,CAAC;EAAA,CACnD,CAAC;AAEL","ignoreList":[]}
|
package/build/details/edit.js
CHANGED
|
@@ -8,7 +8,9 @@ var _blockEditor = require("@wordpress/block-editor");
|
|
|
8
8
|
var _components = require("@wordpress/components");
|
|
9
9
|
var _i18n = require("@wordpress/i18n");
|
|
10
10
|
var _element = require("@wordpress/element");
|
|
11
|
+
var _data = require("@wordpress/data");
|
|
11
12
|
var _hooks = require("../utils/hooks");
|
|
13
|
+
var _lockUnlock = require("../lock-unlock");
|
|
12
14
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
13
15
|
/**
|
|
14
16
|
* WordPress dependencies
|
|
@@ -18,12 +20,16 @@ var _jsxRuntime = require("react/jsx-runtime");
|
|
|
18
20
|
* Internal dependencies
|
|
19
21
|
*/
|
|
20
22
|
|
|
23
|
+
const {
|
|
24
|
+
withIgnoreIMEEvents
|
|
25
|
+
} = (0, _lockUnlock.unlock)(_components.privateApis);
|
|
21
26
|
const TEMPLATE = [['core/paragraph', {
|
|
22
27
|
placeholder: (0, _i18n.__)('Type / to add a hidden block')
|
|
23
28
|
}]];
|
|
24
29
|
function DetailsEdit({
|
|
25
30
|
attributes,
|
|
26
|
-
setAttributes
|
|
31
|
+
setAttributes,
|
|
32
|
+
clientId
|
|
27
33
|
}) {
|
|
28
34
|
const {
|
|
29
35
|
name,
|
|
@@ -40,6 +46,22 @@ function DetailsEdit({
|
|
|
40
46
|
});
|
|
41
47
|
const [isOpen, setIsOpen] = (0, _element.useState)(showContent);
|
|
42
48
|
const dropdownMenuProps = (0, _hooks.useToolsPanelDropdownMenuProps)();
|
|
49
|
+
|
|
50
|
+
// Check if the inner blocks are selected.
|
|
51
|
+
const hasSelectedInnerBlock = (0, _data.useSelect)(select => select(_blockEditor.store).hasSelectedInnerBlock(clientId, true), [clientId]);
|
|
52
|
+
const handleSummaryKeyDown = event => {
|
|
53
|
+
if (event.key === 'Enter' && !event.shiftKey) {
|
|
54
|
+
setIsOpen(prevIsOpen => !prevIsOpen);
|
|
55
|
+
event.preventDefault();
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
// Prevent spacebar from toggling <details> while typing.
|
|
60
|
+
const handleSummaryKeyUp = event => {
|
|
61
|
+
if (event.key === ' ') {
|
|
62
|
+
event.preventDefault();
|
|
63
|
+
}
|
|
64
|
+
};
|
|
43
65
|
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
|
44
66
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_blockEditor.InspectorControls, {
|
|
45
67
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.__experimentalToolsPanel, {
|
|
@@ -83,12 +105,14 @@ function DetailsEdit({
|
|
|
83
105
|
})
|
|
84
106
|
}), /*#__PURE__*/(0, _jsxRuntime.jsxs)("details", {
|
|
85
107
|
...innerBlocksProps,
|
|
86
|
-
open: isOpen,
|
|
108
|
+
open: isOpen || hasSelectedInnerBlock,
|
|
87
109
|
onToggle: event => setIsOpen(event.target.open),
|
|
88
110
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("summary", {
|
|
111
|
+
onKeyDown: withIgnoreIMEEvents(handleSummaryKeyDown),
|
|
112
|
+
onKeyUp: handleSummaryKeyUp,
|
|
89
113
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_blockEditor.RichText, {
|
|
90
114
|
identifier: "summary",
|
|
91
|
-
"aria-label": (0, _i18n.__)('Write summary'),
|
|
115
|
+
"aria-label": (0, _i18n.__)('Write summary. Press Enter to expand or collapse the details.'),
|
|
92
116
|
placeholder: placeholder || (0, _i18n.__)('Write summary…'),
|
|
93
117
|
withoutInteractiveFormatting: true,
|
|
94
118
|
value: summary,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_blockEditor","require","_components","_i18n","_element","_hooks","_jsxRuntime","TEMPLATE","placeholder","__","DetailsEdit","attributes","setAttributes","name","showContent","summary","allowedBlocks","blockProps","useBlockProps","innerBlocksProps","useInnerBlocksProps","template","__experimentalCaptureToolbars","isOpen","setIsOpen","useState","dropdownMenuProps","useToolsPanelDropdownMenuProps","jsxs","Fragment","children","jsx","InspectorControls","__experimentalToolsPanel","label","resetAll","__experimentalToolsPanelItem","isShownByDefault","hasValue","onDeselect","ToggleControl","__nextHasNoMarginBottom","checked","onChange","group","TextControl","__next40pxDefaultSize","value","newName","help","open","onToggle","
|
|
1
|
+
{"version":3,"names":["_blockEditor","require","_components","_i18n","_element","_data","_hooks","_lockUnlock","_jsxRuntime","withIgnoreIMEEvents","unlock","componentsPrivateApis","TEMPLATE","placeholder","__","DetailsEdit","attributes","setAttributes","clientId","name","showContent","summary","allowedBlocks","blockProps","useBlockProps","innerBlocksProps","useInnerBlocksProps","template","__experimentalCaptureToolbars","isOpen","setIsOpen","useState","dropdownMenuProps","useToolsPanelDropdownMenuProps","hasSelectedInnerBlock","useSelect","select","blockEditorStore","handleSummaryKeyDown","event","key","shiftKey","prevIsOpen","preventDefault","handleSummaryKeyUp","jsxs","Fragment","children","jsx","InspectorControls","__experimentalToolsPanel","label","resetAll","__experimentalToolsPanelItem","isShownByDefault","hasValue","onDeselect","ToggleControl","__nextHasNoMarginBottom","checked","onChange","group","TextControl","__next40pxDefaultSize","value","newName","help","open","onToggle","target","onKeyDown","onKeyUp","RichText","identifier","withoutInteractiveFormatting","newSummary","_default","exports","default"],"sources":["@wordpress/block-library/src/details/edit.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tRichText,\n\tuseBlockProps,\n\tuseInnerBlocksProps,\n\tInspectorControls,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport {\n\tTextControl,\n\tToggleControl,\n\t__experimentalToolsPanel as ToolsPanel,\n\t__experimentalToolsPanelItem as ToolsPanelItem,\n\tprivateApis as componentsPrivateApis,\n} from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { useState } from '@wordpress/element';\nimport { useSelect } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { useToolsPanelDropdownMenuProps } from '../utils/hooks';\nimport { unlock } from '../lock-unlock';\n\nconst { withIgnoreIMEEvents } = unlock( componentsPrivateApis );\n\nconst TEMPLATE = [\n\t[\n\t\t'core/paragraph',\n\t\t{\n\t\t\tplaceholder: __( 'Type / to add a hidden block' ),\n\t\t},\n\t],\n];\n\nfunction DetailsEdit( { attributes, setAttributes, clientId } ) {\n\tconst { name, showContent, summary, allowedBlocks, placeholder } =\n\t\tattributes;\n\tconst blockProps = useBlockProps();\n\tconst innerBlocksProps = useInnerBlocksProps( blockProps, {\n\t\ttemplate: TEMPLATE,\n\t\t__experimentalCaptureToolbars: true,\n\t\tallowedBlocks,\n\t} );\n\tconst [ isOpen, setIsOpen ] = useState( showContent );\n\tconst dropdownMenuProps = useToolsPanelDropdownMenuProps();\n\n\t// Check if the inner blocks are selected.\n\tconst hasSelectedInnerBlock = useSelect(\n\t\t( select ) =>\n\t\t\tselect( blockEditorStore ).hasSelectedInnerBlock( clientId, true ),\n\t\t[ clientId ]\n\t);\n\n\tconst handleSummaryKeyDown = ( event ) => {\n\t\tif ( event.key === 'Enter' && ! event.shiftKey ) {\n\t\t\tsetIsOpen( ( prevIsOpen ) => ! prevIsOpen );\n\t\t\tevent.preventDefault();\n\t\t}\n\t};\n\n\t// Prevent spacebar from toggling <details> while typing.\n\tconst handleSummaryKeyUp = ( event ) => {\n\t\tif ( event.key === ' ' ) {\n\t\t\tevent.preventDefault();\n\t\t}\n\t};\n\n\treturn (\n\t\t<>\n\t\t\t<InspectorControls>\n\t\t\t\t<ToolsPanel\n\t\t\t\t\tlabel={ __( 'Settings' ) }\n\t\t\t\t\tresetAll={ () => {\n\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\tshowContent: false,\n\t\t\t\t\t\t} );\n\t\t\t\t\t} }\n\t\t\t\t\tdropdownMenuProps={ dropdownMenuProps }\n\t\t\t\t>\n\t\t\t\t\t<ToolsPanelItem\n\t\t\t\t\t\tisShownByDefault\n\t\t\t\t\t\tlabel={ __( 'Open by default' ) }\n\t\t\t\t\t\thasValue={ () => showContent }\n\t\t\t\t\t\tonDeselect={ () => {\n\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\tshowContent: false,\n\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t} }\n\t\t\t\t\t>\n\t\t\t\t\t\t<ToggleControl\n\t\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\t\tlabel={ __( 'Open by default' ) }\n\t\t\t\t\t\t\tchecked={ showContent }\n\t\t\t\t\t\t\tonChange={ () =>\n\t\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\t\tshowContent: ! showContent,\n\t\t\t\t\t\t\t\t} )\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t/>\n\t\t\t\t\t</ToolsPanelItem>\n\t\t\t\t</ToolsPanel>\n\t\t\t</InspectorControls>\n\t\t\t<InspectorControls group=\"advanced\">\n\t\t\t\t<TextControl\n\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\tlabel={ __( 'Name attribute' ) }\n\t\t\t\t\tvalue={ name || '' }\n\t\t\t\t\tonChange={ ( newName ) =>\n\t\t\t\t\t\tsetAttributes( { name: newName } )\n\t\t\t\t\t}\n\t\t\t\t\thelp={ __(\n\t\t\t\t\t\t'Enables multiple Details blocks with the same name attribute to be connected, with only one open at a time.'\n\t\t\t\t\t) }\n\t\t\t\t/>\n\t\t\t</InspectorControls>\n\t\t\t<details\n\t\t\t\t{ ...innerBlocksProps }\n\t\t\t\topen={ isOpen || hasSelectedInnerBlock }\n\t\t\t\tonToggle={ ( event ) => setIsOpen( event.target.open ) }\n\t\t\t>\n\t\t\t\t<summary\n\t\t\t\t\tonKeyDown={ withIgnoreIMEEvents( handleSummaryKeyDown ) }\n\t\t\t\t\tonKeyUp={ handleSummaryKeyUp }\n\t\t\t\t>\n\t\t\t\t\t<RichText\n\t\t\t\t\t\tidentifier=\"summary\"\n\t\t\t\t\t\taria-label={ __(\n\t\t\t\t\t\t\t'Write summary. Press Enter to expand or collapse the details.'\n\t\t\t\t\t\t) }\n\t\t\t\t\t\tplaceholder={ placeholder || __( 'Write summary…' ) }\n\t\t\t\t\t\twithoutInteractiveFormatting\n\t\t\t\t\t\tvalue={ summary }\n\t\t\t\t\t\tonChange={ ( newSummary ) =>\n\t\t\t\t\t\t\tsetAttributes( { summary: newSummary } )\n\t\t\t\t\t\t}\n\t\t\t\t\t/>\n\t\t\t\t</summary>\n\t\t\t\t{ innerBlocksProps.children }\n\t\t\t</details>\n\t\t</>\n\t);\n}\n\nexport default DetailsEdit;\n"],"mappings":";;;;;;AAGA,IAAAA,YAAA,GAAAC,OAAA;AAOA,IAAAC,WAAA,GAAAD,OAAA;AAOA,IAAAE,KAAA,GAAAF,OAAA;AACA,IAAAG,QAAA,GAAAH,OAAA;AACA,IAAAI,KAAA,GAAAJ,OAAA;AAKA,IAAAK,MAAA,GAAAL,OAAA;AACA,IAAAM,WAAA,GAAAN,OAAA;AAAwC,IAAAO,WAAA,GAAAP,OAAA;AAzBxC;AACA;AACA;;AAmBA;AACA;AACA;;AAIA,MAAM;EAAEQ;AAAoB,CAAC,GAAG,IAAAC,kBAAM,EAAEC,uBAAsB,CAAC;AAE/D,MAAMC,QAAQ,GAAG,CAChB,CACC,gBAAgB,EAChB;EACCC,WAAW,EAAE,IAAAC,QAAE,EAAE,8BAA+B;AACjD,CAAC,CACD,CACD;AAED,SAASC,WAAWA,CAAE;EAAEC,UAAU;EAAEC,aAAa;EAAEC;AAAS,CAAC,EAAG;EAC/D,MAAM;IAAEC,IAAI;IAAEC,WAAW;IAAEC,OAAO;IAAEC,aAAa;IAAET;EAAY,CAAC,GAC/DG,UAAU;EACX,MAAMO,UAAU,GAAG,IAAAC,0BAAa,EAAC,CAAC;EAClC,MAAMC,gBAAgB,GAAG,IAAAC,gCAAmB,EAAEH,UAAU,EAAE;IACzDI,QAAQ,EAAEf,QAAQ;IAClBgB,6BAA6B,EAAE,IAAI;IACnCN;EACD,CAAE,CAAC;EACH,MAAM,CAAEO,MAAM,EAAEC,SAAS,CAAE,GAAG,IAAAC,iBAAQ,EAAEX,WAAY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QAAQ;UACRC,UAAU,EAAC,SAAS;UACpB,cAAa,IAAA3D,QAAE,EACd,+DACD,CAAG;UACHD,WAAW,EAAGA,WAAW,IAAI,IAAAC,QAAE,EAAE,gBAAiB,CAAG;UACrD4D,4BAA4B;UAC5BV,KAAK,EAAG3C,OAAS;UACjBuC,QAAQ,EAAKe,UAAU,IACtB1D,aAAa,CAAE;YAAEI,OAAO,EAAEsD;UAAW,CAAE;QACvC,CACD;MAAC,CACM,CAAC,EACRlD,gBAAgB,CAACsB,QAAQ;IAAA,CACnB,CAAC;EAAA,CACT,CAAC;AAEL;AAAC,IAAA6B,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEc/D,WAAW","ignoreList":[]}
|
package/build/embed/edit.js
CHANGED
|
@@ -107,20 +107,18 @@ const EmbedEdit = props => {
|
|
|
107
107
|
* @return {Object} Merged attributes.
|
|
108
108
|
*/
|
|
109
109
|
const getMergedAttributes = () => (0, _util.getMergedAttributesWithPreview)(attributes, preview, title, responsive);
|
|
110
|
-
|
|
110
|
+
function toggleResponsive(newAllowResponsive) {
|
|
111
111
|
const {
|
|
112
|
-
allowResponsive,
|
|
113
112
|
className
|
|
114
113
|
} = attributes;
|
|
115
114
|
const {
|
|
116
115
|
html
|
|
117
116
|
} = preview;
|
|
118
|
-
const newAllowResponsive = !allowResponsive;
|
|
119
117
|
setAttributes({
|
|
120
118
|
allowResponsive: newAllowResponsive,
|
|
121
119
|
className: (0, _util.getClassNames)(html, className, responsive && newAllowResponsive)
|
|
122
120
|
});
|
|
123
|
-
}
|
|
121
|
+
}
|
|
124
122
|
(0, _element.useEffect)(() => {
|
|
125
123
|
if (preview?.html || !cannotEmbed || !hasResolved) {
|
|
126
124
|
return;
|
package/build/embed/edit.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_util","require","_embedControls","_interopRequireDefault","_icons","_embedLoading","_embedPlaceholder","_embedPreview","_clsx","_i18n","_element","_data","_blockEditor","_coreData","_primitives","_url","_caption","_jsxRuntime","EmbedEdit","props","attributes","providerNameSlug","previewable","responsive","url","attributesUrl","isSelected","onReplace","setAttributes","insertBlocksAfter","onFocus","defaultEmbedInfo","title","_x","icon","embedContentIcon","getEmbedInfoByProvider","setURL","useState","isEditingURL","setIsEditingURL","invalidateResolution","useDispatch","coreStore","preview","fetching","themeSupportsResponsive","cannotEmbed","hasResolved","useSelect","select","getEmbedPreview","isPreviewEmbedFallback","isRequestingEmbedPreview","getThemeSupports","hasFinishedResolution","embedPreview","previewIsFallback","badEmbedProvider","html","type","undefined","wordpressCantEmbed","data","status","validPreview","getMergedAttributes","getMergedAttributesWithPreview","toggleResponsive","allowResponsive","className","newAllowResponsive","getClassNames","useEffect","newURL","replace","getAuthority","URL","host","toString","mergedAttributes","hasChanges","Object","keys","some","key","upgradedBlock","createUpgradedEmbedBlock","blockProps","useBlockProps","jsx","View","children","default","label","sprintf","__","showEmbedPlaceholder","onSubmit","event","preventDefault","blockClass","removeAspectRatioClasses","value","onChange","fallback","tryAgain","caption","classFromPreview","clsx","jsxs","Fragment","showEditButton","blockSupportsResponsive","switchBackToURLInput","onCaptionChange","Caption","showToolbarButton","_default","exports"],"sources":["@wordpress/block-library/src/embed/edit.js"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport {\n\tcreateUpgradedEmbedBlock,\n\tgetClassNames,\n\tremoveAspectRatioClasses,\n\tfallback,\n\tgetEmbedInfoByProvider,\n\tgetMergedAttributesWithPreview,\n} from './util';\nimport EmbedControls from './embed-controls';\nimport { embedContentIcon } from './icons';\nimport EmbedLoading from './embed-loading';\nimport EmbedPlaceholder from './embed-placeholder';\nimport EmbedPreview from './embed-preview';\n\n/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { __, _x, sprintf } from '@wordpress/i18n';\nimport { useState, useEffect } from '@wordpress/element';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { useBlockProps } from '@wordpress/block-editor';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { View } from '@wordpress/primitives';\nimport { getAuthority } from '@wordpress/url';\nimport { Caption } from '../utils/caption';\n\nconst EmbedEdit = ( props ) => {\n\tconst {\n\t\tattributes: {\n\t\t\tproviderNameSlug,\n\t\t\tpreviewable,\n\t\t\tresponsive,\n\t\t\turl: attributesUrl,\n\t\t},\n\t\tattributes,\n\t\tisSelected,\n\t\tonReplace,\n\t\tsetAttributes,\n\t\tinsertBlocksAfter,\n\t\tonFocus,\n\t} = props;\n\n\tconst defaultEmbedInfo = {\n\t\ttitle: _x( 'Embed', 'block title' ),\n\t\ticon: embedContentIcon,\n\t};\n\tconst { icon, title } =\n\t\tgetEmbedInfoByProvider( providerNameSlug ) || defaultEmbedInfo;\n\n\tconst [ url, setURL ] = useState( attributesUrl );\n\tconst [ isEditingURL, setIsEditingURL ] = useState( false );\n\tconst { invalidateResolution } = useDispatch( coreStore );\n\n\tconst {\n\t\tpreview,\n\t\tfetching,\n\t\tthemeSupportsResponsive,\n\t\tcannotEmbed,\n\t\thasResolved,\n\t} = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tgetEmbedPreview,\n\t\t\t\tisPreviewEmbedFallback,\n\t\t\t\tisRequestingEmbedPreview,\n\t\t\t\tgetThemeSupports,\n\t\t\t\thasFinishedResolution,\n\t\t\t} = select( coreStore );\n\t\t\tif ( ! attributesUrl ) {\n\t\t\t\treturn { fetching: false, cannotEmbed: false };\n\t\t\t}\n\n\t\t\tconst embedPreview = getEmbedPreview( attributesUrl );\n\t\t\tconst previewIsFallback = isPreviewEmbedFallback( attributesUrl );\n\n\t\t\t// The external oEmbed provider does not exist. We got no type info and no html.\n\t\t\tconst badEmbedProvider =\n\t\t\t\tembedPreview?.html === false &&\n\t\t\t\tembedPreview?.type === undefined;\n\t\t\t// Some WordPress URLs that can't be embedded will cause the API to return\n\t\t\t// a valid JSON response with no HTML and `data.status` set to 404, rather\n\t\t\t// than generating a fallback response as other embeds do.\n\t\t\tconst wordpressCantEmbed = embedPreview?.data?.status === 404;\n\t\t\tconst validPreview =\n\t\t\t\t!! embedPreview && ! badEmbedProvider && ! wordpressCantEmbed;\n\t\t\treturn {\n\t\t\t\tpreview: validPreview ? embedPreview : undefined,\n\t\t\t\tfetching: isRequestingEmbedPreview( attributesUrl ),\n\t\t\t\tthemeSupportsResponsive:\n\t\t\t\t\tgetThemeSupports()[ 'responsive-embeds' ],\n\t\t\t\tcannotEmbed: ! validPreview || previewIsFallback,\n\t\t\t\thasResolved: hasFinishedResolution( 'getEmbedPreview', [\n\t\t\t\t\tattributesUrl,\n\t\t\t\t] ),\n\t\t\t};\n\t\t},\n\t\t[ attributesUrl ]\n\t);\n\n\t/**\n\t * Returns the attributes derived from the preview, merged with the current attributes.\n\t *\n\t * @return {Object} Merged attributes.\n\t */\n\tconst getMergedAttributes = () =>\n\t\tgetMergedAttributesWithPreview(\n\t\t\tattributes,\n\t\t\tpreview,\n\t\t\ttitle,\n\t\t\tresponsive\n\t\t);\n\n\tconst toggleResponsive = () => {\n\t\tconst { allowResponsive, className } = attributes;\n\t\tconst { html } = preview;\n\t\tconst newAllowResponsive = ! allowResponsive;\n\n\t\tsetAttributes( {\n\t\t\tallowResponsive: newAllowResponsive,\n\t\t\tclassName: getClassNames(\n\t\t\t\thtml,\n\t\t\t\tclassName,\n\t\t\t\tresponsive && newAllowResponsive\n\t\t\t),\n\t\t} );\n\t};\n\n\tuseEffect( () => {\n\t\tif ( preview?.html || ! cannotEmbed || ! hasResolved ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// At this stage, we're not fetching the preview and know it can't be embedded,\n\t\t// so try removing any trailing slash, and resubmit.\n\t\tconst newURL = attributesUrl.replace( /\\/$/, '' );\n\t\tsetURL( newURL );\n\t\tsetIsEditingURL( false );\n\t\tsetAttributes( { url: newURL } );\n\t}, [\n\t\tpreview?.html,\n\t\tattributesUrl,\n\t\tcannotEmbed,\n\t\thasResolved,\n\t\tsetAttributes,\n\t] );\n\n\t// Try a different provider in case the embed url is not supported.\n\tuseEffect( () => {\n\t\tif ( ! cannotEmbed || fetching || ! url ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Until X provider is supported in WordPress, as a workaround we use Twitter provider.\n\t\tif ( getAuthority( url ) === 'x.com' ) {\n\t\t\tconst newURL = new URL( url );\n\t\t\tnewURL.host = 'twitter.com';\n\t\t\tsetAttributes( { url: newURL.toString() } );\n\t\t}\n\t}, [ url, cannotEmbed, fetching, setAttributes ] );\n\n\t// Handle incoming preview.\n\tuseEffect( () => {\n\t\tif ( preview && ! isEditingURL ) {\n\t\t\t// When obtaining an incoming preview,\n\t\t\t// we set the attributes derived from the preview data.\n\t\t\tconst mergedAttributes = getMergedAttributes();\n\t\t\tconst hasChanges = Object.keys( mergedAttributes ).some(\n\t\t\t\t( key ) => mergedAttributes[ key ] !== attributes[ key ]\n\t\t\t);\n\n\t\t\tif ( hasChanges ) {\n\t\t\t\tsetAttributes( mergedAttributes );\n\t\t\t}\n\n\t\t\tif ( onReplace ) {\n\t\t\t\tconst upgradedBlock = createUpgradedEmbedBlock(\n\t\t\t\t\tprops,\n\t\t\t\t\tmergedAttributes\n\t\t\t\t);\n\n\t\t\t\tif ( upgradedBlock ) {\n\t\t\t\t\tonReplace( upgradedBlock );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}, [ preview, isEditingURL ] );\n\n\tconst blockProps = useBlockProps();\n\n\tif ( fetching ) {\n\t\treturn (\n\t\t\t<View { ...blockProps }>\n\t\t\t\t<EmbedLoading />\n\t\t\t</View>\n\t\t);\n\t}\n\n\t// translators: %s: type of embed e.g: \"YouTube\", \"Twitter\", etc. \"Embed\" is used when no specific type exists\n\tconst label = sprintf( __( '%s URL' ), title );\n\n\t// No preview, or we can't embed the current URL, or we've clicked the edit button.\n\tconst showEmbedPlaceholder = ! preview || cannotEmbed || isEditingURL;\n\n\tif ( showEmbedPlaceholder ) {\n\t\treturn (\n\t\t\t<View { ...blockProps }>\n\t\t\t\t<EmbedPlaceholder\n\t\t\t\t\ticon={ icon }\n\t\t\t\t\tlabel={ label }\n\t\t\t\t\tonFocus={ onFocus }\n\t\t\t\t\tonSubmit={ ( event ) => {\n\t\t\t\t\t\tif ( event ) {\n\t\t\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t// If the embed URL was changed, we need to reset the aspect ratio class.\n\t\t\t\t\t\t// To do this we have to remove the existing ratio class so it can be recalculated.\n\t\t\t\t\t\tconst blockClass = removeAspectRatioClasses(\n\t\t\t\t\t\t\tattributes.className\n\t\t\t\t\t\t);\n\n\t\t\t\t\t\tsetIsEditingURL( false );\n\t\t\t\t\t\tsetAttributes( { url, className: blockClass } );\n\t\t\t\t\t} }\n\t\t\t\t\tvalue={ url }\n\t\t\t\t\tcannotEmbed={ cannotEmbed }\n\t\t\t\t\tonChange={ ( value ) => setURL( value ) }\n\t\t\t\t\tfallback={ () => fallback( url, onReplace ) }\n\t\t\t\t\ttryAgain={ () => {\n\t\t\t\t\t\tinvalidateResolution( 'getEmbedPreview', [ url ] );\n\t\t\t\t\t} }\n\t\t\t\t/>\n\t\t\t</View>\n\t\t);\n\t}\n\n\t// Even though we set attributes that get derived from the preview,\n\t// we don't access them directly because for the initial render,\n\t// the `setAttributes` call will not have taken effect. If we're\n\t// rendering responsive content, setting the responsive classes\n\t// after the preview has been rendered can result in unwanted\n\t// clipping or scrollbars. The `getAttributesFromPreview` function\n\t// that `getMergedAttributes` uses is memoized so that we're not\n\t// calculating them on every render.\n\tconst {\n\t\tcaption,\n\t\ttype,\n\t\tallowResponsive,\n\t\tclassName: classFromPreview,\n\t} = getMergedAttributes();\n\tconst className = clsx( classFromPreview, props.className );\n\n\treturn (\n\t\t<>\n\t\t\t<EmbedControls\n\t\t\t\tshowEditButton={ preview && ! cannotEmbed }\n\t\t\t\tthemeSupportsResponsive={ themeSupportsResponsive }\n\t\t\t\tblockSupportsResponsive={ responsive }\n\t\t\t\tallowResponsive={ allowResponsive }\n\t\t\t\ttoggleResponsive={ toggleResponsive }\n\t\t\t\tswitchBackToURLInput={ () => setIsEditingURL( true ) }\n\t\t\t/>\n\t\t\t<figure\n\t\t\t\t{ ...blockProps }\n\t\t\t\tclassName={ clsx( blockProps.className, className, {\n\t\t\t\t\t[ `is-type-${ type }` ]: type,\n\t\t\t\t\t[ `is-provider-${ providerNameSlug }` ]: providerNameSlug,\n\t\t\t\t\t[ `wp-block-embed-${ providerNameSlug }` ]:\n\t\t\t\t\t\tproviderNameSlug,\n\t\t\t\t} ) }\n\t\t\t>\n\t\t\t\t<EmbedPreview\n\t\t\t\t\tpreview={ preview }\n\t\t\t\t\tpreviewable={ previewable }\n\t\t\t\t\tclassName={ className }\n\t\t\t\t\turl={ url }\n\t\t\t\t\ttype={ type }\n\t\t\t\t\tcaption={ caption }\n\t\t\t\t\tonCaptionChange={ ( value ) =>\n\t\t\t\t\t\tsetAttributes( { caption: value } )\n\t\t\t\t\t}\n\t\t\t\t\tisSelected={ isSelected }\n\t\t\t\t\ticon={ icon }\n\t\t\t\t\tlabel={ label }\n\t\t\t\t\tinsertBlocksAfter={ insertBlocksAfter }\n\t\t\t\t\tattributes={ attributes }\n\t\t\t\t\tsetAttributes={ setAttributes }\n\t\t\t\t/>\n\t\t\t\t<Caption\n\t\t\t\t\tattributes={ attributes }\n\t\t\t\t\tsetAttributes={ setAttributes }\n\t\t\t\t\tisSelected={ isSelected }\n\t\t\t\t\tinsertBlocksAfter={ insertBlocksAfter }\n\t\t\t\t\tlabel={ __( 'Embed caption text' ) }\n\t\t\t\t\tshowToolbarButton={ isSelected }\n\t\t\t\t/>\n\t\t\t</figure>\n\t\t</>\n\t);\n};\n\nexport default EmbedEdit;\n"],"mappings":";;;;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AAQA,IAAAC,cAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,MAAA,GAAAH,OAAA;AACA,IAAAI,aAAA,GAAAF,sBAAA,CAAAF,OAAA;AACA,IAAAK,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CACK,CAAC;EAAA,CACR,CAAC;AAEL,CAAC;AAAC,IAAA4F,QAAA,GAAAC,OAAA,CAAA1B,OAAA,GAEa3E,SAAS","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["_util","require","_embedControls","_interopRequireDefault","_icons","_embedLoading","_embedPlaceholder","_embedPreview","_clsx","_i18n","_element","_data","_blockEditor","_coreData","_primitives","_url","_caption","_jsxRuntime","EmbedEdit","props","attributes","providerNameSlug","previewable","responsive","url","attributesUrl","isSelected","onReplace","setAttributes","insertBlocksAfter","onFocus","defaultEmbedInfo","title","_x","icon","embedContentIcon","getEmbedInfoByProvider","setURL","useState","isEditingURL","setIsEditingURL","invalidateResolution","useDispatch","coreStore","preview","fetching","themeSupportsResponsive","cannotEmbed","hasResolved","useSelect","select","getEmbedPreview","isPreviewEmbedFallback","isRequestingEmbedPreview","getThemeSupports","hasFinishedResolution","embedPreview","previewIsFallback","badEmbedProvider","html","type","undefined","wordpressCantEmbed","data","status","validPreview","getMergedAttributes","getMergedAttributesWithPreview","toggleResponsive","newAllowResponsive","className","allowResponsive","getClassNames","useEffect","newURL","replace","getAuthority","URL","host","toString","mergedAttributes","hasChanges","Object","keys","some","key","upgradedBlock","createUpgradedEmbedBlock","blockProps","useBlockProps","jsx","View","children","default","label","sprintf","__","showEmbedPlaceholder","onSubmit","event","preventDefault","blockClass","removeAspectRatioClasses","value","onChange","fallback","tryAgain","caption","classFromPreview","clsx","jsxs","Fragment","showEditButton","blockSupportsResponsive","switchBackToURLInput","onCaptionChange","Caption","showToolbarButton","_default","exports"],"sources":["@wordpress/block-library/src/embed/edit.js"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport {\n\tcreateUpgradedEmbedBlock,\n\tgetClassNames,\n\tremoveAspectRatioClasses,\n\tfallback,\n\tgetEmbedInfoByProvider,\n\tgetMergedAttributesWithPreview,\n} from './util';\nimport EmbedControls from './embed-controls';\nimport { embedContentIcon } from './icons';\nimport EmbedLoading from './embed-loading';\nimport EmbedPlaceholder from './embed-placeholder';\nimport EmbedPreview from './embed-preview';\n\n/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { __, _x, sprintf } from '@wordpress/i18n';\nimport { useState, useEffect } from '@wordpress/element';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { useBlockProps } from '@wordpress/block-editor';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { View } from '@wordpress/primitives';\nimport { getAuthority } from '@wordpress/url';\nimport { Caption } from '../utils/caption';\n\nconst EmbedEdit = ( props ) => {\n\tconst {\n\t\tattributes: {\n\t\t\tproviderNameSlug,\n\t\t\tpreviewable,\n\t\t\tresponsive,\n\t\t\turl: attributesUrl,\n\t\t},\n\t\tattributes,\n\t\tisSelected,\n\t\tonReplace,\n\t\tsetAttributes,\n\t\tinsertBlocksAfter,\n\t\tonFocus,\n\t} = props;\n\n\tconst defaultEmbedInfo = {\n\t\ttitle: _x( 'Embed', 'block title' ),\n\t\ticon: embedContentIcon,\n\t};\n\tconst { icon, title } =\n\t\tgetEmbedInfoByProvider( providerNameSlug ) || defaultEmbedInfo;\n\n\tconst [ url, setURL ] = useState( attributesUrl );\n\tconst [ isEditingURL, setIsEditingURL ] = useState( false );\n\tconst { invalidateResolution } = useDispatch( coreStore );\n\n\tconst {\n\t\tpreview,\n\t\tfetching,\n\t\tthemeSupportsResponsive,\n\t\tcannotEmbed,\n\t\thasResolved,\n\t} = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tgetEmbedPreview,\n\t\t\t\tisPreviewEmbedFallback,\n\t\t\t\tisRequestingEmbedPreview,\n\t\t\t\tgetThemeSupports,\n\t\t\t\thasFinishedResolution,\n\t\t\t} = select( coreStore );\n\t\t\tif ( ! attributesUrl ) {\n\t\t\t\treturn { fetching: false, cannotEmbed: false };\n\t\t\t}\n\n\t\t\tconst embedPreview = getEmbedPreview( attributesUrl );\n\t\t\tconst previewIsFallback = isPreviewEmbedFallback( attributesUrl );\n\n\t\t\t// The external oEmbed provider does not exist. We got no type info and no html.\n\t\t\tconst badEmbedProvider =\n\t\t\t\tembedPreview?.html === false &&\n\t\t\t\tembedPreview?.type === undefined;\n\t\t\t// Some WordPress URLs that can't be embedded will cause the API to return\n\t\t\t// a valid JSON response with no HTML and `data.status` set to 404, rather\n\t\t\t// than generating a fallback response as other embeds do.\n\t\t\tconst wordpressCantEmbed = embedPreview?.data?.status === 404;\n\t\t\tconst validPreview =\n\t\t\t\t!! embedPreview && ! badEmbedProvider && ! wordpressCantEmbed;\n\t\t\treturn {\n\t\t\t\tpreview: validPreview ? embedPreview : undefined,\n\t\t\t\tfetching: isRequestingEmbedPreview( attributesUrl ),\n\t\t\t\tthemeSupportsResponsive:\n\t\t\t\t\tgetThemeSupports()[ 'responsive-embeds' ],\n\t\t\t\tcannotEmbed: ! validPreview || previewIsFallback,\n\t\t\t\thasResolved: hasFinishedResolution( 'getEmbedPreview', [\n\t\t\t\t\tattributesUrl,\n\t\t\t\t] ),\n\t\t\t};\n\t\t},\n\t\t[ attributesUrl ]\n\t);\n\n\t/**\n\t * Returns the attributes derived from the preview, merged with the current attributes.\n\t *\n\t * @return {Object} Merged attributes.\n\t */\n\tconst getMergedAttributes = () =>\n\t\tgetMergedAttributesWithPreview(\n\t\t\tattributes,\n\t\t\tpreview,\n\t\t\ttitle,\n\t\t\tresponsive\n\t\t);\n\n\tfunction toggleResponsive( newAllowResponsive ) {\n\t\tconst { className } = attributes;\n\t\tconst { html } = preview;\n\t\tsetAttributes( {\n\t\t\tallowResponsive: newAllowResponsive,\n\t\t\tclassName: getClassNames(\n\t\t\t\thtml,\n\t\t\t\tclassName,\n\t\t\t\tresponsive && newAllowResponsive\n\t\t\t),\n\t\t} );\n\t}\n\n\tuseEffect( () => {\n\t\tif ( preview?.html || ! cannotEmbed || ! hasResolved ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// At this stage, we're not fetching the preview and know it can't be embedded,\n\t\t// so try removing any trailing slash, and resubmit.\n\t\tconst newURL = attributesUrl.replace( /\\/$/, '' );\n\t\tsetURL( newURL );\n\t\tsetIsEditingURL( false );\n\t\tsetAttributes( { url: newURL } );\n\t}, [\n\t\tpreview?.html,\n\t\tattributesUrl,\n\t\tcannotEmbed,\n\t\thasResolved,\n\t\tsetAttributes,\n\t] );\n\n\t// Try a different provider in case the embed url is not supported.\n\tuseEffect( () => {\n\t\tif ( ! cannotEmbed || fetching || ! url ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Until X provider is supported in WordPress, as a workaround we use Twitter provider.\n\t\tif ( getAuthority( url ) === 'x.com' ) {\n\t\t\tconst newURL = new URL( url );\n\t\t\tnewURL.host = 'twitter.com';\n\t\t\tsetAttributes( { url: newURL.toString() } );\n\t\t}\n\t}, [ url, cannotEmbed, fetching, setAttributes ] );\n\n\t// Handle incoming preview.\n\tuseEffect( () => {\n\t\tif ( preview && ! isEditingURL ) {\n\t\t\t// When obtaining an incoming preview,\n\t\t\t// we set the attributes derived from the preview data.\n\t\t\tconst mergedAttributes = getMergedAttributes();\n\t\t\tconst hasChanges = Object.keys( mergedAttributes ).some(\n\t\t\t\t( key ) => mergedAttributes[ key ] !== attributes[ key ]\n\t\t\t);\n\n\t\t\tif ( hasChanges ) {\n\t\t\t\tsetAttributes( mergedAttributes );\n\t\t\t}\n\n\t\t\tif ( onReplace ) {\n\t\t\t\tconst upgradedBlock = createUpgradedEmbedBlock(\n\t\t\t\t\tprops,\n\t\t\t\t\tmergedAttributes\n\t\t\t\t);\n\n\t\t\t\tif ( upgradedBlock ) {\n\t\t\t\t\tonReplace( upgradedBlock );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}, [ preview, isEditingURL ] );\n\n\tconst blockProps = useBlockProps();\n\n\tif ( fetching ) {\n\t\treturn (\n\t\t\t<View { ...blockProps }>\n\t\t\t\t<EmbedLoading />\n\t\t\t</View>\n\t\t);\n\t}\n\n\t// translators: %s: type of embed e.g: \"YouTube\", \"Twitter\", etc. \"Embed\" is used when no specific type exists\n\tconst label = sprintf( __( '%s URL' ), title );\n\n\t// No preview, or we can't embed the current URL, or we've clicked the edit button.\n\tconst showEmbedPlaceholder = ! preview || cannotEmbed || isEditingURL;\n\n\tif ( showEmbedPlaceholder ) {\n\t\treturn (\n\t\t\t<View { ...blockProps }>\n\t\t\t\t<EmbedPlaceholder\n\t\t\t\t\ticon={ icon }\n\t\t\t\t\tlabel={ label }\n\t\t\t\t\tonFocus={ onFocus }\n\t\t\t\t\tonSubmit={ ( event ) => {\n\t\t\t\t\t\tif ( event ) {\n\t\t\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t// If the embed URL was changed, we need to reset the aspect ratio class.\n\t\t\t\t\t\t// To do this we have to remove the existing ratio class so it can be recalculated.\n\t\t\t\t\t\tconst blockClass = removeAspectRatioClasses(\n\t\t\t\t\t\t\tattributes.className\n\t\t\t\t\t\t);\n\n\t\t\t\t\t\tsetIsEditingURL( false );\n\t\t\t\t\t\tsetAttributes( { url, className: blockClass } );\n\t\t\t\t\t} }\n\t\t\t\t\tvalue={ url }\n\t\t\t\t\tcannotEmbed={ cannotEmbed }\n\t\t\t\t\tonChange={ ( value ) => setURL( value ) }\n\t\t\t\t\tfallback={ () => fallback( url, onReplace ) }\n\t\t\t\t\ttryAgain={ () => {\n\t\t\t\t\t\tinvalidateResolution( 'getEmbedPreview', [ url ] );\n\t\t\t\t\t} }\n\t\t\t\t/>\n\t\t\t</View>\n\t\t);\n\t}\n\n\t// Even though we set attributes that get derived from the preview,\n\t// we don't access them directly because for the initial render,\n\t// the `setAttributes` call will not have taken effect. If we're\n\t// rendering responsive content, setting the responsive classes\n\t// after the preview has been rendered can result in unwanted\n\t// clipping or scrollbars. The `getAttributesFromPreview` function\n\t// that `getMergedAttributes` uses is memoized so that we're not\n\t// calculating them on every render.\n\tconst {\n\t\tcaption,\n\t\ttype,\n\t\tallowResponsive,\n\t\tclassName: classFromPreview,\n\t} = getMergedAttributes();\n\tconst className = clsx( classFromPreview, props.className );\n\n\treturn (\n\t\t<>\n\t\t\t<EmbedControls\n\t\t\t\tshowEditButton={ preview && ! cannotEmbed }\n\t\t\t\tthemeSupportsResponsive={ themeSupportsResponsive }\n\t\t\t\tblockSupportsResponsive={ responsive }\n\t\t\t\tallowResponsive={ allowResponsive }\n\t\t\t\ttoggleResponsive={ toggleResponsive }\n\t\t\t\tswitchBackToURLInput={ () => setIsEditingURL( true ) }\n\t\t\t/>\n\t\t\t<figure\n\t\t\t\t{ ...blockProps }\n\t\t\t\tclassName={ clsx( blockProps.className, className, {\n\t\t\t\t\t[ `is-type-${ type }` ]: type,\n\t\t\t\t\t[ `is-provider-${ providerNameSlug }` ]: providerNameSlug,\n\t\t\t\t\t[ `wp-block-embed-${ providerNameSlug }` ]:\n\t\t\t\t\t\tproviderNameSlug,\n\t\t\t\t} ) }\n\t\t\t>\n\t\t\t\t<EmbedPreview\n\t\t\t\t\tpreview={ preview }\n\t\t\t\t\tpreviewable={ previewable }\n\t\t\t\t\tclassName={ className }\n\t\t\t\t\turl={ url }\n\t\t\t\t\ttype={ type }\n\t\t\t\t\tcaption={ caption }\n\t\t\t\t\tonCaptionChange={ ( value ) =>\n\t\t\t\t\t\tsetAttributes( { caption: value } )\n\t\t\t\t\t}\n\t\t\t\t\tisSelected={ isSelected }\n\t\t\t\t\ticon={ icon }\n\t\t\t\t\tlabel={ label }\n\t\t\t\t\tinsertBlocksAfter={ insertBlocksAfter }\n\t\t\t\t\tattributes={ attributes }\n\t\t\t\t\tsetAttributes={ setAttributes }\n\t\t\t\t/>\n\t\t\t\t<Caption\n\t\t\t\t\tattributes={ attributes }\n\t\t\t\t\tsetAttributes={ setAttributes }\n\t\t\t\t\tisSelected={ isSelected }\n\t\t\t\t\tinsertBlocksAfter={ insertBlocksAfter }\n\t\t\t\t\tlabel={ __( 'Embed caption text' ) }\n\t\t\t\t\tshowToolbarButton={ isSelected }\n\t\t\t\t/>\n\t\t\t</figure>\n\t\t</>\n\t);\n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U,EAAGA,UAAY;QACzBG,iBAAiB,EAAGA,iBAAmB;QACvCiE,KAAK,EAAG,IAAAE,QAAE,EAAE,oBAAqB,CAAG;QACpCqB,iBAAiB,EAAG3F;MAAY,CAChC,CAAC;IAAA,CACK,CAAC;EAAA,CACR,CAAC;AAEL,CAAC;AAAC,IAAA4F,QAAA,GAAAC,OAAA,CAAA1B,OAAA,GAEa3E,SAAS","ignoreList":[]}
|
|
@@ -8,11 +8,16 @@ var _i18n = require("@wordpress/i18n");
|
|
|
8
8
|
var _components = require("@wordpress/components");
|
|
9
9
|
var _blockEditor = require("@wordpress/block-editor");
|
|
10
10
|
var _icons = require("@wordpress/icons");
|
|
11
|
+
var _hooks = require("../utils/hooks");
|
|
11
12
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
12
13
|
/**
|
|
13
14
|
* WordPress dependencies
|
|
14
15
|
*/
|
|
15
16
|
|
|
17
|
+
/**
|
|
18
|
+
* Internal dependencies
|
|
19
|
+
*/
|
|
20
|
+
|
|
16
21
|
function getResponsiveHelp(checked) {
|
|
17
22
|
return checked ? (0, _i18n.__)('This embed will preserve its aspect ratio when the browser is resized.') : (0, _i18n.__)('This embed may not preserve its aspect ratio when the browser is resized.');
|
|
18
23
|
}
|
|
@@ -23,29 +28,43 @@ const EmbedControls = ({
|
|
|
23
28
|
allowResponsive,
|
|
24
29
|
toggleResponsive,
|
|
25
30
|
switchBackToURLInput
|
|
26
|
-
}) =>
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
31
|
+
}) => {
|
|
32
|
+
const dropdownMenuProps = (0, _hooks.useToolsPanelDropdownMenuProps)();
|
|
33
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
|
34
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_blockEditor.BlockControls, {
|
|
35
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.ToolbarGroup, {
|
|
36
|
+
children: showEditButton && /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.ToolbarButton, {
|
|
37
|
+
className: "components-toolbar__control",
|
|
38
|
+
label: (0, _i18n.__)('Edit URL'),
|
|
39
|
+
icon: _icons.edit,
|
|
40
|
+
onClick: switchBackToURLInput
|
|
41
|
+
})
|
|
34
42
|
})
|
|
35
|
-
})
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
43
|
+
}), themeSupportsResponsive && blockSupportsResponsive && /*#__PURE__*/(0, _jsxRuntime.jsx)(_blockEditor.InspectorControls, {
|
|
44
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.__experimentalToolsPanel, {
|
|
45
|
+
label: (0, _i18n.__)('Media settings'),
|
|
46
|
+
resetAll: () => {
|
|
47
|
+
toggleResponsive(true);
|
|
48
|
+
},
|
|
49
|
+
dropdownMenuProps: dropdownMenuProps,
|
|
50
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.__experimentalToolsPanelItem, {
|
|
51
|
+
label: (0, _i18n.__)('Media settings'),
|
|
52
|
+
isShownByDefault: true,
|
|
53
|
+
hasValue: () => !allowResponsive,
|
|
54
|
+
onDeselect: () => {
|
|
55
|
+
toggleResponsive(!allowResponsive);
|
|
56
|
+
},
|
|
57
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.ToggleControl, {
|
|
58
|
+
__nextHasNoMarginBottom: true,
|
|
59
|
+
label: (0, _i18n.__)('Resize for smaller devices'),
|
|
60
|
+
checked: allowResponsive,
|
|
61
|
+
help: getResponsiveHelp,
|
|
62
|
+
onChange: toggleResponsive
|
|
63
|
+
})
|
|
64
|
+
})
|
|
46
65
|
})
|
|
47
|
-
})
|
|
48
|
-
})
|
|
49
|
-
}
|
|
66
|
+
})]
|
|
67
|
+
});
|
|
68
|
+
};
|
|
50
69
|
var _default = exports.default = EmbedControls;
|
|
51
70
|
//# sourceMappingURL=embed-controls.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_i18n","require","_components","_blockEditor","_icons","_jsxRuntime","getResponsiveHelp","checked","__","EmbedControls","blockSupportsResponsive","showEditButton","themeSupportsResponsive","allowResponsive","toggleResponsive","switchBackToURLInput","jsxs","Fragment","children","jsx","BlockControls","ToolbarGroup","ToolbarButton","className","label","icon","edit","onClick","InspectorControls","
|
|
1
|
+
{"version":3,"names":["_i18n","require","_components","_blockEditor","_icons","_hooks","_jsxRuntime","getResponsiveHelp","checked","__","EmbedControls","blockSupportsResponsive","showEditButton","themeSupportsResponsive","allowResponsive","toggleResponsive","switchBackToURLInput","dropdownMenuProps","useToolsPanelDropdownMenuProps","jsxs","Fragment","children","jsx","BlockControls","ToolbarGroup","ToolbarButton","className","label","icon","edit","onClick","InspectorControls","__experimentalToolsPanel","resetAll","__experimentalToolsPanelItem","isShownByDefault","hasValue","onDeselect","ToggleControl","__nextHasNoMarginBottom","help","onChange","_default","exports","default"],"sources":["@wordpress/block-library/src/embed/embed-controls.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport {\n\tToolbarButton,\n\tToggleControl,\n\tToolbarGroup,\n\t__experimentalToolsPanel as ToolsPanel,\n\t__experimentalToolsPanelItem as ToolsPanelItem,\n} from '@wordpress/components';\nimport { BlockControls, InspectorControls } from '@wordpress/block-editor';\nimport { edit } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport { useToolsPanelDropdownMenuProps } from '../utils/hooks';\n\nfunction getResponsiveHelp( checked ) {\n\treturn checked\n\t\t? __(\n\t\t\t\t'This embed will preserve its aspect ratio when the browser is resized.'\n\t\t )\n\t\t: __(\n\t\t\t\t'This embed may not preserve its aspect ratio when the browser is resized.'\n\t\t );\n}\n\nconst EmbedControls = ( {\n\tblockSupportsResponsive,\n\tshowEditButton,\n\tthemeSupportsResponsive,\n\tallowResponsive,\n\ttoggleResponsive,\n\tswitchBackToURLInput,\n} ) => {\n\tconst dropdownMenuProps = useToolsPanelDropdownMenuProps();\n\n\treturn (\n\t\t<>\n\t\t\t<BlockControls>\n\t\t\t\t<ToolbarGroup>\n\t\t\t\t\t{ showEditButton && (\n\t\t\t\t\t\t<ToolbarButton\n\t\t\t\t\t\t\tclassName=\"components-toolbar__control\"\n\t\t\t\t\t\t\tlabel={ __( 'Edit URL' ) }\n\t\t\t\t\t\t\ticon={ edit }\n\t\t\t\t\t\t\tonClick={ switchBackToURLInput }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\t\t\t\t</ToolbarGroup>\n\t\t\t</BlockControls>\n\t\t\t{ themeSupportsResponsive && blockSupportsResponsive && (\n\t\t\t\t<InspectorControls>\n\t\t\t\t\t<ToolsPanel\n\t\t\t\t\t\tlabel={ __( 'Media settings' ) }\n\t\t\t\t\t\tresetAll={ () => {\n\t\t\t\t\t\t\ttoggleResponsive( true );\n\t\t\t\t\t\t} }\n\t\t\t\t\t\tdropdownMenuProps={ dropdownMenuProps }\n\t\t\t\t\t>\n\t\t\t\t\t\t<ToolsPanelItem\n\t\t\t\t\t\t\tlabel={ __( 'Media settings' ) }\n\t\t\t\t\t\t\tisShownByDefault\n\t\t\t\t\t\t\thasValue={ () => ! allowResponsive }\n\t\t\t\t\t\t\tonDeselect={ () => {\n\t\t\t\t\t\t\t\ttoggleResponsive( ! allowResponsive );\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<ToggleControl\n\t\t\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\t\t\tlabel={ __( 'Resize for smaller devices' ) }\n\t\t\t\t\t\t\t\tchecked={ allowResponsive }\n\t\t\t\t\t\t\t\thelp={ getResponsiveHelp }\n\t\t\t\t\t\t\t\tonChange={ toggleResponsive }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t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BAAiB;MAAAV,QAAA,eACjB,IAAAf,WAAA,CAAAgB,GAAA,EAACpB,WAAA,CAAA8B,wBAAU;QACVL,KAAK,EAAG,IAAAlB,QAAE,EAAE,gBAAiB,CAAG;QAChCwB,QAAQ,EAAGA,CAAA,KAAM;UAChBlB,gBAAgB,CAAE,IAAK,CAAC;QACzB,CAAG;QACHE,iBAAiB,EAAGA,iBAAmB;QAAAI,QAAA,eAEvC,IAAAf,WAAA,CAAAgB,GAAA,EAACpB,WAAA,CAAAgC,4BAAc;UACdP,KAAK,EAAG,IAAAlB,QAAE,EAAE,gBAAiB,CAAG;UAChC0B,gBAAgB;UAChBC,QAAQ,EAAGA,CAAA,KAAM,CAAEtB,eAAiB;UACpCuB,UAAU,EAAGA,CAAA,KAAM;YAClBtB,gBAAgB,CAAE,CAAED,eAAgB,CAAC;UACtC,CAAG;UAAAO,QAAA,eAEH,IAAAf,WAAA,CAAAgB,GAAA,EAACpB,WAAA,CAAAoC,aAAa;YACbC,uBAAuB;YACvBZ,KAAK,EAAG,IAAAlB,QAAE,EAAE,4BAA6B,CAAG;YAC5CD,OAAO,EAAGM,eAAiB;YAC3B0B,IAAI,EAAGjC,iBAAmB;YAC1BkC,QAAQ,EAAG1B;UAAkB,CAC7B;QAAC,CACa;MAAC,CACN;IAAC,CACK,CACnB;EAAA,CACA,CAAC;AAEL,CAAC;AAAC,IAAA2B,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEalC,aAAa","ignoreList":[]}
|
|
@@ -256,16 +256,6 @@ const variations = [{
|
|
|
256
256
|
providerNameSlug: 'reverbnation',
|
|
257
257
|
responsive: true
|
|
258
258
|
}
|
|
259
|
-
}, {
|
|
260
|
-
name: 'screencast',
|
|
261
|
-
title: getTitle('Screencast'),
|
|
262
|
-
icon: _icons.embedVideoIcon,
|
|
263
|
-
description: (0, _i18n.__)('Embed Screencast content.'),
|
|
264
|
-
patterns: [/^https?:\/\/(www\.)?screencast\.com\/.+/i],
|
|
265
|
-
attributes: {
|
|
266
|
-
providerNameSlug: 'screencast',
|
|
267
|
-
responsive: true
|
|
268
|
-
}
|
|
269
259
|
}, {
|
|
270
260
|
name: 'scribd',
|
|
271
261
|
title: getTitle('Scribd'),
|