@wordpress/block-editor 14.0.0 → 14.2.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 +4 -0
- package/README.md +10 -24
- package/build/autocompleters/block.js +1 -1
- package/build/autocompleters/block.js.map +1 -1
- package/build/components/block-alignment-matrix-control/index.js +2 -2
- package/build/components/block-alignment-matrix-control/index.js.map +1 -1
- package/build/components/block-breadcrumb/index.js +8 -2
- package/build/components/block-breadcrumb/index.js.map +1 -1
- package/build/components/block-canvas/index.js +8 -1
- package/build/components/block-canvas/index.js.map +1 -1
- package/build/components/block-compare/block-view.js +4 -1
- package/build/components/block-compare/block-view.js.map +1 -1
- package/build/components/block-draggable/index.js +4 -4
- package/build/components/block-draggable/index.js.map +1 -1
- package/build/components/block-draggable/use-scroll-when-dragging.js +25 -25
- package/build/components/block-draggable/use-scroll-when-dragging.js.map +1 -1
- package/build/components/block-edit/multiple-usage-warning.js +8 -2
- package/build/components/block-edit/multiple-usage-warning.js.map +1 -1
- package/build/components/block-inspector/index.js +27 -9
- package/build/components/block-inspector/index.js.map +1 -1
- package/build/components/block-list/block-invalid-warning.js +6 -3
- package/build/components/block-list/block-invalid-warning.js.map +1 -1
- package/build/components/block-list/block.js +5 -1
- package/build/components/block-list/block.js.map +1 -1
- package/build/components/block-list/use-block-props/index.js +7 -3
- package/build/components/block-list/use-block-props/index.js.map +1 -1
- package/build/components/block-list/use-block-props/use-focus-first-element.js +1 -0
- package/build/components/block-list/use-block-props/use-focus-first-element.js.map +1 -1
- package/build/components/block-list/use-block-props/use-zoom-out-mode-exit.js +46 -0
- package/build/components/block-list/use-block-props/use-zoom-out-mode-exit.js.map +1 -0
- package/build/components/block-list/use-in-between-inserter.js +11 -4
- package/build/components/block-list/use-in-between-inserter.js.map +1 -1
- package/build/components/block-lock/toolbar.js +3 -3
- package/build/components/block-lock/toolbar.js.map +1 -1
- package/build/components/block-mover/button.js +4 -1
- package/build/components/block-mover/button.js.map +1 -1
- package/build/components/block-mover/index.js +4 -1
- package/build/components/block-mover/index.js.map +1 -1
- package/build/components/block-navigation/dropdown.js +4 -1
- package/build/components/block-navigation/dropdown.js.map +1 -1
- package/build/components/block-pattern-setup/index.js +1 -4
- package/build/components/block-pattern-setup/index.js.map +1 -1
- package/build/components/block-pattern-setup/setup-toolbar.js +22 -7
- package/build/components/block-pattern-setup/setup-toolbar.js.map +1 -1
- package/build/components/block-patterns-list/index.js +11 -14
- package/build/components/block-patterns-list/index.js.map +1 -1
- package/build/components/block-patterns-paging/index.js +12 -3
- package/build/components/block-patterns-paging/index.js.map +1 -1
- package/build/components/block-popover/index.js +2 -15
- package/build/components/block-popover/index.js.map +1 -1
- package/build/components/block-quick-navigation/index.js +4 -1
- package/build/components/block-quick-navigation/index.js.map +1 -1
- package/build/components/block-settings-menu/block-mode-toggle.js +28 -34
- package/build/components/block-settings-menu/block-mode-toggle.js.map +1 -1
- package/build/components/block-settings-menu-controls/index.js +4 -0
- package/build/components/block-settings-menu-controls/index.js.map +1 -1
- package/build/components/block-switcher/index.js +22 -17
- package/build/components/block-switcher/index.js.map +1 -1
- package/build/components/block-switcher/pattern-transformations-menu.js +1 -4
- package/build/components/block-switcher/pattern-transformations-menu.js.map +1 -1
- package/build/components/block-toolbar/index.js +12 -11
- package/build/components/block-toolbar/index.js.map +1 -1
- package/build/components/block-toolbar/shuffle.js +6 -2
- package/build/components/block-toolbar/shuffle.js.map +1 -1
- package/build/components/block-tools/block-selection-button.js +8 -2
- package/build/components/block-tools/block-selection-button.js.map +1 -1
- package/build/components/block-tools/block-toolbar-popover.js +10 -6
- package/build/components/block-tools/block-toolbar-popover.js.map +1 -1
- package/build/components/block-tools/insertion-point.js +14 -3
- package/build/components/block-tools/insertion-point.js.map +1 -1
- package/build/components/block-tools/use-block-toolbar-popover-props.js +2 -1
- package/build/components/block-tools/use-block-toolbar-popover-props.js.map +1 -1
- package/build/components/block-tools/use-show-block-tools.js +2 -1
- package/build/components/block-tools/use-show-block-tools.js.map +1 -1
- package/build/components/block-tools/zoom-out-mode-inserters.js +4 -5
- package/build/components/block-tools/zoom-out-mode-inserters.js.map +1 -1
- package/build/components/block-tools/zoom-out-popover.js +3 -4
- package/build/components/block-tools/zoom-out-popover.js.map +1 -1
- package/build/components/block-tools/zoom-out-toolbar.js +14 -5
- package/build/components/block-tools/zoom-out-toolbar.js.map +1 -1
- package/build/components/block-variation-picker/index.js +4 -1
- package/build/components/block-variation-picker/index.js.map +1 -1
- package/build/components/block-variation-transforms/index.js +4 -1
- package/build/components/block-variation-transforms/index.js.map +1 -1
- package/build/components/border-radius-control/index.js +1 -0
- package/build/components/border-radius-control/index.js.map +1 -1
- package/build/components/button-block-appender/index.js +14 -3
- package/build/components/button-block-appender/index.js.map +1 -1
- package/build/components/colors-gradients/dropdown.js +4 -1
- package/build/components/colors-gradients/dropdown.js.map +1 -1
- package/build/components/content-lock/index.js +13 -0
- package/build/components/content-lock/index.js.map +1 -0
- package/build/components/content-lock/modify-content-lock-menu-item.js +64 -0
- package/build/components/content-lock/modify-content-lock-menu-item.js.map +1 -0
- package/build/components/convert-to-group-buttons/index.js +1 -1
- package/build/components/convert-to-group-buttons/index.js.map +1 -1
- package/build/components/date-format-picker/index.js +2 -0
- package/build/components/date-format-picker/index.js.map +1 -1
- package/build/components/editor-styles/index.js +4 -3
- package/build/components/editor-styles/index.js.map +1 -1
- package/build/components/font-appearance-control/index.js +3 -0
- package/build/components/font-appearance-control/index.js.map +1 -1
- package/build/components/font-family/index.js +3 -0
- package/build/components/font-family/index.js.map +1 -1
- package/build/components/global-styles/background-panel.js +118 -50
- package/build/components/global-styles/background-panel.js.map +1 -1
- package/build/components/global-styles/color-panel.js +8 -5
- package/build/components/global-styles/color-panel.js.map +1 -1
- package/build/components/global-styles/color-panel.native.js +1 -1
- package/build/components/global-styles/color-panel.native.js.map +1 -1
- package/build/components/global-styles/dimensions-panel.js +34 -37
- package/build/components/global-styles/dimensions-panel.js.map +1 -1
- package/build/components/global-styles/filters-panel.js +4 -1
- package/build/components/global-styles/filters-panel.js.map +1 -1
- package/build/components/global-styles/get-global-styles-changes.js +3 -1
- package/build/components/global-styles/get-global-styles-changes.js.map +1 -1
- package/build/components/global-styles/hooks.js +0 -7
- package/build/components/global-styles/hooks.js.map +1 -1
- package/build/components/global-styles/index.js +0 -6
- package/build/components/global-styles/index.js.map +1 -1
- package/build/components/global-styles/shadow-panel-components.js +13 -7
- package/build/components/global-styles/shadow-panel-components.js.map +1 -1
- package/build/components/global-styles/typography-utils.js +17 -6
- package/build/components/global-styles/typography-utils.js.map +1 -1
- package/build/components/global-styles/use-global-styles-output.js +3 -3
- package/build/components/global-styles/use-global-styles-output.js.map +1 -1
- package/build/components/global-styles/utils.js +11 -29
- package/build/components/global-styles/utils.js.map +1 -1
- package/build/components/grid/grid-item-movers.js +2 -2
- package/build/components/grid/grid-item-movers.js.map +1 -1
- package/build/components/grid/grid-visualizer.js +20 -5
- package/build/components/grid/grid-visualizer.js.map +1 -1
- package/build/components/height-control/index.js +1 -0
- package/build/components/height-control/index.js.map +1 -1
- package/build/components/iframe/index.js +8 -6
- package/build/components/iframe/index.js.map +1 -1
- package/build/components/image-editor/zoom-dropdown.js +11 -7
- package/build/components/image-editor/zoom-dropdown.js.map +1 -1
- package/build/components/inner-blocks/button-block-appender.js +8 -8
- package/build/components/inner-blocks/button-block-appender.js.map +1 -1
- package/build/components/inner-blocks/default-block-appender.js +7 -25
- package/build/components/inner-blocks/default-block-appender.js.map +1 -1
- package/build/components/inner-blocks/index.js +8 -12
- package/build/components/inner-blocks/index.js.map +1 -1
- package/build/components/inner-blocks/use-inner-block-template-sync.js +3 -3
- package/build/components/inner-blocks/use-inner-block-template-sync.js.map +1 -1
- package/build/components/inserter/block-patterns-explorer/pattern-explorer-sidebar.js +4 -1
- package/build/components/inserter/block-patterns-explorer/pattern-explorer-sidebar.js.map +1 -1
- package/build/components/inserter/block-patterns-tab/index.js +4 -1
- package/build/components/inserter/block-patterns-tab/index.js.map +1 -1
- package/build/components/inserter/media-tab/hooks.js +3 -3
- package/build/components/inserter/media-tab/hooks.js.map +1 -1
- package/build/components/inserter/media-tab/media-list.js +1 -4
- package/build/components/inserter/media-tab/media-list.js.map +1 -1
- package/build/components/inserter/media-tab/media-preview.js +8 -2
- package/build/components/inserter/media-tab/media-preview.js.map +1 -1
- package/build/components/inserter/media-tab/media-tab.js +4 -1
- package/build/components/inserter/media-tab/media-tab.js.map +1 -1
- package/build/components/inserter/menu.js +14 -13
- package/build/components/inserter/menu.js.map +1 -1
- package/build/components/inserter/quick-inserter.js +8 -1
- package/build/components/inserter/quick-inserter.js.map +1 -1
- package/build/components/inserter-list-item/index.js +4 -4
- package/build/components/inserter-list-item/index.js.map +1 -1
- package/build/components/inserter-listbox/index.js +3 -7
- package/build/components/inserter-listbox/index.js.map +1 -1
- package/build/components/inserter-listbox/item.js +4 -1
- package/build/components/inserter-listbox/item.js.map +1 -1
- package/build/components/inspector-controls/groups.js +2 -0
- package/build/components/inspector-controls/groups.js.map +1 -1
- package/build/components/inspector-controls-tabs/index.js +4 -1
- package/build/components/inspector-controls-tabs/index.js.map +1 -1
- package/build/components/inspector-controls-tabs/settings-tab.js +3 -1
- package/build/components/inspector-controls-tabs/settings-tab.js.map +1 -1
- package/build/components/inspector-controls-tabs/use-inspector-controls-tabs.js +2 -1
- package/build/components/inspector-controls-tabs/use-inspector-controls-tabs.js.map +1 -1
- package/build/components/inspector-popover-header/index.js +8 -2
- package/build/components/inspector-popover-header/index.js.map +1 -1
- package/build/components/letter-spacing-control/index.js +7 -4
- package/build/components/letter-spacing-control/index.js.map +1 -1
- package/build/components/line-height-control/index.js +3 -0
- package/build/components/line-height-control/index.js.map +1 -1
- package/build/components/link-control/index.js +19 -10
- package/build/components/link-control/index.js.map +1 -1
- package/build/components/link-control/settings-drawer.js +4 -1
- package/build/components/link-control/settings-drawer.js.map +1 -1
- package/build/components/list-view/block-select-button.js +4 -1
- package/build/components/list-view/block-select-button.js.map +1 -1
- package/build/components/media-placeholder/index.js +36 -10
- package/build/components/media-placeholder/index.js.map +1 -1
- package/build/components/media-replace-flow/index.js +8 -1
- package/build/components/media-replace-flow/index.js.map +1 -1
- package/build/components/media-upload/index.native.js +4 -1
- package/build/components/media-upload/index.native.js.map +1 -1
- package/build/components/multi-selection-inspector/index.js +12 -12
- package/build/components/multi-selection-inspector/index.js.map +1 -1
- package/build/components/provider/use-block-sync.js +19 -19
- package/build/components/provider/use-block-sync.js.map +1 -1
- package/build/components/rich-text/event-listeners/paste-handler.js +12 -1
- package/build/components/rich-text/event-listeners/paste-handler.js.map +1 -1
- package/build/components/rich-text/index.js +38 -30
- package/build/components/rich-text/index.js.map +1 -1
- package/build/components/rich-text/use-mark-persistent.js +5 -5
- package/build/components/rich-text/use-mark-persistent.js.map +1 -1
- package/build/components/skip-to-selected-block/index.js +4 -1
- package/build/components/skip-to-selected-block/index.js.map +1 -1
- package/build/components/spacing-sizes-control/input-controls/spacing-input-control.js +4 -2
- package/build/components/spacing-sizes-control/input-controls/spacing-input-control.js.map +1 -1
- package/build/components/text-alignment-control/index.js +13 -8
- package/build/components/text-alignment-control/index.js.map +1 -1
- package/build/components/text-decoration-control/index.js +13 -8
- package/build/components/text-decoration-control/index.js.map +1 -1
- package/build/components/text-transform-control/index.js +13 -8
- package/build/components/text-transform-control/index.js.map +1 -1
- package/build/components/tool-selector/index.js +4 -1
- package/build/components/tool-selector/index.js.map +1 -1
- package/build/components/url-input/button.js +12 -3
- package/build/components/url-input/button.js.map +1 -1
- package/build/components/url-input/index.js +4 -1
- package/build/components/url-input/index.js.map +1 -1
- package/build/components/url-popover/image-url-input-ui.js +2 -0
- package/build/components/url-popover/image-url-input-ui.js.map +1 -1
- package/build/components/use-block-drop-zone/index.js +12 -2
- package/build/components/use-block-drop-zone/index.js.map +1 -1
- package/build/components/writing-flow/index.js +2 -1
- package/build/components/writing-flow/index.js.map +1 -1
- package/build/components/writing-flow/use-arrow-nav.js +4 -1
- package/build/components/writing-flow/use-arrow-nav.js.map +1 -1
- package/build/components/writing-flow/use-event-redirect.js +66 -0
- package/build/components/writing-flow/use-event-redirect.js.map +1 -0
- package/build/components/writing-flow/use-input.js +31 -1
- package/build/components/writing-flow/use-input.js.map +1 -1
- package/build/components/writing-flow/use-select-all.js +14 -1
- package/build/components/writing-flow/use-select-all.js.map +1 -1
- package/build/components/writing-flow/use-selection-observer.js +20 -6
- package/build/components/writing-flow/use-selection-observer.js.map +1 -1
- package/build/components/writing-flow/use-tab-nav.js +4 -4
- package/build/components/writing-flow/use-tab-nav.js.map +1 -1
- package/build/components/writing-flow/utils.js +27 -0
- package/build/components/writing-flow/utils.js.map +1 -1
- package/build/components/writing-mode-control/index.js +13 -8
- package/build/components/writing-mode-control/index.js.map +1 -1
- package/build/hooks/background.js +19 -23
- package/build/hooks/background.js.map +1 -1
- package/build/hooks/block-bindings.js +64 -103
- package/build/hooks/block-bindings.js.map +1 -1
- package/build/hooks/content-lock-ui.js +8 -26
- package/build/hooks/content-lock-ui.js.map +1 -1
- package/build/hooks/duotone.js +0 -4
- package/build/hooks/duotone.js.map +1 -1
- package/build/hooks/layout.js +4 -1
- package/build/hooks/layout.js.map +1 -1
- package/build/hooks/spacing-visualizer.js +3 -3
- package/build/hooks/spacing-visualizer.js.map +1 -1
- package/build/hooks/style.js +1 -5
- package/build/hooks/style.js.map +1 -1
- package/build/hooks/use-bindings-attributes.js +19 -20
- package/build/hooks/use-bindings-attributes.js.map +1 -1
- package/build/hooks/use-zoom-out.js +7 -7
- package/build/hooks/use-zoom-out.js.map +1 -1
- package/build/layouts/constrained.js +42 -41
- package/build/layouts/constrained.js.map +1 -1
- package/build/layouts/flex.js +6 -1
- package/build/layouts/flex.js.map +1 -1
- package/build/layouts/grid.js +3 -0
- package/build/layouts/grid.js.map +1 -1
- package/build/layouts/utils.js +1 -7
- package/build/layouts/utils.js.map +1 -1
- package/build/private-apis.js +4 -1
- package/build/private-apis.js.map +1 -1
- package/build/store/actions.js +2 -7
- package/build/store/actions.js.map +1 -1
- package/build/store/private-actions.js +1 -0
- package/build/store/private-actions.js.map +1 -1
- package/build/store/private-keys.js +2 -1
- package/build/store/private-keys.js.map +1 -1
- package/build/store/private-selectors.js +39 -11
- package/build/store/private-selectors.js.map +1 -1
- package/build/store/reducer.js +2 -0
- package/build/store/reducer.js.map +1 -1
- package/build/store/selectors.js +19 -43
- package/build/store/selectors.js.map +1 -1
- package/build/store/utils.js +48 -0
- package/build/store/utils.js.map +1 -1
- package/build/utils/block-bindings.js +117 -0
- package/build/utils/block-bindings.js.map +1 -0
- package/build/utils/dom.js +101 -0
- package/build/utils/dom.js.map +1 -1
- package/build/utils/get-font-styles-and-weights.js +4 -4
- package/build/utils/get-font-styles-and-weights.js.map +1 -1
- package/build/utils/transform-styles/index.js +120 -16
- package/build/utils/transform-styles/index.js.map +1 -1
- package/build-module/autocompleters/block.js +1 -1
- package/build-module/autocompleters/block.js.map +1 -1
- package/build-module/components/block-alignment-matrix-control/index.js +1 -1
- package/build-module/components/block-alignment-matrix-control/index.js.map +1 -1
- package/build-module/components/block-breadcrumb/index.js +8 -2
- package/build-module/components/block-breadcrumb/index.js.map +1 -1
- package/build-module/components/block-canvas/index.js +9 -1
- package/build-module/components/block-canvas/index.js.map +1 -1
- package/build-module/components/block-compare/block-view.js +4 -1
- package/build-module/components/block-compare/block-view.js.map +1 -1
- package/build-module/components/block-draggable/index.js +4 -4
- package/build-module/components/block-draggable/index.js.map +1 -1
- package/build-module/components/block-draggable/use-scroll-when-dragging.js +25 -25
- package/build-module/components/block-draggable/use-scroll-when-dragging.js.map +1 -1
- package/build-module/components/block-edit/multiple-usage-warning.js +8 -2
- package/build-module/components/block-edit/multiple-usage-warning.js.map +1 -1
- package/build-module/components/block-inspector/index.js +27 -9
- package/build-module/components/block-inspector/index.js.map +1 -1
- package/build-module/components/block-list/block-invalid-warning.js +6 -3
- package/build-module/components/block-list/block-invalid-warning.js.map +1 -1
- package/build-module/components/block-list/block.js +5 -1
- package/build-module/components/block-list/block.js.map +1 -1
- package/build-module/components/block-list/use-block-props/index.js +7 -3
- package/build-module/components/block-list/use-block-props/index.js.map +1 -1
- package/build-module/components/block-list/use-block-props/use-focus-first-element.js +1 -0
- package/build-module/components/block-list/use-block-props/use-focus-first-element.js.map +1 -1
- package/build-module/components/block-list/use-block-props/use-zoom-out-mode-exit.js +40 -0
- package/build-module/components/block-list/use-block-props/use-zoom-out-mode-exit.js.map +1 -0
- package/build-module/components/block-list/use-in-between-inserter.js +11 -4
- package/build-module/components/block-list/use-in-between-inserter.js.map +1 -1
- package/build-module/components/block-lock/toolbar.js +3 -3
- package/build-module/components/block-lock/toolbar.js.map +1 -1
- package/build-module/components/block-mover/button.js +4 -1
- package/build-module/components/block-mover/button.js.map +1 -1
- package/build-module/components/block-mover/index.js +4 -1
- package/build-module/components/block-mover/index.js.map +1 -1
- package/build-module/components/block-navigation/dropdown.js +4 -1
- package/build-module/components/block-navigation/dropdown.js.map +1 -1
- package/build-module/components/block-pattern-setup/index.js +1 -4
- package/build-module/components/block-pattern-setup/index.js.map +1 -1
- package/build-module/components/block-pattern-setup/setup-toolbar.js +23 -8
- package/build-module/components/block-pattern-setup/setup-toolbar.js.map +1 -1
- package/build-module/components/block-patterns-list/index.js +11 -14
- package/build-module/components/block-patterns-list/index.js.map +1 -1
- package/build-module/components/block-patterns-paging/index.js +12 -3
- package/build-module/components/block-patterns-paging/index.js.map +1 -1
- package/build-module/components/block-popover/index.js +2 -15
- package/build-module/components/block-popover/index.js.map +1 -1
- package/build-module/components/block-quick-navigation/index.js +4 -1
- package/build-module/components/block-quick-navigation/index.js.map +1 -1
- package/build-module/components/block-settings-menu/block-mode-toggle.js +29 -34
- package/build-module/components/block-settings-menu/block-mode-toggle.js.map +1 -1
- package/build-module/components/block-settings-menu-controls/index.js +4 -0
- package/build-module/components/block-settings-menu-controls/index.js.map +1 -1
- package/build-module/components/block-switcher/index.js +22 -17
- package/build-module/components/block-switcher/index.js.map +1 -1
- package/build-module/components/block-switcher/pattern-transformations-menu.js +1 -4
- package/build-module/components/block-switcher/pattern-transformations-menu.js.map +1 -1
- package/build-module/components/block-toolbar/index.js +12 -11
- package/build-module/components/block-toolbar/index.js.map +1 -1
- package/build-module/components/block-toolbar/shuffle.js +6 -2
- package/build-module/components/block-toolbar/shuffle.js.map +1 -1
- package/build-module/components/block-tools/block-selection-button.js +8 -2
- package/build-module/components/block-tools/block-selection-button.js.map +1 -1
- package/build-module/components/block-tools/block-toolbar-popover.js +10 -6
- package/build-module/components/block-tools/block-toolbar-popover.js.map +1 -1
- package/build-module/components/block-tools/insertion-point.js +14 -3
- package/build-module/components/block-tools/insertion-point.js.map +1 -1
- package/build-module/components/block-tools/use-block-toolbar-popover-props.js +2 -1
- package/build-module/components/block-tools/use-block-toolbar-popover-props.js.map +1 -1
- package/build-module/components/block-tools/use-show-block-tools.js +2 -1
- package/build-module/components/block-tools/use-show-block-tools.js.map +1 -1
- package/build-module/components/block-tools/zoom-out-mode-inserters.js +4 -5
- package/build-module/components/block-tools/zoom-out-mode-inserters.js.map +1 -1
- package/build-module/components/block-tools/zoom-out-popover.js +3 -4
- package/build-module/components/block-tools/zoom-out-popover.js.map +1 -1
- package/build-module/components/block-tools/zoom-out-toolbar.js +15 -6
- package/build-module/components/block-tools/zoom-out-toolbar.js.map +1 -1
- package/build-module/components/block-variation-picker/index.js +4 -1
- package/build-module/components/block-variation-picker/index.js.map +1 -1
- package/build-module/components/block-variation-transforms/index.js +4 -1
- package/build-module/components/block-variation-transforms/index.js.map +1 -1
- package/build-module/components/border-radius-control/index.js +1 -0
- package/build-module/components/border-radius-control/index.js.map +1 -1
- package/build-module/components/button-block-appender/index.js +15 -4
- package/build-module/components/button-block-appender/index.js.map +1 -1
- package/build-module/components/colors-gradients/dropdown.js +4 -1
- package/build-module/components/colors-gradients/dropdown.js.map +1 -1
- package/build-module/components/content-lock/index.js +2 -0
- package/build-module/components/content-lock/index.js.map +1 -0
- package/build-module/components/content-lock/modify-content-lock-menu-item.js +57 -0
- package/build-module/components/content-lock/modify-content-lock-menu-item.js.map +1 -0
- package/build-module/components/convert-to-group-buttons/index.js +1 -1
- package/build-module/components/convert-to-group-buttons/index.js.map +1 -1
- package/build-module/components/date-format-picker/index.js +2 -0
- package/build-module/components/date-format-picker/index.js.map +1 -1
- package/build-module/components/editor-styles/index.js +4 -3
- package/build-module/components/editor-styles/index.js.map +1 -1
- package/build-module/components/font-appearance-control/index.js +3 -0
- package/build-module/components/font-appearance-control/index.js.map +1 -1
- package/build-module/components/font-family/index.js +3 -0
- package/build-module/components/font-family/index.js.map +1 -1
- package/build-module/components/global-styles/background-panel.js +121 -53
- package/build-module/components/global-styles/background-panel.js.map +1 -1
- package/build-module/components/global-styles/color-panel.js +7 -4
- package/build-module/components/global-styles/color-panel.js.map +1 -1
- package/build-module/components/global-styles/color-panel.native.js +2 -2
- package/build-module/components/global-styles/color-panel.native.js.map +1 -1
- package/build-module/components/global-styles/dimensions-panel.js +36 -39
- package/build-module/components/global-styles/dimensions-panel.js.map +1 -1
- package/build-module/components/global-styles/filters-panel.js +4 -1
- package/build-module/components/global-styles/filters-panel.js.map +1 -1
- package/build-module/components/global-styles/get-global-styles-changes.js +3 -1
- package/build-module/components/global-styles/get-global-styles-changes.js.map +1 -1
- package/build-module/components/global-styles/hooks.js +0 -6
- package/build-module/components/global-styles/hooks.js.map +1 -1
- package/build-module/components/global-styles/index.js +1 -1
- package/build-module/components/global-styles/index.js.map +1 -1
- package/build-module/components/global-styles/shadow-panel-components.js +13 -7
- package/build-module/components/global-styles/shadow-panel-components.js.map +1 -1
- package/build-module/components/global-styles/typography-utils.js +17 -6
- package/build-module/components/global-styles/typography-utils.js.map +1 -1
- package/build-module/components/global-styles/use-global-styles-output.js +5 -5
- package/build-module/components/global-styles/use-global-styles-output.js.map +1 -1
- package/build-module/components/global-styles/utils.js +11 -28
- package/build-module/components/global-styles/utils.js.map +1 -1
- package/build-module/components/grid/grid-item-movers.js +3 -3
- package/build-module/components/grid/grid-item-movers.js.map +1 -1
- package/build-module/components/grid/grid-visualizer.js +20 -5
- package/build-module/components/grid/grid-visualizer.js.map +1 -1
- package/build-module/components/height-control/index.js +1 -0
- package/build-module/components/height-control/index.js.map +1 -1
- package/build-module/components/iframe/index.js +8 -6
- package/build-module/components/iframe/index.js.map +1 -1
- package/build-module/components/image-editor/zoom-dropdown.js +12 -8
- package/build-module/components/image-editor/zoom-dropdown.js.map +1 -1
- package/build-module/components/inner-blocks/button-block-appender.js +7 -6
- package/build-module/components/inner-blocks/button-block-appender.js.map +1 -1
- package/build-module/components/inner-blocks/default-block-appender.js +6 -23
- package/build-module/components/inner-blocks/default-block-appender.js.map +1 -1
- package/build-module/components/inner-blocks/index.js +8 -12
- package/build-module/components/inner-blocks/index.js.map +1 -1
- package/build-module/components/inner-blocks/use-inner-block-template-sync.js +3 -3
- package/build-module/components/inner-blocks/use-inner-block-template-sync.js.map +1 -1
- package/build-module/components/inserter/block-patterns-explorer/pattern-explorer-sidebar.js +4 -1
- package/build-module/components/inserter/block-patterns-explorer/pattern-explorer-sidebar.js.map +1 -1
- package/build-module/components/inserter/block-patterns-tab/index.js +4 -1
- package/build-module/components/inserter/block-patterns-tab/index.js.map +1 -1
- package/build-module/components/inserter/media-tab/hooks.js +3 -3
- package/build-module/components/inserter/media-tab/hooks.js.map +1 -1
- package/build-module/components/inserter/media-tab/media-list.js +1 -4
- package/build-module/components/inserter/media-tab/media-list.js.map +1 -1
- package/build-module/components/inserter/media-tab/media-preview.js +8 -2
- package/build-module/components/inserter/media-tab/media-preview.js.map +1 -1
- package/build-module/components/inserter/media-tab/media-tab.js +4 -1
- package/build-module/components/inserter/media-tab/media-tab.js.map +1 -1
- package/build-module/components/inserter/menu.js +14 -13
- package/build-module/components/inserter/menu.js.map +1 -1
- package/build-module/components/inserter/quick-inserter.js +9 -2
- package/build-module/components/inserter/quick-inserter.js.map +1 -1
- package/build-module/components/inserter-list-item/index.js +4 -4
- package/build-module/components/inserter-list-item/index.js.map +1 -1
- package/build-module/components/inserter-listbox/index.js +3 -7
- package/build-module/components/inserter-listbox/index.js.map +1 -1
- package/build-module/components/inserter-listbox/item.js +4 -1
- package/build-module/components/inserter-listbox/item.js.map +1 -1
- package/build-module/components/inspector-controls/groups.js +2 -0
- package/build-module/components/inspector-controls/groups.js.map +1 -1
- package/build-module/components/inspector-controls-tabs/index.js +4 -1
- package/build-module/components/inspector-controls-tabs/index.js.map +1 -1
- package/build-module/components/inspector-controls-tabs/settings-tab.js +3 -1
- package/build-module/components/inspector-controls-tabs/settings-tab.js.map +1 -1
- package/build-module/components/inspector-controls-tabs/use-inspector-controls-tabs.js +2 -1
- package/build-module/components/inspector-controls-tabs/use-inspector-controls-tabs.js.map +1 -1
- package/build-module/components/inspector-popover-header/index.js +8 -2
- package/build-module/components/inspector-popover-header/index.js.map +1 -1
- package/build-module/components/letter-spacing-control/index.js +7 -4
- package/build-module/components/letter-spacing-control/index.js.map +1 -1
- package/build-module/components/line-height-control/index.js +3 -0
- package/build-module/components/line-height-control/index.js.map +1 -1
- package/build-module/components/link-control/index.js +19 -10
- package/build-module/components/link-control/index.js.map +1 -1
- package/build-module/components/link-control/settings-drawer.js +4 -1
- package/build-module/components/link-control/settings-drawer.js.map +1 -1
- package/build-module/components/list-view/block-select-button.js +4 -1
- package/build-module/components/list-view/block-select-button.js.map +1 -1
- package/build-module/components/media-placeholder/index.js +36 -10
- package/build-module/components/media-placeholder/index.js.map +1 -1
- package/build-module/components/media-replace-flow/index.js +8 -1
- package/build-module/components/media-replace-flow/index.js.map +1 -1
- package/build-module/components/media-upload/index.native.js +4 -1
- package/build-module/components/media-upload/index.native.js.map +1 -1
- package/build-module/components/multi-selection-inspector/index.js +12 -12
- package/build-module/components/multi-selection-inspector/index.js.map +1 -1
- package/build-module/components/provider/use-block-sync.js +19 -19
- package/build-module/components/provider/use-block-sync.js.map +1 -1
- package/build-module/components/rich-text/event-listeners/paste-handler.js +12 -1
- package/build-module/components/rich-text/event-listeners/paste-handler.js.map +1 -1
- package/build-module/components/rich-text/index.js +39 -31
- package/build-module/components/rich-text/index.js.map +1 -1
- package/build-module/components/rich-text/use-mark-persistent.js +5 -5
- package/build-module/components/rich-text/use-mark-persistent.js.map +1 -1
- package/build-module/components/skip-to-selected-block/index.js +4 -1
- package/build-module/components/skip-to-selected-block/index.js.map +1 -1
- package/build-module/components/spacing-sizes-control/input-controls/spacing-input-control.js +4 -2
- package/build-module/components/spacing-sizes-control/input-controls/spacing-input-control.js.map +1 -1
- package/build-module/components/text-alignment-control/index.js +13 -8
- package/build-module/components/text-alignment-control/index.js.map +1 -1
- package/build-module/components/text-decoration-control/index.js +13 -8
- package/build-module/components/text-decoration-control/index.js.map +1 -1
- package/build-module/components/text-transform-control/index.js +13 -8
- package/build-module/components/text-transform-control/index.js.map +1 -1
- package/build-module/components/tool-selector/index.js +4 -1
- package/build-module/components/tool-selector/index.js.map +1 -1
- package/build-module/components/url-input/button.js +12 -3
- package/build-module/components/url-input/button.js.map +1 -1
- package/build-module/components/url-input/index.js +4 -1
- package/build-module/components/url-input/index.js.map +1 -1
- package/build-module/components/url-popover/image-url-input-ui.js +2 -0
- package/build-module/components/url-popover/image-url-input-ui.js.map +1 -1
- package/build-module/components/use-block-drop-zone/index.js +12 -2
- package/build-module/components/use-block-drop-zone/index.js.map +1 -1
- package/build-module/components/writing-flow/index.js +2 -1
- package/build-module/components/writing-flow/index.js.map +1 -1
- package/build-module/components/writing-flow/use-arrow-nav.js +4 -1
- package/build-module/components/writing-flow/use-arrow-nav.js.map +1 -1
- package/build-module/components/writing-flow/use-event-redirect.js +60 -0
- package/build-module/components/writing-flow/use-event-redirect.js.map +1 -0
- package/build-module/components/writing-flow/use-input.js +31 -1
- package/build-module/components/writing-flow/use-input.js.map +1 -1
- package/build-module/components/writing-flow/use-select-all.js +14 -1
- package/build-module/components/writing-flow/use-select-all.js.map +1 -1
- package/build-module/components/writing-flow/use-selection-observer.js +16 -2
- package/build-module/components/writing-flow/use-selection-observer.js.map +1 -1
- package/build-module/components/writing-flow/use-tab-nav.js +4 -4
- package/build-module/components/writing-flow/use-tab-nav.js.map +1 -1
- package/build-module/components/writing-flow/utils.js +26 -0
- package/build-module/components/writing-flow/utils.js.map +1 -1
- package/build-module/components/writing-mode-control/index.js +13 -8
- package/build-module/components/writing-mode-control/index.js.map +1 -1
- package/build-module/hooks/background.js +19 -23
- package/build-module/hooks/background.js.map +1 -1
- package/build-module/hooks/block-bindings.js +66 -105
- package/build-module/hooks/block-bindings.js.map +1 -1
- package/build-module/hooks/content-lock-ui.js +10 -30
- package/build-module/hooks/content-lock-ui.js.map +1 -1
- package/build-module/hooks/duotone.js +0 -4
- package/build-module/hooks/duotone.js.map +1 -1
- package/build-module/hooks/layout.js +4 -1
- package/build-module/hooks/layout.js.map +1 -1
- package/build-module/hooks/spacing-visualizer.js +3 -3
- package/build-module/hooks/spacing-visualizer.js.map +1 -1
- package/build-module/hooks/style.js +1 -5
- package/build-module/hooks/style.js.map +1 -1
- package/build-module/hooks/use-bindings-attributes.js +19 -20
- package/build-module/hooks/use-bindings-attributes.js.map +1 -1
- package/build-module/hooks/use-zoom-out.js +7 -7
- package/build-module/hooks/use-zoom-out.js.map +1 -1
- package/build-module/layouts/constrained.js +44 -43
- package/build-module/layouts/constrained.js.map +1 -1
- package/build-module/layouts/flex.js +6 -1
- package/build-module/layouts/flex.js.map +1 -1
- package/build-module/layouts/grid.js +3 -0
- package/build-module/layouts/grid.js.map +1 -1
- package/build-module/layouts/utils.js +1 -7
- package/build-module/layouts/utils.js.map +1 -1
- package/build-module/private-apis.js +5 -2
- package/build-module/private-apis.js.map +1 -1
- package/build-module/store/actions.js +2 -7
- package/build-module/store/actions.js.map +1 -1
- package/build-module/store/private-actions.js +1 -0
- package/build-module/store/private-actions.js.map +1 -1
- package/build-module/store/private-keys.js +1 -0
- package/build-module/store/private-keys.js.map +1 -1
- package/build-module/store/private-selectors.js +36 -12
- package/build-module/store/private-selectors.js.map +1 -1
- package/build-module/store/reducer.js +2 -0
- package/build-module/store/reducer.js.map +1 -1
- package/build-module/store/selectors.js +22 -46
- package/build-module/store/selectors.js.map +1 -1
- package/build-module/store/utils.js +46 -0
- package/build-module/store/utils.js.map +1 -1
- package/build-module/utils/block-bindings.js +110 -0
- package/build-module/utils/block-bindings.js.map +1 -0
- package/build-module/utils/dom.js +99 -0
- package/build-module/utils/dom.js.map +1 -1
- package/build-module/utils/get-font-styles-and-weights.js +4 -4
- package/build-module/utils/get-font-styles-and-weights.js.map +1 -1
- package/build-module/utils/transform-styles/index.js +120 -16
- package/build-module/utils/transform-styles/index.js.map +1 -1
- package/build-style/content-rtl.css +9 -25
- package/build-style/content.css +9 -25
- package/build-style/default-editor-styles-rtl.css +2 -2
- package/build-style/default-editor-styles.css +2 -2
- package/build-style/style-rtl.css +53 -76
- package/build-style/style.css +53 -76
- package/build-types/utils/dom.d.ts +25 -0
- package/build-types/utils/dom.d.ts.map +1 -1
- package/package.json +34 -32
- package/src/autocompleters/block.js +2 -1
- package/src/components/block-alignment-matrix-control/index.js +1 -1
- package/src/components/block-breadcrumb/index.js +4 -0
- package/src/components/block-breadcrumb/style.scss +1 -1
- package/src/components/block-canvas/index.js +9 -1
- package/src/components/block-compare/block-view.js +7 -1
- package/src/components/block-draggable/content.scss +1 -1
- package/src/components/block-draggable/index.js +4 -4
- package/src/components/block-draggable/style.scss +1 -1
- package/src/components/block-draggable/use-scroll-when-dragging.js +25 -25
- package/src/components/block-edit/multiple-usage-warning.js +4 -0
- package/src/components/block-inspector/index.js +22 -6
- package/src/components/block-list/block-invalid-warning.js +4 -2
- package/src/components/block-list/block.js +6 -2
- package/src/components/block-list/content.scss +7 -16
- package/src/components/block-list/use-block-props/index.js +5 -2
- package/src/components/block-list/use-block-props/use-focus-first-element.js +1 -0
- package/src/components/block-list/use-block-props/use-zoom-out-mode-exit.js +44 -0
- package/src/components/block-list/use-in-between-inserter.js +17 -5
- package/src/components/block-lock/style.scss +1 -1
- package/src/components/block-lock/toolbar.js +3 -3
- package/src/components/block-mover/button.js +2 -0
- package/src/components/block-mover/index.js +2 -0
- package/src/components/block-mover/style.scss +1 -1
- package/src/components/block-navigation/dropdown.js +2 -0
- package/src/components/block-pattern-setup/index.js +3 -7
- package/src/components/block-pattern-setup/setup-toolbar.js +17 -4
- package/src/components/block-pattern-setup/style.scss +2 -2
- package/src/components/block-patterns-list/index.js +15 -13
- package/src/components/block-patterns-list/style.scss +2 -2
- package/src/components/block-patterns-paging/index.js +6 -0
- package/src/components/block-popover/index.js +7 -28
- package/src/components/block-popover/style.scss +1 -1
- package/src/components/block-quick-navigation/index.js +2 -0
- package/src/components/block-settings-menu/block-mode-toggle.js +28 -31
- package/src/components/block-settings-menu/test/block-mode-toggle.js +26 -23
- package/src/components/block-settings-menu-controls/index.js +7 -1
- package/src/components/block-switcher/index.js +26 -20
- package/src/components/block-switcher/pattern-transformations-menu.js +3 -7
- package/src/components/block-switcher/style.scss +5 -6
- package/src/components/block-toolbar/index.js +17 -8
- package/src/components/block-toolbar/shuffle.js +9 -7
- package/src/components/block-tools/block-selection-button.js +4 -0
- package/src/components/block-tools/block-toolbar-popover.js +10 -6
- package/src/components/block-tools/insertion-point.js +11 -0
- package/src/components/block-tools/style.scss +4 -5
- package/src/components/block-tools/use-block-toolbar-popover-props.js +2 -1
- package/src/components/block-tools/use-show-block-tools.js +4 -1
- package/src/components/block-tools/zoom-out-mode-inserters.js +5 -2
- package/src/components/block-tools/zoom-out-popover.js +3 -7
- package/src/components/block-tools/zoom-out-toolbar.js +20 -6
- package/src/components/block-variation-picker/README.md +2 -2
- package/src/components/block-variation-picker/index.js +6 -1
- package/src/components/block-variation-transforms/index.js +2 -0
- package/src/components/block-variation-transforms/style.scss +2 -2
- package/src/components/border-radius-control/index.js +1 -0
- package/src/components/border-radius-control/style.scss +0 -10
- package/src/components/button-block-appender/content.scss +0 -1
- package/src/components/button-block-appender/index.js +14 -3
- package/src/components/color-palette/test/control.js +15 -2
- package/src/components/colors-gradients/dropdown.js +5 -1
- package/src/components/colors-gradients/style.scss +4 -4
- package/src/components/content-lock/index.js +1 -0
- package/src/components/content-lock/modify-content-lock-menu-item.js +58 -0
- package/src/components/convert-to-group-buttons/index.js +1 -1
- package/src/components/date-format-picker/index.js +2 -0
- package/src/components/default-block-appender/content.scss +0 -1
- package/src/components/editor-styles/index.js +4 -3
- package/src/components/font-appearance-control/index.js +3 -0
- package/src/components/font-family/README.md +11 -2
- package/src/components/font-family/index.js +3 -0
- package/src/components/global-styles/background-panel.js +135 -64
- package/src/components/global-styles/color-panel.js +8 -4
- package/src/components/global-styles/color-panel.native.js +2 -2
- package/src/components/global-styles/dimensions-panel.js +40 -40
- package/src/components/global-styles/filters-panel.js +5 -1
- package/src/components/global-styles/get-global-styles-changes.js +4 -1
- package/src/components/global-styles/hooks.js +0 -5
- package/src/components/global-styles/index.js +0 -1
- package/src/components/global-styles/shadow-panel-components.js +12 -8
- package/src/components/global-styles/style.scss +16 -6
- package/src/components/global-styles/test/typography-utils.js +96 -5
- package/src/components/global-styles/test/use-global-styles-output.js +20 -4
- package/src/components/global-styles/test/utils.js +10 -0
- package/src/components/global-styles/typography-utils.js +22 -6
- package/src/components/global-styles/use-global-styles-output.js +5 -6
- package/src/components/global-styles/utils.js +11 -35
- package/src/components/grid/grid-item-movers.js +3 -3
- package/src/components/grid/grid-visualizer.js +22 -7
- package/src/components/grid/style.scss +1 -1
- package/src/components/height-control/index.js +1 -0
- package/src/components/iframe/index.js +8 -6
- package/src/components/image-editor/zoom-dropdown.js +17 -9
- package/src/components/inner-blocks/button-block-appender.js +5 -7
- package/src/components/inner-blocks/default-block-appender.js +4 -23
- package/src/components/inner-blocks/index.js +11 -10
- package/src/components/inner-blocks/use-inner-block-template-sync.js +3 -3
- package/src/components/inserter/block-patterns-explorer/pattern-explorer-sidebar.js +2 -0
- package/src/components/inserter/block-patterns-tab/index.js +2 -0
- package/src/components/inserter/media-tab/hooks.js +3 -3
- package/src/components/inserter/media-tab/media-list.js +1 -4
- package/src/components/inserter/media-tab/media-preview.js +12 -2
- package/src/components/inserter/media-tab/media-tab.js +2 -0
- package/src/components/inserter/menu.js +13 -22
- package/src/components/inserter/quick-inserter.js +6 -1
- package/src/components/inserter/style.scss +7 -9
- package/src/components/inserter-list-item/index.js +4 -4
- package/src/components/inserter-list-item/style.scss +2 -3
- package/src/components/inserter-listbox/index.js +2 -8
- package/src/components/inserter-listbox/item.js +9 -1
- package/src/components/inspector-controls/groups.js +2 -0
- package/src/components/inspector-controls-tabs/index.js +2 -0
- package/src/components/inspector-controls-tabs/settings-tab.js +1 -0
- package/src/components/inspector-controls-tabs/use-inspector-controls-tabs.js +5 -2
- package/src/components/inspector-popover-header/index.js +4 -0
- package/src/components/letter-spacing-control/README.md +8 -1
- package/src/components/letter-spacing-control/index.js +7 -4
- package/src/components/line-height-control/README.md +7 -0
- package/src/components/line-height-control/index.js +3 -0
- package/src/components/link-control/index.js +17 -8
- package/src/components/link-control/settings-drawer.js +2 -0
- package/src/components/link-control/style.scss +2 -4
- package/src/components/list-view/block-select-button.js +2 -0
- package/src/components/list-view/style.scss +14 -16
- package/src/components/media-placeholder/index.js +26 -7
- package/src/components/media-replace-flow/index.js +12 -1
- package/src/components/media-upload/README.md +2 -0
- package/src/components/media-upload/index.native.js +2 -0
- package/src/components/multi-selection-inspector/index.js +8 -9
- package/src/components/provider/use-block-sync.js +20 -20
- package/src/components/responsive-block-control/README.md +3 -26
- package/src/components/responsive-block-control/test/index.js +1 -0
- package/src/components/rich-text/content.scss +1 -1
- package/src/components/rich-text/event-listeners/paste-handler.js +6 -1
- package/src/components/rich-text/index.js +54 -41
- package/src/components/rich-text/style.scss +1 -1
- package/src/components/rich-text/use-mark-persistent.js +5 -5
- package/src/components/skip-to-selected-block/index.js +2 -0
- package/src/components/spacing-sizes-control/input-controls/spacing-input-control.js +8 -4
- package/src/components/spacing-sizes-control/style.scss +17 -16
- package/src/components/text-alignment-control/index.js +20 -8
- package/src/components/text-decoration-control/index.js +20 -8
- package/src/components/text-decoration-control/stories/index.story.js +0 -4
- package/src/components/text-transform-control/index.js +20 -8
- package/src/components/text-transform-control/stories/index.story.js +0 -4
- package/src/components/tool-selector/index.js +2 -0
- package/src/components/url-input/button.js +6 -0
- package/src/components/url-input/index.js +2 -0
- package/src/components/url-input/style.scss +2 -2
- package/src/components/url-popover/image-url-input-ui.js +2 -0
- package/src/components/url-popover/stories/index.story.js +7 -1
- package/src/components/use-block-drop-zone/index.js +21 -3
- package/src/components/warning/content.scss +3 -10
- package/src/components/writing-flow/index.js +2 -0
- package/src/components/writing-flow/use-arrow-nav.js +9 -2
- package/src/components/writing-flow/use-event-redirect.js +72 -0
- package/src/components/writing-flow/use-input.js +36 -1
- package/src/components/writing-flow/use-select-all.js +18 -1
- package/src/components/writing-flow/use-selection-observer.js +23 -3
- package/src/components/writing-flow/use-tab-nav.js +4 -4
- package/src/components/writing-flow/utils.js +30 -0
- package/src/components/writing-mode-control/index.js +20 -8
- package/src/hooks/background.js +21 -27
- package/src/hooks/block-bindings.js +64 -122
- package/src/hooks/block-bindings.scss +2 -10
- package/src/hooks/content-lock-ui.js +11 -36
- package/src/hooks/duotone.js +0 -4
- package/src/hooks/layout.js +2 -0
- package/src/hooks/layout.scss +3 -11
- package/src/hooks/spacing-visualizer.js +3 -3
- package/src/hooks/style.js +1 -4
- package/src/hooks/test/background.js +60 -0
- package/src/hooks/use-bindings-attributes.js +23 -24
- package/src/hooks/use-zoom-out.js +7 -7
- package/src/layouts/constrained.js +51 -47
- package/src/layouts/flex.js +4 -0
- package/src/layouts/grid.js +3 -0
- package/src/layouts/test/grid.js +2 -2
- package/src/layouts/test/utils.js +6 -8
- package/src/layouts/utils.js +1 -9
- package/src/private-apis.js +4 -0
- package/src/store/actions.js +4 -6
- package/src/store/private-actions.js +1 -0
- package/src/store/private-keys.js +1 -0
- package/src/store/private-selectors.js +44 -7
- package/src/store/reducer.js +2 -0
- package/src/store/selectors.js +32 -51
- package/src/store/test/private-selectors.js +89 -0
- package/src/store/utils.js +50 -0
- package/src/style.scss +0 -1
- package/src/utils/block-bindings.js +97 -0
- package/src/utils/dom.js +117 -0
- package/src/utils/get-font-styles-and-weights.js +12 -4
- package/src/utils/test/get-font-styles-and-weights.js +148 -0
- package/src/utils/test/transform-styles.js +284 -26
- package/src/utils/transform-styles/index.js +132 -21
- package/tsconfig.json +1 -0
- package/tsconfig.tsbuildinfo +1 -1
- package/build/components/global-styles/theme-file-uri-utils.js +0 -21
- package/build/components/global-styles/theme-file-uri-utils.js.map +0 -1
- package/build/components/inner-blocks/with-client-id.js +0 -28
- package/build/components/inner-blocks/with-client-id.js.map +0 -1
- package/build/components/segmented-text-control/index.js +0 -63
- package/build/components/segmented-text-control/index.js.map +0 -1
- package/build-module/components/global-styles/theme-file-uri-utils.js +0 -15
- package/build-module/components/global-styles/theme-file-uri-utils.js.map +0 -1
- package/build-module/components/inner-blocks/with-client-id.js +0 -21
- package/build-module/components/inner-blocks/with-client-id.js.map +0 -1
- package/build-module/components/segmented-text-control/index.js +0 -58
- package/build-module/components/segmented-text-control/index.js.map +0 -1
- package/src/components/global-styles/test/theme-file-uri-utils.js +0 -41
- package/src/components/global-styles/theme-file-uri-utils.js +0 -18
- package/src/components/inner-blocks/with-client-id.js +0 -19
- package/src/components/segmented-text-control/index.js +0 -63
- package/src/components/segmented-text-control/style.scss +0 -15
- package/src/utils/test/__snapshots__/transform-styles.js.snap +0 -109
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_clsx","_interopRequireDefault","require","_element","_i18n","_a11y","_components","_data","_keycodes","_icons","_compose","_dom","_notices","_mediaUpload","_check","_linkControl","_store","_jsxRuntime","noop","uniqueId","MediaReplaceFlow","mediaURL","mediaId","mediaIds","allowedTypes","accept","onError","onSelect","onSelectURL","onToggleFeaturedImage","useFeaturedImage","onFilesUpload","name","__","createNotice","removeNotice","children","multiple","addToGallery","handleUpload","popoverProps","mediaUpload","useSelect","select","blockEditorStore","getSettings","canUpload","editMediaButtonRef","useRef","errorNoticeID","onUploadError","message","safeMessage","stripHTML","setTimeout","speak","id","isDismissible","selectMedia","media","closeMenu","uploadFiles","event","files","target","filesList","onFileChange","openOnArrowDown","keyCode","DOWN","preventDefault","click","onlyAllowsImages","length","every","allowedType","startsWith","gallery","jsx","Dropdown","contentClassName","renderToggle","isOpen","onToggle","ToolbarButton","ref","onClick","onKeyDown","renderContent","onClose","jsxs","Fragment","NavigableMenu","className","default","value","render","open","MenuItem","icon","mediaIcon","FormFileUpload","onChange","openFileDialog","upload","postFeaturedImage","isPressed","clsx","url","settings","showSuggestions","current","focus","_default","exports","compose","withDispatch","dispatch","noticesStore","withFilters"],"sources":["@wordpress/block-editor/src/components/media-replace-flow/index.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { useRef } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport { speak } from '@wordpress/a11y';\nimport {\n\tFormFileUpload,\n\tNavigableMenu,\n\tMenuItem,\n\tToolbarButton,\n\tDropdown,\n\twithFilters,\n} from '@wordpress/components';\nimport { useSelect, withDispatch } from '@wordpress/data';\nimport { DOWN } from '@wordpress/keycodes';\nimport {\n\tpostFeaturedImage,\n\tupload,\n\tmedia as mediaIcon,\n} from '@wordpress/icons';\nimport { compose } from '@wordpress/compose';\nimport { __unstableStripHTML as stripHTML } from '@wordpress/dom';\nimport { store as noticesStore } from '@wordpress/notices';\n\n/**\n * Internal dependencies\n */\nimport MediaUpload from '../media-upload';\nimport MediaUploadCheck from '../media-upload/check';\nimport LinkControl from '../link-control';\nimport { store as blockEditorStore } from '../../store';\n\nconst noop = () => {};\nlet uniqueId = 0;\n\nconst MediaReplaceFlow = ( {\n\tmediaURL,\n\tmediaId,\n\tmediaIds,\n\tallowedTypes,\n\taccept,\n\tonError,\n\tonSelect,\n\tonSelectURL,\n\tonToggleFeaturedImage,\n\tuseFeaturedImage,\n\tonFilesUpload = noop,\n\tname = __( 'Replace' ),\n\tcreateNotice,\n\tremoveNotice,\n\tchildren,\n\tmultiple = false,\n\taddToGallery,\n\thandleUpload = true,\n\tpopoverProps,\n} ) => {\n\tconst mediaUpload = useSelect( ( select ) => {\n\t\treturn select( blockEditorStore ).getSettings().mediaUpload;\n\t}, [] );\n\tconst canUpload = !! mediaUpload;\n\tconst editMediaButtonRef = useRef();\n\tconst errorNoticeID = `block-editor/media-replace-flow/error-notice/${ ++uniqueId }`;\n\n\tconst onUploadError = ( message ) => {\n\t\tconst safeMessage = stripHTML( message );\n\t\tif ( onError ) {\n\t\t\tonError( safeMessage );\n\t\t\treturn;\n\t\t}\n\t\t// We need to set a timeout for showing the notice\n\t\t// so that VoiceOver and possibly other screen readers\n\t\t// can announce the error afer the toolbar button\n\t\t// regains focus once the upload dialog closes.\n\t\t// Otherwise VO simply skips over the notice and announces\n\t\t// the focused element and the open menu.\n\t\tsetTimeout( () => {\n\t\t\tcreateNotice( 'error', safeMessage, {\n\t\t\t\tspeak: true,\n\t\t\t\tid: errorNoticeID,\n\t\t\t\tisDismissible: true,\n\t\t\t} );\n\t\t}, 1000 );\n\t};\n\n\tconst selectMedia = ( media, closeMenu ) => {\n\t\tif ( useFeaturedImage && onToggleFeaturedImage ) {\n\t\t\tonToggleFeaturedImage();\n\t\t}\n\t\tcloseMenu();\n\t\t// Calling `onSelect` after the state update since it might unmount the component.\n\t\tonSelect( media );\n\t\tspeak( __( 'The media file has been replaced' ) );\n\t\tremoveNotice( errorNoticeID );\n\t};\n\n\tconst uploadFiles = ( event, closeMenu ) => {\n\t\tconst files = event.target.files;\n\t\tif ( ! handleUpload ) {\n\t\t\tcloseMenu();\n\t\t\treturn onSelect( files );\n\t\t}\n\t\tonFilesUpload( files );\n\t\tmediaUpload( {\n\t\t\tallowedTypes,\n\t\t\tfilesList: files,\n\t\t\tonFileChange: ( [ media ] ) => {\n\t\t\t\tselectMedia( media, closeMenu );\n\t\t\t},\n\t\t\tonError: onUploadError,\n\t\t} );\n\t};\n\n\tconst openOnArrowDown = ( event ) => {\n\t\tif ( event.keyCode === DOWN ) {\n\t\t\tevent.preventDefault();\n\t\t\tevent.target.click();\n\t\t}\n\t};\n\n\tconst onlyAllowsImages = () => {\n\t\tif ( ! allowedTypes || allowedTypes.length === 0 ) {\n\t\t\treturn false;\n\t\t}\n\n\t\treturn allowedTypes.every(\n\t\t\t( allowedType ) =>\n\t\t\t\tallowedType === 'image' || allowedType.startsWith( 'image/' )\n\t\t);\n\t};\n\n\tconst gallery = multiple && onlyAllowsImages();\n\n\treturn (\n\t\t<Dropdown\n\t\t\tpopoverProps={ popoverProps }\n\t\t\tcontentClassName=\"block-editor-media-replace-flow__options\"\n\t\t\trenderToggle={ ( { isOpen, onToggle } ) => (\n\t\t\t\t<ToolbarButton\n\t\t\t\t\tref={ editMediaButtonRef }\n\t\t\t\t\taria-expanded={ isOpen }\n\t\t\t\t\taria-haspopup=\"true\"\n\t\t\t\t\tonClick={ onToggle }\n\t\t\t\t\tonKeyDown={ openOnArrowDown }\n\t\t\t\t>\n\t\t\t\t\t{ name }\n\t\t\t\t</ToolbarButton>\n\t\t\t) }\n\t\t\trenderContent={ ( { onClose } ) => (\n\t\t\t\t<>\n\t\t\t\t\t<NavigableMenu className=\"block-editor-media-replace-flow__media-upload-menu\">\n\t\t\t\t\t\t<MediaUploadCheck>\n\t\t\t\t\t\t\t<MediaUpload\n\t\t\t\t\t\t\t\tgallery={ gallery }\n\t\t\t\t\t\t\t\taddToGallery={ addToGallery }\n\t\t\t\t\t\t\t\tmultiple={ multiple }\n\t\t\t\t\t\t\t\tvalue={ multiple ? mediaIds : mediaId }\n\t\t\t\t\t\t\t\tonSelect={ ( media ) =>\n\t\t\t\t\t\t\t\t\tselectMedia( media, onClose )\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tallowedTypes={ allowedTypes }\n\t\t\t\t\t\t\t\trender={ ( { open } ) => (\n\t\t\t\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\t\t\t\ticon={ mediaIcon }\n\t\t\t\t\t\t\t\t\t\tonClick={ open }\n\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t{ __( 'Open Media Library' ) }\n\t\t\t\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t<FormFileUpload\n\t\t\t\t\t\t\t\tonChange={ ( event ) => {\n\t\t\t\t\t\t\t\t\tuploadFiles( event, onClose );\n\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\taccept={ accept }\n\t\t\t\t\t\t\t\tmultiple={ !! multiple }\n\t\t\t\t\t\t\t\trender={ ( { openFileDialog } ) => {\n\t\t\t\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\t\t\t\t\ticon={ upload }\n\t\t\t\t\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\t\t\t\t\topenFileDialog();\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{ __( 'Upload' ) }\n\t\t\t\t\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</MediaUploadCheck>\n\t\t\t\t\t\t{ onToggleFeaturedImage && (\n\t\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\t\ticon={ postFeaturedImage }\n\t\t\t\t\t\t\t\tonClick={ onToggleFeaturedImage }\n\t\t\t\t\t\t\t\tisPressed={ useFeaturedImage }\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{ __( 'Use featured image' ) }\n\t\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t\t) }\n\t\t\t\t\t\t{ typeof children === 'function'\n\t\t\t\t\t\t\t? children( { onClose } )\n\t\t\t\t\t\t\t: children }\n\t\t\t\t\t</NavigableMenu>\n\t\t\t\t\t{ onSelectURL && (\n\t\t\t\t\t\t// eslint-disable-next-line jsx-a11y/no-noninteractive-element-interactions\n\t\t\t\t\t\t<form\n\t\t\t\t\t\t\tclassName={ clsx(\n\t\t\t\t\t\t\t\t'block-editor-media-flow__url-input',\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t'has-siblings':\n\t\t\t\t\t\t\t\t\t\tcanUpload || onToggleFeaturedImage,\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<span className=\"block-editor-media-replace-flow__image-url-label\">\n\t\t\t\t\t\t\t\t{ __( 'Current media URL:' ) }\n\t\t\t\t\t\t\t</span>\n\n\t\t\t\t\t\t\t<LinkControl\n\t\t\t\t\t\t\t\tvalue={ { url: mediaURL } }\n\t\t\t\t\t\t\t\tsettings={ [] }\n\t\t\t\t\t\t\t\tshowSuggestions={ false }\n\t\t\t\t\t\t\t\tonChange={ ( { url } ) => {\n\t\t\t\t\t\t\t\t\tonSelectURL( url );\n\t\t\t\t\t\t\t\t\teditMediaButtonRef.current.focus();\n\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</form>\n\t\t\t\t\t) }\n\t\t\t\t</>\n\t\t\t) }\n\t\t/>\n\t);\n};\n\n/**\n * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/media-replace-flow/README.md\n */\nexport default compose( [\n\twithDispatch( ( dispatch ) => {\n\t\tconst { createNotice, removeNotice } = dispatch( noticesStore );\n\t\treturn {\n\t\t\tcreateNotice,\n\t\t\tremoveNotice,\n\t\t};\n\t} ),\n\twithFilters( 'editor.MediaReplaceFlow' ),\n] )( MediaReplaceFlow );\n"],"mappings":";;;;;;;AAGA,IAAAA,KAAA,GAAAC,sBAAA,CAAAC,OAAA;AAKA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA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AAW,EAAE,yBAA0B,CAAC,CACvC,CAAC,CAAEnG,gBAAiB,CAAC","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["_clsx","_interopRequireDefault","require","_element","_i18n","_a11y","_components","_data","_keycodes","_icons","_compose","_dom","_notices","_mediaUpload","_check","_linkControl","_store","_jsxRuntime","noop","uniqueId","MediaReplaceFlow","mediaURL","mediaId","mediaIds","allowedTypes","accept","onError","onSelect","onSelectURL","onReset","onToggleFeaturedImage","useFeaturedImage","onFilesUpload","name","__","createNotice","removeNotice","children","multiple","addToGallery","handleUpload","popoverProps","mediaUpload","useSelect","select","blockEditorStore","getSettings","canUpload","editMediaButtonRef","useRef","errorNoticeID","onUploadError","message","safeMessage","stripHTML","setTimeout","speak","id","isDismissible","selectMedia","media","closeMenu","uploadFiles","event","files","target","filesList","onFileChange","openOnArrowDown","keyCode","DOWN","preventDefault","click","onlyAllowsImages","length","every","allowedType","startsWith","gallery","jsx","Dropdown","contentClassName","renderToggle","isOpen","onToggle","ToolbarButton","ref","onClick","onKeyDown","renderContent","onClose","jsxs","Fragment","NavigableMenu","className","default","value","render","open","MenuItem","icon","mediaIcon","FormFileUpload","onChange","openFileDialog","upload","postFeaturedImage","isPressed","clsx","url","settings","showSuggestions","current","focus","_default","exports","compose","withDispatch","dispatch","noticesStore","withFilters"],"sources":["@wordpress/block-editor/src/components/media-replace-flow/index.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { useRef } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport { speak } from '@wordpress/a11y';\nimport {\n\tFormFileUpload,\n\tNavigableMenu,\n\tMenuItem,\n\tToolbarButton,\n\tDropdown,\n\twithFilters,\n} from '@wordpress/components';\nimport { useSelect, withDispatch } from '@wordpress/data';\nimport { DOWN } from '@wordpress/keycodes';\nimport {\n\tpostFeaturedImage,\n\tupload,\n\tmedia as mediaIcon,\n} from '@wordpress/icons';\nimport { compose } from '@wordpress/compose';\nimport { __unstableStripHTML as stripHTML } from '@wordpress/dom';\nimport { store as noticesStore } from '@wordpress/notices';\n\n/**\n * Internal dependencies\n */\nimport MediaUpload from '../media-upload';\nimport MediaUploadCheck from '../media-upload/check';\nimport LinkControl from '../link-control';\nimport { store as blockEditorStore } from '../../store';\n\nconst noop = () => {};\nlet uniqueId = 0;\n\nconst MediaReplaceFlow = ( {\n\tmediaURL,\n\tmediaId,\n\tmediaIds,\n\tallowedTypes,\n\taccept,\n\tonError,\n\tonSelect,\n\tonSelectURL,\n\tonReset,\n\tonToggleFeaturedImage,\n\tuseFeaturedImage,\n\tonFilesUpload = noop,\n\tname = __( 'Replace' ),\n\tcreateNotice,\n\tremoveNotice,\n\tchildren,\n\tmultiple = false,\n\taddToGallery,\n\thandleUpload = true,\n\tpopoverProps,\n} ) => {\n\tconst mediaUpload = useSelect( ( select ) => {\n\t\treturn select( blockEditorStore ).getSettings().mediaUpload;\n\t}, [] );\n\tconst canUpload = !! mediaUpload;\n\tconst editMediaButtonRef = useRef();\n\tconst errorNoticeID = `block-editor/media-replace-flow/error-notice/${ ++uniqueId }`;\n\n\tconst onUploadError = ( message ) => {\n\t\tconst safeMessage = stripHTML( message );\n\t\tif ( onError ) {\n\t\t\tonError( safeMessage );\n\t\t\treturn;\n\t\t}\n\t\t// We need to set a timeout for showing the notice\n\t\t// so that VoiceOver and possibly other screen readers\n\t\t// can announce the error after the toolbar button\n\t\t// regains focus once the upload dialog closes.\n\t\t// Otherwise VO simply skips over the notice and announces\n\t\t// the focused element and the open menu.\n\t\tsetTimeout( () => {\n\t\t\tcreateNotice( 'error', safeMessage, {\n\t\t\t\tspeak: true,\n\t\t\t\tid: errorNoticeID,\n\t\t\t\tisDismissible: true,\n\t\t\t} );\n\t\t}, 1000 );\n\t};\n\n\tconst selectMedia = ( media, closeMenu ) => {\n\t\tif ( useFeaturedImage && onToggleFeaturedImage ) {\n\t\t\tonToggleFeaturedImage();\n\t\t}\n\t\tcloseMenu();\n\t\t// Calling `onSelect` after the state update since it might unmount the component.\n\t\tonSelect( media );\n\t\tspeak( __( 'The media file has been replaced' ) );\n\t\tremoveNotice( errorNoticeID );\n\t};\n\n\tconst uploadFiles = ( event, closeMenu ) => {\n\t\tconst files = event.target.files;\n\t\tif ( ! handleUpload ) {\n\t\t\tcloseMenu();\n\t\t\treturn onSelect( files );\n\t\t}\n\t\tonFilesUpload( files );\n\t\tmediaUpload( {\n\t\t\tallowedTypes,\n\t\t\tfilesList: files,\n\t\t\tonFileChange: ( [ media ] ) => {\n\t\t\t\tselectMedia( media, closeMenu );\n\t\t\t},\n\t\t\tonError: onUploadError,\n\t\t} );\n\t};\n\n\tconst openOnArrowDown = ( event ) => {\n\t\tif ( event.keyCode === DOWN ) {\n\t\t\tevent.preventDefault();\n\t\t\tevent.target.click();\n\t\t}\n\t};\n\n\tconst onlyAllowsImages = () => {\n\t\tif ( ! allowedTypes || allowedTypes.length === 0 ) {\n\t\t\treturn false;\n\t\t}\n\n\t\treturn allowedTypes.every(\n\t\t\t( allowedType ) =>\n\t\t\t\tallowedType === 'image' || allowedType.startsWith( 'image/' )\n\t\t);\n\t};\n\n\tconst gallery = multiple && onlyAllowsImages();\n\n\treturn (\n\t\t<Dropdown\n\t\t\tpopoverProps={ popoverProps }\n\t\t\tcontentClassName=\"block-editor-media-replace-flow__options\"\n\t\t\trenderToggle={ ( { isOpen, onToggle } ) => (\n\t\t\t\t<ToolbarButton\n\t\t\t\t\tref={ editMediaButtonRef }\n\t\t\t\t\taria-expanded={ isOpen }\n\t\t\t\t\taria-haspopup=\"true\"\n\t\t\t\t\tonClick={ onToggle }\n\t\t\t\t\tonKeyDown={ openOnArrowDown }\n\t\t\t\t>\n\t\t\t\t\t{ name }\n\t\t\t\t</ToolbarButton>\n\t\t\t) }\n\t\t\trenderContent={ ( { onClose } ) => (\n\t\t\t\t<>\n\t\t\t\t\t<NavigableMenu className=\"block-editor-media-replace-flow__media-upload-menu\">\n\t\t\t\t\t\t<MediaUploadCheck>\n\t\t\t\t\t\t\t<MediaUpload\n\t\t\t\t\t\t\t\tgallery={ gallery }\n\t\t\t\t\t\t\t\taddToGallery={ addToGallery }\n\t\t\t\t\t\t\t\tmultiple={ multiple }\n\t\t\t\t\t\t\t\tvalue={ multiple ? mediaIds : mediaId }\n\t\t\t\t\t\t\t\tonSelect={ ( media ) =>\n\t\t\t\t\t\t\t\t\tselectMedia( media, onClose )\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tallowedTypes={ allowedTypes }\n\t\t\t\t\t\t\t\trender={ ( { open } ) => (\n\t\t\t\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\t\t\t\ticon={ mediaIcon }\n\t\t\t\t\t\t\t\t\t\tonClick={ open }\n\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t{ __( 'Open Media Library' ) }\n\t\t\t\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t<FormFileUpload\n\t\t\t\t\t\t\t\tonChange={ ( event ) => {\n\t\t\t\t\t\t\t\t\tuploadFiles( event, onClose );\n\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\taccept={ accept }\n\t\t\t\t\t\t\t\tmultiple={ !! multiple }\n\t\t\t\t\t\t\t\trender={ ( { openFileDialog } ) => {\n\t\t\t\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\t\t\t\t\ticon={ upload }\n\t\t\t\t\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\t\t\t\t\topenFileDialog();\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{ __( 'Upload' ) }\n\t\t\t\t\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</MediaUploadCheck>\n\t\t\t\t\t\t{ onToggleFeaturedImage && (\n\t\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\t\ticon={ postFeaturedImage }\n\t\t\t\t\t\t\t\tonClick={ onToggleFeaturedImage }\n\t\t\t\t\t\t\t\tisPressed={ useFeaturedImage }\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{ __( 'Use featured image' ) }\n\t\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t\t) }\n\t\t\t\t\t\t{ mediaURL && onReset && (\n\t\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\t\tonReset();\n\t\t\t\t\t\t\t\t\tonClose();\n\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{ __( 'Reset' ) }\n\t\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t\t) }\n\t\t\t\t\t\t{ typeof children === 'function'\n\t\t\t\t\t\t\t? children( { onClose } )\n\t\t\t\t\t\t\t: children }\n\t\t\t\t\t</NavigableMenu>\n\t\t\t\t\t{ onSelectURL && (\n\t\t\t\t\t\t// eslint-disable-next-line jsx-a11y/no-noninteractive-element-interactions\n\t\t\t\t\t\t<form\n\t\t\t\t\t\t\tclassName={ clsx(\n\t\t\t\t\t\t\t\t'block-editor-media-flow__url-input',\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t'has-siblings':\n\t\t\t\t\t\t\t\t\t\tcanUpload || onToggleFeaturedImage,\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<span className=\"block-editor-media-replace-flow__image-url-label\">\n\t\t\t\t\t\t\t\t{ __( 'Current media URL:' ) }\n\t\t\t\t\t\t\t</span>\n\n\t\t\t\t\t\t\t<LinkControl\n\t\t\t\t\t\t\t\tvalue={ { url: mediaURL } }\n\t\t\t\t\t\t\t\tsettings={ [] }\n\t\t\t\t\t\t\t\tshowSuggestions={ false }\n\t\t\t\t\t\t\t\tonChange={ ( { url } ) => {\n\t\t\t\t\t\t\t\t\tonSelectURL( url );\n\t\t\t\t\t\t\t\t\teditMediaButtonRef.current.focus();\n\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</form>\n\t\t\t\t\t) }\n\t\t\t\t</>\n\t\t\t) }\n\t\t/>\n\t);\n};\n\n/**\n * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/media-replace-flow/README.md\n */\nexport default compose( [\n\twithDispatch( ( dispatch ) => {\n\t\tconst { createNotice, removeNotice } = dispatch( noticesStore );\n\t\treturn {\n\t\t\tcreateNotice,\n\t\t\tremoveNotice,\n\t\t};\n\t} ),\n\twithFilters( 'editor.MediaReplaceFlow' ),\n] )( MediaReplaceFlow );\n"],"mappings":";;;;;;;AAGA,IAAAA,KAAA,GAAAC,sBAAA,CAAAC,OAAA;AAKA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA;AACA,IAAAG,KAAA,GAAAH,OAAA;AACA,IAAAI,WAAA,GAAAJ,OAAA;AAQA,IAAAK,KAAA,GAAAL,OAAA;AACA,IAAAM,SAAA,GAAAN,OAAA;AACA,IAAAO,MAAA,GAAAP,OAAA;AAKA,IAAAQ,QAAA,GAAAR,OAAA;AACA,IAAAS,IAAA,GAAAT,OAAA;AACA,IAAAU,QAAA,GAAAV,OAAA;AAKA,IAAAW,YAAA,GAAAZ,sBAAA,CAAAC,OAAA;AACA,IAAAY,MAAA,GAAAb,sBAAA,CAAAC,OAAA;AACA,IAAAa,YAAA,GAAAd,sBAAA,CAAAC,OAAA;AACA,IAAAc,MAAA,GAAAd,OAAA;AAAwD,IAAAe,WAAA,GAAAf,OAAA;AApCxD;AACA;AACA;;AAGA;AACA;AACA;;AAuBA;AACA;AACA;;AAMA,MAAMgB,IAA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Z;MACA,IAAAX,WAAA,CAAA0E,IAAA;QACCG,SAAS,EAAG,IAAAc,aAAI,EACf,oCAAoC,EACpC;UACC,cAAc,EACb7D,SAAS,IAAIjB;QACf,CACD,CAAG;QAAAO,QAAA,gBAEH,IAAApB,WAAA,CAAA8D,GAAA;UAAMe,SAAS,EAAC,kDAAkD;UAAAzD,QAAA,EAC/D,IAAAH,QAAE,EAAE,oBAAqB;QAAC,CACvB,CAAC,eAEP,IAAAjB,WAAA,CAAA8D,GAAA,EAAChE,YAAA,CAAAgF,OAAW;UACXC,KAAK,EAAG;YAAEa,GAAG,EAAExF;UAAS,CAAG;UAC3ByF,QAAQ,EAAG,EAAI;UACfC,eAAe,EAAG,KAAO;UACzBR,QAAQ,EAAGA,CAAE;YAAEM;UAAI,CAAC,KAAM;YACzBjF,WAAW,CAAEiF,GAAI,CAAC;YAClB7D,kBAAkB,CAACgE,OAAO,CAACC,KAAK,CAAC,CAAC;UACnC;QAAG,CACH,CAAC;MAAA,CACG,CACN;IAAA,CACA;EACA,CACH,CAAC;AAEJ,CAAC;;AAED;AACA;AACA;AAFA,IAAAC,QAAA,GAAAC,OAAA,CAAApB,OAAA,GAGe,IAAAqB,gBAAO,EAAE,CACvB,IAAAC,kBAAY,EAAIC,QAAQ,IAAM;EAC7B,MAAM;IAAEnF,YAAY;IAAEC;EAAa,CAAC,GAAGkF,QAAQ,CAAEC,cAAa,CAAC;EAC/D,OAAO;IACNpF,YAAY;IACZC;EACD,CAAC;AACF,CAAE,CAAC,EACH,IAAAoF,uBAAW,EAAE,yBAA0B,CAAC,CACvC,CAAC,CAAEpG,gBAAiB,CAAC","ignoreList":[]}
|
|
@@ -265,8 +265,11 @@ function URLInput(props) {
|
|
|
265
265
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.PanelBody, {
|
|
266
266
|
style: _style.default['media-upload__link-input'],
|
|
267
267
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.TextControl
|
|
268
|
-
//
|
|
268
|
+
// TODO: Switch to `true` (40px size) if possible
|
|
269
269
|
, {
|
|
270
|
+
__next40pxDefaultSize: false
|
|
271
|
+
// eslint-disable-next-line jsx-a11y/no-autofocus
|
|
272
|
+
,
|
|
270
273
|
autoFocus: true,
|
|
271
274
|
autoCapitalize: "none",
|
|
272
275
|
autoCorrect: false,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_reactNative","require","_element","_i18n","_components","_reactNativeBridge","_icons","_blockEditor","_compose","_data","_constants","_style","_interopRequireDefault","_jsxRuntime","URL_MEDIA_SOURCE","PICKER_OPENING_DELAY","MediaUpload","Component","pickerTimeout","constructor","props","onPickerPresent","bind","onPickerSelect","getAllSources","state","url","showURLInput","otherMediaOptions","componentDidMount","allowedTypes","autoOpen","getOtherMediaOptions","otherMediaOptionsWithIcons","map","option","requiresModal","types","id","value","setState","componentWillUnmount","clearTimeout","onSelectURL","cameraImageSource","mediaSources","deviceCamera","label","OPTION_TAKE_PHOTO","MEDIA_TYPE_IMAGE","icon","capturePhoto","cameraVideoSource","OPTION_TAKE_VIDEO","MEDIA_TYPE_VIDEO","captureVideo","deviceLibrarySource","deviceLibrary","__","image","siteLibrarySource","siteMediaLibrary","OPTION_WORDPRESS_MEDIA_LIBRARY","MEDIA_TYPE_AUDIO","MEDIA_TYPE_ANY","wordpress","mediaLibrary","urlSource","OPTION_INSERT_FROM_URL","globe","internalSources","concat","getMediaOptionsItems","__experimentalOnlyMediaLibrary","isAudioBlockMediaUploadEnabled","filter","source","every","allowedType","includes","some","getChooseFromDeviceIcon","mobile","isIOS","Platform","OS","picker","setTimeout","presentPicker","onSelect","multiple","mediaSource","shift","type","requestMediaPicker","media","render","isReplacingMedia","isOneType","length","isImage","isVideo","isAudio","isAnyType","isImageOrVideo","pickerTitle","getMediaOptions","jsx","Picker","title","hideCancelButton","ref","instance","options","onChange","testID","jsxs","Fragment","children","URLInput","isVisible","onClose","open","exports","BottomSheet","hideHeader","PanelBody","style","styles","TextControl","autoFocus","autoCapitalize","autoCorrect","autoComplete","keyboardType","placeholder","_default","default","compose","withSelect","select","capabilities","blockEditorStore","getSettings"],"sources":["@wordpress/block-editor/src/components/media-upload/index.native.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport { Platform } from 'react-native';\n\n/**\n * WordPress dependencies\n */\nimport { Component, React } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport {\n\tBottomSheet,\n\tPanelBody,\n\tPicker,\n\tTextControl,\n} from '@wordpress/components';\nimport {\n\tgetOtherMediaOptions,\n\trequestMediaPicker,\n\tmediaSources,\n} from '@wordpress/react-native-bridge';\nimport {\n\tcapturePhoto,\n\tcaptureVideo,\n\timage,\n\twordpress,\n\tmobile,\n\tglobe,\n} from '@wordpress/icons';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\nimport { compose } from '@wordpress/compose';\nimport { withSelect } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport {\n\tMEDIA_TYPE_IMAGE,\n\tMEDIA_TYPE_VIDEO,\n\tMEDIA_TYPE_AUDIO,\n\tMEDIA_TYPE_ANY,\n\tOPTION_TAKE_VIDEO,\n\tOPTION_TAKE_PHOTO,\n\tOPTION_INSERT_FROM_URL,\n\tOPTION_WORDPRESS_MEDIA_LIBRARY,\n} from './constants';\nimport styles from './style.scss';\n\nconst URL_MEDIA_SOURCE = 'URL';\n\nconst PICKER_OPENING_DELAY = 200;\n\nexport class MediaUpload extends Component {\n\tpickerTimeout;\n\n\tconstructor( props ) {\n\t\tsuper( props );\n\t\tthis.onPickerPresent = this.onPickerPresent.bind( this );\n\t\tthis.onPickerSelect = this.onPickerSelect.bind( this );\n\t\tthis.getAllSources = this.getAllSources.bind( this );\n\t\tthis.state = {\n\t\t\turl: '',\n\t\t\tshowURLInput: false,\n\t\t\totherMediaOptions: [],\n\t\t};\n\t}\n\n\tcomponentDidMount() {\n\t\tconst { allowedTypes = [], autoOpen } = this.props;\n\t\tgetOtherMediaOptions( allowedTypes, ( otherMediaOptions ) => {\n\t\t\tconst otherMediaOptionsWithIcons = otherMediaOptions.map(\n\t\t\t\t( option ) => {\n\t\t\t\t\treturn {\n\t\t\t\t\t\t...option,\n\t\t\t\t\t\trequiresModal: true,\n\t\t\t\t\t\ttypes: allowedTypes,\n\t\t\t\t\t\tid: option.value,\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t);\n\n\t\t\tthis.setState( { otherMediaOptions: otherMediaOptionsWithIcons } );\n\t\t} );\n\n\t\tif ( autoOpen ) {\n\t\t\tthis.onPickerPresent();\n\t\t}\n\t}\n\n\tcomponentWillUnmount() {\n\t\tclearTimeout( this.pickerTimeout );\n\t}\n\n\tgetAllSources() {\n\t\tconst { onSelectURL } = this.props;\n\n\t\tconst cameraImageSource = {\n\t\t\tid: mediaSources.deviceCamera, // ID is the value sent to native.\n\t\t\tvalue: mediaSources.deviceCamera + '-IMAGE', // This is needed to diferenciate image-camera from video-camera sources.\n\t\t\tlabel: OPTION_TAKE_PHOTO,\n\t\t\trequiresModal: true,\n\t\t\ttypes: [ MEDIA_TYPE_IMAGE ],\n\t\t\ticon: capturePhoto,\n\t\t};\n\n\t\tconst cameraVideoSource = {\n\t\t\tid: mediaSources.deviceCamera,\n\t\t\tvalue: mediaSources.deviceCamera,\n\t\t\tlabel: OPTION_TAKE_VIDEO,\n\t\t\trequiresModal: true,\n\t\t\ttypes: [ MEDIA_TYPE_VIDEO ],\n\t\t\ticon: captureVideo,\n\t\t};\n\n\t\tconst deviceLibrarySource = {\n\t\t\tid: mediaSources.deviceLibrary,\n\t\t\tvalue: mediaSources.deviceLibrary,\n\t\t\tlabel: __( 'Choose from device' ),\n\t\t\trequiresModal: true,\n\t\t\ttypes: [ MEDIA_TYPE_IMAGE, MEDIA_TYPE_VIDEO ],\n\t\t\ticon: image,\n\t\t};\n\n\t\tconst siteLibrarySource = {\n\t\t\tid: mediaSources.siteMediaLibrary,\n\t\t\tvalue: mediaSources.siteMediaLibrary,\n\t\t\tlabel: OPTION_WORDPRESS_MEDIA_LIBRARY,\n\t\t\trequiresModal: true,\n\t\t\ttypes: [\n\t\t\t\tMEDIA_TYPE_IMAGE,\n\t\t\t\tMEDIA_TYPE_VIDEO,\n\t\t\t\tMEDIA_TYPE_AUDIO,\n\t\t\t\tMEDIA_TYPE_ANY,\n\t\t\t],\n\t\t\ticon: wordpress,\n\t\t\tmediaLibrary: true,\n\t\t};\n\n\t\tconst urlSource = {\n\t\t\tid: URL_MEDIA_SOURCE,\n\t\t\tvalue: URL_MEDIA_SOURCE,\n\t\t\tlabel: OPTION_INSERT_FROM_URL,\n\t\t\ttypes: [ MEDIA_TYPE_AUDIO, MEDIA_TYPE_IMAGE, MEDIA_TYPE_VIDEO ],\n\t\t\ticon: globe,\n\t\t};\n\n\t\t// Only include `urlSource` option if `onSelectURL` prop is present, in order to match the web behavior.\n\t\tconst internalSources = [\n\t\t\tdeviceLibrarySource,\n\t\t\tcameraImageSource,\n\t\t\tcameraVideoSource,\n\t\t\tsiteLibrarySource,\n\t\t\t...( onSelectURL ? [ urlSource ] : [] ),\n\t\t];\n\n\t\treturn internalSources.concat( this.state.otherMediaOptions );\n\t}\n\n\tgetMediaOptionsItems() {\n\t\tconst {\n\t\t\tallowedTypes = [],\n\t\t\t__experimentalOnlyMediaLibrary,\n\t\t\tisAudioBlockMediaUploadEnabled,\n\t\t} = this.props;\n\n\t\treturn this.getAllSources()\n\t\t\t.filter( ( source ) => {\n\t\t\t\tif ( __experimentalOnlyMediaLibrary ) {\n\t\t\t\t\treturn source.mediaLibrary;\n\t\t\t\t} else if (\n\t\t\t\t\tallowedTypes.every(\n\t\t\t\t\t\t( allowedType ) =>\n\t\t\t\t\t\t\tallowedType === MEDIA_TYPE_AUDIO &&\n\t\t\t\t\t\t\tsource.types.includes( allowedType )\n\t\t\t\t\t) &&\n\t\t\t\t\tsource.id !== URL_MEDIA_SOURCE\n\t\t\t\t) {\n\t\t\t\t\treturn isAudioBlockMediaUploadEnabled === true;\n\t\t\t\t}\n\n\t\t\t\treturn allowedTypes.some( ( allowedType ) =>\n\t\t\t\t\tsource.types.includes( allowedType )\n\t\t\t\t);\n\t\t\t} )\n\t\t\t.map( ( source ) => {\n\t\t\t\treturn {\n\t\t\t\t\t...source,\n\t\t\t\t\ticon: source.icon || this.getChooseFromDeviceIcon(),\n\t\t\t\t};\n\t\t\t} );\n\t}\n\n\tgetChooseFromDeviceIcon() {\n\t\treturn mobile;\n\t}\n\n\tonPickerPresent() {\n\t\tconst { autoOpen } = this.props;\n\t\tconst isIOS = Platform.OS === 'ios';\n\n\t\tif ( this.picker ) {\n\t\t\t// the delay below is required because on iOS this action sheet gets dismissed by the close event of the Inserter\n\t\t\t// so this delay allows the Inserter to be closed fully before presenting action sheet.\n\t\t\tif ( autoOpen && isIOS ) {\n\t\t\t\tthis.pickerTimeout = setTimeout(\n\t\t\t\t\t() => this.picker.presentPicker(),\n\t\t\t\t\tPICKER_OPENING_DELAY\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\tthis.picker.presentPicker();\n\t\t\t}\n\t\t}\n\t}\n\n\tonPickerSelect( value ) {\n\t\tconst { allowedTypes = [], onSelect, multiple = false } = this.props;\n\n\t\tif ( value === URL_MEDIA_SOURCE ) {\n\t\t\tthis.setState( { showURLInput: true } );\n\t\t\treturn;\n\t\t}\n\n\t\tconst mediaSource = this.getAllSources()\n\t\t\t.filter( ( source ) => source.value === value )\n\t\t\t.shift();\n\t\tconst types = allowedTypes.filter( ( type ) =>\n\t\t\tmediaSource.types.includes( type )\n\t\t);\n\n\t\trequestMediaPicker( mediaSource.id, types, multiple, ( media ) => {\n\t\t\tif ( ( multiple && media ) || ( media && media.id ) ) {\n\t\t\t\tonSelect( media );\n\t\t\t}\n\t\t} );\n\t}\n\n\trender() {\n\t\tconst { allowedTypes = [], isReplacingMedia, multiple } = this.props;\n\t\tconst isOneType = allowedTypes.length === 1;\n\t\tconst isImage = isOneType && allowedTypes.includes( MEDIA_TYPE_IMAGE );\n\t\tconst isVideo = isOneType && allowedTypes.includes( MEDIA_TYPE_VIDEO );\n\t\tconst isAudio = isOneType && allowedTypes.includes( MEDIA_TYPE_AUDIO );\n\t\tconst isAnyType = isOneType && allowedTypes.includes( MEDIA_TYPE_ANY );\n\n\t\tconst isImageOrVideo =\n\t\t\tallowedTypes.length === 2 &&\n\t\t\tallowedTypes.includes( MEDIA_TYPE_IMAGE ) &&\n\t\t\tallowedTypes.includes( MEDIA_TYPE_VIDEO );\n\n\t\tlet pickerTitle;\n\t\tif ( isImage ) {\n\t\t\tif ( isReplacingMedia ) {\n\t\t\t\tpickerTitle = __( 'Replace image' );\n\t\t\t} else {\n\t\t\t\tpickerTitle = multiple\n\t\t\t\t\t? __( 'Choose images' )\n\t\t\t\t\t: __( 'Choose image' );\n\t\t\t}\n\t\t} else if ( isVideo ) {\n\t\t\tif ( isReplacingMedia ) {\n\t\t\t\tpickerTitle = __( 'Replace video' );\n\t\t\t} else {\n\t\t\t\tpickerTitle = __( 'Choose video' );\n\t\t\t}\n\t\t} else if ( isImageOrVideo ) {\n\t\t\tif ( isReplacingMedia ) {\n\t\t\t\tpickerTitle = __( 'Replace image or video' );\n\t\t\t} else {\n\t\t\t\tpickerTitle = __( 'Choose image or video' );\n\t\t\t}\n\t\t} else if ( isAudio ) {\n\t\t\tif ( isReplacingMedia ) {\n\t\t\t\tpickerTitle = __( 'Replace audio' );\n\t\t\t} else {\n\t\t\t\tpickerTitle = __( 'Choose audio' );\n\t\t\t}\n\t\t} else if ( isAnyType ) {\n\t\t\tpickerTitle = __( 'Choose file' );\n\t\t\tif ( isReplacingMedia ) {\n\t\t\t\tpickerTitle = __( 'Replace file' );\n\t\t\t} else {\n\t\t\t\tpickerTitle = __( 'Choose file' );\n\t\t\t}\n\t\t}\n\n\t\tconst getMediaOptions = () => (\n\t\t\t<Picker\n\t\t\t\ttitle={ pickerTitle }\n\t\t\t\thideCancelButton\n\t\t\t\tref={ ( instance ) => ( this.picker = instance ) }\n\t\t\t\toptions={ this.getMediaOptionsItems() }\n\t\t\t\tonChange={ this.onPickerSelect }\n\t\t\t\ttestID=\"media-options-picker\"\n\t\t\t/>\n\t\t);\n\n\t\treturn (\n\t\t\t<>\n\t\t\t\t<URLInput\n\t\t\t\t\tisVisible={ this.state.showURLInput }\n\t\t\t\t\tonClose={ () => {\n\t\t\t\t\t\tif ( this.state.url !== '' ) {\n\t\t\t\t\t\t\tthis.props.onSelectURL( this.state.url );\n\t\t\t\t\t\t}\n\t\t\t\t\t\tthis.setState( { showURLInput: false, url: '' } );\n\t\t\t\t\t} }\n\t\t\t\t\tonChange={ ( url ) => {\n\t\t\t\t\t\tthis.setState( { url } );\n\t\t\t\t\t} }\n\t\t\t\t\tvalue={ this.state.url }\n\t\t\t\t/>\n\t\t\t\t{ this.props.render( {\n\t\t\t\t\topen: this.onPickerPresent,\n\t\t\t\t\tgetMediaOptions,\n\t\t\t\t} ) }\n\t\t\t</>\n\t\t);\n\t}\n}\n\nfunction URLInput( props ) {\n\treturn (\n\t\t<BottomSheet\n\t\t\thideHeader\n\t\t\tisVisible={ props.isVisible }\n\t\t\tonClose={ props.onClose }\n\t\t>\n\t\t\t<PanelBody style={ styles[ 'media-upload__link-input' ] }>\n\t\t\t\t<TextControl\n\t\t\t\t\t// eslint-disable-next-line jsx-a11y/no-autofocus\n\t\t\t\t\tautoFocus\n\t\t\t\t\tautoCapitalize=\"none\"\n\t\t\t\t\tautoCorrect={ false }\n\t\t\t\t\tautoComplete={ Platform.isIOS ? 'url' : 'off' }\n\t\t\t\t\tkeyboardType=\"url\"\n\t\t\t\t\tlabel={ OPTION_INSERT_FROM_URL }\n\t\t\t\t\tonChange={ props.onChange }\n\t\t\t\t\tplaceholder={ __( 'Type a URL' ) }\n\t\t\t\t\tvalue={ props.value }\n\t\t\t\t/>\n\t\t\t</PanelBody>\n\t\t</BottomSheet>\n\t);\n}\n\nexport default compose( [\n\twithSelect( ( select ) => {\n\t\tconst { capabilities } = select( blockEditorStore ).getSettings();\n\t\treturn {\n\t\t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IAAAH,QAAA,eAEzB,IAAAzG,WAAA,CAAA8F,GAAA,EAACvG,WAAA,CAAA0H,SAAS;MAACC,KAAK,EAAGC,cAAM,CAAE,0BAA0B,CAAI;MAAAV,QAAA,eACxD,IAAAzG,WAAA,CAAA8F,GAAA,EAACvG,WAAA,CAAA6H;MACA;MAAA;QACAC,SAAS;QACTC,cAAc,EAAC,MAAM;QACrBC,WAAW,EAAG,KAAO;QACrBC,YAAY,EAAGjD,qBAAQ,CAACD,KAAK,GAAG,KAAK,GAAG,KAAO;QAC/CmD,YAAY,EAAC,KAAK;QAClBvF,KAAK,EAAGqB,iCAAwB;QAChC8C,QAAQ,EAAG9F,KAAK,CAAC8F,QAAU;QAC3BqB,WAAW,EAAG,IAAA7E,QAAE,EAAE,YAAa,CAAG;QAClCnB,KAAK,EAAGnB,KAAK,CAACmB;MAAO,CACrB;IAAC,CACQ;EAAC,CACA,CAAC;AAEhB;AAAC,IAAAiG,QAAA,GAAAb,OAAA,CAAAc,OAAA,GAEc,IAAAC,gBAAO,EAAE,CACvB,IAAAC,gBAAU,EAAIC,MAAM,IAAM;EACzB,MAAM;IAAEC;EAAa,CAAC,GAAGD,MAAM,CAAEE,kBAAiB,CAAC,CAACC,WAAW,CAAC,CAAC;EACjE,OAAO;IACNrE,8BAA8B,EAC7BmE,YAAY,EAAEnE,8BAA8B,KAAK;EACnD,CAAC;AACF,CAAE,CAAC,CACF,CAAC,CAAE1D,WAAY,CAAC","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["_reactNative","require","_element","_i18n","_components","_reactNativeBridge","_icons","_blockEditor","_compose","_data","_constants","_style","_interopRequireDefault","_jsxRuntime","URL_MEDIA_SOURCE","PICKER_OPENING_DELAY","MediaUpload","Component","pickerTimeout","constructor","props","onPickerPresent","bind","onPickerSelect","getAllSources","state","url","showURLInput","otherMediaOptions","componentDidMount","allowedTypes","autoOpen","getOtherMediaOptions","otherMediaOptionsWithIcons","map","option","requiresModal","types","id","value","setState","componentWillUnmount","clearTimeout","onSelectURL","cameraImageSource","mediaSources","deviceCamera","label","OPTION_TAKE_PHOTO","MEDIA_TYPE_IMAGE","icon","capturePhoto","cameraVideoSource","OPTION_TAKE_VIDEO","MEDIA_TYPE_VIDEO","captureVideo","deviceLibrarySource","deviceLibrary","__","image","siteLibrarySource","siteMediaLibrary","OPTION_WORDPRESS_MEDIA_LIBRARY","MEDIA_TYPE_AUDIO","MEDIA_TYPE_ANY","wordpress","mediaLibrary","urlSource","OPTION_INSERT_FROM_URL","globe","internalSources","concat","getMediaOptionsItems","__experimentalOnlyMediaLibrary","isAudioBlockMediaUploadEnabled","filter","source","every","allowedType","includes","some","getChooseFromDeviceIcon","mobile","isIOS","Platform","OS","picker","setTimeout","presentPicker","onSelect","multiple","mediaSource","shift","type","requestMediaPicker","media","render","isReplacingMedia","isOneType","length","isImage","isVideo","isAudio","isAnyType","isImageOrVideo","pickerTitle","getMediaOptions","jsx","Picker","title","hideCancelButton","ref","instance","options","onChange","testID","jsxs","Fragment","children","URLInput","isVisible","onClose","open","exports","BottomSheet","hideHeader","PanelBody","style","styles","TextControl","__next40pxDefaultSize","autoFocus","autoCapitalize","autoCorrect","autoComplete","keyboardType","placeholder","_default","default","compose","withSelect","select","capabilities","blockEditorStore","getSettings"],"sources":["@wordpress/block-editor/src/components/media-upload/index.native.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport { Platform } from 'react-native';\n\n/**\n * WordPress dependencies\n */\nimport { Component, React } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport {\n\tBottomSheet,\n\tPanelBody,\n\tPicker,\n\tTextControl,\n} from '@wordpress/components';\nimport {\n\tgetOtherMediaOptions,\n\trequestMediaPicker,\n\tmediaSources,\n} from '@wordpress/react-native-bridge';\nimport {\n\tcapturePhoto,\n\tcaptureVideo,\n\timage,\n\twordpress,\n\tmobile,\n\tglobe,\n} from '@wordpress/icons';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\nimport { compose } from '@wordpress/compose';\nimport { withSelect } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport {\n\tMEDIA_TYPE_IMAGE,\n\tMEDIA_TYPE_VIDEO,\n\tMEDIA_TYPE_AUDIO,\n\tMEDIA_TYPE_ANY,\n\tOPTION_TAKE_VIDEO,\n\tOPTION_TAKE_PHOTO,\n\tOPTION_INSERT_FROM_URL,\n\tOPTION_WORDPRESS_MEDIA_LIBRARY,\n} from './constants';\nimport styles from './style.scss';\n\nconst URL_MEDIA_SOURCE = 'URL';\n\nconst PICKER_OPENING_DELAY = 200;\n\nexport class MediaUpload extends Component {\n\tpickerTimeout;\n\n\tconstructor( props ) {\n\t\tsuper( props );\n\t\tthis.onPickerPresent = this.onPickerPresent.bind( this );\n\t\tthis.onPickerSelect = this.onPickerSelect.bind( this );\n\t\tthis.getAllSources = this.getAllSources.bind( this );\n\t\tthis.state = {\n\t\t\turl: '',\n\t\t\tshowURLInput: false,\n\t\t\totherMediaOptions: [],\n\t\t};\n\t}\n\n\tcomponentDidMount() {\n\t\tconst { allowedTypes = [], autoOpen } = this.props;\n\t\tgetOtherMediaOptions( allowedTypes, ( otherMediaOptions ) => {\n\t\t\tconst otherMediaOptionsWithIcons = otherMediaOptions.map(\n\t\t\t\t( option ) => {\n\t\t\t\t\treturn {\n\t\t\t\t\t\t...option,\n\t\t\t\t\t\trequiresModal: true,\n\t\t\t\t\t\ttypes: allowedTypes,\n\t\t\t\t\t\tid: option.value,\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t);\n\n\t\t\tthis.setState( { otherMediaOptions: otherMediaOptionsWithIcons } );\n\t\t} );\n\n\t\tif ( autoOpen ) {\n\t\t\tthis.onPickerPresent();\n\t\t}\n\t}\n\n\tcomponentWillUnmount() {\n\t\tclearTimeout( this.pickerTimeout );\n\t}\n\n\tgetAllSources() {\n\t\tconst { onSelectURL } = this.props;\n\n\t\tconst cameraImageSource = {\n\t\t\tid: mediaSources.deviceCamera, // ID is the value sent to native.\n\t\t\tvalue: mediaSources.deviceCamera + '-IMAGE', // This is needed to diferenciate image-camera from video-camera sources.\n\t\t\tlabel: OPTION_TAKE_PHOTO,\n\t\t\trequiresModal: true,\n\t\t\ttypes: [ MEDIA_TYPE_IMAGE ],\n\t\t\ticon: capturePhoto,\n\t\t};\n\n\t\tconst cameraVideoSource = {\n\t\t\tid: mediaSources.deviceCamera,\n\t\t\tvalue: mediaSources.deviceCamera,\n\t\t\tlabel: OPTION_TAKE_VIDEO,\n\t\t\trequiresModal: true,\n\t\t\ttypes: [ MEDIA_TYPE_VIDEO ],\n\t\t\ticon: captureVideo,\n\t\t};\n\n\t\tconst deviceLibrarySource = {\n\t\t\tid: mediaSources.deviceLibrary,\n\t\t\tvalue: mediaSources.deviceLibrary,\n\t\t\tlabel: __( 'Choose from device' ),\n\t\t\trequiresModal: true,\n\t\t\ttypes: [ MEDIA_TYPE_IMAGE, MEDIA_TYPE_VIDEO ],\n\t\t\ticon: image,\n\t\t};\n\n\t\tconst siteLibrarySource = {\n\t\t\tid: mediaSources.siteMediaLibrary,\n\t\t\tvalue: mediaSources.siteMediaLibrary,\n\t\t\tlabel: OPTION_WORDPRESS_MEDIA_LIBRARY,\n\t\t\trequiresModal: true,\n\t\t\ttypes: [\n\t\t\t\tMEDIA_TYPE_IMAGE,\n\t\t\t\tMEDIA_TYPE_VIDEO,\n\t\t\t\tMEDIA_TYPE_AUDIO,\n\t\t\t\tMEDIA_TYPE_ANY,\n\t\t\t],\n\t\t\ticon: wordpress,\n\t\t\tmediaLibrary: true,\n\t\t};\n\n\t\tconst urlSource = {\n\t\t\tid: URL_MEDIA_SOURCE,\n\t\t\tvalue: URL_MEDIA_SOURCE,\n\t\t\tlabel: OPTION_INSERT_FROM_URL,\n\t\t\ttypes: [ MEDIA_TYPE_AUDIO, MEDIA_TYPE_IMAGE, MEDIA_TYPE_VIDEO ],\n\t\t\ticon: globe,\n\t\t};\n\n\t\t// Only include `urlSource` option if `onSelectURL` prop is present, in order to match the web behavior.\n\t\tconst internalSources = [\n\t\t\tdeviceLibrarySource,\n\t\t\tcameraImageSource,\n\t\t\tcameraVideoSource,\n\t\t\tsiteLibrarySource,\n\t\t\t...( onSelectURL ? [ urlSource ] : [] ),\n\t\t];\n\n\t\treturn internalSources.concat( this.state.otherMediaOptions );\n\t}\n\n\tgetMediaOptionsItems() {\n\t\tconst {\n\t\t\tallowedTypes = [],\n\t\t\t__experimentalOnlyMediaLibrary,\n\t\t\tisAudioBlockMediaUploadEnabled,\n\t\t} = this.props;\n\n\t\treturn this.getAllSources()\n\t\t\t.filter( ( source ) => {\n\t\t\t\tif ( __experimentalOnlyMediaLibrary ) {\n\t\t\t\t\treturn source.mediaLibrary;\n\t\t\t\t} else if (\n\t\t\t\t\tallowedTypes.every(\n\t\t\t\t\t\t( allowedType ) =>\n\t\t\t\t\t\t\tallowedType === MEDIA_TYPE_AUDIO &&\n\t\t\t\t\t\t\tsource.types.includes( allowedType )\n\t\t\t\t\t) &&\n\t\t\t\t\tsource.id !== URL_MEDIA_SOURCE\n\t\t\t\t) {\n\t\t\t\t\treturn isAudioBlockMediaUploadEnabled === true;\n\t\t\t\t}\n\n\t\t\t\treturn allowedTypes.some( ( allowedType ) =>\n\t\t\t\t\tsource.types.includes( allowedType )\n\t\t\t\t);\n\t\t\t} )\n\t\t\t.map( ( source ) => {\n\t\t\t\treturn {\n\t\t\t\t\t...source,\n\t\t\t\t\ticon: source.icon || this.getChooseFromDeviceIcon(),\n\t\t\t\t};\n\t\t\t} );\n\t}\n\n\tgetChooseFromDeviceIcon() {\n\t\treturn mobile;\n\t}\n\n\tonPickerPresent() {\n\t\tconst { autoOpen } = this.props;\n\t\tconst isIOS = Platform.OS === 'ios';\n\n\t\tif ( this.picker ) {\n\t\t\t// the delay below is required because on iOS this action sheet gets dismissed by the close event of the Inserter\n\t\t\t// so this delay allows the Inserter to be closed fully before presenting action sheet.\n\t\t\tif ( autoOpen && isIOS ) {\n\t\t\t\tthis.pickerTimeout = setTimeout(\n\t\t\t\t\t() => this.picker.presentPicker(),\n\t\t\t\t\tPICKER_OPENING_DELAY\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\tthis.picker.presentPicker();\n\t\t\t}\n\t\t}\n\t}\n\n\tonPickerSelect( value ) {\n\t\tconst { allowedTypes = [], onSelect, multiple = false } = this.props;\n\n\t\tif ( value === URL_MEDIA_SOURCE ) {\n\t\t\tthis.setState( { showURLInput: true } );\n\t\t\treturn;\n\t\t}\n\n\t\tconst mediaSource = this.getAllSources()\n\t\t\t.filter( ( source ) => source.value === value )\n\t\t\t.shift();\n\t\tconst types = allowedTypes.filter( ( type ) =>\n\t\t\tmediaSource.types.includes( type )\n\t\t);\n\n\t\trequestMediaPicker( mediaSource.id, types, multiple, ( media ) => {\n\t\t\tif ( ( multiple && media ) || ( media && media.id ) ) {\n\t\t\t\tonSelect( media );\n\t\t\t}\n\t\t} );\n\t}\n\n\trender() {\n\t\tconst { allowedTypes = [], isReplacingMedia, multiple } = this.props;\n\t\tconst isOneType = allowedTypes.length === 1;\n\t\tconst isImage = isOneType && allowedTypes.includes( MEDIA_TYPE_IMAGE );\n\t\tconst isVideo = isOneType && allowedTypes.includes( MEDIA_TYPE_VIDEO );\n\t\tconst isAudio = isOneType && allowedTypes.includes( MEDIA_TYPE_AUDIO );\n\t\tconst isAnyType = isOneType && allowedTypes.includes( MEDIA_TYPE_ANY );\n\n\t\tconst isImageOrVideo =\n\t\t\tallowedTypes.length === 2 &&\n\t\t\tallowedTypes.includes( MEDIA_TYPE_IMAGE ) &&\n\t\t\tallowedTypes.includes( MEDIA_TYPE_VIDEO );\n\n\t\tlet pickerTitle;\n\t\tif ( isImage ) {\n\t\t\tif ( isReplacingMedia ) {\n\t\t\t\tpickerTitle = __( 'Replace image' );\n\t\t\t} else {\n\t\t\t\tpickerTitle = multiple\n\t\t\t\t\t? __( 'Choose images' )\n\t\t\t\t\t: __( 'Choose image' );\n\t\t\t}\n\t\t} else if ( isVideo ) {\n\t\t\tif ( isReplacingMedia ) {\n\t\t\t\tpickerTitle = __( 'Replace video' );\n\t\t\t} else {\n\t\t\t\tpickerTitle = __( 'Choose video' );\n\t\t\t}\n\t\t} else if ( isImageOrVideo ) {\n\t\t\tif ( isReplacingMedia ) {\n\t\t\t\tpickerTitle = __( 'Replace image or video' );\n\t\t\t} else {\n\t\t\t\tpickerTitle = __( 'Choose image or video' );\n\t\t\t}\n\t\t} else if ( isAudio ) {\n\t\t\tif ( isReplacingMedia ) {\n\t\t\t\tpickerTitle = __( 'Replace audio' );\n\t\t\t} else {\n\t\t\t\tpickerTitle = __( 'Choose audio' );\n\t\t\t}\n\t\t} else if ( isAnyType ) {\n\t\t\tpickerTitle = __( 'Choose file' );\n\t\t\tif ( isReplacingMedia ) {\n\t\t\t\tpickerTitle = __( 'Replace file' );\n\t\t\t} else {\n\t\t\t\tpickerTitle = __( 'Choose file' );\n\t\t\t}\n\t\t}\n\n\t\tconst getMediaOptions = () => (\n\t\t\t<Picker\n\t\t\t\ttitle={ pickerTitle }\n\t\t\t\thideCancelButton\n\t\t\t\tref={ ( instance ) => ( this.picker = instance ) }\n\t\t\t\toptions={ this.getMediaOptionsItems() }\n\t\t\t\tonChange={ this.onPickerSelect }\n\t\t\t\ttestID=\"media-options-picker\"\n\t\t\t/>\n\t\t);\n\n\t\treturn (\n\t\t\t<>\n\t\t\t\t<URLInput\n\t\t\t\t\tisVisible={ this.state.showURLInput }\n\t\t\t\t\tonClose={ () => {\n\t\t\t\t\t\tif ( this.state.url !== '' ) {\n\t\t\t\t\t\t\tthis.props.onSelectURL( this.state.url );\n\t\t\t\t\t\t}\n\t\t\t\t\t\tthis.setState( { showURLInput: false, url: '' } );\n\t\t\t\t\t} }\n\t\t\t\t\tonChange={ ( url ) => {\n\t\t\t\t\t\tthis.setState( { url } );\n\t\t\t\t\t} }\n\t\t\t\t\tvalue={ this.state.url }\n\t\t\t\t/>\n\t\t\t\t{ this.props.render( {\n\t\t\t\t\topen: this.onPickerPresent,\n\t\t\t\t\tgetMediaOptions,\n\t\t\t\t} ) }\n\t\t\t</>\n\t\t);\n\t}\n}\n\nfunction URLInput( props ) {\n\treturn (\n\t\t<BottomSheet\n\t\t\thideHeader\n\t\t\tisVisible={ props.isVisible }\n\t\t\tonClose={ props.onClose }\n\t\t>\n\t\t\t<PanelBody style={ styles[ 'media-upload__link-input' ] }>\n\t\t\t\t<TextControl\n\t\t\t\t\t// TODO: Switch to `true` (40px size) if possible\n\t\t\t\t\t__next40pxDefaultSize={ false }\n\t\t\t\t\t// eslint-disable-next-line jsx-a11y/no-autofocus\n\t\t\t\t\tautoFocus\n\t\t\t\t\tautoCapitalize=\"none\"\n\t\t\t\t\tautoCorrect={ false }\n\t\t\t\t\tautoComplete={ Platform.isIOS ? 'url' : 'off' }\n\t\t\t\t\tkeyboardType=\"url\"\n\t\t\t\t\tlabel={ OPTION_INSERT_FROM_URL }\n\t\t\t\t\tonChange={ props.onChange }\n\t\t\t\t\tplaceholder={ __( 'Type a URL' ) }\n\t\t\t\t\tvalue={ props.value }\n\t\t\t\t/>\n\t\t\t</PanelBody>\n\t\t</BottomSheet>\n\t);\n}\n\nexport default compose( [\n\twithSelect( ( select ) => {\n\t\tconst { capabilities } = select( blockEditorStore ).getSettings();\n\t\treturn {\n\t\t\tisAudioBlockMediaUploadEnabled:\n\t\t\t\tcapabilities?.isAudioBlockMediaUploadEnabled === true,\n\t\t};\n\t} ),\n] )( MediaUpload );\n"],"mappings":";;;;;;;AAGA,IAAAA,YAAA,GAAAC,OAAA;AAKA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA;AACA,IAAAG,WAAA,GAAAH,OAAA;AAMA,IAAAI,kBAAA,GAAAJ,OAAA;AAKA,IAAAK,MAAA,GAAAL,OAAA;AAQA,IAAAM,YAAA,GAAAN,OAAA;AACA,IAAAO,QAAA,GAAAP,OAAA;AACA,IAAAQ,KAAA,GAAAR,OAAA;AAKA,IAAAS,UAAA,GAAAT,OAAA;AAUA,IAAAU,MAAA,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AAU;QAC3BsB,WAAW,EAAG,IAAA9E,QAAE,EAAE,YAAa,CAAG;QAClCnB,KAAK,EAAGnB,KAAK,CAACmB;MAAO,CACrB;IAAC,CACQ;EAAC,CACA,CAAC;AAEhB;AAAC,IAAAkG,QAAA,GAAAd,OAAA,CAAAe,OAAA,GAEc,IAAAC,gBAAO,EAAE,CACvB,IAAAC,gBAAU,EAAIC,MAAM,IAAM;EACzB,MAAM;IAAEC;EAAa,CAAC,GAAGD,MAAM,CAAEE,kBAAiB,CAAC,CAACC,WAAW,CAAC,CAAC;EACjE,OAAO;IACNtE,8BAA8B,EAC7BoE,YAAY,EAAEpE,8BAA8B,KAAK;EACnD,CAAC;AACF,CAAE,CAAC,CACF,CAAC,CAAE1D,WAAY,CAAC","ignoreList":[]}
|
|
@@ -4,7 +4,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
exports.default =
|
|
7
|
+
exports.default = MultiSelectionInspector;
|
|
8
8
|
var _i18n = require("@wordpress/i18n");
|
|
9
9
|
var _data = require("@wordpress/data");
|
|
10
10
|
var _blocks = require("@wordpress/blocks");
|
|
@@ -21,9 +21,17 @@ var _jsxRuntime = require("react/jsx-runtime");
|
|
|
21
21
|
* Internal dependencies
|
|
22
22
|
*/
|
|
23
23
|
|
|
24
|
-
function MultiSelectionInspector({
|
|
25
|
-
|
|
26
|
-
|
|
24
|
+
function MultiSelectionInspector() {
|
|
25
|
+
const {
|
|
26
|
+
blocks
|
|
27
|
+
} = (0, _data.useSelect)(select => {
|
|
28
|
+
const {
|
|
29
|
+
getMultiSelectedBlocks
|
|
30
|
+
} = select(_store.store);
|
|
31
|
+
return {
|
|
32
|
+
blocks: getMultiSelectedBlocks()
|
|
33
|
+
};
|
|
34
|
+
}, []);
|
|
27
35
|
const words = (0, _wordcount.count)((0, _blocks.serialize)(blocks), 'words');
|
|
28
36
|
return /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
29
37
|
className: "block-editor-multi-selection-inspector__card",
|
|
@@ -44,12 +52,4 @@ function MultiSelectionInspector({
|
|
|
44
52
|
})]
|
|
45
53
|
});
|
|
46
54
|
}
|
|
47
|
-
var _default = exports.default = (0, _data.withSelect)(select => {
|
|
48
|
-
const {
|
|
49
|
-
getMultiSelectedBlocks
|
|
50
|
-
} = select(_store.store);
|
|
51
|
-
return {
|
|
52
|
-
blocks: getMultiSelectedBlocks()
|
|
53
|
-
};
|
|
54
|
-
})(MultiSelectionInspector);
|
|
55
55
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_i18n","require","_data","_blocks","_wordcount","_icons","_blockIcon","_interopRequireDefault","_store","_jsxRuntime","MultiSelectionInspector","blocks","words","wordCount","serialize","jsxs","className","children","jsx","default","icon","copy","showColors","sprintf","_n","length"
|
|
1
|
+
{"version":3,"names":["_i18n","require","_data","_blocks","_wordcount","_icons","_blockIcon","_interopRequireDefault","_store","_jsxRuntime","MultiSelectionInspector","blocks","useSelect","select","getMultiSelectedBlocks","blockEditorStore","words","wordCount","serialize","jsxs","className","children","jsx","default","icon","copy","showColors","sprintf","_n","length"],"sources":["@wordpress/block-editor/src/components/multi-selection-inspector/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { sprintf, _n } from '@wordpress/i18n';\nimport { useSelect } from '@wordpress/data';\nimport { serialize } from '@wordpress/blocks';\nimport { count as wordCount } from '@wordpress/wordcount';\nimport { copy } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport BlockIcon from '../block-icon';\nimport { store as blockEditorStore } from '../../store';\n\nexport default function MultiSelectionInspector() {\n\tconst { blocks } = useSelect( ( select ) => {\n\t\tconst { getMultiSelectedBlocks } = select( blockEditorStore );\n\t\treturn {\n\t\t\tblocks: getMultiSelectedBlocks(),\n\t\t};\n\t}, [] );\n\tconst words = wordCount( serialize( blocks ), 'words' );\n\n\treturn (\n\t\t<div className=\"block-editor-multi-selection-inspector__card\">\n\t\t\t<BlockIcon icon={ copy } showColors />\n\t\t\t<div className=\"block-editor-multi-selection-inspector__card-content\">\n\t\t\t\t<div className=\"block-editor-multi-selection-inspector__card-title\">\n\t\t\t\t\t{ sprintf(\n\t\t\t\t\t\t/* translators: %d: number of blocks */\n\t\t\t\t\t\t_n( '%d Block', '%d Blocks', blocks.length ),\n\t\t\t\t\t\tblocks.length\n\t\t\t\t\t) }\n\t\t\t\t</div>\n\t\t\t\t<div className=\"block-editor-multi-selection-inspector__card-description\">\n\t\t\t\t\t{ sprintf(\n\t\t\t\t\t\t/* translators: %d: number of words */\n\t\t\t\t\t\t_n( '%d word selected.', '%d words selected.', words ),\n\t\t\t\t\t\twords\n\t\t\t\t\t) }\n\t\t\t\t</div>\n\t\t\t</div>\n\t\t</div>\n\t);\n}\n"],"mappings":";;;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,OAAA,GAAAF,OAAA;AACA,IAAAG,UAAA,GAAAH,OAAA;AACA,IAAAI,MAAA,GAAAJ,OAAA;AAKA,IAAAK,UAAA,GAAAC,sBAAA,CAAAN,OAAA;AACA,IAAAO,MAAA,GAAAP,OAAA;AAAwD,IAAAQ,WAAA,GAAAR,OAAA;AAbxD;AACA;AACA;;AAOA;AACA;AACA;;AAIe,SAASS,uBAAuBA,CAAA,EAAG;EACjD,MAAM;IAAEC;EAAO,CAAC,GAAG,IAAAC,eAAS,EAAIC,MAAM,IAAM;IAC3C,MAAM;MAAEC;IAAuB,CAAC,GAAGD,MAAM,CAAEE,YAAiB,CAAC;IAC7D,OAAO;MACNJ,MAAM,EAAEG,sBAAsB,CAAC;IAChC,CAAC;EACF,CAAC,EAAE,EAAG,CAAC;EACP,MAAME,KAAK,GAAG,IAAAC,gBAAS,EAAE,IAAAC,iBAAS,EAAEP,MAAO,CAAC,EAAE,OAAQ,CAAC;EAEvD,oBACC,IAAAF,WAAA,CAAAU,IAAA;IAAKC,SAAS,EAAC,8CAA8C;IAAAC,QAAA,gBAC5D,IAAAZ,WAAA,CAAAa,GAAA,EAAChB,UAAA,CAAAiB,OAAS;MAACC,IAAI,EAAGC,WAAM;MAACC,UAAU;IAAA,CAAE,CAAC,eACtC,IAAAjB,WAAA,CAAAU,IAAA;MAAKC,SAAS,EAAC,sDAAsD;MAAAC,QAAA,gBACpE,IAAAZ,WAAA,CAAAa,GAAA;QAAKF,SAAS,EAAC,oDAAoD;QAAAC,QAAA,EAChE,IAAAM,aAAO,GACR;QACA,IAAAC,QAAE,EAAE,UAAU,EAAE,WAAW,EAAEjB,MAAM,CAACkB,MAAO,CAAC,EAC5ClB,MAAM,CAACkB,MACR;MAAC,CACG,CAAC,eACN,IAAApB,WAAA,CAAAa,GAAA;QAAKF,SAAS,EAAC,0DAA0D;QAAAC,QAAA,EACtE,IAAAM,aAAO,GACR;QACA,IAAAC,QAAE,EAAE,mBAAmB,EAAE,oBAAoB,EAAEZ,KAAM,CAAC,EACtDA,KACD;MAAC,CACG,CAAC;IAAA,CACF,CAAC;EAAA,CACF,CAAC;AAER","ignoreList":[]}
|
|
@@ -93,11 +93,11 @@ function useBlockSync({
|
|
|
93
93
|
const isControlled = (0, _data.useSelect)(select => {
|
|
94
94
|
return !clientId || select(_store.store).areInnerBlocksControlled(clientId);
|
|
95
95
|
}, [clientId]);
|
|
96
|
-
const
|
|
96
|
+
const pendingChangesRef = (0, _element.useRef)({
|
|
97
97
|
incoming: null,
|
|
98
98
|
outgoing: []
|
|
99
99
|
});
|
|
100
|
-
const
|
|
100
|
+
const subscribedRef = (0, _element.useRef)(false);
|
|
101
101
|
const setControlledBlocks = () => {
|
|
102
102
|
if (!controlledBlocks) {
|
|
103
103
|
return;
|
|
@@ -115,15 +115,15 @@ function useBlockSync({
|
|
|
115
115
|
registry.batch(() => {
|
|
116
116
|
setHasControlledInnerBlocks(clientId, true);
|
|
117
117
|
const storeBlocks = controlledBlocks.map(block => (0, _blocks.cloneBlock)(block));
|
|
118
|
-
if (
|
|
119
|
-
|
|
118
|
+
if (subscribedRef.current) {
|
|
119
|
+
pendingChangesRef.current.incoming = storeBlocks;
|
|
120
120
|
}
|
|
121
121
|
__unstableMarkNextChangeAsNotPersistent();
|
|
122
122
|
replaceInnerBlocks(clientId, storeBlocks);
|
|
123
123
|
});
|
|
124
124
|
} else {
|
|
125
|
-
if (
|
|
126
|
-
|
|
125
|
+
if (subscribedRef.current) {
|
|
126
|
+
pendingChangesRef.current.incoming = controlledBlocks;
|
|
127
127
|
}
|
|
128
128
|
resetBlocks(controlledBlocks);
|
|
129
129
|
}
|
|
@@ -155,40 +155,40 @@ function useBlockSync({
|
|
|
155
155
|
|
|
156
156
|
// Determine if blocks need to be reset when they change.
|
|
157
157
|
(0, _element.useEffect)(() => {
|
|
158
|
-
if (
|
|
158
|
+
if (pendingChangesRef.current.outgoing.includes(controlledBlocks)) {
|
|
159
159
|
// Skip block reset if the value matches expected outbound sync
|
|
160
160
|
// triggered by this component by a preceding change detection.
|
|
161
161
|
// Only skip if the value matches expectation, since a reset should
|
|
162
162
|
// still occur if the value is modified (not equal by reference),
|
|
163
163
|
// to allow that the consumer may apply modifications to reflect
|
|
164
164
|
// back on the editor.
|
|
165
|
-
if (
|
|
166
|
-
|
|
165
|
+
if (pendingChangesRef.current.outgoing[pendingChangesRef.current.outgoing.length - 1] === controlledBlocks) {
|
|
166
|
+
pendingChangesRef.current.outgoing = [];
|
|
167
167
|
}
|
|
168
168
|
} else if (getBlocks(clientId) !== controlledBlocks) {
|
|
169
169
|
// Reset changing value in all other cases than the sync described
|
|
170
170
|
// above. Since this can be reached in an update following an out-
|
|
171
171
|
// bound sync, unset the outbound value to avoid considering it in
|
|
172
172
|
// subsequent renders.
|
|
173
|
-
|
|
173
|
+
pendingChangesRef.current.outgoing = [];
|
|
174
174
|
setControlledBlocks();
|
|
175
175
|
if (controlledSelection) {
|
|
176
176
|
resetSelection(controlledSelection.selectionStart, controlledSelection.selectionEnd, controlledSelection.initialPosition);
|
|
177
177
|
}
|
|
178
178
|
}
|
|
179
179
|
}, [controlledBlocks, clientId]);
|
|
180
|
-
const
|
|
180
|
+
const isMountedRef = (0, _element.useRef)(false);
|
|
181
181
|
(0, _element.useEffect)(() => {
|
|
182
182
|
// On mount, controlled blocks are already set in the effect above.
|
|
183
|
-
if (!
|
|
184
|
-
|
|
183
|
+
if (!isMountedRef.current) {
|
|
184
|
+
isMountedRef.current = true;
|
|
185
185
|
return;
|
|
186
186
|
}
|
|
187
187
|
|
|
188
188
|
// When the block becomes uncontrolled, it means its inner state has been reset
|
|
189
189
|
// we need to take the blocks again from the external value property.
|
|
190
190
|
if (!isControlled) {
|
|
191
|
-
|
|
191
|
+
pendingChangesRef.current.outgoing = [];
|
|
192
192
|
setControlledBlocks();
|
|
193
193
|
}
|
|
194
194
|
}, [isControlled]);
|
|
@@ -202,7 +202,7 @@ function useBlockSync({
|
|
|
202
202
|
let blocks = getBlocks(clientId);
|
|
203
203
|
let isPersistent = isLastBlockChangePersistent();
|
|
204
204
|
let previousAreBlocksDifferent = false;
|
|
205
|
-
|
|
205
|
+
subscribedRef.current = true;
|
|
206
206
|
const unsubscribe = registry.subscribe(() => {
|
|
207
207
|
// Sometimes, when changing block lists, lingering subscriptions
|
|
208
208
|
// might trigger before they are cleaned up. If the block for which
|
|
@@ -227,8 +227,8 @@ function useBlockSync({
|
|
|
227
227
|
const newBlocks = getBlocks(clientId);
|
|
228
228
|
const areBlocksDifferent = newBlocks !== blocks;
|
|
229
229
|
blocks = newBlocks;
|
|
230
|
-
if (areBlocksDifferent && (
|
|
231
|
-
|
|
230
|
+
if (areBlocksDifferent && (pendingChangesRef.current.incoming || __unstableIsLastBlockChangeIgnored())) {
|
|
231
|
+
pendingChangesRef.current.incoming = null;
|
|
232
232
|
isPersistent = newIsPersistent;
|
|
233
233
|
return;
|
|
234
234
|
}
|
|
@@ -243,7 +243,7 @@ function useBlockSync({
|
|
|
243
243
|
// We need to be aware that it was caused by an outgoing change
|
|
244
244
|
// so that we do not treat it as an incoming change later on,
|
|
245
245
|
// which would cause a block reset.
|
|
246
|
-
|
|
246
|
+
pendingChangesRef.current.outgoing.push(blocks);
|
|
247
247
|
|
|
248
248
|
// Inform the controlling entity that changes have been made to
|
|
249
249
|
// the block-editor store they should be aware about.
|
|
@@ -259,7 +259,7 @@ function useBlockSync({
|
|
|
259
259
|
previousAreBlocksDifferent = areBlocksDifferent;
|
|
260
260
|
}, _store.store);
|
|
261
261
|
return () => {
|
|
262
|
-
|
|
262
|
+
subscribedRef.current = false;
|
|
263
263
|
unsubscribe();
|
|
264
264
|
};
|
|
265
265
|
}, [registry, clientId]);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_element","require","_data","_blocks","_store","noop","useBlockSync","clientId","value","controlledBlocks","selection","controlledSelection","onChange","onInput","registry","useRegistry","resetBlocks","resetSelection","replaceInnerBlocks","setHasControlledInnerBlocks","__unstableMarkNextChangeAsNotPersistent","dispatch","blockEditorStore","getBlockName","getBlocks","getSelectionStart","getSelectionEnd","select","isControlled","useSelect","areInnerBlocksControlled","pendingChanges","useRef","incoming","outgoing","subscribed","setControlledBlocks","batch","storeBlocks","map","block","cloneBlock","current","unsetControlledBlocks","onInputRef","onChangeRef","useEffect","includes","length","selectionStart","selectionEnd","initialPosition","isMounted","getSelectedBlocksInitialCaretPosition","isLastBlockChangePersistent","__unstableIsLastBlockChangeIgnored","blocks","isPersistent","previousAreBlocksDifferent","unsubscribe","subscribe","isStillControlled","newIsPersistent","newBlocks","areBlocksDifferent","didPersistenceChange","push","updateParent"],"sources":["@wordpress/block-editor/src/components/provider/use-block-sync.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useEffect, useRef } from '@wordpress/element';\nimport { useRegistry, useSelect } from '@wordpress/data';\nimport { cloneBlock } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\n\nconst noop = () => {};\n\n/**\n * A function to call when the block value has been updated in the block-editor\n * store.\n *\n * @callback onBlockUpdate\n * @param {Object[]} blocks The updated blocks.\n * @param {Object} options The updated block options, such as selectionStart\n * and selectionEnd.\n */\n\n/**\n * useBlockSync is a side effect which handles bidirectional sync between the\n * block-editor store and a controlling data source which provides blocks. This\n * is most commonly used by the BlockEditorProvider to synchronize the contents\n * of the block-editor store with the root entity, like a post.\n *\n * Another example would be the template part block, which provides blocks from\n * a separate entity data source than a root entity. This hook syncs edits to\n * the template part in the block editor back to the entity and vice-versa.\n *\n * Here are some of its basic functions:\n * - Initalizes the block-editor store for the given clientID to the blocks\n * given via props.\n * - Adds incoming changes (like undo) to the block-editor store.\n * - Adds outgoing changes (like editing content) to the controlling entity,\n * determining if a change should be considered persistent or not.\n * - Handles edge cases and race conditions which occur in those operations.\n * - Ignores changes which happen to other entities (like nested inner block\n * controllers.\n * - Passes selection state from the block-editor store to the controlling entity.\n *\n * @param {Object} props Props for the block sync hook\n * @param {string} props.clientId The client ID of the inner block controller.\n * If none is passed, then it is assumed to be a\n * root controller rather than an inner block\n * controller.\n * @param {Object[]} props.value The control value for the blocks. This value\n * is used to initalize the block-editor store\n * and for resetting the blocks to incoming\n * changes like undo.\n * @param {Object} props.selection The selection state responsible to restore the selection on undo/redo.\n * @param {onBlockUpdate} props.onChange Function to call when a persistent\n * change has been made in the block-editor blocks\n * for the given clientId. For example, after\n * this function is called, an entity is marked\n * dirty because it has changes to save.\n * @param {onBlockUpdate} props.onInput Function to call when a non-persistent\n * change has been made in the block-editor blocks\n * for the given clientId. When this is called,\n * controlling sources do not become dirty.\n */\nexport default function useBlockSync( {\n\tclientId = null,\n\tvalue: controlledBlocks,\n\tselection: controlledSelection,\n\tonChange = noop,\n\tonInput = noop,\n} ) {\n\tconst registry = useRegistry();\n\n\tconst {\n\t\tresetBlocks,\n\t\tresetSelection,\n\t\treplaceInnerBlocks,\n\t\tsetHasControlledInnerBlocks,\n\t\t__unstableMarkNextChangeAsNotPersistent,\n\t} = registry.dispatch( blockEditorStore );\n\tconst { getBlockName, getBlocks, getSelectionStart, getSelectionEnd } =\n\t\tregistry.select( blockEditorStore );\n\tconst isControlled = useSelect(\n\t\t( select ) => {\n\t\t\treturn (\n\t\t\t\t! clientId ||\n\t\t\t\tselect( blockEditorStore ).areInnerBlocksControlled( clientId )\n\t\t\t);\n\t\t},\n\t\t[ clientId ]\n\t);\n\n\tconst pendingChanges = useRef( { incoming: null, outgoing: [] } );\n\tconst subscribed = useRef( false );\n\n\tconst setControlledBlocks = () => {\n\t\tif ( ! controlledBlocks ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// We don't need to persist this change because we only replace\n\t\t// controlled inner blocks when the change was caused by an entity,\n\t\t// and so it would already be persisted.\n\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\tif ( clientId ) {\n\t\t\t// It is important to batch here because otherwise,\n\t\t\t// as soon as `setHasControlledInnerBlocks` is called\n\t\t\t// the effect to restore might be triggered\n\t\t\t// before the actual blocks get set properly in state.\n\t\t\tregistry.batch( () => {\n\t\t\t\tsetHasControlledInnerBlocks( clientId, true );\n\t\t\t\tconst storeBlocks = controlledBlocks.map( ( block ) =>\n\t\t\t\t\tcloneBlock( block )\n\t\t\t\t);\n\t\t\t\tif ( subscribed.current ) {\n\t\t\t\t\tpendingChanges.current.incoming = storeBlocks;\n\t\t\t\t}\n\t\t\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\t\t\treplaceInnerBlocks( clientId, storeBlocks );\n\t\t\t} );\n\t\t} else {\n\t\t\tif ( subscribed.current ) {\n\t\t\t\tpendingChanges.current.incoming = controlledBlocks;\n\t\t\t}\n\t\t\tresetBlocks( controlledBlocks );\n\t\t}\n\t};\n\n\t// Clean up the changes made by setControlledBlocks() when the component\n\t// containing useBlockSync() unmounts.\n\tconst unsetControlledBlocks = () => {\n\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\tif ( clientId ) {\n\t\t\tsetHasControlledInnerBlocks( clientId, false );\n\t\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\t\treplaceInnerBlocks( clientId, [] );\n\t\t} else {\n\t\t\tresetBlocks( [] );\n\t\t}\n\t};\n\n\t// Add a subscription to the block-editor registry to detect when changes\n\t// have been made. This lets us inform the data source of changes. This\n\t// is an effect so that the subscriber can run synchronously without\n\t// waiting for React renders for changes.\n\tconst onInputRef = useRef( onInput );\n\tconst onChangeRef = useRef( onChange );\n\tuseEffect( () => {\n\t\tonInputRef.current = onInput;\n\t\tonChangeRef.current = onChange;\n\t}, [ onInput, onChange ] );\n\n\t// Determine if blocks need to be reset when they change.\n\tuseEffect( () => {\n\t\tif ( pendingChanges.current.outgoing.includes( controlledBlocks ) ) {\n\t\t\t// Skip block reset if the value matches expected outbound sync\n\t\t\t// triggered by this component by a preceding change detection.\n\t\t\t// Only skip if the value matches expectation, since a reset should\n\t\t\t// still occur if the value is modified (not equal by reference),\n\t\t\t// to allow that the consumer may apply modifications to reflect\n\t\t\t// back on the editor.\n\t\t\tif (\n\t\t\t\tpendingChanges.current.outgoing[\n\t\t\t\t\tpendingChanges.current.outgoing.length - 1\n\t\t\t\t] === controlledBlocks\n\t\t\t) {\n\t\t\t\tpendingChanges.current.outgoing = [];\n\t\t\t}\n\t\t} else if ( getBlocks( clientId ) !== controlledBlocks ) {\n\t\t\t// Reset changing value in all other cases than the sync described\n\t\t\t// above. Since this can be reached in an update following an out-\n\t\t\t// bound sync, unset the outbound value to avoid considering it in\n\t\t\t// subsequent renders.\n\t\t\tpendingChanges.current.outgoing = [];\n\t\t\tsetControlledBlocks();\n\n\t\t\tif ( controlledSelection ) {\n\t\t\t\tresetSelection(\n\t\t\t\t\tcontrolledSelection.selectionStart,\n\t\t\t\t\tcontrolledSelection.selectionEnd,\n\t\t\t\t\tcontrolledSelection.initialPosition\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t}, [ controlledBlocks, clientId ] );\n\n\tconst isMounted = useRef( false );\n\n\tuseEffect( () => {\n\t\t// On mount, controlled blocks are already set in the effect above.\n\t\tif ( ! isMounted.current ) {\n\t\t\tisMounted.current = true;\n\t\t\treturn;\n\t\t}\n\n\t\t// When the block becomes uncontrolled, it means its inner state has been reset\n\t\t// we need to take the blocks again from the external value property.\n\t\tif ( ! isControlled ) {\n\t\t\tpendingChanges.current.outgoing = [];\n\t\t\tsetControlledBlocks();\n\t\t}\n\t}, [ isControlled ] );\n\n\tuseEffect( () => {\n\t\tconst {\n\t\t\tgetSelectedBlocksInitialCaretPosition,\n\t\t\tisLastBlockChangePersistent,\n\t\t\t__unstableIsLastBlockChangeIgnored,\n\t\t\tareInnerBlocksControlled,\n\t\t} = registry.select( blockEditorStore );\n\n\t\tlet blocks = getBlocks( clientId );\n\t\tlet isPersistent = isLastBlockChangePersistent();\n\t\tlet previousAreBlocksDifferent = false;\n\n\t\tsubscribed.current = true;\n\t\tconst unsubscribe = registry.subscribe( () => {\n\t\t\t// Sometimes, when changing block lists, lingering subscriptions\n\t\t\t// might trigger before they are cleaned up. If the block for which\n\t\t\t// the subscription runs is no longer in the store, this would clear\n\t\t\t// its parent entity's block list. To avoid this, we bail out if\n\t\t\t// the subscription is triggering for a block (`clientId !== null`)\n\t\t\t// and its block name can't be found because it's not on the list.\n\t\t\t// (`getBlockName( clientId ) === null`).\n\t\t\tif ( clientId !== null && getBlockName( clientId ) === null ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// When RESET_BLOCKS on parent blocks get called, the controlled blocks\n\t\t\t// can reset to uncontrolled, in these situations, it means we need to populate\n\t\t\t// the blocks again from the external blocks (the value property here)\n\t\t\t// and we should stop triggering onChange\n\t\t\tconst isStillControlled =\n\t\t\t\t! clientId || areInnerBlocksControlled( clientId );\n\t\t\tif ( ! isStillControlled ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst newIsPersistent = isLastBlockChangePersistent();\n\t\t\tconst newBlocks = getBlocks( clientId );\n\t\t\tconst areBlocksDifferent = newBlocks !== blocks;\n\t\t\tblocks = newBlocks;\n\t\t\tif (\n\t\t\t\tareBlocksDifferent &&\n\t\t\t\t( pendingChanges.current.incoming ||\n\t\t\t\t\t__unstableIsLastBlockChangeIgnored() )\n\t\t\t) {\n\t\t\t\tpendingChanges.current.incoming = null;\n\t\t\t\tisPersistent = newIsPersistent;\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// Since we often dispatch an action to mark the previous action as\n\t\t\t// persistent, we need to make sure that the blocks changed on the\n\t\t\t// previous action before committing the change.\n\t\t\tconst didPersistenceChange =\n\t\t\t\tpreviousAreBlocksDifferent &&\n\t\t\t\t! areBlocksDifferent &&\n\t\t\t\tnewIsPersistent &&\n\t\t\t\t! isPersistent;\n\n\t\t\tif ( areBlocksDifferent || didPersistenceChange ) {\n\t\t\t\tisPersistent = newIsPersistent;\n\t\t\t\t// We know that onChange/onInput will update controlledBlocks.\n\t\t\t\t// We need to be aware that it was caused by an outgoing change\n\t\t\t\t// so that we do not treat it as an incoming change later on,\n\t\t\t\t// which would cause a block reset.\n\t\t\t\tpendingChanges.current.outgoing.push( blocks );\n\n\t\t\t\t// Inform the controlling entity that changes have been made to\n\t\t\t\t// the block-editor store they should be aware about.\n\t\t\t\tconst updateParent = isPersistent\n\t\t\t\t\t? onChangeRef.current\n\t\t\t\t\t: onInputRef.current;\n\t\t\t\tupdateParent( blocks, {\n\t\t\t\t\tselection: {\n\t\t\t\t\t\tselectionStart: getSelectionStart(),\n\t\t\t\t\t\tselectionEnd: getSelectionEnd(),\n\t\t\t\t\t\tinitialPosition:\n\t\t\t\t\t\t\tgetSelectedBlocksInitialCaretPosition(),\n\t\t\t\t\t},\n\t\t\t\t} );\n\t\t\t}\n\t\t\tpreviousAreBlocksDifferent = areBlocksDifferent;\n\t\t}, blockEditorStore );\n\n\t\treturn () => {\n\t\t\tsubscribed.current = false;\n\t\t\tunsubscribe();\n\t\t};\n\t}, [ registry, clientId ] );\n\n\tuseEffect( () => {\n\t\treturn () => {\n\t\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F,eAAe,IACf,CAAEL,YAAY;MAEf,IAAKO,kBAAkB,IAAIC,oBAAoB,EAAG;QACjDR,YAAY,GAAGK,eAAe;QAC9B;QACA;QACA;QACA;QACA/B,cAAc,CAACW,OAAO,CAACR,QAAQ,CAACgC,IAAI,CAAEV,MAAO,CAAC;;QAE9C;QACA;QACA,MAAMW,YAAY,GAAGV,YAAY,GAC9BZ,WAAW,CAACH,OAAO,GACnBE,UAAU,CAACF,OAAO;QACrByB,YAAY,CAAEX,MAAM,EAAE;UACrB9C,SAAS,EAAE;YACVuC,cAAc,EAAExB,iBAAiB,CAAC,CAAC;YACnCyB,YAAY,EAAExB,eAAe,CAAC,CAAC;YAC/ByB,eAAe,EACdE,qCAAqC,CAAC;UACxC;QACD,CAAE,CAAC;MACJ;MACAK,0BAA0B,GAAGM,kBAAkB;IAChD,CAAC,EAAE1C,YAAiB,CAAC;IAErB,OAAO,MAAM;MACZa,UAAU,CAACO,OAAO,GAAG,KAAK;MAC1BiB,WAAW,CAAC,CAAC;IACd,CAAC;EACF,CAAC,EAAE,CAAE7C,QAAQ,EAAEP,QAAQ,CAAG,CAAC;EAE3B,IAAAuC,kBAAS,EAAE,MAAM;IAChB,OAAO,MAAM;MACZH,qBAAqB,CAAC,CAAC;IACxB,CAAC;EACF,CAAC,EAAE,EAAG,CAAC;AACR","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["_element","require","_data","_blocks","_store","noop","useBlockSync","clientId","value","controlledBlocks","selection","controlledSelection","onChange","onInput","registry","useRegistry","resetBlocks","resetSelection","replaceInnerBlocks","setHasControlledInnerBlocks","__unstableMarkNextChangeAsNotPersistent","dispatch","blockEditorStore","getBlockName","getBlocks","getSelectionStart","getSelectionEnd","select","isControlled","useSelect","areInnerBlocksControlled","pendingChangesRef","useRef","incoming","outgoing","subscribedRef","setControlledBlocks","batch","storeBlocks","map","block","cloneBlock","current","unsetControlledBlocks","onInputRef","onChangeRef","useEffect","includes","length","selectionStart","selectionEnd","initialPosition","isMountedRef","getSelectedBlocksInitialCaretPosition","isLastBlockChangePersistent","__unstableIsLastBlockChangeIgnored","blocks","isPersistent","previousAreBlocksDifferent","unsubscribe","subscribe","isStillControlled","newIsPersistent","newBlocks","areBlocksDifferent","didPersistenceChange","push","updateParent"],"sources":["@wordpress/block-editor/src/components/provider/use-block-sync.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useEffect, useRef } from '@wordpress/element';\nimport { useRegistry, useSelect } from '@wordpress/data';\nimport { cloneBlock } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\n\nconst noop = () => {};\n\n/**\n * A function to call when the block value has been updated in the block-editor\n * store.\n *\n * @callback onBlockUpdate\n * @param {Object[]} blocks The updated blocks.\n * @param {Object} options The updated block options, such as selectionStart\n * and selectionEnd.\n */\n\n/**\n * useBlockSync is a side effect which handles bidirectional sync between the\n * block-editor store and a controlling data source which provides blocks. This\n * is most commonly used by the BlockEditorProvider to synchronize the contents\n * of the block-editor store with the root entity, like a post.\n *\n * Another example would be the template part block, which provides blocks from\n * a separate entity data source than a root entity. This hook syncs edits to\n * the template part in the block editor back to the entity and vice-versa.\n *\n * Here are some of its basic functions:\n * - Initalizes the block-editor store for the given clientID to the blocks\n * given via props.\n * - Adds incoming changes (like undo) to the block-editor store.\n * - Adds outgoing changes (like editing content) to the controlling entity,\n * determining if a change should be considered persistent or not.\n * - Handles edge cases and race conditions which occur in those operations.\n * - Ignores changes which happen to other entities (like nested inner block\n * controllers.\n * - Passes selection state from the block-editor store to the controlling entity.\n *\n * @param {Object} props Props for the block sync hook\n * @param {string} props.clientId The client ID of the inner block controller.\n * If none is passed, then it is assumed to be a\n * root controller rather than an inner block\n * controller.\n * @param {Object[]} props.value The control value for the blocks. This value\n * is used to initalize the block-editor store\n * and for resetting the blocks to incoming\n * changes like undo.\n * @param {Object} props.selection The selection state responsible to restore the selection on undo/redo.\n * @param {onBlockUpdate} props.onChange Function to call when a persistent\n * change has been made in the block-editor blocks\n * for the given clientId. For example, after\n * this function is called, an entity is marked\n * dirty because it has changes to save.\n * @param {onBlockUpdate} props.onInput Function to call when a non-persistent\n * change has been made in the block-editor blocks\n * for the given clientId. When this is called,\n * controlling sources do not become dirty.\n */\nexport default function useBlockSync( {\n\tclientId = null,\n\tvalue: controlledBlocks,\n\tselection: controlledSelection,\n\tonChange = noop,\n\tonInput = noop,\n} ) {\n\tconst registry = useRegistry();\n\n\tconst {\n\t\tresetBlocks,\n\t\tresetSelection,\n\t\treplaceInnerBlocks,\n\t\tsetHasControlledInnerBlocks,\n\t\t__unstableMarkNextChangeAsNotPersistent,\n\t} = registry.dispatch( blockEditorStore );\n\tconst { getBlockName, getBlocks, getSelectionStart, getSelectionEnd } =\n\t\tregistry.select( blockEditorStore );\n\tconst isControlled = useSelect(\n\t\t( select ) => {\n\t\t\treturn (\n\t\t\t\t! clientId ||\n\t\t\t\tselect( blockEditorStore ).areInnerBlocksControlled( clientId )\n\t\t\t);\n\t\t},\n\t\t[ clientId ]\n\t);\n\n\tconst pendingChangesRef = useRef( { incoming: null, outgoing: [] } );\n\tconst subscribedRef = useRef( false );\n\n\tconst setControlledBlocks = () => {\n\t\tif ( ! controlledBlocks ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// We don't need to persist this change because we only replace\n\t\t// controlled inner blocks when the change was caused by an entity,\n\t\t// and so it would already be persisted.\n\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\tif ( clientId ) {\n\t\t\t// It is important to batch here because otherwise,\n\t\t\t// as soon as `setHasControlledInnerBlocks` is called\n\t\t\t// the effect to restore might be triggered\n\t\t\t// before the actual blocks get set properly in state.\n\t\t\tregistry.batch( () => {\n\t\t\t\tsetHasControlledInnerBlocks( clientId, true );\n\t\t\t\tconst storeBlocks = controlledBlocks.map( ( block ) =>\n\t\t\t\t\tcloneBlock( block )\n\t\t\t\t);\n\t\t\t\tif ( subscribedRef.current ) {\n\t\t\t\t\tpendingChangesRef.current.incoming = storeBlocks;\n\t\t\t\t}\n\t\t\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\t\t\treplaceInnerBlocks( clientId, storeBlocks );\n\t\t\t} );\n\t\t} else {\n\t\t\tif ( subscribedRef.current ) {\n\t\t\t\tpendingChangesRef.current.incoming = controlledBlocks;\n\t\t\t}\n\t\t\tresetBlocks( controlledBlocks );\n\t\t}\n\t};\n\n\t// Clean up the changes made by setControlledBlocks() when the component\n\t// containing useBlockSync() unmounts.\n\tconst unsetControlledBlocks = () => {\n\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\tif ( clientId ) {\n\t\t\tsetHasControlledInnerBlocks( clientId, false );\n\t\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\t\treplaceInnerBlocks( clientId, [] );\n\t\t} else {\n\t\t\tresetBlocks( [] );\n\t\t}\n\t};\n\n\t// Add a subscription to the block-editor registry to detect when changes\n\t// have been made. This lets us inform the data source of changes. This\n\t// is an effect so that the subscriber can run synchronously without\n\t// waiting for React renders for changes.\n\tconst onInputRef = useRef( onInput );\n\tconst onChangeRef = useRef( onChange );\n\tuseEffect( () => {\n\t\tonInputRef.current = onInput;\n\t\tonChangeRef.current = onChange;\n\t}, [ onInput, onChange ] );\n\n\t// Determine if blocks need to be reset when they change.\n\tuseEffect( () => {\n\t\tif ( pendingChangesRef.current.outgoing.includes( controlledBlocks ) ) {\n\t\t\t// Skip block reset if the value matches expected outbound sync\n\t\t\t// triggered by this component by a preceding change detection.\n\t\t\t// Only skip if the value matches expectation, since a reset should\n\t\t\t// still occur if the value is modified (not equal by reference),\n\t\t\t// to allow that the consumer may apply modifications to reflect\n\t\t\t// back on the editor.\n\t\t\tif (\n\t\t\t\tpendingChangesRef.current.outgoing[\n\t\t\t\t\tpendingChangesRef.current.outgoing.length - 1\n\t\t\t\t] === controlledBlocks\n\t\t\t) {\n\t\t\t\tpendingChangesRef.current.outgoing = [];\n\t\t\t}\n\t\t} else if ( getBlocks( clientId ) !== controlledBlocks ) {\n\t\t\t// Reset changing value in all other cases than the sync described\n\t\t\t// above. Since this can be reached in an update following an out-\n\t\t\t// bound sync, unset the outbound value to avoid considering it in\n\t\t\t// subsequent renders.\n\t\t\tpendingChangesRef.current.outgoing = [];\n\t\t\tsetControlledBlocks();\n\n\t\t\tif ( controlledSelection ) {\n\t\t\t\tresetSelection(\n\t\t\t\t\tcontrolledSelection.selectionStart,\n\t\t\t\t\tcontrolledSelection.selectionEnd,\n\t\t\t\t\tcontrolledSelection.initialPosition\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t}, [ controlledBlocks, clientId ] );\n\n\tconst isMountedRef = useRef( false );\n\n\tuseEffect( () => {\n\t\t// On mount, controlled blocks are already set in the effect above.\n\t\tif ( ! isMountedRef.current ) {\n\t\t\tisMountedRef.current = true;\n\t\t\treturn;\n\t\t}\n\n\t\t// When the block becomes uncontrolled, it means its inner state has been reset\n\t\t// we need to take the blocks again from the external value property.\n\t\tif ( ! isControlled ) {\n\t\t\tpendingChangesRef.current.outgoing = [];\n\t\t\tsetControlledBlocks();\n\t\t}\n\t}, [ isControlled ] );\n\n\tuseEffect( () => {\n\t\tconst {\n\t\t\tgetSelectedBlocksInitialCaretPosition,\n\t\t\tisLastBlockChangePersistent,\n\t\t\t__unstableIsLastBlockChangeIgnored,\n\t\t\tareInnerBlocksControlled,\n\t\t} = registry.select( blockEditorStore );\n\n\t\tlet blocks = getBlocks( clientId );\n\t\tlet isPersistent = isLastBlockChangePersistent();\n\t\tlet previousAreBlocksDifferent = false;\n\n\t\tsubscribedRef.current = true;\n\t\tconst unsubscribe = registry.subscribe( () => {\n\t\t\t// Sometimes, when changing block lists, lingering subscriptions\n\t\t\t// might trigger before they are cleaned up. If the block for which\n\t\t\t// the subscription runs is no longer in the store, this would clear\n\t\t\t// its parent entity's block list. To avoid this, we bail out if\n\t\t\t// the subscription is triggering for a block (`clientId !== null`)\n\t\t\t// and its block name can't be found because it's not on the list.\n\t\t\t// (`getBlockName( clientId ) === null`).\n\t\t\tif ( clientId !== null && getBlockName( clientId ) === null ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// When RESET_BLOCKS on parent blocks get called, the controlled blocks\n\t\t\t// can reset to uncontrolled, in these situations, it means we need to populate\n\t\t\t// the blocks again from the external blocks (the value property here)\n\t\t\t// and we should stop triggering onChange\n\t\t\tconst isStillControlled =\n\t\t\t\t! clientId || areInnerBlocksControlled( clientId );\n\t\t\tif ( ! isStillControlled ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst newIsPersistent = isLastBlockChangePersistent();\n\t\t\tconst newBlocks = getBlocks( clientId );\n\t\t\tconst areBlocksDifferent = newBlocks !== blocks;\n\t\t\tblocks = newBlocks;\n\t\t\tif (\n\t\t\t\tareBlocksDifferent &&\n\t\t\t\t( pendingChangesRef.current.incoming ||\n\t\t\t\t\t__unstableIsLastBlockChangeIgnored() )\n\t\t\t) {\n\t\t\t\tpendingChangesRef.current.incoming = null;\n\t\t\t\tisPersistent = newIsPersistent;\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// Since we often dispatch an action to mark the previous action as\n\t\t\t// persistent, we need to make sure that the blocks changed on the\n\t\t\t// previous action before committing the change.\n\t\t\tconst didPersistenceChange =\n\t\t\t\tpreviousAreBlocksDifferent &&\n\t\t\t\t! areBlocksDifferent &&\n\t\t\t\tnewIsPersistent &&\n\t\t\t\t! isPersistent;\n\n\t\t\tif ( areBlocksDifferent || didPersistenceChange ) {\n\t\t\t\tisPersistent = newIsPersistent;\n\t\t\t\t// We know that onChange/onInput will update controlledBlocks.\n\t\t\t\t// We need to be aware that it was caused by an outgoing change\n\t\t\t\t// so that we do not treat it as an incoming change later on,\n\t\t\t\t// which would cause a block reset.\n\t\t\t\tpendingChangesRef.current.outgoing.push( blocks );\n\n\t\t\t\t// Inform the controlling entity that changes have been made to\n\t\t\t\t// the block-editor store they should be aware about.\n\t\t\t\tconst updateParent = isPersistent\n\t\t\t\t\t? onChangeRef.current\n\t\t\t\t\t: onInputRef.current;\n\t\t\t\tupdateParent( blocks, {\n\t\t\t\t\tselection: {\n\t\t\t\t\t\tselectionStart: getSelectionStart(),\n\t\t\t\t\t\tselectionEnd: getSelectionEnd(),\n\t\t\t\t\t\tinitialPosition:\n\t\t\t\t\t\t\tgetSelectedBlocksInitialCaretPosition(),\n\t\t\t\t\t},\n\t\t\t\t} );\n\t\t\t}\n\t\t\tpreviousAreBlocksDifferent = areBlocksDifferent;\n\t\t}, blockEditorStore );\n\n\t\treturn () => {\n\t\t\tsubscribedRef.current = false;\n\t\t\tunsubscribe();\n\t\t};\n\t}, [ registry, clientId ] );\n\n\tuseEffect( () => {\n\t\treturn () => {\n\t\t\tunsetControlledBlocks();\n\t\t};\n\t}, [] );\n}\n"],"mappings":";;;;;;AAGA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,OAAA,GAAAF,OAAA;AAKA,IAAAG,MAAA,GAAAH,OAAA;AAVA;AACA;AACA;;AAKA;AACA;AACA;;AAGA,MAAMI,IAAI,GAAGA,CAAA,KAAM,CAAC,CAAC;;AAErB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACe,SAASC,YAAYA,CAAE;EACrCC,QAAQ,GAAG,IAAI;EACfC,KAAK,EAAEC,gBAAgB;EACvBC,SAAS,EAAEC,mBAAmB;EAC9BC,QAAQ,GAAGP,IAAI;EACfQ,OAAO,GAAGR;AACX,CAAC,EAAG;EACH,MAAMS,QAAQ,GAAG,IAAAC,iBAAW,EAAC,CAAC;EAE9B,MAAM;IACLC,WAAW;IACXC,cAAc;IACdC,kBAAkB;IAClBC,2BAA2B;IAC3BC;EACD,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C;EACF,CAAC,EAAE,EAAG,CAAC;AACR","ignoreList":[]}
|
|
@@ -29,10 +29,21 @@ var _default = props => element => {
|
|
|
29
29
|
preserveWhiteSpace,
|
|
30
30
|
pastePlainText
|
|
31
31
|
} = props.current;
|
|
32
|
+
const {
|
|
33
|
+
ownerDocument
|
|
34
|
+
} = element;
|
|
35
|
+
const {
|
|
36
|
+
defaultView
|
|
37
|
+
} = ownerDocument;
|
|
38
|
+
const {
|
|
39
|
+
anchorNode,
|
|
40
|
+
focusNode
|
|
41
|
+
} = defaultView.getSelection();
|
|
42
|
+
const containsSelection = element.contains(anchorNode) && element.contains(focusNode);
|
|
32
43
|
|
|
33
44
|
// The event listener is attached to the window, so we need to check if
|
|
34
45
|
// the target is the element.
|
|
35
|
-
if (
|
|
46
|
+
if (!containsSelection) {
|
|
36
47
|
return;
|
|
37
48
|
}
|
|
38
49
|
if (event.defaultPrevented) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_blocks","require","_richText","_url","_utils","_pasting","_default","props","element","_onPaste","event","disableFormats","onChange","value","formatTypes","tagName","onReplace","__unstableEmbedURLOnPaste","preserveWhiteSpace","pastePlainText","current","
|
|
1
|
+
{"version":3,"names":["_blocks","require","_richText","_url","_utils","_pasting","_default","props","element","_onPaste","event","disableFormats","onChange","value","formatTypes","tagName","onReplace","__unstableEmbedURLOnPaste","preserveWhiteSpace","pastePlainText","current","ownerDocument","defaultView","anchorNode","focusNode","getSelection","containsSelection","contains","defaultPrevented","plainText","html","getPasteEventData","preventDefault","window","console","log","insert","isInternal","clipboardData","getData","pasteInline","content","transformed","reduce","accumulator","__unstablePasteRule","valueToInsert","create","addActiveFormats","activeFormats","text","mode","trimmedPlainText","trim","isEmpty","isURL","test","pasteHandler","HTML","length","addEventListener","removeEventListener","exports","default"],"sources":["@wordpress/block-editor/src/components/rich-text/event-listeners/paste-handler.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { pasteHandler } from '@wordpress/blocks';\nimport { isEmpty, insert, create } from '@wordpress/rich-text';\nimport { isURL } from '@wordpress/url';\n\n/**\n * Internal dependencies\n */\nimport { addActiveFormats } from '../utils';\nimport { getPasteEventData } from '../../../utils/pasting';\n\n/** @typedef {import('@wordpress/rich-text').RichTextValue} RichTextValue */\n\nexport default ( props ) => ( element ) => {\n\tfunction _onPaste( event ) {\n\t\tconst {\n\t\t\tdisableFormats,\n\t\t\tonChange,\n\t\t\tvalue,\n\t\t\tformatTypes,\n\t\t\ttagName,\n\t\t\tonReplace,\n\t\t\t__unstableEmbedURLOnPaste,\n\t\t\tpreserveWhiteSpace,\n\t\t\tpastePlainText,\n\t\t} = props.current;\n\t\tconst { ownerDocument } = element;\n\t\tconst { defaultView } = ownerDocument;\n\t\tconst { anchorNode, focusNode } = defaultView.getSelection();\n\t\tconst containsSelection =\n\t\t\telement.contains( anchorNode ) && element.contains( focusNode );\n\n\t\t// The event listener is attached to the window, so we need to check if\n\t\t// the target is the element.\n\t\tif ( ! containsSelection ) {\n\t\t\treturn;\n\t\t}\n\n\t\tif ( event.defaultPrevented ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst { plainText, html } = getPasteEventData( event );\n\n\t\tevent.preventDefault();\n\n\t\t// Allows us to ask for this information when we get a report.\n\t\twindow.console.log( 'Received HTML:\\n\\n', html );\n\t\twindow.console.log( 'Received plain text:\\n\\n', plainText );\n\n\t\tif ( disableFormats ) {\n\t\t\tonChange( insert( value, plainText ) );\n\t\t\treturn;\n\t\t}\n\n\t\tconst isInternal =\n\t\t\tevent.clipboardData.getData( 'rich-text' ) === 'true';\n\n\t\tfunction pasteInline( content ) {\n\t\t\tconst transformed = formatTypes.reduce(\n\t\t\t\t( accumulator, { __unstablePasteRule } ) => {\n\t\t\t\t\t// Only allow one transform.\n\t\t\t\t\tif ( __unstablePasteRule && accumulator === value ) {\n\t\t\t\t\t\taccumulator = __unstablePasteRule( value, {\n\t\t\t\t\t\t\thtml,\n\t\t\t\t\t\t\tplainText,\n\t\t\t\t\t\t} );\n\t\t\t\t\t}\n\n\t\t\t\t\treturn accumulator;\n\t\t\t\t},\n\t\t\t\tvalue\n\t\t\t);\n\t\t\tif ( transformed !== value ) {\n\t\t\t\tonChange( transformed );\n\t\t\t} else {\n\t\t\t\tconst valueToInsert = create( { html: content } );\n\t\t\t\taddActiveFormats( valueToInsert, value.activeFormats );\n\t\t\t\tonChange( insert( value, valueToInsert ) );\n\t\t\t}\n\t\t}\n\n\t\t// If the data comes from a rich text instance, we can directly use it\n\t\t// without filtering the data. The filters are only meant for externally\n\t\t// pasted content and remove inline styles.\n\t\tif ( isInternal ) {\n\t\t\tpasteInline( html );\n\t\t\treturn;\n\t\t}\n\n\t\tif ( pastePlainText ) {\n\t\t\tonChange( insert( value, create( { text: plainText } ) ) );\n\t\t\treturn;\n\t\t}\n\n\t\tlet mode = 'INLINE';\n\n\t\tconst trimmedPlainText = plainText.trim();\n\n\t\tif (\n\t\t\t__unstableEmbedURLOnPaste &&\n\t\t\tisEmpty( value ) &&\n\t\t\tisURL( trimmedPlainText ) &&\n\t\t\t// For the link pasting feature, allow only http(s) protocols.\n\t\t\t/^https?:/.test( trimmedPlainText )\n\t\t) {\n\t\t\tmode = 'BLOCKS';\n\t\t}\n\n\t\tconst content = pasteHandler( {\n\t\t\tHTML: html,\n\t\t\tplainText,\n\t\t\tmode,\n\t\t\ttagName,\n\t\t\tpreserveWhiteSpace,\n\t\t} );\n\n\t\tif ( typeof content === 'string' ) {\n\t\t\tpasteInline( content );\n\t\t} else if ( content.length > 0 ) {\n\t\t\tif ( onReplace && isEmpty( value ) ) {\n\t\t\t\tonReplace( content, content.length - 1, -1 );\n\t\t\t}\n\t\t}\n\t}\n\n\tconst { defaultView } = element.ownerDocument;\n\n\t// Attach the listener to the window so parent elements have the chance to\n\t// prevent the default behavior.\n\tdefaultView.addEventListener( 'paste', _onPaste );\n\treturn () => {\n\t\tdefaultView.removeEventListener( 'paste', _onPaste );\n\t};\n};\n"],"mappings":";;;;;;AA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