@wordpress/block-editor 10.3.0 → 10.5.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 +13 -0
- package/README.md +0 -1
- package/build/components/alignment-control/ui.js +1 -1
- package/build/components/alignment-control/ui.js.map +1 -1
- package/build/components/block-alignment-control/constants.js +1 -1
- package/build/components/block-alignment-control/constants.js.map +1 -1
- package/build/components/block-alignment-matrix-control/index.js +1 -1
- package/build/components/block-alignment-matrix-control/index.js.map +1 -1
- package/build/components/block-compare/index.js +1 -3
- package/build/components/block-compare/index.js.map +1 -1
- package/build/components/block-edit/index.js +4 -2
- package/build/components/block-edit/index.js.map +1 -1
- package/build/components/block-list/block.js +3 -1
- package/build/components/block-list/block.js.map +1 -1
- package/build/components/block-lock/menu-item.js +1 -1
- package/build/components/block-lock/menu-item.js.map +1 -1
- package/build/components/block-lock/modal.js +16 -9
- package/build/components/block-lock/modal.js.map +1 -1
- package/build/components/block-popover/inbetween.js +2 -1
- package/build/components/block-popover/inbetween.js.map +1 -1
- package/build/components/block-popover/index.js +2 -1
- package/build/components/block-popover/index.js.map +1 -1
- package/build/components/block-preview/index.js +2 -4
- package/build/components/block-preview/index.js.map +1 -1
- package/build/components/block-settings-menu/block-settings-dropdown.js +2 -8
- package/build/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
- package/build/components/block-styles/utils.js +3 -3
- package/build/components/block-styles/utils.js.map +1 -1
- package/build/components/block-switcher/index.js +21 -12
- package/build/components/block-switcher/index.js.map +1 -1
- package/build/components/block-switcher/preview-block-popover.js +1 -1
- package/build/components/block-switcher/preview-block-popover.js.map +1 -1
- package/build/components/block-tools/insertion-point.js +12 -2
- package/build/components/block-tools/insertion-point.js.map +1 -1
- package/build/components/block-tools/selected-block-popover.js +27 -4
- package/build/components/block-tools/selected-block-popover.js.map +1 -1
- package/build/components/block-vertical-alignment-control/ui.js +1 -1
- package/build/components/block-vertical-alignment-control/ui.js.map +1 -1
- package/build/components/border-radius-control/all-input-control.js +2 -1
- package/build/components/border-radius-control/all-input-control.js.map +1 -1
- package/build/components/border-radius-control/index.js +2 -1
- package/build/components/border-radius-control/index.js.map +1 -1
- package/build/components/border-radius-control/input-controls.js +2 -1
- package/build/components/border-radius-control/input-controls.js.map +1 -1
- package/build/components/colors/with-colors.js +4 -3
- package/build/components/colors/with-colors.js.map +1 -1
- package/build/components/duotone-control/index.js +1 -1
- package/build/components/duotone-control/index.js.map +1 -1
- package/build/components/font-sizes/fluid-utils.js +24 -40
- package/build/components/font-sizes/fluid-utils.js.map +1 -1
- package/build/components/font-sizes/with-font-sizes.js +8 -6
- package/build/components/font-sizes/with-font-sizes.js.map +1 -1
- package/build/components/iframe/index.js +1 -1
- package/build/components/iframe/index.js.map +1 -1
- package/build/components/image-editor/constants.js +1 -1
- package/build/components/image-editor/constants.js.map +1 -1
- package/build/components/index.js +9 -0
- package/build/components/index.js.map +1 -1
- package/build/components/inner-blocks/index.js +10 -4
- package/build/components/inner-blocks/index.js.map +1 -1
- package/build/components/inserter/hooks/use-insertion-point.js +2 -7
- package/build/components/inserter/hooks/use-insertion-point.js.map +1 -1
- package/build/components/inserter/reusable-blocks-tab.js +4 -1
- package/build/components/inserter/reusable-blocks-tab.js.map +1 -1
- package/build/components/inserter/search-items.js +23 -2
- package/build/components/inserter/search-items.js.map +1 -1
- package/build/components/line-height-control/index.js +2 -1
- package/build/components/line-height-control/index.js.map +1 -1
- package/build/components/link-control/index.js +18 -34
- package/build/components/link-control/index.js.map +1 -1
- package/build/components/link-control/search-input.js +1 -1
- package/build/components/link-control/search-input.js.map +1 -1
- package/build/components/link-control/use-internal-input-value.js +26 -0
- package/build/components/link-control/use-internal-input-value.js.map +1 -0
- package/build/components/list-view/block.js +5 -3
- package/build/components/list-view/block.js.map +1 -1
- package/build/components/list-view/branch.js +9 -3
- package/build/components/list-view/branch.js.map +1 -1
- package/build/components/list-view/drop-indicator.js +2 -1
- package/build/components/list-view/drop-indicator.js.map +1 -1
- package/build/components/media-replace-flow/index.js +1 -1
- package/build/components/media-replace-flow/index.js.map +1 -1
- package/build/components/off-canvas-editor/block-contents.js +100 -0
- package/build/components/off-canvas-editor/block-contents.js.map +1 -0
- package/build/components/off-canvas-editor/block-select-button.js +119 -0
- package/build/components/off-canvas-editor/block-select-button.js.map +1 -0
- package/build/components/off-canvas-editor/block.js +292 -0
- package/build/components/off-canvas-editor/block.js.map +1 -0
- package/build/components/off-canvas-editor/branch.js +181 -0
- package/build/components/off-canvas-editor/branch.js.map +1 -0
- package/build/components/off-canvas-editor/context.js +19 -0
- package/build/components/off-canvas-editor/context.js.map +1 -0
- package/build/components/off-canvas-editor/drop-indicator.js +118 -0
- package/build/components/off-canvas-editor/drop-indicator.js.map +1 -0
- package/build/components/off-canvas-editor/expander.js +41 -0
- package/build/components/off-canvas-editor/expander.js.map +1 -0
- package/build/components/off-canvas-editor/index.js +204 -0
- package/build/components/off-canvas-editor/index.js.map +1 -0
- package/build/components/off-canvas-editor/leaf.js +60 -0
- package/build/components/off-canvas-editor/leaf.js.map +1 -0
- package/build/components/off-canvas-editor/use-block-selection.js +139 -0
- package/build/components/off-canvas-editor/use-block-selection.js.map +1 -0
- package/build/components/off-canvas-editor/use-list-view-client-ids.js +33 -0
- package/build/components/off-canvas-editor/use-list-view-client-ids.js.map +1 -0
- package/build/components/off-canvas-editor/use-list-view-drop-zone.js +235 -0
- package/build/components/off-canvas-editor/use-list-view-drop-zone.js.map +1 -0
- package/build/components/off-canvas-editor/use-list-view-expand-selected-item.js +60 -0
- package/build/components/off-canvas-editor/use-list-view-expand-selected-item.js.map +1 -0
- package/build/components/off-canvas-editor/utils.js +60 -0
- package/build/components/off-canvas-editor/utils.js.map +1 -0
- package/build/components/rich-text/format-toolbar/index.js +1 -1
- package/build/components/rich-text/format-toolbar/index.js.map +1 -1
- package/build/components/rich-text/format-toolbar-container.js +1 -1
- package/build/components/rich-text/format-toolbar-container.js.map +1 -1
- package/build/components/rich-text/use-paste-handler.js +1 -1
- package/build/components/rich-text/use-paste-handler.js.map +1 -1
- package/build/components/spacing-sizes-control/all-input-control.js +6 -2
- package/build/components/spacing-sizes-control/all-input-control.js.map +1 -1
- package/build/components/spacing-sizes-control/axial-input-controls.js +6 -2
- package/build/components/spacing-sizes-control/axial-input-controls.js.map +1 -1
- package/build/components/spacing-sizes-control/index.js +6 -2
- package/build/components/spacing-sizes-control/index.js.map +1 -1
- package/build/components/spacing-sizes-control/input-controls.js +6 -2
- package/build/components/spacing-sizes-control/input-controls.js.map +1 -1
- package/build/components/spacing-sizes-control/spacing-input-control.js +12 -5
- package/build/components/spacing-sizes-control/spacing-input-control.js.map +1 -1
- package/build/components/url-input/index.js +1 -1
- package/build/components/url-input/index.js.map +1 -1
- package/build/components/url-popover/index.js +31 -2
- package/build/components/url-popover/index.js.map +1 -1
- package/build/components/use-setting/index.js +1 -1
- package/build/components/use-setting/index.js.map +1 -1
- package/build/hooks/border.js +1 -0
- package/build/hooks/border.js.map +1 -1
- package/build/hooks/color-panel.js +17 -1
- package/build/hooks/color-panel.js.map +1 -1
- package/build/hooks/color.js +1 -1
- package/build/hooks/color.js.map +1 -1
- package/build/hooks/content-lock-ui.js +13 -6
- package/build/hooks/content-lock-ui.js.map +1 -1
- package/build/hooks/dimensions.js +72 -13
- package/build/hooks/dimensions.js.map +1 -1
- package/build/hooks/font-size.js +1 -0
- package/build/hooks/font-size.js.map +1 -1
- package/build/hooks/layout.js +5 -4
- package/build/hooks/layout.js.map +1 -1
- package/build/hooks/margin.js +26 -18
- package/build/hooks/margin.js.map +1 -1
- package/build/hooks/min-height.js +145 -0
- package/build/hooks/min-height.js.map +1 -0
- package/build/hooks/padding.js +22 -13
- package/build/hooks/padding.js.map +1 -1
- package/build/hooks/style.js +3 -2
- package/build/hooks/style.js.map +1 -1
- package/build/hooks/utils.js +7 -6
- package/build/hooks/utils.js.map +1 -1
- package/build/layouts/constrained.js +0 -1
- package/build/layouts/constrained.js.map +1 -1
- package/build/layouts/flex.js +23 -22
- package/build/layouts/flex.js.map +1 -1
- package/build/store/actions.js +30 -0
- package/build/store/actions.js.map +1 -1
- package/build/store/array.js +1 -7
- package/build/store/array.js.map +1 -1
- package/build/store/reducer.js +46 -14
- package/build/store/reducer.js.map +1 -1
- package/build/store/selectors.js +62 -31
- package/build/store/selectors.js.map +1 -1
- package/build-module/components/alignment-control/ui.js +1 -1
- package/build-module/components/alignment-control/ui.js.map +1 -1
- package/build-module/components/block-alignment-control/constants.js +1 -1
- package/build-module/components/block-alignment-control/constants.js.map +1 -1
- package/build-module/components/block-alignment-matrix-control/index.js +1 -1
- package/build-module/components/block-alignment-matrix-control/index.js.map +1 -1
- package/build-module/components/block-compare/index.js +2 -3
- package/build-module/components/block-compare/index.js.map +1 -1
- package/build-module/components/block-edit/index.js +4 -2
- package/build-module/components/block-edit/index.js.map +1 -1
- package/build-module/components/block-list/block.js +3 -1
- package/build-module/components/block-list/block.js.map +1 -1
- package/build-module/components/block-lock/menu-item.js +2 -2
- package/build-module/components/block-lock/menu-item.js.map +1 -1
- package/build-module/components/block-lock/modal.js +17 -10
- package/build-module/components/block-lock/modal.js.map +1 -1
- package/build-module/components/block-popover/inbetween.js +2 -1
- package/build-module/components/block-popover/inbetween.js.map +1 -1
- package/build-module/components/block-popover/index.js +2 -1
- package/build-module/components/block-popover/index.js.map +1 -1
- package/build-module/components/block-preview/index.js +2 -3
- package/build-module/components/block-preview/index.js.map +1 -1
- package/build-module/components/block-settings-menu/block-settings-dropdown.js +2 -7
- package/build-module/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
- package/build-module/components/block-styles/utils.js +3 -3
- package/build-module/components/block-styles/utils.js.map +1 -1
- package/build-module/components/block-switcher/index.js +21 -11
- package/build-module/components/block-switcher/index.js.map +1 -1
- package/build-module/components/block-switcher/preview-block-popover.js +1 -1
- package/build-module/components/block-switcher/preview-block-popover.js.map +1 -1
- package/build-module/components/block-tools/insertion-point.js +12 -2
- package/build-module/components/block-tools/insertion-point.js.map +1 -1
- package/build-module/components/block-tools/selected-block-popover.js +27 -5
- package/build-module/components/block-tools/selected-block-popover.js.map +1 -1
- package/build-module/components/block-vertical-alignment-control/ui.js +1 -1
- package/build-module/components/block-vertical-alignment-control/ui.js.map +1 -1
- package/build-module/components/border-radius-control/all-input-control.js +2 -1
- package/build-module/components/border-radius-control/all-input-control.js.map +1 -1
- package/build-module/components/border-radius-control/index.js +2 -1
- package/build-module/components/border-radius-control/index.js.map +1 -1
- package/build-module/components/border-radius-control/input-controls.js +2 -1
- package/build-module/components/border-radius-control/input-controls.js.map +1 -1
- package/build-module/components/colors/with-colors.js +5 -4
- package/build-module/components/colors/with-colors.js.map +1 -1
- package/build-module/components/duotone-control/index.js +1 -1
- package/build-module/components/duotone-control/index.js.map +1 -1
- package/build-module/components/font-sizes/fluid-utils.js +24 -40
- package/build-module/components/font-sizes/fluid-utils.js.map +1 -1
- package/build-module/components/font-sizes/with-font-sizes.js +9 -7
- package/build-module/components/font-sizes/with-font-sizes.js.map +1 -1
- package/build-module/components/iframe/index.js +1 -1
- package/build-module/components/iframe/index.js.map +1 -1
- package/build-module/components/image-editor/constants.js +1 -1
- package/build-module/components/image-editor/constants.js.map +1 -1
- package/build-module/components/index.js +1 -0
- package/build-module/components/index.js.map +1 -1
- package/build-module/components/inner-blocks/index.js +10 -4
- package/build-module/components/inner-blocks/index.js.map +1 -1
- package/build-module/components/inserter/hooks/use-insertion-point.js +2 -6
- package/build-module/components/inserter/hooks/use-insertion-point.js.map +1 -1
- package/build-module/components/inserter/reusable-blocks-tab.js +3 -1
- package/build-module/components/inserter/reusable-blocks-tab.js.map +1 -1
- package/build-module/components/inserter/search-items.js +23 -3
- package/build-module/components/inserter/search-items.js.map +1 -1
- package/build-module/components/line-height-control/index.js +2 -1
- package/build-module/components/line-height-control/index.js.map +1 -1
- package/build-module/components/link-control/index.js +17 -34
- package/build-module/components/link-control/index.js.map +1 -1
- package/build-module/components/link-control/search-input.js +1 -1
- package/build-module/components/link-control/search-input.js.map +1 -1
- package/build-module/components/link-control/use-internal-input-value.js +18 -0
- package/build-module/components/link-control/use-internal-input-value.js.map +1 -0
- package/build-module/components/list-view/block.js +5 -3
- package/build-module/components/list-view/block.js.map +1 -1
- package/build-module/components/list-view/branch.js +9 -3
- package/build-module/components/list-view/branch.js.map +1 -1
- package/build-module/components/list-view/drop-indicator.js +2 -1
- package/build-module/components/list-view/drop-indicator.js.map +1 -1
- package/build-module/components/media-replace-flow/index.js +1 -1
- package/build-module/components/media-replace-flow/index.js.map +1 -1
- package/build-module/components/off-canvas-editor/block-contents.js +85 -0
- package/build-module/components/off-canvas-editor/block-contents.js.map +1 -0
- package/build-module/components/off-canvas-editor/block-select-button.js +101 -0
- package/build-module/components/off-canvas-editor/block-select-button.js.map +1 -0
- package/build-module/components/off-canvas-editor/block.js +268 -0
- package/build-module/components/off-canvas-editor/block.js.map +1 -0
- package/build-module/components/off-canvas-editor/branch.js +165 -0
- package/build-module/components/off-canvas-editor/branch.js.map +1 -0
- package/build-module/components/off-canvas-editor/context.js +7 -0
- package/build-module/components/off-canvas-editor/context.js.map +1 -0
- package/build-module/components/off-canvas-editor/drop-indicator.js +111 -0
- package/build-module/components/off-canvas-editor/drop-indicator.js.map +1 -0
- package/build-module/components/off-canvas-editor/expander.js +32 -0
- package/build-module/components/off-canvas-editor/expander.js.map +1 -0
- package/build-module/components/off-canvas-editor/index.js +181 -0
- package/build-module/components/off-canvas-editor/index.js.map +1 -0
- package/build-module/components/off-canvas-editor/leaf.js +45 -0
- package/build-module/components/off-canvas-editor/leaf.js.map +1 -0
- package/build-module/components/off-canvas-editor/use-block-selection.js +124 -0
- package/build-module/components/off-canvas-editor/use-block-selection.js.map +1 -0
- package/build-module/components/off-canvas-editor/use-list-view-client-ids.js +24 -0
- package/build-module/components/off-canvas-editor/use-list-view-client-ids.js.map +1 -0
- package/build-module/components/off-canvas-editor/use-list-view-drop-zone.js +220 -0
- package/build-module/components/off-canvas-editor/use-list-view-drop-zone.js.map +1 -0
- package/build-module/components/off-canvas-editor/use-list-view-expand-selected-item.js +50 -0
- package/build-module/components/off-canvas-editor/use-list-view-expand-selected-item.js.map +1 -0
- package/build-module/components/off-canvas-editor/utils.js +44 -0
- package/build-module/components/off-canvas-editor/utils.js.map +1 -0
- package/build-module/components/rich-text/format-toolbar/index.js +1 -1
- package/build-module/components/rich-text/format-toolbar/index.js.map +1 -1
- package/build-module/components/rich-text/format-toolbar-container.js +1 -1
- package/build-module/components/rich-text/format-toolbar-container.js.map +1 -1
- package/build-module/components/rich-text/use-paste-handler.js +1 -1
- package/build-module/components/rich-text/use-paste-handler.js.map +1 -1
- package/build-module/components/spacing-sizes-control/all-input-control.js +6 -2
- package/build-module/components/spacing-sizes-control/all-input-control.js.map +1 -1
- package/build-module/components/spacing-sizes-control/axial-input-controls.js +6 -2
- package/build-module/components/spacing-sizes-control/axial-input-controls.js.map +1 -1
- package/build-module/components/spacing-sizes-control/index.js +6 -2
- package/build-module/components/spacing-sizes-control/index.js.map +1 -1
- package/build-module/components/spacing-sizes-control/input-controls.js +6 -2
- package/build-module/components/spacing-sizes-control/input-controls.js.map +1 -1
- package/build-module/components/spacing-sizes-control/spacing-input-control.js +12 -5
- package/build-module/components/spacing-sizes-control/spacing-input-control.js.map +1 -1
- package/build-module/components/url-input/index.js +1 -1
- package/build-module/components/url-input/index.js.map +1 -1
- package/build-module/components/url-popover/index.js +30 -3
- package/build-module/components/url-popover/index.js.map +1 -1
- package/build-module/components/use-setting/index.js +1 -1
- package/build-module/components/use-setting/index.js.map +1 -1
- package/build-module/hooks/border.js +1 -0
- package/build-module/hooks/border.js.map +1 -1
- package/build-module/hooks/color-panel.js +17 -1
- package/build-module/hooks/color-panel.js.map +1 -1
- package/build-module/hooks/color.js +1 -1
- package/build-module/hooks/color.js.map +1 -1
- package/build-module/hooks/content-lock-ui.js +15 -8
- package/build-module/hooks/content-lock-ui.js.map +1 -1
- package/build-module/hooks/dimensions.js +67 -12
- package/build-module/hooks/dimensions.js.map +1 -1
- package/build-module/hooks/font-size.js +1 -0
- package/build-module/hooks/font-size.js.map +1 -1
- package/build-module/hooks/layout.js +6 -5
- package/build-module/hooks/layout.js.map +1 -1
- package/build-module/hooks/margin.js +27 -19
- package/build-module/hooks/margin.js.map +1 -1
- package/build-module/hooks/min-height.js +122 -0
- package/build-module/hooks/min-height.js.map +1 -0
- package/build-module/hooks/padding.js +23 -14
- package/build-module/hooks/padding.js.map +1 -1
- package/build-module/hooks/style.js +4 -3
- package/build-module/hooks/style.js.map +1 -1
- package/build-module/hooks/utils.js +7 -7
- package/build-module/hooks/utils.js.map +1 -1
- package/build-module/layouts/constrained.js +0 -1
- package/build-module/layouts/constrained.js.map +1 -1
- package/build-module/layouts/flex.js +24 -23
- package/build-module/layouts/flex.js.map +1 -1
- package/build-module/store/actions.js +26 -0
- package/build-module/store/actions.js.map +1 -1
- package/build-module/store/array.js +1 -6
- package/build-module/store/array.js.map +1 -1
- package/build-module/store/reducer.js +44 -14
- package/build-module/store/reducer.js.map +1 -1
- package/build-module/store/selectors.js +59 -31
- package/build-module/store/selectors.js.map +1 -1
- package/build-style/style-rtl.css +88 -88
- package/build-style/style.css +84 -84
- package/package.json +29 -28
- package/src/components/alignment-control/README.md +1 -1
- package/src/components/alignment-control/ui.js +1 -1
- package/src/components/block-alignment-control/constants.js +1 -1
- package/src/components/block-alignment-control/test/index.native.js +4 -4
- package/src/components/block-alignment-matrix-control/index.js +1 -1
- package/src/components/block-breadcrumb/test/__snapshots__/index.js.snap +13 -11
- package/src/components/block-breadcrumb/test/index.js +1 -1
- package/src/components/block-compare/index.js +3 -2
- package/src/components/block-draggable/test/helpers.native.js +3 -3
- package/src/components/block-draggable/test/index.native.js +27 -27
- package/src/components/block-edit/index.js +2 -1
- package/src/components/block-list/block.js +2 -0
- package/src/components/block-list/style.scss +11 -6
- package/src/components/block-lock/menu-item.js +5 -2
- package/src/components/block-lock/modal.js +19 -36
- package/src/components/block-lock/style.scss +8 -17
- package/src/components/block-mover/stories/index.js +1 -1
- package/src/components/block-mover/style.scss +35 -1
- package/src/components/block-popover/inbetween.js +1 -0
- package/src/components/block-popover/index.js +1 -0
- package/src/components/block-popover/style.scss +1 -5
- package/src/components/block-preview/index.js +8 -3
- package/src/components/block-settings-menu/block-settings-dropdown.js +4 -7
- package/src/components/block-styles/utils.js +3 -3
- package/src/components/block-switcher/index.js +21 -11
- package/src/components/block-switcher/preview-block-popover.js +1 -1
- package/src/components/block-tools/insertion-point.js +10 -1
- package/src/components/block-tools/selected-block-popover.js +80 -34
- package/src/components/block-tools/style.scss +15 -0
- package/src/components/block-variation-picker/README.md +1 -1
- package/src/components/block-vertical-alignment-control/ui.js +1 -1
- package/src/components/border-radius-control/all-input-control.js +1 -0
- package/src/components/border-radius-control/index.js +1 -0
- package/src/components/border-radius-control/input-controls.js +1 -0
- package/src/components/border-radius-control/style.scss +15 -24
- package/src/components/color-palette/test/__snapshots__/control.js.snap +85 -83
- package/src/components/color-palette/test/control.js +1 -1
- package/src/components/colors/with-colors.js +13 -23
- package/src/components/default-block-appender/style.scss +1 -0
- package/src/components/duotone-control/index.js +1 -1
- package/src/components/font-sizes/fluid-utils.js +37 -64
- package/src/components/font-sizes/test/fluid-utils.js +5 -5
- package/src/components/font-sizes/with-font-sizes.js +15 -13
- package/src/components/iframe/index.js +1 -1
- package/src/components/image-editor/constants.js +1 -1
- package/src/components/index.js +1 -0
- package/src/components/inner-blocks/index.js +11 -4
- package/src/components/inner-blocks/test/index.js +4 -0
- package/src/components/inserter/hooks/use-insertion-point.js +3 -11
- package/src/components/inserter/reusable-blocks-tab.js +4 -2
- package/src/components/inserter/search-items.js +23 -3
- package/src/components/inserter/style.scss +8 -7
- package/src/components/inserter/test/reusable-blocks-tab.js +14 -57
- package/src/components/inserter/test/search-items.js +6 -0
- package/src/components/inserter-list-item/style.scss +2 -0
- package/src/components/letter-spacing-control/README.md +55 -0
- package/src/components/line-height-control/index.js +1 -0
- package/src/components/link-control/README.md +3 -3
- package/src/components/link-control/index.js +23 -39
- package/src/components/link-control/search-input.js +1 -1
- package/src/components/link-control/test/index.js +272 -241
- package/src/components/link-control/use-internal-input-value.js +22 -0
- package/src/components/list-view/block.js +4 -3
- package/src/components/list-view/branch.js +11 -6
- package/src/components/list-view/drop-indicator.js +1 -0
- package/src/components/list-view/style.scss +1 -36
- package/src/components/media-replace-flow/index.js +1 -1
- package/src/components/media-replace-flow/test/index.js +69 -51
- package/src/components/off-canvas-editor/README.md +5 -0
- package/src/components/off-canvas-editor/block-contents.js +89 -0
- package/src/components/off-canvas-editor/block-select-button.js +113 -0
- package/src/components/off-canvas-editor/block.js +335 -0
- package/src/components/off-canvas-editor/branch.js +210 -0
- package/src/components/off-canvas-editor/context.js +8 -0
- package/src/components/off-canvas-editor/drop-indicator.js +126 -0
- package/src/components/off-canvas-editor/expander.js +26 -0
- package/src/components/off-canvas-editor/index.js +216 -0
- package/src/components/off-canvas-editor/leaf.js +48 -0
- package/src/components/off-canvas-editor/style.scss +397 -0
- package/src/components/off-canvas-editor/test/utils.js +50 -0
- package/src/components/off-canvas-editor/use-block-selection.js +169 -0
- package/src/components/off-canvas-editor/use-list-view-client-ids.js +29 -0
- package/src/components/off-canvas-editor/use-list-view-drop-zone.js +260 -0
- package/src/components/off-canvas-editor/use-list-view-expand-selected-item.js +58 -0
- package/src/components/off-canvas-editor/utils.js +58 -0
- package/src/components/responsive-block-control/test/index.js +69 -92
- package/src/components/rich-text/format-toolbar/index.js +1 -1
- package/src/components/rich-text/format-toolbar-container.js +1 -1
- package/src/components/rich-text/use-paste-handler.js +1 -1
- package/src/components/spacing-sizes-control/all-input-control.js +4 -0
- package/src/components/spacing-sizes-control/axial-input-controls.js +4 -0
- package/src/components/spacing-sizes-control/index.js +4 -0
- package/src/components/spacing-sizes-control/input-controls.js +4 -0
- package/src/components/spacing-sizes-control/spacing-input-control.js +10 -1
- package/src/components/spacing-sizes-control/style.scss +1 -0
- package/src/components/url-input/index.js +1 -1
- package/src/components/url-popover/README.md +12 -3
- package/src/components/url-popover/index.js +33 -3
- package/src/components/use-setting/index.js +7 -1
- package/src/hooks/border.js +1 -0
- package/src/hooks/color-panel.js +13 -1
- package/src/hooks/color.js +2 -0
- package/src/hooks/content-lock-ui.js +46 -34
- package/src/hooks/dimensions.js +106 -19
- package/src/hooks/font-size.js +1 -0
- package/src/hooks/layout.js +8 -11
- package/src/hooks/margin.js +23 -17
- package/src/hooks/min-height.js +121 -0
- package/src/hooks/padding.js +23 -19
- package/src/hooks/style.js +10 -2
- package/src/hooks/test/align.js +96 -72
- package/src/hooks/test/style.js +4 -0
- package/src/hooks/test/use-typography-props.js +1 -1
- package/src/hooks/utils.js +5 -6
- package/src/layouts/constrained.js +0 -1
- package/src/layouts/flex.js +44 -39
- package/src/store/actions.js +26 -0
- package/src/store/array.js +1 -6
- package/src/store/reducer.js +50 -40
- package/src/store/selectors.js +43 -29
- package/src/store/test/actions.js +18 -0
- package/src/store/test/reducer.js +40 -0
- package/src/store/test/selectors.js +20 -1
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* External dependencies
|
|
3
|
-
*/
|
|
4
|
-
import { castArray } from 'lodash';
|
|
5
|
-
|
|
6
1
|
/**
|
|
7
2
|
* WordPress dependencies
|
|
8
3
|
*/
|
|
@@ -118,14 +113,11 @@ function useInsertionPoint( {
|
|
|
118
113
|
meta
|
|
119
114
|
);
|
|
120
115
|
}
|
|
116
|
+
const blockLength = Array.isArray( blocks ) ? blocks.length : 1;
|
|
121
117
|
const message = sprintf(
|
|
122
118
|
// translators: %d: the name of the block that has been added
|
|
123
|
-
_n(
|
|
124
|
-
|
|
125
|
-
'%d blocks added.',
|
|
126
|
-
castArray( blocks ).length
|
|
127
|
-
),
|
|
128
|
-
castArray( blocks ).length
|
|
119
|
+
_n( '%d block added.', '%d blocks added.', blockLength ),
|
|
120
|
+
blockLength
|
|
129
121
|
);
|
|
130
122
|
speak( message );
|
|
131
123
|
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
import { useMemo } from '@wordpress/element';
|
|
5
5
|
import { __ } from '@wordpress/i18n';
|
|
6
6
|
import { addQueryArgs } from '@wordpress/url';
|
|
7
|
+
import { Button } from '@wordpress/components';
|
|
7
8
|
|
|
8
9
|
/**
|
|
9
10
|
* Internal dependencies
|
|
@@ -59,14 +60,15 @@ export function ReusableBlocksTab( { rootClientId, onInsert, onHover } ) {
|
|
|
59
60
|
rootClientId={ rootClientId }
|
|
60
61
|
/>
|
|
61
62
|
<div className="block-editor-inserter__manage-reusable-blocks-container">
|
|
62
|
-
<
|
|
63
|
+
<Button
|
|
63
64
|
className="block-editor-inserter__manage-reusable-blocks"
|
|
65
|
+
variant="secondary"
|
|
64
66
|
href={ addQueryArgs( 'edit.php', {
|
|
65
67
|
post_type: 'wp_block',
|
|
66
68
|
} ) }
|
|
67
69
|
>
|
|
68
70
|
{ __( 'Manage Reusable blocks' ) }
|
|
69
|
-
</
|
|
71
|
+
</Button>
|
|
70
72
|
</div>
|
|
71
73
|
</>
|
|
72
74
|
);
|
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
* External dependencies
|
|
3
3
|
*/
|
|
4
4
|
import removeAccents from 'remove-accents';
|
|
5
|
-
import { find
|
|
5
|
+
import { find } from 'lodash';
|
|
6
|
+
import { noCase } from 'change-case';
|
|
6
7
|
|
|
7
8
|
// Default search helpers.
|
|
8
9
|
const defaultGetName = ( item ) => item.name || '';
|
|
@@ -12,6 +13,25 @@ const defaultGetKeywords = ( item ) => item.keywords || [];
|
|
|
12
13
|
const defaultGetCategory = ( item ) => item.category;
|
|
13
14
|
const defaultGetCollection = () => null;
|
|
14
15
|
|
|
16
|
+
/**
|
|
17
|
+
* Extracts words from an input string.
|
|
18
|
+
*
|
|
19
|
+
* @param {string} input The input string.
|
|
20
|
+
*
|
|
21
|
+
* @return {Array} Words, extracted from the input string.
|
|
22
|
+
*/
|
|
23
|
+
function extractWords( input = '' ) {
|
|
24
|
+
return noCase( input, {
|
|
25
|
+
splitRegexp: [
|
|
26
|
+
/([\p{Ll}\p{Lo}\p{N}])([\p{Lu}\p{Lt}])/gu, // One lowercase or digit, followed by one uppercase.
|
|
27
|
+
/([\p{Lu}\p{Lt}])([\p{Lu}\p{Lt}][\p{Ll}\p{Lo}])/gu, // One uppercase followed by one uppercase and one lowercase.
|
|
28
|
+
],
|
|
29
|
+
stripRegexp: /(\p{C}|\p{P}|\p{S})+/giu, // Anything that's not a punctuation, symbol or control/format character.
|
|
30
|
+
} )
|
|
31
|
+
.split( ' ' )
|
|
32
|
+
.filter( Boolean );
|
|
33
|
+
}
|
|
34
|
+
|
|
15
35
|
/**
|
|
16
36
|
* Sanitizes the search input string.
|
|
17
37
|
*
|
|
@@ -43,7 +63,7 @@ function normalizeSearchInput( input = '' ) {
|
|
|
43
63
|
* @return {string[]} The normalized list of search terms.
|
|
44
64
|
*/
|
|
45
65
|
export const getNormalizedSearchTerms = ( input = '' ) => {
|
|
46
|
-
return
|
|
66
|
+
return extractWords( normalizeSearchInput( input ) );
|
|
47
67
|
};
|
|
48
68
|
|
|
49
69
|
const removeMatchingTerms = ( unmatchedTerms, unprocessedTerms ) => {
|
|
@@ -150,7 +170,7 @@ export function getItemSearchRank( item, searchTerm, config = {} ) {
|
|
|
150
170
|
category,
|
|
151
171
|
collection,
|
|
152
172
|
].join( ' ' );
|
|
153
|
-
const normalizedSearchTerms =
|
|
173
|
+
const normalizedSearchTerms = extractWords( normalizedSearchInput );
|
|
154
174
|
const unmatchedTerms = removeMatchingTerms(
|
|
155
175
|
normalizedSearchTerms,
|
|
156
176
|
terms
|
|
@@ -174,9 +174,13 @@ $block-inserter-tabs-height: 44px;
|
|
|
174
174
|
text-align: right;
|
|
175
175
|
}
|
|
176
176
|
|
|
177
|
+
.block-editor-inserter__manage-reusable-blocks-container {
|
|
178
|
+
margin: auto $grid-unit-20 $grid-unit-20;
|
|
179
|
+
}
|
|
180
|
+
|
|
177
181
|
.block-editor-inserter__manage-reusable-blocks {
|
|
178
|
-
|
|
179
|
-
|
|
182
|
+
justify-content: center;
|
|
183
|
+
width: 100%;
|
|
180
184
|
}
|
|
181
185
|
|
|
182
186
|
.block-editor-inserter__no-results {
|
|
@@ -341,10 +345,6 @@ $block-inserter-tabs-height: 44px;
|
|
|
341
345
|
position: relative; // prevents overscroll when block library is open
|
|
342
346
|
}
|
|
343
347
|
|
|
344
|
-
.block-editor-inserter__manage-reusable-blocks-container {
|
|
345
|
-
padding: $grid-unit-20;
|
|
346
|
-
}
|
|
347
|
-
|
|
348
348
|
.block-editor-inserter__quick-inserter {
|
|
349
349
|
width: 100%;
|
|
350
350
|
|
|
@@ -442,7 +442,8 @@ $block-inserter-tabs-height: 44px;
|
|
|
442
442
|
}
|
|
443
443
|
|
|
444
444
|
&__list {
|
|
445
|
-
margin-left: $sidebar-width
|
|
445
|
+
margin-left: $sidebar-width;
|
|
446
|
+
padding: $grid-unit-30 0 $grid-unit-40;
|
|
446
447
|
}
|
|
447
448
|
|
|
448
449
|
.block-editor-block-patterns-list {
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* External dependencies
|
|
3
3
|
*/
|
|
4
|
-
import { render,
|
|
4
|
+
import { render, screen } from '@testing-library/react';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* WordPress dependencies
|
|
8
8
|
*/
|
|
9
9
|
import { registerBlockType, unregisterBlockType } from '@wordpress/blocks';
|
|
10
|
-
import { useSelect } from '@wordpress/data';
|
|
11
10
|
|
|
12
11
|
/**
|
|
13
12
|
* Internal dependencies
|
|
@@ -22,35 +21,6 @@ jest.mock( '../hooks/use-block-types-state', () => {
|
|
|
22
21
|
return mock;
|
|
23
22
|
} );
|
|
24
23
|
|
|
25
|
-
jest.mock( '@wordpress/data/src/components/use-select', () => {
|
|
26
|
-
// This allows us to tweak the returned value on each test.
|
|
27
|
-
const mock = jest.fn();
|
|
28
|
-
return mock;
|
|
29
|
-
} );
|
|
30
|
-
|
|
31
|
-
jest.mock( '@wordpress/data/src/components/use-dispatch', () => {
|
|
32
|
-
return {
|
|
33
|
-
useDispatch: () => ( {} ),
|
|
34
|
-
};
|
|
35
|
-
} );
|
|
36
|
-
|
|
37
|
-
const debouncedSpeak = jest.fn();
|
|
38
|
-
|
|
39
|
-
function InserterBlockList( props ) {
|
|
40
|
-
return <ReusableBlocksTab debouncedSpeak={ debouncedSpeak } { ...props } />;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
const initializeAllClosedMenuState = ( propOverrides ) => {
|
|
44
|
-
const { container } = render( <InserterBlockList { ...propOverrides } /> );
|
|
45
|
-
const activeTabs = container.querySelectorAll(
|
|
46
|
-
'.components-panel__body.is-opened button.components-panel__body-toggle'
|
|
47
|
-
);
|
|
48
|
-
activeTabs.forEach( ( tab ) => {
|
|
49
|
-
fireEvent.click( tab );
|
|
50
|
-
} );
|
|
51
|
-
return container;
|
|
52
|
-
};
|
|
53
|
-
|
|
54
24
|
describe( 'InserterMenu', () => {
|
|
55
25
|
beforeAll( () => {
|
|
56
26
|
registerBlockType( 'core/block', {
|
|
@@ -59,19 +29,17 @@ describe( 'InserterMenu', () => {
|
|
|
59
29
|
edit: () => {},
|
|
60
30
|
} );
|
|
61
31
|
} );
|
|
32
|
+
|
|
62
33
|
afterAll( () => {
|
|
63
34
|
unregisterBlockType( 'core/block' );
|
|
64
35
|
} );
|
|
65
|
-
beforeEach( () => {
|
|
66
|
-
debouncedSpeak.mockClear();
|
|
67
36
|
|
|
37
|
+
beforeEach( () => {
|
|
68
38
|
useBlockTypesState.mockImplementation( () => [
|
|
69
39
|
items,
|
|
70
40
|
categories,
|
|
71
41
|
collections,
|
|
72
42
|
] );
|
|
73
|
-
|
|
74
|
-
useSelect.mockImplementation( () => false );
|
|
75
43
|
} );
|
|
76
44
|
|
|
77
45
|
it( 'should show nothing if there are no items', () => {
|
|
@@ -81,36 +49,25 @@ describe( 'InserterMenu', () => {
|
|
|
81
49
|
categories,
|
|
82
50
|
collections,
|
|
83
51
|
] );
|
|
84
|
-
const { container } = render(
|
|
85
|
-
<InserterBlockList filterValue="random" />
|
|
86
|
-
);
|
|
87
|
-
const visibleBlocks = container.querySelector(
|
|
88
|
-
'.block-editor-block-types-list__item'
|
|
89
|
-
);
|
|
90
52
|
|
|
91
|
-
|
|
53
|
+
render( <ReusableBlocksTab filterValue="random" /> );
|
|
54
|
+
|
|
55
|
+
expect( screen.queryByRole( 'option' ) ).not.toBeInTheDocument();
|
|
92
56
|
} );
|
|
93
57
|
|
|
94
58
|
it( 'should list reusable blocks', () => {
|
|
95
|
-
|
|
96
|
-
const blocks = container.querySelectorAll(
|
|
97
|
-
'.block-editor-block-types-list__item-title'
|
|
98
|
-
);
|
|
59
|
+
render( <ReusableBlocksTab /> );
|
|
99
60
|
|
|
100
|
-
expect(
|
|
101
|
-
|
|
61
|
+
expect(
|
|
62
|
+
screen.getByRole( 'option', { name: 'My reusable block' } )
|
|
63
|
+
).toBeVisible();
|
|
102
64
|
} );
|
|
103
65
|
|
|
104
66
|
it( 'should trim whitespace of search terms', () => {
|
|
105
|
-
|
|
106
|
-
<InserterBlockList filterValue=" my reusable" />
|
|
107
|
-
);
|
|
108
|
-
|
|
109
|
-
const blocks = container.querySelectorAll(
|
|
110
|
-
'.block-editor-block-types-list__item-title'
|
|
111
|
-
);
|
|
67
|
+
render( <ReusableBlocksTab filterValue=" my reusable" /> );
|
|
112
68
|
|
|
113
|
-
expect(
|
|
114
|
-
|
|
69
|
+
expect(
|
|
70
|
+
screen.getByRole( 'option', { name: 'My reusable block' } )
|
|
71
|
+
).toBeVisible();
|
|
115
72
|
} );
|
|
116
73
|
} );
|
|
@@ -45,6 +45,12 @@ describe( 'getNormalizedSearchTerms', () => {
|
|
|
45
45
|
|
|
46
46
|
it( 'should support non-latin letters', () => {
|
|
47
47
|
expect( getNormalizedSearchTerms( 'მედია' ) ).toEqual( [ 'მედია' ] );
|
|
48
|
+
expect(
|
|
49
|
+
getNormalizedSearchTerms( '师父领进门,修行在个人。' )
|
|
50
|
+
).toEqual( [ '师父领进门', '修行在个人' ] );
|
|
51
|
+
expect(
|
|
52
|
+
getNormalizedSearchTerms( 'Бързата работа – срам за майстора.' )
|
|
53
|
+
).toEqual( [ 'бързата', 'работа', 'срам', 'за', 'майстора' ] );
|
|
48
54
|
} );
|
|
49
55
|
} );
|
|
50
56
|
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
# Letter spacing control
|
|
2
|
+
|
|
3
|
+
The `LetterSpacingControl` component renders a [`UnitControl`](https://github.com/WordPress/gutenberg/blob/trunk/packages/block-editor/src/components/unit-control/README.md) that lets the user enter a numeric value and select a unit, for example px or rem.
|
|
4
|
+
|
|
5
|
+
This component is used for blocks that display text, commonly inside a
|
|
6
|
+
[`ToolsPanelItem`](https://github.com/WordPress/gutenberg/blob/trunk/packages/components/src/tools-panel/tools-panel-item/README.md).
|
|
7
|
+
|
|
8
|
+
## Table of contents
|
|
9
|
+
|
|
10
|
+
1. [Development guidelines](#development-guidelines)
|
|
11
|
+
2. [Related components](#related-components)
|
|
12
|
+
|
|
13
|
+
## Development guidelines
|
|
14
|
+
|
|
15
|
+
### Usage
|
|
16
|
+
|
|
17
|
+
Renders a letter spacing control.
|
|
18
|
+
|
|
19
|
+
```jsx
|
|
20
|
+
import { LetterSpacingControl } from '@wordpress/block-editor';
|
|
21
|
+
|
|
22
|
+
const MyLetterSpacingControl = () => (
|
|
23
|
+
<LetterSpacingControl
|
|
24
|
+
value={ value }
|
|
25
|
+
onChange={ onChange }
|
|
26
|
+
__unstableInputWidth="auto"
|
|
27
|
+
/>
|
|
28
|
+
);
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
### Props
|
|
32
|
+
|
|
33
|
+
### `value`
|
|
34
|
+
|
|
35
|
+
- **Type:** `String`
|
|
36
|
+
- **Default:** `undefined`
|
|
37
|
+
|
|
38
|
+
The current value of the letter spacing setting.
|
|
39
|
+
|
|
40
|
+
### `onChange`
|
|
41
|
+
|
|
42
|
+
- **Type:** `Function`
|
|
43
|
+
|
|
44
|
+
A callback function invoked when the value is changed.
|
|
45
|
+
|
|
46
|
+
### `_unstableInputWidth`
|
|
47
|
+
|
|
48
|
+
- **Type:** `string|number|undefined`
|
|
49
|
+
- **Default:** `undefined`
|
|
50
|
+
|
|
51
|
+
Input width to pass through to inner UnitControl. Should be a valid CSS value.
|
|
52
|
+
|
|
53
|
+
## Related components
|
|
54
|
+
|
|
55
|
+
Block Editor components are components that can be used to compose the UI of your block editor. Thus, they can only be used under a [`BlockEditorProvider`](https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/provider/README.md) in the components tree.
|
|
@@ -192,7 +192,7 @@ A `suggestion` should have the following shape:
|
|
|
192
192
|
)}
|
|
193
193
|
/>
|
|
194
194
|
```
|
|
195
|
-
### renderControlBottom
|
|
195
|
+
### renderControlBottom
|
|
196
196
|
|
|
197
197
|
- Type: `Function`
|
|
198
198
|
- Required: No
|
|
@@ -338,7 +338,7 @@ See the [createSuggestion](#createSuggestion) section of this file to learn more
|
|
|
338
338
|
<LinkControlSearchInput
|
|
339
339
|
renderSuggestions={( { suggestions } ) => {
|
|
340
340
|
return (
|
|
341
|
-
<Popover focusOnMount={ false }
|
|
341
|
+
<Popover focusOnMount={ false } placement="bottom">
|
|
342
342
|
<ul>
|
|
343
343
|
{ suggestions.map( () => ( <li key={ `${ suggestion.id }-${ suggestion.type }` }>{ suggestion.title }</li> ) ) }
|
|
344
344
|
</ul>
|
|
@@ -352,7 +352,7 @@ See the [createSuggestion](#createSuggestion) section of this file to learn more
|
|
|
352
352
|
<LinkControlSearchInput
|
|
353
353
|
renderSuggestions={( suggestionsProps ) => {
|
|
354
354
|
return (
|
|
355
|
-
<Popover focusOnMount={ false }
|
|
355
|
+
<Popover focusOnMount={ false } placement="bottom">
|
|
356
356
|
<LinkControlSearchResults { ...suggestionsProps } />
|
|
357
357
|
</Popover>
|
|
358
358
|
);
|
|
@@ -20,6 +20,7 @@ import LinkControlSettingsDrawer from './settings-drawer';
|
|
|
20
20
|
import LinkControlSearchInput from './search-input';
|
|
21
21
|
import LinkPreview from './link-preview';
|
|
22
22
|
import useCreatePage from './use-create-page';
|
|
23
|
+
import useInternalInputValue from './use-internal-input-value';
|
|
23
24
|
import { ViewerFill } from './viewer-slot';
|
|
24
25
|
import { DEFAULT_LINK_SETTINGS } from './constants';
|
|
25
26
|
|
|
@@ -132,22 +133,19 @@ function LinkControl( {
|
|
|
132
133
|
const isMounting = useRef( true );
|
|
133
134
|
const wrapperNode = useRef();
|
|
134
135
|
const textInputRef = useRef();
|
|
136
|
+
const isEndingEditWithFocus = useRef( false );
|
|
137
|
+
|
|
138
|
+
const [ internalUrlInputValue, setInternalUrlInputValue ] =
|
|
139
|
+
useInternalInputValue( value?.url || '' );
|
|
140
|
+
|
|
141
|
+
const [ internalTextInputValue, setInternalTextInputValue ] =
|
|
142
|
+
useInternalInputValue( value?.title || '' );
|
|
135
143
|
|
|
136
|
-
const [ internalInputValue, setInternalInputValue ] = useState(
|
|
137
|
-
value?.url || ''
|
|
138
|
-
);
|
|
139
|
-
const [ internalTextValue, setInternalTextValue ] = useState(
|
|
140
|
-
value?.title || ''
|
|
141
|
-
);
|
|
142
|
-
const currentInputValue = propInputValue || internalInputValue;
|
|
143
144
|
const [ isEditingLink, setIsEditingLink ] = useState(
|
|
144
145
|
forceIsEditingLink !== undefined
|
|
145
146
|
? forceIsEditingLink
|
|
146
147
|
: ! value || ! value.url
|
|
147
148
|
);
|
|
148
|
-
const isEndingEditWithFocus = useRef( false );
|
|
149
|
-
|
|
150
|
-
const currentInputIsEmpty = ! currentInputValue?.trim()?.length;
|
|
151
149
|
|
|
152
150
|
const { createPage, isCreatingPage, errorMessage } =
|
|
153
151
|
useCreatePage( createSuggestion );
|
|
@@ -191,53 +189,35 @@ function LinkControl( {
|
|
|
191
189
|
isEndingEditWithFocus.current = false;
|
|
192
190
|
}, [ isEditingLink, isCreatingPage ] );
|
|
193
191
|
|
|
194
|
-
useEffect( () => {
|
|
195
|
-
/**
|
|
196
|
-
* If the value's `text` property changes then sync this
|
|
197
|
-
* back up with state.
|
|
198
|
-
*/
|
|
199
|
-
if ( value?.title && value.title !== internalTextValue ) {
|
|
200
|
-
setInternalTextValue( value.title );
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
/**
|
|
204
|
-
* Update the state value internalInputValue if the url value changes
|
|
205
|
-
* for example when clicking on another anchor
|
|
206
|
-
*/
|
|
207
|
-
if ( value?.url ) {
|
|
208
|
-
setInternalInputValue( value.url );
|
|
209
|
-
}
|
|
210
|
-
}, [ value ] );
|
|
211
|
-
|
|
212
192
|
/**
|
|
213
193
|
* Cancels editing state and marks that focus may need to be restored after
|
|
214
194
|
* the next render, if focus was within the wrapper when editing finished.
|
|
215
195
|
*/
|
|
216
|
-
|
|
196
|
+
const stopEditing = () => {
|
|
217
197
|
isEndingEditWithFocus.current = !! wrapperNode.current?.contains(
|
|
218
198
|
wrapperNode.current.ownerDocument.activeElement
|
|
219
199
|
);
|
|
220
200
|
|
|
221
201
|
setIsEditingLink( false );
|
|
222
|
-
}
|
|
202
|
+
};
|
|
223
203
|
|
|
224
204
|
const handleSelectSuggestion = ( updatedValue ) => {
|
|
225
205
|
onChange( {
|
|
226
206
|
...updatedValue,
|
|
227
|
-
title:
|
|
207
|
+
title: internalTextInputValue || updatedValue?.title,
|
|
228
208
|
} );
|
|
229
209
|
stopEditing();
|
|
230
210
|
};
|
|
231
211
|
|
|
232
212
|
const handleSubmit = () => {
|
|
233
213
|
if (
|
|
234
|
-
|
|
235
|
-
|
|
214
|
+
currentUrlInputValue !== value?.url ||
|
|
215
|
+
internalTextInputValue !== value?.title
|
|
236
216
|
) {
|
|
237
217
|
onChange( {
|
|
238
218
|
...value,
|
|
239
|
-
url:
|
|
240
|
-
title:
|
|
219
|
+
url: currentUrlInputValue,
|
|
220
|
+
title: internalTextInputValue,
|
|
241
221
|
} );
|
|
242
222
|
}
|
|
243
223
|
stopEditing();
|
|
@@ -254,6 +234,10 @@ function LinkControl( {
|
|
|
254
234
|
}
|
|
255
235
|
};
|
|
256
236
|
|
|
237
|
+
const currentUrlInputValue = propInputValue || internalUrlInputValue;
|
|
238
|
+
|
|
239
|
+
const currentInputIsEmpty = ! currentUrlInputValue?.trim()?.length;
|
|
240
|
+
|
|
257
241
|
const shownUnlinkControl =
|
|
258
242
|
onRemove && value && ! isEditingLink && ! isCreatingPage;
|
|
259
243
|
|
|
@@ -289,8 +273,8 @@ function LinkControl( {
|
|
|
289
273
|
ref={ textInputRef }
|
|
290
274
|
className="block-editor-link-control__field block-editor-link-control__text-content"
|
|
291
275
|
label="Text"
|
|
292
|
-
value={
|
|
293
|
-
onChange={
|
|
276
|
+
value={ internalTextInputValue }
|
|
277
|
+
onChange={ setInternalTextInputValue }
|
|
294
278
|
onKeyDown={ handleSubmitWithEnter }
|
|
295
279
|
/>
|
|
296
280
|
) }
|
|
@@ -299,10 +283,10 @@ function LinkControl( {
|
|
|
299
283
|
currentLink={ value }
|
|
300
284
|
className="block-editor-link-control__field block-editor-link-control__search-input"
|
|
301
285
|
placeholder={ searchInputPlaceholder }
|
|
302
|
-
value={
|
|
286
|
+
value={ currentUrlInputValue }
|
|
303
287
|
withCreateSuggestion={ withCreateSuggestion }
|
|
304
288
|
onCreateSuggestion={ createPage }
|
|
305
|
-
onChange={
|
|
289
|
+
onChange={ setInternalUrlInputValue }
|
|
306
290
|
onSelect={ handleSelectSuggestion }
|
|
307
291
|
showInitialSuggestions={ showInitialSuggestions }
|
|
308
292
|
allowDirectEntry={ ! noDirectEntry }
|
|
@@ -111,7 +111,7 @@ const LinkControlSearchInput = forwardRef(
|
|
|
111
111
|
allowDirectEntry ||
|
|
112
112
|
( suggestion && Object.keys( suggestion ).length >= 1 )
|
|
113
113
|
) {
|
|
114
|
-
const { id, url, ...restLinkProps } = currentLink;
|
|
114
|
+
const { id, url, ...restLinkProps } = currentLink ?? {};
|
|
115
115
|
onSelect(
|
|
116
116
|
// Some direct entries don't have types or IDs, and we still need to clear the previous ones.
|
|
117
117
|
{ ...restLinkProps, ...suggestion },
|