@wordpress/block-editor 16.2.0 → 17.0.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 +39 -0
- package/build/components/block-inspector/index.cjs +9 -6
- package/build/components/block-inspector/index.cjs.map +2 -2
- package/build/components/block-keyboard-shortcuts/index.cjs +201 -0
- package/build/components/block-keyboard-shortcuts/index.cjs.map +7 -0
- package/build/components/block-list/block.cjs +10 -3
- package/build/components/block-list/block.cjs.map +2 -2
- package/build/components/block-list/index.cjs +6 -1
- package/build/components/block-list/index.cjs.map +2 -2
- package/build/components/block-list/use-block-props/use-focus-first-element.cjs +4 -0
- package/build/components/block-list/use-block-props/use-focus-first-element.cjs.map +2 -2
- package/build/components/block-list/use-block-props/use-selected-block-event-handlers.cjs +6 -7
- package/build/components/block-list/use-block-props/use-selected-block-event-handlers.cjs.map +2 -2
- package/build/components/block-parent-selector/index.cjs +98 -29
- package/build/components/block-parent-selector/index.cjs.map +3 -3
- package/build/components/block-popover/inbetween.cjs +2 -2
- package/build/components/block-popover/inbetween.cjs.map +2 -2
- package/build/components/block-preview/index.cjs +0 -4
- package/build/components/block-preview/index.cjs.map +2 -2
- package/build/components/block-styles/index.cjs +77 -33
- package/build/components/block-styles/index.cjs.map +3 -3
- package/build/components/block-visibility/constants.cjs.map +2 -2
- package/build/components/child-layout-control/index.cjs.map +2 -2
- package/build/components/colors/with-colors.cjs +55 -71
- package/build/components/colors/with-colors.cjs.map +2 -2
- package/build/components/dimensions-tool/aspect-ratio-tool.cjs +4 -2
- package/build/components/dimensions-tool/aspect-ratio-tool.cjs.map +2 -2
- package/build/components/dimensions-tool/index.cjs +18 -16
- package/build/components/dimensions-tool/index.cjs.map +2 -2
- package/build/components/dimensions-tool/utils.cjs +61 -0
- package/build/components/dimensions-tool/utils.cjs.map +7 -0
- package/build/components/duotone-control/index.cjs +2 -0
- package/build/components/duotone-control/index.cjs.map +2 -2
- package/build/components/global-styles/advanced-panel.cjs.map +3 -3
- package/build/components/global-styles/border-panel.cjs +2 -5
- package/build/components/global-styles/border-panel.cjs.map +2 -2
- package/build/components/global-styles/color-panel.cjs +14 -2
- package/build/components/global-styles/color-panel.cjs.map +2 -2
- package/build/components/global-styles/dimensions-panel.cjs +9 -5
- package/build/components/global-styles/dimensions-panel.cjs.map +2 -2
- package/build/components/global-styles/filters-panel.cjs +12 -8
- package/build/components/global-styles/filters-panel.cjs.map +2 -2
- package/build/components/global-styles/shadow-panel-components.cjs +16 -11
- package/build/components/global-styles/shadow-panel-components.cjs.map +2 -2
- package/build/components/global-styles/utils.cjs +9 -0
- package/build/components/global-styles/utils.cjs.map +2 -2
- package/build/components/inner-blocks/index.cjs +5 -3
- package/build/components/inner-blocks/index.cjs.map +2 -2
- package/build/components/inserter/block-patterns-explorer/index.cjs +39 -22
- package/build/components/inserter/block-patterns-explorer/index.cjs.map +2 -2
- package/build/components/inserter/block-patterns-explorer/pattern-explorer-sidebar.cjs +21 -55
- package/build/components/inserter/block-patterns-explorer/pattern-explorer-sidebar.cjs.map +2 -2
- package/build/components/inserter/block-patterns-explorer/pattern-list.cjs +19 -44
- package/build/components/inserter/block-patterns-explorer/pattern-list.cjs.map +3 -3
- package/build/components/inserter/hooks/use-insertion-point.cjs +4 -4
- package/build/components/inserter/hooks/use-insertion-point.cjs.map +2 -2
- package/build/components/inserter/menu.cjs +18 -7
- package/build/components/inserter/menu.cjs.map +2 -2
- package/build/components/inserter/quick-inserter.cjs +30 -27
- package/build/components/inserter/quick-inserter.cjs.map +2 -2
- package/build/components/inspector-controls-tabs/styles-tab.cjs +1 -1
- package/build/components/inspector-controls-tabs/styles-tab.cjs.map +2 -2
- package/build/components/list-view/index.cjs +31 -5
- package/build/components/list-view/index.cjs.map +3 -3
- package/build/components/list-view/utils.cjs +13 -1
- package/build/components/list-view/utils.cjs.map +2 -2
- package/build/components/media-placeholder/index.cjs +1 -1
- package/build/components/media-placeholder/index.cjs.map +3 -3
- package/build/components/provider/index.cjs +5 -1
- package/build/components/provider/index.cjs.map +3 -3
- package/build/components/publish-date-time-picker/index.cjs +3 -2
- package/build/components/publish-date-time-picker/index.cjs.map +2 -2
- package/build/components/rich-text/event-listeners/enter.cjs +46 -39
- package/build/components/rich-text/event-listeners/enter.cjs.map +2 -2
- package/build/components/rich-text/index.cjs +7 -5
- package/build/components/rich-text/index.cjs.map +2 -2
- package/build/components/rich-text/multiline.cjs +105 -70
- package/build/components/rich-text/multiline.cjs.map +3 -3
- package/build/components/url-input/index.cjs.map +2 -2
- package/build/components/writing-flow/use-input.cjs +65 -13
- package/build/components/writing-flow/use-input.cjs.map +3 -3
- package/build/hooks/border.cjs +25 -3
- package/build/hooks/border.cjs.map +2 -2
- package/build/hooks/dimensions.cjs +9 -2
- package/build/hooks/dimensions.cjs.map +2 -2
- package/build/hooks/duotone.cjs +4 -3
- package/build/hooks/duotone.cjs.map +2 -2
- package/build/hooks/gap.cjs +8 -2
- package/build/hooks/gap.cjs.map +2 -2
- package/build/hooks/layout-child.cjs +35 -13
- package/build/hooks/layout-child.cjs.map +2 -2
- package/build/hooks/layout.cjs +23 -1
- package/build/hooks/layout.cjs.map +2 -2
- package/build/hooks/states.cjs +7 -4
- package/build/hooks/states.cjs.map +2 -2
- package/build/layouts/constrained.cjs +8 -1
- package/build/layouts/constrained.cjs.map +2 -2
- package/build/layouts/flex.cjs +9 -0
- package/build/layouts/flex.cjs.map +2 -2
- package/build/layouts/flow.cjs +4 -1
- package/build/layouts/flow.cjs.map +2 -2
- package/build/layouts/grid.cjs +5 -1
- package/build/layouts/grid.cjs.map +2 -2
- package/build/private-apis.cjs +3 -1
- package/build/private-apis.cjs.map +2 -2
- package/build/store/actions.cjs +1 -1
- package/build/store/actions.cjs.map +2 -2
- package/build-module/components/block-inspector/index.mjs +9 -6
- package/build-module/components/block-inspector/index.mjs.map +2 -2
- package/build-module/components/block-keyboard-shortcuts/index.mjs +173 -0
- package/build-module/components/block-keyboard-shortcuts/index.mjs.map +7 -0
- package/build-module/components/block-list/block.mjs +10 -3
- package/build-module/components/block-list/block.mjs.map +2 -2
- package/build-module/components/block-list/index.mjs +6 -1
- package/build-module/components/block-list/index.mjs.map +2 -2
- package/build-module/components/block-list/use-block-props/use-focus-first-element.mjs +4 -0
- package/build-module/components/block-list/use-block-props/use-focus-first-element.mjs.map +2 -2
- package/build-module/components/block-list/use-block-props/use-selected-block-event-handlers.mjs +6 -7
- package/build-module/components/block-list/use-block-props/use-selected-block-event-handlers.mjs.map +2 -2
- package/build-module/components/block-parent-selector/index.mjs +101 -32
- package/build-module/components/block-parent-selector/index.mjs.map +2 -2
- package/build-module/components/block-popover/inbetween.mjs +2 -2
- package/build-module/components/block-popover/inbetween.mjs.map +2 -2
- package/build-module/components/block-preview/index.mjs +0 -4
- package/build-module/components/block-preview/index.mjs.map +2 -2
- package/build-module/components/block-styles/index.mjs +79 -35
- package/build-module/components/block-styles/index.mjs.map +2 -2
- package/build-module/components/block-visibility/constants.mjs.map +2 -2
- package/build-module/components/child-layout-control/index.mjs +5 -5
- package/build-module/components/child-layout-control/index.mjs.map +1 -1
- package/build-module/components/colors/with-colors.mjs +56 -72
- package/build-module/components/colors/with-colors.mjs.map +2 -2
- package/build-module/components/dimensions-tool/aspect-ratio-tool.mjs +4 -2
- package/build-module/components/dimensions-tool/aspect-ratio-tool.mjs.map +2 -2
- package/build-module/components/dimensions-tool/index.mjs +19 -17
- package/build-module/components/dimensions-tool/index.mjs.map +2 -2
- package/build-module/components/dimensions-tool/utils.mjs +35 -0
- package/build-module/components/dimensions-tool/utils.mjs.map +7 -0
- package/build-module/components/duotone-control/index.mjs +2 -0
- package/build-module/components/duotone-control/index.mjs.map +2 -2
- package/build-module/components/global-styles/advanced-panel.mjs +5 -2
- package/build-module/components/global-styles/advanced-panel.mjs.map +2 -2
- package/build-module/components/global-styles/border-panel.mjs +2 -5
- package/build-module/components/global-styles/border-panel.mjs.map +2 -2
- package/build-module/components/global-styles/color-panel.mjs +14 -2
- package/build-module/components/global-styles/color-panel.mjs.map +2 -2
- package/build-module/components/global-styles/dimensions-panel.mjs +9 -5
- package/build-module/components/global-styles/dimensions-panel.mjs.map +2 -2
- package/build-module/components/global-styles/filters-panel.mjs +16 -9
- package/build-module/components/global-styles/filters-panel.mjs.map +2 -2
- package/build-module/components/global-styles/shadow-panel-components.mjs +16 -11
- package/build-module/components/global-styles/shadow-panel-components.mjs.map +2 -2
- package/build-module/components/global-styles/utils.mjs +8 -0
- package/build-module/components/global-styles/utils.mjs.map +2 -2
- package/build-module/components/inner-blocks/index.mjs +5 -3
- package/build-module/components/inner-blocks/index.mjs.map +2 -2
- package/build-module/components/inserter/block-patterns-explorer/index.mjs +39 -22
- package/build-module/components/inserter/block-patterns-explorer/index.mjs.map +2 -2
- package/build-module/components/inserter/block-patterns-explorer/pattern-explorer-sidebar.mjs +22 -56
- package/build-module/components/inserter/block-patterns-explorer/pattern-explorer-sidebar.mjs.map +2 -2
- package/build-module/components/inserter/block-patterns-explorer/pattern-list.mjs +20 -45
- package/build-module/components/inserter/block-patterns-explorer/pattern-list.mjs.map +2 -2
- package/build-module/components/inserter/hooks/use-insertion-point.mjs +4 -4
- package/build-module/components/inserter/hooks/use-insertion-point.mjs.map +2 -2
- package/build-module/components/inserter/menu.mjs +19 -8
- package/build-module/components/inserter/menu.mjs.map +2 -2
- package/build-module/components/inserter/quick-inserter.mjs +30 -27
- package/build-module/components/inserter/quick-inserter.mjs.map +2 -2
- package/build-module/components/inspector-controls-tabs/styles-tab.mjs +1 -1
- package/build-module/components/inspector-controls-tabs/styles-tab.mjs.map +2 -2
- package/build-module/components/list-view/index.mjs +32 -5
- package/build-module/components/list-view/index.mjs.map +3 -3
- package/build-module/components/list-view/utils.mjs +13 -1
- package/build-module/components/list-view/utils.mjs.map +2 -2
- package/build-module/components/media-placeholder/index.mjs +3 -3
- package/build-module/components/media-placeholder/index.mjs.map +2 -2
- package/build-module/components/provider/index.mjs +6 -2
- package/build-module/components/provider/index.mjs.map +2 -2
- package/build-module/components/publish-date-time-picker/index.mjs +3 -2
- package/build-module/components/publish-date-time-picker/index.mjs.map +2 -2
- package/build-module/components/rich-text/event-listeners/enter.mjs +46 -39
- package/build-module/components/rich-text/event-listeners/enter.mjs.map +2 -2
- package/build-module/components/rich-text/index.mjs +7 -5
- package/build-module/components/rich-text/index.mjs.map +2 -2
- package/build-module/components/rich-text/multiline.mjs +112 -72
- package/build-module/components/rich-text/multiline.mjs.map +2 -2
- package/build-module/components/url-input/index.mjs +2 -2
- package/build-module/components/url-input/index.mjs.map +1 -1
- package/build-module/components/writing-flow/use-input.mjs +66 -14
- package/build-module/components/writing-flow/use-input.mjs.map +3 -3
- package/build-module/hooks/border.mjs +26 -8
- package/build-module/hooks/border.mjs.map +2 -2
- package/build-module/hooks/dimensions.mjs +9 -2
- package/build-module/hooks/dimensions.mjs.map +2 -2
- package/build-module/hooks/duotone.mjs +8 -4
- package/build-module/hooks/duotone.mjs.map +2 -2
- package/build-module/hooks/gap.mjs +6 -1
- package/build-module/hooks/gap.mjs.map +2 -2
- package/build-module/hooks/layout-child.mjs +36 -13
- package/build-module/hooks/layout-child.mjs.map +2 -2
- package/build-module/hooks/layout.mjs +22 -1
- package/build-module/hooks/layout.mjs.map +2 -2
- package/build-module/hooks/states.mjs +8 -5
- package/build-module/hooks/states.mjs.map +2 -2
- package/build-module/layouts/constrained.mjs +8 -1
- package/build-module/layouts/constrained.mjs.map +2 -2
- package/build-module/layouts/flex.mjs +9 -0
- package/build-module/layouts/flex.mjs.map +2 -2
- package/build-module/layouts/flow.mjs +4 -1
- package/build-module/layouts/flow.mjs.map +2 -2
- package/build-module/layouts/grid.mjs +5 -1
- package/build-module/layouts/grid.mjs.map +2 -2
- package/build-module/private-apis.mjs +3 -1
- package/build-module/private-apis.mjs.map +2 -2
- package/build-module/store/actions.mjs +1 -1
- package/build-module/store/actions.mjs.map +2 -2
- package/build-style/style-rtl.css +108 -71
- package/build-style/style.css +108 -71
- package/build-types/components/block-visibility/constants.d.ts +4 -3
- package/build-types/components/block-visibility/constants.d.ts.map +1 -1
- package/package.json +43 -43
- package/src/components/background-image-control/README.md +122 -0
- package/src/components/block-edit-visually-button/README.md +39 -0
- package/src/components/block-editing-mode/README.md +72 -0
- package/src/components/block-inspector/index.js +6 -6
- package/src/components/block-keyboard-shortcuts/index.js +256 -0
- package/src/components/block-list/block.js +7 -0
- package/src/components/block-list/index.js +7 -1
- package/src/components/block-list/use-block-props/use-focus-first-element.js +5 -0
- package/src/components/block-list/use-block-props/use-selected-block-event-handlers.js +6 -8
- package/src/components/block-parent-selector/index.js +111 -30
- package/src/components/block-popover/README.md +10 -3
- package/src/components/block-popover/inbetween.js +8 -2
- package/src/components/block-popover/stories/index.story.jsx +143 -0
- package/src/components/block-preview/index.js +0 -2
- package/src/components/block-styles/index.js +95 -43
- package/src/components/block-styles/style.scss +5 -34
- package/src/components/block-tools/style.scss +94 -0
- package/src/components/block-visibility/constants.ts +4 -3
- package/src/components/child-layout-control/index.js +5 -5
- package/src/components/color-palette/test/__snapshots__/control.js.snap +3 -29
- package/src/components/colors/test/with-colors.js +6 -7
- package/src/components/colors/with-colors.js +79 -105
- package/src/components/dimensions-tool/aspect-ratio-tool.js +16 -4
- package/src/components/dimensions-tool/index.js +34 -22
- package/src/components/dimensions-tool/test/index.js +166 -2
- package/src/components/dimensions-tool/test/utils.js +51 -0
- package/src/components/dimensions-tool/utils.js +67 -0
- package/src/components/duotone-control/index.js +2 -0
- package/src/components/duotone-control/test/index.js +100 -0
- package/src/components/global-styles/advanced-panel.js +5 -2
- package/src/components/global-styles/border-panel.js +11 -9
- package/src/components/global-styles/color-panel.js +13 -1
- package/src/components/global-styles/dimensions-panel.js +17 -5
- package/src/components/global-styles/filters-panel.js +24 -10
- package/src/components/global-styles/shadow-panel-components.js +38 -11
- package/src/components/global-styles/test/border-panel.js +230 -0
- package/src/components/global-styles/test/color-panel.js +24 -0
- package/src/components/global-styles/test/dimensions-panel.js +98 -7
- package/src/components/global-styles/test/filters-panel.js +84 -0
- package/src/components/global-styles/test/utils.js +30 -0
- package/src/components/global-styles/utils.js +23 -0
- package/src/components/inner-blocks/index.js +11 -2
- package/src/components/inner-blocks/stories/index.story.jsx +246 -0
- package/src/components/inserter/block-patterns-explorer/index.js +24 -11
- package/src/components/inserter/block-patterns-explorer/pattern-explorer-sidebar.js +18 -56
- package/src/components/inserter/block-patterns-explorer/pattern-list.js +22 -47
- package/src/components/inserter/hooks/use-insertion-point.js +9 -4
- package/src/components/inserter/menu.js +23 -10
- package/src/components/inserter/quick-inserter.js +15 -13
- package/src/components/inserter/style.scss +44 -62
- package/src/components/inspector-controls-tabs/README.md +92 -0
- package/src/components/inspector-controls-tabs/styles-tab.js +1 -1
- package/src/components/link-control/test/index.js +5 -0
- package/src/components/list-view/index.js +50 -7
- package/src/components/list-view/utils.js +16 -1
- package/src/components/media-placeholder/index.js +9 -4
- package/src/components/plain-text/stories/index.story.jsx +3 -0
- package/src/components/provider/index.js +7 -1
- package/src/components/publish-date-time-picker/README.md +10 -0
- package/src/components/publish-date-time-picker/index.js +17 -14
- package/src/components/rich-text/event-listeners/enter.js +58 -45
- package/src/components/rich-text/index.js +9 -4
- package/src/components/rich-text/multiline.js +126 -86
- package/src/components/url-input/index.js +2 -2
- package/src/components/url-input/test/fixtures/validated-input-control-deprecation.js +27 -0
- package/src/components/url-input/test/index.js +5 -0
- package/src/components/url-popover/README.md +7 -0
- package/src/components/url-popover/stories/index.story.jsx +133 -47
- package/src/components/writing-flow/use-input.js +105 -15
- package/src/hooks/border.js +27 -8
- package/src/hooks/dimensions.js +8 -1
- package/src/hooks/duotone.js +23 -7
- package/src/hooks/gap.js +16 -0
- package/src/hooks/layout-child.js +41 -9
- package/src/hooks/layout.js +117 -71
- package/src/hooks/states.js +8 -5
- package/src/hooks/test/gap.js +31 -1
- package/src/hooks/test/layout-child.js +60 -1
- package/src/hooks/test/layout.js +27 -0
- package/src/layouts/constrained.js +9 -1
- package/src/layouts/flex.js +15 -0
- package/src/layouts/flow.js +4 -1
- package/src/layouts/grid.js +9 -1
- package/src/layouts/test/constrained.js +26 -0
- package/src/layouts/test/flow.js +26 -0
- package/src/layouts/test/grid.js +46 -0
- package/src/private-apis.js +2 -0
- package/src/store/actions.js +14 -1
- package/build/components/floating-toolbar/nav-up-icon.cjs +0 -52
- package/build/components/floating-toolbar/nav-up-icon.cjs.map +0 -7
- package/build/components/gradients/with-gradient.cjs +0 -36
- package/build/components/gradients/with-gradient.cjs.map +0 -7
- package/build/components/inserter-button/sparkles.cjs +0 -36
- package/build/components/inserter-button/sparkles.cjs.map +0 -7
- package/build-module/components/floating-toolbar/nav-up-icon.mjs +0 -31
- package/build-module/components/floating-toolbar/nav-up-icon.mjs.map +0 -7
- package/build-module/components/gradients/with-gradient.mjs +0 -11
- package/build-module/components/gradients/with-gradient.mjs.map +0 -7
- package/build-module/components/inserter-button/sparkles.mjs +0 -15
- package/build-module/components/inserter-button/sparkles.mjs.map +0 -7
- package/build-style/default-editor-styles-rtl.css +0 -68
- package/build-style/default-editor-styles.css +0 -68
- package/src/components/floating-toolbar/nav-up-icon.js +0 -22
- package/src/components/gradients/with-gradient.js +0 -9
- package/src/components/inserter-button/README.md +0 -62
- package/src/components/inserter-button/sparkles.js +0 -12
- package/src/default-editor-styles.scss +0 -25
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/inner-blocks/index.js"],
|
|
4
|
-
"sourcesContent": ["import clsx from 'clsx';\nimport { useMergeRefs } from '@wordpress/compose';\nimport { forwardRef, useMemo, memo } from '@wordpress/element';\nimport { useSelect } from '@wordpress/data';\nimport {\n\tgetBlockSupport,\n\tstore as blocksStore,\n\t__unstableGetInnerBlocksProps as getInnerBlocksProps,\n} from '@wordpress/blocks';\nimport ButtonBlockAppender from './button-block-appender';\nimport DefaultBlockAppender from './default-block-appender';\nimport useNestedSettingsUpdate from './use-nested-settings-update';\nimport useInnerBlockTemplateSync from './use-inner-block-template-sync';\nimport useBlockContext from './use-block-context';\nimport { BlockListItems } from '../block-list';\nimport { BlockContextProvider } from '../block-context';\nimport { useBlockEditContext } from '../block-edit/context';\nimport useBlockSync from '../provider/use-block-sync';\nimport { store as blockEditorStore } from '../../store';\nimport useBlockDropZone from '../use-block-drop-zone';\nimport { unlock } from '../../lock-unlock';\n\nconst EMPTY_OBJECT = {};\n\nfunction BlockContext( { children, clientId } ) {\n\tconst context = useBlockContext( clientId );\n\treturn (\n\t\t<BlockContextProvider value={ context }>\n\t\t\t{ children }\n\t\t</BlockContextProvider>\n\t);\n}\n\nconst BlockListItemsMemo = memo( BlockListItems );\n\n/**\n * InnerBlocks is a component which allows a single block to have multiple blocks\n * as children. The UncontrolledInnerBlocks component is used whenever the inner\n * blocks are not controlled by another entity. In other words, it is normally\n * used for inner blocks in the post editor\n *\n * @param {Object} props The component props.\n */\nfunction UncontrolledInnerBlocks( props ) {\n\tconst {\n\t\tclientId,\n\t\tallowedBlocks,\n\t\tprioritizedInserterBlocks,\n\t\tdefaultBlock,\n\t\tdirectInsert,\n\t\t__experimentalDefaultBlock,\n\t\t__experimentalDirectInsert,\n\t\ttemplate,\n\t\ttemplateLock,\n\t\twrapperRef,\n\t\ttemplateInsertUpdatesSelection,\n\t\t__experimentalCaptureToolbars: captureToolbars,\n\t\t__experimentalAppenderTagName,\n\t\trenderAppender,\n\t\torientation,\n\t\tplaceholder,\n\t\tlayout,\n\t\tname,\n\t\tblockType,\n\t\tparentLock,\n\t\tdefaultLayout,\n\t} = props;\n\n\tuseNestedSettingsUpdate(\n\t\tclientId,\n\t\tparentLock,\n\t\tallowedBlocks,\n\t\tprioritizedInserterBlocks,\n\t\tdefaultBlock,\n\t\tdirectInsert,\n\t\t__experimentalDefaultBlock,\n\t\t__experimentalDirectInsert,\n\t\ttemplateLock,\n\t\tcaptureToolbars,\n\t\torientation,\n\t\tlayout\n\t);\n\n\tuseInnerBlockTemplateSync(\n\t\tclientId,\n\t\ttemplate,\n\t\ttemplateLock,\n\t\ttemplateInsertUpdatesSelection\n\t);\n\n\tconst defaultLayoutBlockSupport =\n\t\tgetBlockSupport( name, 'layout' ) ||\n\t\tgetBlockSupport( name, '__experimentalLayout' ) ||\n\t\tEMPTY_OBJECT;\n\n\tconst { allowSizingOnChildren = false } = defaultLayoutBlockSupport;\n\tconst usedLayout = layout || defaultLayoutBlockSupport;\n\n\tconst memoedLayout = useMemo(\n\t\t() => ( {\n\t\t\t// Default layout will know about any content/wide size defined by the theme.\n\t\t\t...defaultLayout,\n\t\t\t...usedLayout,\n\t\t\t...( allowSizingOnChildren && {\n\t\t\t\tallowSizingOnChildren: true,\n\t\t\t} ),\n\t\t} ),\n\t\t[ defaultLayout, usedLayout, allowSizingOnChildren ]\n\t);\n\n\t// For controlled inner blocks, we don't want a change in blocks to\n\t// re-render the blocks list.\n\tconst items = (\n\t\t<BlockListItemsMemo\n\t\t\trootClientId={ clientId }\n\t\t\trenderAppender={ renderAppender }\n\t\t\t__experimentalAppenderTagName={ __experimentalAppenderTagName }\n\t\t\tlayout={ memoedLayout }\n\t\t\twrapperRef={ wrapperRef }\n\t\t\tplaceholder={ placeholder }\n\t\t/>\n\t);\n\n\tif (\n\t\t! blockType?.providesContext ||\n\t\tObject.keys( blockType.providesContext ).length === 0\n\t) {\n\t\treturn items;\n\t}\n\n\treturn <BlockContext clientId={ clientId }>{ items }</BlockContext>;\n}\n\n/**\n * The controlled inner blocks component wraps the uncontrolled inner blocks\n * component with the blockSync hook. This keeps the innerBlocks of the block in\n * the block-editor store in sync with the blocks of the controlling entity. An\n * example of an inner block controller is a template part block, which provides\n * its own blocks from the template part entity data source.\n *\n * @param {Object} props The component props.\n */\nfunction ControlledInnerBlocks( props ) {\n\tuseBlockSync( props );\n\treturn <UncontrolledInnerBlocks { ...props } />;\n}\n\nconst ForwardedInnerBlocks = forwardRef( ( props, ref ) => {\n\tconst innerBlocksProps = useInnerBlocksProps( { ref }, props );\n\treturn (\n\t\t<div className=\"block-editor-inner-blocks\">\n\t\t\t<div { ...innerBlocksProps } />\n\t\t</div>\n\t);\n} );\n\n/**\n * This hook is used to lightly mark an element as an inner blocks wrapper\n * element. Call this hook and pass the returned props to the element to mark as\n * an inner blocks wrapper, automatically rendering inner blocks as children. If\n * you define a ref for the element, it is important to pass the ref to this\n * hook, which the hook in turn will pass to the component through the props it\n * returns. Optionally, you can also pass any other props through this hook, and\n * they will be merged and returned.\n *\n * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/inner-blocks/README.md\n *\n * @param {Object} props Optional. Props to pass to the element. Must contain\n * the ref if one is defined.\n * @param {Object} options Optional. Inner blocks options.\n */\nexport function useInnerBlocksProps( props = {}, options = {} ) {\n\tconst {\n\t\t__unstableDisableLayoutClassNames,\n\t\t__unstableDisableDropZone,\n\t\tdropZoneElement,\n\t} = options;\n\tconst {\n\t\tclientId,\n\t\tlayout = null,\n\t\t__unstableLayoutClassNames: layoutClassNames = '',\n\t} = useBlockEditContext();\n\tconst selected = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tgetBlockName,\n\t\t\t\tisZoomOut,\n\t\t\t\tgetTemplateLock,\n\t\t\t\tgetBlockRootClientId,\n\t\t\t\tgetBlockEditingMode,\n\t\t\t\tgetBlockSettings,\n\t\t\t\tgetSectionRootClientId,\n\t\t\t} = unlock( select( blockEditorStore ) );\n\n\t\t\tif ( ! clientId ) {\n\t\t\t\tconst sectionRootClientId = getSectionRootClientId();\n\t\t\t\t// Disable the root drop zone when zoomed out and the section root client id\n\t\t\t\t// is not the root block list (represented by an empty string).\n\t\t\t\t// This avoids drag handling bugs caused by having two block lists acting as\n\t\t\t\t// drop zones - the actual 'root' block list and the section root.\n\t\t\t\treturn {\n\t\t\t\t\tisDropZoneDisabled:\n\t\t\t\t\t\tisZoomOut() && sectionRootClientId !== '',\n\t\t\t\t};\n\t\t\t}\n\n\t\t\tconst { hasBlockSupport, getBlockType } = select( blocksStore );\n\t\t\tconst blockName = getBlockName( clientId );\n\t\t\tconst blockEditingMode = getBlockEditingMode( clientId );\n\t\t\tconst parentClientId = getBlockRootClientId( clientId );\n\t\t\tconst [ defaultLayout ] = getBlockSettings( clientId, 'layout' );\n\n\t\t\tlet _isDropZoneDisabled = blockEditingMode === 'disabled';\n\n\t\t\tif ( isZoomOut() ) {\n\t\t\t\t// In zoom out mode, we want to disable the drop zone for the sections.\n\t\t\t\t// The inner blocks belonging to the section drop zone is\n\t\t\t\t// already disabled by the blocks themselves being disabled.\n\t\t\t\tconst sectionRootClientId = getSectionRootClientId();\n\t\t\t\t_isDropZoneDisabled = clientId !== sectionRootClientId;\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\t__experimentalCaptureToolbars: hasBlockSupport(\n\t\t\t\t\tblockName,\n\t\t\t\t\t'__experimentalExposeControlsToChildren',\n\t\t\t\t\tfalse\n\t\t\t\t),\n\t\t\t\tname: blockName,\n\t\t\t\tblockType: getBlockType( blockName ),\n\t\t\t\tparentLock: getTemplateLock( parentClientId ),\n\t\t\t\tparentClientId,\n\t\t\t\tisDropZoneDisabled: _isDropZoneDisabled,\n\t\t\t\tdefaultLayout,\n\t\t\t};\n\t\t},\n\t\t[ clientId ]\n\t);\n\tconst {\n\t\t__experimentalCaptureToolbars,\n\t\tname,\n\t\tblockType,\n\t\tparentLock,\n\t\tparentClientId,\n\t\tisDropZoneDisabled,\n\t\tdefaultLayout,\n\t} = selected;\n\n\tconst blockDropZoneRef = useBlockDropZone( {\n\t\tdropZoneElement,\n\t\trootClientId: clientId,\n\t\tparentClientId,\n\t} );\n\n\tconst ref = useMergeRefs( [\n\t\tprops.ref,\n\t\t__unstableDisableDropZone ||\n\t\tisDropZoneDisabled ||\n\t\t( layout?.isManualPlacement &&\n\t\t\twindow.__experimentalEnableGridInteractivity )\n\t\t\t? null\n\t\t\t: blockDropZoneRef,\n\t] );\n\n\tconst innerBlocksProps = {\n\t\t__experimentalCaptureToolbars,\n\t\tlayout,\n\t\tname,\n\t\tblockType,\n\t\tparentLock,\n\t\tdefaultLayout,\n\t\t...options,\n\t};\n\tconst InnerBlocks =\n\t\tinnerBlocksProps.value && innerBlocksProps.onChange\n\t\t\t? ControlledInnerBlocks\n\t\t\t: UncontrolledInnerBlocks;\n\n\treturn {\n\t\t...props,\n\t\tref,\n\t\tclassName: clsx(\n\t\t\tprops.className,\n\t\t\t'block-editor-block-list__layout',\n\t\t\t__unstableDisableLayoutClassNames ? '' : layoutClassNames\n\t\t),\n\t\tchildren: clientId ? (\n\t\t\t<InnerBlocks { ...innerBlocksProps } clientId={ clientId } />\n\t\t) : (\n\t\t\t<BlockListItems { ...options } />\n\t\t),\n\t};\n}\n\nuseInnerBlocksProps.save = getInnerBlocksProps;\n\n// Expose default appender placeholders as components.\nForwardedInnerBlocks.DefaultBlockAppender = DefaultBlockAppender;\nForwardedInnerBlocks.ButtonBlockAppender = ButtonBlockAppender;\n\nForwardedInnerBlocks.Content = () => useInnerBlocksProps.save().children;\n\n/**\n * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/inner-blocks/README.md\n */\nexport default ForwardedInnerBlocks;\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAiB;AACjB,qBAA6B;AAC7B,qBAA0C;AAC1C,kBAA0B;AAC1B,oBAIO;AACP,mCAAgC;AAChC,oCAAiC;AACjC,wCAAoC;AACpC,2CAAsC;AACtC,+BAA4B;AAC5B,wBAA+B;AAC/B,2BAAqC;AACrC,qBAAoC;AACpC,4BAAyB;AACzB,mBAA0C;AAC1C,iCAA6B;AAC7B,yBAAuB;AAOrB;AALF,IAAM,eAAe,CAAC;AAEtB,SAAS,aAAc,EAAE,UAAU,SAAS,GAAI;AAC/C,QAAM,cAAU,yBAAAA,SAAiB,QAAS;AAC1C,SACC,4CAAC,6CAAqB,OAAQ,SAC3B,UACH;AAEF;AAEA,IAAM,yBAAqB,qBAAM,gCAAe;AAUhD,SAAS,wBAAyB,OAAQ;AACzC,QAAM;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,+BAA+B;AAAA,IAC/B;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACD,IAAI;AAEJ,wCAAAC;AAAA,IACC;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACD;AAEA,2CAAAC;AAAA,IACC;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACD;AAEA,QAAM,gCACL,+BAAiB,MAAM,QAAS,SAChC,+BAAiB,MAAM,sBAAuB,KAC9C;AAED,QAAM,EAAE,wBAAwB,MAAM,IAAI;
|
|
4
|
+
"sourcesContent": ["import clsx from 'clsx';\nimport { useMergeRefs } from '@wordpress/compose';\nimport { forwardRef, useMemo, memo } from '@wordpress/element';\nimport { useSelect } from '@wordpress/data';\nimport {\n\tgetBlockSupport,\n\tstore as blocksStore,\n\t__unstableGetInnerBlocksProps as getInnerBlocksProps,\n} from '@wordpress/blocks';\nimport ButtonBlockAppender from './button-block-appender';\nimport DefaultBlockAppender from './default-block-appender';\nimport useNestedSettingsUpdate from './use-nested-settings-update';\nimport useInnerBlockTemplateSync from './use-inner-block-template-sync';\nimport useBlockContext from './use-block-context';\nimport { BlockListItems } from '../block-list';\nimport { BlockContextProvider } from '../block-context';\nimport { useBlockEditContext } from '../block-edit/context';\nimport useBlockSync from '../provider/use-block-sync';\nimport { store as blockEditorStore } from '../../store';\nimport useBlockDropZone from '../use-block-drop-zone';\nimport { unlock } from '../../lock-unlock';\n\nconst EMPTY_OBJECT = {};\n\nfunction BlockContext( { children, clientId } ) {\n\tconst context = useBlockContext( clientId );\n\treturn (\n\t\t<BlockContextProvider value={ context }>\n\t\t\t{ children }\n\t\t</BlockContextProvider>\n\t);\n}\n\nconst BlockListItemsMemo = memo( BlockListItems );\n\n/**\n * InnerBlocks is a component which allows a single block to have multiple blocks\n * as children. The UncontrolledInnerBlocks component is used whenever the inner\n * blocks are not controlled by another entity. In other words, it is normally\n * used for inner blocks in the post editor\n *\n * @param {Object} props The component props.\n */\nfunction UncontrolledInnerBlocks( props ) {\n\tconst {\n\t\tclientId,\n\t\tallowedBlocks,\n\t\tprioritizedInserterBlocks,\n\t\tdefaultBlock,\n\t\tdirectInsert,\n\t\t__experimentalDefaultBlock,\n\t\t__experimentalDirectInsert,\n\t\ttemplate,\n\t\ttemplateLock,\n\t\twrapperRef,\n\t\ttemplateInsertUpdatesSelection,\n\t\t__experimentalCaptureToolbars: captureToolbars,\n\t\t__experimentalAppenderTagName,\n\t\trenderAppender,\n\t\torientation,\n\t\tplaceholder,\n\t\tlayout,\n\t\tname,\n\t\tblockType,\n\t\tparentLock,\n\t\tdefaultLayout,\n\t} = props;\n\n\tuseNestedSettingsUpdate(\n\t\tclientId,\n\t\tparentLock,\n\t\tallowedBlocks,\n\t\tprioritizedInserterBlocks,\n\t\tdefaultBlock,\n\t\tdirectInsert,\n\t\t__experimentalDefaultBlock,\n\t\t__experimentalDirectInsert,\n\t\ttemplateLock,\n\t\tcaptureToolbars,\n\t\torientation,\n\t\tlayout\n\t);\n\n\tuseInnerBlockTemplateSync(\n\t\tclientId,\n\t\ttemplate,\n\t\ttemplateLock,\n\t\ttemplateInsertUpdatesSelection\n\t);\n\n\tconst defaultLayoutBlockSupport =\n\t\tgetBlockSupport( name, 'layout' ) ||\n\t\tgetBlockSupport( name, '__experimentalLayout' ) ||\n\t\tEMPTY_OBJECT;\n\n\tconst { allowSizingOnChildren = false } = defaultLayoutBlockSupport;\n\t// The support is a config object, e.g. `{ allowSwitching: false, default: { type: 'flex' } }`,\n\t// so the layout itself lives under `default`. Passing the config through would leave the\n\t// context without a `type`, and consumers would resolve it to the flow layout.\n\tconst usedLayout =\n\t\tlayout || defaultLayoutBlockSupport.default || EMPTY_OBJECT;\n\n\tconst memoedLayout = useMemo(\n\t\t() => ( {\n\t\t\t// Default layout will know about any content/wide size defined by the theme.\n\t\t\t...defaultLayout,\n\t\t\t...usedLayout,\n\t\t\t...( allowSizingOnChildren && {\n\t\t\t\tallowSizingOnChildren: true,\n\t\t\t} ),\n\t\t} ),\n\t\t[ defaultLayout, usedLayout, allowSizingOnChildren ]\n\t);\n\n\t// For controlled inner blocks, we don't want a change in blocks to\n\t// re-render the blocks list.\n\tconst items = (\n\t\t<BlockListItemsMemo\n\t\t\trootClientId={ clientId }\n\t\t\trenderAppender={ renderAppender }\n\t\t\t__experimentalAppenderTagName={ __experimentalAppenderTagName }\n\t\t\tlayout={ memoedLayout }\n\t\t\twrapperRef={ wrapperRef }\n\t\t\tplaceholder={ placeholder }\n\t\t/>\n\t);\n\n\tif (\n\t\t! blockType?.providesContext ||\n\t\tObject.keys( blockType.providesContext ).length === 0\n\t) {\n\t\treturn items;\n\t}\n\n\treturn <BlockContext clientId={ clientId }>{ items }</BlockContext>;\n}\n\n/**\n * The controlled inner blocks component wraps the uncontrolled inner blocks\n * component with the blockSync hook. This keeps the innerBlocks of the block in\n * the block-editor store in sync with the blocks of the controlling entity. An\n * example of an inner block controller is a template part block, which provides\n * its own blocks from the template part entity data source.\n *\n * @param {Object} props The component props.\n */\nfunction ControlledInnerBlocks( props ) {\n\tuseBlockSync( props );\n\treturn <UncontrolledInnerBlocks { ...props } />;\n}\n\nconst ForwardedInnerBlocks = forwardRef( ( props, ref ) => {\n\tconst innerBlocksProps = useInnerBlocksProps( { ref }, props );\n\treturn (\n\t\t<div className=\"block-editor-inner-blocks\">\n\t\t\t<div { ...innerBlocksProps } />\n\t\t</div>\n\t);\n} );\n\n/**\n * This hook is used to lightly mark an element as an inner blocks wrapper\n * element. Call this hook and pass the returned props to the element to mark as\n * an inner blocks wrapper, automatically rendering inner blocks as children. If\n * you define a ref for the element, it is important to pass the ref to this\n * hook, which the hook in turn will pass to the component through the props it\n * returns. Optionally, you can also pass any other props through this hook, and\n * they will be merged and returned.\n *\n * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/inner-blocks/README.md\n *\n * @param {Object} props Optional. Props to pass to the element. Must contain\n * the ref if one is defined.\n * @param {Object} options Optional. Inner blocks options.\n */\nexport function useInnerBlocksProps( props = {}, options = {} ) {\n\tconst {\n\t\t__unstableDisableLayoutClassNames,\n\t\t__unstableDisableDropZone,\n\t\tdropZoneElement,\n\t\tlayout: layoutOverride,\n\t} = options;\n\tconst {\n\t\tclientId,\n\t\tlayout: contextLayout = null,\n\t\t__unstableLayoutClassNames: layoutClassNames = '',\n\t} = useBlockEditContext();\n\t// An options layout takes precedence over the context layout, as it does\n\t// for the inner blocks settings, so containers whose layout attribute\n\t// doesn't apply to their inner blocks (e.g. Post Template) can opt out.\n\tconst layout = layoutOverride ?? contextLayout;\n\tconst selected = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tgetBlockName,\n\t\t\t\tisZoomOut,\n\t\t\t\tgetTemplateLock,\n\t\t\t\tgetBlockRootClientId,\n\t\t\t\tgetBlockEditingMode,\n\t\t\t\tgetBlockSettings,\n\t\t\t\tgetSectionRootClientId,\n\t\t\t} = unlock( select( blockEditorStore ) );\n\n\t\t\tif ( ! clientId ) {\n\t\t\t\tconst sectionRootClientId = getSectionRootClientId();\n\t\t\t\t// Disable the root drop zone when zoomed out and the section root client id\n\t\t\t\t// is not the root block list (represented by an empty string).\n\t\t\t\t// This avoids drag handling bugs caused by having two block lists acting as\n\t\t\t\t// drop zones - the actual 'root' block list and the section root.\n\t\t\t\treturn {\n\t\t\t\t\tisDropZoneDisabled:\n\t\t\t\t\t\tisZoomOut() && sectionRootClientId !== '',\n\t\t\t\t};\n\t\t\t}\n\n\t\t\tconst { hasBlockSupport, getBlockType } = select( blocksStore );\n\t\t\tconst blockName = getBlockName( clientId );\n\t\t\tconst blockEditingMode = getBlockEditingMode( clientId );\n\t\t\tconst parentClientId = getBlockRootClientId( clientId );\n\t\t\tconst [ defaultLayout ] = getBlockSettings( clientId, 'layout' );\n\n\t\t\tlet _isDropZoneDisabled = blockEditingMode === 'disabled';\n\n\t\t\tif ( isZoomOut() ) {\n\t\t\t\t// In zoom out mode, we want to disable the drop zone for the sections.\n\t\t\t\t// The inner blocks belonging to the section drop zone is\n\t\t\t\t// already disabled by the blocks themselves being disabled.\n\t\t\t\tconst sectionRootClientId = getSectionRootClientId();\n\t\t\t\t_isDropZoneDisabled = clientId !== sectionRootClientId;\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\t__experimentalCaptureToolbars: hasBlockSupport(\n\t\t\t\t\tblockName,\n\t\t\t\t\t'__experimentalExposeControlsToChildren',\n\t\t\t\t\tfalse\n\t\t\t\t),\n\t\t\t\tname: blockName,\n\t\t\t\tblockType: getBlockType( blockName ),\n\t\t\t\tparentLock: getTemplateLock( parentClientId ),\n\t\t\t\tparentClientId,\n\t\t\t\tisDropZoneDisabled: _isDropZoneDisabled,\n\t\t\t\tdefaultLayout,\n\t\t\t};\n\t\t},\n\t\t[ clientId ]\n\t);\n\tconst {\n\t\t__experimentalCaptureToolbars,\n\t\tname,\n\t\tblockType,\n\t\tparentLock,\n\t\tparentClientId,\n\t\tisDropZoneDisabled,\n\t\tdefaultLayout,\n\t} = selected;\n\n\tconst blockDropZoneRef = useBlockDropZone( {\n\t\tdropZoneElement,\n\t\trootClientId: clientId,\n\t\tparentClientId,\n\t} );\n\n\tconst ref = useMergeRefs( [\n\t\tprops.ref,\n\t\t__unstableDisableDropZone ||\n\t\tisDropZoneDisabled ||\n\t\t( layout?.isManualPlacement &&\n\t\t\twindow.__experimentalEnableGridInteractivity )\n\t\t\t? null\n\t\t\t: blockDropZoneRef,\n\t] );\n\n\tconst innerBlocksProps = {\n\t\t__experimentalCaptureToolbars,\n\t\tlayout,\n\t\tname,\n\t\tblockType,\n\t\tparentLock,\n\t\tdefaultLayout,\n\t\t...options,\n\t};\n\tconst InnerBlocks =\n\t\tinnerBlocksProps.value && innerBlocksProps.onChange\n\t\t\t? ControlledInnerBlocks\n\t\t\t: UncontrolledInnerBlocks;\n\n\treturn {\n\t\t...props,\n\t\tref,\n\t\tclassName: clsx(\n\t\t\tprops.className,\n\t\t\t'block-editor-block-list__layout',\n\t\t\t__unstableDisableLayoutClassNames ? '' : layoutClassNames\n\t\t),\n\t\tchildren: clientId ? (\n\t\t\t<InnerBlocks { ...innerBlocksProps } clientId={ clientId } />\n\t\t) : (\n\t\t\t<BlockListItems { ...options } />\n\t\t),\n\t};\n}\n\nuseInnerBlocksProps.save = getInnerBlocksProps;\n\n// Expose default appender placeholders as components.\nForwardedInnerBlocks.DefaultBlockAppender = DefaultBlockAppender;\nForwardedInnerBlocks.ButtonBlockAppender = ButtonBlockAppender;\n\nForwardedInnerBlocks.Content = () => useInnerBlocksProps.save().children;\n\n/**\n * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/inner-blocks/README.md\n */\nexport default ForwardedInnerBlocks;\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAiB;AACjB,qBAA6B;AAC7B,qBAA0C;AAC1C,kBAA0B;AAC1B,oBAIO;AACP,mCAAgC;AAChC,oCAAiC;AACjC,wCAAoC;AACpC,2CAAsC;AACtC,+BAA4B;AAC5B,wBAA+B;AAC/B,2BAAqC;AACrC,qBAAoC;AACpC,4BAAyB;AACzB,mBAA0C;AAC1C,iCAA6B;AAC7B,yBAAuB;AAOrB;AALF,IAAM,eAAe,CAAC;AAEtB,SAAS,aAAc,EAAE,UAAU,SAAS,GAAI;AAC/C,QAAM,cAAU,yBAAAA,SAAiB,QAAS;AAC1C,SACC,4CAAC,6CAAqB,O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AAAA,QACD;AAAA,QACA,MAAM;AAAA,QACN,WAAW,aAAc,SAAU;AAAA,QACnC,YAAY,gBAAiBD,eAAe;AAAA,QAC5C,gBAAAA;AAAA,QACA,oBAAoB;AAAA,QACpB,eAAAC;AAAA,MACD;AAAA,IACD;AAAA,IACA,CAAE,QAAS;AAAA,EACZ;AACA,QAAM;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACD,IAAI;AAEJ,QAAM,uBAAmB,2BAAAC,SAAkB;AAAA,IAC1C;AAAA,IACA,cAAc;AAAA,IACd;AAAA,EACD,CAAE;AAEF,QAAM,UAAM,6BAAc;AAAA,IACzB,MAAM;AAAA,IACN,6BACA,sBACE,QAAQ,qBACT,OAAO,wCACL,OACA;AAAA,EACJ,CAAE;AAEF,QAAM,mBAAmB;AAAA,IACxB;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,GAAG;AAAA,EACJ;AACA,QAAM,cACL,iBAAiB,SAAS,iBAAiB,WACxC,wBACA;AAEJ,SAAO;AAAA,IACN,GAAG;AAAA,IACH;AAAA,IACA,eAAW,YAAAC;AAAA,MACV,MAAM;AAAA,MACN;AAAA,MACA,oCAAoC,KAAK;AAAA,IAC1C;AAAA,IACA,UAAU,WACT,4CAAC,eAAc,GAAG,kBAAmB,UAAsB,IAE3D,4CAAC,oCAAiB,GAAG,SAAU;AAAA,EAEjC;AACD;AAEA,oBAAoB,OAAO,cAAAC;AAG3B,qBAAqB,uBAAuB,8BAAAC;AAC5C,qBAAqB,sBAAsB,6BAAAC;AAE3C,qBAAqB,UAAU,MAAM,oBAAoB,KAAK,EAAE;AAKhE,IAAO,uBAAQ;",
|
|
6
6
|
"names": ["useBlockContext", "useNestedSettingsUpdate", "useInnerBlockTemplateSync", "useBlockSync", "blockEditorStore", "blocksStore", "parentClientId", "defaultLayout", "useBlockDropZone", "clsx", "getInnerBlocksProps", "DefaultBlockAppender", "ButtonBlockAppender"]
|
|
7
7
|
}
|
|
@@ -34,6 +34,7 @@ __export(block_patterns_explorer_exports, {
|
|
|
34
34
|
});
|
|
35
35
|
module.exports = __toCommonJS(block_patterns_explorer_exports);
|
|
36
36
|
var import_components = require("@wordpress/components");
|
|
37
|
+
var import_ui = require("@wordpress/ui");
|
|
37
38
|
var import_element = require("@wordpress/element");
|
|
38
39
|
var import_i18n = require("@wordpress/i18n");
|
|
39
40
|
var import_pattern_explorer_sidebar = __toESM(require("./pattern-explorer-sidebar.cjs"));
|
|
@@ -46,28 +47,44 @@ function PatternsExplorer({ initialCategory, rootClientId, onModalClose }) {
|
|
|
46
47
|
initialCategory?.name
|
|
47
48
|
);
|
|
48
49
|
const patternCategories = (0, import_use_pattern_categories.usePatternCategories)(rootClientId);
|
|
49
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
patternCategories,
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
50
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
51
|
+
import_ui.Tabs.Root,
|
|
52
|
+
{
|
|
53
|
+
className: "block-editor-block-patterns-explorer",
|
|
54
|
+
orientation: "vertical",
|
|
55
|
+
value: selectedCategory,
|
|
56
|
+
onValueChange: setSelectedCategory,
|
|
57
|
+
children: [
|
|
58
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
59
|
+
import_pattern_explorer_sidebar.default,
|
|
60
|
+
{
|
|
61
|
+
patternCategories,
|
|
62
|
+
searchValue,
|
|
63
|
+
setSearchValue
|
|
64
|
+
}
|
|
65
|
+
),
|
|
66
|
+
patternCategories.map(({ name }) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
67
|
+
import_ui.Tabs.Panel,
|
|
68
|
+
{
|
|
69
|
+
value: name,
|
|
70
|
+
tabIndex: -1,
|
|
71
|
+
className: "block-editor-block-patterns-explorer__panel",
|
|
72
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
73
|
+
import_pattern_list.default,
|
|
74
|
+
{
|
|
75
|
+
searchValue,
|
|
76
|
+
selectedCategory: name,
|
|
77
|
+
patternCategories,
|
|
78
|
+
rootClientId,
|
|
79
|
+
onModalClose
|
|
80
|
+
}
|
|
81
|
+
)
|
|
82
|
+
},
|
|
83
|
+
name
|
|
84
|
+
))
|
|
85
|
+
]
|
|
86
|
+
}
|
|
87
|
+
);
|
|
71
88
|
}
|
|
72
89
|
function PatternsExplorerModal({ onModalClose, ...restProps }) {
|
|
73
90
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/components/inserter/block-patterns-explorer/index.js"],
|
|
4
|
-
"sourcesContent": ["import { Modal } from '@wordpress/components';\nimport { useState } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport PatternExplorerSidebar from './pattern-explorer-sidebar';\nimport PatternList from './pattern-list';\nimport { usePatternCategories } from '../block-patterns-tab/use-pattern-categories';\n\nfunction PatternsExplorer( { initialCategory, rootClientId, onModalClose } ) {\n\tconst [ searchValue, setSearchValue ] = useState( '' );\n\tconst [ selectedCategory, setSelectedCategory ] = useState(\n\t\tinitialCategory?.name\n\t);\n\n\tconst patternCategories = usePatternCategories( rootClientId );\n\n\treturn (\n\t\t<
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,wBAAsB;AACtB,qBAAyB;AACzB,kBAAmB;AACnB,sCAAmC;AACnC,0BAAwB;AACxB,oCAAqC;AAWnC;AATF,SAAS,iBAAkB,EAAE,iBAAiB,cAAc,aAAa,GAAI;AAC5E,QAAM,CAAE,aAAa,cAAe,QAAI,yBAAU,EAAG;AACrD,QAAM,CAAE,kBAAkB,mBAAoB,QAAI;AAAA,IACjD,iBAAiB;AAAA,EAClB;AAEA,QAAM,wBAAoB,oDAAsB,YAAa;AAE7D,SACC,
|
|
4
|
+
"sourcesContent": ["import { Modal } from '@wordpress/components';\nimport { Tabs } from '@wordpress/ui';\nimport { useState } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport PatternExplorerSidebar from './pattern-explorer-sidebar';\nimport PatternList from './pattern-list';\nimport { usePatternCategories } from '../block-patterns-tab/use-pattern-categories';\n\nfunction PatternsExplorer( { initialCategory, rootClientId, onModalClose } ) {\n\tconst [ searchValue, setSearchValue ] = useState( '' );\n\tconst [ selectedCategory, setSelectedCategory ] = useState(\n\t\tinitialCategory?.name\n\t);\n\n\tconst patternCategories = usePatternCategories( rootClientId );\n\n\treturn (\n\t\t<Tabs.Root\n\t\t\tclassName=\"block-editor-block-patterns-explorer\"\n\t\t\torientation=\"vertical\"\n\t\t\tvalue={ selectedCategory }\n\t\t\tonValueChange={ setSelectedCategory }\n\t\t>\n\t\t\t<PatternExplorerSidebar\n\t\t\t\tpatternCategories={ patternCategories }\n\t\t\t\tsearchValue={ searchValue }\n\t\t\t\tsetSearchValue={ setSearchValue }\n\t\t\t/>\n\t\t\t{ patternCategories.map( ( { name } ) => (\n\t\t\t\t<Tabs.Panel\n\t\t\t\t\tkey={ name }\n\t\t\t\t\tvalue={ name }\n\t\t\t\t\ttabIndex={ -1 }\n\t\t\t\t\tclassName=\"block-editor-block-patterns-explorer__panel\"\n\t\t\t\t>\n\t\t\t\t\t<PatternList\n\t\t\t\t\t\tsearchValue={ searchValue }\n\t\t\t\t\t\tselectedCategory={ name }\n\t\t\t\t\t\tpatternCategories={ patternCategories }\n\t\t\t\t\t\trootClientId={ rootClientId }\n\t\t\t\t\t\tonModalClose={ onModalClose }\n\t\t\t\t\t/>\n\t\t\t\t</Tabs.Panel>\n\t\t\t) ) }\n\t\t</Tabs.Root>\n\t);\n}\n\nfunction PatternsExplorerModal( { onModalClose, ...restProps } ) {\n\treturn (\n\t\t<Modal\n\t\t\ttitle={ __( 'Patterns' ) }\n\t\t\tonRequestClose={ onModalClose }\n\t\t\tisFullScreen\n\t\t>\n\t\t\t<PatternsExplorer onModalClose={ onModalClose } { ...restProps } />\n\t\t</Modal>\n\t);\n}\n\nexport default PatternsExplorerModal;\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,wBAAsB;AACtB,gBAAqB;AACrB,qBAAyB;AACzB,kBAAmB;AACnB,sCAAmC;AACnC,0BAAwB;AACxB,oCAAqC;AAWnC;AATF,SAAS,iBAAkB,EAAE,iBAAiB,cAAc,aAAa,GAAI;AAC5E,QAAM,CAAE,aAAa,cAAe,QAAI,yBAAU,EAAG;AACrD,QAAM,CAAE,kBAAkB,mBAAoB,QAAI;AAAA,IACjD,iBAAiB;AAAA,EAClB;AAEA,QAAM,wBAAoB,oDAAsB,YAAa;AAE7D,SACC;AAAA,IAAC,eAAK;AAAA,IAAL;AAAA,MACA,WAAU;AAAA,MACV,aAAY;AAAA,MACZ,OAAQ;AAAA,MACR,eAAgB;AAAA,MAEhB;AAAA;AAAA,UAAC,gCAAAA;AAAA,UAAA;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA;AAAA,QACD;AAAA,QACE,kBAAkB,IAAK,CAAE,EAAE,KAAK,MACjC;AAAA,UAAC,eAAK;AAAA,UAAL;AAAA,YAEA,OAAQ;AAAA,YACR,UAAW;AAAA,YACX,WAAU;AAAA,YAEV;AAAA,cAAC,oBAAAC;AAAA,cAAA;AAAA,gBACA;AAAA,gBACA,kBAAmB;AAAA,gBACnB;AAAA,gBACA;AAAA,gBACA;AAAA;AAAA,YACD;AAAA;AAAA,UAXM;AAAA,QAYP,CACC;AAAA;AAAA;AAAA,EACH;AAEF;AAEA,SAAS,sBAAuB,EAAE,cAAc,GAAG,UAAU,GAAI;AAChE,SACC;AAAA,IAAC;AAAA;AAAA,MACA,WAAQ,gBAAI,UAAW;AAAA,MACvB,gBAAiB;AAAA,MACjB,cAAY;AAAA,MAEZ,sDAAC,oBAAiB,cAAgC,GAAG,WAAY;AAAA;AAAA,EAClE;AAEF;AAEA,IAAO,kCAAQ;",
|
|
6
6
|
"names": ["PatternExplorerSidebar", "PatternList"]
|
|
7
7
|
}
|
|
@@ -24,68 +24,34 @@ __export(pattern_explorer_sidebar_exports, {
|
|
|
24
24
|
});
|
|
25
25
|
module.exports = __toCommonJS(pattern_explorer_sidebar_exports);
|
|
26
26
|
var import_components = require("@wordpress/components");
|
|
27
|
+
var import_ui = require("@wordpress/ui");
|
|
27
28
|
var import_i18n = require("@wordpress/i18n");
|
|
28
29
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
29
|
-
function PatternCategoriesList({
|
|
30
|
-
selectedCategory,
|
|
31
|
-
patternCategories,
|
|
32
|
-
onClickCategory
|
|
33
|
-
}) {
|
|
34
|
-
const baseClassName = "block-editor-block-patterns-explorer__sidebar";
|
|
35
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: `${baseClassName}__categories-list`, children: patternCategories.map(({ name, label }) => {
|
|
36
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
37
|
-
import_components.Button,
|
|
38
|
-
{
|
|
39
|
-
__next40pxDefaultSize: true,
|
|
40
|
-
label,
|
|
41
|
-
className: `${baseClassName}__categories-list__item`,
|
|
42
|
-
isPressed: selectedCategory === name,
|
|
43
|
-
onClick: () => {
|
|
44
|
-
onClickCategory(name);
|
|
45
|
-
},
|
|
46
|
-
children: label
|
|
47
|
-
},
|
|
48
|
-
name
|
|
49
|
-
);
|
|
50
|
-
}) });
|
|
51
|
-
}
|
|
52
|
-
function PatternsExplorerSearch({ searchValue, setSearchValue }) {
|
|
53
|
-
const baseClassName = "block-editor-block-patterns-explorer__search";
|
|
54
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: baseClassName, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
55
|
-
import_components.SearchControl,
|
|
56
|
-
{
|
|
57
|
-
onChange: setSearchValue,
|
|
58
|
-
value: searchValue,
|
|
59
|
-
label: (0, import_i18n.__)("Search"),
|
|
60
|
-
placeholder: (0, import_i18n.__)("Search")
|
|
61
|
-
}
|
|
62
|
-
) });
|
|
63
|
-
}
|
|
64
30
|
function PatternExplorerSidebar({
|
|
65
|
-
selectedCategory,
|
|
66
31
|
patternCategories,
|
|
67
|
-
onClickCategory,
|
|
68
32
|
searchValue,
|
|
69
33
|
setSearchValue
|
|
70
34
|
}) {
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
35
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
36
|
+
import_ui.Stack,
|
|
37
|
+
{
|
|
38
|
+
direction: "column",
|
|
39
|
+
gap: "lg",
|
|
40
|
+
className: "block-editor-block-patterns-explorer__sidebar",
|
|
41
|
+
children: [
|
|
42
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
43
|
+
import_components.SearchControl,
|
|
44
|
+
{
|
|
45
|
+
onChange: setSearchValue,
|
|
46
|
+
value: searchValue,
|
|
47
|
+
label: (0, import_i18n.__)("Search"),
|
|
48
|
+
placeholder: (0, import_i18n.__)("Search")
|
|
49
|
+
}
|
|
50
|
+
),
|
|
51
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ui.Tabs.List, { children: patternCategories.map(({ name, label }) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ui.Tabs.Tab, { value: name, children: label }, name)) })
|
|
52
|
+
]
|
|
53
|
+
}
|
|
54
|
+
);
|
|
89
55
|
}
|
|
90
56
|
var pattern_explorer_sidebar_default = PatternExplorerSidebar;
|
|
91
57
|
//# sourceMappingURL=pattern-explorer-sidebar.cjs.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/components/inserter/block-patterns-explorer/pattern-explorer-sidebar.js"],
|
|
4
|
-
"sourcesContent": ["import {
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,
|
|
4
|
+
"sourcesContent": ["import { SearchControl } from '@wordpress/components';\nimport { Stack, Tabs } from '@wordpress/ui';\nimport { __ } from '@wordpress/i18n';\n\nfunction PatternExplorerSidebar( {\n\tpatternCategories,\n\tsearchValue,\n\tsetSearchValue,\n} ) {\n\treturn (\n\t\t<Stack\n\t\t\tdirection=\"column\"\n\t\t\tgap=\"lg\"\n\t\t\tclassName=\"block-editor-block-patterns-explorer__sidebar\"\n\t\t>\n\t\t\t<SearchControl\n\t\t\t\tonChange={ setSearchValue }\n\t\t\t\tvalue={ searchValue }\n\t\t\t\tlabel={ __( 'Search' ) }\n\t\t\t\tplaceholder={ __( 'Search' ) }\n\t\t\t/>\n\t\t\t<Tabs.List>\n\t\t\t\t{ patternCategories.map( ( { name, label } ) => (\n\t\t\t\t\t<Tabs.Tab key={ name } value={ name }>\n\t\t\t\t\t\t{ label }\n\t\t\t\t\t</Tabs.Tab>\n\t\t\t\t) ) }\n\t\t\t</Tabs.List>\n\t\t</Stack>\n\t);\n}\n\nexport default PatternExplorerSidebar;\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,wBAA8B;AAC9B,gBAA4B;AAC5B,kBAAmB;AAQjB;AANF,SAAS,uBAAwB;AAAA,EAChC;AAAA,EACA;AAAA,EACA;AACD,GAAI;AACH,SACC;AAAA,IAAC;AAAA;AAAA,MACA,WAAU;AAAA,MACV,KAAI;AAAA,MACJ,WAAU;AAAA,MAEV;AAAA;AAAA,UAAC;AAAA;AAAA,YACA,UAAW;AAAA,YACX,OAAQ;AAAA,YACR,WAAQ,gBAAI,QAAS;AAAA,YACrB,iBAAc,gBAAI,QAAS;AAAA;AAAA,QAC5B;AAAA,QACA,4CAAC,eAAK,MAAL,EACE,4BAAkB,IAAK,CAAE,EAAE,MAAM,MAAM,MACxC,4CAAC,eAAK,KAAL,EAAsB,OAAQ,MAC5B,mBADa,IAEhB,CACC,GACH;AAAA;AAAA;AAAA,EACD;AAEF;AAEA,IAAO,mCAAQ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -36,39 +36,16 @@ module.exports = __toCommonJS(pattern_list_exports);
|
|
|
36
36
|
var import_element = require("@wordpress/element");
|
|
37
37
|
var import_i18n = require("@wordpress/i18n");
|
|
38
38
|
var import_compose = require("@wordpress/compose");
|
|
39
|
-
var
|
|
39
|
+
var import_ui = require("@wordpress/ui");
|
|
40
40
|
var import_a11y = require("@wordpress/a11y");
|
|
41
41
|
var import_block_patterns_list = __toESM(require("../../block-patterns-list/index.cjs"));
|
|
42
42
|
var import_use_insertion_point = __toESM(require("../hooks/use-insertion-point.cjs"));
|
|
43
43
|
var import_use_patterns_state = __toESM(require("../hooks/use-patterns-state.cjs"));
|
|
44
|
-
var import_inserter_listbox = __toESM(require("../../inserter-listbox/index.cjs"));
|
|
45
44
|
var import_search_items = require("../search-items.cjs");
|
|
46
45
|
var import_block_patterns_paging = __toESM(require("../../block-patterns-paging/index.cjs"));
|
|
47
46
|
var import_use_patterns_paging = __toESM(require("../hooks/use-patterns-paging.cjs"));
|
|
48
47
|
var import_utils = require("../block-patterns-tab/utils.cjs");
|
|
49
48
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
50
|
-
function PatternsListHeader({ filterValue, filteredBlockPatternsLength }) {
|
|
51
|
-
if (!filterValue) {
|
|
52
|
-
return null;
|
|
53
|
-
}
|
|
54
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
55
|
-
import_components.__experimentalHeading,
|
|
56
|
-
{
|
|
57
|
-
level: 2,
|
|
58
|
-
lineHeight: "48px",
|
|
59
|
-
className: "block-editor-block-patterns-explorer__search-results-count",
|
|
60
|
-
children: (0, import_i18n.sprintf)(
|
|
61
|
-
/* translators: %d: number of patterns. */
|
|
62
|
-
(0, import_i18n._n)(
|
|
63
|
-
"%d pattern found",
|
|
64
|
-
"%d patterns found",
|
|
65
|
-
filteredBlockPatternsLength
|
|
66
|
-
),
|
|
67
|
-
filteredBlockPatternsLength
|
|
68
|
-
)
|
|
69
|
-
}
|
|
70
|
-
);
|
|
71
|
-
}
|
|
72
49
|
function PatternList({
|
|
73
50
|
searchValue,
|
|
74
51
|
selectedCategory,
|
|
@@ -145,34 +122,32 @@ function PatternList({
|
|
|
145
122
|
pagingProps.changePage(1);
|
|
146
123
|
}
|
|
147
124
|
const hasItems = !!filteredBlockPatterns?.length;
|
|
148
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.
|
|
125
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
149
126
|
"div",
|
|
150
127
|
{
|
|
151
128
|
className: "block-editor-block-patterns-explorer__list",
|
|
152
129
|
ref: container,
|
|
153
|
-
children: [
|
|
130
|
+
children: hasItems ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
|
154
131
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
155
|
-
|
|
132
|
+
import_block_patterns_list.default,
|
|
156
133
|
{
|
|
157
|
-
|
|
158
|
-
|
|
134
|
+
blockPatterns: pagingProps.categoryPatterns,
|
|
135
|
+
onClickPattern: (pattern, blocks) => {
|
|
136
|
+
onClickPattern(pattern, blocks);
|
|
137
|
+
onModalClose();
|
|
138
|
+
},
|
|
139
|
+
isDraggable: false
|
|
159
140
|
}
|
|
160
141
|
),
|
|
161
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
isDraggable: false
|
|
171
|
-
}
|
|
172
|
-
),
|
|
173
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_block_patterns_paging.default, { ...pagingProps })
|
|
174
|
-
] }) })
|
|
175
|
-
]
|
|
142
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_block_patterns_paging.default, { ...pagingProps })
|
|
143
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
144
|
+
import_ui.Text,
|
|
145
|
+
{
|
|
146
|
+
render: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", {}),
|
|
147
|
+
className: "block-editor-block-patterns-explorer__no-results",
|
|
148
|
+
children: (0, import_i18n.__)("No results found.")
|
|
149
|
+
}
|
|
150
|
+
)
|
|
176
151
|
}
|
|
177
152
|
);
|
|
178
153
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/components/inserter/block-patterns-explorer/pattern-list.js"],
|
|
4
|
-
"sourcesContent": ["import { useMemo, useEffect, useRef, useState } from '@wordpress/element';\nimport { _n, sprintf } from '@wordpress/i18n';\nimport { useDebounce } from '@wordpress/compose';\nimport {
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,qBAAqD;AACrD,
|
|
6
|
-
"names": ["
|
|
4
|
+
"sourcesContent": ["import { useMemo, useEffect, useRef, useState } from '@wordpress/element';\nimport { __, _n, sprintf } from '@wordpress/i18n';\nimport { useDebounce } from '@wordpress/compose';\nimport { Text } from '@wordpress/ui';\nimport { speak } from '@wordpress/a11y';\nimport BlockPatternsList from '../../block-patterns-list';\nimport useInsertionPoint from '../hooks/use-insertion-point';\nimport usePatternsState from '../hooks/use-patterns-state';\nimport { searchItems } from '../search-items';\nimport BlockPatternsPaging from '../../block-patterns-paging';\nimport usePatternsPaging from '../hooks/use-patterns-paging';\nimport {\n\tINSERTER_PATTERN_TYPES,\n\tallPatternsCategory,\n\tmyPatternsCategory,\n\tstarterPatternsCategory,\n} from '../block-patterns-tab/utils';\n\nfunction PatternList( {\n\tsearchValue,\n\tselectedCategory,\n\tpatternCategories,\n\trootClientId,\n\tonModalClose,\n} ) {\n\tconst container = useRef();\n\tconst debouncedSpeak = useDebounce( speak, 500 );\n\tconst [ destinationRootClientId, onInsertBlocks ] = useInsertionPoint( {\n\t\trootClientId,\n\t\tshouldFocusBlock: true,\n\t} );\n\tconst [ patterns, , onClickPattern ] = usePatternsState(\n\t\tonInsertBlocks,\n\t\tdestinationRootClientId,\n\t\tselectedCategory\n\t);\n\n\tconst registeredPatternCategories = useMemo(\n\t\t() =>\n\t\t\tpatternCategories.map(\n\t\t\t\t( patternCategory ) => patternCategory.name\n\t\t\t),\n\t\t[ patternCategories ]\n\t);\n\n\tconst filteredBlockPatterns = useMemo( () => {\n\t\tconst filteredPatterns = patterns.filter( ( pattern ) => {\n\t\t\tif ( selectedCategory === allPatternsCategory.name ) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t\tif (\n\t\t\t\tselectedCategory === myPatternsCategory.name &&\n\t\t\t\tpattern.type === INSERTER_PATTERN_TYPES.user\n\t\t\t) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t\tif (\n\t\t\t\tselectedCategory === starterPatternsCategory.name &&\n\t\t\t\tpattern.blockTypes?.includes( 'core/post-content' )\n\t\t\t) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t\tif ( selectedCategory === 'uncategorized' ) {\n\t\t\t\tconst hasKnownCategory =\n\t\t\t\t\tpattern.categories?.some( ( category ) =>\n\t\t\t\t\t\tregisteredPatternCategories.includes( category )\n\t\t\t\t\t) ?? false;\n\n\t\t\t\treturn ! pattern.categories?.length || ! hasKnownCategory;\n\t\t\t}\n\n\t\t\treturn pattern.categories?.includes( selectedCategory );\n\t\t} );\n\n\t\tif ( ! searchValue ) {\n\t\t\treturn filteredPatterns;\n\t\t}\n\n\t\treturn searchItems( filteredPatterns, searchValue );\n\t}, [\n\t\tsearchValue,\n\t\tpatterns,\n\t\tselectedCategory,\n\t\tregisteredPatternCategories,\n\t] );\n\n\t// Announce search results on change.\n\tuseEffect( () => {\n\t\tif ( ! searchValue ) {\n\t\t\treturn;\n\t\t}\n\t\tconst count = filteredBlockPatterns.length;\n\t\tconst resultsFoundMessage = sprintf(\n\t\t\t/* translators: %d: number of results. */\n\t\t\t_n( '%d result found.', '%d results found.', count ),\n\t\t\tcount\n\t\t);\n\t\tdebouncedSpeak( resultsFoundMessage );\n\t}, [ searchValue, debouncedSpeak, filteredBlockPatterns.length ] );\n\n\tconst pagingProps = usePatternsPaging(\n\t\tfilteredBlockPatterns,\n\t\tselectedCategory,\n\t\tcontainer\n\t);\n\n\t// Reset page when search value changes.\n\tconst [ previousSearchValue, setPreviousSearchValue ] =\n\t\tuseState( searchValue );\n\tif ( searchValue !== previousSearchValue ) {\n\t\tsetPreviousSearchValue( searchValue );\n\t\tpagingProps.changePage( 1 );\n\t}\n\n\tconst hasItems = !! filteredBlockPatterns?.length;\n\treturn (\n\t\t<div\n\t\t\tclassName=\"block-editor-block-patterns-explorer__list\"\n\t\t\tref={ container }\n\t\t>\n\t\t\t{ hasItems ? (\n\t\t\t\t<>\n\t\t\t\t\t<BlockPatternsList\n\t\t\t\t\t\tblockPatterns={ pagingProps.categoryPatterns }\n\t\t\t\t\t\tonClickPattern={ ( pattern, blocks ) => {\n\t\t\t\t\t\t\tonClickPattern( pattern, blocks );\n\t\t\t\t\t\t\tonModalClose();\n\t\t\t\t\t\t} }\n\t\t\t\t\t\tisDraggable={ false }\n\t\t\t\t\t/>\n\t\t\t\t\t<BlockPatternsPaging { ...pagingProps } />\n\t\t\t\t</>\n\t\t\t) : (\n\t\t\t\t<Text\n\t\t\t\t\trender={ <p /> }\n\t\t\t\t\tclassName=\"block-editor-block-patterns-explorer__no-results\"\n\t\t\t\t>\n\t\t\t\t\t{ __( 'No results found.' ) }\n\t\t\t\t</Text>\n\t\t\t) }\n\t\t</div>\n\t);\n}\n\nexport default PatternList;\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,qBAAqD;AACrD,kBAAgC;AAChC,qBAA4B;AAC5B,gBAAqB;AACrB,kBAAsB;AACtB,iCAA8B;AAC9B,iCAA8B;AAC9B,gCAA6B;AAC7B,0BAA4B;AAC5B,mCAAgC;AAChC,iCAA8B;AAC9B,mBAKO;AAyGH;AAvGJ,SAAS,YAAa;AAAA,EACrB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACD,GAAI;AACH,QAAM,gBAAY,uBAAO;AACzB,QAAM,qBAAiB,4BAAa,mBAAO,GAAI;AAC/C,QAAM,CAAE,yBAAyB,cAAe,QAAI,2BAAAA,SAAmB;AAAA,IACtE;AAAA,IACA,kBAAkB;AAAA,EACnB,CAAE;AACF,QAAM,CAAE,UAAU,EAAE,cAAe,QAAI,0BAAAC;AAAA,IACtC;AAAA,IACA;AAAA,IACA;AAAA,EACD;AAEA,QAAM,kCAA8B;AAAA,IACnC,MACC,kBAAkB;AAAA,MACjB,CAAE,oBAAqB,gBAAgB;AAAA,IACxC;AAAA,IACD,CAAE,iBAAkB;AAAA,EACrB;AAEA,QAAM,4BAAwB,wBAAS,MAAM;AAC5C,UAAM,mBAAmB,SAAS,OAAQ,CAAE,YAAa;AACxD,UAAK,qBAAqB,iCAAoB,M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UAAA;AAAA,YACA,eAAgB,YAAY;AAAA,YAC5B,gBAAiB,CAAE,SAAS,WAAY;AACvC,6BAAgB,SAAS,MAAO;AAChC,2BAAa;AAAA,YACd;AAAA,YACA,aAAc;AAAA;AAAA,QACf;AAAA,QACA,4CAAC,6BAAAC,SAAA,EAAsB,GAAG,aAAc;AAAA,SACzC,IAEA;AAAA,QAAC;AAAA;AAAA,UACA,QAAS,4CAAC,OAAE;AAAA,UACZ,WAAU;AAAA,UAER,8BAAI,mBAAoB;AAAA;AAAA,MAC3B;AAAA;AAAA,EAEF;AAEF;AAEA,IAAO,uBAAQ;",
|
|
6
|
+
"names": ["useInsertionPoint", "usePatternsState", "usePatternsPaging", "BlockPatternsList", "BlockPatternsPaging"]
|
|
7
7
|
}
|
|
@@ -63,7 +63,7 @@ function useInsertionPoint({
|
|
|
63
63
|
const {
|
|
64
64
|
getSelectedBlock,
|
|
65
65
|
getClosestAllowedInsertionPoint,
|
|
66
|
-
|
|
66
|
+
getBlockInsertionPoint
|
|
67
67
|
} = (0, import_lock_unlock.unlock)((0, import_data.useSelect)(import_store.store));
|
|
68
68
|
const { destinationRootClientId, destinationIndex } = (0, import_data.useSelect)(
|
|
69
69
|
(select) => {
|
|
@@ -165,7 +165,7 @@ function useInsertionPoint({
|
|
|
165
165
|
);
|
|
166
166
|
const onToggleInsertionPoint = (0, import_element.useCallback)(
|
|
167
167
|
(item) => {
|
|
168
|
-
if (item
|
|
168
|
+
if (item) {
|
|
169
169
|
const allowedDestinationRootClientId = getClosestAllowedInsertionPoint(
|
|
170
170
|
item.name,
|
|
171
171
|
destinationRootClientId
|
|
@@ -181,13 +181,13 @@ function useInsertionPoint({
|
|
|
181
181
|
})
|
|
182
182
|
);
|
|
183
183
|
}
|
|
184
|
-
} else {
|
|
184
|
+
} else if (!getBlockInsertionPoint()?.__unstableWithInserter) {
|
|
185
185
|
hideInsertionPoint();
|
|
186
186
|
}
|
|
187
187
|
},
|
|
188
188
|
[
|
|
189
189
|
getClosestAllowedInsertionPoint,
|
|
190
|
-
|
|
190
|
+
getBlockInsertionPoint,
|
|
191
191
|
showInsertionPoint,
|
|
192
192
|
hideInsertionPoint,
|
|
193
193
|
destinationRootClientId,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/components/inserter/hooks/use-insertion-point.js"],
|
|
4
|
-
"sourcesContent": ["import { useDispatch, useRegistry, useSelect } from '@wordpress/data';\nimport { isUnmodifiedDefaultBlock } from '@wordpress/blocks';\nimport { _n, sprintf } from '@wordpress/i18n';\nimport { speak } from '@wordpress/a11y';\nimport { useCallback } from '@wordpress/element';\nimport { store as blockEditorStore } from '../../../store';\nimport { unlock } from '../../../lock-unlock';\n\nfunction getIndex( {\n\tdestinationRootClientId,\n\tdestinationIndex,\n\trootClientId,\n\tregistry,\n} ) {\n\tif ( rootClientId === destinationRootClientId ) {\n\t\treturn destinationIndex;\n\t}\n\tconst parents = [\n\t\t'',\n\t\t...registry\n\t\t\t.select( blockEditorStore )\n\t\t\t.getBlockParents( destinationRootClientId ),\n\t\tdestinationRootClientId,\n\t];\n\tconst parentIndex = parents.indexOf( rootClientId );\n\tif ( parentIndex !== -1 ) {\n\t\treturn (\n\t\t\tregistry\n\t\t\t\t.select( blockEditorStore )\n\t\t\t\t.getBlockIndex( parents[ parentIndex + 1 ] ) + 1\n\t\t);\n\t}\n\treturn registry.select( blockEditorStore ).getBlockOrder( rootClientId )\n\t\t.length;\n}\n\n/**\n * @typedef WPInserterConfig\n *\n * @property {string=} rootClientId If set, insertion will be into the\n * block with this ID.\n * @property {number=} insertionIndex If set, insertion will be into this\n * explicit position.\n * @property {string=} clientId If set, insertion will be after the\n * block with this ID.\n * @property {boolean=} isAppender Whether the inserter is an appender\n * or not.\n * @property {Function=} onSelect Called after insertion.\n */\n\n/**\n * Returns the insertion point state given the inserter config.\n *\n * @param {WPInserterConfig} config Inserter Config.\n * @return {Array} Insertion Point State (rootClientID, onInsertBlocks and onToggle).\n */\nfunction useInsertionPoint( {\n\trootClientId = '',\n\tinsertionIndex,\n\tclientId,\n\tisAppender,\n\tonSelect,\n\tshouldFocusBlock = true,\n\tselectBlockOnInsert = true,\n} ) {\n\tconst registry = useRegistry();\n\tconst {\n\t\tgetSelectedBlock,\n\t\tgetClosestAllowedInsertionPoint,\n\t\
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAoD;AACpD,oBAAyC;AACzC,kBAA4B;AAC5B,kBAAsB;AACtB,qBAA4B;AAC5B,mBAA0C;AAC1C,yBAAuB;AAEvB,SAAS,SAAU;AAAA,EAClB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACD,GAAI;AACH,MAAK,iBAAiB,yBAA0B;AAC/C,WAAO;AAAA,EACR;AACA,QAAM,UAAU;AAAA,IACf;AAAA,IACA,GAAG,SACD,OAAQ,aAAAA,KAAiB,EACzB,gBAAiB,uBAAwB;AAAA,IAC3C;AAAA,EACD;AACA,QAAM,cAAc,QAAQ,QAAS,YAAa;AAClD,MAAK,gBAAgB,IAAK;AACzB,WACC,SACE,OAAQ,aAAAA,KAAiB,EACzB,cAAe,QAAS,cAAc,CAAE,CAAE,IAAI;AAAA,EAElD;AACA,SAAO,SAAS,OAAQ,aAAAA,KAAiB,EAAE,cAAe,YAAa,EACrE;AACH;AAsBA,SAAS,kBAAmB;AAAA,EAC3B,eAAe;AAAA,EACf;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,mBAAmB;AAAA,EACnB,sBAAsB;AACvB,GAAI;AACH,QAAM,eAAW,yBAAY;AAC7B,QAAM;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,EACD,QAAI,+BAAQ,uBAAW,aAAAA,KAAiB,CAAE;AAC1C,QAAM,EAAE,yBAAyB,iBAAiB,QAAI;AAAA,IACrD,CAAE,WAAY;AACb,YAAM;AAAA,QACL;AAAA,QACA;A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AAA,YACA,cAAc;AAAA,YACd;AAAA,UACA,CAAE;AAAA,UACL,cAAc,kBAAkB,SAC7B,0BACA;AAAA,UACH;AAAA,UACA,oBAAoB,wBAAwB,IAAI;AAAA,UAChD;AAAA,QACD;AAAA,MACD;AACA,YAAM,cAAc,MAAM,QAAS,MAAO,IAAI,OAAO,SAAS;AAC9D,YAAM,cAAU;AAAA;AAAA,YAEf,gBAAI,mBAAmB,oBAAoB,WAAY;AAAA,QACvD;AAAA,MACD;AACA,6BAAO,OAAQ;AAEf,UAAK,UAAW;AACf,iBAAU,MAAO;AAAA,MAClB;AAAA,IACD;AAAA,IACA;AAAA,MACC;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACD;AAAA,EACD;AAEA,QAAM,6BAAyB;AAAA,IAC9B,CAAE,SAAU;AACX,UAAK,
|
|
4
|
+
"sourcesContent": ["import { useDispatch, useRegistry, useSelect } from '@wordpress/data';\nimport { isUnmodifiedDefaultBlock } from '@wordpress/blocks';\nimport { _n, sprintf } from '@wordpress/i18n';\nimport { speak } from '@wordpress/a11y';\nimport { useCallback } from '@wordpress/element';\nimport { store as blockEditorStore } from '../../../store';\nimport { unlock } from '../../../lock-unlock';\n\nfunction getIndex( {\n\tdestinationRootClientId,\n\tdestinationIndex,\n\trootClientId,\n\tregistry,\n} ) {\n\tif ( rootClientId === destinationRootClientId ) {\n\t\treturn destinationIndex;\n\t}\n\tconst parents = [\n\t\t'',\n\t\t...registry\n\t\t\t.select( blockEditorStore )\n\t\t\t.getBlockParents( destinationRootClientId ),\n\t\tdestinationRootClientId,\n\t];\n\tconst parentIndex = parents.indexOf( rootClientId );\n\tif ( parentIndex !== -1 ) {\n\t\treturn (\n\t\t\tregistry\n\t\t\t\t.select( blockEditorStore )\n\t\t\t\t.getBlockIndex( parents[ parentIndex + 1 ] ) + 1\n\t\t);\n\t}\n\treturn registry.select( blockEditorStore ).getBlockOrder( rootClientId )\n\t\t.length;\n}\n\n/**\n * @typedef WPInserterConfig\n *\n * @property {string=} rootClientId If set, insertion will be into the\n * block with this ID.\n * @property {number=} insertionIndex If set, insertion will be into this\n * explicit position.\n * @property {string=} clientId If set, insertion will be after the\n * block with this ID.\n * @property {boolean=} isAppender Whether the inserter is an appender\n * or not.\n * @property {Function=} onSelect Called after insertion.\n */\n\n/**\n * Returns the insertion point state given the inserter config.\n *\n * @param {WPInserterConfig} config Inserter Config.\n * @return {Array} Insertion Point State (rootClientID, onInsertBlocks and onToggle).\n */\nfunction useInsertionPoint( {\n\trootClientId = '',\n\tinsertionIndex,\n\tclientId,\n\tisAppender,\n\tonSelect,\n\tshouldFocusBlock = true,\n\tselectBlockOnInsert = true,\n} ) {\n\tconst registry = useRegistry();\n\tconst {\n\t\tgetSelectedBlock,\n\t\tgetClosestAllowedInsertionPoint,\n\t\tgetBlockInsertionPoint,\n\t} = unlock( useSelect( blockEditorStore ) );\n\tconst { destinationRootClientId, destinationIndex } = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tgetSelectedBlockClientId,\n\t\t\t\tgetBlockRootClientId,\n\t\t\t\tgetBlockIndex,\n\t\t\t\tgetBlockOrder,\n\t\t\t\tgetInsertionPoint,\n\t\t\t} = unlock( select( blockEditorStore ) );\n\t\t\tconst selectedBlockClientId = getSelectedBlockClientId();\n\t\t\tlet _destinationRootClientId = rootClientId;\n\t\t\tlet _destinationIndex;\n\t\t\tconst insertionPoint = getInsertionPoint();\n\n\t\t\tif ( insertionIndex !== undefined ) {\n\t\t\t\t// Insert into a specific index.\n\t\t\t\t_destinationIndex = insertionIndex;\n\t\t\t} else if (\n\t\t\t\tinsertionPoint &&\n\t\t\t\tinsertionPoint.hasOwnProperty( 'index' )\n\t\t\t) {\n\t\t\t\t_destinationRootClientId = insertionPoint?.rootClientId\n\t\t\t\t\t? insertionPoint.rootClientId\n\t\t\t\t\t: rootClientId;\n\t\t\t\t_destinationIndex = insertionPoint.index;\n\t\t\t} else if ( clientId ) {\n\t\t\t\t// Insert after a specific client ID.\n\t\t\t\t_destinationIndex = getBlockIndex( clientId );\n\t\t\t} else if ( ! isAppender && selectedBlockClientId ) {\n\t\t\t\t_destinationRootClientId = getBlockRootClientId(\n\t\t\t\t\tselectedBlockClientId\n\t\t\t\t);\n\t\t\t\t_destinationIndex = getBlockIndex( selectedBlockClientId ) + 1;\n\t\t\t} else {\n\t\t\t\t// Insert at the end of the list.\n\t\t\t\t_destinationIndex = getBlockOrder(\n\t\t\t\t\t_destinationRootClientId\n\t\t\t\t).length;\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\tdestinationRootClientId: _destinationRootClientId,\n\t\t\t\tdestinationIndex: _destinationIndex,\n\t\t\t};\n\t\t},\n\t\t[ rootClientId, insertionIndex, clientId, isAppender ]\n\t);\n\n\tconst {\n\t\treplaceBlocks,\n\t\tinsertBlocks,\n\t\tshowInsertionPoint,\n\t\thideInsertionPoint,\n\t\tsetLastFocus,\n\t} = unlock( useDispatch( blockEditorStore ) );\n\n\tconst onInsertBlocks = useCallback(\n\t\t( blocks, meta, shouldForceFocusBlock = false, _rootClientId ) => {\n\t\t\t// When we are trying to move focus or select a new block on insert, we also\n\t\t\t// need to clear the last focus to avoid the focus being set to the wrong block\n\t\t\t// when tabbing back into the canvas if the block was added from outside the\n\t\t\t// editor canvas.\n\t\t\tif (\n\t\t\t\tshouldForceFocusBlock ||\n\t\t\t\tshouldFocusBlock ||\n\t\t\t\tselectBlockOnInsert\n\t\t\t) {\n\t\t\t\tsetLastFocus( null );\n\t\t\t}\n\n\t\t\tconst selectedBlock = getSelectedBlock();\n\n\t\t\tif (\n\t\t\t\t! isAppender &&\n\t\t\t\tselectedBlock &&\n\t\t\t\tisUnmodifiedDefaultBlock( selectedBlock, 'content' )\n\t\t\t) {\n\t\t\t\treplaceBlocks(\n\t\t\t\t\tselectedBlock.clientId,\n\t\t\t\t\tblocks,\n\t\t\t\t\tnull,\n\t\t\t\t\tshouldFocusBlock || shouldForceFocusBlock ? 0 : null,\n\t\t\t\t\tmeta\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\tinsertBlocks(\n\t\t\t\t\tblocks,\n\t\t\t\t\tisAppender || _rootClientId === undefined\n\t\t\t\t\t\t? destinationIndex\n\t\t\t\t\t\t: getIndex( {\n\t\t\t\t\t\t\t\tdestinationRootClientId,\n\t\t\t\t\t\t\t\tdestinationIndex,\n\t\t\t\t\t\t\t\trootClientId: _rootClientId,\n\t\t\t\t\t\t\t\tregistry,\n\t\t\t\t\t\t } ),\n\t\t\t\t\tisAppender || _rootClientId === undefined\n\t\t\t\t\t\t? destinationRootClientId\n\t\t\t\t\t\t: _rootClientId,\n\t\t\t\t\tselectBlockOnInsert,\n\t\t\t\t\tshouldFocusBlock || shouldForceFocusBlock ? 0 : null,\n\t\t\t\t\tmeta\n\t\t\t\t);\n\t\t\t}\n\t\t\tconst blockLength = Array.isArray( blocks ) ? blocks.length : 1;\n\t\t\tconst message = sprintf(\n\t\t\t\t// translators: %d: the name of the block that has been added\n\t\t\t\t_n( '%d block added.', '%d blocks added.', blockLength ),\n\t\t\t\tblockLength\n\t\t\t);\n\t\t\tspeak( message );\n\n\t\t\tif ( onSelect ) {\n\t\t\t\tonSelect( blocks );\n\t\t\t}\n\t\t},\n\t\t[\n\t\t\tisAppender,\n\t\t\tgetSelectedBlock,\n\t\t\treplaceBlocks,\n\t\t\tinsertBlocks,\n\t\t\tdestinationRootClientId,\n\t\t\tdestinationIndex,\n\t\t\tonSelect,\n\t\t\tshouldFocusBlock,\n\t\t\tselectBlockOnInsert,\n\t\t\tsetLastFocus,\n\t\t\tregistry,\n\t\t]\n\t);\n\n\tconst onToggleInsertionPoint = useCallback(\n\t\t( item ) => {\n\t\t\tif ( item ) {\n\t\t\t\tconst allowedDestinationRootClientId =\n\t\t\t\t\tgetClosestAllowedInsertionPoint(\n\t\t\t\t\t\titem.name,\n\t\t\t\t\t\tdestinationRootClientId\n\t\t\t\t\t);\n\t\t\t\tif ( allowedDestinationRootClientId !== null ) {\n\t\t\t\t\tshowInsertionPoint(\n\t\t\t\t\t\tallowedDestinationRootClientId,\n\t\t\t\t\t\tgetIndex( {\n\t\t\t\t\t\t\tdestinationRootClientId,\n\t\t\t\t\t\t\tdestinationIndex,\n\t\t\t\t\t\t\trootClientId: allowedDestinationRootClientId,\n\t\t\t\t\t\t\tregistry,\n\t\t\t\t\t\t} )\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t} else if ( ! getBlockInsertionPoint()?.__unstableWithInserter ) {\n\t\t\t\t// The insertion cue is shared state. The in-between inserter\n\t\t\t\t// marks its own cue with `__unstableWithInserter` and mounts an\n\t\t\t\t// inserter inside that cue's popover, so hiding that cue here\n\t\t\t\t// would unmount a UI this inserter does not own.\n\t\t\t\t// See https://github.com/WordPress/gutenberg/issues/72297.\n\t\t\t\thideInsertionPoint();\n\t\t\t}\n\t\t},\n\t\t[\n\t\t\tgetClosestAllowedInsertionPoint,\n\t\t\tgetBlockInsertionPoint,\n\t\t\tshowInsertionPoint,\n\t\t\thideInsertionPoint,\n\t\t\tdestinationRootClientId,\n\t\t\tdestinationIndex,\n\t\t\tregistry,\n\t\t]\n\t);\n\n\treturn [ destinationRootClientId, onInsertBlocks, onToggleInsertionPoint ];\n}\n\nexport default useInsertionPoint;\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAoD;AACpD,oBAAyC;AACzC,kBAA4B;AAC5B,kBAAsB;AACtB,qBAA4B;AAC5B,mBAA0C;AAC1C,yBAAuB;AAEvB,SAAS,SAAU;AAAA,EAClB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACD,GAAI;AACH,MAAK,iBAAiB,yBAA0B;AAC/C,WAAO;AAAA,EACR;AACA,QAAM,UAAU;AAAA,IACf;AAAA,IACA,GAAG,SACD,OAAQ,aAAAA,KAAiB,EACzB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L;AAAA,UACC,KAAK;AAAA,UACL;AAAA,QACD;AACD,YAAK,mCAAmC,MAAO;AAC9C;AAAA,YACC;AAAA,YACA,SAAU;AAAA,cACT;AAAA,cACA;AAAA,cACA,cAAc;AAAA,cACd;AAAA,YACD,CAAE;AAAA,UACH;AAAA,QACD;AAAA,MACD,WAAY,CAAE,uBAAuB,GAAG,wBAAyB;AAMhE,2BAAmB;AAAA,MACpB;AAAA,IACD;AAAA,IACA;AAAA,MACC;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACD;AAAA,EACD;AAEA,SAAO,CAAE,yBAAyB,gBAAgB,sBAAuB;AAC1E;AAEA,IAAO,8BAAQ;",
|
|
6
6
|
"names": ["blockEditorStore"]
|
|
7
7
|
}
|
|
@@ -109,9 +109,11 @@ function InserterMenu({
|
|
|
109
109
|
insertionIndex: __experimentalInsertionIndex,
|
|
110
110
|
shouldFocusBlock
|
|
111
111
|
});
|
|
112
|
+
const { hideInsertionPoint } = (0, import_data.useDispatch)(import_store.store);
|
|
112
113
|
const blockTypesTabRef = (0, import_element.useRef)();
|
|
113
114
|
const onInsert = (0, import_element.useCallback)(
|
|
114
115
|
(blocks, meta, shouldForceFocusBlock, _rootClientId) => {
|
|
116
|
+
hideInsertionPoint();
|
|
115
117
|
onInsertBlocks(
|
|
116
118
|
blocks,
|
|
117
119
|
meta,
|
|
@@ -128,16 +130,23 @@ function InserterMenu({
|
|
|
128
130
|
}
|
|
129
131
|
});
|
|
130
132
|
},
|
|
131
|
-
[
|
|
133
|
+
[
|
|
134
|
+
hideInsertionPoint,
|
|
135
|
+
onInsertBlocks,
|
|
136
|
+
maybeCloseInserter,
|
|
137
|
+
onSelect,
|
|
138
|
+
ref,
|
|
139
|
+
shouldFocusBlock
|
|
140
|
+
]
|
|
132
141
|
);
|
|
133
142
|
const onInsertPattern = (0, import_element.useCallback)(
|
|
134
143
|
(blocks, patternName, ...args) => {
|
|
135
|
-
|
|
144
|
+
hideInsertionPoint();
|
|
136
145
|
onInsertBlocks(blocks, { patternName }, ...args);
|
|
137
146
|
onSelect();
|
|
138
147
|
maybeCloseInserter();
|
|
139
148
|
},
|
|
140
|
-
[onInsertBlocks, maybeCloseInserter, onSelect
|
|
149
|
+
[hideInsertionPoint, onInsertBlocks, maybeCloseInserter, onSelect]
|
|
141
150
|
);
|
|
142
151
|
const onHover = (0, import_element.useCallback)(
|
|
143
152
|
(item) => {
|
|
@@ -317,11 +326,13 @@ function InserterMenu({
|
|
|
317
326
|
};
|
|
318
327
|
const tabsRef = (0, import_element.useRef)();
|
|
319
328
|
(0, import_element.useLayoutEffect)(() => {
|
|
320
|
-
if (tabsRef.current) {
|
|
321
|
-
|
|
322
|
-
tabsRef.current.querySelector('[role="tab"][aria-selected="true"]')?.focus();
|
|
323
|
-
});
|
|
329
|
+
if (!tabsRef.current) {
|
|
330
|
+
return;
|
|
324
331
|
}
|
|
332
|
+
const frame = window.requestAnimationFrame(() => {
|
|
333
|
+
tabsRef.current?.querySelector('[role="tab"][aria-selected="true"]')?.focus();
|
|
334
|
+
});
|
|
335
|
+
return () => window.cancelAnimationFrame(frame);
|
|
325
336
|
}, []);
|
|
326
337
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
327
338
|
"div",
|