@wordpress/block-library 9.44.1-next.v.202604201441.0 → 9.45.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/build/accordion/edit.cjs +0 -2
- package/build/accordion/edit.cjs.map +2 -2
- package/build/accordion-item/block.json +1 -0
- package/build/categories/edit.cjs +5 -1
- package/build/categories/edit.cjs.map +2 -2
- package/build/embed/edit.cjs +38 -34
- package/build/embed/edit.cjs.map +3 -3
- package/build/embed/transforms.cjs +3 -1
- package/build/embed/transforms.cjs.map +2 -2
- package/build/embed/util.cjs +13 -2
- package/build/embed/util.cjs.map +2 -2
- package/build/form/block.json +1 -1
- package/build/form-input/block.json +1 -1
- package/build/form-submission-notification/block.json +1 -1
- package/build/form-submit-button/block.json +1 -1
- package/build/image/edit.cjs +1 -1
- package/build/image/edit.cjs.map +2 -2
- package/build/image/image.cjs +29 -10
- package/build/image/image.cjs.map +3 -3
- package/build/index.cjs +4 -4
- package/build/index.cjs.map +2 -2
- package/build/math/edit.cjs +2 -2
- package/build/math/edit.cjs.map +2 -2
- package/build/navigation/edit/accessible-description.cjs +2 -2
- package/build/navigation/edit/accessible-description.cjs.map +2 -2
- package/build/navigation/edit/overlay-template-part-selector.cjs.map +2 -2
- package/build/navigation-link/edit.cjs +2 -1
- package/build/navigation-link/edit.cjs.map +2 -2
- package/build/navigation-link/link-ui/dialog-wrapper.cjs +2 -1
- package/build/navigation-link/link-ui/dialog-wrapper.cjs.map +2 -2
- package/build/navigation-link/link-ui/index.cjs +2 -1
- package/build/navigation-link/link-ui/index.cjs.map +2 -2
- package/build/post-author/edit.cjs.map +3 -3
- package/build/post-comments-form/edit.cjs +2 -2
- package/build/post-comments-form/edit.cjs.map +2 -2
- package/build/query/edit/inspector-controls/author-control.cjs +1 -1
- package/build/query/edit/inspector-controls/author-control.cjs.map +2 -2
- package/build/query/edit/inspector-controls/format-controls.cjs +1 -1
- package/build/query/edit/inspector-controls/format-controls.cjs.map +2 -2
- package/build/query/edit/inspector-controls/parent-control.cjs +1 -1
- package/build/query/edit/inspector-controls/parent-control.cjs.map +2 -2
- package/build/query/edit/inspector-controls/taxonomy-controls.cjs +1 -1
- package/build/query/edit/inspector-controls/taxonomy-controls.cjs.map +2 -2
- package/build/site-logo/edit.cjs +32 -18
- package/build/site-logo/edit.cjs.map +2 -2
- package/build/tab/block.json +23 -23
- package/build/tab/controls.cjs +5 -48
- package/build/tab/controls.cjs.map +3 -3
- package/build/tab/edit.cjs +77 -75
- package/build/tab/edit.cjs.map +3 -3
- package/build/tab/save.cjs +3 -3
- package/build/tab/save.cjs.map +2 -2
- package/{src/tabs-menu → build/tab-list}/block.json +3 -3
- package/build/{tabs-menu → tab-list}/edit.cjs +4 -4
- package/build/tab-list/edit.cjs.map +7 -0
- package/build/{tabs-menu → tab-list}/index.cjs +5 -5
- package/build/tab-list/index.cjs.map +7 -0
- package/build/{tabs-menu → tab-list}/save.cjs +1 -1
- package/build/{tabs-menu → tab-list}/save.cjs.map +1 -1
- package/build/{tab → tab-panel}/add-tab-toolbar-control.cjs +16 -16
- package/build/tab-panel/add-tab-toolbar-control.cjs.map +7 -0
- package/build/tab-panel/block.json +27 -37
- package/build/tab-panel/controls.cjs +89 -0
- package/build/tab-panel/controls.cjs.map +7 -0
- package/build/tab-panel/edit.cjs +90 -17
- package/build/tab-panel/edit.cjs.map +3 -3
- package/build/tab-panel/index.cjs +1 -1
- package/build/tab-panel/index.cjs.map +1 -1
- package/build/{tab → tab-panel}/init.cjs +1 -1
- package/build/{tab → tab-panel}/init.cjs.map +1 -1
- package/build/{tab → tab-panel}/remove-tab-toolbar-control.cjs +16 -16
- package/build/tab-panel/remove-tab-toolbar-control.cjs.map +7 -0
- package/build/tab-panel/save.cjs +4 -2
- package/build/tab-panel/save.cjs.map +2 -2
- package/build/tab-panels/block.json +66 -0
- package/build/{tabs-menu-item/controls.cjs → tab-panels/edit.cjs} +25 -11
- package/build/tab-panels/edit.cjs.map +7 -0
- package/build/{tabs-menu-item → tab-panels}/index.cjs +5 -5
- package/build/{tabs-menu → tab-panels}/index.cjs.map +2 -2
- package/build/{tabs-menu-item → tab-panels}/save.cjs +4 -6
- package/build/tab-panels/save.cjs.map +7 -0
- package/build/tabs/block.json +1 -1
- package/build/tabs/controls.cjs +2 -2
- package/build/tabs/controls.cjs.map +1 -1
- package/build/tabs/edit.cjs +24 -19
- package/build/tabs/edit.cjs.map +3 -3
- package/build/tabs/index.cjs +5 -5
- package/build/tabs/index.cjs.map +1 -1
- package/build/tabs/{use-tab-menu-sync.cjs → use-tab-list-sync.cjs} +78 -80
- package/build/tabs/use-tab-list-sync.cjs.map +7 -0
- package/build/terms-query/edit/inspector-controls/include-control.cjs +1 -1
- package/build/terms-query/edit/inspector-controls/include-control.cjs.map +2 -2
- package/build/video/tracks-editor.cjs +2 -2
- package/build/video/tracks-editor.cjs.map +2 -2
- package/build-module/accordion/edit.mjs +0 -2
- package/build-module/accordion/edit.mjs.map +2 -2
- package/build-module/accordion-item/block.json +1 -0
- package/build-module/categories/edit.mjs +5 -2
- package/build-module/categories/edit.mjs.map +2 -2
- package/build-module/embed/edit.mjs +45 -36
- package/build-module/embed/edit.mjs.map +2 -2
- package/build-module/embed/transforms.mjs +8 -2
- package/build-module/embed/transforms.mjs.map +2 -2
- package/build-module/embed/util.mjs +11 -1
- package/build-module/embed/util.mjs.map +2 -2
- package/build-module/form/block.json +1 -1
- package/build-module/form-input/block.json +1 -1
- package/build-module/form-submission-notification/block.json +1 -1
- package/build-module/form-submit-button/block.json +1 -1
- package/build-module/image/edit.mjs +1 -1
- package/build-module/image/edit.mjs.map +2 -2
- package/build-module/image/image.mjs +29 -10
- package/build-module/image/image.mjs.map +3 -3
- package/build-module/index.mjs +4 -4
- package/build-module/index.mjs.map +2 -2
- package/build-module/math/edit.mjs +2 -2
- package/build-module/math/edit.mjs.map +2 -2
- package/build-module/navigation/edit/accessible-description.mjs +1 -1
- package/build-module/navigation/edit/accessible-description.mjs.map +1 -1
- package/build-module/navigation/edit/overlay-template-part-selector.mjs +2 -2
- package/build-module/navigation/edit/overlay-template-part-selector.mjs.map +1 -1
- package/build-module/navigation-link/edit.mjs +2 -5
- package/build-module/navigation-link/edit.mjs.map +2 -2
- package/build-module/navigation-link/link-ui/dialog-wrapper.mjs +2 -1
- package/build-module/navigation-link/link-ui/dialog-wrapper.mjs.map +2 -2
- package/build-module/navigation-link/link-ui/index.mjs +1 -1
- package/build-module/navigation-link/link-ui/index.mjs.map +2 -2
- package/build-module/post-author/edit.mjs +2 -2
- package/build-module/post-author/edit.mjs.map +2 -2
- package/build-module/post-comments-form/edit.mjs +1 -1
- package/build-module/post-comments-form/edit.mjs.map +2 -2
- package/build-module/query/edit/inspector-controls/author-control.mjs +1 -1
- package/build-module/query/edit/inspector-controls/author-control.mjs.map +2 -2
- package/build-module/query/edit/inspector-controls/format-controls.mjs +1 -1
- package/build-module/query/edit/inspector-controls/format-controls.mjs.map +2 -2
- package/build-module/query/edit/inspector-controls/parent-control.mjs +1 -1
- package/build-module/query/edit/inspector-controls/parent-control.mjs.map +2 -2
- package/build-module/query/edit/inspector-controls/taxonomy-controls.mjs +1 -1
- package/build-module/query/edit/inspector-controls/taxonomy-controls.mjs.map +2 -2
- package/build-module/site-logo/edit.mjs +32 -18
- package/build-module/site-logo/edit.mjs.map +2 -2
- package/build-module/tab/block.json +23 -23
- package/build-module/tab/controls.mjs +7 -57
- package/build-module/tab/controls.mjs.map +2 -2
- package/build-module/tab/edit.mjs +81 -79
- package/build-module/tab/edit.mjs.map +3 -3
- package/build-module/tab/save.mjs +4 -4
- package/build-module/tab/save.mjs.map +2 -2
- package/build-module/{tabs-menu → tab-list}/block.json +3 -3
- package/build-module/{tabs-menu → tab-list}/edit.mjs +4 -4
- package/build-module/tab-list/edit.mjs.map +7 -0
- package/build-module/{tabs-menu → tab-list}/index.mjs +2 -2
- package/build-module/tab-list/index.mjs.map +7 -0
- package/build-module/{tabs-menu → tab-list}/save.mjs +1 -1
- package/build-module/{tabs-menu → tab-list}/save.mjs.map +1 -1
- package/build-module/{tab → tab-panel}/add-tab-toolbar-control.mjs +16 -16
- package/build-module/tab-panel/add-tab-toolbar-control.mjs.map +7 -0
- package/build-module/tab-panel/block.json +27 -37
- package/build-module/tab-panel/controls.mjs +65 -0
- package/build-module/tab-panel/controls.mjs.map +7 -0
- package/build-module/tab-panel/edit.mjs +92 -19
- package/build-module/tab-panel/edit.mjs.map +2 -2
- package/build-module/tab-panel/index.mjs +1 -1
- package/build-module/tab-panel/index.mjs.map +1 -1
- package/build-module/{tab → tab-panel}/init.mjs +1 -1
- package/build-module/{tab → tab-panel}/init.mjs.map +1 -1
- package/build-module/{tab → tab-panel}/remove-tab-toolbar-control.mjs +16 -16
- package/build-module/tab-panel/remove-tab-toolbar-control.mjs.map +7 -0
- package/build-module/tab-panel/save.mjs +4 -2
- package/build-module/tab-panel/save.mjs.map +2 -2
- package/build-module/tab-panels/block.json +66 -0
- package/build-module/tab-panels/edit.mjs +33 -0
- package/build-module/tab-panels/edit.mjs.map +7 -0
- package/build-module/{tabs-menu-item → tab-panels}/index.mjs +2 -2
- package/build-module/{tabs-menu → tab-panels}/index.mjs.map +2 -2
- package/build-module/tab-panels/save.mjs +12 -0
- package/build-module/tab-panels/save.mjs.map +7 -0
- package/build-module/tabs/block.json +1 -1
- package/build-module/tabs/controls.mjs +2 -2
- package/build-module/tabs/controls.mjs.map +1 -1
- package/build-module/tabs/edit.mjs +24 -19
- package/build-module/tabs/edit.mjs.map +2 -2
- package/build-module/tabs/index.mjs +5 -5
- package/build-module/tabs/index.mjs.map +1 -1
- package/build-module/tabs/use-tab-list-sync.mjs +169 -0
- package/build-module/tabs/use-tab-list-sync.mjs.map +7 -0
- package/build-module/terms-query/edit/inspector-controls/include-control.mjs +1 -1
- package/build-module/terms-query/edit/inspector-controls/include-control.mjs.map +2 -2
- package/build-module/video/tracks-editor.mjs +2 -2
- package/build-module/video/tracks-editor.mjs.map +2 -2
- package/build-style/classic-rtl.css +14 -0
- package/build-style/classic.css +14 -0
- package/build-style/editor-rtl.css +9 -5
- package/build-style/editor.css +9 -5
- package/build-style/style-rtl.css +40 -40
- package/build-style/style.css +40 -40
- package/build-style/tab/editor-rtl.css +11 -0
- package/build-style/tab/editor.css +11 -0
- package/build-style/tab/style-rtl.css +29 -16
- package/build-style/tab/style.css +29 -16
- package/build-style/tab-list/editor-rtl.css +6 -0
- package/build-style/tab-list/editor.css +6 -0
- package/build-style/tab-panel/style-rtl.css +17 -1
- package/build-style/tab-panel/style.css +17 -1
- package/build-style/tab-panels/style-rtl.css +4 -0
- package/build-style/tab-panels/style.css +4 -0
- package/build-style/video/editor-rtl.css +4 -0
- package/build-style/video/editor.css +4 -0
- package/package.json +39 -38
- package/src/accordion/edit.js +0 -2
- package/src/accordion-item/block.json +1 -0
- package/src/categories/edit.js +3 -2
- package/src/classic.scss +25 -0
- package/src/editor.scss +2 -2
- package/src/embed/edit.js +61 -52
- package/src/embed/edit.native.js +71 -57
- package/src/embed/transforms.js +8 -2
- package/src/embed/util.js +17 -0
- package/src/form/block.json +1 -1
- package/src/form-input/block.json +1 -1
- package/src/form-submission-notification/block.json +1 -1
- package/src/form-submit-button/block.json +1 -1
- package/src/image/edit.js +5 -1
- package/src/image/edit.native.js +3 -3
- package/src/image/image.js +30 -5
- package/src/index.js +4 -4
- package/src/math/edit.js +3 -3
- package/src/navigation/edit/accessible-description.js +1 -1
- package/src/navigation/edit/overlay-template-part-selector.js +3 -3
- package/src/navigation-link/edit.js +2 -5
- package/src/navigation-link/link-ui/dialog-wrapper.js +2 -1
- package/src/navigation-link/link-ui/index.js +1 -1
- package/src/post-author/edit.js +3 -5
- package/src/post-comments-form/edit.js +1 -1
- package/src/query/edit/inspector-controls/author-control.js +1 -1
- package/src/query/edit/inspector-controls/format-controls.js +1 -1
- package/src/query/edit/inspector-controls/parent-control.js +1 -1
- package/src/query/edit/inspector-controls/taxonomy-controls.js +1 -1
- package/src/site-logo/edit.js +38 -18
- package/src/style.scss +1 -1
- package/src/tab/block.json +23 -23
- package/src/tab/controls.js +6 -52
- package/src/tab/edit.js +99 -103
- package/src/{tabs-menu-item → tab}/editor.scss +3 -3
- package/src/tab/index.php +32 -51
- package/src/tab/save.js +4 -4
- package/src/tab/style.scss +34 -17
- package/{build/tabs-menu → src/tab-list}/block.json +3 -3
- package/src/{tabs-menu → tab-list}/edit.js +3 -3
- package/src/{tabs-menu → tab-list}/editor.scss +2 -2
- package/src/{tabs-menu → tab-list}/index.js +1 -1
- package/src/tab-list/index.php +80 -0
- package/src/{tab → tab-panel}/add-tab-toolbar-control.js +19 -19
- package/src/tab-panel/block.json +27 -37
- package/src/tab-panel/controls.js +65 -0
- package/src/tab-panel/edit.js +123 -20
- package/src/tab-panel/index.js +1 -1
- package/src/tab-panel/index.php +88 -0
- package/src/{tab → tab-panel}/remove-tab-toolbar-control.js +20 -19
- package/src/tab-panel/save.js +4 -2
- package/src/tab-panel/style.scss +20 -1
- package/src/tab-panels/block.json +66 -0
- package/src/tab-panels/edit.js +42 -0
- package/src/{tabs-menu-item → tab-panels}/index.js +1 -1
- package/src/tab-panels/save.js +11 -0
- package/src/tab-panels/style.scss +4 -0
- package/src/tabs/block.json +1 -1
- package/src/tabs/controls.js +2 -2
- package/src/tabs/edit.js +25 -20
- package/src/tabs/index.js +5 -5
- package/src/tabs/index.php +5 -5
- package/src/tabs/use-tab-list-sync.js +237 -0
- package/src/terms-query/edit/inspector-controls/include-control.js +1 -1
- package/src/video/editor.scss +5 -0
- package/src/video/tracks-editor.js +2 -2
- package/build/tab/add-tab-toolbar-control.cjs.map +0 -7
- package/build/tab/remove-tab-toolbar-control.cjs.map +0 -7
- package/build/tabs/use-tab-menu-sync.cjs.map +0 -7
- package/build/tabs-menu/edit.cjs.map +0 -7
- package/build/tabs-menu-item/block.json +0 -56
- package/build/tabs-menu-item/controls.cjs.map +0 -7
- package/build/tabs-menu-item/edit.cjs +0 -135
- package/build/tabs-menu-item/edit.cjs.map +0 -7
- package/build/tabs-menu-item/index.cjs.map +0 -7
- package/build/tabs-menu-item/save.cjs.map +0 -7
- package/build-module/tab/add-tab-toolbar-control.mjs.map +0 -7
- package/build-module/tab/remove-tab-toolbar-control.mjs.map +0 -7
- package/build-module/tabs/use-tab-menu-sync.mjs +0 -171
- package/build-module/tabs/use-tab-menu-sync.mjs.map +0 -7
- package/build-module/tabs-menu/edit.mjs.map +0 -7
- package/build-module/tabs-menu-item/block.json +0 -56
- package/build-module/tabs-menu-item/controls.mjs +0 -15
- package/build-module/tabs-menu-item/controls.mjs.map +0 -7
- package/build-module/tabs-menu-item/edit.mjs +0 -108
- package/build-module/tabs-menu-item/edit.mjs.map +0 -7
- package/build-module/tabs-menu-item/index.mjs.map +0 -7
- package/build-module/tabs-menu-item/save.mjs +0 -14
- package/build-module/tabs-menu-item/save.mjs.map +0 -7
- package/build-style/tabs-menu/editor-rtl.css +0 -6
- package/build-style/tabs-menu/editor.css +0 -6
- package/build-style/tabs-menu-item/editor-rtl.css +0 -11
- package/build-style/tabs-menu-item/editor.css +0 -11
- package/build-style/tabs-menu-item/style-rtl.css +0 -33
- package/build-style/tabs-menu-item/style.css +0 -33
- package/src/tabs/use-tab-menu-sync.js +0 -239
- package/src/tabs-menu/index.php +0 -80
- package/src/tabs-menu-item/block.json +0 -56
- package/src/tabs-menu-item/controls.js +0 -19
- package/src/tabs-menu-item/edit.js +0 -141
- package/src/tabs-menu-item/index.php +0 -70
- package/src/tabs-menu-item/save.js +0 -13
- package/src/tabs-menu-item/style.scss +0 -40
- /package/src/{tabs-menu → tab-list}/save.js +0 -0
- /package/src/{tab → tab-panel}/init.js +0 -0
package/CHANGELOG.md
CHANGED
package/build/accordion/edit.cjs
CHANGED
|
@@ -120,7 +120,6 @@ function Edit({
|
|
|
120
120
|
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
121
121
|
import_components.ToggleControl,
|
|
122
122
|
{
|
|
123
|
-
isBlock: true,
|
|
124
123
|
label: (0, import_i18n.__)("Auto-close"),
|
|
125
124
|
onChange: (value) => {
|
|
126
125
|
setAttributes({
|
|
@@ -145,7 +144,6 @@ function Edit({
|
|
|
145
144
|
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
146
145
|
import_components.ToggleControl,
|
|
147
146
|
{
|
|
148
|
-
isBlock: true,
|
|
149
147
|
label: (0, import_i18n.__)("Show icon"),
|
|
150
148
|
onChange: (value) => {
|
|
151
149
|
setAttributes({
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/accordion/edit.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport {\n\tuseBlockProps,\n\tuseInnerBlocksProps,\n\tInspectorControls,\n\tBlockControls,\n\tuseBlockEditingMode,\n\tstore as blockEditorStore,\n\tHeadingLevelDropdown,\n} from '@wordpress/block-editor';\nimport { __ } from '@wordpress/i18n';\nimport {\n\tToggleControl,\n\t__experimentalToggleGroupControl as ToggleGroupControl,\n\t__experimentalToggleGroupControlOption as ToggleGroupControlOption,\n\t__experimentalToolsPanel as ToolsPanel,\n\t__experimentalToolsPanelItem as ToolsPanelItem,\n\tToolbarButton,\n\tToolbarGroup,\n} from '@wordpress/components';\nimport { useDispatch, useSelect, useRegistry } from '@wordpress/data';\nimport { createBlock } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport { useToolsPanelDropdownMenuProps } from '../utils/hooks';\n\nconst ACCORDION_BLOCK_NAME = 'core/accordion-item';\nconst ACCORDION_HEADING_BLOCK_NAME = 'core/accordion-heading';\nconst ACCORDION_BLOCK = {\n\tname: ACCORDION_BLOCK_NAME,\n};\n\nexport default function Edit( {\n\tattributes: {\n\t\tautoclose,\n\t\ticonPosition,\n\t\tshowIcon,\n\t\theadingLevel,\n\t\tlevelOptions,\n\t},\n\tclientId,\n\tsetAttributes,\n\tisSelected: isSingleSelected,\n} ) {\n\tconst registry = useRegistry();\n\tconst { getBlockOrder } = useSelect( blockEditorStore );\n\tconst blockProps = useBlockProps( {\n\t\trole: 'group',\n\t} );\n\tconst dropdownMenuProps = useToolsPanelDropdownMenuProps();\n\tconst { updateBlockAttributes, insertBlock } =\n\t\tuseDispatch( blockEditorStore );\n\tconst blockEditingMode = useBlockEditingMode();\n\tconst isContentOnlyMode = blockEditingMode === 'contentOnly';\n\n\tconst innerBlocksProps = useInnerBlocksProps( blockProps, {\n\t\ttemplate: [ [ ACCORDION_BLOCK_NAME ] ],\n\t\tdefaultBlock: ACCORDION_BLOCK,\n\t\tdirectInsert: true,\n\t\ttemplateInsertUpdatesSelection: true,\n\t} );\n\n\tconst addAccordionItemBlock = () => {\n\t\t// When adding, set the header's level to current headingLevel\n\t\tconst newAccordionItem = createBlock( ACCORDION_BLOCK_NAME, {}, [\n\t\t\tcreateBlock( ACCORDION_HEADING_BLOCK_NAME, {\n\t\t\t\tlevel: headingLevel,\n\t\t\t} ),\n\t\t\tcreateBlock( 'core/accordion-panel', {} ),\n\t\t] );\n\t\tinsertBlock( newAccordionItem, undefined, clientId );\n\t};\n\n\t/**\n\t * Update all child Accordion Header blocks with a new heading level\n\t * based on the accordion group setting.\n\t * @param {number} newHeadingLevel The new heading level to set\n\t */\n\tconst updateHeadingLevel = ( newHeadingLevel ) => {\n\t\tconst innerBlockClientIds = getBlockOrder( clientId );\n\n\t\t// Get all accordion-header blocks from all accordion-content blocks.\n\t\tconst accordionHeaderClientIds = [];\n\t\tinnerBlockClientIds.forEach( ( contentClientId ) => {\n\t\t\tconst headerClientIds = getBlockOrder( contentClientId );\n\t\t\taccordionHeaderClientIds.push( ...headerClientIds );\n\t\t} );\n\n\t\t// Update own and child block heading levels.\n\t\tregistry.batch( () => {\n\t\t\tsetAttributes( { headingLevel: newHeadingLevel } );\n\t\t\tupdateBlockAttributes( accordionHeaderClientIds, {\n\t\t\t\tlevel: newHeadingLevel,\n\t\t\t} );\n\t\t} );\n\t};\n\n\treturn (\n\t\t<>\n\t\t\t{ isSingleSelected && ! isContentOnlyMode && (\n\t\t\t\t<>\n\t\t\t\t\t<BlockControls>\n\t\t\t\t\t\t<ToolbarGroup>\n\t\t\t\t\t\t\t<HeadingLevelDropdown\n\t\t\t\t\t\t\t\tvalue={ headingLevel }\n\t\t\t\t\t\t\t\toptions={ levelOptions }\n\t\t\t\t\t\t\t\tonChange={ updateHeadingLevel }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</ToolbarGroup>\n\t\t\t\t\t</BlockControls>\n\t\t\t\t\t<BlockControls group=\"other\">\n\t\t\t\t\t\t<ToolbarButton onClick={ addAccordionItemBlock }>\n\t\t\t\t\t\t\t{ __( 'Add item' ) }\n\t\t\t\t\t\t</ToolbarButton>\n\t\t\t\t\t</BlockControls>\n\t\t\t\t</>\n\t\t\t) }\n\t\t\t<InspectorControls key=\"setting\">\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\tautoclose: false,\n\t\t\t\t\t\t\tshowIcon: true,\n\t\t\t\t\t\t\ticonPosition: 'right',\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\tlabel={ __( 'Auto-close' ) }\n\t\t\t\t\t\tisShownByDefault\n\t\t\t\t\t\thasValue={ () => !! autoclose }\n\t\t\t\t\t\tonDeselect={ () =>\n\t\t\t\t\t\t\tsetAttributes( { autoclose: false } )\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\
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,0BAQO;AACP,kBAAmB;AACnB,wBAQO;AACP,kBAAoD;AACpD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CAAE;AACjD,4BAAuB,0BAA0B;AAAA,QAChD,OAAO;AAAA,MACR,CAAE;AAAA,IACH,CAAE;AAAA,EACH;AAEA,SACC,4EACG;AAAA,wBAAoB,CAAE,qBACvB,4EACC;AAAA,kDAAC,qCACA,sDAAC,kCACA;AAAA,QAAC;AAAA;AAAA,UACA,OAAQ;AAAA,UACR,SAAU;AAAA,UACV,UAAW;AAAA;AAAA,MACZ,GACD,GACD;AAAA,MACA,4CAAC,qCAAc,OAAM,SACpB,sDAAC,mCAAc,SAAU,uBACtB,8BAAI,UAAW,GAClB,GACD;AAAA,OACD;AAAA,IAED,4CAAC,yCACA;AAAA,MAAC,kBAAAC;AAAA,MAAA;AAAA,QACA,WAAQ,gBAAI,UAAW;AAAA,QACvB,UAAW,MAAM;AAChB,wBAAe;AAAA,YACd,WAAW;AAAA,YACX,UAAU;AAAA,YACV,cAAc;AAAA,UACf,CAAE;AAAA,QACH;AAAA,QACA;AAAA,QAEA;AAAA;AAAA,YAAC,kBAAAC;AAAA,YAAA;AAAA,cACA,WAAQ,gBAAI,YAAa;AAAA,cACzB,kBAAgB;AAAA,cAChB,UAAW,MAAM,CAAC,CAAE;AAAA,cACpB,YAAa,MACZ,cAAe,EAAE,WAAW,MAAM,CAAE;AAAA,cAGrC;AAAA,gBAAC;AAAA;AAAA,kBACA,
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport {\n\tuseBlockProps,\n\tuseInnerBlocksProps,\n\tInspectorControls,\n\tBlockControls,\n\tuseBlockEditingMode,\n\tstore as blockEditorStore,\n\tHeadingLevelDropdown,\n} from '@wordpress/block-editor';\nimport { __ } from '@wordpress/i18n';\nimport {\n\tToggleControl,\n\t__experimentalToggleGroupControl as ToggleGroupControl,\n\t__experimentalToggleGroupControlOption as ToggleGroupControlOption,\n\t__experimentalToolsPanel as ToolsPanel,\n\t__experimentalToolsPanelItem as ToolsPanelItem,\n\tToolbarButton,\n\tToolbarGroup,\n} from '@wordpress/components';\nimport { useDispatch, useSelect, useRegistry } from '@wordpress/data';\nimport { createBlock } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport { useToolsPanelDropdownMenuProps } from '../utils/hooks';\n\nconst ACCORDION_BLOCK_NAME = 'core/accordion-item';\nconst ACCORDION_HEADING_BLOCK_NAME = 'core/accordion-heading';\nconst ACCORDION_BLOCK = {\n\tname: ACCORDION_BLOCK_NAME,\n};\n\nexport default function Edit( {\n\tattributes: {\n\t\tautoclose,\n\t\ticonPosition,\n\t\tshowIcon,\n\t\theadingLevel,\n\t\tlevelOptions,\n\t},\n\tclientId,\n\tsetAttributes,\n\tisSelected: isSingleSelected,\n} ) {\n\tconst registry = useRegistry();\n\tconst { getBlockOrder } = useSelect( blockEditorStore );\n\tconst blockProps = useBlockProps( {\n\t\trole: 'group',\n\t} );\n\tconst dropdownMenuProps = useToolsPanelDropdownMenuProps();\n\tconst { updateBlockAttributes, insertBlock } =\n\t\tuseDispatch( blockEditorStore );\n\tconst blockEditingMode = useBlockEditingMode();\n\tconst isContentOnlyMode = blockEditingMode === 'contentOnly';\n\n\tconst innerBlocksProps = useInnerBlocksProps( blockProps, {\n\t\ttemplate: [ [ ACCORDION_BLOCK_NAME ] ],\n\t\tdefaultBlock: ACCORDION_BLOCK,\n\t\tdirectInsert: true,\n\t\ttemplateInsertUpdatesSelection: true,\n\t} );\n\n\tconst addAccordionItemBlock = () => {\n\t\t// When adding, set the header's level to current headingLevel\n\t\tconst newAccordionItem = createBlock( ACCORDION_BLOCK_NAME, {}, [\n\t\t\tcreateBlock( ACCORDION_HEADING_BLOCK_NAME, {\n\t\t\t\tlevel: headingLevel,\n\t\t\t} ),\n\t\t\tcreateBlock( 'core/accordion-panel', {} ),\n\t\t] );\n\t\tinsertBlock( newAccordionItem, undefined, clientId );\n\t};\n\n\t/**\n\t * Update all child Accordion Header blocks with a new heading level\n\t * based on the accordion group setting.\n\t * @param {number} newHeadingLevel The new heading level to set\n\t */\n\tconst updateHeadingLevel = ( newHeadingLevel ) => {\n\t\tconst innerBlockClientIds = getBlockOrder( clientId );\n\n\t\t// Get all accordion-header blocks from all accordion-content blocks.\n\t\tconst accordionHeaderClientIds = [];\n\t\tinnerBlockClientIds.forEach( ( contentClientId ) => {\n\t\t\tconst headerClientIds = getBlockOrder( contentClientId );\n\t\t\taccordionHeaderClientIds.push( ...headerClientIds );\n\t\t} );\n\n\t\t// Update own and child block heading levels.\n\t\tregistry.batch( () => {\n\t\t\tsetAttributes( { headingLevel: newHeadingLevel } );\n\t\t\tupdateBlockAttributes( accordionHeaderClientIds, {\n\t\t\t\tlevel: newHeadingLevel,\n\t\t\t} );\n\t\t} );\n\t};\n\n\treturn (\n\t\t<>\n\t\t\t{ isSingleSelected && ! isContentOnlyMode && (\n\t\t\t\t<>\n\t\t\t\t\t<BlockControls>\n\t\t\t\t\t\t<ToolbarGroup>\n\t\t\t\t\t\t\t<HeadingLevelDropdown\n\t\t\t\t\t\t\t\tvalue={ headingLevel }\n\t\t\t\t\t\t\t\toptions={ levelOptions }\n\t\t\t\t\t\t\t\tonChange={ updateHeadingLevel }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</ToolbarGroup>\n\t\t\t\t\t</BlockControls>\n\t\t\t\t\t<BlockControls group=\"other\">\n\t\t\t\t\t\t<ToolbarButton onClick={ addAccordionItemBlock }>\n\t\t\t\t\t\t\t{ __( 'Add item' ) }\n\t\t\t\t\t\t</ToolbarButton>\n\t\t\t\t\t</BlockControls>\n\t\t\t\t</>\n\t\t\t) }\n\t\t\t<InspectorControls key=\"setting\">\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\tautoclose: false,\n\t\t\t\t\t\t\tshowIcon: true,\n\t\t\t\t\t\t\ticonPosition: 'right',\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\tlabel={ __( 'Auto-close' ) }\n\t\t\t\t\t\tisShownByDefault\n\t\t\t\t\t\thasValue={ () => !! autoclose }\n\t\t\t\t\t\tonDeselect={ () =>\n\t\t\t\t\t\t\tsetAttributes( { autoclose: false } )\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\tlabel={ __( 'Auto-close' ) }\n\t\t\t\t\t\t\tonChange={ ( value ) => {\n\t\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\t\tautoclose: 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\tchecked={ autoclose }\n\t\t\t\t\t\t\thelp={ __(\n\t\t\t\t\t\t\t\t'Automatically close accordions when a new one is opened.'\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\t<ToolsPanelItem\n\t\t\t\t\t\tlabel={ __( 'Show icon' ) }\n\t\t\t\t\t\tisShownByDefault\n\t\t\t\t\t\thasValue={ () => ! showIcon }\n\t\t\t\t\t\tonDeselect={ () => setAttributes( { showIcon: true } ) }\n\t\t\t\t\t>\n\t\t\t\t\t\t<ToggleControl\n\t\t\t\t\t\t\tlabel={ __( 'Show icon' ) }\n\t\t\t\t\t\t\tonChange={ ( value ) => {\n\t\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\t\tshowIcon: value,\n\t\t\t\t\t\t\t\t\ticonPosition: value\n\t\t\t\t\t\t\t\t\t\t? iconPosition\n\t\t\t\t\t\t\t\t\t\t: 'right',\n\t\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\tchecked={ showIcon }\n\t\t\t\t\t\t\thelp={ __(\n\t\t\t\t\t\t\t\t'Display a plus icon next to the accordion header.'\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\t{ showIcon && (\n\t\t\t\t\t\t<ToolsPanelItem\n\t\t\t\t\t\t\tlabel={ __( 'Icon Position' ) }\n\t\t\t\t\t\t\tisShownByDefault\n\t\t\t\t\t\t\thasValue={ () => iconPosition !== 'right' }\n\t\t\t\t\t\t\tonDeselect={ () =>\n\t\t\t\t\t\t\t\tsetAttributes( { iconPosition: 'right' } )\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<ToggleGroupControl\n\t\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t\t\tisBlock\n\t\t\t\t\t\t\t\tlabel={ __( 'Icon Position' ) }\n\t\t\t\t\t\t\t\tvalue={ iconPosition }\n\t\t\t\t\t\t\t\tonChange={ ( value ) => {\n\t\t\t\t\t\t\t\t\tsetAttributes( { iconPosition: 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\t\t<ToggleGroupControlOption\n\t\t\t\t\t\t\t\t\tlabel={ __( 'Left' ) }\n\t\t\t\t\t\t\t\t\tvalue=\"left\"\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t<ToggleGroupControlOption\n\t\t\t\t\t\t\t\t\tlabel={ __( 'Right' ) }\n\t\t\t\t\t\t\t\t\tvalue=\"right\"\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t</ToggleGroupControl>\n\t\t\t\t\t\t</ToolsPanelItem>\n\t\t\t\t\t) }\n\t\t\t\t</ToolsPanel>\n\t\t\t</InspectorControls>\n\t\t\t<div { ...innerBlocksProps } />\n\t\t</>\n\t);\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,0BAQO;AACP,kBAAmB;AACnB,wBAQO;AACP,kBAAoD;AACpD,oBAA4B;AAK5B,mBAA+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AAQ,gBAAI,WAAY;AAAA,kBACxB,UAAW,CAAE,UAAW;AACvB,kCAAe;AAAA,sBACd,UAAU;AAAA,sBACV,cAAc,QACX,eACA;AAAA,oBACJ,CAAE;AAAA,kBACH;AAAA,kBACA,SAAU;AAAA,kBACV,UAAO;AAAA,oBACN;AAAA,kBACD;AAAA;AAAA,cACD;AAAA;AAAA,UACD;AAAA,UACE,YACD;AAAA,YAAC,kBAAAA;AAAA,YAAA;AAAA,cACA,WAAQ,gBAAI,eAAgB;AAAA,cAC5B,kBAAgB;AAAA,cAChB,UAAW,MAAM,iBAAiB;AAAA,cAClC,YAAa,MACZ,cAAe,EAAE,cAAc,QAAQ,CAAE;AAAA,cAG1C;AAAA,gBAAC,kBAAAC;AAAA,gBAAA;AAAA,kBACA,uBAAqB;AAAA,kBACrB,SAAO;AAAA,kBACP,WAAQ,gBAAI,eAAgB;AAAA,kBAC5B,OAAQ;AAAA,kBACR,UAAW,CAAE,UAAW;AACvB,kCAAe,EAAE,cAAc,MAAM,CAAE;AAAA,kBACxC;AAAA,kBAEA;AAAA;AAAA,sBAAC,kBAAAC;AAAA,sBAAA;AAAA,wBACA,WAAQ,gBAAI,MAAO;AAAA,wBACnB,OAAM;AAAA;AAAA,oBACP;AAAA,oBACA;AAAA,sBAAC,kBAAAA;AAAA,sBAAA;AAAA,wBACA,WAAQ,gBAAI,OAAQ;AAAA,wBACpB,OAAM;AAAA;AAAA,oBACP;AAAA;AAAA;AAAA,cACD;AAAA;AAAA,UACD;AAAA;AAAA;AAAA,IAEF,KApFsB,SAqFvB;AAAA,IACA,4CAAC,SAAM,GAAG,kBAAmB;AAAA,KAC9B;AAEF;",
|
|
6
6
|
"names": ["blockEditorStore", "ToolsPanel", "ToolsPanelItem", "ToggleGroupControl", "ToggleGroupControlOption"]
|
|
7
7
|
}
|
|
@@ -42,6 +42,7 @@ var import_i18n = require("@wordpress/i18n");
|
|
|
42
42
|
var import_icons = require("@wordpress/icons");
|
|
43
43
|
var import_core_data = require("@wordpress/core-data");
|
|
44
44
|
var import_data = require("@wordpress/data");
|
|
45
|
+
var import_ui = require("@wordpress/ui");
|
|
45
46
|
var import_notices = require("@wordpress/notices");
|
|
46
47
|
var import_hooks = require("../utils/hooks.cjs");
|
|
47
48
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
@@ -129,7 +130,10 @@ function CategoriesEdit({
|
|
|
129
130
|
value: label,
|
|
130
131
|
onChange: (html) => setAttributes({ label: html })
|
|
131
132
|
}
|
|
132
|
-
) :
|
|
133
|
+
) : (
|
|
134
|
+
// eslint-disable-next-line jsx-a11y/label-has-associated-control
|
|
135
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ui.VisuallyHidden, { render: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("label", { htmlFor: selectId }), children: label ? label : taxonomy?.name })
|
|
136
|
+
),
|
|
133
137
|
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("select", { id: selectId, children: [
|
|
134
138
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("option", { children: (0, import_i18n.sprintf)(
|
|
135
139
|
/* translators: %s: taxonomy's singular name */
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/categories/edit.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tPlaceholder,\n\tSelectControl,\n\tSpinner,\n\tToggleControl,\n\tVisuallyHidden,\n\t__experimentalToolsPanel as ToolsPanel,\n\t__experimentalToolsPanelItem as ToolsPanelItem,\n} from '@wordpress/components';\nimport { useInstanceId } from '@wordpress/compose';\nimport {\n\tInspectorControls,\n\tuseBlockProps,\n\tRichText,\n} from '@wordpress/block-editor';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { pin } from '@wordpress/icons';\nimport { useEntityRecords } from '@wordpress/core-data';\nimport { useDispatch } from '@wordpress/data';\nimport { store as noticeStore } from '@wordpress/notices';\n\n/**\n * Internal dependencies\n */\nimport { useToolsPanelDropdownMenuProps } from '../utils/hooks';\n\nexport default function CategoriesEdit( {\n\tattributes: {\n\t\tdisplayAsDropdown,\n\t\tshowHierarchy,\n\t\tshowPostCounts,\n\t\tshowOnlyTopLevel,\n\t\tshowEmpty,\n\t\tlabel,\n\t\tshowLabel,\n\t\ttaxonomy: taxonomySlug,\n\t},\n\tsetAttributes,\n\tclassName,\n\tclientId,\n} ) {\n\tconst selectId = useInstanceId( CategoriesEdit, 'blocks-category-select' );\n\n\tconst { records: allTaxonomies, isResolvingTaxonomies } = useEntityRecords(\n\t\t'root',\n\t\t'taxonomy',\n\t\t{ per_page: -1 }\n\t);\n\n\tconst taxonomies = allTaxonomies?.filter( ( t ) => t.visibility.public );\n\n\tconst taxonomy = taxonomies?.find( ( t ) => t.slug === taxonomySlug );\n\n\tconst isHierarchicalTaxonomy =\n\t\t! isResolvingTaxonomies && taxonomy?.hierarchical;\n\n\tconst query = { per_page: -1, hide_empty: ! showEmpty, context: 'view' };\n\tif ( isHierarchicalTaxonomy && showOnlyTopLevel ) {\n\t\tquery.parent = 0;\n\t}\n\n\tconst { records: categories, isResolving } = useEntityRecords(\n\t\t'taxonomy',\n\t\ttaxonomySlug,\n\t\tquery\n\t);\n\n\tconst { createWarningNotice } = useDispatch( noticeStore );\n\tconst showRedirectionPreventedNotice = ( event ) => {\n\t\tevent.preventDefault();\n\t\tcreateWarningNotice( __( 'Links are disabled in the editor.' ), {\n\t\t\tid: `block-library/core/categories/redirection-prevented/${ clientId }`,\n\t\t\ttype: 'snackbar',\n\t\t} );\n\t};\n\n\tconst getCategoriesList = ( parentId ) => {\n\t\tif ( ! categories?.length ) {\n\t\t\treturn [];\n\t\t}\n\t\tif ( parentId === null ) {\n\t\t\treturn categories;\n\t\t}\n\t\treturn categories.filter( ( { parent } ) => parent === parentId );\n\t};\n\n\tconst toggleAttribute = ( attributeName ) => ( newValue ) =>\n\t\tsetAttributes( { [ attributeName ]: newValue } );\n\n\tconst renderCategoryName = ( name ) =>\n\t\t! name ? __( '(Untitled)' ) : decodeEntities( name ).trim();\n\n\tconst renderCategoryList = () => {\n\t\tconst parentId = isHierarchicalTaxonomy && showHierarchy ? 0 : null;\n\t\tconst categoriesList = getCategoriesList( parentId );\n\t\treturn categoriesList.map( ( category ) =>\n\t\t\trenderCategoryListItem( category )\n\t\t);\n\t};\n\n\tconst renderCategoryListItem = ( category ) => {\n\t\tconst childCategories = getCategoriesList( category.id );\n\t\tconst { id, link, count, name } = category;\n\t\treturn (\n\t\t\t<li key={ id } className={ `cat-item cat-item-${ id }` }>\n\t\t\t\t<a href={ link } onClick={ showRedirectionPreventedNotice }>\n\t\t\t\t\t{ renderCategoryName( name ) }\n\t\t\t\t</a>\n\t\t\t\t{ showPostCounts && ` (${ count })` }\n\t\t\t\t{ isHierarchicalTaxonomy &&\n\t\t\t\t\tshowHierarchy &&\n\t\t\t\t\t!! childCategories.length && (\n\t\t\t\t\t\t<ul className=\"children\">\n\t\t\t\t\t\t\t{ childCategories.map( ( childCategory ) =>\n\t\t\t\t\t\t\t\trenderCategoryListItem( childCategory )\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</ul>\n\t\t\t\t\t) }\n\t\t\t</li>\n\t\t);\n\t};\n\n\tconst renderCategoryDropdown = () => {\n\t\tconst parentId = isHierarchicalTaxonomy && showHierarchy ? 0 : null;\n\t\tconst categoriesList = getCategoriesList( parentId );\n\t\treturn (\n\t\t\t<>\n\t\t\t\t{ showLabel ? (\n\t\t\t\t\t<RichText\n\t\t\t\t\t\tclassName=\"wp-block-categories__label\"\n\t\t\t\t\t\taria-label={ __( 'Label text' ) }\n\t\t\t\t\t\tplaceholder={ taxonomy?.name }\n\t\t\t\t\t\twithoutInteractiveFormatting\n\t\t\t\t\t\tvalue={ label }\n\t\t\t\t\t\tonChange={ ( html ) =>\n\t\t\t\t\t\t\tsetAttributes( { label: html } )\n\t\t\t\t\t\t}\n\t\t\t\t\t/>\n\t\t\t\t) : (\n\t\t\t\t\t<VisuallyHidden as=\"label\" htmlFor={ selectId }>\n\t\t\t\t\t\t{ label ? label : taxonomy?.name }\n\t\t\t\t\t</VisuallyHidden>\n\t\t\t\t) }\n\t\t\t\t<select id={ selectId }>\n\t\t\t\t\t<option>\n\t\t\t\t\t\t{ sprintf(\n\t\t\t\t\t\t\t/* translators: %s: taxonomy's singular name */\n\t\t\t\t\t\t\t__( 'Select %s' ),\n\t\t\t\t\t\t\ttaxonomy?.labels?.singular_name\n\t\t\t\t\t\t) }\n\t\t\t\t\t</option>\n\t\t\t\t\t{ categoriesList.map( ( category ) =>\n\t\t\t\t\t\trenderCategoryDropdownItem( category, 0 )\n\t\t\t\t\t) }\n\t\t\t\t</select>\n\t\t\t</>\n\t\t);\n\t};\n\n\tconst renderCategoryDropdownItem = ( category, level ) => {\n\t\tconst { id, count, name } = category;\n\t\tconst childCategories = getCategoriesList( id );\n\t\treturn [\n\t\t\t<option key={ id } className={ `level-${ level }` }>\n\t\t\t\t{ Array.from( { length: level * 3 } ).map( () => '\\xa0' ) }\n\t\t\t\t{ renderCategoryName( name ) }\n\t\t\t\t{ showPostCounts && ` (${ count })` }\n\t\t\t</option>,\n\t\t\tisHierarchicalTaxonomy &&\n\t\t\t\tshowHierarchy &&\n\t\t\t\t!! childCategories.length &&\n\t\t\t\tchildCategories.map( ( childCategory ) =>\n\t\t\t\t\trenderCategoryDropdownItem( childCategory, level + 1 )\n\t\t\t\t),\n\t\t];\n\t};\n\n\tconst TagName =\n\t\t!! categories?.length && ! displayAsDropdown && ! isResolving\n\t\t\t? 'ul'\n\t\t\t: 'div';\n\n\tconst classes = clsx(\n\t\tclassName,\n\t\t`wp-block-categories-taxonomy-${ taxonomySlug }`,\n\t\t{\n\t\t\t'wp-block-categories-list':\n\t\t\t\t!! categories?.length && ! displayAsDropdown && ! isResolving,\n\t\t\t'wp-block-categories-dropdown':\n\t\t\t\t!! categories?.length && displayAsDropdown && ! isResolving,\n\t\t}\n\t);\n\n\tconst blockProps = useBlockProps( {\n\t\tclassName: classes,\n\t} );\n\tconst dropdownMenuProps = useToolsPanelDropdownMenuProps();\n\n\treturn (\n\t\t<TagName { ...blockProps }>\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\ttaxonomy: 'category',\n\t\t\t\t\t\t\tdisplayAsDropdown: false,\n\t\t\t\t\t\t\tshowHierarchy: false,\n\t\t\t\t\t\t\tshowPostCounts: false,\n\t\t\t\t\t\t\tshowOnlyTopLevel: false,\n\t\t\t\t\t\t\tshowEmpty: false,\n\t\t\t\t\t\t\tshowLabel: true,\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{ Array.isArray( taxonomies ) && (\n\t\t\t\t\t\t<ToolsPanelItem\n\t\t\t\t\t\t\thasValue={ () => {\n\t\t\t\t\t\t\t\treturn taxonomySlug !== 'category';\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\tlabel={ __( 'Taxonomy' ) }\n\t\t\t\t\t\t\tonDeselect={ () => {\n\t\t\t\t\t\t\t\tsetAttributes( { taxonomy: 'category' } );\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<SelectControl\n\t\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t\t\tlabel={ __( 'Taxonomy' ) }\n\t\t\t\t\t\t\t\toptions={ taxonomies.map( ( t ) => ( {\n\t\t\t\t\t\t\t\t\tlabel: t.name,\n\t\t\t\t\t\t\t\t\tvalue: t.slug,\n\t\t\t\t\t\t\t\t} ) ) }\n\t\t\t\t\t\t\t\tvalue={ taxonomySlug }\n\t\t\t\t\t\t\t\tonChange={ ( selectedTaxonomy ) =>\n\t\t\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\t\t\ttaxonomy: selectedTaxonomy,\n\t\t\t\t\t\t\t\t\t} )\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) }\n\t\t\t\t\t<ToolsPanelItem\n\t\t\t\t\t\thasValue={ () => !! displayAsDropdown }\n\t\t\t\t\t\tlabel={ __( 'Display as dropdown' ) }\n\t\t\t\t\t\tonDeselect={ () =>\n\t\t\t\t\t\t\tsetAttributes( { displayAsDropdown: false } )\n\t\t\t\t\t\t}\n\t\t\t\t\t\tisShownByDefault\n\t\t\t\t\t>\n\t\t\t\t\t\t<ToggleControl\n\t\t\t\t\t\t\tlabel={ __( 'Display as dropdown' ) }\n\t\t\t\t\t\t\tchecked={ displayAsDropdown }\n\t\t\t\t\t\t\tonChange={ toggleAttribute( 'displayAsDropdown' ) }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</ToolsPanelItem>\n\t\t\t\t\t{ displayAsDropdown && (\n\t\t\t\t\t\t<ToolsPanelItem\n\t\t\t\t\t\t\thasValue={ () => ! showLabel }\n\t\t\t\t\t\t\tlabel={ __( 'Show label' ) }\n\t\t\t\t\t\t\tonDeselect={ () =>\n\t\t\t\t\t\t\t\tsetAttributes( { showLabel: true } )\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<ToggleControl\n\t\t\t\t\t\t\t\tclassName=\"wp-block-categories__indentation\"\n\t\t\t\t\t\t\t\tlabel={ __( 'Show label' ) }\n\t\t\t\t\t\t\t\tchecked={ showLabel }\n\t\t\t\t\t\t\t\tonChange={ toggleAttribute( 'showLabel' ) }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</ToolsPanelItem>\n\t\t\t\t\t) }\n\t\t\t\t\t<ToolsPanelItem\n\t\t\t\t\t\thasValue={ () => !! showPostCounts }\n\t\t\t\t\t\tlabel={ __( 'Show post counts' ) }\n\t\t\t\t\t\tonDeselect={ () =>\n\t\t\t\t\t\t\tsetAttributes( { showPostCounts: false } )\n\t\t\t\t\t\t}\n\t\t\t\t\t\tisShownByDefault\n\t\t\t\t\t>\n\t\t\t\t\t\t<ToggleControl\n\t\t\t\t\t\t\tlabel={ __( 'Show post counts' ) }\n\t\t\t\t\t\t\tchecked={ showPostCounts }\n\t\t\t\t\t\t\tonChange={ toggleAttribute( 'showPostCounts' ) }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</ToolsPanelItem>\n\t\t\t\t\t{ isHierarchicalTaxonomy && (\n\t\t\t\t\t\t<ToolsPanelItem\n\t\t\t\t\t\t\thasValue={ () => !! showOnlyTopLevel }\n\t\t\t\t\t\t\tlabel={ __( 'Show only top level terms' ) }\n\t\t\t\t\t\t\tonDeselect={ () =>\n\t\t\t\t\t\t\t\tsetAttributes( { showOnlyTopLevel: false } )\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<ToggleControl\n\t\t\t\t\t\t\t\tlabel={ __( 'Show only top level terms' ) }\n\t\t\t\t\t\t\t\tchecked={ showOnlyTopLevel }\n\t\t\t\t\t\t\t\tonChange={ toggleAttribute(\n\t\t\t\t\t\t\t\t\t'showOnlyTopLevel'\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) }\n\t\t\t\t\t<ToolsPanelItem\n\t\t\t\t\t\thasValue={ () => !! showEmpty }\n\t\t\t\t\t\tlabel={ __( 'Show empty terms' ) }\n\t\t\t\t\t\tonDeselect={ () =>\n\t\t\t\t\t\t\tsetAttributes( { showEmpty: false } )\n\t\t\t\t\t\t}\n\t\t\t\t\t\tisShownByDefault\n\t\t\t\t\t>\n\t\t\t\t\t\t<ToggleControl\n\t\t\t\t\t\t\tlabel={ __( 'Show empty terms' ) }\n\t\t\t\t\t\t\tchecked={ showEmpty }\n\t\t\t\t\t\t\tonChange={ toggleAttribute( 'showEmpty' ) }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</ToolsPanelItem>\n\t\t\t\t\t{ isHierarchicalTaxonomy && ! showOnlyTopLevel && (\n\t\t\t\t\t\t<ToolsPanelItem\n\t\t\t\t\t\t\thasValue={ () => !! showHierarchy }\n\t\t\t\t\t\t\tlabel={ __( 'Show hierarchy' ) }\n\t\t\t\t\t\t\tonDeselect={ () =>\n\t\t\t\t\t\t\t\tsetAttributes( { showHierarchy: false } )\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<ToggleControl\n\t\t\t\t\t\t\t\tlabel={ __( 'Show hierarchy' ) }\n\t\t\t\t\t\t\t\tchecked={ showHierarchy }\n\t\t\t\t\t\t\t\tonChange={ toggleAttribute( 'showHierarchy' ) }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</ToolsPanelItem>\n\t\t\t\t\t) }\n\t\t\t\t</ToolsPanel>\n\t\t\t</InspectorControls>\n\t\t\t{ isResolving && (\n\t\t\t\t<Placeholder icon={ pin } label={ __( 'Terms' ) }>\n\t\t\t\t\t<Spinner />\n\t\t\t\t</Placeholder>\n\t\t\t) }\n\t\t\t{ ! isResolving && categories?.length === 0 && (\n\t\t\t\t<p>{ taxonomy.labels.no_terms }</p>\n\t\t\t) }\n\t\t\t{ ! isResolving &&\n\t\t\t\tcategories?.length > 0 &&\n\t\t\t\t( displayAsDropdown\n\t\t\t\t\t? renderCategoryDropdown()\n\t\t\t\t\t: renderCategoryList() ) }\n\t\t</TagName>\n\t);\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAAiB;AAKjB,
|
|
4
|
+
"sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tPlaceholder,\n\tSelectControl,\n\tSpinner,\n\tToggleControl,\n\t__experimentalToolsPanel as ToolsPanel,\n\t__experimentalToolsPanelItem as ToolsPanelItem,\n} from '@wordpress/components';\nimport { useInstanceId } from '@wordpress/compose';\nimport {\n\tInspectorControls,\n\tuseBlockProps,\n\tRichText,\n} from '@wordpress/block-editor';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { pin } from '@wordpress/icons';\nimport { useEntityRecords } from '@wordpress/core-data';\nimport { useDispatch } from '@wordpress/data';\nimport { VisuallyHidden } from '@wordpress/ui';\nimport { store as noticeStore } from '@wordpress/notices';\n\n/**\n * Internal dependencies\n */\nimport { useToolsPanelDropdownMenuProps } from '../utils/hooks';\n\nexport default function CategoriesEdit( {\n\tattributes: {\n\t\tdisplayAsDropdown,\n\t\tshowHierarchy,\n\t\tshowPostCounts,\n\t\tshowOnlyTopLevel,\n\t\tshowEmpty,\n\t\tlabel,\n\t\tshowLabel,\n\t\ttaxonomy: taxonomySlug,\n\t},\n\tsetAttributes,\n\tclassName,\n\tclientId,\n} ) {\n\tconst selectId = useInstanceId( CategoriesEdit, 'blocks-category-select' );\n\n\tconst { records: allTaxonomies, isResolvingTaxonomies } = useEntityRecords(\n\t\t'root',\n\t\t'taxonomy',\n\t\t{ per_page: -1 }\n\t);\n\n\tconst taxonomies = allTaxonomies?.filter( ( t ) => t.visibility.public );\n\n\tconst taxonomy = taxonomies?.find( ( t ) => t.slug === taxonomySlug );\n\n\tconst isHierarchicalTaxonomy =\n\t\t! isResolvingTaxonomies && taxonomy?.hierarchical;\n\n\tconst query = { per_page: -1, hide_empty: ! showEmpty, context: 'view' };\n\tif ( isHierarchicalTaxonomy && showOnlyTopLevel ) {\n\t\tquery.parent = 0;\n\t}\n\n\tconst { records: categories, isResolving } = useEntityRecords(\n\t\t'taxonomy',\n\t\ttaxonomySlug,\n\t\tquery\n\t);\n\n\tconst { createWarningNotice } = useDispatch( noticeStore );\n\tconst showRedirectionPreventedNotice = ( event ) => {\n\t\tevent.preventDefault();\n\t\tcreateWarningNotice( __( 'Links are disabled in the editor.' ), {\n\t\t\tid: `block-library/core/categories/redirection-prevented/${ clientId }`,\n\t\t\ttype: 'snackbar',\n\t\t} );\n\t};\n\n\tconst getCategoriesList = ( parentId ) => {\n\t\tif ( ! categories?.length ) {\n\t\t\treturn [];\n\t\t}\n\t\tif ( parentId === null ) {\n\t\t\treturn categories;\n\t\t}\n\t\treturn categories.filter( ( { parent } ) => parent === parentId );\n\t};\n\n\tconst toggleAttribute = ( attributeName ) => ( newValue ) =>\n\t\tsetAttributes( { [ attributeName ]: newValue } );\n\n\tconst renderCategoryName = ( name ) =>\n\t\t! name ? __( '(Untitled)' ) : decodeEntities( name ).trim();\n\n\tconst renderCategoryList = () => {\n\t\tconst parentId = isHierarchicalTaxonomy && showHierarchy ? 0 : null;\n\t\tconst categoriesList = getCategoriesList( parentId );\n\t\treturn categoriesList.map( ( category ) =>\n\t\t\trenderCategoryListItem( category )\n\t\t);\n\t};\n\n\tconst renderCategoryListItem = ( category ) => {\n\t\tconst childCategories = getCategoriesList( category.id );\n\t\tconst { id, link, count, name } = category;\n\t\treturn (\n\t\t\t<li key={ id } className={ `cat-item cat-item-${ id }` }>\n\t\t\t\t<a href={ link } onClick={ showRedirectionPreventedNotice }>\n\t\t\t\t\t{ renderCategoryName( name ) }\n\t\t\t\t</a>\n\t\t\t\t{ showPostCounts && ` (${ count })` }\n\t\t\t\t{ isHierarchicalTaxonomy &&\n\t\t\t\t\tshowHierarchy &&\n\t\t\t\t\t!! childCategories.length && (\n\t\t\t\t\t\t<ul className=\"children\">\n\t\t\t\t\t\t\t{ childCategories.map( ( childCategory ) =>\n\t\t\t\t\t\t\t\trenderCategoryListItem( childCategory )\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</ul>\n\t\t\t\t\t) }\n\t\t\t</li>\n\t\t);\n\t};\n\n\tconst renderCategoryDropdown = () => {\n\t\tconst parentId = isHierarchicalTaxonomy && showHierarchy ? 0 : null;\n\t\tconst categoriesList = getCategoriesList( parentId );\n\t\treturn (\n\t\t\t<>\n\t\t\t\t{ showLabel ? (\n\t\t\t\t\t<RichText\n\t\t\t\t\t\tclassName=\"wp-block-categories__label\"\n\t\t\t\t\t\taria-label={ __( 'Label text' ) }\n\t\t\t\t\t\tplaceholder={ taxonomy?.name }\n\t\t\t\t\t\twithoutInteractiveFormatting\n\t\t\t\t\t\tvalue={ label }\n\t\t\t\t\t\tonChange={ ( html ) =>\n\t\t\t\t\t\t\tsetAttributes( { label: html } )\n\t\t\t\t\t\t}\n\t\t\t\t\t/>\n\t\t\t\t) : (\n\t\t\t\t\t// eslint-disable-next-line jsx-a11y/label-has-associated-control\n\t\t\t\t\t<VisuallyHidden render={ <label htmlFor={ selectId } /> }>\n\t\t\t\t\t\t{ label ? label : taxonomy?.name }\n\t\t\t\t\t</VisuallyHidden>\n\t\t\t\t) }\n\t\t\t\t<select id={ selectId }>\n\t\t\t\t\t<option>\n\t\t\t\t\t\t{ sprintf(\n\t\t\t\t\t\t\t/* translators: %s: taxonomy's singular name */\n\t\t\t\t\t\t\t__( 'Select %s' ),\n\t\t\t\t\t\t\ttaxonomy?.labels?.singular_name\n\t\t\t\t\t\t) }\n\t\t\t\t\t</option>\n\t\t\t\t\t{ categoriesList.map( ( category ) =>\n\t\t\t\t\t\trenderCategoryDropdownItem( category, 0 )\n\t\t\t\t\t) }\n\t\t\t\t</select>\n\t\t\t</>\n\t\t);\n\t};\n\n\tconst renderCategoryDropdownItem = ( category, level ) => {\n\t\tconst { id, count, name } = category;\n\t\tconst childCategories = getCategoriesList( id );\n\t\treturn [\n\t\t\t<option key={ id } className={ `level-${ level }` }>\n\t\t\t\t{ Array.from( { length: level * 3 } ).map( () => '\\xa0' ) }\n\t\t\t\t{ renderCategoryName( name ) }\n\t\t\t\t{ showPostCounts && ` (${ count })` }\n\t\t\t</option>,\n\t\t\tisHierarchicalTaxonomy &&\n\t\t\t\tshowHierarchy &&\n\t\t\t\t!! childCategories.length &&\n\t\t\t\tchildCategories.map( ( childCategory ) =>\n\t\t\t\t\trenderCategoryDropdownItem( childCategory, level + 1 )\n\t\t\t\t),\n\t\t];\n\t};\n\n\tconst TagName =\n\t\t!! categories?.length && ! displayAsDropdown && ! isResolving\n\t\t\t? 'ul'\n\t\t\t: 'div';\n\n\tconst classes = clsx(\n\t\tclassName,\n\t\t`wp-block-categories-taxonomy-${ taxonomySlug }`,\n\t\t{\n\t\t\t'wp-block-categories-list':\n\t\t\t\t!! categories?.length && ! displayAsDropdown && ! isResolving,\n\t\t\t'wp-block-categories-dropdown':\n\t\t\t\t!! categories?.length && displayAsDropdown && ! isResolving,\n\t\t}\n\t);\n\n\tconst blockProps = useBlockProps( {\n\t\tclassName: classes,\n\t} );\n\tconst dropdownMenuProps = useToolsPanelDropdownMenuProps();\n\n\treturn (\n\t\t<TagName { ...blockProps }>\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\ttaxonomy: 'category',\n\t\t\t\t\t\t\tdisplayAsDropdown: false,\n\t\t\t\t\t\t\tshowHierarchy: false,\n\t\t\t\t\t\t\tshowPostCounts: false,\n\t\t\t\t\t\t\tshowOnlyTopLevel: false,\n\t\t\t\t\t\t\tshowEmpty: false,\n\t\t\t\t\t\t\tshowLabel: true,\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{ Array.isArray( taxonomies ) && (\n\t\t\t\t\t\t<ToolsPanelItem\n\t\t\t\t\t\t\thasValue={ () => {\n\t\t\t\t\t\t\t\treturn taxonomySlug !== 'category';\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\tlabel={ __( 'Taxonomy' ) }\n\t\t\t\t\t\t\tonDeselect={ () => {\n\t\t\t\t\t\t\t\tsetAttributes( { taxonomy: 'category' } );\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<SelectControl\n\t\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t\t\tlabel={ __( 'Taxonomy' ) }\n\t\t\t\t\t\t\t\toptions={ taxonomies.map( ( t ) => ( {\n\t\t\t\t\t\t\t\t\tlabel: t.name,\n\t\t\t\t\t\t\t\t\tvalue: t.slug,\n\t\t\t\t\t\t\t\t} ) ) }\n\t\t\t\t\t\t\t\tvalue={ taxonomySlug }\n\t\t\t\t\t\t\t\tonChange={ ( selectedTaxonomy ) =>\n\t\t\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\t\t\ttaxonomy: selectedTaxonomy,\n\t\t\t\t\t\t\t\t\t} )\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) }\n\t\t\t\t\t<ToolsPanelItem\n\t\t\t\t\t\thasValue={ () => !! displayAsDropdown }\n\t\t\t\t\t\tlabel={ __( 'Display as dropdown' ) }\n\t\t\t\t\t\tonDeselect={ () =>\n\t\t\t\t\t\t\tsetAttributes( { displayAsDropdown: false } )\n\t\t\t\t\t\t}\n\t\t\t\t\t\tisShownByDefault\n\t\t\t\t\t>\n\t\t\t\t\t\t<ToggleControl\n\t\t\t\t\t\t\tlabel={ __( 'Display as dropdown' ) }\n\t\t\t\t\t\t\tchecked={ displayAsDropdown }\n\t\t\t\t\t\t\tonChange={ toggleAttribute( 'displayAsDropdown' ) }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</ToolsPanelItem>\n\t\t\t\t\t{ displayAsDropdown && (\n\t\t\t\t\t\t<ToolsPanelItem\n\t\t\t\t\t\t\thasValue={ () => ! showLabel }\n\t\t\t\t\t\t\tlabel={ __( 'Show label' ) }\n\t\t\t\t\t\t\tonDeselect={ () =>\n\t\t\t\t\t\t\t\tsetAttributes( { showLabel: true } )\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<ToggleControl\n\t\t\t\t\t\t\t\tclassName=\"wp-block-categories__indentation\"\n\t\t\t\t\t\t\t\tlabel={ __( 'Show label' ) }\n\t\t\t\t\t\t\t\tchecked={ showLabel }\n\t\t\t\t\t\t\t\tonChange={ toggleAttribute( 'showLabel' ) }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</ToolsPanelItem>\n\t\t\t\t\t) }\n\t\t\t\t\t<ToolsPanelItem\n\t\t\t\t\t\thasValue={ () => !! showPostCounts }\n\t\t\t\t\t\tlabel={ __( 'Show post counts' ) }\n\t\t\t\t\t\tonDeselect={ () =>\n\t\t\t\t\t\t\tsetAttributes( { showPostCounts: false } )\n\t\t\t\t\t\t}\n\t\t\t\t\t\tisShownByDefault\n\t\t\t\t\t>\n\t\t\t\t\t\t<ToggleControl\n\t\t\t\t\t\t\tlabel={ __( 'Show post counts' ) }\n\t\t\t\t\t\t\tchecked={ showPostCounts }\n\t\t\t\t\t\t\tonChange={ toggleAttribute( 'showPostCounts' ) }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</ToolsPanelItem>\n\t\t\t\t\t{ isHierarchicalTaxonomy && (\n\t\t\t\t\t\t<ToolsPanelItem\n\t\t\t\t\t\t\thasValue={ () => !! showOnlyTopLevel }\n\t\t\t\t\t\t\tlabel={ __( 'Show only top level terms' ) }\n\t\t\t\t\t\t\tonDeselect={ () =>\n\t\t\t\t\t\t\t\tsetAttributes( { showOnlyTopLevel: false } )\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<ToggleControl\n\t\t\t\t\t\t\t\tlabel={ __( 'Show only top level terms' ) }\n\t\t\t\t\t\t\t\tchecked={ showOnlyTopLevel }\n\t\t\t\t\t\t\t\tonChange={ toggleAttribute(\n\t\t\t\t\t\t\t\t\t'showOnlyTopLevel'\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) }\n\t\t\t\t\t<ToolsPanelItem\n\t\t\t\t\t\thasValue={ () => !! showEmpty }\n\t\t\t\t\t\tlabel={ __( 'Show empty terms' ) }\n\t\t\t\t\t\tonDeselect={ () =>\n\t\t\t\t\t\t\tsetAttributes( { showEmpty: false } )\n\t\t\t\t\t\t}\n\t\t\t\t\t\tisShownByDefault\n\t\t\t\t\t>\n\t\t\t\t\t\t<ToggleControl\n\t\t\t\t\t\t\tlabel={ __( 'Show empty terms' ) }\n\t\t\t\t\t\t\tchecked={ showEmpty }\n\t\t\t\t\t\t\tonChange={ toggleAttribute( 'showEmpty' ) }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</ToolsPanelItem>\n\t\t\t\t\t{ isHierarchicalTaxonomy && ! showOnlyTopLevel && (\n\t\t\t\t\t\t<ToolsPanelItem\n\t\t\t\t\t\t\thasValue={ () => !! showHierarchy }\n\t\t\t\t\t\t\tlabel={ __( 'Show hierarchy' ) }\n\t\t\t\t\t\t\tonDeselect={ () =>\n\t\t\t\t\t\t\t\tsetAttributes( { showHierarchy: false } )\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<ToggleControl\n\t\t\t\t\t\t\t\tlabel={ __( 'Show hierarchy' ) }\n\t\t\t\t\t\t\t\tchecked={ showHierarchy }\n\t\t\t\t\t\t\t\tonChange={ toggleAttribute( 'showHierarchy' ) }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</ToolsPanelItem>\n\t\t\t\t\t) }\n\t\t\t\t</ToolsPanel>\n\t\t\t</InspectorControls>\n\t\t\t{ isResolving && (\n\t\t\t\t<Placeholder icon={ pin } label={ __( 'Terms' ) }>\n\t\t\t\t\t<Spinner />\n\t\t\t\t</Placeholder>\n\t\t\t) }\n\t\t\t{ ! isResolving && categories?.length === 0 && (\n\t\t\t\t<p>{ taxonomy.labels.no_terms }</p>\n\t\t\t) }\n\t\t\t{ ! isResolving &&\n\t\t\t\tcategories?.length > 0 &&\n\t\t\t\t( displayAsDropdown\n\t\t\t\t\t? renderCategoryDropdown()\n\t\t\t\t\t: renderCategoryList() ) }\n\t\t</TagName>\n\t);\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAAiB;AAKjB,wBAOO;AACP,qBAA8B;AAC9B,0BAIO;AACP,2BAA+B;AAC/B,kBAA4B;AAC5B,mBAAoB;AACpB,uBAAiC;AACjC,kBAA4B;AAC5B,gBAA+B;AAC/B,qBAAqC;AAKrC,mBAA+C;AAgF5C;AA9EY,SAAR,eAAiC;AAAA,EACvC,YAAY;AAAA,IACX;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,UAAU;AAAA,EACX;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACD,GAAI;AACH,QAAM,eAAW,8BAAe,gBAAgB,wBAAyB;AAEzE,QAAM,EAAE,SAAS,eAAe,sBAAsB,QAAI;AAAA,IACzD;AAAA,IACA;AAAA,IACA,EAAE,UAAU,GAAG;AAAA,EAChB;AAEA,QAAM,aAAa,eAAe,OAAQ,CAAE,MAAO,EAAE,WAAW,MAAO;AAEvE,QAAM,WAAW,YAAY,KAAM,CAAE,MAAO,EAAE,SAAS,YAAa;AAEpE,QAAM,yBACL,CAAE,yBAAyB,UAAU;AAEtC,QAAM,QAAQ,EAAE,UAAU,IAAI,YAAY,CAAE,WAAW,SAAS,OAAO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AAAA,IAE9B,CAAE,eACH,YAAY,SAAS,MACnB,oBACC,uBAAuB,IACvB,mBAAmB;AAAA,KACxB;AAEF;",
|
|
6
6
|
"names": ["noticeStore", "clsx", "ToolsPanel", "ToolsPanelItem"]
|
|
7
7
|
}
|
package/build/embed/edit.cjs
CHANGED
|
@@ -33,12 +33,6 @@ __export(edit_exports, {
|
|
|
33
33
|
default: () => edit_default
|
|
34
34
|
});
|
|
35
35
|
module.exports = __toCommonJS(edit_exports);
|
|
36
|
-
var import_util = require("./util.cjs");
|
|
37
|
-
var import_embed_controls = __toESM(require("./embed-controls.cjs"));
|
|
38
|
-
var import_icons = require("./icons.cjs");
|
|
39
|
-
var import_embed_loading = __toESM(require("./embed-loading.cjs"));
|
|
40
|
-
var import_embed_placeholder = __toESM(require("./embed-placeholder.cjs"));
|
|
41
|
-
var import_embed_preview = __toESM(require("./embed-preview.cjs"));
|
|
42
36
|
var import_clsx = __toESM(require("clsx"));
|
|
43
37
|
var import_i18n = require("@wordpress/i18n");
|
|
44
38
|
var import_element = require("@wordpress/element");
|
|
@@ -46,8 +40,13 @@ var import_data = require("@wordpress/data");
|
|
|
46
40
|
var import_block_editor = require("@wordpress/block-editor");
|
|
47
41
|
var import_core_data = require("@wordpress/core-data");
|
|
48
42
|
var import_primitives = require("@wordpress/primitives");
|
|
49
|
-
var import_url = require("@wordpress/url");
|
|
50
43
|
var import_caption = require("../utils/caption.cjs");
|
|
44
|
+
var import_util = require("./util.cjs");
|
|
45
|
+
var import_embed_controls = __toESM(require("./embed-controls.cjs"));
|
|
46
|
+
var import_icons = require("./icons.cjs");
|
|
47
|
+
var import_embed_loading = __toESM(require("./embed-loading.cjs"));
|
|
48
|
+
var import_embed_placeholder = __toESM(require("./embed-placeholder.cjs"));
|
|
49
|
+
var import_embed_preview = __toESM(require("./embed-preview.cjs"));
|
|
51
50
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
52
51
|
var EmbedEdit = (props) => {
|
|
53
52
|
const {
|
|
@@ -72,6 +71,7 @@ var EmbedEdit = (props) => {
|
|
|
72
71
|
const [url, setURL] = (0, import_element.useState)(attributesUrl);
|
|
73
72
|
const [isEditingURL, setIsEditingURL] = (0, import_element.useState)(false);
|
|
74
73
|
const { invalidateResolution } = (0, import_data.useDispatch)(import_core_data.store);
|
|
74
|
+
const { __unstableMarkNextChangeAsNotPersistent } = (0, import_data.useDispatch)(import_block_editor.store);
|
|
75
75
|
const {
|
|
76
76
|
preview,
|
|
77
77
|
fetching,
|
|
@@ -126,49 +126,47 @@ var EmbedEdit = (props) => {
|
|
|
126
126
|
});
|
|
127
127
|
}
|
|
128
128
|
(0, import_element.useEffect)(() => {
|
|
129
|
-
if (
|
|
129
|
+
if (!cannotEmbed || !hasResolved || !attributesUrl) {
|
|
130
130
|
return;
|
|
131
131
|
}
|
|
132
132
|
const newURL = attributesUrl.replace(/\/$/, "");
|
|
133
|
+
if (newURL === attributesUrl) {
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
133
136
|
setURL(newURL);
|
|
134
137
|
setIsEditingURL(false);
|
|
138
|
+
__unstableMarkNextChangeAsNotPersistent();
|
|
135
139
|
setAttributes({ url: newURL });
|
|
136
140
|
}, [
|
|
137
|
-
preview?.html,
|
|
138
141
|
attributesUrl,
|
|
139
142
|
cannotEmbed,
|
|
140
143
|
hasResolved,
|
|
141
|
-
setAttributes
|
|
144
|
+
setAttributes,
|
|
145
|
+
__unstableMarkNextChangeAsNotPersistent
|
|
142
146
|
]);
|
|
143
147
|
(0, import_element.useEffect)(() => {
|
|
144
|
-
if (!
|
|
148
|
+
if (!preview || isEditingURL) {
|
|
145
149
|
return;
|
|
146
150
|
}
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
}, [url, cannotEmbed, fetching, setAttributes]);
|
|
153
|
-
(0, import_element.useEffect)(() => {
|
|
154
|
-
if (preview && !isEditingURL) {
|
|
155
|
-
const mergedAttributes = getMergedAttributes();
|
|
156
|
-
const hasChanges = Object.keys(mergedAttributes).some(
|
|
157
|
-
(key) => mergedAttributes[key] !== attributes[key]
|
|
151
|
+
const mergedAttributes = getMergedAttributes();
|
|
152
|
+
if (onReplace) {
|
|
153
|
+
const upgradedBlock = (0, import_util.createUpgradedEmbedBlock)(
|
|
154
|
+
props,
|
|
155
|
+
mergedAttributes
|
|
158
156
|
);
|
|
159
|
-
if (
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
const upgradedBlock = (0, import_util.createUpgradedEmbedBlock)(
|
|
164
|
-
props,
|
|
165
|
-
mergedAttributes
|
|
166
|
-
);
|
|
167
|
-
if (upgradedBlock) {
|
|
168
|
-
onReplace(upgradedBlock);
|
|
169
|
-
}
|
|
157
|
+
if (upgradedBlock) {
|
|
158
|
+
__unstableMarkNextChangeAsNotPersistent();
|
|
159
|
+
setAttributes(upgradedBlock.attributes);
|
|
160
|
+
return;
|
|
170
161
|
}
|
|
171
162
|
}
|
|
163
|
+
const hasChanges = Object.keys(mergedAttributes).some(
|
|
164
|
+
(key) => mergedAttributes[key] !== attributes[key]
|
|
165
|
+
);
|
|
166
|
+
if (hasChanges) {
|
|
167
|
+
__unstableMarkNextChangeAsNotPersistent();
|
|
168
|
+
setAttributes(mergedAttributes);
|
|
169
|
+
}
|
|
172
170
|
}, [preview, isEditingURL]);
|
|
173
171
|
const blockProps = (0, import_block_editor.useBlockProps)();
|
|
174
172
|
if (fetching) {
|
|
@@ -187,11 +185,17 @@ var EmbedEdit = (props) => {
|
|
|
187
185
|
if (event) {
|
|
188
186
|
event.preventDefault();
|
|
189
187
|
}
|
|
188
|
+
const rewrittenURL = (0, import_util.rewriteXToTwitter)(url);
|
|
190
189
|
const blockClass = (0, import_util.removeAspectRatioClasses)(
|
|
191
190
|
attributes.className
|
|
192
191
|
);
|
|
192
|
+
setURL(rewrittenURL);
|
|
193
|
+
setAttributes({
|
|
194
|
+
url: rewrittenURL,
|
|
195
|
+
...(0, import_util.findMoreSuitableBlock)(rewrittenURL)?.attributes,
|
|
196
|
+
className: blockClass
|
|
197
|
+
});
|
|
193
198
|
setIsEditingURL(false);
|
|
194
|
-
setAttributes({ url, className: blockClass });
|
|
195
199
|
},
|
|
196
200
|
value: url,
|
|
197
201
|
cannotEmbed,
|
package/build/embed/edit.cjs.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/embed/edit.js"],
|
|
4
|
-
"sourcesContent": ["/**\n *
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,
|
|
6
|
-
"names": ["coreStore", "className", "EmbedLoading", "EmbedPlaceholder", "clsx", "EmbedControls", "EmbedPreview"]
|
|
4
|
+
"sourcesContent": ["/**\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 {\n\tuseBlockProps,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { View } from '@wordpress/primitives';\nimport { Caption } from '../utils/caption';\n\n/**\n * Internal dependencies\n */\nimport {\n\tcreateUpgradedEmbedBlock,\n\tfindMoreSuitableBlock,\n\tgetClassNames,\n\trewriteXToTwitter,\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\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\tconst { __unstableMarkNextChangeAsNotPersistent } =\n\t\tuseDispatch( blockEditorStore );\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\t// When the preview can't be embedded, retry without any trailing slash.\n\tuseEffect( () => {\n\t\tif ( ! cannotEmbed || ! hasResolved || ! attributesUrl ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst newURL = attributesUrl.replace( /\\/$/, '' );\n\t\tif ( newURL === attributesUrl ) {\n\t\t\treturn;\n\t\t}\n\n\t\tsetURL( newURL );\n\t\tsetIsEditingURL( false );\n\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\tsetAttributes( { url: newURL } );\n\t}, [\n\t\tattributesUrl,\n\t\tcannotEmbed,\n\t\thasResolved,\n\t\tsetAttributes,\n\t\t__unstableMarkNextChangeAsNotPersistent,\n\t] );\n\n\t// Apply preview-derived attributes once the preview resolves.\n\tuseEffect( () => {\n\t\tif ( ! preview || isEditingURL ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst mergedAttributes = getMergedAttributes();\n\n\t\tif ( onReplace ) {\n\t\t\tconst upgradedBlock = createUpgradedEmbedBlock(\n\t\t\t\tprops,\n\t\t\t\tmergedAttributes\n\t\t\t);\n\n\t\t\tif ( upgradedBlock ) {\n\t\t\t\t// Mutate via setAttributes; onReplace would remount the\n\t\t\t\t// block and clear the URL textbox on undo.\n\t\t\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\t\t\tsetAttributes( upgradedBlock.attributes );\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\n\t\tconst hasChanges = Object.keys( mergedAttributes ).some(\n\t\t\t( key ) => mergedAttributes[ key ] !== attributes[ key ]\n\t\t);\n\n\t\tif ( hasChanges ) {\n\t\t\t// Merge into the URL-submit undo level so a single undo\n\t\t\t// reverts both the submit and the preview-driven attributes.\n\t\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\t\tsetAttributes( mergedAttributes );\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\tconst rewrittenURL = rewriteXToTwitter( url );\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\tsetURL( rewrittenURL );\n\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\turl: rewrittenURL,\n\t\t\t\t\t\t\t...findMoreSuitableBlock( rewrittenURL )\n\t\t\t\t\t\t\t\t?.attributes,\n\t\t\t\t\t\t\tclassName: blockClass,\n\t\t\t\t\t\t} );\n\t\t\t\t\t\tsetIsEditingURL( false );\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"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAAiB;AAKjB,kBAAgC;AAChC,qBAAoC;AACpC,kBAAuC;AACvC,0BAGO;AACP,uBAAmC;AACnC,wBAAqB;AACrB,qBAAwB;AAKxB,kBASO;AACP,4BAA0B;AAC1B,mBAAiC;AACjC,2BAAyB;AACzB,+BAA6B;AAC7B,2BAAyB;AAsKrB;AApKJ,IA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AA,IACA;AAAA,MAAC;AAAA;AAAA,QACE,GAAG;AAAA,QACL,eAAY,YAAAD,SAAM,WAAW,WAAW,WAAW;AAAA,UAClD,CAAE,WAAY,IAAK,EAAG,GAAG;AAAA,UACzB,CAAE,eAAgB,gBAAiB,EAAG,GAAG;AAAA,UACzC,CAAE,kBAAmB,gBAAiB,EAAG,GACxC;AAAA,QACF,CAAE;AAAA,QAEF;AAAA;AAAA,YAAC,qBAAAE;AAAA,YAAA;AAAA,cACA;AAAA,cACA;AAAA,cACA;AAAA,cACA;AAAA,cACA;AAAA,cACA;AAAA,cACA,iBAAkB,CAAE,UACnB,cAAe,EAAE,SAAS,MAAM,CAAE;AAAA,cAEnC;AAAA,cACA;AAAA,cACA;AAAA,cACA;AAAA,cACA;AAAA,cACA;AAAA;AAAA,UACD;AAAA,UACA;AAAA,YAAC;AAAA;AAAA,cACA;AAAA,cACA;AAAA,cACA;AAAA,cACA;AAAA,cACA,WAAQ,gBAAI,oBAAqB;AAAA,cACjC,mBAAoB;AAAA;AAAA,UACrB;AAAA;AAAA;AAAA,IACD;AAAA,KACD;AAEF;AAEA,IAAO,eAAQ;",
|
|
6
|
+
"names": ["coreStore", "blockEditorStore", "className", "EmbedLoading", "EmbedPlaceholder", "clsx", "EmbedControls", "EmbedPreview"]
|
|
7
7
|
}
|
|
@@ -43,8 +43,10 @@ var transforms = {
|
|
|
43
43
|
type: "raw",
|
|
44
44
|
isMatch: (node) => node.nodeName === "P" && /^\s*(https?:\/\/\S+)\s*$/i.test(node.textContent) && node.textContent?.match(/https/gi)?.length === 1,
|
|
45
45
|
transform: (node) => {
|
|
46
|
+
const url = (0, import_util.rewriteXToTwitter)(node.textContent.trim());
|
|
46
47
|
return (0, import_blocks.createBlock)(EMBED_BLOCK, {
|
|
47
|
-
url
|
|
48
|
+
url,
|
|
49
|
+
...(0, import_util.findMoreSuitableBlock)(url)?.attributes
|
|
48
50
|
});
|
|
49
51
|
}
|
|
50
52
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/embed/transforms.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { createBlock } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport metadata from './block.json';\nimport {
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,oBAA4B;AAK5B,mBAAqB;AACrB,
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { createBlock } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport metadata from './block.json';\nimport {\n\tfindMoreSuitableBlock,\n\trewriteXToTwitter,\n\tremoveAspectRatioClasses,\n} from './util';\n\nconst { name: EMBED_BLOCK } = metadata;\n\n/**\n * Default transforms for generic embeds.\n */\nconst transforms = {\n\tfrom: [\n\t\t{\n\t\t\ttype: 'raw',\n\t\t\tisMatch: ( node ) =>\n\t\t\t\tnode.nodeName === 'P' &&\n\t\t\t\t/^\\s*(https?:\\/\\/\\S+)\\s*$/i.test( node.textContent ) &&\n\t\t\t\tnode.textContent?.match( /https/gi )?.length === 1,\n\t\t\ttransform: ( node ) => {\n\t\t\t\tconst url = rewriteXToTwitter( node.textContent.trim() );\n\t\t\t\treturn createBlock( EMBED_BLOCK, {\n\t\t\t\t\turl,\n\t\t\t\t\t...findMoreSuitableBlock( url )?.attributes,\n\t\t\t\t} );\n\t\t\t},\n\t\t},\n\t],\n\tto: [\n\t\t{\n\t\t\ttype: 'block',\n\t\t\tblocks: [ 'core/paragraph' ],\n\t\t\tisMatch: ( { url } ) => !! url,\n\t\t\ttransform: ( { url, caption, className } ) => {\n\t\t\t\tlet value = `<a href=\"${ url }\">${ url }</a>`;\n\t\t\t\tif ( caption?.trim() ) {\n\t\t\t\t\tvalue += `<br />${ caption }`;\n\t\t\t\t}\n\t\t\t\treturn createBlock( 'core/paragraph', {\n\t\t\t\t\tcontent: value,\n\t\t\t\t\tclassName: removeAspectRatioClasses( className ),\n\t\t\t\t} );\n\t\t\t},\n\t\t},\n\t],\n};\n\nexport default transforms;\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,oBAA4B;AAK5B,mBAAqB;AACrB,kBAIO;AAEP,IAAM,EAAE,MAAM,YAAY,IAAI,aAAAA;AAK9B,IAAM,aAAa;AAAA,EAClB,MAAM;AAAA,IACL;AAAA,MACC,MAAM;AAAA,MACN,SAAS,CAAE,SACV,KAAK,aAAa,OAClB,4BAA4B,KAAM,KAAK,WAAY,KACnD,KAAK,aAAa,MAAO,SAAU,GAAG,WAAW;AAAA,MAClD,WAAW,CAAE,SAAU;AACtB,cAAM,UAAM,+BAAmB,KAAK,YAAY,KAAK,CAAE;AACvD,mBAAO,2BAAa,aAAa;AAAA,UAChC;AAAA,UACA,OAAG,mCAAuB,GAAI,GAAG;AAAA,QAClC,CAAE;AAAA,MACH;AAAA,IACD;AAAA,EACD;AAAA,EACA,IAAI;AAAA,IACH;AAAA,MACC,MAAM;AAAA,MACN,QAAQ,CAAE,gBAAiB;AAAA,MAC3B,SAAS,CAAE,EAAE,IAAI,MAAO,CAAC,CAAE;AAAA,MAC3B,WAAW,CAAE,EAAE,KAAK,SAAS,UAAU,MAAO;AAC7C,YAAI,QAAQ,YAAa,GAAI,KAAM,GAAI;AACvC,YAAK,SAAS,KAAK,GAAI;AACtB,mBAAS,SAAU,OAAQ;AAAA,QAC5B;AACA,mBAAO,2BAAa,kBAAkB;AAAA,UACrC,SAAS;AAAA,UACT,eAAW,sCAA0B,SAAU;AAAA,QAChD,CAAE;AAAA,MACH;AAAA,IACD;AAAA,EACD;AACD;AAEA,IAAO,qBAAQ;",
|
|
6
6
|
"names": ["metadata"]
|
|
7
7
|
}
|
package/build/embed/util.cjs
CHANGED
|
@@ -42,7 +42,8 @@ __export(util_exports, {
|
|
|
42
42
|
hasInlineResponsivePadding: () => hasInlineResponsivePadding,
|
|
43
43
|
isFromWordPress: () => isFromWordPress,
|
|
44
44
|
matchesPatterns: () => matchesPatterns,
|
|
45
|
-
removeAspectRatioClasses: () => removeAspectRatioClasses
|
|
45
|
+
removeAspectRatioClasses: () => removeAspectRatioClasses,
|
|
46
|
+
rewriteXToTwitter: () => rewriteXToTwitter
|
|
46
47
|
});
|
|
47
48
|
module.exports = __toCommonJS(util_exports);
|
|
48
49
|
var import_clsx = __toESM(require("clsx"));
|
|
@@ -50,6 +51,7 @@ var import_memize = __toESM(require("memize"));
|
|
|
50
51
|
var import_components = require("@wordpress/components");
|
|
51
52
|
var import_element = require("@wordpress/element");
|
|
52
53
|
var import_blocks = require("@wordpress/blocks");
|
|
54
|
+
var import_url = require("@wordpress/url");
|
|
53
55
|
var import_block = __toESM(require("./block.json"));
|
|
54
56
|
var import_constants = require("./constants.cjs");
|
|
55
57
|
var import_lock_unlock = require("../lock-unlock.cjs");
|
|
@@ -63,6 +65,14 @@ var matchesPatterns = (url, patterns = []) => patterns.some((pattern) => url.mat
|
|
|
63
65
|
var findMoreSuitableBlock = (url) => (0, import_blocks.getBlockVariations)(DEFAULT_EMBED_BLOCK)?.find(
|
|
64
66
|
({ patterns }) => matchesPatterns(url, patterns)
|
|
65
67
|
);
|
|
68
|
+
function rewriteXToTwitter(url) {
|
|
69
|
+
if (!url || (0, import_url.getAuthority)(url) !== "x.com") {
|
|
70
|
+
return url;
|
|
71
|
+
}
|
|
72
|
+
const rewritten = new URL(url);
|
|
73
|
+
rewritten.host = "twitter.com";
|
|
74
|
+
return rewritten.toString();
|
|
75
|
+
}
|
|
66
76
|
var isFromWordPress = (html) => html && html.includes('class="wp-embedded-content"');
|
|
67
77
|
var getPhotoHtml = (photo) => {
|
|
68
78
|
const imageUrl = photo.url || photo.thumbnail_url;
|
|
@@ -224,6 +234,7 @@ var getMergedAttributesWithPreview = (currentAttributes, preview, title, isRespo
|
|
|
224
234
|
hasInlineResponsivePadding,
|
|
225
235
|
isFromWordPress,
|
|
226
236
|
matchesPatterns,
|
|
227
|
-
removeAspectRatioClasses
|
|
237
|
+
removeAspectRatioClasses,
|
|
238
|
+
rewriteXToTwitter
|
|
228
239
|
});
|
|
229
240
|
//# sourceMappingURL=util.cjs.map
|
package/build/embed/util.cjs.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/embed/util.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\nimport memoize from 'memize';\n\n/**\n * WordPress dependencies\n */\nimport { privateApis as componentsPrivateApis } from '@wordpress/components';\nimport { renderToString } from '@wordpress/element';\nimport {\n\tcreateBlock,\n\tgetBlockType,\n\tgetBlockVariations,\n} from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport metadata from './block.json';\nimport { ASPECT_RATIOS, WP_EMBED_TYPE } from './constants';\nimport { unlock } from '../lock-unlock';\n\nconst { name: DEFAULT_EMBED_BLOCK } = metadata;\nconst { kebabCase } = unlock( componentsPrivateApis );\n\n/** @typedef {import('@wordpress/blocks').WPBlockVariation} WPBlockVariation */\n\n/**\n * Returns the embed block's information by matching the provided service provider\n *\n * @param {string} provider The embed block's provider\n * @return {WPBlockVariation} The embed block's information\n */\nexport const getEmbedInfoByProvider = ( provider ) =>\n\tgetBlockVariations( DEFAULT_EMBED_BLOCK )?.find(\n\t\t( { name } ) => name === provider\n\t);\n\n/**\n * Returns true if any of the regular expressions match the URL.\n *\n * @param {string} url The URL to test.\n * @param {Array} patterns The list of regular expressions to test against.\n * @return {boolean} True if any of the regular expressions match the URL.\n */\nexport const matchesPatterns = ( url, patterns = [] ) =>\n\tpatterns.some( ( pattern ) => url.match( pattern ) );\n\n/**\n * Finds the block variation that should be used for the URL,\n * based on the provided URL and the variation's patterns.\n *\n * @param {string} url The URL to test.\n * @return {WPBlockVariation} The block variation that should be used for this URL\n */\nexport const findMoreSuitableBlock = ( url ) =>\n\tgetBlockVariations( DEFAULT_EMBED_BLOCK )?.find( ( { patterns } ) =>\n\t\tmatchesPatterns( url, patterns )\n\t);\n\nexport const isFromWordPress = ( html ) =>\n\thtml && html.includes( 'class=\"wp-embedded-content\"' );\n\nexport const getPhotoHtml = ( photo ) => {\n\t// If full image url not found use thumbnail.\n\tconst imageUrl = photo.url || photo.thumbnail_url;\n\n\t// 100% width for the preview so it fits nicely into the document, some \"thumbnails\" are\n\t// actually the full size photo.\n\tconst photoPreview = (\n\t\t<p>\n\t\t\t<img src={ imageUrl } alt={ photo.title } width=\"100%\" />\n\t\t</p>\n\t);\n\treturn renderToString( photoPreview );\n};\n\n/**\n * Creates a more suitable embed block based on the passed in props\n * and attributes generated from an embed block's preview.\n *\n * We require `attributesFromPreview` to be generated from the latest attributes\n * and preview, and because of the way the react lifecycle operates, we can't\n * guarantee that the attributes contained in the block's props are the latest\n * versions, so we require that these are generated separately.\n * See `getAttributesFromPreview` in the generated embed edit component.\n *\n * @param {Object} props The block's props.\n * @param {Object} [attributesFromPreview] Attributes generated from the block's most up to date preview.\n * @return {Object|undefined} A more suitable embed block if one exists.\n */\nexport const createUpgradedEmbedBlock = (\n\tprops,\n\tattributesFromPreview = {}\n) => {\n\tconst { preview, attributes = {} } = props;\n\tconst { url, providerNameSlug, type, ...restAttributes } = attributes;\n\n\tif ( ! url || ! getBlockType( DEFAULT_EMBED_BLOCK ) ) {\n\t\treturn;\n\t}\n\n\tconst matchedBlock = findMoreSuitableBlock( url );\n\n\t// WordPress blocks can work on multiple sites, and so don't have patterns,\n\t// so if we're in a WordPress block, assume the user has chosen it for a WordPress URL.\n\tconst isCurrentBlockWP =\n\t\tproviderNameSlug === 'wordpress' || type === WP_EMBED_TYPE;\n\t// If current block is not WordPress and a more suitable block found\n\t// that is different from the current one, create the new matched block.\n\tconst shouldCreateNewBlock =\n\t\t! isCurrentBlockWP &&\n\t\tmatchedBlock &&\n\t\t( matchedBlock.attributes.providerNameSlug !== providerNameSlug ||\n\t\t\t! providerNameSlug );\n\tif ( shouldCreateNewBlock ) {\n\t\treturn createBlock( DEFAULT_EMBED_BLOCK, {\n\t\t\turl,\n\t\t\t...restAttributes,\n\t\t\t...matchedBlock.attributes,\n\t\t} );\n\t}\n\n\tconst wpVariation = getBlockVariations( DEFAULT_EMBED_BLOCK )?.find(\n\t\t( { name } ) => name === 'wordpress'\n\t);\n\n\t// We can't match the URL for WordPress embeds, we have to check the HTML instead.\n\tif (\n\t\t! wpVariation ||\n\t\t! preview ||\n\t\t! isFromWordPress( preview.html ) ||\n\t\tisCurrentBlockWP\n\t) {\n\t\treturn;\n\t}\n\n\t// This is not the WordPress embed block so transform it into one.\n\treturn createBlock( DEFAULT_EMBED_BLOCK, {\n\t\turl,\n\t\t...wpVariation.attributes,\n\t\t// By now we have the preview, but when the new block first renders, it\n\t\t// won't have had all the attributes set, and so won't get the correct\n\t\t// type and it won't render correctly. So, we pass through the current attributes\n\t\t// here so that the initial render works when we switch to the WordPress\n\t\t// block. This only affects the WordPress block because it can't be\n\t\t// rendered in the usual Sandbox (it has a sandbox of its own) and it\n\t\t// relies on the preview to set the correct render type.\n\t\t...attributesFromPreview,\n\t} );\n};\n\n/**\n * Determine if the block already has an aspect ratio class applied.\n *\n * @param {string} existingClassNames Existing block classes.\n * @return {boolean} True or false if the classnames contain an aspect ratio class.\n */\nexport const hasAspectRatioClass = ( existingClassNames ) => {\n\tif ( ! existingClassNames ) {\n\t\treturn false;\n\t}\n\treturn ASPECT_RATIOS.some( ( { className } ) =>\n\t\texistingClassNames.includes( className )\n\t);\n};\n\n/**\n * Removes all previously set aspect ratio related classes and return the rest\n * existing class names.\n *\n * @param {string} existingClassNames Any existing class names.\n * @return {string} The class names without any aspect ratio related class.\n */\nexport const removeAspectRatioClasses = ( existingClassNames ) => {\n\tif ( ! existingClassNames ) {\n\t\t// Avoids extraneous work and also, by returning the same value as\n\t\t// received, ensures the post is not dirtied by a change of the block\n\t\t// attribute from `undefined` to an empty string.\n\t\treturn existingClassNames;\n\t}\n\tconst aspectRatioClassNames = ASPECT_RATIOS.reduce(\n\t\t( accumulator, { className } ) => {\n\t\t\taccumulator.push( className );\n\t\t\treturn accumulator;\n\t\t},\n\t\t[ 'wp-has-aspect-ratio' ]\n\t);\n\tlet outputClassNames = existingClassNames;\n\tfor ( const className of aspectRatioClassNames ) {\n\t\toutputClassNames = outputClassNames.replace( className, '' );\n\t}\n\treturn outputClassNames.trim();\n};\n\n/**\n * Checks if HTML already contains responsive aspect ratio styling.\n * Some embed providers (like Flickr) include their own responsive wrapper\n * with padding-bottom or padding-top percentages for aspect ratio.\n *\n * @param {string} html The embed HTML to check.\n * @return {boolean} True if the HTML already has responsive styling.\n */\nexport function hasInlineResponsivePadding( html ) {\n\t// Check for padding-bottom or padding-top with percentage values in style attributes\n\t// This pattern matches: padding-bottom: 56.25%; or padding-top: 50%; etc.\n\tconst paddingPattern = /padding-(top|bottom)\\s*:\\s*[\\d.]+%/i;\n\treturn paddingPattern.test( html );\n}\n\n/**\n * Returns class names with any relevant responsive aspect ratio names.\n *\n * @param {string} html The preview HTML that possibly contains an iframe with width and height set.\n * @param {string} existingClassNames Any existing class names.\n * @param {boolean} allowResponsive If the responsive class names should be added, or removed.\n * @return {string} Deduped class names.\n */\nexport function getClassNames(\n\thtml,\n\texistingClassNames,\n\tallowResponsive = true\n) {\n\tif ( ! allowResponsive ) {\n\t\treturn removeAspectRatioClasses( existingClassNames );\n\t}\n\n\t// If the embed HTML already contains responsive wrapper styling (like Flickr),\n\t// don't add our own aspect ratio classes to avoid double padding.\n\tif ( hasInlineResponsivePadding( html ) ) {\n\t\treturn removeAspectRatioClasses( existingClassNames );\n\t}\n\n\tconst previewDocument = document.implementation.createHTMLDocument( '' );\n\tpreviewDocument.body.innerHTML = html;\n\tconst iframe = previewDocument.body.querySelector( 'iframe' );\n\n\t// If we have a fixed aspect iframe, and it's a responsive embed block.\n\tif ( iframe && iframe.height && iframe.width ) {\n\t\tconst aspectRatio = ( iframe.width / iframe.height ).toFixed( 2 );\n\t\t// Given the actual aspect ratio, find the widest ratio to support it.\n\t\tfor (\n\t\t\tlet ratioIndex = 0;\n\t\t\tratioIndex < ASPECT_RATIOS.length;\n\t\t\tratioIndex++\n\t\t) {\n\t\t\tconst potentialRatio = ASPECT_RATIOS[ ratioIndex ];\n\t\t\tif ( aspectRatio >= potentialRatio.ratio ) {\n\t\t\t\t// Evaluate the difference between actual aspect ratio and closest match.\n\t\t\t\t// If the difference is too big, do not scale the embed according to aspect ratio.\n\t\t\t\tconst ratioDiff = aspectRatio - potentialRatio.ratio;\n\t\t\t\tif ( ratioDiff > 0.1 ) {\n\t\t\t\t\t// No close aspect ratio match found.\n\t\t\t\t\treturn removeAspectRatioClasses( existingClassNames );\n\t\t\t\t}\n\t\t\t\t// Close aspect ratio match found.\n\t\t\t\treturn clsx(\n\t\t\t\t\tremoveAspectRatioClasses( existingClassNames ),\n\t\t\t\t\tpotentialRatio.className,\n\t\t\t\t\t'wp-has-aspect-ratio'\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t}\n\n\treturn existingClassNames;\n}\n\n/**\n * Fallback behaviour for unembeddable URLs.\n * Creates a paragraph block containing a link to the URL, and calls `onReplace`.\n *\n * @param {string} url The URL that could not be embedded.\n * @param {Function} onReplace Function to call with the created fallback block.\n */\nexport function fallback( url, onReplace ) {\n\tconst link = <a href={ url }>{ url }</a>;\n\tonReplace(\n\t\tcreateBlock( 'core/paragraph', { content: renderToString( link ) } )\n\t);\n}\n\n/***\n * Gets block attributes based on the preview and responsive state.\n *\n * @param {Object} preview The preview data.\n * @param {string} title The block's title, e.g. Twitter.\n * @param {Object} currentClassNames The block's current class names.\n * @param {boolean} isResponsive Boolean indicating if the block supports responsive content.\n * @param {boolean} allowResponsive Apply responsive classes to fixed size content.\n * @return {Object} Attributes and values.\n */\nexport const getAttributesFromPreview = memoize(\n\t(\n\t\tpreview,\n\t\ttitle,\n\t\tcurrentClassNames,\n\t\tisResponsive,\n\t\tallowResponsive = true\n\t) => {\n\t\tif ( ! preview ) {\n\t\t\treturn {};\n\t\t}\n\n\t\tconst attributes = {};\n\t\t// Some plugins only return HTML with no type info, so default this to 'rich'.\n\t\tlet { type = 'rich' } = preview;\n\t\t// If we got a provider name from the API, use it for the slug, otherwise we use the title,\n\t\t// because not all embed code gives us a provider name.\n\t\tconst { html, provider_name: providerName } = preview;\n\t\tconst providerNameSlug = kebabCase(\n\t\t\t( providerName || title ).toLowerCase()\n\t\t);\n\n\t\tif ( isFromWordPress( html ) ) {\n\t\t\ttype = WP_EMBED_TYPE;\n\t\t}\n\n\t\tif ( html || 'photo' === type ) {\n\t\t\tattributes.type = type;\n\t\t\tattributes.providerNameSlug = providerNameSlug;\n\t\t}\n\n\t\t// Aspect ratio classes are removed when the embed URL is updated.\n\t\t// If the embed already has an aspect ratio class, that means the URL has not changed.\n\t\t// Which also means no need to regenerate it with getClassNames.\n\t\tif ( hasAspectRatioClass( currentClassNames ) ) {\n\t\t\treturn attributes;\n\t\t}\n\n\t\tattributes.className = getClassNames(\n\t\t\thtml,\n\t\t\tcurrentClassNames,\n\t\t\tisResponsive && allowResponsive\n\t\t);\n\n\t\treturn attributes;\n\t}\n);\n\n/**\n * Returns the attributes derived from the preview, merged with the current attributes.\n *\n * @param {Object} currentAttributes The current attributes of the block.\n * @param {Object} preview The preview data.\n * @param {string} title The block's title, e.g. Twitter.\n * @param {boolean} isResponsive Boolean indicating if the block supports responsive content.\n * @return {Object} Merged attributes.\n */\nexport const getMergedAttributesWithPreview = (\n\tcurrentAttributes,\n\tpreview,\n\ttitle,\n\tisResponsive\n) => {\n\tconst { allowResponsive, className } = currentAttributes;\n\n\treturn {\n\t\t...currentAttributes,\n\t\t...getAttributesFromPreview(\n\t\t\tpreview,\n\t\t\ttitle,\n\t\t\tclassName,\n\t\t\tisResponsive,\n\t\t\tallowResponsive\n\t\t),\n\t};\n};\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAAiB;AACjB,oBAAoB;AAKpB,wBAAqD;AACrD,qBAA+B;AAC/B,oBAIO;
|
|
4
|
+
"sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\nimport memoize from 'memize';\n\n/**\n * WordPress dependencies\n */\nimport { privateApis as componentsPrivateApis } from '@wordpress/components';\nimport { renderToString } from '@wordpress/element';\nimport {\n\tcreateBlock,\n\tgetBlockType,\n\tgetBlockVariations,\n} from '@wordpress/blocks';\nimport { getAuthority } from '@wordpress/url';\n\n/**\n * Internal dependencies\n */\nimport metadata from './block.json';\nimport { ASPECT_RATIOS, WP_EMBED_TYPE } from './constants';\nimport { unlock } from '../lock-unlock';\n\nconst { name: DEFAULT_EMBED_BLOCK } = metadata;\nconst { kebabCase } = unlock( componentsPrivateApis );\n\n/** @typedef {import('@wordpress/blocks').WPBlockVariation} WPBlockVariation */\n\n/**\n * Returns the embed block's information by matching the provided service provider\n *\n * @param {string} provider The embed block's provider\n * @return {WPBlockVariation} The embed block's information\n */\nexport const getEmbedInfoByProvider = ( provider ) =>\n\tgetBlockVariations( DEFAULT_EMBED_BLOCK )?.find(\n\t\t( { name } ) => name === provider\n\t);\n\n/**\n * Returns true if any of the regular expressions match the URL.\n *\n * @param {string} url The URL to test.\n * @param {Array} patterns The list of regular expressions to test against.\n * @return {boolean} True if any of the regular expressions match the URL.\n */\nexport const matchesPatterns = ( url, patterns = [] ) =>\n\tpatterns.some( ( pattern ) => url.match( pattern ) );\n\n/**\n * Finds the block variation that should be used for the URL,\n * based on the provided URL and the variation's patterns.\n *\n * @param {string} url The URL to test.\n * @return {WPBlockVariation} The block variation that should be used for this URL\n */\nexport const findMoreSuitableBlock = ( url ) =>\n\tgetBlockVariations( DEFAULT_EMBED_BLOCK )?.find( ( { patterns } ) =>\n\t\tmatchesPatterns( url, patterns )\n\t);\n\n/**\n * Rewrites `x.com` URLs to `twitter.com` as a workaround while the\n * WordPress oEmbed registry lacks an X provider. See: https://core.trac.wordpress.org/ticket/59142.\n *\n * @param {string} url The URL to rewrite.\n * @return {string} The (possibly) rewritten URL.\n */\nexport function rewriteXToTwitter( url ) {\n\tif ( ! url || getAuthority( url ) !== 'x.com' ) {\n\t\treturn url;\n\t}\n\tconst rewritten = new URL( url );\n\trewritten.host = 'twitter.com';\n\treturn rewritten.toString();\n}\n\nexport const isFromWordPress = ( html ) =>\n\thtml && html.includes( 'class=\"wp-embedded-content\"' );\n\nexport const getPhotoHtml = ( photo ) => {\n\t// If full image url not found use thumbnail.\n\tconst imageUrl = photo.url || photo.thumbnail_url;\n\n\t// 100% width for the preview so it fits nicely into the document, some \"thumbnails\" are\n\t// actually the full size photo.\n\tconst photoPreview = (\n\t\t<p>\n\t\t\t<img src={ imageUrl } alt={ photo.title } width=\"100%\" />\n\t\t</p>\n\t);\n\treturn renderToString( photoPreview );\n};\n\n/**\n * Creates a more suitable embed block based on the passed in props\n * and attributes generated from an embed block's preview.\n *\n * We require `attributesFromPreview` to be generated from the latest attributes\n * and preview, and because of the way the react lifecycle operates, we can't\n * guarantee that the attributes contained in the block's props are the latest\n * versions, so we require that these are generated separately.\n * See `getAttributesFromPreview` in the generated embed edit component.\n *\n * @param {Object} props The block's props.\n * @param {Object} [attributesFromPreview] Attributes generated from the block's most up to date preview.\n * @return {Object|undefined} A more suitable embed block if one exists.\n */\nexport const createUpgradedEmbedBlock = (\n\tprops,\n\tattributesFromPreview = {}\n) => {\n\tconst { preview, attributes = {} } = props;\n\tconst { url, providerNameSlug, type, ...restAttributes } = attributes;\n\n\tif ( ! url || ! getBlockType( DEFAULT_EMBED_BLOCK ) ) {\n\t\treturn;\n\t}\n\n\tconst matchedBlock = findMoreSuitableBlock( url );\n\n\t// WordPress blocks can work on multiple sites, and so don't have patterns,\n\t// so if we're in a WordPress block, assume the user has chosen it for a WordPress URL.\n\tconst isCurrentBlockWP =\n\t\tproviderNameSlug === 'wordpress' || type === WP_EMBED_TYPE;\n\t// If current block is not WordPress and a more suitable block found\n\t// that is different from the current one, create the new matched block.\n\tconst shouldCreateNewBlock =\n\t\t! isCurrentBlockWP &&\n\t\tmatchedBlock &&\n\t\t( matchedBlock.attributes.providerNameSlug !== providerNameSlug ||\n\t\t\t! providerNameSlug );\n\tif ( shouldCreateNewBlock ) {\n\t\treturn createBlock( DEFAULT_EMBED_BLOCK, {\n\t\t\turl,\n\t\t\t...restAttributes,\n\t\t\t...matchedBlock.attributes,\n\t\t} );\n\t}\n\n\tconst wpVariation = getBlockVariations( DEFAULT_EMBED_BLOCK )?.find(\n\t\t( { name } ) => name === 'wordpress'\n\t);\n\n\t// We can't match the URL for WordPress embeds, we have to check the HTML instead.\n\tif (\n\t\t! wpVariation ||\n\t\t! preview ||\n\t\t! isFromWordPress( preview.html ) ||\n\t\tisCurrentBlockWP\n\t) {\n\t\treturn;\n\t}\n\n\t// This is not the WordPress embed block so transform it into one.\n\treturn createBlock( DEFAULT_EMBED_BLOCK, {\n\t\turl,\n\t\t...wpVariation.attributes,\n\t\t// By now we have the preview, but when the new block first renders, it\n\t\t// won't have had all the attributes set, and so won't get the correct\n\t\t// type and it won't render correctly. So, we pass through the current attributes\n\t\t// here so that the initial render works when we switch to the WordPress\n\t\t// block. This only affects the WordPress block because it can't be\n\t\t// rendered in the usual Sandbox (it has a sandbox of its own) and it\n\t\t// relies on the preview to set the correct render type.\n\t\t...attributesFromPreview,\n\t} );\n};\n\n/**\n * Determine if the block already has an aspect ratio class applied.\n *\n * @param {string} existingClassNames Existing block classes.\n * @return {boolean} True or false if the classnames contain an aspect ratio class.\n */\nexport const hasAspectRatioClass = ( existingClassNames ) => {\n\tif ( ! existingClassNames ) {\n\t\treturn false;\n\t}\n\treturn ASPECT_RATIOS.some( ( { className } ) =>\n\t\texistingClassNames.includes( className )\n\t);\n};\n\n/**\n * Removes all previously set aspect ratio related classes and return the rest\n * existing class names.\n *\n * @param {string} existingClassNames Any existing class names.\n * @return {string} The class names without any aspect ratio related class.\n */\nexport const removeAspectRatioClasses = ( existingClassNames ) => {\n\tif ( ! existingClassNames ) {\n\t\t// Avoids extraneous work and also, by returning the same value as\n\t\t// received, ensures the post is not dirtied by a change of the block\n\t\t// attribute from `undefined` to an empty string.\n\t\treturn existingClassNames;\n\t}\n\tconst aspectRatioClassNames = ASPECT_RATIOS.reduce(\n\t\t( accumulator, { className } ) => {\n\t\t\taccumulator.push( className );\n\t\t\treturn accumulator;\n\t\t},\n\t\t[ 'wp-has-aspect-ratio' ]\n\t);\n\tlet outputClassNames = existingClassNames;\n\tfor ( const className of aspectRatioClassNames ) {\n\t\toutputClassNames = outputClassNames.replace( className, '' );\n\t}\n\treturn outputClassNames.trim();\n};\n\n/**\n * Checks if HTML already contains responsive aspect ratio styling.\n * Some embed providers (like Flickr) include their own responsive wrapper\n * with padding-bottom or padding-top percentages for aspect ratio.\n *\n * @param {string} html The embed HTML to check.\n * @return {boolean} True if the HTML already has responsive styling.\n */\nexport function hasInlineResponsivePadding( html ) {\n\t// Check for padding-bottom or padding-top with percentage values in style attributes\n\t// This pattern matches: padding-bottom: 56.25%; or padding-top: 50%; etc.\n\tconst paddingPattern = /padding-(top|bottom)\\s*:\\s*[\\d.]+%/i;\n\treturn paddingPattern.test( html );\n}\n\n/**\n * Returns class names with any relevant responsive aspect ratio names.\n *\n * @param {string} html The preview HTML that possibly contains an iframe with width and height set.\n * @param {string} existingClassNames Any existing class names.\n * @param {boolean} allowResponsive If the responsive class names should be added, or removed.\n * @return {string} Deduped class names.\n */\nexport function getClassNames(\n\thtml,\n\texistingClassNames,\n\tallowResponsive = true\n) {\n\tif ( ! allowResponsive ) {\n\t\treturn removeAspectRatioClasses( existingClassNames );\n\t}\n\n\t// If the embed HTML already contains responsive wrapper styling (like Flickr),\n\t// don't add our own aspect ratio classes to avoid double padding.\n\tif ( hasInlineResponsivePadding( html ) ) {\n\t\treturn removeAspectRatioClasses( existingClassNames );\n\t}\n\n\tconst previewDocument = document.implementation.createHTMLDocument( '' );\n\tpreviewDocument.body.innerHTML = html;\n\tconst iframe = previewDocument.body.querySelector( 'iframe' );\n\n\t// If we have a fixed aspect iframe, and it's a responsive embed block.\n\tif ( iframe && iframe.height && iframe.width ) {\n\t\tconst aspectRatio = ( iframe.width / iframe.height ).toFixed( 2 );\n\t\t// Given the actual aspect ratio, find the widest ratio to support it.\n\t\tfor (\n\t\t\tlet ratioIndex = 0;\n\t\t\tratioIndex < ASPECT_RATIOS.length;\n\t\t\tratioIndex++\n\t\t) {\n\t\t\tconst potentialRatio = ASPECT_RATIOS[ ratioIndex ];\n\t\t\tif ( aspectRatio >= potentialRatio.ratio ) {\n\t\t\t\t// Evaluate the difference between actual aspect ratio and closest match.\n\t\t\t\t// If the difference is too big, do not scale the embed according to aspect ratio.\n\t\t\t\tconst ratioDiff = aspectRatio - potentialRatio.ratio;\n\t\t\t\tif ( ratioDiff > 0.1 ) {\n\t\t\t\t\t// No close aspect ratio match found.\n\t\t\t\t\treturn removeAspectRatioClasses( existingClassNames );\n\t\t\t\t}\n\t\t\t\t// Close aspect ratio match found.\n\t\t\t\treturn clsx(\n\t\t\t\t\tremoveAspectRatioClasses( existingClassNames ),\n\t\t\t\t\tpotentialRatio.className,\n\t\t\t\t\t'wp-has-aspect-ratio'\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t}\n\n\treturn existingClassNames;\n}\n\n/**\n * Fallback behaviour for unembeddable URLs.\n * Creates a paragraph block containing a link to the URL, and calls `onReplace`.\n *\n * @param {string} url The URL that could not be embedded.\n * @param {Function} onReplace Function to call with the created fallback block.\n */\nexport function fallback( url, onReplace ) {\n\tconst link = <a href={ url }>{ url }</a>;\n\tonReplace(\n\t\tcreateBlock( 'core/paragraph', { content: renderToString( link ) } )\n\t);\n}\n\n/***\n * Gets block attributes based on the preview and responsive state.\n *\n * @param {Object} preview The preview data.\n * @param {string} title The block's title, e.g. Twitter.\n * @param {Object} currentClassNames The block's current class names.\n * @param {boolean} isResponsive Boolean indicating if the block supports responsive content.\n * @param {boolean} allowResponsive Apply responsive classes to fixed size content.\n * @return {Object} Attributes and values.\n */\nexport const getAttributesFromPreview = memoize(\n\t(\n\t\tpreview,\n\t\ttitle,\n\t\tcurrentClassNames,\n\t\tisResponsive,\n\t\tallowResponsive = true\n\t) => {\n\t\tif ( ! preview ) {\n\t\t\treturn {};\n\t\t}\n\n\t\tconst attributes = {};\n\t\t// Some plugins only return HTML with no type info, so default this to 'rich'.\n\t\tlet { type = 'rich' } = preview;\n\t\t// If we got a provider name from the API, use it for the slug, otherwise we use the title,\n\t\t// because not all embed code gives us a provider name.\n\t\tconst { html, provider_name: providerName } = preview;\n\t\tconst providerNameSlug = kebabCase(\n\t\t\t( providerName || title ).toLowerCase()\n\t\t);\n\n\t\tif ( isFromWordPress( html ) ) {\n\t\t\ttype = WP_EMBED_TYPE;\n\t\t}\n\n\t\tif ( html || 'photo' === type ) {\n\t\t\tattributes.type = type;\n\t\t\tattributes.providerNameSlug = providerNameSlug;\n\t\t}\n\n\t\t// Aspect ratio classes are removed when the embed URL is updated.\n\t\t// If the embed already has an aspect ratio class, that means the URL has not changed.\n\t\t// Which also means no need to regenerate it with getClassNames.\n\t\tif ( hasAspectRatioClass( currentClassNames ) ) {\n\t\t\treturn attributes;\n\t\t}\n\n\t\tattributes.className = getClassNames(\n\t\t\thtml,\n\t\t\tcurrentClassNames,\n\t\t\tisResponsive && allowResponsive\n\t\t);\n\n\t\treturn attributes;\n\t}\n);\n\n/**\n * Returns the attributes derived from the preview, merged with the current attributes.\n *\n * @param {Object} currentAttributes The current attributes of the block.\n * @param {Object} preview The preview data.\n * @param {string} title The block's title, e.g. Twitter.\n * @param {boolean} isResponsive Boolean indicating if the block supports responsive content.\n * @return {Object} Merged attributes.\n */\nexport const getMergedAttributesWithPreview = (\n\tcurrentAttributes,\n\tpreview,\n\ttitle,\n\tisResponsive\n) => {\n\tconst { allowResponsive, className } = currentAttributes;\n\n\treturn {\n\t\t...currentAttributes,\n\t\t...getAttributesFromPreview(\n\t\t\tpreview,\n\t\t\ttitle,\n\t\t\tclassName,\n\t\t\tisResponsive,\n\t\t\tallowResponsive\n\t\t),\n\t};\n};\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAAiB;AACjB,oBAAoB;AAKpB,wBAAqD;AACrD,qBAA+B;AAC/B,oBAIO;AACP,iBAA6B;AAK7B,mBAAqB;AACrB,uBAA6C;AAC7C,yBAAuB;AAmEpB;AAjEH,IAAM,EAAE,MAAM,oBAAoB,IAAI,aAAAA;AACtC,IAAM,EAAE,UAAU,QAAI,2BAAQ,kBAAAC,WAAsB;AAU7C,IAAM,yBAAyB,CAAE,iBACvC,kCAAoB,mBAAoB,GAAG;AAAA,EAC1C,CAAE,EAAE,KAAK,MAAO,SAAS;AAC1B;AASM,IAAM,kBAAkB,CAAE,KAAK,WAAW,CAAC,MACjD,SAAS,KAAM,CAAE,YAAa,IAAI,MAAO,OAAQ,CAAE;AAS7C,IAAM,wBAAwB,CAAE,YACtC,kCAAoB,mBAAoB,GAAG;AAAA,EAAM,CAAE,EAAE,SAAS,MAC7D,gBAAiB,KAAK,QAAS;AAChC;AASM,SAAS,kBAAmB,KAAM;AACxC,MAAK,CAAE,WAAO,yBAAc,GAAI,MAAM,SAAU;AAC/C,WAAO;AAAA,EACR;AACA,QAAM,YAAY,IAAI,IAAK,GAAI;AAC/B,YAAU,OAAO;AACjB,SAAO,UAAU,SAAS;AAC3B;AAEO,IAAM,kBAAkB,CAAE,SAChC,QAAQ,KAAK,SAAU,6BAA8B;AAE/C,IAAM,eAAe,CAAE,UAAW;AAExC,QAAM,WAAW,MAAM,OAA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