@wordpress/block-editor 15.21.0 → 15.22.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 +23 -1
- package/README.md +2 -2
- package/build/components/block-card/index.cjs +4 -5
- package/build/components/block-card/index.cjs.map +2 -2
- package/build/components/block-compare/index.cjs +2 -2
- package/build/components/block-compare/index.cjs.map +2 -2
- package/build/components/block-editing-mode/index.cjs +13 -7
- package/build/components/block-editing-mode/index.cjs.map +2 -2
- package/build/components/block-inspector/index.cjs +35 -20
- package/build/components/block-inspector/index.cjs.map +2 -2
- package/build/components/block-mover/mover-description.cjs +6 -6
- package/build/components/block-mover/mover-description.cjs.map +1 -1
- package/build/components/block-patterns-list/index.cjs +1 -1
- package/build/components/block-patterns-list/index.cjs.map +2 -2
- package/build/components/block-patterns-paging/index.cjs +4 -4
- package/build/components/block-patterns-paging/index.cjs.map +2 -2
- package/build/components/block-popover/use-popover-scroll.cjs.map +1 -1
- package/build/components/block-quick-navigation/index.cjs +7 -5
- package/build/components/block-quick-navigation/index.cjs.map +2 -2
- package/build/components/block-rename/modal.cjs +0 -1
- package/build/components/block-rename/modal.cjs.map +2 -2
- package/build/components/block-switcher/block-transformations-menu.cjs +16 -15
- package/build/components/block-switcher/block-transformations-menu.cjs.map +2 -2
- package/build/components/block-switcher/index.cjs +4 -4
- package/build/components/block-switcher/index.cjs.map +2 -2
- package/build/components/block-toolbar/block-toolbar-icon.cjs +14 -6
- package/build/components/block-toolbar/block-toolbar-icon.cjs.map +2 -2
- package/build/components/block-toolbar/edit-section-button.cjs.map +1 -1
- package/build/components/block-tools/use-block-toolbar-popover-props.cjs +10 -4
- package/build/components/block-tools/use-block-toolbar-popover-props.cjs.map +2 -2
- package/build/components/child-layout-control/index.cjs +51 -19
- package/build/components/child-layout-control/index.cjs.map +2 -2
- package/build/components/colors-gradients/control.cjs +25 -14
- package/build/components/colors-gradients/control.cjs.map +2 -2
- package/build/components/colors-gradients/dropdown.cjs +4 -1
- package/build/components/colors-gradients/dropdown.cjs.map +3 -3
- package/build/components/contrast-checker/index.cjs +22 -4
- package/build/components/contrast-checker/index.cjs.map +2 -2
- package/build/components/date-format-picker/index.cjs +0 -1
- package/build/components/date-format-picker/index.cjs.map +2 -2
- package/build/components/dimensions-tool/index.cjs +4 -5
- package/build/components/dimensions-tool/index.cjs.map +2 -2
- package/build/components/dimensions-tool/scale-tool.cjs +1 -1
- package/build/components/dimensions-tool/scale-tool.cjs.map +2 -2
- package/build/components/global-styles/advanced-panel.cjs +23 -15
- package/build/components/global-styles/advanced-panel.cjs.map +2 -2
- package/build/components/global-styles/background-panel.cjs +154 -26
- package/build/components/global-styles/background-panel.cjs.map +3 -3
- package/build/components/global-styles/border-panel.cjs +2 -0
- package/build/components/global-styles/border-panel.cjs.map +2 -2
- package/build/components/global-styles/color-gradient-dropdown-item.cjs +227 -0
- package/build/components/global-styles/color-gradient-dropdown-item.cjs.map +7 -0
- package/build/components/global-styles/color-panel.cjs +98 -375
- package/build/components/global-styles/color-panel.cjs.map +3 -3
- package/build/components/global-styles/dimensions-panel.cjs +2 -5
- package/build/components/global-styles/dimensions-panel.cjs.map +2 -2
- package/build/components/global-styles/hooks.cjs +34 -0
- package/build/components/global-styles/hooks.cjs.map +2 -2
- package/build/components/global-styles/shadow-panel-components.cjs.map +2 -2
- package/build/components/global-styles/typography-panel.cjs +82 -10
- package/build/components/global-styles/typography-panel.cjs.map +3 -3
- package/build/components/grid/grid-item-resizer.cjs.map +1 -1
- package/build/components/grid/grid-visualizer.cjs.map +1 -1
- package/build/components/iframe/index.cjs +6 -3
- package/build/components/iframe/index.cjs.map +3 -3
- package/build/components/image-editor/use-transform-image.cjs.map +1 -1
- package/build/components/inner-blocks/use-inner-block-template-sync.cjs +3 -1
- package/build/components/inner-blocks/use-inner-block-template-sync.cjs.map +2 -2
- package/build/components/inserter/get-appender-label.cjs.map +1 -1
- package/build/components/inserter/hooks/use-patterns-state.cjs +1 -1
- package/build/components/inserter/hooks/use-patterns-state.cjs.map +2 -2
- package/build/components/inserter/index.cjs +179 -220
- package/build/components/inserter/index.cjs.map +3 -3
- package/build/components/inserter/media-tab/media-preview.cjs.map +2 -2
- package/build/components/inserter/search-items.cjs.map +1 -1
- package/build/components/inserter/search-results.cjs +1 -1
- package/build/components/inserter/search-results.cjs.map +2 -2
- package/build/components/inspector-controls/fill.cjs +1 -3
- package/build/components/inspector-controls/fill.cjs.map +2 -2
- package/build/components/inspector-controls/groups.cjs +2 -0
- package/build/components/inspector-controls/groups.cjs.map +2 -2
- package/build/components/inspector-controls-tabs/index.cjs.map +2 -2
- package/build/components/inspector-controls-tabs/styles-tab.cjs +76 -32
- package/build/components/inspector-controls-tabs/styles-tab.cjs.map +2 -2
- package/build/components/keyboard-shortcuts/index.cjs.map +1 -1
- package/build/components/line-height-control/index.cjs.map +1 -1
- package/build/components/link-control/index.cjs +2 -3
- package/build/components/link-control/index.cjs.map +2 -2
- package/build/components/link-control/normalize-url.cjs.map +1 -1
- package/build/components/list-view/block-select-button.cjs +9 -20
- package/build/components/list-view/block-select-button.cjs.map +3 -3
- package/build/components/list-view/block.cjs +2 -1
- package/build/components/list-view/block.cjs.map +2 -2
- package/build/components/list-view/utils.cjs.map +1 -1
- package/build/components/preset-input-control/custom-value-controls.cjs.map +2 -2
- package/build/components/provider/index.cjs.map +1 -1
- package/build/components/provider/use-block-sync.cjs +14 -3
- package/build/components/provider/use-block-sync.cjs.map +2 -2
- package/build/components/rich-text/event-listeners/before-input-rules.cjs +5 -5
- package/build/components/rich-text/event-listeners/before-input-rules.cjs.map +3 -3
- package/build/components/rich-text/event-listeners/delete.cjs +4 -4
- package/build/components/rich-text/event-listeners/delete.cjs.map +3 -3
- package/build/components/rich-text/event-listeners/enter.cjs +7 -2
- package/build/components/rich-text/event-listeners/enter.cjs.map +2 -2
- package/build/components/rich-text/event-listeners/input-events.cjs +4 -4
- package/build/components/rich-text/event-listeners/input-events.cjs.map +3 -3
- package/build/components/rich-text/event-listeners/input-rules.cjs +17 -4
- package/build/components/rich-text/event-listeners/input-rules.cjs.map +3 -3
- package/build/components/rich-text/event-listeners/insert-replacement-text.cjs +4 -4
- package/build/components/rich-text/event-listeners/insert-replacement-text.cjs.map +3 -3
- package/build/components/rich-text/event-listeners/paste-handler.cjs.map +1 -1
- package/build/components/rich-text/event-listeners/remove-browser-shortcuts.cjs +4 -4
- package/build/components/rich-text/event-listeners/remove-browser-shortcuts.cjs.map +3 -3
- package/build/components/rich-text/event-listeners/shortcuts.cjs +4 -4
- package/build/components/rich-text/event-listeners/shortcuts.cjs.map +3 -3
- package/build/components/rich-text/event-listeners/undo-automatic-change.cjs +4 -4
- package/build/components/rich-text/event-listeners/undo-automatic-change.cjs.map +3 -3
- package/build/components/rich-text/index.cjs +1 -23
- package/build/components/rich-text/index.cjs.map +2 -2
- package/build/components/rich-text/prevent-event-discovery.cjs +1 -1
- package/build/components/rich-text/prevent-event-discovery.cjs.map +1 -1
- package/build/components/url-popover/image-url-input-ui.cjs +0 -2
- package/build/components/url-popover/image-url-input-ui.cjs.map +2 -2
- package/build/components/use-block-commands/index.cjs +5 -5
- package/build/components/use-block-commands/index.cjs.map +2 -2
- package/build/components/use-block-display-information/index.cjs +10 -3
- package/build/components/use-block-display-information/index.cjs.map +2 -2
- package/build/components/writing-flow/use-tab-nav.cjs.map +1 -1
- package/build/hooks/anchor.cjs +12 -17
- package/build/hooks/anchor.cjs.map +2 -2
- package/build/hooks/background.cjs +124 -75
- package/build/hooks/background.cjs.map +3 -3
- package/build/hooks/block-fields/index.cjs +13 -2
- package/build/hooks/block-fields/index.cjs.map +2 -2
- package/build/hooks/border.cjs +0 -3
- package/build/hooks/border.cjs.map +2 -2
- package/build/hooks/color.cjs +0 -165
- package/build/hooks/color.cjs.map +3 -3
- package/build/hooks/contrast-checker.cjs +31 -28
- package/build/hooks/contrast-checker.cjs.map +3 -3
- package/build/hooks/custom-class-name.cjs +0 -1
- package/build/hooks/custom-class-name.cjs.map +2 -2
- package/build/hooks/dimensions.cjs +13 -5
- package/build/hooks/dimensions.cjs.map +2 -2
- package/build/hooks/elements.cjs +142 -0
- package/build/hooks/elements.cjs.map +7 -0
- package/build/hooks/fit-text.cjs +11 -0
- package/build/hooks/fit-text.cjs.map +2 -2
- package/build/hooks/grid-visualizer.cjs +21 -11
- package/build/hooks/grid-visualizer.cjs.map +2 -2
- package/build/hooks/layout-child.cjs +65 -10
- package/build/hooks/layout-child.cjs.map +2 -2
- package/build/hooks/layout.cjs +6 -3
- package/build/hooks/layout.cjs.map +2 -2
- package/build/hooks/list-view.cjs +10 -7
- package/build/hooks/list-view.cjs.map +2 -2
- package/build/hooks/position.cjs +19 -22
- package/build/hooks/position.cjs.map +2 -2
- package/build/hooks/spacing-visualizer.cjs.map +1 -1
- package/build/hooks/state-utils.cjs.map +1 -1
- package/build/hooks/states.cjs +2 -2
- package/build/hooks/states.cjs.map +2 -2
- package/build/hooks/style.cjs +50 -6
- package/build/hooks/style.cjs.map +2 -2
- package/build/hooks/supports.cjs +0 -7
- package/build/hooks/supports.cjs.map +2 -2
- package/build/hooks/typography.cjs +62 -10
- package/build/hooks/typography.cjs.map +3 -3
- package/build/layouts/flex.cjs +99 -6
- package/build/layouts/flex.cjs.map +2 -2
- package/build/private-apis.cjs +4 -0
- package/build/private-apis.cjs.map +2 -2
- package/build/store/actions.cjs +7 -3
- package/build/store/actions.cjs.map +2 -2
- package/build/store/private-actions.cjs +1 -2
- package/build/store/private-actions.cjs.map +2 -2
- package/build/store/private-selectors.cjs +42 -2
- package/build/store/private-selectors.cjs.map +2 -2
- package/build/store/reducer.cjs +14 -6
- package/build/store/reducer.cjs.map +2 -2
- package/build/store/selectors.cjs +60 -41
- package/build/store/selectors.cjs.map +2 -2
- package/build/utils/block-bindings.cjs +9 -9
- package/build/utils/block-bindings.cjs.map +3 -3
- package/build/utils/color-values.cjs +10 -1
- package/build/utils/color-values.cjs.map +3 -3
- package/build/utils/dom.cjs +2 -5
- package/build/utils/dom.cjs.map +3 -3
- package/build/utils/fit-text-frontend.cjs +6 -2
- package/build/utils/fit-text-frontend.cjs.map +3 -3
- package/build/utils/fit-text-utils.cjs +1 -1
- package/build/utils/fit-text-utils.cjs.map +3 -3
- package/build/utils/format-font-style.cjs +1 -1
- package/build/utils/format-font-style.cjs.map +3 -3
- package/build/utils/format-font-weight.cjs +1 -1
- package/build/utils/format-font-weight.cjs.map +3 -3
- package/build/utils/get-editor-region.cjs +4 -2
- package/build/utils/get-editor-region.cjs.map +3 -3
- package/build/utils/get-font-styles-and-weights.cjs +8 -12
- package/build/utils/get-font-styles-and-weights.cjs.map +3 -3
- package/build/utils/get-px-from-css-unit.cjs +1 -1
- package/build/utils/get-px-from-css-unit.cjs.map +1 -1
- package/build/utils/index.cjs +1 -1
- package/build/utils/index.cjs.map +1 -1
- package/build/utils/math.cjs +1 -1
- package/build/utils/math.cjs.map +3 -3
- package/build/utils/object.cjs +8 -8
- package/build/utils/object.cjs.map +3 -3
- package/build/utils/order-inserter-block-items.cjs +1 -1
- package/build/utils/order-inserter-block-items.cjs.map +3 -3
- package/build/utils/pasting.cjs +4 -2
- package/build/utils/pasting.cjs.map +3 -3
- package/build/utils/selection.cjs +3 -2
- package/build/utils/selection.cjs.map +3 -3
- package/build/utils/sorting.cjs +9 -3
- package/build/utils/sorting.cjs.map +3 -3
- package/build/utils/transform-styles/index.cjs +3 -2
- package/build/utils/transform-styles/index.cjs.map +3 -3
- package/build/utils/transform-styles/postcss-urlrebase.d.cjs +2 -0
- package/build/utils/transform-styles/postcss-urlrebase.d.cjs.map +7 -0
- package/build/{components/rich-text/native/index.cjs → utils/transform-styles/types.cjs} +4 -13
- package/build/utils/transform-styles/types.cjs.map +7 -0
- package/build/utils/types.cjs +19 -0
- package/build/utils/types.cjs.map +7 -0
- package/build-module/components/block-card/index.mjs +5 -6
- package/build-module/components/block-card/index.mjs.map +2 -2
- package/build-module/components/block-compare/index.mjs +1 -1
- package/build-module/components/block-compare/index.mjs.map +2 -2
- package/build-module/components/block-editing-mode/index.mjs +14 -8
- package/build-module/components/block-editing-mode/index.mjs.map +2 -2
- package/build-module/components/block-inspector/index.mjs +35 -21
- package/build-module/components/block-inspector/index.mjs.map +2 -2
- package/build-module/components/block-mover/mover-description.mjs +6 -6
- package/build-module/components/block-mover/mover-description.mjs.map +1 -1
- package/build-module/components/block-patterns-list/index.mjs +1 -1
- package/build-module/components/block-patterns-list/index.mjs.map +2 -2
- package/build-module/components/block-patterns-paging/index.mjs +4 -4
- package/build-module/components/block-patterns-paging/index.mjs.map +2 -2
- package/build-module/components/block-popover/use-popover-scroll.mjs.map +1 -1
- package/build-module/components/block-quick-navigation/index.mjs +8 -6
- package/build-module/components/block-quick-navigation/index.mjs.map +2 -2
- package/build-module/components/block-rename/modal.mjs +0 -1
- package/build-module/components/block-rename/modal.mjs.map +2 -2
- package/build-module/components/block-switcher/block-transformations-menu.mjs +16 -15
- package/build-module/components/block-switcher/block-transformations-menu.mjs.map +2 -2
- package/build-module/components/block-switcher/index.mjs +4 -4
- package/build-module/components/block-switcher/index.mjs.map +2 -2
- package/build-module/components/block-toolbar/block-toolbar-icon.mjs +14 -6
- package/build-module/components/block-toolbar/block-toolbar-icon.mjs.map +2 -2
- package/build-module/components/block-toolbar/edit-section-button.mjs.map +1 -1
- package/build-module/components/block-tools/use-block-toolbar-popover-props.mjs +10 -4
- package/build-module/components/block-tools/use-block-toolbar-popover-props.mjs.map +2 -2
- package/build-module/components/child-layout-control/index.mjs +51 -19
- package/build-module/components/child-layout-control/index.mjs.map +2 -2
- package/build-module/components/colors-gradients/control.mjs +27 -15
- package/build-module/components/colors-gradients/control.mjs.map +2 -2
- package/build-module/components/colors-gradients/dropdown.mjs +4 -1
- package/build-module/components/colors-gradients/dropdown.mjs.map +2 -2
- package/build-module/components/contrast-checker/index.mjs +18 -4
- package/build-module/components/contrast-checker/index.mjs.map +2 -2
- package/build-module/components/date-format-picker/index.mjs +0 -1
- package/build-module/components/date-format-picker/index.mjs.map +2 -2
- package/build-module/components/dimensions-tool/index.mjs +4 -5
- package/build-module/components/dimensions-tool/index.mjs.map +2 -2
- package/build-module/components/dimensions-tool/scale-tool.mjs +1 -1
- package/build-module/components/dimensions-tool/scale-tool.mjs.map +2 -2
- package/build-module/components/global-styles/advanced-panel.mjs +23 -15
- package/build-module/components/global-styles/advanced-panel.mjs.map +2 -2
- package/build-module/components/global-styles/background-panel.mjs +157 -29
- package/build-module/components/global-styles/background-panel.mjs.map +2 -2
- package/build-module/components/global-styles/border-panel.mjs +2 -0
- package/build-module/components/global-styles/border-panel.mjs.map +2 -2
- package/build-module/components/global-styles/color-gradient-dropdown-item.mjs +207 -0
- package/build-module/components/global-styles/color-gradient-dropdown-item.mjs.map +7 -0
- package/build-module/components/global-styles/color-panel.mjs +106 -387
- package/build-module/components/global-styles/color-panel.mjs.map +3 -3
- package/build-module/components/global-styles/dimensions-panel.mjs +3 -7
- package/build-module/components/global-styles/dimensions-panel.mjs.map +2 -2
- package/build-module/components/global-styles/hooks.mjs +33 -0
- package/build-module/components/global-styles/hooks.mjs.map +2 -2
- package/build-module/components/global-styles/shadow-panel-components.mjs.map +2 -2
- package/build-module/components/global-styles/typography-panel.mjs +84 -10
- package/build-module/components/global-styles/typography-panel.mjs.map +2 -2
- package/build-module/components/grid/grid-item-resizer.mjs.map +1 -1
- package/build-module/components/grid/grid-visualizer.mjs.map +1 -1
- package/build-module/components/iframe/index.mjs +6 -3
- package/build-module/components/iframe/index.mjs.map +2 -2
- package/build-module/components/image-editor/use-transform-image.mjs.map +1 -1
- package/build-module/components/inner-blocks/use-inner-block-template-sync.mjs +3 -1
- package/build-module/components/inner-blocks/use-inner-block-template-sync.mjs.map +2 -2
- package/build-module/components/inserter/get-appender-label.mjs.map +1 -1
- package/build-module/components/inserter/hooks/use-patterns-state.mjs +1 -1
- package/build-module/components/inserter/hooks/use-patterns-state.mjs.map +2 -2
- package/build-module/components/inserter/index.mjs +185 -222
- package/build-module/components/inserter/index.mjs.map +3 -3
- package/build-module/components/inserter/media-tab/media-preview.mjs.map +2 -2
- package/build-module/components/inserter/search-items.mjs.map +1 -1
- package/build-module/components/inserter/search-results.mjs +1 -1
- package/build-module/components/inserter/search-results.mjs.map +2 -2
- package/build-module/components/inspector-controls/fill.mjs +1 -3
- package/build-module/components/inspector-controls/fill.mjs.map +2 -2
- package/build-module/components/inspector-controls/groups.mjs +2 -0
- package/build-module/components/inspector-controls/groups.mjs.map +2 -2
- package/build-module/components/inspector-controls-tabs/index.mjs.map +2 -2
- package/build-module/components/inspector-controls-tabs/styles-tab.mjs +76 -32
- package/build-module/components/inspector-controls-tabs/styles-tab.mjs.map +2 -2
- package/build-module/components/keyboard-shortcuts/index.mjs.map +1 -1
- package/build-module/components/line-height-control/index.mjs.map +1 -1
- package/build-module/components/link-control/index.mjs +2 -3
- package/build-module/components/link-control/index.mjs.map +2 -2
- package/build-module/components/link-control/normalize-url.mjs.map +1 -1
- package/build-module/components/list-view/block-select-button.mjs +10 -27
- package/build-module/components/list-view/block-select-button.mjs.map +2 -2
- package/build-module/components/list-view/block.mjs +2 -1
- package/build-module/components/list-view/block.mjs.map +2 -2
- package/build-module/components/list-view/utils.mjs.map +1 -1
- package/build-module/components/preset-input-control/custom-value-controls.mjs.map +2 -2
- package/build-module/components/provider/index.mjs.map +1 -1
- package/build-module/components/provider/use-block-sync.mjs +14 -3
- package/build-module/components/provider/use-block-sync.mjs.map +2 -2
- package/build-module/components/rich-text/event-listeners/before-input-rules.mjs +5 -5
- package/build-module/components/rich-text/event-listeners/before-input-rules.mjs.map +2 -2
- package/build-module/components/rich-text/event-listeners/delete.mjs +4 -4
- package/build-module/components/rich-text/event-listeners/delete.mjs.map +2 -2
- package/build-module/components/rich-text/event-listeners/enter.mjs +7 -2
- package/build-module/components/rich-text/event-listeners/enter.mjs.map +2 -2
- package/build-module/components/rich-text/event-listeners/input-events.mjs +4 -4
- package/build-module/components/rich-text/event-listeners/input-events.mjs.map +2 -2
- package/build-module/components/rich-text/event-listeners/input-rules.mjs +17 -4
- package/build-module/components/rich-text/event-listeners/input-rules.mjs.map +2 -2
- package/build-module/components/rich-text/event-listeners/insert-replacement-text.mjs +4 -4
- package/build-module/components/rich-text/event-listeners/insert-replacement-text.mjs.map +2 -2
- package/build-module/components/rich-text/event-listeners/paste-handler.mjs.map +1 -1
- package/build-module/components/rich-text/event-listeners/remove-browser-shortcuts.mjs +4 -4
- package/build-module/components/rich-text/event-listeners/remove-browser-shortcuts.mjs.map +2 -2
- package/build-module/components/rich-text/event-listeners/shortcuts.mjs +4 -4
- package/build-module/components/rich-text/event-listeners/shortcuts.mjs.map +2 -2
- package/build-module/components/rich-text/event-listeners/undo-automatic-change.mjs +4 -4
- package/build-module/components/rich-text/event-listeners/undo-automatic-change.mjs.map +2 -2
- package/build-module/components/rich-text/index.mjs +1 -23
- package/build-module/components/rich-text/index.mjs.map +2 -2
- package/build-module/components/rich-text/prevent-event-discovery.mjs +1 -1
- package/build-module/components/rich-text/prevent-event-discovery.mjs.map +1 -1
- package/build-module/components/url-popover/image-url-input-ui.mjs +0 -2
- package/build-module/components/url-popover/image-url-input-ui.mjs.map +2 -2
- package/build-module/components/use-block-commands/index.mjs +5 -5
- package/build-module/components/use-block-commands/index.mjs.map +2 -2
- package/build-module/components/use-block-display-information/index.mjs +10 -3
- package/build-module/components/use-block-display-information/index.mjs.map +2 -2
- package/build-module/components/writing-flow/use-tab-nav.mjs.map +1 -1
- package/build-module/hooks/anchor.mjs +12 -17
- package/build-module/hooks/anchor.mjs.map +2 -2
- package/build-module/hooks/background.mjs +123 -75
- package/build-module/hooks/background.mjs.map +2 -2
- package/build-module/hooks/block-fields/index.mjs +13 -2
- package/build-module/hooks/block-fields/index.mjs.map +2 -2
- package/build-module/hooks/border.mjs +1 -4
- package/build-module/hooks/border.mjs.map +2 -2
- package/build-module/hooks/color.mjs +2 -178
- package/build-module/hooks/color.mjs.map +2 -2
- package/build-module/hooks/contrast-checker.mjs +32 -19
- package/build-module/hooks/contrast-checker.mjs.map +2 -2
- package/build-module/hooks/custom-class-name.mjs +0 -1
- package/build-module/hooks/custom-class-name.mjs.map +2 -2
- package/build-module/hooks/dimensions.mjs +13 -6
- package/build-module/hooks/dimensions.mjs.map +2 -2
- package/build-module/hooks/elements.mjs +115 -0
- package/build-module/hooks/elements.mjs.map +7 -0
- package/build-module/hooks/fit-text.mjs +11 -0
- package/build-module/hooks/fit-text.mjs.map +2 -2
- package/build-module/hooks/grid-visualizer.mjs +21 -11
- package/build-module/hooks/grid-visualizer.mjs.map +2 -2
- package/build-module/hooks/layout-child.mjs +68 -10
- package/build-module/hooks/layout-child.mjs.map +2 -2
- package/build-module/hooks/layout.mjs +6 -3
- package/build-module/hooks/layout.mjs.map +2 -2
- package/build-module/hooks/list-view.mjs +10 -7
- package/build-module/hooks/list-view.mjs.map +2 -2
- package/build-module/hooks/position.mjs +20 -23
- package/build-module/hooks/position.mjs.map +2 -2
- package/build-module/hooks/spacing-visualizer.mjs.map +1 -1
- package/build-module/hooks/state-utils.mjs.map +1 -1
- package/build-module/hooks/states.mjs +2 -2
- package/build-module/hooks/states.mjs.map +2 -2
- package/build-module/hooks/style.mjs +53 -8
- package/build-module/hooks/style.mjs.map +2 -2
- package/build-module/hooks/supports.mjs +0 -7
- package/build-module/hooks/supports.mjs.map +2 -2
- package/build-module/hooks/typography.mjs +62 -10
- package/build-module/hooks/typography.mjs.map +2 -2
- package/build-module/layouts/flex.mjs +105 -7
- package/build-module/layouts/flex.mjs.map +2 -2
- package/build-module/private-apis.mjs +8 -0
- package/build-module/private-apis.mjs.map +2 -2
- package/build-module/store/actions.mjs +7 -3
- package/build-module/store/actions.mjs.map +2 -2
- package/build-module/store/private-actions.mjs +1 -2
- package/build-module/store/private-actions.mjs.map +2 -2
- package/build-module/store/private-selectors.mjs +39 -1
- package/build-module/store/private-selectors.mjs.map +2 -2
- package/build-module/store/reducer.mjs +14 -6
- package/build-module/store/reducer.mjs.map +2 -2
- package/build-module/store/selectors.mjs +62 -42
- package/build-module/store/selectors.mjs.map +2 -2
- package/build-module/utils/block-bindings.mjs +9 -9
- package/build-module/utils/block-bindings.mjs.map +3 -3
- package/build-module/utils/color-values.mjs +9 -1
- package/build-module/utils/color-values.mjs.map +3 -3
- package/build-module/utils/dom.mjs +2 -5
- package/build-module/utils/dom.mjs.map +3 -3
- package/build-module/utils/fit-text-frontend.mjs +6 -2
- package/build-module/utils/fit-text-frontend.mjs.map +3 -3
- package/build-module/utils/fit-text-utils.mjs +1 -1
- package/build-module/utils/fit-text-utils.mjs.map +3 -3
- package/build-module/utils/format-font-style.mjs +1 -1
- package/build-module/utils/format-font-style.mjs.map +3 -3
- package/build-module/utils/format-font-weight.mjs +1 -1
- package/build-module/utils/format-font-weight.mjs.map +3 -3
- package/build-module/utils/get-editor-region.mjs +4 -2
- package/build-module/utils/get-editor-region.mjs.map +3 -3
- package/build-module/utils/get-font-styles-and-weights.mjs +8 -12
- package/build-module/utils/get-font-styles-and-weights.mjs.map +3 -3
- package/build-module/utils/get-px-from-css-unit.mjs +1 -1
- package/build-module/utils/get-px-from-css-unit.mjs.map +1 -1
- package/build-module/utils/index.mjs +1 -1
- package/build-module/utils/index.mjs.map +1 -1
- package/build-module/utils/math.mjs +1 -1
- package/build-module/utils/math.mjs.map +3 -3
- package/build-module/utils/object.mjs +8 -8
- package/build-module/utils/object.mjs.map +3 -3
- package/build-module/utils/order-inserter-block-items.mjs +1 -1
- package/build-module/utils/order-inserter-block-items.mjs.map +3 -3
- package/build-module/utils/pasting.mjs +4 -2
- package/build-module/utils/pasting.mjs.map +3 -3
- package/build-module/utils/selection.mjs +3 -2
- package/build-module/utils/selection.mjs.map +3 -3
- package/build-module/utils/sorting.mjs +9 -3
- package/build-module/utils/sorting.mjs.map +3 -3
- package/build-module/utils/transform-styles/index.mjs +3 -2
- package/build-module/utils/transform-styles/index.mjs.map +3 -3
- package/build-module/utils/transform-styles/postcss-urlrebase.d.mjs +1 -0
- package/build-module/utils/transform-styles/postcss-urlrebase.d.mjs.map +7 -0
- package/build-module/utils/transform-styles/types.mjs +1 -0
- package/build-module/utils/transform-styles/types.mjs.map +7 -0
- package/build-module/utils/types.mjs +1 -0
- package/build-module/utils/types.mjs.map +7 -0
- package/build-style/content-rtl.css +14 -0
- package/build-style/content.css +14 -0
- package/build-style/style-rtl.css +60 -49
- package/build-style/style.css +60 -49
- package/build-types/utils/block-bindings.d.ts +27 -0
- package/build-types/utils/block-bindings.d.ts.map +1 -0
- package/build-types/utils/color-values.d.ts +40 -0
- package/build-types/utils/color-values.d.ts.map +1 -0
- package/build-types/utils/dom.d.ts +19 -19
- package/build-types/utils/dom.d.ts.map +1 -1
- package/build-types/utils/fit-text-frontend.d.ts +7 -0
- package/build-types/utils/fit-text-frontend.d.ts.map +1 -0
- package/build-types/utils/fit-text-utils.d.ts +15 -0
- package/build-types/utils/fit-text-utils.d.ts.map +1 -0
- package/build-types/utils/format-font-style.d.ts +12 -0
- package/build-types/utils/format-font-style.d.ts.map +1 -0
- package/build-types/utils/format-font-weight.d.ts +12 -0
- package/build-types/utils/format-font-weight.d.ts.map +1 -0
- package/build-types/utils/get-editor-region.d.ts +9 -0
- package/build-types/utils/get-editor-region.d.ts.map +1 -0
- package/build-types/utils/get-font-styles-and-weights.d.ts +16 -0
- package/build-types/utils/get-font-styles-and-weights.d.ts.map +1 -0
- package/build-types/utils/get-px-from-css-unit.d.ts +10 -0
- package/build-types/utils/get-px-from-css-unit.d.ts.map +1 -0
- package/build-types/utils/index.d.ts +3 -0
- package/build-types/utils/index.d.ts.map +1 -0
- package/build-types/utils/math.d.ts +61 -0
- package/build-types/utils/math.d.ts.map +1 -0
- package/build-types/utils/object.d.ts +39 -0
- package/build-types/utils/object.d.ts.map +1 -0
- package/build-types/utils/order-inserter-block-items.d.ts +13 -0
- package/build-types/utils/order-inserter-block-items.d.ts.map +1 -0
- package/build-types/utils/pasting.d.ts +28 -0
- package/build-types/utils/pasting.d.ts.map +1 -0
- package/build-types/utils/selection.d.ts +21 -0
- package/build-types/utils/selection.d.ts.map +1 -0
- package/build-types/utils/sorting.d.ts +17 -0
- package/build-types/utils/sorting.d.ts.map +1 -0
- package/build-types/utils/transform-styles/index.d.ts +15 -0
- package/build-types/utils/transform-styles/index.d.ts.map +1 -0
- package/build-types/utils/transform-styles/types.d.ts +13 -0
- package/build-types/utils/transform-styles/types.d.ts.map +1 -0
- package/build-types/utils/types.d.ts +28 -0
- package/build-types/utils/types.d.ts.map +1 -0
- package/package.json +55 -46
- package/src/components/alignment-control/test/__snapshots__/index.js.snap +6 -0
- package/src/components/block-alignment-control/test/__snapshots__/index.js.snap +5 -0
- package/src/components/block-breadcrumb/README.md +2 -2
- package/src/components/block-card/index.js +7 -13
- package/src/components/block-compare/README.md +6 -6
- package/src/components/block-compare/index.js +1 -3
- package/src/components/block-editing-mode/index.js +17 -9
- package/src/components/block-icon/test/__snapshots__/index.js.snap +1 -0
- package/src/components/block-inspector/index.js +22 -20
- package/src/components/block-patterns-list/index.js +1 -2
- package/src/components/block-preview/README.md +1 -1
- package/src/components/block-quick-navigation/index.js +7 -7
- package/src/components/block-rename/modal.js +0 -1
- package/src/components/block-switcher/block-transformations-menu.js +16 -18
- package/src/components/block-switcher/index.js +4 -4
- package/src/components/block-toolbar/block-toolbar-icon.js +22 -6
- package/src/components/block-toolbar/test/block-toolbar-icon.js +99 -0
- package/src/components/block-tools/use-block-toolbar-popover-props.js +10 -4
- package/src/components/block-types-list/README.md +0 -19
- package/src/components/block-vertical-alignment-control/test/__snapshots__/index.js.snap +4 -0
- package/src/components/child-layout-control/index.js +65 -20
- package/src/components/child-layout-control/test/index.js +64 -0
- package/src/components/colors-gradients/control.js +29 -12
- package/src/components/colors-gradients/dropdown.js +4 -1
- package/src/components/colors-gradients/style.scss +39 -2
- package/src/components/contrast-checker/README.md +9 -0
- package/src/components/contrast-checker/index.js +42 -3
- package/src/components/date-format-picker/index.js +0 -1
- package/src/components/default-block-appender/content.scss +3 -0
- package/src/components/dimensions-tool/index.js +4 -9
- package/src/components/dimensions-tool/scale-tool.js +1 -2
- package/src/components/dimensions-tool/test/index.js +89 -11
- package/src/components/global-styles/advanced-panel.js +5 -1
- package/src/components/global-styles/background-panel.js +203 -36
- package/src/components/global-styles/border-panel.js +2 -0
- package/src/components/global-styles/color-gradient-dropdown-item.js +258 -0
- package/src/components/global-styles/color-panel.js +125 -487
- package/src/components/global-styles/dimensions-panel.js +13 -18
- package/src/components/global-styles/hooks.js +45 -0
- package/src/components/global-styles/shadow-panel-components.js +0 -1
- package/src/components/global-styles/test/background-panel.js +56 -0
- package/src/components/global-styles/test/color-panel.js +172 -118
- package/src/components/global-styles/test/typography-panel.js +167 -0
- package/src/components/global-styles/typography-panel.js +100 -11
- package/src/components/iframe/index.js +8 -3
- package/src/components/inner-blocks/use-inner-block-template-sync.js +3 -1
- package/src/components/inserter/hooks/use-patterns-state.js +1 -1
- package/src/components/inserter/index.js +257 -288
- package/src/components/inserter/media-tab/media-preview.js +0 -1
- package/src/components/inserter/search-results.js +1 -3
- package/src/components/inspector-controls/README.md +0 -2
- package/src/components/inspector-controls/fill.js +6 -8
- package/src/components/inspector-controls/groups.js +2 -0
- package/src/components/inspector-controls-tabs/index.js +0 -1
- package/src/components/inspector-controls-tabs/styles-tab.js +78 -28
- package/src/components/justify-content-control/README.md +1 -1
- package/src/components/link-control/index.js +0 -1
- package/src/components/link-control/test/index.js +2 -3
- package/src/components/list-view/block-select-button.js +9 -29
- package/src/components/list-view/block.js +1 -0
- package/src/components/media-placeholder/README.md +1 -29
- package/src/components/media-upload/README.md +0 -19
- package/src/components/preset-input-control/custom-value-controls.js +0 -1
- package/src/components/provider/test/use-block-sync.js +40 -0
- package/src/components/provider/use-block-sync.js +15 -3
- package/src/components/rich-text/content.scss +2 -0
- package/src/components/rich-text/event-listeners/before-input-rules.js +5 -4
- package/src/components/rich-text/event-listeners/delete.js +9 -4
- package/src/components/rich-text/event-listeners/enter.js +9 -2
- package/src/components/rich-text/event-listeners/input-events.js +13 -4
- package/src/components/rich-text/event-listeners/input-rules.js +20 -4
- package/src/components/rich-text/event-listeners/insert-replacement-text.js +9 -4
- package/src/components/rich-text/event-listeners/remove-browser-shortcuts.js +9 -4
- package/src/components/rich-text/event-listeners/shortcuts.js +13 -4
- package/src/components/rich-text/event-listeners/undo-automatic-change.js +5 -4
- package/src/components/rich-text/index.js +1 -33
- package/src/components/unit-control/README.md +1 -1
- package/src/components/url-popover/README.md +1 -1
- package/src/components/url-popover/image-url-input-ui.js +0 -2
- package/src/components/use-block-commands/index.js +5 -5
- package/src/components/use-block-display-information/index.js +15 -2
- package/src/components/use-block-display-information/test/index.js +140 -0
- package/src/hooks/anchor.js +9 -18
- package/src/hooks/background.js +210 -133
- package/src/hooks/background.scss +0 -35
- package/src/hooks/block-fields/index.js +27 -2
- package/src/hooks/border.js +1 -5
- package/src/hooks/color.js +2 -210
- package/src/hooks/color.scss +3 -9
- package/src/hooks/contrast-checker.js +60 -17
- package/src/hooks/custom-class-name.js +0 -1
- package/src/hooks/dimensions.js +15 -8
- package/src/hooks/elements.js +140 -0
- package/src/hooks/elements.scss +8 -0
- package/src/hooks/fit-text.js +16 -0
- package/src/hooks/grid-visualizer.js +59 -45
- package/src/hooks/layout-child.js +92 -14
- package/src/hooks/layout.js +6 -3
- package/src/hooks/list-view.js +10 -11
- package/src/hooks/position.js +23 -27
- package/src/hooks/states.js +2 -2
- package/src/hooks/style.js +91 -9
- package/src/hooks/supports.js +0 -9
- package/src/hooks/test/background.js +59 -0
- package/src/hooks/test/block-style-state.js +14 -14
- package/src/hooks/test/dimensions.js +71 -0
- package/src/hooks/test/layout-child.js +165 -0
- package/src/hooks/test/layout.js +6 -6
- package/src/hooks/test/style.js +133 -11
- package/src/hooks/typography.js +70 -6
- package/src/layouts/flex.js +118 -15
- package/src/private-apis.js +8 -0
- package/src/store/actions.js +13 -3
- package/src/store/private-actions.js +1 -4
- package/src/store/private-selectors.js +89 -0
- package/src/store/reducer.js +19 -7
- package/src/store/selectors.js +91 -53
- package/src/store/test/actions.js +21 -0
- package/src/store/test/private-selectors.js +166 -7
- package/src/store/test/reducer.js +107 -10
- package/src/store/test/selectors.js +77 -0
- package/src/style.scss +1 -0
- package/src/utils/block-bindings.ts +51 -0
- package/src/utils/color-values.ts +63 -0
- package/src/utils/{dom.js → dom.ts} +27 -27
- package/src/utils/{fit-text-frontend.js → fit-text-frontend.ts} +12 -4
- package/src/utils/{fit-text-utils.js → fit-text-utils.ts} +15 -7
- package/src/utils/{format-font-style.js → format-font-style.ts} +10 -3
- package/src/utils/{format-font-weight.js → format-font-weight.ts} +10 -3
- package/src/utils/{get-editor-region.js → get-editor-region.ts} +10 -6
- package/src/utils/{get-font-styles-and-weights.js → get-font-styles-and-weights.ts} +21 -17
- package/src/utils/{math.js → math.ts} +37 -30
- package/src/utils/object.ts +89 -0
- package/src/utils/{order-inserter-block-items.js → order-inserter-block-items.ts} +8 -5
- package/src/utils/{pasting.js → pasting.ts} +18 -11
- package/src/utils/{selection.js → selection.ts} +11 -4
- package/src/utils/sorting.ts +81 -0
- package/src/utils/test/color-values.js +44 -1
- package/src/utils/transform-styles/{index.js → index.ts} +25 -25
- package/src/utils/transform-styles/postcss-urlrebase.d.ts +15 -0
- package/src/utils/transform-styles/types.ts +13 -0
- package/src/utils/types.ts +29 -0
- package/build/components/media-upload-progress/constants.cjs +0 -46
- package/build/components/media-upload-progress/constants.cjs.map +0 -7
- package/build/components/rich-text/native/format-edit.cjs +0 -60
- package/build/components/rich-text/native/format-edit.cjs.map +0 -7
- package/build/components/rich-text/native/index.cjs.map +0 -7
- package/build/components/rich-text/native/use-format-types.cjs +0 -139
- package/build/components/rich-text/native/use-format-types.cjs.map +0 -7
- package/build-module/components/media-upload-progress/constants.mjs +0 -16
- package/build-module/components/media-upload-progress/constants.mjs.map +0 -7
- package/build-module/components/rich-text/native/format-edit.mjs +0 -39
- package/build-module/components/rich-text/native/format-edit.mjs.map +0 -7
- package/build-module/components/rich-text/native/index.mjs +0 -7
- package/build-module/components/rich-text/native/index.mjs.map +0 -7
- package/build-module/components/rich-text/native/use-format-types.mjs +0 -114
- package/build-module/components/rich-text/native/use-format-types.mjs.map +0 -7
- package/src/components/audio-player/audio-url-parser.native.js +0 -20
- package/src/components/audio-player/index.native.js +0 -225
- package/src/components/audio-player/styles.native.scss +0 -114
- package/src/components/audio-player/test/audio-url-parser.native.js +0 -53
- package/src/components/block-alignment-control/test/index.native.js +0 -37
- package/src/components/block-alignment-control/ui.native.js +0 -86
- package/src/components/block-caption/README.md +0 -104
- package/src/components/block-caption/index.native.js +0 -89
- package/src/components/block-caption/styles.native.scss +0 -7
- package/src/components/block-controls/slot.native.js +0 -33
- package/src/components/block-draggable/draggable-chip.native.js +0 -49
- package/src/components/block-draggable/dropping-insertion-point.native.js +0 -181
- package/src/components/block-draggable/dropping-insertion-point.native.scss +0 -8
- package/src/components/block-draggable/index.native.js +0 -467
- package/src/components/block-draggable/style.native.scss +0 -19
- package/src/components/block-draggable/test/__snapshots__/index.native.js.snap +0 -73
- package/src/components/block-draggable/test/helpers.native.js +0 -182
- package/src/components/block-draggable/test/index.native.js +0 -419
- package/src/components/block-draggable/use-scroll-when-dragging.native.js +0 -135
- package/src/components/block-edit/edit.native.js +0 -49
- package/src/components/block-edit/test/edit.native.js +0 -65
- package/src/components/block-heading-level-dropdown/index.native.js +0 -68
- package/src/components/block-icon/index.native.js +0 -47
- package/src/components/block-icon/style.native.scss +0 -7
- package/src/components/block-list/block-crash-boundary.native.js +0 -43
- package/src/components/block-list/block-crash-warning.native.js +0 -21
- package/src/components/block-list/block-invalid-warning.native.js +0 -70
- package/src/components/block-list/block-list-context.native.js +0 -172
- package/src/components/block-list/block-list-item-cell.native.js +0 -62
- package/src/components/block-list/block-list-item.native.js +0 -209
- package/src/components/block-list/block-list-item.native.scss +0 -16
- package/src/components/block-list/block-outline.native.js +0 -77
- package/src/components/block-list/block-selection-button.native.js +0 -100
- package/src/components/block-list/block-selection-button.native.scss +0 -34
- package/src/components/block-list/block.native.js +0 -716
- package/src/components/block-list/block.native.scss +0 -62
- package/src/components/block-list/grid-item.native.js +0 -58
- package/src/components/block-list/index.native.js +0 -437
- package/src/components/block-list/insertion-point.native.js +0 -36
- package/src/components/block-list/style.native.scss +0 -117
- package/src/components/block-list/test/block-invalid-warning.native.js +0 -62
- package/src/components/block-list/test/block-list-context.native.js +0 -243
- package/src/components/block-list/test/block-outline.native.js +0 -255
- package/src/components/block-list/test/fixtures/block-list-context.native.js +0 -79
- package/src/components/block-list/test/index.native.js +0 -205
- package/src/components/block-list/use-block-props/index.native.js +0 -10
- package/src/components/block-list/use-scroll-upon-insertion.native.js +0 -52
- package/src/components/block-list-appender/index.native.js +0 -70
- package/src/components/block-list-appender/style.native.scss +0 -8
- package/src/components/block-media-update-progress/README.md +0 -100
- package/src/components/block-media-update-progress/index.native.js +0 -299
- package/src/components/block-media-update-progress/styles.native.scss +0 -9
- package/src/components/block-media-update-progress/test/index.native.js +0 -543
- package/src/components/block-mover/index.native.js +0 -193
- package/src/components/block-mover/mover-description.native.js +0 -155
- package/src/components/block-mover/test/__snapshots__/index.native.js.snap +0 -218
- package/src/components/block-mover/test/index.native.js +0 -186
- package/src/components/block-settings/button.native.js +0 -41
- package/src/components/block-settings/container.native.js +0 -91
- package/src/components/block-settings/container.native.scss +0 -4
- package/src/components/block-settings/index.native.js +0 -5
- package/src/components/block-styles/index.native.js +0 -94
- package/src/components/block-styles/preview.native.js +0 -109
- package/src/components/block-styles/style.native.scss +0 -64
- package/src/components/block-switcher/block-transformations-menu.native.js +0 -91
- package/src/components/block-toolbar/block-toolbar-menu.native.js +0 -477
- package/src/components/block-toolbar/index.native.js +0 -126
- package/src/components/block-toolbar/test/__snapshots__/block-toolbar-menu.native.js.snap +0 -125
- package/src/components/block-toolbar/test/block-toolbar-menu.native.js +0 -405
- package/src/components/block-toolbar/test/index.native.js +0 -36
- package/src/components/block-types-list/index.native.js +0 -175
- package/src/components/block-types-list/style.native.scss +0 -25
- package/src/components/block-variation-picker/index.native.js +0 -107
- package/src/components/block-variation-picker/style.native.scss +0 -32
- package/src/components/button-block-appender/index.native.js +0 -92
- package/src/components/button-block-appender/styles.native.scss +0 -43
- package/src/components/caption/README.md +0 -44
- package/src/components/caption/index.native.js +0 -61
- package/src/components/colors-gradients/panel-color-gradient-settings.native.js +0 -59
- package/src/components/contrast-checker/index.native.js +0 -113
- package/src/components/contrast-checker/style.native.scss +0 -26
- package/src/components/convert-to-group-buttons/index.native.js +0 -79
- package/src/components/default-block-appender/index.native.js +0 -113
- package/src/components/default-block-appender/style.native.scss +0 -18
- package/src/components/floating-toolbar/floatingToolbar.android.scss +0 -4
- package/src/components/floating-toolbar/floatingToolbar.ios.scss +0 -3
- package/src/components/floating-toolbar/index.native.js +0 -141
- package/src/components/floating-toolbar/styles.native.scss +0 -43
- package/src/components/font-sizes/index.native.js +0 -7
- package/src/components/global-styles/color-panel.native.js +0 -207
- package/src/components/global-styles/test/use-global-styles-context.native.js +0 -435
- package/src/components/global-styles/use-global-styles-context.native.js +0 -592
- package/src/components/gradients/index.native.js +0 -2
- package/src/components/image-link-destinations/index.native.js +0 -152
- package/src/components/image-link-destinations/style.native.scss +0 -16
- package/src/components/index.native.js +0 -108
- package/src/components/inner-blocks/constants.native.js +0 -5
- package/src/components/inner-blocks/index.native.js +0 -221
- package/src/components/inner-blocks/warning-max-depth-exceeded.native.js +0 -124
- package/src/components/inserter/block-types-tab.native.js +0 -76
- package/src/components/inserter/hooks/use-block-type-impressions.native.js +0 -47
- package/src/components/inserter/hooks/use-clipboard-block.native.js +0 -40
- package/src/components/inserter/index.native.js +0 -424
- package/src/components/inserter/menu.native.js +0 -237
- package/src/components/inserter/no-results.native.js +0 -49
- package/src/components/inserter/reusable-blocks-tab.native.js +0 -45
- package/src/components/inserter/search-results.native.js +0 -67
- package/src/components/inserter/style.native.scss +0 -83
- package/src/components/inserter/tabs.native.js +0 -152
- package/src/components/inserter/test/__snapshots__/index.native.js.snap +0 -117
- package/src/components/inserter/test/fixtures/index.native.js +0 -12
- package/src/components/inserter/test/index.native.js +0 -273
- package/src/components/inserter/test/reusable-blocks-tab.native.js +0 -62
- package/src/components/inserter/test/utils.native.js +0 -37
- package/src/components/inserter/utils.native.js +0 -46
- package/src/components/inserter-button/index.native.js +0 -108
- package/src/components/inserter-button/style.native.scss +0 -72
- package/src/components/inspector-controls/fill.native.js +0 -62
- package/src/components/inspector-controls/slot.native.js +0 -35
- package/src/components/inspector-controls-tabs/advanced-controls-panel.native.js +0 -31
- package/src/components/line-height-control/index.native.js +0 -28
- package/src/components/media-placeholder/index.native.js +0 -258
- package/src/components/media-placeholder/styles.native.scss +0 -108
- package/src/components/media-replace-flow/index.native.js +0 -12
- package/src/components/media-upload/constants.native.js +0 -14
- package/src/components/media-upload/index.native.js +0 -356
- package/src/components/media-upload/style.native.scss +0 -4
- package/src/components/media-upload/test/index.native.js +0 -172
- package/src/components/media-upload-progress/README.md +0 -100
- package/src/components/media-upload-progress/constants.js +0 -6
- package/src/components/media-upload-progress/index.native.js +0 -233
- package/src/components/media-upload-progress/styles.native.scss +0 -15
- package/src/components/media-upload-progress/test/index.native.js +0 -220
- package/src/components/plain-text/index.native.js +0 -164
- package/src/components/plain-text/style.native.scss +0 -10
- package/src/components/provider/index.native.js +0 -32
- package/src/components/rich-text/embed-handler-picker.native.js +0 -65
- package/src/components/rich-text/file-paste-handler.native.js +0 -3
- package/src/components/rich-text/format-toolbar/index.native.js +0 -21
- package/src/components/rich-text/format-toolbar-container.native.js +0 -16
- package/src/components/rich-text/index.native.js +0 -701
- package/src/components/rich-text/input-event.native.js +0 -10
- package/src/components/rich-text/native/format-edit.js +0 -44
- package/src/components/rich-text/native/get-format-colors.native.js +0 -47
- package/src/components/rich-text/native/index.js +0 -1
- package/src/components/rich-text/native/index.native.js +0 -1389
- package/src/components/rich-text/native/style.native.scss +0 -28
- package/src/components/rich-text/native/test/__snapshots__/index.native.js.snap +0 -79
- package/src/components/rich-text/native/test/index.native.js +0 -345
- package/src/components/rich-text/native/test/performance/rich-text.native.js +0 -44
- package/src/components/rich-text/native/toolbar-button-with-options.native.js +0 -61
- package/src/components/rich-text/native/use-format-types.js +0 -146
- package/src/components/rich-text/remove-browser-shortcuts.native.js +0 -1
- package/src/components/rich-text/shortcut.native.js +0 -10
- package/src/components/ungroup-button/README.md +0 -23
- package/src/components/ungroup-button/index.native.js +0 -77
- package/src/components/unsupported-block-details/index.native.js +0 -187
- package/src/components/unsupported-block-details/style.native.scss +0 -56
- package/src/components/url-input/index.native.js +0 -33
- package/src/components/use-block-drop-zone/index.native.js +0 -207
- package/src/components/use-on-block-drop/index.native.js +0 -115
- package/src/components/use-unsupported-block-editor/index.native.js +0 -59
- package/src/components/video-player/gridicon-play.native.js +0 -13
- package/src/components/video-player/index.native.js +0 -133
- package/src/components/video-player/styles.native.scss +0 -29
- package/src/components/warning/index.native.js +0 -64
- package/src/components/warning/style.native.scss +0 -47
- package/src/hooks/align.native.js +0 -49
- package/src/hooks/custom-class-name.native.js +0 -70
- package/src/hooks/index.native.js +0 -36
- package/src/hooks/layout.native.js +0 -23
- package/src/hooks/test/__snapshots__/align.native.js.snap +0 -73
- package/src/hooks/test/__snapshots__/anchor.native.js.snap +0 -7
- package/src/hooks/test/align.native.js +0 -134
- package/src/hooks/test/anchor.native.js +0 -32
- package/src/hooks/test/use-editor-wrapper-styles.native.js +0 -282
- package/src/hooks/typography.native.js +0 -60
- package/src/hooks/use-editor-wrapper-styles.native.js +0 -250
- package/src/hooks/use-editor-wrapper-styles.native.scss +0 -12
- package/src/index.native.js +0 -6
- package/src/private-apis.native.js +0 -21
- package/src/store/defaults.native.js +0 -23
- package/src/utils/block-bindings.js +0 -46
- package/src/utils/color-values.js +0 -28
- package/src/utils/object.js +0 -67
- package/src/utils/sorting.js +0 -54
- /package/src/utils/{get-px-from-css-unit.js → get-px-from-css-unit.ts} +0 -0
- /package/src/utils/{index.js → index.ts} +0 -0
|
@@ -37,17 +37,16 @@ var import_clsx = __toESM(require("clsx"));
|
|
|
37
37
|
var import_a11y = require("@wordpress/a11y");
|
|
38
38
|
var import_i18n = require("@wordpress/i18n");
|
|
39
39
|
var import_components = require("@wordpress/components");
|
|
40
|
-
var import_element = require("@wordpress/element");
|
|
41
40
|
var import_data = require("@wordpress/data");
|
|
42
|
-
var import_compose = require("@wordpress/compose");
|
|
43
41
|
var import_blocks = require("@wordpress/blocks");
|
|
42
|
+
var import_element = require("@wordpress/element");
|
|
44
43
|
var import_icons = require("@wordpress/icons");
|
|
45
44
|
var import_menu = __toESM(require("./menu.cjs"));
|
|
46
45
|
var import_quick_inserter = __toESM(require("./quick-inserter.cjs"));
|
|
47
46
|
var import_store = require("../../store/index.cjs");
|
|
48
47
|
var import_get_appender_label = require("./get-appender-label.cjs");
|
|
49
48
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
50
|
-
var
|
|
49
|
+
var UnforwardedInserterToggle = ({
|
|
51
50
|
onToggle,
|
|
52
51
|
disabled,
|
|
53
52
|
isOpen,
|
|
@@ -55,7 +54,7 @@ var defaultRenderToggle = ({
|
|
|
55
54
|
hasSingleBlockType,
|
|
56
55
|
appenderLabel,
|
|
57
56
|
toggleProps = {}
|
|
58
|
-
}) => {
|
|
57
|
+
}, ref) => {
|
|
59
58
|
const {
|
|
60
59
|
as: Wrapper = import_components.Button,
|
|
61
60
|
label: labelProp,
|
|
@@ -85,6 +84,7 @@ var defaultRenderToggle = ({
|
|
|
85
84
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
86
85
|
Wrapper,
|
|
87
86
|
{
|
|
87
|
+
ref,
|
|
88
88
|
__next40pxDefaultSize: toggleProps.as ? void 0 : true,
|
|
89
89
|
icon: import_icons.plus,
|
|
90
90
|
label,
|
|
@@ -99,70 +99,169 @@ var defaultRenderToggle = ({
|
|
|
99
99
|
}
|
|
100
100
|
);
|
|
101
101
|
};
|
|
102
|
-
var
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
102
|
+
var InserterToggle = (0, import_element.forwardRef)(UnforwardedInserterToggle);
|
|
103
|
+
var UnforwardedInserter = ({
|
|
104
|
+
clientId,
|
|
105
|
+
rootClientId,
|
|
106
|
+
disabled,
|
|
107
|
+
isAppender,
|
|
108
|
+
position,
|
|
109
|
+
selectBlockOnInsert,
|
|
110
|
+
shouldDirectInsert = true,
|
|
111
|
+
showInserterHelpPanel,
|
|
112
|
+
// This prop is experimental to give some time for the quick inserter to mature
|
|
113
|
+
// Feel free to make them stable after a few releases.
|
|
114
|
+
__experimentalIsQuick: isQuick,
|
|
115
|
+
onSelectOrClose,
|
|
116
|
+
onToggle,
|
|
117
|
+
renderToggle: renderToggleProp,
|
|
118
|
+
toggleProps
|
|
119
|
+
}, ref) => {
|
|
120
|
+
const {
|
|
121
|
+
hasItems,
|
|
122
|
+
hasSingleBlockType,
|
|
123
|
+
blockTitle,
|
|
124
|
+
allowedBlockType,
|
|
125
|
+
blockToInsert,
|
|
126
|
+
appenderLabel,
|
|
127
|
+
targetRootClientId
|
|
128
|
+
} = (0, import_data.useSelect)(
|
|
129
|
+
(select) => {
|
|
130
|
+
const {
|
|
131
|
+
getBlockRootClientId: getBlockRootClientId2,
|
|
132
|
+
hasInserterItems,
|
|
133
|
+
getAllowedBlocks,
|
|
134
|
+
getDirectInsertBlock,
|
|
135
|
+
getBlockListSettings
|
|
136
|
+
} = select(import_store.store);
|
|
137
|
+
const { getBlockVariations, getBlockType: getBlockType2 } = select(import_blocks.store);
|
|
138
|
+
const _targetRootClientId = rootClientId || getBlockRootClientId2(clientId) || void 0;
|
|
139
|
+
const allowedBlocks = getAllowedBlocks(_targetRootClientId);
|
|
140
|
+
const directInsertBlock = shouldDirectInsert && getDirectInsertBlock(_targetRootClientId);
|
|
141
|
+
const { defaultBlock } = getBlockListSettings(_targetRootClientId) ?? {};
|
|
142
|
+
const _hasSingleBlockType = allowedBlocks?.length === 1 && getBlockVariations(allowedBlocks[0].name, "inserter")?.length === 0;
|
|
143
|
+
const _allowedBlockType = _hasSingleBlockType ? allowedBlocks[0] : null;
|
|
144
|
+
let _blockToInsert = directInsertBlock || null;
|
|
145
|
+
if (!_blockToInsert && _hasSingleBlockType && defaultBlock?.name === _allowedBlockType.name) {
|
|
146
|
+
_blockToInsert = defaultBlock;
|
|
147
|
+
}
|
|
148
|
+
const defaultBlockType = directInsertBlock ? getBlockType2(directInsertBlock.name) : null;
|
|
149
|
+
return {
|
|
150
|
+
hasItems: hasInserterItems(_targetRootClientId),
|
|
151
|
+
hasSingleBlockType: _hasSingleBlockType,
|
|
152
|
+
blockTitle: _allowedBlockType ? _allowedBlockType.title : "",
|
|
153
|
+
allowedBlockType: _allowedBlockType,
|
|
154
|
+
blockToInsert: _blockToInsert,
|
|
155
|
+
appenderLabel: (0, import_get_appender_label.getAppenderLabel)(
|
|
156
|
+
directInsertBlock,
|
|
157
|
+
defaultBlockType
|
|
158
|
+
),
|
|
159
|
+
targetRootClientId: _targetRootClientId
|
|
160
|
+
};
|
|
161
|
+
},
|
|
162
|
+
[rootClientId, clientId, shouldDirectInsert]
|
|
163
|
+
);
|
|
164
|
+
const { insertBlock } = (0, import_data.useDispatch)(import_store.store);
|
|
165
|
+
const {
|
|
166
|
+
getBlock,
|
|
167
|
+
getBlockIndex,
|
|
168
|
+
getBlockOrder,
|
|
169
|
+
getBlockRootClientId,
|
|
170
|
+
getBlockSelectionEnd,
|
|
171
|
+
getPreviousBlockClientId
|
|
172
|
+
} = (0, import_data.useSelect)(import_store.store);
|
|
173
|
+
const { getActiveBlockVariation, getBlockType } = (0, import_data.useSelect)(import_blocks.store);
|
|
174
|
+
if (!hasItems && (isAppender || targetRootClientId || clientId)) {
|
|
175
|
+
return null;
|
|
108
176
|
}
|
|
109
|
-
|
|
110
|
-
const
|
|
111
|
-
|
|
112
|
-
|
|
177
|
+
function insertOnlyAllowedBlock() {
|
|
178
|
+
const blockName = blockToInsert?.name ?? allowedBlockType.name;
|
|
179
|
+
function getAdjacentBlockAttributes(attributesToCopy) {
|
|
180
|
+
if (!attributesToCopy?.length) {
|
|
181
|
+
return {};
|
|
182
|
+
}
|
|
183
|
+
let adjacentAttributes;
|
|
184
|
+
if (clientId) {
|
|
185
|
+
const currentBlock = getBlock(clientId);
|
|
186
|
+
const previousBlock = getBlock(
|
|
187
|
+
getPreviousBlockClientId(clientId)
|
|
188
|
+
);
|
|
189
|
+
if (currentBlock?.name === previousBlock?.name) {
|
|
190
|
+
adjacentAttributes = previousBlock?.attributes;
|
|
191
|
+
}
|
|
192
|
+
} else if (targetRootClientId) {
|
|
193
|
+
const lastInnerBlock = getBlock(targetRootClientId)?.innerBlocks?.at(-1);
|
|
194
|
+
if (lastInnerBlock?.name === blockName) {
|
|
195
|
+
adjacentAttributes = lastInnerBlock.attributes;
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
if (!adjacentAttributes) {
|
|
199
|
+
return {};
|
|
200
|
+
}
|
|
201
|
+
return Object.fromEntries(
|
|
202
|
+
attributesToCopy.filter((attr) => attr in adjacentAttributes).map((attr) => [attr, adjacentAttributes[attr]])
|
|
203
|
+
);
|
|
204
|
+
}
|
|
205
|
+
function getInsertionIndex() {
|
|
206
|
+
if (clientId) {
|
|
207
|
+
return getBlockIndex(clientId);
|
|
208
|
+
}
|
|
209
|
+
const end = getBlockSelectionEnd();
|
|
210
|
+
if (!isAppender && end && getBlockRootClientId(end) === targetRootClientId) {
|
|
211
|
+
return getBlockIndex(end) + 1;
|
|
212
|
+
}
|
|
213
|
+
return getBlockOrder(targetRootClientId).length;
|
|
214
|
+
}
|
|
215
|
+
const newAttributes = getAdjacentBlockAttributes(
|
|
216
|
+
blockToInsert?.attributesToCopy
|
|
217
|
+
);
|
|
218
|
+
const newBlock = (0, import_blocks.createBlock)(blockName, {
|
|
219
|
+
...blockToInsert?.attributes,
|
|
220
|
+
...newAttributes
|
|
221
|
+
});
|
|
222
|
+
insertBlock(
|
|
223
|
+
newBlock,
|
|
224
|
+
getInsertionIndex(),
|
|
225
|
+
targetRootClientId,
|
|
226
|
+
selectBlockOnInsert
|
|
227
|
+
);
|
|
228
|
+
onSelectOrClose?.(newBlock);
|
|
229
|
+
const blockTypeToInsert = getBlockType(blockName);
|
|
230
|
+
let blockLabelToInsert;
|
|
231
|
+
if (blockTypeToInsert) {
|
|
232
|
+
blockLabelToInsert = (0, import_blocks.__experimentalGetBlockLabel)(
|
|
233
|
+
blockTypeToInsert,
|
|
234
|
+
newBlock.attributes
|
|
235
|
+
);
|
|
236
|
+
if (blockLabelToInsert === blockTypeToInsert.title) {
|
|
237
|
+
blockLabelToInsert = getActiveBlockVariation(blockName, newBlock.attributes)?.title || blockLabelToInsert;
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
if (blockLabelToInsert) {
|
|
241
|
+
const message = (0, import_i18n.sprintf)(
|
|
242
|
+
// translators: %s: the name of the block that has been added
|
|
243
|
+
(0, import_i18n.__)("%s block added"),
|
|
244
|
+
blockLabelToInsert
|
|
245
|
+
);
|
|
246
|
+
(0, import_a11y.speak)(message);
|
|
113
247
|
}
|
|
114
248
|
}
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
* @param {Object} options
|
|
119
|
-
* @param {Function} options.onToggle Callback to invoke when toggle is
|
|
120
|
-
* pressed.
|
|
121
|
-
* @param {boolean} options.isOpen Whether dropdown is currently open.
|
|
122
|
-
*
|
|
123
|
-
* @return {Element} Dropdown toggle element.
|
|
124
|
-
*/
|
|
125
|
-
renderToggle({ onToggle, isOpen }) {
|
|
126
|
-
const {
|
|
127
|
-
disabled,
|
|
128
|
-
blockTitle,
|
|
129
|
-
hasSingleBlockType,
|
|
130
|
-
appenderLabel,
|
|
131
|
-
toggleProps,
|
|
132
|
-
hasItems,
|
|
133
|
-
renderToggle = defaultRenderToggle
|
|
134
|
-
} = this.props;
|
|
135
|
-
return renderToggle({
|
|
136
|
-
onToggle,
|
|
249
|
+
function renderToggle({ onToggle: dropdownOnToggle, isOpen }) {
|
|
250
|
+
const toggleArgs = {
|
|
251
|
+
onToggle: dropdownOnToggle,
|
|
137
252
|
isOpen,
|
|
138
253
|
disabled: disabled || !hasItems,
|
|
139
254
|
blockTitle,
|
|
140
255
|
hasSingleBlockType,
|
|
141
256
|
appenderLabel,
|
|
142
257
|
toggleProps
|
|
143
|
-
}
|
|
258
|
+
};
|
|
259
|
+
if (renderToggleProp) {
|
|
260
|
+
return renderToggleProp(toggleArgs);
|
|
261
|
+
}
|
|
262
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(InserterToggle, { ref, ...toggleArgs });
|
|
144
263
|
}
|
|
145
|
-
|
|
146
|
-
* Render callback to display Dropdown content element.
|
|
147
|
-
*
|
|
148
|
-
* @param {Object} options
|
|
149
|
-
* @param {Function} options.onClose Callback to invoke when dropdown is
|
|
150
|
-
* closed.
|
|
151
|
-
*
|
|
152
|
-
* @return {Element} Dropdown content element.
|
|
153
|
-
*/
|
|
154
|
-
renderContent({ onClose }) {
|
|
155
|
-
const {
|
|
156
|
-
rootClientId,
|
|
157
|
-
clientId,
|
|
158
|
-
isAppender,
|
|
159
|
-
showInserterHelpPanel,
|
|
160
|
-
// This prop is experimental to give some time for the quick inserter to mature
|
|
161
|
-
// Feel free to make them stable after a few releases.
|
|
162
|
-
__experimentalIsQuick: isQuick,
|
|
163
|
-
onSelectOrClose,
|
|
164
|
-
selectBlockOnInsert
|
|
165
|
-
} = this.props;
|
|
264
|
+
function renderContent({ onClose }) {
|
|
166
265
|
if (isQuick) {
|
|
167
266
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
168
267
|
import_quick_inserter.default,
|
|
@@ -174,7 +273,7 @@ var Inserter = class extends import_element.Component {
|
|
|
174
273
|
}
|
|
175
274
|
onClose();
|
|
176
275
|
},
|
|
177
|
-
rootClientId,
|
|
276
|
+
rootClientId: targetRootClientId,
|
|
178
277
|
clientId,
|
|
179
278
|
isAppender,
|
|
180
279
|
selectBlockOnInsert
|
|
@@ -188,173 +287,33 @@ var Inserter = class extends import_element.Component {
|
|
|
188
287
|
onClose();
|
|
189
288
|
},
|
|
190
289
|
onClose,
|
|
191
|
-
rootClientId,
|
|
290
|
+
rootClientId: targetRootClientId,
|
|
192
291
|
clientId,
|
|
193
292
|
isAppender,
|
|
194
293
|
showInserterHelpPanel
|
|
195
294
|
}
|
|
196
295
|
);
|
|
197
296
|
}
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
position,
|
|
201
|
-
hasSingleBlockType,
|
|
202
|
-
blockToInsert,
|
|
203
|
-
insertOnlyAllowedBlock,
|
|
204
|
-
__experimentalIsQuick: isQuick,
|
|
205
|
-
onSelectOrClose
|
|
206
|
-
} = this.props;
|
|
207
|
-
if (hasSingleBlockType || blockToInsert) {
|
|
208
|
-
return this.renderToggle({ onToggle: insertOnlyAllowedBlock });
|
|
209
|
-
}
|
|
210
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
211
|
-
import_components.Dropdown,
|
|
212
|
-
{
|
|
213
|
-
className: "block-editor-inserter",
|
|
214
|
-
contentClassName: (0, import_clsx.default)("block-editor-inserter__popover", {
|
|
215
|
-
"is-quick": isQuick
|
|
216
|
-
}),
|
|
217
|
-
popoverProps: { position, shift: true },
|
|
218
|
-
onToggle: this.onToggle,
|
|
219
|
-
expandOnMobile: true,
|
|
220
|
-
headerTitle: (0, import_i18n.__)("Add a block"),
|
|
221
|
-
renderToggle: this.renderToggle,
|
|
222
|
-
renderContent: this.renderContent,
|
|
223
|
-
onClose: onSelectOrClose
|
|
224
|
-
}
|
|
225
|
-
);
|
|
297
|
+
if (hasSingleBlockType || blockToInsert) {
|
|
298
|
+
return renderToggle({ onToggle: insertOnlyAllowedBlock });
|
|
226
299
|
}
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
const directInsertBlock = shouldDirectInsert && getDirectInsertBlock(rootClientId);
|
|
242
|
-
const { defaultBlock } = getBlockListSettings(rootClientId) ?? {};
|
|
243
|
-
const hasSingleBlockType = allowedBlocks?.length === 1 && getBlockVariations(allowedBlocks[0].name, "inserter")?.length === 0;
|
|
244
|
-
const allowedBlockType = hasSingleBlockType ? allowedBlocks[0] : null;
|
|
245
|
-
let blockToInsert = directInsertBlock || null;
|
|
246
|
-
if (!blockToInsert && hasSingleBlockType && defaultBlock?.name === allowedBlockType.name) {
|
|
247
|
-
blockToInsert = defaultBlock;
|
|
248
|
-
}
|
|
249
|
-
const defaultBlockType = directInsertBlock ? getBlockType(directInsertBlock.name) : null;
|
|
250
|
-
const appenderLabel = (0, import_get_appender_label.getAppenderLabel)(
|
|
251
|
-
directInsertBlock,
|
|
252
|
-
defaultBlockType
|
|
253
|
-
);
|
|
254
|
-
return {
|
|
255
|
-
hasItems: hasInserterItems(rootClientId),
|
|
256
|
-
hasSingleBlockType,
|
|
257
|
-
blockTitle: allowedBlockType ? allowedBlockType.title : "",
|
|
258
|
-
allowedBlockType,
|
|
259
|
-
blockToInsert,
|
|
260
|
-
appenderLabel,
|
|
261
|
-
rootClientId
|
|
262
|
-
};
|
|
300
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
301
|
+
import_components.Dropdown,
|
|
302
|
+
{
|
|
303
|
+
className: "block-editor-inserter",
|
|
304
|
+
contentClassName: (0, import_clsx.default)("block-editor-inserter__popover", {
|
|
305
|
+
"is-quick": isQuick
|
|
306
|
+
}),
|
|
307
|
+
popoverProps: { position, shift: true },
|
|
308
|
+
onToggle,
|
|
309
|
+
expandOnMobile: true,
|
|
310
|
+
headerTitle: (0, import_i18n.__)("Add a block"),
|
|
311
|
+
renderToggle,
|
|
312
|
+
renderContent,
|
|
313
|
+
onClose: onSelectOrClose
|
|
263
314
|
}
|
|
264
|
-
)
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
const {
|
|
269
|
-
rootClientId,
|
|
270
|
-
clientId,
|
|
271
|
-
isAppender,
|
|
272
|
-
hasSingleBlockType,
|
|
273
|
-
allowedBlockType,
|
|
274
|
-
blockToInsert,
|
|
275
|
-
onSelectOrClose,
|
|
276
|
-
selectBlockOnInsert
|
|
277
|
-
} = ownProps;
|
|
278
|
-
if (!hasSingleBlockType && !blockToInsert) {
|
|
279
|
-
return;
|
|
280
|
-
}
|
|
281
|
-
const blockName = blockToInsert?.name ?? allowedBlockType.name;
|
|
282
|
-
function getAdjacentBlockAttributes(attributesToCopy) {
|
|
283
|
-
if (!attributesToCopy?.length) {
|
|
284
|
-
return {};
|
|
285
|
-
}
|
|
286
|
-
const { getBlock, getPreviousBlockClientId } = select(import_store.store);
|
|
287
|
-
let adjacentAttributes;
|
|
288
|
-
if (clientId) {
|
|
289
|
-
const currentBlock = getBlock(clientId);
|
|
290
|
-
const previousBlock = getBlock(
|
|
291
|
-
getPreviousBlockClientId(clientId)
|
|
292
|
-
);
|
|
293
|
-
if (currentBlock?.name === previousBlock?.name) {
|
|
294
|
-
adjacentAttributes = previousBlock?.attributes;
|
|
295
|
-
}
|
|
296
|
-
} else if (rootClientId) {
|
|
297
|
-
const lastInnerBlock = getBlock(rootClientId)?.innerBlocks?.at(-1);
|
|
298
|
-
if (lastInnerBlock?.name === blockName) {
|
|
299
|
-
adjacentAttributes = lastInnerBlock.attributes;
|
|
300
|
-
}
|
|
301
|
-
}
|
|
302
|
-
if (!adjacentAttributes) {
|
|
303
|
-
return {};
|
|
304
|
-
}
|
|
305
|
-
return Object.fromEntries(
|
|
306
|
-
attributesToCopy.filter((attr) => attr in adjacentAttributes).map((attr) => [
|
|
307
|
-
attr,
|
|
308
|
-
adjacentAttributes[attr]
|
|
309
|
-
])
|
|
310
|
-
);
|
|
311
|
-
}
|
|
312
|
-
function getInsertionIndex() {
|
|
313
|
-
const {
|
|
314
|
-
getBlockIndex,
|
|
315
|
-
getBlockSelectionEnd,
|
|
316
|
-
getBlockOrder,
|
|
317
|
-
getBlockRootClientId
|
|
318
|
-
} = select(import_store.store);
|
|
319
|
-
if (clientId) {
|
|
320
|
-
return getBlockIndex(clientId);
|
|
321
|
-
}
|
|
322
|
-
const end = getBlockSelectionEnd();
|
|
323
|
-
if (!isAppender && end && getBlockRootClientId(end) === rootClientId) {
|
|
324
|
-
return getBlockIndex(end) + 1;
|
|
325
|
-
}
|
|
326
|
-
return getBlockOrder(rootClientId).length;
|
|
327
|
-
}
|
|
328
|
-
const { insertBlock } = dispatch(import_store.store);
|
|
329
|
-
const newAttributes = getAdjacentBlockAttributes(
|
|
330
|
-
blockToInsert?.attributesToCopy
|
|
331
|
-
);
|
|
332
|
-
const newBlock = (0, import_blocks.createBlock)(blockName, {
|
|
333
|
-
...blockToInsert?.attributes || {},
|
|
334
|
-
...newAttributes
|
|
335
|
-
});
|
|
336
|
-
insertBlock(
|
|
337
|
-
newBlock,
|
|
338
|
-
getInsertionIndex(),
|
|
339
|
-
rootClientId,
|
|
340
|
-
selectBlockOnInsert
|
|
341
|
-
);
|
|
342
|
-
if (onSelectOrClose) {
|
|
343
|
-
onSelectOrClose(newBlock);
|
|
344
|
-
}
|
|
345
|
-
const message = (0, import_i18n.sprintf)(
|
|
346
|
-
// translators: %s: the name of the block that has been added
|
|
347
|
-
(0, import_i18n.__)("%s block added"),
|
|
348
|
-
allowedBlockType.title
|
|
349
|
-
);
|
|
350
|
-
(0, import_a11y.speak)(message);
|
|
351
|
-
}
|
|
352
|
-
};
|
|
353
|
-
}),
|
|
354
|
-
// The global inserter should always be visible, we are using ( ! isAppender && ! rootClientId && ! clientId ) as
|
|
355
|
-
// a way to detect the global Inserter.
|
|
356
|
-
(0, import_compose.ifCondition)(
|
|
357
|
-
({ hasItems, isAppender, rootClientId, clientId }) => hasItems || !isAppender && !rootClientId && !clientId
|
|
358
|
-
)
|
|
359
|
-
])(Inserter);
|
|
315
|
+
);
|
|
316
|
+
};
|
|
317
|
+
var Inserter = (0, import_element.forwardRef)(UnforwardedInserter);
|
|
318
|
+
var inserter_default = Inserter;
|
|
360
319
|
//# sourceMappingURL=index.cjs.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/inserter/index.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { speak } from '@wordpress/a11y';\nimport { __, _x, sprintf } from '@wordpress/i18n';\nimport { Dropdown, Button } from '@wordpress/components';\nimport { Component } from '@wordpress/element';\nimport { withDispatch, withSelect } from '@wordpress/data';\nimport { compose, ifCondition } from '@wordpress/compose';\nimport { createBlock, store as blocksStore } from '@wordpress/blocks';\nimport { plus } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport InserterMenu from './menu';\nimport QuickInserter from './quick-inserter';\nimport { store as blockEditorStore } from '../../store';\nimport { getAppenderLabel } from './get-appender-label';\n\nconst defaultRenderToggle = ( {\n\tonToggle,\n\tdisabled,\n\tisOpen,\n\tblockTitle,\n\thasSingleBlockType,\n\tappenderLabel,\n\ttoggleProps = {},\n} ) => {\n\tconst {\n\t\tas: Wrapper = Button,\n\t\tlabel: labelProp,\n\t\tonClick,\n\t\t...rest\n\t} = toggleProps;\n\n\tlet label = labelProp;\n\tif ( ! label && appenderLabel ) {\n\t\t// Block returns the full label; use directly (consistent with getBlockLabel).\n\t\tlabel = appenderLabel;\n\t} else if ( ! label && hasSingleBlockType ) {\n\t\tlabel = sprintf(\n\t\t\t// translators: %s: the name of the block when there is only one\n\t\t\t_x( 'Add %s', 'directly add the only allowed block' ),\n\t\t\tblockTitle.toLowerCase()\n\t\t);\n\t} else if ( ! label ) {\n\t\tlabel = _x( 'Add block', 'Generic label for block inserter button' );\n\t}\n\n\t// Handle both onClick functions from the toggle and the parent component.\n\tfunction handleClick( event ) {\n\t\tif ( onToggle ) {\n\t\t\tonToggle( event );\n\t\t}\n\t\tif ( onClick ) {\n\t\t\tonClick( event );\n\t\t}\n\t}\n\n\treturn (\n\t\t<Wrapper\n\t\t\t__next40pxDefaultSize={ toggleProps.as ? undefined : true }\n\t\t\ticon={ plus }\n\t\t\tlabel={ label }\n\t\t\ttooltipPosition=\"bottom\"\n\t\t\tonClick={ handleClick }\n\t\t\tclassName=\"block-editor-inserter__toggle\"\n\t\t\taria-haspopup={ ! hasSingleBlockType ? 'true' : false }\n\t\t\taria-expanded={ ! hasSingleBlockType ? isOpen : false }\n\t\t\tisPressed={ ! hasSingleBlockType && isOpen }\n\t\t\tdisabled={ disabled }\n\t\t\t{ ...rest }\n\t\t/>\n\t);\n};\n\nclass Inserter extends Component {\n\tconstructor() {\n\t\tsuper( ...arguments );\n\n\t\tthis.onToggle = this.onToggle.bind( this );\n\t\tthis.renderToggle = this.renderToggle.bind( this );\n\t\tthis.renderContent = this.renderContent.bind( this );\n\t}\n\n\tonToggle( isOpen ) {\n\t\tconst { onToggle } = this.props;\n\n\t\t// Surface toggle callback to parent component.\n\t\tif ( onToggle ) {\n\t\t\tonToggle( isOpen );\n\t\t}\n\t}\n\n\t/**\n\t * Render callback to display Dropdown toggle element.\n\t *\n\t * @param {Object} options\n\t * @param {Function} options.onToggle Callback to invoke when toggle is\n\t * pressed.\n\t * @param {boolean} options.isOpen Whether dropdown is currently open.\n\t *\n\t * @return {Element} Dropdown toggle element.\n\t */\n\trenderToggle( { onToggle, isOpen } ) {\n\t\tconst {\n\t\t\tdisabled,\n\t\t\tblockTitle,\n\t\t\thasSingleBlockType,\n\t\t\tappenderLabel,\n\t\t\ttoggleProps,\n\t\t\thasItems,\n\t\t\trenderToggle = defaultRenderToggle,\n\t\t} = this.props;\n\n\t\treturn renderToggle( {\n\t\t\tonToggle,\n\t\t\tisOpen,\n\t\t\tdisabled: disabled || ! hasItems,\n\t\t\tblockTitle,\n\t\t\thasSingleBlockType,\n\t\t\tappenderLabel,\n\t\t\ttoggleProps,\n\t\t} );\n\t}\n\n\t/**\n\t * Render callback to display Dropdown content element.\n\t *\n\t * @param {Object} options\n\t * @param {Function} options.onClose Callback to invoke when dropdown is\n\t * closed.\n\t *\n\t * @return {Element} Dropdown content element.\n\t */\n\trenderContent( { onClose } ) {\n\t\tconst {\n\t\t\trootClientId,\n\t\t\tclientId,\n\t\t\tisAppender,\n\t\t\tshowInserterHelpPanel,\n\t\t\t// This prop is experimental to give some time for the quick inserter to mature\n\t\t\t// Feel free to make them stable after a few releases.\n\t\t\t__experimentalIsQuick: isQuick,\n\t\t\tonSelectOrClose,\n\t\t\tselectBlockOnInsert,\n\t\t} = this.props;\n\n\t\tif ( isQuick ) {\n\t\t\treturn (\n\t\t\t\t<QuickInserter\n\t\t\t\t\tonSelect={ ( blocks ) => {\n\t\t\t\t\t\tconst firstBlock =\n\t\t\t\t\t\t\tArray.isArray( blocks ) && blocks?.length\n\t\t\t\t\t\t\t\t? blocks[ 0 ]\n\t\t\t\t\t\t\t\t: blocks;\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\tonSelectOrClose &&\n\t\t\t\t\t\t\ttypeof onSelectOrClose === 'function'\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\tonSelectOrClose( firstBlock );\n\t\t\t\t\t\t}\n\t\t\t\t\t\tonClose();\n\t\t\t\t\t} }\n\t\t\t\t\trootClientId={ rootClientId }\n\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\tisAppender={ isAppender }\n\t\t\t\t\tselectBlockOnInsert={ selectBlockOnInsert }\n\t\t\t\t/>\n\t\t\t);\n\t\t}\n\n\t\treturn (\n\t\t\t<InserterMenu\n\t\t\t\tonSelect={ () => {\n\t\t\t\t\tonClose();\n\t\t\t\t} }\n\t\t\t\tonClose={ onClose }\n\t\t\t\trootClientId={ rootClientId }\n\t\t\t\tclientId={ clientId }\n\t\t\t\tisAppender={ isAppender }\n\t\t\t\tshowInserterHelpPanel={ showInserterHelpPanel }\n\t\t\t/>\n\t\t);\n\t}\n\n\trender() {\n\t\tconst {\n\t\t\tposition,\n\t\t\thasSingleBlockType,\n\t\t\tblockToInsert,\n\t\t\tinsertOnlyAllowedBlock,\n\t\t\t__experimentalIsQuick: isQuick,\n\t\t\tonSelectOrClose,\n\t\t} = this.props;\n\n\t\tif ( hasSingleBlockType || blockToInsert ) {\n\t\t\treturn this.renderToggle( { onToggle: insertOnlyAllowedBlock } );\n\t\t}\n\n\t\treturn (\n\t\t\t<Dropdown\n\t\t\t\tclassName=\"block-editor-inserter\"\n\t\t\t\tcontentClassName={ clsx( 'block-editor-inserter__popover', {\n\t\t\t\t\t'is-quick': isQuick,\n\t\t\t\t} ) }\n\t\t\t\tpopoverProps={ { position, shift: true } }\n\t\t\t\tonToggle={ this.onToggle }\n\t\t\t\texpandOnMobile\n\t\t\t\theaderTitle={ __( 'Add a block' ) }\n\t\t\t\trenderToggle={ this.renderToggle }\n\t\t\t\trenderContent={ this.renderContent }\n\t\t\t\tonClose={ onSelectOrClose }\n\t\t\t/>\n\t\t);\n\t}\n}\n\nexport default compose( [\n\twithSelect(\n\t\t( select, { clientId, rootClientId, shouldDirectInsert = true } ) => {\n\t\t\tconst {\n\t\t\t\tgetBlockRootClientId,\n\t\t\t\thasInserterItems,\n\t\t\t\tgetAllowedBlocks,\n\t\t\t\tgetDirectInsertBlock,\n\t\t\t\tgetBlockListSettings,\n\t\t\t} = select( blockEditorStore );\n\t\t\tconst { getBlockVariations, getBlockType } = select( blocksStore );\n\n\t\t\trootClientId =\n\t\t\t\trootClientId || getBlockRootClientId( clientId ) || undefined;\n\n\t\t\tconst allowedBlocks = getAllowedBlocks( rootClientId );\n\t\t\tconst directInsertBlock =\n\t\t\t\tshouldDirectInsert && getDirectInsertBlock( rootClientId );\n\t\t\tconst { defaultBlock } = getBlockListSettings( rootClientId ) ?? {};\n\n\t\t\tconst hasSingleBlockType =\n\t\t\t\tallowedBlocks?.length === 1 &&\n\t\t\t\tgetBlockVariations( allowedBlocks[ 0 ].name, 'inserter' )\n\t\t\t\t\t?.length === 0;\n\t\t\tconst allowedBlockType = hasSingleBlockType\n\t\t\t\t? allowedBlocks[ 0 ]\n\t\t\t\t: null;\n\n\t\t\t// Single-block-type parents get adjacent-attribute copying\n\t\t\t// without needing to set `directInsert: true`.\n\t\t\tlet blockToInsert = directInsertBlock || null;\n\t\t\tif (\n\t\t\t\t! blockToInsert &&\n\t\t\t\thasSingleBlockType &&\n\t\t\t\tdefaultBlock?.name === allowedBlockType.name\n\t\t\t) {\n\t\t\t\tblockToInsert = defaultBlock;\n\t\t\t}\n\n\t\t\tconst defaultBlockType = directInsertBlock\n\t\t\t\t? getBlockType( directInsertBlock.name )\n\t\t\t\t: null;\n\t\t\tconst appenderLabel = getAppenderLabel(\n\t\t\t\tdirectInsertBlock,\n\t\t\t\tdefaultBlockType\n\t\t\t);\n\n\t\t\treturn {\n\t\t\t\thasItems: hasInserterItems( rootClientId ),\n\t\t\t\thasSingleBlockType,\n\t\t\t\tblockTitle: allowedBlockType ? allowedBlockType.title : '',\n\t\t\t\tallowedBlockType,\n\t\t\t\tblockToInsert,\n\t\t\t\tappenderLabel,\n\t\t\t\trootClientId,\n\t\t\t};\n\t\t}\n\t),\n\twithDispatch( ( dispatch, ownProps, { select } ) => {\n\t\treturn {\n\t\t\tinsertOnlyAllowedBlock() {\n\t\t\t\tconst {\n\t\t\t\t\trootClientId,\n\t\t\t\t\tclientId,\n\t\t\t\t\tisAppender,\n\t\t\t\t\thasSingleBlockType,\n\t\t\t\t\tallowedBlockType,\n\t\t\t\t\tblockToInsert,\n\t\t\t\t\tonSelectOrClose,\n\t\t\t\t\tselectBlockOnInsert,\n\t\t\t\t} = ownProps;\n\n\t\t\t\tif ( ! hasSingleBlockType && ! blockToInsert ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tconst blockName = blockToInsert?.name ?? allowedBlockType.name;\n\n\t\t\t\tfunction getAdjacentBlockAttributes( attributesToCopy ) {\n\t\t\t\t\tif ( ! attributesToCopy?.length ) {\n\t\t\t\t\t\treturn {};\n\t\t\t\t\t}\n\n\t\t\t\t\tconst { getBlock, getPreviousBlockClientId } =\n\t\t\t\t\t\tselect( blockEditorStore );\n\n\t\t\t\t\t// Find the adjacent block of the same type whose attributes\n\t\t\t\t\t// should be copied: previous sibling when inserting next to\n\t\t\t\t\t// an existing block, otherwise the last child of the root.\n\t\t\t\t\tlet adjacentAttributes;\n\t\t\t\t\tif ( clientId ) {\n\t\t\t\t\t\tconst currentBlock = getBlock( clientId );\n\t\t\t\t\t\tconst previousBlock = getBlock(\n\t\t\t\t\t\t\tgetPreviousBlockClientId( clientId )\n\t\t\t\t\t\t);\n\t\t\t\t\t\tif ( currentBlock?.name === previousBlock?.name ) {\n\t\t\t\t\t\t\tadjacentAttributes = previousBlock?.attributes;\n\t\t\t\t\t\t}\n\t\t\t\t\t} else if ( rootClientId ) {\n\t\t\t\t\t\tconst lastInnerBlock =\n\t\t\t\t\t\t\tgetBlock( rootClientId )?.innerBlocks?.at( -1 );\n\t\t\t\t\t\tif ( lastInnerBlock?.name === blockName ) {\n\t\t\t\t\t\t\tadjacentAttributes = lastInnerBlock.attributes;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tif ( ! adjacentAttributes ) {\n\t\t\t\t\t\treturn {};\n\t\t\t\t\t}\n\n\t\t\t\t\treturn Object.fromEntries(\n\t\t\t\t\t\tattributesToCopy\n\t\t\t\t\t\t\t.filter( ( attr ) => attr in adjacentAttributes )\n\t\t\t\t\t\t\t.map( ( attr ) => [\n\t\t\t\t\t\t\t\tattr,\n\t\t\t\t\t\t\t\tadjacentAttributes[ attr ],\n\t\t\t\t\t\t\t] )\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\tfunction getInsertionIndex() {\n\t\t\t\t\tconst {\n\t\t\t\t\t\tgetBlockIndex,\n\t\t\t\t\t\tgetBlockSelectionEnd,\n\t\t\t\t\t\tgetBlockOrder,\n\t\t\t\t\t\tgetBlockRootClientId,\n\t\t\t\t\t} = select( blockEditorStore );\n\n\t\t\t\t\t// If the clientId is defined, we insert at the position of the block.\n\t\t\t\t\tif ( clientId ) {\n\t\t\t\t\t\treturn getBlockIndex( clientId );\n\t\t\t\t\t}\n\n\t\t\t\t\t// If there a selected block, we insert after the selected block.\n\t\t\t\t\tconst end = getBlockSelectionEnd();\n\t\t\t\t\tif (\n\t\t\t\t\t\t! isAppender &&\n\t\t\t\t\t\tend &&\n\t\t\t\t\t\tgetBlockRootClientId( end ) === rootClientId\n\t\t\t\t\t) {\n\t\t\t\t\t\treturn getBlockIndex( end ) + 1;\n\t\t\t\t\t}\n\n\t\t\t\t\t// Otherwise, we insert at the end of the current rootClientId.\n\t\t\t\t\treturn getBlockOrder( rootClientId ).length;\n\t\t\t\t}\n\n\t\t\t\tconst { insertBlock } = dispatch( blockEditorStore );\n\n\t\t\t\t// Attempt to augment the inserted block with attributes from an adjacent block.\n\t\t\t\t// This ensures styling from nearby blocks is preserved in the newly inserted block.\n\t\t\t\t// See: https://github.com/WordPress/gutenberg/issues/37904\n\t\t\t\tconst newAttributes = getAdjacentBlockAttributes(\n\t\t\t\t\tblockToInsert?.attributesToCopy\n\t\t\t\t);\n\n\t\t\t\tconst newBlock = createBlock( blockName, {\n\t\t\t\t\t...( blockToInsert?.attributes || {} ),\n\t\t\t\t\t...newAttributes,\n\t\t\t\t} );\n\n\t\t\t\tinsertBlock(\n\t\t\t\t\tnewBlock,\n\t\t\t\t\tgetInsertionIndex(),\n\t\t\t\t\trootClientId,\n\t\t\t\t\tselectBlockOnInsert\n\t\t\t\t);\n\n\t\t\t\tif ( onSelectOrClose ) {\n\t\t\t\t\tonSelectOrClose( newBlock );\n\t\t\t\t}\n\n\t\t\t\tconst message = sprintf(\n\t\t\t\t\t// translators: %s: the name of the block that has been added\n\t\t\t\t\t__( '%s block added' ),\n\t\t\t\t\tallowedBlockType.title\n\t\t\t\t);\n\t\t\t\tspeak( message );\n\t\t\t},\n\t\t};\n\t} ),\n\t// The global inserter should always be visible, we are using ( ! isAppender && ! rootClientId && ! clientId ) as\n\t// a way to detect the global Inserter.\n\tifCondition(\n\t\t( { hasItems, isAppender, rootClientId, clientId } ) =>\n\t\t\thasItems || ( ! isAppender && ! rootClientId && ! clientId )\n\t),\n] )( Inserter );\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAAiB;AAKjB,kBAAsB;AACtB,kBAAgC;AAChC,wBAAiC;AACjC,
|
|
6
|
-
"names": ["
|
|
4
|
+
"sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { speak } from '@wordpress/a11y';\nimport { __, _x, sprintf } from '@wordpress/i18n';\nimport { Dropdown, Button } from '@wordpress/components';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport {\n\tcreateBlock,\n\tstore as blocksStore,\n\t__experimentalGetBlockLabel as getBlockLabel,\n} from '@wordpress/blocks';\nimport { forwardRef } from '@wordpress/element';\nimport { plus } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport InserterMenu from './menu';\nimport QuickInserter from './quick-inserter';\nimport { store as blockEditorStore } from '../../store';\nimport { getAppenderLabel } from './get-appender-label';\n\nconst UnforwardedInserterToggle = (\n\t{\n\t\tonToggle,\n\t\tdisabled,\n\t\tisOpen,\n\t\tblockTitle,\n\t\thasSingleBlockType,\n\t\tappenderLabel,\n\t\ttoggleProps = {},\n\t},\n\tref\n) => {\n\tconst {\n\t\tas: Wrapper = Button,\n\t\tlabel: labelProp,\n\t\tonClick,\n\t\t...rest\n\t} = toggleProps;\n\n\tlet label = labelProp;\n\tif ( ! label && appenderLabel ) {\n\t\t// Block returns the full label; use directly (consistent with getBlockLabel).\n\t\tlabel = appenderLabel;\n\t} else if ( ! label && hasSingleBlockType ) {\n\t\tlabel = sprintf(\n\t\t\t// translators: %s: the name of the block when there is only one\n\t\t\t_x( 'Add %s', 'directly add the only allowed block' ),\n\t\t\tblockTitle.toLowerCase()\n\t\t);\n\t} else if ( ! label ) {\n\t\tlabel = _x( 'Add block', 'Generic label for block inserter button' );\n\t}\n\n\t// Handle both onClick functions from the toggle and the parent component.\n\tfunction handleClick( event ) {\n\t\tif ( onToggle ) {\n\t\t\tonToggle( event );\n\t\t}\n\t\tif ( onClick ) {\n\t\t\tonClick( event );\n\t\t}\n\t}\n\n\treturn (\n\t\t<Wrapper\n\t\t\tref={ ref }\n\t\t\t__next40pxDefaultSize={ toggleProps.as ? undefined : true }\n\t\t\ticon={ plus }\n\t\t\tlabel={ label }\n\t\t\ttooltipPosition=\"bottom\"\n\t\t\tonClick={ handleClick }\n\t\t\tclassName=\"block-editor-inserter__toggle\"\n\t\t\taria-haspopup={ ! hasSingleBlockType ? 'true' : false }\n\t\t\taria-expanded={ ! hasSingleBlockType ? isOpen : false }\n\t\t\tisPressed={ ! hasSingleBlockType && isOpen }\n\t\t\tdisabled={ disabled }\n\t\t\t{ ...rest }\n\t\t/>\n\t);\n};\n\nconst InserterToggle = forwardRef( UnforwardedInserterToggle );\n\nconst UnforwardedInserter = (\n\t{\n\t\tclientId,\n\t\trootClientId,\n\t\tdisabled,\n\t\tisAppender,\n\t\tposition,\n\t\tselectBlockOnInsert,\n\t\tshouldDirectInsert = true,\n\t\tshowInserterHelpPanel,\n\t\t// This prop is experimental to give some time for the quick inserter to mature\n\t\t// Feel free to make them stable after a few releases.\n\t\t__experimentalIsQuick: isQuick,\n\t\tonSelectOrClose,\n\t\tonToggle,\n\t\trenderToggle: renderToggleProp,\n\t\ttoggleProps,\n\t},\n\tref\n) => {\n\tconst {\n\t\thasItems,\n\t\thasSingleBlockType,\n\t\tblockTitle,\n\t\tallowedBlockType,\n\t\tblockToInsert,\n\t\tappenderLabel,\n\t\ttargetRootClientId,\n\t} = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tgetBlockRootClientId,\n\t\t\t\thasInserterItems,\n\t\t\t\tgetAllowedBlocks,\n\t\t\t\tgetDirectInsertBlock,\n\t\t\t\tgetBlockListSettings,\n\t\t\t} = select( blockEditorStore );\n\t\t\tconst { getBlockVariations, getBlockType } = select( blocksStore );\n\n\t\t\tconst _targetRootClientId =\n\t\t\t\trootClientId || getBlockRootClientId( clientId ) || undefined;\n\n\t\t\tconst allowedBlocks = getAllowedBlocks( _targetRootClientId );\n\t\t\tconst directInsertBlock =\n\t\t\t\tshouldDirectInsert &&\n\t\t\t\tgetDirectInsertBlock( _targetRootClientId );\n\t\t\tconst { defaultBlock } =\n\t\t\t\tgetBlockListSettings( _targetRootClientId ) ?? {};\n\n\t\t\tconst _hasSingleBlockType =\n\t\t\t\tallowedBlocks?.length === 1 &&\n\t\t\t\tgetBlockVariations( allowedBlocks[ 0 ].name, 'inserter' )\n\t\t\t\t\t?.length === 0;\n\t\t\tconst _allowedBlockType = _hasSingleBlockType\n\t\t\t\t? allowedBlocks[ 0 ]\n\t\t\t\t: null;\n\n\t\t\t// Single-block-type parents get adjacent-attribute copying\n\t\t\t// without needing to set `directInsert: true`.\n\t\t\tlet _blockToInsert = directInsertBlock || null;\n\t\t\tif (\n\t\t\t\t! _blockToInsert &&\n\t\t\t\t_hasSingleBlockType &&\n\t\t\t\tdefaultBlock?.name === _allowedBlockType.name\n\t\t\t) {\n\t\t\t\t_blockToInsert = defaultBlock;\n\t\t\t}\n\n\t\t\tconst defaultBlockType = directInsertBlock\n\t\t\t\t? getBlockType( directInsertBlock.name )\n\t\t\t\t: null;\n\t\t\treturn {\n\t\t\t\thasItems: hasInserterItems( _targetRootClientId ),\n\t\t\t\thasSingleBlockType: _hasSingleBlockType,\n\t\t\t\tblockTitle: _allowedBlockType ? _allowedBlockType.title : '',\n\t\t\t\tallowedBlockType: _allowedBlockType,\n\t\t\t\tblockToInsert: _blockToInsert,\n\t\t\t\tappenderLabel: getAppenderLabel(\n\t\t\t\t\tdirectInsertBlock,\n\t\t\t\t\tdefaultBlockType\n\t\t\t\t),\n\t\t\t\ttargetRootClientId: _targetRootClientId,\n\t\t\t};\n\t\t},\n\t\t[ rootClientId, clientId, shouldDirectInsert ]\n\t);\n\n\tconst { insertBlock } = useDispatch( blockEditorStore );\n\tconst {\n\t\tgetBlock,\n\t\tgetBlockIndex,\n\t\tgetBlockOrder,\n\t\tgetBlockRootClientId,\n\t\tgetBlockSelectionEnd,\n\t\tgetPreviousBlockClientId,\n\t} = useSelect( blockEditorStore );\n\tconst { getActiveBlockVariation, getBlockType } = useSelect( blocksStore );\n\n\t// The global inserter (no isAppender, no rootClientId, no clientId) should\n\t// always render, even with no items.\n\tif ( ! hasItems && ( isAppender || targetRootClientId || clientId ) ) {\n\t\treturn null;\n\t}\n\n\tfunction insertOnlyAllowedBlock() {\n\t\tconst blockName = blockToInsert?.name ?? allowedBlockType.name;\n\n\t\tfunction getAdjacentBlockAttributes( attributesToCopy ) {\n\t\t\tif ( ! attributesToCopy?.length ) {\n\t\t\t\treturn {};\n\t\t\t}\n\n\t\t\t// Find the adjacent block of the same type whose attributes\n\t\t\t// should be copied: previous sibling when inserting next to\n\t\t\t// an existing block, otherwise the last child of the root.\n\t\t\tlet adjacentAttributes;\n\t\t\tif ( clientId ) {\n\t\t\t\tconst currentBlock = getBlock( clientId );\n\t\t\t\tconst previousBlock = getBlock(\n\t\t\t\t\tgetPreviousBlockClientId( clientId )\n\t\t\t\t);\n\t\t\t\tif ( currentBlock?.name === previousBlock?.name ) {\n\t\t\t\t\tadjacentAttributes = previousBlock?.attributes;\n\t\t\t\t}\n\t\t\t} else if ( targetRootClientId ) {\n\t\t\t\tconst lastInnerBlock =\n\t\t\t\t\tgetBlock( targetRootClientId )?.innerBlocks?.at( -1 );\n\t\t\t\tif ( lastInnerBlock?.name === blockName ) {\n\t\t\t\t\tadjacentAttributes = lastInnerBlock.attributes;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif ( ! adjacentAttributes ) {\n\t\t\t\treturn {};\n\t\t\t}\n\n\t\t\treturn Object.fromEntries(\n\t\t\t\tattributesToCopy\n\t\t\t\t\t.filter( ( attr ) => attr in adjacentAttributes )\n\t\t\t\t\t.map( ( attr ) => [ attr, adjacentAttributes[ attr ] ] )\n\t\t\t);\n\t\t}\n\n\t\tfunction getInsertionIndex() {\n\t\t\t// If the clientId is defined, we insert at the position of the block.\n\t\t\tif ( clientId ) {\n\t\t\t\treturn getBlockIndex( clientId );\n\t\t\t}\n\n\t\t\t// If there a selected block, we insert after the selected block.\n\t\t\tconst end = getBlockSelectionEnd();\n\t\t\tif (\n\t\t\t\t! isAppender &&\n\t\t\t\tend &&\n\t\t\t\tgetBlockRootClientId( end ) === targetRootClientId\n\t\t\t) {\n\t\t\t\treturn getBlockIndex( end ) + 1;\n\t\t\t}\n\n\t\t\t// Otherwise, we insert at the end of the current rootClientId.\n\t\t\treturn getBlockOrder( targetRootClientId ).length;\n\t\t}\n\n\t\t// Attempt to augment the inserted block with attributes from an adjacent block.\n\t\t// This ensures styling from nearby blocks is preserved in the newly inserted block.\n\t\t// See: https://github.com/WordPress/gutenberg/issues/37904\n\t\tconst newAttributes = getAdjacentBlockAttributes(\n\t\t\tblockToInsert?.attributesToCopy\n\t\t);\n\n\t\tconst newBlock = createBlock( blockName, {\n\t\t\t...blockToInsert?.attributes,\n\t\t\t...newAttributes,\n\t\t} );\n\n\t\tinsertBlock(\n\t\t\tnewBlock,\n\t\t\tgetInsertionIndex(),\n\t\t\ttargetRootClientId,\n\t\t\tselectBlockOnInsert\n\t\t);\n\n\t\tonSelectOrClose?.( newBlock );\n\n\t\tconst blockTypeToInsert = getBlockType( blockName );\n\t\tlet blockLabelToInsert;\n\t\tif ( blockTypeToInsert ) {\n\t\t\tblockLabelToInsert = getBlockLabel(\n\t\t\t\tblockTypeToInsert,\n\t\t\t\tnewBlock.attributes\n\t\t\t);\n\n\t\t\tif ( blockLabelToInsert === blockTypeToInsert.title ) {\n\t\t\t\tblockLabelToInsert =\n\t\t\t\t\tgetActiveBlockVariation( blockName, newBlock.attributes )\n\t\t\t\t\t\t?.title || blockLabelToInsert;\n\t\t\t}\n\t\t}\n\n\t\tif ( blockLabelToInsert ) {\n\t\t\tconst message = sprintf(\n\t\t\t\t// translators: %s: the name of the block that has been added\n\t\t\t\t__( '%s block added' ),\n\t\t\t\tblockLabelToInsert\n\t\t\t);\n\t\t\tspeak( message );\n\t\t}\n\t}\n\n\tfunction renderToggle( { onToggle: dropdownOnToggle, isOpen } ) {\n\t\tconst toggleArgs = {\n\t\t\tonToggle: dropdownOnToggle,\n\t\t\tisOpen,\n\t\t\tdisabled: disabled || ! hasItems,\n\t\t\tblockTitle,\n\t\t\thasSingleBlockType,\n\t\t\tappenderLabel,\n\t\t\ttoggleProps,\n\t\t};\n\n\t\tif ( renderToggleProp ) {\n\t\t\treturn renderToggleProp( toggleArgs );\n\t\t}\n\n\t\treturn <InserterToggle ref={ ref } { ...toggleArgs } />;\n\t}\n\n\tfunction renderContent( { onClose } ) {\n\t\tif ( isQuick ) {\n\t\t\treturn (\n\t\t\t\t<QuickInserter\n\t\t\t\t\tonSelect={ ( blocks ) => {\n\t\t\t\t\t\tconst firstBlock =\n\t\t\t\t\t\t\tArray.isArray( blocks ) && blocks?.length\n\t\t\t\t\t\t\t\t? blocks[ 0 ]\n\t\t\t\t\t\t\t\t: blocks;\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\tonSelectOrClose &&\n\t\t\t\t\t\t\ttypeof onSelectOrClose === 'function'\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\tonSelectOrClose( firstBlock );\n\t\t\t\t\t\t}\n\t\t\t\t\t\tonClose();\n\t\t\t\t\t} }\n\t\t\t\t\trootClientId={ targetRootClientId }\n\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\tisAppender={ isAppender }\n\t\t\t\t\tselectBlockOnInsert={ selectBlockOnInsert }\n\t\t\t\t/>\n\t\t\t);\n\t\t}\n\n\t\treturn (\n\t\t\t<InserterMenu\n\t\t\t\tonSelect={ () => {\n\t\t\t\t\tonClose();\n\t\t\t\t} }\n\t\t\t\tonClose={ onClose }\n\t\t\t\trootClientId={ targetRootClientId }\n\t\t\t\tclientId={ clientId }\n\t\t\t\tisAppender={ isAppender }\n\t\t\t\tshowInserterHelpPanel={ showInserterHelpPanel }\n\t\t\t/>\n\t\t);\n\t}\n\n\tif ( hasSingleBlockType || blockToInsert ) {\n\t\treturn renderToggle( { onToggle: insertOnlyAllowedBlock } );\n\t}\n\n\treturn (\n\t\t<Dropdown\n\t\t\tclassName=\"block-editor-inserter\"\n\t\t\tcontentClassName={ clsx( 'block-editor-inserter__popover', {\n\t\t\t\t'is-quick': isQuick,\n\t\t\t} ) }\n\t\t\tpopoverProps={ { position, shift: true } }\n\t\t\tonToggle={ onToggle }\n\t\t\texpandOnMobile\n\t\t\theaderTitle={ __( 'Add a block' ) }\n\t\t\trenderToggle={ renderToggle }\n\t\t\trenderContent={ renderContent }\n\t\t\tonClose={ onSelectOrClose }\n\t\t/>\n\t);\n};\n\nconst Inserter = forwardRef( UnforwardedInserter );\n\nexport default Inserter;\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAAiB;AAKjB,kBAAsB;AACtB,kBAAgC;AAChC,wBAAiC;AACjC,kBAAuC;AACvC,oBAIO;AACP,qBAA2B;AAC3B,mBAAqB;AAKrB,kBAAyB;AACzB,4BAA0B;AAC1B,mBAA0C;AAC1C,gCAAiC;AA8C/B;AA5CF,IAAM,4BAA4B,CACjC;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,cAAc,CAAC;AAChB,GACA,QACI;AACJ,QAAM;AAAA,IACL,IAAI,UAAU;AAAA,IACd,OAAO;AAAA,IACP;AAAA,IACA,GAAG;AAAA,EACJ,IAAI;AAEJ,MAAI,QAAQ;AACZ,MAAK,CAAE,SAAS,eAAgB;AAE/B,YAAQ;AAAA,EACT,WAAY,CAAE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AO,KAAK;AAAA,MACvC;AAAA,MACA,gBAAc;AAAA,MACd,iBAAc,gBAAI,aAAc;AAAA,MAChC;AAAA,MACA;AAAA,MACA,SAAU;AAAA;AAAA,EACX;AAEF;AAEA,IAAM,eAAW,2BAAY,mBAAoB;AAEjD,IAAO,mBAAQ;",
|
|
6
|
+
"names": ["getBlockRootClientId", "blockEditorStore", "getBlockType", "blocksStore", "getBlockLabel", "QuickInserter", "InserterMenu", "clsx"]
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/components/inserter/media-tab/media-preview.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tDropdownMenu,\n\tMenuGroup,\n\tMenuItem,\n\tSpinner,\n\tModal,\n\tFlex,\n\tFlexItem,\n\tButton,\n\tComposite,\n\t__experimentalVStack as VStack,\n} from '@wordpress/components';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { useMemo, useCallback, useState } from '@wordpress/element';\nimport { cloneBlock } from '@wordpress/blocks';\nimport { moreVertical, external } from '@wordpress/icons';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { store as noticesStore } from '@wordpress/notices';\nimport { isBlobURL } from '@wordpress/blob';\nimport { getFilename } from '@wordpress/url';\n\n// eslint-disable-next-line @wordpress/use-recommended-components -- `Tooltip` is not yet on the recommended `@wordpress/ui` allow-list; landing as a migration step ahead of the wider rollout.\nimport { Tooltip } from '@wordpress/ui';\n\n/**\n * Internal dependencies\n */\nimport InserterDraggableBlocks from '../../inserter-draggable-blocks';\nimport { getBlockAndPreviewFromMedia } from './utils';\nimport { store as blockEditorStore } from '../../../store';\n\nconst ALLOWED_MEDIA_TYPES = [ 'image' ];\nconst MEDIA_OPTIONS_POPOVER_PROPS = {\n\tplacement: 'bottom-end',\n\tclassName:\n\t\t'block-editor-inserter__media-list__item-preview-options__popover',\n};\n\nfunction MediaPreviewOptions( { category, media } ) {\n\tif ( ! category.getReportUrl ) {\n\t\treturn null;\n\t}\n\tconst reportUrl = category.getReportUrl( media );\n\treturn (\n\t\t<DropdownMenu\n\t\t\tclassName=\"block-editor-inserter__media-list__item-preview-options\"\n\t\t\tlabel={ __( 'Options' ) }\n\t\t\tpopoverProps={ MEDIA_OPTIONS_POPOVER_PROPS }\n\t\t\ticon={ moreVertical }\n\t\t>\n\t\t\t{ () => (\n\t\t\t\t<MenuGroup>\n\t\t\t\t\t<MenuItem\n\t\t\t\t\t\tonClick={ () =>\n\t\t\t\t\t\t\twindow.open( reportUrl, '_blank' ).focus()\n\t\t\t\t\t\t}\n\t\t\t\t\t\ticon={ external }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ sprintf(\n\t\t\t\t\t\t\t/* translators: %s: The media type to report e.g: \"image\", \"video\", \"audio\" */\n\t\t\t\t\t\t\t__( 'Report %s' ),\n\t\t\t\t\t\t\tcategory.mediaType\n\t\t\t\t\t\t) }\n\t\t\t\t\t</MenuItem>\n\t\t\t\t</MenuGroup>\n\t\t\t) }\n\t\t</DropdownMenu>\n\t);\n}\n\nfunction InsertExternalImageModal( { onClose, onSubmit } ) {\n\treturn (\n\t\t<Modal\n\t\t\ttitle={ __( 'Insert external image' ) }\n\t\t\tonRequestClose={ onClose }\n\t\t\tclassName=\"block-editor-inserter-media-tab-media-preview-inserter-external-image-modal\"\n\t\t>\n\t\t\t<VStack spacing={ 3 }>\n\t\t\t\t<p>\n\t\t\t\t\t{ __(\n\t\t\t\t\t\t'This image cannot be uploaded to your Media Library, but it can still be inserted as an external image.'\n\t\t\t\t\t) }\n\t\t\t\t</p>\n\t\t\t\t<p>\n\t\t\t\t\t{ __(\n\t\t\t\t\t\t'External images can be removed by the external provider without warning and could even have legal compliance issues related to privacy legislation.'\n\t\t\t\t\t) }\n\t\t\t\t</p>\n\t\t\t</VStack>\n\t\t\t<Flex\n\t\t\t\tclassName=\"block-editor-block-lock-modal__actions\"\n\t\t\t\tjustify=\"flex-end\"\n\t\t\t\texpanded={ false }\n\t\t\t>\n\t\t\t\t<FlexItem>\n\t\t\t\t\t<Button\n\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\tvariant=\"tertiary\"\n\t\t\t\t\t\tonClick={ onClose }\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</FlexItem>\n\t\t\t\t<FlexItem>\n\t\t\t\t\t<Button\n\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\t\tonClick={ onSubmit }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Insert' ) }\n\t\t\t\t\t</Button>\n\t\t\t\t</FlexItem>\n\t\t\t</Flex>\n\t\t</Modal>\n\t);\n}\n\nexport function MediaPreview( { media, onClick, category } ) {\n\tconst [ showExternalUploadModal, setShowExternalUploadModal ] =\n\t\tuseState( false );\n\tconst [ isHovered, setIsHovered ] = useState( false );\n\tconst [ isInserting, setIsInserting ] = useState( false );\n\tconst [ block, preview ] = useMemo(\n\t\t() => getBlockAndPreviewFromMedia( media, category.mediaType ),\n\t\t[ media, category.mediaType ]\n\t);\n\tconst { createErrorNotice, createSuccessNotice } =\n\t\tuseDispatch( noticesStore );\n\tconst { getSettings, getBlock } = useSelect( blockEditorStore );\n\tconst { updateBlockAttributes } = useDispatch( blockEditorStore );\n\n\tconst onMediaInsert = useCallback(\n\t\t( previewBlock ) => {\n\t\t\t// Prevent multiple uploads when we're in the process of inserting.\n\t\t\tif ( isInserting ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst settings = getSettings();\n\t\t\tconst clonedBlock = cloneBlock( previewBlock );\n\t\t\tconst { id, url, caption } = clonedBlock.attributes;\n\n\t\t\t// User has no permission to upload media.\n\t\t\tif ( ! id && ! settings.mediaUpload ) {\n\t\t\t\tsetShowExternalUploadModal( true );\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// Media item already exists in library, so just insert it.\n\t\t\tif ( !! id ) {\n\t\t\t\tonClick( clonedBlock );\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tsetIsInserting( true );\n\t\t\t// Media item does not exist in library, so try to upload it.\n\t\t\t// Fist fetch the image data. This may fail if the image host\n\t\t\t// doesn't allow CORS with the domain.\n\t\t\t// If this happens, we insert the image block using the external\n\t\t\t// URL and let the user know about the possible implications.\n\t\t\twindow\n\t\t\t\t.fetch( url )\n\t\t\t\t.then( ( response ) => response.blob() )\n\t\t\t\t.then( ( blob ) => {\n\t\t\t\t\tconst fileName = getFilename( url ) || 'image.jpg';\n\t\t\t\t\tconst file = new File( [ blob ], fileName, {\n\t\t\t\t\t\ttype: blob.type,\n\t\t\t\t\t} );\n\n\t\t\t\t\tsettings.mediaUpload( {\n\t\t\t\t\t\tfilesList: [ file ],\n\t\t\t\t\t\tadditionalData: { caption },\n\t\t\t\t\t\tonFileChange( [ img ] ) {\n\t\t\t\t\t\t\tif ( isBlobURL( img.url ) ) {\n\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tif ( ! getBlock( clonedBlock.clientId ) ) {\n\t\t\t\t\t\t\t\t// Ensure the block is only inserted once.\n\t\t\t\t\t\t\t\tonClick( {\n\t\t\t\t\t\t\t\t\t...clonedBlock,\n\t\t\t\t\t\t\t\t\tattributes: {\n\t\t\t\t\t\t\t\t\t\t...clonedBlock.attributes,\n\t\t\t\t\t\t\t\t\t\tid: img.id,\n\t\t\t\t\t\t\t\t\t\turl: img.url,\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t} );\n\n\t\t\t\t\t\t\t\tcreateSuccessNotice(\n\t\t\t\t\t\t\t\t\t__( 'Image uploaded and inserted.' ),\n\t\t\t\t\t\t\t\t\t{ type: 'snackbar', id: 'inserter-notice' }\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t// For subsequent calls, update the existing block.\n\t\t\t\t\t\t\t\tupdateBlockAttributes( clonedBlock.clientId, {\n\t\t\t\t\t\t\t\t\t...clonedBlock.attributes,\n\t\t\t\t\t\t\t\t\tid: img.id,\n\t\t\t\t\t\t\t\t\turl: img.url,\n\t\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tsetIsInserting( false );\n\t\t\t\t\t\t},\n\t\t\t\t\t\tallowedTypes: ALLOWED_MEDIA_TYPES,\n\t\t\t\t\t\tonError( message ) {\n\t\t\t\t\t\t\tcreateErrorNotice( message, {\n\t\t\t\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t\t\t\t\tid: 'inserter-notice',\n\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\tsetIsInserting( false );\n\t\t\t\t\t\t},\n\t\t\t\t\t} );\n\t\t\t\t} )\n\t\t\t\t.catch( () => {\n\t\t\t\t\tsetShowExternalUploadModal( true );\n\t\t\t\t\tsetIsInserting( false );\n\t\t\t\t} );\n\t\t},\n\t\t[\n\t\t\tisInserting,\n\t\t\tgetSettings,\n\t\t\tonClick,\n\t\t\tcreateSuccessNotice,\n\t\t\tupdateBlockAttributes,\n\t\t\tcreateErrorNotice,\n\t\t\tgetBlock,\n\t\t]\n\t);\n\n\tconst title =\n\t\ttypeof media.title === 'string'\n\t\t\t? media.title\n\t\t\t: media.title?.rendered || __( 'no title' );\n\n\tconst onMouseEnter = useCallback( () => setIsHovered( true ), [] );\n\tconst onMouseLeave = useCallback( () => setIsHovered( false ), [] );\n\treturn (\n\t\t<>\n\t\t\t<InserterDraggableBlocks isEnabled blocks={ [ block ] }>\n\t\t\t\t{ ( { draggable, onDragStart, onDragEnd } ) => (\n\t\t\t\t\t<div\n\t\t\t\t\t\tclassName={ clsx(\n\t\t\t\t\t\t\t'block-editor-inserter__media-list__list-item',\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t'is-hovered': isHovered,\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t) }\n\t\t\t\t\t\tdraggable={ draggable }\n\t\t\t\t\t\tonDragStart={ onDragStart }\n\t\t\t\t\t\tonDragEnd={ onDragEnd }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ /* Adding `is-hovered` class to the wrapper element is needed\n\t\t\t\t\t\tbecause the options Popover is rendered outside of this node. */ }\n\t\t\t\t\t\t<div\n\t\t\t\t\t\t\tonMouseEnter={ onMouseEnter }\n\t\t\t\t\t\t\tonMouseLeave={ onMouseLeave }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<Tooltip.Root>\n\t\t\t\t\t\t\t\t<Tooltip.Trigger\n\t\t\t\t\t\t\t\t\trender={\n\t\t\t\t\t\t\t\t\t\t<Composite.Item\n\t\t\t\t\t\t\t\t\t\t\trender={\n\t\t\t\t\t\t\t\t\t\t\t\t<div\n\t\t\t\t\t\t\t\t\t\t\t\t\taria-label={ title }\n\t\t\t\t\t\t\t\t\t\t\t\t\trole=\"option\"\n\t\t\t\t\t\t\t\t\t\t\t\t\tclassName=\"block-editor-inserter__media-list__item\"\n\t\t\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\tonClick={ () =>\n\t\t\t\t\t\t\t\t\t\t\t\tonMediaInsert( block )\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t<div className=\"block-editor-inserter__media-list__item-preview\">\n\t\t\t\t\t\t\t\t\t\t\t\t{ preview }\n\t\t\t\t\t\t\t\t\t\t\t\t{ isInserting && (\n\t\t\t\t\t\t\t\t\t\t\t\t\t<div className=\"block-editor-inserter__media-list__item-preview-spinner\">\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t<Spinner />\n\t\t\t\t\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t\t\t</Composite.Item>\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t<Tooltip.Popup>{ title }</Tooltip.Popup>\n\t\t\t\t\t\t\t</Tooltip.Root>\n\t\t\t\t\t\t\t{ ! isInserting && (\n\t\t\t\t\t\t\t\t<MediaPreviewOptions\n\t\t\t\t\t\t\t\t\tcategory={ category }\n\t\t\t\t\t\t\t\t\tmedia={ media }\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</div>\n\t\t\t\t\t</div>\n\t\t\t\t) }\n\t\t\t</InserterDraggableBlocks>\n\t\t\t{ showExternalUploadModal && (\n\t\t\t\t<InsertExternalImageModal\n\t\t\t\t\tonClose={ () => setShowExternalUploadModal( false ) }\n\t\t\t\t\tonSubmit={ () => {\n\t\t\t\t\t\tonClick( cloneBlock( block ) );\n\t\t\t\t\t\tcreateSuccessNotice( __( 'Image inserted.' ), {\n\t\t\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t\t\t\tid: 'inserter-notice',\n\t\t\t\t\t\t} );\n\t\t\t\t\t\tsetShowExternalUploadModal( false );\n\t\t\t\t\t} }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</>\n\t);\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAAiB;AAKjB,wBAWO;AACP,kBAA4B;AAC5B,qBAA+C;AAC/C,oBAA2B;AAC3B,mBAAuC;AACvC,kBAAuC;AACvC,qBAAsC;AACtC,kBAA0B;AAC1B,iBAA4B;
|
|
4
|
+
"sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tDropdownMenu,\n\tMenuGroup,\n\tMenuItem,\n\tSpinner,\n\tModal,\n\tFlex,\n\tFlexItem,\n\tButton,\n\tComposite,\n\t__experimentalVStack as VStack,\n} from '@wordpress/components';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { useMemo, useCallback, useState } from '@wordpress/element';\nimport { cloneBlock } from '@wordpress/blocks';\nimport { moreVertical, external } from '@wordpress/icons';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { store as noticesStore } from '@wordpress/notices';\nimport { isBlobURL } from '@wordpress/blob';\nimport { getFilename } from '@wordpress/url';\n\nimport { Tooltip } from '@wordpress/ui';\n\n/**\n * Internal dependencies\n */\nimport InserterDraggableBlocks from '../../inserter-draggable-blocks';\nimport { getBlockAndPreviewFromMedia } from './utils';\nimport { store as blockEditorStore } from '../../../store';\n\nconst ALLOWED_MEDIA_TYPES = [ 'image' ];\nconst MEDIA_OPTIONS_POPOVER_PROPS = {\n\tplacement: 'bottom-end',\n\tclassName:\n\t\t'block-editor-inserter__media-list__item-preview-options__popover',\n};\n\nfunction MediaPreviewOptions( { category, media } ) {\n\tif ( ! category.getReportUrl ) {\n\t\treturn null;\n\t}\n\tconst reportUrl = category.getReportUrl( media );\n\treturn (\n\t\t<DropdownMenu\n\t\t\tclassName=\"block-editor-inserter__media-list__item-preview-options\"\n\t\t\tlabel={ __( 'Options' ) }\n\t\t\tpopoverProps={ MEDIA_OPTIONS_POPOVER_PROPS }\n\t\t\ticon={ moreVertical }\n\t\t>\n\t\t\t{ () => (\n\t\t\t\t<MenuGroup>\n\t\t\t\t\t<MenuItem\n\t\t\t\t\t\tonClick={ () =>\n\t\t\t\t\t\t\twindow.open( reportUrl, '_blank' ).focus()\n\t\t\t\t\t\t}\n\t\t\t\t\t\ticon={ external }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ sprintf(\n\t\t\t\t\t\t\t/* translators: %s: The media type to report e.g: \"image\", \"video\", \"audio\" */\n\t\t\t\t\t\t\t__( 'Report %s' ),\n\t\t\t\t\t\t\tcategory.mediaType\n\t\t\t\t\t\t) }\n\t\t\t\t\t</MenuItem>\n\t\t\t\t</MenuGroup>\n\t\t\t) }\n\t\t</DropdownMenu>\n\t);\n}\n\nfunction InsertExternalImageModal( { onClose, onSubmit } ) {\n\treturn (\n\t\t<Modal\n\t\t\ttitle={ __( 'Insert external image' ) }\n\t\t\tonRequestClose={ onClose }\n\t\t\tclassName=\"block-editor-inserter-media-tab-media-preview-inserter-external-image-modal\"\n\t\t>\n\t\t\t<VStack spacing={ 3 }>\n\t\t\t\t<p>\n\t\t\t\t\t{ __(\n\t\t\t\t\t\t'This image cannot be uploaded to your Media Library, but it can still be inserted as an external image.'\n\t\t\t\t\t) }\n\t\t\t\t</p>\n\t\t\t\t<p>\n\t\t\t\t\t{ __(\n\t\t\t\t\t\t'External images can be removed by the external provider without warning and could even have legal compliance issues related to privacy legislation.'\n\t\t\t\t\t) }\n\t\t\t\t</p>\n\t\t\t</VStack>\n\t\t\t<Flex\n\t\t\t\tclassName=\"block-editor-block-lock-modal__actions\"\n\t\t\t\tjustify=\"flex-end\"\n\t\t\t\texpanded={ false }\n\t\t\t>\n\t\t\t\t<FlexItem>\n\t\t\t\t\t<Button\n\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\tvariant=\"tertiary\"\n\t\t\t\t\t\tonClick={ onClose }\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</FlexItem>\n\t\t\t\t<FlexItem>\n\t\t\t\t\t<Button\n\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\t\tonClick={ onSubmit }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Insert' ) }\n\t\t\t\t\t</Button>\n\t\t\t\t</FlexItem>\n\t\t\t</Flex>\n\t\t</Modal>\n\t);\n}\n\nexport function MediaPreview( { media, onClick, category } ) {\n\tconst [ showExternalUploadModal, setShowExternalUploadModal ] =\n\t\tuseState( false );\n\tconst [ isHovered, setIsHovered ] = useState( false );\n\tconst [ isInserting, setIsInserting ] = useState( false );\n\tconst [ block, preview ] = useMemo(\n\t\t() => getBlockAndPreviewFromMedia( media, category.mediaType ),\n\t\t[ media, category.mediaType ]\n\t);\n\tconst { createErrorNotice, createSuccessNotice } =\n\t\tuseDispatch( noticesStore );\n\tconst { getSettings, getBlock } = useSelect( blockEditorStore );\n\tconst { updateBlockAttributes } = useDispatch( blockEditorStore );\n\n\tconst onMediaInsert = useCallback(\n\t\t( previewBlock ) => {\n\t\t\t// Prevent multiple uploads when we're in the process of inserting.\n\t\t\tif ( isInserting ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst settings = getSettings();\n\t\t\tconst clonedBlock = cloneBlock( previewBlock );\n\t\t\tconst { id, url, caption } = clonedBlock.attributes;\n\n\t\t\t// User has no permission to upload media.\n\t\t\tif ( ! id && ! settings.mediaUpload ) {\n\t\t\t\tsetShowExternalUploadModal( true );\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// Media item already exists in library, so just insert it.\n\t\t\tif ( !! id ) {\n\t\t\t\tonClick( clonedBlock );\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tsetIsInserting( true );\n\t\t\t// Media item does not exist in library, so try to upload it.\n\t\t\t// Fist fetch the image data. This may fail if the image host\n\t\t\t// doesn't allow CORS with the domain.\n\t\t\t// If this happens, we insert the image block using the external\n\t\t\t// URL and let the user know about the possible implications.\n\t\t\twindow\n\t\t\t\t.fetch( url )\n\t\t\t\t.then( ( response ) => response.blob() )\n\t\t\t\t.then( ( blob ) => {\n\t\t\t\t\tconst fileName = getFilename( url ) || 'image.jpg';\n\t\t\t\t\tconst file = new File( [ blob ], fileName, {\n\t\t\t\t\t\ttype: blob.type,\n\t\t\t\t\t} );\n\n\t\t\t\t\tsettings.mediaUpload( {\n\t\t\t\t\t\tfilesList: [ file ],\n\t\t\t\t\t\tadditionalData: { caption },\n\t\t\t\t\t\tonFileChange( [ img ] ) {\n\t\t\t\t\t\t\tif ( isBlobURL( img.url ) ) {\n\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tif ( ! getBlock( clonedBlock.clientId ) ) {\n\t\t\t\t\t\t\t\t// Ensure the block is only inserted once.\n\t\t\t\t\t\t\t\tonClick( {\n\t\t\t\t\t\t\t\t\t...clonedBlock,\n\t\t\t\t\t\t\t\t\tattributes: {\n\t\t\t\t\t\t\t\t\t\t...clonedBlock.attributes,\n\t\t\t\t\t\t\t\t\t\tid: img.id,\n\t\t\t\t\t\t\t\t\t\turl: img.url,\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t} );\n\n\t\t\t\t\t\t\t\tcreateSuccessNotice(\n\t\t\t\t\t\t\t\t\t__( 'Image uploaded and inserted.' ),\n\t\t\t\t\t\t\t\t\t{ type: 'snackbar', id: 'inserter-notice' }\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t// For subsequent calls, update the existing block.\n\t\t\t\t\t\t\t\tupdateBlockAttributes( clonedBlock.clientId, {\n\t\t\t\t\t\t\t\t\t...clonedBlock.attributes,\n\t\t\t\t\t\t\t\t\tid: img.id,\n\t\t\t\t\t\t\t\t\turl: img.url,\n\t\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tsetIsInserting( false );\n\t\t\t\t\t\t},\n\t\t\t\t\t\tallowedTypes: ALLOWED_MEDIA_TYPES,\n\t\t\t\t\t\tonError( message ) {\n\t\t\t\t\t\t\tcreateErrorNotice( message, {\n\t\t\t\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t\t\t\t\tid: 'inserter-notice',\n\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\tsetIsInserting( false );\n\t\t\t\t\t\t},\n\t\t\t\t\t} );\n\t\t\t\t} )\n\t\t\t\t.catch( () => {\n\t\t\t\t\tsetShowExternalUploadModal( true );\n\t\t\t\t\tsetIsInserting( false );\n\t\t\t\t} );\n\t\t},\n\t\t[\n\t\t\tisInserting,\n\t\t\tgetSettings,\n\t\t\tonClick,\n\t\t\tcreateSuccessNotice,\n\t\t\tupdateBlockAttributes,\n\t\t\tcreateErrorNotice,\n\t\t\tgetBlock,\n\t\t]\n\t);\n\n\tconst title =\n\t\ttypeof media.title === 'string'\n\t\t\t? media.title\n\t\t\t: media.title?.rendered || __( 'no title' );\n\n\tconst onMouseEnter = useCallback( () => setIsHovered( true ), [] );\n\tconst onMouseLeave = useCallback( () => setIsHovered( false ), [] );\n\treturn (\n\t\t<>\n\t\t\t<InserterDraggableBlocks isEnabled blocks={ [ block ] }>\n\t\t\t\t{ ( { draggable, onDragStart, onDragEnd } ) => (\n\t\t\t\t\t<div\n\t\t\t\t\t\tclassName={ clsx(\n\t\t\t\t\t\t\t'block-editor-inserter__media-list__list-item',\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t'is-hovered': isHovered,\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t) }\n\t\t\t\t\t\tdraggable={ draggable }\n\t\t\t\t\t\tonDragStart={ onDragStart }\n\t\t\t\t\t\tonDragEnd={ onDragEnd }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ /* Adding `is-hovered` class to the wrapper element is needed\n\t\t\t\t\t\tbecause the options Popover is rendered outside of this node. */ }\n\t\t\t\t\t\t<div\n\t\t\t\t\t\t\tonMouseEnter={ onMouseEnter }\n\t\t\t\t\t\t\tonMouseLeave={ onMouseLeave }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<Tooltip.Root>\n\t\t\t\t\t\t\t\t<Tooltip.Trigger\n\t\t\t\t\t\t\t\t\trender={\n\t\t\t\t\t\t\t\t\t\t<Composite.Item\n\t\t\t\t\t\t\t\t\t\t\trender={\n\t\t\t\t\t\t\t\t\t\t\t\t<div\n\t\t\t\t\t\t\t\t\t\t\t\t\taria-label={ title }\n\t\t\t\t\t\t\t\t\t\t\t\t\trole=\"option\"\n\t\t\t\t\t\t\t\t\t\t\t\t\tclassName=\"block-editor-inserter__media-list__item\"\n\t\t\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\tonClick={ () =>\n\t\t\t\t\t\t\t\t\t\t\t\tonMediaInsert( block )\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t<div className=\"block-editor-inserter__media-list__item-preview\">\n\t\t\t\t\t\t\t\t\t\t\t\t{ preview }\n\t\t\t\t\t\t\t\t\t\t\t\t{ isInserting && (\n\t\t\t\t\t\t\t\t\t\t\t\t\t<div className=\"block-editor-inserter__media-list__item-preview-spinner\">\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t<Spinner />\n\t\t\t\t\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t\t\t</Composite.Item>\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t<Tooltip.Popup>{ title }</Tooltip.Popup>\n\t\t\t\t\t\t\t</Tooltip.Root>\n\t\t\t\t\t\t\t{ ! isInserting && (\n\t\t\t\t\t\t\t\t<MediaPreviewOptions\n\t\t\t\t\t\t\t\t\tcategory={ category }\n\t\t\t\t\t\t\t\t\tmedia={ media }\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</div>\n\t\t\t\t\t</div>\n\t\t\t\t) }\n\t\t\t</InserterDraggableBlocks>\n\t\t\t{ showExternalUploadModal && (\n\t\t\t\t<InsertExternalImageModal\n\t\t\t\t\tonClose={ () => setShowExternalUploadModal( false ) }\n\t\t\t\t\tonSubmit={ () => {\n\t\t\t\t\t\tonClick( cloneBlock( block ) );\n\t\t\t\t\t\tcreateSuccessNotice( __( 'Image inserted.' ), {\n\t\t\t\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