@wordpress/block-editor 13.1.0 → 13.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +21 -17
- package/README.md +1 -2
- package/build/components/block-breadcrumb/index.js +12 -1
- package/build/components/block-breadcrumb/index.js.map +1 -1
- package/build/components/block-lock/modal.js +67 -67
- package/build/components/block-lock/modal.js.map +1 -1
- package/build/components/block-lock/toolbar.js +0 -1
- package/build/components/block-lock/toolbar.js.map +1 -1
- package/build/components/block-mover/button.js +1 -1
- package/build/components/block-mover/button.js.map +1 -1
- package/build/components/block-mover/index.js +12 -6
- package/build/components/block-mover/index.js.map +1 -1
- package/build/components/block-pattern-setup/setup-toolbar.js +2 -2
- package/build/components/block-pattern-setup/setup-toolbar.js.map +1 -1
- package/build/components/block-patterns-paging/index.js +5 -7
- package/build/components/block-patterns-paging/index.js.map +1 -1
- package/build/components/block-quick-navigation/index.js +20 -17
- package/build/components/block-quick-navigation/index.js.map +1 -1
- package/build/components/block-rename/modal.js +4 -12
- package/build/components/block-rename/modal.js.map +1 -1
- package/build/components/block-toolbar/shuffle.js +4 -1
- package/build/components/block-toolbar/shuffle.js.map +1 -1
- package/build/components/block-tools/block-selection-button.js +7 -58
- package/build/components/block-tools/block-selection-button.js.map +1 -1
- package/build/components/block-tools/block-toolbar-breadcrumb.js +9 -2
- package/build/components/block-tools/block-toolbar-breadcrumb.js.map +1 -1
- package/build/components/block-tools/index.js +14 -1
- package/build/components/block-tools/index.js.map +1 -1
- package/build/components/block-tools/use-show-block-tools.js +4 -2
- package/build/components/block-tools/use-show-block-tools.js.map +1 -1
- package/build/components/block-tools/zoom-out-mode-inserters.js +5 -4
- package/build/components/block-tools/zoom-out-mode-inserters.js.map +1 -1
- package/build/components/block-tools/zoom-out-popover.js +57 -0
- package/build/components/block-tools/zoom-out-popover.js.map +1 -0
- package/build/components/block-tools/zoom-out-toolbar.js +138 -0
- package/build/components/block-tools/zoom-out-toolbar.js.map +1 -0
- package/build/components/button-block-appender/index.js +3 -1
- package/build/components/button-block-appender/index.js.map +1 -1
- package/build/components/child-layout-control/index.js +193 -127
- package/build/components/child-layout-control/index.js.map +1 -1
- package/build/components/date-format-picker/index.js +10 -1
- package/build/components/date-format-picker/index.js.map +1 -1
- package/build/components/dimensions-tool/index.js +6 -4
- package/build/components/dimensions-tool/index.js.map +1 -1
- package/build/components/font-appearance-control/index.js +26 -61
- package/build/components/font-appearance-control/index.js.map +1 -1
- package/build/components/global-styles/background-panel.js +178 -116
- package/build/components/global-styles/background-panel.js.map +1 -1
- package/build/components/global-styles/border-panel.js +2 -1
- package/build/components/global-styles/border-panel.js.map +1 -1
- package/build/components/global-styles/color-panel.js +2 -1
- package/build/components/global-styles/color-panel.js.map +1 -1
- package/build/components/global-styles/dimensions-panel.js +2 -1
- package/build/components/global-styles/dimensions-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/hooks.js +8 -0
- package/build/components/global-styles/hooks.js.map +1 -1
- package/build/components/global-styles/image-settings-panel.js +2 -1
- package/build/components/global-styles/image-settings-panel.js.map +1 -1
- package/build/components/global-styles/typography-panel.js +50 -12
- package/build/components/global-styles/typography-panel.js.map +1 -1
- package/build/components/global-styles/typography-utils.js +50 -0
- package/build/components/global-styles/typography-utils.js.map +1 -1
- package/build/components/global-styles/use-global-styles-output.js +25 -9
- package/build/components/global-styles/use-global-styles-output.js.map +1 -1
- package/build/components/global-styles/utils.js +17 -7
- package/build/components/global-styles/utils.js.map +1 -1
- package/build/components/grid/grid-item-movers.js +94 -0
- package/build/components/grid/grid-item-movers.js.map +1 -0
- package/build/components/{grid-visualizer → grid}/grid-item-resizer.js +18 -56
- package/build/components/grid/grid-item-resizer.js.map +1 -0
- package/build/components/grid/grid-visualizer.js +305 -0
- package/build/components/grid/grid-visualizer.js.map +1 -0
- package/build/components/{grid-visualizer → grid}/index.js +14 -0
- package/build/components/grid/index.js.map +1 -0
- package/build/components/grid/use-get-number-of-blocks-before-cell.js +40 -0
- package/build/components/grid/use-get-number-of-blocks-before-cell.js.map +1 -0
- package/build/components/grid/use-grid-layout-sync.js +169 -0
- package/build/components/grid/use-grid-layout-sync.js.map +1 -0
- package/build/components/grid/utils.js +145 -0
- package/build/components/grid/utils.js.map +1 -0
- package/build/components/image-editor/aspect-ratio-dropdown.js +0 -1
- package/build/components/image-editor/aspect-ratio-dropdown.js.map +1 -1
- package/build/components/inner-blocks/index.js +1 -1
- package/build/components/inner-blocks/index.js.map +1 -1
- package/build/components/inserter/block-patterns-tab/pattern-category-preview-panel.js +1 -19
- package/build/components/inserter/block-patterns-tab/pattern-category-preview-panel.js.map +1 -1
- package/build/components/inserter/menu.js +26 -4
- package/build/components/inserter/menu.js.map +1 -1
- package/build/components/inserter/quick-inserter.js +2 -1
- package/build/components/inserter/quick-inserter.js.map +1 -1
- package/build/components/inspector-controls/block-support-tools-panel.js +2 -1
- package/build/components/inspector-controls/block-support-tools-panel.js.map +1 -1
- package/build/components/link-control/link-preview.js +1 -1
- package/build/components/link-control/link-preview.js.map +1 -1
- package/build/components/media-placeholder/index.js +19 -23
- package/build/components/media-placeholder/index.js.map +1 -1
- package/build/components/navigable-toolbar/index.js +3 -1
- package/build/components/navigable-toolbar/index.js.map +1 -1
- package/build/components/rich-text/event-listeners/input-rules.js +1 -0
- package/build/components/rich-text/event-listeners/input-rules.js.map +1 -1
- package/build/components/rich-text/index.native.js +10 -4
- package/build/components/rich-text/index.native.js.map +1 -1
- package/build/components/rich-text/native/index.native.js +14 -0
- package/build/components/rich-text/native/index.native.js.map +1 -1
- package/build/components/spacing-sizes-control/input-controls/spacing-input-control.js +5 -1
- package/build/components/spacing-sizes-control/input-controls/spacing-input-control.js.map +1 -1
- package/build/components/tabbed-sidebar/index.js +66 -0
- package/build/components/tabbed-sidebar/index.js.map +1 -0
- package/build/components/url-popover/index.js +3 -0
- package/build/components/url-popover/index.js.map +1 -1
- package/build/hooks/background.js +26 -4
- package/build/hooks/background.js.map +1 -1
- package/build/hooks/block-hooks.js +11 -17
- package/build/hooks/block-hooks.js.map +1 -1
- package/build/hooks/block-style-variation.js +195 -11
- package/build/hooks/block-style-variation.js.map +1 -1
- package/build/hooks/duotone.js +16 -11
- package/build/hooks/duotone.js.map +1 -1
- package/build/hooks/grid-visualizer.js +65 -0
- package/build/hooks/grid-visualizer.js.map +1 -0
- package/build/hooks/index.js +15 -2
- package/build/hooks/index.js.map +1 -1
- package/build/hooks/layout-child.js +65 -40
- package/build/hooks/layout-child.js.map +1 -1
- package/build/hooks/position.js +2 -9
- package/build/hooks/position.js.map +1 -1
- package/build/hooks/use-bindings-attributes.js +16 -6
- package/build/hooks/use-bindings-attributes.js.map +1 -1
- package/build/hooks/utils.js +5 -2
- package/build/hooks/utils.js.map +1 -1
- package/build/layouts/constrained.js +44 -2
- package/build/layouts/constrained.js.map +1 -1
- package/build/layouts/grid.js +92 -76
- package/build/layouts/grid.js.map +1 -1
- package/build/lock-unlock.js +1 -1
- package/build/lock-unlock.js.map +1 -1
- package/build/private-apis.js +6 -1
- package/build/private-apis.js.map +1 -1
- package/build/store/actions.js +17 -1
- package/build/store/actions.js.map +1 -1
- package/build/store/defaults.js +0 -2
- package/build/store/defaults.js.map +1 -1
- package/build/store/defaults.native.js +0 -3
- package/build/store/defaults.native.js.map +1 -1
- package/build/store/private-keys.js +2 -1
- package/build/store/private-keys.js.map +1 -1
- package/build/utils/format-font-style.js +45 -0
- package/build/utils/format-font-style.js.map +1 -0
- package/build/utils/format-font-weight.js +68 -0
- package/build/utils/format-font-weight.js.map +1 -0
- package/build/utils/get-editor-region.js +34 -0
- package/build/utils/get-editor-region.js.map +1 -0
- package/build/utils/get-font-styles-and-weights.js +167 -0
- package/build/utils/get-font-styles-and-weights.js.map +1 -0
- package/build/utils/pasting.js +5 -13
- package/build/utils/pasting.js.map +1 -1
- package/build-module/components/block-breadcrumb/index.js +12 -1
- package/build-module/components/block-breadcrumb/index.js.map +1 -1
- package/build-module/components/block-lock/modal.js +67 -67
- package/build-module/components/block-lock/modal.js.map +1 -1
- package/build-module/components/block-lock/toolbar.js +0 -1
- package/build-module/components/block-lock/toolbar.js.map +1 -1
- package/build-module/components/block-mover/button.js +1 -1
- package/build-module/components/block-mover/button.js.map +1 -1
- package/build-module/components/block-mover/index.js +12 -6
- package/build-module/components/block-mover/index.js.map +1 -1
- package/build-module/components/block-pattern-setup/setup-toolbar.js +2 -2
- package/build-module/components/block-pattern-setup/setup-toolbar.js.map +1 -1
- package/build-module/components/block-patterns-paging/index.js +5 -7
- package/build-module/components/block-patterns-paging/index.js.map +1 -1
- package/build-module/components/block-quick-navigation/index.js +20 -17
- package/build-module/components/block-quick-navigation/index.js.map +1 -1
- package/build-module/components/block-rename/modal.js +5 -13
- package/build-module/components/block-rename/modal.js.map +1 -1
- package/build-module/components/block-toolbar/shuffle.js +4 -1
- package/build-module/components/block-toolbar/shuffle.js.map +1 -1
- package/build-module/components/block-tools/block-selection-button.js +10 -61
- package/build-module/components/block-tools/block-selection-button.js.map +1 -1
- package/build-module/components/block-tools/block-toolbar-breadcrumb.js +9 -2
- package/build-module/components/block-tools/block-toolbar-breadcrumb.js.map +1 -1
- package/build-module/components/block-tools/index.js +14 -1
- package/build-module/components/block-tools/index.js.map +1 -1
- package/build-module/components/block-tools/use-show-block-tools.js +4 -2
- package/build-module/components/block-tools/use-show-block-tools.js.map +1 -1
- package/build-module/components/block-tools/zoom-out-mode-inserters.js +5 -4
- package/build-module/components/block-tools/zoom-out-mode-inserters.js.map +1 -1
- package/build-module/components/block-tools/zoom-out-popover.js +48 -0
- package/build-module/components/block-tools/zoom-out-popover.js.map +1 -0
- package/build-module/components/block-tools/zoom-out-toolbar.js +131 -0
- package/build-module/components/block-tools/zoom-out-toolbar.js.map +1 -0
- package/build-module/components/button-block-appender/index.js +3 -1
- package/build-module/components/button-block-appender/index.js.map +1 -1
- package/build-module/components/child-layout-control/index.js +194 -128
- package/build-module/components/child-layout-control/index.js.map +1 -1
- package/build-module/components/date-format-picker/index.js +11 -3
- package/build-module/components/date-format-picker/index.js.map +1 -1
- package/build-module/components/dimensions-tool/index.js +6 -4
- package/build-module/components/dimensions-tool/index.js.map +1 -1
- package/build-module/components/font-appearance-control/index.js +28 -63
- package/build-module/components/font-appearance-control/index.js.map +1 -1
- package/build-module/components/global-styles/background-panel.js +181 -119
- package/build-module/components/global-styles/background-panel.js.map +1 -1
- package/build-module/components/global-styles/border-panel.js +3 -2
- package/build-module/components/global-styles/border-panel.js.map +1 -1
- package/build-module/components/global-styles/color-panel.js +3 -2
- package/build-module/components/global-styles/color-panel.js.map +1 -1
- package/build-module/components/global-styles/dimensions-panel.js +3 -2
- package/build-module/components/global-styles/dimensions-panel.js.map +1 -1
- package/build-module/components/global-styles/filters-panel.js +3 -2
- package/build-module/components/global-styles/filters-panel.js.map +1 -1
- package/build-module/components/global-styles/hooks.js +8 -0
- package/build-module/components/global-styles/hooks.js.map +1 -1
- package/build-module/components/global-styles/image-settings-panel.js +3 -2
- package/build-module/components/global-styles/image-settings-panel.js.map +1 -1
- package/build-module/components/global-styles/typography-panel.js +52 -14
- package/build-module/components/global-styles/typography-panel.js.map +1 -1
- package/build-module/components/global-styles/typography-utils.js +48 -0
- package/build-module/components/global-styles/typography-utils.js.map +1 -1
- package/build-module/components/global-styles/use-global-styles-output.js +25 -9
- package/build-module/components/global-styles/use-global-styles-output.js.map +1 -1
- package/build-module/components/global-styles/utils.js +15 -6
- package/build-module/components/global-styles/utils.js.map +1 -1
- package/build-module/components/grid/grid-item-movers.js +87 -0
- package/build-module/components/grid/grid-item-movers.js.map +1 -0
- package/build-module/components/{grid-visualizer → grid}/grid-item-resizer.js +13 -51
- package/build-module/components/grid/grid-item-resizer.js.map +1 -0
- package/build-module/components/grid/grid-visualizer.js +297 -0
- package/build-module/components/grid/grid-visualizer.js.map +1 -0
- package/build-module/components/grid/index.js +5 -0
- package/build-module/components/grid/index.js.map +1 -0
- package/build-module/components/grid/use-get-number-of-blocks-before-cell.js +33 -0
- package/build-module/components/grid/use-get-number-of-blocks-before-cell.js.map +1 -0
- package/build-module/components/grid/use-grid-layout-sync.js +162 -0
- package/build-module/components/grid/use-grid-layout-sync.js.map +1 -0
- package/build-module/components/grid/utils.js +131 -0
- package/build-module/components/grid/utils.js.map +1 -0
- package/build-module/components/image-editor/aspect-ratio-dropdown.js +0 -1
- package/build-module/components/image-editor/aspect-ratio-dropdown.js.map +1 -1
- package/build-module/components/inner-blocks/index.js +1 -1
- package/build-module/components/inner-blocks/index.js.map +1 -1
- package/build-module/components/inserter/block-patterns-tab/pattern-category-preview-panel.js +1 -19
- package/build-module/components/inserter/block-patterns-tab/pattern-category-preview-panel.js.map +1 -1
- package/build-module/components/inserter/menu.js +26 -4
- package/build-module/components/inserter/menu.js.map +1 -1
- package/build-module/components/inserter/quick-inserter.js +2 -1
- package/build-module/components/inserter/quick-inserter.js.map +1 -1
- package/build-module/components/inspector-controls/block-support-tools-panel.js +3 -2
- package/build-module/components/inspector-controls/block-support-tools-panel.js.map +1 -1
- package/build-module/components/link-control/link-preview.js +1 -1
- package/build-module/components/link-control/link-preview.js.map +1 -1
- package/build-module/components/media-placeholder/index.js +19 -23
- package/build-module/components/media-placeholder/index.js.map +1 -1
- package/build-module/components/navigable-toolbar/index.js +3 -1
- package/build-module/components/navigable-toolbar/index.js.map +1 -1
- package/build-module/components/rich-text/event-listeners/input-rules.js +1 -1
- package/build-module/components/rich-text/event-listeners/input-rules.js.map +1 -1
- package/build-module/components/rich-text/index.native.js +11 -5
- package/build-module/components/rich-text/index.native.js.map +1 -1
- package/build-module/components/rich-text/native/index.native.js +14 -0
- package/build-module/components/rich-text/native/index.native.js.map +1 -1
- package/build-module/components/spacing-sizes-control/input-controls/spacing-input-control.js +5 -1
- package/build-module/components/spacing-sizes-control/input-controls/spacing-input-control.js.map +1 -1
- package/build-module/components/tabbed-sidebar/index.js +60 -0
- package/build-module/components/tabbed-sidebar/index.js.map +1 -0
- package/build-module/components/url-popover/index.js +3 -0
- package/build-module/components/url-popover/index.js.map +1 -1
- package/build-module/hooks/background.js +26 -4
- package/build-module/hooks/background.js.map +1 -1
- package/build-module/hooks/block-hooks.js +11 -17
- package/build-module/hooks/block-hooks.js.map +1 -1
- package/build-module/hooks/block-style-variation.js +193 -11
- package/build-module/hooks/block-style-variation.js.map +1 -1
- package/build-module/hooks/duotone.js +16 -11
- package/build-module/hooks/duotone.js.map +1 -1
- package/build-module/hooks/grid-visualizer.js +64 -0
- package/build-module/hooks/grid-visualizer.js.map +1 -0
- package/build-module/hooks/index.js +3 -0
- package/build-module/hooks/index.js.map +1 -1
- package/build-module/hooks/layout-child.js +63 -38
- package/build-module/hooks/layout-child.js.map +1 -1
- package/build-module/hooks/position.js +2 -9
- package/build-module/hooks/position.js.map +1 -1
- package/build-module/hooks/use-bindings-attributes.js +16 -6
- package/build-module/hooks/use-bindings-attributes.js.map +1 -1
- package/build-module/hooks/utils.js +5 -2
- package/build-module/hooks/utils.js.map +1 -1
- package/build-module/layouts/constrained.js +44 -2
- package/build-module/layouts/constrained.js.map +1 -1
- package/build-module/layouts/grid.js +92 -76
- package/build-module/layouts/grid.js.map +1 -1
- package/build-module/lock-unlock.js +1 -1
- package/build-module/lock-unlock.js.map +1 -1
- package/build-module/private-apis.js +8 -3
- package/build-module/private-apis.js.map +1 -1
- package/build-module/store/actions.js +17 -1
- package/build-module/store/actions.js.map +1 -1
- package/build-module/store/defaults.js +0 -2
- package/build-module/store/defaults.js.map +1 -1
- package/build-module/store/defaults.native.js +0 -3
- package/build-module/store/defaults.native.js.map +1 -1
- package/build-module/store/private-keys.js +1 -0
- package/build-module/store/private-keys.js.map +1 -1
- package/build-module/utils/format-font-style.js +39 -0
- package/build-module/utils/format-font-style.js.map +1 -0
- package/build-module/utils/format-font-weight.js +62 -0
- package/build-module/utils/format-font-weight.js.map +1 -0
- package/build-module/utils/get-editor-region.js +28 -0
- package/build-module/utils/get-editor-region.js.map +1 -0
- package/build-module/utils/get-font-styles-and-weights.js +160 -0
- package/build-module/utils/get-font-styles-and-weights.js.map +1 -0
- package/build-module/utils/pasting.js +5 -13
- package/build-module/utils/pasting.js.map +1 -1
- package/build-style/content-rtl.css +1 -0
- package/build-style/content.css +1 -0
- package/build-style/style-rtl.css +238 -106
- package/build-style/style.css +238 -106
- package/package.json +32 -32
- package/src/components/block-breadcrumb/index.js +16 -1
- package/src/components/block-lock/modal.js +95 -82
- package/src/components/block-lock/style.scss +11 -1
- package/src/components/block-lock/toolbar.js +0 -1
- package/src/components/block-mover/button.js +1 -1
- package/src/components/block-mover/index.js +37 -24
- package/src/components/block-pattern-setup/setup-toolbar.js +2 -2
- package/src/components/block-patterns-paging/index.js +8 -11
- package/src/components/block-patterns-paging/style.scss +18 -0
- package/src/components/block-quick-navigation/index.js +21 -28
- package/src/components/block-rename/modal.js +2 -8
- package/src/components/block-switcher/test/index.js +6 -6
- package/src/components/block-toolbar/shuffle.js +4 -1
- package/src/components/block-toolbar/style.scss +1 -11
- package/src/components/block-tools/block-selection-button.js +11 -83
- package/src/components/block-tools/block-toolbar-breadcrumb.js +9 -4
- package/src/components/block-tools/index.js +21 -1
- package/src/components/block-tools/style.scss +15 -0
- package/src/components/block-tools/use-show-block-tools.js +14 -6
- package/src/components/block-tools/zoom-out-mode-inserters.js +5 -4
- package/src/components/block-tools/zoom-out-popover.js +49 -0
- package/src/components/block-tools/zoom-out-toolbar.js +140 -0
- package/src/components/button-block-appender/index.js +2 -1
- package/src/components/child-layout-control/index.js +243 -160
- package/src/components/date-format-picker/index.js +10 -1
- package/src/components/date-format-picker/style.scss +0 -9
- package/src/components/dimensions-tool/index.js +97 -89
- package/src/components/font-appearance-control/index.js +29 -83
- package/src/components/font-appearance-control/style.scss +3 -5
- package/src/components/global-styles/background-panel.js +249 -170
- package/src/components/global-styles/border-panel.js +3 -2
- package/src/components/global-styles/color-panel.js +3 -2
- package/src/components/global-styles/dimensions-panel.js +3 -2
- package/src/components/global-styles/filters-panel.js +3 -2
- package/src/components/global-styles/hooks.js +9 -0
- package/src/components/global-styles/image-settings-panel.js +3 -2
- package/src/components/global-styles/style.scss +105 -20
- package/src/components/global-styles/test/typography-utils.js +269 -0
- package/src/components/global-styles/test/use-global-styles-output.js +38 -3
- package/src/components/global-styles/typography-panel.js +49 -12
- package/src/components/global-styles/typography-utils.js +63 -0
- package/src/components/global-styles/use-global-styles-output.js +25 -9
- package/src/components/global-styles/utils.js +17 -6
- package/src/components/grid/grid-item-movers.js +112 -0
- package/src/components/{grid-visualizer → grid}/grid-item-resizer.js +15 -52
- package/src/components/grid/grid-visualizer.js +384 -0
- package/src/components/grid/index.js +4 -0
- package/src/components/grid/style.scss +98 -0
- package/src/components/grid/use-get-number-of-blocks-before-cell.js +30 -0
- package/src/components/grid/use-grid-layout-sync.js +170 -0
- package/src/components/grid/utils.js +178 -0
- package/src/components/iframe/content.scss +1 -0
- package/src/components/image-editor/aspect-ratio-dropdown.js +0 -1
- package/src/components/inner-blocks/index.js +4 -1
- package/src/components/inserter/block-patterns-tab/pattern-category-preview-panel.js +1 -16
- package/src/components/inserter/menu.js +47 -13
- package/src/components/inserter/quick-inserter.js +6 -1
- package/src/components/inserter/style.scss +1 -49
- package/src/components/inspector-controls/block-support-tools-panel.js +3 -3
- package/src/components/link-control/link-preview.js +1 -1
- package/src/components/media-placeholder/index.js +22 -32
- package/src/components/navigable-toolbar/index.js +3 -1
- package/src/components/rich-text/event-listeners/input-rules.js +1 -1
- package/src/components/rich-text/index.native.js +10 -8
- package/src/components/rich-text/native/index.native.js +17 -0
- package/src/components/spacing-sizes-control/input-controls/spacing-input-control.js +6 -1
- package/src/components/tabbed-sidebar/README.md +76 -0
- package/src/components/tabbed-sidebar/index.js +70 -0
- package/src/components/tabbed-sidebar/style.scss +53 -0
- package/src/components/url-popover/index.js +3 -0
- package/src/hooks/background.js +25 -10
- package/src/hooks/block-hooks.js +9 -16
- package/src/hooks/block-style-variation.js +226 -9
- package/src/hooks/duotone.js +16 -12
- package/src/hooks/grid-visualizer.js +64 -0
- package/src/hooks/index.js +3 -0
- package/src/hooks/layout-child.js +75 -39
- package/src/hooks/position.js +3 -10
- package/src/hooks/test/get-variation-styles-with-ref-values.js +91 -0
- package/src/hooks/use-bindings-attributes.js +18 -4
- package/src/hooks/utils.js +5 -1
- package/src/layouts/constrained.js +43 -2
- package/src/layouts/grid.js +175 -88
- package/src/lock-unlock.js +1 -1
- package/src/private-apis.js +12 -1
- package/src/store/actions.js +21 -1
- package/src/store/defaults.js +0 -2
- package/src/store/defaults.native.js +0 -3
- package/src/store/private-keys.js +1 -0
- package/src/style.scss +2 -2
- package/src/utils/format-font-style.js +40 -0
- package/src/utils/format-font-weight.js +63 -0
- package/src/utils/get-editor-region.js +31 -0
- package/src/utils/get-font-styles-and-weights.js +191 -0
- package/src/utils/pasting.js +5 -12
- package/src/utils/test/format-font-style.js +34 -0
- package/src/utils/test/format-font-weight.js +66 -0
- package/src/utils/test/get-font-styles-and-weights.js +513 -0
- package/tsconfig.tsbuildinfo +1 -1
- package/build/components/grid-visualizer/grid-item-resizer.js.map +0 -1
- package/build/components/grid-visualizer/grid-visualizer.js +0 -92
- package/build/components/grid-visualizer/grid-visualizer.js.map +0 -1
- package/build/components/grid-visualizer/index.js.map +0 -1
- package/build/components/grid-visualizer/utils.js +0 -10
- package/build/components/grid-visualizer/utils.js.map +0 -1
- package/build-module/components/grid-visualizer/grid-item-resizer.js.map +0 -1
- package/build-module/components/grid-visualizer/grid-visualizer.js +0 -84
- package/build-module/components/grid-visualizer/grid-visualizer.js.map +0 -1
- package/build-module/components/grid-visualizer/index.js +0 -3
- package/build-module/components/grid-visualizer/index.js.map +0 -1
- package/build-module/components/grid-visualizer/utils.js +0 -4
- package/build-module/components/grid-visualizer/utils.js.map +0 -1
- package/src/components/grid-visualizer/grid-visualizer.js +0 -101
- package/src/components/grid-visualizer/index.js +0 -2
- package/src/components/grid-visualizer/style.scss +0 -34
- package/src/components/grid-visualizer/utils.js +0 -5
- package/src/hooks/position.scss +0 -18
- /package/src/components/font-sizes/{README.MD → README.md} +0 -0
|
@@ -33,6 +33,7 @@ function BlockSupportToolsPanel({
|
|
|
33
33
|
getSelectedBlockClientId,
|
|
34
34
|
hasMultiSelection
|
|
35
35
|
} = (0, _data.useSelect)(_store.store);
|
|
36
|
+
const dropdownMenuProps = (0, _utils2.useToolsPanelDropdownMenuProps)();
|
|
36
37
|
const panelId = getSelectedBlockClientId();
|
|
37
38
|
const resetAll = (0, _element.useCallback)((resetFilters = []) => {
|
|
38
39
|
const newAttributes = {};
|
|
@@ -70,7 +71,7 @@ function BlockSupportToolsPanel({
|
|
|
70
71
|
,
|
|
71
72
|
__experimentalFirstVisibleItemClass: "first",
|
|
72
73
|
__experimentalLastVisibleItemClass: "last",
|
|
73
|
-
dropdownMenuProps:
|
|
74
|
+
dropdownMenuProps: dropdownMenuProps,
|
|
74
75
|
children: children
|
|
75
76
|
}, panelId);
|
|
76
77
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_components","require","_data","_element","_store","_utils","_utils2","_jsxRuntime","BlockSupportToolsPanel","children","group","label","updateBlockAttributes","useDispatch","blockEditorStore","getBlockAttributes","getMultiSelectedBlockClientIds","getSelectedBlockClientId","hasMultiSelection","useSelect","panelId","resetAll","useCallback","resetFilters","newAttributes","clientIds","forEach","clientId","style","newBlockAttributes","resetFilter","cleanEmptyObject","jsx","__experimentalToolsPanel","className","hasInnerWrapper","shouldRenderPlaceholderItems","__experimentalFirstVisibleItemClass","__experimentalLastVisibleItemClass"
|
|
1
|
+
{"version":3,"names":["_components","require","_data","_element","_store","_utils","_utils2","_jsxRuntime","BlockSupportToolsPanel","children","group","label","updateBlockAttributes","useDispatch","blockEditorStore","getBlockAttributes","getMultiSelectedBlockClientIds","getSelectedBlockClientId","hasMultiSelection","useSelect","dropdownMenuProps","useToolsPanelDropdownMenuProps","panelId","resetAll","useCallback","resetFilters","newAttributes","clientIds","forEach","clientId","style","newBlockAttributes","resetFilter","cleanEmptyObject","jsx","__experimentalToolsPanel","className","hasInnerWrapper","shouldRenderPlaceholderItems","__experimentalFirstVisibleItemClass","__experimentalLastVisibleItemClass"],"sources":["@wordpress/block-editor/src/components/inspector-controls/block-support-tools-panel.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __experimentalToolsPanel as ToolsPanel } from '@wordpress/components';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { useCallback } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\nimport { cleanEmptyObject } from '../../hooks/utils';\nimport { useToolsPanelDropdownMenuProps } from '../global-styles/utils';\n\nexport default function BlockSupportToolsPanel( { children, group, label } ) {\n\tconst { updateBlockAttributes } = useDispatch( blockEditorStore );\n\tconst {\n\t\tgetBlockAttributes,\n\t\tgetMultiSelectedBlockClientIds,\n\t\tgetSelectedBlockClientId,\n\t\thasMultiSelection,\n\t} = useSelect( blockEditorStore );\n\tconst dropdownMenuProps = useToolsPanelDropdownMenuProps();\n\tconst panelId = getSelectedBlockClientId();\n\tconst resetAll = useCallback(\n\t\t( resetFilters = [] ) => {\n\t\t\tconst newAttributes = {};\n\n\t\t\tconst clientIds = hasMultiSelection()\n\t\t\t\t? getMultiSelectedBlockClientIds()\n\t\t\t\t: [ panelId ];\n\n\t\t\tclientIds.forEach( ( clientId ) => {\n\t\t\t\tconst { style } = getBlockAttributes( clientId );\n\t\t\t\tlet newBlockAttributes = { style };\n\n\t\t\t\tresetFilters.forEach( ( resetFilter ) => {\n\t\t\t\t\tnewBlockAttributes = {\n\t\t\t\t\t\t...newBlockAttributes,\n\t\t\t\t\t\t...resetFilter( newBlockAttributes ),\n\t\t\t\t\t};\n\t\t\t\t} );\n\n\t\t\t\t// Enforce a cleaned style object.\n\t\t\t\tnewBlockAttributes = {\n\t\t\t\t\t...newBlockAttributes,\n\t\t\t\t\tstyle: cleanEmptyObject( newBlockAttributes.style ),\n\t\t\t\t};\n\n\t\t\t\tnewAttributes[ clientId ] = newBlockAttributes;\n\t\t\t} );\n\n\t\t\tupdateBlockAttributes( clientIds, newAttributes, true );\n\t\t},\n\t\t[\n\t\t\tgetBlockAttributes,\n\t\t\tgetMultiSelectedBlockClientIds,\n\t\t\thasMultiSelection,\n\t\t\tpanelId,\n\t\t\tupdateBlockAttributes,\n\t\t]\n\t);\n\n\treturn (\n\t\t<ToolsPanel\n\t\t\tclassName={ `${ group }-block-support-panel` }\n\t\t\tlabel={ label }\n\t\t\tresetAll={ resetAll }\n\t\t\tkey={ panelId }\n\t\t\tpanelId={ panelId }\n\t\t\thasInnerWrapper\n\t\t\tshouldRenderPlaceholderItems // Required to maintain fills ordering.\n\t\t\t__experimentalFirstVisibleItemClass=\"first\"\n\t\t\t__experimentalLastVisibleItemClass=\"last\"\n\t\t\tdropdownMenuProps={ dropdownMenuProps }\n\t\t>\n\t\t\t{ children }\n\t\t</ToolsPanel>\n\t);\n}\n"],"mappings":";;;;;;AAGA,IAAAA,WAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,QAAA,GAAAF,OAAA;AAKA,IAAAG,MAAA,GAAAH,OAAA;AACA,IAAAI,MAAA,GAAAJ,OAAA;AACA,IAAAK,OAAA,GAAAL,OAAA;AAAwE,IAAAM,WAAA,GAAAN,OAAA;AAZxE;AACA;AACA;;AAKA;AACA;AACA;;AAKe,SAASO,sBAAsBA,CAAE;EAAEC,QAAQ;EAAEC,KAAK;EAAEC;AAAM,CAAC,EAAG;EAC5E,MAAM;IAAEC;EAAsB,CAAC,GAAG,IAAAC,iBAAW,EAAEC,YAAiB,CAAC;EACjE,MAAM;IACLC,kBAAkB;IAClBC,8BAA8B;IAC9BC,wBAAwB;IACxBC;EACD,CAAC,GAAG,IAAAC,eAAS,EAAEL,YAAiB,CAAC;EACjC,MAAMM,iBAAiB,GAAG,IAAAC,sCAA8B,EAAC,CAAC;EAC1D,MAAMC,OAAO,GAAGL,wBAA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AErCA;EAAQ,GARJa,OASK,CAAC;AAEf","ignoreList":[]}
|
|
@@ -148,7 +148,7 @@ function LinkPreview({
|
|
|
148
148
|
// Ends up looking like "Copy link: https://example.com".
|
|
149
149
|
isEmptyURL || showIconLabels ? '' : ': ' + value.url),
|
|
150
150
|
ref: ref,
|
|
151
|
-
|
|
151
|
+
accessibleWhenDisabled: true,
|
|
152
152
|
disabled: isEmptyURL,
|
|
153
153
|
size: "compact"
|
|
154
154
|
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_viewerSlot.ViewerSlot, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_clsx","_interopRequireDefault","require","_i18n","_components","_compose","_url","_icons","_dom","_data","_notices","_preferences","_viewerSlot","_useRichUrlData","_jsxRuntime","filterTitleForDisplay","title","replace","LinkPreview","value","onEditClick","hasRichPreviews","hasUnlinkControl","onRemove","showIconLabels","useSelect","select","preferencesStore","get","showRichPreviews","url","richData","isFetching","useRichUrlData","hasRichData","Object","keys","length","displayURL","filterURLForDisplay","safeDecodeURI","isEmptyURL","displayTitle","stripHTML","isUrlRedundant","icon","jsx","src","alt","Icon","info","size","globe","createNotice","useDispatch","noticesStore","ref","useCopyToClipboard","__","isDismissible","type","className","clsx","children","jsxs","Fragment","ExternalLink","href","__experimentalTruncate","numberOfLines","Button","edit","label","onClick","linkOff","copySmall","sprintf","__experimentalIsFocusable","disabled","ViewerSlot","fillProps"],"sources":["@wordpress/block-editor/src/components/link-control/link-preview.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { __, sprintf } from '@wordpress/i18n';\nimport {\n\tButton,\n\tExternalLink,\n\t__experimentalTruncate as Truncate,\n} from '@wordpress/components';\nimport { useCopyToClipboard } from '@wordpress/compose';\nimport { filterURLForDisplay, safeDecodeURI } from '@wordpress/url';\nimport { Icon, globe, info, linkOff, edit, copySmall } from '@wordpress/icons';\nimport { __unstableStripHTML as stripHTML } from '@wordpress/dom';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { store as noticesStore } from '@wordpress/notices';\nimport { store as preferencesStore } from '@wordpress/preferences';\n\n/**\n * Internal dependencies\n */\nimport { ViewerSlot } from './viewer-slot';\n\nimport useRichUrlData from './use-rich-url-data';\n\n/**\n * Filters the title for display. Removes the protocol and www prefix.\n *\n * @param {string} title The title to be filtered.\n *\n * @return {string} The filtered title.\n */\nfunction filterTitleForDisplay( title ) {\n\t// Derived from `filterURLForDisplay` in `@wordpress/url`.\n\treturn title\n\t\t.replace( /^[a-z\\-.\\+]+[0-9]*:(\\/\\/)?/i, '' )\n\t\t.replace( /^www\\./i, '' );\n}\n\nexport default function LinkPreview( {\n\tvalue,\n\tonEditClick,\n\thasRichPreviews = false,\n\thasUnlinkControl = false,\n\tonRemove,\n} ) {\n\tconst showIconLabels = useSelect(\n\t\t( select ) =>\n\t\t\tselect( preferencesStore ).get( 'core', 'showIconLabels' ),\n\t\t[]\n\t);\n\n\t// Avoid fetching if rich previews are not desired.\n\tconst showRichPreviews = hasRichPreviews ? value?.url : null;\n\n\tconst { richData, isFetching } = useRichUrlData( showRichPreviews );\n\n\t// Rich data may be an empty object so test for that.\n\tconst hasRichData = richData && Object.keys( richData ).length;\n\n\tconst displayURL =\n\t\t( value && filterURLForDisplay( safeDecodeURI( value.url ), 24 ) ) ||\n\t\t'';\n\n\t// url can be undefined if the href attribute is unset\n\tconst isEmptyURL = ! value?.url?.length;\n\n\tconst displayTitle =\n\t\t! isEmptyURL &&\n\t\tstripHTML( richData?.title || value?.title || displayURL );\n\n\tconst isUrlRedundant =\n\t\t! value?.url || filterTitleForDisplay( displayTitle ) === displayURL;\n\n\tlet icon;\n\n\tif ( richData?.icon ) {\n\t\ticon = <img src={ richData?.icon } alt=\"\" />;\n\t} else if ( isEmptyURL ) {\n\t\ticon = <Icon icon={ info } size={ 32 } />;\n\t} else {\n\t\ticon = <Icon icon={ globe } />;\n\t}\n\n\tconst { createNotice } = useDispatch( noticesStore );\n\tconst ref = useCopyToClipboard( value.url, () => {\n\t\tcreateNotice( 'info', __( 'Link copied to clipboard.' ), {\n\t\t\tisDismissible: true,\n\t\t\ttype: 'snackbar',\n\t\t} );\n\t} );\n\n\treturn (\n\t\t<div\n\t\t\taria-label={ __( 'Currently selected' ) }\n\t\t\tclassName={ clsx( 'block-editor-link-control__search-item', {\n\t\t\t\t'is-current': true,\n\t\t\t\t'is-rich': hasRichData,\n\t\t\t\t'is-fetching': !! isFetching,\n\t\t\t\t'is-preview': true,\n\t\t\t\t'is-error': isEmptyURL,\n\t\t\t\t'is-url-title': displayTitle === displayURL,\n\t\t\t} ) }\n\t\t>\n\t\t\t<div className=\"block-editor-link-control__search-item-top\">\n\t\t\t\t<span className=\"block-editor-link-control__search-item-header\">\n\t\t\t\t\t<span\n\t\t\t\t\t\tclassName={ clsx(\n\t\t\t\t\t\t\t'block-editor-link-control__search-item-icon',\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t'is-image': richData?.icon,\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t) }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ icon }\n\t\t\t\t\t</span>\n\t\t\t\t\t<span className=\"block-editor-link-control__search-item-details\">\n\t\t\t\t\t\t{ ! isEmptyURL ? (\n\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t<ExternalLink\n\t\t\t\t\t\t\t\t\tclassName=\"block-editor-link-control__search-item-title\"\n\t\t\t\t\t\t\t\t\thref={ value.url }\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t<Truncate numberOfLines={ 1 }>\n\t\t\t\t\t\t\t\t\t\t{ displayTitle }\n\t\t\t\t\t\t\t\t\t</Truncate>\n\t\t\t\t\t\t\t\t</ExternalLink>\n\t\t\t\t\t\t\t\t{ ! isUrlRedundant && (\n\t\t\t\t\t\t\t\t\t<span className=\"block-editor-link-control__search-item-info\">\n\t\t\t\t\t\t\t\t\t\t<Truncate numberOfLines={ 1 }>\n\t\t\t\t\t\t\t\t\t\t\t{ displayURL }\n\t\t\t\t\t\t\t\t\t\t</Truncate>\n\t\t\t\t\t\t\t\t\t</span>\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-link-control__search-item-error-notice\">\n\t\t\t\t\t\t\t\t{ __( 'Link is empty' ) }\n\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t) }\n\t\t\t\t\t</span>\n\t\t\t\t</span>\n\t\t\t\t<Button\n\t\t\t\t\ticon={ edit }\n\t\t\t\t\tlabel={ __( 'Edit link' ) }\n\t\t\t\t\tonClick={ onEditClick }\n\t\t\t\t\tsize=\"compact\"\n\t\t\t\t/>\n\t\t\t\t{ hasUnlinkControl && (\n\t\t\t\t\t<Button\n\t\t\t\t\t\ticon={ linkOff }\n\t\t\t\t\t\tlabel={ __( 'Remove link' ) }\n\t\t\t\t\t\tonClick={ onRemove }\n\t\t\t\t\t\tsize=\"compact\"\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t\t<Button\n\t\t\t\t\ticon={ copySmall }\n\t\t\t\t\tlabel={ sprintf(\n\t\t\t\t\t\t// Translators: %s is a placeholder for the link URL and an optional colon, (if a Link URL is present).\n\t\t\t\t\t\t__( 'Copy link%s' ), // Ends up looking like \"Copy link: https://example.com\".\n\t\t\t\t\t\tisEmptyURL || showIconLabels ? '' : ': ' + value.url\n\t\t\t\t\t) }\n\t\t\t\t\tref={ ref }\n\t\t\t\t\t__experimentalIsFocusable\n\t\t\t\t\tdisabled={ isEmptyURL }\n\t\t\t\t\tsize=\"compact\"\n\t\t\t\t/>\n\t\t\t\t<ViewerSlot fillProps={ value } />\n\t\t\t</div>\n\t\t</div>\n\t);\n}\n"],"mappings":";;;;;;;AAGA,IAAAA,KAAA,GAAAC,sBAAA,CAAAC,OAAA;AAKA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,WAA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","_components","_compose","_url","_icons","_dom","_data","_notices","_preferences","_viewerSlot","_useRichUrlData","_jsxRuntime","filterTitleForDisplay","title","replace","LinkPreview","value","onEditClick","hasRichPreviews","hasUnlinkControl","onRemove","showIconLabels","useSelect","select","preferencesStore","get","showRichPreviews","url","richData","isFetching","useRichUrlData","hasRichData","Object","keys","length","displayURL","filterURLForDisplay","safeDecodeURI","isEmptyURL","displayTitle","stripHTML","isUrlRedundant","icon","jsx","src","alt","Icon","info","size","globe","createNotice","useDispatch","noticesStore","ref","useCopyToClipboard","__","isDismissible","type","className","clsx","children","jsxs","Fragment","ExternalLink","href","__experimentalTruncate","numberOfLines","Button","edit","label","onClick","linkOff","copySmall","sprintf","accessibleWhenDisabled","disabled","ViewerSlot","fillProps"],"sources":["@wordpress/block-editor/src/components/link-control/link-preview.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { __, sprintf } from '@wordpress/i18n';\nimport {\n\tButton,\n\tExternalLink,\n\t__experimentalTruncate as Truncate,\n} from '@wordpress/components';\nimport { useCopyToClipboard } from '@wordpress/compose';\nimport { filterURLForDisplay, safeDecodeURI } from '@wordpress/url';\nimport { Icon, globe, info, linkOff, edit, copySmall } from '@wordpress/icons';\nimport { __unstableStripHTML as stripHTML } from '@wordpress/dom';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { store as noticesStore } from '@wordpress/notices';\nimport { store as preferencesStore } from '@wordpress/preferences';\n\n/**\n * Internal dependencies\n */\nimport { ViewerSlot } from './viewer-slot';\n\nimport useRichUrlData from './use-rich-url-data';\n\n/**\n * Filters the title for display. Removes the protocol and www prefix.\n *\n * @param {string} title The title to be filtered.\n *\n * @return {string} The filtered title.\n */\nfunction filterTitleForDisplay( title ) {\n\t// Derived from `filterURLForDisplay` in `@wordpress/url`.\n\treturn title\n\t\t.replace( /^[a-z\\-.\\+]+[0-9]*:(\\/\\/)?/i, '' )\n\t\t.replace( /^www\\./i, '' );\n}\n\nexport default function LinkPreview( {\n\tvalue,\n\tonEditClick,\n\thasRichPreviews = false,\n\thasUnlinkControl = false,\n\tonRemove,\n} ) {\n\tconst showIconLabels = useSelect(\n\t\t( select ) =>\n\t\t\tselect( preferencesStore ).get( 'core', 'showIconLabels' ),\n\t\t[]\n\t);\n\n\t// Avoid fetching if rich previews are not desired.\n\tconst showRichPreviews = hasRichPreviews ? value?.url : null;\n\n\tconst { richData, isFetching } = useRichUrlData( showRichPreviews );\n\n\t// Rich data may be an empty object so test for that.\n\tconst hasRichData = richData && Object.keys( richData ).length;\n\n\tconst displayURL =\n\t\t( value && filterURLForDisplay( safeDecodeURI( value.url ), 24 ) ) ||\n\t\t'';\n\n\t// url can be undefined if the href attribute is unset\n\tconst isEmptyURL = ! value?.url?.length;\n\n\tconst displayTitle =\n\t\t! isEmptyURL &&\n\t\tstripHTML( richData?.title || value?.title || displayURL );\n\n\tconst isUrlRedundant =\n\t\t! value?.url || filterTitleForDisplay( displayTitle ) === displayURL;\n\n\tlet icon;\n\n\tif ( richData?.icon ) {\n\t\ticon = <img src={ richData?.icon } alt=\"\" />;\n\t} else if ( isEmptyURL ) {\n\t\ticon = <Icon icon={ info } size={ 32 } />;\n\t} else {\n\t\ticon = <Icon icon={ globe } />;\n\t}\n\n\tconst { createNotice } = useDispatch( noticesStore );\n\tconst ref = useCopyToClipboard( value.url, () => {\n\t\tcreateNotice( 'info', __( 'Link copied to clipboard.' ), {\n\t\t\tisDismissible: true,\n\t\t\ttype: 'snackbar',\n\t\t} );\n\t} );\n\n\treturn (\n\t\t<div\n\t\t\taria-label={ __( 'Currently selected' ) }\n\t\t\tclassName={ clsx( 'block-editor-link-control__search-item', {\n\t\t\t\t'is-current': true,\n\t\t\t\t'is-rich': hasRichData,\n\t\t\t\t'is-fetching': !! isFetching,\n\t\t\t\t'is-preview': true,\n\t\t\t\t'is-error': isEmptyURL,\n\t\t\t\t'is-url-title': displayTitle === displayURL,\n\t\t\t} ) }\n\t\t>\n\t\t\t<div className=\"block-editor-link-control__search-item-top\">\n\t\t\t\t<span className=\"block-editor-link-control__search-item-header\">\n\t\t\t\t\t<span\n\t\t\t\t\t\tclassName={ clsx(\n\t\t\t\t\t\t\t'block-editor-link-control__search-item-icon',\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t'is-image': richData?.icon,\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t) }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ icon }\n\t\t\t\t\t</span>\n\t\t\t\t\t<span className=\"block-editor-link-control__search-item-details\">\n\t\t\t\t\t\t{ ! isEmptyURL ? (\n\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t<ExternalLink\n\t\t\t\t\t\t\t\t\tclassName=\"block-editor-link-control__search-item-title\"\n\t\t\t\t\t\t\t\t\thref={ value.url }\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t<Truncate numberOfLines={ 1 }>\n\t\t\t\t\t\t\t\t\t\t{ displayTitle }\n\t\t\t\t\t\t\t\t\t</Truncate>\n\t\t\t\t\t\t\t\t</ExternalLink>\n\t\t\t\t\t\t\t\t{ ! isUrlRedundant && (\n\t\t\t\t\t\t\t\t\t<span className=\"block-editor-link-control__search-item-info\">\n\t\t\t\t\t\t\t\t\t\t<Truncate numberOfLines={ 1 }>\n\t\t\t\t\t\t\t\t\t\t\t{ displayURL }\n\t\t\t\t\t\t\t\t\t\t</Truncate>\n\t\t\t\t\t\t\t\t\t</span>\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-link-control__search-item-error-notice\">\n\t\t\t\t\t\t\t\t{ __( 'Link is empty' ) }\n\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t) }\n\t\t\t\t\t</span>\n\t\t\t\t</span>\n\t\t\t\t<Button\n\t\t\t\t\ticon={ edit }\n\t\t\t\t\tlabel={ __( 'Edit link' ) }\n\t\t\t\t\tonClick={ onEditClick }\n\t\t\t\t\tsize=\"compact\"\n\t\t\t\t/>\n\t\t\t\t{ hasUnlinkControl && (\n\t\t\t\t\t<Button\n\t\t\t\t\t\ticon={ linkOff }\n\t\t\t\t\t\tlabel={ __( 'Remove link' ) }\n\t\t\t\t\t\tonClick={ onRemove }\n\t\t\t\t\t\tsize=\"compact\"\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t\t<Button\n\t\t\t\t\ticon={ copySmall }\n\t\t\t\t\tlabel={ sprintf(\n\t\t\t\t\t\t// Translators: %s is a placeholder for the link URL and an optional colon, (if a Link URL is present).\n\t\t\t\t\t\t__( 'Copy link%s' ), // Ends up looking like \"Copy link: https://example.com\".\n\t\t\t\t\t\tisEmptyURL || showIconLabels ? '' : ': ' + value.url\n\t\t\t\t\t) }\n\t\t\t\t\tref={ ref }\n\t\t\t\t\taccessibleWhenDisabled\n\t\t\t\t\tdisabled={ isEmptyURL }\n\t\t\t\t\tsize=\"compact\"\n\t\t\t\t/>\n\t\t\t\t<ViewerSlot fillProps={ value } />\n\t\t\t</div>\n\t\t</div>\n\t);\n}\n"],"mappings":";;;;;;;AAGA,IAAAA,KAAA,GAAAC,sBAAA,CAAAC,OAAA;AAKA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,WAAA,GAAAF,OAAA;AAKA,IAAAG,QAAA,GAAAH,OAAA;AACA,IAAAI,IAAA,GAAAJ,OAAA;AACA,IAAAK,MAAA,GAAAL,OAAA;AACA,IAAAM,IAAA,GAAAN,OAAA;AACA,IAAAO,KAAA,GAAAP,OAAA;AACA,IAAAQ,QAAA,GAAAR,OAAA;AACA,IAAAS,YAAA,GAAAT,OAAA;AAKA,IAAAU,WAAA,GAAAV,OAAA;AAEA,IAAAW,eAAA,GAAAZ,sBAAA,CAAAC,OAAA;AAAiD,IAAAY,WAAA,GAAAZ,OAAA;AA3BjD;AACA;AACA;;AAGA;AACA;AACA;;AAeA;AACA;AACA;;AAKA;AACA;AAC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+B,IAAI,EAAC;MAAS,CACd,CAAC,EACA7B,gBAAgB,iBACjB,IAAAR,WAAA,CAAAgC,GAAA,EAAC1C,WAAA,CAAAkE,MAAM;QACNzB,IAAI,EAAG6B,cAAS;QAChBF,KAAK,EAAG,IAAAd,QAAE,EAAE,aAAc,CAAG;QAC7Be,OAAO,EAAGlD,QAAU;QACpB4B,IAAI,EAAC;MAAS,CACd,CACD,eACD,IAAArC,WAAA,CAAAgC,GAAA,EAAC1C,WAAA,CAAAkE,MAAM;QACNzB,IAAI,EAAG8B,gBAAW;QAClBH,KAAK,EAAG,IAAAI,aAAO;QACd;QACA,IAAAlB,QAAE,EAAE,aAAc,CAAC;QAAE;QACrBjB,UAAU,IAAIjB,cAAc,GAAG,EAAE,GAAG,IAAI,GAAGL,KAAK,CAACW,GAClD,CAAG;QACH0B,GAAG,EAAGA,GAAK;QACXqB,sBAAsB;QACtBC,QAAQ,EAAGrC,UAAY;QACvBU,IAAI,EAAC;MAAS,CACd,CAAC,eACF,IAAArC,WAAA,CAAAgC,GAAA,EAAClC,WAAA,CAAAmE,UAAU;QAACC,SAAS,EAAG7D;MAAO,CAAE,CAAC;IAAA,CAC9B;EAAC,CACF,CAAC;AAER","ignoreList":[]}
|
|
@@ -60,24 +60,37 @@ const InsertFromURLPopover = ({
|
|
|
60
60
|
})
|
|
61
61
|
});
|
|
62
62
|
const URLSelectionUI = ({
|
|
63
|
-
isURLInputVisible,
|
|
64
63
|
src,
|
|
65
64
|
onChangeSrc,
|
|
66
|
-
|
|
67
|
-
openURLInput,
|
|
68
|
-
closeURLInput
|
|
65
|
+
onSelectURL
|
|
69
66
|
}) => {
|
|
70
67
|
// Use internal state instead of a ref to make sure that the component
|
|
71
68
|
// re-renders when the popover's anchor updates.
|
|
72
69
|
const [popoverAnchor, setPopoverAnchor] = (0, _element.useState)(null);
|
|
70
|
+
const [isURLInputVisible, setIsURLInputVisible] = (0, _element.useState)(false);
|
|
71
|
+
const openURLInput = () => {
|
|
72
|
+
setIsURLInputVisible(true);
|
|
73
|
+
};
|
|
74
|
+
const closeURLInput = () => {
|
|
75
|
+
setIsURLInputVisible(false);
|
|
76
|
+
popoverAnchor?.focus();
|
|
77
|
+
};
|
|
78
|
+
const onSubmitSrc = event => {
|
|
79
|
+
event.preventDefault();
|
|
80
|
+
if (src && onSelectURL) {
|
|
81
|
+
onSelectURL(src);
|
|
82
|
+
closeURLInput();
|
|
83
|
+
}
|
|
84
|
+
};
|
|
73
85
|
return /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
74
86
|
className: "block-editor-media-placeholder__url-input-container",
|
|
75
|
-
ref: setPopoverAnchor,
|
|
76
87
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Button, {
|
|
77
88
|
className: "block-editor-media-placeholder__button",
|
|
78
89
|
onClick: openURLInput,
|
|
79
90
|
isPressed: isURLInputVisible,
|
|
80
91
|
variant: "secondary",
|
|
92
|
+
"aria-haspopup": "dialog",
|
|
93
|
+
ref: setPopoverAnchor,
|
|
81
94
|
children: (0, _i18n.__)('Insert from URL')
|
|
82
95
|
}), isURLInputVisible && /*#__PURE__*/(0, _jsxRuntime.jsx)(InsertFromURLPopover, {
|
|
83
96
|
src: src,
|
|
@@ -129,7 +142,6 @@ function MediaPlaceholder({
|
|
|
129
142
|
return getSettings().mediaUpload;
|
|
130
143
|
}, []);
|
|
131
144
|
const [src, setSrc] = (0, _element.useState)('');
|
|
132
|
-
const [isURLInputVisible, setIsURLInputVisible] = (0, _element.useState)(false);
|
|
133
145
|
(0, _element.useEffect)(() => {
|
|
134
146
|
var _value$src;
|
|
135
147
|
setSrc((_value$src = value?.src) !== null && _value$src !== void 0 ? _value$src : '');
|
|
@@ -143,19 +155,6 @@ function MediaPlaceholder({
|
|
|
143
155
|
const onChangeSrc = event => {
|
|
144
156
|
setSrc(event.target.value);
|
|
145
157
|
};
|
|
146
|
-
const openURLInput = () => {
|
|
147
|
-
setIsURLInputVisible(true);
|
|
148
|
-
};
|
|
149
|
-
const closeURLInput = () => {
|
|
150
|
-
setIsURLInputVisible(false);
|
|
151
|
-
};
|
|
152
|
-
const onSubmitSrc = event => {
|
|
153
|
-
event.preventDefault();
|
|
154
|
-
if (src && onSelectURL) {
|
|
155
|
-
onSelectURL(src);
|
|
156
|
-
closeURLInput();
|
|
157
|
-
}
|
|
158
|
-
};
|
|
159
158
|
const onFilesUpload = files => {
|
|
160
159
|
if (!handleUpload) {
|
|
161
160
|
return onSelect(files);
|
|
@@ -330,12 +329,9 @@ function MediaPlaceholder({
|
|
|
330
329
|
};
|
|
331
330
|
const renderUrlSelectionUI = () => {
|
|
332
331
|
return onSelectURL && /*#__PURE__*/(0, _jsxRuntime.jsx)(URLSelectionUI, {
|
|
333
|
-
isURLInputVisible: isURLInputVisible,
|
|
334
332
|
src: src,
|
|
335
333
|
onChangeSrc: onChangeSrc,
|
|
336
|
-
|
|
337
|
-
openURLInput: openURLInput,
|
|
338
|
-
closeURLInput: closeURLInput
|
|
334
|
+
onSelectURL: onSelectURL
|
|
339
335
|
});
|
|
340
336
|
};
|
|
341
337
|
const renderFeaturedImageToggle = () => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_clsx","_interopRequireDefault","require","_components","_i18n","_element","_data","_icons","_blocks2","_deprecated","_mediaUpload","_check","_urlPopover","_store","_jsxRuntime","noop","InsertFromURLPopover","src","onChange","onSubmit","onClose","popoverAnchor","jsx","default","anchor","children","jsxs","className","type","__","placeholder","value","Button","icon","keyboardReturn","label","URLSelectionUI","isURLInputVisible","onChangeSrc","onSubmitSrc","openURLInput","closeURLInput","setPopoverAnchor","useState","ref","onClick","isPressed","variant","MediaPlaceholder","allowedTypes","labels","mediaPreview","notices","isAppender","accept","addToGallery","multiple","handleUpload","disableDropZone","disableMediaButtons","onError","onSelect","onCancel","onSelectURL","onToggleFeaturedImage","onDoubleClick","onFilesPreUpload","onHTMLDrop","deprecatedOnHTMLDrop","mediaLibraryButton","style","deprecated","since","version","mediaUpload","useSelect","select","getSettings","blockEditorStore","setSrc","setIsURLInputVisible","useEffect","_value$src","onlyAllowsImages","length","every","allowedType","startsWith","event","target","preventDefault","onFilesUpload","files","setMedia","lastMediaPassed","newMedia","filteredMedia","filter","item","id","some","Number","urlSlug","url","includes","concat","map","media","cutOffIndex","lastIndexOf","slice","filesList","onFileChange","handleBlocksDrop","blocks","Array","isArray","recursivelyFindMediaFromBlocks","_blocks","flatMap","block","name","attributes","innerBlocks","mediaBlocks","uploadedMediaList","Promise","all","resolve","reject","window","fetch","then","response","blob","additionalData","title","alt_text","alt","caption","catch","err","HTML","pasteHandler","onUpload","defaultRenderPlaceholder","content","instructions","undefined","typesAllowed","firstAllowedType","isOneType","isAudio","isImage","isVideo","placeholderClassName","clsx","Placeholder","preview","renderPlaceholder","renderDropZone","DropZone","onFilesDrop","renderCancelLink","renderUrlSelectionUI","renderFeaturedImageToggle","renderMediaUploadChecked","defaultButton","open","libraryButton","uploadMediaLibraryButton","gallery","mode","render","Fragment","FormFileUpload","openFileDialog","fallback","_default","exports","withFilters"],"sources":["@wordpress/block-editor/src/components/media-placeholder/index.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tButton,\n\tFormFileUpload,\n\tPlaceholder,\n\tDropZone,\n\twithFilters,\n} from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { useState, useEffect } from '@wordpress/element';\nimport { useSelect } from '@wordpress/data';\nimport { keyboardReturn } from '@wordpress/icons';\nimport { pasteHandler } from '@wordpress/blocks';\nimport deprecated from '@wordpress/deprecated';\n\n/**\n * Internal dependencies\n */\nimport MediaUpload from '../media-upload';\nimport MediaUploadCheck from '../media-upload/check';\nimport URLPopover from '../url-popover';\nimport { store as blockEditorStore } from '../../store';\n\nconst noop = () => {};\n\nconst InsertFromURLPopover = ( {\n\tsrc,\n\tonChange,\n\tonSubmit,\n\tonClose,\n\tpopoverAnchor,\n} ) => (\n\t<URLPopover anchor={ popoverAnchor } onClose={ onClose }>\n\t\t<form\n\t\t\tclassName=\"block-editor-media-placeholder__url-input-form\"\n\t\t\tonSubmit={ onSubmit }\n\t\t>\n\t\t\t<input\n\t\t\t\tclassName=\"block-editor-media-placeholder__url-input-field\"\n\t\t\t\ttype=\"text\"\n\t\t\t\taria-label={ __( 'URL' ) }\n\t\t\t\tplaceholder={ __( 'Paste or type URL' ) }\n\t\t\t\tonChange={ onChange }\n\t\t\t\tvalue={ src }\n\t\t\t/>\n\t\t\t<Button\n\t\t\t\tclassName=\"block-editor-media-placeholder__url-input-submit-button\"\n\t\t\t\ticon={ keyboardReturn }\n\t\t\t\tlabel={ __( 'Apply' ) }\n\t\t\t\ttype=\"submit\"\n\t\t\t/>\n\t\t</form>\n\t</URLPopover>\n);\n\nconst URLSelectionUI = ( {\n\tisURLInputVisible,\n\tsrc,\n\tonChangeSrc,\n\tonSubmitSrc,\n\topenURLInput,\n\tcloseURLInput,\n} ) => {\n\t// Use internal state instead of a ref to make sure that the component\n\t// re-renders when the popover's anchor updates.\n\tconst [ popoverAnchor, setPopoverAnchor ] = useState( null );\n\n\treturn (\n\t\t<div\n\t\t\tclassName=\"block-editor-media-placeholder__url-input-container\"\n\t\t\tref={ setPopoverAnchor }\n\t\t>\n\t\t\t<Button\n\t\t\t\tclassName=\"block-editor-media-placeholder__button\"\n\t\t\t\tonClick={ openURLInput }\n\t\t\t\tisPressed={ isURLInputVisible }\n\t\t\t\tvariant=\"secondary\"\n\t\t\t>\n\t\t\t\t{ __( 'Insert from URL' ) }\n\t\t\t</Button>\n\t\t\t{ isURLInputVisible && (\n\t\t\t\t<InsertFromURLPopover\n\t\t\t\t\tsrc={ src }\n\t\t\t\t\tonChange={ onChangeSrc }\n\t\t\t\t\tonSubmit={ onSubmitSrc }\n\t\t\t\t\tonClose={ closeURLInput }\n\t\t\t\t\tpopoverAnchor={ popoverAnchor }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</div>\n\t);\n};\n\nexport function MediaPlaceholder( {\n\tvalue = {},\n\tallowedTypes,\n\tclassName,\n\ticon,\n\tlabels = {},\n\tmediaPreview,\n\tnotices,\n\tisAppender,\n\taccept,\n\taddToGallery,\n\tmultiple = false,\n\thandleUpload = true,\n\tdisableDropZone,\n\tdisableMediaButtons,\n\tonError,\n\tonSelect,\n\tonCancel,\n\tonSelectURL,\n\tonToggleFeaturedImage,\n\tonDoubleClick,\n\tonFilesPreUpload = noop,\n\tonHTMLDrop: deprecatedOnHTMLDrop,\n\tchildren,\n\tmediaLibraryButton,\n\tplaceholder,\n\tstyle,\n} ) {\n\tif ( deprecatedOnHTMLDrop ) {\n\t\tdeprecated( 'wp.blockEditor.MediaPlaceholder onHTMLDrop prop', {\n\t\t\tsince: '6.2',\n\t\t\tversion: '6.4',\n\t\t} );\n\t}\n\n\tconst mediaUpload = useSelect( ( select ) => {\n\t\tconst { getSettings } = select( blockEditorStore );\n\t\treturn getSettings().mediaUpload;\n\t}, [] );\n\tconst [ src, setSrc ] = useState( '' );\n\tconst [ isURLInputVisible, setIsURLInputVisible ] = useState( false );\n\n\tuseEffect( () => {\n\t\tsetSrc( value?.src ?? '' );\n\t}, [ value?.src ] );\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 onChangeSrc = ( event ) => {\n\t\tsetSrc( event.target.value );\n\t};\n\n\tconst openURLInput = () => {\n\t\tsetIsURLInputVisible( true );\n\t};\n\tconst closeURLInput = () => {\n\t\tsetIsURLInputVisible( false );\n\t};\n\n\tconst onSubmitSrc = ( event ) => {\n\t\tevent.preventDefault();\n\t\tif ( src && onSelectURL ) {\n\t\t\tonSelectURL( src );\n\t\t\tcloseURLInput();\n\t\t}\n\t};\n\n\tconst onFilesUpload = ( files ) => {\n\t\tif ( ! handleUpload ) {\n\t\t\treturn onSelect( files );\n\t\t}\n\t\tonFilesPreUpload( files );\n\t\tlet setMedia;\n\t\tif ( multiple ) {\n\t\t\tif ( addToGallery ) {\n\t\t\t\t// Since the setMedia function runs multiple times per upload group\n\t\t\t\t// and is passed newMedia containing every item in its group each time, we must\n\t\t\t\t// filter out whatever this upload group had previously returned to the\n\t\t\t\t// gallery before adding and returning the image array with replacement newMedia\n\t\t\t\t// values.\n\n\t\t\t\t// Define an array to store urls from newMedia between subsequent function calls.\n\t\t\t\tlet lastMediaPassed = [];\n\t\t\t\tsetMedia = ( newMedia ) => {\n\t\t\t\t\t// Remove any images this upload group is responsible for (lastMediaPassed).\n\t\t\t\t\t// Their replacements are contained in newMedia.\n\t\t\t\t\tconst filteredMedia = ( value ?? [] ).filter( ( item ) => {\n\t\t\t\t\t\t// If Item has id, only remove it if lastMediaPassed has an item with that id.\n\t\t\t\t\t\tif ( item.id ) {\n\t\t\t\t\t\t\treturn ! lastMediaPassed.some(\n\t\t\t\t\t\t\t\t// Be sure to convert to number for comparison.\n\t\t\t\t\t\t\t\t( { id } ) => Number( id ) === Number( item.id )\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t\t// Compare transient images via .includes since gallery may append extra info onto the url.\n\t\t\t\t\t\treturn ! lastMediaPassed.some( ( { urlSlug } ) =>\n\t\t\t\t\t\t\titem.url.includes( urlSlug )\n\t\t\t\t\t\t);\n\t\t\t\t\t} );\n\t\t\t\t\t// Return the filtered media array along with newMedia.\n\t\t\t\t\tonSelect( filteredMedia.concat( newMedia ) );\n\t\t\t\t\t// Reset lastMediaPassed and set it with ids and urls from newMedia.\n\t\t\t\t\tlastMediaPassed = newMedia.map( ( media ) => {\n\t\t\t\t\t\t// Add everything up to '.fileType' to compare via .includes.\n\t\t\t\t\t\tconst cutOffIndex = media.url.lastIndexOf( '.' );\n\t\t\t\t\t\tconst urlSlug = media.url.slice( 0, cutOffIndex );\n\t\t\t\t\t\treturn { id: media.id, urlSlug };\n\t\t\t\t\t} );\n\t\t\t\t};\n\t\t\t} else {\n\t\t\t\tsetMedia = onSelect;\n\t\t\t}\n\t\t} else {\n\t\t\tsetMedia = ( [ media ] ) => onSelect( media );\n\t\t}\n\t\tmediaUpload( {\n\t\t\tallowedTypes,\n\t\t\tfilesList: files,\n\t\t\tonFileChange: setMedia,\n\t\t\tonError,\n\t\t} );\n\t};\n\n\tasync function handleBlocksDrop( blocks ) {\n\t\tif ( ! blocks || ! Array.isArray( blocks ) ) {\n\t\t\treturn;\n\t\t}\n\n\t\tfunction recursivelyFindMediaFromBlocks( _blocks ) {\n\t\t\treturn _blocks.flatMap( ( block ) =>\n\t\t\t\t( block.name === 'core/image' ||\n\t\t\t\t\tblock.name === 'core/audio' ||\n\t\t\t\t\tblock.name === 'core/video' ) &&\n\t\t\t\tblock.attributes.url\n\t\t\t\t\t? [ block ]\n\t\t\t\t\t: recursivelyFindMediaFromBlocks( block.innerBlocks )\n\t\t\t);\n\t\t}\n\n\t\tconst mediaBlocks = recursivelyFindMediaFromBlocks( blocks );\n\n\t\tif ( ! mediaBlocks.length ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst uploadedMediaList = await Promise.all(\n\t\t\tmediaBlocks.map( ( block ) =>\n\t\t\t\tblock.attributes.id\n\t\t\t\t\t? block.attributes\n\t\t\t\t\t: new Promise( ( resolve, reject ) => {\n\t\t\t\t\t\t\twindow\n\t\t\t\t\t\t\t\t.fetch( block.attributes.url )\n\t\t\t\t\t\t\t\t.then( ( response ) => response.blob() )\n\t\t\t\t\t\t\t\t.then( ( blob ) =>\n\t\t\t\t\t\t\t\t\tmediaUpload( {\n\t\t\t\t\t\t\t\t\t\tfilesList: [ blob ],\n\t\t\t\t\t\t\t\t\t\tadditionalData: {\n\t\t\t\t\t\t\t\t\t\t\ttitle: block.attributes.title,\n\t\t\t\t\t\t\t\t\t\t\talt_text: block.attributes.alt,\n\t\t\t\t\t\t\t\t\t\t\tcaption: block.attributes.caption,\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\tonFileChange: ( [ media ] ) => {\n\t\t\t\t\t\t\t\t\t\t\tif ( media.id ) {\n\t\t\t\t\t\t\t\t\t\t\t\tresolve( media );\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\tallowedTypes,\n\t\t\t\t\t\t\t\t\t\tonError: reject,\n\t\t\t\t\t\t\t\t\t} )\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t.catch( () => resolve( block.attributes.url ) );\n\t\t\t\t\t } )\n\t\t\t)\n\t\t).catch( ( err ) => onError( err ) );\n\n\t\tif ( multiple ) {\n\t\t\tonSelect( uploadedMediaList );\n\t\t} else {\n\t\t\tonSelect( uploadedMediaList[ 0 ] );\n\t\t}\n\t}\n\n\tasync function onHTMLDrop( HTML ) {\n\t\tconst blocks = pasteHandler( { HTML } );\n\t\treturn await handleBlocksDrop( blocks );\n\t}\n\n\tconst onUpload = ( event ) => {\n\t\tonFilesUpload( event.target.files );\n\t};\n\n\tconst defaultRenderPlaceholder = ( content ) => {\n\t\tlet { instructions, title } = labels;\n\n\t\tif ( ! mediaUpload && ! onSelectURL ) {\n\t\t\tinstructions = __(\n\t\t\t\t'To edit this block, you need permission to upload media.'\n\t\t\t);\n\t\t}\n\n\t\tif ( instructions === undefined || title === undefined ) {\n\t\t\tconst typesAllowed = allowedTypes ?? [];\n\n\t\t\tconst [ firstAllowedType ] = typesAllowed;\n\t\t\tconst isOneType = 1 === typesAllowed.length;\n\t\t\tconst isAudio = isOneType && 'audio' === firstAllowedType;\n\t\t\tconst isImage = isOneType && 'image' === firstAllowedType;\n\t\t\tconst isVideo = isOneType && 'video' === firstAllowedType;\n\n\t\t\tif ( instructions === undefined && mediaUpload ) {\n\t\t\t\tinstructions = __(\n\t\t\t\t\t'Upload a media file or pick one from your media library.'\n\t\t\t\t);\n\n\t\t\t\tif ( isAudio ) {\n\t\t\t\t\tinstructions = __(\n\t\t\t\t\t\t'Upload an audio file, pick one from your media library, or add one with a URL.'\n\t\t\t\t\t);\n\t\t\t\t} else if ( isImage ) {\n\t\t\t\t\tinstructions = __(\n\t\t\t\t\t\t'Upload an image file, pick one from your media library, or add one with a URL.'\n\t\t\t\t\t);\n\t\t\t\t} else if ( isVideo ) {\n\t\t\t\t\tinstructions = __(\n\t\t\t\t\t\t'Upload a video file, pick one from your media library, or add one with a URL.'\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif ( title === undefined ) {\n\t\t\t\ttitle = __( 'Media' );\n\n\t\t\t\tif ( isAudio ) {\n\t\t\t\t\ttitle = __( 'Audio' );\n\t\t\t\t} else if ( isImage ) {\n\t\t\t\t\ttitle = __( 'Image' );\n\t\t\t\t} else if ( isVideo ) {\n\t\t\t\t\ttitle = __( 'Video' );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tconst placeholderClassName = clsx(\n\t\t\t'block-editor-media-placeholder',\n\t\t\tclassName,\n\t\t\t{\n\t\t\t\t'is-appender': isAppender,\n\t\t\t}\n\t\t);\n\n\t\treturn (\n\t\t\t<Placeholder\n\t\t\t\ticon={ icon }\n\t\t\t\tlabel={ title }\n\t\t\t\tinstructions={ instructions }\n\t\t\t\tclassName={ placeholderClassName }\n\t\t\t\tnotices={ notices }\n\t\t\t\tonDoubleClick={ onDoubleClick }\n\t\t\t\tpreview={ mediaPreview }\n\t\t\t\tstyle={ style }\n\t\t\t>\n\t\t\t\t{ content }\n\t\t\t\t{ children }\n\t\t\t</Placeholder>\n\t\t);\n\t};\n\tconst renderPlaceholder = placeholder ?? defaultRenderPlaceholder;\n\n\tconst renderDropZone = () => {\n\t\tif ( disableDropZone ) {\n\t\t\treturn null;\n\t\t}\n\n\t\treturn (\n\t\t\t<DropZone onFilesDrop={ onFilesUpload } onHTMLDrop={ onHTMLDrop } />\n\t\t);\n\t};\n\n\tconst renderCancelLink = () => {\n\t\treturn (\n\t\t\tonCancel && (\n\t\t\t\t<Button\n\t\t\t\t\tclassName=\"block-editor-media-placeholder__cancel-button\"\n\t\t\t\t\ttitle={ __( 'Cancel' ) }\n\t\t\t\t\tvariant=\"link\"\n\t\t\t\t\tonClick={ onCancel }\n\t\t\t\t>\n\t\t\t\t\t{ __( 'Cancel' ) }\n\t\t\t\t</Button>\n\t\t\t)\n\t\t);\n\t};\n\n\tconst renderUrlSelectionUI = () => {\n\t\treturn (\n\t\t\tonSelectURL && (\n\t\t\t\t<URLSelectionUI\n\t\t\t\t\tisURLInputVisible={ isURLInputVisible }\n\t\t\t\t\tsrc={ src }\n\t\t\t\t\tonChangeSrc={ onChangeSrc }\n\t\t\t\t\tonSubmitSrc={ onSubmitSrc }\n\t\t\t\t\topenURLInput={ openURLInput }\n\t\t\t\t\tcloseURLInput={ closeURLInput }\n\t\t\t\t/>\n\t\t\t)\n\t\t);\n\t};\n\n\tconst renderFeaturedImageToggle = () => {\n\t\treturn (\n\t\t\tonToggleFeaturedImage && (\n\t\t\t\t<div className=\"block-editor-media-placeholder__url-input-container\">\n\t\t\t\t\t<Button\n\t\t\t\t\t\tclassName=\"block-editor-media-placeholder__button\"\n\t\t\t\t\t\tonClick={ onToggleFeaturedImage }\n\t\t\t\t\t\tvariant=\"secondary\"\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Use featured image' ) }\n\t\t\t\t\t</Button>\n\t\t\t\t</div>\n\t\t\t)\n\t\t);\n\t};\n\n\tconst renderMediaUploadChecked = () => {\n\t\tconst defaultButton = ( { open } ) => {\n\t\t\treturn (\n\t\t\t\t<Button\n\t\t\t\t\tvariant=\"secondary\"\n\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\topen();\n\t\t\t\t\t} }\n\t\t\t\t>\n\t\t\t\t\t{ __( 'Media Library' ) }\n\t\t\t\t</Button>\n\t\t\t);\n\t\t};\n\t\tconst libraryButton = mediaLibraryButton ?? defaultButton;\n\t\tconst uploadMediaLibraryButton = (\n\t\t\t<MediaUpload\n\t\t\t\taddToGallery={ addToGallery }\n\t\t\t\tgallery={ multiple && onlyAllowsImages() }\n\t\t\t\tmultiple={ multiple }\n\t\t\t\tonSelect={ onSelect }\n\t\t\t\tallowedTypes={ allowedTypes }\n\t\t\t\tmode=\"browse\"\n\t\t\t\tvalue={\n\t\t\t\t\tArray.isArray( value )\n\t\t\t\t\t\t? value.map( ( { id } ) => id )\n\t\t\t\t\t\t: value.id\n\t\t\t\t}\n\t\t\t\trender={ libraryButton }\n\t\t\t/>\n\t\t);\n\n\t\tif ( mediaUpload && isAppender ) {\n\t\t\treturn (\n\t\t\t\t<>\n\t\t\t\t\t{ renderDropZone() }\n\t\t\t\t\t<FormFileUpload\n\t\t\t\t\t\tonChange={ onUpload }\n\t\t\t\t\t\taccept={ accept }\n\t\t\t\t\t\tmultiple={ !! multiple }\n\t\t\t\t\t\trender={ ( { openFileDialog } ) => {\n\t\t\t\t\t\t\tconst content = (\n\t\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\t\t\t\t\t\tclassName={ clsx(\n\t\t\t\t\t\t\t\t\t\t\t'block-editor-media-placeholder__button',\n\t\t\t\t\t\t\t\t\t\t\t'block-editor-media-placeholder__upload-button'\n\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t\tonClick={ openFileDialog }\n\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t{ __( 'Upload' ) }\n\t\t\t\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t\t\t\t{ uploadMediaLibraryButton }\n\t\t\t\t\t\t\t\t\t{ renderUrlSelectionUI() }\n\t\t\t\t\t\t\t\t\t{ renderFeaturedImageToggle() }\n\t\t\t\t\t\t\t\t\t{ renderCancelLink() }\n\t\t\t\t\t\t\t\t</>\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\treturn renderPlaceholder( content );\n\t\t\t\t\t\t} }\n\t\t\t\t\t/>\n\t\t\t\t</>\n\t\t\t);\n\t\t}\n\n\t\tif ( mediaUpload ) {\n\t\t\tconst content = (\n\t\t\t\t<>\n\t\t\t\t\t{ renderDropZone() }\n\t\t\t\t\t<FormFileUpload\n\t\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\t\tclassName={ clsx(\n\t\t\t\t\t\t\t'block-editor-media-placeholder__button',\n\t\t\t\t\t\t\t'block-editor-media-placeholder__upload-button'\n\t\t\t\t\t\t) }\n\t\t\t\t\t\tonChange={ onUpload }\n\t\t\t\t\t\taccept={ accept }\n\t\t\t\t\t\tmultiple={ !! multiple }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Upload' ) }\n\t\t\t\t\t</FormFileUpload>\n\t\t\t\t\t{ uploadMediaLibraryButton }\n\t\t\t\t\t{ renderUrlSelectionUI() }\n\t\t\t\t\t{ renderFeaturedImageToggle() }\n\t\t\t\t\t{ renderCancelLink() }\n\t\t\t\t</>\n\t\t\t);\n\t\t\treturn renderPlaceholder( content );\n\t\t}\n\n\t\treturn renderPlaceholder( uploadMediaLibraryButton );\n\t};\n\n\tif ( disableMediaButtons ) {\n\t\treturn <MediaUploadCheck>{ renderDropZone() }</MediaUploadCheck>;\n\t}\n\n\treturn (\n\t\t<MediaUploadCheck\n\t\t\tfallback={ renderPlaceholder( renderUrlSelectionUI() ) }\n\t\t>\n\t\t\t{ renderMediaUploadChecked() }\n\t\t</MediaUploadCheck>\n\t);\n}\n\n/**\n * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/media-placeholder/README.md\n */\nexport default withFilters( 'editor.MediaPlaceholder' )( MediaPlaceholder );\n"],"mappings":";;;;;;;;AAGA,IAAAA,KAAA,GAAAC,sBAAA,CAAAC,OAAA;AAKA,IAAAC,WAAA,GAAAD,OAAA;AAOA,IAAAE,KAAA,GAAAF,OAAA;AACA,IAAAG,QAAA,GAAAH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,wBAAwB,CAAC;EAAC,CACX,CAAC;AAErB;;AAEA;AACA;AACA;AAFA,IAAAY,QAAA,GAAAC,OAAA,CAAA5J,OAAA,GAGe,IAAA6J,uBAAW,EAAE,yBAA0B,CAAC,CAAEpI,gBAAiB,CAAC","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["_clsx","_interopRequireDefault","require","_components","_i18n","_element","_data","_icons","_blocks2","_deprecated","_mediaUpload","_check","_urlPopover","_store","_jsxRuntime","noop","InsertFromURLPopover","src","onChange","onSubmit","onClose","popoverAnchor","jsx","default","anchor","children","jsxs","className","type","__","placeholder","value","Button","icon","keyboardReturn","label","URLSelectionUI","onChangeSrc","onSelectURL","setPopoverAnchor","useState","isURLInputVisible","setIsURLInputVisible","openURLInput","closeURLInput","focus","onSubmitSrc","event","preventDefault","onClick","isPressed","variant","ref","MediaPlaceholder","allowedTypes","labels","mediaPreview","notices","isAppender","accept","addToGallery","multiple","handleUpload","disableDropZone","disableMediaButtons","onError","onSelect","onCancel","onToggleFeaturedImage","onDoubleClick","onFilesPreUpload","onHTMLDrop","deprecatedOnHTMLDrop","mediaLibraryButton","style","deprecated","since","version","mediaUpload","useSelect","select","getSettings","blockEditorStore","setSrc","useEffect","_value$src","onlyAllowsImages","length","every","allowedType","startsWith","target","onFilesUpload","files","setMedia","lastMediaPassed","newMedia","filteredMedia","filter","item","id","some","Number","urlSlug","url","includes","concat","map","media","cutOffIndex","lastIndexOf","slice","filesList","onFileChange","handleBlocksDrop","blocks","Array","isArray","recursivelyFindMediaFromBlocks","_blocks","flatMap","block","name","attributes","innerBlocks","mediaBlocks","uploadedMediaList","Promise","all","resolve","reject","window","fetch","then","response","blob","additionalData","title","alt_text","alt","caption","catch","err","HTML","pasteHandler","onUpload","defaultRenderPlaceholder","content","instructions","undefined","typesAllowed","firstAllowedType","isOneType","isAudio","isImage","isVideo","placeholderClassName","clsx","Placeholder","preview","renderPlaceholder","renderDropZone","DropZone","onFilesDrop","renderCancelLink","renderUrlSelectionUI","renderFeaturedImageToggle","renderMediaUploadChecked","defaultButton","open","libraryButton","uploadMediaLibraryButton","gallery","mode","render","Fragment","FormFileUpload","openFileDialog","fallback","_default","exports","withFilters"],"sources":["@wordpress/block-editor/src/components/media-placeholder/index.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tButton,\n\tFormFileUpload,\n\tPlaceholder,\n\tDropZone,\n\twithFilters,\n} from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { useState, useEffect } from '@wordpress/element';\nimport { useSelect } from '@wordpress/data';\nimport { keyboardReturn } from '@wordpress/icons';\nimport { pasteHandler } from '@wordpress/blocks';\nimport deprecated from '@wordpress/deprecated';\n\n/**\n * Internal dependencies\n */\nimport MediaUpload from '../media-upload';\nimport MediaUploadCheck from '../media-upload/check';\nimport URLPopover from '../url-popover';\nimport { store as blockEditorStore } from '../../store';\n\nconst noop = () => {};\n\nconst InsertFromURLPopover = ( {\n\tsrc,\n\tonChange,\n\tonSubmit,\n\tonClose,\n\tpopoverAnchor,\n} ) => (\n\t<URLPopover anchor={ popoverAnchor } onClose={ onClose }>\n\t\t<form\n\t\t\tclassName=\"block-editor-media-placeholder__url-input-form\"\n\t\t\tonSubmit={ onSubmit }\n\t\t>\n\t\t\t<input\n\t\t\t\tclassName=\"block-editor-media-placeholder__url-input-field\"\n\t\t\t\ttype=\"text\"\n\t\t\t\taria-label={ __( 'URL' ) }\n\t\t\t\tplaceholder={ __( 'Paste or type URL' ) }\n\t\t\t\tonChange={ onChange }\n\t\t\t\tvalue={ src }\n\t\t\t/>\n\t\t\t<Button\n\t\t\t\tclassName=\"block-editor-media-placeholder__url-input-submit-button\"\n\t\t\t\ticon={ keyboardReturn }\n\t\t\t\tlabel={ __( 'Apply' ) }\n\t\t\t\ttype=\"submit\"\n\t\t\t/>\n\t\t</form>\n\t</URLPopover>\n);\n\nconst URLSelectionUI = ( { src, onChangeSrc, onSelectURL } ) => {\n\t// Use internal state instead of a ref to make sure that the component\n\t// re-renders when the popover's anchor updates.\n\tconst [ popoverAnchor, setPopoverAnchor ] = useState( null );\n\tconst [ isURLInputVisible, setIsURLInputVisible ] = useState( false );\n\n\tconst openURLInput = () => {\n\t\tsetIsURLInputVisible( true );\n\t};\n\tconst closeURLInput = () => {\n\t\tsetIsURLInputVisible( false );\n\t\tpopoverAnchor?.focus();\n\t};\n\n\tconst onSubmitSrc = ( event ) => {\n\t\tevent.preventDefault();\n\t\tif ( src && onSelectURL ) {\n\t\t\tonSelectURL( src );\n\t\t\tcloseURLInput();\n\t\t}\n\t};\n\n\treturn (\n\t\t<div className=\"block-editor-media-placeholder__url-input-container\">\n\t\t\t<Button\n\t\t\t\tclassName=\"block-editor-media-placeholder__button\"\n\t\t\t\tonClick={ openURLInput }\n\t\t\t\tisPressed={ isURLInputVisible }\n\t\t\t\tvariant=\"secondary\"\n\t\t\t\taria-haspopup=\"dialog\"\n\t\t\t\tref={ setPopoverAnchor }\n\t\t\t>\n\t\t\t\t{ __( 'Insert from URL' ) }\n\t\t\t</Button>\n\t\t\t{ isURLInputVisible && (\n\t\t\t\t<InsertFromURLPopover\n\t\t\t\t\tsrc={ src }\n\t\t\t\t\tonChange={ onChangeSrc }\n\t\t\t\t\tonSubmit={ onSubmitSrc }\n\t\t\t\t\tonClose={ closeURLInput }\n\t\t\t\t\tpopoverAnchor={ popoverAnchor }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</div>\n\t);\n};\n\nexport function MediaPlaceholder( {\n\tvalue = {},\n\tallowedTypes,\n\tclassName,\n\ticon,\n\tlabels = {},\n\tmediaPreview,\n\tnotices,\n\tisAppender,\n\taccept,\n\taddToGallery,\n\tmultiple = false,\n\thandleUpload = true,\n\tdisableDropZone,\n\tdisableMediaButtons,\n\tonError,\n\tonSelect,\n\tonCancel,\n\tonSelectURL,\n\tonToggleFeaturedImage,\n\tonDoubleClick,\n\tonFilesPreUpload = noop,\n\tonHTMLDrop: deprecatedOnHTMLDrop,\n\tchildren,\n\tmediaLibraryButton,\n\tplaceholder,\n\tstyle,\n} ) {\n\tif ( deprecatedOnHTMLDrop ) {\n\t\tdeprecated( 'wp.blockEditor.MediaPlaceholder onHTMLDrop prop', {\n\t\t\tsince: '6.2',\n\t\t\tversion: '6.4',\n\t\t} );\n\t}\n\n\tconst mediaUpload = useSelect( ( select ) => {\n\t\tconst { getSettings } = select( blockEditorStore );\n\t\treturn getSettings().mediaUpload;\n\t}, [] );\n\tconst [ src, setSrc ] = useState( '' );\n\n\tuseEffect( () => {\n\t\tsetSrc( value?.src ?? '' );\n\t}, [ value?.src ] );\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 onChangeSrc = ( event ) => {\n\t\tsetSrc( event.target.value );\n\t};\n\n\tconst onFilesUpload = ( files ) => {\n\t\tif ( ! handleUpload ) {\n\t\t\treturn onSelect( files );\n\t\t}\n\t\tonFilesPreUpload( files );\n\t\tlet setMedia;\n\t\tif ( multiple ) {\n\t\t\tif ( addToGallery ) {\n\t\t\t\t// Since the setMedia function runs multiple times per upload group\n\t\t\t\t// and is passed newMedia containing every item in its group each time, we must\n\t\t\t\t// filter out whatever this upload group had previously returned to the\n\t\t\t\t// gallery before adding and returning the image array with replacement newMedia\n\t\t\t\t// values.\n\n\t\t\t\t// Define an array to store urls from newMedia between subsequent function calls.\n\t\t\t\tlet lastMediaPassed = [];\n\t\t\t\tsetMedia = ( newMedia ) => {\n\t\t\t\t\t// Remove any images this upload group is responsible for (lastMediaPassed).\n\t\t\t\t\t// Their replacements are contained in newMedia.\n\t\t\t\t\tconst filteredMedia = ( value ?? [] ).filter( ( item ) => {\n\t\t\t\t\t\t// If Item has id, only remove it if lastMediaPassed has an item with that id.\n\t\t\t\t\t\tif ( item.id ) {\n\t\t\t\t\t\t\treturn ! lastMediaPassed.some(\n\t\t\t\t\t\t\t\t// Be sure to convert to number for comparison.\n\t\t\t\t\t\t\t\t( { id } ) => Number( id ) === Number( item.id )\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t\t// Compare transient images via .includes since gallery may append extra info onto the url.\n\t\t\t\t\t\treturn ! lastMediaPassed.some( ( { urlSlug } ) =>\n\t\t\t\t\t\t\titem.url.includes( urlSlug )\n\t\t\t\t\t\t);\n\t\t\t\t\t} );\n\t\t\t\t\t// Return the filtered media array along with newMedia.\n\t\t\t\t\tonSelect( filteredMedia.concat( newMedia ) );\n\t\t\t\t\t// Reset lastMediaPassed and set it with ids and urls from newMedia.\n\t\t\t\t\tlastMediaPassed = newMedia.map( ( media ) => {\n\t\t\t\t\t\t// Add everything up to '.fileType' to compare via .includes.\n\t\t\t\t\t\tconst cutOffIndex = media.url.lastIndexOf( '.' );\n\t\t\t\t\t\tconst urlSlug = media.url.slice( 0, cutOffIndex );\n\t\t\t\t\t\treturn { id: media.id, urlSlug };\n\t\t\t\t\t} );\n\t\t\t\t};\n\t\t\t} else {\n\t\t\t\tsetMedia = onSelect;\n\t\t\t}\n\t\t} else {\n\t\t\tsetMedia = ( [ media ] ) => onSelect( media );\n\t\t}\n\t\tmediaUpload( {\n\t\t\tallowedTypes,\n\t\t\tfilesList: files,\n\t\t\tonFileChange: setMedia,\n\t\t\tonError,\n\t\t} );\n\t};\n\n\tasync function handleBlocksDrop( blocks ) {\n\t\tif ( ! blocks || ! Array.isArray( blocks ) ) {\n\t\t\treturn;\n\t\t}\n\n\t\tfunction recursivelyFindMediaFromBlocks( _blocks ) {\n\t\t\treturn _blocks.flatMap( ( block ) =>\n\t\t\t\t( block.name === 'core/image' ||\n\t\t\t\t\tblock.name === 'core/audio' ||\n\t\t\t\t\tblock.name === 'core/video' ) &&\n\t\t\t\tblock.attributes.url\n\t\t\t\t\t? [ block ]\n\t\t\t\t\t: recursivelyFindMediaFromBlocks( block.innerBlocks )\n\t\t\t);\n\t\t}\n\n\t\tconst mediaBlocks = recursivelyFindMediaFromBlocks( blocks );\n\n\t\tif ( ! mediaBlocks.length ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst uploadedMediaList = await Promise.all(\n\t\t\tmediaBlocks.map( ( block ) =>\n\t\t\t\tblock.attributes.id\n\t\t\t\t\t? block.attributes\n\t\t\t\t\t: new Promise( ( resolve, reject ) => {\n\t\t\t\t\t\t\twindow\n\t\t\t\t\t\t\t\t.fetch( block.attributes.url )\n\t\t\t\t\t\t\t\t.then( ( response ) => response.blob() )\n\t\t\t\t\t\t\t\t.then( ( blob ) =>\n\t\t\t\t\t\t\t\t\tmediaUpload( {\n\t\t\t\t\t\t\t\t\t\tfilesList: [ blob ],\n\t\t\t\t\t\t\t\t\t\tadditionalData: {\n\t\t\t\t\t\t\t\t\t\t\ttitle: block.attributes.title,\n\t\t\t\t\t\t\t\t\t\t\talt_text: block.attributes.alt,\n\t\t\t\t\t\t\t\t\t\t\tcaption: block.attributes.caption,\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\tonFileChange: ( [ media ] ) => {\n\t\t\t\t\t\t\t\t\t\t\tif ( media.id ) {\n\t\t\t\t\t\t\t\t\t\t\t\tresolve( media );\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\tallowedTypes,\n\t\t\t\t\t\t\t\t\t\tonError: reject,\n\t\t\t\t\t\t\t\t\t} )\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t.catch( () => resolve( block.attributes.url ) );\n\t\t\t\t\t } )\n\t\t\t)\n\t\t).catch( ( err ) => onError( err ) );\n\n\t\tif ( multiple ) {\n\t\t\tonSelect( uploadedMediaList );\n\t\t} else {\n\t\t\tonSelect( uploadedMediaList[ 0 ] );\n\t\t}\n\t}\n\n\tasync function onHTMLDrop( HTML ) {\n\t\tconst blocks = pasteHandler( { HTML } );\n\t\treturn await handleBlocksDrop( blocks );\n\t}\n\n\tconst onUpload = ( event ) => {\n\t\tonFilesUpload( event.target.files );\n\t};\n\n\tconst defaultRenderPlaceholder = ( content ) => {\n\t\tlet { instructions, title } = labels;\n\n\t\tif ( ! mediaUpload && ! onSelectURL ) {\n\t\t\tinstructions = __(\n\t\t\t\t'To edit this block, you need permission to upload media.'\n\t\t\t);\n\t\t}\n\n\t\tif ( instructions === undefined || title === undefined ) {\n\t\t\tconst typesAllowed = allowedTypes ?? [];\n\n\t\t\tconst [ firstAllowedType ] = typesAllowed;\n\t\t\tconst isOneType = 1 === typesAllowed.length;\n\t\t\tconst isAudio = isOneType && 'audio' === firstAllowedType;\n\t\t\tconst isImage = isOneType && 'image' === firstAllowedType;\n\t\t\tconst isVideo = isOneType && 'video' === firstAllowedType;\n\n\t\t\tif ( instructions === undefined && mediaUpload ) {\n\t\t\t\tinstructions = __(\n\t\t\t\t\t'Upload a media file or pick one from your media library.'\n\t\t\t\t);\n\n\t\t\t\tif ( isAudio ) {\n\t\t\t\t\tinstructions = __(\n\t\t\t\t\t\t'Upload an audio file, pick one from your media library, or add one with a URL.'\n\t\t\t\t\t);\n\t\t\t\t} else if ( isImage ) {\n\t\t\t\t\tinstructions = __(\n\t\t\t\t\t\t'Upload an image file, pick one from your media library, or add one with a URL.'\n\t\t\t\t\t);\n\t\t\t\t} else if ( isVideo ) {\n\t\t\t\t\tinstructions = __(\n\t\t\t\t\t\t'Upload a video file, pick one from your media library, or add one with a URL.'\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif ( title === undefined ) {\n\t\t\t\ttitle = __( 'Media' );\n\n\t\t\t\tif ( isAudio ) {\n\t\t\t\t\ttitle = __( 'Audio' );\n\t\t\t\t} else if ( isImage ) {\n\t\t\t\t\ttitle = __( 'Image' );\n\t\t\t\t} else if ( isVideo ) {\n\t\t\t\t\ttitle = __( 'Video' );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tconst placeholderClassName = clsx(\n\t\t\t'block-editor-media-placeholder',\n\t\t\tclassName,\n\t\t\t{\n\t\t\t\t'is-appender': isAppender,\n\t\t\t}\n\t\t);\n\n\t\treturn (\n\t\t\t<Placeholder\n\t\t\t\ticon={ icon }\n\t\t\t\tlabel={ title }\n\t\t\t\tinstructions={ instructions }\n\t\t\t\tclassName={ placeholderClassName }\n\t\t\t\tnotices={ notices }\n\t\t\t\tonDoubleClick={ onDoubleClick }\n\t\t\t\tpreview={ mediaPreview }\n\t\t\t\tstyle={ style }\n\t\t\t>\n\t\t\t\t{ content }\n\t\t\t\t{ children }\n\t\t\t</Placeholder>\n\t\t);\n\t};\n\tconst renderPlaceholder = placeholder ?? defaultRenderPlaceholder;\n\n\tconst renderDropZone = () => {\n\t\tif ( disableDropZone ) {\n\t\t\treturn null;\n\t\t}\n\n\t\treturn (\n\t\t\t<DropZone onFilesDrop={ onFilesUpload } onHTMLDrop={ onHTMLDrop } />\n\t\t);\n\t};\n\n\tconst renderCancelLink = () => {\n\t\treturn (\n\t\t\tonCancel && (\n\t\t\t\t<Button\n\t\t\t\t\tclassName=\"block-editor-media-placeholder__cancel-button\"\n\t\t\t\t\ttitle={ __( 'Cancel' ) }\n\t\t\t\t\tvariant=\"link\"\n\t\t\t\t\tonClick={ onCancel }\n\t\t\t\t>\n\t\t\t\t\t{ __( 'Cancel' ) }\n\t\t\t\t</Button>\n\t\t\t)\n\t\t);\n\t};\n\n\tconst renderUrlSelectionUI = () => {\n\t\treturn (\n\t\t\tonSelectURL && (\n\t\t\t\t<URLSelectionUI\n\t\t\t\t\tsrc={ src }\n\t\t\t\t\tonChangeSrc={ onChangeSrc }\n\t\t\t\t\tonSelectURL={ onSelectURL }\n\t\t\t\t/>\n\t\t\t)\n\t\t);\n\t};\n\n\tconst renderFeaturedImageToggle = () => {\n\t\treturn (\n\t\t\tonToggleFeaturedImage && (\n\t\t\t\t<div className=\"block-editor-media-placeholder__url-input-container\">\n\t\t\t\t\t<Button\n\t\t\t\t\t\tclassName=\"block-editor-media-placeholder__button\"\n\t\t\t\t\t\tonClick={ onToggleFeaturedImage }\n\t\t\t\t\t\tvariant=\"secondary\"\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Use featured image' ) }\n\t\t\t\t\t</Button>\n\t\t\t\t</div>\n\t\t\t)\n\t\t);\n\t};\n\n\tconst renderMediaUploadChecked = () => {\n\t\tconst defaultButton = ( { open } ) => {\n\t\t\treturn (\n\t\t\t\t<Button\n\t\t\t\t\tvariant=\"secondary\"\n\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\topen();\n\t\t\t\t\t} }\n\t\t\t\t>\n\t\t\t\t\t{ __( 'Media Library' ) }\n\t\t\t\t</Button>\n\t\t\t);\n\t\t};\n\t\tconst libraryButton = mediaLibraryButton ?? defaultButton;\n\t\tconst uploadMediaLibraryButton = (\n\t\t\t<MediaUpload\n\t\t\t\taddToGallery={ addToGallery }\n\t\t\t\tgallery={ multiple && onlyAllowsImages() }\n\t\t\t\tmultiple={ multiple }\n\t\t\t\tonSelect={ onSelect }\n\t\t\t\tallowedTypes={ allowedTypes }\n\t\t\t\tmode=\"browse\"\n\t\t\t\tvalue={\n\t\t\t\t\tArray.isArray( value )\n\t\t\t\t\t\t? value.map( ( { id } ) => id )\n\t\t\t\t\t\t: value.id\n\t\t\t\t}\n\t\t\t\trender={ libraryButton }\n\t\t\t/>\n\t\t);\n\n\t\tif ( mediaUpload && isAppender ) {\n\t\t\treturn (\n\t\t\t\t<>\n\t\t\t\t\t{ renderDropZone() }\n\t\t\t\t\t<FormFileUpload\n\t\t\t\t\t\tonChange={ onUpload }\n\t\t\t\t\t\taccept={ accept }\n\t\t\t\t\t\tmultiple={ !! multiple }\n\t\t\t\t\t\trender={ ( { openFileDialog } ) => {\n\t\t\t\t\t\t\tconst content = (\n\t\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\t\t\t\t\t\tclassName={ clsx(\n\t\t\t\t\t\t\t\t\t\t\t'block-editor-media-placeholder__button',\n\t\t\t\t\t\t\t\t\t\t\t'block-editor-media-placeholder__upload-button'\n\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t\tonClick={ openFileDialog }\n\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t{ __( 'Upload' ) }\n\t\t\t\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t\t\t\t{ uploadMediaLibraryButton }\n\t\t\t\t\t\t\t\t\t{ renderUrlSelectionUI() }\n\t\t\t\t\t\t\t\t\t{ renderFeaturedImageToggle() }\n\t\t\t\t\t\t\t\t\t{ renderCancelLink() }\n\t\t\t\t\t\t\t\t</>\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\treturn renderPlaceholder( content );\n\t\t\t\t\t\t} }\n\t\t\t\t\t/>\n\t\t\t\t</>\n\t\t\t);\n\t\t}\n\n\t\tif ( mediaUpload ) {\n\t\t\tconst content = (\n\t\t\t\t<>\n\t\t\t\t\t{ renderDropZone() }\n\t\t\t\t\t<FormFileUpload\n\t\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\t\tclassName={ clsx(\n\t\t\t\t\t\t\t'block-editor-media-placeholder__button',\n\t\t\t\t\t\t\t'block-editor-media-placeholder__upload-button'\n\t\t\t\t\t\t) }\n\t\t\t\t\t\tonChange={ onUpload }\n\t\t\t\t\t\taccept={ accept }\n\t\t\t\t\t\tmultiple={ !! multiple }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Upload' ) }\n\t\t\t\t\t</FormFileUpload>\n\t\t\t\t\t{ uploadMediaLibraryButton }\n\t\t\t\t\t{ renderUrlSelectionUI() }\n\t\t\t\t\t{ renderFeaturedImageToggle() }\n\t\t\t\t\t{ renderCancelLink() }\n\t\t\t\t</>\n\t\t\t);\n\t\t\treturn renderPlaceholder( content );\n\t\t}\n\n\t\treturn renderPlaceholder( uploadMediaLibraryButton );\n\t};\n\n\tif ( disableMediaButtons ) {\n\t\treturn <MediaUploadCheck>{ renderDropZone() }</MediaUploadCheck>;\n\t}\n\n\treturn (\n\t\t<MediaUploadCheck\n\t\t\tfallback={ renderPlaceholder( renderUrlSelectionUI() ) }\n\t\t>\n\t\t\t{ renderMediaUploadChecked() }\n\t\t</MediaUploadCheck>\n\t);\n}\n\n/**\n * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/media-placeholder/README.md\n */\nexport default withFilters( 'editor.MediaPlaceholder' )( MediaPlaceholder );\n"],"mappings":";;;;;;;;AAGA,IAAAA,KAAA,GAAAC,sBAAA,CAAAC,OAAA;AAKA,IAAAC,WAAA,GAAAD,OAAA;AAOA,IAAAE,KAAA,GAAAF,OAAA;AACA,IAAAG,QAAA,GAAAH,OAAA;AACA,IAAAI,KAAA,GAAAJ,OAAA;AACA,IAAAK,MAAA,GAAAL,OAAA;AACA,IAAAM,QAAA,GAAAN,OAAA;AACA,IAAAO,WAAA,GAAAR,sBAAA,CAAAC,OAAA;AAKA,IAAAQ,YAAA,GAAAT,sBAAA,CAAAC,OAAA;AACA,IAAAS,MAAA,GAAAV,sBAAA,CAAAC,OAAA;AACA,IAAAU,WAAA,GAAAX,sBAAA,CAAAC,OAAA;AACA,IAAAW,MAAA,GAAAX,OAAA;AAAwD,IAAAY,WAAA,GAAAZ,OAAA;AA5BxD;AACA;AACA;;AAGA;AACA;AACA;;AAeA;AACA;AACA;;AAMA,MAAMa,IAAI,GAAGA,CAAA,KAAM,CAAC,CAAC;AAErB,MAAMC,oBAAoB,GAAGA,CAAE;EAC9BC,GAAG;EACHC,QAAQ;EACRC,QAAQ;EACRC,OAAO;EACPC;AACD,CAAC,kBACA,IAAAP,WAAA,CAAAQ,GAAA,EAACV,WAAA,CAAAW,OAAU;EAACC,MAAM,EAAGH,aAAe;EAACD,OAAO,EAAGA,OAAS;EA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AAC,CAAC,EACtBC,yBAAyB,CAAC,CAAC,EAC3BF,gBAAgB,CAAC,CAAC;MAAA,CACnB,CACF;MACD,OAAOJ,iBAAiB,CAAEb,OAAQ,CAAC;IACpC;IAEA,OAAOa,iBAAiB,CAAEW,wBAAyB,CAAC;EACrD,CAAC;EAED,IAAK3G,mBAAmB,EAAG;IAC1B,oBAAO,IAAAlD,WAAA,CAAAQ,GAAA,EAACX,MAAA,CAAAY,OAAgB;MAAAE,QAAA,EAAGwI,cAAc,CAAC;IAAC,CAAoB,CAAC;EACjE;EAEA,oBACC,IAAAnJ,WAAA,CAAAQ,GAAA,EAACX,MAAA,CAAAY,OAAgB;IAChB2J,QAAQ,EAAGlB,iBAAiB,CAAEK,oBAAoB,CAAC,CAAE,CAAG;IAAA5I,QAAA,EAEtD8I,wBAAwB,CAAC;EAAC,CACX,CAAC;AAErB;;AAEA;AACA;AACA;AAFA,IAAAY,QAAA,GAAAC,OAAA,CAAA7J,OAAA,GAGe,IAAA8J,uBAAW,EAAE,yBAA0B,CAAC,CAAEhI,gBAAiB,CAAC","ignoreList":[]}
|
|
@@ -184,6 +184,7 @@ function NavigableToolbar({
|
|
|
184
184
|
shouldUseKeyboardFocusShortcut = true,
|
|
185
185
|
__experimentalInitialIndex: initialIndex,
|
|
186
186
|
__experimentalOnIndexChange: onIndexChange,
|
|
187
|
+
orientation = 'horizontal',
|
|
187
188
|
...props
|
|
188
189
|
}) {
|
|
189
190
|
const toolbarRef = (0, _element.useRef)();
|
|
@@ -201,12 +202,13 @@ function NavigableToolbar({
|
|
|
201
202
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Toolbar, {
|
|
202
203
|
label: props['aria-label'],
|
|
203
204
|
ref: toolbarRef,
|
|
205
|
+
orientation: orientation,
|
|
204
206
|
...props,
|
|
205
207
|
children: children
|
|
206
208
|
});
|
|
207
209
|
}
|
|
208
210
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.NavigableMenu, {
|
|
209
|
-
orientation:
|
|
211
|
+
orientation: orientation,
|
|
210
212
|
role: "toolbar",
|
|
211
213
|
ref: toolbarRef,
|
|
212
214
|
...props,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_components","require","_element","_data","_deprecated","_interopRequireDefault","_dom","_keyboardShortcuts","_keycodes","_store","_lockUnlock","_jsxRuntime","hasOnlyToolbarItem","elements","dataProp","some","element","dataset","getAllFocusableToolbarItemsIn","container","Array","from","querySelectorAll","hasFocusWithin","contains","ownerDocument","activeElement","focusFirstTabbableIn","firstTabbable","focus","tabbable","find","preventScroll","useIsAccessibleToolbar","toolbarRef","initialAccessibleToolbarState","isAccessibleToolbar","setIsAccessibleToolbar","useState","determineIsAccessibleToolbar","useCallback","tabbables","current","onlyToolbarItem","deprecated","since","alternative","link","useLayoutEffect","observer","window","MutationObserver","observe","childList","subtree","disconnect","useToolbarFocus","focusOnMount","defaultIndex","onIndexChange","shouldUseKeyboardFocusShortcut","focusEditorOnEscape","initialFocusOnMount","initialIndex","focusToolbar","focusToolbarViaShortcut","useShortcut","useEffect","navigableToolbarRef","raf","requestAnimationFrame","items","index","cancelAnimationFrame","findIndex","item","tabIndex","getLastFocus","unlock","useSelect","blockEditorStore","handleKeyDown","event","lastFocus","keyCode","ESCAPE","preventDefault","addEventListener","removeEventListener","NavigableToolbar","children","__experimentalInitialIndex","__experimentalOnIndexChange","props","useRef","jsx","Toolbar","label","ref","NavigableMenu","orientation","role"],"sources":["@wordpress/block-editor/src/components/navigable-toolbar/index.js"],"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 { useSelect } from '@wordpress/data';\nimport deprecated from '@wordpress/deprecated';\nimport { focus } from '@wordpress/dom';\nimport { useShortcut } from '@wordpress/keyboard-shortcuts';\nimport { ESCAPE } from '@wordpress/keycodes';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\nimport { unlock } from '../../lock-unlock';\n\nfunction hasOnlyToolbarItem( elements ) {\n\tconst dataProp = 'toolbarItem';\n\treturn ! elements.some( ( element ) => ! ( dataProp in element.dataset ) );\n}\n\nfunction getAllFocusableToolbarItemsIn( container ) {\n\treturn Array.from(\n\t\tcontainer.querySelectorAll( '[data-toolbar-item]:not([disabled])' )\n\t);\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\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( toolbarRef ) {\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( toolbarRef.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}, [ toolbarRef ] );\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( toolbarRef.current, {\n\t\t\tchildList: true,\n\t\t\tsubtree: true,\n\t\t} );\n\t\treturn () => observer.disconnect();\n\t}, [ determineIsAccessibleToolbar, isAccessibleToolbar, toolbarRef ] );\n\n\treturn isAccessibleToolbar;\n}\n\nfunction useToolbarFocus( {\n\ttoolbarRef,\n\tfocusOnMount,\n\tisAccessibleToolbar,\n\tdefaultIndex,\n\tonIndexChange,\n\tshouldUseKeyboardFocusShortcut,\n\tfocusEditorOnEscape,\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( toolbarRef.current );\n\t}, [ toolbarRef ] );\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 = toolbarRef.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\n\t\t// If the toolbar already had focus before the render, we don't want to move it.\n\t\t// https://github.com/WordPress/gutenberg/issues/58511\n\t\tif (\n\t\t\t! initialFocusOnMount &&\n\t\t\t! hasFocusWithin( navigableToolbarRef )\n\t\t) {\n\t\t\traf = window.requestAnimationFrame( () => {\n\t\t\t\tconst items =\n\t\t\t\t\tgetAllFocusableToolbarItemsIn( 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 ) {\n\t\t\t\treturn;\n\t\t\t}\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 = getAllFocusableToolbarItemsIn( navigableToolbarRef );\n\t\t\tconst index = items.findIndex( ( item ) => item.tabIndex === 0 );\n\t\t\tonIndexChange( index );\n\t\t};\n\t}, [ initialIndex, initialFocusOnMount, onIndexChange, toolbarRef ] );\n\n\tconst { getLastFocus } = unlock( useSelect( blockEditorStore ) );\n\t/**\n\t * Handles returning focus to the block editor canvas when pressing escape.\n\t */\n\tuseEffect( () => {\n\t\tconst navigableToolbarRef = toolbarRef.current;\n\n\t\tif ( focusEditorOnEscape ) {\n\t\t\tconst handleKeyDown = ( event ) => {\n\t\t\t\tconst lastFocus = getLastFocus();\n\t\t\t\tif ( event.keyCode === ESCAPE && lastFocus?.current ) {\n\t\t\t\t\t// Focus the last focused element when pressing escape.\n\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\tlastFocus.current.focus();\n\t\t\t\t}\n\t\t\t};\n\t\t\tnavigableToolbarRef.addEventListener( 'keydown', handleKeyDown );\n\t\t\treturn () => {\n\t\t\t\tnavigableToolbarRef.removeEventListener(\n\t\t\t\t\t'keydown',\n\t\t\t\t\thandleKeyDown\n\t\t\t\t);\n\t\t\t};\n\t\t}\n\t}, [ focusEditorOnEscape, getLastFocus, toolbarRef ] );\n}\n\nexport default function NavigableToolbar( {\n\tchildren,\n\tfocusOnMount,\n\tfocusEditorOnEscape = false,\n\tshouldUseKeyboardFocusShortcut = true,\n\t__experimentalInitialIndex: initialIndex,\n\t__experimentalOnIndexChange: onIndexChange,\n\t...props\n} ) {\n\tconst toolbarRef = useRef();\n\tconst isAccessibleToolbar = useIsAccessibleToolbar( toolbarRef );\n\n\tuseToolbarFocus( {\n\t\ttoolbarRef,\n\t\tfocusOnMount,\n\t\tdefaultIndex: initialIndex,\n\t\tonIndexChange,\n\t\tisAccessibleToolbar,\n\t\tshouldUseKeyboardFocusShortcut,\n\t\tfocusEditorOnEscape,\n\t} );\n\n\tif ( isAccessibleToolbar ) {\n\t\treturn (\n\t\t\t<Toolbar\n\t\t\t\tlabel={ props[ 'aria-label' ] }\n\t\t\t\tref={ toolbarRef }\n\t\t\t\t{ ...props }\n\t\t\t>\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={ toolbarRef }\n\t\t\t{ ...props }\n\t\t>\n\t\t\t{ children }\n\t\t</N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ACJ,CAAC,EAAG;EACH,MAAM3D,UAAU,GAAG,IAAA4D,eAAM,EAAC,CAAC;EAC3B,MAAM1D,mBAAmB,GAAGH,sBAAsB,CAAEC,UAAW,CAAC;EAEhEsB,eAAe,CAAE;IAChBtB,UAAU;IACVuB,YAAY;IACZC,YAAY,EAAEK,YAAY;IAC1BJ,aAAa;IACbvB,mBAAmB;IACnBwB,8BAA8B;IAC9BC;EACD,CAAE,CAAC;EAEH,IAAKzB,mBAAmB,EAAG;IAC1B,oBACC,IAAAzB,WAAA,CAAAoF,GAAA,EAAC/F,WAAA,CAAAgG,OAAO;MACPC,KAAK,EAAGJ,KAAK,CAAE,YAAY,CAAI;MAC/BK,GAAG,EAAGhE,UAAY;MAAA,GACb2D,KAAK;MAAAH,QAAA,EAERA;IAAQ,CACF,CAAC;EAEZ;EAEA,oBACC,IAAA/E,WAAA,CAAAoF,GAAA,EAAC/F,WAAA,CAAAmG,aAAa;IACbC,WAAW,EAAC,YAAY;IACxBC,IAAI,EAAC,SAAS;IACdH,GAAG,EAAGhE,UAAY;IAAA,GACb2D,KAAK;IAAAH,QAAA,EAERA;EAAQ,CACI,CAAC;AAElB","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["_components","require","_element","_data","_deprecated","_interopRequireDefault","_dom","_keyboardShortcuts","_keycodes","_store","_lockUnlock","_jsxRuntime","hasOnlyToolbarItem","elements","dataProp","some","element","dataset","getAllFocusableToolbarItemsIn","container","Array","from","querySelectorAll","hasFocusWithin","contains","ownerDocument","activeElement","focusFirstTabbableIn","firstTabbable","focus","tabbable","find","preventScroll","useIsAccessibleToolbar","toolbarRef","initialAccessibleToolbarState","isAccessibleToolbar","setIsAccessibleToolbar","useState","determineIsAccessibleToolbar","useCallback","tabbables","current","onlyToolbarItem","deprecated","since","alternative","link","useLayoutEffect","observer","window","MutationObserver","observe","childList","subtree","disconnect","useToolbarFocus","focusOnMount","defaultIndex","onIndexChange","shouldUseKeyboardFocusShortcut","focusEditorOnEscape","initialFocusOnMount","initialIndex","focusToolbar","focusToolbarViaShortcut","useShortcut","useEffect","navigableToolbarRef","raf","requestAnimationFrame","items","index","cancelAnimationFrame","findIndex","item","tabIndex","getLastFocus","unlock","useSelect","blockEditorStore","handleKeyDown","event","lastFocus","keyCode","ESCAPE","preventDefault","addEventListener","removeEventListener","NavigableToolbar","children","__experimentalInitialIndex","__experimentalOnIndexChange","orientation","props","useRef","jsx","Toolbar","label","ref","NavigableMenu","role"],"sources":["@wordpress/block-editor/src/components/navigable-toolbar/index.js"],"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 { useSelect } from '@wordpress/data';\nimport deprecated from '@wordpress/deprecated';\nimport { focus } from '@wordpress/dom';\nimport { useShortcut } from '@wordpress/keyboard-shortcuts';\nimport { ESCAPE } from '@wordpress/keycodes';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\nimport { unlock } from '../../lock-unlock';\n\nfunction hasOnlyToolbarItem( elements ) {\n\tconst dataProp = 'toolbarItem';\n\treturn ! elements.some( ( element ) => ! ( dataProp in element.dataset ) );\n}\n\nfunction getAllFocusableToolbarItemsIn( container ) {\n\treturn Array.from(\n\t\tcontainer.querySelectorAll( '[data-toolbar-item]:not([disabled])' )\n\t);\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\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( toolbarRef ) {\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( toolbarRef.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}, [ toolbarRef ] );\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( toolbarRef.current, {\n\t\t\tchildList: true,\n\t\t\tsubtree: true,\n\t\t} );\n\t\treturn () => observer.disconnect();\n\t}, [ determineIsAccessibleToolbar, isAccessibleToolbar, toolbarRef ] );\n\n\treturn isAccessibleToolbar;\n}\n\nfunction useToolbarFocus( {\n\ttoolbarRef,\n\tfocusOnMount,\n\tisAccessibleToolbar,\n\tdefaultIndex,\n\tonIndexChange,\n\tshouldUseKeyboardFocusShortcut,\n\tfocusEditorOnEscape,\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( toolbarRef.current );\n\t}, [ toolbarRef ] );\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 = toolbarRef.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\n\t\t// If the toolbar already had focus before the render, we don't want to move it.\n\t\t// https://github.com/WordPress/gutenberg/issues/58511\n\t\tif (\n\t\t\t! initialFocusOnMount &&\n\t\t\t! hasFocusWithin( navigableToolbarRef )\n\t\t) {\n\t\t\traf = window.requestAnimationFrame( () => {\n\t\t\t\tconst items =\n\t\t\t\t\tgetAllFocusableToolbarItemsIn( 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 ) {\n\t\t\t\treturn;\n\t\t\t}\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 = getAllFocusableToolbarItemsIn( navigableToolbarRef );\n\t\t\tconst index = items.findIndex( ( item ) => item.tabIndex === 0 );\n\t\t\tonIndexChange( index );\n\t\t};\n\t}, [ initialIndex, initialFocusOnMount, onIndexChange, toolbarRef ] );\n\n\tconst { getLastFocus } = unlock( useSelect( blockEditorStore ) );\n\t/**\n\t * Handles returning focus to the block editor canvas when pressing escape.\n\t */\n\tuseEffect( () => {\n\t\tconst navigableToolbarRef = toolbarRef.current;\n\n\t\tif ( focusEditorOnEscape ) {\n\t\t\tconst handleKeyDown = ( event ) => {\n\t\t\t\tconst lastFocus = getLastFocus();\n\t\t\t\tif ( event.keyCode === ESCAPE && lastFocus?.current ) {\n\t\t\t\t\t// Focus the last focused element when pressing escape.\n\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\tlastFocus.current.focus();\n\t\t\t\t}\n\t\t\t};\n\t\t\tnavigableToolbarRef.addEventListener( 'keydown', handleKeyDown );\n\t\t\treturn () => {\n\t\t\t\tnavigableToolbarRef.removeEventListener(\n\t\t\t\t\t'keydown',\n\t\t\t\t\thandleKeyDown\n\t\t\t\t);\n\t\t\t};\n\t\t}\n\t}, [ focusEditorOnEscape, getLastFocus, toolbarRef ] );\n}\n\nexport default function NavigableToolbar( {\n\tchildren,\n\tfocusOnMount,\n\tfocusEditorOnEscape = false,\n\tshouldUseKeyboardFocusShortcut = true,\n\t__experimentalInitialIndex: initialIndex,\n\t__experimentalOnIndexChange: onIndexChange,\n\torientation = 'horizontal',\n\t...props\n} ) {\n\tconst toolbarRef = useRef();\n\tconst isAccessibleToolbar = useIsAccessibleToolbar( toolbarRef );\n\n\tuseToolbarFocus( {\n\t\ttoolbarRef,\n\t\tfocusOnMount,\n\t\tdefaultIndex: initialIndex,\n\t\tonIndexChange,\n\t\tisAccessibleToolbar,\n\t\tshouldUseKeyboardFocusShortcut,\n\t\tfocusEditorOnEscape,\n\t} );\n\n\tif ( isAccessibleToolbar ) {\n\t\treturn (\n\t\t\t<Toolbar\n\t\t\t\tlabel={ props[ 'aria-label' ] }\n\t\t\t\tref={ toolbarRef }\n\t\t\t\torientation={ orientation }\n\t\t\t\t{ ...props }\n\t\t\t>\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={ orientation }\n\t\t\trole=\"toolbar\"\n\t\t\tref={ toolbarRef }\n\t\t\t{ ...props }\n\t\t>\n\t\t\t{ children }\n\t\t</NavigableMenu>\n\t);\n}\n"],"mappings":";;;;;;;AAGA,IAAAA,WAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AAOA,IAAAE,KAAA,GAAAF,OAAA;AACA,IAAAG,WAAA,GAAAC,sBAAA,CAAAJ,OAAA;AACA,IAAAK,IAAA,GAAAL,OAAA;AACA,IAAAM,kBAAA,GAAAN,OAAA;AACA,IAAAO,SAAA,GAAAP,OAAA;AAKA,IAAAQ,MAAA,GAAAR,OAAA;AACA,IAAAS,WAAA,GAAAT,OAAA;AAA2C,IAAAU,WAAA,GAAAV,OAAA;AArB3C;AACA;AACA;;AAeA;AACA;AACA;;AAIA,SAASW,kBAAkBA,CAAEC,QAAQ,EAAG;EACvC,MAAMC,QAAQ,GAAG,aAAa;EAC9B,OAAO,CAAED,QAAQ,CAACE,IAAI,CAAIC,OAAO,IAAM,EAAIF,QAAQ,IAAIE,OAAO,CAACC,OAAO,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AA/E,WAAA,CAAAqF,GAAA,EAAChG,WAAA,CAAAoG,aAAa;IACbP,WAAW,EAAGA,WAAa;IAC3BQ,IAAI,EAAC,SAAS;IACdF,GAAG,EAAGjE,UAAY;IAAA,GACb4D,KAAK;IAAAJ,QAAA,EAERA;EAAQ,CACI,CAAC;AAElB","ignoreList":[]}
|
|
@@ -4,6 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
+
exports.findSelection = findSelection;
|
|
7
8
|
var _richText = require("@wordpress/rich-text");
|
|
8
9
|
var _blocks = require("@wordpress/blocks");
|
|
9
10
|
var _store = require("../../../store");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_richText","require","_blocks","_store","_preventEventDiscovery","_selection","findSelection","blocks","i","length","attributeKey","retrieveSelectedAttribute","attributes","toString","replace","START_OF_SELECTED_AREA","clientId","nestedSelection","innerBlocks","_default","props","element","inputRule","getValue","onReplace","selectionChange","registry","current","value","start","text","characterBefore","slice","trimmedTextBefore","trim","prefixTransforms","getBlockTransforms","filter","type","transformation","findTransform","prefix","content","toHTMLString","insert","block","transform","dispatch","blockEditorStore","__unstableMarkAutomaticChange","onInput","event","inputType","onChange","__unstableAllowPrefixTransformations","formatTypes","transformed","reduce","accumlator","__unstableInputRule","preventEventDiscovery","__unstableMarkLastChangeAsPersistent","activeFormats","addEventListener","removeEventListener","exports","default"],"sources":["@wordpress/block-editor/src/components/rich-text/event-listeners/input-rules.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { insert, toHTMLString } from '@wordpress/rich-text';\nimport { getBlockTransforms, findTransform } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../../store';\nimport { preventEventDiscovery } from '../prevent-event-discovery';\nimport {\n\tretrieveSelectedAttribute,\n\tSTART_OF_SELECTED_AREA,\n} from '../../../utils/selection';\n\
|
|
1
|
+
{"version":3,"names":["_richText","require","_blocks","_store","_preventEventDiscovery","_selection","findSelection","blocks","i","length","attributeKey","retrieveSelectedAttribute","attributes","toString","replace","START_OF_SELECTED_AREA","clientId","nestedSelection","innerBlocks","_default","props","element","inputRule","getValue","onReplace","selectionChange","registry","current","value","start","text","characterBefore","slice","trimmedTextBefore","trim","prefixTransforms","getBlockTransforms","filter","type","transformation","findTransform","prefix","content","toHTMLString","insert","block","transform","dispatch","blockEditorStore","__unstableMarkAutomaticChange","onInput","event","inputType","onChange","__unstableAllowPrefixTransformations","formatTypes","transformed","reduce","accumlator","__unstableInputRule","preventEventDiscovery","__unstableMarkLastChangeAsPersistent","activeFormats","addEventListener","removeEventListener","exports","default"],"sources":["@wordpress/block-editor/src/components/rich-text/event-listeners/input-rules.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { insert, toHTMLString } from '@wordpress/rich-text';\nimport { getBlockTransforms, findTransform } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../../store';\nimport { preventEventDiscovery } from '../prevent-event-discovery';\nimport {\n\tretrieveSelectedAttribute,\n\tSTART_OF_SELECTED_AREA,\n} from '../../../utils/selection';\n\nexport function findSelection( blocks ) {\n\tlet i = blocks.length;\n\n\twhile ( i-- ) {\n\t\tconst attributeKey = retrieveSelectedAttribute(\n\t\t\tblocks[ i ].attributes\n\t\t);\n\n\t\tif ( attributeKey ) {\n\t\t\tblocks[ i ].attributes[ attributeKey ] = blocks[ i ].attributes[\n\t\t\t\tattributeKey\n\t\t\t]\n\t\t\t\t// To do: refactor this to use rich text's selection instead, so\n\t\t\t\t// we no longer have to use on this hack inserting a special\n\t\t\t\t// character.\n\t\t\t\t.toString()\n\t\t\t\t.replace( START_OF_SELECTED_AREA, '' );\n\t\t\treturn [ blocks[ i ].clientId, attributeKey, 0, 0 ];\n\t\t}\n\n\t\tconst nestedSelection = findSelection( blocks[ i ].innerBlocks );\n\n\t\tif ( nestedSelection ) {\n\t\t\treturn nestedSelection;\n\t\t}\n\t}\n\n\treturn [];\n}\n\nexport default ( props ) => ( element ) => {\n\tfunction inputRule() {\n\t\tconst { getValue, onReplace, selectionChange, registry } =\n\t\t\tprops.current;\n\n\t\tif ( ! onReplace ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// We must use getValue() here because value may be update\n\t\t// asynchronously.\n\t\tconst value = getValue();\n\t\tconst { start, text } = value;\n\t\tconst characterBefore = text.slice( start - 1, start );\n\n\t\t// The character right before the caret must be a plain space.\n\t\tif ( characterBefore !== ' ' ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst trimmedTextBefore = text.slice( 0, start ).trim();\n\t\tconst prefixTransforms = getBlockTransforms( 'from' ).filter(\n\t\t\t( { type } ) => type === 'prefix'\n\t\t);\n\t\tconst transformation = findTransform(\n\t\t\tprefixTransforms,\n\t\t\t( { prefix } ) => {\n\t\t\t\treturn trimmedTextBefore === prefix;\n\t\t\t}\n\t\t);\n\n\t\tif ( ! transformation ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst content = toHTMLString( {\n\t\t\tvalue: insert( value, START_OF_SELECTED_AREA, 0, start ),\n\t\t} );\n\t\tconst block = transformation.transform( content );\n\n\t\tselectionChange( ...findSelection( [ block ] ) );\n\t\tonReplace( [ block ] );\n\t\tregistry.dispatch( blockEditorStore ).__unstableMarkAutomaticChange();\n\n\t\treturn true;\n\t}\n\n\tfunction onInput( event ) {\n\t\tconst { inputType, type } = event;\n\t\tconst {\n\t\t\tgetValue,\n\t\t\tonChange,\n\t\t\t__unstableAllowPrefixTransformations,\n\t\t\tformatTypes,\n\t\t\tregistry,\n\t\t} = props.current;\n\n\t\t// Only run input rules when inserting text.\n\t\tif ( inputType !== 'insertText' && type !== 'compositionend' ) {\n\t\t\treturn;\n\t\t}\n\n\t\tif ( __unstableAllowPrefixTransformations && inputRule() ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst value = getValue();\n\t\tconst transformed = formatTypes.reduce(\n\t\t\t( accumlator, { __unstableInputRule } ) => {\n\t\t\t\tif ( __unstableInputRule ) {\n\t\t\t\t\taccumlator = __unstableInputRule( accumlator );\n\t\t\t\t}\n\n\t\t\t\treturn accumlator;\n\t\t\t},\n\t\t\tpreventEventDiscovery( value )\n\t\t);\n\n\t\tconst {\n\t\t\t__unstableMarkLastChangeAsPersistent,\n\t\t\t__unstableMarkAutomaticChange,\n\t\t} = registry.dispatch( blockEditorStore );\n\n\t\tif ( transformed !== value ) {\n\t\t\t__unstableMarkLastChangeAsPersistent();\n\t\t\tonChange( {\n\t\t\t\t...transformed,\n\t\t\t\tactiveFormats: value.activeFormats,\n\t\t\t} );\n\t\t\t__unstableMarkAutomaticChange();\n\t\t}\n\t}\n\n\telement.addEventListener( 'input', onInput );\n\telement.addEventListener( 'compositionend', onInput );\n\treturn () => {\n\t\telement.removeEventListener( 'input', onInput );\n\t\telement.removeEventListener( 'compositionend', onInput );\n\t};\n};\n"],"mappings":";;;;;;;AAGA,IAAAA,SAAA,GAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AAKA,IAAAE,MAAA,GAAAF,OAAA;AACA,IAAAG,sBAAA,GAAAH,OAAA;AACA,IAAAI,UAAA,GAAAJ,OAAA;AAXA;AACA;AACA;;AAIA;AACA;AACA;;AAQO,SAASK,aAAaA,CAAEC,MAAM,EAAG;EACvC,IAAIC,CAAC,GAAGD,MAAM,CAACE,MAAM;EAErB,OAAQD,CAAC,EAAE,EAAG;IACb,MAAME,YAAY,GAAG,IAAAC,oCAAyB,EAC7CJ,MAAM,CAAEC,CAAC,CAAE,CAACI,UACb,CAAC;IAED,IAAKF,YAAY,EAAG;MACnBH,MAAM,CAAEC,CAAC,CAAE,CAACI,UAAU,CAAEF,YAAY,CAAE,GAAGH,MAAM,CAAEC,CAAC,CAAE,CAACI,UAAU,CAC9DF,YAAY;MAEZ;MACA;MACA;MAAA,CACCG,QAAQ,CAAC,CAAC,CACVC,OAAO,CAAEC,iCAAsB,EAAE,EAAG,CA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ACtCR,QAAQ,CAAE;QACT,GAAGG,WAAW;QACdM,aAAa,EAAElC,KAAK,CAACkC;MACtB,CAAE,CAAC;MACHb,6BAA6B,CAAC,CAAC;IAChC;EACD;EAEA5B,OAAO,CAAC0C,gBAAgB,CAAE,OAAO,EAAEb,OAAQ,CAAC;EAC5C7B,OAAO,CAAC0C,gBAAgB,CAAE,gBAAgB,EAAEb,OAAQ,CAAC;EACrD,OAAO,MAAM;IACZ7B,OAAO,CAAC2C,mBAAmB,CAAE,OAAO,EAAEd,OAAQ,CAAC;IAC/C7B,OAAO,CAAC2C,mBAAmB,CAAE,gBAAgB,EAAEd,OAAQ,CAAC;EACzD,CAAC;AACF,CAAC;AAAAe,OAAA,CAAAC,OAAA,GAAA/C,QAAA","ignoreList":[]}
|
|
@@ -43,6 +43,8 @@ var _embedHandlerPicker = _interopRequireDefault(require("./embed-handler-picker
|
|
|
43
43
|
var _content = require("./content");
|
|
44
44
|
var _native = _interopRequireDefault(require("./native"));
|
|
45
45
|
var _withDeprecations = require("./with-deprecations");
|
|
46
|
+
var _inputRules = require("./event-listeners/input-rules");
|
|
47
|
+
var _selection = require("../../utils/selection");
|
|
46
48
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
47
49
|
var _shortcut = require("./shortcut");
|
|
48
50
|
var _toolbarButton = require("./toolbar-button");
|
|
@@ -435,7 +437,7 @@ function RichTextWrapper({
|
|
|
435
437
|
}
|
|
436
438
|
}
|
|
437
439
|
}, [tagName, onReplace, onSplit, splitValue, __unstableEmbedURLOnPaste, preserveWhiteSpace, pastePlainText]);
|
|
438
|
-
const inputRule = (0, _element.useCallback)(
|
|
440
|
+
const inputRule = (0, _element.useCallback)(value => {
|
|
439
441
|
if (!onReplace) {
|
|
440
442
|
return;
|
|
441
443
|
}
|
|
@@ -449,7 +451,7 @@ function RichTextWrapper({
|
|
|
449
451
|
if (characterBefore !== ' ') {
|
|
450
452
|
return;
|
|
451
453
|
}
|
|
452
|
-
const trimmedTextBefore = text.slice(0,
|
|
454
|
+
const trimmedTextBefore = text.slice(0, start).trim();
|
|
453
455
|
const prefixTransforms = (0, _blocks.getBlockTransforms)('from').filter(({
|
|
454
456
|
type
|
|
455
457
|
}) => type === 'prefix');
|
|
@@ -461,11 +463,15 @@ function RichTextWrapper({
|
|
|
461
463
|
if (!transformation) {
|
|
462
464
|
return;
|
|
463
465
|
}
|
|
464
|
-
const content =
|
|
466
|
+
const content = (0, _richText.toHTMLString)({
|
|
467
|
+
value: (0, _richText.insert)(value, _selection.START_OF_SELECTED_AREA, 0, start)
|
|
468
|
+
});
|
|
465
469
|
const block = transformation.transform(content);
|
|
470
|
+
const currentSelection = (0, _inputRules.findSelection)([block]);
|
|
466
471
|
onReplace([block]);
|
|
472
|
+
selectionChange(...currentSelection);
|
|
467
473
|
__unstableMarkAutomaticChange();
|
|
468
|
-
}, [onReplace, __unstableMarkAutomaticChange]);
|
|
474
|
+
}, [onReplace, start, selectionChange, __unstableMarkAutomaticChange]);
|
|
469
475
|
const mergedRef = (0, _compose.useMergeRefs)([providedRef, fallbackRef]);
|
|
470
476
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_native.default, {
|
|
471
477
|
clientId: clientId,
|