@wordpress/block-editor 11.4.0 → 11.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +8 -0
- package/build/components/block-inspector/index.js +11 -10
- package/build/components/block-inspector/index.js.map +1 -1
- package/build/components/block-inspector/useBlockInspectorAnimationSettings.js +46 -0
- package/build/components/block-inspector/useBlockInspectorAnimationSettings.js.map +1 -0
- package/build/components/block-list/block-invalid-warning.js +63 -80
- package/build/components/block-list/block-invalid-warning.js.map +1 -1
- package/build/components/block-lock/modal.js +1 -0
- package/build/components/block-lock/modal.js.map +1 -1
- package/build/components/block-settings-menu/block-settings-dropdown.js +2 -2
- package/build/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
- package/build/components/block-settings-menu-controls/index.js +1 -1
- package/build/components/block-settings-menu-controls/index.js.map +1 -1
- package/build/components/block-styles/index.js +2 -1
- package/build/components/block-styles/index.js.map +1 -1
- package/build/components/block-switcher/block-transformations-menu.native.js +1 -0
- package/build/components/block-switcher/block-transformations-menu.native.js.map +1 -1
- package/build/components/child-layout-control/index.js +107 -0
- package/build/components/child-layout-control/index.js.map +1 -0
- package/build/components/convert-to-group-buttons/use-convert-to-group-button-props.js +6 -3
- package/build/components/convert-to-group-buttons/use-convert-to-group-button-props.js.map +1 -1
- package/build/components/date-format-picker/index.js +3 -3
- package/build/components/date-format-picker/index.js.map +1 -1
- package/build/components/global-styles/border-panel.js +306 -0
- package/build/components/global-styles/border-panel.js.map +1 -0
- package/build/components/global-styles/dimensions-panel.js +594 -0
- package/build/components/global-styles/dimensions-panel.js.map +1 -0
- package/build/components/global-styles/hooks.js +127 -37
- package/build/components/global-styles/hooks.js.map +1 -1
- package/build/components/global-styles/index.js +36 -2
- package/build/components/global-styles/index.js.map +1 -1
- package/build/components/global-styles/typography-panel.js +87 -27
- package/build/components/global-styles/typography-panel.js.map +1 -1
- package/build/components/global-styles/use-global-styles-output.js +21 -14
- package/build/components/global-styles/use-global-styles-output.js.map +1 -1
- package/build/components/global-styles/utils.js +2 -0
- package/build/components/global-styles/utils.js.map +1 -1
- package/build/components/index.native.js +23 -0
- package/build/components/index.native.js.map +1 -1
- package/build/components/inserter/index.js +29 -17
- package/build/components/inserter/index.js.map +1 -1
- package/build/components/inserter/media-tab/hooks.js +10 -11
- package/build/components/inserter/media-tab/hooks.js.map +1 -1
- package/build/components/inserter/media-tab/media-list.js +5 -108
- package/build/components/inserter/media-tab/media-list.js.map +1 -1
- package/build/components/inserter/media-tab/media-preview.js +242 -0
- package/build/components/inserter/media-tab/media-preview.js.map +1 -0
- package/build/components/inserter/menu.js +1 -1
- package/build/components/inserter/menu.js.map +1 -1
- package/build/components/inserter/quick-inserter.js +4 -2
- package/build/components/inserter/quick-inserter.js.map +1 -1
- package/build/components/inserter/search-results.js +10 -3
- package/build/components/inserter/search-results.js.map +1 -1
- package/build/components/inserter/tabs.js +1 -1
- package/build/components/inserter/tabs.js.map +1 -1
- package/build/components/inspector-controls/block-support-tools-panel.js +1 -1
- package/build/components/inspector-controls/block-support-tools-panel.js.map +1 -1
- package/build/components/inspector-controls/fill.js +38 -9
- package/build/components/inspector-controls/fill.js.map +1 -1
- package/build/components/link-control/index.js +1 -1
- package/build/components/link-control/index.js.map +1 -1
- package/build/components/link-control/search-item.js +5 -2
- package/build/components/link-control/search-item.js.map +1 -1
- package/build/components/link-control/settings-drawer.js +1 -1
- package/build/components/link-control/settings-drawer.js.map +1 -1
- package/build/components/link-control/settings.js +1 -0
- package/build/components/link-control/settings.js.map +1 -1
- package/build/components/list-view/block.js +17 -3
- package/build/components/list-view/block.js.map +1 -1
- package/build/components/list-view/branch.js +2 -2
- package/build/components/list-view/branch.js.map +1 -1
- package/build/components/list-view/expander.js +2 -1
- package/build/components/list-view/expander.js.map +1 -1
- package/build/components/list-view/leaf.js +10 -6
- package/build/components/list-view/leaf.js.map +1 -1
- package/build/components/list-view/use-block-selection.js +1 -2
- package/build/components/list-view/use-block-selection.js.map +1 -1
- package/build/components/list-view/use-list-view-scroll-into-view.js +51 -0
- package/build/components/list-view/use-list-view-scroll-into-view.js.map +1 -0
- package/build/components/off-canvas-editor/appender.js +33 -13
- package/build/components/off-canvas-editor/appender.js.map +1 -1
- package/build/components/off-canvas-editor/branch.js +6 -3
- package/build/components/off-canvas-editor/branch.js.map +1 -1
- package/build/components/off-canvas-editor/index.js +8 -2
- package/build/components/off-canvas-editor/index.js.map +1 -1
- package/build/components/off-canvas-editor/leaf-more-menu.js +34 -4
- package/build/components/off-canvas-editor/leaf-more-menu.js.map +1 -1
- package/build/components/provider/use-block-sync.js +17 -3
- package/build/components/provider/use-block-sync.js.map +1 -1
- package/build/components/responsive-block-control/index.js +1 -0
- package/build/components/responsive-block-control/index.js.map +1 -1
- package/build/components/rich-text/format-toolbar-container.js +0 -3
- package/build/components/rich-text/format-toolbar-container.js.map +1 -1
- package/build/components/rich-text/index.js +9 -43
- package/build/components/rich-text/index.js.map +1 -1
- package/build/components/rich-text/use-delete.js +73 -0
- package/build/components/rich-text/use-delete.js.map +1 -0
- package/build/components/rich-text/use-input-rules.js +14 -6
- package/build/components/rich-text/use-input-rules.js.map +1 -1
- package/build/components/writing-flow/use-selection-observer.js +4 -1
- package/build/components/writing-flow/use-selection-observer.js.map +1 -1
- package/build/hooks/align.js +3 -1
- package/build/hooks/align.js.map +1 -1
- package/build/hooks/border.js +91 -240
- package/build/hooks/border.js.map +1 -1
- package/build/hooks/custom-class-name.js +4 -4
- package/build/hooks/custom-class-name.js.map +1 -1
- package/build/hooks/custom-class-name.native.js +3 -4
- package/build/hooks/custom-class-name.native.js.map +1 -1
- package/build/hooks/dimensions.js +72 -190
- package/build/hooks/dimensions.js.map +1 -1
- package/build/hooks/duotone.js +94 -25
- package/build/hooks/duotone.js.map +1 -1
- package/build/hooks/gap.js +0 -202
- package/build/hooks/gap.js.map +1 -1
- package/build/hooks/layout.js +33 -27
- package/build/hooks/layout.js.map +1 -1
- package/build/hooks/margin.js +7 -163
- package/build/hooks/margin.js.map +1 -1
- package/build/hooks/padding.js +7 -163
- package/build/hooks/padding.js.map +1 -1
- package/build/hooks/supports.js +7 -1
- package/build/hooks/supports.js.map +1 -1
- package/build/hooks/typography.js +52 -66
- package/build/hooks/typography.js.map +1 -1
- package/build/hooks/utils.js +101 -0
- package/build/hooks/utils.js.map +1 -1
- package/build/layouts/constrained.js +6 -2
- package/build/layouts/constrained.js.map +1 -1
- package/build/layouts/flex.js +1 -0
- package/build/layouts/flex.js.map +1 -1
- package/build/private-apis.js +4 -1
- package/build/private-apis.js.map +1 -1
- package/build/store/actions.js +28 -14
- package/build/store/actions.js.map +1 -1
- package/build/store/defaults.js +28 -1
- package/build/store/defaults.js.map +1 -1
- package/build/store/reducer.js +53 -47
- package/build/store/reducer.js.map +1 -1
- package/build/store/selectors.js +24 -4
- package/build/store/selectors.js.map +1 -1
- package/build/utils/parse-css-unit-to-px.js +49 -10
- package/build/utils/parse-css-unit-to-px.js.map +1 -1
- package/build-module/components/block-inspector/index.js +9 -9
- package/build-module/components/block-inspector/index.js.map +1 -1
- package/build-module/components/block-inspector/useBlockInspectorAnimationSettings.js +37 -0
- package/build-module/components/block-inspector/useBlockInspectorAnimationSettings.js.map +1 -0
- package/build-module/components/block-list/block-invalid-warning.js +66 -78
- package/build-module/components/block-list/block-invalid-warning.js.map +1 -1
- package/build-module/components/block-lock/modal.js +1 -0
- package/build-module/components/block-lock/modal.js.map +1 -1
- package/build-module/components/block-settings-menu/block-settings-dropdown.js +2 -2
- package/build-module/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
- package/build-module/components/block-settings-menu-controls/index.js +1 -1
- package/build-module/components/block-settings-menu-controls/index.js.map +1 -1
- package/build-module/components/block-styles/index.js +2 -1
- package/build-module/components/block-styles/index.js.map +1 -1
- package/build-module/components/block-switcher/block-transformations-menu.native.js +1 -0
- package/build-module/components/block-switcher/block-transformations-menu.native.js.map +1 -1
- package/build-module/components/child-layout-control/index.js +98 -0
- package/build-module/components/child-layout-control/index.js.map +1 -0
- package/build-module/components/convert-to-group-buttons/use-convert-to-group-button-props.js +6 -3
- package/build-module/components/convert-to-group-buttons/use-convert-to-group-button-props.js.map +1 -1
- package/build-module/components/date-format-picker/index.js +4 -4
- package/build-module/components/date-format-picker/index.js.map +1 -1
- package/build-module/components/global-styles/border-panel.js +291 -0
- package/build-module/components/global-styles/border-panel.js.map +1 -0
- package/build-module/components/global-styles/dimensions-panel.js +574 -0
- package/build-module/components/global-styles/dimensions-panel.js.map +1 -0
- package/build-module/components/global-styles/hooks.js +123 -34
- package/build-module/components/global-styles/hooks.js.map +1 -1
- package/build-module/components/global-styles/index.js +3 -1
- package/build-module/components/global-styles/index.js.map +1 -1
- package/build-module/components/global-styles/typography-panel.js +88 -27
- package/build-module/components/global-styles/typography-panel.js.map +1 -1
- package/build-module/components/global-styles/use-global-styles-output.js +21 -14
- package/build-module/components/global-styles/use-global-styles-output.js.map +1 -1
- package/build-module/components/global-styles/utils.js +2 -0
- package/build-module/components/global-styles/utils.js.map +1 -1
- package/build-module/components/index.native.js +2 -1
- package/build-module/components/index.native.js.map +1 -1
- package/build-module/components/inserter/index.js +28 -16
- package/build-module/components/inserter/index.js.map +1 -1
- package/build-module/components/inserter/media-tab/hooks.js +10 -11
- package/build-module/components/inserter/media-tab/hooks.js.map +1 -1
- package/build-module/components/inserter/media-tab/media-list.js +6 -105
- package/build-module/components/inserter/media-tab/media-list.js.map +1 -1
- package/build-module/components/inserter/media-tab/media-preview.js +222 -0
- package/build-module/components/inserter/media-tab/media-preview.js.map +1 -0
- package/build-module/components/inserter/menu.js +1 -1
- package/build-module/components/inserter/menu.js.map +1 -1
- package/build-module/components/inserter/quick-inserter.js +4 -2
- package/build-module/components/inserter/quick-inserter.js.map +1 -1
- package/build-module/components/inserter/search-results.js +10 -3
- package/build-module/components/inserter/search-results.js.map +1 -1
- package/build-module/components/inserter/tabs.js +1 -1
- package/build-module/components/inserter/tabs.js.map +1 -1
- package/build-module/components/inspector-controls/block-support-tools-panel.js +1 -1
- package/build-module/components/inspector-controls/block-support-tools-panel.js.map +1 -1
- package/build-module/components/inspector-controls/fill.js +39 -9
- package/build-module/components/inspector-controls/fill.js.map +1 -1
- package/build-module/components/link-control/index.js +1 -1
- package/build-module/components/link-control/index.js.map +1 -1
- package/build-module/components/link-control/search-item.js +4 -2
- package/build-module/components/link-control/search-item.js.map +1 -1
- package/build-module/components/link-control/settings-drawer.js +1 -1
- package/build-module/components/link-control/settings-drawer.js.map +1 -1
- package/build-module/components/link-control/settings.js +1 -0
- package/build-module/components/link-control/settings.js.map +1 -1
- package/build-module/components/list-view/block.js +16 -3
- package/build-module/components/list-view/block.js.map +1 -1
- package/build-module/components/list-view/branch.js +2 -2
- package/build-module/components/list-view/branch.js.map +1 -1
- package/build-module/components/list-view/expander.js +2 -1
- package/build-module/components/list-view/expander.js.map +1 -1
- package/build-module/components/list-view/leaf.js +8 -4
- package/build-module/components/list-view/leaf.js.map +1 -1
- package/build-module/components/list-view/use-block-selection.js +1 -2
- package/build-module/components/list-view/use-block-selection.js.map +1 -1
- package/build-module/components/list-view/use-list-view-scroll-into-view.js +42 -0
- package/build-module/components/list-view/use-list-view-scroll-into-view.js.map +1 -0
- package/build-module/components/off-canvas-editor/appender.js +33 -14
- package/build-module/components/off-canvas-editor/appender.js.map +1 -1
- package/build-module/components/off-canvas-editor/branch.js +6 -3
- package/build-module/components/off-canvas-editor/branch.js.map +1 -1
- package/build-module/components/off-canvas-editor/index.js +8 -2
- package/build-module/components/off-canvas-editor/index.js.map +1 -1
- package/build-module/components/off-canvas-editor/leaf-more-menu.js +36 -7
- package/build-module/components/off-canvas-editor/leaf-more-menu.js.map +1 -1
- package/build-module/components/provider/use-block-sync.js +17 -3
- package/build-module/components/provider/use-block-sync.js.map +1 -1
- package/build-module/components/responsive-block-control/index.js +1 -0
- package/build-module/components/responsive-block-control/index.js.map +1 -1
- package/build-module/components/rich-text/format-toolbar-container.js +0 -3
- package/build-module/components/rich-text/format-toolbar-container.js.map +1 -1
- package/build-module/components/rich-text/index.js +9 -43
- package/build-module/components/rich-text/index.js.map +1 -1
- package/build-module/components/rich-text/use-delete.js +62 -0
- package/build-module/components/rich-text/use-delete.js.map +1 -0
- package/build-module/components/rich-text/use-input-rules.js +14 -6
- package/build-module/components/rich-text/use-input-rules.js.map +1 -1
- package/build-module/components/writing-flow/use-selection-observer.js +4 -1
- package/build-module/components/writing-flow/use-selection-observer.js.map +1 -1
- package/build-module/hooks/align.js +3 -1
- package/build-module/hooks/align.js.map +1 -1
- package/build-module/hooks/border.js +93 -240
- package/build-module/hooks/border.js.map +1 -1
- package/build-module/hooks/custom-class-name.js +4 -4
- package/build-module/hooks/custom-class-name.js.map +1 -1
- package/build-module/hooks/custom-class-name.native.js +3 -4
- package/build-module/hooks/custom-class-name.native.js.map +1 -1
- package/build-module/hooks/dimensions.js +75 -187
- package/build-module/hooks/dimensions.js.map +1 -1
- package/build-module/hooks/duotone.js +86 -24
- package/build-module/hooks/duotone.js.map +1 -1
- package/build-module/hooks/gap.js +0 -183
- package/build-module/hooks/gap.js.map +1 -1
- package/build-module/hooks/layout.js +33 -27
- package/build-module/hooks/layout.js.map +1 -1
- package/build-module/hooks/margin.js +4 -143
- package/build-module/hooks/margin.js.map +1 -1
- package/build-module/hooks/padding.js +4 -143
- package/build-module/hooks/padding.js.map +1 -1
- package/build-module/hooks/supports.js +7 -1
- package/build-module/hooks/supports.js.map +1 -1
- package/build-module/hooks/typography.js +54 -66
- package/build-module/hooks/typography.js.map +1 -1
- package/build-module/hooks/utils.js +96 -0
- package/build-module/hooks/utils.js.map +1 -1
- package/build-module/layouts/constrained.js +6 -2
- package/build-module/layouts/constrained.js.map +1 -1
- package/build-module/layouts/flex.js +1 -0
- package/build-module/layouts/flex.js.map +1 -1
- package/build-module/private-apis.js +3 -1
- package/build-module/private-apis.js.map +1 -1
- package/build-module/store/actions.js +28 -14
- package/build-module/store/actions.js.map +1 -1
- package/build-module/store/defaults.js +28 -1
- package/build-module/store/defaults.js.map +1 -1
- package/build-module/store/reducer.js +53 -45
- package/build-module/store/reducer.js.map +1 -1
- package/build-module/store/selectors.js +22 -4
- package/build-module/store/selectors.js.map +1 -1
- package/build-module/utils/parse-css-unit-to-px.js +49 -10
- package/build-module/utils/parse-css-unit-to-px.js.map +1 -1
- package/build-style/style-rtl.css +39 -27
- package/build-style/style.css +39 -27
- package/package.json +31 -31
- package/src/components/block-draggable/test/__snapshots__/index.native.js.snap +24 -24
- package/src/components/block-inspector/index.js +11 -14
- package/src/components/block-inspector/style.scss +3 -0
- package/src/components/block-inspector/useBlockInspectorAnimationSettings.js +53 -0
- package/src/components/block-list/block-invalid-warning.js +72 -64
- package/src/components/block-lock/modal.js +1 -0
- package/src/components/block-lock/style.scss +0 -9
- package/src/components/block-mobile-toolbar/test/__snapshots__/block-actions-menu.native.js.snap +20 -20
- package/src/components/block-mover/test/__snapshots__/index.native.js.snap +35 -17
- package/src/components/block-preview/test/index.js +0 -2
- package/src/components/block-settings-menu/block-settings-dropdown.js +4 -1
- package/src/components/block-settings-menu-controls/index.js +2 -1
- package/src/components/block-styles/index.js +5 -1
- package/src/components/block-styles/style.scss +2 -2
- package/src/components/block-switcher/block-transformations-menu.native.js +1 -0
- package/src/components/child-layout-control/index.js +106 -0
- package/src/components/color-palette/test/__snapshots__/control.js.snap +17 -15
- package/src/components/convert-to-group-buttons/use-convert-to-group-button-props.js +48 -38
- package/src/components/date-format-picker/index.js +6 -8
- package/src/components/date-format-picker/style.scss +0 -5
- package/src/components/global-styles/border-panel.js +285 -0
- package/src/components/global-styles/dimensions-panel.js +627 -0
- package/src/components/global-styles/hooks.js +160 -44
- package/src/components/global-styles/index.js +7 -1
- package/src/components/global-styles/test/use-global-styles-output.js +1 -1
- package/src/components/global-styles/typography-panel.js +81 -9
- package/src/components/global-styles/use-global-styles-output.js +17 -16
- package/src/components/global-styles/utils.js +2 -0
- package/src/components/index.native.js +5 -0
- package/src/components/inner-blocks/test/__snapshots__/index.js.snap +1 -1
- package/src/components/inserter/index.js +30 -11
- package/src/components/inserter/media-tab/hooks.js +9 -8
- package/src/components/inserter/media-tab/media-list.js +3 -122
- package/src/components/inserter/media-tab/media-preview.js +268 -0
- package/src/components/inserter/menu.js +0 -1
- package/src/components/inserter/quick-inserter.js +2 -0
- package/src/components/inserter/search-results.js +7 -1
- package/src/components/inserter/style.scss +25 -0
- package/src/components/inserter/tabs.js +1 -9
- package/src/components/inserter/test/__snapshots__/index.native.js.snap +15 -15
- package/src/components/inspector-controls/block-support-tools-panel.js +0 -1
- package/src/components/inspector-controls/fill.js +32 -8
- package/src/components/link-control/index.js +1 -1
- package/src/components/link-control/search-item.js +3 -1
- package/src/components/link-control/settings-drawer.js +2 -1
- package/src/components/link-control/settings.js +1 -0
- package/src/components/link-control/style.scss +18 -12
- package/src/components/link-control/test/index.js +3 -5
- package/src/components/list-view/block.js +19 -1
- package/src/components/list-view/branch.js +1 -2
- package/src/components/list-view/expander.js +1 -0
- package/src/components/list-view/leaf.js +43 -29
- package/src/components/list-view/use-block-selection.js +0 -2
- package/src/components/list-view/use-list-view-scroll-into-view.js +48 -0
- package/src/components/media-replace-flow/style.scss +7 -9
- package/src/components/off-canvas-editor/appender.js +44 -21
- package/src/components/off-canvas-editor/branch.js +4 -1
- package/src/components/off-canvas-editor/index.js +7 -1
- package/src/components/off-canvas-editor/leaf-more-menu.js +57 -15
- package/src/components/provider/use-block-sync.js +21 -4
- package/src/components/responsive-block-control/index.js +1 -0
- package/src/components/rich-text/format-toolbar-container.js +1 -7
- package/src/components/rich-text/index.js +8 -44
- package/src/components/rich-text/use-delete.js +59 -0
- package/src/components/rich-text/use-input-rules.js +13 -5
- package/src/components/spacing-sizes-control/style.scss +1 -1
- package/src/components/url-popover/stories/index.js +1 -0
- package/src/components/url-popover/test/index.js +0 -2
- package/src/components/writing-flow/use-selection-observer.js +5 -1
- package/src/hooks/align.js +1 -1
- package/src/hooks/border.js +94 -225
- package/src/hooks/custom-class-name.js +4 -4
- package/src/hooks/custom-class-name.native.js +3 -4
- package/src/hooks/dimensions.js +85 -269
- package/src/hooks/duotone.js +100 -30
- package/src/hooks/gap.js +0 -208
- package/src/hooks/layout.js +38 -22
- package/src/hooks/margin.js +1 -164
- package/src/hooks/padding.js +1 -163
- package/src/hooks/supports.js +6 -0
- package/src/hooks/test/__snapshots__/align.native.js.snap +24 -24
- package/src/hooks/test/duotone.js +102 -0
- package/src/hooks/test/style.js +2 -1
- package/src/hooks/test/use-typography-props.js +2 -0
- package/src/hooks/typography.js +68 -88
- package/src/hooks/utils.js +126 -0
- package/src/layouts/constrained.js +23 -17
- package/src/layouts/flex.js +1 -0
- package/src/private-apis.js +2 -0
- package/src/store/actions.js +16 -6
- package/src/store/defaults.js +14 -1
- package/src/store/reducer.js +68 -43
- package/src/store/selectors.js +28 -4
- package/src/store/test/actions.js +4 -2
- package/src/utils/parse-css-unit-to-px.js +48 -13
- package/src/utils/test/parse-css-unit-to-px.js +13 -2
- package/tsconfig.tsbuildinfo +1 -1
- package/build/hooks/border-radius.js +0 -100
- package/build/hooks/border-radius.js.map +0 -1
- package/build/hooks/child-layout.js +0 -213
- package/build/hooks/child-layout.js.map +0 -1
- package/build/hooks/min-height.js +0 -139
- package/build/hooks/min-height.js.map +0 -1
- package/build-module/hooks/border-radius.js +0 -84
- package/build-module/hooks/border-radius.js.map +0 -1
- package/build-module/hooks/child-layout.js +0 -193
- package/build-module/hooks/child-layout.js.map +0 -1
- package/build-module/hooks/min-height.js +0 -116
- package/build-module/hooks/min-height.js.map +0 -1
- package/src/hooks/border-radius.js +0 -70
- package/src/hooks/child-layout.js +0 -195
- package/src/hooks/min-height.js +0 -104
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
-
import { createElement } from "@wordpress/element";
|
|
2
|
+
import { createElement, Fragment } from "@wordpress/element";
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* WordPress dependencies
|
|
6
6
|
*/
|
|
7
7
|
import { createBlock } from '@wordpress/blocks';
|
|
8
|
-
import { addSubmenu, moreVertical } from '@wordpress/icons';
|
|
8
|
+
import { addSubmenu, chevronUp, chevronDown, moreVertical } from '@wordpress/icons';
|
|
9
9
|
import { DropdownMenu, MenuItem, MenuGroup } from '@wordpress/components';
|
|
10
|
-
import { useDispatch } from '@wordpress/data';
|
|
10
|
+
import { useDispatch, useSelect } from '@wordpress/data';
|
|
11
11
|
import { __, sprintf } from '@wordpress/i18n';
|
|
12
12
|
/**
|
|
13
13
|
* Internal dependencies
|
|
@@ -15,6 +15,7 @@ import { __, sprintf } from '@wordpress/i18n';
|
|
|
15
15
|
|
|
16
16
|
import { store as blockEditorStore } from '../../store';
|
|
17
17
|
import BlockTitle from '../block-title';
|
|
18
|
+
import { useListViewContext } from './context';
|
|
18
19
|
const POPOVER_PROPS = {
|
|
19
20
|
className: 'block-editor-block-settings-menu__popover',
|
|
20
21
|
position: 'bottom right',
|
|
@@ -27,6 +28,10 @@ function AddSubmenuItem(_ref) {
|
|
|
27
28
|
block,
|
|
28
29
|
onClose
|
|
29
30
|
} = _ref;
|
|
31
|
+
const {
|
|
32
|
+
expandedState,
|
|
33
|
+
expand
|
|
34
|
+
} = useListViewContext();
|
|
30
35
|
const {
|
|
31
36
|
insertBlock,
|
|
32
37
|
replaceBlock,
|
|
@@ -56,6 +61,10 @@ function AddSubmenuItem(_ref) {
|
|
|
56
61
|
replaceInnerBlocks(newSubmenu.clientId, [newLink], updateSelectionOnInsert);
|
|
57
62
|
}
|
|
58
63
|
|
|
64
|
+
if (!expandedState[block.clientId]) {
|
|
65
|
+
expand(block.clientId);
|
|
66
|
+
}
|
|
67
|
+
|
|
59
68
|
onClose();
|
|
60
69
|
}
|
|
61
70
|
}, __('Add submenu link'));
|
|
@@ -67,14 +76,22 @@ export default function LeafMoreMenu(props) {
|
|
|
67
76
|
block
|
|
68
77
|
} = props;
|
|
69
78
|
const {
|
|
79
|
+
moveBlocksDown,
|
|
80
|
+
moveBlocksUp,
|
|
70
81
|
removeBlocks
|
|
71
82
|
} = useDispatch(blockEditorStore);
|
|
72
|
-
const
|
|
83
|
+
const removeLabel = sprintf(
|
|
73
84
|
/* translators: %s: block name */
|
|
74
85
|
__('Remove %s'), BlockTitle({
|
|
75
86
|
clientId,
|
|
76
87
|
maximumLength: 25
|
|
77
88
|
}));
|
|
89
|
+
const rootClientId = useSelect(select => {
|
|
90
|
+
const {
|
|
91
|
+
getBlockRootClientId
|
|
92
|
+
} = select(blockEditorStore);
|
|
93
|
+
return getBlockRootClientId(clientId);
|
|
94
|
+
}, [clientId]);
|
|
78
95
|
return createElement(DropdownMenu, _extends({
|
|
79
96
|
icon: moreVertical,
|
|
80
97
|
label: __('Options'),
|
|
@@ -85,15 +102,27 @@ export default function LeafMoreMenu(props) {
|
|
|
85
102
|
let {
|
|
86
103
|
onClose
|
|
87
104
|
} = _ref2;
|
|
88
|
-
return createElement(MenuGroup, null, createElement(
|
|
105
|
+
return createElement(Fragment, null, createElement(MenuGroup, null, createElement(MenuItem, {
|
|
106
|
+
icon: chevronUp,
|
|
107
|
+
onClick: () => {
|
|
108
|
+
moveBlocksUp([clientId], rootClientId);
|
|
109
|
+
onClose();
|
|
110
|
+
}
|
|
111
|
+
}, __('Move up')), createElement(MenuItem, {
|
|
112
|
+
icon: chevronDown,
|
|
113
|
+
onClick: () => {
|
|
114
|
+
moveBlocksDown([clientId], rootClientId);
|
|
115
|
+
onClose();
|
|
116
|
+
}
|
|
117
|
+
}, __('Move down')), createElement(AddSubmenuItem, {
|
|
89
118
|
block: block,
|
|
90
119
|
onClose: onClose
|
|
91
|
-
}), createElement(MenuItem, {
|
|
120
|
+
})), createElement(MenuGroup, null, createElement(MenuItem, {
|
|
92
121
|
onClick: () => {
|
|
93
122
|
removeBlocks([clientId], false);
|
|
94
123
|
onClose();
|
|
95
124
|
}
|
|
96
|
-
},
|
|
125
|
+
}, removeLabel)));
|
|
97
126
|
});
|
|
98
127
|
}
|
|
99
128
|
//# sourceMappingURL=leaf-more-menu.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/off-canvas-editor/leaf-more-menu.js"],"names":["createBlock","addSubmenu","moreVertical","DropdownMenu","MenuItem","MenuGroup","useDispatch","__","sprintf","store","blockEditorStore","BlockTitle","POPOVER_PROPS","className","position","variant","BLOCKS_THAT_CAN_BE_CONVERTED_TO_SUBMENU","AddSubmenuItem","block","onClose","insertBlock","replaceBlock","replaceInnerBlocks","clientId","isDisabled","includes","name","updateSelectionOnInsert","newLink","innerBlocks","length","newSubmenu","attributes","LeafMoreMenu","props","removeBlocks","
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/off-canvas-editor/leaf-more-menu.js"],"names":["createBlock","addSubmenu","chevronUp","chevronDown","moreVertical","DropdownMenu","MenuItem","MenuGroup","useDispatch","useSelect","__","sprintf","store","blockEditorStore","BlockTitle","useListViewContext","POPOVER_PROPS","className","position","variant","BLOCKS_THAT_CAN_BE_CONVERTED_TO_SUBMENU","AddSubmenuItem","block","onClose","expandedState","expand","insertBlock","replaceBlock","replaceInnerBlocks","clientId","isDisabled","includes","name","updateSelectionOnInsert","newLink","innerBlocks","length","newSubmenu","attributes","LeafMoreMenu","props","moveBlocksDown","moveBlocksUp","removeBlocks","removeLabel","maximumLength","rootClientId","select","getBlockRootClientId"],"mappings":";;;AAAA;AACA;AACA;AACA,SAASA,WAAT,QAA4B,mBAA5B;AACA,SACCC,UADD,EAECC,SAFD,EAGCC,WAHD,EAICC,YAJD,QAKO,kBALP;AAMA,SAASC,YAAT,EAAuBC,QAAvB,EAAiCC,SAAjC,QAAkD,uBAAlD;AACA,SAASC,WAAT,EAAsBC,SAAtB,QAAuC,iBAAvC;AACA,SAASC,EAAT,EAAaC,OAAb,QAA4B,iBAA5B;AAEA;AACA;AACA;;AACA,SAASC,KAAK,IAAIC,gBAAlB,QAA0C,aAA1C;AACA,OAAOC,UAAP,MAAuB,gBAAv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A,IAAI,EAAGrB,SADR;AAEC,MAAA,OAAO,EAAG,MAAM;AACfwC,QAAAA,YAAY,CAAE,CAAEb,QAAF,CAAF,EAAgBiB,YAAhB,CAAZ;AACAvB,QAAAA,OAAO;AACP;AALF,OAOGb,EAAE,CAAE,SAAF,CAPL,CADD,EAUC,cAAC,QAAD;AACC,MAAA,IAAI,EAAGP,WADR;AAEC,MAAA,OAAO,EAAG,MAAM;AACfsC,QAAAA,cAAc,CAAE,CAAEZ,QAAF,CAAF,EAAgBiB,YAAhB,CAAd;AACAvB,QAAAA,OAAO;AACP;AALF,OAOGb,EAAE,CAAE,WAAF,CAPL,CAVD,EAmBC,cAAC,cAAD;AAAgB,MAAA,KAAK,EAAGY,KAAxB;AAAgC,MAAA,OAAO,EAAGC;AAA1C,MAnBD,CADD,EAsBC,cAAC,SAAD,QACC,cAAC,QAAD;AACC,MAAA,OAAO,EAAG,MAAM;AACfoB,QAAAA,YAAY,CAAE,CAAEd,QAAF,CAAF,EAAgB,KAAhB,CAAZ;AACAN,QAAAA,OAAO;AACP;AAJF,OAMGqB,WANH,CADD,CAtBD,CADC;AAAA,GARH,CADD;AA8CA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { createBlock } from '@wordpress/blocks';\nimport {\n\taddSubmenu,\n\tchevronUp,\n\tchevronDown,\n\tmoreVertical,\n} from '@wordpress/icons';\nimport { DropdownMenu, MenuItem, MenuGroup } from '@wordpress/components';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { __, sprintf } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\nimport BlockTitle from '../block-title';\nimport { useListViewContext } from './context';\n\nconst POPOVER_PROPS = {\n\tclassName: 'block-editor-block-settings-menu__popover',\n\tposition: 'bottom right',\n\tvariant: 'toolbar',\n};\n\nconst BLOCKS_THAT_CAN_BE_CONVERTED_TO_SUBMENU = [\n\t'core/navigation-link',\n\t'core/navigation-submenu',\n];\n\nfunction AddSubmenuItem( { block, onClose } ) {\n\tconst { expandedState, expand } = useListViewContext();\n\tconst { insertBlock, replaceBlock, replaceInnerBlocks } =\n\t\tuseDispatch( blockEditorStore );\n\n\tconst clientId = block.clientId;\n\tconst isDisabled = ! BLOCKS_THAT_CAN_BE_CONVERTED_TO_SUBMENU.includes(\n\t\tblock.name\n\t);\n\treturn (\n\t\t<MenuItem\n\t\t\ticon={ addSubmenu }\n\t\t\tdisabled={ isDisabled }\n\t\t\tonClick={ () => {\n\t\t\t\tconst updateSelectionOnInsert = false;\n\t\t\t\tconst newLink = createBlock( 'core/navigation-link' );\n\n\t\t\t\tif ( block.name === 'core/navigation-submenu' ) {\n\t\t\t\t\tinsertBlock(\n\t\t\t\t\t\tnewLink,\n\t\t\t\t\t\tblock.innerBlocks.length,\n\t\t\t\t\t\tclientId,\n\t\t\t\t\t\tupdateSelectionOnInsert\n\t\t\t\t\t);\n\t\t\t\t} else {\n\t\t\t\t\t// Convert to a submenu if the block currently isn't one.\n\t\t\t\t\tconst newSubmenu = createBlock(\n\t\t\t\t\t\t'core/navigation-submenu',\n\t\t\t\t\t\tblock.attributes,\n\t\t\t\t\t\tblock.innerBlocks\n\t\t\t\t\t);\n\n\t\t\t\t\t// The following must happen as two independent actions.\n\t\t\t\t\t// Why? Because the offcanvas editor relies on the getLastInsertedBlocksClientIds\n\t\t\t\t\t// selector to determine which block is \"active\". As the UX needs the newLink to be\n\t\t\t\t\t// the \"active\" block it must be the last block to be inserted.\n\t\t\t\t\t// Therefore the Submenu is first created and **then** the newLink is inserted\n\t\t\t\t\t// thus ensuring it is the last inserted block.\n\t\t\t\t\treplaceBlock( clientId, newSubmenu );\n\n\t\t\t\t\treplaceInnerBlocks(\n\t\t\t\t\t\tnewSubmenu.clientId,\n\t\t\t\t\t\t[ newLink ],\n\t\t\t\t\t\tupdateSelectionOnInsert\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tif ( ! expandedState[ block.clientId ] ) {\n\t\t\t\t\texpand( block.clientId );\n\t\t\t\t}\n\t\t\t\tonClose();\n\t\t\t} }\n\t\t>\n\t\t\t{ __( 'Add submenu link' ) }\n\t\t</MenuItem>\n\t);\n}\n\nexport default function LeafMoreMenu( props ) {\n\tconst { clientId, block } = props;\n\n\tconst { moveBlocksDown, moveBlocksUp, removeBlocks } =\n\t\tuseDispatch( blockEditorStore );\n\n\tconst removeLabel = sprintf(\n\t\t/* translators: %s: block name */\n\t\t__( 'Remove %s' ),\n\t\tBlockTitle( { clientId, maximumLength: 25 } )\n\t);\n\n\tconst rootClientId = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getBlockRootClientId } = select( blockEditorStore );\n\n\t\t\treturn getBlockRootClientId( clientId );\n\t\t},\n\t\t[ clientId ]\n\t);\n\n\treturn (\n\t\t<DropdownMenu\n\t\t\ticon={ moreVertical }\n\t\t\tlabel={ __( 'Options' ) }\n\t\t\tclassName=\"block-editor-block-settings-menu\"\n\t\t\tpopoverProps={ POPOVER_PROPS }\n\t\t\tnoIcons\n\t\t\t{ ...props }\n\t\t>\n\t\t\t{ ( { onClose } ) => (\n\t\t\t\t<>\n\t\t\t\t\t<MenuGroup>\n\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\ticon={ chevronUp }\n\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\tmoveBlocksUp( [ clientId ], rootClientId );\n\t\t\t\t\t\t\t\tonClose();\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Move up' ) }\n\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\ticon={ chevronDown }\n\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\tmoveBlocksDown( [ clientId ], rootClientId );\n\t\t\t\t\t\t\t\tonClose();\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Move down' ) }\n\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t\t<AddSubmenuItem block={ block } onClose={ onClose } />\n\t\t\t\t\t</MenuGroup>\n\t\t\t\t\t<MenuGroup>\n\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\tremoveBlocks( [ clientId ], false );\n\t\t\t\t\t\t\t\tonClose();\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ removeLabel }\n\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t</MenuGroup>\n\t\t\t\t</>\n\t\t\t) }\n\t\t</DropdownMenu>\n\t);\n}\n"]}
|
|
@@ -77,12 +77,17 @@ export default function useBlockSync(_ref) {
|
|
|
77
77
|
resetBlocks,
|
|
78
78
|
resetSelection,
|
|
79
79
|
replaceInnerBlocks,
|
|
80
|
+
selectBlock,
|
|
80
81
|
setHasControlledInnerBlocks,
|
|
81
82
|
__unstableMarkNextChangeAsNotPersistent
|
|
82
83
|
} = registry.dispatch(blockEditorStore);
|
|
83
84
|
const {
|
|
85
|
+
hasSelectedBlock,
|
|
84
86
|
getBlockName,
|
|
85
|
-
getBlocks
|
|
87
|
+
getBlocks,
|
|
88
|
+
getSelectionStart,
|
|
89
|
+
getSelectionEnd,
|
|
90
|
+
getBlock
|
|
86
91
|
} = registry.select(blockEditorStore);
|
|
87
92
|
const isControlled = useSelect(select => {
|
|
88
93
|
return !clientId || select(blockEditorStore).areInnerBlocksControlled(clientId);
|
|
@@ -157,10 +162,21 @@ export default function useBlockSync(_ref) {
|
|
|
157
162
|
// bound sync, unset the outbound value to avoid considering it in
|
|
158
163
|
// subsequent renders.
|
|
159
164
|
pendingChanges.current.outgoing = [];
|
|
165
|
+
const hadSelecton = hasSelectedBlock();
|
|
166
|
+
const selectionAnchor = getSelectionStart();
|
|
167
|
+
const selectionFocus = getSelectionEnd();
|
|
160
168
|
setControlledBlocks();
|
|
161
169
|
|
|
162
170
|
if (controlledSelection) {
|
|
163
171
|
resetSelection(controlledSelection.selectionStart, controlledSelection.selectionEnd, controlledSelection.initialPosition);
|
|
172
|
+
} else {
|
|
173
|
+
const selectionStillExists = getBlock(selectionAnchor.clientId);
|
|
174
|
+
|
|
175
|
+
if (hadSelecton && !selectionStillExists) {
|
|
176
|
+
selectBlock(clientId);
|
|
177
|
+
} else {
|
|
178
|
+
resetSelection(selectionAnchor, selectionFocus);
|
|
179
|
+
}
|
|
164
180
|
}
|
|
165
181
|
}
|
|
166
182
|
}, [controlledBlocks, clientId]);
|
|
@@ -174,8 +190,6 @@ export default function useBlockSync(_ref) {
|
|
|
174
190
|
}, [isControlled]);
|
|
175
191
|
useEffect(() => {
|
|
176
192
|
const {
|
|
177
|
-
getSelectionStart,
|
|
178
|
-
getSelectionEnd,
|
|
179
193
|
getSelectedBlocksInitialCaretPosition,
|
|
180
194
|
isLastBlockChangePersistent,
|
|
181
195
|
__unstableIsLastBlockChangeIgnored,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/provider/use-block-sync.js"],"names":["useEffect","useRef","useRegistry","useSelect","cloneBlock","store","blockEditorStore","noop","useBlockSync","clientId","value","controlledBlocks","selection","controlledSelection","onChange","onInput","registry","resetBlocks","resetSelection","replaceInnerBlocks","setHasControlledInnerBlocks","__unstableMarkNextChangeAsNotPersistent","dispatch","getBlockName","getBlocks","select","isControlled","areInnerBlocksControlled","pendingChanges","incoming","outgoing","subscribed","setControlledBlocks","batch","storeBlocks","map","block","current","onInputRef","onChangeRef","includes","length","selectionStart","selectionEnd","initialPosition","getSelectionStart","getSelectionEnd","getSelectedBlocksInitialCaretPosition","isLastBlockChangePersistent","__unstableIsLastBlockChangeIgnored","blocks","isPersistent","previousAreBlocksDifferent","unsubscribe","subscribe","isStillControlled","newIsPersistent","newBlocks","areBlocksDifferent","didPersistenceChange","push","updateParent"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,SAAT,EAAoBC,MAApB,QAAkC,oBAAlC;AACA,SAASC,W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ADkB,GAE9BC,UAAU,CAACD,OAFd;AAGAwB,QAAAA,YAAY,CAAEX,MAAF,EAAU;AACrBtC,UAAAA,SAAS,EAAE;AACV8B,YAAAA,cAAc,EAAEG,iBAAiB,EADvB;AAEVF,YAAAA,YAAY,EAAEG,eAAe,EAFnB;AAGVF,YAAAA,eAAe,EACdG,qCAAqC;AAJ5B;AADU,SAAV,CAAZ;AAQA;;AACDK,MAAAA,0BAA0B,GAAGM,kBAA7B;AACA,KApEmB,CAApB;AAsEA,WAAO,MAAM;AACZ3B,MAAAA,UAAU,CAACM,OAAX,GAAqB,KAArB;AACAgB,MAAAA,WAAW;AACX,KAHD;AAIA,GAzFQ,EAyFN,CAAErC,QAAF,EAAYP,QAAZ,CAzFM,CAAT;AA0FA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useEffect, useRef } from '@wordpress/element';\nimport { useRegistry, useSelect } from '@wordpress/data';\nimport { cloneBlock } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\n\nconst noop = () => {};\n\n/**\n * A function to call when the block value has been updated in the block-editor\n * store.\n *\n * @callback onBlockUpdate\n * @param {Object[]} blocks The updated blocks.\n * @param {Object} options The updated block options, such as selectionStart\n * and selectionEnd.\n */\n\n/**\n * useBlockSync is a side effect which handles bidirectional sync between the\n * block-editor store and a controlling data source which provides blocks. This\n * is most commonly used by the BlockEditorProvider to synchronize the contents\n * of the block-editor store with the root entity, like a post.\n *\n * Another example would be the template part block, which provides blocks from\n * a separate entity data source than a root entity. This hook syncs edits to\n * the template part in the block editor back to the entity and vice-versa.\n *\n * Here are some of its basic functions:\n * - Initalizes the block-editor store for the given clientID to the blocks\n * given via props.\n * - Adds incoming changes (like undo) to the block-editor store.\n * - Adds outgoing changes (like editing content) to the controlling entity,\n * determining if a change should be considered persistent or not.\n * - Handles edge cases and race conditions which occur in those operations.\n * - Ignores changes which happen to other entities (like nested inner block\n * controllers.\n * - Passes selection state from the block-editor store to the controlling entity.\n *\n * @param {Object} props Props for the block sync hook\n * @param {string} props.clientId The client ID of the inner block controller.\n * If none is passed, then it is assumed to be a\n * root controller rather than an inner block\n * controller.\n * @param {Object[]} props.value The control value for the blocks. This value\n * is used to initalize the block-editor store\n * and for resetting the blocks to incoming\n * changes like undo.\n * @param {Object} props.selection The selection state responsible to restore the selection on undo/redo.\n * @param {onBlockUpdate} props.onChange Function to call when a persistent\n * change has been made in the block-editor blocks\n * for the given clientId. For example, after\n * this function is called, an entity is marked\n * dirty because it has changes to save.\n * @param {onBlockUpdate} props.onInput Function to call when a non-persistent\n * change has been made in the block-editor blocks\n * for the given clientId. When this is called,\n * controlling sources do not become dirty.\n */\nexport default function useBlockSync( {\n\tclientId = null,\n\tvalue: controlledBlocks,\n\tselection: controlledSelection,\n\tonChange = noop,\n\tonInput = noop,\n} ) {\n\tconst registry = useRegistry();\n\n\tconst {\n\t\tresetBlocks,\n\t\tresetSelection,\n\t\treplaceInnerBlocks,\n\t\tsetHasControlledInnerBlocks,\n\t\t__unstableMarkNextChangeAsNotPersistent,\n\t} = registry.dispatch( blockEditorStore );\n\tconst { getBlockName, getBlocks } = registry.select( blockEditorStore );\n\tconst isControlled = useSelect(\n\t\t( select ) => {\n\t\t\treturn (\n\t\t\t\t! clientId ||\n\t\t\t\tselect( blockEditorStore ).areInnerBlocksControlled( clientId )\n\t\t\t);\n\t\t},\n\t\t[ clientId ]\n\t);\n\n\tconst pendingChanges = useRef( { incoming: null, outgoing: [] } );\n\tconst subscribed = useRef( false );\n\n\tconst setControlledBlocks = () => {\n\t\tif ( ! controlledBlocks ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// We don't need to persist this change because we only replace\n\t\t// controlled inner blocks when the change was caused by an entity,\n\t\t// and so it would already be persisted.\n\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\tif ( clientId ) {\n\t\t\t// It is important to batch here because otherwise,\n\t\t\t// as soon as `setHasControlledInnerBlocks` is called\n\t\t\t// the effect to restore might be triggered\n\t\t\t// before the actual blocks get set properly in state.\n\t\t\tregistry.batch( () => {\n\t\t\t\tsetHasControlledInnerBlocks( clientId, true );\n\t\t\t\tconst storeBlocks = controlledBlocks.map( ( block ) =>\n\t\t\t\t\tcloneBlock( block )\n\t\t\t\t);\n\t\t\t\tif ( subscribed.current ) {\n\t\t\t\t\tpendingChanges.current.incoming = storeBlocks;\n\t\t\t\t}\n\t\t\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\t\t\treplaceInnerBlocks( clientId, storeBlocks );\n\t\t\t} );\n\t\t} else {\n\t\t\tif ( subscribed.current ) {\n\t\t\t\tpendingChanges.current.incoming = controlledBlocks;\n\t\t\t}\n\t\t\tresetBlocks( controlledBlocks );\n\t\t}\n\t};\n\n\t// Add a subscription to the block-editor registry to detect when changes\n\t// have been made. This lets us inform the data source of changes. This\n\t// is an effect so that the subscriber can run synchronously without\n\t// waiting for React renders for changes.\n\tconst onInputRef = useRef( onInput );\n\tconst onChangeRef = useRef( onChange );\n\tuseEffect( () => {\n\t\tonInputRef.current = onInput;\n\t\tonChangeRef.current = onChange;\n\t}, [ onInput, onChange ] );\n\n\t// Determine if blocks need to be reset when they change.\n\tuseEffect( () => {\n\t\tif ( pendingChanges.current.outgoing.includes( controlledBlocks ) ) {\n\t\t\t// Skip block reset if the value matches expected outbound sync\n\t\t\t// triggered by this component by a preceding change detection.\n\t\t\t// Only skip if the value matches expectation, since a reset should\n\t\t\t// still occur if the value is modified (not equal by reference),\n\t\t\t// to allow that the consumer may apply modifications to reflect\n\t\t\t// back on the editor.\n\t\t\tif (\n\t\t\t\tpendingChanges.current.outgoing[\n\t\t\t\t\tpendingChanges.current.outgoing.length - 1\n\t\t\t\t] === controlledBlocks\n\t\t\t) {\n\t\t\t\tpendingChanges.current.outgoing = [];\n\t\t\t}\n\t\t} else if ( getBlocks( clientId ) !== controlledBlocks ) {\n\t\t\t// Reset changing value in all other cases than the sync described\n\t\t\t// above. Since this can be reached in an update following an out-\n\t\t\t// bound sync, unset the outbound value to avoid considering it in\n\t\t\t// subsequent renders.\n\t\t\tpendingChanges.current.outgoing = [];\n\t\t\tsetControlledBlocks();\n\n\t\t\tif ( controlledSelection ) {\n\t\t\t\tresetSelection(\n\t\t\t\t\tcontrolledSelection.selectionStart,\n\t\t\t\t\tcontrolledSelection.selectionEnd,\n\t\t\t\t\tcontrolledSelection.initialPosition\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t}, [ controlledBlocks, clientId ] );\n\n\tuseEffect( () => {\n\t\t// When the block becomes uncontrolled, it means its inner state has been reset\n\t\t// we need to take the blocks again from the external value property.\n\t\tif ( ! isControlled ) {\n\t\t\tpendingChanges.current.outgoing = [];\n\t\t\tsetControlledBlocks();\n\t\t}\n\t}, [ isControlled ] );\n\n\tuseEffect( () => {\n\t\tconst {\n\t\t\tgetSelectionStart,\n\t\t\tgetSelectionEnd,\n\t\t\tgetSelectedBlocksInitialCaretPosition,\n\t\t\tisLastBlockChangePersistent,\n\t\t\t__unstableIsLastBlockChangeIgnored,\n\t\t\tareInnerBlocksControlled,\n\t\t} = registry.select( blockEditorStore );\n\n\t\tlet blocks = getBlocks( clientId );\n\t\tlet isPersistent = isLastBlockChangePersistent();\n\t\tlet previousAreBlocksDifferent = false;\n\n\t\tsubscribed.current = true;\n\t\tconst unsubscribe = registry.subscribe( () => {\n\t\t\t// Sometimes, when changing block lists, lingering subscriptions\n\t\t\t// might trigger before they are cleaned up. If the block for which\n\t\t\t// the subscription runs is no longer in the store, this would clear\n\t\t\t// its parent entity's block list. To avoid this, we bail out if\n\t\t\t// the subscription is triggering for a block (`clientId !== null`)\n\t\t\t// and its block name can't be found because it's not on the list.\n\t\t\t// (`getBlockName( clientId ) === null`).\n\t\t\tif ( clientId !== null && getBlockName( clientId ) === null )\n\t\t\t\treturn;\n\n\t\t\t// When RESET_BLOCKS on parent blocks get called, the controlled blocks\n\t\t\t// can reset to uncontrolled, in these situations, it means we need to populate\n\t\t\t// the blocks again from the external blocks (the value property here)\n\t\t\t// and we should stop triggering onChange\n\t\t\tconst isStillControlled =\n\t\t\t\t! clientId || areInnerBlocksControlled( clientId );\n\t\t\tif ( ! isStillControlled ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst newIsPersistent = isLastBlockChangePersistent();\n\t\t\tconst newBlocks = getBlocks( clientId );\n\t\t\tconst areBlocksDifferent = newBlocks !== blocks;\n\t\t\tblocks = newBlocks;\n\n\t\t\tif (\n\t\t\t\tareBlocksDifferent &&\n\t\t\t\t( pendingChanges.current.incoming ||\n\t\t\t\t\t__unstableIsLastBlockChangeIgnored() )\n\t\t\t) {\n\t\t\t\tpendingChanges.current.incoming = null;\n\t\t\t\tisPersistent = newIsPersistent;\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// Since we often dispatch an action to mark the previous action as\n\t\t\t// persistent, we need to make sure that the blocks changed on the\n\t\t\t// previous action before committing the change.\n\t\t\tconst didPersistenceChange =\n\t\t\t\tpreviousAreBlocksDifferent &&\n\t\t\t\t! areBlocksDifferent &&\n\t\t\t\tnewIsPersistent &&\n\t\t\t\t! isPersistent;\n\n\t\t\tif ( areBlocksDifferent || didPersistenceChange ) {\n\t\t\t\tisPersistent = newIsPersistent;\n\t\t\t\t// We know that onChange/onInput will update controlledBlocks.\n\t\t\t\t// We need to be aware that it was caused by an outgoing change\n\t\t\t\t// so that we do not treat it as an incoming change later on,\n\t\t\t\t// which would cause a block reset.\n\t\t\t\tpendingChanges.current.outgoing.push( blocks );\n\n\t\t\t\t// Inform the controlling entity that changes have been made to\n\t\t\t\t// the block-editor store they should be aware about.\n\t\t\t\tconst updateParent = isPersistent\n\t\t\t\t\t? onChangeRef.current\n\t\t\t\t\t: onInputRef.current;\n\t\t\t\tupdateParent( blocks, {\n\t\t\t\t\tselection: {\n\t\t\t\t\t\tselectionStart: getSelectionStart(),\n\t\t\t\t\t\tselectionEnd: getSelectionEnd(),\n\t\t\t\t\t\tinitialPosition:\n\t\t\t\t\t\t\tgetSelectedBlocksInitialCaretPosition(),\n\t\t\t\t\t},\n\t\t\t\t} );\n\t\t\t}\n\t\t\tpreviousAreBlocksDifferent = areBlocksDifferent;\n\t\t} );\n\n\t\treturn () => {\n\t\t\tsubscribed.current = false;\n\t\t\tunsubscribe();\n\t\t};\n\t}, [ registry, clientId ] );\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/provider/use-block-sync.js"],"names":["useEffect","useRef","useRegistry","useSelect","cloneBlock","store","blockEditorStore","noop","useBlockSync","clientId","value","controlledBlocks","selection","controlledSelection","onChange","onInput","registry","resetBlocks","resetSelection","replaceInnerBlocks","selectBlock","setHasControlledInnerBlocks","__unstableMarkNextChangeAsNotPersistent","dispatch","hasSelectedBlock","getBlockName","getBlocks","getSelectionStart","getSelectionEnd","getBlock","select","isControlled","areInnerBlocksControlled","pendingChanges","incoming","outgoing","subscribed","setControlledBlocks","batch","storeBlocks","map","block","current","onInputRef","onChangeRef","includes","length","hadSelecton","selectionAnchor","selectionFocus","selectionStart","selectionEnd","initialPosition","selectionStillExists","getSelectedBlocksInitialCaretPosition","isLastBlockChangePersistent","__unstableIsLastBlockChangeIgnored","blocks","isPersistent","previousAreBlocksDifferent","unsubscribe","subscribe","isStillControlled","newIsPersistent","newBlocks","areBlocksDifferent","didPersistenceChange","push","updateParent"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,SAAT,EAAoBC,MAApB,QAAkC,oBAAlC;AACA,SAASC,WAAT,EAAsBC,SAAtB,QAAuC,iBAAvC;AACA,SAASC,UAAT,QAA2B,mBAA3B;AAEA;AACA;AACA;;AACA,SAASC,KAAK,IAAIC,gBAAlB,QAA0C,aAA1C;;AAEA,MAAMC,IAAI,GAAG,MAAM,CAAE,CAArB;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAC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vB,CAAgCgC,IAAhC,CAAsCV,MAAtC,EANiD,CAQjD;AACA;;AACA,cAAMW,YAAY,GAAGV,YAAY,GAC9Bd,WAAW,CAACF,OADkB,GAE9BC,UAAU,CAACD,OAFd;AAGA0B,QAAAA,YAAY,CAAEX,MAAF,EAAU;AACrB7C,UAAAA,SAAS,EAAE;AACVsC,YAAAA,cAAc,EAAEvB,iBAAiB,EADvB;AAEVwB,YAAAA,YAAY,EAAEvB,eAAe,EAFnB;AAGVwB,YAAAA,eAAe,EACdE,qCAAqC;AAJ5B;AADU,SAAV,CAAZ;AAQA;;AACDK,MAAAA,0BAA0B,GAAGM,kBAA7B;AACA,KAnEmB,CAApB;AAqEA,WAAO,MAAM;AACZ7B,MAAAA,UAAU,CAACM,OAAX,GAAqB,KAArB;AACAkB,MAAAA,WAAW;AACX,KAHD;AAIA,GAtFQ,EAsFN,CAAE5C,QAAF,EAAYP,QAAZ,CAtFM,CAAT;AAuFA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useEffect, useRef } from '@wordpress/element';\nimport { useRegistry, useSelect } from '@wordpress/data';\nimport { cloneBlock } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\n\nconst noop = () => {};\n\n/**\n * A function to call when the block value has been updated in the block-editor\n * store.\n *\n * @callback onBlockUpdate\n * @param {Object[]} blocks The updated blocks.\n * @param {Object} options The updated block options, such as selectionStart\n * and selectionEnd.\n */\n\n/**\n * useBlockSync is a side effect which handles bidirectional sync between the\n * block-editor store and a controlling data source which provides blocks. This\n * is most commonly used by the BlockEditorProvider to synchronize the contents\n * of the block-editor store with the root entity, like a post.\n *\n * Another example would be the template part block, which provides blocks from\n * a separate entity data source than a root entity. This hook syncs edits to\n * the template part in the block editor back to the entity and vice-versa.\n *\n * Here are some of its basic functions:\n * - Initalizes the block-editor store for the given clientID to the blocks\n * given via props.\n * - Adds incoming changes (like undo) to the block-editor store.\n * - Adds outgoing changes (like editing content) to the controlling entity,\n * determining if a change should be considered persistent or not.\n * - Handles edge cases and race conditions which occur in those operations.\n * - Ignores changes which happen to other entities (like nested inner block\n * controllers.\n * - Passes selection state from the block-editor store to the controlling entity.\n *\n * @param {Object} props Props for the block sync hook\n * @param {string} props.clientId The client ID of the inner block controller.\n * If none is passed, then it is assumed to be a\n * root controller rather than an inner block\n * controller.\n * @param {Object[]} props.value The control value for the blocks. This value\n * is used to initalize the block-editor store\n * and for resetting the blocks to incoming\n * changes like undo.\n * @param {Object} props.selection The selection state responsible to restore the selection on undo/redo.\n * @param {onBlockUpdate} props.onChange Function to call when a persistent\n * change has been made in the block-editor blocks\n * for the given clientId. For example, after\n * this function is called, an entity is marked\n * dirty because it has changes to save.\n * @param {onBlockUpdate} props.onInput Function to call when a non-persistent\n * change has been made in the block-editor blocks\n * for the given clientId. When this is called,\n * controlling sources do not become dirty.\n */\nexport default function useBlockSync( {\n\tclientId = null,\n\tvalue: controlledBlocks,\n\tselection: controlledSelection,\n\tonChange = noop,\n\tonInput = noop,\n} ) {\n\tconst registry = useRegistry();\n\n\tconst {\n\t\tresetBlocks,\n\t\tresetSelection,\n\t\treplaceInnerBlocks,\n\t\tselectBlock,\n\t\tsetHasControlledInnerBlocks,\n\t\t__unstableMarkNextChangeAsNotPersistent,\n\t} = registry.dispatch( blockEditorStore );\n\tconst {\n\t\thasSelectedBlock,\n\t\tgetBlockName,\n\t\tgetBlocks,\n\t\tgetSelectionStart,\n\t\tgetSelectionEnd,\n\t\tgetBlock,\n\t} = registry.select( blockEditorStore );\n\tconst isControlled = useSelect(\n\t\t( select ) => {\n\t\t\treturn (\n\t\t\t\t! clientId ||\n\t\t\t\tselect( blockEditorStore ).areInnerBlocksControlled( clientId )\n\t\t\t);\n\t\t},\n\t\t[ clientId ]\n\t);\n\n\tconst pendingChanges = useRef( { incoming: null, outgoing: [] } );\n\tconst subscribed = useRef( false );\n\n\tconst setControlledBlocks = () => {\n\t\tif ( ! controlledBlocks ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// We don't need to persist this change because we only replace\n\t\t// controlled inner blocks when the change was caused by an entity,\n\t\t// and so it would already be persisted.\n\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\tif ( clientId ) {\n\t\t\t// It is important to batch here because otherwise,\n\t\t\t// as soon as `setHasControlledInnerBlocks` is called\n\t\t\t// the effect to restore might be triggered\n\t\t\t// before the actual blocks get set properly in state.\n\t\t\tregistry.batch( () => {\n\t\t\t\tsetHasControlledInnerBlocks( clientId, true );\n\t\t\t\tconst storeBlocks = controlledBlocks.map( ( block ) =>\n\t\t\t\t\tcloneBlock( block )\n\t\t\t\t);\n\t\t\t\tif ( subscribed.current ) {\n\t\t\t\t\tpendingChanges.current.incoming = storeBlocks;\n\t\t\t\t}\n\t\t\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\t\t\treplaceInnerBlocks( clientId, storeBlocks );\n\t\t\t} );\n\t\t} else {\n\t\t\tif ( subscribed.current ) {\n\t\t\t\tpendingChanges.current.incoming = controlledBlocks;\n\t\t\t}\n\t\t\tresetBlocks( controlledBlocks );\n\t\t}\n\t};\n\n\t// Add a subscription to the block-editor registry to detect when changes\n\t// have been made. This lets us inform the data source of changes. This\n\t// is an effect so that the subscriber can run synchronously without\n\t// waiting for React renders for changes.\n\tconst onInputRef = useRef( onInput );\n\tconst onChangeRef = useRef( onChange );\n\tuseEffect( () => {\n\t\tonInputRef.current = onInput;\n\t\tonChangeRef.current = onChange;\n\t}, [ onInput, onChange ] );\n\n\t// Determine if blocks need to be reset when they change.\n\tuseEffect( () => {\n\t\tif ( pendingChanges.current.outgoing.includes( controlledBlocks ) ) {\n\t\t\t// Skip block reset if the value matches expected outbound sync\n\t\t\t// triggered by this component by a preceding change detection.\n\t\t\t// Only skip if the value matches expectation, since a reset should\n\t\t\t// still occur if the value is modified (not equal by reference),\n\t\t\t// to allow that the consumer may apply modifications to reflect\n\t\t\t// back on the editor.\n\t\t\tif (\n\t\t\t\tpendingChanges.current.outgoing[\n\t\t\t\t\tpendingChanges.current.outgoing.length - 1\n\t\t\t\t] === controlledBlocks\n\t\t\t) {\n\t\t\t\tpendingChanges.current.outgoing = [];\n\t\t\t}\n\t\t} else if ( getBlocks( clientId ) !== controlledBlocks ) {\n\t\t\t// Reset changing value in all other cases than the sync described\n\t\t\t// above. Since this can be reached in an update following an out-\n\t\t\t// bound sync, unset the outbound value to avoid considering it in\n\t\t\t// subsequent renders.\n\t\t\tpendingChanges.current.outgoing = [];\n\t\t\tconst hadSelecton = hasSelectedBlock();\n\t\t\tconst selectionAnchor = getSelectionStart();\n\t\t\tconst selectionFocus = getSelectionEnd();\n\t\t\tsetControlledBlocks();\n\n\t\t\tif ( controlledSelection ) {\n\t\t\t\tresetSelection(\n\t\t\t\t\tcontrolledSelection.selectionStart,\n\t\t\t\t\tcontrolledSelection.selectionEnd,\n\t\t\t\t\tcontrolledSelection.initialPosition\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\tconst selectionStillExists = getBlock(\n\t\t\t\t\tselectionAnchor.clientId\n\t\t\t\t);\n\t\t\t\tif ( hadSelecton && ! selectionStillExists ) {\n\t\t\t\t\tselectBlock( clientId );\n\t\t\t\t} else {\n\t\t\t\t\tresetSelection( selectionAnchor, selectionFocus );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}, [ controlledBlocks, clientId ] );\n\n\tuseEffect( () => {\n\t\t// When the block becomes uncontrolled, it means its inner state has been reset\n\t\t// we need to take the blocks again from the external value property.\n\t\tif ( ! isControlled ) {\n\t\t\tpendingChanges.current.outgoing = [];\n\t\t\tsetControlledBlocks();\n\t\t}\n\t}, [ isControlled ] );\n\n\tuseEffect( () => {\n\t\tconst {\n\t\t\tgetSelectedBlocksInitialCaretPosition,\n\t\t\tisLastBlockChangePersistent,\n\t\t\t__unstableIsLastBlockChangeIgnored,\n\t\t\tareInnerBlocksControlled,\n\t\t} = registry.select( blockEditorStore );\n\n\t\tlet blocks = getBlocks( clientId );\n\t\tlet isPersistent = isLastBlockChangePersistent();\n\t\tlet previousAreBlocksDifferent = false;\n\n\t\tsubscribed.current = true;\n\t\tconst unsubscribe = registry.subscribe( () => {\n\t\t\t// Sometimes, when changing block lists, lingering subscriptions\n\t\t\t// might trigger before they are cleaned up. If the block for which\n\t\t\t// the subscription runs is no longer in the store, this would clear\n\t\t\t// its parent entity's block list. To avoid this, we bail out if\n\t\t\t// the subscription is triggering for a block (`clientId !== null`)\n\t\t\t// and its block name can't be found because it's not on the list.\n\t\t\t// (`getBlockName( clientId ) === null`).\n\t\t\tif ( clientId !== null && getBlockName( clientId ) === null )\n\t\t\t\treturn;\n\n\t\t\t// When RESET_BLOCKS on parent blocks get called, the controlled blocks\n\t\t\t// can reset to uncontrolled, in these situations, it means we need to populate\n\t\t\t// the blocks again from the external blocks (the value property here)\n\t\t\t// and we should stop triggering onChange\n\t\t\tconst isStillControlled =\n\t\t\t\t! clientId || areInnerBlocksControlled( clientId );\n\t\t\tif ( ! isStillControlled ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst newIsPersistent = isLastBlockChangePersistent();\n\t\t\tconst newBlocks = getBlocks( clientId );\n\t\t\tconst areBlocksDifferent = newBlocks !== blocks;\n\t\t\tblocks = newBlocks;\n\t\t\tif (\n\t\t\t\tareBlocksDifferent &&\n\t\t\t\t( pendingChanges.current.incoming ||\n\t\t\t\t\t__unstableIsLastBlockChangeIgnored() )\n\t\t\t) {\n\t\t\t\tpendingChanges.current.incoming = null;\n\t\t\t\tisPersistent = newIsPersistent;\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// Since we often dispatch an action to mark the previous action as\n\t\t\t// persistent, we need to make sure that the blocks changed on the\n\t\t\t// previous action before committing the change.\n\t\t\tconst didPersistenceChange =\n\t\t\t\tpreviousAreBlocksDifferent &&\n\t\t\t\t! areBlocksDifferent &&\n\t\t\t\tnewIsPersistent &&\n\t\t\t\t! isPersistent;\n\n\t\t\tif ( areBlocksDifferent || didPersistenceChange ) {\n\t\t\t\tisPersistent = newIsPersistent;\n\t\t\t\t// We know that onChange/onInput will update controlledBlocks.\n\t\t\t\t// We need to be aware that it was caused by an outgoing change\n\t\t\t\t// so that we do not treat it as an incoming change later on,\n\t\t\t\t// which would cause a block reset.\n\t\t\t\tpendingChanges.current.outgoing.push( blocks );\n\n\t\t\t\t// Inform the controlling entity that changes have been made to\n\t\t\t\t// the block-editor store they should be aware about.\n\t\t\t\tconst updateParent = isPersistent\n\t\t\t\t\t? onChangeRef.current\n\t\t\t\t\t: onInputRef.current;\n\t\t\t\tupdateParent( blocks, {\n\t\t\t\t\tselection: {\n\t\t\t\t\t\tselectionStart: getSelectionStart(),\n\t\t\t\t\t\tselectionEnd: getSelectionEnd(),\n\t\t\t\t\t\tinitialPosition:\n\t\t\t\t\t\t\tgetSelectedBlocksInitialCaretPosition(),\n\t\t\t\t\t},\n\t\t\t\t} );\n\t\t\t}\n\t\t\tpreviousAreBlocksDifferent = areBlocksDifferent;\n\t\t} );\n\n\t\treturn () => {\n\t\t\tsubscribed.current = false;\n\t\t\tunsubscribe();\n\t\t};\n\t}, [ registry, clientId ] );\n}\n"]}
|
|
@@ -76,6 +76,7 @@ function ResponsiveBlockControl(props) {
|
|
|
76
76
|
}, title), createElement("div", {
|
|
77
77
|
className: "block-editor-responsive-block-control__inner"
|
|
78
78
|
}, createElement(ToggleControl, {
|
|
79
|
+
__nextHasNoMarginBottom: true,
|
|
79
80
|
className: "block-editor-responsive-block-control__toggle",
|
|
80
81
|
label: toggleControlLabel,
|
|
81
82
|
checked: !isResponsive,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/responsive-block-control/index.js"],"names":["classnames","__","sprintf","Fragment","ToggleControl","ResponsiveBlockControlLabel","ResponsiveBlockControl","props","title","property","toggleLabel","onIsResponsiveChange","renderDefaultControl","renderResponsiveControls","isResponsive","defaultLabel","id","label","viewports","toggleControlLabel","toggleHelpText","defaultControl","defaultResponsiveControls","map","viewport"],"mappings":";;AAAA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Z;AAEC,IAAA,QAAQ,EAAGM;AAFZ,IAD0C,EAK1CA,YAL0C,CAA3C;;AAQA,QAAMO,yBAAyB,GAAG,MAAM;AACvC,WAAOJ,SAAS,CAACK,GAAV,CAAiBC,QAAF,IACrB,cAAC,QAAD;AAAU,MAAA,GAAG,EAAGA,QAAQ,CAACR;AAAzB,OACGJ,oBAAoB,CACrB,cAAC,2BAAD;AACC,MAAA,QAAQ,EAAGH,QADZ;AAEC,MAAA,QAAQ,EAAGe;AAFZ,MADqB,EAKrBA,QALqB,CADvB,CADM,CAAP;AAWA,GAZD;;AAcA,SACC;AAAU,IAAA,SAAS,EAAC;AAApB,KACC;AAAQ,IAAA,SAAS,EAAC;AAAlB,KACGhB,KADH,CADD,EAKC;AAAK,IAAA,SAAS,EAAC;AAAf,KACC,cAAC,aAAD;AACC,IAAA,SAAS,EAAC,+
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/responsive-block-control/index.js"],"names":["classnames","__","sprintf","Fragment","ToggleControl","ResponsiveBlockControlLabel","ResponsiveBlockControl","props","title","property","toggleLabel","onIsResponsiveChange","renderDefaultControl","renderResponsiveControls","isResponsive","defaultLabel","id","label","viewports","toggleControlLabel","toggleHelpText","defaultControl","defaultResponsiveControls","map","viewport"],"mappings":";;AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,YAAvB;AAEA;AACA;AACA;;AACA,SAASC,EAAT,EAAaC,OAAb,QAA4B,iBAA5B;AACA,SAASC,QAAT,QAAyB,oBAAzB;AACA,SAASC,aAAT,QAA8B,uBAA9B;AAEA;AACA;AACA;;AACA,OAAOC,2BAAP,MAAwC,SAAxC;;AAEA,SAASC,sBAAT,CAAiCC,KAAjC,EAAyC;AACxC,QAAM;AACLC,IAAAA,KADK;AAELC,IAAAA,QAFK;AAGLC,IAAAA,WAHK;AAILC,IAAAA,oBAJK;AAKLC,IAAAA,oBALK;AAMLC,IAAAA,wBANK;AAOLC,IAAAA,YAAY,GAAG,KAPV;AAQ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C;AAAlB,KACGhB,KADH,CADD,EAKC;AAAK,IAAA,SAAS,EAAC;AAAf,KACC,cAAC,aAAD;AACC,IAAA,uBAAuB,MADxB;AAEC,IAAA,SAAS,EAAC,+CAFX;AAGC,IAAA,KAAK,EAAGW,kBAHT;AAIC,IAAA,OAAO,EAAG,CAAEL,YAJb;AAKC,IAAA,QAAQ,EAAGH,oBALZ;AAMC,IAAA,IAAI,EAAGS;AANR,IADD,EASC;AACC,IAAA,SAAS,EAAGpB,UAAU,CACrB,8CADqB,EAErB;AACC,uBAAiBc;AADlB,KAFqB;AADvB,KAQG,CAAEA,YAAF,IAAkBO,cARrB,EASGP,YAAY,KACXD,wBAAwB,GACvBA,wBAAwB,CAAEK,SAAF,CADD,GAEvBI,yBAAyB,EAHf,CATf,CATD,CALD,CADD;AAgCA;;AAED,eAAehB,sBAAf","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { __, sprintf } from '@wordpress/i18n';\nimport { Fragment } from '@wordpress/element';\nimport { ToggleControl } from '@wordpress/components';\n\n/**\n * Internal dependencies\n */\nimport ResponsiveBlockControlLabel from './label';\n\nfunction ResponsiveBlockControl( props ) {\n\tconst {\n\t\ttitle,\n\t\tproperty,\n\t\ttoggleLabel,\n\t\tonIsResponsiveChange,\n\t\trenderDefaultControl,\n\t\trenderResponsiveControls,\n\t\tisResponsive = false,\n\t\tdefaultLabel = {\n\t\t\tid: 'all',\n\t\t\t/* translators: 'Label. Used to signify a layout property (eg: margin, padding) will apply uniformly to all screensizes.' */\n\t\t\tlabel: __( 'All' ),\n\t\t},\n\t\tviewports = [\n\t\t\t{\n\t\t\t\tid: 'small',\n\t\t\t\tlabel: __( 'Small screens' ),\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: 'medium',\n\t\t\t\tlabel: __( 'Medium screens' ),\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: 'large',\n\t\t\t\tlabel: __( 'Large screens' ),\n\t\t\t},\n\t\t],\n\t} = props;\n\n\tif ( ! title || ! property || ! renderDefaultControl ) {\n\t\treturn null;\n\t}\n\n\tconst toggleControlLabel =\n\t\ttoggleLabel ||\n\t\tsprintf(\n\t\t\t/* translators: 'Toggle control label. Should the property be the same across all screen sizes or unique per screen size.'. %s property value for the control (eg: margin, padding...etc) */\n\t\t\t__( 'Use the same %s on all screensizes.' ),\n\t\t\tproperty\n\t\t);\n\n\t/* translators: 'Help text for the responsive mode toggle control.' */\n\tconst toggleHelpText = __(\n\t\t'Toggle between using the same value for all screen sizes or using a unique value per screen size.'\n\t);\n\n\tconst defaultControl = renderDefaultControl(\n\t\t<ResponsiveBlockControlLabel\n\t\t\tproperty={ property }\n\t\t\tviewport={ defaultLabel }\n\t\t/>,\n\t\tdefaultLabel\n\t);\n\n\tconst defaultResponsiveControls = () => {\n\t\treturn viewports.map( ( viewport ) => (\n\t\t\t<Fragment key={ viewport.id }>\n\t\t\t\t{ renderDefaultControl(\n\t\t\t\t\t<ResponsiveBlockControlLabel\n\t\t\t\t\t\tproperty={ property }\n\t\t\t\t\t\tviewport={ viewport }\n\t\t\t\t\t/>,\n\t\t\t\t\tviewport\n\t\t\t\t) }\n\t\t\t</Fragment>\n\t\t) );\n\t};\n\n\treturn (\n\t\t<fieldset className=\"block-editor-responsive-block-control\">\n\t\t\t<legend className=\"block-editor-responsive-block-control__title\">\n\t\t\t\t{ title }\n\t\t\t</legend>\n\n\t\t\t<div className=\"block-editor-responsive-block-control__inner\">\n\t\t\t\t<ToggleControl\n\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\tclassName=\"block-editor-responsive-block-control__toggle\"\n\t\t\t\t\tlabel={ toggleControlLabel }\n\t\t\t\t\tchecked={ ! isResponsive }\n\t\t\t\t\tonChange={ onIsResponsiveChange }\n\t\t\t\t\thelp={ toggleHelpText }\n\t\t\t\t/>\n\t\t\t\t<div\n\t\t\t\t\tclassName={ classnames(\n\t\t\t\t\t\t'block-editor-responsive-block-control__group',\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t'is-responsive': isResponsive,\n\t\t\t\t\t\t}\n\t\t\t\t\t) }\n\t\t\t\t>\n\t\t\t\t\t{ ! isResponsive && defaultControl }\n\t\t\t\t\t{ isResponsive &&\n\t\t\t\t\t\t( renderResponsiveControls\n\t\t\t\t\t\t\t? renderResponsiveControls( viewports )\n\t\t\t\t\t\t\t: defaultResponsiveControls() ) }\n\t\t\t\t</div>\n\t\t\t</div>\n\t\t</fieldset>\n\t);\n}\n\nexport default ResponsiveBlockControl;\n"]}
|
|
@@ -18,7 +18,6 @@ import { store as blockEditorStore } from '../../store';
|
|
|
18
18
|
|
|
19
19
|
function InlineSelectionToolbar(_ref) {
|
|
20
20
|
let {
|
|
21
|
-
value,
|
|
22
21
|
editableContentElement,
|
|
23
22
|
activeFormats
|
|
24
23
|
} = _ref;
|
|
@@ -27,7 +26,6 @@ function InlineSelectionToolbar(_ref) {
|
|
|
27
26
|
const settings = useSelect(select => select(richTextStore).getFormatType(lastFormatType), [lastFormatType]);
|
|
28
27
|
const popoverAnchor = useAnchor({
|
|
29
28
|
editableContentElement,
|
|
30
|
-
value,
|
|
31
29
|
settings
|
|
32
30
|
});
|
|
33
31
|
return createElement(InlineToolbar, {
|
|
@@ -76,7 +74,6 @@ const FormatToolbarContainer = _ref3 => {
|
|
|
76
74
|
|
|
77
75
|
return createElement(InlineSelectionToolbar, {
|
|
78
76
|
editableContentElement: editableContentElement,
|
|
79
|
-
value: value,
|
|
80
77
|
activeFormats: activeFormats
|
|
81
78
|
});
|
|
82
79
|
} // Render regular toolbar.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/rich-text/format-toolbar-container.js"],"names":["__","Popover","ToolbarGroup","useSelect","isCollapsed","getActiveFormats","useAnchor","store","richTextStore","BlockControls","FormatToolbar","NavigableToolbar","blockEditorStore","InlineSelectionToolbar","
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/rich-text/format-toolbar-container.js"],"names":["__","Popover","ToolbarGroup","useSelect","isCollapsed","getActiveFormats","useAnchor","store","richTextStore","BlockControls","FormatToolbar","NavigableToolbar","blockEditorStore","InlineSelectionToolbar","editableContentElement","activeFormats","lastFormat","length","lastFormatType","type","settings","select","getFormatType","popoverAnchor","InlineToolbar","FormatToolbarContainer","inline","value","hasInlineToolbar","getSettings"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,EAAT,QAAmB,iBAAnB;AACA,SAASC,OAAT,EAAkBC,YAAlB,QAAsC,uBAAtC;AACA,SAASC,SAAT,QAA0B,iBAA1B;AACA,SACCC,WADD,EAECC,gBAFD,EAGCC,SAHD,EAICC,KAAK,IAAIC,aAJV,QAKO,sBALP;AAOA;AACA;AACA;;AACA,OAAOC,aAAP,MAA0B,mBAA1B;AACA,OAAOC,aAAP,MAA0B,kBAA1B;AACA,OAAOC,gBAAP,MAA6B,sBAA7B;AACA,SAASJ,KAAK,IAAIK,gBAAlB,QAA0C,aAA1C;;AAEA,SAASC,sBAAT,OAA6E;AAAA,MAA5C;AAAEC,IAAAA,sBAAF;AAA0BC,IAAAA;AAA1B,GAA4C;AAC5E,QAAMC,UAAU,GAAGD,aAAa,CAAEA,aAAa,CAACE,MAAd,GAAuB,CAAzB,CAAhC;AACA,QAAMC,cAAc,GAAGF,UAAH,aAAGA,UAAH,uBAAGA,UAAU,CAAEG,IAAnC;AACA,QAAMC,QAAQ,GAAGjB,SAAS,CACvBkB,MAAF,IAAcA,MAAM,CAAEb,aAAF,CAAN,CAAwBc,aAAxB,CAAuCJ,cAAvC,CADW,EAEzB,CAAEA,cAAF,CAFyB,CAA1B;AAIA,QAAMK,aAAa,GAAGjB,SAAS,CAAE;AAChCQ,IAAAA,sBADgC;AAEhCM,IAAAA;AAFgC,GAAF,CAA/B;AAKA,SAAO,cAAC,aAAD;AAAe,IAAA,aAAa,EAAGG;AAA/B,IAAP;AACA;;AAED,SAASC,aAAT,QAA4C;AAAA,MAApB;AAAED,IAAAA;AAAF,GAAoB;AAC3C,SACC,cAAC,OAAD;AACC,IAAA,SAAS,EAAC,KADX;AAEC,IAAA,YAAY,EAAG,KAFhB;AAGC,IAAA,MAAM,EAAGA,aAHV;AAIC,IAAA,SAAS,EAAC,+CAJX;AAKC,IAAA,kBAAkB,EAAC;AALpB,KAOC,cAAC,gBAAD;AACC,IAAA,SAAS,EAAC;AACV;AAFD;AAGC,kBAAavB,EAAE,CAAE,cAAF;AAHhB,KAKC,cAAC,YAAD,QACC,cAAC,aAAD,OADD,CALD,CAPD,CADD;AAmBA;;AAED,MAAMyB,sBAAsB,GAAG,SAIxB;AAAA,MAJ0B;AAChCC,IAAAA,MADgC;AAEhCZ,IAAAA,sBAFgC;AAGhCa,IAAAA;AAHgC,GAI1B;AACN,QAAMC,gBAAgB,GAAGzB,SAAS,CAC/BkB,MAAF,IAAcA,MAAM,CAAET,gBAAF,CAAN,CAA2BiB,WAA3B,GAAyCD,gBADtB,EAEjC,EAFiC,CAAlC;;AAKA,MAAKF,MAAL,EAAc;AACb,WAAO,cAAC,aAAD;AAAe,MAAA,aAAa,EAAGZ;AAA/B,MAAP;AACA;;AAED,MAAKc,gBAAL,EAAwB;AACvB,UAAMb,aAAa,GAAGV,gBAAgB,CAAEsB,KAAF,CAAtC;;AAEA,QAAKvB,WAAW,CAAEuB,KAAF,CAAX,IAAwB,CAAEZ,aAAa,CAACE,MAA7C,EAAsD;AACrD,aAAO,IAAP;AACA;;AAED,WACC,cAAC,sBAAD;AACC,MAAA,sBAAsB,EAAGH,sBAD1B;AAEC,MAAA,aAAa,EAAGC;AAFjB,MADD;AAMA,GAvBK,CAyBN;;;AACA,SACC,cAAC,aAAD;AAAe,IAAA,KAAK,EAAC;AAArB,KACC,cAAC,aAAD,OADD,CADD;AAKA,CAnCD;;AAqCA,eAAeU,sBAAf","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { Popover, ToolbarGroup } from '@wordpress/components';\nimport { useSelect } from '@wordpress/data';\nimport {\n\tisCollapsed,\n\tgetActiveFormats,\n\tuseAnchor,\n\tstore as richTextStore,\n} from '@wordpress/rich-text';\n\n/**\n * Internal dependencies\n */\nimport BlockControls from '../block-controls';\nimport FormatToolbar from './format-toolbar';\nimport NavigableToolbar from '../navigable-toolbar';\nimport { store as blockEditorStore } from '../../store';\n\nfunction InlineSelectionToolbar( { editableContentElement, activeFormats } ) {\n\tconst lastFormat = activeFormats[ activeFormats.length - 1 ];\n\tconst lastFormatType = lastFormat?.type;\n\tconst settings = useSelect(\n\t\t( select ) => select( richTextStore ).getFormatType( lastFormatType ),\n\t\t[ lastFormatType ]\n\t);\n\tconst popoverAnchor = useAnchor( {\n\t\teditableContentElement,\n\t\tsettings,\n\t} );\n\n\treturn <InlineToolbar popoverAnchor={ popoverAnchor } />;\n}\n\nfunction InlineToolbar( { popoverAnchor } ) {\n\treturn (\n\t\t<Popover\n\t\t\tplacement=\"top\"\n\t\t\tfocusOnMount={ false }\n\t\t\tanchor={ popoverAnchor }\n\t\t\tclassName=\"block-editor-rich-text__inline-format-toolbar\"\n\t\t\t__unstableSlotName=\"block-toolbar\"\n\t\t>\n\t\t\t<NavigableToolbar\n\t\t\t\tclassName=\"block-editor-rich-text__inline-format-toolbar-group\"\n\t\t\t\t/* translators: accessibility text for the inline format toolbar */\n\t\t\t\taria-label={ __( 'Format tools' ) }\n\t\t\t>\n\t\t\t\t<ToolbarGroup>\n\t\t\t\t\t<FormatToolbar />\n\t\t\t\t</ToolbarGroup>\n\t\t\t</NavigableToolbar>\n\t\t</Popover>\n\t);\n}\n\nconst FormatToolbarContainer = ( {\n\tinline,\n\teditableContentElement,\n\tvalue,\n} ) => {\n\tconst hasInlineToolbar = useSelect(\n\t\t( select ) => select( blockEditorStore ).getSettings().hasInlineToolbar,\n\t\t[]\n\t);\n\n\tif ( inline ) {\n\t\treturn <InlineToolbar popoverAnchor={ editableContentElement } />;\n\t}\n\n\tif ( hasInlineToolbar ) {\n\t\tconst activeFormats = getActiveFormats( value );\n\n\t\tif ( isCollapsed( value ) && ! activeFormats.length ) {\n\t\t\treturn null;\n\t\t}\n\n\t\treturn (\n\t\t\t<InlineSelectionToolbar\n\t\t\t\teditableContentElement={ editableContentElement }\n\t\t\t\tactiveFormats={ activeFormats }\n\t\t\t/>\n\t\t);\n\t}\n\n\t// Render regular toolbar.\n\treturn (\n\t\t<BlockControls group=\"inline\">\n\t\t\t<FormatToolbar />\n\t\t</BlockControls>\n\t);\n};\n\nexport default FormatToolbarContainer;\n"]}
|
|
@@ -13,9 +13,8 @@ import { RawHTML, useRef, useCallback, forwardRef, createContext } from '@wordpr
|
|
|
13
13
|
import { useDispatch, useSelect } from '@wordpress/data';
|
|
14
14
|
import { children as childrenSource } from '@wordpress/blocks';
|
|
15
15
|
import { useInstanceId, useMergeRefs } from '@wordpress/compose';
|
|
16
|
-
import { __unstableUseRichText as useRichText, __unstableCreateElement,
|
|
16
|
+
import { __unstableUseRichText as useRichText, __unstableCreateElement, removeFormat } from '@wordpress/rich-text';
|
|
17
17
|
import deprecated from '@wordpress/deprecated';
|
|
18
|
-
import { BACKSPACE, DELETE } from '@wordpress/keycodes';
|
|
19
18
|
import { Popover } from '@wordpress/components';
|
|
20
19
|
/**
|
|
21
20
|
* Internal dependencies
|
|
@@ -30,6 +29,7 @@ import { useMarkPersistent } from './use-mark-persistent';
|
|
|
30
29
|
import { usePasteHandler } from './use-paste-handler';
|
|
31
30
|
import { useBeforeInputRules } from './use-before-input-rules';
|
|
32
31
|
import { useInputRules } from './use-input-rules';
|
|
32
|
+
import { useDelete } from './use-delete';
|
|
33
33
|
import { useEnter } from './use-enter';
|
|
34
34
|
import { useFormatTypes } from './use-format-types';
|
|
35
35
|
import { useRemoveBrowserShortcuts } from './use-remove-browser-shortcuts';
|
|
@@ -247,6 +247,7 @@ function RichTextWrapper(_ref, forwardedRef) {
|
|
|
247
247
|
|
|
248
248
|
const {
|
|
249
249
|
value,
|
|
250
|
+
getValue,
|
|
250
251
|
onChange,
|
|
251
252
|
ref: richTextRef
|
|
252
253
|
} = useRichText({
|
|
@@ -289,44 +290,6 @@ function RichTextWrapper(_ref, forwardedRef) {
|
|
|
289
290
|
const keyboardShortcuts = useRef(new Set());
|
|
290
291
|
const inputEvents = useRef(new Set());
|
|
291
292
|
|
|
292
|
-
function onKeyDown(event) {
|
|
293
|
-
const {
|
|
294
|
-
keyCode
|
|
295
|
-
} = event;
|
|
296
|
-
|
|
297
|
-
if (event.defaultPrevented) {
|
|
298
|
-
return;
|
|
299
|
-
}
|
|
300
|
-
|
|
301
|
-
if (keyCode === DELETE || keyCode === BACKSPACE) {
|
|
302
|
-
const {
|
|
303
|
-
start,
|
|
304
|
-
end,
|
|
305
|
-
text
|
|
306
|
-
} = value;
|
|
307
|
-
const isReverse = keyCode === BACKSPACE;
|
|
308
|
-
const hasActiveFormats = value.activeFormats && !!value.activeFormats.length; // Only process delete if the key press occurs at an uncollapsed edge.
|
|
309
|
-
|
|
310
|
-
if (!isCollapsed(value) || hasActiveFormats || isReverse && start !== 0 || !isReverse && end !== text.length) {
|
|
311
|
-
return;
|
|
312
|
-
}
|
|
313
|
-
|
|
314
|
-
if (onMerge) {
|
|
315
|
-
onMerge(!isReverse);
|
|
316
|
-
} // Only handle remove on Backspace. This serves dual-purpose of being
|
|
317
|
-
// an intentional user interaction distinguishing between Backspace and
|
|
318
|
-
// Delete to remove the empty field, but also to avoid merge & remove
|
|
319
|
-
// causing destruction of two fields (merge, then removed merged).
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
if (onRemove && isEmpty(value) && isReverse) {
|
|
323
|
-
onRemove(!isReverse);
|
|
324
|
-
}
|
|
325
|
-
|
|
326
|
-
event.preventDefault();
|
|
327
|
-
}
|
|
328
|
-
}
|
|
329
|
-
|
|
330
293
|
function onFocus() {
|
|
331
294
|
var _anchorRef$current;
|
|
332
295
|
|
|
@@ -364,7 +327,7 @@ function RichTextWrapper(_ref, forwardedRef) {
|
|
|
364
327
|
value,
|
|
365
328
|
onChange
|
|
366
329
|
}), useInputRules({
|
|
367
|
-
|
|
330
|
+
getValue,
|
|
368
331
|
onChange,
|
|
369
332
|
__unstableAllowPrefixTransformations,
|
|
370
333
|
formatTypes,
|
|
@@ -384,6 +347,10 @@ function RichTextWrapper(_ref, forwardedRef) {
|
|
|
384
347
|
multilineTag,
|
|
385
348
|
preserveWhiteSpace,
|
|
386
349
|
pastePlainText
|
|
350
|
+
}), useDelete({
|
|
351
|
+
value,
|
|
352
|
+
onMerge,
|
|
353
|
+
onRemove
|
|
387
354
|
}), useEnter({
|
|
388
355
|
removeEditorOnlyFormats,
|
|
389
356
|
value,
|
|
@@ -397,8 +364,7 @@ function RichTextWrapper(_ref, forwardedRef) {
|
|
|
397
364
|
}), useFirefoxCompat(), anchorRef]),
|
|
398
365
|
contentEditable: true,
|
|
399
366
|
suppressContentEditableWarning: true,
|
|
400
|
-
className: classnames('block-editor-rich-text__editable', props.className, 'rich-text')
|
|
401
|
-
onKeyDown: onKeyDown
|
|
367
|
+
className: classnames('block-editor-rich-text__editable', props.className, 'rich-text')
|
|
402
368
|
})));
|
|
403
369
|
}
|
|
404
370
|
|