@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
|
@@ -164,15 +164,12 @@ async function loadScript( head, { id, src } ) {
|
|
|
164
164
|
} );
|
|
165
165
|
}
|
|
166
166
|
|
|
167
|
-
function Iframe(
|
|
168
|
-
{ contentRef, children, head, tabIndex = 0, assets, ...props },
|
|
169
|
-
ref
|
|
170
|
-
) {
|
|
167
|
+
function Iframe( { contentRef, children, head, tabIndex = 0, ...props }, ref ) {
|
|
171
168
|
const [ , forceRender ] = useReducer( () => ( {} ) );
|
|
172
169
|
const [ iframeDocument, setIframeDocument ] = useState();
|
|
173
170
|
const [ bodyClasses, setBodyClasses ] = useState( [] );
|
|
174
|
-
const styles = useParsedAssets(
|
|
175
|
-
const scripts = useParsedAssets(
|
|
171
|
+
const styles = useParsedAssets( window.__editorAssets?.styles );
|
|
172
|
+
const scripts = useParsedAssets( window.__editorAssets?.scripts );
|
|
176
173
|
const clearerRef = useBlockSelectionClearer();
|
|
177
174
|
const [ before, writingFlowRef, after ] = useWritingFlow();
|
|
178
175
|
const setRef = useRefEffect( ( node ) => {
|
package/src/components/index.js
CHANGED
|
@@ -24,7 +24,6 @@ export { default as BlockColorsStyleSelector } from './color-style-selector';
|
|
|
24
24
|
export { default as BlockEdit, useBlockEditContext } from './block-edit';
|
|
25
25
|
export { default as BlockIcon } from './block-icon';
|
|
26
26
|
export { default as BlockNavigationDropdown } from './block-navigation/dropdown';
|
|
27
|
-
export { default as BlockStyles } from './block-styles';
|
|
28
27
|
export { default as __experimentalBlockVariationPicker } from './block-variation-picker';
|
|
29
28
|
export { default as __experimentalBlockPatternSetup } from './block-pattern-setup';
|
|
30
29
|
export { default as __experimentalBlockVariationTransforms } from './block-variation-transforms';
|
|
@@ -141,6 +140,7 @@ export {
|
|
|
141
140
|
} from './typewriter';
|
|
142
141
|
export { default as Warning } from './warning';
|
|
143
142
|
export { default as WritingFlow } from './writing-flow';
|
|
143
|
+
export { useCanvasClickRedirect as __unstableUseCanvasClickRedirect } from './use-canvas-click-redirect';
|
|
144
144
|
export { default as useBlockDisplayInformation } from './use-block-display-information';
|
|
145
145
|
export { default as __unstableIframe } from './iframe';
|
|
146
146
|
export { default as __experimentalUseNoRecursiveRenders } from './use-no-recursive-renders';
|
|
@@ -41,8 +41,6 @@ _Note:_ A block can render at most a single `InnerBlocks` and `InnerBlocks.Conte
|
|
|
41
41
|
|
|
42
42
|
_Note:_ Because the save step will automatically apply props to the element returned by `save`, it is important to include the wrapping `div` in the above simple example even though we are applying no props of our own. In a real-world example, you may have your own attributes to apply to the saved markup, or sibling content adjacent to the rendered nested blocks.
|
|
43
43
|
|
|
44
|
-
_Note:_ Inner blocks, by default, are not visible inside a WordPress excerpt. If you wish your block to appear then it needs to be returned from the `excerpt_allowed_wrapper_blocks` filter. More details can be found on the [filter reference page](https://developer.wordpress.org/reference/hooks/excerpt_allowed_wrapper_blocks/) page, as well as the [excerpt_remove_blocks](https://developer.wordpress.org/reference/functions/excerpt_remove_blocks/) page.
|
|
45
|
-
|
|
46
44
|
## Props
|
|
47
45
|
|
|
48
46
|
### `allowedBlocks`
|
|
@@ -16,8 +16,13 @@ import BaseDefaultBlockAppender from '../default-block-appender';
|
|
|
16
16
|
import withClientId from './with-client-id';
|
|
17
17
|
import { store as blockEditorStore } from '../../store';
|
|
18
18
|
|
|
19
|
-
export const DefaultBlockAppender = ( { clientId } ) => {
|
|
20
|
-
return
|
|
19
|
+
export const DefaultBlockAppender = ( { clientId, lastBlockClientId } ) => {
|
|
20
|
+
return (
|
|
21
|
+
<BaseDefaultBlockAppender
|
|
22
|
+
rootClientId={ clientId }
|
|
23
|
+
lastBlockClientId={ lastBlockClientId }
|
|
24
|
+
/>
|
|
25
|
+
);
|
|
21
26
|
};
|
|
22
27
|
|
|
23
28
|
export default compose( [
|
|
@@ -64,19 +64,12 @@ function useInsertionPoint( {
|
|
|
64
64
|
_destinationIndex = insertionIndex;
|
|
65
65
|
} else if ( clientId ) {
|
|
66
66
|
// Insert after a specific client ID.
|
|
67
|
-
_destinationIndex = getBlockIndex(
|
|
68
|
-
clientId,
|
|
69
|
-
_destinationRootClientId
|
|
70
|
-
);
|
|
67
|
+
_destinationIndex = getBlockIndex( clientId );
|
|
71
68
|
} else if ( ! isAppender && selectedBlockClientId ) {
|
|
72
69
|
_destinationRootClientId = getBlockRootClientId(
|
|
73
70
|
selectedBlockClientId
|
|
74
71
|
);
|
|
75
|
-
_destinationIndex =
|
|
76
|
-
getBlockIndex(
|
|
77
|
-
selectedBlockClientId,
|
|
78
|
-
_destinationRootClientId
|
|
79
|
-
) + 1;
|
|
72
|
+
_destinationIndex = getBlockIndex( selectedBlockClientId ) + 1;
|
|
80
73
|
} else {
|
|
81
74
|
// Insert at the end of the list.
|
|
82
75
|
_destinationIndex = getBlockOrder( _destinationRootClientId )
|
|
@@ -265,7 +265,7 @@ export default compose( [
|
|
|
265
265
|
|
|
266
266
|
// If the clientId is defined, we insert at the position of the block.
|
|
267
267
|
if ( clientId ) {
|
|
268
|
-
return getBlockIndex( clientId
|
|
268
|
+
return getBlockIndex( clientId );
|
|
269
269
|
}
|
|
270
270
|
|
|
271
271
|
// If there a selected block, we insert after the selected block.
|
|
@@ -275,7 +275,7 @@ export default compose( [
|
|
|
275
275
|
end &&
|
|
276
276
|
getBlockRootClientId( end ) === rootClientId
|
|
277
277
|
) {
|
|
278
|
-
return getBlockIndex( end
|
|
278
|
+
return getBlockIndex( end ) + 1;
|
|
279
279
|
}
|
|
280
280
|
|
|
281
281
|
// Otherwise, we insert at the end of the current rootClientId
|
|
@@ -7,7 +7,7 @@ import { delay } from 'lodash';
|
|
|
7
7
|
/**
|
|
8
8
|
* WordPress dependencies
|
|
9
9
|
*/
|
|
10
|
-
import { __
|
|
10
|
+
import { __ } from '@wordpress/i18n';
|
|
11
11
|
import { Dropdown, ToolbarButton, Picker } from '@wordpress/components';
|
|
12
12
|
import { Component } from '@wordpress/element';
|
|
13
13
|
import { withDispatch, withSelect } from '@wordpress/data';
|
|
@@ -34,7 +34,7 @@ const VOICE_OVER_ANNOUNCEMENT_DELAY = 1000;
|
|
|
34
34
|
|
|
35
35
|
const defaultRenderToggle = ( { onToggle, disabled, style, onLongPress } ) => (
|
|
36
36
|
<ToolbarButton
|
|
37
|
-
title={
|
|
37
|
+
title={ __( 'Add block' ) }
|
|
38
38
|
icon={
|
|
39
39
|
<Icon
|
|
40
40
|
icon={ plusCircleFilled }
|
|
@@ -343,10 +343,7 @@ export default compose( [
|
|
|
343
343
|
const destinationRootClientId = isAnyBlockSelected
|
|
344
344
|
? getBlockRootClientId( end )
|
|
345
345
|
: rootClientId;
|
|
346
|
-
const selectedBlockIndex = getBlockIndex(
|
|
347
|
-
end,
|
|
348
|
-
destinationRootClientId
|
|
349
|
-
);
|
|
346
|
+
const selectedBlockIndex = getBlockIndex( end );
|
|
350
347
|
const endOfRootIndex = getBlockOrder( rootClientId ).length;
|
|
351
348
|
const isSelectedUnmodifiedDefaultBlock = isAnyBlockSelected
|
|
352
349
|
? isUnmodifiedDefaultBlock( getBlock( end ) )
|
|
@@ -364,7 +361,7 @@ export default compose( [
|
|
|
364
361
|
|
|
365
362
|
// If the clientId is defined, we insert at the position of the block.
|
|
366
363
|
if ( clientId ) {
|
|
367
|
-
return getBlockIndex( clientId
|
|
364
|
+
return getBlockIndex( clientId );
|
|
368
365
|
}
|
|
369
366
|
|
|
370
367
|
// If there is a selected block,
|
|
@@ -56,7 +56,7 @@ export default function QuickInserter( {
|
|
|
56
56
|
const { getSettings, getBlockIndex, getBlockCount } = select(
|
|
57
57
|
blockEditorStore
|
|
58
58
|
);
|
|
59
|
-
const index = getBlockIndex( clientId
|
|
59
|
+
const index = getBlockIndex( clientId );
|
|
60
60
|
return {
|
|
61
61
|
setInserterIsOpened: getSettings()
|
|
62
62
|
.__experimentalSetIsInserterOpened,
|
|
@@ -63,7 +63,7 @@ function InserterTabs( {
|
|
|
63
63
|
}, [ tabIndex ] );
|
|
64
64
|
|
|
65
65
|
const { tabs, tabKeys } = useMemo( () => {
|
|
66
|
-
const filteredTabs = InserterTabs.
|
|
66
|
+
const filteredTabs = InserterTabs.TABS.filter(
|
|
67
67
|
( { name } ) => showReusableBlocks || name !== 'reusable'
|
|
68
68
|
);
|
|
69
69
|
return {
|
|
@@ -114,9 +114,8 @@ function InserterTabs( {
|
|
|
114
114
|
}
|
|
115
115
|
|
|
116
116
|
function TabsControl( { onChangeTab, showReusableBlocks } ) {
|
|
117
|
-
const tabs = InserterTabs.getTabs();
|
|
118
117
|
const segments = useMemo( () => {
|
|
119
|
-
const filteredTabs =
|
|
118
|
+
const filteredTabs = InserterTabs.TABS.filter(
|
|
120
119
|
( { name } ) => showReusableBlocks || name !== 'reusable'
|
|
121
120
|
);
|
|
122
121
|
return filteredTabs.map( ( { title } ) => title );
|
|
@@ -124,7 +123,7 @@ function TabsControl( { onChangeTab, showReusableBlocks } ) {
|
|
|
124
123
|
|
|
125
124
|
const segmentHandler = useCallback(
|
|
126
125
|
( selectedTab ) => {
|
|
127
|
-
const tabTitles =
|
|
126
|
+
const tabTitles = InserterTabs.TABS.map( ( { title } ) => title );
|
|
128
127
|
onChangeTab( tabTitles.indexOf( selectedTab ) );
|
|
129
128
|
},
|
|
130
129
|
[ onChangeTab ]
|
|
@@ -140,7 +139,7 @@ function TabsControl( { onChangeTab, showReusableBlocks } ) {
|
|
|
140
139
|
|
|
141
140
|
InserterTabs.Control = TabsControl;
|
|
142
141
|
|
|
143
|
-
InserterTabs.
|
|
142
|
+
InserterTabs.TABS = [
|
|
144
143
|
{ name: 'blocks', title: __( 'Blocks' ), component: BlockTypesTab },
|
|
145
144
|
{ name: 'reusable', title: __( 'Reusable' ), component: ReusableBlocksTab },
|
|
146
145
|
];
|
|
@@ -6,7 +6,5 @@ import { useContext } from '@wordpress/element';
|
|
|
6
6
|
|
|
7
7
|
export default function BlockSupportSlotContainer( { Slot, ...props } ) {
|
|
8
8
|
const toolsPanelContext = useContext( ToolsPanelContext );
|
|
9
|
-
return
|
|
10
|
-
<Slot { ...props } fillProps={ toolsPanelContext } bubblesVirtually />
|
|
11
|
-
);
|
|
9
|
+
return <Slot { ...props } fillProps={ toolsPanelContext } />;
|
|
12
10
|
}
|
|
@@ -11,37 +11,73 @@ import { store as blockEditorStore } from '../../store';
|
|
|
11
11
|
import { cleanEmptyObject } from '../../hooks/utils';
|
|
12
12
|
|
|
13
13
|
export default function BlockSupportToolsPanel( { children, group, label } ) {
|
|
14
|
-
const {
|
|
15
|
-
const {
|
|
16
|
-
|
|
17
|
-
|
|
14
|
+
const { attributes, clientIds, panelId } = useSelect( ( select ) => {
|
|
15
|
+
const {
|
|
16
|
+
getBlockAttributes,
|
|
17
|
+
getMultiSelectedBlockClientIds,
|
|
18
|
+
getSelectedBlockClientId,
|
|
19
|
+
hasMultiSelection,
|
|
20
|
+
} = select( blockEditorStore );
|
|
21
|
+
|
|
22
|
+
// When we currently have a multi-selection, the value returned from
|
|
23
|
+
// `getSelectedBlockClientId()` is `null`. When a `null` value is used
|
|
24
|
+
// for the `panelId`, a `ToolsPanel` will still allow panel items to
|
|
25
|
+
// register themselves despite their panelIds not matching.
|
|
18
26
|
const selectedBlockClientId = getSelectedBlockClientId();
|
|
19
27
|
|
|
28
|
+
if ( hasMultiSelection() ) {
|
|
29
|
+
const selectedBlockClientIds = getMultiSelectedBlockClientIds();
|
|
30
|
+
const selectedBlockAttributes = selectedBlockClientIds.reduce(
|
|
31
|
+
( blockAttributes, blockId ) => {
|
|
32
|
+
blockAttributes[ blockId ] = getBlockAttributes( blockId );
|
|
33
|
+
return blockAttributes;
|
|
34
|
+
},
|
|
35
|
+
{}
|
|
36
|
+
);
|
|
37
|
+
|
|
38
|
+
return {
|
|
39
|
+
panelId: selectedBlockClientId,
|
|
40
|
+
clientIds: selectedBlockClientIds,
|
|
41
|
+
attributes: selectedBlockAttributes,
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
|
|
20
45
|
return {
|
|
21
|
-
|
|
22
|
-
|
|
46
|
+
panelId: selectedBlockClientId,
|
|
47
|
+
clientIds: [ selectedBlockClientId ],
|
|
48
|
+
attributes: {
|
|
49
|
+
[ selectedBlockClientId ]: getBlockAttributes(
|
|
50
|
+
selectedBlockClientId
|
|
51
|
+
),
|
|
52
|
+
},
|
|
23
53
|
};
|
|
24
54
|
}, [] );
|
|
25
55
|
const { updateBlockAttributes } = useDispatch( blockEditorStore );
|
|
26
56
|
|
|
27
57
|
const resetAll = ( resetFilters = [] ) => {
|
|
28
|
-
const
|
|
29
|
-
|
|
58
|
+
const newAttributes = {};
|
|
59
|
+
|
|
60
|
+
clientIds.forEach( ( clientId ) => {
|
|
61
|
+
const { style } = attributes[ clientId ];
|
|
62
|
+
let newBlockAttributes = { style };
|
|
30
63
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
64
|
+
resetFilters.forEach( ( resetFilter ) => {
|
|
65
|
+
newBlockAttributes = {
|
|
66
|
+
...newBlockAttributes,
|
|
67
|
+
...resetFilter( newBlockAttributes ),
|
|
68
|
+
};
|
|
69
|
+
} );
|
|
70
|
+
|
|
71
|
+
// Enforce a cleaned style object.
|
|
72
|
+
newBlockAttributes = {
|
|
73
|
+
...newBlockAttributes,
|
|
74
|
+
style: cleanEmptyObject( newBlockAttributes.style ),
|
|
35
75
|
};
|
|
36
|
-
} );
|
|
37
76
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
...newAttributes,
|
|
41
|
-
style: cleanEmptyObject( newAttributes.style ),
|
|
42
|
-
};
|
|
77
|
+
newAttributes[ clientId ] = newBlockAttributes;
|
|
78
|
+
} );
|
|
43
79
|
|
|
44
|
-
updateBlockAttributes(
|
|
80
|
+
updateBlockAttributes( clientIds, newAttributes, true );
|
|
45
81
|
};
|
|
46
82
|
|
|
47
83
|
return (
|
|
@@ -49,8 +85,8 @@ export default function BlockSupportToolsPanel( { children, group, label } ) {
|
|
|
49
85
|
className={ `${ group }-block-support-panel` }
|
|
50
86
|
label={ label }
|
|
51
87
|
resetAll={ resetAll }
|
|
52
|
-
key={
|
|
53
|
-
panelId={
|
|
88
|
+
key={ panelId }
|
|
89
|
+
panelId={ panelId }
|
|
54
90
|
hasInnerWrapper={ true }
|
|
55
91
|
shouldRenderPlaceholderItems={ true } // Required to maintain fills ordering.
|
|
56
92
|
>
|
|
@@ -14,7 +14,7 @@ import warning from '@wordpress/warning';
|
|
|
14
14
|
* Internal dependencies
|
|
15
15
|
*/
|
|
16
16
|
import groups from './groups';
|
|
17
|
-
import
|
|
17
|
+
import { useBlockEditContext } from '../block-edit/context';
|
|
18
18
|
import { BlockSettingsButton } from '../block-settings';
|
|
19
19
|
|
|
20
20
|
export default function InspectorControlsFill( {
|
|
@@ -22,14 +22,13 @@ export default function InspectorControlsFill( {
|
|
|
22
22
|
__experimentalGroup: group = 'default',
|
|
23
23
|
...props
|
|
24
24
|
} ) {
|
|
25
|
-
const
|
|
26
|
-
|
|
25
|
+
const { isSelected } = useBlockEditContext();
|
|
27
26
|
const Fill = groups[ group ]?.Fill;
|
|
28
27
|
if ( ! Fill ) {
|
|
29
28
|
warning( `Unknown InspectorControl group "${ group }" provided.` );
|
|
30
29
|
return null;
|
|
31
30
|
}
|
|
32
|
-
if ( !
|
|
31
|
+
if ( ! isSelected ) {
|
|
33
32
|
return null;
|
|
34
33
|
}
|
|
35
34
|
|
|
@@ -5,7 +5,6 @@ import { createSlotFill } from '@wordpress/components';
|
|
|
5
5
|
|
|
6
6
|
const InspectorControlsDefault = createSlotFill( 'InspectorControls' );
|
|
7
7
|
const InspectorControlsAdvanced = createSlotFill( 'InspectorAdvancedControls' );
|
|
8
|
-
const InspectorControlsBorder = createSlotFill( 'InspectorControlsBorder' );
|
|
9
8
|
const InspectorControlsDimensions = createSlotFill(
|
|
10
9
|
'InspectorControlsDimensions'
|
|
11
10
|
);
|
|
@@ -16,7 +15,6 @@ const InspectorControlsTypography = createSlotFill(
|
|
|
16
15
|
const groups = {
|
|
17
16
|
default: InspectorControlsDefault,
|
|
18
17
|
advanced: InspectorControlsAdvanced,
|
|
19
|
-
border: InspectorControlsBorder,
|
|
20
18
|
dimensions: InspectorControlsDimensions,
|
|
21
19
|
typography: InspectorControlsTypography,
|
|
22
20
|
};
|
|
@@ -13,6 +13,7 @@ import groups from './groups';
|
|
|
13
13
|
|
|
14
14
|
export default function InspectorControlsSlot( {
|
|
15
15
|
__experimentalGroup: group = 'default',
|
|
16
|
+
bubblesVirtually = true,
|
|
16
17
|
label,
|
|
17
18
|
...props
|
|
18
19
|
} ) {
|
|
@@ -31,10 +32,14 @@ export default function InspectorControlsSlot( {
|
|
|
31
32
|
if ( label ) {
|
|
32
33
|
return (
|
|
33
34
|
<BlockSupportToolsPanel group={ group } label={ label }>
|
|
34
|
-
<BlockSupportSlotContainer
|
|
35
|
+
<BlockSupportSlotContainer
|
|
36
|
+
{ ...props }
|
|
37
|
+
bubblesVirtually={ bubblesVirtually }
|
|
38
|
+
Slot={ Slot }
|
|
39
|
+
/>
|
|
35
40
|
</BlockSupportToolsPanel>
|
|
36
41
|
);
|
|
37
42
|
}
|
|
38
43
|
|
|
39
|
-
return <Slot { ...props } bubblesVirtually />;
|
|
44
|
+
return <Slot { ...props } bubblesVirtually={ bubblesVirtually } />;
|
|
40
45
|
}
|
|
@@ -15,12 +15,12 @@ import useSetting from '../../components/use-setting';
|
|
|
15
15
|
/**
|
|
16
16
|
* Control for letter-spacing.
|
|
17
17
|
*
|
|
18
|
-
* @param {Object}
|
|
19
|
-
* @param {string}
|
|
20
|
-
* @param {Function}
|
|
21
|
-
* @param {
|
|
18
|
+
* @param {Object} props Component props.
|
|
19
|
+
* @param {string} props.value Currently selected letter-spacing.
|
|
20
|
+
* @param {Function} props.onChange Handles change in letter-spacing selection.
|
|
21
|
+
* @param {boolean} props.__unstableInputWidth Input width to pass through to inner UnitControl.
|
|
22
22
|
*
|
|
23
|
-
* @return {WPElement}
|
|
23
|
+
* @return {WPElement} Letter-spacing control.
|
|
24
24
|
*/
|
|
25
25
|
export default function LetterSpacingControl( {
|
|
26
26
|
value,
|
|
@@ -33,7 +33,7 @@ export default function LetterSpacingControl( {
|
|
|
33
33
|
} );
|
|
34
34
|
return (
|
|
35
35
|
<UnitControl
|
|
36
|
-
label={ __( 'Letter
|
|
36
|
+
label={ __( 'Letter-spacing' ) }
|
|
37
37
|
value={ value }
|
|
38
38
|
__unstableInputWidth={ __unstableInputWidth }
|
|
39
39
|
units={ units }
|
|
@@ -1634,7 +1634,6 @@ describe( 'Selecting links', () => {
|
|
|
1634
1634
|
);
|
|
1635
1635
|
|
|
1636
1636
|
// We should have highlighted the first item using the keyboard
|
|
1637
|
-
// eslint-disable-next-line jest/no-conditional-expect
|
|
1638
1637
|
expect( selectedSearchResultElement ).toEqual(
|
|
1639
1638
|
secondSearchSuggestion
|
|
1640
1639
|
);
|
|
@@ -1649,7 +1648,6 @@ describe( 'Selecting links', () => {
|
|
|
1649
1648
|
);
|
|
1650
1649
|
|
|
1651
1650
|
// We should be back to highlighting the first search result again
|
|
1652
|
-
// eslint-disable-next-line jest/no-conditional-expect
|
|
1653
1651
|
expect( selectedSearchResultElement ).toEqual(
|
|
1654
1652
|
firstSearchSuggestion
|
|
1655
1653
|
);
|
|
@@ -19,7 +19,6 @@ import useBlockDisplayInformation from '../use-block-display-information';
|
|
|
19
19
|
import { getBlockPositionDescription } from './utils';
|
|
20
20
|
import BlockTitle from '../block-title';
|
|
21
21
|
import ListViewExpander from './expander';
|
|
22
|
-
import { SPACE, ENTER } from '@wordpress/keycodes';
|
|
23
22
|
|
|
24
23
|
function ListViewBlockSelectButton(
|
|
25
24
|
{
|
|
@@ -48,22 +47,6 @@ function ListViewBlockSelectButton(
|
|
|
48
47
|
level
|
|
49
48
|
);
|
|
50
49
|
|
|
51
|
-
// The `href` attribute triggers the browser's native HTML drag operations.
|
|
52
|
-
// When the link is dragged, the element's outerHTML is set in DataTransfer object as text/html.
|
|
53
|
-
// We need to clear any HTML drag data to prevent `pasteHandler` from firing
|
|
54
|
-
// inside the `useOnBlockDrop` hook.
|
|
55
|
-
const onDragStartHandler = ( event ) => {
|
|
56
|
-
event.dataTransfer.clearData();
|
|
57
|
-
onDragStart( event );
|
|
58
|
-
};
|
|
59
|
-
|
|
60
|
-
function onKeyDownHandler( event ) {
|
|
61
|
-
if ( event.keyCode === ENTER || event.keyCode === SPACE ) {
|
|
62
|
-
event.preventDefault();
|
|
63
|
-
onClick( event );
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
|
|
67
50
|
return (
|
|
68
51
|
<>
|
|
69
52
|
<Button
|
|
@@ -72,15 +55,13 @@ function ListViewBlockSelectButton(
|
|
|
72
55
|
className
|
|
73
56
|
) }
|
|
74
57
|
onClick={ onClick }
|
|
75
|
-
onKeyDown={ onKeyDownHandler }
|
|
76
58
|
aria-describedby={ descriptionId }
|
|
77
59
|
ref={ ref }
|
|
78
60
|
tabIndex={ tabIndex }
|
|
79
61
|
onFocus={ onFocus }
|
|
80
|
-
onDragStart={
|
|
62
|
+
onDragStart={ onDragStart }
|
|
81
63
|
onDragEnd={ onDragEnd }
|
|
82
64
|
draggable={ draggable }
|
|
83
|
-
href={ `#block-${ clientId }` }
|
|
84
65
|
>
|
|
85
66
|
<ListViewExpander onClick={ onToggleExpanded } />
|
|
86
67
|
<BlockIcon icon={ blockInformation?.icon } showColors />
|
|
@@ -226,7 +226,7 @@ export default function useListViewDropZone() {
|
|
|
226
226
|
return {
|
|
227
227
|
clientId,
|
|
228
228
|
rootClientId,
|
|
229
|
-
blockIndex: getBlockIndex( clientId
|
|
229
|
+
blockIndex: getBlockIndex( clientId ),
|
|
230
230
|
element: blockElement,
|
|
231
231
|
isDraggedBlock: isBlockDrag
|
|
232
232
|
? draggedBlockClientIds.includes( clientId )
|
|
@@ -75,7 +75,6 @@ export function MediaPlaceholder( {
|
|
|
75
75
|
onDoubleClick,
|
|
76
76
|
onFilesPreUpload = noop,
|
|
77
77
|
onHTMLDrop = noop,
|
|
78
|
-
onClose = noop,
|
|
79
78
|
children,
|
|
80
79
|
mediaLibraryButton,
|
|
81
80
|
placeholder,
|
|
@@ -329,7 +328,6 @@ export function MediaPlaceholder( {
|
|
|
329
328
|
gallery={ multiple && onlyAllowsImages() }
|
|
330
329
|
multiple={ multiple }
|
|
331
330
|
onSelect={ onSelect }
|
|
332
|
-
onClose={ onClose }
|
|
333
331
|
allowedTypes={ allowedTypes }
|
|
334
332
|
value={
|
|
335
333
|
Array.isArray( value )
|
|
@@ -39,7 +39,6 @@ const MediaReplaceFlow = ( {
|
|
|
39
39
|
onSelect,
|
|
40
40
|
onSelectURL,
|
|
41
41
|
onFilesUpload = noop,
|
|
42
|
-
onCloseModal = noop,
|
|
43
42
|
name = __( 'Replace' ),
|
|
44
43
|
createNotice,
|
|
45
44
|
removeNotice,
|
|
@@ -137,7 +136,6 @@ const MediaReplaceFlow = ( {
|
|
|
137
136
|
value={ mediaId }
|
|
138
137
|
onSelect={ ( media ) => selectMedia( media ) }
|
|
139
138
|
allowedTypes={ allowedTypes }
|
|
140
|
-
onClose={ onCloseModal }
|
|
141
139
|
render={ ( { open } ) => (
|
|
142
140
|
<MenuItem icon={ mediaIcon } onClick={ open }>
|
|
143
141
|
{ __( 'Open Media Library' ) }
|
|
@@ -7,7 +7,7 @@ import { last, noop } from 'lodash';
|
|
|
7
7
|
* WordPress dependencies
|
|
8
8
|
*/
|
|
9
9
|
import { useEffect, useRef } from '@wordpress/element';
|
|
10
|
-
import { useRegistry } from '@wordpress/data';
|
|
10
|
+
import { useRegistry, useSelect } from '@wordpress/data';
|
|
11
11
|
import { cloneBlock } from '@wordpress/blocks';
|
|
12
12
|
|
|
13
13
|
/**
|
|
@@ -83,6 +83,15 @@ export default function useBlockSync( {
|
|
|
83
83
|
__unstableMarkNextChangeAsNotPersistent,
|
|
84
84
|
} = registry.dispatch( blockEditorStore );
|
|
85
85
|
const { getBlockName, getBlocks } = registry.select( blockEditorStore );
|
|
86
|
+
const isControlled = useSelect(
|
|
87
|
+
( select ) => {
|
|
88
|
+
return (
|
|
89
|
+
! clientId ||
|
|
90
|
+
select( blockEditorStore ).areInnerBlocksControlled( clientId )
|
|
91
|
+
);
|
|
92
|
+
},
|
|
93
|
+
[ clientId ]
|
|
94
|
+
);
|
|
86
95
|
|
|
87
96
|
const pendingChanges = useRef( { incoming: null, outgoing: [] } );
|
|
88
97
|
const subscribed = useRef( false );
|
|
@@ -97,15 +106,21 @@ export default function useBlockSync( {
|
|
|
97
106
|
// and so it would already be persisted.
|
|
98
107
|
__unstableMarkNextChangeAsNotPersistent();
|
|
99
108
|
if ( clientId ) {
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
)
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
+
// It is important to batch here because otherwise,
|
|
110
|
+
// as soon as `setHasControlledInnerBlocks` is called
|
|
111
|
+
// the effect to restore might be triggered
|
|
112
|
+
// before the actual blocks get set properly in state.
|
|
113
|
+
registry.batch( () => {
|
|
114
|
+
setHasControlledInnerBlocks( clientId, true );
|
|
115
|
+
const storeBlocks = controlledBlocks.map( ( block ) =>
|
|
116
|
+
cloneBlock( block )
|
|
117
|
+
);
|
|
118
|
+
if ( subscribed.current ) {
|
|
119
|
+
pendingChanges.current.incoming = storeBlocks;
|
|
120
|
+
}
|
|
121
|
+
__unstableMarkNextChangeAsNotPersistent();
|
|
122
|
+
replaceInnerBlocks( clientId, storeBlocks );
|
|
123
|
+
} );
|
|
109
124
|
} else {
|
|
110
125
|
if ( subscribed.current ) {
|
|
111
126
|
pendingChanges.current.incoming = controlledBlocks;
|
|
@@ -157,6 +172,15 @@ export default function useBlockSync( {
|
|
|
157
172
|
}
|
|
158
173
|
}, [ controlledBlocks, clientId ] );
|
|
159
174
|
|
|
175
|
+
useEffect( () => {
|
|
176
|
+
// When the block becomes uncontrolled, it means its inner state has been reset
|
|
177
|
+
// we need to take the blocks again from the external value property.
|
|
178
|
+
if ( ! isControlled ) {
|
|
179
|
+
pendingChanges.current.outgoing = [];
|
|
180
|
+
setControlledBlocks();
|
|
181
|
+
}
|
|
182
|
+
}, [ isControlled ] );
|
|
183
|
+
|
|
160
184
|
useEffect( () => {
|
|
161
185
|
const {
|
|
162
186
|
getSelectionStart,
|
|
@@ -164,6 +188,7 @@ export default function useBlockSync( {
|
|
|
164
188
|
getSelectedBlocksInitialCaretPosition,
|
|
165
189
|
isLastBlockChangePersistent,
|
|
166
190
|
__unstableIsLastBlockChangeIgnored,
|
|
191
|
+
areInnerBlocksControlled,
|
|
167
192
|
} = registry.select( blockEditorStore );
|
|
168
193
|
|
|
169
194
|
let blocks = getBlocks( clientId );
|
|
@@ -182,8 +207,17 @@ export default function useBlockSync( {
|
|
|
182
207
|
if ( clientId !== null && getBlockName( clientId ) === null )
|
|
183
208
|
return;
|
|
184
209
|
|
|
185
|
-
|
|
210
|
+
// When RESET_BLOCKS on parent blocks get called, the controlled blocks
|
|
211
|
+
// can reset to uncontrolled, in these situations, it means we need to populate
|
|
212
|
+
// the blocks again from the external blocks (the value property here)
|
|
213
|
+
// and we should stop triggering onChange
|
|
214
|
+
const isStillControlled =
|
|
215
|
+
! clientId || areInnerBlocksControlled( clientId );
|
|
216
|
+
if ( ! isStillControlled ) {
|
|
217
|
+
return;
|
|
218
|
+
}
|
|
186
219
|
|
|
220
|
+
const newIsPersistent = isLastBlockChangePersistent();
|
|
187
221
|
const newBlocks = getBlocks( clientId );
|
|
188
222
|
const areBlocksDifferent = newBlocks !== blocks;
|
|
189
223
|
blocks = newBlocks;
|
|
@@ -5,9 +5,7 @@ import { createBlobURL } from '@wordpress/blob';
|
|
|
5
5
|
|
|
6
6
|
export function filePasteHandler( files ) {
|
|
7
7
|
return files
|
|
8
|
-
.filter( ( { type } ) =>
|
|
9
|
-
/^image\/(?:jpe?g|png|gif|webp)$/.test( type )
|
|
10
|
-
)
|
|
8
|
+
.filter( ( { type } ) => /^image\/(?:jpe?g|png|gif)$/.test( type ) )
|
|
11
9
|
.map( ( file ) => `<img src="${ createBlobURL( file ) }">` )
|
|
12
10
|
.join( '' );
|
|
13
11
|
}
|
|
@@ -11,7 +11,6 @@ import { useDispatch } from '@wordpress/data';
|
|
|
11
11
|
* Internal dependencies
|
|
12
12
|
*/
|
|
13
13
|
import { store as blockEditorStore } from '../../store';
|
|
14
|
-
import { preventEventDiscovery } from './prevent-event-discovery';
|
|
15
14
|
|
|
16
15
|
export function useInputRules( props ) {
|
|
17
16
|
const {
|
|
@@ -86,7 +85,7 @@ export function useInputRules( props ) {
|
|
|
86
85
|
|
|
87
86
|
return accumlator;
|
|
88
87
|
},
|
|
89
|
-
|
|
88
|
+
value
|
|
90
89
|
);
|
|
91
90
|
|
|
92
91
|
if ( transformed !== value ) {
|