@wordpress/block-editor 12.3.0 → 12.3.2
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 +10 -0
- package/README.md +13 -0
- package/build/autocompleters/block.js +5 -3
- package/build/autocompleters/block.js.map +1 -1
- package/build/components/alignment-control/index.js +4 -6
- package/build/components/alignment-control/index.js.map +1 -1
- package/build/components/alignment-control/ui.js +5 -9
- package/build/components/alignment-control/ui.js.map +1 -1
- package/build/components/autocomplete/index.js +2 -4
- package/build/components/autocomplete/index.js.map +1 -1
- package/build/components/block-actions/index.js +4 -0
- package/build/components/block-actions/index.js.map +1 -1
- package/build/components/block-alignment-control/constants.js +1 -5
- package/build/components/block-alignment-control/constants.js.map +1 -1
- package/build/components/block-alignment-control/index.js +4 -6
- package/build/components/block-alignment-control/index.js.map +1 -1
- package/build/components/block-alignment-control/ui.js +3 -4
- package/build/components/block-alignment-control/ui.js.map +1 -1
- package/build/components/block-alignment-control/ui.native.js +3 -3
- package/build/components/block-alignment-control/ui.native.js.map +1 -1
- package/build/components/block-alignment-matrix-control/index.js +0 -1
- package/build/components/block-alignment-matrix-control/index.js.map +1 -1
- package/build/components/block-breadcrumb/index.js +2 -3
- package/build/components/block-breadcrumb/index.js.map +1 -1
- package/build/components/block-controls/fill.js +2 -1
- package/build/components/block-controls/fill.js.map +1 -1
- package/build/components/block-controls/index.js +8 -8
- package/build/components/block-controls/index.js.map +1 -1
- package/build/components/block-controls/slot.js +2 -4
- package/build/components/block-controls/slot.js.map +1 -1
- package/build/components/block-controls/slot.native.js +4 -2
- package/build/components/block-controls/slot.native.js.map +1 -1
- package/build/components/block-edit/edit.js +4 -6
- package/build/components/block-edit/edit.js.map +1 -1
- package/build/components/block-edit/edit.native.js +2 -4
- package/build/components/block-edit/edit.native.js.map +1 -1
- package/build/components/block-edit/index.js +3 -2
- package/build/components/block-edit/index.js.map +1 -1
- package/build/components/block-heading-level-dropdown/heading-level-icon.js +47 -0
- package/build/components/block-heading-level-dropdown/heading-level-icon.js.map +1 -0
- package/build/components/block-heading-level-dropdown/index.js +83 -0
- package/build/components/block-heading-level-dropdown/index.js.map +1 -0
- package/build/components/block-heading-level-dropdown/index.native.js +72 -0
- package/build/components/block-heading-level-dropdown/index.native.js.map +1 -0
- package/build/components/block-icon/index.native.js +6 -7
- package/build/components/block-icon/index.native.js.map +1 -1
- package/build/components/block-info-slot-fill/index.js +4 -2
- package/build/components/block-info-slot-fill/index.js.map +1 -1
- package/build/components/block-inspector/index.js +20 -87
- package/build/components/block-inspector/index.js.map +1 -1
- package/build/components/block-list/block-list-item.native.js +4 -2
- package/build/components/block-list/block-list-item.native.js.map +1 -1
- package/build/components/block-list/block.js +6 -4
- package/build/components/block-list/block.js.map +1 -1
- package/build/components/block-list/block.native.js +1 -0
- package/build/components/block-list/block.native.js.map +1 -1
- package/build/components/block-list/index.js +7 -4
- package/build/components/block-list/index.js.map +1 -1
- package/build/components/block-list/index.native.js +8 -9
- package/build/components/block-list/index.native.js.map +1 -1
- package/build/components/block-list/subdirectory-icon.js +4 -7
- package/build/components/block-list/subdirectory-icon.js.map +1 -1
- package/build/components/block-list/use-in-between-inserter.js +1 -3
- package/build/components/block-list/use-in-between-inserter.js.map +1 -1
- package/build/components/block-list-appender/index.js +21 -19
- package/build/components/block-list-appender/index.js.map +1 -1
- package/build/components/block-lock/toolbar.js +25 -6
- package/build/components/block-lock/toolbar.js.map +1 -1
- package/build/components/block-mobile-toolbar/block-actions-menu.native.js +1 -1
- package/build/components/block-mobile-toolbar/block-actions-menu.native.js.map +1 -1
- package/build/components/block-mover/button.js +12 -12
- package/build/components/block-mover/button.js.map +1 -1
- package/build/components/block-mover/index.js +11 -10
- package/build/components/block-mover/index.js.map +1 -1
- package/build/components/block-navigation/dropdown.js +4 -6
- package/build/components/block-navigation/dropdown.js.map +1 -1
- package/build/components/block-parent-selector/index.js +4 -5
- package/build/components/block-parent-selector/index.js.map +1 -1
- package/build/components/block-pattern-setup/index.js +6 -8
- package/build/components/block-pattern-setup/index.js.map +1 -1
- package/build/components/block-patterns-list/index.js +6 -8
- package/build/components/block-patterns-list/index.js.map +1 -1
- package/build/components/block-popover/inbetween.js +4 -6
- package/build/components/block-popover/inbetween.js.map +1 -1
- package/build/components/block-popover/index.js +4 -6
- package/build/components/block-popover/index.js.map +1 -1
- package/build/components/block-preview/auto.js +2 -4
- package/build/components/block-preview/auto.js.map +1 -1
- package/build/components/block-preview/index.js +7 -7
- package/build/components/block-preview/index.js.map +1 -1
- package/build/components/block-quick-navigation/index.js +83 -0
- package/build/components/block-quick-navigation/index.js.map +1 -0
- package/build/components/block-removal-warning-modal/index.js +90 -0
- package/build/components/block-removal-warning-modal/index.js.map +1 -0
- package/build/components/block-selection-clearer/index.js +4 -7
- package/build/components/block-selection-clearer/index.js.map +1 -1
- package/build/components/block-settings/button.native.js +2 -1
- package/build/components/block-settings/button.native.js.map +1 -1
- package/build/components/block-settings/container.native.js +6 -6
- package/build/components/block-settings/container.native.js.map +1 -1
- package/build/components/block-settings-menu/block-settings-dropdown.js +10 -11
- package/build/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
- package/build/components/block-settings-menu/index.js +4 -5
- package/build/components/block-settings-menu/index.js.map +1 -1
- package/build/components/block-settings-menu-controls/index.js +4 -5
- package/build/components/block-settings-menu-controls/index.js.map +1 -1
- package/build/components/block-switcher/index.js +1 -2
- package/build/components/block-switcher/index.js.map +1 -1
- package/build/components/block-switcher/pattern-transformations-menu.js +6 -8
- package/build/components/block-switcher/pattern-transformations-menu.js.map +1 -1
- package/build/components/block-toolbar/index.js +10 -8
- package/build/components/block-toolbar/index.js.map +1 -1
- package/build/components/block-tools/block-contextual-toolbar.js +4 -5
- package/build/components/block-tools/block-contextual-toolbar.js.map +1 -1
- package/build/components/block-tools/block-selection-button.js +4 -5
- package/build/components/block-tools/block-selection-button.js.map +1 -1
- package/build/components/block-tools/index.js +13 -6
- package/build/components/block-tools/index.js.map +1 -1
- package/build/components/block-tools/insertion-point.js +5 -5
- package/build/components/block-tools/insertion-point.js.map +1 -1
- package/build/components/block-tools/selected-block-popover.js +8 -8
- package/build/components/block-tools/selected-block-popover.js.map +1 -1
- package/build/components/block-types-list/index.native.js +4 -6
- package/build/components/block-types-list/index.native.js.map +1 -1
- package/build/components/block-vertical-alignment-control/index.js +4 -6
- package/build/components/block-vertical-alignment-control/index.js.map +1 -1
- package/build/components/block-vertical-alignment-control/ui.js +5 -12
- package/build/components/block-vertical-alignment-control/ui.js.map +1 -1
- package/build/components/border-radius-control/all-input-control.js +2 -6
- package/build/components/border-radius-control/all-input-control.js.map +1 -1
- package/build/components/border-radius-control/input-controls.js +2 -6
- package/build/components/border-radius-control/input-controls.js.map +1 -1
- package/build/components/border-radius-control/linked-button.js +2 -6
- package/build/components/border-radius-control/linked-button.js.map +1 -1
- package/build/components/color-palette/control.js +2 -4
- package/build/components/color-palette/control.js.map +1 -1
- package/build/components/color-palette/with-color-context.js +2 -4
- package/build/components/color-palette/with-color-context.js.map +1 -1
- package/build/components/colors/utils.js +7 -3
- package/build/components/colors/utils.js.map +1 -1
- package/build/components/colors/with-colors.js +11 -16
- package/build/components/colors/with-colors.js.map +1 -1
- package/build/components/colors-gradients/control.js +7 -5
- package/build/components/colors-gradients/control.js.map +1 -1
- package/build/components/colors-gradients/dropdown.js +12 -11
- package/build/components/colors-gradients/dropdown.js.map +1 -1
- package/build/components/colors-gradients/panel-color-gradient-settings.js +7 -5
- package/build/components/colors-gradients/panel-color-gradient-settings.js.map +1 -1
- package/build/components/copy-handler/index.js +5 -6
- package/build/components/copy-handler/index.js.map +1 -1
- package/build/components/dimensions-tool/aspect-ratio-tool.js +99 -0
- package/build/components/dimensions-tool/aspect-ratio-tool.js.map +1 -0
- package/build/components/dimensions-tool/index.js +207 -0
- package/build/components/dimensions-tool/index.js.map +1 -0
- package/build/components/dimensions-tool/scale-tool.js +111 -0
- package/build/components/dimensions-tool/scale-tool.js.map +1 -0
- package/build/components/dimensions-tool/width-height-tool.js +125 -0
- package/build/components/dimensions-tool/width-height-tool.js.map +1 -0
- package/build/components/duotone-control/index.js +1 -2
- package/build/components/duotone-control/index.js.map +1 -1
- package/build/components/editable-text/index.js +6 -7
- package/build/components/editable-text/index.js.map +1 -1
- package/build/components/font-appearance-control/index.js +2 -6
- package/build/components/font-appearance-control/index.js.map +1 -1
- package/build/components/font-family/index.js +4 -5
- package/build/components/font-family/index.js.map +1 -1
- package/build/components/font-sizes/font-size-picker.js +2 -4
- package/build/components/font-sizes/font-size-picker.js.map +1 -1
- package/build/components/font-sizes/utils.js +3 -3
- package/build/components/font-sizes/utils.js.map +1 -1
- package/build/components/font-sizes/with-font-sizes.js +7 -7
- package/build/components/font-sizes/with-font-sizes.js.map +1 -1
- package/build/components/global-styles/color-panel.js +15 -16
- package/build/components/global-styles/color-panel.js.map +1 -1
- package/build/components/global-styles/effects-panel.js +2 -1
- package/build/components/global-styles/effects-panel.js.map +1 -1
- package/build/components/global-styles/filters-panel.js +2 -1
- package/build/components/global-styles/filters-panel.js.map +1 -1
- package/build/components/global-styles/index.js +6 -0
- package/build/components/global-styles/index.js.map +1 -1
- package/build/components/global-styles/typography-panel.js +7 -7
- package/build/components/global-styles/typography-panel.js.map +1 -1
- package/build/components/global-styles/use-global-styles-output.js +19 -16
- package/build/components/global-styles/use-global-styles-output.js.map +1 -1
- package/build/components/gradients/with-gradient.js +2 -6
- package/build/components/gradients/with-gradient.js.map +1 -1
- package/build/components/iframe/index.js +5 -7
- package/build/components/iframe/index.js.map +1 -1
- package/build/components/image-editor/aspect-ratio-dropdown.js +1 -1
- package/build/components/image-editor/aspect-ratio-dropdown.js.map +1 -1
- package/build/components/image-editor/constants.js +1 -2
- package/build/components/image-editor/constants.js.map +1 -1
- package/build/components/image-editor/use-save-image.js +1 -2
- package/build/components/image-editor/use-save-image.js.map +1 -1
- package/build/components/image-size-control/index.js +6 -0
- package/build/components/image-size-control/index.js.map +1 -1
- package/build/components/index.js +9 -9
- package/build/components/index.js.map +1 -1
- package/build/components/index.native.js +9 -0
- package/build/components/index.native.js.map +1 -1
- package/build/components/inner-blocks/index.js +9 -8
- package/build/components/inner-blocks/index.js.map +1 -1
- package/build/components/inner-blocks/index.native.js +8 -7
- package/build/components/inner-blocks/index.native.js.map +1 -1
- package/build/components/inner-blocks/use-nested-settings-update.js +24 -30
- package/build/components/inner-blocks/use-nested-settings-update.js.map +1 -1
- package/build/components/inner-blocks/with-client-id.js +2 -6
- package/build/components/inner-blocks/with-client-id.js.map +1 -1
- package/build/components/inserter/block-patterns-explorer/explorer.js +2 -1
- package/build/components/inserter/block-patterns-explorer/explorer.js.map +1 -1
- package/build/components/inserter/block-patterns-tab.js +33 -5
- package/build/components/inserter/block-patterns-tab.js.map +1 -1
- package/build/components/inserter/hooks/use-block-types-state.js +4 -3
- package/build/components/inserter/hooks/use-block-types-state.js.map +1 -1
- package/build/components/inserter/hooks/use-insertion-point.js +1 -1
- package/build/components/inserter/hooks/use-insertion-point.js.map +1 -1
- package/build/components/inserter/index.js +8 -8
- package/build/components/inserter/index.js.map +1 -1
- package/build/components/inserter/index.native.js +4 -5
- package/build/components/inserter/index.native.js.map +1 -1
- package/build/components/inserter/library.js +1 -1
- package/build/components/inserter/library.js.map +1 -1
- package/build/components/inserter/media-tab/media-list.js +2 -6
- package/build/components/inserter/media-tab/media-list.js.map +1 -1
- package/build/components/inserter/media-tab/media-preview.js +4 -6
- package/build/components/inserter/media-tab/media-preview.js.map +1 -1
- package/build/components/inserter/media-tab/media-tab.js +1 -1
- package/build/components/inserter/media-tab/media-tab.js.map +1 -1
- package/build/components/inserter/reusable-blocks-tab.js +3 -3
- package/build/components/inserter/reusable-blocks-tab.js.map +1 -1
- package/build/components/inserter/tabs.js +3 -3
- package/build/components/inserter/tabs.js.map +1 -1
- package/build/components/inserter-list-item/index.js +4 -5
- package/build/components/inserter-list-item/index.js.map +1 -1
- package/build/components/inserter-listbox/group.js +4 -7
- package/build/components/inserter-listbox/group.js.map +1 -1
- package/build/components/inserter-listbox/item.js +8 -7
- package/build/components/inserter-listbox/item.js.map +1 -1
- package/build/components/inserter-listbox/row.js +4 -5
- package/build/components/inserter-listbox/row.js.map +1 -1
- package/build/components/inspector-controls/block-support-slot-container.js +2 -6
- package/build/components/inspector-controls/block-support-slot-container.js.map +1 -1
- package/build/components/inspector-controls/fill.native.js +2 -1
- package/build/components/inspector-controls/fill.native.js.map +1 -1
- package/build/components/inspector-controls/index.js +4 -6
- package/build/components/inspector-controls/index.js.map +1 -1
- package/build/components/inspector-controls/slot.js +4 -6
- package/build/components/inspector-controls/slot.js.map +1 -1
- package/build/components/inspector-controls/slot.native.js +2 -1
- package/build/components/inspector-controls/slot.native.js.map +1 -1
- package/build/components/justify-content-control/index.js +4 -6
- package/build/components/justify-content-control/index.js.map +1 -1
- package/build/components/justify-content-control/ui.js +4 -7
- package/build/components/justify-content-control/ui.js.map +1 -1
- package/build/components/letter-spacing-control/index.js +2 -4
- package/build/components/letter-spacing-control/index.js.map +1 -1
- package/build/components/line-height-control/index.js +2 -4
- package/build/components/line-height-control/index.js.map +1 -1
- package/build/components/link-control/index.js +20 -24
- package/build/components/link-control/index.js.map +1 -1
- package/build/components/link-control/search-create-button.js +2 -4
- package/build/components/link-control/search-create-button.js.map +1 -1
- package/build/components/link-control/search-input.js +7 -5
- package/build/components/link-control/search-input.js.map +1 -1
- package/build/components/link-control/search-item.js +2 -4
- package/build/components/link-control/search-item.js.map +1 -1
- package/build/components/link-control/search-results.js +2 -4
- package/build/components/link-control/search-results.js.map +1 -1
- package/build/components/link-control/settings-drawer.js +2 -3
- package/build/components/link-control/settings-drawer.js.map +1 -1
- package/build/components/list-view/appender.js +4 -6
- package/build/components/list-view/appender.js.map +1 -1
- package/build/components/list-view/aria-referenced-text.js +4 -8
- package/build/components/list-view/aria-referenced-text.js.map +1 -1
- package/build/components/list-view/block-contents.js +4 -5
- package/build/components/list-view/block-contents.js.map +1 -1
- package/build/components/list-view/block-select-button.js +13 -2
- package/build/components/list-view/block-select-button.js.map +1 -1
- package/build/components/list-view/branch.js +9 -8
- package/build/components/list-view/branch.js.map +1 -1
- package/build/components/list-view/drop-indicator.js +62 -11
- package/build/components/list-view/drop-indicator.js.map +1 -1
- package/build/components/list-view/index.js +4 -6
- package/build/components/list-view/index.js.map +1 -1
- package/build/components/list-view/leaf.js +4 -5
- package/build/components/list-view/leaf.js.map +1 -1
- package/build/components/list-view/use-list-view-client-ids.js +2 -22
- package/build/components/list-view/use-list-view-client-ids.js.map +1 -1
- package/build/components/list-view/use-list-view-drop-zone.js +46 -34
- package/build/components/list-view/use-list-view-drop-zone.js.map +1 -1
- package/build/components/media-placeholder/index.js +38 -13
- package/build/components/media-placeholder/index.js.map +1 -1
- package/build/components/media-replace-flow/index.js +1 -3
- package/build/components/media-replace-flow/index.js.map +1 -1
- package/build/components/navigable-toolbar/index.js +8 -8
- package/build/components/navigable-toolbar/index.js.map +1 -1
- package/build/components/panel-color-settings/index.js +4 -5
- package/build/components/panel-color-settings/index.js.map +1 -1
- package/build/components/plain-text/index.js +8 -8
- package/build/components/plain-text/index.js.map +1 -1
- package/build/components/plain-text/index.native.js +7 -6
- package/build/components/plain-text/index.native.js.map +1 -1
- package/build/components/preview-options/index.js +5 -4
- package/build/components/preview-options/index.js.map +1 -1
- package/build/components/provider/index.js +2 -4
- package/build/components/provider/index.js.map +1 -1
- package/build/components/provider/use-block-sync.js +21 -0
- package/build/components/provider/use-block-sync.js.map +1 -1
- package/build/components/provider/with-registry-provider.js +8 -10
- package/build/components/provider/with-registry-provider.js.map +1 -1
- package/build/components/publish-date-time-picker/index.js +4 -5
- package/build/components/publish-date-time-picker/index.js.map +1 -1
- package/build/components/resizable-box-popover/index.js +5 -5
- package/build/components/resizable-box-popover/index.js.map +1 -1
- package/build/components/resolution-tool/index.js +55 -0
- package/build/components/resolution-tool/index.js.map +1 -0
- package/build/components/rich-text/content.js +99 -0
- package/build/components/rich-text/content.js.map +1 -0
- package/build/components/rich-text/format-toolbar/index.js +1 -2
- package/build/components/rich-text/format-toolbar/index.js.map +1 -1
- package/build/components/rich-text/index.js +8 -42
- package/build/components/rich-text/index.js.map +1 -1
- package/build/components/rich-text/index.native.js +6 -34
- package/build/components/rich-text/index.native.js.map +1 -1
- package/build/components/rich-text/toolbar-button.js +2 -6
- package/build/components/rich-text/toolbar-button.js.map +1 -1
- package/build/components/spacing-sizes-control/index.js +8 -8
- package/build/components/spacing-sizes-control/index.js.map +1 -1
- package/build/components/tool-selector/index.js +2 -6
- package/build/components/tool-selector/index.js.map +1 -1
- package/build/components/unit-control/index.js +4 -5
- package/build/components/unit-control/index.js.map +1 -1
- package/build/components/url-input/index.js +12 -10
- package/build/components/url-input/index.js.map +1 -1
- package/build/components/url-input/index.native.js +4 -7
- package/build/components/url-input/index.native.js.map +1 -1
- package/build/components/url-popover/image-url-input-ui.js +21 -14
- package/build/components/url-popover/image-url-input-ui.js.map +1 -1
- package/build/components/url-popover/index.js +4 -5
- package/build/components/url-popover/index.js.map +1 -1
- package/build/components/url-popover/link-editor.js +4 -5
- package/build/components/url-popover/link-editor.js.map +1 -1
- package/build/components/url-popover/link-viewer.js +4 -5
- package/build/components/url-popover/link-viewer.js.map +1 -1
- package/build/components/use-block-display-information/index.js +30 -2
- package/build/components/use-block-display-information/index.js.map +1 -1
- package/build/components/video-player/index.native.js +2 -4
- package/build/components/video-player/index.native.js.map +1 -1
- package/build/components/warning/index.native.js +4 -5
- package/build/components/warning/index.native.js.map +1 -1
- package/build/components/writing-flow/index.js +2 -4
- package/build/components/writing-flow/index.js.map +1 -1
- package/build/components/writing-flow/use-drag-selection.js +1 -1
- package/build/components/writing-flow/use-drag-selection.js.map +1 -1
- package/build/components/writing-flow/use-tab-nav.js +32 -4
- package/build/components/writing-flow/use-tab-nav.js.map +1 -1
- package/build/hooks/align.js +8 -8
- package/build/hooks/align.js.map +1 -1
- package/build/hooks/anchor.js +4 -2
- package/build/hooks/anchor.js.map +1 -1
- package/build/hooks/behaviors.js +75 -37
- package/build/hooks/behaviors.js.map +1 -1
- package/build/hooks/border.js +4 -5
- package/build/hooks/border.js.map +1 -1
- package/build/hooks/color.js +4 -5
- package/build/hooks/color.js.map +1 -1
- package/build/hooks/content-lock-ui.js +8 -10
- package/build/hooks/content-lock-ui.js.map +1 -1
- package/build/hooks/custom-class-name.js +4 -2
- package/build/hooks/custom-class-name.js.map +1 -1
- package/build/hooks/dimensions.js +7 -7
- package/build/hooks/dimensions.js.map +1 -1
- package/build/hooks/duotone.js +5 -5
- package/build/hooks/duotone.js.map +1 -1
- package/build/hooks/font-family.js +2 -6
- package/build/hooks/font-family.js.map +1 -1
- package/build/hooks/font-size.js +10 -8
- package/build/hooks/font-size.js.map +1 -1
- package/build/hooks/layout.js +30 -28
- package/build/hooks/layout.js.map +1 -1
- package/build/hooks/position.js +24 -16
- package/build/hooks/position.js.map +1 -1
- package/build/hooks/style.js +8 -5
- package/build/hooks/style.js.map +1 -1
- package/build/hooks/supports.js +1 -1
- package/build/hooks/supports.js.map +1 -1
- package/build/hooks/typography.native.js +3 -1
- package/build/hooks/typography.native.js.map +1 -1
- package/build/hooks/use-typography-props.js +10 -17
- package/build/hooks/use-typography-props.js.map +1 -1
- package/build/index.js +0 -14
- package/build/index.js.map +1 -1
- package/build/layouts/constrained.js +3 -1
- package/build/layouts/constrained.js.map +1 -1
- package/build/layouts/definitions.js +154 -0
- package/build/layouts/definitions.js.map +1 -0
- package/build/layouts/flex.js +8 -5
- package/build/layouts/flex.js.map +1 -1
- package/build/layouts/flow.js +3 -1
- package/build/layouts/flow.js.map +1 -1
- package/build/layouts/grid.js +3 -1
- package/build/layouts/grid.js.map +1 -1
- package/build/layouts/utils.js +8 -2
- package/build/layouts/utils.js.map +1 -1
- package/build/private-apis.js +23 -1
- package/build/private-apis.js.map +1 -1
- package/build/store/actions.js +2 -62
- package/build/store/actions.js.map +1 -1
- package/build/store/defaults.js +1 -0
- package/build/store/defaults.js.map +1 -1
- package/build/store/private-actions.js +200 -0
- package/build/store/private-actions.js.map +1 -1
- package/build/store/private-selectors.js +72 -4
- package/build/store/private-selectors.js.map +1 -1
- package/build/store/reducer.js +52 -1
- package/build/store/reducer.js.map +1 -1
- package/build/store/selectors.js +42 -42
- package/build/store/selectors.js.map +1 -1
- package/build/utils/object.js +39 -0
- package/build/utils/object.js.map +1 -1
- package/build-module/autocompleters/block.js +5 -3
- package/build-module/autocompleters/block.js.map +1 -1
- package/build-module/components/alignment-control/index.js +4 -5
- package/build-module/components/alignment-control/index.js.map +1 -1
- package/build-module/components/alignment-control/ui.js +5 -6
- package/build-module/components/alignment-control/ui.js.map +1 -1
- package/build-module/components/autocomplete/index.js +2 -3
- package/build-module/components/autocomplete/index.js.map +1 -1
- package/build-module/components/block-actions/index.js +4 -0
- package/build-module/components/block-actions/index.js.map +1 -1
- package/build-module/components/block-alignment-control/constants.js +0 -3
- package/build-module/components/block-alignment-control/constants.js.map +1 -1
- package/build-module/components/block-alignment-control/index.js +4 -5
- package/build-module/components/block-alignment-control/index.js.map +1 -1
- package/build-module/components/block-alignment-control/ui.js +4 -4
- package/build-module/components/block-alignment-control/ui.js.map +1 -1
- package/build-module/components/block-alignment-control/ui.native.js +3 -2
- package/build-module/components/block-alignment-control/ui.native.js.map +1 -1
- package/build-module/components/block-alignment-matrix-control/index.js +0 -1
- package/build-module/components/block-alignment-matrix-control/index.js.map +1 -1
- package/build-module/components/block-breadcrumb/index.js +2 -3
- package/build-module/components/block-breadcrumb/index.js.map +1 -1
- package/build-module/components/block-controls/fill.js +2 -1
- package/build-module/components/block-controls/fill.js.map +1 -1
- package/build-module/components/block-controls/index.js +8 -7
- package/build-module/components/block-controls/index.js.map +1 -1
- package/build-module/components/block-controls/slot.js +2 -3
- package/build-module/components/block-controls/slot.js.map +1 -1
- package/build-module/components/block-controls/slot.native.js +4 -2
- package/build-module/components/block-controls/slot.native.js.map +1 -1
- package/build-module/components/block-edit/edit.js +4 -5
- package/build-module/components/block-edit/edit.js.map +1 -1
- package/build-module/components/block-edit/edit.native.js +2 -3
- package/build-module/components/block-edit/edit.native.js.map +1 -1
- package/build-module/components/block-edit/index.js +3 -2
- package/build-module/components/block-edit/index.js.map +1 -1
- package/build-module/components/block-heading-level-dropdown/heading-level-icon.js +39 -0
- package/build-module/components/block-heading-level-dropdown/heading-level-icon.js.map +1 -0
- package/build-module/components/block-heading-level-dropdown/index.js +71 -0
- package/build-module/components/block-heading-level-dropdown/index.js.map +1 -0
- package/build-module/components/block-heading-level-dropdown/index.native.js +60 -0
- package/build-module/components/block-heading-level-dropdown/index.native.js.map +1 -0
- package/build-module/components/block-icon/index.native.js +6 -6
- package/build-module/components/block-icon/index.native.js.map +1 -1
- package/build-module/components/block-info-slot-fill/index.js +4 -2
- package/build-module/components/block-info-slot-fill/index.js.map +1 -1
- package/build-module/components/block-inspector/index.js +20 -88
- package/build-module/components/block-inspector/index.js.map +1 -1
- package/build-module/components/block-list/block-list-item.native.js +4 -2
- package/build-module/components/block-list/block-list-item.native.js.map +1 -1
- package/build-module/components/block-list/block.js +6 -4
- package/build-module/components/block-list/block.js.map +1 -1
- package/build-module/components/block-list/block.native.js +1 -0
- package/build-module/components/block-list/block.native.js.map +1 -1
- package/build-module/components/block-list/index.js +7 -4
- package/build-module/components/block-list/index.js.map +1 -1
- package/build-module/components/block-list/index.native.js +8 -8
- package/build-module/components/block-list/index.native.js.map +1 -1
- package/build-module/components/block-list/subdirectory-icon.js +4 -4
- package/build-module/components/block-list/subdirectory-icon.js.map +1 -1
- package/build-module/components/block-list/use-in-between-inserter.js +1 -3
- package/build-module/components/block-list/use-in-between-inserter.js.map +1 -1
- package/build-module/components/block-list-appender/index.js +21 -19
- package/build-module/components/block-list-appender/index.js.map +1 -1
- package/build-module/components/block-lock/toolbar.js +25 -7
- package/build-module/components/block-lock/toolbar.js.map +1 -1
- package/build-module/components/block-mobile-toolbar/block-actions-menu.native.js +1 -1
- package/build-module/components/block-mobile-toolbar/block-actions-menu.native.js.map +1 -1
- package/build-module/components/block-mover/button.js +12 -11
- package/build-module/components/block-mover/button.js.map +1 -1
- package/build-module/components/block-mover/index.js +11 -9
- package/build-module/components/block-mover/index.js.map +1 -1
- package/build-module/components/block-navigation/dropdown.js +4 -5
- package/build-module/components/block-navigation/dropdown.js.map +1 -1
- package/build-module/components/block-parent-selector/index.js +4 -4
- package/build-module/components/block-parent-selector/index.js.map +1 -1
- package/build-module/components/block-pattern-setup/index.js +6 -7
- package/build-module/components/block-pattern-setup/index.js.map +1 -1
- package/build-module/components/block-patterns-list/index.js +6 -7
- package/build-module/components/block-patterns-list/index.js.map +1 -1
- package/build-module/components/block-popover/inbetween.js +4 -5
- package/build-module/components/block-popover/inbetween.js.map +1 -1
- package/build-module/components/block-popover/index.js +4 -5
- package/build-module/components/block-popover/index.js.map +1 -1
- package/build-module/components/block-preview/auto.js +2 -3
- package/build-module/components/block-preview/auto.js.map +1 -1
- package/build-module/components/block-preview/index.js +7 -7
- package/build-module/components/block-preview/index.js.map +1 -1
- package/build-module/components/block-quick-navigation/index.js +69 -0
- package/build-module/components/block-quick-navigation/index.js.map +1 -0
- package/build-module/components/block-removal-warning-modal/index.js +76 -0
- package/build-module/components/block-removal-warning-modal/index.js.map +1 -0
- package/build-module/components/block-selection-clearer/index.js +4 -4
- package/build-module/components/block-selection-clearer/index.js.map +1 -1
- package/build-module/components/block-settings/button.native.js +2 -1
- package/build-module/components/block-settings/button.native.js.map +1 -1
- package/build-module/components/block-settings/container.native.js +6 -5
- package/build-module/components/block-settings/container.native.js.map +1 -1
- package/build-module/components/block-settings-menu/block-settings-dropdown.js +10 -10
- package/build-module/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
- package/build-module/components/block-settings-menu/index.js +4 -4
- package/build-module/components/block-settings-menu/index.js.map +1 -1
- package/build-module/components/block-settings-menu-controls/index.js +4 -4
- package/build-module/components/block-settings-menu-controls/index.js.map +1 -1
- package/build-module/components/block-switcher/index.js +1 -2
- package/build-module/components/block-switcher/index.js.map +1 -1
- package/build-module/components/block-switcher/pattern-transformations-menu.js +6 -7
- package/build-module/components/block-switcher/pattern-transformations-menu.js.map +1 -1
- package/build-module/components/block-toolbar/index.js +10 -7
- package/build-module/components/block-toolbar/index.js.map +1 -1
- package/build-module/components/block-tools/block-contextual-toolbar.js +4 -4
- package/build-module/components/block-tools/block-contextual-toolbar.js.map +1 -1
- package/build-module/components/block-tools/block-selection-button.js +4 -4
- package/build-module/components/block-tools/block-selection-button.js.map +1 -1
- package/build-module/components/block-tools/index.js +13 -5
- package/build-module/components/block-tools/index.js.map +1 -1
- package/build-module/components/block-tools/insertion-point.js +5 -4
- package/build-module/components/block-tools/insertion-point.js.map +1 -1
- package/build-module/components/block-tools/selected-block-popover.js +8 -7
- package/build-module/components/block-tools/selected-block-popover.js.map +1 -1
- package/build-module/components/block-types-list/index.native.js +4 -5
- package/build-module/components/block-types-list/index.native.js.map +1 -1
- package/build-module/components/block-vertical-alignment-control/index.js +4 -5
- package/build-module/components/block-vertical-alignment-control/index.js.map +1 -1
- package/build-module/components/block-vertical-alignment-control/ui.js +5 -9
- package/build-module/components/block-vertical-alignment-control/ui.js.map +1 -1
- package/build-module/components/border-radius-control/all-input-control.js +2 -3
- package/build-module/components/border-radius-control/all-input-control.js.map +1 -1
- package/build-module/components/border-radius-control/input-controls.js +2 -3
- package/build-module/components/border-radius-control/input-controls.js.map +1 -1
- package/build-module/components/border-radius-control/linked-button.js +2 -3
- package/build-module/components/border-radius-control/linked-button.js.map +1 -1
- package/build-module/components/color-palette/control.js +2 -3
- package/build-module/components/color-palette/control.js.map +1 -1
- package/build-module/components/color-palette/with-color-context.js +2 -3
- package/build-module/components/color-palette/with-color-context.js.map +1 -1
- package/build-module/components/colors/utils.js +5 -1
- package/build-module/components/colors/utils.js.map +1 -1
- package/build-module/components/colors/with-colors.js +10 -14
- package/build-module/components/colors/with-colors.js.map +1 -1
- package/build-module/components/colors-gradients/control.js +7 -4
- package/build-module/components/colors-gradients/control.js.map +1 -1
- package/build-module/components/colors-gradients/dropdown.js +12 -10
- package/build-module/components/colors-gradients/dropdown.js.map +1 -1
- package/build-module/components/colors-gradients/panel-color-gradient-settings.js +7 -4
- package/build-module/components/colors-gradients/panel-color-gradient-settings.js.map +1 -1
- package/build-module/components/copy-handler/index.js +5 -6
- package/build-module/components/copy-handler/index.js.map +1 -1
- package/build-module/components/dimensions-tool/aspect-ratio-tool.js +87 -0
- package/build-module/components/dimensions-tool/aspect-ratio-tool.js.map +1 -0
- package/build-module/components/dimensions-tool/index.js +195 -0
- package/build-module/components/dimensions-tool/index.js.map +1 -0
- package/build-module/components/dimensions-tool/scale-tool.js +103 -0
- package/build-module/components/dimensions-tool/scale-tool.js.map +1 -0
- package/build-module/components/dimensions-tool/width-height-tool.js +122 -0
- package/build-module/components/dimensions-tool/width-height-tool.js.map +1 -0
- package/build-module/components/duotone-control/index.js +1 -2
- package/build-module/components/duotone-control/index.js.map +1 -1
- package/build-module/components/editable-text/index.js +6 -6
- package/build-module/components/editable-text/index.js.map +1 -1
- package/build-module/components/font-appearance-control/index.js +2 -3
- package/build-module/components/font-appearance-control/index.js.map +1 -1
- package/build-module/components/font-family/index.js +4 -4
- package/build-module/components/font-family/index.js.map +1 -1
- package/build-module/components/font-sizes/font-size-picker.js +2 -3
- package/build-module/components/font-sizes/font-size-picker.js.map +1 -1
- package/build-module/components/font-sizes/utils.js +2 -2
- package/build-module/components/font-sizes/utils.js.map +1 -1
- package/build-module/components/font-sizes/with-font-sizes.js +7 -6
- package/build-module/components/font-sizes/with-font-sizes.js.map +1 -1
- package/build-module/components/global-styles/color-panel.js +15 -15
- package/build-module/components/global-styles/color-panel.js.map +1 -1
- package/build-module/components/global-styles/effects-panel.js +2 -1
- package/build-module/components/global-styles/effects-panel.js.map +1 -1
- package/build-module/components/global-styles/filters-panel.js +2 -1
- package/build-module/components/global-styles/filters-panel.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/typography-panel.js +7 -7
- package/build-module/components/global-styles/typography-panel.js.map +1 -1
- package/build-module/components/global-styles/use-global-styles-output.js +11 -10
- package/build-module/components/global-styles/use-global-styles-output.js.map +1 -1
- package/build-module/components/gradients/with-gradient.js +2 -3
- package/build-module/components/gradients/with-gradient.js.map +1 -1
- package/build-module/components/iframe/index.js +5 -6
- package/build-module/components/iframe/index.js.map +1 -1
- package/build-module/components/image-editor/aspect-ratio-dropdown.js +1 -1
- package/build-module/components/image-editor/aspect-ratio-dropdown.js.map +1 -1
- package/build-module/components/image-editor/constants.js +1 -2
- package/build-module/components/image-editor/constants.js.map +1 -1
- package/build-module/components/image-editor/use-save-image.js +1 -2
- package/build-module/components/image-editor/use-save-image.js.map +1 -1
- package/build-module/components/image-size-control/index.js +5 -0
- package/build-module/components/image-size-control/index.js.map +1 -1
- package/build-module/components/index.js +1 -1
- package/build-module/components/index.js.map +1 -1
- package/build-module/components/index.native.js +1 -0
- package/build-module/components/index.native.js.map +1 -1
- package/build-module/components/inner-blocks/index.js +9 -7
- package/build-module/components/inner-blocks/index.js.map +1 -1
- package/build-module/components/inner-blocks/index.native.js +8 -6
- package/build-module/components/inner-blocks/index.native.js.map +1 -1
- package/build-module/components/inner-blocks/use-nested-settings-update.js +24 -27
- package/build-module/components/inner-blocks/use-nested-settings-update.js.map +1 -1
- package/build-module/components/inner-blocks/with-client-id.js +2 -3
- package/build-module/components/inner-blocks/with-client-id.js.map +1 -1
- package/build-module/components/inserter/block-patterns-explorer/explorer.js +2 -1
- package/build-module/components/inserter/block-patterns-explorer/explorer.js.map +1 -1
- package/build-module/components/inserter/block-patterns-tab.js +33 -7
- package/build-module/components/inserter/block-patterns-tab.js.map +1 -1
- package/build-module/components/inserter/hooks/use-block-types-state.js +4 -3
- package/build-module/components/inserter/hooks/use-block-types-state.js.map +1 -1
- package/build-module/components/inserter/hooks/use-insertion-point.js +1 -1
- package/build-module/components/inserter/hooks/use-insertion-point.js.map +1 -1
- package/build-module/components/inserter/index.js +8 -7
- package/build-module/components/inserter/index.js.map +1 -1
- package/build-module/components/inserter/index.native.js +4 -4
- package/build-module/components/inserter/index.native.js.map +1 -1
- package/build-module/components/inserter/library.js +1 -1
- package/build-module/components/inserter/library.js.map +1 -1
- package/build-module/components/inserter/media-tab/media-list.js +2 -3
- package/build-module/components/inserter/media-tab/media-list.js.map +1 -1
- package/build-module/components/inserter/media-tab/media-preview.js +4 -5
- package/build-module/components/inserter/media-tab/media-preview.js.map +1 -1
- package/build-module/components/inserter/media-tab/media-tab.js +3 -3
- package/build-module/components/inserter/media-tab/media-tab.js.map +1 -1
- package/build-module/components/inserter/reusable-blocks-tab.js +3 -3
- package/build-module/components/inserter/reusable-blocks-tab.js.map +1 -1
- package/build-module/components/inserter/tabs.js +3 -3
- package/build-module/components/inserter/tabs.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/group.js +4 -4
- package/build-module/components/inserter-listbox/group.js.map +1 -1
- package/build-module/components/inserter-listbox/item.js +8 -6
- package/build-module/components/inserter-listbox/item.js.map +1 -1
- package/build-module/components/inserter-listbox/row.js +4 -4
- package/build-module/components/inserter-listbox/row.js.map +1 -1
- package/build-module/components/inspector-controls/block-support-slot-container.js +2 -3
- package/build-module/components/inspector-controls/block-support-slot-container.js.map +1 -1
- package/build-module/components/inspector-controls/fill.native.js +2 -1
- package/build-module/components/inspector-controls/fill.native.js.map +1 -1
- package/build-module/components/inspector-controls/index.js +4 -5
- package/build-module/components/inspector-controls/index.js.map +1 -1
- package/build-module/components/inspector-controls/slot.js +4 -5
- package/build-module/components/inspector-controls/slot.js.map +1 -1
- package/build-module/components/inspector-controls/slot.native.js +2 -1
- package/build-module/components/inspector-controls/slot.native.js.map +1 -1
- package/build-module/components/justify-content-control/index.js +4 -5
- package/build-module/components/justify-content-control/index.js.map +1 -1
- package/build-module/components/justify-content-control/ui.js +4 -4
- package/build-module/components/justify-content-control/ui.js.map +1 -1
- package/build-module/components/letter-spacing-control/index.js +2 -3
- package/build-module/components/letter-spacing-control/index.js.map +1 -1
- package/build-module/components/line-height-control/index.js +2 -3
- package/build-module/components/line-height-control/index.js.map +1 -1
- package/build-module/components/link-control/index.js +20 -24
- package/build-module/components/link-control/index.js.map +1 -1
- package/build-module/components/link-control/search-create-button.js +2 -3
- package/build-module/components/link-control/search-create-button.js.map +1 -1
- package/build-module/components/link-control/search-input.js +7 -5
- package/build-module/components/link-control/search-input.js.map +1 -1
- package/build-module/components/link-control/search-item.js +2 -3
- package/build-module/components/link-control/search-item.js.map +1 -1
- package/build-module/components/link-control/search-results.js +2 -3
- package/build-module/components/link-control/search-results.js.map +1 -1
- package/build-module/components/link-control/settings-drawer.js +4 -5
- package/build-module/components/link-control/settings-drawer.js.map +1 -1
- package/build-module/components/list-view/appender.js +4 -5
- package/build-module/components/list-view/appender.js.map +1 -1
- package/build-module/components/list-view/aria-referenced-text.js +4 -5
- package/build-module/components/list-view/aria-referenced-text.js.map +1 -1
- package/build-module/components/list-view/block-contents.js +4 -4
- package/build-module/components/list-view/block-contents.js.map +1 -1
- package/build-module/components/list-view/block-select-button.js +14 -4
- package/build-module/components/list-view/block-select-button.js.map +1 -1
- package/build-module/components/list-view/branch.js +9 -7
- package/build-module/components/list-view/branch.js.map +1 -1
- package/build-module/components/list-view/drop-indicator.js +61 -11
- package/build-module/components/list-view/drop-indicator.js.map +1 -1
- package/build-module/components/list-view/index.js +4 -5
- package/build-module/components/list-view/index.js.map +1 -1
- package/build-module/components/list-view/leaf.js +4 -4
- package/build-module/components/list-view/leaf.js.map +1 -1
- package/build-module/components/list-view/use-list-view-client-ids.js +2 -22
- package/build-module/components/list-view/use-list-view-client-ids.js.map +1 -1
- package/build-module/components/list-view/use-list-view-drop-zone.js +45 -34
- package/build-module/components/list-view/use-list-view-drop-zone.js.map +1 -1
- package/build-module/components/media-placeholder/index.js +38 -13
- package/build-module/components/media-placeholder/index.js.map +1 -1
- package/build-module/components/media-replace-flow/index.js +1 -3
- package/build-module/components/media-replace-flow/index.js.map +1 -1
- package/build-module/components/navigable-toolbar/index.js +8 -7
- package/build-module/components/navigable-toolbar/index.js.map +1 -1
- package/build-module/components/panel-color-settings/index.js +4 -4
- package/build-module/components/panel-color-settings/index.js.map +1 -1
- package/build-module/components/plain-text/index.js +8 -7
- package/build-module/components/plain-text/index.js.map +1 -1
- package/build-module/components/plain-text/index.native.js +7 -5
- package/build-module/components/plain-text/index.native.js.map +1 -1
- package/build-module/components/preview-options/index.js +5 -4
- package/build-module/components/preview-options/index.js.map +1 -1
- package/build-module/components/provider/index.js +2 -3
- package/build-module/components/provider/index.js.map +1 -1
- package/build-module/components/provider/use-block-sync.js +21 -0
- package/build-module/components/provider/use-block-sync.js.map +1 -1
- package/build-module/components/provider/with-registry-provider.js +8 -7
- package/build-module/components/provider/with-registry-provider.js.map +1 -1
- package/build-module/components/publish-date-time-picker/index.js +4 -4
- package/build-module/components/publish-date-time-picker/index.js.map +1 -1
- package/build-module/components/resizable-box-popover/index.js +5 -4
- package/build-module/components/resizable-box-popover/index.js.map +1 -1
- package/build-module/components/resolution-tool/index.js +45 -0
- package/build-module/components/resolution-tool/index.js.map +1 -0
- package/build-module/components/rich-text/content.js +85 -0
- package/build-module/components/rich-text/content.js.map +1 -0
- package/build-module/components/rich-text/format-toolbar/index.js +1 -2
- package/build-module/components/rich-text/format-toolbar/index.js.map +1 -1
- package/build-module/components/rich-text/index.js +8 -42
- package/build-module/components/rich-text/index.js.map +1 -1
- package/build-module/components/rich-text/index.native.js +6 -34
- package/build-module/components/rich-text/index.native.js.map +1 -1
- package/build-module/components/rich-text/toolbar-button.js +2 -3
- package/build-module/components/rich-text/toolbar-button.js.map +1 -1
- package/build-module/components/spacing-sizes-control/index.js +8 -7
- package/build-module/components/spacing-sizes-control/index.js.map +1 -1
- package/build-module/components/tool-selector/index.js +2 -3
- package/build-module/components/tool-selector/index.js.map +1 -1
- package/build-module/components/unit-control/index.js +4 -4
- package/build-module/components/unit-control/index.js.map +1 -1
- package/build-module/components/url-input/index.js +12 -9
- package/build-module/components/url-input/index.js.map +1 -1
- package/build-module/components/url-input/index.native.js +4 -4
- package/build-module/components/url-input/index.native.js.map +1 -1
- package/build-module/components/url-popover/image-url-input-ui.js +22 -15
- package/build-module/components/url-popover/image-url-input-ui.js.map +1 -1
- package/build-module/components/url-popover/index.js +4 -4
- package/build-module/components/url-popover/index.js.map +1 -1
- package/build-module/components/url-popover/link-editor.js +4 -4
- package/build-module/components/url-popover/link-editor.js.map +1 -1
- package/build-module/components/url-popover/link-viewer.js +4 -4
- package/build-module/components/url-popover/link-viewer.js.map +1 -1
- package/build-module/components/use-block-display-information/index.js +29 -2
- package/build-module/components/use-block-display-information/index.js.map +1 -1
- package/build-module/components/video-player/index.native.js +2 -3
- package/build-module/components/video-player/index.native.js.map +1 -1
- package/build-module/components/warning/index.native.js +4 -4
- package/build-module/components/warning/index.native.js.map +1 -1
- package/build-module/components/writing-flow/index.js +2 -3
- package/build-module/components/writing-flow/index.js.map +1 -1
- package/build-module/components/writing-flow/use-drag-selection.js +1 -1
- package/build-module/components/writing-flow/use-drag-selection.js.map +1 -1
- package/build-module/components/writing-flow/use-tab-nav.js +32 -5
- package/build-module/components/writing-flow/use-tab-nav.js.map +1 -1
- package/build-module/hooks/align.js +8 -7
- package/build-module/hooks/align.js.map +1 -1
- package/build-module/hooks/anchor.js +4 -2
- package/build-module/hooks/anchor.js.map +1 -1
- package/build-module/hooks/behaviors.js +76 -34
- package/build-module/hooks/behaviors.js.map +1 -1
- package/build-module/hooks/border.js +4 -4
- package/build-module/hooks/border.js.map +1 -1
- package/build-module/hooks/color.js +4 -4
- package/build-module/hooks/color.js.map +1 -1
- package/build-module/hooks/content-lock-ui.js +8 -7
- package/build-module/hooks/content-lock-ui.js.map +1 -1
- package/build-module/hooks/custom-class-name.js +4 -2
- package/build-module/hooks/custom-class-name.js.map +1 -1
- package/build-module/hooks/dimensions.js +7 -6
- package/build-module/hooks/dimensions.js.map +1 -1
- package/build-module/hooks/duotone.js +5 -4
- package/build-module/hooks/duotone.js.map +1 -1
- package/build-module/hooks/font-family.js +1 -5
- package/build-module/hooks/font-family.js.map +1 -1
- package/build-module/hooks/font-size.js +10 -9
- package/build-module/hooks/font-size.js.map +1 -1
- package/build-module/hooks/layout.js +26 -24
- package/build-module/hooks/layout.js.map +1 -1
- package/build-module/hooks/position.js +23 -15
- package/build-module/hooks/position.js.map +1 -1
- package/build-module/hooks/style.js +8 -4
- package/build-module/hooks/style.js.map +1 -1
- package/build-module/hooks/supports.js +1 -1
- package/build-module/hooks/supports.js.map +1 -1
- package/build-module/hooks/typography.native.js +3 -1
- package/build-module/hooks/typography.native.js.map +1 -1
- package/build-module/hooks/use-typography-props.js +8 -15
- package/build-module/hooks/use-typography-props.js.map +1 -1
- package/build-module/index.js +1 -1
- package/build-module/index.js.map +1 -1
- package/build-module/layouts/constrained.js +2 -1
- package/build-module/layouts/constrained.js.map +1 -1
- package/build-module/layouts/definitions.js +147 -0
- package/build-module/layouts/definitions.js.map +1 -0
- package/build-module/layouts/flex.js +8 -6
- package/build-module/layouts/flex.js.map +1 -1
- package/build-module/layouts/flow.js +2 -1
- package/build-module/layouts/flow.js.map +1 -1
- package/build-module/layouts/grid.js +2 -1
- package/build-module/layouts/grid.js.map +1 -1
- package/build-module/layouts/utils.js +7 -2
- package/build-module/layouts/utils.js.map +1 -1
- package/build-module/private-apis.js +16 -1
- package/build-module/private-apis.js.map +1 -1
- package/build-module/store/actions.js +2 -62
- package/build-module/store/actions.js.map +1 -1
- package/build-module/store/defaults.js +1 -0
- package/build-module/store/defaults.js.map +1 -1
- package/build-module/store/private-actions.js +186 -0
- package/build-module/store/private-actions.js.map +1 -1
- package/build-module/store/private-selectors.js +63 -3
- package/build-module/store/private-selectors.js.map +1 -1
- package/build-module/store/reducer.js +52 -1
- package/build-module/store/reducer.js.map +1 -1
- package/build-module/store/selectors.js +42 -42
- package/build-module/store/selectors.js.map +1 -1
- package/build-module/utils/object.js +37 -1
- package/build-module/utils/object.js.map +1 -1
- package/build-style/style-rtl.css +58 -67
- package/build-style/style.css +58 -67
- package/package.json +32 -31
- package/src/autocompleters/block.js +4 -2
- package/src/components/alignment-control/test/__snapshots__/index.js.snap +6 -6
- package/src/components/alignment-control/ui.js +1 -2
- package/src/components/block-actions/index.js +10 -0
- package/src/components/block-alignment-control/constants.js +0 -4
- package/src/components/block-alignment-control/test/__snapshots__/index.js.snap +5 -5
- package/src/components/block-alignment-control/ui.js +1 -6
- package/src/components/block-alignment-matrix-control/index.js +1 -1
- package/src/components/block-breadcrumb/index.js +2 -6
- package/src/components/block-edit/index.js +3 -5
- package/src/components/block-heading-level-dropdown/README.md +52 -0
- package/src/components/block-heading-level-dropdown/heading-level-icon.js +43 -0
- package/src/components/block-heading-level-dropdown/index.js +77 -0
- package/src/components/block-heading-level-dropdown/index.native.js +63 -0
- package/src/components/block-inspector/index.js +18 -92
- package/src/components/block-inspector/style.scss +0 -5
- package/src/components/block-list/block.native.js +1 -0
- package/src/components/block-list/index.js +1 -1
- package/src/components/block-list/use-in-between-inserter.js +0 -4
- package/src/components/block-list-appender/index.js +29 -22
- package/src/components/block-lock/style.scss +11 -4
- package/src/components/block-lock/toolbar.js +34 -6
- package/src/components/block-mobile-toolbar/block-actions-menu.native.js +1 -1
- package/src/components/block-mobile-toolbar/test/block-actions-menu.native.js +2 -2
- package/src/components/block-mover/test/__snapshots__/index.native.js.snap +3 -3
- package/src/components/block-mover/test/index.native.js +1 -20
- package/src/components/block-preview/index.js +7 -14
- package/src/components/block-quick-navigation/index.js +81 -0
- package/src/components/block-removal-warning-modal/index.js +94 -0
- package/src/components/block-settings-menu/block-settings-dropdown.js +15 -13
- package/src/components/block-switcher/index.js +1 -2
- package/src/components/block-toolbar/index.js +9 -6
- package/src/components/block-toolbar/style.scss +0 -4
- package/src/components/block-tools/index.js +10 -1
- package/src/components/block-tools/style.scss +4 -0
- package/src/components/block-vertical-alignment-control/ui.js +1 -3
- package/src/components/colors/utils.js +5 -1
- package/src/components/colors/with-colors.js +1 -5
- package/src/components/copy-handler/index.js +5 -5
- package/src/components/dimensions-tool/aspect-ratio-tool.js +124 -0
- package/src/components/dimensions-tool/index.js +212 -0
- package/src/components/dimensions-tool/scale-tool.js +124 -0
- package/src/components/dimensions-tool/stories/aspect-ratio-tool.js +52 -0
- package/src/components/dimensions-tool/stories/index.js +54 -0
- package/src/components/dimensions-tool/stories/scale-tool.js +48 -0
- package/src/components/dimensions-tool/stories/width-height-tool.js +54 -0
- package/src/components/dimensions-tool/test/index.js +641 -0
- package/src/components/dimensions-tool/width-height-tool.js +113 -0
- package/src/components/duotone-control/index.js +0 -1
- package/src/components/font-sizes/test/fluid-utils.js +97 -76
- package/src/components/font-sizes/utils.js +2 -2
- package/src/components/global-styles/color-panel.js +3 -3
- package/src/components/global-styles/index.js +1 -0
- package/src/components/global-styles/test/use-global-styles-output.js +14 -9
- package/src/components/global-styles/typography-panel.js +19 -16
- package/src/components/global-styles/use-global-styles-output.js +12 -12
- package/src/components/iframe/index.js +1 -1
- package/src/components/image-editor/aspect-ratio-dropdown.js +1 -1
- package/src/components/image-editor/constants.js +0 -1
- package/src/components/image-editor/use-save-image.js +0 -1
- package/src/components/image-size-control/index.js +6 -0
- package/src/components/index.js +1 -1
- package/src/components/index.native.js +1 -0
- package/src/components/inner-blocks/index.js +4 -2
- package/src/components/inner-blocks/index.native.js +1 -1
- package/src/components/inner-blocks/use-nested-settings-update.js +31 -36
- package/src/components/inserter/block-patterns-tab.js +63 -8
- package/src/components/inserter/hooks/use-block-types-state.js +4 -3
- package/src/components/inserter/hooks/use-insertion-point.js +1 -0
- package/src/components/inserter/library.js +2 -1
- package/src/components/inserter/media-tab/media-tab.js +9 -3
- package/src/components/inserter/reusable-blocks-tab.js +3 -3
- package/src/components/inserter/tabs.js +3 -3
- package/src/components/link-control/index.js +34 -37
- package/src/components/link-control/search-input.js +5 -3
- package/src/components/link-control/settings-drawer.js +6 -5
- package/src/components/link-control/style.scss +33 -55
- package/src/components/link-control/test/index.js +161 -159
- package/src/components/list-view/block-select-button.js +19 -1
- package/src/components/list-view/branch.js +6 -3
- package/src/components/list-view/drop-indicator.js +94 -9
- package/src/components/list-view/style.scss +13 -12
- package/src/components/list-view/test/use-list-view-drop-zone.js +188 -93
- package/src/components/list-view/use-list-view-client-ids.js +3 -20
- package/src/components/list-view/use-list-view-drop-zone.js +97 -54
- package/src/components/media-placeholder/index.js +54 -20
- package/src/components/media-replace-flow/index.js +1 -3
- package/src/components/media-replace-flow/test/index.js +1 -1
- package/src/components/preview-options/index.js +3 -2
- package/src/components/provider/test/experimental-provider.js +9 -6
- package/src/components/provider/test/use-block-sync.js +21 -6
- package/src/components/provider/use-block-sync.js +19 -0
- package/src/components/resolution-tool/index.js +56 -0
- package/src/components/resolution-tool/stories/index.js +48 -0
- package/src/components/rich-text/content.js +85 -0
- package/src/components/rich-text/format-toolbar/index.js +1 -2
- package/src/components/rich-text/index.js +2 -35
- package/src/components/rich-text/index.native.js +3 -33
- package/src/components/url-input/index.js +2 -0
- package/src/components/url-popover/image-url-input-ui.js +15 -15
- package/src/components/url-popover/test/__snapshots__/index.js.snap +3 -3
- package/src/components/use-block-display-information/index.js +26 -0
- package/src/components/writing-flow/use-drag-selection.js +1 -1
- package/src/components/writing-flow/use-tab-nav.js +42 -6
- package/src/hooks/behaviors.js +82 -39
- package/src/hooks/font-family.js +1 -5
- package/src/hooks/font-size.js +12 -17
- package/src/hooks/layout.js +17 -25
- package/src/hooks/position.js +24 -12
- package/src/hooks/supports.js +1 -1
- package/src/hooks/use-typography-props.js +14 -19
- package/src/index.js +0 -2
- package/src/layouts/constrained.js +2 -1
- package/src/layouts/definitions.js +174 -0
- package/src/layouts/flex.js +7 -5
- package/src/layouts/flow.js +2 -1
- package/src/layouts/grid.js +2 -1
- package/src/layouts/test/utils.js +2 -7
- package/src/layouts/utils.js +7 -2
- package/src/private-apis.js +15 -0
- package/src/store/actions.js +7 -56
- package/src/store/defaults.js +1 -0
- package/src/store/private-actions.js +193 -0
- package/src/store/private-selectors.js +108 -35
- package/src/store/reducer.js +44 -0
- package/src/store/selectors.js +61 -39
- package/src/store/test/private-selectors.js +269 -1
- package/src/store/test/selectors.js +18 -17
- package/src/utils/object.js +35 -0
- package/src/utils/test/object.js +96 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/media-replace-flow/index.js"],"names":["noop","uniqueId","MediaReplaceFlow","mediaURL","mediaId","mediaIds","allowedTypes","accept","onError","onSelect","onSelectURL","onToggleFeaturedImage","useFeaturedImage","onFilesUpload","name","createNotice","removeNotice","children","multiple","addToGallery","handleUpload","popoverProps","variant","mediaUpload","select","blockEditorStore","getSettings","canUpload","editMediaButtonRef","errorNoticeID","onUploadError","message","safeMessage","setTimeout","speak","id","isDismissible","selectMedia","media","closeMenu","uploadFiles","event","files","target","filesList","onFileChange","openOnArrowDown","keyCode","DOWN","preventDefault","click","onlyAllowsImages","length","every","allowedType","startsWith","gallery","isOpen","onToggle","onClose","open","mediaIcon","openFileDialog","upload","postFeaturedImage","url","current","focus","dispatch","noticesStore"],"mappings":";;;;;;;;;AAQA;;AALA;;AAMA;;AACA;;AACA;;AASA;;AACA;;AACA;;AAKA;;AACA;;AACA;;AAKA;;AACA;;AACA;;AACA;;AArCA;AACA;AACA;;AAGA;AACA;AACA;;AAwBA;AACA;AACA;AAMA,MAAMA,IAAI,GAAG,MAAM,CAAE,CAArB;;AACA,IAAIC,QAAQ,GAAG,CAAf;;AAEA,MAAMC,gBAAgB,GAAG,CAAE;AAC1BC,EAAAA,QAD0B;AAE1BC,EAAAA,OAF0B;AAG1BC,EAAAA,QAH0B;AAI1BC,EAAAA,YAJ0B;AAK1BC,EAAAA,MAL0B;AAM1BC,EAAAA,OAN0B;AAO1BC,EAAAA,QAP0B;AAQ1BC,EAAAA,WAR0B;AAS1BC,EAAAA,qBAT0B;AAU1BC,EAAAA,gBAV0B;AAW1BC,EAAAA,aAAa,GAA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,cAAI,QAAJ,CANH,CADD;AAUA;AAjBF,MAnBD,CADD,EAwCGnD,qBAAqB,IACtB,4BAAC,oBAAD;AACC,MAAA,IAAI,EAAGqD,wBADR;AAEC,MAAA,OAAO,EAAGrD,qBAFX;AAGC,MAAA,SAAS,EAAGC;AAHb,OAKG,cAAI,oBAAJ,CALH,CAzCF,EAiDGK,QAjDH,CADD,EAoDGP,WAAW,IACZ;AACA;AACC,MAAA,SAAS,EAAG,yBACX,oCADW,EAEX;AACC,wBACCiB,SAAS,IAAIhB;AAFf,OAFW;AADb,OASC;AAAM,MAAA,SAAS,EAAC;AAAhB,OACG,cAAI,oBAAJ,CADH,CATD,EAaC,4BAAC,mBAAD;AAAS,MAAA,IAAI,EAAGR,QAAhB;AAA2B,MAAA,QAAQ,EAAC;AAApC,OACC,yCACC,4BAAC,oBAAD;AACC,MAAA,KAAK,EAAG;AAAE8D,QAAAA,GAAG,EAAE9D;AAAP,OADT;AAEC,MAAA,QAAQ,EAAG,EAFZ;AAGC,MAAA,eAAe,EAAG,KAHnB;AAIC,MAAA,QAAQ,EAAG,CAAE;AAAE8D,QAAAA;AAAF,OAAF,KAAe;AACzBvD,QAAAA,WAAW,CAAEuD,GAAF,CAAX;AACArC,QAAAA,kBAAkB,CAACsC,OAAnB,CAA2BC,KAA3B;AACA;AAPF,MADD,CADD,CAbD,CAtDF;AAfF,IADD;AAsGA,CAzMD;AA2MA;AACA;AACA;;;eACe,sBAAS,CACvB,wBAAgBC,QAAF,IAAgB;AAC7B,QAAM;AAAErD,IAAAA,YAAF;AAAgBC,IAAAA;AAAhB,MAAiCoD,QAAQ,CAAEC,cAAF,CAA/C;AACA,SAAO;AACNtD,IAAAA,YADM;AAENC,IAAAA;AAFM,GAAP;AAIA,CAND,CADuB,EAQvB,6BAAa,yBAAb,CARuB,CAAT,EASVd,gBATU,C","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\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\tTooltip,\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\t\tvariant: 'toolbar',\n\t},\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{ 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={ classnames(\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<Tooltip text={ mediaURL } position=\"bottom\">\n\t\t\t\t\t\t\t\t<div>\n\t\t\t\t\t\t\t\t\t<LinkControl\n\t\t\t\t\t\t\t\t\t\tvalue={ { url: mediaURL } }\n\t\t\t\t\t\t\t\t\t\tsettings={ [] }\n\t\t\t\t\t\t\t\t\t\tshowSuggestions={ false }\n\t\t\t\t\t\t\t\t\t\tonChange={ ( { url } ) => {\n\t\t\t\t\t\t\t\t\t\t\tonSelectURL( url );\n\t\t\t\t\t\t\t\t\t\t\teditMediaButtonRef.current.focus();\n\t\t\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t</Tooltip>\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"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/media-replace-flow/index.js"],"names":["noop","uniqueId","MediaReplaceFlow","mediaURL","mediaId","mediaIds","allowedTypes","accept","onError","onSelect","onSelectURL","onToggleFeaturedImage","useFeaturedImage","onFilesUpload","name","createNotice","removeNotice","children","multiple","addToGallery","handleUpload","popoverProps","mediaUpload","select","blockEditorStore","getSettings","canUpload","editMediaButtonRef","errorNoticeID","onUploadError","message","safeMessage","setTimeout","speak","id","isDismissible","selectMedia","media","closeMenu","uploadFiles","event","files","target","filesList","onFileChange","openOnArrowDown","keyCode","DOWN","preventDefault","click","onlyAllowsImages","length","every","allowedType","startsWith","gallery","isOpen","onToggle","onClose","open","mediaIcon","openFileDialog","upload","postFeaturedImage","url","current","focus","dispatch","noticesStore"],"mappings":";;;;;;;;;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C,QAAAA,kBAAkB,CAACsC,OAAnB,CAA2BC,KAA3B;AACA;AAPF,MADD,CADD,CAbD,CAtDF;AAfF,IADD;AAsGA,CAvMD;AAyMA;AACA;AACA;;;eACe,sBAAS,CACvB,wBAAgBC,QAAF,IAAgB;AAC7B,QAAM;AAAEpD,IAAAA,YAAF;AAAgBC,IAAAA;AAAhB,MAAiCmD,QAAQ,CAAEC,cAAF,CAA/C;AACA,SAAO;AACNrD,IAAAA,YADM;AAENC,IAAAA;AAFM,GAAP;AAIA,CAND,CADuB,EAQvB,6BAAa,yBAAb,CARuB,CAAT,EASVd,gBATU,C","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\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\tTooltip,\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{ 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={ classnames(\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<Tooltip text={ mediaURL } position=\"bottom\">\n\t\t\t\t\t\t\t\t<div>\n\t\t\t\t\t\t\t\t\t<LinkControl\n\t\t\t\t\t\t\t\t\t\tvalue={ { url: mediaURL } }\n\t\t\t\t\t\t\t\t\t\tsettings={ [] }\n\t\t\t\t\t\t\t\t\t\tshowSuggestions={ false }\n\t\t\t\t\t\t\t\t\t\tonChange={ ( { url } ) => {\n\t\t\t\t\t\t\t\t\t\t\tonSelectURL( url );\n\t\t\t\t\t\t\t\t\t\t\teditMediaButtonRef.current.focus();\n\t\t\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t</Tooltip>\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"]}
|
|
@@ -9,8 +9,6 @@ exports.default = void 0;
|
|
|
9
9
|
|
|
10
10
|
var _element = require("@wordpress/element");
|
|
11
11
|
|
|
12
|
-
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
13
|
-
|
|
14
12
|
var _components = require("@wordpress/components");
|
|
15
13
|
|
|
16
14
|
var _deprecated = _interopRequireDefault(require("@wordpress/deprecated"));
|
|
@@ -166,17 +164,19 @@ function NavigableToolbar({
|
|
|
166
164
|
useToolbarFocus(ref, focusOnMount, isAccessibleToolbar, initialIndex, onIndexChange, shouldUseKeyboardFocusShortcut);
|
|
167
165
|
|
|
168
166
|
if (isAccessibleToolbar) {
|
|
169
|
-
return (0, _element.createElement)(_components.Toolbar,
|
|
167
|
+
return (0, _element.createElement)(_components.Toolbar, {
|
|
170
168
|
label: props['aria-label'],
|
|
171
|
-
ref: ref
|
|
172
|
-
|
|
169
|
+
ref: ref,
|
|
170
|
+
...props
|
|
171
|
+
}, children);
|
|
173
172
|
}
|
|
174
173
|
|
|
175
|
-
return (0, _element.createElement)(_components.NavigableMenu,
|
|
174
|
+
return (0, _element.createElement)(_components.NavigableMenu, {
|
|
176
175
|
orientation: "horizontal",
|
|
177
176
|
role: "toolbar",
|
|
178
|
-
ref: ref
|
|
179
|
-
|
|
177
|
+
ref: ref,
|
|
178
|
+
...props
|
|
179
|
+
}, children);
|
|
180
180
|
}
|
|
181
181
|
|
|
182
182
|
var _default = NavigableToolbar;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/navigable-toolbar/index.js"],"names":["hasOnlyToolbarItem","elements","dataProp","some","element","dataset","getAllToolbarItemsIn","container","Array","from","querySelectorAll","hasFocusWithin","contains","ownerDocument","activeElement","focusFirstTabbableIn","firstTabbable","focus","tabbable","find","preventScroll","useIsAccessibleToolbar","ref","initialAccessibleToolbarState","isAccessibleToolbar","setIsAccessibleToolbar","determineIsAccessibleToolbar","tabbables","current","onlyToolbarItem","since","alternative","link","observer","window","MutationObserver","observe","childList","subtree","disconnect","useToolbarFocus","focusOnMount","defaultIndex","onIndexChange","shouldUseKeyboardFocusShortcut","initialFocusOnMount","initialIndex","focusToolbar","focusToolbarViaShortcut","navigableToolbarRef","raf","requestAnimationFrame","items","index","cancelAnimationFrame","findIndex","item","tabIndex","NavigableToolbar","children","__experimentalInitialIndex","__experimentalOnIndexChange","props"],"mappings":";;;;;;;;;AAIA;;;;AADA;;AAQA;;AACA;;AACA;;AAbA;AACA;AACA;AAaA,SAASA,kBAAT,CAA6BC,QAA7B,EAAwC;AACvC,QAAMC,QAAQ,GAAG,aAAjB;AACA,SAAO,CAAED,QAAQ,CAACE,IAAT,CAAiBC,OAAF,IAAe,EAAIF,QAAQ,IAAIE,OAAO,CAACC,OAAxB,CAA9B,CAAT;AACA;;AAED,SAASC,oBAAT,CAA+BC,SAA/B,EAA2C;AAC1C,SAAOC,KAAK,CAACC,IAAN,CAAYF,SAAS,CAACG,gBAAV,CAA4B,qBAA5B,CAAZ,CAAP;AACA;;AAED,SAASC,cAAT,CAAyBJ,SAAzB,EAAqC;AACpC,SAAOA,SAAS,CAACK,QAAV,CAAoBL,SAAS,CAACM,aAAV,CAAwBC,aAA5C,CAAP;AACA;;AAED,SAASC,oBAAT,CAA+BR,SAA/B,EAA2C;AAC1C,QAAM,CAAES,aAAF,IAAoBC,WAAMC,QAAN,CAAeC,IAAf,CAAqBZ,SAArB,CAA1B;;AACA,MAAKS,aAAL,EAAqB;AACpBA,IAAAA,aAAa,CAACC,KAAd,CAAqB;AACpB;AACA;AACA;AACAG,MAAAA,aAAa,EAAE;AAJK,KAArB;AAMA;AACD;;AAED,SAASC,sBAAT,CAAiCC,GAAjC,EAAuC;AACtC;AACD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACC,QAAMC,6BAA6B,GAAG,IAAtC,CAbsC,CAetC;AACA;AACA;AACA;;AACA,QAAM,CAAEC,mBAAF,EAAuBC,sBAAvB,IAAkD,uBACvDF,6BADuD,CAAxD;AAIA,QAAMG,4BAA4B,GAAG,0BAA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8BAA8B,GAAG,IAHP;AAI1BgB,EAAAA,0BAA0B,EAAEd,YAJF;AAK1Be,EAAAA,2BAA2B,EAAElB,aALH;AAM1B,KAAGmB;AANuB,CAA3B,EAOI;AACH,QAAMxC,GAAG,GAAG,sBAAZ;AACA,QAAME,mBAAmB,GAAGH,sBAAsB,CAAEC,GAAF,CAAlD;AAEAkB,EAAAA,eAAe,CACdlB,GADc,EAEdmB,YAFc,EAGdjB,mBAHc,EAIdsB,YAJc,EAKdH,aALc,EAMdC,8BANc,CAAf;;AASA,MAAKpB,mBAAL,EAA2B;AAC1B,WACC,4BAAC,mBAAD;AAAS,MAAA,KAAK,EAAGsC,KAAK,CAAE,YAAF,CAAtB;AAAyC,MAAA,GAAG,EAAGxC;AAA/C,OAA0DwC,KAA1D,GACGH,QADH,CADD;AAKA;;AAED,SACC,4BAAC,yBAAD;AACC,IAAA,WAAW,EAAC,YADb;AAEC,IAAA,IAAI,EAAC,SAFN;AAGC,IAAA,GAAG,EAAGrC;AAHP,KAIMwC,KAJN,GAMGH,QANH,CADD;AAUA;;eAEcD,gB","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { NavigableMenu, Toolbar } from '@wordpress/components';\nimport {\n\tuseState,\n\tuseRef,\n\tuseLayoutEffect,\n\tuseEffect,\n\tuseCallback,\n} from '@wordpress/element';\nimport deprecated from '@wordpress/deprecated';\nimport { focus } from '@wordpress/dom';\nimport { useShortcut } from '@wordpress/keyboard-shortcuts';\n\nfunction hasOnlyToolbarItem( elements ) {\n\tconst dataProp = 'toolbarItem';\n\treturn ! elements.some( ( element ) => ! ( dataProp in element.dataset ) );\n}\n\nfunction getAllToolbarItemsIn( container ) {\n\treturn Array.from( container.querySelectorAll( '[data-toolbar-item]' ) );\n}\n\nfunction hasFocusWithin( container ) {\n\treturn container.contains( container.ownerDocument.activeElement );\n}\n\nfunction focusFirstTabbableIn( container ) {\n\tconst [ firstTabbable ] = focus.tabbable.find( container );\n\tif ( firstTabbable ) {\n\t\tfirstTabbable.focus( {\n\t\t\t// When focusing newly mounted toolbars,\n\t\t\t// the position of the popover is often not right on the first render\n\t\t\t// This prevents the layout shifts when focusing the dialogs.\n\t\t\tpreventScroll: true,\n\t\t} );\n\t}\n}\n\nfunction useIsAccessibleToolbar( ref ) {\n\t/*\n\t * By default, we'll assume the starting accessible state of the Toolbar\n\t * is true, as it seems to be the most common case.\n\t *\n\t * Transitioning from an (initial) false to true state causes the\n\t * <Toolbar /> component to mount twice, which is causing undesired\n\t * side-effects. These side-effects appear to only affect certain\n\t * E2E tests.\n\t *\n\t * This was initial discovered in this pull-request:\n\t * https://github.com/WordPress/gutenberg/pull/23425\n\t */\n\tconst initialAccessibleToolbarState = true;\n\n\t// By default, it's gonna render NavigableMenu. If all the tabbable elements\n\t// inside the toolbar are ToolbarItem components (or derived components like\n\t// ToolbarButton), then we can wrap them with the accessible Toolbar\n\t// component.\n\tconst [ isAccessibleToolbar, setIsAccessibleToolbar ] = useState(\n\t\tinitialAccessibleToolbarState\n\t);\n\n\tconst determineIsAccessibleToolbar = useCallback( () => {\n\t\tconst tabbables = focus.tabbable.find( ref.current );\n\t\tconst onlyToolbarItem = hasOnlyToolbarItem( tabbables );\n\t\tif ( ! onlyToolbarItem ) {\n\t\t\tdeprecated( 'Using custom components as toolbar controls', {\n\t\t\t\tsince: '5.6',\n\t\t\t\talternative:\n\t\t\t\t\t'ToolbarItem, ToolbarButton or ToolbarDropdownMenu components',\n\t\t\t\tlink: 'https://developer.wordpress.org/block-editor/components/toolbar-button/#inside-blockcontrols',\n\t\t\t} );\n\t\t}\n\t\tsetIsAccessibleToolbar( onlyToolbarItem );\n\t}, [] );\n\n\tuseLayoutEffect( () => {\n\t\t// Toolbar buttons may be rendered asynchronously, so we use\n\t\t// MutationObserver to check if the toolbar subtree has been modified.\n\t\tconst observer = new window.MutationObserver(\n\t\t\tdetermineIsAccessibleToolbar\n\t\t);\n\t\tobserver.observe( ref.current, { childList: true, subtree: true } );\n\t\treturn () => observer.disconnect();\n\t}, [ isAccessibleToolbar ] );\n\n\treturn isAccessibleToolbar;\n}\n\nfunction useToolbarFocus(\n\tref,\n\tfocusOnMount,\n\tisAccessibleToolbar,\n\tdefaultIndex,\n\tonIndexChange,\n\tshouldUseKeyboardFocusShortcut\n) {\n\t// Make sure we don't use modified versions of this prop.\n\tconst [ initialFocusOnMount ] = useState( focusOnMount );\n\tconst [ initialIndex ] = useState( defaultIndex );\n\n\tconst focusToolbar = useCallback( () => {\n\t\tfocusFirstTabbableIn( ref.current );\n\t}, [] );\n\n\tconst focusToolbarViaShortcut = () => {\n\t\tif ( shouldUseKeyboardFocusShortcut ) {\n\t\t\tfocusToolbar();\n\t\t}\n\t};\n\n\t// Focus on toolbar when pressing alt+F10 when the toolbar is visible.\n\tuseShortcut( 'core/block-editor/focus-toolbar', focusToolbarViaShortcut );\n\n\tuseEffect( () => {\n\t\tif ( initialFocusOnMount ) {\n\t\t\tfocusToolbar();\n\t\t}\n\t}, [ isAccessibleToolbar, initialFocusOnMount, focusToolbar ] );\n\n\tuseEffect( () => {\n\t\t// Store ref so we have access on useEffect cleanup: https://legacy.reactjs.org/blog/2020/08/10/react-v17-rc.html#effect-cleanup-timing\n\t\tconst navigableToolbarRef = ref.current;\n\t\t// If initialIndex is passed, we focus on that toolbar item when the\n\t\t// toolbar gets mounted and initial focus is not forced.\n\t\t// We have to wait for the next browser paint because block controls aren't\n\t\t// rendered right away when the toolbar gets mounted.\n\t\tlet raf = 0;\n\t\tif ( ! initialFocusOnMount ) {\n\t\t\traf = window.requestAnimationFrame( () => {\n\t\t\t\tconst items = getAllToolbarItemsIn( navigableToolbarRef );\n\t\t\t\tconst index = initialIndex || 0;\n\t\t\t\tif ( items[ index ] && hasFocusWithin( navigableToolbarRef ) ) {\n\t\t\t\t\titems[ index ].focus( {\n\t\t\t\t\t\t// When focusing newly mounted toolbars,\n\t\t\t\t\t\t// the position of the popover is often not right on the first render\n\t\t\t\t\t\t// This prevents the layout shifts when focusing the dialogs.\n\t\t\t\t\t\tpreventScroll: true,\n\t\t\t\t\t} );\n\t\t\t\t}\n\t\t\t} );\n\t\t}\n\t\treturn () => {\n\t\t\twindow.cancelAnimationFrame( raf );\n\t\t\tif ( ! onIndexChange || ! navigableToolbarRef ) return;\n\t\t\t// When the toolbar element is unmounted and onIndexChange is passed, we\n\t\t\t// pass the focused toolbar item index so it can be hydrated later.\n\t\t\tconst items = getAllToolbarItemsIn( navigableToolbarRef );\n\t\t\tconst index = items.findIndex( ( item ) => item.tabIndex === 0 );\n\t\t\tonIndexChange( index );\n\t\t};\n\t}, [ initialIndex, initialFocusOnMount ] );\n}\n\nfunction NavigableToolbar( {\n\tchildren,\n\tfocusOnMount,\n\tshouldUseKeyboardFocusShortcut = true,\n\t__experimentalInitialIndex: initialIndex,\n\t__experimentalOnIndexChange: onIndexChange,\n\t...props\n} ) {\n\tconst ref = useRef();\n\tconst isAccessibleToolbar = useIsAccessibleToolbar( ref );\n\n\tuseToolbarFocus(\n\t\tref,\n\t\tfocusOnMount,\n\t\tisAccessibleToolbar,\n\t\tinitialIndex,\n\t\tonIndexChange,\n\t\tshouldUseKeyboardFocusShortcut\n\t);\n\n\tif ( isAccessibleToolbar ) {\n\t\treturn (\n\t\t\t<Toolbar label={ props[ 'aria-label' ] } ref={ ref } { ...props }>\n\t\t\t\t{ children }\n\t\t\t</Toolbar>\n\t\t);\n\t}\n\n\treturn (\n\t\t<NavigableMenu\n\t\t\torientation=\"horizontal\"\n\t\t\trole=\"toolbar\"\n\t\t\tref={ ref }\n\t\t\t{ ...props }\n\t\t>\n\t\t\t{ children }\n\t\t</NavigableMenu>\n\t);\n}\n\nexport default NavigableToolbar;\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/navigable-toolbar/index.js"],"names":["hasOnlyToolbarItem","elements","dataProp","some","element","dataset","getAllToolbarItemsIn","container","Array","from","querySelectorAll","hasFocusWithin","contains","ownerDocument","activeElement","focusFirstTabbableIn","firstTabbable","focus","tabbable","find","preventScroll","useIsAccessibleToolbar","ref","initialAccessibleToolbarState","isAccessibleToolbar","setIsAccessibleToolbar","determineIsAccessibleToolbar","tabbables","current","onlyToolbarItem","since","alternative","link","observer","window","MutationObserver","observe","childList","subtree","disconnect","useToolbarFocus","focusOnMount","defaultIndex","onIndexChange","shouldUseKeyboardFocusShortcut","initialFocusOnMount","initialIndex","focusToolbar","focusToolbarViaShortcut","navigableToolbarRef","raf","requestAnimationFrame","items","index","cancelAnimationFrame","findIndex","item","tabIndex","NavigableToolbar","children","__experimentalInitialIndex","__experimentalOnIndexChange","props"],"mappings":";;;;;;;;;AAIA;;AADA;;AAQA;;AACA;;AACA;;AAbA;AACA;AACA;AAaA,SAASA,kBAAT,CAA6BC,QAA7B,EAAwC;AACvC,QAAMC,QAAQ,GAAG,aAAjB;AACA,SAAO,CAAED,QAAQ,CAACE,IAAT,CAAiBC,OAAF,IAAe,EAAIF,QAAQ,IAAIE,OAAO,CAACC,OAAxB,CAA9B,CAAT;AACA;;AAED,SAASC,oBAAT,CAA+BC,SAA/B,EAA2C;AAC1C,SAAOC,KAAK,CAACC,IAAN,CAAYF,SAAS,CAACG,gBAAV,CAA4B,qBAA5B,CAAZ,CAAP;AACA;;AAED,SAASC,cAAT,CAAyBJ,SAAzB,EAAqC;AACpC,SAAOA,SAAS,CAACK,QAAV,CAAoBL,SAAS,CAACM,aAAV,CAAwBC,aAA5C,CAAP;AACA;;AAED,SAASC,oBAAT,CAA+BR,SAA/B,EAA2C;AAC1C,QAAM,CAAES,aAAF,IAAoBC,WAAMC,QAAN,CAAeC,IAAf,CAAqBZ,SAArB,CAA1B;;AACA,MAAKS,aAAL,EAAqB;AACpBA,IAAAA,aAAa,CAACC,KAAd,CAAqB;AACpB;AACA;AACA;AACAG,MAAAA,aAAa,EAAE;AAJK,KAArB;AAMA;AACD;;AAED,SAASC,sBAAT,CAAiCC,GAAjC,EAAuC;AACtC;AACD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA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CAAb;AACA,KARD;AASA,GA/BD,EA+BG,CAAEP,YAAF,EAAgBD,mBAAhB,CA/BH;AAgCA;;AAED,SAASa,gBAAT,CAA2B;AAC1BC,EAAAA,QAD0B;AAE1BlB,EAAAA,YAF0B;AAG1BG,EAAAA,8BAA8B,GAAG,IAHP;AAI1BgB,EAAAA,0BAA0B,EAAEd,YAJF;AAK1Be,EAAAA,2BAA2B,EAAElB,aALH;AAM1B,KAAGmB;AANuB,CAA3B,EAOI;AACH,QAAMxC,GAAG,GAAG,sBAAZ;AACA,QAAME,mBAAmB,GAAGH,sBAAsB,CAAEC,GAAF,CAAlD;AAEAkB,EAAAA,eAAe,CACdlB,GADc,EAEdmB,YAFc,EAGdjB,mBAHc,EAIdsB,YAJc,EAKdH,aALc,EAMdC,8BANc,CAAf;;AASA,MAAKpB,mBAAL,EAA2B;AAC1B,WACC,4BAAC,mBAAD;AAAS,MAAA,KAAK,EAAGsC,KAAK,CAAE,YAAF,CAAtB;AAAyC,MAAA,GAAG,EAAGxC,GAA/C;AAAA,SAA0DwC;AAA1D,OACGH,QADH,CADD;AAKA;;AAED,SACC,4BAAC,yBAAD;AACC,IAAA,WAAW,EAAC,YADb;AAEC,IAAA,IAAI,EAAC,SAFN;AAGC,IAAA,GAAG,EAAGrC,GAHP;AAAA,OAIMwC;AAJN,KAMGH,QANH,CADD;AAUA;;eAEcD,gB","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { NavigableMenu, Toolbar } from '@wordpress/components';\nimport {\n\tuseState,\n\tuseRef,\n\tuseLayoutEffect,\n\tuseEffect,\n\tuseCallback,\n} from '@wordpress/element';\nimport deprecated from '@wordpress/deprecated';\nimport { focus } from '@wordpress/dom';\nimport { useShortcut } from '@wordpress/keyboard-shortcuts';\n\nfunction hasOnlyToolbarItem( elements ) {\n\tconst dataProp = 'toolbarItem';\n\treturn ! elements.some( ( element ) => ! ( dataProp in element.dataset ) );\n}\n\nfunction getAllToolbarItemsIn( container ) {\n\treturn Array.from( container.querySelectorAll( '[data-toolbar-item]' ) );\n}\n\nfunction hasFocusWithin( container ) {\n\treturn container.contains( container.ownerDocument.activeElement );\n}\n\nfunction focusFirstTabbableIn( container ) {\n\tconst [ firstTabbable ] = focus.tabbable.find( container );\n\tif ( firstTabbable ) {\n\t\tfirstTabbable.focus( {\n\t\t\t// When focusing newly mounted toolbars,\n\t\t\t// the position of the popover is often not right on the first render\n\t\t\t// This prevents the layout shifts when focusing the dialogs.\n\t\t\tpreventScroll: true,\n\t\t} );\n\t}\n}\n\nfunction useIsAccessibleToolbar( ref ) {\n\t/*\n\t * By default, we'll assume the starting accessible state of the Toolbar\n\t * is true, as it seems to be the most common case.\n\t *\n\t * Transitioning from an (initial) false to true state causes the\n\t * <Toolbar /> component to mount twice, which is causing undesired\n\t * side-effects. These side-effects appear to only affect certain\n\t * E2E tests.\n\t *\n\t * This was initial discovered in this pull-request:\n\t * https://github.com/WordPress/gutenberg/pull/23425\n\t */\n\tconst initialAccessibleToolbarState = true;\n\n\t// By default, it's gonna render NavigableMenu. If all the tabbable elements\n\t// inside the toolbar are ToolbarItem components (or derived components like\n\t// ToolbarButton), then we can wrap them with the accessible Toolbar\n\t// component.\n\tconst [ isAccessibleToolbar, setIsAccessibleToolbar ] = useState(\n\t\tinitialAccessibleToolbarState\n\t);\n\n\tconst determineIsAccessibleToolbar = useCallback( () => {\n\t\tconst tabbables = focus.tabbable.find( ref.current );\n\t\tconst onlyToolbarItem = hasOnlyToolbarItem( tabbables );\n\t\tif ( ! onlyToolbarItem ) {\n\t\t\tdeprecated( 'Using custom components as toolbar controls', {\n\t\t\t\tsince: '5.6',\n\t\t\t\talternative:\n\t\t\t\t\t'ToolbarItem, ToolbarButton or ToolbarDropdownMenu components',\n\t\t\t\tlink: 'https://developer.wordpress.org/block-editor/components/toolbar-button/#inside-blockcontrols',\n\t\t\t} );\n\t\t}\n\t\tsetIsAccessibleToolbar( onlyToolbarItem );\n\t}, [] );\n\n\tuseLayoutEffect( () => {\n\t\t// Toolbar buttons may be rendered asynchronously, so we use\n\t\t// MutationObserver to check if the toolbar subtree has been modified.\n\t\tconst observer = new window.MutationObserver(\n\t\t\tdetermineIsAccessibleToolbar\n\t\t);\n\t\tobserver.observe( ref.current, { childList: true, subtree: true } );\n\t\treturn () => observer.disconnect();\n\t}, [ isAccessibleToolbar ] );\n\n\treturn isAccessibleToolbar;\n}\n\nfunction useToolbarFocus(\n\tref,\n\tfocusOnMount,\n\tisAccessibleToolbar,\n\tdefaultIndex,\n\tonIndexChange,\n\tshouldUseKeyboardFocusShortcut\n) {\n\t// Make sure we don't use modified versions of this prop.\n\tconst [ initialFocusOnMount ] = useState( focusOnMount );\n\tconst [ initialIndex ] = useState( defaultIndex );\n\n\tconst focusToolbar = useCallback( () => {\n\t\tfocusFirstTabbableIn( ref.current );\n\t}, [] );\n\n\tconst focusToolbarViaShortcut = () => {\n\t\tif ( shouldUseKeyboardFocusShortcut ) {\n\t\t\tfocusToolbar();\n\t\t}\n\t};\n\n\t// Focus on toolbar when pressing alt+F10 when the toolbar is visible.\n\tuseShortcut( 'core/block-editor/focus-toolbar', focusToolbarViaShortcut );\n\n\tuseEffect( () => {\n\t\tif ( initialFocusOnMount ) {\n\t\t\tfocusToolbar();\n\t\t}\n\t}, [ isAccessibleToolbar, initialFocusOnMount, focusToolbar ] );\n\n\tuseEffect( () => {\n\t\t// Store ref so we have access on useEffect cleanup: https://legacy.reactjs.org/blog/2020/08/10/react-v17-rc.html#effect-cleanup-timing\n\t\tconst navigableToolbarRef = ref.current;\n\t\t// If initialIndex is passed, we focus on that toolbar item when the\n\t\t// toolbar gets mounted and initial focus is not forced.\n\t\t// We have to wait for the next browser paint because block controls aren't\n\t\t// rendered right away when the toolbar gets mounted.\n\t\tlet raf = 0;\n\t\tif ( ! initialFocusOnMount ) {\n\t\t\traf = window.requestAnimationFrame( () => {\n\t\t\t\tconst items = getAllToolbarItemsIn( navigableToolbarRef );\n\t\t\t\tconst index = initialIndex || 0;\n\t\t\t\tif ( items[ index ] && hasFocusWithin( navigableToolbarRef ) ) {\n\t\t\t\t\titems[ index ].focus( {\n\t\t\t\t\t\t// When focusing newly mounted toolbars,\n\t\t\t\t\t\t// the position of the popover is often not right on the first render\n\t\t\t\t\t\t// This prevents the layout shifts when focusing the dialogs.\n\t\t\t\t\t\tpreventScroll: true,\n\t\t\t\t\t} );\n\t\t\t\t}\n\t\t\t} );\n\t\t}\n\t\treturn () => {\n\t\t\twindow.cancelAnimationFrame( raf );\n\t\t\tif ( ! onIndexChange || ! navigableToolbarRef ) return;\n\t\t\t// When the toolbar element is unmounted and onIndexChange is passed, we\n\t\t\t// pass the focused toolbar item index so it can be hydrated later.\n\t\t\tconst items = getAllToolbarItemsIn( navigableToolbarRef );\n\t\t\tconst index = items.findIndex( ( item ) => item.tabIndex === 0 );\n\t\t\tonIndexChange( index );\n\t\t};\n\t}, [ initialIndex, initialFocusOnMount ] );\n}\n\nfunction NavigableToolbar( {\n\tchildren,\n\tfocusOnMount,\n\tshouldUseKeyboardFocusShortcut = true,\n\t__experimentalInitialIndex: initialIndex,\n\t__experimentalOnIndexChange: onIndexChange,\n\t...props\n} ) {\n\tconst ref = useRef();\n\tconst isAccessibleToolbar = useIsAccessibleToolbar( ref );\n\n\tuseToolbarFocus(\n\t\tref,\n\t\tfocusOnMount,\n\t\tisAccessibleToolbar,\n\t\tinitialIndex,\n\t\tonIndexChange,\n\t\tshouldUseKeyboardFocusShortcut\n\t);\n\n\tif ( isAccessibleToolbar ) {\n\t\treturn (\n\t\t\t<Toolbar label={ props[ 'aria-label' ] } ref={ ref } { ...props }>\n\t\t\t\t{ children }\n\t\t\t</Toolbar>\n\t\t);\n\t}\n\n\treturn (\n\t\t<NavigableMenu\n\t\t\torientation=\"horizontal\"\n\t\t\trole=\"toolbar\"\n\t\t\tref={ ref }\n\t\t\t{ ...props }\n\t\t>\n\t\t\t{ children }\n\t\t</NavigableMenu>\n\t);\n}\n\nexport default NavigableToolbar;\n"]}
|
|
@@ -9,8 +9,6 @@ exports.default = void 0;
|
|
|
9
9
|
|
|
10
10
|
var _element = require("@wordpress/element");
|
|
11
11
|
|
|
12
|
-
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
13
|
-
|
|
14
12
|
var _panelColorGradientSettings = _interopRequireDefault(require("../colors-gradients/panel-color-gradient-settings"));
|
|
15
13
|
|
|
16
14
|
/**
|
|
@@ -35,11 +33,12 @@ const PanelColorSettings = ({
|
|
|
35
33
|
onColorChange: onChange
|
|
36
34
|
};
|
|
37
35
|
});
|
|
38
|
-
return (0, _element.createElement)(_panelColorGradientSettings.default,
|
|
36
|
+
return (0, _element.createElement)(_panelColorGradientSettings.default, {
|
|
39
37
|
settings: settings,
|
|
40
38
|
gradients: [],
|
|
41
|
-
disableCustomGradients: true
|
|
42
|
-
|
|
39
|
+
disableCustomGradients: true,
|
|
40
|
+
...props
|
|
41
|
+
});
|
|
43
42
|
};
|
|
44
43
|
|
|
45
44
|
var _default = PanelColorSettings;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/panel-color-settings/index.js"],"names":["PanelColorSettings","colorSettings","props","settings","map","setting","value","onChange","otherSettings","colorValue","onColorChange"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/panel-color-settings/index.js"],"names":["PanelColorSettings","colorSettings","props","settings","map","setting","value","onChange","otherSettings","colorValue","onColorChange"],"mappings":";;;;;;;;;;;AAGA;;AAHA;AACA;AACA;AAGA,MAAMA,kBAAkB,GAAG,CAAE;AAAEC,EAAAA,aAAF;AAAiB,KAAGC;AAApB,CAAF,KAAmC;AAC7D,QAAMC,QAAQ,GAAGF,aAAa,CAACG,GAAd,CAAqBC,OAAF,IAAe;AAClD,QAAK,CAAEA,OAAP,EAAiB;AAChB,aAAOA,OAAP;AACA;;AACD,UAAM;AAAEC,MAAAA,KAAF;AAASC,MAAAA,QAAT;AAAmB,SAAGC;AAAtB,QAAwCH,OAA9C;AACA,WAAO,EACN,GAAGG,aADG;AAENC,MAAAA,UAAU,EAAEH,KAFN;AAGNI,MAAAA,aAAa,EAAEH;AAHT,KAAP;AAKA,GAVgB,CAAjB;AAWA,SACC,4BAAC,mCAAD;AACC,IAAA,QAAQ,EAAGJ,QADZ;AAEC,IAAA,SAAS,EAAG,EAFb;AAGC,IAAA,sBAAsB,EAAG,IAH1B;AAAA,OAIMD;AAJN,IADD;AAQA,CApBD;;eAqBeF,kB","sourcesContent":["/**\n * Internal dependencies\n */\nimport PanelColorGradientSettings from '../colors-gradients/panel-color-gradient-settings';\n\nconst PanelColorSettings = ( { colorSettings, ...props } ) => {\n\tconst settings = colorSettings.map( ( setting ) => {\n\t\tif ( ! setting ) {\n\t\t\treturn setting;\n\t\t}\n\t\tconst { value, onChange, ...otherSettings } = setting;\n\t\treturn {\n\t\t\t...otherSettings,\n\t\t\tcolorValue: value,\n\t\t\tonColorChange: onChange,\n\t\t};\n\t} );\n\treturn (\n\t\t<PanelColorGradientSettings\n\t\t\tsettings={ settings }\n\t\t\tgradients={ [] }\n\t\t\tdisableCustomGradients={ true }\n\t\t\t{ ...props }\n\t\t/>\n\t);\n};\nexport default PanelColorSettings;\n"]}
|
|
@@ -9,8 +9,6 @@ exports.default = void 0;
|
|
|
9
9
|
|
|
10
10
|
var _element = require("@wordpress/element");
|
|
11
11
|
|
|
12
|
-
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
13
|
-
|
|
14
12
|
var _reactAutosizeTextarea = _interopRequireDefault(require("react-autosize-textarea"));
|
|
15
13
|
|
|
16
14
|
var _classnames = _interopRequireDefault(require("classnames"));
|
|
@@ -37,9 +35,10 @@ const PlainText = (0, _element.forwardRef)(({
|
|
|
37
35
|
...props
|
|
38
36
|
}, ref) => {
|
|
39
37
|
if (__experimentalVersion === 2) {
|
|
40
|
-
return (0, _element.createElement)(_editableText.default,
|
|
41
|
-
ref: ref
|
|
42
|
-
|
|
38
|
+
return (0, _element.createElement)(_editableText.default, {
|
|
39
|
+
ref: ref,
|
|
40
|
+
...props
|
|
41
|
+
});
|
|
43
42
|
}
|
|
44
43
|
|
|
45
44
|
const {
|
|
@@ -47,11 +46,12 @@ const PlainText = (0, _element.forwardRef)(({
|
|
|
47
46
|
onChange,
|
|
48
47
|
...remainingProps
|
|
49
48
|
} = props;
|
|
50
|
-
return (0, _element.createElement)(_reactAutosizeTextarea.default,
|
|
49
|
+
return (0, _element.createElement)(_reactAutosizeTextarea.default, {
|
|
51
50
|
ref: ref,
|
|
52
51
|
className: (0, _classnames.default)('block-editor-plain-text', className),
|
|
53
|
-
onChange: event => onChange(event.target.value)
|
|
54
|
-
|
|
52
|
+
onChange: event => onChange(event.target.value),
|
|
53
|
+
...remainingProps
|
|
54
|
+
});
|
|
55
55
|
});
|
|
56
56
|
var _default = PlainText;
|
|
57
57
|
exports.default = _default;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/plain-text/index.js"],"names":["PlainText","__experimentalVersion","props","ref","className","onChange","remainingProps","event","target","value"],"mappings":";;;;;;;;;AASA
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/plain-text/index.js"],"names":["PlainText","__experimentalVersion","props","ref","className","onChange","remainingProps","event","target","value"],"mappings":";;;;;;;;;AASA;;AANA;;AACA;;AAUA;;AAdA;AACA;AACA;;AAIA;AACA;AACA;;AAGA;AACA;AACA;;AAGA;AACA;AACA;AACA,MAAMA,SAAS,GAAG,yBAAY,CAAE;AAAEC,EAAAA,qBAAF;AAAyB,KAAGC;AAA5B,CAAF,EAAuCC,GAAvC,KAAgD;AAC7E,MAAKF,qBAAqB,KAAK,CAA/B,EAAmC;AAClC,WAAO,4BAAC,qBAAD;AAAc,MAAA,GAAG,EAAGE,GAApB;AAAA,SAA+BD;AAA/B,MAAP;AACA;;AAED,QAAM;AAAEE,IAAAA,SAAF;AAAaC,IAAAA,QAAb;AAAuB,OAAGC;AAA1B,MAA6CJ,KAAnD;AAEA,SACC,4BAAC,8BAAD;AACC,IAAA,GAAG,EAAGC,GADP;AAEC,IAAA,SAAS,EAAG,yBAAY,yBAAZ,EAAuCC,SAAvC,CAFb;AAGC,IAAA,QAAQ,EAAKG,KAAF,IAAaF,QAAQ,CAAEE,KAAK,CAACC,MAAN,CAAaC,KAAf,CAHjC;AAAA,OAIMH;AAJN,IADD;AAQA,CAfiB,CAAlB;eAiBeN,S","sourcesContent":["/**\n * External dependencies\n */\nimport TextareaAutosize from 'react-autosize-textarea';\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { forwardRef } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport EditableText from '../editable-text';\n\n/**\n * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/plain-text/README.md\n */\nconst PlainText = forwardRef( ( { __experimentalVersion, ...props }, ref ) => {\n\tif ( __experimentalVersion === 2 ) {\n\t\treturn <EditableText ref={ ref } { ...props } />;\n\t}\n\n\tconst { className, onChange, ...remainingProps } = props;\n\n\treturn (\n\t\t<TextareaAutosize\n\t\t\tref={ ref }\n\t\t\tclassName={ classnames( 'block-editor-plain-text', className ) }\n\t\t\tonChange={ ( event ) => onChange( event.target.value ) }\n\t\t\t{ ...remainingProps }\n\t\t/>\n\t);\n} );\n\nexport default PlainText;\n"]}
|
|
@@ -9,8 +9,6 @@ exports.default = void 0;
|
|
|
9
9
|
|
|
10
10
|
var _element = require("@wordpress/element");
|
|
11
11
|
|
|
12
|
-
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
13
|
-
|
|
14
12
|
var _reactNative = require("react-native");
|
|
15
13
|
|
|
16
14
|
var _blockEditor = require("@wordpress/block-editor");
|
|
@@ -143,15 +141,18 @@ class PlainText extends _element.Component {
|
|
|
143
141
|
fontSize: style?.fontSize,
|
|
144
142
|
fontWeight: style?.fontWeight
|
|
145
143
|
};
|
|
146
|
-
return (0, _element.createElement)(_blockEditor.RichText,
|
|
144
|
+
return (0, _element.createElement)(_blockEditor.RichText, { ...otherProps,
|
|
145
|
+
...disableFormattingProps,
|
|
146
|
+
...forcePlainTextProps,
|
|
147
|
+
...fontProps,
|
|
147
148
|
identifier: "content",
|
|
148
149
|
style: style,
|
|
149
150
|
onChange: this.onChangeRichText,
|
|
150
151
|
unstableOnFocus: onFocus
|
|
151
|
-
})
|
|
152
|
+
});
|
|
152
153
|
}
|
|
153
154
|
|
|
154
|
-
return (0, _element.createElement)(_reactNative.TextInput,
|
|
155
|
+
return (0, _element.createElement)(_reactNative.TextInput, { ...this.props,
|
|
155
156
|
ref: x => this._input = x,
|
|
156
157
|
onChange: this.onChangeTextInput,
|
|
157
158
|
onFocus: this.props.onFocus // Always assign onFocus as a props.
|
|
@@ -161,7 +162,7 @@ class PlainText extends _element.Component {
|
|
|
161
162
|
fontFamily: this.props.style && this.props.style.fontFamily || _style.default['block-editor-plain-text'].fontFamily,
|
|
162
163
|
style: textStyles,
|
|
163
164
|
scrollEnabled: false
|
|
164
|
-
})
|
|
165
|
+
});
|
|
165
166
|
}
|
|
166
167
|
|
|
167
168
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/plain-text/index.native.js"],"names":["PlainText","Component","constructor","arguments","isAndroid","Platform","OS","onChangeTextInput","bind","onChangeRichText","componentDidMount","_input","isFocused","props","isSelected","timeoutID","setTimeout","focus","componentDidUpdate","prevProps","blur","componentWillUnmount","clearTimeout","getFontSize","style","fontSize","width","height","Dimensions","get","cssUnitOptions","parseFloat","replaceLineBreakTags","value","replace","RegExp","event","onChange","nativeEvent","text","render","__experimentalVersion","onFocus","otherProps","textStyles","styles","disableFormattingProps","withoutInteractiveFormatting","disableEditingMenu","__unstableDisableFormats","disableSuggestions","forcePlainTextProps","preserveWhiteSpace","__unstablePastePlainText","multiline","fontProps","fontFamily","fontWeight","x","onBlur"],"mappings":";;;;;;;;;AAQA
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/plain-text/index.native.js"],"names":["PlainText","Component","constructor","arguments","isAndroid","Platform","OS","onChangeTextInput","bind","onChangeRichText","componentDidMount","_input","isFocused","props","isSelected","timeoutID","setTimeout","focus","componentDidUpdate","prevProps","blur","componentWillUnmount","clearTimeout","getFontSize","style","fontSize","width","height","Dimensions","get","cssUnitOptions","parseFloat","replaceLineBreakTags","value","replace","RegExp","event","onChange","nativeEvent","text","render","__experimentalVersion","onFocus","otherProps","textStyles","styles","disableFormattingProps","withoutInteractiveFormatting","disableEditingMenu","__unstableDisableFormats","disableSuggestions","forcePlainTextProps","preserveWhiteSpace","__unstablePastePlainText","multiline","fontProps","fontFamily","fontWeight","x","onBlur"],"mappings":";;;;;;;;;AAQA;;AALA;;AAMA;;AAKA;;AAdA;AACA;AACA;;AAGA;AACA;AACA;;AAIA;AACA;AACA;AAGe,MAAMA,SAAN,SAAwBC,kBAAxB,CAAkC;AAChDC,EAAAA,WAAW,GAAG;AACb,UAAO,GAAGC,SAAV;AACA,SAAKC,SAAL,GAAiBC,sBAASC,EAAT,KAAgB,SAAjC;AAEA,SAAKC,iBAAL,GAAyB,KAAKA,iBAAL,CAAuBC,IAAvB,CAA6B,IAA7B,CAAzB;AACA,SAAKC,gBAAL,GAAwB,KAAKA,gBAAL,CAAsBD,IAAtB,CAA4B,IAA5B,CAAxB;AACA;;AAEDE,EAAAA,iBAAiB,GAAG;AACnB;AACA,QACC,KAAKC,MAAL,IACA,KAAKA,MAAL,CAAYC,SAAZ,OAA4B,KAD5B,IAEA,KAAKC,KAAL,CAAWC,UAHZ,EAIE;AACD,UAAK,KAAKV,SAAV,EAAsB;AACrB;AACJ;AACA;AACA;AACA;AACI,aAAKW,SAAL,GAAiBC,UAAU,CAAE,MAAM;AAClC,eAAKL,MAAL,CAAYM,KAAZ;AACA,SAF0B,EAExB,GAFwB,CAA3B;AAGA,OATD,MASO;AACN,aAAKN,MAAL,CAAYM,KAAZ;AACA;AACD;AACD;;AAEDC,EA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,MAAL,GAAc+C,CAFhC;AAGC,MAAA,QAAQ,EAAG,KAAKnD,iBAHjB;AAIC,MAAA,OAAO,EAAG,KAAKM,KAAL,CAAW6B,OAJtB,CAIgC;AAJhC;AAKC,MAAA,MAAM,EAAG,KAAK7B,KAAL,CAAW8C,MALrB,CAK8B;AAL9B;AAMC,MAAA,UAAU,EACP,KAAK9C,KAAL,CAAWW,KAAX,IAAoB,KAAKX,KAAL,CAAWW,KAAX,CAAiBgC,UAAvC,IACAX,eAAQ,yBAAR,EAAoCW,UARtC;AAUC,MAAA,KAAK,EAAGZ,UAVT;AAWC,MAAA,aAAa,EAAG;AAXjB,MADD;AAeA;;AA7I+C","sourcesContent":["/**\n * External dependencies\n */\nimport { TextInput, Platform, Dimensions } from 'react-native';\n\n/**\n * WordPress dependencies\n */\nimport { Component } from '@wordpress/element';\nimport { RichText, getPxFromCssUnit } from '@wordpress/block-editor';\n\n/**\n * Internal dependencies\n */\nimport styles from './style.scss';\n\nexport default class PlainText extends Component {\n\tconstructor() {\n\t\tsuper( ...arguments );\n\t\tthis.isAndroid = Platform.OS === 'android';\n\n\t\tthis.onChangeTextInput = this.onChangeTextInput.bind( this );\n\t\tthis.onChangeRichText = this.onChangeRichText.bind( this );\n\t}\n\n\tcomponentDidMount() {\n\t\t// If isSelected is true, we should request the focus on this TextInput.\n\t\tif (\n\t\t\tthis._input &&\n\t\t\tthis._input.isFocused() === false &&\n\t\t\tthis.props.isSelected\n\t\t) {\n\t\t\tif ( this.isAndroid ) {\n\t\t\t\t/*\n\t\t\t\t * There seems to be an issue in React Native where the keyboard doesn't show if called shortly after rendering.\n\t\t\t\t * As a common work around this delay is used.\n\t\t\t\t * https://github.com/facebook/react-native/issues/19366#issuecomment-400603928\n\t\t\t\t */\n\t\t\t\tthis.timeoutID = setTimeout( () => {\n\t\t\t\t\tthis._input.focus();\n\t\t\t\t}, 100 );\n\t\t\t} else {\n\t\t\t\tthis._input.focus();\n\t\t\t}\n\t\t}\n\t}\n\n\tcomponentDidUpdate( prevProps ) {\n\t\tif ( ! this.props.isSelected && prevProps.isSelected ) {\n\t\t\tthis._input?.blur();\n\t\t}\n\t}\n\n\tcomponentWillUnmount() {\n\t\tif ( this.isAndroid ) {\n\t\t\tclearTimeout( this.timeoutID );\n\t\t}\n\t}\n\n\tfocus() {\n\t\tthis._input?.focus();\n\t}\n\n\tblur() {\n\t\tthis._input?.blur();\n\t}\n\n\tgetFontSize() {\n\t\tconst { style } = this.props;\n\n\t\tif ( ! style?.fontSize ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst { width, height } = Dimensions.get( 'window' );\n\t\tconst cssUnitOptions = { height, width };\n\n\t\treturn {\n\t\t\tfontSize: parseFloat(\n\t\t\t\tgetPxFromCssUnit( style.fontSize, cssUnitOptions )\n\t\t\t),\n\t\t};\n\t}\n\n\treplaceLineBreakTags( value ) {\n\t\treturn value?.replace( RegExp( '<br>', 'gim' ), '\\n' );\n\t}\n\n\tonChangeTextInput( event ) {\n\t\tconst { onChange } = this.props;\n\t\tonChange( event.nativeEvent.text );\n\t}\n\n\tonChangeRichText( value ) {\n\t\tconst { onChange } = this.props;\n\t\t// The <br> tags have to be replaced with new line characters\n\t\t// as the content of plain text shouldn't contain HTML tags.\n\t\tonChange( this.replaceLineBreakTags( value ) );\n\t}\n\n\trender() {\n\t\tconst { style, __experimentalVersion, onFocus, ...otherProps } =\n\t\t\tthis.props;\n\t\tconst textStyles = [\n\t\t\tstyle || styles[ 'block-editor-plain-text' ],\n\t\t\tthis.getFontSize(),\n\t\t];\n\n\t\tif ( __experimentalVersion === 2 ) {\n\t\t\tconst disableFormattingProps = {\n\t\t\t\twithoutInteractiveFormatting: true,\n\t\t\t\tdisableEditingMenu: true,\n\t\t\t\t__unstableDisableFormats: true,\n\t\t\t\tdisableSuggestions: true,\n\t\t\t};\n\n\t\t\tconst forcePlainTextProps = {\n\t\t\t\tpreserveWhiteSpace: true,\n\t\t\t\t__unstablePastePlainText: true,\n\t\t\t\tmultiline: false,\n\t\t\t};\n\n\t\t\tconst fontProps = {\n\t\t\t\tfontFamily: style?.fontFamily,\n\t\t\t\tfontSize: style?.fontSize,\n\t\t\t\tfontWeight: style?.fontWeight,\n\t\t\t};\n\n\t\t\treturn (\n\t\t\t\t<RichText\n\t\t\t\t\t{ ...otherProps }\n\t\t\t\t\t{ ...disableFormattingProps }\n\t\t\t\t\t{ ...forcePlainTextProps }\n\t\t\t\t\t{ ...fontProps }\n\t\t\t\t\tidentifier=\"content\"\n\t\t\t\t\tstyle={ style }\n\t\t\t\t\tonChange={ this.onChangeRichText }\n\t\t\t\t\tunstableOnFocus={ onFocus }\n\t\t\t\t/>\n\t\t\t);\n\t\t}\n\n\t\treturn (\n\t\t\t<TextInput\n\t\t\t\t{ ...this.props }\n\t\t\t\tref={ ( x ) => ( this._input = x ) }\n\t\t\t\tonChange={ this.onChangeTextInput }\n\t\t\t\tonFocus={ this.props.onFocus } // Always assign onFocus as a props.\n\t\t\t\tonBlur={ this.props.onBlur } // Always assign onBlur as a props.\n\t\t\t\tfontFamily={\n\t\t\t\t\t( this.props.style && this.props.style.fontFamily ) ||\n\t\t\t\t\tstyles[ 'block-editor-plain-text' ].fontFamily\n\t\t\t\t}\n\t\t\t\tstyle={ textStyles }\n\t\t\t\tscrollEnabled={ false }\n\t\t\t/>\n\t\t);\n\t}\n}\n"]}
|
|
@@ -32,16 +32,16 @@ function PreviewOptions({
|
|
|
32
32
|
className,
|
|
33
33
|
isEnabled = true,
|
|
34
34
|
deviceType,
|
|
35
|
-
setDeviceType
|
|
35
|
+
setDeviceType,
|
|
36
|
+
label
|
|
36
37
|
}) {
|
|
37
38
|
const isMobile = (0, _compose.useViewportMatch)('small', '<');
|
|
38
39
|
if (isMobile) return null;
|
|
39
40
|
const popoverProps = {
|
|
40
41
|
className: (0, _classnames.default)(className, 'block-editor-post-preview__dropdown-content'),
|
|
41
|
-
|
|
42
|
+
placement: 'bottom-end'
|
|
42
43
|
};
|
|
43
44
|
const toggleProps = {
|
|
44
|
-
variant: 'tertiary',
|
|
45
45
|
className: 'block-editor-post-preview__button-toggle',
|
|
46
46
|
disabled: !isEnabled,
|
|
47
47
|
children: viewLabel
|
|
@@ -59,7 +59,8 @@ function PreviewOptions({
|
|
|
59
59
|
popoverProps: popoverProps,
|
|
60
60
|
toggleProps: toggleProps,
|
|
61
61
|
menuProps: menuProps,
|
|
62
|
-
icon: deviceIcons[deviceType.toLowerCase()]
|
|
62
|
+
icon: deviceIcons[deviceType.toLowerCase()],
|
|
63
|
+
label: label || (0, _i18n.__)('Preview')
|
|
63
64
|
}, () => (0, _element.createElement)(_element.Fragment, null, (0, _element.createElement)(_components.MenuGroup, null, (0, _element.createElement)(_components.MenuItem, {
|
|
64
65
|
className: "block-editor-post-preview__button-resize",
|
|
65
66
|
onClick: () => setDeviceType('Desktop'),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/preview-options/index.js"],"names":["PreviewOptions","children","viewLabel","className","isEnabled","deviceType","setDeviceType","isMobile","popoverProps","
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/preview-options/index.js"],"names":["PreviewOptions","children","viewLabel","className","isEnabled","deviceType","setDeviceType","label","isMobile","popoverProps","placement","toggleProps","disabled","menuProps","deviceIcons","mobile","tablet","desktop","toLowerCase","check"],"mappings":";;;;;;;;;;;AAGA;;AAKA;;AACA;;AACA;;AACA;;AAXA;AACA;AACA;;AAGA;AACA;AACA;AAMe,SAASA,cAAT,CAAyB;AACvCC,EAAAA,QADuC;AAEvCC,EAAAA,SAFuC;AAGvCC,EAAAA,SAHuC;AAIvCC,EAAAA,SAAS,GAAG,IAJ2B;AAKvCC,EAAAA,UALuC;AAMvCC,EAAAA,aANuC;AAOvCC,EAAAA;AAPuC,CAAzB,EAQX;AACH,QAAMC,QAAQ,GAAG,+BAAkB,OAAlB,EAA2B,GAA3B,CAAjB;AACA,MAAKA,QAAL,EAAgB,OAAO,IAAP;AAEhB,QAA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AAE,QAAF,CAF9B;AAGC,IAAA,IAAI,EAAGD,UAAU,KAAK,QAAf,IAA2Bc;AAHnC,KAKG,cAAI,QAAJ,CALH,CAfD,CADD,EAwBGlB,QAxBH,CATF,CADD;AAuCA","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { useViewportMatch } from '@wordpress/compose';\nimport { DropdownMenu, MenuGroup, MenuItem } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { check, desktop, mobile, tablet } from '@wordpress/icons';\n\nexport default function PreviewOptions( {\n\tchildren,\n\tviewLabel,\n\tclassName,\n\tisEnabled = true,\n\tdeviceType,\n\tsetDeviceType,\n\tlabel,\n} ) {\n\tconst isMobile = useViewportMatch( 'small', '<' );\n\tif ( isMobile ) return null;\n\n\tconst popoverProps = {\n\t\tclassName: classnames(\n\t\t\tclassName,\n\t\t\t'block-editor-post-preview__dropdown-content'\n\t\t),\n\t\tplacement: 'bottom-end',\n\t};\n\tconst toggleProps = {\n\t\tclassName: 'block-editor-post-preview__button-toggle',\n\t\tdisabled: ! isEnabled,\n\t\tchildren: viewLabel,\n\t};\n\tconst menuProps = {\n\t\t'aria-label': __( 'View options' ),\n\t};\n\n\tconst deviceIcons = {\n\t\tmobile,\n\t\ttablet,\n\t\tdesktop,\n\t};\n\n\treturn (\n\t\t<DropdownMenu\n\t\t\tclassName=\"block-editor-post-preview__dropdown\"\n\t\t\tpopoverProps={ popoverProps }\n\t\t\ttoggleProps={ toggleProps }\n\t\t\tmenuProps={ menuProps }\n\t\t\ticon={ deviceIcons[ deviceType.toLowerCase() ] }\n\t\t\tlabel={ label || __( 'Preview' ) }\n\t\t>\n\t\t\t{ () => (\n\t\t\t\t<>\n\t\t\t\t\t<MenuGroup>\n\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\tclassName=\"block-editor-post-preview__button-resize\"\n\t\t\t\t\t\t\tonClick={ () => setDeviceType( 'Desktop' ) }\n\t\t\t\t\t\t\ticon={ deviceType === 'Desktop' && check }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Desktop' ) }\n\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\tclassName=\"block-editor-post-preview__button-resize\"\n\t\t\t\t\t\t\tonClick={ () => setDeviceType( 'Tablet' ) }\n\t\t\t\t\t\t\ticon={ deviceType === 'Tablet' && check }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Tablet' ) }\n\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\tclassName=\"block-editor-post-preview__button-resize\"\n\t\t\t\t\t\t\tonClick={ () => setDeviceType( 'Mobile' ) }\n\t\t\t\t\t\t\ticon={ deviceType === 'Mobile' && check }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Mobile' ) }\n\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t</MenuGroup>\n\t\t\t\t\t{ children }\n\t\t\t\t</>\n\t\t\t) }\n\t\t</DropdownMenu>\n\t);\n}\n"]}
|
|
@@ -9,8 +9,6 @@ exports.default = exports.ExperimentalBlockEditorProvider = exports.BlockEditorP
|
|
|
9
9
|
|
|
10
10
|
var _element = require("@wordpress/element");
|
|
11
11
|
|
|
12
|
-
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
13
|
-
|
|
14
12
|
var _data = require("@wordpress/data");
|
|
15
13
|
|
|
16
14
|
var _withRegistryProvider = _interopRequireDefault(require("./with-registry-provider"));
|
|
@@ -53,9 +51,9 @@ const ExperimentalBlockEditorProvider = (0, _withRegistryProvider.default)(props
|
|
|
53
51
|
exports.ExperimentalBlockEditorProvider = ExperimentalBlockEditorProvider;
|
|
54
52
|
|
|
55
53
|
const BlockEditorProvider = props => {
|
|
56
|
-
return (0, _element.createElement)(ExperimentalBlockEditorProvider,
|
|
54
|
+
return (0, _element.createElement)(ExperimentalBlockEditorProvider, { ...props,
|
|
57
55
|
stripExperimentalSettings: true
|
|
58
|
-
}
|
|
56
|
+
}, props.children);
|
|
59
57
|
};
|
|
60
58
|
|
|
61
59
|
exports.BlockEditorProvider = BlockEditorProvider;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/provider/index.js"],"names":["ExperimentalBlockEditorProvider","props","children","settings","stripExperimentalSettings","__experimentalUpdateSettings","blockEditorStore","__internalIsInitialized","BlockEditorProvider"],"mappings":";;;;;;;;;AAIA
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/provider/index.js"],"names":["ExperimentalBlockEditorProvider","props","children","settings","stripExperimentalSettings","__experimentalUpdateSettings","blockEditorStore","__internalIsInitialized","BlockEditorProvider"],"mappings":";;;;;;;;;AAIA;;AADA;;AAMA;;AACA;;AACA;;AACA;;AACA;;AAbA;AACA;AACA;;AAIA;AACA;AACA;;AAOA;AAEO,MAAMA,+BAA+B,GAAG,mCAC5CC,KAAF,IAAa;AACZ,QAAM;AAAEC,IAAAA,QAAF;AAAYC,IAAAA,QAAZ;AAAsBC,IAAAA,yBAAyB,GAAG;AAAlD,MAA4DH,KAAlE;AAEA,QAAM;AAAEI,IAAAA;AAAF,MAAmC,wBACxC,uBAAaC,YAAb,CADwC,CAAzC;AAGA,0BAAW,MAAM;AAChBD,IAAAA,4BAA4B,CAC3B,EACC,GAAGF,QADJ;AAECI,MAAAA,uBAAuB,EAAE;AAF1B,KAD2B,EAK3BH,yBAL2B,CAA5B;AAOA,GARD,EAQG,CAAED,QAAF,CARH,EANY,CAgBZ;;AACA,6BAAcF,KAAd;AAEA,SAAO,4BAAC,oCAAD,QAAqBC,QAArB,CAAP;AACA,CArB6C,CAAxC;;;AAwBA,MAAMM,mBAAmB,GAAKP,KAAF,IAAa;AAC/C,SACC,4BAAC,+BAAD,OACMA,KADN;AAEC,IAAA,yBAAyB,EAAG;AAF7B,KAIGA,KAAK,CAACC,QAJT,CADD;AAQA,CATM;;;eAWQM,mB","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useDispatch } from '@wordpress/data';\nimport { useEffect } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport withRegistryProvider from './with-registry-provider';\nimport useBlockSync from './use-block-sync';\nimport { store as blockEditorStore } from '../../store';\nimport { BlockRefsProvider } from './block-refs-provider';\nimport { unlock } from '../../lock-unlock';\n\n/** @typedef {import('@wordpress/data').WPDataRegistry} WPDataRegistry */\n\nexport const ExperimentalBlockEditorProvider = withRegistryProvider(\n\t( props ) => {\n\t\tconst { children, settings, stripExperimentalSettings = false } = props;\n\n\t\tconst { __experimentalUpdateSettings } = unlock(\n\t\t\tuseDispatch( blockEditorStore )\n\t\t);\n\t\tuseEffect( () => {\n\t\t\t__experimentalUpdateSettings(\n\t\t\t\t{\n\t\t\t\t\t...settings,\n\t\t\t\t\t__internalIsInitialized: true,\n\t\t\t\t},\n\t\t\t\tstripExperimentalSettings\n\t\t\t);\n\t\t}, [ settings ] );\n\n\t\t// Syncs the entity provider with changes in the block-editor store.\n\t\tuseBlockSync( props );\n\n\t\treturn <BlockRefsProvider>{ children }</BlockRefsProvider>;\n\t}\n);\n\nexport const BlockEditorProvider = ( props ) => {\n\treturn (\n\t\t<ExperimentalBlockEditorProvider\n\t\t\t{ ...props }\n\t\t\tstripExperimentalSettings={ true }\n\t\t>\n\t\t\t{ props.children }\n\t\t</ExperimentalBlockEditorProvider>\n\t);\n};\n\nexport default BlockEditorProvider;\n"]}
|
|
@@ -141,6 +141,22 @@ function useBlockSync({
|
|
|
141
141
|
|
|
142
142
|
resetBlocks(controlledBlocks);
|
|
143
143
|
}
|
|
144
|
+
}; // Clean up the changes made by setControlledBlocks() when the component
|
|
145
|
+
// containing useBlockSync() unmounts.
|
|
146
|
+
|
|
147
|
+
|
|
148
|
+
const unsetControlledBlocks = () => {
|
|
149
|
+
__unstableMarkNextChangeAsNotPersistent();
|
|
150
|
+
|
|
151
|
+
if (clientId) {
|
|
152
|
+
setHasControlledInnerBlocks(clientId, false);
|
|
153
|
+
|
|
154
|
+
__unstableMarkNextChangeAsNotPersistent();
|
|
155
|
+
|
|
156
|
+
replaceInnerBlocks(clientId, []);
|
|
157
|
+
} else {
|
|
158
|
+
resetBlocks([]);
|
|
159
|
+
}
|
|
144
160
|
}; // Add a subscription to the block-editor registry to detect when changes
|
|
145
161
|
// have been made. This lets us inform the data source of changes. This
|
|
146
162
|
// is an effect so that the subscriber can run synchronously without
|
|
@@ -269,5 +285,10 @@ function useBlockSync({
|
|
|
269
285
|
unsubscribe();
|
|
270
286
|
};
|
|
271
287
|
}, [registry, clientId]);
|
|
288
|
+
(0, _element.useEffect)(() => {
|
|
289
|
+
return () => {
|
|
290
|
+
unsetControlledBlocks();
|
|
291
|
+
};
|
|
292
|
+
}, []);
|
|
272
293
|
}
|
|
273
294
|
//# sourceMappingURL=use-block-sync.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/provider/use-block-sync.js"],"names":["noop","useBlockSync","clientId","value","controlledBlocks","selection","controlledSelection","onChange","onInput","registry","resetBlocks","resetSelection","replaceInnerBlocks","selectBlock","setHasControlledInnerBlocks","__unstableMarkNextChangeAsNotPersistent","dispatch","blockEditorStore","hasSelectedBlock","getBlockName","getBlocks","getSelectionStart","getSelectionEnd","getBlock","select","isControlled","areInnerBlocksControlled","pendingChanges","incoming","outgoing","subscribed","setControlledBlocks","batch","storeBlocks","map","block","current","onInputRef","onChangeRef","includes","length","hadSelecton","selectionAnchor","selectionFocus","selectionStart","selectionEnd","initialPosition","selectionStillExists","getSelectedBlocksInitialCaretPosition","isLastBlockChangePersistent","__unstableIsLastBlockChangeIgnored","blocks","isPersistent","previousAreBlocksDifferent","unsubscribe","subscribe","isStillControlled","newIsPersistent","newBlocks","areBlocksDifferent","didPersistenceChange","push","updateParent"],"mappings":";;;;;;;AAGA;;AACA;;AACA;;AAKA;;AAVA;AACA;AACA;;AAKA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CAEjD;AACA;AACA;AACA;;AACA9B,QAAAA,cAAc,CAACS,OAAf,CAAuBP,QAAvB,CAAgCgC,IAAhC,CAAsCV,MAAtC,EANiD,CAQjD;AACA;;AACA,cAAMW,YAAY,GAAGV,YAAY,GAC9Bd,WAAW,CAACF,OADkB,GAE9BC,UAAU,CAACD,OAFd;AAGA0B,QAAAA,YAAY,CAAEX,MAAF,EAAU;AACrB9C,UAAAA,SAAS,EAAE;AACVuC,YAAAA,cAAc,EAAEvB,iBAAiB,EADvB;AAEVwB,YAAAA,YAAY,EAAEvB,eAAe,EAFnB;AAGVwB,YAAAA,eAAe,EACdE,qCAAqC;AAJ5B;AADU,SAAV,CAAZ;AAQA;;AACDK,MAAAA,0BAA0B,GAAGM,kBAA7B;AACA,KAnEmB,CAApB;AAqEA,WAAO,MAAM;AACZ7B,MAAAA,UAAU,CAACM,OAAX,GAAqB,KAArB;AACAkB,MAAAA,WAAW;AACX,KAHD;AAIA,GAtFD,EAsFG,CAAE7C,QAAF,EAAYP,QAAZ,CAtFH;AAuFA","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\tselectBlock,\n\t\tsetHasControlledInnerBlocks,\n\t\t__unstableMarkNextChangeAsNotPersistent,\n\t} = registry.dispatch( blockEditorStore );\n\tconst {\n\t\thasSelectedBlock,\n\t\tgetBlockName,\n\t\tgetBlocks,\n\t\tgetSelectionStart,\n\t\tgetSelectionEnd,\n\t\tgetBlock,\n\t} = registry.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// 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\tconst hadSelecton = hasSelectedBlock();\n\t\t\tconst selectionAnchor = getSelectionStart();\n\t\t\tconst selectionFocus = getSelectionEnd();\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} else {\n\t\t\t\tconst selectionStillExists = getBlock(\n\t\t\t\t\tselectionAnchor.clientId\n\t\t\t\t);\n\t\t\t\tif ( hadSelecton && ! selectionStillExists ) {\n\t\t\t\t\tselectBlock( clientId );\n\t\t\t\t} else {\n\t\t\t\t\tresetSelection( selectionAnchor, selectionFocus );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}, [ controlledBlocks, clientId ] );\n\n\tuseEffect( () => {\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\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} );\n\n\t\treturn () => {\n\t\t\tsubscribed.current = false;\n\t\t\tunsubscribe();\n\t\t};\n\t}, [ registry, clientId ] );\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/provider/use-block-sync.js"],"names":["noop","useBlockSync","clientId","value","controlledBlocks","selection","controlledSelection","onChange","onInput","registry","resetBlocks","resetSelection","replaceInnerBlocks","selectBlock","setHasControlledInnerBlocks","__unstableMarkNextChangeAsNotPersistent","dispatch","blockEditorStore","hasSelectedBlock","getBlockName","getBlocks","getSelectionStart","getSelectionEnd","getBlock","select","isControlled","areInnerBlocksControlled","pendingChanges","incoming","outgoing","subscribed","setControlledBlocks","batch","storeBlocks","map","block","current","unsetControlledBlocks","onInputRef","onChangeRef","includes","length","hadSelecton","selectionAnchor","selectionFocus","selectionStart","selectionEnd","initialPosition","selectionStillExists","getSelectedBlocksInitialCaretPosition","isLastBlockChangePersistent","__unstableIsLastBlockChangeIgnored","blocks","isPersistent","previousAreBlocksDifferent","unsubscribe","subscribe","isStillControlled","newIsPersistent","newBlocks","areBlocksDifferent","didPersistenceChange","push","updateParent"],"mappings":";;;;;;;AAGA;;AACA;;AACA;;AAKA;;AAVA;AACA;AACA;;AAKA;AACA;AACA;AAGA,MAAMA,IAAI,GAAG,MAAM,CAAE,CAArB;AAEA;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,YAAT,CAAuB;AACrCC,EAAAA,QAAQ,GAAG,IAD0B;AAErCC,EAAAA,KAAK,EAAEC,gBAF8B;AAGrCC,EAAAA,SAAS,EAAEC,mBAH0B;AAIrCC,EAAAA,QAAQ,GAAGP,IAJ0B;AAKrCQ,EAAAA,OAAO,GAAGR;AAL2B,CAAvB,EAMX;AACH,QAAMS,QAAQ,GAAG,wBAAjB;AAEA,QAAM;AACLC,IAAAA,WADK;AAELC,IAAAA,cAFK;AAGLC,IAAAA,kBAHK;AAILC,IAAAA,WAJK;AAKLC,IAAAA,2BALK;AAMLC,IAAAA;AANK,MAOFN,QAAQ,CAACO,QAAT,CAAmBC,YAAnB,CAPJ;AAQA,QAAM;AACLC,IAAAA,gBADK;AAELC,IAAAA,YAFK;AAGLC,IAAAA,SAHK;AAILC,IAAAA,iBAJK;AAKLC,IAAAA,eALK;AAMLC,IAAAA;AANK,MAOFd,QAAQ,CAACe,MAAT,CAAiBP,YAAjB,CAPJ;AAQA,QAAMQ,YAAY,GAAG,qBAClBD,MAAF,IAAc;AACb,WACC,CAAEtB,QAAF,IACAsB,MAAM,CAAEP,YAAF,CAAN,CAA2BS,wBAA3B,CAAqDxB,QAArD,CAFD;A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Content":["/**\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\tselectBlock,\n\t\tsetHasControlledInnerBlocks,\n\t\t__unstableMarkNextChangeAsNotPersistent,\n\t} = registry.dispatch( blockEditorStore );\n\tconst {\n\t\thasSelectedBlock,\n\t\tgetBlockName,\n\t\tgetBlocks,\n\t\tgetSelectionStart,\n\t\tgetSelectionEnd,\n\t\tgetBlock,\n\t} = registry.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\tconst hadSelecton = hasSelectedBlock();\n\t\t\tconst selectionAnchor = getSelectionStart();\n\t\t\tconst selectionFocus = getSelectionEnd();\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} else {\n\t\t\t\tconst selectionStillExists = getBlock(\n\t\t\t\t\tselectionAnchor.clientId\n\t\t\t\t);\n\t\t\t\tif ( hadSelecton && ! selectionStillExists ) {\n\t\t\t\t\tselectBlock( clientId );\n\t\t\t\t} else {\n\t\t\t\t\tresetSelection( selectionAnchor, selectionFocus );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}, [ controlledBlocks, clientId ] );\n\n\tuseEffect( () => {\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\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} );\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\t\tunsetControlledBlocks();\n\t\t};\n\t}, [] );\n}\n"]}
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
3
|
Object.defineProperty(exports, "__esModule", {
|
|
6
4
|
value: true
|
|
7
5
|
});
|
|
@@ -9,8 +7,6 @@ exports.default = void 0;
|
|
|
9
7
|
|
|
10
8
|
var _element = require("@wordpress/element");
|
|
11
9
|
|
|
12
|
-
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
13
|
-
|
|
14
10
|
var _data = require("@wordpress/data");
|
|
15
11
|
|
|
16
12
|
var _compose = require("@wordpress/compose");
|
|
@@ -33,9 +29,10 @@ const withRegistryProvider = (0, _compose.createHigherOrderComponent)(WrappedCom
|
|
|
33
29
|
...props
|
|
34
30
|
}) => {
|
|
35
31
|
if (!useSubRegistry) {
|
|
36
|
-
return (0, _element.createElement)(WrappedComponent,
|
|
37
|
-
registry: registry
|
|
38
|
-
|
|
32
|
+
return (0, _element.createElement)(WrappedComponent, {
|
|
33
|
+
registry: registry,
|
|
34
|
+
...props
|
|
35
|
+
});
|
|
39
36
|
}
|
|
40
37
|
|
|
41
38
|
const [subRegistry, setSubRegistry] = (0, _element.useState)(null);
|
|
@@ -51,9 +48,10 @@ const withRegistryProvider = (0, _compose.createHigherOrderComponent)(WrappedCom
|
|
|
51
48
|
|
|
52
49
|
return (0, _element.createElement)(_data.RegistryProvider, {
|
|
53
50
|
value: subRegistry
|
|
54
|
-
}, (0, _element.createElement)(WrappedComponent,
|
|
55
|
-
registry: subRegistry
|
|
56
|
-
|
|
51
|
+
}, (0, _element.createElement)(WrappedComponent, {
|
|
52
|
+
registry: subRegistry,
|
|
53
|
+
...props
|
|
54
|
+
}));
|
|
57
55
|
});
|
|
58
56
|
}, 'withRegistryProvider');
|
|
59
57
|
var _default = withRegistryProvider;
|