@wordpress/block-editor 15.12.0 → 15.12.2-next.v.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 +6 -0
- package/build/components/block-allowed-blocks/modal.cjs +1 -1
- package/build/components/block-allowed-blocks/modal.cjs.map +2 -2
- package/build/components/block-inspector/index.cjs +9 -9
- package/build/components/block-inspector/index.cjs.map +3 -3
- package/build/components/block-removal-warning-modal/index.cjs +30 -5
- package/build/components/block-removal-warning-modal/index.cjs.map +3 -3
- package/build/components/block-visibility/use-block-visibility.cjs +14 -29
- package/build/components/block-visibility/use-block-visibility.cjs.map +2 -2
- package/build/components/global-styles/hooks.cjs +7 -0
- package/build/components/global-styles/hooks.cjs.map +2 -2
- package/build/components/global-styles/typography-panel.cjs +71 -3
- package/build/components/global-styles/typography-panel.cjs.map +3 -3
- package/build/components/grid/grid-visualizer.cjs +49 -13
- package/build/components/grid/grid-visualizer.cjs.map +2 -2
- package/build/components/iframe/index.cjs +3 -1
- package/build/components/iframe/index.cjs.map +2 -2
- package/build/components/iframe/use-scale-canvas.cjs +1 -0
- package/build/components/iframe/use-scale-canvas.cjs.map +2 -2
- package/build/components/inspector-controls/last-item.cjs +41 -0
- package/build/components/inspector-controls/last-item.cjs.map +7 -0
- package/build/components/inspector-controls-tabs/styles-tab.cjs +3 -3
- package/build/components/inspector-controls-tabs/styles-tab.cjs.map +2 -2
- package/build/components/link-control/index.cjs +73 -2
- package/build/components/link-control/index.cjs.map +3 -3
- package/build/components/link-control/is-url-like.cjs +15 -3
- package/build/components/link-control/is-url-like.cjs.map +2 -2
- package/build/components/link-control/search-input.cjs +4 -1
- package/build/components/link-control/search-input.cjs.map +2 -2
- package/build/components/link-control/use-search-handler.cjs +1 -1
- package/build/components/link-control/use-search-handler.cjs.map +2 -2
- package/build/components/provider/use-block-sync.cjs +60 -8
- package/build/components/provider/use-block-sync.cjs.map +2 -2
- package/build/components/text-indent-control/index.cjs +121 -0
- package/build/components/text-indent-control/index.cjs.map +7 -0
- package/build/components/url-input/index.cjs +22 -2
- package/build/components/url-input/index.cjs.map +3 -3
- package/build/components/url-popover/image-url-input-ui.cjs +1 -1
- package/build/components/url-popover/image-url-input-ui.cjs.map +2 -2
- package/build/components/writing-flow/use-arrow-nav.cjs +0 -3
- package/build/components/writing-flow/use-arrow-nav.cjs.map +2 -2
- package/build/hooks/anchor.cjs +1 -1
- package/build/hooks/anchor.cjs.map +1 -1
- package/build/hooks/aria-label.cjs +2 -1
- package/build/hooks/aria-label.cjs.map +2 -2
- package/build/hooks/grid-visualizer.cjs +59 -6
- package/build/hooks/grid-visualizer.cjs.map +3 -3
- package/build/hooks/layout-child.cjs +47 -6
- package/build/hooks/layout-child.cjs.map +3 -3
- package/build/hooks/typography.cjs +2 -0
- package/build/hooks/typography.cjs.map +2 -2
- package/build/hooks/utils.cjs +4 -0
- package/build/hooks/utils.cjs.map +2 -2
- package/build/private-apis.cjs +2 -0
- package/build/private-apis.cjs.map +3 -3
- package/build/store/actions.cjs +2 -2
- package/build/store/actions.cjs.map +2 -2
- package/build-module/components/block-allowed-blocks/modal.mjs +2 -2
- package/build-module/components/block-allowed-blocks/modal.mjs.map +2 -2
- package/build-module/components/block-inspector/index.mjs +10 -9
- package/build-module/components/block-inspector/index.mjs.map +2 -2
- package/build-module/components/block-removal-warning-modal/index.mjs +34 -7
- package/build-module/components/block-removal-warning-modal/index.mjs.map +2 -2
- package/build-module/components/block-visibility/use-block-visibility.mjs +14 -29
- package/build-module/components/block-visibility/use-block-visibility.mjs.map +2 -2
- package/build-module/components/global-styles/hooks.mjs +7 -0
- package/build-module/components/global-styles/hooks.mjs.map +2 -2
- package/build-module/components/global-styles/typography-panel.mjs +73 -4
- package/build-module/components/global-styles/typography-panel.mjs.map +2 -2
- package/build-module/components/grid/grid-visualizer.mjs +50 -14
- package/build-module/components/grid/grid-visualizer.mjs.map +2 -2
- package/build-module/components/iframe/index.mjs +9 -2
- package/build-module/components/iframe/index.mjs.map +2 -2
- package/build-module/components/iframe/use-scale-canvas.mjs +1 -0
- package/build-module/components/iframe/use-scale-canvas.mjs.map +2 -2
- package/build-module/components/inspector-controls/last-item.mjs +23 -0
- package/build-module/components/inspector-controls/last-item.mjs.map +7 -0
- package/build-module/components/inspector-controls-tabs/styles-tab.mjs +3 -3
- package/build-module/components/inspector-controls-tabs/styles-tab.mjs.map +2 -2
- package/build-module/components/link-control/index.mjs +74 -3
- package/build-module/components/link-control/index.mjs.map +2 -2
- package/build-module/components/link-control/is-url-like.mjs +10 -3
- package/build-module/components/link-control/is-url-like.mjs.map +2 -2
- package/build-module/components/link-control/search-input.mjs +4 -1
- package/build-module/components/link-control/search-input.mjs.map +2 -2
- package/build-module/components/link-control/use-search-handler.mjs +2 -2
- package/build-module/components/link-control/use-search-handler.mjs.map +2 -2
- package/build-module/components/provider/use-block-sync.mjs +60 -8
- package/build-module/components/provider/use-block-sync.mjs.map +2 -2
- package/build-module/components/text-indent-control/index.mjs +110 -0
- package/build-module/components/text-indent-control/index.mjs.map +7 -0
- package/build-module/components/url-input/index.mjs +24 -4
- package/build-module/components/url-input/index.mjs.map +2 -2
- package/build-module/components/url-popover/image-url-input-ui.mjs +2 -2
- package/build-module/components/url-popover/image-url-input-ui.mjs.map +2 -2
- package/build-module/components/writing-flow/use-arrow-nav.mjs +0 -3
- package/build-module/components/writing-flow/use-arrow-nav.mjs.map +2 -2
- package/build-module/hooks/anchor.mjs +1 -1
- package/build-module/hooks/anchor.mjs.map +1 -1
- package/build-module/hooks/aria-label.mjs +2 -1
- package/build-module/hooks/aria-label.mjs.map +2 -2
- package/build-module/hooks/grid-visualizer.mjs +37 -6
- package/build-module/hooks/grid-visualizer.mjs.map +2 -2
- package/build-module/hooks/layout-child.mjs +37 -6
- package/build-module/hooks/layout-child.mjs.map +2 -2
- package/build-module/hooks/typography.mjs +2 -0
- package/build-module/hooks/typography.mjs.map +2 -2
- package/build-module/hooks/utils.mjs +4 -0
- package/build-module/hooks/utils.mjs.map +2 -2
- package/build-module/private-apis.mjs +2 -0
- package/build-module/private-apis.mjs.map +2 -2
- package/build-module/store/actions.mjs +2 -2
- package/build-module/store/actions.mjs.map +2 -2
- package/package.json +39 -39
- package/src/components/block-allowed-blocks/modal.js +2 -2
- package/src/components/block-inspector/index.js +19 -17
- package/src/components/block-removal-warning-modal/index.js +55 -19
- package/src/components/block-switcher/block-transformations-menu.native.js +1 -0
- package/src/components/block-toolbar/test/__snapshots__/block-toolbar-menu.native.js.snap +4 -6
- package/src/components/block-toolbar/test/block-toolbar-menu.native.js +2 -2
- package/src/components/block-visibility/use-block-visibility.js +17 -32
- package/src/components/global-styles/hooks.js +10 -0
- package/src/components/global-styles/typography-panel.js +78 -1
- package/src/components/grid/grid-visualizer.js +58 -12
- package/src/components/iframe/index.js +12 -2
- package/src/components/iframe/use-scale-canvas.js +1 -0
- package/src/components/inserter/menu.native.js +1 -0
- package/src/components/inspector-controls/last-item.js +29 -0
- package/src/components/inspector-controls-tabs/styles-tab.js +3 -3
- package/src/components/link-control/index.js +160 -3
- package/src/components/link-control/is-url-like.js +43 -8
- package/src/components/link-control/search-input.js +7 -0
- package/src/components/link-control/test/index.js +260 -0
- package/src/components/link-control/test/is-url-like.js +49 -1
- package/src/components/link-control/use-search-handler.js +2 -2
- package/src/components/provider/test/use-block-sync.js +105 -0
- package/src/components/provider/use-block-sync.js +118 -9
- package/src/components/text-indent-control/index.js +138 -0
- package/src/components/url-input/index.js +21 -2
- package/src/components/url-popover/image-url-input-ui.js +2 -2
- package/src/components/writing-flow/use-arrow-nav.js +0 -4
- package/src/hooks/anchor.js +1 -1
- package/src/hooks/aria-label.js +9 -1
- package/src/hooks/grid-visualizer.js +63 -24
- package/src/hooks/layout-child.js +45 -3
- package/src/hooks/typography.js +2 -0
- package/src/hooks/utils.js +4 -0
- package/src/private-apis.js +2 -0
- package/src/store/actions.js +8 -6
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/block-inspector/index.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport {\n\tgetBlockType,\n\tgetUnregisteredTypeHandlerName,\n\tstore as blocksStore,\n} from '@wordpress/blocks';\nimport { __unstableMotion as motion } from '@wordpress/components';\nimport { useSelect } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport EditContents from './edit-contents';\nimport SkipToSelectedBlock from '../skip-to-selected-block';\nimport BlockCard from '../block-card';\nimport MultiSelectionInspector from '../multi-selection-inspector';\nimport BlockVariationTransforms from '../block-variation-transforms';\nimport useBlockDisplayInformation from '../use-block-display-information';\nimport { store as blockEditorStore } from '../../store';\nimport BlockStyles from '../block-styles';\nimport { default as InspectorControls } from '../inspector-controls';\nimport { default as InspectorControlsTabs } from '../inspector-controls-tabs';\nimport useInspectorControlsTabs from '../inspector-controls-tabs/use-inspector-controls-tabs';\nimport AdvancedControls from '../inspector-controls-tabs/advanced-controls-panel';\nimport PositionControls from '../inspector-controls-tabs/position-controls-panel';\nimport useBlockInspectorAnimationSettings from './useBlockInspectorAnimationSettings';\nimport { useBorderPanelLabel } from '../../hooks/border';\nimport ContentTab from '../inspector-controls-tabs/content-tab';\nimport ViewportVisibilityInfo from '../block-visibility/viewport-visibility-info';\nimport { unlock } from '../../lock-unlock';\n\nfunction StyleInspectorSlots( {\n\tblockName,\n\tshowAdvancedControls = true,\n\tshowPositionControls = true,\n\tshowBindingsControls = true,\n} ) {\n\tconst borderPanelLabel = useBorderPanelLabel( { blockName } );\n\treturn (\n\t\t<>\n\t\t\t<InspectorControls.Slot />\n\t\t\t<InspectorControls.Slot\n\t\t\t\tgroup=\"color\"\n\t\t\t\tlabel={ __( 'Color' ) }\n\t\t\t\tclassName=\"color-block-support-panel__inner-wrapper\"\n\t\t\t/>\n\t\t\t<InspectorControls.Slot\n\t\t\t\tgroup=\"background\"\n\t\t\t\tlabel={ __( 'Background image' ) }\n\t\t\t/>\n\t\t\t<InspectorControls.Slot\n\t\t\t\tgroup=\"typography\"\n\t\t\t\tlabel={ __( 'Typography' ) }\n\t\t\t/>\n\t\t\t<InspectorControls.Slot\n\t\t\t\tgroup=\"dimensions\"\n\t\t\t\tlabel={ __( 'Dimensions' ) }\n\t\t\t/>\n\t\t\t<InspectorControls.Slot group=\"border\" label={ borderPanelLabel } />\n\t\t\t<InspectorControls.Slot group=\"styles\" />\n\t\t\t{ showPositionControls && <PositionControls /> }\n\t\t\t{ showBindingsControls && (\n\t\t\t\t<InspectorControls.Slot group=\"bindings\" />\n\t\t\t) }\n\t\t\t{ showAdvancedControls && (\n\t\t\t\t<div>\n\t\t\t\t\t<AdvancedControls />\n\t\t\t\t</div>\n\t\t\t) }\n\t\t</>\n\t);\n}\n\nfunction BlockInspector() {\n\tconst {\n\t\tselectedBlockCount,\n\t\trenderedBlockName,\n\t\trenderedBlockClientId,\n\t\tblockType,\n\t\tisSectionBlock,\n\t\tisSectionBlockInSelection,\n\t\thasBlockStyles,\n\t\teditedContentOnlySection,\n\t} = useSelect( ( select ) => {\n\t\tconst {\n\t\t\tgetSelectedBlockClientId,\n\t\t\tgetSelectedBlockClientIds,\n\t\t\tgetSelectedBlockCount,\n\t\t\tgetBlockName,\n\t\t\tgetParentSectionBlock,\n\t\t\tisSectionBlock: _isSectionBlock,\n\t\t\tgetEditedContentOnlySection,\n\t\t\tisWithinEditedContentOnlySection,\n\t\t} = unlock( select( blockEditorStore ) );\n\t\tconst { getBlockStyles } = select( blocksStore );\n\t\tconst _selectedBlockClientId = getSelectedBlockClientId();\n\t\tconst isWithinEditedSection = isWithinEditedContentOnlySection(\n\t\t\t_selectedBlockClientId\n\t\t);\n\t\tconst _renderedBlockClientId = isWithinEditedSection\n\t\t\t? _selectedBlockClientId\n\t\t\t: getParentSectionBlock( _selectedBlockClientId ) ||\n\t\t\t _selectedBlockClientId;\n\t\tconst _renderedBlockName =\n\t\t\t_renderedBlockClientId && getBlockName( _renderedBlockClientId );\n\t\tconst _blockType =\n\t\t\t_renderedBlockName && getBlockType( _renderedBlockName );\n\t\tconst selectedBlockClientIds = getSelectedBlockClientIds();\n\t\tconst _isSectionBlockInSelection = selectedBlockClientIds.some(\n\t\t\t( id ) => _isSectionBlock( id )\n\t\t);\n\t\tconst blockStyles =\n\t\t\t_renderedBlockName && getBlockStyles( _renderedBlockName );\n\t\tconst _hasBlockStyles = blockStyles && blockStyles.length > 0;\n\n\t\treturn {\n\t\t\tselectedBlockCount: getSelectedBlockCount(),\n\t\t\trenderedBlockClientId: _renderedBlockClientId,\n\t\t\trenderedBlockName: _renderedBlockName,\n\t\t\tblockType: _blockType,\n\t\t\tisSectionBlockInSelection: _isSectionBlockInSelection,\n\t\t\tisSectionBlock: _isSectionBlock( _renderedBlockClientId ),\n\t\t\thasBlockStyles: _hasBlockStyles,\n\t\t\teditedContentOnlySection: getEditedContentOnlySection(),\n\t\t};\n\t}, [] );\n\n\t// Separate useSelect for contentClientIds with proper dependencies\n\tconst contentClientIds = useSelect(\n\t\t( select ) => {\n\t\t\tif ( ! isSectionBlock || ! renderedBlockClientId ) {\n\t\t\t\treturn [];\n\t\t\t}\n\n\t\t\tconst {\n\t\t\t\tgetClientIdsOfDescendants,\n\t\t\t\tgetBlockName,\n\t\t\t\tgetBlockEditingMode,\n\t\t\t} = unlock( select( blockEditorStore ) );\n\n\t\t\tconst descendants = getClientIdsOfDescendants(\n\t\t\t\trenderedBlockClientId\n\t\t\t);\n\n\t\t\t// Temporary workaround for issue #71991\n\t\t\t// Exclude Navigation block children from Content sidebar until proper\n\t\t\t// drill-down experience is implemented (see #65699)\n\t\t\t// This prevents a poor UX where all Nav block sub-items are shown\n\t\t\t// when the parent block is in contentOnly mode.\n\t\t\t// Build a Set of all navigation block descendants for efficient lookup\n\t\t\tconst navigationDescendants = new Set();\n\t\t\tdescendants.forEach( ( clientId ) => {\n\t\t\t\tif ( getBlockName( clientId ) === 'core/navigation' ) {\n\t\t\t\t\tconst navChildren = getClientIdsOfDescendants( clientId );\n\t\t\t\t\tnavChildren.forEach( ( childId ) =>\n\t\t\t\t\t\tnavigationDescendants.add( childId )\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t} );\n\n\t\t\treturn descendants.filter( ( current ) => {\n\t\t\t\t// Exclude navigation block children\n\t\t\t\tif ( navigationDescendants.has( current ) ) {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\n\t\t\t\treturn (\n\t\t\t\t\tgetBlockName( current ) !== 'core/list-item' &&\n\t\t\t\t\tgetBlockEditingMode( current ) === 'contentOnly'\n\t\t\t\t);\n\t\t\t} );\n\t\t},\n\t\t[ isSectionBlock, renderedBlockClientId ]\n\t);\n\n\tconst availableTabs = useInspectorControlsTabs(\n\t\tblockType?.name,\n\t\tcontentClientIds,\n\t\tisSectionBlock,\n\t\thasBlockStyles\n\t);\n\tconst hasMultipleTabs = availableTabs?.length > 1;\n\n\t// The block inspector animation settings will be completely\n\t// removed in the future to create an API which allows the block\n\t// inspector to transition between what it\n\t// displays based on the relationship between the selected block\n\t// and its parent, and only enable it if the parent is controlling\n\t// its children blocks.\n\tconst blockInspectorAnimationSettings =\n\t\tuseBlockInspectorAnimationSettings( blockType );\n\n\tconst hasSelectedBlocks = selectedBlockCount > 1;\n\n\tif ( hasSelectedBlocks && ! isSectionBlockInSelection ) {\n\t\treturn (\n\t\t\t<div className=\"block-editor-block-inspector\">\n\t\t\t\t<MultiSelectionInspector />\n\t\t\t\t{ hasMultipleTabs ? (\n\t\t\t\t\t<InspectorControlsTabs tabs={ availableTabs } />\n\t\t\t\t) : (\n\t\t\t\t\t<StyleInspectorSlots\n\t\t\t\t\t\tblockName={ renderedBlockName }\n\t\t\t\t\t\tshowAdvancedControls={ false }\n\t\t\t\t\t\tshowPositionControls={ false }\n\t\t\t\t\t\tshowBindingsControls={ false }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t</div>\n\t\t);\n\t}\n\n\tif ( hasSelectedBlocks && isSectionBlockInSelection ) {\n\t\treturn (\n\t\t\t<div className=\"block-editor-block-inspector\">\n\t\t\t\t<MultiSelectionInspector />\n\t\t\t</div>\n\t\t);\n\t}\n\n\tconst isRenderedBlockUnregistered =\n\t\trenderedBlockName === getUnregisteredTypeHandlerName();\n\n\t/*\n\t * If the rendered block is of an unregistered type, avoid showing it as an actual selection\n\t * because we want the user to focus on the unregistered block warning, not block settings.\n\t */\n\tconst shouldShowWarning =\n\t\t! blockType || ! renderedBlockClientId || isRenderedBlockUnregistered;\n\n\tif ( shouldShowWarning ) {\n\t\treturn (\n\t\t\t<span className=\"block-editor-block-inspector__no-blocks\">\n\t\t\t\t{ __( 'No block selected.' ) }\n\t\t\t</span>\n\t\t);\n\t}\n\n\treturn (\n\t\t<BlockInspectorSingleBlockWrapper\n\t\t\tanimate={ blockInspectorAnimationSettings }\n\t\t\twrapper={ ( children ) => (\n\t\t\t\t<AnimatedContainer\n\t\t\t\t\tblockInspectorAnimationSettings={\n\t\t\t\t\t\tblockInspectorAnimationSettings\n\t\t\t\t\t}\n\t\t\t\t\trenderedBlockClientId={ renderedBlockClientId }\n\t\t\t\t>\n\t\t\t\t\t{ children }\n\t\t\t\t</AnimatedContainer>\n\t\t\t) }\n\t\t>\n\t\t\t<BlockInspectorSingleBlock\n\t\t\t\trenderedBlockClientId={ renderedBlockClientId }\n\t\t\t\tblockName={ blockType.name }\n\t\t\t\tisSectionBlock={ isSectionBlock }\n\t\t\t\tavailableTabs={ availableTabs }\n\t\t\t\tcontentClientIds={ contentClientIds }\n\t\t\t\thasBlockStyles={ hasBlockStyles }\n\t\t\t\teditedContentOnlySection={ editedContentOnlySection }\n\t\t\t/>\n\t\t</BlockInspectorSingleBlockWrapper>\n\t);\n}\n\nconst BlockInspectorSingleBlockWrapper = ( { animate, wrapper, children } ) => {\n\treturn animate ? wrapper( children ) : children;\n};\n\nconst AnimatedContainer = ( {\n\tblockInspectorAnimationSettings,\n\trenderedBlockClientId,\n\tchildren,\n} ) => {\n\tconst animationOrigin =\n\t\tblockInspectorAnimationSettings &&\n\t\tblockInspectorAnimationSettings.enterDirection === 'leftToRight'\n\t\t\t? -50\n\t\t\t: 50;\n\n\treturn (\n\t\t<motion.div\n\t\t\tanimate={ {\n\t\t\t\tx: 0,\n\t\t\t\topacity: 1,\n\t\t\t\ttransition: {\n\t\t\t\t\tease: 'easeInOut',\n\t\t\t\t\tduration: 0.14,\n\t\t\t\t},\n\t\t\t} }\n\t\t\tinitial={ {\n\t\t\t\tx: animationOrigin,\n\t\t\t\topacity: 0,\n\t\t\t} }\n\t\t\tkey={ renderedBlockClientId }\n\t\t>\n\t\t\t{ children }\n\t\t</motion.div>\n\t);\n};\n\nconst BlockInspectorSingleBlock = ( {\n\t// The block that is displayed in the inspector. This is the block whose\n\t// controls and information are shown to the user.\n\trenderedBlockClientId,\n\tblockName,\n\tisSectionBlock,\n\tavailableTabs,\n\tcontentClientIds,\n\thasBlockStyles,\n\teditedContentOnlySection,\n} ) => {\n\tconst hasMultipleTabs = availableTabs?.length > 1;\n\tconst hasParentChildBlockCards =\n\t\teditedContentOnlySection &&\n\t\teditedContentOnlySection !== renderedBlockClientId;\n\tconst parentBlockInformation = useBlockDisplayInformation(\n\t\teditedContentOnlySection\n\t);\n\tconst blockInformation = useBlockDisplayInformation(\n\t\trenderedBlockClientId\n\t);\n\tconst isBlockSynced = blockInformation.isSynced;\n\n\treturn (\n\t\t<div className=\"block-editor-block-inspector\">\n\t\t\t{ hasParentChildBlockCards && (\n\t\t\t\t<BlockCard\n\t\t\t\t\t{ ...parentBlockInformation }\n\t\t\t\t\tclassName={ parentBlockInformation.isSynced && 'is-synced' }\n\t\t\t\t\tparentClientId={ editedContentOnlySection }\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t<BlockCard\n\t\t\t\t{ ...blockInformation }\n\t\t\t\tallowParentNavigation\n\t\t\t\tclassName={ isBlockSynced && 'is-synced' }\n\t\t\t\tisChild={ hasParentChildBlockCards }\n\t\t\t\tclientId={ renderedBlockClientId }\n\t\t\t/>\n\t\t\t<ViewportVisibilityInfo clientId={ renderedBlockClientId } />\n\t\t\t<EditContents clientId={ renderedBlockClientId } />\n\t\t\t<BlockVariationTransforms blockClientId={ renderedBlockClientId } />\n\t\t\t{ hasMultipleTabs && (\n\t\t\t\t<>\n\t\t\t\t\t<InspectorControlsTabs\n\t\t\t\t\t\thasBlockStyles={ hasBlockStyles }\n\t\t\t\t\t\tclientId={ renderedBlockClientId }\n\t\t\t\t\t\tblockName={ blockName }\n\t\t\t\t\t\ttabs={ availableTabs }\n\t\t\t\t\t\tisSectionBlock={ isSectionBlock }\n\t\t\t\t\t\tcontentClientIds={ contentClientIds }\n\t\t\t\t\t/>\n\t\t\t\t</>\n\t\t\t) }\n\t\t\t{ ! hasMultipleTabs && (\n\t\t\t\t<>\n\t\t\t\t\t{ hasBlockStyles && (\n\t\t\t\t\t\t<BlockStyles clientId={ renderedBlockClientId } />\n\t\t\t\t\t) }\n\t\t\t\t\t<ContentTab contentClientIds={ contentClientIds } />\n\t\t\t\t\t<InspectorControls.Slot group=\"content\" />\n\t\t\t\t\t<InspectorControls.Slot group=\"list\" />\n\t\t\t\t\t{ ! isSectionBlock && (\n\t\t\t\t\t\t<StyleInspectorSlots blockName={ blockName } />\n\t\t\t\t\t) }\n\t\t\t\t</>\n\t\t\t) }\n\t\t\t<SkipToSelectedBlock key=\"back\" />\n\t\t</div>\n\t);\n};\n\n/**\n * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/block-inspector/README.md\n */\nexport default BlockInspector;\n"],
|
|
5
|
-
"mappings": ";AAGA,SAAS,UAAU;AACnB;AAAA,EACC;AAAA,EACA;AAAA,EACA,SAAS;AAAA,OACH;AACP,SAAS,oBAAoB,cAAc;AAC3C,SAAS,iBAAiB;AAK1B,OAAO,kBAAkB;AACzB,OAAO,yBAAyB;AAChC,OAAO,eAAe;AACtB,OAAO,6BAA6B;AACpC,OAAO,8BAA8B;AACrC,OAAO,gCAA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,cAAc;AAAA,QACnB;AAAA,MACD;
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport {\n\tgetBlockType,\n\tgetUnregisteredTypeHandlerName,\n\thasBlockSupport,\n\tstore as blocksStore,\n} from '@wordpress/blocks';\nimport { __unstableMotion as motion } from '@wordpress/components';\nimport { useSelect } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport EditContents from './edit-contents';\nimport SkipToSelectedBlock from '../skip-to-selected-block';\nimport BlockCard from '../block-card';\nimport MultiSelectionInspector from '../multi-selection-inspector';\nimport BlockVariationTransforms from '../block-variation-transforms';\nimport useBlockDisplayInformation from '../use-block-display-information';\nimport { store as blockEditorStore } from '../../store';\nimport BlockStyles from '../block-styles';\nimport { default as InspectorControls } from '../inspector-controls';\nimport { default as InspectorControlsTabs } from '../inspector-controls-tabs';\nimport useInspectorControlsTabs from '../inspector-controls-tabs/use-inspector-controls-tabs';\nimport InspectorControlsLastItem from '../inspector-controls/last-item';\nimport AdvancedControls from '../inspector-controls-tabs/advanced-controls-panel';\nimport PositionControls from '../inspector-controls-tabs/position-controls-panel';\nimport useBlockInspectorAnimationSettings from './useBlockInspectorAnimationSettings';\nimport { useBorderPanelLabel } from '../../hooks/border';\nimport ContentTab from '../inspector-controls-tabs/content-tab';\nimport ViewportVisibilityInfo from '../block-visibility/viewport-visibility-info';\nimport { unlock } from '../../lock-unlock';\n\nfunction StyleInspectorSlots( {\n\tblockName,\n\tshowAdvancedControls = true,\n\tshowPositionControls = true,\n\tshowBindingsControls = true,\n} ) {\n\tconst borderPanelLabel = useBorderPanelLabel( { blockName } );\n\treturn (\n\t\t<>\n\t\t\t<InspectorControls.Slot />\n\t\t\t<InspectorControls.Slot\n\t\t\t\tgroup=\"color\"\n\t\t\t\tlabel={ __( 'Color' ) }\n\t\t\t\tclassName=\"color-block-support-panel__inner-wrapper\"\n\t\t\t/>\n\t\t\t<InspectorControls.Slot\n\t\t\t\tgroup=\"background\"\n\t\t\t\tlabel={ __( 'Background image' ) }\n\t\t\t/>\n\t\t\t<InspectorControls.Slot\n\t\t\t\tgroup=\"typography\"\n\t\t\t\tlabel={ __( 'Typography' ) }\n\t\t\t/>\n\t\t\t<InspectorControls.Slot\n\t\t\t\tgroup=\"dimensions\"\n\t\t\t\tlabel={ __( 'Dimensions' ) }\n\t\t\t/>\n\t\t\t<InspectorControls.Slot group=\"border\" label={ borderPanelLabel } />\n\t\t\t<InspectorControls.Slot group=\"styles\" />\n\t\t\t{ showPositionControls && <PositionControls /> }\n\t\t\t{ showBindingsControls && (\n\t\t\t\t<InspectorControls.Slot group=\"bindings\" />\n\t\t\t) }\n\t\t\t{ showAdvancedControls && (\n\t\t\t\t<div>\n\t\t\t\t\t<AdvancedControls />\n\t\t\t\t</div>\n\t\t\t) }\n\t\t</>\n\t);\n}\n\nfunction BlockInspector() {\n\tconst {\n\t\tselectedBlockCount,\n\t\trenderedBlockName,\n\t\trenderedBlockClientId,\n\t\tblockType,\n\t\tisSectionBlock,\n\t\tisSectionBlockInSelection,\n\t\thasBlockStyles,\n\t\teditedContentOnlySection,\n\t} = useSelect( ( select ) => {\n\t\tconst {\n\t\t\tgetSelectedBlockClientId,\n\t\t\tgetSelectedBlockClientIds,\n\t\t\tgetSelectedBlockCount,\n\t\t\tgetBlockName,\n\t\t\tgetParentSectionBlock,\n\t\t\tisSectionBlock: _isSectionBlock,\n\t\t\tgetEditedContentOnlySection,\n\t\t\tisWithinEditedContentOnlySection,\n\t\t} = unlock( select( blockEditorStore ) );\n\t\tconst { getBlockStyles } = select( blocksStore );\n\t\tconst _selectedBlockClientId = getSelectedBlockClientId();\n\t\tconst isWithinEditedSection = isWithinEditedContentOnlySection(\n\t\t\t_selectedBlockClientId\n\t\t);\n\t\tconst _renderedBlockClientId = isWithinEditedSection\n\t\t\t? _selectedBlockClientId\n\t\t\t: getParentSectionBlock( _selectedBlockClientId ) ||\n\t\t\t _selectedBlockClientId;\n\t\tconst _renderedBlockName =\n\t\t\t_renderedBlockClientId && getBlockName( _renderedBlockClientId );\n\t\tconst _blockType =\n\t\t\t_renderedBlockName && getBlockType( _renderedBlockName );\n\t\tconst selectedBlockClientIds = getSelectedBlockClientIds();\n\t\tconst _isSectionBlockInSelection = selectedBlockClientIds.some(\n\t\t\t( id ) => _isSectionBlock( id )\n\t\t);\n\t\tconst blockStyles =\n\t\t\t_renderedBlockName && getBlockStyles( _renderedBlockName );\n\t\tconst _hasBlockStyles = blockStyles && blockStyles.length > 0;\n\n\t\treturn {\n\t\t\tselectedBlockCount: getSelectedBlockCount(),\n\t\t\trenderedBlockClientId: _renderedBlockClientId,\n\t\t\trenderedBlockName: _renderedBlockName,\n\t\t\tblockType: _blockType,\n\t\t\tisSectionBlockInSelection: _isSectionBlockInSelection,\n\t\t\tisSectionBlock: _isSectionBlock( _renderedBlockClientId ),\n\t\t\thasBlockStyles: _hasBlockStyles,\n\t\t\teditedContentOnlySection: getEditedContentOnlySection(),\n\t\t};\n\t}, [] );\n\n\t// Separate useSelect for contentClientIds with proper dependencies\n\tconst contentClientIds = useSelect(\n\t\t( select ) => {\n\t\t\tif ( ! isSectionBlock || ! renderedBlockClientId ) {\n\t\t\t\treturn [];\n\t\t\t}\n\n\t\t\tconst {\n\t\t\t\tgetClientIdsOfDescendants,\n\t\t\t\tgetBlockName,\n\t\t\t\tgetBlockEditingMode,\n\t\t\t} = unlock( select( blockEditorStore ) );\n\n\t\t\tconst descendants = getClientIdsOfDescendants(\n\t\t\t\trenderedBlockClientId\n\t\t\t);\n\n\t\t\t// Exclude items from the content tab that are already present in the\n\t\t\t// List View tab.\n\t\t\tconst listViewDescendants = new Set();\n\t\t\tdescendants.forEach( ( clientId ) => {\n\t\t\t\tconst blockName = getBlockName( clientId );\n\t\t\t\t// Navigation block doesn't have List View block support, but\n\t\t\t\t// it does have a custom implementation that is shown within\n\t\t\t\t// patterns, so it's included in this condition.\n\t\t\t\tif (\n\t\t\t\t\tblockName === 'core/navigation' ||\n\t\t\t\t\thasBlockSupport( blockName, 'listView' )\n\t\t\t\t) {\n\t\t\t\t\tconst listViewChildren =\n\t\t\t\t\t\tgetClientIdsOfDescendants( clientId );\n\t\t\t\t\tlistViewChildren.forEach( ( childId ) =>\n\t\t\t\t\t\tlistViewDescendants.add( childId )\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t} );\n\n\t\t\treturn descendants.filter( ( current ) => {\n\t\t\t\treturn (\n\t\t\t\t\t! listViewDescendants.has( current ) &&\n\t\t\t\t\tgetBlockEditingMode( current ) === 'contentOnly'\n\t\t\t\t);\n\t\t\t} );\n\t\t},\n\t\t[ isSectionBlock, renderedBlockClientId ]\n\t);\n\n\tconst availableTabs = useInspectorControlsTabs(\n\t\tblockType?.name,\n\t\tcontentClientIds,\n\t\tisSectionBlock,\n\t\thasBlockStyles\n\t);\n\tconst hasMultipleTabs = availableTabs?.length > 1;\n\n\t// The block inspector animation settings will be completely\n\t// removed in the future to create an API which allows the block\n\t// inspector to transition between what it\n\t// displays based on the relationship between the selected block\n\t// and its parent, and only enable it if the parent is controlling\n\t// its children blocks.\n\tconst blockInspectorAnimationSettings =\n\t\tuseBlockInspectorAnimationSettings( blockType );\n\n\tconst hasSelectedBlocks = selectedBlockCount > 1;\n\n\tif ( hasSelectedBlocks && ! isSectionBlockInSelection ) {\n\t\treturn (\n\t\t\t<div className=\"block-editor-block-inspector\">\n\t\t\t\t<MultiSelectionInspector />\n\t\t\t\t{ hasMultipleTabs ? (\n\t\t\t\t\t<InspectorControlsTabs tabs={ availableTabs } />\n\t\t\t\t) : (\n\t\t\t\t\t<StyleInspectorSlots\n\t\t\t\t\t\tblockName={ renderedBlockName }\n\t\t\t\t\t\tshowAdvancedControls={ false }\n\t\t\t\t\t\tshowPositionControls={ false }\n\t\t\t\t\t\tshowBindingsControls={ false }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t</div>\n\t\t);\n\t}\n\n\tif ( hasSelectedBlocks && isSectionBlockInSelection ) {\n\t\treturn (\n\t\t\t<div className=\"block-editor-block-inspector\">\n\t\t\t\t<MultiSelectionInspector />\n\t\t\t</div>\n\t\t);\n\t}\n\n\tconst isRenderedBlockUnregistered =\n\t\trenderedBlockName === getUnregisteredTypeHandlerName();\n\n\t/*\n\t * If the rendered block is of an unregistered type, avoid showing it as an actual selection\n\t * because we want the user to focus on the unregistered block warning, not block settings.\n\t */\n\tconst shouldShowWarning =\n\t\t! blockType || ! renderedBlockClientId || isRenderedBlockUnregistered;\n\n\tif ( shouldShowWarning ) {\n\t\treturn (\n\t\t\t<span className=\"block-editor-block-inspector__no-blocks\">\n\t\t\t\t{ __( 'No block selected.' ) }\n\t\t\t</span>\n\t\t);\n\t}\n\n\treturn (\n\t\t<BlockInspectorSingleBlockWrapper\n\t\t\tanimate={ blockInspectorAnimationSettings }\n\t\t\twrapper={ ( children ) => (\n\t\t\t\t<AnimatedContainer\n\t\t\t\t\tblockInspectorAnimationSettings={\n\t\t\t\t\t\tblockInspectorAnimationSettings\n\t\t\t\t\t}\n\t\t\t\t\trenderedBlockClientId={ renderedBlockClientId }\n\t\t\t\t>\n\t\t\t\t\t{ children }\n\t\t\t\t</AnimatedContainer>\n\t\t\t) }\n\t\t>\n\t\t\t<BlockInspectorSingleBlock\n\t\t\t\trenderedBlockClientId={ renderedBlockClientId }\n\t\t\t\tblockName={ blockType.name }\n\t\t\t\tisSectionBlock={ isSectionBlock }\n\t\t\t\tavailableTabs={ availableTabs }\n\t\t\t\tcontentClientIds={ contentClientIds }\n\t\t\t\thasBlockStyles={ hasBlockStyles }\n\t\t\t\teditedContentOnlySection={ editedContentOnlySection }\n\t\t\t/>\n\t\t</BlockInspectorSingleBlockWrapper>\n\t);\n}\n\nconst BlockInspectorSingleBlockWrapper = ( { animate, wrapper, children } ) => {\n\treturn animate ? wrapper( children ) : children;\n};\n\nconst AnimatedContainer = ( {\n\tblockInspectorAnimationSettings,\n\trenderedBlockClientId,\n\tchildren,\n} ) => {\n\tconst animationOrigin =\n\t\tblockInspectorAnimationSettings &&\n\t\tblockInspectorAnimationSettings.enterDirection === 'leftToRight'\n\t\t\t? -50\n\t\t\t: 50;\n\n\treturn (\n\t\t<motion.div\n\t\t\tanimate={ {\n\t\t\t\tx: 0,\n\t\t\t\topacity: 1,\n\t\t\t\ttransition: {\n\t\t\t\t\tease: 'easeInOut',\n\t\t\t\t\tduration: 0.14,\n\t\t\t\t},\n\t\t\t} }\n\t\t\tinitial={ {\n\t\t\t\tx: animationOrigin,\n\t\t\t\topacity: 0,\n\t\t\t} }\n\t\t\tkey={ renderedBlockClientId }\n\t\t>\n\t\t\t{ children }\n\t\t</motion.div>\n\t);\n};\n\nconst BlockInspectorSingleBlock = ( {\n\t// The block that is displayed in the inspector. This is the block whose\n\t// controls and information are shown to the user.\n\trenderedBlockClientId,\n\tblockName,\n\tisSectionBlock,\n\tavailableTabs,\n\tcontentClientIds,\n\thasBlockStyles,\n\teditedContentOnlySection,\n} ) => {\n\tconst hasMultipleTabs = availableTabs?.length > 1;\n\tconst hasParentChildBlockCards =\n\t\teditedContentOnlySection &&\n\t\teditedContentOnlySection !== renderedBlockClientId;\n\tconst parentBlockInformation = useBlockDisplayInformation(\n\t\teditedContentOnlySection\n\t);\n\tconst blockInformation = useBlockDisplayInformation(\n\t\trenderedBlockClientId\n\t);\n\tconst isBlockSynced = blockInformation.isSynced;\n\n\treturn (\n\t\t<div className=\"block-editor-block-inspector\">\n\t\t\t{ hasParentChildBlockCards && (\n\t\t\t\t<BlockCard\n\t\t\t\t\t{ ...parentBlockInformation }\n\t\t\t\t\tclassName={ parentBlockInformation.isSynced && 'is-synced' }\n\t\t\t\t\tparentClientId={ editedContentOnlySection }\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t<BlockCard\n\t\t\t\t{ ...blockInformation }\n\t\t\t\tallowParentNavigation\n\t\t\t\tclassName={ isBlockSynced && 'is-synced' }\n\t\t\t\tisChild={ hasParentChildBlockCards }\n\t\t\t\tclientId={ renderedBlockClientId }\n\t\t\t/>\n\t\t\t<ViewportVisibilityInfo clientId={ renderedBlockClientId } />\n\t\t\t<EditContents clientId={ renderedBlockClientId } />\n\t\t\t<BlockVariationTransforms blockClientId={ renderedBlockClientId } />\n\t\t\t{ hasMultipleTabs && (\n\t\t\t\t<>\n\t\t\t\t\t<InspectorControlsTabs\n\t\t\t\t\t\thasBlockStyles={ hasBlockStyles }\n\t\t\t\t\t\tclientId={ renderedBlockClientId }\n\t\t\t\t\t\tblockName={ blockName }\n\t\t\t\t\t\ttabs={ availableTabs }\n\t\t\t\t\t\tisSectionBlock={ isSectionBlock }\n\t\t\t\t\t\tcontentClientIds={ contentClientIds }\n\t\t\t\t\t/>\n\t\t\t\t</>\n\t\t\t) }\n\t\t\t{ ! hasMultipleTabs && (\n\t\t\t\t<>\n\t\t\t\t\t{ hasBlockStyles && (\n\t\t\t\t\t\t<BlockStyles clientId={ renderedBlockClientId } />\n\t\t\t\t\t) }\n\t\t\t\t\t<ContentTab contentClientIds={ contentClientIds } />\n\t\t\t\t\t<InspectorControls.Slot group=\"content\" />\n\t\t\t\t\t<InspectorControls.Slot group=\"list\" />\n\t\t\t\t\t{ ! isSectionBlock && (\n\t\t\t\t\t\t<StyleInspectorSlots blockName={ blockName } />\n\t\t\t\t\t) }\n\t\t\t\t</>\n\t\t\t) }\n\t\t\t<InspectorControlsLastItem.Slot />\n\t\t\t<SkipToSelectedBlock key=\"back\" />\n\t\t</div>\n\t);\n};\n\n/**\n * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/block-inspector/README.md\n */\nexport default BlockInspector;\n"],
|
|
5
|
+
"mappings": ";AAGA,SAAS,UAAU;AACnB;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA,SAAS;AAAA,OACH;AACP,SAAS,oBAAoB,cAAc;AAC3C,SAAS,iBAAiB;AAK1B,OAAO,kBAAkB;AACzB,OAAO,yBAAyB;AAChC,OAAO,eAAe;AACtB,OAAO,6BAA6B;AACpC,OAAO,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A,QACL,WAAY,uBAAuB,YAAY;AAAA,QAC/C,gBAAiB;AAAA;AAAA,IAClB;AAAA,IAED;AAAA,MAAC;AAAA;AAAA,QACE,GAAG;AAAA,QACL,uBAAqB;AAAA,QACrB,WAAY,iBAAiB;AAAA,QAC7B,SAAU;AAAA,QACV,UAAW;AAAA;AAAA,IACZ;AAAA,IACA,oBAAC,0BAAuB,UAAW,uBAAwB;AAAA,IAC3D,oBAAC,gBAAa,UAAW,uBAAwB;AAAA,IACjD,oBAAC,4BAAyB,eAAgB,uBAAwB;AAAA,IAChE,mBACD,gCACC;AAAA,MAAC;AAAA;AAAA,QACA;AAAA,QACA,UAAW;AAAA,QACX;AAAA,QACA,MAAO;AAAA,QACP;AAAA,QACA;AAAA;AAAA,IACD,GACD;AAAA,IAEC,CAAE,mBACH,iCACG;AAAA,wBACD,oBAAC,eAAY,UAAW,uBAAwB;AAAA,MAEjD,oBAAC,cAAW,kBAAsC;AAAA,MAClD,oBAAC,kBAAkB,MAAlB,EAAuB,OAAM,WAAU;AAAA,MACxC,oBAAC,kBAAkB,MAAlB,EAAuB,OAAM,QAAO;AAAA,MACnC,CAAE,kBACH,oBAAC,uBAAoB,WAAwB;AAAA,OAE/C;AAAA,IAED,oBAAC,0BAA0B,MAA1B,EAA+B;AAAA,IAChC,oBAAC,yBAAwB,MAAO;AAAA,KACjC;AAEF;AAKA,IAAO,0BAAQ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,16 +1,19 @@
|
|
|
1
1
|
// packages/block-editor/src/components/block-removal-warning-modal/index.js
|
|
2
|
-
import { useEffect } from "@wordpress/element";
|
|
2
|
+
import { useEffect, useState } from "@wordpress/element";
|
|
3
3
|
import { useDispatch, useSelect } from "@wordpress/data";
|
|
4
4
|
import {
|
|
5
5
|
Modal,
|
|
6
6
|
Button,
|
|
7
|
-
|
|
7
|
+
CheckboxControl,
|
|
8
|
+
__experimentalHStack as HStack,
|
|
9
|
+
__experimentalVStack as VStack
|
|
8
10
|
} from "@wordpress/components";
|
|
9
11
|
import { __ } from "@wordpress/i18n";
|
|
10
12
|
import { store as blockEditorStore } from "../../store/index.mjs";
|
|
11
13
|
import { unlock } from "../../lock-unlock.mjs";
|
|
12
14
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
13
15
|
function BlockRemovalWarningModal({ rules }) {
|
|
16
|
+
const [confirmed, setConfirmed] = useState(false);
|
|
14
17
|
const { clientIds, selectPrevious, message } = useSelect(
|
|
15
18
|
(select) => unlock(select(blockEditorStore)).getRemovalPromptData()
|
|
16
19
|
);
|
|
@@ -25,9 +28,16 @@ function BlockRemovalWarningModal({ rules }) {
|
|
|
25
28
|
setBlockRemovalRules();
|
|
26
29
|
};
|
|
27
30
|
}, [rules, setBlockRemovalRules]);
|
|
31
|
+
useEffect(() => {
|
|
32
|
+
setConfirmed(false);
|
|
33
|
+
}, [clientIds]);
|
|
28
34
|
if (!message) {
|
|
29
35
|
return;
|
|
30
36
|
}
|
|
37
|
+
const isStructured = typeof message === "object" && message !== null;
|
|
38
|
+
const description = isStructured ? message.description : message;
|
|
39
|
+
const requireConfirmation = isStructured && message.requireConfirmation;
|
|
40
|
+
const isRemoveDisabled = requireConfirmation && !confirmed;
|
|
31
41
|
const onConfirmRemoval = () => {
|
|
32
42
|
privateRemoveBlocks(
|
|
33
43
|
clientIds,
|
|
@@ -37,14 +47,29 @@ function BlockRemovalWarningModal({ rules }) {
|
|
|
37
47
|
);
|
|
38
48
|
clearBlockRemovalPrompt();
|
|
39
49
|
};
|
|
40
|
-
return /* @__PURE__ */
|
|
50
|
+
return /* @__PURE__ */ jsx(
|
|
41
51
|
Modal,
|
|
42
52
|
{
|
|
43
|
-
title: __("
|
|
53
|
+
title: __("Confirm deletion"),
|
|
44
54
|
onRequestClose: clearBlockRemovalPrompt,
|
|
45
55
|
size: "medium",
|
|
46
|
-
children: [
|
|
47
|
-
/* @__PURE__ */
|
|
56
|
+
children: /* @__PURE__ */ jsxs(VStack, { spacing: 4, children: [
|
|
57
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
58
|
+
/* @__PURE__ */ jsx("p", { children: description }),
|
|
59
|
+
isStructured && (message.warning || message.subtext) && /* @__PURE__ */ jsxs("p", { children: [
|
|
60
|
+
message.warning && /* @__PURE__ */ jsx("strong", { children: message.warning }),
|
|
61
|
+
message.warning && message.subtext && " ",
|
|
62
|
+
message.subtext
|
|
63
|
+
] })
|
|
64
|
+
] }),
|
|
65
|
+
requireConfirmation && /* @__PURE__ */ jsx(
|
|
66
|
+
CheckboxControl,
|
|
67
|
+
{
|
|
68
|
+
label: __("I understand the consequences"),
|
|
69
|
+
checked: confirmed,
|
|
70
|
+
onChange: setConfirmed
|
|
71
|
+
}
|
|
72
|
+
),
|
|
48
73
|
/* @__PURE__ */ jsxs(HStack, { justify: "right", children: [
|
|
49
74
|
/* @__PURE__ */ jsx(
|
|
50
75
|
Button,
|
|
@@ -60,12 +85,14 @@ function BlockRemovalWarningModal({ rules }) {
|
|
|
60
85
|
{
|
|
61
86
|
variant: "primary",
|
|
62
87
|
onClick: onConfirmRemoval,
|
|
88
|
+
disabled: isRemoveDisabled,
|
|
89
|
+
accessibleWhenDisabled: true,
|
|
63
90
|
__next40pxDefaultSize: true,
|
|
64
91
|
children: __("Delete")
|
|
65
92
|
}
|
|
66
93
|
)
|
|
67
94
|
] })
|
|
68
|
-
]
|
|
95
|
+
] })
|
|
69
96
|
}
|
|
70
97
|
);
|
|
71
98
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/block-removal-warning-modal/index.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useEffect } from '@wordpress/element';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport {\n\tModal,\n\tButton,\n\t__experimentalHStack as HStack,\n} from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\nimport { unlock } from '../../lock-unlock';\n\nexport function BlockRemovalWarningModal( { rules } ) {\n\tconst { clientIds, selectPrevious, message } = useSelect( ( select ) =>\n\t\tunlock( select( blockEditorStore ) ).getRemovalPromptData()\n\t);\n\n\tconst {\n\t\tclearBlockRemovalPrompt,\n\t\tsetBlockRemovalRules,\n\t\tprivateRemoveBlocks,\n\t} = unlock( useDispatch( blockEditorStore ) );\n\n\t// Load block removal rules, simultaneously signalling that the block\n\t// removal prompt is in place.\n\tuseEffect( () => {\n\t\tsetBlockRemovalRules( rules );\n\t\treturn () => {\n\t\t\tsetBlockRemovalRules();\n\t\t};\n\t}, [ rules, setBlockRemovalRules ] );\n\n\tif ( ! message ) {\n\t\treturn;\n\t}\n\n\tconst onConfirmRemoval = () => {\n\t\tprivateRemoveBlocks( clientIds, selectPrevious, /* force */ true );\n\t\tclearBlockRemovalPrompt();\n\t};\n\n\treturn (\n\t\t<Modal\n\t\t\ttitle={ __( '
|
|
5
|
-
"mappings": ";AAGA,SAAS,
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useEffect, useState } from '@wordpress/element';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport {\n\tModal,\n\tButton,\n\tCheckboxControl,\n\t__experimentalHStack as HStack,\n\t__experimentalVStack as VStack,\n} from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\nimport { unlock } from '../../lock-unlock';\n\nexport function BlockRemovalWarningModal( { rules } ) {\n\tconst [ confirmed, setConfirmed ] = useState( false );\n\tconst { clientIds, selectPrevious, message } = useSelect( ( select ) =>\n\t\tunlock( select( blockEditorStore ) ).getRemovalPromptData()\n\t);\n\n\tconst {\n\t\tclearBlockRemovalPrompt,\n\t\tsetBlockRemovalRules,\n\t\tprivateRemoveBlocks,\n\t} = unlock( useDispatch( blockEditorStore ) );\n\n\t// Load block removal rules, simultaneously signalling that the block\n\t// removal prompt is in place.\n\tuseEffect( () => {\n\t\tsetBlockRemovalRules( rules );\n\t\treturn () => {\n\t\t\tsetBlockRemovalRules();\n\t\t};\n\t}, [ rules, setBlockRemovalRules ] );\n\n\t// Reset confirmed state when modal opens with new content.\n\tuseEffect( () => {\n\t\tsetConfirmed( false );\n\t}, [ clientIds ] );\n\n\tif ( ! message ) {\n\t\treturn;\n\t}\n\n\tconst isStructured = typeof message === 'object' && message !== null;\n\tconst description = isStructured ? message.description : message;\n\tconst requireConfirmation = isStructured && message.requireConfirmation;\n\tconst isRemoveDisabled = requireConfirmation && ! confirmed;\n\n\tconst onConfirmRemoval = () => {\n\t\tprivateRemoveBlocks( clientIds, selectPrevious, /* force */ true );\n\t\tclearBlockRemovalPrompt();\n\t};\n\n\treturn (\n\t\t<Modal\n\t\t\ttitle={ __( 'Confirm deletion' ) }\n\t\t\tonRequestClose={ clearBlockRemovalPrompt }\n\t\t\tsize=\"medium\"\n\t\t>\n\t\t\t<VStack spacing={ 4 }>\n\t\t\t\t<div>\n\t\t\t\t\t<p>{ description }</p>\n\t\t\t\t\t{ isStructured &&\n\t\t\t\t\t\t( message.warning || message.subtext ) && (\n\t\t\t\t\t\t\t<p>\n\t\t\t\t\t\t\t\t{ message.warning && (\n\t\t\t\t\t\t\t\t\t<strong>{ message.warning }</strong>\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t{ message.warning && message.subtext && ' ' }\n\t\t\t\t\t\t\t\t{ message.subtext }\n\t\t\t\t\t\t\t</p>\n\t\t\t\t\t\t) }\n\t\t\t\t</div>\n\t\t\t\t{ requireConfirmation && (\n\t\t\t\t\t<CheckboxControl\n\t\t\t\t\t\tlabel={ __( 'I understand the consequences' ) }\n\t\t\t\t\t\tchecked={ confirmed }\n\t\t\t\t\t\tonChange={ setConfirmed }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t\t<HStack justify=\"right\">\n\t\t\t\t\t<Button\n\t\t\t\t\t\tvariant=\"tertiary\"\n\t\t\t\t\t\tonClick={ clearBlockRemovalPrompt }\n\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Cancel' ) }\n\t\t\t\t\t</Button>\n\t\t\t\t\t<Button\n\t\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\t\tonClick={ onConfirmRemoval }\n\t\t\t\t\t\tdisabled={ isRemoveDisabled }\n\t\t\t\t\t\taccessibleWhenDisabled\n\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Delete' ) }\n\t\t\t\t\t</Button>\n\t\t\t\t</HStack>\n\t\t\t</VStack>\n\t\t</Modal>\n\t);\n}\n"],
|
|
5
|
+
"mappings": ";AAGA,SAAS,WAAW,gBAAgB;AACpC,SAAS,aAAa,iBAAiB;AACvC;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA,wBAAwB;AAAA,EACxB,wBAAwB;AAAA,OAClB;AACP,SAAS,UAAU;AAKnB,SAAS,SAAS,wBAAwB;AAC1C,SAAS,cAAc;AAkDlB,cAGE,YAHF;AAhDE,SAAS,yBAA0B,EAAE,MAAM,GAAI;AACrD,QAAM,CAAE,WAAW,YAAa,IAAI,SAAU,KAAM;AACpD,QAAM,EAAE,WAAW,gBAAgB,QAAQ,IAAI;AAAA,IAAW,CAAE,WAC3D,OAAQ,OAAQ,gBAAiB,CAAE,EAAE,qBAAqB;AAAA,EAC3D;AAEA,QAAM;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,EACD,IAAI,OAAQ,YAAa,gBAAiB,CAAE;AAI5C,YAAW,MAAM;AAChB,yBAAsB,KAAM;AAC5B,WAAO,MAAM;AACZ,2BAAqB;AAAA,IACtB;AAAA,EACD,GAAG,CAAE,OAAO,oBAAqB,CAAE;AAGnC,YAAW,MAAM;AAChB,iBAAc,KAAM;AAAA,EACrB,GAAG,CAAE,SAAU,CAAE;AAEjB,MAAK,CAAE,SAAU;A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ibility/use-block-visibility.js
|
|
2
2
|
import { useViewportMatch } from "@wordpress/compose";
|
|
3
|
-
import { useMemo } from "@wordpress/element";
|
|
4
3
|
import { BLOCK_VISIBILITY_VIEWPORTS } from "./constants.mjs";
|
|
5
4
|
function useBlockVisibility(options = {}) {
|
|
6
5
|
const {
|
|
@@ -9,34 +8,20 @@ function useBlockVisibility(options = {}) {
|
|
|
9
8
|
} = options;
|
|
10
9
|
const isLargerThanMobile = useViewportMatch("mobile", ">=");
|
|
11
10
|
const isLargerThanTablet = useViewportMatch("medium", ">=");
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
}, [deviceType, isLargerThanMobile, isLargerThanTablet]);
|
|
27
|
-
const isBlockCurrentlyHidden = useMemo(() => {
|
|
28
|
-
if (blockVisibility === false) {
|
|
29
|
-
return true;
|
|
30
|
-
}
|
|
31
|
-
if (blockVisibility?.viewport?.[currentViewport] === false) {
|
|
32
|
-
return true;
|
|
33
|
-
}
|
|
34
|
-
return false;
|
|
35
|
-
}, [blockVisibility, currentViewport]);
|
|
36
|
-
return {
|
|
37
|
-
isBlockCurrentlyHidden,
|
|
38
|
-
currentViewport
|
|
39
|
-
};
|
|
11
|
+
let currentViewport;
|
|
12
|
+
if (deviceType === BLOCK_VISIBILITY_VIEWPORTS.mobile.key) {
|
|
13
|
+
currentViewport = BLOCK_VISIBILITY_VIEWPORTS.mobile.key;
|
|
14
|
+
} else if (deviceType === BLOCK_VISIBILITY_VIEWPORTS.tablet.key) {
|
|
15
|
+
currentViewport = BLOCK_VISIBILITY_VIEWPORTS.tablet.key;
|
|
16
|
+
} else if (!isLargerThanMobile) {
|
|
17
|
+
currentViewport = BLOCK_VISIBILITY_VIEWPORTS.mobile.key;
|
|
18
|
+
} else if (isLargerThanMobile && !isLargerThanTablet) {
|
|
19
|
+
currentViewport = BLOCK_VISIBILITY_VIEWPORTS.tablet.key;
|
|
20
|
+
} else {
|
|
21
|
+
currentViewport = BLOCK_VISIBILITY_VIEWPORTS.desktop.key;
|
|
22
|
+
}
|
|
23
|
+
const isBlockCurrentlyHidden = blockVisibility === false || blockVisibility?.viewport?.[currentViewport] === false;
|
|
24
|
+
return { isBlockCurrentlyHidden, currentViewport };
|
|
40
25
|
}
|
|
41
26
|
export {
|
|
42
27
|
useBlockVisibility as default
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/block-visibility/use-block-visibility.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useViewportMatch } from '@wordpress/compose';\
|
|
5
|
-
"mappings": ";AAGA,SAAS,wBAAwB;
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useViewportMatch } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport { BLOCK_VISIBILITY_VIEWPORTS } from './constants';\n\n/**\n * Returns information about the current block visibility state.\n *\n * @param {Object} options Parameters to avoid extra store subscriptions.\n * @param {Object|boolean} options.blockVisibility Block visibility metadata.\n * @param {string} options.deviceType Current device type ('desktop', 'tablet', 'mobile').\n * @return {Object} Object with `isBlockCurrentlyHidden` (boolean) and `currentViewport` (string) properties.\n */\nexport default function useBlockVisibility( options = {} ) {\n\tconst {\n\t\tblockVisibility = undefined,\n\t\tdeviceType = BLOCK_VISIBILITY_VIEWPORTS.desktop.key,\n\t} = options;\n\n\tconst isLargerThanMobile = useViewportMatch( 'mobile', '>=' ); // >= 480px\n\tconst isLargerThanTablet = useViewportMatch( 'medium', '>=' ); // >= 782px\n\n\t/*\n\t * Priority:\n\t * 1. Device type override (Mobile/Tablet) - uses device type to determine viewport\n\t * 2. Actual window size (Desktop mode) - uses viewport detection\n\t */\n\tlet currentViewport;\n\tif ( deviceType === BLOCK_VISIBILITY_VIEWPORTS.mobile.key ) {\n\t\tcurrentViewport = BLOCK_VISIBILITY_VIEWPORTS.mobile.key;\n\t} else if ( deviceType === BLOCK_VISIBILITY_VIEWPORTS.tablet.key ) {\n\t\tcurrentViewport = BLOCK_VISIBILITY_VIEWPORTS.tablet.key;\n\t} else if ( ! isLargerThanMobile ) {\n\t\tcurrentViewport = BLOCK_VISIBILITY_VIEWPORTS.mobile.key;\n\t} else if ( isLargerThanMobile && ! isLargerThanTablet ) {\n\t\tcurrentViewport = BLOCK_VISIBILITY_VIEWPORTS.tablet.key;\n\t} else {\n\t\tcurrentViewport = BLOCK_VISIBILITY_VIEWPORTS.desktop.key;\n\t}\n\n\t// Determine if block is currently hidden.\n\tconst isBlockCurrentlyHidden =\n\t\tblockVisibility === false ||\n\t\tblockVisibility?.viewport?.[ currentViewport ] === false;\n\n\treturn { isBlockCurrentlyHidden, currentViewport };\n}\n"],
|
|
5
|
+
"mappings": ";AAGA,SAAS,wBAAwB;AAKjC,SAAS,kCAAkC;AAU5B,SAAR,mBAAqC,UAAU,CAAC,GAAI;AAC1D,QAAM;AAAA,IACL,kBAAkB;AAAA,IAClB,aAAa,2BAA2B,QAAQ;AAAA,EACjD,IAAI;AAEJ,QAAM,qBAAqB,iBAAkB,UAAU,IAAK;AAC5D,QAAM,qBAAqB,iBAAkB,UAAU,IAAK;AAO5D,MAAI;AACJ,MAAK,eAAe,2BAA2B,OAAO,KAAM;AAC3D,sBAAkB,2BAA2B,OAAO;AAAA,EACrD,WAAY,eAAe,2BAA2B,OAAO,KAAM;AAClE,sBAAkB,2BAA2B,OAAO;AAAA,EACrD,WAAY,CAAE,oBAAqB;AAClC,sBAAkB,2BAA2B,OAAO;AAAA,EACrD,WAAY,sBAAsB,CAAE,oBAAqB;AACxD,sBAAkB,2BAA2B,OAAO;AAAA,EACrD,OAAO;AACN,sBAAkB,2BAA2B,QAAQ;AAAA,EACtD;AAGA,QAAM,yBACL,oBAAoB,SACpB,iBAAiB,WAAY,eAAgB,MAAM;AAEpD,SAAO,EAAE,wBAAwB,gBAAgB;AAClD;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -57,6 +57,7 @@ function useSettingsForBlockElement(parentSettings, blockName, element) {
|
|
|
57
57
|
"textAlign",
|
|
58
58
|
"textTransform",
|
|
59
59
|
"textDecoration",
|
|
60
|
+
"textIndent",
|
|
60
61
|
"writingMode"
|
|
61
62
|
].forEach((key) => {
|
|
62
63
|
if (!supportedStyles.includes(key)) {
|
|
@@ -66,6 +67,12 @@ function useSettingsForBlockElement(parentSettings, blockName, element) {
|
|
|
66
67
|
};
|
|
67
68
|
}
|
|
68
69
|
});
|
|
70
|
+
if (supportedStyles.includes("textIndent")) {
|
|
71
|
+
updatedSettings.typography = {
|
|
72
|
+
...updatedSettings.typography,
|
|
73
|
+
textIndent: updatedSettings.typography?.textIndent ?? "subsequent"
|
|
74
|
+
};
|
|
75
|
+
}
|
|
69
76
|
if (!supportedStyles.includes("columnCount")) {
|
|
70
77
|
updatedSettings.typography = {
|
|
71
78
|
...updatedSettings.typography,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/global-styles/hooks.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useMemo } from '@wordpress/element';\nimport { useSelect } from '@wordpress/data';\nimport { store as blocksStore } from '@wordpress/blocks';\nimport { _x } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../../lock-unlock';\n\n/**\n * React hook that overrides a global settings object with block and element specific settings.\n *\n * @param {Object} parentSettings Settings object.\n * @param {blockName?} blockName Block name.\n * @param {element?} element Element name.\n *\n * @return {Object} Merge of settings and supports.\n */\nexport function useSettingsForBlockElement(\n\tparentSettings,\n\tblockName,\n\telement\n) {\n\tconst { supportedStyles, supports } = useSelect(\n\t\t( select ) => {\n\t\t\treturn {\n\t\t\t\tsupportedStyles: unlock(\n\t\t\t\t\tselect( blocksStore )\n\t\t\t\t).getSupportedStyles( blockName, element ),\n\t\t\t\tsupports:\n\t\t\t\t\tselect( blocksStore ).getBlockType( blockName )?.supports,\n\t\t\t};\n\t\t},\n\t\t[ blockName, element ]\n\t);\n\n\treturn useMemo( () => {\n\t\tconst updatedSettings = { ...parentSettings };\n\n\t\tif ( ! supportedStyles.includes( 'fontSize' ) ) {\n\t\t\tupdatedSettings.typography = {\n\t\t\t\t...updatedSettings.typography,\n\t\t\t\tfontSizes: {},\n\t\t\t\tcustomFontSize: false,\n\t\t\t\tdefaultFontSizes: false,\n\t\t\t};\n\t\t}\n\n\t\tif ( ! supportedStyles.includes( 'fontFamily' ) ) {\n\t\t\tupdatedSettings.typography = {\n\t\t\t\t...updatedSettings.typography,\n\t\t\t\tfontFamilies: {},\n\t\t\t};\n\t\t}\n\n\t\tupdatedSettings.color = {\n\t\t\t...updatedSettings.color,\n\t\t\ttext:\n\t\t\t\tupdatedSettings.color?.text &&\n\t\t\t\tsupportedStyles.includes( 'color' ),\n\t\t\tbackground:\n\t\t\t\tupdatedSettings.color?.background &&\n\t\t\t\t( supportedStyles.includes( 'background' ) ||\n\t\t\t\t\tsupportedStyles.includes( 'backgroundColor' ) ),\n\t\t\tbutton:\n\t\t\t\tupdatedSettings.color?.button &&\n\t\t\t\tsupportedStyles.includes( 'buttonColor' ),\n\t\t\theading:\n\t\t\t\tupdatedSettings.color?.heading &&\n\t\t\t\tsupportedStyles.includes( 'headingColor' ),\n\t\t\tlink:\n\t\t\t\tupdatedSettings.color?.link &&\n\t\t\t\tsupportedStyles.includes( 'linkColor' ),\n\t\t\tcaption:\n\t\t\t\tupdatedSettings.color?.caption &&\n\t\t\t\tsupportedStyles.includes( 'captionColor' ),\n\t\t};\n\n\t\t// Some blocks can enable background colors but disable gradients.\n\t\tif ( ! supportedStyles.includes( 'background' ) ) {\n\t\t\tupdatedSettings.color.gradients = [];\n\t\t\tupdatedSettings.color.customGradient = false;\n\t\t}\n\n\t\t// If filters are not supported by the block/element, disable duotone.\n\t\tif ( ! supportedStyles.includes( 'filter' ) ) {\n\t\t\tupdatedSettings.color.defaultDuotone = false;\n\t\t\tupdatedSettings.color.customDuotone = false;\n\t\t}\n\n\t\t[\n\t\t\t'lineHeight',\n\t\t\t'fontStyle',\n\t\t\t'fontWeight',\n\t\t\t'letterSpacing',\n\t\t\t'textAlign',\n\t\t\t'textTransform',\n\t\t\t'textDecoration',\n\t\t\t'writingMode',\n\t\t].forEach( ( key ) => {\n\t\t\tif ( ! supportedStyles.includes( key ) ) {\n\t\t\t\tupdatedSettings.typography = {\n\t\t\t\t\t...updatedSettings.typography,\n\t\t\t\t\t[ key ]: false,\n\t\t\t\t};\n\t\t\t}\n\t\t} );\n\n\t\t// The column-count style is named text column to reduce confusion with\n\t\t// the columns block and manage expectations from the support.\n\t\t// See: https://github.com/WordPress/gutenberg/pull/33587\n\t\tif ( ! supportedStyles.includes( 'columnCount' ) ) {\n\t\t\tupdatedSettings.typography = {\n\t\t\t\t...updatedSettings.typography,\n\t\t\t\ttextColumns: false,\n\t\t\t};\n\t\t}\n\n\t\t[ 'contentSize', 'wideSize' ].forEach( ( key ) => {\n\t\t\tif ( ! supportedStyles.includes( key ) ) {\n\t\t\t\tupdatedSettings.layout = {\n\t\t\t\t\t...updatedSettings.layout,\n\t\t\t\t\t[ key ]: false,\n\t\t\t\t};\n\t\t\t}\n\t\t} );\n\n\t\t[ 'padding', 'margin', 'blockGap' ].forEach( ( key ) => {\n\t\t\tif ( ! supportedStyles.includes( key ) ) {\n\t\t\t\tupdatedSettings.spacing = {\n\t\t\t\t\t...updatedSettings.spacing,\n\t\t\t\t\t[ key ]: false,\n\t\t\t\t};\n\t\t\t}\n\n\t\t\tconst sides = Array.isArray( supports?.spacing?.[ key ] )\n\t\t\t\t? supports?.spacing?.[ key ]\n\t\t\t\t: supports?.spacing?.[ key ]?.sides;\n\t\t\t// Check if spacing type is supported before adding sides.\n\t\t\tif ( sides?.length && updatedSettings.spacing?.[ key ] ) {\n\t\t\t\tupdatedSettings.spacing = {\n\t\t\t\t\t...updatedSettings.spacing,\n\t\t\t\t\t[ key ]: {\n\t\t\t\t\t\t...updatedSettings.spacing?.[ key ],\n\t\t\t\t\t\tsides,\n\t\t\t\t\t},\n\t\t\t\t};\n\t\t\t}\n\t\t} );\n\n\t\t[ 'aspectRatio', 'height', 'minHeight', 'width' ].forEach( ( key ) => {\n\t\t\tif ( ! supportedStyles.includes( key ) ) {\n\t\t\t\tupdatedSettings.dimensions = {\n\t\t\t\t\t...updatedSettings.dimensions,\n\t\t\t\t\t[ key ]: false,\n\t\t\t\t};\n\t\t\t}\n\t\t} );\n\n\t\t[ 'radius', 'color', 'style', 'width' ].forEach( ( key ) => {\n\t\t\tif (\n\t\t\t\t! supportedStyles.includes(\n\t\t\t\t\t'border' + key.charAt( 0 ).toUpperCase() + key.slice( 1 )\n\t\t\t\t)\n\t\t\t) {\n\t\t\t\tupdatedSettings.border = {\n\t\t\t\t\t...updatedSettings.border,\n\t\t\t\t\t[ key ]: false,\n\t\t\t\t};\n\t\t\t}\n\t\t} );\n\n\t\t[ 'backgroundImage', 'backgroundSize' ].forEach( ( key ) => {\n\t\t\tif ( ! supportedStyles.includes( key ) ) {\n\t\t\t\tupdatedSettings.background = {\n\t\t\t\t\t...updatedSettings.background,\n\t\t\t\t\t[ key ]: false,\n\t\t\t\t};\n\t\t\t}\n\t\t} );\n\n\t\tupdatedSettings.shadow = supportedStyles.includes( 'shadow' )\n\t\t\t? updatedSettings.shadow\n\t\t\t: false;\n\n\t\treturn updatedSettings;\n\t}, [ parentSettings, supportedStyles, supports ] );\n}\n\nexport function useColorsPerOrigin( settings ) {\n\tconst customColors = settings?.color?.palette?.custom;\n\tconst themeColors = settings?.color?.palette?.theme;\n\tconst defaultColors = settings?.color?.palette?.default;\n\tconst shouldDisplayDefaultColors = settings?.color?.defaultPalette;\n\n\treturn useMemo( () => {\n\t\tconst result = [];\n\t\tif ( themeColors && themeColors.length ) {\n\t\t\tresult.push( {\n\t\t\t\tname: _x(\n\t\t\t\t\t'Theme',\n\t\t\t\t\t'Indicates this palette comes from the theme.'\n\t\t\t\t),\n\t\t\t\tcolors: themeColors,\n\t\t\t} );\n\t\t}\n\t\tif (\n\t\t\tshouldDisplayDefaultColors &&\n\t\t\tdefaultColors &&\n\t\t\tdefaultColors.length\n\t\t) {\n\t\t\tresult.push( {\n\t\t\t\tname: _x(\n\t\t\t\t\t'Default',\n\t\t\t\t\t'Indicates this palette comes from WordPress.'\n\t\t\t\t),\n\t\t\t\tcolors: defaultColors,\n\t\t\t} );\n\t\t}\n\t\tif ( customColors && customColors.length ) {\n\t\t\tresult.push( {\n\t\t\t\tname: _x(\n\t\t\t\t\t'Custom',\n\t\t\t\t\t'Indicates this palette is created by the user.'\n\t\t\t\t),\n\t\t\t\tcolors: customColors,\n\t\t\t} );\n\t\t}\n\t\treturn result;\n\t}, [\n\t\tcustomColors,\n\t\tthemeColors,\n\t\tdefaultColors,\n\t\tshouldDisplayDefaultColors,\n\t] );\n}\n\nexport function useGradientsPerOrigin( settings ) {\n\tconst customGradients = settings?.color?.gradients?.custom;\n\tconst themeGradients = settings?.color?.gradients?.theme;\n\tconst defaultGradients = settings?.color?.gradients?.default;\n\tconst shouldDisplayDefaultGradients = settings?.color?.defaultGradients;\n\n\treturn useMemo( () => {\n\t\tconst result = [];\n\t\tif ( themeGradients && themeGradients.length ) {\n\t\t\tresult.push( {\n\t\t\t\tname: _x(\n\t\t\t\t\t'Theme',\n\t\t\t\t\t'Indicates this palette comes from the theme.'\n\t\t\t\t),\n\t\t\t\tgradients: themeGradients,\n\t\t\t} );\n\t\t}\n\t\tif (\n\t\t\tshouldDisplayDefaultGradients &&\n\t\t\tdefaultGradients &&\n\t\t\tdefaultGradients.length\n\t\t) {\n\t\t\tresult.push( {\n\t\t\t\tname: _x(\n\t\t\t\t\t'Default',\n\t\t\t\t\t'Indicates this palette comes from WordPress.'\n\t\t\t\t),\n\t\t\t\tgradients: defaultGradients,\n\t\t\t} );\n\t\t}\n\t\tif ( customGradients && customGradients.length ) {\n\t\t\tresult.push( {\n\t\t\t\tname: _x(\n\t\t\t\t\t'Custom',\n\t\t\t\t\t'Indicates this palette is created by the user.'\n\t\t\t\t),\n\t\t\t\tgradients: customGradients,\n\t\t\t} );\n\t\t}\n\t\treturn result;\n\t}, [\n\t\tcustomGradients,\n\t\tthemeGradients,\n\t\tdefaultGradients,\n\t\tshouldDisplayDefaultGradients,\n\t] );\n}\n"],
|
|
5
|
-
"mappings": ";AAGA,SAAS,eAAe;AACxB,SAAS,iBAAiB;AAC1B,SAAS,SAAS,mBAAmB;AACrC,SAAS,UAAU;AAKnB,SAAS,cAAc;AAWhB,SAAS,2BACf,gBACA,WACA,SACC;AACD,QAAM,EAAE,iBAAiB,SAAS,IAAI;AAAA,IACrC,CAAE,WAAY;AACb,aAAO;AAAA,QACN,iBAAiB;AAAA,UAChB,OAAQ,WAAY;AAAA,QACrB,EAAE,mBAAoB,WAAW,OAAQ;AAAA,QACzC,UACC,OAAQ,WAAY,EAAE,aAAc,SAAU,GAAG;AAAA,MACnD;AAAA,IACD;AAAA,IACA,CAAE,WAAW,OAAQ;AAAA,EACtB;AAEA,SAAO,QAAS,MAAM;AACrB,UAAM,kBAAkB,EAAE,GAAG,eAAe;AAE5C,QAAK,CAAE,gBAAgB,SAAU,UAAW,GAAI;AAC/C,sBAAgB,aAAa;AAAA,QAC5B,GAAG,gBAAgB;AAAA,QACnB,WAAW,CAAC;AAAA,QACZ,gBAAgB;AAAA,QAChB,kBAAkB;AAAA,MACnB;AAAA,IACD;AAEA,QAAK,CAAE,gBAAgB,SAAU,YAAa,GAAI;AACjD,sBAAgB,aAAa;AAAA,QAC5B,GAAG,gBAAgB;AAAA,QACnB,cAAc,CAAC;AAAA,MAChB;AAAA,IACD;AAEA,oBAAgB,QAAQ;AAAA,MACvB,GAAG,gBAAgB;AAAA,MACnB,MACC,gBAAgB,OAAO,QACvB,gBAAgB,SAAU,OAAQ;AAAA,MACnC,YACC,gBAAgB,OAAO,eACrB,gBAAgB,SAAU,YAAa,KACxC,gBAAgB,SAAU,iBAAkB;AAAA,MAC9C,QACC,gBAAgB,OAAO,UACvB,gBAAgB,SAAU,aAAc;AAAA,MACzC,SACC,gBAAgB,OAAO,WACvB,gBAAgB,SAAU,cAAe;AAAA,MAC1C,MACC,gBAAgB,OAAO,QACvB,gBAAgB,SAAU,WAAY;AAAA,MACvC,SACC,gBAAgB,OAAO,WACvB,gBAAgB,SAAU,cAAe;AAAA,IAC3C;AAGA,QAAK,CAAE,gBAAgB,SAAU,YAAa,GAAI;AACjD,sBAAgB,MAAM,YAAY,CAAC;AACnC,sBAAgB,MAAM,iBAAiB;AAAA,IACxC;AAGA,QAAK,CAAE,gBAAgB,SAAU,QAAS,GAAI;AAC7C,sBAAgB,MAAM,iBAAiB;AACvC,sBAAgB,MAAM,gBAAgB;AAAA,IACvC;AAEA;AAAA,MACC;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACD,EAAE,QAAS,CAAE,QAAS;AACrB,UAAK,CAAE,gBAAgB,SAAU,GAAI,GAAI;AACxC,wBAAgB,aAAa;AAAA,UAC5B,GAAG,gBAAgB;AAAA,UACnB,CAAE,GAAI,GAAG;AAAA,QACV;AAAA,MACD;AAAA,IACD,CAAE;
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useMemo } from '@wordpress/element';\nimport { useSelect } from '@wordpress/data';\nimport { store as blocksStore } from '@wordpress/blocks';\nimport { _x } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../../lock-unlock';\n\n/**\n * React hook that overrides a global settings object with block and element specific settings.\n *\n * @param {Object} parentSettings Settings object.\n * @param {blockName?} blockName Block name.\n * @param {element?} element Element name.\n *\n * @return {Object} Merge of settings and supports.\n */\nexport function useSettingsForBlockElement(\n\tparentSettings,\n\tblockName,\n\telement\n) {\n\tconst { supportedStyles, supports } = useSelect(\n\t\t( select ) => {\n\t\t\treturn {\n\t\t\t\tsupportedStyles: unlock(\n\t\t\t\t\tselect( blocksStore )\n\t\t\t\t).getSupportedStyles( blockName, element ),\n\t\t\t\tsupports:\n\t\t\t\t\tselect( blocksStore ).getBlockType( blockName )?.supports,\n\t\t\t};\n\t\t},\n\t\t[ blockName, element ]\n\t);\n\n\treturn useMemo( () => {\n\t\tconst updatedSettings = { ...parentSettings };\n\n\t\tif ( ! supportedStyles.includes( 'fontSize' ) ) {\n\t\t\tupdatedSettings.typography = {\n\t\t\t\t...updatedSettings.typography,\n\t\t\t\tfontSizes: {},\n\t\t\t\tcustomFontSize: false,\n\t\t\t\tdefaultFontSizes: false,\n\t\t\t};\n\t\t}\n\n\t\tif ( ! supportedStyles.includes( 'fontFamily' ) ) {\n\t\t\tupdatedSettings.typography = {\n\t\t\t\t...updatedSettings.typography,\n\t\t\t\tfontFamilies: {},\n\t\t\t};\n\t\t}\n\n\t\tupdatedSettings.color = {\n\t\t\t...updatedSettings.color,\n\t\t\ttext:\n\t\t\t\tupdatedSettings.color?.text &&\n\t\t\t\tsupportedStyles.includes( 'color' ),\n\t\t\tbackground:\n\t\t\t\tupdatedSettings.color?.background &&\n\t\t\t\t( supportedStyles.includes( 'background' ) ||\n\t\t\t\t\tsupportedStyles.includes( 'backgroundColor' ) ),\n\t\t\tbutton:\n\t\t\t\tupdatedSettings.color?.button &&\n\t\t\t\tsupportedStyles.includes( 'buttonColor' ),\n\t\t\theading:\n\t\t\t\tupdatedSettings.color?.heading &&\n\t\t\t\tsupportedStyles.includes( 'headingColor' ),\n\t\t\tlink:\n\t\t\t\tupdatedSettings.color?.link &&\n\t\t\t\tsupportedStyles.includes( 'linkColor' ),\n\t\t\tcaption:\n\t\t\t\tupdatedSettings.color?.caption &&\n\t\t\t\tsupportedStyles.includes( 'captionColor' ),\n\t\t};\n\n\t\t// Some blocks can enable background colors but disable gradients.\n\t\tif ( ! supportedStyles.includes( 'background' ) ) {\n\t\t\tupdatedSettings.color.gradients = [];\n\t\t\tupdatedSettings.color.customGradient = false;\n\t\t}\n\n\t\t// If filters are not supported by the block/element, disable duotone.\n\t\tif ( ! supportedStyles.includes( 'filter' ) ) {\n\t\t\tupdatedSettings.color.defaultDuotone = false;\n\t\t\tupdatedSettings.color.customDuotone = false;\n\t\t}\n\n\t\t[\n\t\t\t'lineHeight',\n\t\t\t'fontStyle',\n\t\t\t'fontWeight',\n\t\t\t'letterSpacing',\n\t\t\t'textAlign',\n\t\t\t'textTransform',\n\t\t\t'textDecoration',\n\t\t\t'textIndent',\n\t\t\t'writingMode',\n\t\t].forEach( ( key ) => {\n\t\t\tif ( ! supportedStyles.includes( key ) ) {\n\t\t\t\tupdatedSettings.typography = {\n\t\t\t\t\t...updatedSettings.typography,\n\t\t\t\t\t[ key ]: false,\n\t\t\t\t};\n\t\t\t}\n\t\t} );\n\n\t\t// Text indent needs explicit handling since it may not be in parent settings.\n\t\tif ( supportedStyles.includes( 'textIndent' ) ) {\n\t\t\tupdatedSettings.typography = {\n\t\t\t\t...updatedSettings.typography,\n\t\t\t\ttextIndent:\n\t\t\t\t\tupdatedSettings.typography?.textIndent ?? 'subsequent',\n\t\t\t};\n\t\t}\n\n\t\t// The column-count style is named text column to reduce confusion with\n\t\t// the columns block and manage expectations from the support.\n\t\t// See: https://github.com/WordPress/gutenberg/pull/33587\n\t\tif ( ! supportedStyles.includes( 'columnCount' ) ) {\n\t\t\tupdatedSettings.typography = {\n\t\t\t\t...updatedSettings.typography,\n\t\t\t\ttextColumns: false,\n\t\t\t};\n\t\t}\n\n\t\t[ 'contentSize', 'wideSize' ].forEach( ( key ) => {\n\t\t\tif ( ! supportedStyles.includes( key ) ) {\n\t\t\t\tupdatedSettings.layout = {\n\t\t\t\t\t...updatedSettings.layout,\n\t\t\t\t\t[ key ]: false,\n\t\t\t\t};\n\t\t\t}\n\t\t} );\n\n\t\t[ 'padding', 'margin', 'blockGap' ].forEach( ( key ) => {\n\t\t\tif ( ! supportedStyles.includes( key ) ) {\n\t\t\t\tupdatedSettings.spacing = {\n\t\t\t\t\t...updatedSettings.spacing,\n\t\t\t\t\t[ key ]: false,\n\t\t\t\t};\n\t\t\t}\n\n\t\t\tconst sides = Array.isArray( supports?.spacing?.[ key ] )\n\t\t\t\t? supports?.spacing?.[ key ]\n\t\t\t\t: supports?.spacing?.[ key ]?.sides;\n\t\t\t// Check if spacing type is supported before adding sides.\n\t\t\tif ( sides?.length && updatedSettings.spacing?.[ key ] ) {\n\t\t\t\tupdatedSettings.spacing = {\n\t\t\t\t\t...updatedSettings.spacing,\n\t\t\t\t\t[ key ]: {\n\t\t\t\t\t\t...updatedSettings.spacing?.[ key ],\n\t\t\t\t\t\tsides,\n\t\t\t\t\t},\n\t\t\t\t};\n\t\t\t}\n\t\t} );\n\n\t\t[ 'aspectRatio', 'height', 'minHeight', 'width' ].forEach( ( key ) => {\n\t\t\tif ( ! supportedStyles.includes( key ) ) {\n\t\t\t\tupdatedSettings.dimensions = {\n\t\t\t\t\t...updatedSettings.dimensions,\n\t\t\t\t\t[ key ]: false,\n\t\t\t\t};\n\t\t\t}\n\t\t} );\n\n\t\t[ 'radius', 'color', 'style', 'width' ].forEach( ( key ) => {\n\t\t\tif (\n\t\t\t\t! supportedStyles.includes(\n\t\t\t\t\t'border' + key.charAt( 0 ).toUpperCase() + key.slice( 1 )\n\t\t\t\t)\n\t\t\t) {\n\t\t\t\tupdatedSettings.border = {\n\t\t\t\t\t...updatedSettings.border,\n\t\t\t\t\t[ key ]: false,\n\t\t\t\t};\n\t\t\t}\n\t\t} );\n\n\t\t[ 'backgroundImage', 'backgroundSize' ].forEach( ( key ) => {\n\t\t\tif ( ! supportedStyles.includes( key ) ) {\n\t\t\t\tupdatedSettings.background = {\n\t\t\t\t\t...updatedSettings.background,\n\t\t\t\t\t[ key ]: false,\n\t\t\t\t};\n\t\t\t}\n\t\t} );\n\n\t\tupdatedSettings.shadow = supportedStyles.includes( 'shadow' )\n\t\t\t? updatedSettings.shadow\n\t\t\t: false;\n\n\t\treturn updatedSettings;\n\t}, [ parentSettings, supportedStyles, supports ] );\n}\n\nexport function useColorsPerOrigin( settings ) {\n\tconst customColors = settings?.color?.palette?.custom;\n\tconst themeColors = settings?.color?.palette?.theme;\n\tconst defaultColors = settings?.color?.palette?.default;\n\tconst shouldDisplayDefaultColors = settings?.color?.defaultPalette;\n\n\treturn useMemo( () => {\n\t\tconst result = [];\n\t\tif ( themeColors && themeColors.length ) {\n\t\t\tresult.push( {\n\t\t\t\tname: _x(\n\t\t\t\t\t'Theme',\n\t\t\t\t\t'Indicates this palette comes from the theme.'\n\t\t\t\t),\n\t\t\t\tcolors: themeColors,\n\t\t\t} );\n\t\t}\n\t\tif (\n\t\t\tshouldDisplayDefaultColors &&\n\t\t\tdefaultColors &&\n\t\t\tdefaultColors.length\n\t\t) {\n\t\t\tresult.push( {\n\t\t\t\tname: _x(\n\t\t\t\t\t'Default',\n\t\t\t\t\t'Indicates this palette comes from WordPress.'\n\t\t\t\t),\n\t\t\t\tcolors: defaultColors,\n\t\t\t} );\n\t\t}\n\t\tif ( customColors && customColors.length ) {\n\t\t\tresult.push( {\n\t\t\t\tname: _x(\n\t\t\t\t\t'Custom',\n\t\t\t\t\t'Indicates this palette is created by the user.'\n\t\t\t\t),\n\t\t\t\tcolors: customColors,\n\t\t\t} );\n\t\t}\n\t\treturn result;\n\t}, [\n\t\tcustomColors,\n\t\tthemeColors,\n\t\tdefaultColors,\n\t\tshouldDisplayDefaultColors,\n\t] );\n}\n\nexport function useGradientsPerOrigin( settings ) {\n\tconst customGradients = settings?.color?.gradients?.custom;\n\tconst themeGradients = settings?.color?.gradients?.theme;\n\tconst defaultGradients = settings?.color?.gradients?.default;\n\tconst shouldDisplayDefaultGradients = settings?.color?.defaultGradients;\n\n\treturn useMemo( () => {\n\t\tconst result = [];\n\t\tif ( themeGradients && themeGradients.length ) {\n\t\t\tresult.push( {\n\t\t\t\tname: _x(\n\t\t\t\t\t'Theme',\n\t\t\t\t\t'Indicates this palette comes from the theme.'\n\t\t\t\t),\n\t\t\t\tgradients: themeGradients,\n\t\t\t} );\n\t\t}\n\t\tif (\n\t\t\tshouldDisplayDefaultGradients &&\n\t\t\tdefaultGradients &&\n\t\t\tdefaultGradients.length\n\t\t) {\n\t\t\tresult.push( {\n\t\t\t\tname: _x(\n\t\t\t\t\t'Default',\n\t\t\t\t\t'Indicates this palette comes from WordPress.'\n\t\t\t\t),\n\t\t\t\tgradients: defaultGradients,\n\t\t\t} );\n\t\t}\n\t\tif ( customGradients && customGradients.length ) {\n\t\t\tresult.push( {\n\t\t\t\tname: _x(\n\t\t\t\t\t'Custom',\n\t\t\t\t\t'Indicates this palette is created by the user.'\n\t\t\t\t),\n\t\t\t\tgradients: customGradients,\n\t\t\t} );\n\t\t}\n\t\treturn result;\n\t}, [\n\t\tcustomGradients,\n\t\tthemeGradients,\n\t\tdefaultGradients,\n\t\tshouldDisplayDefaultGradients,\n\t] );\n}\n"],
|
|
5
|
+
"mappings": ";AAGA,SAAS,eAAe;AACxB,SAAS,iBAAiB;AAC1B,SAAS,SAAS,mBAAmB;AACrC,SAAS,UAAU;AAKnB,SAAS,cAAc;AAWhB,SAAS,2BACf,gBACA,WACA,SACC;AACD,QAAM,EAAE,iBAAiB,SAAS,IAAI;AAAA,IACrC,CAAE,WAAY;AACb,aAAO;AAAA,QACN,iBAAiB;AAAA,UAChB,OAAQ,WAAY;AAAA,QACrB,EAAE,mBAAoB,WAAW,OAAQ;AAAA,QACzC,UACC,OAAQ,WAAY,EAAE,aAAc,SAAU,GAAG;AAAA,MACnD;AAAA,IACD;AAAA,IACA,CAAE,WAAW,OAAQ;AAAA,EACtB;AAEA,SAAO,QAAS,MAAM;AACrB,UAAM,kBAAkB,EAAE,GAAG,eAAe;AAE5C,QAAK,CAAE,gBAAgB,SAAU,UAAW,GAAI;AAC/C,sBAAgB,aAAa;AAAA,QAC5B,G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,UACA;AAAA,QACD;AAAA,QACA,QAAQ;AAAA,MACT,CAAE;AAAA,IACH;AACA,WAAO;AAAA,EACR,GAAG;AAAA,IACF;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACD,CAAE;AACH;AAEO,SAAS,sBAAuB,UAAW;AACjD,QAAM,kBAAkB,UAAU,OAAO,WAAW;AACpD,QAAM,iBAAiB,UAAU,OAAO,WAAW;AACnD,QAAM,mBAAmB,UAAU,OAAO,WAAW;AACrD,QAAM,gCAAgC,UAAU,OAAO;AAEvD,SAAO,QAAS,MAAM;AACrB,UAAM,SAAS,CAAC;AAChB,QAAK,kBAAkB,eAAe,QAAS;AAC9C,aAAO,KAAM;AAAA,QACZ,MAAM;AAAA,UACL;AAAA,UACA;AAAA,QACD;AAAA,QACA,WAAW;AAAA,MACZ,CAAE;AAAA,IACH;AACA,QACC,iCACA,oBACA,iBAAiB,QAChB;AACD,aAAO,KAAM;AAAA,QACZ,MAAM;AAAA,UACL;AAAA,UACA;AAAA,QACD;AAAA,QACA,WAAW;AAAA,MACZ,CAAE;AAAA,IACH;AACA,QAAK,mBAAmB,gBAAgB,QAAS;AAChD,aAAO,KAAM;AAAA,QACZ,MAAM;AAAA,UACL;AAAA,UACA;AAAA,QACD;AAAA,QACA,WAAW;AAAA,MACZ,CAAE;AAAA,IACH;AACA,WAAO;AAAA,EACR,GAAG;AAAA,IACF;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACD,CAAE;AACH;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -4,7 +4,8 @@ import {
|
|
|
4
4
|
__experimentalNumberControl as NumberControl,
|
|
5
5
|
__experimentalToolsPanel as ToolsPanel,
|
|
6
6
|
__experimentalToolsPanelItem as ToolsPanelItem,
|
|
7
|
-
Notice
|
|
7
|
+
Notice,
|
|
8
|
+
ToggleControl
|
|
8
9
|
} from "@wordpress/components";
|
|
9
10
|
import { __ } from "@wordpress/i18n";
|
|
10
11
|
import { useCallback, useMemo } from "@wordpress/element";
|
|
@@ -16,6 +17,7 @@ import LetterSpacingControl from "../letter-spacing-control/index.mjs";
|
|
|
16
17
|
import TextAlignmentControl from "../text-alignment-control/index.mjs";
|
|
17
18
|
import TextTransformControl from "../text-transform-control/index.mjs";
|
|
18
19
|
import TextDecorationControl from "../text-decoration-control/index.mjs";
|
|
20
|
+
import TextIndentControl from "../text-indent-control/index.mjs";
|
|
19
21
|
import WritingModeControl from "../writing-mode-control/index.mjs";
|
|
20
22
|
import { useToolsPanelDropdownMenuProps } from "./utils.mjs";
|
|
21
23
|
import { setImmutably } from "../../utils/object.mjs";
|
|
@@ -35,10 +37,11 @@ function useHasTypographyPanel(settings) {
|
|
|
35
37
|
const hasTextAlign = useHasTextAlignmentControl(settings);
|
|
36
38
|
const hasTextTransform = useHasTextTransformControl(settings);
|
|
37
39
|
const hasTextDecoration = useHasTextDecorationControl(settings);
|
|
40
|
+
const hasTextIndent = useHasTextIndentControl(settings);
|
|
38
41
|
const hasWritingMode = useHasWritingModeControl(settings);
|
|
39
42
|
const hasTextColumns = useHasTextColumnsControl(settings);
|
|
40
43
|
const hasFontSize = useHasFontSizeControl(settings);
|
|
41
|
-
return hasFontFamily || hasLineHeight || hasFontAppearance || hasLetterSpacing || hasTextAlign || hasTextTransform || hasFontSize || hasTextDecoration || hasWritingMode || hasTextColumns;
|
|
44
|
+
return hasFontFamily || hasLineHeight || hasFontAppearance || hasLetterSpacing || hasTextAlign || hasTextTransform || hasFontSize || hasTextDecoration || hasTextIndent || hasWritingMode || hasTextColumns;
|
|
42
45
|
}
|
|
43
46
|
function useHasFontSizeControl(settings) {
|
|
44
47
|
return settings?.typography?.defaultFontSizes !== false && settings?.typography?.fontSizes?.default?.length || settings?.typography?.fontSizes?.theme?.length || settings?.typography?.fontSizes?.custom?.length || settings?.typography?.customFontSize;
|
|
@@ -81,6 +84,9 @@ function useHasWritingModeControl(settings) {
|
|
|
81
84
|
function useHasTextColumnsControl(settings) {
|
|
82
85
|
return settings?.typography?.textColumns;
|
|
83
86
|
}
|
|
87
|
+
function useHasTextIndentControl(settings) {
|
|
88
|
+
return settings?.typography?.textIndent;
|
|
89
|
+
}
|
|
84
90
|
function getMergedFontSizes(settings) {
|
|
85
91
|
const fontSizes = settings?.typography?.fontSizes;
|
|
86
92
|
const defaultFontSizesEnabled = !!settings?.typography?.defaultFontSizes;
|
|
@@ -122,6 +128,7 @@ var DEFAULT_CONTROLS = {
|
|
|
122
128
|
textAlign: true,
|
|
123
129
|
textTransform: true,
|
|
124
130
|
textDecoration: true,
|
|
131
|
+
textIndent: true,
|
|
125
132
|
writingMode: true,
|
|
126
133
|
textColumns: true
|
|
127
134
|
};
|
|
@@ -132,7 +139,8 @@ function TypographyPanel({
|
|
|
132
139
|
inheritedValue = value,
|
|
133
140
|
settings,
|
|
134
141
|
panelId,
|
|
135
|
-
defaultControls = DEFAULT_CONTROLS
|
|
142
|
+
defaultControls = DEFAULT_CONTROLS,
|
|
143
|
+
isGlobalStyles = false
|
|
136
144
|
}) {
|
|
137
145
|
const decodeValue = (rawValue) => getValueFromVariable({ settings }, "", rawValue);
|
|
138
146
|
const hasFontFamilyEnabled = useHasFontFamilyControl(settings);
|
|
@@ -272,6 +280,36 @@ function TypographyPanel({
|
|
|
272
280
|
};
|
|
273
281
|
const hasLetterSpacing = () => !!value?.typography?.letterSpacing;
|
|
274
282
|
const resetLetterSpacing = () => setLetterSpacing(void 0);
|
|
283
|
+
const hasTextIndentControl = useHasTextIndentControl(settings);
|
|
284
|
+
const textIndent = decodeValue(inheritedValue?.typography?.textIndent);
|
|
285
|
+
const textIndentSetting = settings?.typography?.textIndent ?? "subsequent";
|
|
286
|
+
const isTextIndentAll = textIndentSetting === "all";
|
|
287
|
+
const setTextIndentValue = (newValue) => {
|
|
288
|
+
onChange(
|
|
289
|
+
setImmutably(
|
|
290
|
+
value,
|
|
291
|
+
["typography", "textIndent"],
|
|
292
|
+
newValue || void 0
|
|
293
|
+
)
|
|
294
|
+
);
|
|
295
|
+
};
|
|
296
|
+
const onToggleTextIndentAll = (newValue) => {
|
|
297
|
+
onChange({
|
|
298
|
+
...value,
|
|
299
|
+
settings: {
|
|
300
|
+
typography: {
|
|
301
|
+
textIndent: newValue ? "all" : "subsequent"
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
});
|
|
305
|
+
};
|
|
306
|
+
const hasTextIndent = () => !!value?.typography?.textIndent;
|
|
307
|
+
const resetTextIndent = () => {
|
|
308
|
+
onChange(
|
|
309
|
+
setImmutably(value, ["typography", "textIndent"], void 0)
|
|
310
|
+
);
|
|
311
|
+
};
|
|
312
|
+
const textIndentHelp = isTextIndentAll ? __("Indents the first line of all paragraphs.") : __("Indents the first line of each paragraph after the first one.");
|
|
275
313
|
const hasTextColumnsControl = useHasTextColumnsControl(settings);
|
|
276
314
|
const textColumns = decodeValue(inheritedValue?.typography?.textColumns);
|
|
277
315
|
const setTextColumns = (newValue) => {
|
|
@@ -400,7 +438,6 @@ function TypographyPanel({
|
|
|
400
438
|
hasAppearanceControl && /* @__PURE__ */ jsx(
|
|
401
439
|
ToolsPanelItem,
|
|
402
440
|
{
|
|
403
|
-
className: "single-column",
|
|
404
441
|
label: appearanceControlLabel,
|
|
405
442
|
hasValue: hasFontAppearance,
|
|
406
443
|
onDeselect: resetFontAppearance,
|
|
@@ -462,6 +499,38 @@ function TypographyPanel({
|
|
|
462
499
|
)
|
|
463
500
|
}
|
|
464
501
|
),
|
|
502
|
+
hasTextIndentControl && /* @__PURE__ */ jsxs(
|
|
503
|
+
ToolsPanelItem,
|
|
504
|
+
{
|
|
505
|
+
label: __("Line indent"),
|
|
506
|
+
hasValue: hasTextIndent,
|
|
507
|
+
onDeselect: resetTextIndent,
|
|
508
|
+
isShownByDefault: defaultControls.textIndent,
|
|
509
|
+
panelId,
|
|
510
|
+
children: [
|
|
511
|
+
/* @__PURE__ */ jsx(
|
|
512
|
+
TextIndentControl,
|
|
513
|
+
{
|
|
514
|
+
value: textIndent,
|
|
515
|
+
onChange: setTextIndentValue,
|
|
516
|
+
size: "__unstable-large",
|
|
517
|
+
__unstableInputWidth: "auto",
|
|
518
|
+
withSlider: true,
|
|
519
|
+
hasBottomMargin: isGlobalStyles
|
|
520
|
+
}
|
|
521
|
+
),
|
|
522
|
+
isGlobalStyles && /* @__PURE__ */ jsx(
|
|
523
|
+
ToggleControl,
|
|
524
|
+
{
|
|
525
|
+
label: __("Indent all paragraphs"),
|
|
526
|
+
checked: isTextIndentAll,
|
|
527
|
+
onChange: onToggleTextIndentAll,
|
|
528
|
+
help: textIndentHelp
|
|
529
|
+
}
|
|
530
|
+
)
|
|
531
|
+
]
|
|
532
|
+
}
|
|
533
|
+
),
|
|
465
534
|
hasTextColumnsControl && /* @__PURE__ */ jsx(
|
|
466
535
|
ToolsPanelItem,
|
|
467
536
|
{
|