@wordpress/block-editor 8.0.12-next.33ec3857e2.0 → 8.0.12
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/README.md +0 -4
- package/build/components/block-caption/index.native.js +3 -14
- package/build/components/block-caption/index.native.js.map +1 -1
- package/build/components/block-inspector/index.js +33 -12
- package/build/components/block-inspector/index.js.map +1 -1
- package/build/components/block-list/block.js +1 -1
- package/build/components/block-list/block.js.map +1 -1
- package/build/components/block-list/block.native.js +2 -3
- package/build/components/block-list/block.native.js.map +1 -1
- package/build/components/block-list/use-block-props/index.js +1 -3
- package/build/components/block-list/use-block-props/index.js.map +1 -1
- package/build/components/block-list/use-in-between-inserter.js +1 -1
- package/build/components/block-list/use-in-between-inserter.js.map +1 -1
- package/build/components/block-list-appender/index.js +11 -3
- package/build/components/block-list-appender/index.js.map +1 -1
- package/build/components/block-mobile-toolbar/block-actions-menu.native.js +2 -2
- package/build/components/block-mobile-toolbar/block-actions-menu.native.js.map +1 -1
- package/build/components/block-mover/button.js +2 -2
- package/build/components/block-mover/button.js.map +1 -1
- package/build/components/block-mover/index.js +2 -2
- package/build/components/block-mover/index.js.map +1 -1
- package/build/components/block-mover/index.native.js +2 -2
- package/build/components/block-mover/index.native.js.map +1 -1
- package/build/components/block-preview/auto.js +2 -10
- package/build/components/block-preview/auto.js.map +1 -1
- package/build/components/block-settings/container.native.js +1 -2
- package/build/components/block-settings/container.native.js.map +1 -1
- package/build/components/block-styles/index.js +134 -110
- package/build/components/block-styles/index.js.map +1 -1
- package/build/components/block-styles/utils.js +0 -39
- package/build/components/block-styles/utils.js.map +1 -1
- package/build/components/block-switcher/block-styles-menu.js +23 -3
- package/build/components/block-switcher/block-styles-menu.js.map +1 -1
- package/build/components/block-tools/back-compat.js +1 -2
- package/build/components/block-tools/back-compat.js.map +1 -1
- package/build/components/block-tools/block-selection-button.js +3 -3
- package/build/components/block-tools/block-selection-button.js.map +1 -1
- package/build/components/block-tools/insertion-point.js +1 -11
- package/build/components/block-tools/insertion-point.js.map +1 -1
- package/build/components/button-block-appender/index.js +1 -2
- package/build/components/button-block-appender/index.js.map +1 -1
- package/build/components/colors-gradients/panel-color-gradient-settings.js +10 -51
- package/build/components/colors-gradients/panel-color-gradient-settings.js.map +1 -1
- package/build/components/default-block-appender/index.js +19 -16
- package/build/components/default-block-appender/index.js.map +1 -1
- package/build/components/default-style-picker/index.js +3 -18
- package/build/components/default-style-picker/index.js.map +1 -1
- package/build/components/iframe/index.js +4 -3
- package/build/components/iframe/index.js.map +1 -1
- package/build/components/index.js +9 -9
- package/build/components/index.js.map +1 -1
- package/build/components/inner-blocks/default-block-appender.js +4 -2
- package/build/components/inner-blocks/default-block-appender.js.map +1 -1
- package/build/components/inserter/hooks/use-insertion-point.js +2 -2
- package/build/components/inserter/hooks/use-insertion-point.js.map +1 -1
- package/build/components/inserter/index.js +2 -2
- package/build/components/inserter/index.js.map +1 -1
- package/build/components/inserter/index.native.js +3 -3
- package/build/components/inserter/index.native.js.map +1 -1
- package/build/components/inserter/quick-inserter.js +1 -1
- package/build/components/inserter/quick-inserter.js.map +1 -1
- package/build/components/inserter/tabs.native.js +4 -7
- package/build/components/inserter/tabs.native.js.map +1 -1
- package/build/components/inspector-controls/block-support-slot-container.js +1 -2
- package/build/components/inspector-controls/block-support-slot-container.js.map +1 -1
- package/build/components/inspector-controls/block-support-tools-panel.js +50 -22
- package/build/components/inspector-controls/block-support-tools-panel.js.map +1 -1
- package/build/components/inspector-controls/fill.native.js +5 -3
- package/build/components/inspector-controls/fill.native.js.map +1 -1
- package/build/components/inspector-controls/groups.js +0 -2
- package/build/components/inspector-controls/groups.js.map +1 -1
- package/build/components/inspector-controls/slot.js +3 -1
- package/build/components/inspector-controls/slot.js.map +1 -1
- package/build/components/letter-spacing-control/index.js +6 -6
- package/build/components/letter-spacing-control/index.js.map +1 -1
- package/build/components/list-view/block-select-button.js +3 -23
- package/build/components/list-view/block-select-button.js.map +1 -1
- package/build/components/list-view/use-list-view-drop-zone.js +1 -1
- package/build/components/list-view/use-list-view-drop-zone.js.map +1 -1
- package/build/components/media-placeholder/index.js +0 -2
- package/build/components/media-placeholder/index.js.map +1 -1
- package/build/components/media-replace-flow/index.js +0 -2
- package/build/components/media-replace-flow/index.js.map +1 -1
- package/build/components/provider/use-block-sync.js +37 -10
- package/build/components/provider/use-block-sync.js.map +1 -1
- package/build/components/rich-text/file-paste-handler.js +1 -1
- package/build/components/rich-text/file-paste-handler.js.map +1 -1
- package/build/components/rich-text/use-input-rules.js +1 -3
- package/build/components/rich-text/use-input-rules.js.map +1 -1
- package/build/components/selection-scroll-into-view/index.js +1 -2
- package/build/components/selection-scroll-into-view/index.js.map +1 -1
- package/build/components/use-canvas-click-redirect/index.js +66 -0
- package/build/components/use-canvas-click-redirect/index.js.map +1 -0
- package/build/components/use-on-block-drop/index.js +4 -8
- package/build/components/use-on-block-drop/index.js.map +1 -1
- package/build/components/use-setting/index.js +7 -0
- package/build/components/use-setting/index.js.map +1 -1
- package/build/components/writing-flow/use-multi-selection.js +1 -3
- package/build/components/writing-flow/use-multi-selection.js.map +1 -1
- package/build/hooks/border-color.js +5 -63
- package/build/hooks/border-color.js.map +1 -1
- package/build/hooks/border-radius.js +0 -47
- package/build/hooks/border-radius.js.map +1 -1
- package/build/hooks/border-style.js +0 -41
- package/build/hooks/border-style.js.map +1 -1
- package/build/hooks/border-width.js +31 -70
- package/build/hooks/border-width.js.map +1 -1
- package/build/hooks/border.js +11 -81
- package/build/hooks/border.js.map +1 -1
- package/build/hooks/letter-spacing.js +1 -1
- package/build/hooks/letter-spacing.js.map +1 -1
- package/build/hooks/typography.js +1 -1
- package/build/hooks/typography.js.map +1 -1
- package/build/layouts/flex.js +3 -27
- package/build/layouts/flex.js.map +1 -1
- package/build/store/actions.js +5 -4
- package/build/store/actions.js.map +1 -1
- package/build/store/defaults.js +1 -5
- package/build/store/defaults.js.map +1 -1
- package/build/store/reducer.js +24 -1
- package/build/store/reducer.js.map +1 -1
- package/build/store/selectors.js +9 -27
- package/build/store/selectors.js.map +1 -1
- package/build/utils/get-paste-event-data.js +1 -1
- package/build/utils/get-paste-event-data.js.map +1 -1
- package/build/utils/parse-css-unit-to-px.js +1 -1
- package/build/utils/parse-css-unit-to-px.js.map +1 -1
- package/build-module/components/block-caption/index.native.js +3 -13
- package/build-module/components/block-caption/index.native.js.map +1 -1
- package/build-module/components/block-inspector/index.js +33 -12
- package/build-module/components/block-inspector/index.js.map +1 -1
- package/build-module/components/block-list/block.js +1 -1
- package/build-module/components/block-list/block.js.map +1 -1
- package/build-module/components/block-list/block.native.js +2 -3
- package/build-module/components/block-list/block.native.js.map +1 -1
- package/build-module/components/block-list/use-block-props/index.js +1 -3
- package/build-module/components/block-list/use-block-props/index.js.map +1 -1
- package/build-module/components/block-list/use-in-between-inserter.js +1 -1
- package/build-module/components/block-list/use-in-between-inserter.js.map +1 -1
- package/build-module/components/block-list-appender/index.js +10 -3
- package/build-module/components/block-list-appender/index.js.map +1 -1
- package/build-module/components/block-mobile-toolbar/block-actions-menu.native.js +2 -2
- package/build-module/components/block-mobile-toolbar/block-actions-menu.native.js.map +1 -1
- package/build-module/components/block-mover/button.js +2 -2
- package/build-module/components/block-mover/button.js.map +1 -1
- package/build-module/components/block-mover/index.js +2 -2
- package/build-module/components/block-mover/index.js.map +1 -1
- package/build-module/components/block-mover/index.native.js +2 -2
- package/build-module/components/block-mover/index.native.js.map +1 -1
- package/build-module/components/block-preview/auto.js +2 -10
- package/build-module/components/block-preview/auto.js.map +1 -1
- package/build-module/components/block-settings/container.native.js +1 -2
- package/build-module/components/block-settings/container.native.js.map +1 -1
- package/build-module/components/block-styles/index.js +133 -112
- package/build-module/components/block-styles/index.js.map +1 -1
- package/build-module/components/block-styles/utils.js +0 -34
- package/build-module/components/block-styles/utils.js.map +1 -1
- package/build-module/components/block-switcher/block-styles-menu.js +21 -3
- package/build-module/components/block-switcher/block-styles-menu.js.map +1 -1
- package/build-module/components/block-tools/back-compat.js +1 -2
- package/build-module/components/block-tools/back-compat.js.map +1 -1
- package/build-module/components/block-tools/block-selection-button.js +3 -3
- package/build-module/components/block-tools/block-selection-button.js.map +1 -1
- package/build-module/components/block-tools/insertion-point.js +1 -11
- package/build-module/components/block-tools/insertion-point.js.map +1 -1
- package/build-module/components/button-block-appender/index.js +1 -2
- package/build-module/components/button-block-appender/index.js.map +1 -1
- package/build-module/components/colors-gradients/panel-color-gradient-settings.js +13 -54
- package/build-module/components/colors-gradients/panel-color-gradient-settings.js.map +1 -1
- package/build-module/components/default-block-appender/index.js +18 -15
- package/build-module/components/default-block-appender/index.js.map +1 -1
- package/build-module/components/default-style-picker/index.js +3 -17
- package/build-module/components/default-style-picker/index.js.map +1 -1
- package/build-module/components/iframe/index.js +4 -3
- package/build-module/components/iframe/index.js.map +1 -1
- package/build-module/components/index.js +1 -1
- package/build-module/components/index.js.map +1 -1
- package/build-module/components/inner-blocks/default-block-appender.js +4 -2
- package/build-module/components/inner-blocks/default-block-appender.js.map +1 -1
- package/build-module/components/inserter/hooks/use-insertion-point.js +2 -2
- package/build-module/components/inserter/hooks/use-insertion-point.js.map +1 -1
- package/build-module/components/inserter/index.js +2 -2
- package/build-module/components/inserter/index.js.map +1 -1
- package/build-module/components/inserter/index.native.js +4 -4
- package/build-module/components/inserter/index.native.js.map +1 -1
- package/build-module/components/inserter/quick-inserter.js +1 -1
- package/build-module/components/inserter/quick-inserter.js.map +1 -1
- package/build-module/components/inserter/tabs.native.js +4 -7
- package/build-module/components/inserter/tabs.native.js.map +1 -1
- package/build-module/components/inspector-controls/block-support-slot-container.js +1 -2
- package/build-module/components/inspector-controls/block-support-slot-container.js.map +1 -1
- package/build-module/components/inspector-controls/block-support-tools-panel.js +50 -22
- package/build-module/components/inspector-controls/block-support-tools-panel.js.map +1 -1
- package/build-module/components/inspector-controls/fill.native.js +5 -3
- package/build-module/components/inspector-controls/fill.native.js.map +1 -1
- package/build-module/components/inspector-controls/groups.js +0 -2
- package/build-module/components/inspector-controls/groups.js.map +1 -1
- package/build-module/components/inspector-controls/slot.js +3 -1
- package/build-module/components/inspector-controls/slot.js.map +1 -1
- package/build-module/components/letter-spacing-control/index.js +6 -6
- package/build-module/components/letter-spacing-control/index.js.map +1 -1
- package/build-module/components/list-view/block-select-button.js +3 -22
- package/build-module/components/list-view/block-select-button.js.map +1 -1
- package/build-module/components/list-view/use-list-view-drop-zone.js +1 -1
- package/build-module/components/list-view/use-list-view-drop-zone.js.map +1 -1
- package/build-module/components/media-placeholder/index.js +0 -2
- package/build-module/components/media-placeholder/index.js.map +1 -1
- package/build-module/components/media-replace-flow/index.js +0 -2
- package/build-module/components/media-replace-flow/index.js.map +1 -1
- package/build-module/components/provider/use-block-sync.js +41 -14
- package/build-module/components/provider/use-block-sync.js.map +1 -1
- package/build-module/components/rich-text/file-paste-handler.js +1 -1
- package/build-module/components/rich-text/file-paste-handler.js.map +1 -1
- package/build-module/components/rich-text/use-input-rules.js +1 -2
- package/build-module/components/rich-text/use-input-rules.js.map +1 -1
- package/build-module/components/selection-scroll-into-view/index.js +1 -2
- package/build-module/components/selection-scroll-into-view/index.js.map +1 -1
- package/build-module/components/use-canvas-click-redirect/index.js +54 -0
- package/build-module/components/use-canvas-click-redirect/index.js.map +1 -0
- package/build-module/components/use-on-block-drop/index.js +4 -8
- package/build-module/components/use-on-block-drop/index.js.map +1 -1
- package/build-module/components/use-setting/index.js +7 -0
- package/build-module/components/use-setting/index.js.map +1 -1
- package/build-module/components/writing-flow/use-multi-selection.js +4 -3
- package/build-module/components/writing-flow/use-multi-selection.js.map +1 -1
- package/build-module/hooks/border-color.js +7 -61
- package/build-module/hooks/border-color.js.map +1 -1
- package/build-module/hooks/border-radius.js +0 -42
- package/build-module/hooks/border-radius.js.map +1 -1
- package/build-module/hooks/border-style.js +0 -36
- package/build-module/hooks/border-style.js.map +1 -1
- package/build-module/hooks/border-width.js +32 -66
- package/build-module/hooks/border-width.js.map +1 -1
- package/build-module/hooks/border.js +12 -80
- package/build-module/hooks/border.js.map +1 -1
- package/build-module/hooks/letter-spacing.js +1 -1
- package/build-module/hooks/letter-spacing.js.map +1 -1
- package/build-module/hooks/typography.js +1 -1
- package/build-module/hooks/typography.js.map +1 -1
- package/build-module/layouts/flex.js +3 -27
- package/build-module/layouts/flex.js.map +1 -1
- package/build-module/store/actions.js +5 -4
- package/build-module/store/actions.js.map +1 -1
- package/build-module/store/defaults.js +1 -5
- package/build-module/store/defaults.js.map +1 -1
- package/build-module/store/reducer.js +24 -1
- package/build-module/store/reducer.js.map +1 -1
- package/build-module/store/selectors.js +9 -26
- package/build-module/store/selectors.js.map +1 -1
- package/build-module/utils/get-paste-event-data.js +1 -1
- package/build-module/utils/get-paste-event-data.js.map +1 -1
- package/build-module/utils/parse-css-unit-to-px.js +1 -1
- package/build-module/utils/parse-css-unit-to-px.js.map +1 -1
- package/build-style/style-rtl.css +180 -212
- package/build-style/style.css +180 -212
- package/package.json +27 -27
- package/src/components/block-caption/index.native.js +4 -22
- package/src/components/block-inspector/index.js +32 -13
- package/src/components/block-list/block.js +1 -1
- package/src/components/block-list/block.native.js +2 -2
- package/src/components/block-list/use-block-props/index.js +1 -3
- package/src/components/block-list/use-in-between-inserter.js +1 -1
- package/src/components/block-list-appender/index.js +21 -5
- package/src/components/block-mobile-toolbar/block-actions-menu.native.js +2 -5
- package/src/components/block-mover/button.js +2 -6
- package/src/components/block-mover/index.js +2 -5
- package/src/components/block-mover/index.native.js +2 -5
- package/src/components/block-preview/auto.js +2 -7
- package/src/components/block-settings/container.native.js +0 -1
- package/src/components/block-styles/index.js +145 -125
- package/src/components/block-styles/style.scss +51 -59
- package/src/components/block-styles/test/{utils.js → index.js} +1 -60
- package/src/components/block-styles/utils.js +0 -39
- package/src/components/block-switcher/block-styles-menu.js +38 -3
- package/src/components/block-tools/back-compat.js +0 -1
- package/src/components/block-tools/block-selection-button.js +3 -9
- package/src/components/block-tools/insertion-point.js +1 -10
- package/src/components/border-style-control/style.scss +1 -0
- package/src/components/button-block-appender/index.js +0 -1
- package/src/components/colors-gradients/panel-color-gradient-settings.js +19 -75
- package/src/components/colors-gradients/style.scss +5 -42
- package/src/components/default-block-appender/index.js +24 -17
- package/src/components/default-block-appender/style.scss +0 -4
- package/src/components/default-block-appender/test/__snapshots__/index.js.snap +24 -12
- package/src/components/default-block-appender/test/index.js +14 -4
- package/src/components/default-style-picker/index.js +6 -18
- package/src/components/iframe/index.js +3 -6
- package/src/components/index.js +1 -1
- package/src/components/inner-blocks/README.md +0 -2
- package/src/components/inner-blocks/default-block-appender.js +7 -2
- package/src/components/inserter/hooks/use-insertion-point.js +2 -9
- package/src/components/inserter/index.js +2 -2
- package/src/components/inserter/index.native.js +4 -7
- package/src/components/inserter/quick-inserter.js +1 -1
- package/src/components/inserter/tabs.native.js +4 -5
- package/src/components/inspector-controls/block-support-slot-container.js +1 -3
- package/src/components/inspector-controls/block-support-tools-panel.js +57 -21
- package/src/components/inspector-controls/fill.native.js +3 -4
- package/src/components/inspector-controls/groups.js +0 -2
- package/src/components/inspector-controls/slot.js +7 -2
- package/src/components/letter-spacing-control/index.js +6 -6
- package/src/components/link-control/README.md +1 -1
- package/src/components/link-control/test/index.js +0 -2
- package/src/components/list-view/block-select-button.js +1 -20
- package/src/components/list-view/use-list-view-drop-zone.js +1 -1
- package/src/components/media-placeholder/index.js +0 -2
- package/src/components/media-replace-flow/index.js +0 -2
- package/src/components/provider/use-block-sync.js +45 -11
- package/src/components/rich-text/file-paste-handler.js +1 -3
- package/src/components/rich-text/use-input-rules.js +1 -2
- package/src/components/selection-scroll-into-view/index.js +0 -1
- package/src/components/url-input/README.md +0 -5
- package/src/components/use-canvas-click-redirect/index.js +57 -0
- package/src/components/use-on-block-drop/index.js +4 -11
- package/src/components/use-setting/index.js +9 -0
- package/src/components/writing-flow/use-multi-selection.js +9 -12
- package/src/hooks/border-color.js +3 -55
- package/src/hooks/border-radius.js +0 -32
- package/src/hooks/border-style.js +0 -26
- package/src/hooks/border-width.js +32 -56
- package/src/hooks/border.js +20 -115
- package/src/hooks/border.scss +17 -3
- package/src/hooks/letter-spacing.js +1 -1
- package/src/hooks/typography.js +1 -1
- package/src/layouts/flex.js +4 -25
- package/src/store/actions.js +5 -5
- package/src/store/defaults.js +0 -2
- package/src/store/reducer.js +23 -1
- package/src/store/selectors.js +9 -39
- package/src/store/test/reducer.js +35 -0
- package/src/store/test/selectors.js +1 -1
- package/src/style.scss +3 -4
- package/src/utils/get-paste-event-data.js +1 -1
- package/src/utils/parse-css-unit-to-px.js +1 -1
- package/src/utils/test/parse-css-unit-to-px.js +0 -1
- package/tsconfig.tsbuildinfo +1 -1
- package/build/components/block-styles/menu-items.js +0 -63
- package/build/components/block-styles/menu-items.js.map +0 -1
- package/build/components/block-styles/preview-panel.js +0 -45
- package/build/components/block-styles/preview-panel.js.map +0 -1
- package/build/components/block-styles/use-styles-for-block.js +0 -119
- package/build/components/block-styles/use-styles-for-block.js.map +0 -1
- package/build/components/rich-text/prevent-event-discovery.js +0 -33
- package/build/components/rich-text/prevent-event-discovery.js.map +0 -1
- package/build/components/use-display-block-controls/index.native.js +0 -45
- package/build/components/use-display-block-controls/index.native.js.map +0 -1
- package/build-module/components/block-styles/menu-items.js +0 -50
- package/build-module/components/block-styles/menu-items.js.map +0 -1
- package/build-module/components/block-styles/preview-panel.js +0 -35
- package/build-module/components/block-styles/preview-panel.js.map +0 -1
- package/build-module/components/block-styles/use-styles-for-block.js +0 -107
- package/build-module/components/block-styles/use-styles-for-block.js.map +0 -1
- package/build-module/components/rich-text/prevent-event-discovery.js +0 -25
- package/build-module/components/rich-text/prevent-event-discovery.js.map +0 -1
- package/build-module/components/use-display-block-controls/index.native.js +0 -34
- package/build-module/components/use-display-block-controls/index.native.js.map +0 -1
- package/src/components/block-styles/menu-items.js +0 -49
- package/src/components/block-styles/preview-panel.js +0 -36
- package/src/components/block-styles/use-styles-for-block.js +0 -99
- package/src/components/rich-text/prevent-event-discovery.js +0 -23
- package/src/components/use-display-block-controls/index.native.js +0 -38
- package/src/components/writing-flow/test/use-multi-selection.js +0 -36
- package/src/hooks/dimensions.scss +0 -5
|
@@ -29,17 +29,41 @@ function BlockSupportToolsPanel(_ref) {
|
|
|
29
29
|
label
|
|
30
30
|
} = _ref;
|
|
31
31
|
const {
|
|
32
|
-
|
|
33
|
-
|
|
32
|
+
attributes,
|
|
33
|
+
clientIds,
|
|
34
|
+
panelId
|
|
34
35
|
} = (0, _data.useSelect)(select => {
|
|
35
36
|
const {
|
|
36
37
|
getBlockAttributes,
|
|
37
|
-
|
|
38
|
-
|
|
38
|
+
getMultiSelectedBlockClientIds,
|
|
39
|
+
getSelectedBlockClientId,
|
|
40
|
+
hasMultiSelection
|
|
41
|
+
} = select(_store.store); // When we currently have a multi-selection, the value returned from
|
|
42
|
+
// `getSelectedBlockClientId()` is `null`. When a `null` value is used
|
|
43
|
+
// for the `panelId`, a `ToolsPanel` will still allow panel items to
|
|
44
|
+
// register themselves despite their panelIds not matching.
|
|
45
|
+
|
|
39
46
|
const selectedBlockClientId = getSelectedBlockClientId();
|
|
47
|
+
|
|
48
|
+
if (hasMultiSelection()) {
|
|
49
|
+
const selectedBlockClientIds = getMultiSelectedBlockClientIds();
|
|
50
|
+
const selectedBlockAttributes = selectedBlockClientIds.reduce((blockAttributes, blockId) => {
|
|
51
|
+
blockAttributes[blockId] = getBlockAttributes(blockId);
|
|
52
|
+
return blockAttributes;
|
|
53
|
+
}, {});
|
|
54
|
+
return {
|
|
55
|
+
panelId: selectedBlockClientId,
|
|
56
|
+
clientIds: selectedBlockClientIds,
|
|
57
|
+
attributes: selectedBlockAttributes
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
|
|
40
61
|
return {
|
|
41
|
-
|
|
42
|
-
|
|
62
|
+
panelId: selectedBlockClientId,
|
|
63
|
+
clientIds: [selectedBlockClientId],
|
|
64
|
+
attributes: {
|
|
65
|
+
[selectedBlockClientId]: getBlockAttributes(selectedBlockClientId)
|
|
66
|
+
}
|
|
43
67
|
};
|
|
44
68
|
}, []);
|
|
45
69
|
const {
|
|
@@ -48,30 +72,34 @@ function BlockSupportToolsPanel(_ref) {
|
|
|
48
72
|
|
|
49
73
|
const resetAll = function () {
|
|
50
74
|
let resetFilters = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
51
|
-
const {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
newAttributes = { ...newAttributes,
|
|
59
|
-
...resetFilter(newAttributes)
|
|
75
|
+
const newAttributes = {};
|
|
76
|
+
clientIds.forEach(clientId => {
|
|
77
|
+
const {
|
|
78
|
+
style
|
|
79
|
+
} = attributes[clientId];
|
|
80
|
+
let newBlockAttributes = {
|
|
81
|
+
style
|
|
60
82
|
};
|
|
61
|
-
|
|
83
|
+
resetFilters.forEach(resetFilter => {
|
|
84
|
+
newBlockAttributes = { ...newBlockAttributes,
|
|
85
|
+
...resetFilter(newBlockAttributes)
|
|
86
|
+
};
|
|
87
|
+
}); // Enforce a cleaned style object.
|
|
62
88
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
89
|
+
newBlockAttributes = { ...newBlockAttributes,
|
|
90
|
+
style: (0, _utils.cleanEmptyObject)(newBlockAttributes.style)
|
|
91
|
+
};
|
|
92
|
+
newAttributes[clientId] = newBlockAttributes;
|
|
93
|
+
});
|
|
94
|
+
updateBlockAttributes(clientIds, newAttributes, true);
|
|
67
95
|
};
|
|
68
96
|
|
|
69
97
|
return (0, _element.createElement)(_components.__experimentalToolsPanel, {
|
|
70
98
|
className: `${group}-block-support-panel`,
|
|
71
99
|
label: label,
|
|
72
100
|
resetAll: resetAll,
|
|
73
|
-
key:
|
|
74
|
-
panelId:
|
|
101
|
+
key: panelId,
|
|
102
|
+
panelId: panelId,
|
|
75
103
|
hasInnerWrapper: true,
|
|
76
104
|
shouldRenderPlaceholderItems: true // Required to maintain fills ordering.
|
|
77
105
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/inspector-controls/block-support-tools-panel.js"],"names":["BlockSupportToolsPanel","children","group","label","
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/inspector-controls/block-support-tools-panel.js"],"names":["BlockSupportToolsPanel","children","group","label","attributes","clientIds","panelId","select","getBlockAttributes","getMultiSelectedBlockClientIds","getSelectedBlockClientId","hasMultiSelection","blockEditorStore","selectedBlockClientId","selectedBlockClientIds","selectedBlockAttributes","reduce","blockAttributes","blockId","updateBlockAttributes","resetAll","resetFilters","newAttributes","forEach","clientId","style","newBlockAttributes","resetFilter"],"mappings":";;;;;;;;;AAGA;;AACA;;AAKA;;AACA;;AAVA;AACA;AACA;;AAIA;AACA;AACA;AAIe,SAASA,sBAAT,OAA8D;AAAA,MAA7B;AAAEC,IAAAA,QAAF;AAAYC,IAAAA,KAAZ;AAAmBC,IAAAA;AAAnB,GAA6B;AAC5E,QAAM;AAAEC,IAAAA,UAAF;AAAcC,IAAAA,SAAd;AAAyBC,IAAAA;AAAzB,MAAqC,qBAAaC,MAAF,IAAc;AACnE,UAAM;AACLC,MAAAA,kBADK;AAELC,MAAAA,8BAFK;AAGLC,MAAAA,wBAHK;AAILC,MAAAA;AAJK,QAKFJ,MAAM,CAAEK,YAAF,CALV,CADmE,CAQnE;AACA;AACA;AACA;;AACA,UAAMC,qBAAqB,GAAGH,wBAAwB,EAAtD;;AAEA,QAAKC,iBAAiB,EAAtB,EAA2B;AAC1B,YAAMG,sBAAsB,GAAGL,8BAA8B,EAA7D;AACA,YAAMM,uBAAuB,GAAGD,sBAAsB,CAACE,MAAvB,CAC/B,CAAEC,eAAF,EAAmBC,OAAnB,KAAgC;AAC/BD,QAAAA,eAAe,CAAEC,OAAF,CAAf,GAA6BV,kBAAkB,CAAEU,OAAF,CAA/C;AACA,eAAOD,eAAP;AACA,OAJ8B,EAK/B,EAL+B,CAAhC;AAQA,aAAO;AACNX,QAA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A,QAAQ,EAAGiB,QAHZ;AAIC,IAAA,GAAG,EAAGd,OAJP;AAKC,IAAA,OAAO,EAAGA,OALX;AAMC,IAAA,eAAe,EAAG,IANnB;AAOC,IAAA,4BAA4B,EAAG,IAPhC,CAOuC;;AAPvC,KASGL,QATH,CADD;AAaA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __experimentalToolsPanel as ToolsPanel } from '@wordpress/components';\nimport { useDispatch, useSelect } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\nimport { cleanEmptyObject } from '../../hooks/utils';\n\nexport default function BlockSupportToolsPanel( { children, group, label } ) {\n\tconst { attributes, clientIds, panelId } = useSelect( ( select ) => {\n\t\tconst {\n\t\t\tgetBlockAttributes,\n\t\t\tgetMultiSelectedBlockClientIds,\n\t\t\tgetSelectedBlockClientId,\n\t\t\thasMultiSelection,\n\t\t} = select( blockEditorStore );\n\n\t\t// When we currently have a multi-selection, the value returned from\n\t\t// `getSelectedBlockClientId()` is `null`. When a `null` value is used\n\t\t// for the `panelId`, a `ToolsPanel` will still allow panel items to\n\t\t// register themselves despite their panelIds not matching.\n\t\tconst selectedBlockClientId = getSelectedBlockClientId();\n\n\t\tif ( hasMultiSelection() ) {\n\t\t\tconst selectedBlockClientIds = getMultiSelectedBlockClientIds();\n\t\t\tconst selectedBlockAttributes = selectedBlockClientIds.reduce(\n\t\t\t\t( blockAttributes, blockId ) => {\n\t\t\t\t\tblockAttributes[ blockId ] = getBlockAttributes( blockId );\n\t\t\t\t\treturn blockAttributes;\n\t\t\t\t},\n\t\t\t\t{}\n\t\t\t);\n\n\t\t\treturn {\n\t\t\t\tpanelId: selectedBlockClientId,\n\t\t\t\tclientIds: selectedBlockClientIds,\n\t\t\t\tattributes: selectedBlockAttributes,\n\t\t\t};\n\t\t}\n\n\t\treturn {\n\t\t\tpanelId: selectedBlockClientId,\n\t\t\tclientIds: [ selectedBlockClientId ],\n\t\t\tattributes: {\n\t\t\t\t[ selectedBlockClientId ]: getBlockAttributes(\n\t\t\t\t\tselectedBlockClientId\n\t\t\t\t),\n\t\t\t},\n\t\t};\n\t}, [] );\n\tconst { updateBlockAttributes } = useDispatch( blockEditorStore );\n\n\tconst resetAll = ( resetFilters = [] ) => {\n\t\tconst newAttributes = {};\n\n\t\tclientIds.forEach( ( clientId ) => {\n\t\t\tconst { style } = attributes[ clientId ];\n\t\t\tlet newBlockAttributes = { style };\n\n\t\t\tresetFilters.forEach( ( resetFilter ) => {\n\t\t\t\tnewBlockAttributes = {\n\t\t\t\t\t...newBlockAttributes,\n\t\t\t\t\t...resetFilter( newBlockAttributes ),\n\t\t\t\t};\n\t\t\t} );\n\n\t\t\t// Enforce a cleaned style object.\n\t\t\tnewBlockAttributes = {\n\t\t\t\t...newBlockAttributes,\n\t\t\t\tstyle: cleanEmptyObject( newBlockAttributes.style ),\n\t\t\t};\n\n\t\t\tnewAttributes[ clientId ] = newBlockAttributes;\n\t\t} );\n\n\t\tupdateBlockAttributes( clientIds, newAttributes, true );\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={ true }\n\t\t\tshouldRenderPlaceholderItems={ true } // Required to maintain fills ordering.\n\t\t>\n\t\t\t{ children }\n\t\t</ToolsPanel>\n\t);\n}\n"]}
|
|
@@ -17,7 +17,7 @@ var _warning = _interopRequireDefault(require("@wordpress/warning"));
|
|
|
17
17
|
|
|
18
18
|
var _groups = _interopRequireDefault(require("./groups"));
|
|
19
19
|
|
|
20
|
-
var
|
|
20
|
+
var _context = require("../block-edit/context");
|
|
21
21
|
|
|
22
22
|
var _blockSettings = require("../block-settings");
|
|
23
23
|
|
|
@@ -40,7 +40,9 @@ function InspectorControlsFill(_ref) {
|
|
|
40
40
|
__experimentalGroup: group = 'default',
|
|
41
41
|
...props
|
|
42
42
|
} = _ref;
|
|
43
|
-
const
|
|
43
|
+
const {
|
|
44
|
+
isSelected
|
|
45
|
+
} = (0, _context.useBlockEditContext)();
|
|
44
46
|
const Fill = (_groups$group = _groups.default[group]) === null || _groups$group === void 0 ? void 0 : _groups$group.Fill;
|
|
45
47
|
|
|
46
48
|
if (!Fill) {
|
|
@@ -48,7 +50,7 @@ function InspectorControlsFill(_ref) {
|
|
|
48
50
|
return null;
|
|
49
51
|
}
|
|
50
52
|
|
|
51
|
-
if (!
|
|
53
|
+
if (!isSelected) {
|
|
52
54
|
return null;
|
|
53
55
|
}
|
|
54
56
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/inspector-controls/fill.native.js"],"names":["InspectorControlsFill","children","__experimentalGroup","group","props","
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/inspector-controls/fill.native.js"],"names":["InspectorControlsFill","children","__experimentalGroup","group","props","isSelected","Fill","groups","Children","count"],"mappings":";;;;;;;;;AAQA;;AALA;;AAMA;;AACA;;AAKA;;AACA;;AACA;;AAjBA;AACA;AACA;;AAGA;AACA;AACA;;AAKA;AACA;AACA;AAKe,SAASA,qBAAT,OAIX;AAAA;;AAAA,MAJ2C;AAC9CC,IAAAA,QAD8C;AAE9CC,IAAAA,mBAAmB,EAAEC,KAAK,GAAG,SAFiB;AAG9C,OAAGC;AAH2C,GAI3C;AACH,QAAM;AAAEC,IAAAA;AAAF,MAAiB,mCAAvB;AACA,QAAMC,IAAI,oBAAGC,gBAAQJ,KAAR,CAAH,kDAAG,cAAiBG,IAA9B;;AACA,MAAK,CAAEA,IAAP,EAAc;AACb,mHAAU,mCAAmCH,KAAO,aAApD;AACA,WAAO,IAAP;AACA;;AACD,MAAK,CAAEE,UAAP,EAAoB;AACnB,WAAO,IAAP;AACA;;AAED,SACC,qDACC,4BAAC,IAAD,EAAWD,KAAX,EAEE,4BAAC,+BAAD,QACG,MAAM,4BAAC,iBAAD,QAAQH,QAAR,CADT,CAFF,CADD,EAQGO,kBAASC,KAAT,CAAgBR,QAAhB,IAA6B,CAA7B,IAAkC,4BAAC,kCAAD,OARrC,CADD;AAYA","sourcesContent":["/**\n * External dependencies\n */\nimport { View } from 'react-native';\n\n/**\n * WordPress dependencies\n */\nimport { Children } from '@wordpress/element';\nimport { BottomSheetConsumer } from '@wordpress/components';\nimport warning from '@wordpress/warning';\n\n/**\n * Internal dependencies\n */\nimport groups from './groups';\nimport { useBlockEditContext } from '../block-edit/context';\nimport { BlockSettingsButton } from '../block-settings';\n\nexport default function InspectorControlsFill( {\n\tchildren,\n\t__experimentalGroup: group = 'default',\n\t...props\n} ) {\n\tconst { isSelected } = useBlockEditContext();\n\tconst Fill = groups[ group ]?.Fill;\n\tif ( ! Fill ) {\n\t\twarning( `Unknown InspectorControl group \"${ group }\" provided.` );\n\t\treturn null;\n\t}\n\tif ( ! isSelected ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t<Fill { ...props }>\n\t\t\t\t{\n\t\t\t\t\t<BottomSheetConsumer>\n\t\t\t\t\t\t{ () => <View>{ children }</View> }\n\t\t\t\t\t</BottomSheetConsumer>\n\t\t\t\t}\n\t\t\t</Fill>\n\t\t\t{ Children.count( children ) > 0 && <BlockSettingsButton /> }\n\t\t</>\n\t);\n}\n"]}
|
|
@@ -12,13 +12,11 @@ var _components = require("@wordpress/components");
|
|
|
12
12
|
*/
|
|
13
13
|
const InspectorControlsDefault = (0, _components.createSlotFill)('InspectorControls');
|
|
14
14
|
const InspectorControlsAdvanced = (0, _components.createSlotFill)('InspectorAdvancedControls');
|
|
15
|
-
const InspectorControlsBorder = (0, _components.createSlotFill)('InspectorControlsBorder');
|
|
16
15
|
const InspectorControlsDimensions = (0, _components.createSlotFill)('InspectorControlsDimensions');
|
|
17
16
|
const InspectorControlsTypography = (0, _components.createSlotFill)('InspectorControlsTypography');
|
|
18
17
|
const groups = {
|
|
19
18
|
default: InspectorControlsDefault,
|
|
20
19
|
advanced: InspectorControlsAdvanced,
|
|
21
|
-
border: InspectorControlsBorder,
|
|
22
20
|
dimensions: InspectorControlsDimensions,
|
|
23
21
|
typography: InspectorControlsTypography
|
|
24
22
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/inspector-controls/groups.js"],"names":["InspectorControlsDefault","InspectorControlsAdvanced","
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/inspector-controls/groups.js"],"names":["InspectorControlsDefault","InspectorControlsAdvanced","InspectorControlsDimensions","InspectorControlsTypography","groups","default","advanced","dimensions","typography"],"mappings":";;;;;;;AAGA;;AAHA;AACA;AACA;AAGA,MAAMA,wBAAwB,GAAG,gCAAgB,mBAAhB,CAAjC;AACA,MAAMC,yBAAyB,GAAG,gCAAgB,2BAAhB,CAAlC;AACA,MAAMC,2BAA2B,GAAG,gCACnC,6BADmC,CAApC;AAGA,MAAMC,2BAA2B,GAAG,gCACnC,6BADmC,CAApC;AAIA,MAAMC,MAAM,GAAG;AACdC,EAAAA,OAAO,EAAEL,wBADK;AAEdM,EAAAA,QAAQ,EAAEL,yBAFI;AAGdM,EAAAA,UAAU,EAAEL,2BAHE;AAIdM,EAAAA,UAAU,EAAEL;AAJE,CAAf;eAOeC,M","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { createSlotFill } from '@wordpress/components';\n\nconst InspectorControlsDefault = createSlotFill( 'InspectorControls' );\nconst InspectorControlsAdvanced = createSlotFill( 'InspectorAdvancedControls' );\nconst InspectorControlsDimensions = createSlotFill(\n\t'InspectorControlsDimensions'\n);\nconst InspectorControlsTypography = createSlotFill(\n\t'InspectorControlsTypography'\n);\n\nconst groups = {\n\tdefault: InspectorControlsDefault,\n\tadvanced: InspectorControlsAdvanced,\n\tdimensions: InspectorControlsDimensions,\n\ttypography: InspectorControlsTypography,\n};\n\nexport default groups;\n"]}
|
|
@@ -33,6 +33,7 @@ function InspectorControlsSlot(_ref) {
|
|
|
33
33
|
|
|
34
34
|
let {
|
|
35
35
|
__experimentalGroup: group = 'default',
|
|
36
|
+
bubblesVirtually = true,
|
|
36
37
|
label,
|
|
37
38
|
...props
|
|
38
39
|
} = _ref;
|
|
@@ -55,12 +56,13 @@ function InspectorControlsSlot(_ref) {
|
|
|
55
56
|
group: group,
|
|
56
57
|
label: label
|
|
57
58
|
}, (0, _element.createElement)(_blockSupportSlotContainer.default, (0, _extends2.default)({}, props, {
|
|
59
|
+
bubblesVirtually: bubblesVirtually,
|
|
58
60
|
Slot: Slot
|
|
59
61
|
})));
|
|
60
62
|
}
|
|
61
63
|
|
|
62
64
|
return (0, _element.createElement)(Slot, (0, _extends2.default)({}, props, {
|
|
63
|
-
bubblesVirtually:
|
|
65
|
+
bubblesVirtually: bubblesVirtually
|
|
64
66
|
}));
|
|
65
67
|
}
|
|
66
68
|
//# sourceMappingURL=slot.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/inspector-controls/slot.js"],"names":["InspectorControlsSlot","__experimentalGroup","group","label","props","Slot","groups","slot","__unstableName","hasFills","Boolean","fills","length"],"mappings":";;;;;;;;;;;;;AAGA;;AACA;;AAKA;;AACA;;AACA;;AAXA;AACA;AACA;;AAIA;AACA;AACA;AAKe,SAASA,qBAAT,
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/inspector-controls/slot.js"],"names":["InspectorControlsSlot","__experimentalGroup","group","bubblesVirtually","label","props","Slot","groups","slot","__unstableName","hasFills","Boolean","fills","length"],"mappings":";;;;;;;;;;;;;AAGA;;AACA;;AAKA;;AACA;;AACA;;AAXA;AACA;AACA;;AAIA;AACA;AACA;AAKe,SAASA,qBAAT,OAKX;AAAA;;AAAA,MAL2C;AAC9CC,IAAAA,mBAAmB,EAAEC,KAAK,GAAG,SADiB;AAE9CC,IAAAA,gBAAgB,GAAG,IAF2B;AAG9CC,IAAAA,KAH8C;AAI9C,OAAGC;AAJ2C,GAK3C;AACH,QAAMC,IAAI,oBAAGC,gBAAQL,KAAR,CAAH,kDAAG,cAAiBI,IAA9B;AACA,QAAME,IAAI,GAAG,uCAASF,IAAT,aAASA,IAAT,uBAASA,IAAI,CAAEG,cAAf,CAAb;;AACA,MAAK,CAAEH,IAAF,IAAU,CAAEE,IAAjB,EAAwB;AACvB,mHAAU,mCAAmCN,KAAO,aAApD;AACA,WAAO,IAAP;AACA;;AAED,QAAMQ,QAAQ,GAAGC,OAAO,CAAEH,IAAI,CAACI,KAAL,IAAcJ,IAAI,CAACI,KAAL,CAAWC,MAA3B,CAAxB;;AACA,MAAK,CAAEH,QAAP,EAAkB;AACjB,WAAO,IAAP;AACA;;AAED,MAAKN,KAAL,EAAa;AACZ,WACC,4BAAC,+BAAD;AAAwB,MAAA,KAAK,EAAGF,KAAhC;AAAwC,MAAA,KAAK,EAAGE;AAAhD,OACC,4BAAC,kCAAD,6BACMC,KADN;AAEC,MAAA,gBAAgB,EAAGF,gBAFpB;AAGC,MAAA,IAAI,EAAGG;AAHR,OADD,CADD;AASA;;AAED,SAAO,4BAAC,IAAD,6BAAWD,KAAX;AAAmB,IAAA,gBAAgB,EAAGF;AAAtC,KAAP;AACA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __experimentalUseSlot as useSlot } from '@wordpress/components';\nimport warning from '@wordpress/warning';\n\n/**\n * Internal dependencies\n */\nimport BlockSupportToolsPanel from './block-support-tools-panel';\nimport BlockSupportSlotContainer from './block-support-slot-container';\nimport groups from './groups';\n\nexport default function InspectorControlsSlot( {\n\t__experimentalGroup: group = 'default',\n\tbubblesVirtually = true,\n\tlabel,\n\t...props\n} ) {\n\tconst Slot = groups[ group ]?.Slot;\n\tconst slot = useSlot( Slot?.__unstableName );\n\tif ( ! Slot || ! slot ) {\n\t\twarning( `Unknown InspectorControl group \"${ group }\" provided.` );\n\t\treturn null;\n\t}\n\n\tconst hasFills = Boolean( slot.fills && slot.fills.length );\n\tif ( ! hasFills ) {\n\t\treturn null;\n\t}\n\n\tif ( label ) {\n\t\treturn (\n\t\t\t<BlockSupportToolsPanel group={ group } label={ label }>\n\t\t\t\t<BlockSupportSlotContainer\n\t\t\t\t\t{ ...props }\n\t\t\t\t\tbubblesVirtually={ bubblesVirtually }\n\t\t\t\t\tSlot={ Slot }\n\t\t\t\t/>\n\t\t\t</BlockSupportToolsPanel>\n\t\t);\n\t}\n\n\treturn <Slot { ...props } bubblesVirtually={ bubblesVirtually } />;\n}\n"]}
|
|
@@ -26,12 +26,12 @@ var _useSetting = _interopRequireDefault(require("../../components/use-setting")
|
|
|
26
26
|
/**
|
|
27
27
|
* Control for letter-spacing.
|
|
28
28
|
*
|
|
29
|
-
* @param {Object}
|
|
30
|
-
* @param {string}
|
|
31
|
-
* @param {Function}
|
|
32
|
-
* @param {
|
|
29
|
+
* @param {Object} props Component props.
|
|
30
|
+
* @param {string} props.value Currently selected letter-spacing.
|
|
31
|
+
* @param {Function} props.onChange Handles change in letter-spacing selection.
|
|
32
|
+
* @param {boolean} props.__unstableInputWidth Input width to pass through to inner UnitControl.
|
|
33
33
|
*
|
|
34
|
-
* @return {WPElement}
|
|
34
|
+
* @return {WPElement} Letter-spacing control.
|
|
35
35
|
*/
|
|
36
36
|
function LetterSpacingControl(_ref) {
|
|
37
37
|
let {
|
|
@@ -48,7 +48,7 @@ function LetterSpacingControl(_ref) {
|
|
|
48
48
|
}
|
|
49
49
|
});
|
|
50
50
|
return (0, _element.createElement)(_components.__experimentalUnitControl, {
|
|
51
|
-
label: (0, _i18n.__)('Letter
|
|
51
|
+
label: (0, _i18n.__)('Letter-spacing'),
|
|
52
52
|
value: value,
|
|
53
53
|
__unstableInputWidth: __unstableInputWidth,
|
|
54
54
|
units: units,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/letter-spacing-control/index.js"],"names":["LetterSpacingControl","value","onChange","__unstableInputWidth","units","availableUnits","defaultValues","px","em","rem"],"mappings":";;;;;;;;;;;AAGA;;AAIA;;AAKA;;AAZA;AACA;AACA;;AAOA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACe,SAASA,oBAAT,OAIX;AAAA,MAJ0C;AAC7CC,IAAAA,KAD6C;AAE7CC,IAAAA,QAF6C;AAG7CC,IAAAA,oBAAoB,GAAG;AAHsB,GAI1C;AACH,QAAMC,KAAK,GAAG,8CAAgB;AAC7BC,IAAAA,cAAc,EAAE,yBAAY,eAAZ,KAAiC,CAAE,IAAF,EAAQ,IAAR,EAAc,KAAd,CADpB;AAE7BC,IAAAA,aAAa,EAAE;AAAEC,MAAAA,EAAE,EAAE,GAAN;AAAWC,MAAAA,EAAE,EAAE,IAAf;AAAqBC,MAAAA,GAAG,EAAE;AAA1B;AAFc,GAAhB,CAAd;AAIA,SACC,4BAAC,qCAAD;AACC,IAAA,KAAK,EAAG,cAAI,gBAAJ,CADT;AAEC,IAAA,KAAK,EAAGR,KAFT;AAGC,IAAA,oBAAoB,EAAGE,oBAHxB;AAIC,IAAA,KAAK,EAAGC,KAJT;AAKC,IAAA,QAAQ,EAAGF;AALZ,IADD;AASA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\t__experimentalUnitControl as UnitControl,\n\t__experimentalUseCustomUnits as useCustomUnits,\n} from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport useSetting from '../../components/use-setting';\n\n/**\n * Control for letter-spacing.\n *\n * @param {Object}
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/letter-spacing-control/index.js"],"names":["LetterSpacingControl","value","onChange","__unstableInputWidth","units","availableUnits","defaultValues","px","em","rem"],"mappings":";;;;;;;;;;;AAGA;;AAIA;;AAKA;;AAZA;AACA;AACA;;AAOA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACe,SAASA,oBAAT,OAIX;AAAA,MAJ0C;AAC7CC,IAAAA,KAD6C;AAE7CC,IAAAA,QAF6C;AAG7CC,IAAAA,oBAAoB,GAAG;AAHsB,GAI1C;AACH,QAAMC,KAAK,GAAG,8CAAgB;AAC7BC,IAAAA,cAAc,EAAE,yBAAY,eAAZ,KAAiC,CAAE,IAAF,EAAQ,IAAR,EAAc,KAAd,CADpB;AAE7BC,IAAAA,aAAa,EAAE;AAAEC,MAAAA,EAAE,EAAE,GAAN;AAAWC,MAAAA,EAAE,EAAE,IAAf;AAAqBC,MAAAA,GAAG,EAAE;AAA1B;AAFc,GAAhB,CAAd;AAIA,SACC,4BAAC,qCAAD;AACC,IAAA,KAAK,EAAG,cAAI,gBAAJ,CADT;AAEC,IAAA,KAAK,EAAGR,KAFT;AAGC,IAAA,oBAAoB,EAAGE,oBAHxB;AAIC,IAAA,KAAK,EAAGC,KAJT;AAKC,IAAA,QAAQ,EAAGF;AALZ,IADD;AASA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\t__experimentalUnitControl as UnitControl,\n\t__experimentalUseCustomUnits as useCustomUnits,\n} from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport useSetting from '../../components/use-setting';\n\n/**\n * Control for letter-spacing.\n *\n * @param {Object} props Component props.\n * @param {string} props.value Currently selected letter-spacing.\n * @param {Function} props.onChange Handles change in letter-spacing selection.\n * @param {boolean} props.__unstableInputWidth Input width to pass through to inner UnitControl.\n *\n * @return {WPElement} Letter-spacing control.\n */\nexport default function LetterSpacingControl( {\n\tvalue,\n\tonChange,\n\t__unstableInputWidth = '60px',\n} ) {\n\tconst units = useCustomUnits( {\n\t\tavailableUnits: useSetting( 'spacing.units' ) || [ 'px', 'em', 'rem' ],\n\t\tdefaultValues: { px: '2', em: '.2', rem: '.2' },\n\t} );\n\treturn (\n\t\t<UnitControl\n\t\t\tlabel={ __( 'Letter-spacing' ) }\n\t\t\tvalue={ value }\n\t\t\t__unstableInputWidth={ __unstableInputWidth }\n\t\t\tunits={ units }\n\t\t\tonChange={ onChange }\n\t\t/>\n\t);\n}\n"]}
|
|
@@ -27,8 +27,6 @@ var _blockTitle = _interopRequireDefault(require("../block-title"));
|
|
|
27
27
|
|
|
28
28
|
var _expander = _interopRequireDefault(require("./expander"));
|
|
29
29
|
|
|
30
|
-
var _keycodes = require("@wordpress/keycodes");
|
|
31
|
-
|
|
32
30
|
/**
|
|
33
31
|
* External dependencies
|
|
34
32
|
*/
|
|
@@ -61,35 +59,17 @@ function ListViewBlockSelectButton(_ref, ref) {
|
|
|
61
59
|
const blockInformation = (0, _useBlockDisplayInformation.default)(clientId);
|
|
62
60
|
const instanceId = (0, _compose.useInstanceId)(ListViewBlockSelectButton);
|
|
63
61
|
const descriptionId = `list-view-block-select-button__${instanceId}`;
|
|
64
|
-
const blockPositionDescription = (0, _utils.getBlockPositionDescription)(position, siblingBlockCount, level);
|
|
65
|
-
// When the link is dragged, the element's outerHTML is set in DataTransfer object as text/html.
|
|
66
|
-
// We need to clear any HTML drag data to prevent `pasteHandler` from firing
|
|
67
|
-
// inside the `useOnBlockDrop` hook.
|
|
68
|
-
|
|
69
|
-
const onDragStartHandler = event => {
|
|
70
|
-
event.dataTransfer.clearData();
|
|
71
|
-
onDragStart(event);
|
|
72
|
-
};
|
|
73
|
-
|
|
74
|
-
function onKeyDownHandler(event) {
|
|
75
|
-
if (event.keyCode === _keycodes.ENTER || event.keyCode === _keycodes.SPACE) {
|
|
76
|
-
event.preventDefault();
|
|
77
|
-
onClick(event);
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
|
|
62
|
+
const blockPositionDescription = (0, _utils.getBlockPositionDescription)(position, siblingBlockCount, level);
|
|
81
63
|
return (0, _element.createElement)(_element.Fragment, null, (0, _element.createElement)(_components.Button, {
|
|
82
64
|
className: (0, _classnames.default)('block-editor-list-view-block-select-button', className),
|
|
83
65
|
onClick: onClick,
|
|
84
|
-
onKeyDown: onKeyDownHandler,
|
|
85
66
|
"aria-describedby": descriptionId,
|
|
86
67
|
ref: ref,
|
|
87
68
|
tabIndex: tabIndex,
|
|
88
69
|
onFocus: onFocus,
|
|
89
|
-
onDragStart:
|
|
70
|
+
onDragStart: onDragStart,
|
|
90
71
|
onDragEnd: onDragEnd,
|
|
91
|
-
draggable: draggable
|
|
92
|
-
href: `#block-${clientId}`
|
|
72
|
+
draggable: draggable
|
|
93
73
|
}, (0, _element.createElement)(_expander.default, {
|
|
94
74
|
onClick: onToggleExpanded
|
|
95
75
|
}), (0, _element.createElement)(_blockIcon.default, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/list-view/block-select-button.js"],"names":["ListViewBlockSelectButton","ref","className","block","clientId","isSelected","onClick","onToggleExpanded","position","siblingBlockCount","level","tabIndex","onFocus","onDragStart","onDragEnd","draggable","blockInformation","instanceId","descriptionId","blockPositionDescription","
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/list-view/block-select-button.js"],"names":["ListViewBlockSelectButton","ref","className","block","clientId","isSelected","onClick","onToggleExpanded","position","siblingBlockCount","level","tabIndex","onFocus","onDragStart","onDragEnd","draggable","blockInformation","instanceId","descriptionId","blockPositionDescription","icon","anchor"],"mappings":";;;;;;;;;AAUA;;AAPA;;AAKA;;AACA;;AAEA;;AAKA;;AACA;;AACA;;AACA;;AACA;;AApBA;AACA;AACA;;AAGA;AACA;AACA;;AAMA;AACA;AACA;AAOA,SAASA,yBAAT,OAgBCC,GAhBD,EAiBE;AAAA,MAhBD;AACCC,IAAAA,SADD;AAECC,IAAAA,KAAK,EAAE;AAAEC,MAAAA;AAAF,KAFR;AAGCC,IAAAA,UAHD;AAICC,IAAAA,OAJD;AAKCC,IAAAA,gBALD;AAMCC,IAAAA,QAND;AAOCC,IAAAA,iBAPD;AAQCC,IAAAA,KARD;AASCC,IAAAA,QATD;AAUCC,IAAAA,OAVD;AAWCC,IAAAA,WAXD;AAYCC,IAAAA,SAZD;AAaCC,IAAAA;AAbD,GAgBC;AACD,QAAMC,gBAAgB,GAAG,yCAA4BZ,QAA5B,CAAzB;AACA,QAAMa,UAAU,GAAG,4BAAejB,yBAAf,CAAnB;AACA,QAAMkB,aAAa,GAAI,kCAAkCD,UAAY,EAArE;AACA,QAAME,wBAAwB,GAAG,wCAChCX,QADgC,EAEhCC,iBAFgC,EAGhCC,KAHgC,CAAjC;AAMA,SACC,qDACC,4BAAC,kBAAD;AACC,IAAA,SAAS,EAAG,yBACX,4CADW,EAEXR,SAFW,CADb;AAKC,IAAA,OAAO,EAAGI,OALX;AAMC,wBAAmBY,aANpB;AAOC,IAAA,GAAG,EAAGjB,GAPP;AAQC,IAAA,QAAQ,EAAGU,QARZ;AASC,IAAA,OAAO,EAAGC,OATX;AAUC,IAAA,WAAW,EAAGC,WAVf;AAWC,IAAA,SAAS,EAAGC,SAXb;AAYC,IAAA,SAAS,EAAGC;AAZb,KAcC,4BAAC,iBAAD;AAAkB,IAAA,OAAO,EAAGR;AAA5B,IAdD,EAeC,4BAAC,kBAAD;AAAW,IAAA,IAAI,EAAGS,gBAAH,aAAGA,gBAAH,uBAAGA,gBAAgB,CAAEI,IAApC;AAA2C,IAAA,UAAU;AAArD,IAfD,EAgBC,4BAAC,mBAAD;AAAY,IAAA,QAAQ,EAAGhB;AAAvB,IAhBD,EAiBG,CAAAY,gBAAgB,SAAhB,IAAAA,gBAAgB,WAAhB,YAAAA,gBAAgB,CAAEK,MAAlB,KACD;AAAM,IAAA,SAAS,EAAC;AAAhB,KACGL,gBAAgB,CAACK,MADpB,CAlBF,EAsBGhB,UAAU,IACX,4BAAC,0BAAD,QACG,cAAI,kBAAJ,CADH,CAvBF,CADD,EA6BC;AACC,IAAA,SAAS,EAAC,yDADX;AAEC,IAAA,EAAE,EAAGa;AAFN,KAIGC,wBAJH,CA7BD,CADD;AAsCA;;eAEc,yBAAYnB,yBAAZ,C","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { Button, VisuallyHidden } from '@wordpress/components';\nimport { useInstanceId } from '@wordpress/compose';\nimport { forwardRef } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport BlockIcon from '../block-icon';\nimport useBlockDisplayInformation from '../use-block-display-information';\nimport { getBlockPositionDescription } from './utils';\nimport BlockTitle from '../block-title';\nimport ListViewExpander from './expander';\n\nfunction ListViewBlockSelectButton(\n\t{\n\t\tclassName,\n\t\tblock: { clientId },\n\t\tisSelected,\n\t\tonClick,\n\t\tonToggleExpanded,\n\t\tposition,\n\t\tsiblingBlockCount,\n\t\tlevel,\n\t\ttabIndex,\n\t\tonFocus,\n\t\tonDragStart,\n\t\tonDragEnd,\n\t\tdraggable,\n\t},\n\tref\n) {\n\tconst blockInformation = useBlockDisplayInformation( clientId );\n\tconst instanceId = useInstanceId( ListViewBlockSelectButton );\n\tconst descriptionId = `list-view-block-select-button__${ instanceId }`;\n\tconst blockPositionDescription = getBlockPositionDescription(\n\t\tposition,\n\t\tsiblingBlockCount,\n\t\tlevel\n\t);\n\n\treturn (\n\t\t<>\n\t\t\t<Button\n\t\t\t\tclassName={ classnames(\n\t\t\t\t\t'block-editor-list-view-block-select-button',\n\t\t\t\t\tclassName\n\t\t\t\t) }\n\t\t\t\tonClick={ onClick }\n\t\t\t\taria-describedby={ descriptionId }\n\t\t\t\tref={ ref }\n\t\t\t\ttabIndex={ tabIndex }\n\t\t\t\tonFocus={ onFocus }\n\t\t\t\tonDragStart={ onDragStart }\n\t\t\t\tonDragEnd={ onDragEnd }\n\t\t\t\tdraggable={ draggable }\n\t\t\t>\n\t\t\t\t<ListViewExpander onClick={ onToggleExpanded } />\n\t\t\t\t<BlockIcon icon={ blockInformation?.icon } showColors />\n\t\t\t\t<BlockTitle clientId={ clientId } />\n\t\t\t\t{ blockInformation?.anchor && (\n\t\t\t\t\t<span className=\"block-editor-list-view-block-select-button__anchor\">\n\t\t\t\t\t\t{ blockInformation.anchor }\n\t\t\t\t\t</span>\n\t\t\t\t) }\n\t\t\t\t{ isSelected && (\n\t\t\t\t\t<VisuallyHidden>\n\t\t\t\t\t\t{ __( '(selected block)' ) }\n\t\t\t\t\t</VisuallyHidden>\n\t\t\t\t) }\n\t\t\t</Button>\n\t\t\t<div\n\t\t\t\tclassName=\"block-editor-list-view-block-select-button__description\"\n\t\t\t\tid={ descriptionId }\n\t\t\t>\n\t\t\t\t{ blockPositionDescription }\n\t\t\t</div>\n\t\t</>\n\t);\n}\n\nexport default forwardRef( ListViewBlockSelectButton );\n"]}
|
|
@@ -210,7 +210,7 @@ function useListViewDropZone() {
|
|
|
210
210
|
return {
|
|
211
211
|
clientId,
|
|
212
212
|
rootClientId,
|
|
213
|
-
blockIndex: getBlockIndex(clientId
|
|
213
|
+
blockIndex: getBlockIndex(clientId),
|
|
214
214
|
element: blockElement,
|
|
215
215
|
isDraggedBlock: isBlockDrag ? draggedBlockClientIds.includes(clientId) : false,
|
|
216
216
|
innerBlockCount: getBlockCount(clientId),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/list-view/use-list-view-drop-zone.js"],"names":["isPointContainedByRect","point","rect","left","x","right","top","y","bottom","isNestingGesture","blockCenterX","width","ALLOWED_DROP_EDGES","getListViewDropTarget","blocksData","position","candidateEdge","candidateBlockData","candidateDistance","candidateRect","blockData","isDraggedBlock","element","getBoundingClientRect","distance","edge","isCursorWithinBlock","undefined","index","indexOf","previousBlockData","rootClientId","isDraggingBelow","canInsertDraggedBlocksAsChild","innerBlockCount","clientId","blockIndex","dropPosition","canInsertDraggedBlocksAsSibling","offset","useListViewDropZone","getBlockRootClientId","getBlockIndex","getBlockCount","getDraggedBlockClientIds","canInsertBlocks","blockEditorStore","target","setTarget","targetRootClientId","targetBlockIndex","onBlockDrop","draggedBlockClientIds","throttled","event","currentTarget","clientX","clientY","isBlockDrag","length","blockElements","Array","from","querySelectorAll","map","blockElement","dataset","block","includes","newTarget","ref","onDrop","onDragOver","onDragEnd","cancel"],"mappings":";;;;;;;;;AAGA;;AACA;;AACA;;AAQA;;AACA;;AACA;;AAfA;AACA;AACA;;AAQA;AACA;AACA;;AAKA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,sBAAT,CAAiCC,KAAjC,EAAwCC,IAAxC,EAA+C;AAC9C,SACCA,IAAI,CAACC,IAAL,IAAaF,KAAK,CAACG,CAAnB,IACAF,IAAI,CAACG,KAAL,IAAcJ,KAAK,CAACG,CADpB,IAEAF,IAAI,CAACI,GAAL,IAAYL,KAAK,CAACM,CAFlB,IAGAL,IAAI,CAACM,MAAL,IAAeP,KAAK,CAACM,CAJtB;AAMA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACA,SAASE,gBAAT,CAA2BR,KAA3B,EAAkCC,IAAlC,EAAyC;AACxC,QAAMQ,YAAY,GAAGR,IAAI,CAACC,IAAL,GAAYD,IAAI,CAACS,KAAL,GAAa,CAA9C;AACA,SAAOV,KAAK,CAACG,CAAN,GAAUM,YAAjB;AACA,C,CAED;AACA;;;AACA,MAAME,kBAAkB,GAAG,CAAE,KAAF,EAAS,QAAT,CAA3B;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,SAASC,qBAAT,CAAgCC,UAAhC,EAA4CC,QAA5C,EAAuD;AACtD,MAAIC,aAAJ;AACA,MAAIC,kBAAJ;AACA,MAAIC,iBAAJ;AACA,MAAIC,aAAJ;;AAEA,OAAM,MAAMC,SAAZ,IAAyBN,UAAzB,EAAsC;AACrC,QAAKM,SAAS,CAACC,cAAf,EAAgC;AAC/B;AACA;;AAED,UAAMnB,IAAI,GAAGkB,SAAS,CAACE,OAAV,CAAkBC,qBAAlB,EAAb;AACA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f,CAAT;AACA,KAPuB;;AAQxBkB,IAAAA,SAAS,GAAG;AACXpB,MAAAA,SAAS,CAACqB,MAAV;AACA1B,MAAAA,SAAS,CAAE,IAAF,CAAT;AACA;;AAXuB,GAAb,CAAZ;AAcA,SAAO;AAAEsB,IAAAA,GAAF;AAAOvB,IAAAA;AAAP,GAAP;AACA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport { useState, useCallback } from '@wordpress/element';\nimport {\n\tuseThrottle,\n\t__experimentalUseDropZone as useDropZone,\n} from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport { getDistanceToNearestEdge } from '../../utils/math';\nimport useOnBlockDrop from '../use-on-block-drop';\nimport { store as blockEditorStore } from '../../store';\n\n/** @typedef {import('../../utils/math').WPPoint} WPPoint */\n\n/**\n * The type of a drag event.\n *\n * @typedef {'default'|'file'|'html'} WPDragEventType\n */\n\n/**\n * An array representing data for blocks in the DOM used by drag and drop.\n *\n * @typedef {Object} WPListViewDropZoneBlocks\n * @property {string} clientId The client id for the block.\n * @property {string} rootClientId The root client id for the block.\n * @property {number} blockIndex The block's index.\n * @property {Element} element The DOM element representing the block.\n * @property {number} innerBlockCount The number of inner blocks the block has.\n * @property {boolean} isDraggedBlock Whether the block is currently being dragged.\n * @property {boolean} canInsertDraggedBlocksAsSibling Whether the dragged block can be a sibling of this block.\n * @property {boolean} canInsertDraggedBlocksAsChild Whether the dragged block can be a child of this block.\n */\n\n/**\n * An object containing details of a drop target.\n *\n * @typedef {Object} WPListViewDropZoneTarget\n * @property {string} blockIndex The insertion index.\n * @property {string} rootClientId The root client id for the block.\n * @property {string|undefined} clientId The client id for the block.\n * @property {'top'|'bottom'|'inside'} dropPosition The position relative to the block that the user is dropping to.\n * 'inside' refers to nesting as an inner block.\n */\n\n/**\n * Is the point contained by the rectangle.\n *\n * @param {WPPoint} point The point.\n * @param {DOMRect} rect The rectangle.\n *\n * @return {boolean} True if the point is contained by the rectangle, false otherwise.\n */\nfunction isPointContainedByRect( point, rect ) {\n\treturn (\n\t\trect.left <= point.x &&\n\t\trect.right >= point.x &&\n\t\trect.top <= point.y &&\n\t\trect.bottom >= point.y\n\t);\n}\n\n/**\n * Determines whether the user positioning the dragged block to nest as an\n * inner block.\n *\n * Presently this is determined by whether the cursor is on the right hand side\n * of the block.\n *\n * @param {WPPoint} point The point representing the cursor position when dragging.\n * @param {DOMRect} rect The rectangle.\n */\nfunction isNestingGesture( point, rect ) {\n\tconst blockCenterX = rect.left + rect.width / 2;\n\treturn point.x > blockCenterX;\n}\n\n// Block navigation is always a vertical list, so only allow dropping\n// to the above or below a block.\nconst ALLOWED_DROP_EDGES = [ 'top', 'bottom' ];\n\n/**\n * Given blocks data and the cursor position, compute the drop target.\n *\n * @param {WPListViewDropZoneBlocks} blocksData Data about the blocks in list view.\n * @param {WPPoint} position The point representing the cursor position when dragging.\n *\n * @return {WPListViewDropZoneTarget} An object containing data about the drop target.\n */\nfunction getListViewDropTarget( blocksData, position ) {\n\tlet candidateEdge;\n\tlet candidateBlockData;\n\tlet candidateDistance;\n\tlet candidateRect;\n\n\tfor ( const blockData of blocksData ) {\n\t\tif ( blockData.isDraggedBlock ) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst rect = blockData.element.getBoundingClientRect();\n\t\tconst [ distance, edge ] = getDistanceToNearestEdge(\n\t\t\tposition,\n\t\t\trect,\n\t\t\tALLOWED_DROP_EDGES\n\t\t);\n\n\t\tconst isCursorWithinBlock = isPointContainedByRect( position, rect );\n\t\tif (\n\t\t\tcandidateDistance === undefined ||\n\t\t\tdistance < candidateDistance ||\n\t\t\tisCursorWithinBlock\n\t\t) {\n\t\t\tcandidateDistance = distance;\n\n\t\t\tconst index = blocksData.indexOf( blockData );\n\t\t\tconst previousBlockData = blocksData[ index - 1 ];\n\n\t\t\t// If dragging near the top of a block and the preceding block\n\t\t\t// is at the same level, use the preceding block as the candidate\n\t\t\t// instead, as later it makes determining a nesting drop easier.\n\t\t\tif (\n\t\t\t\tedge === 'top' &&\n\t\t\t\tpreviousBlockData &&\n\t\t\t\tpreviousBlockData.rootClientId === blockData.rootClientId &&\n\t\t\t\t! previousBlockData.isDraggedBlock\n\t\t\t) {\n\t\t\t\tcandidateBlockData = previousBlockData;\n\t\t\t\tcandidateEdge = 'bottom';\n\t\t\t\tcandidateRect = previousBlockData.element.getBoundingClientRect();\n\t\t\t} else {\n\t\t\t\tcandidateBlockData = blockData;\n\t\t\t\tcandidateEdge = edge;\n\t\t\t\tcandidateRect = rect;\n\t\t\t}\n\n\t\t\t// If the mouse position is within the block, break early\n\t\t\t// as the user would intend to drop either before or after\n\t\t\t// this block.\n\t\t\t//\n\t\t\t// This solves an issue where some rows in the list view\n\t\t\t// tree overlap slightly due to sub-pixel rendering.\n\t\t\tif ( isCursorWithinBlock ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\n\tif ( ! candidateBlockData ) {\n\t\treturn;\n\t}\n\n\tconst isDraggingBelow = candidateEdge === 'bottom';\n\n\t// If the user is dragging towards the bottom of the block check whether\n\t// they might be trying to nest the block as a child.\n\t// If the block already has inner blocks, this should always be treated\n\t// as nesting since the next block in the tree will be the first child.\n\tif (\n\t\tisDraggingBelow &&\n\t\tcandidateBlockData.canInsertDraggedBlocksAsChild &&\n\t\t( candidateBlockData.innerBlockCount > 0 ||\n\t\t\tisNestingGesture( position, candidateRect ) )\n\t) {\n\t\treturn {\n\t\t\trootClientId: candidateBlockData.clientId,\n\t\t\tblockIndex: 0,\n\t\t\tdropPosition: 'inside',\n\t\t};\n\t}\n\n\t// If dropping as a sibling, but block cannot be inserted in\n\t// this context, return early.\n\tif ( ! candidateBlockData.canInsertDraggedBlocksAsSibling ) {\n\t\treturn;\n\t}\n\n\tconst offset = isDraggingBelow ? 1 : 0;\n\treturn {\n\t\trootClientId: candidateBlockData.rootClientId,\n\t\tclientId: candidateBlockData.clientId,\n\t\tblockIndex: candidateBlockData.blockIndex + offset,\n\t\tdropPosition: candidateEdge,\n\t};\n}\n\n/**\n * A react hook for implementing a drop zone in list view.\n *\n * @return {WPListViewDropZoneTarget} The drop target.\n */\nexport default function useListViewDropZone() {\n\tconst {\n\t\tgetBlockRootClientId,\n\t\tgetBlockIndex,\n\t\tgetBlockCount,\n\t\tgetDraggedBlockClientIds,\n\t\tcanInsertBlocks,\n\t} = useSelect( blockEditorStore );\n\tconst [ target, setTarget ] = useState();\n\tconst { rootClientId: targetRootClientId, blockIndex: targetBlockIndex } =\n\t\ttarget || {};\n\n\tconst onBlockDrop = useOnBlockDrop( targetRootClientId, targetBlockIndex );\n\n\tconst draggedBlockClientIds = getDraggedBlockClientIds();\n\tconst throttled = useThrottle(\n\t\tuseCallback(\n\t\t\t( event, currentTarget ) => {\n\t\t\t\tconst position = { x: event.clientX, y: event.clientY };\n\t\t\t\tconst isBlockDrag = !! draggedBlockClientIds?.length;\n\n\t\t\t\tconst blockElements = Array.from(\n\t\t\t\t\tcurrentTarget.querySelectorAll( '[data-block]' )\n\t\t\t\t);\n\n\t\t\t\tconst blocksData = blockElements.map( ( blockElement ) => {\n\t\t\t\t\tconst clientId = blockElement.dataset.block;\n\t\t\t\t\tconst rootClientId = getBlockRootClientId( clientId );\n\n\t\t\t\t\treturn {\n\t\t\t\t\t\tclientId,\n\t\t\t\t\t\trootClientId,\n\t\t\t\t\t\tblockIndex: getBlockIndex( clientId, rootClientId ),\n\t\t\t\t\t\telement: blockElement,\n\t\t\t\t\t\tisDraggedBlock: isBlockDrag\n\t\t\t\t\t\t\t? draggedBlockClientIds.includes( clientId )\n\t\t\t\t\t\t\t: false,\n\t\t\t\t\t\tinnerBlockCount: getBlockCount( clientId ),\n\t\t\t\t\t\tcanInsertDraggedBlocksAsSibling: isBlockDrag\n\t\t\t\t\t\t\t? canInsertBlocks(\n\t\t\t\t\t\t\t\t\tdraggedBlockClientIds,\n\t\t\t\t\t\t\t\t\trootClientId\n\t\t\t\t\t\t\t )\n\t\t\t\t\t\t\t: true,\n\t\t\t\t\t\tcanInsertDraggedBlocksAsChild: isBlockDrag\n\t\t\t\t\t\t\t? canInsertBlocks( draggedBlockClientIds, clientId )\n\t\t\t\t\t\t\t: true,\n\t\t\t\t\t};\n\t\t\t\t} );\n\n\t\t\t\tconst newTarget = getListViewDropTarget( blocksData, position );\n\n\t\t\t\tif ( newTarget ) {\n\t\t\t\t\tsetTarget( newTarget );\n\t\t\t\t}\n\t\t\t},\n\t\t\t[ draggedBlockClientIds ]\n\t\t),\n\t\t200\n\t);\n\n\tconst ref = useDropZone( {\n\t\tonDrop: onBlockDrop,\n\t\tonDragOver( event ) {\n\t\t\t// `currentTarget` is only available while the event is being\n\t\t\t// handled, so get it now and pass it to the thottled function.\n\t\t\t// https://developer.mozilla.org/en-US/docs/Web/API/Event/currentTarget\n\t\t\tthrottled( event, event.currentTarget );\n\t\t},\n\t\tonDragEnd() {\n\t\t\tthrottled.cancel();\n\t\t\tsetTarget( null );\n\t\t},\n\t} );\n\n\treturn { ref, target };\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/list-view/use-list-view-drop-zone.js"],"names":["isPointContainedByRect","point","rect","left","x","right","top","y","bottom","isNestingGesture","blockCenterX","width","ALLOWED_DROP_EDGES","getListViewDropTarget","blocksData","position","candidateEdge","candidateBlockData","candidateDistance","candidateRect","blockData","isDraggedBlock","element","getBoundingClientRect","distance","edge","isCursorWithinBlock","undefined","index","indexOf","previousBlockData","rootClientId","isDraggingBelow","canInsertDraggedBlocksAsChild","innerBlockCount","clientId","blockIndex","dropPosition","canInsertDraggedBlocksAsSibling","offset","useListViewDropZone","getBlockRootClientId","getBlockIndex","getBlockCount","getDraggedBlockClientIds","canInsertBlocks","blockEditorStore","target","setTarget","targetRootClientId","targetBlockIndex","onBlockDrop","draggedBlockClientIds","throttled","event","currentTarget","clientX","clientY","isBlockDrag","length","blockElements","Array","from","querySelectorAll","map","blockElement","dataset","block","includes","newTarget","ref","onDrop","onDragOver","onDragEnd","cancel"],"m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AAA,SAAS,GAAG;AACXpB,MAAAA,SAAS,CAACqB,MAAV;AACA1B,MAAAA,SAAS,CAAE,IAAF,CAAT;AACA;;AAXuB,GAAb,CAAZ;AAcA,SAAO;AAAEsB,IAAAA,GAAF;AAAOvB,IAAAA;AAAP,GAAP;AACA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport { useState, useCallback } from '@wordpress/element';\nimport {\n\tuseThrottle,\n\t__experimentalUseDropZone as useDropZone,\n} from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport { getDistanceToNearestEdge } from '../../utils/math';\nimport useOnBlockDrop from '../use-on-block-drop';\nimport { store as blockEditorStore } from '../../store';\n\n/** @typedef {import('../../utils/math').WPPoint} WPPoint */\n\n/**\n * The type of a drag event.\n *\n * @typedef {'default'|'file'|'html'} WPDragEventType\n */\n\n/**\n * An array representing data for blocks in the DOM used by drag and drop.\n *\n * @typedef {Object} WPListViewDropZoneBlocks\n * @property {string} clientId The client id for the block.\n * @property {string} rootClientId The root client id for the block.\n * @property {number} blockIndex The block's index.\n * @property {Element} element The DOM element representing the block.\n * @property {number} innerBlockCount The number of inner blocks the block has.\n * @property {boolean} isDraggedBlock Whether the block is currently being dragged.\n * @property {boolean} canInsertDraggedBlocksAsSibling Whether the dragged block can be a sibling of this block.\n * @property {boolean} canInsertDraggedBlocksAsChild Whether the dragged block can be a child of this block.\n */\n\n/**\n * An object containing details of a drop target.\n *\n * @typedef {Object} WPListViewDropZoneTarget\n * @property {string} blockIndex The insertion index.\n * @property {string} rootClientId The root client id for the block.\n * @property {string|undefined} clientId The client id for the block.\n * @property {'top'|'bottom'|'inside'} dropPosition The position relative to the block that the user is dropping to.\n * 'inside' refers to nesting as an inner block.\n */\n\n/**\n * Is the point contained by the rectangle.\n *\n * @param {WPPoint} point The point.\n * @param {DOMRect} rect The rectangle.\n *\n * @return {boolean} True if the point is contained by the rectangle, false otherwise.\n */\nfunction isPointContainedByRect( point, rect ) {\n\treturn (\n\t\trect.left <= point.x &&\n\t\trect.right >= point.x &&\n\t\trect.top <= point.y &&\n\t\trect.bottom >= point.y\n\t);\n}\n\n/**\n * Determines whether the user positioning the dragged block to nest as an\n * inner block.\n *\n * Presently this is determined by whether the cursor is on the right hand side\n * of the block.\n *\n * @param {WPPoint} point The point representing the cursor position when dragging.\n * @param {DOMRect} rect The rectangle.\n */\nfunction isNestingGesture( point, rect ) {\n\tconst blockCenterX = rect.left + rect.width / 2;\n\treturn point.x > blockCenterX;\n}\n\n// Block navigation is always a vertical list, so only allow dropping\n// to the above or below a block.\nconst ALLOWED_DROP_EDGES = [ 'top', 'bottom' ];\n\n/**\n * Given blocks data and the cursor position, compute the drop target.\n *\n * @param {WPListViewDropZoneBlocks} blocksData Data about the blocks in list view.\n * @param {WPPoint} position The point representing the cursor position when dragging.\n *\n * @return {WPListViewDropZoneTarget} An object containing data about the drop target.\n */\nfunction getListViewDropTarget( blocksData, position ) {\n\tlet candidateEdge;\n\tlet candidateBlockData;\n\tlet candidateDistance;\n\tlet candidateRect;\n\n\tfor ( const blockData of blocksData ) {\n\t\tif ( blockData.isDraggedBlock ) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst rect = blockData.element.getBoundingClientRect();\n\t\tconst [ distance, edge ] = getDistanceToNearestEdge(\n\t\t\tposition,\n\t\t\trect,\n\t\t\tALLOWED_DROP_EDGES\n\t\t);\n\n\t\tconst isCursorWithinBlock = isPointContainedByRect( position, rect );\n\t\tif (\n\t\t\tcandidateDistance === undefined ||\n\t\t\tdistance < candidateDistance ||\n\t\t\tisCursorWithinBlock\n\t\t) {\n\t\t\tcandidateDistance = distance;\n\n\t\t\tconst index = blocksData.indexOf( blockData );\n\t\t\tconst previousBlockData = blocksData[ index - 1 ];\n\n\t\t\t// If dragging near the top of a block and the preceding block\n\t\t\t// is at the same level, use the preceding block as the candidate\n\t\t\t// instead, as later it makes determining a nesting drop easier.\n\t\t\tif (\n\t\t\t\tedge === 'top' &&\n\t\t\t\tpreviousBlockData &&\n\t\t\t\tpreviousBlockData.rootClientId === blockData.rootClientId &&\n\t\t\t\t! previousBlockData.isDraggedBlock\n\t\t\t) {\n\t\t\t\tcandidateBlockData = previousBlockData;\n\t\t\t\tcandidateEdge = 'bottom';\n\t\t\t\tcandidateRect = previousBlockData.element.getBoundingClientRect();\n\t\t\t} else {\n\t\t\t\tcandidateBlockData = blockData;\n\t\t\t\tcandidateEdge = edge;\n\t\t\t\tcandidateRect = rect;\n\t\t\t}\n\n\t\t\t// If the mouse position is within the block, break early\n\t\t\t// as the user would intend to drop either before or after\n\t\t\t// this block.\n\t\t\t//\n\t\t\t// This solves an issue where some rows in the list view\n\t\t\t// tree overlap slightly due to sub-pixel rendering.\n\t\t\tif ( isCursorWithinBlock ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\n\tif ( ! candidateBlockData ) {\n\t\treturn;\n\t}\n\n\tconst isDraggingBelow = candidateEdge === 'bottom';\n\n\t// If the user is dragging towards the bottom of the block check whether\n\t// they might be trying to nest the block as a child.\n\t// If the block already has inner blocks, this should always be treated\n\t// as nesting since the next block in the tree will be the first child.\n\tif (\n\t\tisDraggingBelow &&\n\t\tcandidateBlockData.canInsertDraggedBlocksAsChild &&\n\t\t( candidateBlockData.innerBlockCount > 0 ||\n\t\t\tisNestingGesture( position, candidateRect ) )\n\t) {\n\t\treturn {\n\t\t\trootClientId: candidateBlockData.clientId,\n\t\t\tblockIndex: 0,\n\t\t\tdropPosition: 'inside',\n\t\t};\n\t}\n\n\t// If dropping as a sibling, but block cannot be inserted in\n\t// this context, return early.\n\tif ( ! candidateBlockData.canInsertDraggedBlocksAsSibling ) {\n\t\treturn;\n\t}\n\n\tconst offset = isDraggingBelow ? 1 : 0;\n\treturn {\n\t\trootClientId: candidateBlockData.rootClientId,\n\t\tclientId: candidateBlockData.clientId,\n\t\tblockIndex: candidateBlockData.blockIndex + offset,\n\t\tdropPosition: candidateEdge,\n\t};\n}\n\n/**\n * A react hook for implementing a drop zone in list view.\n *\n * @return {WPListViewDropZoneTarget} The drop target.\n */\nexport default function useListViewDropZone() {\n\tconst {\n\t\tgetBlockRootClientId,\n\t\tgetBlockIndex,\n\t\tgetBlockCount,\n\t\tgetDraggedBlockClientIds,\n\t\tcanInsertBlocks,\n\t} = useSelect( blockEditorStore );\n\tconst [ target, setTarget ] = useState();\n\tconst { rootClientId: targetRootClientId, blockIndex: targetBlockIndex } =\n\t\ttarget || {};\n\n\tconst onBlockDrop = useOnBlockDrop( targetRootClientId, targetBlockIndex );\n\n\tconst draggedBlockClientIds = getDraggedBlockClientIds();\n\tconst throttled = useThrottle(\n\t\tuseCallback(\n\t\t\t( event, currentTarget ) => {\n\t\t\t\tconst position = { x: event.clientX, y: event.clientY };\n\t\t\t\tconst isBlockDrag = !! draggedBlockClientIds?.length;\n\n\t\t\t\tconst blockElements = Array.from(\n\t\t\t\t\tcurrentTarget.querySelectorAll( '[data-block]' )\n\t\t\t\t);\n\n\t\t\t\tconst blocksData = blockElements.map( ( blockElement ) => {\n\t\t\t\t\tconst clientId = blockElement.dataset.block;\n\t\t\t\t\tconst rootClientId = getBlockRootClientId( clientId );\n\n\t\t\t\t\treturn {\n\t\t\t\t\t\tclientId,\n\t\t\t\t\t\trootClientId,\n\t\t\t\t\t\tblockIndex: getBlockIndex( clientId ),\n\t\t\t\t\t\telement: blockElement,\n\t\t\t\t\t\tisDraggedBlock: isBlockDrag\n\t\t\t\t\t\t\t? draggedBlockClientIds.includes( clientId )\n\t\t\t\t\t\t\t: false,\n\t\t\t\t\t\tinnerBlockCount: getBlockCount( clientId ),\n\t\t\t\t\t\tcanInsertDraggedBlocksAsSibling: isBlockDrag\n\t\t\t\t\t\t\t? canInsertBlocks(\n\t\t\t\t\t\t\t\t\tdraggedBlockClientIds,\n\t\t\t\t\t\t\t\t\trootClientId\n\t\t\t\t\t\t\t )\n\t\t\t\t\t\t\t: true,\n\t\t\t\t\t\tcanInsertDraggedBlocksAsChild: isBlockDrag\n\t\t\t\t\t\t\t? canInsertBlocks( draggedBlockClientIds, clientId )\n\t\t\t\t\t\t\t: true,\n\t\t\t\t\t};\n\t\t\t\t} );\n\n\t\t\t\tconst newTarget = getListViewDropTarget( blocksData, position );\n\n\t\t\t\tif ( newTarget ) {\n\t\t\t\t\tsetTarget( newTarget );\n\t\t\t\t}\n\t\t\t},\n\t\t\t[ draggedBlockClientIds ]\n\t\t),\n\t\t200\n\t);\n\n\tconst ref = useDropZone( {\n\t\tonDrop: onBlockDrop,\n\t\tonDragOver( event ) {\n\t\t\t// `currentTarget` is only available while the event is being\n\t\t\t// handled, so get it now and pass it to the thottled function.\n\t\t\t// https://developer.mozilla.org/en-US/docs/Web/API/Event/currentTarget\n\t\t\tthrottled( event, event.currentTarget );\n\t\t},\n\t\tonDragEnd() {\n\t\t\tthrottled.cancel();\n\t\t\tsetTarget( null );\n\t\t},\n\t} );\n\n\treturn { ref, target };\n}\n"]}
|
|
@@ -94,7 +94,6 @@ function MediaPlaceholder(_ref2) {
|
|
|
94
94
|
onDoubleClick,
|
|
95
95
|
onFilesPreUpload = _lodash.noop,
|
|
96
96
|
onHTMLDrop = _lodash.noop,
|
|
97
|
-
onClose = _lodash.noop,
|
|
98
97
|
children,
|
|
99
98
|
mediaLibraryButton,
|
|
100
99
|
placeholder,
|
|
@@ -334,7 +333,6 @@ function MediaPlaceholder(_ref2) {
|
|
|
334
333
|
gallery: multiple && onlyAllowsImages(),
|
|
335
334
|
multiple: multiple,
|
|
336
335
|
onSelect: onSelect,
|
|
337
|
-
onClose: onClose,
|
|
338
336
|
allowedTypes: allowedTypes,
|
|
339
337
|
value: Array.isArray(value) ? value.map(_ref7 => {
|
|
340
338
|
let {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/media-placeholder/index.js"],"names":["InsertFromURLPopover","src","onChange","onSubmit","onClose","keyboardReturn","MediaPlaceholder","value","allowedTypes","className","icon","labels","mediaPreview","notices","isAppender","accept","addToGallery","multiple","handleUpload","dropZoneUIOnly","disableDropZone","disableMediaButtons","onError","onSelect","onCancel","onSelectURL","onDoubleClick","onFilesPreUpload","noop","onHTMLDrop","children","mediaLibraryButton","placeholder","style","mediaUpload","select","getSettings","blockEditorStore","setSrc","isURLInputVisible","setIsURLInputVisible","onlyAllowsImages","length","every","allowedType","startsWith","onChangeSrc","event","target","openURLInput","closeURLInput","onSubmitSrc","preventDefault","onFilesUpload","files","setMedia","lastMediaPassed","newMedia","filteredMedia","filter","item","id","some","Number","urlSlug","url","includes","concat","map","media","cutOffIndex","lastIndexOf","slice","filesList","onFileChange","onUpload","defaultRenderPlaceholder","content","instructions","title","undefined","typesAllowed","firstAllowedType","isOneType","isAudio","isImage","isVideo","placeholderClassName","renderPlaceholder","renderDropZone","renderCancelLink","renderUrlSelectionUI","renderMediaUploadChecked","defaultButton","open","libraryButton","uploadMediaLibraryButton","Array","isArray","openFileDialog","since","alternative"],"mappings":";;;;;;;;;;AAiBA;;AAdA;;AACA;;AAKA;;AAOA;;AAEA;;AACA;;AACA;;AAKA;;AACA;;AACA;;AACA;;AA5BA;AACA;AACA;;AAIA;AACA;AACA;;AAcA;AACA;AACA;AAMA,MAAMA,oBAAoB,GAAG;AAAA,MAAE;AAAEC,IAAAA,GAAF;AAAOC,IAAAA,QAAP;AAAiBC,IAAAA,QAAjB;AAA2BC,IAAAA;AAA3B,GAAF;AAAA,SAC5B,4BAAC,mBAAD;AAAY,IAAA,OAAO,EAAGA;AAAtB,KACC;AACC,IAAA,SAAS,EAAC,gDADX;AAEC,IAAA,QAAQ,EAAGD;AAFZ,KAIC;AACC,IAAA,SAAS,EAAC,iDADX;AAEC,IAAA,IAAI,EAAC,MAFN;AAGC,kBAAa,cAAI,KAAJ,CAHd;AAIC,IAAA,WAAW,EAAG,cAAI,mBAAJ,CAJf;AAKC,IAAA,QAAQ,EAAGD,QALZ;AAMC,IAAA,KAAK,EAAGD;AANT,IAJD,EAYC,4BAAC,kBAAD;AACC,IA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OF,iBAAiB,CAAEX,OAAF,CAAxB;AACA;;AAED,WAAOW,iBAAiB,CAAEQ,wBAAF,CAAxB;AACA,GAzFD;;AA2FA,MAAK7E,cAAc,IAAIE,mBAAvB,EAA6C;AAC5C,QAAKF,cAAL,EAAsB;AACrB,+BAAY,qDAAZ,EAAmE;AAClEiF,QAAAA,KAAK,EAAE,KAD2D;AAElEC,QAAAA,WAAW,EAAE;AAFqD,OAAnE;AAIA;;AAED,WAAO,4BAAC,cAAD,QAAoBZ,cAAc,EAAlC,CAAP;AACA;;AAED,SACC,4BAAC,cAAD;AACC,IAAA,QAAQ,EAAGD,iBAAiB,CAAEG,oBAAoB,EAAtB;AAD7B,KAGGC,wBAAwB,EAH3B,CADD;AAOA;AAED;AACA;AACA;;;eACe,6BAAa,yBAAb,EAA0CtF,gBAA1C,C","sourcesContent":["/**\n * External dependencies\n */\nimport { noop } from 'lodash';\nimport classnames from 'classnames';\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 deprecated from '@wordpress/deprecated';\nimport { keyboardReturn } from '@wordpress/icons';\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 InsertFromURLPopover = ( { src, onChange, onSubmit, onClose } ) => (\n\t<URLPopover 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\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\tdropZoneUIOnly,\n\tdisableDropZone,\n\tdisableMediaButtons,\n\tonError,\n\tonSelect,\n\tonCancel,\n\tonSelectURL,\n\tonDoubleClick,\n\tonFilesPreUpload = noop,\n\tonHTMLDrop = noop,\n\tonClose = noop,\n\tchildren,\n\tmediaLibraryButton,\n\tplaceholder,\n\tstyle,\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\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 = classnames(\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<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={ openURLInput }\n\t\t\t\t\t\tisPressed={ isURLInputVisible }\n\t\t\t\t\t\tvariant=\"tertiary\"\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Insert from URL' ) }\n\t\t\t\t\t</Button>\n\t\t\t\t\t{ isURLInputVisible && (\n\t\t\t\t\t\t<InsertFromURLPopover\n\t\t\t\t\t\t\tsrc={ src }\n\t\t\t\t\t\t\tonChange={ onChangeSrc }\n\t\t\t\t\t\t\tonSubmit={ onSubmitSrc }\n\t\t\t\t\t\t\tonClose={ closeURLInput }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\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=\"tertiary\"\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\tonClose={ onClose }\n\t\t\t\tallowedTypes={ allowedTypes }\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={ classnames(\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{ 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={ classnames(\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{ 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 ( dropZoneUIOnly || disableMediaButtons ) {\n\t\tif ( dropZoneUIOnly ) {\n\t\t\tdeprecated( 'wp.blockEditor.MediaPlaceholder dropZoneUIOnly prop', {\n\t\t\t\tsince: '5.4',\n\t\t\t\talternative: 'disableMediaButtons',\n\t\t\t} );\n\t\t}\n\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"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/media-placeholder/index.js"],"names":["InsertFromURLPopover","src","onChange","onSubmit","onClose","keyboardReturn","MediaPlaceholder","value","allowedTypes","className","icon","labels","mediaPreview","notices","isAppender","accept","addToGallery","multiple","handleUpload","dropZoneUIOnly","disableDropZone","disableMediaButtons","onError","onSelect","onCancel","onSelectURL","onDoubleClick","onFilesPreUpload","noop","onHTMLDrop","children","mediaLibraryButton","placeholder","style","mediaUpload","select","getSettings","blockEditorStore","setSrc","isURLInputVisible","setIsURLInputVisible","onlyAllowsImages","length","every","allowedType","startsWith","onChangeSrc","event","target","openURLInput","closeURLInput","onSubmitSrc","preventDefault","onFilesUpload","files","setMedia","lastMediaPassed","newMedia","filteredMedia","filter","item","id","some","Number","urlSlug","url","includes","concat","map","media","cutOffIndex","lastIndexOf","slice","filesList","onFileChange","onUpload","defaultRenderPlaceholder","content","instructions","title","undefined","typesAllowed","firstAllowedType","isOneType","isAudio","isImage","isVideo","placeholderClassName","renderPlaceholder","renderDropZone","renderCancelLink","renderUrlSelectionUI","renderMediaUploadChecked","defaultButton","open","libraryButton","uploadMediaLibraryButton","Array","isArray","openFileDialog","since","alternative"],"mappings":";;;;;;;;;;AAiBA;;AAdA;;AACA;;AAKA;;AAOA;;AAEA;;AACA;;AACA;;AAKA;;AACA;;AACA;;AACA;;AA5BA;AACA;AACA;;AAIA;AACA;AACA;;AAcA;AACA;AACA;AAMA,MAAMA,oBAAoB,GAAG;AAAA,MAAE;AAAEC,IAAAA,GAAF;AAAOC,IAAAA,QAAP;AAAiBC,IAAAA,QAAjB;AAA2BC,IAAAA;AAA3B,GAAF;AAAA,SAC5B,4BAAC,mBAAD;AAAY,IAAA,OAAO,EAAGA;AAAtB,KACC;AACC,IAAA,SAAS,EAAC,gDADX;AAEC,IAAA,QAAQ,EAAGD;AAFZ,KAIC;AACC,IAAA,SAAS,EAAC,iDADX;AAEC,IAAA,IAAI,EAAC,MAFN;AAGC,kBAAa,cAAI,KAAJ,CAHd;AAIC,IAAA,WAAW,EAAG,cAAI,mBAAJ,CAJf;AAKC,IAAA,QAAQ,EAAGD,QALZ;AAMC,IAAA,KAAK,EAAGD;AANT,IAJD,EAYC,4BAAC,kBAAD;AACC,IAAA,SAAS,EAAC,yDADX;AAEC,IAAA,IAAI,EAAGI,qBAFR;AAGC,IAAA,KAAK,EAAG,cAAI,OAAJ,CAHT;AAIC,IAAA,IAAI,EAAC;AAJN,IAZD,CADD,CAD4B;AAAA,CAA7B;;AAwBO,SAASC,gBAAT,QA2BH;AAAA,MA3B8B;AACjCC,IAAAA,KAAK,GAAG,EADyB;AAEjCC,IAAA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AlC,CAAP;AACA;;AAED,SACC,4BAAC,cAAD;AACC,IAAA,QAAQ,EAAGD,iBAAiB,CAAEG,oBAAoB,EAAtB;AAD7B,KAGGC,wBAAwB,EAH3B,CADD;AAOA;AAED;AACA;AACA;;;eACe,6BAAa,yBAAb,EAA0CtF,gBAA1C,C","sourcesContent":["/**\n * External dependencies\n */\nimport { noop } from 'lodash';\nimport classnames from 'classnames';\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 deprecated from '@wordpress/deprecated';\nimport { keyboardReturn } from '@wordpress/icons';\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 InsertFromURLPopover = ( { src, onChange, onSubmit, onClose } ) => (\n\t<URLPopover 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\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\tdropZoneUIOnly,\n\tdisableDropZone,\n\tdisableMediaButtons,\n\tonError,\n\tonSelect,\n\tonCancel,\n\tonSelectURL,\n\tonDoubleClick,\n\tonFilesPreUpload = noop,\n\tonHTMLDrop = noop,\n\tchildren,\n\tmediaLibraryButton,\n\tplaceholder,\n\tstyle,\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\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 = classnames(\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<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={ openURLInput }\n\t\t\t\t\t\tisPressed={ isURLInputVisible }\n\t\t\t\t\t\tvariant=\"tertiary\"\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Insert from URL' ) }\n\t\t\t\t\t</Button>\n\t\t\t\t\t{ isURLInputVisible && (\n\t\t\t\t\t\t<InsertFromURLPopover\n\t\t\t\t\t\t\tsrc={ src }\n\t\t\t\t\t\t\tonChange={ onChangeSrc }\n\t\t\t\t\t\t\tonSubmit={ onSubmitSrc }\n\t\t\t\t\t\t\tonClose={ closeURLInput }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\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=\"tertiary\"\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\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={ classnames(\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{ 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={ classnames(\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{ 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 ( dropZoneUIOnly || disableMediaButtons ) {\n\t\tif ( dropZoneUIOnly ) {\n\t\t\tdeprecated( 'wp.blockEditor.MediaPlaceholder dropZoneUIOnly prop', {\n\t\t\t\tsince: '5.4',\n\t\t\t\talternative: 'disableMediaButtons',\n\t\t\t} );\n\t\t}\n\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"]}
|
|
@@ -55,7 +55,6 @@ const MediaReplaceFlow = _ref => {
|
|
|
55
55
|
onSelect,
|
|
56
56
|
onSelectURL,
|
|
57
57
|
onFilesUpload = _lodash.noop,
|
|
58
|
-
onCloseModal = _lodash.noop,
|
|
59
58
|
name = (0, _i18n.__)('Replace'),
|
|
60
59
|
createNotice,
|
|
61
60
|
removeNotice,
|
|
@@ -156,7 +155,6 @@ const MediaReplaceFlow = _ref => {
|
|
|
156
155
|
value: mediaId,
|
|
157
156
|
onSelect: media => selectMedia(media),
|
|
158
157
|
allowedTypes: allowedTypes,
|
|
159
|
-
onClose: onCloseModal,
|
|
160
158
|
render: _ref5 => {
|
|
161
159
|
let {
|
|
162
160
|
open
|