@wordpress/block-editor 15.8.1-next.dc3f6d3c1.0 → 15.9.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/components/block-list/index.js +2 -1
- package/build/components/block-list/index.js.map +2 -2
- package/build/components/block-list/use-block-props/use-selected-block-event-handlers.js +27 -5
- package/build/components/block-list/use-block-props/use-selected-block-event-handlers.js.map +2 -2
- package/build/components/block-lock/modal.js +5 -5
- package/build/components/block-lock/modal.js.map +2 -2
- package/build/components/block-lock/use-block-lock.js +10 -13
- package/build/components/block-lock/use-block-lock.js.map +2 -2
- package/build/components/block-settings-menu-controls/index.js +1 -1
- package/build/components/block-settings-menu-controls/index.js.map +2 -2
- package/build/components/block-tools/index.js +56 -45
- package/build/components/block-tools/index.js.map +3 -3
- package/build/components/block-visibility/toolbar.js +1 -1
- package/build/components/block-visibility/toolbar.js.map +1 -1
- package/build/components/content-only-controls/fields-dropdown-menu.js +66 -0
- package/build/components/content-only-controls/fields-dropdown-menu.js.map +7 -0
- package/build/components/content-only-controls/index.js +225 -44
- package/build/components/content-only-controls/index.js.map +3 -3
- package/build/components/content-only-controls/link/index.js +92 -103
- package/build/components/content-only-controls/link/index.js.map +3 -3
- package/build/components/content-only-controls/media/index.js +134 -134
- package/build/components/content-only-controls/media/index.js.map +3 -3
- package/build/components/content-only-controls/rich-text/index.js +65 -74
- package/build/components/content-only-controls/rich-text/index.js.map +3 -3
- package/build/components/font-family/index.js +1 -15
- package/build/components/font-family/index.js.map +2 -2
- package/build/components/global-styles/dimensions-panel.js +35 -2
- package/build/components/global-styles/dimensions-panel.js.map +2 -2
- package/build/components/global-styles/hooks.js +1 -1
- package/build/components/global-styles/hooks.js.map +2 -2
- package/build/components/global-styles/typography-panel.js +1 -2
- package/build/components/global-styles/typography-panel.js.map +2 -2
- package/build/components/inspector-controls-tabs/use-inspector-controls-tabs.js +1 -1
- package/build/components/inspector-controls-tabs/use-inspector-controls-tabs.js.map +2 -2
- package/build/components/link-control/index.js +15 -7
- package/build/components/link-control/index.js.map +2 -2
- package/build/components/list-view/block-select-button.js +3 -11
- package/build/components/list-view/block-select-button.js.map +2 -2
- package/build/components/list-view/block.js +9 -7
- package/build/components/list-view/block.js.map +2 -2
- package/build/components/media-placeholder/index.js +17 -4
- package/build/components/media-placeholder/index.js.map +2 -2
- package/build/components/media-placeholder/utils.js +60 -0
- package/build/components/media-placeholder/utils.js.map +7 -0
- package/build/components/media-replace-flow/index.js +20 -3
- package/build/components/media-replace-flow/index.js.map +2 -2
- package/build/components/use-block-commands/index.js +1 -1
- package/build/components/use-block-commands/index.js.map +2 -2
- package/build/components/use-block-drop-zone/index.js +1 -5
- package/build/components/use-block-drop-zone/index.js.map +2 -2
- package/build/hooks/dimensions.js +3 -3
- package/build/hooks/dimensions.js.map +2 -2
- package/build/hooks/metadata.js +1 -1
- package/build/hooks/metadata.js.map +2 -2
- package/build/hooks/utils.js +5 -1
- package/build/hooks/utils.js.map +2 -2
- package/build/store/private-selectors.js +43 -3
- package/build/store/private-selectors.js.map +2 -2
- package/build/store/reducer.js +2 -1
- package/build/store/reducer.js.map +2 -2
- package/build/store/selectors.js +6 -4
- package/build/store/selectors.js.map +2 -2
- package/build-module/components/block-list/index.js +2 -1
- package/build-module/components/block-list/index.js.map +2 -2
- package/build-module/components/block-list/use-block-props/use-selected-block-event-handlers.js +27 -5
- package/build-module/components/block-list/use-block-props/use-selected-block-event-handlers.js.map +2 -2
- package/build-module/components/block-lock/modal.js +5 -5
- package/build-module/components/block-lock/modal.js.map +2 -2
- package/build-module/components/block-lock/use-block-lock.js +10 -13
- package/build-module/components/block-lock/use-block-lock.js.map +2 -2
- package/build-module/components/block-settings-menu-controls/index.js +1 -1
- package/build-module/components/block-settings-menu-controls/index.js.map +2 -2
- package/build-module/components/block-tools/index.js +56 -45
- package/build-module/components/block-tools/index.js.map +2 -2
- package/build-module/components/block-visibility/toolbar.js +1 -1
- package/build-module/components/block-visibility/toolbar.js.map +1 -1
- package/build-module/components/content-only-controls/fields-dropdown-menu.js +45 -0
- package/build-module/components/content-only-controls/fields-dropdown-menu.js.map +7 -0
- package/build-module/components/content-only-controls/index.js +229 -46
- package/build-module/components/content-only-controls/index.js.map +2 -2
- package/build-module/components/content-only-controls/link/index.js +92 -104
- package/build-module/components/content-only-controls/link/index.js.map +2 -2
- package/build-module/components/content-only-controls/media/index.js +134 -135
- package/build-module/components/content-only-controls/media/index.js.map +2 -2
- package/build-module/components/content-only-controls/rich-text/index.js +67 -81
- package/build-module/components/content-only-controls/rich-text/index.js.map +2 -2
- package/build-module/components/font-family/index.js +1 -15
- package/build-module/components/font-family/index.js.map +2 -2
- package/build-module/components/global-styles/dimensions-panel.js +35 -2
- package/build-module/components/global-styles/dimensions-panel.js.map +2 -2
- package/build-module/components/global-styles/hooks.js +1 -1
- package/build-module/components/global-styles/hooks.js.map +2 -2
- package/build-module/components/global-styles/typography-panel.js +1 -2
- package/build-module/components/global-styles/typography-panel.js.map +2 -2
- package/build-module/components/inspector-controls-tabs/use-inspector-controls-tabs.js +1 -1
- package/build-module/components/inspector-controls-tabs/use-inspector-controls-tabs.js.map +2 -2
- package/build-module/components/link-control/index.js +16 -8
- package/build-module/components/link-control/index.js.map +2 -2
- package/build-module/components/list-view/block-select-button.js +3 -11
- package/build-module/components/list-view/block-select-button.js.map +2 -2
- package/build-module/components/list-view/block.js +9 -7
- package/build-module/components/list-view/block.js.map +2 -2
- package/build-module/components/media-placeholder/index.js +18 -5
- package/build-module/components/media-placeholder/index.js.map +2 -2
- package/build-module/components/media-placeholder/utils.js +35 -0
- package/build-module/components/media-placeholder/utils.js.map +7 -0
- package/build-module/components/media-replace-flow/index.js +20 -3
- package/build-module/components/media-replace-flow/index.js.map +2 -2
- package/build-module/components/use-block-commands/index.js +1 -1
- package/build-module/components/use-block-commands/index.js.map +2 -2
- package/build-module/components/use-block-drop-zone/index.js +1 -5
- package/build-module/components/use-block-drop-zone/index.js.map +2 -2
- package/build-module/hooks/dimensions.js +3 -3
- package/build-module/hooks/dimensions.js.map +2 -2
- package/build-module/hooks/metadata.js +1 -1
- package/build-module/hooks/metadata.js.map +2 -2
- package/build-module/hooks/utils.js +5 -1
- package/build-module/hooks/utils.js.map +2 -2
- package/build-module/store/private-selectors.js +39 -3
- package/build-module/store/private-selectors.js.map +2 -2
- package/build-module/store/reducer.js +2 -1
- package/build-module/store/reducer.js.map +2 -2
- package/build-module/store/selectors.js +6 -4
- package/build-module/store/selectors.js.map +2 -2
- package/build-style/content-rtl.css +3 -0
- package/build-style/content.css +3 -0
- package/build-style/style-rtl.css +14 -5
- package/build-style/style.css +14 -5
- package/package.json +38 -37
- package/src/components/block-list/content.scss +5 -0
- package/src/components/block-list/index.js +3 -1
- package/src/components/block-list/use-block-props/use-selected-block-event-handlers.js +34 -3
- package/src/components/block-lock/modal.js +6 -5
- package/src/components/block-lock/use-block-lock.js +10 -14
- package/src/components/block-patterns-list/stories/{index.story.js → index.story.jsx} +3 -1
- package/src/components/block-settings-menu-controls/index.js +1 -1
- package/src/components/block-tools/index.js +15 -2
- package/src/components/block-tools/style.scss +4 -0
- package/src/components/block-visibility/toolbar.js +1 -1
- package/src/components/content-only-controls/fields-dropdown-menu.js +53 -0
- package/src/components/content-only-controls/index.js +314 -50
- package/src/components/content-only-controls/link/index.js +62 -57
- package/src/components/content-only-controls/media/index.js +177 -156
- package/src/components/content-only-controls/rich-text/index.js +30 -44
- package/src/components/content-only-controls/styles.scss +10 -1
- package/src/components/font-family/README.md +0 -9
- package/src/components/font-family/index.js +1 -16
- package/src/components/font-family/stories/{index.story.js → index.story.jsx} +0 -1
- package/src/components/global-styles/dimensions-panel.js +36 -0
- package/src/components/global-styles/hooks.js +1 -1
- package/src/components/global-styles/typography-panel.js +0 -1
- package/src/components/inspector-controls-tabs/use-inspector-controls-tabs.js +1 -5
- package/src/components/link-control/index.js +36 -12
- package/src/components/list-view/block-select-button.js +22 -30
- package/src/components/list-view/block.js +9 -7
- package/src/components/media-placeholder/index.js +20 -5
- package/src/components/media-placeholder/test/get-computed-accept-attribute.js +164 -0
- package/src/components/media-placeholder/utils.js +65 -0
- package/src/components/media-replace-flow/index.js +22 -3
- package/src/components/use-block-commands/index.js +1 -1
- package/src/components/use-block-drop-zone/index.js +1 -5
- package/src/hooks/dimensions.js +8 -3
- package/src/hooks/metadata.js +1 -1
- package/src/hooks/test/metadata.js +1 -1
- package/src/hooks/utils.js +4 -0
- package/src/store/private-selectors.js +123 -6
- package/src/store/reducer.js +3 -0
- package/src/store/selectors.js +6 -4
- package/src/store/test/private-selectors.js +242 -0
- package/src/store/test/reducer.js +17 -7
- package/src/style.scss +0 -1
- package/tsconfig.json +1 -0
- package/build/components/content-only-controls/plain-text/index.js +0 -68
- package/build/components/content-only-controls/plain-text/index.js.map +0 -7
- package/build-module/components/content-only-controls/plain-text/index.js +0 -50
- package/build-module/components/content-only-controls/plain-text/index.js.map +0 -7
- package/src/components/content-only-controls/plain-text/index.js +0 -49
- package/src/components/font-family/style.scss +0 -7
- /package/src/components/alignment-control/stories/{aliginment-toolbar.story.js → aliginment-toolbar.story.jsx} +0 -0
- /package/src/components/alignment-control/stories/{index.story.js → index.story.jsx} +0 -0
- /package/src/components/block-alignment-matrix-control/stories/{index.story.js → index.story.jsx} +0 -0
- /package/src/components/block-draggable/stories/{index.story.js → index.story.jsx} +0 -0
- /package/src/components/block-heading-level-dropdown/stories/{index.story.js → index.story.jsx} +0 -0
- /package/src/components/block-mover/stories/{index.story.js → index.story.jsx} +0 -0
- /package/src/components/block-title/stories/{index.story.js → index.story.jsx} +0 -0
- /package/src/components/border-radius-control/stories/{index.story.js → index.story.jsx} +0 -0
- /package/src/components/date-format-picker/stories/{index.story.js → index.story.jsx} +0 -0
- /package/src/components/dimensions-tool/stories/{aspect-ratio-tool.story.js → aspect-ratio-tool.story.jsx} +0 -0
- /package/src/components/dimensions-tool/stories/{index.story.js → index.story.jsx} +0 -0
- /package/src/components/dimensions-tool/stories/{scale-tool.story.js → scale-tool.story.jsx} +0 -0
- /package/src/components/dimensions-tool/stories/{width-height-tool.story.js → width-height-tool.story.jsx} +0 -0
- /package/src/components/height-control/stories/{index.story.js → index.story.jsx} +0 -0
- /package/src/components/inserter/stories/{index.story.js → index.story.jsx} +0 -0
- /package/src/components/line-height-control/stories/{index.story.js → index.story.jsx} +0 -0
- /package/src/components/plain-text/stories/{index.story.js → index.story.jsx} +0 -0
- /package/src/components/resolution-tool/stories/{index.story.js → index.story.jsx} +0 -0
- /package/src/components/tabbed-sidebar/stories/{index.story.js → index.story.jsx} +0 -0
- /package/src/components/text-alignment-control/stories/{index.story.js → index.story.jsx} +0 -0
- /package/src/components/text-decoration-control/stories/{index.story.js → index.story.jsx} +0 -0
- /package/src/components/text-transform-control/stories/{index.story.js → index.story.jsx} +0 -0
- /package/src/components/unit-control/stories/{index.story.js → index.story.jsx} +0 -0
- /package/src/components/url-popover/stories/{index.story.js → index.story.jsx} +0 -0
- /package/src/components/warning/stories/{index.story.js → index.story.jsx} +0 -0
- /package/src/components/writing-mode-control/stories/{index.story.js → index.story.jsx} +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/block-tools/index.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { isTextField } from '@wordpress/dom';\nimport { Popover } from '@wordpress/components';\nimport { __unstableUseShortcutEventMatch as useShortcutEventMatch } from '@wordpress/keyboard-shortcuts';\nimport { useRef } from '@wordpress/element';\nimport {\n\tswitchToBlockType,\n\tstore as blocksStore,\n\thasBlockSupport,\n} from '@wordpress/blocks';\nimport { speak } from '@wordpress/a11y';\nimport { __, sprintf, _n } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport EmptyBlockInserter from './empty-block-inserter';\nimport {\n\tInsertionPointOpenRef,\n\tdefault as InsertionPoint,\n} from './insertion-point';\nimport BlockToolbarPopover from './block-toolbar-popover';\nimport { store as blockEditorStore } from '../../store';\nimport usePopoverScroll from '../block-popover/use-popover-scroll';\nimport ZoomOutModeInserters from './zoom-out-mode-inserters';\nimport { useShowBlockTools } from './use-show-block-tools';\nimport { unlock } from '../../lock-unlock';\nimport { cleanEmptyObject } from '../../hooks/utils';\nimport usePasteStyles from '../use-paste-styles';\n\nfunction selector( select ) {\n\tconst {\n\t\tgetSelectedBlockClientId,\n\t\tgetFirstMultiSelectedBlockClientId,\n\t\tgetSettings,\n\t\tisTyping,\n\t\tisDragging,\n\t\tisZoomOut,\n\t} = unlock( select( blockEditorStore ) );\n\n\tconst clientId =\n\t\tgetSelectedBlockClientId() || getFirstMultiSelectedBlockClientId();\n\n\treturn {\n\t\tclientId,\n\t\thasFixedToolbar: getSettings().hasFixedToolbar,\n\t\tisTyping: isTyping(),\n\t\tisZoomOutMode: isZoomOut(),\n\t\tisDragging: isDragging(),\n\t};\n}\n\n/**\n * Renders block tools (the block toolbar, select/navigation mode toolbar, the\n * insertion point and a slot for the inline rich text toolbar). Must be wrapped\n * around the block content and editor styles wrapper or iframe.\n *\n * @param {Object} $0 Props.\n * @param {Object} $0.children The block content and style container.\n * @param {Object} $0.__unstableContentRef Ref holding the content scroll container.\n */\nexport default function BlockTools( {\n\tchildren,\n\t__unstableContentRef,\n\t...props\n} ) {\n\tconst { clientId, hasFixedToolbar, isTyping, isZoomOutMode, isDragging } =\n\t\tuseSelect( selector, [] );\n\n\tconst isMatch = useShortcutEventMatch();\n\tconst {\n\t\tgetBlocksByClientId,\n\t\tgetSelectedBlockClientIds,\n\t\tgetBlockRootClientId,\n\t\tisGroupable,\n\t\tgetBlockName,\n\t\tgetEditedContentOnlySection,\n\t} = unlock( useSelect( blockEditorStore ) );\n\tconst { getGroupingBlockName } = useSelect( blocksStore );\n\tconst { showEmptyBlockSideInserter, showBlockToolbarPopover } =\n\t\tuseShowBlockTools();\n\tconst pasteStyles = usePasteStyles();\n\n\tconst {\n\t\tduplicateBlocks,\n\t\tremoveBlocks,\n\t\treplaceBlocks,\n\t\tinsertAfterBlock,\n\t\tinsertBeforeBlock,\n\t\tselectBlock,\n\t\tmoveBlocksUp,\n\t\tmoveBlocksDown,\n\t\texpandBlock,\n\t\tupdateBlockAttributes,\n\t\tstopEditingContentOnlySection,\n\t} = unlock( useDispatch( blockEditorStore ) );\n\n\tfunction onKeyDown( event ) {\n\t\tif ( event.defaultPrevented ) {\n\t\t\treturn;\n\t\t}\n\n\t\tif (\n\t\t\tisMatch( 'core/block-editor/move-up', event ) ||\n\t\t\tisMatch( 'core/block-editor/move-down', event )\n\t\t) {\n\t\t\tconst clientIds = getSelectedBlockClientIds();\n\t\t\tif ( clientIds.length ) {\n\t\t\t\tevent.preventDefault();\n\t\t\t\tconst rootClientId = getBlockRootClientId( clientIds[ 0 ] );\n\t\t\t\tconst direction = isMatch( 'core/block-editor/move-up', event )\n\t\t\t\t\t? 'up'\n\t\t\t\t\t: 'down';\n\t\t\t\tif ( direction === 'up' ) {\n\t\t\t\t\tmoveBlocksUp( clientIds, rootClientId );\n\t\t\t\t} else {\n\t\t\t\t\tmoveBlocksDown( clientIds, rootClientId );\n\t\t\t\t}\n\t\t\t\tconst blockLength = Array.isArray( clientIds )\n\t\t\t\t\t? clientIds.length\n\t\t\t\t\t: 1;\n\t\t\t\tconst message = sprintf(\n\t\t\t\t\t// translators: %d: the name of the block that has been moved\n\t\t\t\t\t_n(\n\t\t\t\t\t\t'%d block moved.',\n\t\t\t\t\t\t'%d blocks moved.',\n\t\t\t\t\t\tclientIds.length\n\t\t\t\t\t),\n\t\t\t\t\tblockLength\n\t\t\t\t);\n\t\t\t\tspeak( message );\n\t\t\t}\n\t\t} else if ( isMatch( 'core/block-editor/duplicate', event ) ) {\n\t\t\tconst clientIds = getSelectedBlockClientIds();\n\t\t\tif ( clientIds.length ) {\n\t\t\t\tevent.preventDefault();\n\t\t\t\tduplicateBlocks( clientIds );\n\t\t\t}\n\t\t} else if ( isMatch( 'core/block-editor/remove', event ) ) {\n\t\t\tconst clientIds = getSelectedBlockClientIds();\n\t\t\tif ( clientIds.length ) {\n\t\t\t\tevent.preventDefault();\n\t\t\t\tremoveBlocks( clientIds );\n\t\t\t}\n\t\t} else if ( isMatch( 'core/block-editor/paste-styles', event ) ) {\n\t\t\tconst clientIds = getSelectedBlockClientIds();\n\t\t\tif ( clientIds.length ) {\n\t\t\t\tevent.preventDefault();\n\t\t\t\tconst blocks = getBlocksByClientId( clientIds );\n\t\t\t\tpasteStyles( blocks );\n\t\t\t}\n\t\t} else if ( isMatch( 'core/block-editor/insert-after', event ) ) {\n\t\t\tconst clientIds = getSelectedBlockClientIds();\n\t\t\tif ( clientIds.length ) {\n\t\t\t\tevent.preventDefault();\n\t\t\t\tinsertAfterBlock( clientIds[ clientIds.length - 1 ] );\n\t\t\t}\n\t\t} else if ( isMatch( 'core/block-editor/insert-before', event ) ) {\n\t\t\tconst clientIds = getSelectedBlockClientIds();\n\t\t\tif ( clientIds.length ) {\n\t\t\t\tevent.preventDefault();\n\t\t\t\tinsertBeforeBlock( clientIds[ 0 ] );\n\t\t\t}\n\t\t} else if ( isMatch( 'core/block-editor/unselect', event ) ) {\n\t\t\tif ( event.target.closest( '[role=toolbar]' ) ) {\n\t\t\t\t// This shouldn't be necessary, but we have a combination of a few things all combining to create a situation where:\n\t\t\t\t// - Because the block toolbar uses createPortal to populate the block toolbar fills, we can't rely on the React event bubbling to hit the onKeyDown listener for the block toolbar\n\t\t\t\t// - Since we can't use the React tree, we use the DOM tree which _should_ handle the event bubbling correctly from a `createPortal` element.\n\t\t\t\t// - This bubbles via the React tree, which hits this `unselect` escape keypress before the block toolbar DOM event listener has access to it.\n\t\t\t\t// An alternative would be to remove the addEventListener on the navigableToolbar and use this event to handle it directly right here. That feels hacky too though.\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst clientIds = getSelectedBlockClientIds();\n\t\t\tif ( clientIds.length > 1 ) {\n\t\t\t\tevent.preventDefault();\n\t\t\t\t// If there is more than one block selected, select the first\n\t\t\t\t// block so that focus is directed back to the beginning of the selection.\n\t\t\t\t// In effect, to the user this feels like deselecting the multi-selection.\n\t\t\t\tselectBlock( clientIds[ 0 ] );\n\t\t\t}\n\t\t} else if ( isMatch( 'core/block-editor/collapse-list-view', event ) ) {\n\t\t\t// If focus is currently within a text field, such as a rich text block or other editable field,\n\t\t\t// skip collapsing the list view, and allow the keyboard shortcut to be handled by the text field.\n\t\t\t// This condition checks for both the active element and the active element within an iframed editor.\n\t\t\tif (\n\t\t\t\tisTextField( event.target ) ||\n\t\t\t\tisTextField(\n\t\t\t\t\tevent.target?.contentWindow?.document?.activeElement\n\t\t\t\t)\n\t\t\t) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tevent.preventDefault();\n\t\t\texpandBlock( clientId );\n\t\t} else if ( isMatch( 'core/block-editor/group', event ) ) {\n\t\t\tconst clientIds = getSelectedBlockClientIds();\n\t\t\tif ( clientIds.length > 1 && isGroupable( clientIds ) ) {\n\t\t\t\tevent.preventDefault();\n\t\t\t\tconst blocks = getBlocksByClientId( clientIds );\n\t\t\t\tconst groupingBlockName = getGroupingBlockName();\n\t\t\t\tconst newBlocks = switchToBlockType(\n\t\t\t\t\tblocks,\n\t\t\t\t\tgroupingBlockName\n\t\t\t\t);\n\t\t\t\treplaceBlocks( clientIds, newBlocks );\n\t\t\t\tspeak( __( 'Selected blocks are grouped.' ) );\n\t\t\t}\n\t\t} else if (\n\t\t\tisMatch( 'core/block-editor/toggle-block-visibility', event )\n\t\t) {\n\t\t\tconst clientIds = getSelectedBlockClientIds();\n\t\t\tif ( clientIds.length ) {\n\t\t\t\tevent.preventDefault();\n\t\t\t\tconst blocks = getBlocksByClientId( clientIds );\n\t\t\t\tconst canToggleBlockVisibility = blocks.every( ( block ) =>\n\t\t\t\t\thasBlockSupport(\n\t\t\t\t\t\tgetBlockName( block.clientId ),\n\t\t\t\t\t\t'blockVisibility',\n\t\t\t\t\t\ttrue\n\t\t\t\t\t)\n\t\t\t\t);\n\t\t\t\tif ( ! canToggleBlockVisibility ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tconst hasHiddenBlock = blocks.some(\n\t\t\t\t\t( block ) =>\n\t\t\t\t\t\tblock.attributes.metadata?.blockVisibility === false\n\t\t\t\t);\n\t\t\t\tconst attributesByClientId = Object.fromEntries(\n\t\t\t\t\tblocks.map( ( { clientId: mapClientId, attributes } ) => [\n\t\t\t\t\t\tmapClientId,\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tmetadata: cleanEmptyObject( {\n\t\t\t\t\t\t\t\t...attributes?.metadata,\n\t\t\t\t\t\t\t\tblockVisibility: hasHiddenBlock\n\t\t\t\t\t\t\t\t\t? undefined\n\t\t\t\t\t\t\t\t\t: false,\n\t\t\t\t\t\t\t} ),\n\t\t\t\t\t\t},\n\t\t\t\t\t] )\n\t\t\t\t);\n\t\t\t\tupdateBlockAttributes( clientIds, attributesByClientId, {\n\t\t\t\t\tuniqueByBlock: true,\n\t\t\t\t} );\n\t\t\t}\n\t\t}\n\n\t\t// Has the same keyboard shortcut as 'unselect', so can't be within the\n\t\t// if/else chain above.\n\t\tif ( isMatch( 'core/block-editor/stop-editing-as-blocks', event ) ) {\n\t\t\tif ( getEditedContentOnlySection() ) {\n\t\t\t\tstopEditingContentOnlySection();\n\t\t\t}\n\t\t}\n\t}\n\tconst blockToolbarRef = usePopoverScroll( __unstableContentRef );\n\tconst blockToolbarAfterRef = usePopoverScroll( __unstableContentRef );\n\n\treturn (\n\t\t// eslint-disable-next-line jsx-a11y/no-static-element-interactions\n\t\t<div { ...props } onKeyDown={ onKeyDown }>\n\t\t\t<InsertionPointOpenRef.Provider value={ useRef( false ) }>\n\t\t\t\t{ ! isTyping && ! isZoomOutMode && (\n\t\t\t\t\t<InsertionPoint\n\t\t\t\t\t\t__unstableContentRef={ __unstableContentRef }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\n\t\t\t\t{ showEmptyBlockSideInserter && (\n\t\t\t\t\t<EmptyBlockInserter\n\t\t\t\t\t\t__unstableContentRef={ __unstableContentRef }\n\t\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\n\t\t\t\t{ showBlockToolbarPopover && (\n\t\t\t\t\t<BlockToolbarPopover\n\t\t\t\t\t\t__unstableContentRef={ __unstableContentRef }\n\t\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\t\tisTyping={ isTyping }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\n\t\t\t\t{ /* Used for the inline rich text toolbar. Until this toolbar is combined into BlockToolbar, someone implementing their own BlockToolbar will also need to use this to see the image caption toolbar. */ }\n\t\t\t\t{ ! isZoomOutMode && ! hasFixedToolbar && (\n\t\t\t\t\t<Popover.Slot\n\t\t\t\t\t\tname=\"block-toolbar\"\n\t\t\t\t\t\tref={ blockToolbarRef }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t\t{ children }\n\t\t\t\t{ /* Used for inline rich text popovers. */ }\n\t\t\t\t<Popover.Slot\n\t\t\t\t\tname=\"__unstable-block-tools-after\"\n\t\t\t\t\tref={ blockToolbarAfterRef }\n\t\t\t\t/>\n\t\t\t\t{ isZoomOutMode && ! isDragging && (\n\t\t\t\t\t<ZoomOutModeInserters\n\t\t\t\t\t\t__unstableContentRef={ __unstableContentRef }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t</InsertionPointOpenRef.Provider>\n\t\t</div>\n\t);\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAAuC;AACvC,iBAA4B;AAC5B,wBAAwB;AACxB,gCAAyE;AACzE,qBAAuB;AACvB,oBAIO;AACP,kBAAsB;AACtB,kBAAgC;AAKhC,kCAA+B;AAC/B,6BAGO;AACP,mCAAgC;AAChC,mBAA0C;AAC1C,gCAA6B;AAC7B,qCAAiC;AACjC,kCAAkC;AAClC,yBAAuB;AACvB,mBAAiC;AACjC,8BAA2B;
|
|
6
|
-
"names": ["blockEditorStore", "useShortcutEventMatch", "blocksStore", "usePasteStyles", "usePopoverScroll", "InsertionPoint", "EmptyBlockInserter", "BlockToolbarPopover", "ZoomOutModeInserters"]
|
|
4
|
+
"sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { isTextField } from '@wordpress/dom';\nimport { Popover } from '@wordpress/components';\nimport { __unstableUseShortcutEventMatch as useShortcutEventMatch } from '@wordpress/keyboard-shortcuts';\nimport { useRef } from '@wordpress/element';\nimport {\n\tswitchToBlockType,\n\tstore as blocksStore,\n\thasBlockSupport,\n} from '@wordpress/blocks';\nimport { speak } from '@wordpress/a11y';\nimport { __, sprintf, _n } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport EmptyBlockInserter from './empty-block-inserter';\nimport {\n\tInsertionPointOpenRef,\n\tdefault as InsertionPoint,\n} from './insertion-point';\nimport BlockToolbarPopover from './block-toolbar-popover';\nimport { store as blockEditorStore } from '../../store';\nimport usePopoverScroll from '../block-popover/use-popover-scroll';\nimport ZoomOutModeInserters from './zoom-out-mode-inserters';\nimport { useShowBlockTools } from './use-show-block-tools';\nimport { unlock } from '../../lock-unlock';\nimport { cleanEmptyObject } from '../../hooks/utils';\nimport usePasteStyles from '../use-paste-styles';\n\nfunction selector( select ) {\n\tconst {\n\t\tgetSelectedBlockClientId,\n\t\tgetFirstMultiSelectedBlockClientId,\n\t\tgetSettings,\n\t\tisTyping,\n\t\tisDragging,\n\t\tisZoomOut,\n\t} = unlock( select( blockEditorStore ) );\n\n\tconst clientId =\n\t\tgetSelectedBlockClientId() || getFirstMultiSelectedBlockClientId();\n\n\treturn {\n\t\tclientId,\n\t\thasFixedToolbar: getSettings().hasFixedToolbar,\n\t\tisTyping: isTyping(),\n\t\tisZoomOutMode: isZoomOut(),\n\t\tisDragging: isDragging(),\n\t};\n}\n\n/**\n * Renders block tools (the block toolbar, select/navigation mode toolbar, the\n * insertion point and a slot for the inline rich text toolbar). Must be wrapped\n * around the block content and editor styles wrapper or iframe.\n *\n * @param {Object} $0 Props.\n * @param {Object} $0.children The block content and style container.\n * @param {Object} $0.__unstableContentRef Ref holding the content scroll container.\n */\nexport default function BlockTools( {\n\tchildren,\n\t__unstableContentRef,\n\t...props\n} ) {\n\tconst { clientId, hasFixedToolbar, isTyping, isZoomOutMode, isDragging } =\n\t\tuseSelect( selector, [] );\n\n\tconst isMatch = useShortcutEventMatch();\n\tconst {\n\t\tgetBlocksByClientId,\n\t\tgetSelectedBlockClientIds,\n\t\tgetBlockRootClientId,\n\t\tisGroupable,\n\t\tgetBlockName,\n\t\tgetEditedContentOnlySection,\n\t} = unlock( useSelect( blockEditorStore ) );\n\tconst { getGroupingBlockName } = useSelect( blocksStore );\n\tconst { showEmptyBlockSideInserter, showBlockToolbarPopover } =\n\t\tuseShowBlockTools();\n\tconst pasteStyles = usePasteStyles();\n\n\tconst {\n\t\tduplicateBlocks,\n\t\tremoveBlocks,\n\t\treplaceBlocks,\n\t\tinsertAfterBlock,\n\t\tinsertBeforeBlock,\n\t\tselectBlock,\n\t\tmoveBlocksUp,\n\t\tmoveBlocksDown,\n\t\texpandBlock,\n\t\tupdateBlockAttributes,\n\t\tstopEditingContentOnlySection,\n\t} = unlock( useDispatch( blockEditorStore ) );\n\n\tfunction onKeyDown( event ) {\n\t\tif ( event.defaultPrevented ) {\n\t\t\treturn;\n\t\t}\n\n\t\tif (\n\t\t\tisMatch( 'core/block-editor/move-up', event ) ||\n\t\t\tisMatch( 'core/block-editor/move-down', event )\n\t\t) {\n\t\t\tconst clientIds = getSelectedBlockClientIds();\n\t\t\tif ( clientIds.length ) {\n\t\t\t\tevent.preventDefault();\n\t\t\t\tconst rootClientId = getBlockRootClientId( clientIds[ 0 ] );\n\t\t\t\tconst direction = isMatch( 'core/block-editor/move-up', event )\n\t\t\t\t\t? 'up'\n\t\t\t\t\t: 'down';\n\t\t\t\tif ( direction === 'up' ) {\n\t\t\t\t\tmoveBlocksUp( clientIds, rootClientId );\n\t\t\t\t} else {\n\t\t\t\t\tmoveBlocksDown( clientIds, rootClientId );\n\t\t\t\t}\n\t\t\t\tconst blockLength = Array.isArray( clientIds )\n\t\t\t\t\t? clientIds.length\n\t\t\t\t\t: 1;\n\t\t\t\tconst message = sprintf(\n\t\t\t\t\t// translators: %d: the name of the block that has been moved\n\t\t\t\t\t_n(\n\t\t\t\t\t\t'%d block moved.',\n\t\t\t\t\t\t'%d blocks moved.',\n\t\t\t\t\t\tclientIds.length\n\t\t\t\t\t),\n\t\t\t\t\tblockLength\n\t\t\t\t);\n\t\t\t\tspeak( message );\n\t\t\t}\n\t\t} else if ( isMatch( 'core/block-editor/duplicate', event ) ) {\n\t\t\tconst clientIds = getSelectedBlockClientIds();\n\t\t\tif ( clientIds.length ) {\n\t\t\t\tevent.preventDefault();\n\t\t\t\tduplicateBlocks( clientIds );\n\t\t\t}\n\t\t} else if ( isMatch( 'core/block-editor/remove', event ) ) {\n\t\t\tconst clientIds = getSelectedBlockClientIds();\n\t\t\tif ( clientIds.length ) {\n\t\t\t\tevent.preventDefault();\n\t\t\t\tremoveBlocks( clientIds );\n\t\t\t}\n\t\t} else if ( isMatch( 'core/block-editor/paste-styles', event ) ) {\n\t\t\tconst clientIds = getSelectedBlockClientIds();\n\t\t\tif ( clientIds.length ) {\n\t\t\t\tevent.preventDefault();\n\t\t\t\tconst blocks = getBlocksByClientId( clientIds );\n\t\t\t\tpasteStyles( blocks );\n\t\t\t}\n\t\t} else if ( isMatch( 'core/block-editor/insert-after', event ) ) {\n\t\t\tconst clientIds = getSelectedBlockClientIds();\n\t\t\tif ( clientIds.length ) {\n\t\t\t\tevent.preventDefault();\n\t\t\t\tinsertAfterBlock( clientIds[ clientIds.length - 1 ] );\n\t\t\t}\n\t\t} else if ( isMatch( 'core/block-editor/insert-before', event ) ) {\n\t\t\tconst clientIds = getSelectedBlockClientIds();\n\t\t\tif ( clientIds.length ) {\n\t\t\t\tevent.preventDefault();\n\t\t\t\tinsertBeforeBlock( clientIds[ 0 ] );\n\t\t\t}\n\t\t} else if ( isMatch( 'core/block-editor/unselect', event ) ) {\n\t\t\tif ( event.target.closest( '[role=toolbar]' ) ) {\n\t\t\t\t// This shouldn't be necessary, but we have a combination of a few things all combining to create a situation where:\n\t\t\t\t// - Because the block toolbar uses createPortal to populate the block toolbar fills, we can't rely on the React event bubbling to hit the onKeyDown listener for the block toolbar\n\t\t\t\t// - Since we can't use the React tree, we use the DOM tree which _should_ handle the event bubbling correctly from a `createPortal` element.\n\t\t\t\t// - This bubbles via the React tree, which hits this `unselect` escape keypress before the block toolbar DOM event listener has access to it.\n\t\t\t\t// An alternative would be to remove the addEventListener on the navigableToolbar and use this event to handle it directly right here. That feels hacky too though.\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst clientIds = getSelectedBlockClientIds();\n\t\t\tif ( clientIds.length > 1 ) {\n\t\t\t\tevent.preventDefault();\n\t\t\t\t// If there is more than one block selected, select the first\n\t\t\t\t// block so that focus is directed back to the beginning of the selection.\n\t\t\t\t// In effect, to the user this feels like deselecting the multi-selection.\n\t\t\t\tselectBlock( clientIds[ 0 ] );\n\t\t\t}\n\t\t} else if ( isMatch( 'core/block-editor/collapse-list-view', event ) ) {\n\t\t\t// If focus is currently within a text field, such as a rich text block or other editable field,\n\t\t\t// skip collapsing the list view, and allow the keyboard shortcut to be handled by the text field.\n\t\t\t// This condition checks for both the active element and the active element within an iframed editor.\n\t\t\tif (\n\t\t\t\tisTextField( event.target ) ||\n\t\t\t\tisTextField(\n\t\t\t\t\tevent.target?.contentWindow?.document?.activeElement\n\t\t\t\t)\n\t\t\t) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tevent.preventDefault();\n\t\t\texpandBlock( clientId );\n\t\t} else if ( isMatch( 'core/block-editor/group', event ) ) {\n\t\t\tconst clientIds = getSelectedBlockClientIds();\n\t\t\tif ( clientIds.length > 1 && isGroupable( clientIds ) ) {\n\t\t\t\tevent.preventDefault();\n\t\t\t\tconst blocks = getBlocksByClientId( clientIds );\n\t\t\t\tconst groupingBlockName = getGroupingBlockName();\n\t\t\t\tconst newBlocks = switchToBlockType(\n\t\t\t\t\tblocks,\n\t\t\t\t\tgroupingBlockName\n\t\t\t\t);\n\t\t\t\treplaceBlocks( clientIds, newBlocks );\n\t\t\t\tspeak( __( 'Selected blocks are grouped.' ) );\n\t\t\t}\n\t\t} else if (\n\t\t\tisMatch( 'core/block-editor/toggle-block-visibility', event )\n\t\t) {\n\t\t\tconst clientIds = getSelectedBlockClientIds();\n\t\t\tif ( clientIds.length ) {\n\t\t\t\tevent.preventDefault();\n\t\t\t\tconst blocks = getBlocksByClientId( clientIds );\n\t\t\t\tconst canToggleBlockVisibility = blocks.every( ( block ) =>\n\t\t\t\t\thasBlockSupport(\n\t\t\t\t\t\tgetBlockName( block.clientId ),\n\t\t\t\t\t\t'visibility',\n\t\t\t\t\t\ttrue\n\t\t\t\t\t)\n\t\t\t\t);\n\t\t\t\tif ( ! canToggleBlockVisibility ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tconst hasHiddenBlock = blocks.some(\n\t\t\t\t\t( block ) =>\n\t\t\t\t\t\tblock.attributes.metadata?.blockVisibility === false\n\t\t\t\t);\n\t\t\t\tconst attributesByClientId = Object.fromEntries(\n\t\t\t\t\tblocks.map( ( { clientId: mapClientId, attributes } ) => [\n\t\t\t\t\t\tmapClientId,\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tmetadata: cleanEmptyObject( {\n\t\t\t\t\t\t\t\t...attributes?.metadata,\n\t\t\t\t\t\t\t\tblockVisibility: hasHiddenBlock\n\t\t\t\t\t\t\t\t\t? undefined\n\t\t\t\t\t\t\t\t\t: false,\n\t\t\t\t\t\t\t} ),\n\t\t\t\t\t\t},\n\t\t\t\t\t] )\n\t\t\t\t);\n\t\t\t\tupdateBlockAttributes( clientIds, attributesByClientId, {\n\t\t\t\t\tuniqueByBlock: true,\n\t\t\t\t} );\n\t\t\t}\n\t\t}\n\n\t\t// Has the same keyboard shortcut as 'unselect', so can't be within the\n\t\t// if/else chain above.\n\t\tif ( isMatch( 'core/block-editor/stop-editing-as-blocks', event ) ) {\n\t\t\tif ( getEditedContentOnlySection() ) {\n\t\t\t\tstopEditingContentOnlySection();\n\t\t\t}\n\t\t}\n\t}\n\tconst blockToolbarRef = usePopoverScroll( __unstableContentRef );\n\tconst blockToolbarAfterRef = usePopoverScroll( __unstableContentRef );\n\n\treturn (\n\t\t// eslint-disable-next-line jsx-a11y/no-static-element-interactions\n\t\t<div\n\t\t\t{ ...props }\n\t\t\tonKeyDown={ onKeyDown }\n\t\t\t// Popover slots cannot be unmounted during dragging because the\n\t\t\t// will just be rendered in a fallback popover slot instead.\n\t\t\tclassName={ clsx( props.className, {\n\t\t\t\t'block-editor-block-tools--is-dragging': isDragging,\n\t\t\t} ) }\n\t\t>\n\t\t\t<InsertionPointOpenRef.Provider value={ useRef( false ) }>\n\t\t\t\t{ ! isTyping && ! isZoomOutMode && (\n\t\t\t\t\t<InsertionPoint\n\t\t\t\t\t\t__unstableContentRef={ __unstableContentRef }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\n\t\t\t\t{ showEmptyBlockSideInserter && (\n\t\t\t\t\t<EmptyBlockInserter\n\t\t\t\t\t\t__unstableContentRef={ __unstableContentRef }\n\t\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\n\t\t\t\t{ showBlockToolbarPopover && (\n\t\t\t\t\t<BlockToolbarPopover\n\t\t\t\t\t\t__unstableContentRef={ __unstableContentRef }\n\t\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\t\tisTyping={ isTyping }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\n\t\t\t\t{ /* Used for the inline rich text toolbar. Until this toolbar is combined into BlockToolbar, someone implementing their own BlockToolbar will also need to use this to see the image caption toolbar. */ }\n\t\t\t\t{ ! isZoomOutMode && ! hasFixedToolbar && (\n\t\t\t\t\t<Popover.Slot\n\t\t\t\t\t\tname=\"block-toolbar\"\n\t\t\t\t\t\tref={ blockToolbarRef }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t\t{ children }\n\t\t\t\t{ /* Used for inline rich text popovers. */ }\n\t\t\t\t<Popover.Slot\n\t\t\t\t\tname=\"__unstable-block-tools-after\"\n\t\t\t\t\tref={ blockToolbarAfterRef }\n\t\t\t\t/>\n\t\t\t\t{ isZoomOutMode && ! isDragging && (\n\t\t\t\t\t<ZoomOutModeInserters\n\t\t\t\t\t\t__unstableContentRef={ __unstableContentRef }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t</InsertionPointOpenRef.Provider>\n\t\t</div>\n\t);\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAAiB;AAKjB,kBAAuC;AACvC,iBAA4B;AAC5B,wBAAwB;AACxB,gCAAyE;AACzE,qBAAuB;AACvB,oBAIO;AACP,kBAAsB;AACtB,kBAAgC;AAKhC,kCAA+B;AAC/B,6BAGO;AACP,mCAAgC;AAChC,mBAA0C;AAC1C,gCAA6B;AAC7B,qCAAiC;AACjC,kCAAkC;AAClC,yBAAuB;AACvB,mBAAiC;AACjC,8BAA2B;AAkPxB;AAhPH,SAAS,SAAU,QAAS;AAC3B,QAAM;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACD,QAAI,2BAAQ,OAAQ,aAAAA,KAAiB,CAAE;AAEvC,QAAM,WACL,yBAAyB,KAAK,mCAAmC;AAElE,SAAO;AAAA,IACN;AAAA,IACA,iBAAiB,YAAY,EAAE;AAAA,IAC/B,UAAU,SAAS;AAAA,IACnB,eAAe,UAAU;AAAA,IACzB,YAA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AAC/D,QAAM,2BAAuB,0BAAAA,SAAkB,oBAAqB;AAEpE;AAAA;AAAA,IAEC;AAAA,MAAC;AAAA;AAAA,QACE,GAAG;AAAA,QACL;AAAA,QAGA,eAAY,YAAAC,SAAM,MAAM,WAAW;AAAA,UAClC,yCAAyC;AAAA,QAC1C,CAAE;AAAA,QAEF,uDAAC,6CAAsB,UAAtB,EAA+B,WAAQ,uBAAQ,KAAM,GACnD;AAAA,WAAE,YAAY,CAAE,iBACjB;AAAA,YAAC,uBAAAC;AAAA,YAAA;AAAA,cACA;AAAA;AAAA,UACD;AAAA,UAGC,8BACD;AAAA,YAAC,4BAAAC;AAAA,YAAA;AAAA,cACA;AAAA,cACA;AAAA;AAAA,UACD;AAAA,UAGC,2BACD;AAAA,YAAC,6BAAAC;AAAA,YAAA;AAAA,cACA;AAAA,cACA;AAAA,cACA;AAAA;AAAA,UACD;AAAA,UAIC,CAAE,iBAAiB,CAAE,mBACtB;AAAA,YAAC,0BAAQ;AAAA,YAAR;AAAA,cACA,MAAK;AAAA,cACL,KAAM;AAAA;AAAA,UACP;AAAA,UAEC;AAAA,UAEF;AAAA,YAAC,0BAAQ;AAAA,YAAR;AAAA,cACA,MAAK;AAAA,cACL,KAAM;AAAA;AAAA,UACP;AAAA,UACE,iBAAiB,CAAE,cACpB;AAAA,YAAC,+BAAAC;AAAA,YAAA;AAAA,cACA;AAAA;AAAA,UACD;AAAA,WAEF;AAAA;AAAA,IACD;AAAA;AAEF;",
|
|
6
|
+
"names": ["blockEditorStore", "useShortcutEventMatch", "blocksStore", "usePasteStyles", "usePopoverScroll", "clsx", "InsertionPoint", "EmptyBlockInserter", "BlockToolbarPopover", "ZoomOutModeInserters"]
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/block-visibility/toolbar.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { ToolbarButton, ToolbarGroup } from '@wordpress/components';\nimport { useRef, useEffect } from '@wordpress/element';\nimport { seen, unseen } from '@wordpress/icons';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { hasBlockSupport } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\nimport { cleanEmptyObject } from '../../hooks/utils';\n\nexport default function BlockVisibilityToolbar( { clientIds } ) {\n\tconst { blocks, canToggleBlockVisibility } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getBlockName, getBlocksByClientId } =\n\t\t\t\tselect( blockEditorStore );\n\t\t\tconst _blocks = getBlocksByClientId( clientIds );\n\t\t\treturn {\n\t\t\t\tblocks: _blocks,\n\t\t\t\tcanToggleBlockVisibility: _blocks.every( ( { clientId } ) =>\n\t\t\t\t\thasBlockSupport(\n\t\t\t\t\t\tgetBlockName( clientId ),\n\t\t\t\t\t\t'
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { ToolbarButton, ToolbarGroup } from '@wordpress/components';\nimport { useRef, useEffect } from '@wordpress/element';\nimport { seen, unseen } from '@wordpress/icons';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { hasBlockSupport } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\nimport { cleanEmptyObject } from '../../hooks/utils';\n\nexport default function BlockVisibilityToolbar( { clientIds } ) {\n\tconst { blocks, canToggleBlockVisibility } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getBlockName, getBlocksByClientId } =\n\t\t\t\tselect( blockEditorStore );\n\t\t\tconst _blocks = getBlocksByClientId( clientIds );\n\t\t\treturn {\n\t\t\t\tblocks: _blocks,\n\t\t\t\tcanToggleBlockVisibility: _blocks.every( ( { clientId } ) =>\n\t\t\t\t\thasBlockSupport(\n\t\t\t\t\t\tgetBlockName( clientId ),\n\t\t\t\t\t\t'visibility',\n\t\t\t\t\t\ttrue\n\t\t\t\t\t)\n\t\t\t\t),\n\t\t\t};\n\t\t},\n\t\t[ clientIds ]\n\t);\n\n\tconst hasHiddenBlock = blocks.some(\n\t\t( block ) => block.attributes.metadata?.blockVisibility === false\n\t);\n\n\tconst hasBlockVisibilityButtonShownRef = useRef( false );\n\tconst { updateBlockAttributes } = useDispatch( blockEditorStore );\n\n\t// If the block visibility button has been shown, we don't want to\n\t// remove it from the toolbar until the toolbar is rendered again\n\t// without it. Removing it beforehand can cause focus loss issues.\n\t// It needs to return focus from whence it came, and to do that,\n\t// we need to leave the button in the toolbar.\n\tuseEffect( () => {\n\t\tif ( hasHiddenBlock ) {\n\t\t\thasBlockVisibilityButtonShownRef.current = true;\n\t\t}\n\t}, [ hasHiddenBlock ] );\n\n\tif ( ! hasHiddenBlock && ! hasBlockVisibilityButtonShownRef.current ) {\n\t\treturn null;\n\t}\n\n\tconst toggleBlockVisibility = () => {\n\t\tconst attributesByClientId = Object.fromEntries(\n\t\t\tblocks?.map( ( { clientId, attributes } ) => [\n\t\t\t\tclientId,\n\t\t\t\t{\n\t\t\t\t\tmetadata: cleanEmptyObject( {\n\t\t\t\t\t\t...attributes?.metadata,\n\t\t\t\t\t\tblockVisibility: hasHiddenBlock ? undefined : false,\n\t\t\t\t\t} ),\n\t\t\t\t},\n\t\t\t] )\n\t\t);\n\t\tupdateBlockAttributes( clientIds, attributesByClientId, {\n\t\t\tuniqueByBlock: true,\n\t\t} );\n\t};\n\n\treturn (\n\t\t<>\n\t\t\t<ToolbarGroup className=\"block-editor-block-lock-toolbar\">\n\t\t\t\t<ToolbarButton\n\t\t\t\t\tdisabled={ ! canToggleBlockVisibility }\n\t\t\t\t\ticon={ hasHiddenBlock ? unseen : seen }\n\t\t\t\t\tlabel={ hasHiddenBlock ? __( 'Hidden' ) : __( 'Visible' ) }\n\t\t\t\t\tonClick={ toggleBlockVisibility }\n\t\t\t\t/>\n\t\t\t</ToolbarGroup>\n\t\t</>\n\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QACH;AAAA,MACD,CAAE;AAAA,IACH;AACA,0BAAuB,WAAW,sBAAsB;AAAA,MACvD,eAAe;AAAA,IAChB,CAAE;AAAA,EACH;AAEA,SACC,2EACC,sDAAC,kCAAa,WAAU,mCACvB;AAAA,IAAC;AAAA;AAAA,MACA,UAAW,CAAE;AAAA,MACb,MAAO,iBAAiB,sBAAS;AAAA,MACjC,OAAQ,qBAAiB,gBAAI,QAAS,QAAI,gBAAI,SAAU;AAAA,MACxD,SAAU;AAAA;AAAA,EACX,GACD,GACD;AAEF;",
|
|
6
6
|
"names": ["blockEditorStore"]
|
|
7
7
|
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// packages/block-editor/src/components/content-only-controls/fields-dropdown-menu.js
|
|
21
|
+
var fields_dropdown_menu_exports = {};
|
|
22
|
+
__export(fields_dropdown_menu_exports, {
|
|
23
|
+
default: () => FieldsDropdownMenu
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(fields_dropdown_menu_exports);
|
|
26
|
+
var import_components = require("@wordpress/components");
|
|
27
|
+
var import_icons = require("@wordpress/icons");
|
|
28
|
+
var import_i18n = require("@wordpress/i18n");
|
|
29
|
+
var import_use_inspector_popover_placement = require("./use-inspector-popover-placement");
|
|
30
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
31
|
+
function FieldsDropdownMenu({
|
|
32
|
+
fields,
|
|
33
|
+
visibleFields,
|
|
34
|
+
onToggleField
|
|
35
|
+
}) {
|
|
36
|
+
const { popoverProps } = (0, import_use_inspector_popover_placement.useInspectorPopoverPlacement)();
|
|
37
|
+
if (!fields || fields.length === 0) {
|
|
38
|
+
return null;
|
|
39
|
+
}
|
|
40
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
41
|
+
import_components.DropdownMenu,
|
|
42
|
+
{
|
|
43
|
+
icon: import_icons.moreVertical,
|
|
44
|
+
label: (0, import_i18n.__)("Options"),
|
|
45
|
+
popoverProps,
|
|
46
|
+
children: ({ onClose }) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_components.MenuGroup, { label: (0, import_i18n.__)("Show / Hide"), children: fields.map((field) => {
|
|
47
|
+
const isVisible = visibleFields.includes(field.id);
|
|
48
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
49
|
+
import_components.MenuItem,
|
|
50
|
+
{
|
|
51
|
+
isSelected: isVisible,
|
|
52
|
+
onClick: () => {
|
|
53
|
+
onToggleField(field.id);
|
|
54
|
+
onClose();
|
|
55
|
+
},
|
|
56
|
+
role: "menuitemcheckbox",
|
|
57
|
+
icon: isVisible ? import_icons.check : null,
|
|
58
|
+
children: field.label
|
|
59
|
+
},
|
|
60
|
+
field.id
|
|
61
|
+
);
|
|
62
|
+
}) })
|
|
63
|
+
}
|
|
64
|
+
);
|
|
65
|
+
}
|
|
66
|
+
//# sourceMappingURL=fields-dropdown-menu.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/components/content-only-controls/fields-dropdown-menu.js"],
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { DropdownMenu, MenuGroup, MenuItem } from '@wordpress/components';\nimport { moreVertical, check } from '@wordpress/icons';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { useInspectorPopoverPlacement } from './use-inspector-popover-placement';\n\nexport default function FieldsDropdownMenu( {\n\tfields,\n\tvisibleFields,\n\tonToggleField,\n} ) {\n\tconst { popoverProps } = useInspectorPopoverPlacement();\n\n\tif ( ! fields || fields.length === 0 ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<DropdownMenu\n\t\t\ticon={ moreVertical }\n\t\t\tlabel={ __( 'Options' ) }\n\t\t\tpopoverProps={ popoverProps }\n\t\t>\n\t\t\t{ ( { onClose } ) => (\n\t\t\t\t<MenuGroup label={ __( 'Show / Hide' ) }>\n\t\t\t\t\t{ fields.map( ( field ) => {\n\t\t\t\t\t\tconst isVisible = visibleFields.includes( field.id );\n\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\t\tkey={ field.id }\n\t\t\t\t\t\t\t\tisSelected={ isVisible }\n\t\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\t\tonToggleField( field.id );\n\t\t\t\t\t\t\t\t\tonClose();\n\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\trole=\"menuitemcheckbox\"\n\t\t\t\t\t\t\t\ticon={ isVisible ? check : null }\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{ field.label }\n\t\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t\t);\n\t\t\t\t\t} ) }\n\t\t\t\t</MenuGroup>\n\t\t\t) }\n\t\t</DropdownMenu>\n\t);\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,wBAAkD;AAClD,mBAAoC;AACpC,kBAAmB;AAKnB,6CAA6C;AAwBtC;AAtBQ,SAAR,mBAAqC;AAAA,EAC3C;AAAA,EACA;AAAA,EACA;AACD,GAAI;AACH,QAAM,EAAE,aAAa,QAAI,qEAA6B;AAEtD,MAAK,CAAE,UAAU,OAAO,WAAW,GAAI;AACtC,WAAO;AAAA,EACR;AAEA,SACC;AAAA,IAAC;AAAA;AAAA,MACA,MAAO;AAAA,MACP,WAAQ,gBAAI,SAAU;AAAA,MACtB;AAAA,MAEE,WAAE,EAAE,QAAQ,MACb,4CAAC,+BAAU,WAAQ,gBAAI,aAAc,GAClC,iBAAO,IAAK,CAAE,UAAW;AAC1B,cAAM,YAAY,cAAc,SAAU,MAAM,EAAG;AACnD,eACC;AAAA,UAAC;AAAA;AAAA,YAEA,YAAa;AAAA,YACb,SAAU,MAAM;AACf,4BAAe,MAAM,EAAG;AACxB,sBAAQ;AAAA,YACT;AAAA,YACA,MAAK;AAAA,YACL,MAAO,YAAY,qBAAQ;AAAA,YAEzB,gBAAM;AAAA;AAAA,UATF,MAAM;AAAA,QAUb;AAAA,MAEF,CAAE,GACH;AAAA;AAAA,EAEF;AAEF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -38,44 +38,99 @@ var import_components = require("@wordpress/components");
|
|
|
38
38
|
var import_data = require("@wordpress/data");
|
|
39
39
|
var import_i18n = require("@wordpress/i18n");
|
|
40
40
|
var import_icons = require("@wordpress/icons");
|
|
41
|
+
var import_dataviews = require("@wordpress/dataviews");
|
|
42
|
+
var import_element = require("@wordpress/element");
|
|
41
43
|
var import_lock_unlock = require("../../lock-unlock");
|
|
42
44
|
var import_store = require("../../store");
|
|
43
45
|
var import_block_icon = __toESM(require("../block-icon"));
|
|
44
46
|
var import_use_block_display_title = __toESM(require("../block-title/use-block-display-title"));
|
|
45
47
|
var import_use_block_display_information = __toESM(require("../use-block-display-information"));
|
|
46
|
-
var
|
|
47
|
-
var import_plain_text = __toESM(require("./plain-text"));
|
|
48
|
+
var import_fields_dropdown_menu = __toESM(require("./fields-dropdown-menu"));
|
|
48
49
|
var import_rich_text = __toESM(require("./rich-text"));
|
|
49
50
|
var import_media = __toESM(require("./media"));
|
|
50
51
|
var import_link = __toESM(require("./link"));
|
|
51
52
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
52
|
-
var
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
53
|
+
var { fieldsKey, formKey } = (0, import_lock_unlock.unlock)(import_blocks.privateApis);
|
|
54
|
+
var CONTROLS = {
|
|
55
|
+
richtext: import_rich_text.default,
|
|
56
|
+
media: import_media.default,
|
|
57
|
+
link: import_link.default
|
|
57
58
|
};
|
|
58
|
-
function
|
|
59
|
-
|
|
60
|
-
control
|
|
61
|
-
blockType,
|
|
62
|
-
attributeValues
|
|
63
|
-
}) {
|
|
64
|
-
const { updateBlockAttributes } = (0, import_data.useDispatch)(import_store.store);
|
|
65
|
-
const ControlComponent = controls[control.type];
|
|
59
|
+
function createConfiguredControl(config) {
|
|
60
|
+
const { control, ...controlConfig } = config;
|
|
61
|
+
const ControlComponent = CONTROLS[control];
|
|
66
62
|
if (!ControlComponent) {
|
|
67
|
-
|
|
63
|
+
throw new Error(`Control type "${control}" not found`);
|
|
68
64
|
}
|
|
69
|
-
return
|
|
70
|
-
ControlComponent,
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
65
|
+
return function ConfiguredControl(props) {
|
|
66
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ControlComponent, { ...props, config: controlConfig });
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
function normalizeMediaValue(value, fieldDef) {
|
|
70
|
+
const defaults = {
|
|
71
|
+
id: null,
|
|
72
|
+
url: "",
|
|
73
|
+
caption: "",
|
|
74
|
+
alt: "",
|
|
75
|
+
type: "image",
|
|
76
|
+
poster: "",
|
|
77
|
+
featuredImage: false,
|
|
78
|
+
link: ""
|
|
79
|
+
};
|
|
80
|
+
const result = {};
|
|
81
|
+
if (fieldDef?.mapping) {
|
|
82
|
+
Object.keys(fieldDef.mapping).forEach((key) => {
|
|
83
|
+
result[key] = value?.[key] ?? defaults[key] ?? "";
|
|
84
|
+
});
|
|
85
|
+
return result;
|
|
86
|
+
}
|
|
87
|
+
Object.keys(defaults).forEach((key) => {
|
|
88
|
+
result[key] = value?.[key] ?? defaults[key];
|
|
89
|
+
});
|
|
90
|
+
return result;
|
|
91
|
+
}
|
|
92
|
+
function denormalizeMediaValue(value, fieldDef) {
|
|
93
|
+
if (!fieldDef.mapping) {
|
|
94
|
+
return value;
|
|
95
|
+
}
|
|
96
|
+
const result = {};
|
|
97
|
+
Object.entries(fieldDef.mapping).forEach(([key]) => {
|
|
98
|
+
if (key in value) {
|
|
99
|
+
result[key] = value[key];
|
|
77
100
|
}
|
|
78
|
-
);
|
|
101
|
+
});
|
|
102
|
+
return result;
|
|
103
|
+
}
|
|
104
|
+
function normalizeLinkValue(value, fieldDef) {
|
|
105
|
+
const defaults = {
|
|
106
|
+
url: "",
|
|
107
|
+
rel: "",
|
|
108
|
+
linkTarget: "",
|
|
109
|
+
destination: ""
|
|
110
|
+
};
|
|
111
|
+
const result = {};
|
|
112
|
+
if (fieldDef?.mapping) {
|
|
113
|
+
Object.keys(fieldDef.mapping).forEach((key) => {
|
|
114
|
+
result[key] = value?.[key] ?? defaults[key] ?? "";
|
|
115
|
+
});
|
|
116
|
+
return result;
|
|
117
|
+
}
|
|
118
|
+
Object.keys(defaults).forEach((key) => {
|
|
119
|
+
result[key] = value?.[key] ?? defaults[key];
|
|
120
|
+
});
|
|
121
|
+
return result;
|
|
122
|
+
}
|
|
123
|
+
function denormalizeLinkValue(value, fieldDef) {
|
|
124
|
+
if (!fieldDef.mapping) {
|
|
125
|
+
return value;
|
|
126
|
+
}
|
|
127
|
+
const result = {};
|
|
128
|
+
Object.entries(fieldDef.mapping).forEach(([key]) => {
|
|
129
|
+
if (key in value) {
|
|
130
|
+
result[key] = value[key];
|
|
131
|
+
}
|
|
132
|
+
});
|
|
133
|
+
return result;
|
|
79
134
|
}
|
|
80
135
|
function BlockFields({ clientId }) {
|
|
81
136
|
const { attributes, blockType } = (0, import_data.useSelect)(
|
|
@@ -90,36 +145,162 @@ function BlockFields({ clientId }) {
|
|
|
90
145
|
},
|
|
91
146
|
[clientId]
|
|
92
147
|
);
|
|
148
|
+
const { updateBlockAttributes } = (0, import_data.useDispatch)(import_store.store);
|
|
93
149
|
const blockTitle = (0, import_use_block_display_title.default)({
|
|
94
150
|
clientId,
|
|
95
151
|
context: "list-view"
|
|
96
152
|
});
|
|
97
153
|
const blockInformation = (0, import_use_block_display_information.default)(clientId);
|
|
98
|
-
const
|
|
99
|
-
|
|
154
|
+
const blockTypeFields = blockType?.[fieldsKey];
|
|
155
|
+
const [form, setForm] = (0, import_element.useState)(() => {
|
|
156
|
+
return blockType?.[formKey];
|
|
157
|
+
});
|
|
158
|
+
const dataFormFields = (0, import_element.useMemo)(() => {
|
|
159
|
+
if (!blockTypeFields?.length) {
|
|
160
|
+
return [];
|
|
161
|
+
}
|
|
162
|
+
return blockTypeFields.map((fieldDef) => {
|
|
163
|
+
const ControlComponent = CONTROLS[fieldDef.type];
|
|
164
|
+
const defaultValues = {};
|
|
165
|
+
if (fieldDef.mapping && blockType?.attributes) {
|
|
166
|
+
Object.entries(fieldDef.mapping).forEach(
|
|
167
|
+
([key, attrKey]) => {
|
|
168
|
+
defaultValues[key] = blockType.attributes[attrKey]?.defaultValue ?? void 0;
|
|
169
|
+
}
|
|
170
|
+
);
|
|
171
|
+
}
|
|
172
|
+
const field = {
|
|
173
|
+
id: fieldDef.id,
|
|
174
|
+
label: fieldDef.label,
|
|
175
|
+
type: fieldDef.type,
|
|
176
|
+
// Use the field's type; DataForm will use built-in or custom Edit
|
|
177
|
+
config: { ...fieldDef.args, defaultValues },
|
|
178
|
+
hideLabelFromVision: fieldDef.id === "content",
|
|
179
|
+
// getValue and setValue handle the mapping to block attributes
|
|
180
|
+
getValue: ({ item }) => {
|
|
181
|
+
if (fieldDef.mapping) {
|
|
182
|
+
const mappedValue = {};
|
|
183
|
+
Object.entries(fieldDef.mapping).forEach(
|
|
184
|
+
([key, attrKey]) => {
|
|
185
|
+
mappedValue[key] = item[attrKey];
|
|
186
|
+
}
|
|
187
|
+
);
|
|
188
|
+
if (fieldDef.type === "media") {
|
|
189
|
+
return normalizeMediaValue(mappedValue, fieldDef);
|
|
190
|
+
}
|
|
191
|
+
if (fieldDef.type === "link") {
|
|
192
|
+
return normalizeLinkValue(mappedValue, fieldDef);
|
|
193
|
+
}
|
|
194
|
+
return mappedValue;
|
|
195
|
+
}
|
|
196
|
+
return item[fieldDef.id];
|
|
197
|
+
},
|
|
198
|
+
setValue: ({ item, value }) => {
|
|
199
|
+
if (fieldDef.mapping) {
|
|
200
|
+
let denormalizedValue = value;
|
|
201
|
+
if (fieldDef.type === "media") {
|
|
202
|
+
denormalizedValue = denormalizeMediaValue(
|
|
203
|
+
value,
|
|
204
|
+
fieldDef
|
|
205
|
+
);
|
|
206
|
+
} else if (fieldDef.type === "link") {
|
|
207
|
+
denormalizedValue = denormalizeLinkValue(
|
|
208
|
+
value,
|
|
209
|
+
fieldDef
|
|
210
|
+
);
|
|
211
|
+
}
|
|
212
|
+
const updates = {};
|
|
213
|
+
Object.entries(fieldDef.mapping).forEach(
|
|
214
|
+
([key, attrKey]) => {
|
|
215
|
+
if (key in denormalizedValue) {
|
|
216
|
+
updates[attrKey] = denormalizedValue[key];
|
|
217
|
+
} else {
|
|
218
|
+
updates[attrKey] = item[attrKey];
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
);
|
|
222
|
+
return updates;
|
|
223
|
+
}
|
|
224
|
+
return { [fieldDef.id]: value };
|
|
225
|
+
}
|
|
226
|
+
};
|
|
227
|
+
if (ControlComponent) {
|
|
228
|
+
field.Edit = createConfiguredControl({
|
|
229
|
+
control: fieldDef.type,
|
|
230
|
+
clientId,
|
|
231
|
+
updateBlockAttributes,
|
|
232
|
+
fieldDef
|
|
233
|
+
});
|
|
234
|
+
}
|
|
235
|
+
return field;
|
|
236
|
+
});
|
|
237
|
+
}, [
|
|
238
|
+
blockTypeFields,
|
|
239
|
+
blockType?.attributes,
|
|
240
|
+
clientId,
|
|
241
|
+
updateBlockAttributes
|
|
242
|
+
]);
|
|
243
|
+
const handleToggleField = (fieldId) => {
|
|
244
|
+
setForm((prev) => {
|
|
245
|
+
if (prev.fields?.includes(fieldId)) {
|
|
246
|
+
return {
|
|
247
|
+
...prev,
|
|
248
|
+
fields: prev.fields.filter((id) => id !== fieldId)
|
|
249
|
+
};
|
|
250
|
+
}
|
|
251
|
+
return {
|
|
252
|
+
...prev,
|
|
253
|
+
fields: [...prev.fields || [], fieldId]
|
|
254
|
+
};
|
|
255
|
+
});
|
|
256
|
+
};
|
|
257
|
+
if (!blockTypeFields?.length) {
|
|
100
258
|
return null;
|
|
101
259
|
}
|
|
102
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.
|
|
103
|
-
import_components.
|
|
104
|
-
|
|
105
|
-
label: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_components.__experimentalHStack, { spacing: 1, children: [
|
|
260
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "block-editor-content-only-controls__fields-container", children: [
|
|
261
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "block-editor-content-only-controls__fields-header", children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_components.__experimentalHStack, { spacing: 1, justify: "space-between", expanded: true, children: [
|
|
262
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_components.__experimentalHStack, { spacing: 1, justify: "flex-start", children: [
|
|
106
263
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_block_icon.default, { icon: blockInformation?.icon }),
|
|
107
264
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { children: blockTitle })
|
|
108
265
|
] }),
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
children: blockType?.fields?.map((field, index) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
112
|
-
BlockAttributeToolsPanelItem,
|
|
266
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
267
|
+
import_fields_dropdown_menu.default,
|
|
113
268
|
{
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
269
|
+
fields: dataFormFields,
|
|
270
|
+
visibleFields: form.fields,
|
|
271
|
+
onToggleField: handleToggleField
|
|
272
|
+
}
|
|
273
|
+
)
|
|
274
|
+
] }) }),
|
|
275
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
276
|
+
import_dataviews.DataForm,
|
|
277
|
+
{
|
|
278
|
+
data: attributes,
|
|
279
|
+
fields: dataFormFields,
|
|
280
|
+
form,
|
|
281
|
+
onChange: (changes) => {
|
|
282
|
+
const mappedChanges = {};
|
|
283
|
+
Object.entries(changes).forEach(
|
|
284
|
+
([fieldId, fieldValue]) => {
|
|
285
|
+
const field = dataFormFields.find(
|
|
286
|
+
(f) => f.id === fieldId
|
|
287
|
+
);
|
|
288
|
+
if (field && field.setValue) {
|
|
289
|
+
const updates = field.setValue({
|
|
290
|
+
item: attributes,
|
|
291
|
+
value: fieldValue
|
|
292
|
+
});
|
|
293
|
+
Object.assign(mappedChanges, updates);
|
|
294
|
+
} else {
|
|
295
|
+
mappedChanges[fieldId] = fieldValue;
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
);
|
|
299
|
+
updateBlockAttributes(clientId, mappedChanges);
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
)
|
|
303
|
+
] });
|
|
123
304
|
}
|
|
124
305
|
function DrillDownButton({ clientId }) {
|
|
125
306
|
const blockTitle = (0, import_use_block_display_title.default)({
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/content-only-controls/index.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { store as blocksStore } from '@wordpress/blocks';\nimport {\n\t__experimentalToolsPanel as ToolsPanel,\n\t__experimentalHStack as HStack,\n\tIcon,\n\tNavigator,\n} from '@wordpress/components';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { __ } from '@wordpress/i18n';\nimport { arrowLeft, arrowRight } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../../lock-unlock';\nimport { store as blockEditorStore } from '../../store';\nimport BlockIcon from '../block-icon';\nimport useBlockDisplayTitle from '../block-title/use-block-display-title';\nimport useBlockDisplayInformation from '../use-block-display-information';\nimport { useInspectorPopoverPlacement } from './use-inspector-popover-placement';\n\n// controls\nimport PlainText from './plain-text';\nimport RichText from './rich-text';\nimport Media from './media';\nimport Link from './link';\n\nconst controls = {\n\tPlainText,\n\tRichText,\n\tMedia,\n\tLink,\n};\n\nfunction BlockAttributeToolsPanelItem( {\n\tclientId,\n\tcontrol,\n\tblockType,\n\tattributeValues,\n} ) {\n\tconst { updateBlockAttributes } = useDispatch( blockEditorStore );\n\tconst ControlComponent = controls[ control.type ];\n\n\tif ( ! ControlComponent ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<ControlComponent\n\t\t\tclientId={ clientId }\n\t\t\tcontrol={ control }\n\t\t\tblockType={ blockType }\n\t\t\tattributeValues={ attributeValues }\n\t\t\tupdateAttributes={ ( attributes ) =>\n\t\t\t\tupdateBlockAttributes( clientId, attributes )\n\t\t\t}\n\t\t/>\n\t);\n}\n\nfunction BlockFields( { clientId } ) {\n\tconst { attributes, blockType } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getBlockAttributes, getBlockName } =\n\t\t\t\tselect( blockEditorStore );\n\t\t\tconst { getBlockType } = select( blocksStore );\n\t\t\tconst blockName = getBlockName( clientId );\n\t\t\treturn {\n\t\t\t\tattributes: getBlockAttributes( clientId ),\n\t\t\t\tblockType: getBlockType( blockName ),\n\t\t\t};\n\t\t},\n\t\t[ clientId ]\n\t);\n\n\tconst blockTitle = useBlockDisplayTitle( {\n\t\tclientId,\n\t\tcontext: 'list-view',\n\t} );\n\tconst blockInformation = useBlockDisplayInformation( clientId );\n\tconst popoverPlacementProps = useInspectorPopoverPlacement();\n\n\tif ( ! blockType?.fields?.length ) {\n\t\t// TODO - we might still want to show a placeholder for blocks with no fields.\n\t\t// for example, a way to select the block.\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<ToolsPanel\n\t\t\tlabel={\n\t\t\t\t<HStack spacing={ 1 }>\n\t\t\t\t\t<BlockIcon icon={ blockInformation?.icon } />\n\t\t\t\t\t<div>{ blockTitle }</div>\n\t\t\t\t</HStack>\n\t\t\t}\n\t\t\tpanelId={ clientId }\n\t\t\tdropdownMenuProps={ popoverPlacementProps }\n\t\t>\n\t\t\t{ blockType?.fields?.map( ( field, index ) => (\n\t\t\t\t<BlockAttributeToolsPanelItem\n\t\t\t\t\tkey={ `${ clientId }/${ index }` }\n\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\tcontrol={ field }\n\t\t\t\t\tblockType={ blockType }\n\t\t\t\t\tattributeValues={ attributes }\n\t\t\t\t/>\n\t\t\t) ) }\n\t\t</ToolsPanel>\n\t);\n}\n\nfunction DrillDownButton( { clientId } ) {\n\tconst blockTitle = useBlockDisplayTitle( {\n\t\tclientId,\n\t\tcontext: 'list-view',\n\t} );\n\tconst blockInformation = useBlockDisplayInformation( clientId );\n\treturn (\n\t\t<div className=\"block-editor-content-only-controls__button-panel\">\n\t\t\t<Navigator.Button\n\t\t\t\tpath={ `/${ clientId }` }\n\t\t\t\tclassName=\"block-editor-content-only-controls__drill-down-button\"\n\t\t\t>\n\t\t\t\t<HStack expanded justify=\"space-between\">\n\t\t\t\t\t<HStack justify=\"flex-start\" spacing={ 1 }>\n\t\t\t\t\t\t<BlockIcon icon={ blockInformation?.icon } />\n\t\t\t\t\t\t<div>{ blockTitle }</div>\n\t\t\t\t\t</HStack>\n\t\t\t\t\t<Icon icon={ arrowRight } />\n\t\t\t\t</HStack>\n\t\t\t</Navigator.Button>\n\t\t</div>\n\t);\n}\n\nfunction ContentOnlyControlsScreen( {\n\trootClientId,\n\tcontentClientIds,\n\tparentClientIds,\n\tisNested,\n} ) {\n\tconst isRootContentBlock = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getBlockName } = select( blockEditorStore );\n\t\t\tconst blockName = getBlockName( rootClientId );\n\t\t\tconst { hasContentRoleAttribute } = unlock( select( blocksStore ) );\n\t\t\treturn hasContentRoleAttribute( blockName );\n\t\t},\n\t\t[ rootClientId ]\n\t);\n\n\tif ( ! isRootContentBlock && ! contentClientIds.length ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t{ isNested && (\n\t\t\t\t<div className=\"block-editor-content-only-controls__button-panel\">\n\t\t\t\t\t<Navigator.BackButton className=\"block-editor-content-only-controls__back-button\">\n\t\t\t\t\t\t<HStack expanded spacing={ 1 } justify=\"flex-start\">\n\t\t\t\t\t\t\t<Icon icon={ arrowLeft } />\n\t\t\t\t\t\t\t<div>{ __( 'Back' ) }</div>\n\t\t\t\t\t\t</HStack>\n\t\t\t\t\t</Navigator.BackButton>\n\t\t\t\t</div>\n\t\t\t) }\n\t\t\t{ isRootContentBlock && <BlockFields clientId={ rootClientId } /> }\n\t\t\t{ contentClientIds.map( ( clientId ) => {\n\t\t\t\tif ( parentClientIds?.[ clientId ] ) {\n\t\t\t\t\treturn (\n\t\t\t\t\t\t<DrillDownButton\n\t\t\t\t\t\t\tkey={ clientId }\n\t\t\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\t\t/>\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\treturn <BlockFields key={ clientId } clientId={ clientId } />;\n\t\t\t} ) }\n\t\t</>\n\t);\n}\n\nexport default function ContentOnlyControls( { rootClientId } ) {\n\tconst { updatedRootClientId, nestedContentClientIds, contentClientIds } =\n\t\tuseSelect(\n\t\t\t( select ) => {\n\t\t\t\tconst { getClientIdsOfDescendants, getBlockEditingMode } =\n\t\t\t\t\tselect( blockEditorStore );\n\n\t\t\t\t// _nestedContentClientIds is for content blocks within 'drilldowns'.\n\t\t\t\t// It's an object where the key is the parent clientId, and the element is\n\t\t\t\t// an array of child clientIds whose controls are shown within the drilldown.\n\t\t\t\tconst _nestedContentClientIds = {};\n\n\t\t\t\t// _contentClientIds is the list of contentClientIds for blocks being\n\t\t\t\t// shown at the root level. Includes parent blocks that might have a drilldown,\n\t\t\t\t// but not the children of those blocks.\n\t\t\t\tconst _contentClientIds = [];\n\n\t\t\t\t// An array of all nested client ids. Used for ensuring blocks within drilldowns\n\t\t\t\t// don't appear at the root level.\n\t\t\t\tlet allNestedClientIds = [];\n\n\t\t\t\t// A flattened list of all content clientIds to arrange into the\n\t\t\t\t// groups above.\n\t\t\t\tconst allContentClientIds = getClientIdsOfDescendants(\n\t\t\t\t\trootClientId\n\t\t\t\t).filter(\n\t\t\t\t\t( clientId ) =>\n\t\t\t\t\t\tgetBlockEditingMode( clientId ) === 'contentOnly'\n\t\t\t\t);\n\n\t\t\t\tfor ( const clientId of allContentClientIds ) {\n\t\t\t\t\tconst childClientIds = getClientIdsOfDescendants(\n\t\t\t\t\t\tclientId\n\t\t\t\t\t).filter(\n\t\t\t\t\t\t( childClientId ) =>\n\t\t\t\t\t\t\tgetBlockEditingMode( childClientId ) ===\n\t\t\t\t\t\t\t'contentOnly'\n\t\t\t\t\t);\n\n\t\t\t\t\t// If there's more than one child block, use a drilldown.\n\t\t\t\t\tif (\n\t\t\t\t\t\tchildClientIds.length > 1 &&\n\t\t\t\t\t\t! allNestedClientIds.includes( clientId )\n\t\t\t\t\t) {\n\t\t\t\t\t\t_nestedContentClientIds[ clientId ] = childClientIds;\n\t\t\t\t\t\tallNestedClientIds = [\n\t\t\t\t\t\t\tallNestedClientIds,\n\t\t\t\t\t\t\t...childClientIds,\n\t\t\t\t\t\t];\n\t\t\t\t\t}\n\n\t\t\t\t\tif ( ! allNestedClientIds.includes( clientId ) ) {\n\t\t\t\t\t\t_contentClientIds.push( clientId );\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\t// Avoid showing only one drilldown block at the root.\n\t\t\t\tif (\n\t\t\t\t\t_contentClientIds.length === 1 &&\n\t\t\t\t\tObject.keys( _nestedContentClientIds ).length === 1\n\t\t\t\t) {\n\t\t\t\t\tconst onlyParentClientId = Object.keys(\n\t\t\t\t\t\t_nestedContentClientIds\n\t\t\t\t\t)[ 0 ];\n\t\t\t\t\treturn {\n\t\t\t\t\t\tupdatedRootClientId: onlyParentClientId,\n\t\t\t\t\t\tcontentClientIds:\n\t\t\t\t\t\t\t_nestedContentClientIds[ onlyParentClientId ],\n\t\t\t\t\t\tnestedContentClientIds: {},\n\t\t\t\t\t};\n\t\t\t\t}\n\n\t\t\t\treturn {\n\t\t\t\t\tnestedContentClientIds: _nestedContentClientIds,\n\t\t\t\t\tcontentClientIds: _contentClientIds,\n\t\t\t\t};\n\t\t\t},\n\t\t\t[ rootClientId ]\n\t\t);\n\n\treturn (\n\t\t<Navigator initialPath=\"/\">\n\t\t\t<Navigator.Screen\n\t\t\t\tpath=\"/\"\n\t\t\t\tclassName=\"block-editor-content-only-controls__screen\"\n\t\t\t>\n\t\t\t\t<ContentOnlyControlsScreen\n\t\t\t\t\trootClientId={ updatedRootClientId ?? rootClientId }\n\t\t\t\t\tcontentClientIds={ contentClientIds }\n\t\t\t\t\tparentClientIds={ nestedContentClientIds }\n\t\t\t\t/>\n\t\t\t</Navigator.Screen>\n\t\t\t{ Object.keys( nestedContentClientIds ).map( ( clientId ) => (\n\t\t\t\t<Navigator.Screen\n\t\t\t\t\tkey={ clientId }\n\t\t\t\t\tpath={ `/${ clientId }` }\n\t\t\t\t\tclassName=\"block-editor-content-only-controls__screen\"\n\t\t\t\t>\n\t\t\t\t\t<ContentOnlyControlsScreen\n\t\t\t\t\t\tisNested\n\t\t\t\t\t\trootClientId={ clientId }\n\t\t\t\t\t\tcontentClientIds={ nestedContentClientIds[ clientId ] }\n\t\t\t\t\t/>\n\t\t\t\t</Navigator.Screen>\n\t\t\t) ) }\n\t\t</Navigator>\n\t);\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,
|
|
6
|
-
"names": ["
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport {\n\tstore as blocksStore,\n\tprivateApis as blocksPrivateApis,\n} from '@wordpress/blocks';\nimport {\n\t__experimentalHStack as HStack,\n\tIcon,\n\tNavigator,\n} from '@wordpress/components';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { __ } from '@wordpress/i18n';\nimport { arrowLeft, arrowRight } from '@wordpress/icons';\nimport { DataForm } from '@wordpress/dataviews';\nimport { useState, useMemo } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../../lock-unlock';\nimport { store as blockEditorStore } from '../../store';\nimport BlockIcon from '../block-icon';\nimport useBlockDisplayTitle from '../block-title/use-block-display-title';\nimport useBlockDisplayInformation from '../use-block-display-information';\nconst { fieldsKey, formKey } = unlock( blocksPrivateApis );\nimport FieldsDropdownMenu from './fields-dropdown-menu';\n\n// controls\nimport RichText from './rich-text';\nimport Media from './media';\nimport Link from './link';\n\nconst CONTROLS = {\n\trichtext: RichText,\n\tmedia: Media,\n\tlink: Link,\n};\n\n/**\n * Creates a configured control component that wraps a custom control\n * and passes configuration as props.\n *\n * @param {Object} config - The control configuration\n * @param {string} config.control - The control type (key in CONTROLS map)\n * @return {Function} A wrapped control component\n */\nfunction createConfiguredControl( config ) {\n\tconst { control, ...controlConfig } = config;\n\tconst ControlComponent = CONTROLS[ control ];\n\n\tif ( ! ControlComponent ) {\n\t\tthrow new Error( `Control type \"${ control }\" not found` );\n\t}\n\n\treturn function ConfiguredControl( props ) {\n\t\treturn <ControlComponent { ...props } config={ controlConfig } />;\n\t};\n}\n\n/**\n * Normalize a media value to a canonical structure.\n * Only includes properties that are present in the field's mapping (if provided).\n *\n * @param {Object} value - The mapped value from the block attributes (with canonical keys)\n * @param {Object} fieldDef - Optional field definition containing the mapping\n * @return {Object} Normalized media value with canonical properties\n */\nfunction normalizeMediaValue( value, fieldDef ) {\n\tconst defaults = {\n\t\tid: null,\n\t\turl: '',\n\t\tcaption: '',\n\t\talt: '',\n\t\ttype: 'image',\n\t\tposter: '',\n\t\tfeaturedImage: false,\n\t\tlink: '',\n\t};\n\n\tconst result = {};\n\n\t// If there's a mapping, only include properties that are in it\n\tif ( fieldDef?.mapping ) {\n\t\tObject.keys( fieldDef.mapping ).forEach( ( key ) => {\n\t\t\tresult[ key ] = value?.[ key ] ?? defaults[ key ] ?? '';\n\t\t} );\n\t\treturn result;\n\t}\n\n\t// Without mapping, include all default properties\n\tObject.keys( defaults ).forEach( ( key ) => {\n\t\tresult[ key ] = value?.[ key ] ?? defaults[ key ];\n\t} );\n\treturn result;\n}\n\n/**\n * Denormalize a media value from canonical structure back to mapped keys.\n * Only includes properties that are present in the field's mapping.\n *\n * @param {Object} value - The normalized media value\n * @param {Object} fieldDef - The field definition containing the mapping\n * @return {Object} Value with only mapped properties\n */\nfunction denormalizeMediaValue( value, fieldDef ) {\n\tif ( ! fieldDef.mapping ) {\n\t\treturn value;\n\t}\n\n\tconst result = {};\n\tObject.entries( fieldDef.mapping ).forEach( ( [ key ] ) => {\n\t\tif ( key in value ) {\n\t\t\tresult[ key ] = value[ key ];\n\t\t}\n\t} );\n\treturn result;\n}\n\n/**\n * Normalize a link value to a canonical structure.\n * Only includes properties that are present in the field's mapping (if provided).\n *\n * @param {Object} value - The mapped value from the block attributes (with canonical keys)\n * @param {Object} fieldDef - Optional field definition containing the mapping\n * @return {Object} Normalized link value with canonical properties\n */\nfunction normalizeLinkValue( value, fieldDef ) {\n\tconst defaults = {\n\t\turl: '',\n\t\trel: '',\n\t\tlinkTarget: '',\n\t\tdestination: '',\n\t};\n\n\tconst result = {};\n\n\t// If there's a mapping, only include properties that are in it\n\tif ( fieldDef?.mapping ) {\n\t\tObject.keys( fieldDef.mapping ).forEach( ( key ) => {\n\t\t\tresult[ key ] = value?.[ key ] ?? defaults[ key ] ?? '';\n\t\t} );\n\t\treturn result;\n\t}\n\n\t// Without mapping, include all default properties\n\tObject.keys( defaults ).forEach( ( key ) => {\n\t\tresult[ key ] = value?.[ key ] ?? defaults[ key ];\n\t} );\n\treturn result;\n}\n\n/**\n * Denormalize a link value from canonical structure back to mapped keys.\n * Only includes properties that are present in the field's mapping.\n *\n * @param {Object} value - The normalized link value\n * @param {Object} fieldDef - The field definition containing the mapping\n * @return {Object} Value with only mapped properties\n */\nfunction denormalizeLinkValue( value, fieldDef ) {\n\tif ( ! fieldDef.mapping ) {\n\t\treturn value;\n\t}\n\n\tconst result = {};\n\tObject.entries( fieldDef.mapping ).forEach( ( [ key ] ) => {\n\t\tif ( key in value ) {\n\t\t\tresult[ key ] = value[ key ];\n\t\t}\n\t} );\n\treturn result;\n}\n\nfunction BlockFields( { clientId } ) {\n\tconst { attributes, blockType } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getBlockAttributes, getBlockName } =\n\t\t\t\tselect( blockEditorStore );\n\t\t\tconst { getBlockType } = select( blocksStore );\n\t\t\tconst blockName = getBlockName( clientId );\n\t\t\treturn {\n\t\t\t\tattributes: getBlockAttributes( clientId ),\n\t\t\t\tblockType: getBlockType( blockName ),\n\t\t\t};\n\t\t},\n\t\t[ clientId ]\n\t);\n\n\tconst { updateBlockAttributes } = useDispatch( blockEditorStore );\n\tconst blockTitle = useBlockDisplayTitle( {\n\t\tclientId,\n\t\tcontext: 'list-view',\n\t} );\n\tconst blockInformation = useBlockDisplayInformation( clientId );\n\n\tconst blockTypeFields = blockType?.[ fieldsKey ];\n\n\tconst [ form, setForm ] = useState( () => {\n\t\treturn blockType?.[ formKey ];\n\t} );\n\n\t// Build DataForm fields with proper structure\n\tconst dataFormFields = useMemo( () => {\n\t\tif ( ! blockTypeFields?.length ) {\n\t\t\treturn [];\n\t\t}\n\n\t\treturn blockTypeFields.map( ( fieldDef ) => {\n\t\t\tconst ControlComponent = CONTROLS[ fieldDef.type ];\n\n\t\t\tconst defaultValues = {};\n\t\t\tif ( fieldDef.mapping && blockType?.attributes ) {\n\t\t\t\tObject.entries( fieldDef.mapping ).forEach(\n\t\t\t\t\t( [ key, attrKey ] ) => {\n\t\t\t\t\t\tdefaultValues[ key ] =\n\t\t\t\t\t\t\tblockType.attributes[ attrKey ]?.defaultValue ??\n\t\t\t\t\t\t\tundefined;\n\t\t\t\t\t}\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tconst field = {\n\t\t\t\tid: fieldDef.id,\n\t\t\t\tlabel: fieldDef.label,\n\t\t\t\ttype: fieldDef.type, // Use the field's type; DataForm will use built-in or custom Edit\n\t\t\t\tconfig: { ...fieldDef.args, defaultValues },\n\t\t\t\thideLabelFromVision: fieldDef.id === 'content',\n\t\t\t\t// getValue and setValue handle the mapping to block attributes\n\t\t\t\tgetValue: ( { item } ) => {\n\t\t\t\t\tif ( fieldDef.mapping ) {\n\t\t\t\t\t\t// Extract mapped properties from the block attributes\n\t\t\t\t\t\tconst mappedValue = {};\n\t\t\t\t\t\tObject.entries( fieldDef.mapping ).forEach(\n\t\t\t\t\t\t\t( [ key, attrKey ] ) => {\n\t\t\t\t\t\t\t\tmappedValue[ key ] = item[ attrKey ];\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t);\n\n\t\t\t\t\t\t// Normalize to canonical structure based on field type\n\t\t\t\t\t\tif ( fieldDef.type === 'media' ) {\n\t\t\t\t\t\t\treturn normalizeMediaValue( mappedValue, fieldDef );\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif ( fieldDef.type === 'link' ) {\n\t\t\t\t\t\t\treturn normalizeLinkValue( mappedValue, fieldDef );\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t// For other types, return as-is\n\t\t\t\t\t\treturn mappedValue;\n\t\t\t\t\t}\n\t\t\t\t\t// For simple id-based fields, use the id as the attribute key\n\t\t\t\t\treturn item[ fieldDef.id ];\n\t\t\t\t},\n\t\t\t\tsetValue: ( { item, value } ) => {\n\t\t\t\t\tif ( fieldDef.mapping ) {\n\t\t\t\t\t\t// Denormalize from canonical structure back to mapped keys\n\t\t\t\t\t\tlet denormalizedValue = value;\n\t\t\t\t\t\tif ( fieldDef.type === 'media' ) {\n\t\t\t\t\t\t\tdenormalizedValue = denormalizeMediaValue(\n\t\t\t\t\t\t\t\tvalue,\n\t\t\t\t\t\t\t\tfieldDef\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t} else if ( fieldDef.type === 'link' ) {\n\t\t\t\t\t\t\tdenormalizedValue = denormalizeLinkValue(\n\t\t\t\t\t\t\t\tvalue,\n\t\t\t\t\t\t\t\tfieldDef\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t// Build an object with all mapped attributes\n\t\t\t\t\t\tconst updates = {};\n\t\t\t\t\t\tObject.entries( fieldDef.mapping ).forEach(\n\t\t\t\t\t\t\t( [ key, attrKey ] ) => {\n\t\t\t\t\t\t\t\t// If key is explicitly in value, use it (even if undefined to allow clearing)\n\t\t\t\t\t\t\t\t// Otherwise, preserve the old value\n\t\t\t\t\t\t\t\tif ( key in denormalizedValue ) {\n\t\t\t\t\t\t\t\t\tupdates[ attrKey ] =\n\t\t\t\t\t\t\t\t\t\tdenormalizedValue[ key ];\n\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\tupdates[ attrKey ] = item[ attrKey ];\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t);\n\t\t\t\t\t\treturn updates;\n\t\t\t\t\t}\n\t\t\t\t\t// For simple id-based fields, use the id as the attribute key\n\t\t\t\t\treturn { [ fieldDef.id ]: value };\n\t\t\t\t},\n\t\t\t};\n\n\t\t\t// Only add custom Edit component if one exists for this type\n\t\t\tif ( ControlComponent ) {\n\t\t\t\t// Use EditConfig pattern: Edit is an object with control type and config props\n\t\t\t\tfield.Edit = createConfiguredControl( {\n\t\t\t\t\tcontrol: fieldDef.type,\n\t\t\t\t\tclientId,\n\t\t\t\t\tupdateBlockAttributes,\n\t\t\t\t\tfieldDef,\n\t\t\t\t} );\n\t\t\t}\n\n\t\t\treturn field;\n\t\t} );\n\t}, [\n\t\tblockTypeFields,\n\t\tblockType?.attributes,\n\t\tclientId,\n\t\tupdateBlockAttributes,\n\t] );\n\n\tconst handleToggleField = ( fieldId ) => {\n\t\tsetForm( ( prev ) => {\n\t\t\tif ( prev.fields?.includes( fieldId ) ) {\n\t\t\t\treturn {\n\t\t\t\t\t...prev,\n\t\t\t\t\tfields: prev.fields.filter( ( id ) => id !== fieldId ),\n\t\t\t\t};\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\t...prev,\n\t\t\t\tfields: [ ...( prev.fields || [] ), fieldId ],\n\t\t\t};\n\t\t} );\n\t};\n\n\tif ( ! blockTypeFields?.length ) {\n\t\t// TODO - we might still want to show a placeholder for blocks with no fields.\n\t\t// for example, a way to select the block.\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<div className=\"block-editor-content-only-controls__fields-container\">\n\t\t\t<div className=\"block-editor-content-only-controls__fields-header\">\n\t\t\t\t<HStack spacing={ 1 } justify=\"space-between\" expanded>\n\t\t\t\t\t<HStack spacing={ 1 } justify=\"flex-start\">\n\t\t\t\t\t\t<BlockIcon icon={ blockInformation?.icon } />\n\t\t\t\t\t\t<div>{ blockTitle }</div>\n\t\t\t\t\t</HStack>\n\t\t\t\t\t<FieldsDropdownMenu\n\t\t\t\t\t\tfields={ dataFormFields }\n\t\t\t\t\t\tvisibleFields={ form.fields }\n\t\t\t\t\t\tonToggleField={ handleToggleField }\n\t\t\t\t\t/>\n\t\t\t\t</HStack>\n\t\t\t</div>\n\t\t\t<DataForm\n\t\t\t\tdata={ attributes }\n\t\t\t\tfields={ dataFormFields }\n\t\t\t\tform={ form }\n\t\t\t\tonChange={ ( changes ) => {\n\t\t\t\t\t// Map field values to block attributes using field.setValue\n\t\t\t\t\tconst mappedChanges = {};\n\t\t\t\t\tObject.entries( changes ).forEach(\n\t\t\t\t\t\t( [ fieldId, fieldValue ] ) => {\n\t\t\t\t\t\t\tconst field = dataFormFields.find(\n\t\t\t\t\t\t\t\t( f ) => f.id === fieldId\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\tif ( field && field.setValue ) {\n\t\t\t\t\t\t\t\tconst updates = field.setValue( {\n\t\t\t\t\t\t\t\t\titem: attributes,\n\t\t\t\t\t\t\t\t\tvalue: fieldValue,\n\t\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\t\tObject.assign( mappedChanges, updates );\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t// For fields without setValue, use the value directly\n\t\t\t\t\t\t\t\tmappedChanges[ fieldId ] = fieldValue;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t);\n\t\t\t\t\tupdateBlockAttributes( clientId, mappedChanges );\n\t\t\t\t} }\n\t\t\t/>\n\t\t</div>\n\t);\n}\n\nfunction DrillDownButton( { clientId } ) {\n\tconst blockTitle = useBlockDisplayTitle( {\n\t\tclientId,\n\t\tcontext: 'list-view',\n\t} );\n\tconst blockInformation = useBlockDisplayInformation( clientId );\n\treturn (\n\t\t<div className=\"block-editor-content-only-controls__button-panel\">\n\t\t\t<Navigator.Button\n\t\t\t\tpath={ `/${ clientId }` }\n\t\t\t\tclassName=\"block-editor-content-only-controls__drill-down-button\"\n\t\t\t>\n\t\t\t\t<HStack expanded justify=\"space-between\">\n\t\t\t\t\t<HStack justify=\"flex-start\" spacing={ 1 }>\n\t\t\t\t\t\t<BlockIcon icon={ blockInformation?.icon } />\n\t\t\t\t\t\t<div>{ blockTitle }</div>\n\t\t\t\t\t</HStack>\n\t\t\t\t\t<Icon icon={ arrowRight } />\n\t\t\t\t</HStack>\n\t\t\t</Navigator.Button>\n\t\t</div>\n\t);\n}\n\nfunction ContentOnlyControlsScreen( {\n\trootClientId,\n\tcontentClientIds,\n\tparentClientIds,\n\tisNested,\n} ) {\n\tconst isRootContentBlock = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getBlockName } = select( blockEditorStore );\n\t\t\tconst blockName = getBlockName( rootClientId );\n\t\t\tconst { hasContentRoleAttribute } = unlock( select( blocksStore ) );\n\t\t\treturn hasContentRoleAttribute( blockName );\n\t\t},\n\t\t[ rootClientId ]\n\t);\n\n\tif ( ! isRootContentBlock && ! contentClientIds.length ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t{ isNested && (\n\t\t\t\t<div className=\"block-editor-content-only-controls__button-panel\">\n\t\t\t\t\t<Navigator.BackButton className=\"block-editor-content-only-controls__back-button\">\n\t\t\t\t\t\t<HStack expanded spacing={ 1 } justify=\"flex-start\">\n\t\t\t\t\t\t\t<Icon icon={ arrowLeft } />\n\t\t\t\t\t\t\t<div>{ __( 'Back' ) }</div>\n\t\t\t\t\t\t</HStack>\n\t\t\t\t\t</Navigator.BackButton>\n\t\t\t\t</div>\n\t\t\t) }\n\t\t\t{ isRootContentBlock && <BlockFields clientId={ rootClientId } /> }\n\t\t\t{ contentClientIds.map( ( clientId ) => {\n\t\t\t\tif ( parentClientIds?.[ clientId ] ) {\n\t\t\t\t\treturn (\n\t\t\t\t\t\t<DrillDownButton\n\t\t\t\t\t\t\tkey={ clientId }\n\t\t\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\t\t/>\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\treturn <BlockFields key={ clientId } clientId={ clientId } />;\n\t\t\t} ) }\n\t\t</>\n\t);\n}\n\nexport default function ContentOnlyControls( { rootClientId } ) {\n\tconst { updatedRootClientId, nestedContentClientIds, contentClientIds } =\n\t\tuseSelect(\n\t\t\t( select ) => {\n\t\t\t\tconst { getClientIdsOfDescendants, getBlockEditingMode } =\n\t\t\t\t\tselect( blockEditorStore );\n\n\t\t\t\t// _nestedContentClientIds is for content blocks within 'drilldowns'.\n\t\t\t\t// It's an object where the key is the parent clientId, and the element is\n\t\t\t\t// an array of child clientIds whose controls are shown within the drilldown.\n\t\t\t\tconst _nestedContentClientIds = {};\n\n\t\t\t\t// _contentClientIds is the list of contentClientIds for blocks being\n\t\t\t\t// shown at the root level. Includes parent blocks that might have a drilldown,\n\t\t\t\t// but not the children of those blocks.\n\t\t\t\tconst _contentClientIds = [];\n\n\t\t\t\t// An array of all nested client ids. Used for ensuring blocks within drilldowns\n\t\t\t\t// don't appear at the root level.\n\t\t\t\tlet allNestedClientIds = [];\n\n\t\t\t\t// A flattened list of all content clientIds to arrange into the\n\t\t\t\t// groups above.\n\t\t\t\tconst allContentClientIds = getClientIdsOfDescendants(\n\t\t\t\t\trootClientId\n\t\t\t\t).filter(\n\t\t\t\t\t( clientId ) =>\n\t\t\t\t\t\tgetBlockEditingMode( clientId ) === 'contentOnly'\n\t\t\t\t);\n\n\t\t\t\tfor ( const clientId of allContentClientIds ) {\n\t\t\t\t\tconst childClientIds = getClientIdsOfDescendants(\n\t\t\t\t\t\tclientId\n\t\t\t\t\t).filter(\n\t\t\t\t\t\t( childClientId ) =>\n\t\t\t\t\t\t\tgetBlockEditingMode( childClientId ) ===\n\t\t\t\t\t\t\t'contentOnly'\n\t\t\t\t\t);\n\n\t\t\t\t\t// If there's more than one child block, use a drilldown.\n\t\t\t\t\tif (\n\t\t\t\t\t\tchildClientIds.length > 1 &&\n\t\t\t\t\t\t! allNestedClientIds.includes( clientId )\n\t\t\t\t\t) {\n\t\t\t\t\t\t_nestedContentClientIds[ clientId ] = childClientIds;\n\t\t\t\t\t\tallNestedClientIds = [\n\t\t\t\t\t\t\tallNestedClientIds,\n\t\t\t\t\t\t\t...childClientIds,\n\t\t\t\t\t\t];\n\t\t\t\t\t}\n\n\t\t\t\t\tif ( ! allNestedClientIds.includes( clientId ) ) {\n\t\t\t\t\t\t_contentClientIds.push( clientId );\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\t// Avoid showing only one drilldown block at the root.\n\t\t\t\tif (\n\t\t\t\t\t_contentClientIds.length === 1 &&\n\t\t\t\t\tObject.keys( _nestedContentClientIds ).length === 1\n\t\t\t\t) {\n\t\t\t\t\tconst onlyParentClientId = Object.keys(\n\t\t\t\t\t\t_nestedContentClientIds\n\t\t\t\t\t)[ 0 ];\n\t\t\t\t\treturn {\n\t\t\t\t\t\tupdatedRootClientId: onlyParentClientId,\n\t\t\t\t\t\tcontentClientIds:\n\t\t\t\t\t\t\t_nestedContentClientIds[ onlyParentClientId ],\n\t\t\t\t\t\tnestedContentClientIds: {},\n\t\t\t\t\t};\n\t\t\t\t}\n\n\t\t\t\treturn {\n\t\t\t\t\tnestedContentClientIds: _nestedContentClientIds,\n\t\t\t\t\tcontentClientIds: _contentClientIds,\n\t\t\t\t};\n\t\t\t},\n\t\t\t[ rootClientId ]\n\t\t);\n\n\treturn (\n\t\t<Navigator initialPath=\"/\">\n\t\t\t<Navigator.Screen\n\t\t\t\tpath=\"/\"\n\t\t\t\tclassName=\"block-editor-content-only-controls__screen\"\n\t\t\t>\n\t\t\t\t<ContentOnlyControlsScreen\n\t\t\t\t\trootClientId={ updatedRootClientId ?? rootClientId }\n\t\t\t\t\tcontentClientIds={ contentClientIds }\n\t\t\t\t\tparentClientIds={ nestedContentClientIds }\n\t\t\t\t/>\n\t\t\t</Navigator.Screen>\n\t\t\t{ Object.keys( nestedContentClientIds ).map( ( clientId ) => (\n\t\t\t\t<Navigator.Screen\n\t\t\t\t\tkey={ clientId }\n\t\t\t\t\tpath={ `/${ clientId }` }\n\t\t\t\t\tclassName=\"block-editor-content-only-controls__screen\"\n\t\t\t\t>\n\t\t\t\t\t<ContentOnlyControlsScreen\n\t\t\t\t\t\tisNested\n\t\t\t\t\t\trootClientId={ clientId }\n\t\t\t\t\t\tcontentClientIds={ nestedContentClientIds[ clientId ] }\n\t\t\t\t\t/>\n\t\t\t\t</Navigator.Screen>\n\t\t\t) ) }\n\t\t</Navigator>\n\t);\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,oBAGO;AACP,wBAIO;AACP,kBAAuC;AACvC,kBAAmB;AACnB,mBAAsC;AACtC,uBAAyB;AACzB,qBAAkC;AAKlC,yBAAuB;AACvB,mBAA0C;AAC1C,wBAAsB;AACtB,qCAAiC;AACjC,2CAAuC;AAEvC,kCAA+B;AAG/B,uBAAqB;AACrB,mBAAkB;AAClB,kBAAiB;AAyBR;AA/BT,IAAM,EAAE,WAAW,QAAQ,QAAI,2BAAQ,cAAAA,WAAkB;AAQzD,IAAM,WAAW;AAAA,EAChB,UAAU,iBAAAC;AAAA,EACV,OAAO,aAAAC;AAAA,EACP,MAAM,YAAAC;AACP;AAUA,SAAS,wBAAyB,QAAS;AAC1C,QAAM,EAAE,SAAS,GAAG,cAAc,IAAI;AACtC,QAAM,mBAAmB,SAAU,OAAQ;AAE3C,MAAK,CAAE,kBAAmB;AACzB,UAAM,IAAI,MAAO,iBAAkB,OAAQ,aAAc;AAAA,EAC1D;AAEA,SAAO,SAAS,kBAAmB,OAAQ;AAC1C,WAAO,4CAAC,oBAAmB,GAAG,OAAQ,QAAS,eAAgB;AAAA,EAChE;AACD;AAUA,SAAS,oBAAqB,OAAO,UAAW;AAC/C,QAAM,WAAW;AAAA,IAChB,IAAI;AAAA,IACJ,KAAK;AAAA,IACL,SAAS;AAAA,IACT,KAAK;AAAA,IACL,MAAM;AAAA,IACN,QAAQ;AAAA,IACR,eAAe;AAAA,IACf,MAAM;AAAA,EACP;AAEA,QAAM,SAAS,CAAC;AAGhB,MAAK,UAAU,SAAU;AACxB,W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AAAA,QACF;AAGA,YACC,eAAe,SAAS,KACxB,CAAE,mBAAmB,SAAU,QAAS,GACvC;AACD,kCAAyB,QAAS,IAAI;AACtC,+BAAqB;AAAA,YACpB;AAAA,YACA,GAAG;AAAA,UACJ;AAAA,QACD;AAEA,YAAK,CAAE,mBAAmB,SAAU,QAAS,GAAI;AAChD,4BAAkB,KAAM,QAAS;AAAA,QAClC;AAAA,MACD;AAGA,UACC,kBAAkB,WAAW,KAC7B,OAAO,KAAM,uBAAwB,EAAE,WAAW,GACjD;AACD,cAAM,qBAAqB,OAAO;AAAA,UACjC;AAAA,QACD,EAAG,CAAE;AACL,eAAO;AAAA,UACN,qBAAqB;AAAA,UACrB,kBACC,wBAAyB,kBAAmB;AAAA,UAC7C,wBAAwB,CAAC;AAAA,QAC1B;AAAA,MACD;AAEA,aAAO;AAAA,QACN,wBAAwB;AAAA,QACxB,kBAAkB;AAAA,MACnB;AAAA,IACD;AAAA,IACA,CAAE,YAAa;AAAA,EAChB;AAED,SACC,6CAAC,+BAAU,aAAY,KACtB;AAAA;AAAA,MAAC,4BAAU;AAAA,MAAV;AAAA,QACA,MAAK;AAAA,QACL,WAAU;AAAA,QAEV;AAAA,UAAC;AAAA;AAAA,YACA,cAAe,uBAAuB;AAAA,YACtC;AAAA,YACA,iBAAkB;AAAA;AAAA,QACnB;AAAA;AAAA,IACD;AAAA,IACE,OAAO,KAAM,sBAAuB,EAAE,IAAK,CAAE,aAC9C;AAAA,MAAC,4BAAU;AAAA,MAAV;AAAA,QAEA,MAAO,IAAK,QAAS;AAAA,QACrB,WAAU;AAAA,QAEV;AAAA,UAAC;AAAA;AAAA,YACA,UAAQ;AAAA,YACR,cAAe;AAAA,YACf,kBAAmB,uBAAwB,QAAS;AAAA;AAAA,QACrD;AAAA;AAAA,MARM;AAAA,IASP,CACC;AAAA,KACH;AAEF;",
|
|
6
|
+
"names": ["blocksPrivateApis", "RichText", "Media", "Link", "blockEditorStore", "blocksStore", "useBlockDisplayTitle", "useBlockDisplayInformation", "HStack", "BlockIcon", "FieldsDropdownMenu"]
|
|
7
7
|
}
|