@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
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/inserter/quick-inserter.js"],"names":["classnames","useState","useEffect","__","Button","SearchControl","useSelect","InserterSearchResults","useInsertionPoint","usePatternsState","useBlockTypesState","store","blockEditorStore","SEARCH_THRESHOLD","SHOWN_BLOCK_TYPES","SHOWN_BLOCK_PATTERNS","QuickInserter","onSelect","rootClientId","clientId","isAppender","filterValue","setFilterValue","destinationRootClientId","onInsertBlocks","blockTypes","patterns","showPatterns","length","showSearch","setInserterIsOpened","insertionIndex","select","getSettings","getBlockIndex","getBlockCount","index","__experimentalSetIsInserterOpened","onBrowseAll","value"],"mappings":";;AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,YAAvB;AAEA;AACA;AACA;;AACA,SAASC,QAAT,EAAmBC,SAAnB,QAAoC,oBAApC;AACA,SAASC,EAAT,QAAmB,iBAAnB;AACA,SAASC,MAAT,EAAiBC,aAAjB,QAAsC,uBAAtC;AACA,SAASC,SAAT,QAA0B,iBAA1B;AAEA;AACA;AACA;;AACA,OAAOC,qBAAP,MAAkC,kBAAlC;AACA,OAAOC,iBAAP,MAA8B,6BAA9B;AACA,OAAOC,gBAAP,MAA6B,4BAA7B;AACA,OAAOC,kBAAP,MAA+B,+BAA/B;AACA,SAASC,KAAK,IAAIC,gBAAlB,QAA0C,aAA1C;AAEA,MAAMC,gBAAgB,GAAG,CAAzB;AACA,MAAMC,iBAAiB,GAAG,CAA1B;AACA,MAAMC,oBAAoB,GAAG,CAA7B;AAEA,eAAe,SAASC,aAAT,OAKX;AAAA,MALmC;AACtCC,IAAAA,QADsC;AAEtCC,IAAAA,YAFsC;AAGtCC,IAAAA,QAHsC;AAItCC,IAAAA;AAJsC,GAKnC;AACH,QAAM,CAAEC,WAAF,EAAeC,cAAf,IAAkCrB,QAAQ,CAAE,EAAF,CAAhD;AACA,QAAM,CAAEsB,uBAAF,EAA2BC,cAA3B,IAA8ChB,iBAAiB,CAAE;AACtES,IAAAA,QADsE;AAEtEC,IAAAA,YAFsE;AAGtEC,IAAAA,QAHsE;AAItEC,IAAAA;AAJsE,GAAF,CAArE;AAMA,QAAM,CAAEK,UAAF,IAAiBf,kBAAkB,CACxCa,uBADwC,EAExCC,cAFwC,CAAzC;AAKA,QAAM,CAAEE,QAAF,IAAejB,gBAAgB,CACpCe,cADoC,EAEpCD,uBAFoC,CAArC;AAIA,QAAMI,YAAY,GAAGD,QAAQ,CAACE,MAAT,IAAmB,CAAC,CAAEP,WAA3C;AACA,QAAMQ,UAAU,GACbF,YAAY,IAAID,QAAQ,CAACE,MAAT,GAAkBf,gBAApC,IACAY,UAAU,CAACG,MAAX,GAAoBf,gBAFrB;AAIA,QAAM;AAAEiB,IAAAA,mBAAF;AAAuBC,IAAAA;AAAvB,MAA0CzB,SAAS,CACtD0B,MAAF,IAAc;AACb,UAAM;AAAEC,MAAAA,WAAF;AAAeC,MAAAA,aAAf;AAA8BC,MAAAA;AAA9B,QAAgDH,MAAM,CAC3DpB,gBAD2D,CAA5D;AAGA,UAAMwB,KAAK,GAAGF,aAAa,CAAEf,QAAF,
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/inserter/quick-inserter.js"],"names":["classnames","useState","useEffect","__","Button","SearchControl","useSelect","InserterSearchResults","useInsertionPoint","usePatternsState","useBlockTypesState","store","blockEditorStore","SEARCH_THRESHOLD","SHOWN_BLOCK_TYPES","SHOWN_BLOCK_PATTERNS","QuickInserter","onSelect","rootClientId","clientId","isAppender","filterValue","setFilterValue","destinationRootClientId","onInsertBlocks","blockTypes","patterns","showPatterns","length","showSearch","setInserterIsOpened","insertionIndex","select","getSettings","getBlockIndex","getBlockCount","index","__experimentalSetIsInserterOpened","onBrowseAll","value"],"mappings":";;AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,YAAvB;AAEA;AACA;AACA;;AACA,SA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,EAAGkB,WADf;AAEC,IAAA,QAAQ,EAAGJ,QAFZ;AAGC,IAAA,YAAY,EAAGC,YAHhB;AAIC,IAAA,QAAQ,EAAGC,QAJZ;AAKC,IAAA,UAAU,EAAGC,UALd;AAMC,IAAA,gBAAgB,EAAGO,YAAY,GAAGZ,oBAAH,GAA0B,CAN1D;AAOC,IAAA,aAAa,EAAGD,iBAPjB;AAQC,IAAA,WAAW,EAAG;AARf,IADD,CAlBD,EA+BGgB,mBAAmB,IACpB,cAAC,MAAD;AACC,IAAA,SAAS,EAAC,8CADX;AAEC,IAAA,OAAO,EAAGQ,WAFX;AAGC,kBAAanC,EAAE,CACd,2EADc;AAHhB,KAOGA,EAAE,CAAE,YAAF,CAPL,CAhCF,CADD;AA6CA","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { useState, useEffect } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport { Button, SearchControl } from '@wordpress/components';\nimport { useSelect } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport InserterSearchResults from './search-results';\nimport useInsertionPoint from './hooks/use-insertion-point';\nimport usePatternsState from './hooks/use-patterns-state';\nimport useBlockTypesState from './hooks/use-block-types-state';\nimport { store as blockEditorStore } from '../../store';\n\nconst SEARCH_THRESHOLD = 6;\nconst SHOWN_BLOCK_TYPES = 6;\nconst SHOWN_BLOCK_PATTERNS = 2;\n\nexport default function QuickInserter( {\n\tonSelect,\n\trootClientId,\n\tclientId,\n\tisAppender,\n} ) {\n\tconst [ filterValue, setFilterValue ] = useState( '' );\n\tconst [ destinationRootClientId, onInsertBlocks ] = useInsertionPoint( {\n\t\tonSelect,\n\t\trootClientId,\n\t\tclientId,\n\t\tisAppender,\n\t} );\n\tconst [ blockTypes ] = useBlockTypesState(\n\t\tdestinationRootClientId,\n\t\tonInsertBlocks\n\t);\n\n\tconst [ patterns ] = usePatternsState(\n\t\tonInsertBlocks,\n\t\tdestinationRootClientId\n\t);\n\tconst showPatterns = patterns.length && !! filterValue;\n\tconst showSearch =\n\t\t( showPatterns && patterns.length > SEARCH_THRESHOLD ) ||\n\t\tblockTypes.length > SEARCH_THRESHOLD;\n\n\tconst { setInserterIsOpened, insertionIndex } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getSettings, getBlockIndex, getBlockCount } = select(\n\t\t\t\tblockEditorStore\n\t\t\t);\n\t\t\tconst index = getBlockIndex( clientId );\n\t\t\treturn {\n\t\t\t\tsetInserterIsOpened: getSettings()\n\t\t\t\t\t.__experimentalSetIsInserterOpened,\n\t\t\t\tinsertionIndex: index === -1 ? getBlockCount() : index,\n\t\t\t};\n\t\t},\n\t\t[ clientId, rootClientId ]\n\t);\n\n\tuseEffect( () => {\n\t\tif ( setInserterIsOpened ) {\n\t\t\tsetInserterIsOpened( false );\n\t\t}\n\t}, [ setInserterIsOpened ] );\n\n\t// When clicking Browse All select the appropriate block so as\n\t// the insertion point can work as expected\n\tconst onBrowseAll = () => {\n\t\tsetInserterIsOpened( { rootClientId, insertionIndex, filterValue } );\n\t};\n\n\treturn (\n\t\t<div\n\t\t\tclassName={ classnames( 'block-editor-inserter__quick-inserter', {\n\t\t\t\t'has-search': showSearch,\n\t\t\t\t'has-expand': setInserterIsOpened,\n\t\t\t} ) }\n\t\t>\n\t\t\t{ showSearch && (\n\t\t\t\t<SearchControl\n\t\t\t\t\tclassName=\"block-editor-inserter__search\"\n\t\t\t\t\tvalue={ filterValue }\n\t\t\t\t\tonChange={ ( value ) => {\n\t\t\t\t\t\tsetFilterValue( value );\n\t\t\t\t\t} }\n\t\t\t\t\tlabel={ __( 'Search for blocks and patterns' ) }\n\t\t\t\t\tplaceholder={ __( 'Search' ) }\n\t\t\t\t/>\n\t\t\t) }\n\n\t\t\t<div className=\"block-editor-inserter__quick-inserter-results\">\n\t\t\t\t<InserterSearchResults\n\t\t\t\t\tfilterValue={ filterValue }\n\t\t\t\t\tonSelect={ onSelect }\n\t\t\t\t\trootClientId={ rootClientId }\n\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\tisAppender={ isAppender }\n\t\t\t\t\tmaxBlockPatterns={ showPatterns ? SHOWN_BLOCK_PATTERNS : 0 }\n\t\t\t\t\tmaxBlockTypes={ SHOWN_BLOCK_TYPES }\n\t\t\t\t\tisDraggable={ false }\n\t\t\t\t/>\n\t\t\t</div>\n\n\t\t\t{ setInserterIsOpened && (\n\t\t\t\t<Button\n\t\t\t\t\tclassName=\"block-editor-inserter__quick-inserter-expand\"\n\t\t\t\t\tonClick={ onBrowseAll }\n\t\t\t\t\taria-label={ __(\n\t\t\t\t\t\t'Browse all. This will open the main inserter panel in the editor toolbar.'\n\t\t\t\t\t) }\n\t\t\t\t>\n\t\t\t\t\t{ __( 'Browse all' ) }\n\t\t\t\t</Button>\n\t\t\t) }\n\t\t</div>\n\t);\n}\n"]}
|
|
@@ -62,7 +62,7 @@ function InserterTabs(_ref) {
|
|
|
62
62
|
tabs,
|
|
63
63
|
tabKeys
|
|
64
64
|
} = useMemo(() => {
|
|
65
|
-
const filteredTabs = InserterTabs.
|
|
65
|
+
const filteredTabs = InserterTabs.TABS.filter(_ref3 => {
|
|
66
66
|
let {
|
|
67
67
|
name
|
|
68
68
|
} = _ref3;
|
|
@@ -109,9 +109,8 @@ function TabsControl(_ref5) {
|
|
|
109
109
|
onChangeTab,
|
|
110
110
|
showReusableBlocks
|
|
111
111
|
} = _ref5;
|
|
112
|
-
const tabs = InserterTabs.getTabs();
|
|
113
112
|
const segments = useMemo(() => {
|
|
114
|
-
const filteredTabs =
|
|
113
|
+
const filteredTabs = InserterTabs.TABS.filter(_ref6 => {
|
|
115
114
|
let {
|
|
116
115
|
name
|
|
117
116
|
} = _ref6;
|
|
@@ -125,7 +124,7 @@ function TabsControl(_ref5) {
|
|
|
125
124
|
});
|
|
126
125
|
}, [showReusableBlocks]);
|
|
127
126
|
const segmentHandler = useCallback(selectedTab => {
|
|
128
|
-
const tabTitles =
|
|
127
|
+
const tabTitles = InserterTabs.TABS.map(_ref8 => {
|
|
129
128
|
let {
|
|
130
129
|
title
|
|
131
130
|
} = _ref8;
|
|
@@ -140,8 +139,7 @@ function TabsControl(_ref5) {
|
|
|
140
139
|
}
|
|
141
140
|
|
|
142
141
|
InserterTabs.Control = TabsControl;
|
|
143
|
-
|
|
144
|
-
InserterTabs.getTabs = () => [{
|
|
142
|
+
InserterTabs.TABS = [{
|
|
145
143
|
name: 'blocks',
|
|
146
144
|
title: __('Blocks'),
|
|
147
145
|
component: BlockTypesTab
|
|
@@ -150,6 +148,5 @@ InserterTabs.getTabs = () => [{
|
|
|
150
148
|
title: __('Reusable'),
|
|
151
149
|
component: ReusableBlocksTab
|
|
152
150
|
}];
|
|
153
|
-
|
|
154
151
|
export default InserterTabs;
|
|
155
152
|
//# sourceMappingURL=tabs.native.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/inserter/tabs.native.js"],"names":["Animated","View","useCallback","useEffect","useMemo","useRef","useState","__","SegmentedControl","BlockTypesTab","ReusableBlocksTab","styles","TAB_ANIMATION_DURATION","InserterTabs","listProps","onSelect","rootClientId","showReusableBlocks","tabIndex","tabAnimation","Value","current","lastScrollEvents","wrapperWidth","setWrapperWidth","onScroll","event","nativeEvent","onWrapperLayout","layout","width","timing","duration","toValue","useNativeDriver","start","lastScrollEvent","tabs","tabKeys","filteredTabs","
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/inserter/tabs.native.js"],"names":["Animated","View","useCallback","useEffect","useMemo","useRef","useState","__","SegmentedControl","BlockTypesTab","ReusableBlocksTab","styles","TAB_ANIMATION_DURATION","InserterTabs","listProps","onSelect","rootClientId","showReusableBlocks","tabIndex","tabAnimation","Value","current","lastScrollEvents","wrapperWidth","setWrapperWidth","onScroll","event","nativeEvent","onWrapperLayout","layout","width","timing","duration","toValue","useNativeDriver","start","lastScrollEvent","tabs","tabKeys","filteredTabs","TABS","filter","name","keys","translateX","length","interpolate","inputRange","outputRange","map","key","containerStyle","transform","index","component","TabComponent","TabsControl","onChangeTab","segments","title","segmentHandler","selectedTab","tabTitles","indexOf","Control"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,QAAT,EAAmBC,IAAnB,QAA+B,cAA/B;AAEA;AACA;AACA;;AACA,SACCC,WADD,EAECC,SAFD,EAGCC,OAHD,EAICC,MAJD,EAKCC,QALD,QAMO,oBANP;AAOA,SAASC,EAAT,QAAmB,iBAAnB;AACA,SAASC,gBAAT,QAAiC,uBAAjC;AAEA;AACA;AACA;;AACA,OAAOC,aAAP,MAA0B,mBAA1B;AACA,OAAOC,iBAAP,MAA8B,uBAA9B;AACA,OAAOC,MAAP,MAAmB,cAAnB;AAEA,MAAMC,sBAAsB,GAAG,GAA/B;;AAEA,SAASC,YAAT,OAMI;AAAA,MANmB;AACtBC,IAAAA,SADsB;AAEtBC,IAAAA,QAFsB;AAGtBC,IAAAA,YAHsB;AAItBC,IAAAA,kBAJsB;AAKtBC,IAAAA;AALsB,GAMnB;AACH,QAAMC,YAAY,GAAGd,MAAM,CAAE,IAAIL,QAAQ,CAACoB,KAAb,CAAoB,CAApB,CAAF,CAAN,CAAkCC,OAAvD;AACA,QAAMC,gBAAgB,GAAGjB,MAAM,CAAE,EAAF,CAAN,CAAagB,OAAtC;AACA,QAAM,CAAEE,YAAF,EAAgBC,eAAhB,IAAoClB,QAAQ,CAAE,CAAF,CAAlD;;AAEA,WAASmB,QAAT,CAAmBC,KAAnB,EAA2B;AAC1BJ,IAAAA,gBAAgB,CAAEJ,QAAF,CAAhB,GAA+BQ,KAAK,CAACC,WAArC;AACAb,IAAAA,SAAS,CAACW,QAAV,CAAoBC,KAApB;AACA;;AAED,QAAME,eAAe,GAAG1B,WAAW,CAClC,SAAuB;AAAA,QAArB;AAAEyB,MAAAA;AAAF,KAAqB;AACtBH,IAAAA,eAAe,CAAEG,WAAW,CAACE,MAAZ,CAAmBC,KAArB,CAAf;AACA,GAHiC,EAIlC,C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AAxB;AAOA,QAAM2C,cAAc,GAAG1D,WAAW,CAC/B2D,WAAF,IAAmB;AAClB,UAAMC,SAAS,GAAGjD,YAAY,CAAC2B,IAAb,CAAkBS,GAAlB,CAAuB;AAAA,UAAE;AAAEU,QAAAA;AAAF,OAAF;AAAA,aAAiBA,KAAjB;AAAA,KAAvB,CAAlB;AACAF,IAAAA,WAAW,CAAEK,SAAS,CAACC,OAAV,CAAmBF,WAAnB,CAAF,CAAX;AACA,GAJgC,EAKjC,CAAEJ,WAAF,CALiC,CAAlC;AAQA,SAAOC,QAAQ,CAACb,MAAT,GAAkB,CAAlB,GACN,cAAC,gBAAD;AACC,IAAA,QAAQ,EAAGa,QADZ;AAEC,IAAA,cAAc,EAAGE;AAFlB,IADM,GAKH,IALJ;AAMA;;AAED/C,YAAY,CAACmD,OAAb,GAAuBR,WAAvB;AAEA3C,YAAY,CAAC2B,IAAb,GAAoB,CACnB;AAAEE,EAAAA,IAAI,EAAE,QAAR;AAAkBiB,EAAAA,KAAK,EAAEpD,EAAE,CAAE,QAAF,CAA3B;AAAyC+C,EAAAA,SAAS,EAAE7C;AAApD,CADmB,EAEnB;AAAEiC,EAAAA,IAAI,EAAE,UAAR;AAAoBiB,EAAAA,KAAK,EAAEpD,EAAE,CAAE,UAAF,CAA7B;AAA6C+C,EAAAA,SAAS,EAAE5C;AAAxD,CAFmB,CAApB;AAKA,eAAeG,YAAf","sourcesContent":["/**\n * External dependencies\n */\nimport { Animated, View } from 'react-native';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tuseCallback,\n\tuseEffect,\n\tuseMemo,\n\tuseRef,\n\tuseState,\n} from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport { SegmentedControl } from '@wordpress/components';\n\n/**\n * Internal dependencies\n */\nimport BlockTypesTab from './block-types-tab';\nimport ReusableBlocksTab from './reusable-blocks-tab';\nimport styles from './style.scss';\n\nconst TAB_ANIMATION_DURATION = 250;\n\nfunction InserterTabs( {\n\tlistProps,\n\tonSelect,\n\trootClientId,\n\tshowReusableBlocks,\n\ttabIndex,\n} ) {\n\tconst tabAnimation = useRef( new Animated.Value( 0 ) ).current;\n\tconst lastScrollEvents = useRef( [] ).current;\n\tconst [ wrapperWidth, setWrapperWidth ] = useState( 0 );\n\n\tfunction onScroll( event ) {\n\t\tlastScrollEvents[ tabIndex ] = event.nativeEvent;\n\t\tlistProps.onScroll( event );\n\t}\n\n\tconst onWrapperLayout = useCallback(\n\t\t( { nativeEvent } ) => {\n\t\t\tsetWrapperWidth( nativeEvent.layout.width );\n\t\t},\n\t\t[ setWrapperWidth ]\n\t);\n\n\tuseEffect( () => {\n\t\tAnimated.timing( tabAnimation, {\n\t\t\tduration: TAB_ANIMATION_DURATION,\n\t\t\ttoValue: tabIndex,\n\t\t\tuseNativeDriver: true,\n\t\t} ).start();\n\n\t\t// Notify upstream with the last scroll event of the current tab.\n\t\tconst lastScrollEvent = lastScrollEvents[ tabIndex ];\n\t\tif ( lastScrollEvent ) {\n\t\t\tlistProps.onScroll( { nativeEvent: lastScrollEvent } );\n\t\t}\n\t}, [ tabIndex ] );\n\n\tconst { tabs, tabKeys } = useMemo( () => {\n\t\tconst filteredTabs = InserterTabs.TABS.filter(\n\t\t\t( { name } ) => showReusableBlocks || name !== 'reusable'\n\t\t);\n\t\treturn {\n\t\t\ttabs: filteredTabs,\n\t\t\ttabKeys: [ ...filteredTabs.keys() ],\n\t\t};\n\t}, [ showReusableBlocks ] );\n\n\tconst translateX = useMemo(\n\t\t() =>\n\t\t\ttabKeys.length > 1\n\t\t\t\t? tabAnimation.interpolate( {\n\t\t\t\t\t\tinputRange: tabKeys,\n\t\t\t\t\t\toutputRange: tabKeys.map(\n\t\t\t\t\t\t\t( key ) => key * -wrapperWidth\n\t\t\t\t\t\t),\n\t\t\t\t } )\n\t\t\t\t: tabAnimation,\n\t\t[ tabAnimation, tabKeys, wrapperWidth ]\n\t);\n\n\tconst containerStyle = [\n\t\tstyles[ 'inserter-tabs__container' ],\n\t\t{\n\t\t\twidth: wrapperWidth * tabKeys.length,\n\t\t\ttransform: [ { translateX } ],\n\t\t},\n\t];\n\n\treturn (\n\t\t<View\n\t\t\tstyle={ styles[ 'inserter-tabs__wrapper' ] }\n\t\t\tonLayout={ onWrapperLayout }\n\t\t>\n\t\t\t<Animated.View style={ containerStyle }>\n\t\t\t\t{ tabs.map( ( { component: TabComponent }, index ) => (\n\t\t\t\t\t<View key={ `tab-${ index }` }>\n\t\t\t\t\t\t<TabComponent\n\t\t\t\t\t\t\trootClientId={ rootClientId }\n\t\t\t\t\t\t\tonSelect={ onSelect }\n\t\t\t\t\t\t\tlistProps={ { ...listProps, onScroll } }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</View>\n\t\t\t\t) ) }\n\t\t\t</Animated.View>\n\t\t</View>\n\t);\n}\n\nfunction TabsControl( { onChangeTab, showReusableBlocks } ) {\n\tconst segments = useMemo( () => {\n\t\tconst filteredTabs = InserterTabs.TABS.filter(\n\t\t\t( { name } ) => showReusableBlocks || name !== 'reusable'\n\t\t);\n\t\treturn filteredTabs.map( ( { title } ) => title );\n\t}, [ showReusableBlocks ] );\n\n\tconst segmentHandler = useCallback(\n\t\t( selectedTab ) => {\n\t\t\tconst tabTitles = InserterTabs.TABS.map( ( { title } ) => title );\n\t\t\tonChangeTab( tabTitles.indexOf( selectedTab ) );\n\t\t},\n\t\t[ onChangeTab ]\n\t);\n\n\treturn segments.length > 1 ? (\n\t\t<SegmentedControl\n\t\t\tsegments={ segments }\n\t\t\tsegmentHandler={ segmentHandler }\n\t\t/>\n\t) : null;\n}\n\nInserterTabs.Control = TabsControl;\n\nInserterTabs.TABS = [\n\t{ name: 'blocks', title: __( 'Blocks' ), component: BlockTypesTab },\n\t{ name: 'reusable', title: __( 'Reusable' ), component: ReusableBlocksTab },\n];\n\nexport default InserterTabs;\n"]}
|
|
@@ -13,8 +13,7 @@ export default function BlockSupportSlotContainer(_ref) {
|
|
|
13
13
|
} = _ref;
|
|
14
14
|
const toolsPanelContext = useContext(ToolsPanelContext);
|
|
15
15
|
return createElement(Slot, _extends({}, props, {
|
|
16
|
-
fillProps: toolsPanelContext
|
|
17
|
-
bubblesVirtually: true
|
|
16
|
+
fillProps: toolsPanelContext
|
|
18
17
|
}));
|
|
19
18
|
}
|
|
20
19
|
//# sourceMappingURL=block-support-slot-container.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/inspector-controls/block-support-slot-container.js"],"names":["__experimentalToolsPanelContext","ToolsPanelContext","useContext","BlockSupportSlotContainer","Slot","props","toolsPanelContext"],"mappings":";;;AAAA;AACA;AACA;AACA,SAASA,+BAA+B,IAAIC,iBAA5C,QAAqE,uBAArE;AACA,SAASC,UAAT,QAA2B,oBAA3B;AAEA,eAAe,SAASC,yBAAT,OAAyD;AAAA,MAArB;AAAEC,IAAAA,IAAF;AAAQ,OAAGC;AAAX,GAAqB;AACvE,QAAMC,iBAAiB,GAAGJ,UAAU,CAAED,iBAAF,CAApC;AACA,
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/inspector-controls/block-support-slot-container.js"],"names":["__experimentalToolsPanelContext","ToolsPanelContext","useContext","BlockSupportSlotContainer","Slot","props","toolsPanelContext"],"mappings":";;;AAAA;AACA;AACA;AACA,SAASA,+BAA+B,IAAIC,iBAA5C,QAAqE,uBAArE;AACA,SAASC,UAAT,QAA2B,oBAA3B;AAEA,eAAe,SAASC,yBAAT,OAAyD;AAAA,MAArB;AAAEC,IAAAA,IAAF;AAAQ,OAAGC;AAAX,GAAqB;AACvE,QAAMC,iBAAiB,GAAGJ,UAAU,CAAED,iBAAF,CAApC;AACA,SAAO,cAAC,IAAD,eAAWI,KAAX;AAAmB,IAAA,SAAS,EAAGC;AAA/B,KAAP;AACA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __experimentalToolsPanelContext as ToolsPanelContext } from '@wordpress/components';\nimport { useContext } from '@wordpress/element';\n\nexport default function BlockSupportSlotContainer( { Slot, ...props } ) {\n\tconst toolsPanelContext = useContext( ToolsPanelContext );\n\treturn <Slot { ...props } fillProps={ toolsPanelContext } />;\n}\n"]}
|
|
@@ -18,17 +18,41 @@ export default function BlockSupportToolsPanel(_ref) {
|
|
|
18
18
|
label
|
|
19
19
|
} = _ref;
|
|
20
20
|
const {
|
|
21
|
-
|
|
22
|
-
|
|
21
|
+
attributes,
|
|
22
|
+
clientIds,
|
|
23
|
+
panelId
|
|
23
24
|
} = useSelect(select => {
|
|
24
25
|
const {
|
|
25
26
|
getBlockAttributes,
|
|
26
|
-
|
|
27
|
-
|
|
27
|
+
getMultiSelectedBlockClientIds,
|
|
28
|
+
getSelectedBlockClientId,
|
|
29
|
+
hasMultiSelection
|
|
30
|
+
} = select(blockEditorStore); // When we currently have a multi-selection, the value returned from
|
|
31
|
+
// `getSelectedBlockClientId()` is `null`. When a `null` value is used
|
|
32
|
+
// for the `panelId`, a `ToolsPanel` will still allow panel items to
|
|
33
|
+
// register themselves despite their panelIds not matching.
|
|
34
|
+
|
|
28
35
|
const selectedBlockClientId = getSelectedBlockClientId();
|
|
36
|
+
|
|
37
|
+
if (hasMultiSelection()) {
|
|
38
|
+
const selectedBlockClientIds = getMultiSelectedBlockClientIds();
|
|
39
|
+
const selectedBlockAttributes = selectedBlockClientIds.reduce((blockAttributes, blockId) => {
|
|
40
|
+
blockAttributes[blockId] = getBlockAttributes(blockId);
|
|
41
|
+
return blockAttributes;
|
|
42
|
+
}, {});
|
|
43
|
+
return {
|
|
44
|
+
panelId: selectedBlockClientId,
|
|
45
|
+
clientIds: selectedBlockClientIds,
|
|
46
|
+
attributes: selectedBlockAttributes
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
|
|
29
50
|
return {
|
|
30
|
-
|
|
31
|
-
|
|
51
|
+
panelId: selectedBlockClientId,
|
|
52
|
+
clientIds: [selectedBlockClientId],
|
|
53
|
+
attributes: {
|
|
54
|
+
[selectedBlockClientId]: getBlockAttributes(selectedBlockClientId)
|
|
55
|
+
}
|
|
32
56
|
};
|
|
33
57
|
}, []);
|
|
34
58
|
const {
|
|
@@ -37,30 +61,34 @@ export default function BlockSupportToolsPanel(_ref) {
|
|
|
37
61
|
|
|
38
62
|
const resetAll = function () {
|
|
39
63
|
let resetFilters = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
40
|
-
const {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
newAttributes = { ...newAttributes,
|
|
48
|
-
...resetFilter(newAttributes)
|
|
64
|
+
const newAttributes = {};
|
|
65
|
+
clientIds.forEach(clientId => {
|
|
66
|
+
const {
|
|
67
|
+
style
|
|
68
|
+
} = attributes[clientId];
|
|
69
|
+
let newBlockAttributes = {
|
|
70
|
+
style
|
|
49
71
|
};
|
|
50
|
-
|
|
72
|
+
resetFilters.forEach(resetFilter => {
|
|
73
|
+
newBlockAttributes = { ...newBlockAttributes,
|
|
74
|
+
...resetFilter(newBlockAttributes)
|
|
75
|
+
};
|
|
76
|
+
}); // Enforce a cleaned style object.
|
|
51
77
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
78
|
+
newBlockAttributes = { ...newBlockAttributes,
|
|
79
|
+
style: cleanEmptyObject(newBlockAttributes.style)
|
|
80
|
+
};
|
|
81
|
+
newAttributes[clientId] = newBlockAttributes;
|
|
82
|
+
});
|
|
83
|
+
updateBlockAttributes(clientIds, newAttributes, true);
|
|
56
84
|
};
|
|
57
85
|
|
|
58
86
|
return createElement(ToolsPanel, {
|
|
59
87
|
className: `${group}-block-support-panel`,
|
|
60
88
|
label: label,
|
|
61
89
|
resetAll: resetAll,
|
|
62
|
-
key:
|
|
63
|
-
panelId:
|
|
90
|
+
key: panelId,
|
|
91
|
+
panelId: panelId,
|
|
64
92
|
hasInnerWrapper: true,
|
|
65
93
|
shouldRenderPlaceholderItems: true // Required to maintain fills ordering.
|
|
66
94
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/inspector-controls/block-support-tools-panel.js"],"names":["__experimentalToolsPanel","ToolsPanel","useDispatch","useSelect","store","blockEditorStore","cleanEmptyObject","BlockSupportToolsPanel","children","group","label","
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/inspector-controls/block-support-tools-panel.js"],"names":["__experimentalToolsPanel","ToolsPanel","useDispatch","useSelect","store","blockEditorStore","cleanEmptyObject","BlockSupportToolsPanel","children","group","label","attributes","clientIds","panelId","select","getBlockAttributes","getMultiSelectedBlockClientIds","getSelectedBlockClientId","hasMultiSelection","selectedBlockClientId","selectedBlockClientIds","selectedBlockAttributes","reduce","blockAttributes","blockId","updateBlockAttributes","resetAll","resetFilters","newAttributes","forEach","clientId","style","newBlockAttributes","resetFilter"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,wBAAwB,IAAIC,UAArC,QAAuD,uBAAvD;AACA,SAASC,WAAT,EAAsBC,SAAtB,QAAuC,iBAAvC;AAEA;AACA;AACA;;AACA,SAASC,KAAK,IAAIC,gBAAlB,QAA0C,aAA1C;AACA,SAASC,gBAAT,QAAiC,mBAAjC;AAEA,eAAe,SAASC,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,MAAqCV,SAAS,CAAIW,MAAF,IAAc;AACnE,UAAM;AACLC,MAAAA,kBADK;AAELC,MAAAA,8BAFK;AAGLC,MAAAA,wBAHK;AAILC,MAAAA;AAJK,QAKFJ,MAAM,CAAET,gBAAF,CALV,CADmE,CAQnE;AACA;AACA;AACA;;AACA,UAAMc,qBAAqB,GAAGF,wBAAwB,EAAtD;;AAEA,QAAKC,iBAAiB,EAAtB,EAA2B;AAC1B,YAAME,sBAA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kB,CAACD,KAArB;AAFH,OAArB;AAKAH,MAAAA,aAAa,CAAEE,QAAF,CAAb,GAA4BE,kBAA5B;AACA,KAlBD;AAoBAP,IAAAA,qBAAqB,CAAEb,SAAF,EAAagB,aAAb,EAA4B,IAA5B,CAArB;AACA,GAxBD;;AA0BA,SACC,cAAC,UAAD;AACC,IAAA,SAAS,EAAI,GAAGnB,KAAO,sBADxB;AAEC,IAAA,KAAK,EAAGC,KAFT;AAGC,IAAA,QAAQ,EAAGgB,QAHZ;AAIC,IAAA,GAAG,EAAGb,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"]}
|
|
@@ -16,7 +16,7 @@ import warning from '@wordpress/warning';
|
|
|
16
16
|
*/
|
|
17
17
|
|
|
18
18
|
import groups from './groups';
|
|
19
|
-
import
|
|
19
|
+
import { useBlockEditContext } from '../block-edit/context';
|
|
20
20
|
import { BlockSettingsButton } from '../block-settings';
|
|
21
21
|
export default function InspectorControlsFill(_ref) {
|
|
22
22
|
var _groups$group;
|
|
@@ -26,7 +26,9 @@ export default function InspectorControlsFill(_ref) {
|
|
|
26
26
|
__experimentalGroup: group = 'default',
|
|
27
27
|
...props
|
|
28
28
|
} = _ref;
|
|
29
|
-
const
|
|
29
|
+
const {
|
|
30
|
+
isSelected
|
|
31
|
+
} = useBlockEditContext();
|
|
30
32
|
const Fill = (_groups$group = groups[group]) === null || _groups$group === void 0 ? void 0 : _groups$group.Fill;
|
|
31
33
|
|
|
32
34
|
if (!Fill) {
|
|
@@ -34,7 +36,7 @@ export default function InspectorControlsFill(_ref) {
|
|
|
34
36
|
return null;
|
|
35
37
|
}
|
|
36
38
|
|
|
37
|
-
if (!
|
|
39
|
+
if (!isSelected) {
|
|
38
40
|
return null;
|
|
39
41
|
}
|
|
40
42
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/inspector-controls/fill.native.js"],"names":["View","Children","BottomSheetConsumer","warning","groups","
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/inspector-controls/fill.native.js"],"names":["View","Children","BottomSheetConsumer","warning","groups","useBlockEditContext","BlockSettingsButton","InspectorControlsFill","children","__experimentalGroup","group","props","isSelected","Fill","count"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,IAAT,QAAqB,cAArB;AAEA;AACA;AACA;;AACA,SAASC,QAAT,QAAyB,oBAAzB;AACA,SAASC,mBAAT,QAAoC,uBAApC;AACA,OAAOC,OAAP,MAAoB,oBAApB;AAEA;AACA;AACA;;AACA,OAAOC,MAAP,MAAmB,UAAnB;AACA,SAASC,mBAAT,QAAoC,uBAApC;AACA,SAASC,mBAAT,QAAoC,mBAApC;AAEA,eAAe,SAASC,qBAAT,OAIX;AAAA;;AAAA,MAJ2C;AAC9CC,IAAAA,QAD8C;AAE9CC,IAAAA,mBAAmB,EAAEC,KAAK,GAAG,SAFiB;AAG9C,OAAGC;AAH2C,GAI3C;AACH,QAAM;AAAEC,IAAAA;AAAF,MAAiBP,mBAAmB,EAA1C;AACA,QAAMQ,IAAI,oBAAGT,MAAM,CAAEM,KAAF,CAAT,kDAAG,cAAiBG,IAA9B;;AACA,MAAK,CAAEA,IAAP,EAAc;AACb,6FAAAV,OAAO,CAAG,mCAAmCO,KAAO,aAA7C,CAAP;AACA,WAAO,IAAP;AACA;;AACD,MAAK,CAAEE,UAAP,EAAoB;AACnB,WAAO,IAAP;AACA;;AAED,SACC,8BACC,cAAC,IAAD,EAAWD,KAAX,EAEE,cAAC,mBAAD,QACG,MAAM,cAAC,IAAD,QAAQH,QAAR,CADT,CAFF,CADD,EAQGP,QAAQ,CAACa,KAAT,CAAgBN,QAAhB,IAA6B,CAA7B,IAAkC,cAAC,mBAAD,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"]}
|
|
@@ -4,13 +4,11 @@
|
|
|
4
4
|
import { createSlotFill } from '@wordpress/components';
|
|
5
5
|
const InspectorControlsDefault = createSlotFill('InspectorControls');
|
|
6
6
|
const InspectorControlsAdvanced = createSlotFill('InspectorAdvancedControls');
|
|
7
|
-
const InspectorControlsBorder = createSlotFill('InspectorControlsBorder');
|
|
8
7
|
const InspectorControlsDimensions = createSlotFill('InspectorControlsDimensions');
|
|
9
8
|
const InspectorControlsTypography = createSlotFill('InspectorControlsTypography');
|
|
10
9
|
const groups = {
|
|
11
10
|
default: InspectorControlsDefault,
|
|
12
11
|
advanced: InspectorControlsAdvanced,
|
|
13
|
-
border: InspectorControlsBorder,
|
|
14
12
|
dimensions: InspectorControlsDimensions,
|
|
15
13
|
typography: InspectorControlsTypography
|
|
16
14
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/inspector-controls/groups.js"],"names":["createSlotFill","InspectorControlsDefault","InspectorControlsAdvanced","
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/inspector-controls/groups.js"],"names":["createSlotFill","InspectorControlsDefault","InspectorControlsAdvanced","InspectorControlsDimensions","InspectorControlsTypography","groups","default","advanced","dimensions","typography"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,cAAT,QAA+B,uBAA/B;AAEA,MAAMC,wBAAwB,GAAGD,cAAc,CAAE,mBAAF,CAA/C;AACA,MAAME,yBAAyB,GAAGF,cAAc,CAAE,2BAAF,CAAhD;AACA,MAAMG,2BAA2B,GAAGH,cAAc,CACjD,6BADiD,CAAlD;AAGA,MAAMI,2BAA2B,GAAGJ,cAAc,CACjD,6BADiD,CAAlD;AAIA,MAAMK,MAAM,GAAG;AACdC,EAAAA,OAAO,EAAEL,wBADK;AAEdM,EAAAA,QAAQ,EAAEL,yBAFI;AAGdM,EAAAA,UAAU,EAAEL,2BAHE;AAIdM,EAAAA,UAAU,EAAEL;AAJE,CAAf;AAOA,eAAeC,MAAf","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"]}
|
|
@@ -18,6 +18,7 @@ export default function InspectorControlsSlot(_ref) {
|
|
|
18
18
|
|
|
19
19
|
let {
|
|
20
20
|
__experimentalGroup: group = 'default',
|
|
21
|
+
bubblesVirtually = true,
|
|
21
22
|
label,
|
|
22
23
|
...props
|
|
23
24
|
} = _ref;
|
|
@@ -40,12 +41,13 @@ export default function InspectorControlsSlot(_ref) {
|
|
|
40
41
|
group: group,
|
|
41
42
|
label: label
|
|
42
43
|
}, createElement(BlockSupportSlotContainer, _extends({}, props, {
|
|
44
|
+
bubblesVirtually: bubblesVirtually,
|
|
43
45
|
Slot: Slot
|
|
44
46
|
})));
|
|
45
47
|
}
|
|
46
48
|
|
|
47
49
|
return createElement(Slot, _extends({}, props, {
|
|
48
|
-
bubblesVirtually:
|
|
50
|
+
bubblesVirtually: bubblesVirtually
|
|
49
51
|
}));
|
|
50
52
|
}
|
|
51
53
|
//# sourceMappingURL=slot.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/inspector-controls/slot.js"],"names":["__experimentalUseSlot","useSlot","warning","BlockSupportToolsPanel","BlockSupportSlotContainer","groups","InspectorControlsSlot","__experimentalGroup","group","label","props","Slot","slot","__unstableName","hasFills","Boolean","fills","length"],"mappings":";;;AAAA;AACA;AACA;AACA,SAASA,qBAAqB,IAAIC,OAAlC,QAAiD,uBAAjD;AACA,OAAOC,OAAP,MAAoB,oBAApB;AAEA;AACA;AACA;;AACA,OAAOC,sBAAP,MAAmC,6BAAnC;AACA,OAAOC,yBAAP,MAAsC,gCAAtC;AACA,OAAOC,MAAP,MAAmB,UAAnB;AAEA,eAAe,SAASC,qBAAT,
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/inspector-controls/slot.js"],"names":["__experimentalUseSlot","useSlot","warning","BlockSupportToolsPanel","BlockSupportSlotContainer","groups","InspectorControlsSlot","__experimentalGroup","group","bubblesVirtually","label","props","Slot","slot","__unstableName","hasFills","Boolean","fills","length"],"mappings":";;;AAAA;AACA;AACA;AACA,SAASA,qBAAqB,IAAIC,OAAlC,QAAiD,uBAAjD;AACA,OAAOC,OAAP,MAAoB,oBAApB;AAEA;AACA;AACA;;AACA,OAAOC,sBAAP,MAAmC,6BAAnC;AACA,OAAOC,yBAAP,MAAsC,gCAAtC;AACA,OAAOC,MAAP,MAAmB,UAAnB;AAEA,eAAe,SAASC,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,oBAAGP,MAAM,CAAEG,KAAF,CAAT,kDAAG,cAAiBI,IAA9B;AACA,QAAMC,IAAI,GAAGZ,OAAO,CAAEW,IAAF,aAAEA,IAAF,uBAAEA,IAAI,CAAEE,cAAR,CAApB;;AACA,MAAK,CAAEF,IAAF,IAAU,CAAEC,IAAjB,EAAwB;AACvB,6FAAAX,OAAO,CAAG,mCAAmCM,KAAO,aAA7C,CAAP;AACA,WAAO,IAAP;AACA;;AAED,QAAMO,QAAQ,GAAGC,OAAO,CAAEH,IAAI,CAACI,KAAL,IAAcJ,IAAI,CAACI,KAAL,CAAWC,MAA3B,CAAxB;;AACA,MAAK,CAAEH,QAAP,EAAkB;AACjB,WAAO,IAAP;AACA;;AAED,MAAKL,KAAL,EAAa;AACZ,WACC,cAAC,sBAAD;AAAwB,MAAA,KAAK,EAAGF,KAAhC;AAAwC,MAAA,KAAK,EAAGE;AAAhD,OACC,cAAC,yBAAD,eACMC,KADN;AAEC,MAAA,gBAAgB,EAAGF,gBAFpB;AAGC,MAAA,IAAI,EAAGG;AAHR,OADD,CADD;AASA;;AAED,SAAO,cAAC,IAAD,eAAWD,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"]}
|
|
@@ -13,12 +13,12 @@ import useSetting from '../../components/use-setting';
|
|
|
13
13
|
/**
|
|
14
14
|
* Control for letter-spacing.
|
|
15
15
|
*
|
|
16
|
-
* @param {Object}
|
|
17
|
-
* @param {string}
|
|
18
|
-
* @param {Function}
|
|
19
|
-
* @param {
|
|
16
|
+
* @param {Object} props Component props.
|
|
17
|
+
* @param {string} props.value Currently selected letter-spacing.
|
|
18
|
+
* @param {Function} props.onChange Handles change in letter-spacing selection.
|
|
19
|
+
* @param {boolean} props.__unstableInputWidth Input width to pass through to inner UnitControl.
|
|
20
20
|
*
|
|
21
|
-
* @return {WPElement}
|
|
21
|
+
* @return {WPElement} Letter-spacing control.
|
|
22
22
|
*/
|
|
23
23
|
|
|
24
24
|
export default function LetterSpacingControl(_ref) {
|
|
@@ -36,7 +36,7 @@ export default function LetterSpacingControl(_ref) {
|
|
|
36
36
|
}
|
|
37
37
|
});
|
|
38
38
|
return createElement(UnitControl, {
|
|
39
|
-
label: __('Letter
|
|
39
|
+
label: __('Letter-spacing'),
|
|
40
40
|
value: value,
|
|
41
41
|
__unstableInputWidth: __unstableInputWidth,
|
|
42
42
|
units: units,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/letter-spacing-control/index.js"],"names":["__experimentalUnitControl","UnitControl","__experimentalUseCustomUnits","useCustomUnits","__","useSetting","LetterSpacingControl","value","onChange","__unstableInputWidth","units","availableUnits","defaultValues","px","em","rem"],"mappings":";;AAAA;AACA;AACA;AACA,SACCA,yBAAyB,IAAIC,WAD9B,EAECC,4BAA4B,IAAIC,cAFjC,QAGO,uBAHP;AAIA,SAASC,EAAT,QAAmB,iBAAnB;AAEA;AACA;AACA;;AACA,OAAOC,UAAP,MAAuB,8BAAvB;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,eAAe,SAASC,oBAAT,OAIX;AAAA,MAJ0C;AAC7CC,IAAAA,KAD6C;AAE7CC,IAAAA,QAF6C;AAG7CC,IAAAA,oBAAoB,GAAG;AAHsB,GAI1C;AACH,QAAMC,KAAK,GAAGP,cAAc,CAAE;AAC7BQ,IAAAA,cAAc,EAAEN,UAAU,CAAE,eAAF,CAAV,IAAiC,CAAE,IAAF,EAAQ,IAAR,EAAc,KAAd,CADpB;AAE7BO,IAAAA,aAAa,EAAE;AAAEC,MAAAA,EAAE,EAAE,GAAN;AAAWC,MAAAA,EAAE,EAAE,IAAf;AAAqBC,MAAAA,GAAG,EAAE;AAA1B;AAFc,GAAF,CAA5B;AAIA,SACC,cAAC,WAAD;AACC,IAAA,KAAK,EAAGX,EAAE,CAAE,gBAAF,CADX;AAEC,IAAA,KAAK,EAAGG,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":["__experimentalUnitControl","UnitControl","__experimentalUseCustomUnits","useCustomUnits","__","useSetting","LetterSpacingControl","value","onChange","__unstableInputWidth","units","availableUnits","defaultValues","px","em","rem"],"mappings":";;AAAA;AACA;AACA;AACA,SACCA,yBAAyB,IAAIC,WAD9B,EAECC,4BAA4B,IAAIC,cAFjC,QAGO,uBAHP;AAIA,SAASC,EAAT,QAAmB,iBAAnB;AAEA;AACA;AACA;;AACA,OAAOC,UAAP,MAAuB,8BAAvB;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,eAAe,SAASC,oBAAT,OAIX;AAAA,MAJ0C;AAC7CC,IAAAA,KAD6C;AAE7CC,IAAAA,QAF6C;AAG7CC,IAAAA,oBAAoB,GAAG;AAHsB,GAI1C;AACH,QAAMC,KAAK,GAAGP,cAAc,CAAE;AAC7BQ,IAAAA,cAAc,EAAEN,UAAU,CAAE,eAAF,CAAV,IAAiC,CAAE,IAAF,EAAQ,IAAR,EAAc,KAAd,CADpB;AAE7BO,IAAAA,aAAa,EAAE;AAAEC,MAAAA,EAAE,EAAE,GAAN;AAAWC,MAAAA,EAAE,EAAE,IAAf;AAAqBC,MAAAA,GAAG,EAAE;AAA1B;AAFc,GAAF,CAA5B;AAIA,SACC,cAAC,WAAD;AACC,IAAA,KAAK,EAAGX,EAAE,CAAE,gBAAF,CADX;AAEC,IAAA,KAAK,EAAGG,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"]}
|
|
@@ -21,7 +21,6 @@ import useBlockDisplayInformation from '../use-block-display-information';
|
|
|
21
21
|
import { getBlockPositionDescription } from './utils';
|
|
22
22
|
import BlockTitle from '../block-title';
|
|
23
23
|
import ListViewExpander from './expander';
|
|
24
|
-
import { SPACE, ENTER } from '@wordpress/keycodes';
|
|
25
24
|
|
|
26
25
|
function ListViewBlockSelectButton(_ref, ref) {
|
|
27
26
|
let {
|
|
@@ -44,35 +43,17 @@ function ListViewBlockSelectButton(_ref, ref) {
|
|
|
44
43
|
const blockInformation = useBlockDisplayInformation(clientId);
|
|
45
44
|
const instanceId = useInstanceId(ListViewBlockSelectButton);
|
|
46
45
|
const descriptionId = `list-view-block-select-button__${instanceId}`;
|
|
47
|
-
const blockPositionDescription = getBlockPositionDescription(position, siblingBlockCount, level);
|
|
48
|
-
// When the link is dragged, the element's outerHTML is set in DataTransfer object as text/html.
|
|
49
|
-
// We need to clear any HTML drag data to prevent `pasteHandler` from firing
|
|
50
|
-
// inside the `useOnBlockDrop` hook.
|
|
51
|
-
|
|
52
|
-
const onDragStartHandler = event => {
|
|
53
|
-
event.dataTransfer.clearData();
|
|
54
|
-
onDragStart(event);
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
function onKeyDownHandler(event) {
|
|
58
|
-
if (event.keyCode === ENTER || event.keyCode === SPACE) {
|
|
59
|
-
event.preventDefault();
|
|
60
|
-
onClick(event);
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
|
|
46
|
+
const blockPositionDescription = getBlockPositionDescription(position, siblingBlockCount, level);
|
|
64
47
|
return createElement(Fragment, null, createElement(Button, {
|
|
65
48
|
className: classnames('block-editor-list-view-block-select-button', className),
|
|
66
49
|
onClick: onClick,
|
|
67
|
-
onKeyDown: onKeyDownHandler,
|
|
68
50
|
"aria-describedby": descriptionId,
|
|
69
51
|
ref: ref,
|
|
70
52
|
tabIndex: tabIndex,
|
|
71
53
|
onFocus: onFocus,
|
|
72
|
-
onDragStart:
|
|
54
|
+
onDragStart: onDragStart,
|
|
73
55
|
onDragEnd: onDragEnd,
|
|
74
|
-
draggable: draggable
|
|
75
|
-
href: `#block-${clientId}`
|
|
56
|
+
draggable: draggable
|
|
76
57
|
}, createElement(ListViewExpander, {
|
|
77
58
|
onClick: onToggleExpanded
|
|
78
59
|
}), createElement(BlockIcon, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/list-view/block-select-button.js"],"names":["classnames","Button","VisuallyHidden","useInstanceId","forwardRef","__","BlockIcon","useBlockDisplayInformation","getBlockPositionDescription","BlockTitle","ListViewExpander","
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/list-view/block-select-button.js"],"names":["classnames","Button","VisuallyHidden","useInstanceId","forwardRef","__","BlockIcon","useBlockDisplayInformation","getBlockPositionDescription","BlockTitle","ListViewExpander","ListViewBlockSelectButton","ref","className","block","clientId","isSelected","onClick","onToggleExpanded","position","siblingBlockCount","level","tabIndex","onFocus","onDragStart","onDragEnd","draggable","blockInformation","instanceId","descriptionId","blockPositionDescription","icon","anchor"],"mappings":";;AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,YAAvB;AAEA;AACA;AACA;;AACA,SAASC,MAAT,EAAiBC,cAAjB,QAAuC,uBAAvC;AACA,SAASC,aAAT,QAA8B,oBAA9B;AACA,SAASC,UAAT,QAA2B,oBAA3B;AACA,SAASC,EAAT,QAAmB,iBAAnB;AAEA;AACA;AACA;;AACA,OAAOC,SAAP,MAAsB,eAAtB;AACA,OAAOC,0BAAP,MAAuC,kCAAvC;AACA,SAASC,2BAAT,QAA4C,SAA5C;AACA,OAAOC,UAAP,MAAuB,gBAAvB;AACA,OAAOC,gBAAP,MAA6B,YAA7B;;AAEA,SAASC,yBAAT,OA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CAAEK,MAAlB,KACD;AAAM,IAAA,SAAS,EAAC;AAAhB,KACGL,gBAAgB,CAACK,MADpB,CAlBF,EAsBGhB,UAAU,IACX,cAAC,cAAD,QACGX,EAAE,CAAE,kBAAF,CADL,CAvBF,CADD,EA6BC;AACC,IAAA,SAAS,EAAC,yDADX;AAEC,IAAA,EAAE,EAAGwB;AAFN,KAIGC,wBAJH,CA7BD,CADD;AAsCA;;AAED,eAAe1B,UAAU,CAAEO,yBAAF,CAAzB","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"]}
|
|
@@ -195,7 +195,7 @@ export default function useListViewDropZone() {
|
|
|
195
195
|
return {
|
|
196
196
|
clientId,
|
|
197
197
|
rootClientId,
|
|
198
|
-
blockIndex: getBlockIndex(clientId
|
|
198
|
+
blockIndex: getBlockIndex(clientId),
|
|
199
199
|
element: blockElement,
|
|
200
200
|
isDraggedBlock: isBlockDrag ? draggedBlockClientIds.includes(clientId) : false,
|
|
201
201
|
innerBlockCount: getBlockCount(clientId),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/list-view/use-list-view-drop-zone.js"],"names":["useSelect","useState","useCallback","useThrottle","__experimentalUseDropZone","useDropZone","getDistanceToNearestEdge","useOnBlockDrop","store","blockEditorStore","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","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":"AAAA;AACA;AACA;AACA,SAASA,SAAT,QAA0B,iBAA1B;AACA,SAASC,QAAT,EAAmBC,WAAnB,QAAsC,oBAAtC;AACA,SACCC,WADD,EAECC,yBAAyB,IAAIC,WAF9B,QAGO,oBAHP;AAKA;AACA;AACA;;AACA,SAASC,wBAAT,QAAyC,kBAAzC;AACA,OAAOC,cAAP,MAA2B,sBAA3B;AACA,SAASC,KAAK,IAAIC,gBAAlB,QAA0C,aAA1C;AAEA;;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,SAASC,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;A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tB,CAAgChC,QAAhC,CADwB,GAExB,KAPG;AAQND,QAAAA,eAAe,EAAES,aAAa,CAAER,QAAF,CARxB;AASNG,QAAAA,+BAA+B,EAAEmB,WAAW,GACzCZ,eAAe,CACfM,qBADe,EAEfpB,YAFe,CAD0B,GAKzC,IAdG;AAeNE,QAAAA,6BAA6B,EAAEwB,WAAW,GACvCZ,eAAe,CAAEM,qBAAF,EAAyBhB,QAAzB,CADwB,GAEvC;AAjBG,OAAP;AAmBA,KAvBkB,CAAnB;AAyBA,UAAMiC,SAAS,GAAGvD,qBAAqB,CAAEC,UAAF,EAAcC,QAAd,CAAvC;;AAEA,QAAKqD,SAAL,EAAiB;AAChBrB,MAAAA,SAAS,CAAEqB,SAAF,CAAT;AACA;AACD,GAvCS,EAwCV,CAAEjB,qBAAF,CAxCU,CADiB,EA2C5B,GA3C4B,CAA7B;AA8CA,QAAMkB,GAAG,GAAG1E,WAAW,CAAE;AACxB2E,IAAAA,MAAM,EAAEpB,WADgB;;AAExBqB,IAAAA,UAAU,CAAElB,KAAF,EAAU;AACnB;AACA;AACA;AACAD,MAAAA,SAAS,CAAEC,KAAF,EAASA,KAAK,CAACC,aAAf,CAAT;AACA,KAPuB;;AAQxBkB,IAAAA,SAAS,GAAG;AACXpB,MAAAA,SAAS,CAACqB,MAAV;AACA1B,MAAAA,SAAS,CAAE,IAAF,CAAT;AACA;;AAXuB,GAAF,CAAvB;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":["useSelect","useState","useCallback","useThrottle","__experimentalUseDropZone","useDropZone","getDistanceToNearestEdge","useOnBlockDrop","store","blockEditorStore","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","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":"AAAA;AACA;AACA;AACA,SAASA,SAAT,QAA0B,iBAA1B;AACA,SAASC,QAAT,EAAmBC,WAAnB,QAAsC,oBAAtC;AACA,SACCC,WADD,EAECC,yBAAyB,IAAIC,WAF9B,QAGO,oBAHP;AAKA;AACA;AACA;;AACA,SAASC,wBAAT,QAAyC,kBAAzC;AACA,OAAOC,cAAP,MAA2B,sBAA3B;AACA,SAASC,KAAK,IAAIC,gBAAlB,QAA0C,aAA1C;AAEA;;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;AAC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A;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"]}
|