@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
package/src/layouts/flex.js
CHANGED
|
@@ -85,10 +85,7 @@ export default {
|
|
|
85
85
|
);
|
|
86
86
|
},
|
|
87
87
|
save: function FlexLayoutStyle( { selector, layout } ) {
|
|
88
|
-
const {
|
|
89
|
-
orientation = 'horizontal',
|
|
90
|
-
setCascadingProperties = false,
|
|
91
|
-
} = layout;
|
|
88
|
+
const { orientation = 'horizontal' } = layout;
|
|
92
89
|
const blockGapSupport = useSetting( 'spacing.blockGap' );
|
|
93
90
|
const hasBlockGapStylesSupport = blockGapSupport !== null;
|
|
94
91
|
const justifyContent =
|
|
@@ -97,36 +94,18 @@ export default {
|
|
|
97
94
|
const flexWrap = flexWrapOptions.includes( layout.flexWrap )
|
|
98
95
|
? layout.flexWrap
|
|
99
96
|
: 'wrap';
|
|
100
|
-
|
|
97
|
+
const rowOrientation = `
|
|
101
98
|
flex-direction: row;
|
|
102
99
|
align-items: center;
|
|
103
100
|
justify-content: ${ justifyContent };
|
|
104
101
|
`;
|
|
105
|
-
if ( setCascadingProperties ) {
|
|
106
|
-
// --layout-justification-setting allows children to inherit the value
|
|
107
|
-
// regardless or row or column direction.
|
|
108
|
-
rowOrientation += `
|
|
109
|
-
--layout-justification-setting: ${ justifyContent };
|
|
110
|
-
--layout-direction: row;
|
|
111
|
-
--layout-wrap: ${ flexWrap };
|
|
112
|
-
--layout-justify: ${ justifyContent };
|
|
113
|
-
--layout-align: center;
|
|
114
|
-
`;
|
|
115
|
-
}
|
|
116
102
|
const alignItems =
|
|
117
103
|
alignItemsMap[ layout.justifyContent ] || alignItemsMap.left;
|
|
118
|
-
|
|
104
|
+
const columnOrientation = `
|
|
119
105
|
flex-direction: column;
|
|
120
106
|
align-items: ${ alignItems };
|
|
121
107
|
`;
|
|
122
|
-
|
|
123
|
-
columnOrientation += `
|
|
124
|
-
--layout-justification-setting: ${ alignItems };
|
|
125
|
-
--layout-direction: column;
|
|
126
|
-
--layout-justify: initial;
|
|
127
|
-
--layout-align: ${ alignItems };
|
|
128
|
-
`;
|
|
129
|
-
}
|
|
108
|
+
|
|
130
109
|
return (
|
|
131
110
|
<style>{ `
|
|
132
111
|
${ appendSelectors( selector ) } {
|
package/src/store/actions.js
CHANGED
|
@@ -555,7 +555,8 @@ export const insertBlocks = (
|
|
|
555
555
|
meta = initialPosition;
|
|
556
556
|
initialPosition = 0;
|
|
557
557
|
deprecated( "meta argument in wp.data.dispatch('core/block-editor')", {
|
|
558
|
-
since: '
|
|
558
|
+
since: '10.1',
|
|
559
|
+
plugin: 'Gutenberg',
|
|
559
560
|
hint: 'The meta argument is now the 6th argument of the function',
|
|
560
561
|
} );
|
|
561
562
|
}
|
|
@@ -1169,8 +1170,7 @@ export const duplicateBlocks = ( clientIds, updateSelection = true ) => ( {
|
|
|
1169
1170
|
|
|
1170
1171
|
const rootClientId = select.getBlockRootClientId( clientIds[ 0 ] );
|
|
1171
1172
|
const lastSelectedIndex = select.getBlockIndex(
|
|
1172
|
-
last( castArray( clientIds ) )
|
|
1173
|
-
rootClientId
|
|
1173
|
+
last( castArray( clientIds ) )
|
|
1174
1174
|
);
|
|
1175
1175
|
const clonedBlocks = blocks.map( ( block ) =>
|
|
1176
1176
|
__experimentalCloneSanitizedBlock( block )
|
|
@@ -1205,7 +1205,7 @@ export const insertBeforeBlock = ( clientId ) => ( { select, dispatch } ) => {
|
|
|
1205
1205
|
return;
|
|
1206
1206
|
}
|
|
1207
1207
|
|
|
1208
|
-
const firstSelectedIndex = select.getBlockIndex( clientId
|
|
1208
|
+
const firstSelectedIndex = select.getBlockIndex( clientId );
|
|
1209
1209
|
return dispatch.insertDefaultBlock( {}, rootClientId, firstSelectedIndex );
|
|
1210
1210
|
};
|
|
1211
1211
|
|
|
@@ -1224,7 +1224,7 @@ export const insertAfterBlock = ( clientId ) => ( { select, dispatch } ) => {
|
|
|
1224
1224
|
return;
|
|
1225
1225
|
}
|
|
1226
1226
|
|
|
1227
|
-
const firstSelectedIndex = select.getBlockIndex( clientId
|
|
1227
|
+
const firstSelectedIndex = select.getBlockIndex( clientId );
|
|
1228
1228
|
return dispatch.insertDefaultBlock(
|
|
1229
1229
|
{},
|
|
1230
1230
|
rootClientId,
|
package/src/store/defaults.js
CHANGED
package/src/store/reducer.js
CHANGED
|
@@ -737,6 +737,27 @@ const withSaveReusableBlock = ( reducer ) => ( state, action ) => {
|
|
|
737
737
|
|
|
738
738
|
return reducer( state, action );
|
|
739
739
|
};
|
|
740
|
+
/**
|
|
741
|
+
* Higher-order reducer which removes blocks from state when switching parent block controlled state.
|
|
742
|
+
*
|
|
743
|
+
* @param {Function} reducer Original reducer function.
|
|
744
|
+
*
|
|
745
|
+
* @return {Function} Enhanced reducer function.
|
|
746
|
+
*/
|
|
747
|
+
const withResetControlledBlocks = ( reducer ) => ( state, action ) => {
|
|
748
|
+
if ( action.type === 'SET_HAS_CONTROLLED_INNER_BLOCKS' ) {
|
|
749
|
+
// when switching a block from controlled to uncontrolled or inverse,
|
|
750
|
+
// we need to remove its content first.
|
|
751
|
+
const tempState = reducer( state, {
|
|
752
|
+
type: 'REPLACE_INNER_BLOCKS',
|
|
753
|
+
rootClientId: action.clientId,
|
|
754
|
+
blocks: [],
|
|
755
|
+
} );
|
|
756
|
+
return reducer( tempState, action );
|
|
757
|
+
}
|
|
758
|
+
|
|
759
|
+
return reducer( state, action );
|
|
760
|
+
};
|
|
740
761
|
|
|
741
762
|
/**
|
|
742
763
|
* Reducer returning the blocks state.
|
|
@@ -754,7 +775,8 @@ export const blocks = flow(
|
|
|
754
775
|
withReplaceInnerBlocks, // needs to be after withInnerBlocksRemoveCascade
|
|
755
776
|
withBlockReset,
|
|
756
777
|
withPersistentBlockChange,
|
|
757
|
-
withIgnoredBlockChange
|
|
778
|
+
withIgnoredBlockChange,
|
|
779
|
+
withResetControlledBlocks
|
|
758
780
|
)( {
|
|
759
781
|
byClientId( state = {}, action ) {
|
|
760
782
|
switch ( action.type ) {
|
package/src/store/selectors.js
CHANGED
|
@@ -30,7 +30,6 @@ import {
|
|
|
30
30
|
parse,
|
|
31
31
|
} from '@wordpress/blocks';
|
|
32
32
|
import { Platform } from '@wordpress/element';
|
|
33
|
-
import { applyFilters } from '@wordpress/hooks';
|
|
34
33
|
import { symbol } from '@wordpress/icons';
|
|
35
34
|
|
|
36
35
|
/**
|
|
@@ -827,7 +826,6 @@ export const isAncestorMultiSelected = createSelector(
|
|
|
827
826
|
state.selection.selectionEnd.clientId,
|
|
828
827
|
]
|
|
829
828
|
);
|
|
830
|
-
|
|
831
829
|
/**
|
|
832
830
|
* Returns the client ID of the block which begins the multi-selection set, or
|
|
833
831
|
* null if there is no multi-selection.
|
|
@@ -892,11 +890,11 @@ export function getBlockOrder( state, rootClientId ) {
|
|
|
892
890
|
*
|
|
893
891
|
* @param {Object} state Editor state.
|
|
894
892
|
* @param {string} clientId Block client ID.
|
|
895
|
-
* @param {?string} rootClientId Optional root client ID of block list.
|
|
896
893
|
*
|
|
897
894
|
* @return {number} Index at which block exists in order.
|
|
898
895
|
*/
|
|
899
|
-
export function getBlockIndex( state, clientId
|
|
896
|
+
export function getBlockIndex( state, clientId ) {
|
|
897
|
+
const rootClientId = getBlockRootClientId( state, clientId );
|
|
900
898
|
return getBlockOrder( state, rootClientId ).indexOf( clientId );
|
|
901
899
|
}
|
|
902
900
|
|
|
@@ -1261,43 +1259,15 @@ const canInsertBlockTypeUnmemoized = (
|
|
|
1261
1259
|
parentName
|
|
1262
1260
|
);
|
|
1263
1261
|
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
return canInsert;
|
|
1262
|
+
if ( hasParentAllowedBlock !== null && hasBlockAllowedParent !== null ) {
|
|
1263
|
+
return hasParentAllowedBlock || hasBlockAllowedParent;
|
|
1264
|
+
} else if ( hasParentAllowedBlock !== null ) {
|
|
1265
|
+
return hasParentAllowedBlock;
|
|
1266
|
+
} else if ( hasBlockAllowedParent !== null ) {
|
|
1267
|
+
return hasBlockAllowedParent;
|
|
1271
1268
|
}
|
|
1272
1269
|
|
|
1273
|
-
|
|
1274
|
-
* This filter is an ad-hoc solution to prevent adding template parts inside post content.
|
|
1275
|
-
* Conceptually, having a filter inside a selector is bad pattern so this code will be
|
|
1276
|
-
* replaced by a declarative API that doesn't the following drawbacks:
|
|
1277
|
-
*
|
|
1278
|
-
* Filters are not reactive: Upon switching between "template mode" and non "template mode",
|
|
1279
|
-
* the filter and selector won't necessarily be executed again. For now, it doesn't matter much
|
|
1280
|
-
* because you can't switch between the two modes while the inserter stays open.
|
|
1281
|
-
*
|
|
1282
|
-
* Filters are global: Once they're defined, they will affect all editor instances and all registries.
|
|
1283
|
-
* An ideal API would only affect specific editor instances.
|
|
1284
|
-
*/
|
|
1285
|
-
return applyFilters(
|
|
1286
|
-
'blockEditor.__unstableCanInsertBlockType',
|
|
1287
|
-
canInsert,
|
|
1288
|
-
blockType,
|
|
1289
|
-
rootClientId,
|
|
1290
|
-
{
|
|
1291
|
-
// Pass bound selectors of the current registry. If we're in a nested
|
|
1292
|
-
// context, the data will differ from the one selected from the root
|
|
1293
|
-
// registry.
|
|
1294
|
-
getBlock: getBlock.bind( null, state ),
|
|
1295
|
-
getBlockParentsByBlockName: getBlockParentsByBlockName.bind(
|
|
1296
|
-
null,
|
|
1297
|
-
state
|
|
1298
|
-
),
|
|
1299
|
-
}
|
|
1300
|
-
);
|
|
1270
|
+
return true;
|
|
1301
1271
|
};
|
|
1302
1272
|
|
|
1303
1273
|
/**
|
|
@@ -2050,6 +2050,41 @@ describe( 'state', () => {
|
|
|
2050
2050
|
expect( state.isIgnoredChange ).toBe( true );
|
|
2051
2051
|
} );
|
|
2052
2052
|
} );
|
|
2053
|
+
|
|
2054
|
+
describe( 'controlledInnerBlocks', () => {
|
|
2055
|
+
it( 'should remove the content of the block if it switches from controlled to uncontrolled or opposite', () => {
|
|
2056
|
+
const original = blocks( undefined, {
|
|
2057
|
+
type: 'RESET_BLOCKS',
|
|
2058
|
+
blocks: [
|
|
2059
|
+
{
|
|
2060
|
+
clientId: 'chicken',
|
|
2061
|
+
name: 'core/test-block',
|
|
2062
|
+
attributes: {},
|
|
2063
|
+
innerBlocks: [
|
|
2064
|
+
{
|
|
2065
|
+
clientId: 'child',
|
|
2066
|
+
name: 'core/test-block',
|
|
2067
|
+
attributes: {},
|
|
2068
|
+
innerBlocks: [],
|
|
2069
|
+
},
|
|
2070
|
+
],
|
|
2071
|
+
},
|
|
2072
|
+
],
|
|
2073
|
+
} );
|
|
2074
|
+
|
|
2075
|
+
const state = blocks( original, {
|
|
2076
|
+
type: 'SET_HAS_CONTROLLED_INNER_BLOCKS',
|
|
2077
|
+
clientId: 'chicken',
|
|
2078
|
+
hasControlledInnerBlocks: true,
|
|
2079
|
+
} );
|
|
2080
|
+
|
|
2081
|
+
expect( state.controlledInnerBlocks.chicken ).toBe( true );
|
|
2082
|
+
// The previous content of the block should be removed
|
|
2083
|
+
expect( state.byClientId.child ).toBeUndefined();
|
|
2084
|
+
expect( state.tree.child ).toBeUndefined();
|
|
2085
|
+
expect( state.tree.chicken.innerBlocks ).toEqual( [] );
|
|
2086
|
+
} );
|
|
2087
|
+
} );
|
|
2053
2088
|
} );
|
|
2054
2089
|
} );
|
|
2055
2090
|
|
package/src/style.scss
CHANGED
|
@@ -32,12 +32,12 @@
|
|
|
32
32
|
@import "./components/default-block-appender/style.scss";
|
|
33
33
|
@import "./components/duotone-control/style.scss";
|
|
34
34
|
@import "./components/font-appearance-control/style.scss";
|
|
35
|
+
@import "./components/justify-content-control/style.scss";
|
|
36
|
+
@import "./components/link-control/style.scss";
|
|
37
|
+
@import "./components/line-height-control/style.scss";
|
|
35
38
|
@import "./components/image-size-control/style.scss";
|
|
36
39
|
@import "./components/inner-blocks/style.scss";
|
|
37
40
|
@import "./components/inserter-list-item/style.scss";
|
|
38
|
-
@import "./components/justify-content-control/style.scss";
|
|
39
|
-
@import "./components/line-height-control/style.scss";
|
|
40
|
-
@import "./components/link-control/style.scss";
|
|
41
41
|
@import "./components/list-view/style.scss";
|
|
42
42
|
@import "./components/media-replace-flow/style.scss";
|
|
43
43
|
@import "./components/media-placeholder/style.scss";
|
|
@@ -55,7 +55,6 @@
|
|
|
55
55
|
@import "./hooks/anchor.scss";
|
|
56
56
|
@import "./hooks/layout.scss";
|
|
57
57
|
@import "./hooks/border.scss";
|
|
58
|
-
@import "./hooks/dimensions.scss";
|
|
59
58
|
@import "./hooks/typography.scss";
|
|
60
59
|
|
|
61
60
|
@import "./components/block-toolbar/style.scss";
|
|
@@ -27,7 +27,7 @@ export function getPasteEventData( { clipboardData } ) {
|
|
|
27
27
|
|
|
28
28
|
const files = getFilesFromDataTransfer(
|
|
29
29
|
clipboardData
|
|
30
|
-
).filter( ( { type } ) => /^image\/(?:jpe?g|png|gif
|
|
30
|
+
).filter( ( { type } ) => /^image\/(?:jpe?g|png|gif)$/.test( type ) );
|
|
31
31
|
|
|
32
32
|
// Only process files if no HTML is present.
|
|
33
33
|
// A pasted file may have the URL as plain text.
|
|
@@ -8,7 +8,7 @@ function parseUnit( cssUnit ) {
|
|
|
8
8
|
const match = cssUnit
|
|
9
9
|
?.trim()
|
|
10
10
|
.match(
|
|
11
|
-
/^(0?[-.]?\d
|
|
11
|
+
/^(0?[-.]?\d+)(r?e[m|x]|v[h|w|min|max]+|p[x|t|c]|[c|m]m|%|in|ch|Q|lh)$/
|
|
12
12
|
);
|
|
13
13
|
if ( ! isNaN( cssUnit ) && ! isNaN( parseFloat( cssUnit ) ) ) {
|
|
14
14
|
return { value: parseFloat( cssUnit ), unit: 'px' };
|
package/tsconfig.tsbuildinfo
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"program":{"fileNames":["../../node_modules/typescript/lib/lib.es5.d.ts","../../node_modules/typescript/lib/lib.es2015.d.ts","../../node_modules/typescript/lib/lib.es2016.d.ts","../../node_modules/typescript/lib/lib.es2017.d.ts","../../node_modules/typescript/lib/lib.es2018.d.ts","../../node_modules/typescript/lib/lib.es2019.d.ts","../../node_modules/typescript/lib/lib.es2020.d.ts","../../node_modules/typescript/lib/lib.es2021.d.ts","../../node_modules/typescript/lib/lib.esnext.d.ts","../../node_modules/typescript/lib/lib.dom.d.ts","../../node_modules/typescript/lib/lib.es2015.core.d.ts","../../node_modules/typescript/lib/lib.es2015.collection.d.ts","../../node_modules/typescript/lib/lib.es2015.generator.d.ts","../../node_modules/typescript/lib/lib.es2015.iterable.d.ts","../../node_modules/typescript/lib/lib.es2015.promise.d.ts","../../node_modules/typescript/lib/lib.es2015.proxy.d.ts","../../node_modules/typescript/lib/lib.es2015.reflect.d.ts","../../node_modules/typescript/lib/lib.es2015.symbol.d.ts","../../node_modules/typescript/lib/lib.es2015.symbol.wellknown.d.ts","../../node_modules/typescript/lib/lib.es2016.array.include.d.ts","../../node_modules/typescript/lib/lib.es2017.object.d.ts","../../node_modules/typescript/lib/lib.es2017.sharedmemory.d.ts","../../node_modules/typescript/lib/lib.es2017.string.d.ts","../../node_modules/typescript/lib/lib.es2017.intl.d.ts","../../node_modules/typescript/lib/lib.es2017.typedarrays.d.ts","../../node_modules/typescript/lib/lib.es2018.asyncgenerator.d.ts","../../node_modules/typescript/lib/lib.es2018.asynciterable.d.ts","../../node_modules/typescript/lib/lib.es2018.intl.d.ts","../../node_modules/typescript/lib/lib.es2018.promise.d.ts","../../node_modules/typescript/lib/lib.es2018.regexp.d.ts","../../node_modules/typescript/lib/lib.es2019.array.d.ts","../../node_modules/typescript/lib/lib.es2019.object.d.ts","../../node_modules/typescript/lib/lib.es2019.string.d.ts","../../node_modules/typescript/lib/lib.es2019.symbol.d.ts","../../node_modules/typescript/lib/lib.es2020.bigint.d.ts","../../node_modules/typescript/lib/lib.es2020.promise.d.ts","../../node_modules/typescript/lib/lib.es2020.sharedmemory.d.ts","../../node_modules/typescript/lib/lib.es2020.string.d.ts","../../node_modules/typescript/lib/lib.es2020.symbol.wellknown.d.ts","../../node_modules/typescript/lib/lib.es2020.intl.d.ts","../../node_modules/typescript/lib/lib.es2021.promise.d.ts","../../node_modules/typescript/lib/lib.es2021.string.d.ts","../../node_modules/typescript/lib/lib.es2021.weakref.d.ts","../../node_modules/typescript/lib/lib.esnext.intl.d.ts","../../node_modules/@types/react/global.d.ts","../../node_modules/@types/react/node_modules/csstype/index.d.ts","../../node_modules/@types/prop-types/index.d.ts","../../node_modules/@types/
|
|
1
|
+
{"program":{"fileNames":["../../node_modules/typescript/lib/lib.es5.d.ts","../../node_modules/typescript/lib/lib.es2015.d.ts","../../node_modules/typescript/lib/lib.es2016.d.ts","../../node_modules/typescript/lib/lib.es2017.d.ts","../../node_modules/typescript/lib/lib.es2018.d.ts","../../node_modules/typescript/lib/lib.es2019.d.ts","../../node_modules/typescript/lib/lib.es2020.d.ts","../../node_modules/typescript/lib/lib.es2021.d.ts","../../node_modules/typescript/lib/lib.esnext.d.ts","../../node_modules/typescript/lib/lib.dom.d.ts","../../node_modules/typescript/lib/lib.es2015.core.d.ts","../../node_modules/typescript/lib/lib.es2015.collection.d.ts","../../node_modules/typescript/lib/lib.es2015.generator.d.ts","../../node_modules/typescript/lib/lib.es2015.iterable.d.ts","../../node_modules/typescript/lib/lib.es2015.promise.d.ts","../../node_modules/typescript/lib/lib.es2015.proxy.d.ts","../../node_modules/typescript/lib/lib.es2015.reflect.d.ts","../../node_modules/typescript/lib/lib.es2015.symbol.d.ts","../../node_modules/typescript/lib/lib.es2015.symbol.wellknown.d.ts","../../node_modules/typescript/lib/lib.es2016.array.include.d.ts","../../node_modules/typescript/lib/lib.es2017.object.d.ts","../../node_modules/typescript/lib/lib.es2017.sharedmemory.d.ts","../../node_modules/typescript/lib/lib.es2017.string.d.ts","../../node_modules/typescript/lib/lib.es2017.intl.d.ts","../../node_modules/typescript/lib/lib.es2017.typedarrays.d.ts","../../node_modules/typescript/lib/lib.es2018.asyncgenerator.d.ts","../../node_modules/typescript/lib/lib.es2018.asynciterable.d.ts","../../node_modules/typescript/lib/lib.es2018.intl.d.ts","../../node_modules/typescript/lib/lib.es2018.promise.d.ts","../../node_modules/typescript/lib/lib.es2018.regexp.d.ts","../../node_modules/typescript/lib/lib.es2019.array.d.ts","../../node_modules/typescript/lib/lib.es2019.object.d.ts","../../node_modules/typescript/lib/lib.es2019.string.d.ts","../../node_modules/typescript/lib/lib.es2019.symbol.d.ts","../../node_modules/typescript/lib/lib.es2020.bigint.d.ts","../../node_modules/typescript/lib/lib.es2020.promise.d.ts","../../node_modules/typescript/lib/lib.es2020.sharedmemory.d.ts","../../node_modules/typescript/lib/lib.es2020.string.d.ts","../../node_modules/typescript/lib/lib.es2020.symbol.wellknown.d.ts","../../node_modules/typescript/lib/lib.es2020.intl.d.ts","../../node_modules/typescript/lib/lib.es2021.promise.d.ts","../../node_modules/typescript/lib/lib.es2021.string.d.ts","../../node_modules/typescript/lib/lib.es2021.weakref.d.ts","../../node_modules/typescript/lib/lib.esnext.intl.d.ts","../../node_modules/@types/react/global.d.ts","../../node_modules/@types/react/node_modules/csstype/index.d.ts","../../node_modules/@types/prop-types/index.d.ts","../../node_modules/@types/react/index.d.ts","../element/build-types/react.d.ts","../element/build-types/create-interpolate-element.d.ts","../../node_modules/@types/react-dom/index.d.ts","../element/build-types/react-platform.d.ts","../element/build-types/utils.d.ts","../element/build-types/platform.d.ts","../element/build-types/serialize.d.ts","../element/build-types/raw-html.d.ts","../element/build-types/index.d.ts","./src/components/block-context/index.js","./src/utils/dom.js"],"fileInfos":[{"version":"aa9fb4c70f369237c2f45f9d969c9a59e0eae9a192962eb48581fe864aa609db","affectsGlobalScope":true},"dc47c4fa66b9b9890cf076304de2a9c5201e94b740cffdf09f87296d877d71f6","7a387c58583dfca701b6c85e0adaf43fb17d590fb16d5b2dc0a2fbd89f35c467","8a12173c586e95f4433e0c6dc446bc88346be73ffe9ca6eec7aa63c8f3dca7f9","5f4e733ced4e129482ae2186aae29fde948ab7182844c3a5a51dd346182c7b06","e6b724280c694a9f588847f754198fb96c43d805f065c3a5b28bbc9594541c84","e21c071ca3e1b4a815d5f04a7475adcaeea5d64367e840dd0154096d705c3940","eb75e89d63b3b72dd9ca8b0cac801cecae5be352307c004adeaa60bc9d6df51f","2cc028cd0bdb35b1b5eb723d84666a255933fffbea607f72cbd0c7c7b4bee144",{"version":"e54c8715a4954cfdc66cd69489f2b725c09ebf37492dbd91cff0a1688b1159e8","affectsGlobalScope":true},{"version":"51b8b27c21c066bf877646e320bf6a722b80d1ade65e686923cd9d4494aef1ca","affectsGlobalScope":true},{"version":"43fb1d932e4966a39a41b464a12a81899d9ae5f2c829063f5571b6b87e6d2f9c","affectsGlobalScope":true},{"version":"cdccba9a388c2ee3fd6ad4018c640a471a6c060e96f1232062223063b0a5ac6a","affectsGlobalScope":true},{"version":"2c8c5ee58f30e7c944e04ab1fb5506fdbb4dd507c9efa6972cf4b91cec90c503","affectsGlobalScope":true},{"version":"2bb4b3927299434052b37851a47bf5c39764f2ba88a888a107b32262e9292b7c","affectsGlobalScope":true},{"version":"810627a82ac06fb5166da5ada4159c4ec11978dfbb0805fe804c86406dab8357","affectsGlobalScope":true},{"version":"62d80405c46c3f4c527ee657ae9d43fda65a0bf582292429aea1e69144a522a6","affectsGlobalScope":true},{"version":"3013574108c36fd3aaca79764002b3717da09725a36a6fc02eac386593110f93","affectsGlobalScope":true},{"version":"75ec0bdd727d887f1b79ed6619412ea72ba3c81d92d0787ccb64bab18d261f14","affectsGlobalScope":true},{"version":"3be5a1453daa63e031d266bf342f3943603873d890ab8b9ada95e22389389006","affectsGlobalScope":true},{"version":"17bb1fc99591b00515502d264fa55dc8370c45c5298f4a5c2083557dccba5a2a","affectsGlobalScope":true},{"version":"7ce9f0bde3307ca1f944119f6365f2d776d281a393b576a18a2f2893a2d75c98","affectsGlobalScope":true},{"version":"6a6b173e739a6a99629a8594bfb294cc7329bfb7b227f12e1f7c11bc163b8577","affectsGlobalScope":true},{"version":"12a310447c5d23c7d0d5ca2af606e3bd08afda69100166730ab92c62999ebb9d","affectsGlobalScope":true},{"version":"b0124885ef82641903d232172577f2ceb5d3e60aed4da1153bab4221e1f6dd4e","affectsGlobalScope":true},{"version":"0eb85d6c590b0d577919a79e0084fa1744c1beba6fd0d4e951432fa1ede5510a","affectsGlobalScope":true},{"version":"da233fc1c8a377ba9e0bed690a73c290d843c2c3d23a7bd7ec5cd3d7d73ba1e0","affectsGlobalScope":true},{"version":"df9c8a72ca8b0ed62f5470b41208a0587f0f73f0a7db28e5a1272cf92537518e","affectsGlobalScope":true},{"version":"bb2d3fb05a1d2ffbca947cc7cbc95d23e1d053d6595391bd325deb265a18d36c","affectsGlobalScope":true},{"version":"c80df75850fea5caa2afe43b9949338ce4e2de086f91713e9af1a06f973872b8","affectsGlobalScope":true},{"version":"9d57b2b5d15838ed094aa9ff1299eecef40b190722eb619bac4616657a05f951","affectsGlobalScope":true},{"version":"6c51b5dd26a2c31dbf37f00cfc32b2aa6a92e19c995aefb5b97a3a64f1ac99de","affectsGlobalScope":true},{"version":"93544ca2f26a48716c1b6c5091842cad63129daac422dfa4bc52460465f22bb1","affectsGlobalScope":true},{"version":"2ad234885a4240522efccd77de6c7d99eecf9b4de0914adb9a35c0c22433f993","affectsGlobalScope":true},{"version":"1b3fe904465430e030c93239a348f05e1be80640d91f2f004c3512c2c2c89f34","affectsGlobalScope":true},{"version":"7435b75fdf3509622e79622dbe5091cf4b09688410ee2034e4fc17d0c99d0862","affectsGlobalScope":true},{"version":"e7e8e1d368290e9295ef18ca23f405cf40d5456fa9f20db6373a61ca45f75f40","affectsGlobalScope":true},{"version":"faf0221ae0465363c842ce6aa8a0cbda5d9296940a8e26c86e04cc4081eea21e","affectsGlobalScope":true},{"version":"06393d13ea207a1bfe08ec8d7be562549c5e2da8983f2ee074e00002629d1871","affectsGlobalScope":true},{"version":"9f1817f7c3f02f6d56e0f403b927e90bb133f371dcebc36fa7d6d208ef6899da","affectsGlobalScope":true},{"version":"cd6efb9467a8b6338ece2e2855e37765700f2cd061ca54b01b33878cf5c7677e","affectsGlobalScope":true},{"version":"fb4416144c1bf0323ccbc9afb0ab289c07312214e8820ad17d709498c865a3fe","affectsGlobalScope":true},{"version":"5b0ca94ec819d68d33da516306c15297acec88efeb0ae9e2b39f71dbd9685ef7","affectsGlobalScope":true},{"version":"4632665b87204bb1caa8b44d165bce0c50dfab177df5b561b345a567cabacf9a","affectsGlobalScope":true},{"version":"ecf78e637f710f340ec08d5d92b3f31b134a46a4fcf2e758690d8c46ce62cba6","affectsGlobalScope":true},"b3a4ee9791cdd4f5029b3ffe60b9cae1ac308a4238b0444f40a5222e4ecc5cc1","a7e32dcb90bf0c1b7a1e4ac89b0f7747cbcba25e7beddc1ebf17be1e161842ad",{"version":"0290ce481d9430774f1d41e757d087e9324b497e1ee0a9e908cf57a9f8bc6e0d","affectsGlobalScope":true},"e59d00012fb20e6746def2f4bc94650526aa6c574c49ad6a50a992f61a3ee675","e47b8ec56eb49bc1c53c9012daa9874de14ad0c5da442485aec333571c74b526","c45d6f4d3a20be54e46237608f537a8d85397f87b9c3318d68ed925c2f1d0b51","64edfb2b255173bc63214290f9c3ed2306d658b5895ca482a0f20f03fd544ffc","d2d9e98a2b167079474768593e1e7125fc3db055add8fbdb5977e3d05a8a3696","6462da67490105ba7d98cf312c2faf8794c425781128b161ea8394d66502eec8","62359da52b6c8d00c50c2e50738fac82e902f916fdf458d8159e7edb1c60c3a8","1e0ac21bc775686383ea8c8e48bd98b385e6195b25c85525a7affd08a2cd38b9","0449615e1ed03c7d54fc435a63b7ef0cb4e5cea5ac40c9a63280a46f7eeae0ff","c2785f1635be52763ea678e43064f7b5195af88fc8652781950ae12bdd8049d7","f29123409ffe930309965e27265b28e67aae92692077c7147935351ec2321cef"],"options":{"allowSyntheticDefaultImports":true,"composite":true,"declaration":true,"declarationDir":"./build-types","declarationMap":true,"emitDeclarationOnly":true,"esModuleInterop":false,"importsNotUsedAsValues":2,"jsx":1,"module":99,"noFallthroughCasesInSwitch":true,"noImplicitReturns":true,"noUnusedLocals":true,"noUnusedParameters":true,"rootDir":"./src","strict":true,"target":99},"fileIdsList":[[48],[45,46,47],[48,57],[49],[49,50,52,53,54,55,56],[51],[48,49]],"referencedMap":[[51,1],[48,2],[58,3],[50,4],[57,5],[56,1],[52,6],[49,1],[55,7]],"exportedModulesMap":[[51,1],[48,2],[58,3],[50,4],[57,5],[56,1],[52,6],[49,1],[55,7]],"semanticDiagnosticsPerFile":[47,51,45,48,46,10,12,11,2,13,14,15,16,17,18,19,20,3,4,24,21,22,23,25,26,27,5,28,29,30,31,6,32,33,34,35,7,40,36,37,38,39,8,41,42,43,1,9,44,58,59,50,57,54,56,52,49,55,53]},"version":"4.4.2"}
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
|
-
Object.defineProperty(exports, "__esModule", {
|
|
6
|
-
value: true
|
|
7
|
-
});
|
|
8
|
-
exports.default = BlockStylesMenuItems;
|
|
9
|
-
|
|
10
|
-
var _element = require("@wordpress/element");
|
|
11
|
-
|
|
12
|
-
var _lodash = require("lodash");
|
|
13
|
-
|
|
14
|
-
var _components = require("@wordpress/components");
|
|
15
|
-
|
|
16
|
-
var _icons = require("@wordpress/icons");
|
|
17
|
-
|
|
18
|
-
var _useStylesForBlock = _interopRequireDefault(require("./use-styles-for-block"));
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* External dependencies
|
|
22
|
-
*/
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* WordPress dependencies
|
|
26
|
-
*/
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* Internal dependencies
|
|
30
|
-
*/
|
|
31
|
-
function BlockStylesMenuItems(_ref) {
|
|
32
|
-
let {
|
|
33
|
-
clientId,
|
|
34
|
-
onSwitch = _lodash.noop
|
|
35
|
-
} = _ref;
|
|
36
|
-
const {
|
|
37
|
-
onSelect,
|
|
38
|
-
stylesToRender,
|
|
39
|
-
activeStyle
|
|
40
|
-
} = (0, _useStylesForBlock.default)({
|
|
41
|
-
clientId,
|
|
42
|
-
onSwitch
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
if (!stylesToRender || stylesToRender.length === 0) {
|
|
46
|
-
return null;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
return (0, _element.createElement)(_element.Fragment, null, stylesToRender.map(style => {
|
|
50
|
-
const menuItemText = style.label || style.name;
|
|
51
|
-
return (0, _element.createElement)(_components.MenuItem, {
|
|
52
|
-
key: style.name,
|
|
53
|
-
icon: activeStyle.name === style.name ? _icons.check : null,
|
|
54
|
-
onClick: () => onSelect(style)
|
|
55
|
-
}, (0, _element.createElement)(_components.__experimentalText, {
|
|
56
|
-
as: "span",
|
|
57
|
-
limit: 18,
|
|
58
|
-
ellipsizeMode: "tail",
|
|
59
|
-
truncate: true
|
|
60
|
-
}, menuItemText));
|
|
61
|
-
}));
|
|
62
|
-
}
|
|
63
|
-
//# sourceMappingURL=menu-items.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/block-styles/menu-items.js"],"names":["BlockStylesMenuItems","clientId","onSwitch","noop","onSelect","stylesToRender","activeStyle","length","map","style","menuItemText","label","name","check"],"mappings":";;;;;;;;;;;AAGA;;AAKA;;AACA;;AAKA;;AAdA;AACA;AACA;;AAGA;AACA;AACA;;AAIA;AACA;AACA;AAGe,SAASA,oBAAT,OAA+D;AAAA,MAAhC;AAAEC,IAAAA,QAAF;AAAYC,IAAAA,QAAQ,GAAGC;AAAvB,GAAgC;AAC7E,QAAM;AAAEC,IAAAA,QAAF;AAAYC,IAAAA,cAAZ;AAA4BC,IAAAA;AAA5B,MAA4C,gCAAoB;AACrEL,IAAAA,QADqE;AAErEC,IAAAA;AAFqE,GAApB,CAAlD;;AAKA,MAAK,CAAEG,cAAF,IAAoBA,cAAc,CAACE,MAAf,KAA0B,CAAnD,EAAuD;AACtD,WAAO,IAAP;AACA;;AACD,SACC,qDACGF,cAAc,CAACG,GAAf,CAAsBC,KAAF,IAAa;AAClC,UAAMC,YAAY,GAAGD,KAAK,CAACE,KAAN,IAAeF,KAAK,CAACG,IAA1C;AACA,WACC,4BAAC,oBAAD;AACC,MAAA,GAAG,EAAGH,KAAK,CAACG,IADb;AAEC,MAAA,IAAI,EAAGN,WAAW,CAACM,IAAZ,KAAqBH,KAAK,CAACG,IAA3B,GAAkCC,YAAlC,GAA0C,IAFlD;AAGC,MAAA,OAAO,EAAG,MAAMT,QAAQ,CAAEK,KAAF;AAHzB,OAKC,4BAAC,8BAAD;AACC,MAAA,EAAE,EAAC,MADJ;AAEC,MAAA,KAAK,EAAG,EAFT;AAGC,MAAA,aAAa,EAAC,MAHf;AAIC,MAAA,QAAQ;AAJT,OAMGC,YANH,CALD,CADD;AAgBA,GAlBC,CADH,CADD;AAuBA","sourcesContent":["/**\n * External dependencies\n */\nimport { noop } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { MenuItem, __experimentalText as Text } from '@wordpress/components';\nimport { check } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport useStylesForBlocks from './use-styles-for-block';\n\nexport default function BlockStylesMenuItems( { clientId, onSwitch = noop } ) {\n\tconst { onSelect, stylesToRender, activeStyle } = useStylesForBlocks( {\n\t\tclientId,\n\t\tonSwitch,\n\t} );\n\n\tif ( ! stylesToRender || stylesToRender.length === 0 ) {\n\t\treturn null;\n\t}\n\treturn (\n\t\t<>\n\t\t\t{ stylesToRender.map( ( style ) => {\n\t\t\t\tconst menuItemText = style.label || style.name;\n\t\t\t\treturn (\n\t\t\t\t\t<MenuItem\n\t\t\t\t\t\tkey={ style.name }\n\t\t\t\t\t\ticon={ activeStyle.name === style.name ? check : null }\n\t\t\t\t\t\tonClick={ () => onSelect( style ) }\n\t\t\t\t\t>\n\t\t\t\t\t\t<Text\n\t\t\t\t\t\t\tas=\"span\"\n\t\t\t\t\t\t\tlimit={ 18 }\n\t\t\t\t\t\t\tellipsizeMode=\"tail\"\n\t\t\t\t\t\t\ttruncate\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ menuItemText }\n\t\t\t\t\t\t</Text>\n\t\t\t\t\t</MenuItem>\n\t\t\t\t);\n\t\t\t} ) }\n\t\t</>\n\t);\n}\n"]}
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
|
-
Object.defineProperty(exports, "__esModule", {
|
|
6
|
-
value: true
|
|
7
|
-
});
|
|
8
|
-
exports.default = BlockStylesPreviewPanel;
|
|
9
|
-
|
|
10
|
-
var _element = require("@wordpress/element");
|
|
11
|
-
|
|
12
|
-
var _previewPanel = _interopRequireDefault(require("../inserter/preview-panel"));
|
|
13
|
-
|
|
14
|
-
var _utils = require("./utils");
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* WordPress dependencies
|
|
18
|
-
*/
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* Internal dependencies
|
|
22
|
-
*/
|
|
23
|
-
function BlockStylesPreviewPanel(_ref) {
|
|
24
|
-
let {
|
|
25
|
-
genericPreviewBlock,
|
|
26
|
-
style,
|
|
27
|
-
className,
|
|
28
|
-
activeStyle
|
|
29
|
-
} = _ref;
|
|
30
|
-
const styleClassName = (0, _utils.replaceActiveStyle)(className, activeStyle, style);
|
|
31
|
-
const previewBlocks = (0, _element.useMemo)(() => {
|
|
32
|
-
return { ...genericPreviewBlock,
|
|
33
|
-
title: style.label || style.name,
|
|
34
|
-
description: style.description,
|
|
35
|
-
initialAttributes: { ...genericPreviewBlock.attributes,
|
|
36
|
-
className: styleClassName + ' block-editor-block-styles__block-preview-container'
|
|
37
|
-
}
|
|
38
|
-
};
|
|
39
|
-
}, [genericPreviewBlock, styleClassName]);
|
|
40
|
-
return (0, _element.createElement)(_previewPanel.default, {
|
|
41
|
-
item: previewBlocks,
|
|
42
|
-
isStylePreview: true
|
|
43
|
-
});
|
|
44
|
-
}
|
|
45
|
-
//# sourceMappingURL=preview-panel.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/block-styles/preview-panel.js"],"names":["BlockStylesPreviewPanel","genericPreviewBlock","style","className","activeStyle","styleClassName","previewBlocks","title","label","name","description","initialAttributes","attributes"],"mappings":";;;;;;;;;AAGA;;AAKA;;AACA;;AATA;AACA;AACA;;AAGA;AACA;AACA;AAIe,SAASA,uBAAT,OAKX;AAAA,MAL6C;AAChDC,IAAAA,mBADgD;AAEhDC,IAAAA,KAFgD;AAGhDC,IAAAA,SAHgD;AAIhDC,IAAAA;AAJgD,GAK7C;AACH,QAAMC,cAAc,GAAG,+BAAoBF,SAApB,EAA+BC,WAA/B,EAA4CF,KAA5C,CAAvB;AACA,QAAMI,aAAa,GAAG,sBAAS,MAAM;AACpC,WAAO,EACN,GAAGL,mBADG;AAENM,MAAAA,KAAK,EAAEL,KAAK,CAACM,KAAN,IAAeN,KAAK,CAACO,IAFtB;AAGNC,MAAAA,WAAW,EAAER,KAAK,CAACQ,WAHb;AAINC,MAAAA,iBAAiB,EAAE,EAClB,GAAGV,mBAAmB,CAACW,UADL;AAElBT,QAAAA,SAAS,EACRE,cAAc,GACd;AAJiB;AAJb,KAAP;AAWA,GAZqB,EAYnB,CAAEJ,mBAAF,EAAuBI,cAAvB,CAZmB,CAAtB;AAcA,SACC,4BAAC,qBAAD;AAAsB,IAAA,IAAI,EAAGC,aAA7B;AAA6C,IAAA,cAAc,EAAG;AAA9D,IADD;AAGA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useMemo } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport InserterPreviewPanel from '../inserter/preview-panel';\nimport { replaceActiveStyle } from './utils';\n\nexport default function BlockStylesPreviewPanel( {\n\tgenericPreviewBlock,\n\tstyle,\n\tclassName,\n\tactiveStyle,\n} ) {\n\tconst styleClassName = replaceActiveStyle( className, activeStyle, style );\n\tconst previewBlocks = useMemo( () => {\n\t\treturn {\n\t\t\t...genericPreviewBlock,\n\t\t\ttitle: style.label || style.name,\n\t\t\tdescription: style.description,\n\t\t\tinitialAttributes: {\n\t\t\t\t...genericPreviewBlock.attributes,\n\t\t\t\tclassName:\n\t\t\t\t\tstyleClassName +\n\t\t\t\t\t' block-editor-block-styles__block-preview-container',\n\t\t\t},\n\t\t};\n\t}, [ genericPreviewBlock, styleClassName ] );\n\n\treturn (\n\t\t<InserterPreviewPanel item={ previewBlocks } isStylePreview={ true } />\n\t);\n}\n"]}
|
|
@@ -1,119 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = useStylesForBlocks;
|
|
7
|
-
|
|
8
|
-
var _data = require("@wordpress/data");
|
|
9
|
-
|
|
10
|
-
var _blocks = require("@wordpress/blocks");
|
|
11
|
-
|
|
12
|
-
var _element = require("@wordpress/element");
|
|
13
|
-
|
|
14
|
-
var _utils = require("./utils");
|
|
15
|
-
|
|
16
|
-
var _store = require("../../store");
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* WordPress dependencies
|
|
20
|
-
*/
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* Internal dependencies
|
|
24
|
-
*/
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
*
|
|
28
|
-
* @param {WPBlock} block Block object.
|
|
29
|
-
* @param {WPBlockType} type Block type settings.
|
|
30
|
-
* @return {WPBlock} A generic block ready for styles preview.
|
|
31
|
-
*/
|
|
32
|
-
function useGenericPreviewBlock(block, type) {
|
|
33
|
-
return (0, _element.useMemo)(() => {
|
|
34
|
-
const example = type === null || type === void 0 ? void 0 : type.example;
|
|
35
|
-
const blockName = type === null || type === void 0 ? void 0 : type.name;
|
|
36
|
-
|
|
37
|
-
if (example && blockName) {
|
|
38
|
-
return (0, _blocks.getBlockFromExample)(blockName, {
|
|
39
|
-
attributes: example.attributes,
|
|
40
|
-
innerBlocks: example.innerBlocks
|
|
41
|
-
});
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
if (block) {
|
|
45
|
-
return (0, _blocks.cloneBlock)(block);
|
|
46
|
-
}
|
|
47
|
-
}, [type !== null && type !== void 0 && type.example ? block === null || block === void 0 ? void 0 : block.name : block, type]);
|
|
48
|
-
}
|
|
49
|
-
/**
|
|
50
|
-
* @typedef useStylesForBlocksArguments
|
|
51
|
-
* @property {string} clientId Block client ID.
|
|
52
|
-
* @property {() => void} onSwitch Block style switch callback function.
|
|
53
|
-
*/
|
|
54
|
-
|
|
55
|
-
/**
|
|
56
|
-
*
|
|
57
|
-
* @param {useStylesForBlocksArguments} useStylesForBlocks arguments.
|
|
58
|
-
* @return {Object} Results of the select methods.
|
|
59
|
-
*/
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
function useStylesForBlocks(_ref) {
|
|
63
|
-
let {
|
|
64
|
-
clientId,
|
|
65
|
-
onSwitch
|
|
66
|
-
} = _ref;
|
|
67
|
-
|
|
68
|
-
const selector = select => {
|
|
69
|
-
const {
|
|
70
|
-
getBlock
|
|
71
|
-
} = select(_store.store);
|
|
72
|
-
const block = getBlock(clientId);
|
|
73
|
-
|
|
74
|
-
if (!block) {
|
|
75
|
-
return {};
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
const blockType = (0, _blocks.getBlockType)(block.name);
|
|
79
|
-
const {
|
|
80
|
-
getBlockStyles
|
|
81
|
-
} = select(_blocks.store);
|
|
82
|
-
return {
|
|
83
|
-
block,
|
|
84
|
-
blockType,
|
|
85
|
-
styles: getBlockStyles(block.name),
|
|
86
|
-
className: block.attributes.className || ''
|
|
87
|
-
};
|
|
88
|
-
};
|
|
89
|
-
|
|
90
|
-
const {
|
|
91
|
-
styles,
|
|
92
|
-
block,
|
|
93
|
-
blockType,
|
|
94
|
-
className
|
|
95
|
-
} = (0, _data.useSelect)(selector, [clientId]);
|
|
96
|
-
const {
|
|
97
|
-
updateBlockAttributes
|
|
98
|
-
} = (0, _data.useDispatch)(_store.store);
|
|
99
|
-
const stylesToRender = (0, _utils.getRenderedStyles)(styles);
|
|
100
|
-
const activeStyle = (0, _utils.getActiveStyle)(stylesToRender, className);
|
|
101
|
-
const genericPreviewBlock = useGenericPreviewBlock(block, blockType);
|
|
102
|
-
|
|
103
|
-
const onSelect = style => {
|
|
104
|
-
const styleClassName = (0, _utils.replaceActiveStyle)(className, activeStyle, style);
|
|
105
|
-
updateBlockAttributes(clientId, {
|
|
106
|
-
className: styleClassName
|
|
107
|
-
});
|
|
108
|
-
onSwitch();
|
|
109
|
-
};
|
|
110
|
-
|
|
111
|
-
return {
|
|
112
|
-
onSelect,
|
|
113
|
-
stylesToRender,
|
|
114
|
-
activeStyle,
|
|
115
|
-
genericPreviewBlock,
|
|
116
|
-
className
|
|
117
|
-
};
|
|
118
|
-
}
|
|
119
|
-
//# sourceMappingURL=use-styles-for-block.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/block-styles/use-styles-for-block.js"],"names":["useGenericPreviewBlock","block","type","example","blockName","name","attributes","innerBlocks","useStylesForBlocks","clientId","onSwitch","selector","select","getBlock","blockEditorStore","blockType","getBlockStyles","blocksStore","styles","className","updateBlockAttributes","stylesToRender","activeStyle","genericPreviewBlock","onSelect","style","styleClassName"],"mappings":";;;;;;;AAGA;;AACA;;AAMA;;AAKA;;AACA;;AAhBA;AACA;AACA;;AAUA;AACA;AACA;;AAIA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,sBAAT,CAAiCC,KAAjC,EAAwCC,IAAxC,EAA+C;AAC9C,SAAO,sBAAS,MAAM;AACrB,UAAMC,OAAO,GAAGD,IAAH,aAAGA,IAAH,uBAAGA,IAAI,CAAEC,OAAtB;AACA,UAAMC,SAAS,GAAGF,IAAH,aAAGA,IAAH,uBAAGA,IAAI,CAAEG,IAAxB;;AAEA,QAAKF,OAAO,IAAIC,SAAhB,EAA4B;AAC3B,aAAO,iCAAqBA,SAArB,EAAgC;AACtCE,QAAAA,UAAU,EAAEH,OAAO,CAACG,UADkB;AAEtCC,QAAAA,WAAW,EAAEJ,OAAO,CAACI;AAFiB,OAAhC,CAAP;AAIA;;AAED,QAAKN,KAAL,EAAa;AACZ,aAAO,wBAAYA,KAAZ,CAAP;AACA;AACD,GAdM,EAcJ,CAAEC,IAAI,SAAJ,IAAAA,IAAI,WAAJ,IAAAA,IAAI,CAAEC,OAAN,GAAgBF,KAAhB,aAAgBA,KAAhB,uBAAgBA,KAAK,CAAEI,IAAvB,GAA8BJ,KAAhC,EAAuCC,IAAvC,CAdI,CAAP;AAeA;AAED;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;;AACe,SAASM,kBAAT,OAAsD;AAAA,MAAzB;AAAEC,IAAAA,QAAF;AAAYC,IAAAA;AAAZ,GAAyB;;AACpE,QAAMC,QAAQ,GAAKC,MAAF,IAAc;AAC9B,UAAM;AAAEC,MAAAA;AAAF,QAAeD,MAAM,CAAEE,YAAF,CAA3B;AACA,UAAMb,KAAK,GAAGY,QAAQ,CAAEJ,QAAF,CAAtB;;AAEA,QAAK,CAAER,KAAP,EAAe;AACd,aAAO,EAAP;AACA;;AACD,UAAMc,SAAS,GAAG,0BAAcd,KAAK,CAACI,IAApB,CAAlB;AACA,UAAM;AAAEW,MAAAA;AAAF,QAAqBJ,MAAM,CAAEK,aAAF,CAAjC;AAEA,WAAO;AACNhB,MAAAA,KADM;AAENc,MAAAA,SAFM;AAGNG,MAAAA,MAAM,EAAEF,cAAc,CAAEf,KAAK,CAACI,IAAR,CAHhB;AAINc,MAAAA,SAAS,EAAElB,KAAK,CAACK,UAAN,CAAiBa,SAAjB,IAA8B;AAJnC,KAAP;AAMA,GAhBD;;AAiBA,QAAM;AAAED,IAAAA,MAAF;AAAUjB,IAAAA,KAAV;AAAiBc,IAAAA,SAAjB;AAA4BI,IAAAA;AAA5B,MAA0C,qBAAWR,QAAX,EAAqB,CACpEF,QADoE,CAArB,CAAhD;AAGA,QAAM;AAAEW,IAAAA;AAAF,MAA4B,uBAAaN,YAAb,CAAlC;AACA,QAAMO,cAAc,GAAG,8BAAmBH,MAAnB,CAAvB;AACA,QAAMI,WAAW,GAAG,2BAAgBD,cAAhB,EAAgCF,SAAhC,CAApB;AACA,QAAMI,mBAAmB,GAAGvB,sBAAsB,CAAEC,KAAF,EAASc,SAAT,CAAlD;;AAEA,QAAMS,QAAQ,GAAKC,KAAF,IAAa;AAC7B,UAAMC,cAAc,GAAG,+BACtBP,SADsB,EAEtBG,WAFsB,EAGtBG,KAHsB,CAAvB;AAKAL,IAAAA,qBAAqB,CAAEX,QAAF,EAAY;AAChCU,MAAAA,SAAS,EAAEO;AADqB,KAAZ,CAArB;AAGAhB,IAAAA,QAAQ;AACR,GAVD;;AAYA,SAAO;AACNc,IAAAA,QADM;AAENH,IAAAA,cAFM;AAGNC,IAAAA,WAHM;AAINC,IAAAA,mBAJM;AAKNJ,IAAAA;AALM,GAAP;AAOA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport {\n\tcloneBlock,\n\tgetBlockType,\n\tgetBlockFromExample,\n\tstore as blocksStore,\n} from '@wordpress/blocks';\nimport { useMemo } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { getActiveStyle, getRenderedStyles, replaceActiveStyle } from './utils';\nimport { store as blockEditorStore } from '../../store';\n\n/**\n *\n * @param {WPBlock} block Block object.\n * @param {WPBlockType} type Block type settings.\n * @return {WPBlock} A generic block ready for styles preview.\n */\nfunction useGenericPreviewBlock( block, type ) {\n\treturn useMemo( () => {\n\t\tconst example = type?.example;\n\t\tconst blockName = type?.name;\n\n\t\tif ( example && blockName ) {\n\t\t\treturn getBlockFromExample( blockName, {\n\t\t\t\tattributes: example.attributes,\n\t\t\t\tinnerBlocks: example.innerBlocks,\n\t\t\t} );\n\t\t}\n\n\t\tif ( block ) {\n\t\t\treturn cloneBlock( block );\n\t\t}\n\t}, [ type?.example ? block?.name : block, type ] );\n}\n\n/**\n * @typedef useStylesForBlocksArguments\n * @property {string} clientId Block client ID.\n * @property {() => void} onSwitch Block style switch callback function.\n */\n\n/**\n *\n * @param {useStylesForBlocksArguments} useStylesForBlocks arguments.\n * @return {Object} Results of the select methods.\n */\nexport default function useStylesForBlocks( { clientId, onSwitch } ) {\n\tconst selector = ( select ) => {\n\t\tconst { getBlock } = select( blockEditorStore );\n\t\tconst block = getBlock( clientId );\n\n\t\tif ( ! block ) {\n\t\t\treturn {};\n\t\t}\n\t\tconst blockType = getBlockType( block.name );\n\t\tconst { getBlockStyles } = select( blocksStore );\n\n\t\treturn {\n\t\t\tblock,\n\t\t\tblockType,\n\t\t\tstyles: getBlockStyles( block.name ),\n\t\t\tclassName: block.attributes.className || '',\n\t\t};\n\t};\n\tconst { styles, block, blockType, className } = useSelect( selector, [\n\t\tclientId,\n\t] );\n\tconst { updateBlockAttributes } = useDispatch( blockEditorStore );\n\tconst stylesToRender = getRenderedStyles( styles );\n\tconst activeStyle = getActiveStyle( stylesToRender, className );\n\tconst genericPreviewBlock = useGenericPreviewBlock( block, blockType );\n\n\tconst onSelect = ( style ) => {\n\t\tconst styleClassName = replaceActiveStyle(\n\t\t\tclassName,\n\t\t\tactiveStyle,\n\t\t\tstyle\n\t\t);\n\t\tupdateBlockAttributes( clientId, {\n\t\t\tclassName: styleClassName,\n\t\t} );\n\t\tonSwitch();\n\t};\n\n\treturn {\n\t\tonSelect,\n\t\tstylesToRender,\n\t\tactiveStyle,\n\t\tgenericPreviewBlock,\n\t\tclassName,\n\t};\n}\n"]}
|