@wordpress/block-editor 11.3.6 → 11.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 +3 -1
- package/build/components/block-lock/modal.js +1 -0
- package/build/components/block-lock/modal.js.map +1 -1
- package/build/components/block-popover/inbetween.js +10 -33
- package/build/components/block-popover/inbetween.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-styles/index.js +2 -1
- package/build/components/block-styles/index.js.map +1 -1
- package/build/components/block-types-list/index.native.js +2 -0
- package/build/components/block-types-list/index.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/colors-gradients/control.js +6 -3
- package/build/components/colors-gradients/control.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/font-appearance-control/index.js +0 -3
- package/build/components/font-appearance-control/index.js.map +1 -1
- 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 +142 -45
- package/build/components/global-styles/hooks.js.map +1 -1
- package/build/components/global-styles/index.js +38 -0
- package/build/components/global-styles/index.js.map +1 -1
- package/build/components/global-styles/typography-panel.js +434 -0
- package/build/components/global-styles/typography-panel.js.map +1 -0
- package/build/components/global-styles/use-global-styles-output.js +7 -3
- 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/iframe/index.js +17 -11
- package/build/components/iframe/index.js.map +1 -1
- package/build/components/image-editor/aspect-ratio-dropdown.js +2 -1
- package/build/components/image-editor/aspect-ratio-dropdown.js.map +1 -1
- package/build/components/image-size-control/index.js +6 -11
- package/build/components/image-size-control/index.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/block-patterns-tab.js +9 -15
- package/build/components/inserter/block-patterns-tab.js.map +1 -1
- package/build/components/inserter/block-types-tab.native.js +4 -1
- package/build/components/inserter/block-types-tab.native.js.map +1 -1
- package/build/components/inserter/reusable-blocks-tab.native.js +4 -1
- package/build/components/inserter/reusable-blocks-tab.native.js.map +1 -1
- package/build/components/inserter/search-results.native.js +4 -1
- package/build/components/inserter/search-results.native.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 +55 -28
- package/build/components/link-control/index.js.map +1 -1
- package/build/components/link-control/settings-drawer.js +72 -30
- package/build/components/link-control/settings-drawer.js.map +1 -1
- package/build/components/link-control/settings.js +53 -0
- package/build/components/link-control/settings.js.map +1 -0
- package/build/components/list-view/block.js +4 -2
- package/build/components/list-view/block.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/index.js +6 -1
- package/build/components/list-view/index.js.map +1 -1
- package/build/components/off-canvas-editor/appender.js +5 -10
- package/build/components/off-canvas-editor/appender.js.map +1 -1
- package/build/components/off-canvas-editor/block-contents.js +3 -2
- package/build/components/off-canvas-editor/block-contents.js.map +1 -1
- package/build/components/off-canvas-editor/branch.js +1 -0
- package/build/components/off-canvas-editor/branch.js.map +1 -1
- package/build/components/off-canvas-editor/index.js +7 -3
- package/build/components/off-canvas-editor/index.js.map +1 -1
- package/build/components/off-canvas-editor/leaf-more-menu.js +24 -4
- package/build/components/off-canvas-editor/leaf-more-menu.js.map +1 -1
- package/build/components/off-canvas-editor/link-ui.js +2 -0
- package/build/components/off-canvas-editor/link-ui.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/index.js +9 -45
- 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/url-input/index.js +2 -2
- package/build/components/url-input/index.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/dimensions.js +78 -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/font-family.js +2 -76
- package/build/hooks/font-family.js.map +1 -1
- package/build/hooks/font-size.js +3 -51
- package/build/hooks/font-size.js.map +1 -1
- package/build/hooks/gap.js +0 -201
- package/build/hooks/gap.js.map +1 -1
- package/build/hooks/index.js +2 -0
- package/build/hooks/index.js.map +1 -1
- package/build/hooks/layout.js +14 -5
- package/build/hooks/layout.js.map +1 -1
- package/build/hooks/line-height.js +0 -42
- package/build/hooks/line-height.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/typography.js +98 -128
- package/build/hooks/typography.js.map +1 -1
- package/build/hooks/utils.js +75 -0
- package/build/hooks/utils.js.map +1 -1
- package/build/layouts/flex.js +1 -0
- package/build/layouts/flex.js.map +1 -1
- package/build/store/actions.js +24 -12
- package/build/store/actions.js.map +1 -1
- package/build/store/reducer.js +53 -47
- package/build/store/reducer.js.map +1 -1
- package/build/store/selectors.js +22 -1
- package/build/store/selectors.js.map +1 -1
- package/build/utils/parse-css-unit-to-px.js +36 -3
- package/build/utils/parse-css-unit-to-px.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-popover/inbetween.js +10 -33
- package/build-module/components/block-popover/inbetween.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-styles/index.js +2 -1
- package/build-module/components/block-styles/index.js.map +1 -1
- package/build-module/components/block-types-list/index.native.js +2 -0
- package/build-module/components/block-types-list/index.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/colors-gradients/control.js +6 -3
- package/build-module/components/colors-gradients/control.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/font-appearance-control/index.js +2 -1
- package/build-module/components/font-appearance-control/index.js.map +1 -1
- 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 +138 -46
- 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 +415 -0
- package/build-module/components/global-styles/typography-panel.js.map +1 -0
- package/build-module/components/global-styles/use-global-styles-output.js +7 -3
- 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/iframe/index.js +17 -11
- package/build-module/components/iframe/index.js.map +1 -1
- package/build-module/components/image-editor/aspect-ratio-dropdown.js +2 -1
- package/build-module/components/image-editor/aspect-ratio-dropdown.js.map +1 -1
- package/build-module/components/image-size-control/index.js +7 -12
- package/build-module/components/image-size-control/index.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/block-patterns-tab.js +9 -15
- package/build-module/components/inserter/block-patterns-tab.js.map +1 -1
- package/build-module/components/inserter/block-types-tab.native.js +3 -1
- package/build-module/components/inserter/block-types-tab.native.js.map +1 -1
- package/build-module/components/inserter/reusable-blocks-tab.native.js +3 -1
- package/build-module/components/inserter/reusable-blocks-tab.native.js.map +1 -1
- package/build-module/components/inserter/search-results.native.js +3 -1
- package/build-module/components/inserter/search-results.native.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 +56 -28
- package/build-module/components/link-control/index.js.map +1 -1
- package/build-module/components/link-control/settings-drawer.js +68 -30
- package/build-module/components/link-control/settings-drawer.js.map +1 -1
- package/build-module/components/link-control/settings.js +44 -0
- package/build-module/components/link-control/settings.js.map +1 -0
- package/build-module/components/list-view/block.js +4 -2
- package/build-module/components/list-view/block.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/index.js +6 -1
- package/build-module/components/list-view/index.js.map +1 -1
- package/build-module/components/off-canvas-editor/appender.js +5 -10
- package/build-module/components/off-canvas-editor/appender.js.map +1 -1
- package/build-module/components/off-canvas-editor/block-contents.js +3 -2
- package/build-module/components/off-canvas-editor/block-contents.js.map +1 -1
- package/build-module/components/off-canvas-editor/branch.js +1 -0
- package/build-module/components/off-canvas-editor/branch.js.map +1 -1
- package/build-module/components/off-canvas-editor/index.js +7 -3
- package/build-module/components/off-canvas-editor/index.js.map +1 -1
- package/build-module/components/off-canvas-editor/leaf-more-menu.js +27 -7
- package/build-module/components/off-canvas-editor/leaf-more-menu.js.map +1 -1
- package/build-module/components/off-canvas-editor/link-ui.js +2 -0
- package/build-module/components/off-canvas-editor/link-ui.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/index.js +9 -45
- 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/url-input/index.js +2 -2
- package/build-module/components/url-input/index.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/dimensions.js +81 -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/font-family.js +3 -69
- package/build-module/hooks/font-family.js.map +1 -1
- package/build-module/hooks/font-size.js +6 -47
- package/build-module/hooks/font-size.js.map +1 -1
- package/build-module/hooks/gap.js +0 -182
- package/build-module/hooks/gap.js.map +1 -1
- package/build-module/hooks/index.js +1 -0
- package/build-module/hooks/index.js.map +1 -1
- package/build-module/hooks/layout.js +14 -5
- package/build-module/hooks/layout.js.map +1 -1
- package/build-module/hooks/line-height.js +0 -38
- package/build-module/hooks/line-height.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/typography.js +97 -123
- package/build-module/hooks/typography.js.map +1 -1
- package/build-module/hooks/utils.js +70 -0
- package/build-module/hooks/utils.js.map +1 -1
- package/build-module/layouts/flex.js +1 -0
- package/build-module/layouts/flex.js.map +1 -1
- package/build-module/store/actions.js +24 -12
- package/build-module/store/actions.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 -1
- package/build-module/store/selectors.js.map +1 -1
- package/build-module/utils/parse-css-unit-to-px.js +36 -3
- package/build-module/utils/parse-css-unit-to-px.js.map +1 -1
- package/build-style/style-rtl.css +54 -64
- package/build-style/style.css +54 -64
- package/package.json +31 -31
- package/src/components/block-draggable/test/__snapshots__/index.native.js.snap +24 -24
- 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 +15 -15
- package/src/components/block-popover/inbetween.js +21 -53
- package/src/components/block-settings-menu/block-settings-dropdown.js +4 -1
- package/src/components/block-styles/index.js +5 -1
- package/src/components/block-types-list/index.native.js +2 -0
- package/src/components/child-layout-control/index.js +106 -0
- package/src/components/color-palette/test/__snapshots__/control.js.snap +1 -1
- package/src/components/colors-gradients/control.js +3 -0
- package/src/components/date-format-picker/index.js +6 -8
- package/src/components/date-format-picker/style.scss +0 -5
- package/src/components/font-appearance-control/index.js +1 -1
- package/src/components/global-styles/dimensions-panel.js +627 -0
- package/src/components/global-styles/hooks.js +229 -66
- package/src/components/global-styles/index.js +9 -0
- package/src/components/global-styles/typography-panel.js +428 -0
- package/src/components/global-styles/use-global-styles-output.js +10 -5
- package/src/components/global-styles/utils.js +2 -0
- package/src/components/iframe/index.js +20 -18
- package/src/components/image-editor/aspect-ratio-dropdown.js +1 -0
- package/src/components/image-size-control/index.js +10 -12
- package/src/components/image-size-control/style.scss +3 -21
- package/src/components/index.native.js +5 -0
- package/src/components/inner-blocks/test/__snapshots__/index.js.snap +1 -1
- package/src/components/inserter/block-patterns-tab.js +9 -23
- package/src/components/inserter/block-types-tab.native.js +2 -0
- package/src/components/inserter/reusable-blocks-tab.native.js +2 -0
- package/src/components/inserter/search-results.native.js +2 -0
- 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 +69 -34
- package/src/components/link-control/settings-drawer.js +85 -29
- package/src/components/link-control/settings.js +42 -0
- package/src/components/link-control/style.scss +63 -37
- package/src/components/link-control/test/index.js +347 -9
- package/src/components/list-view/block.js +7 -1
- package/src/components/list-view/expander.js +1 -0
- package/src/components/list-view/index.js +5 -0
- package/src/components/media-replace-flow/style.scss +7 -9
- package/src/components/media-replace-flow/test/index.js +1 -1
- package/src/components/off-canvas-editor/appender.js +13 -16
- package/src/components/off-canvas-editor/block-contents.js +2 -1
- package/src/components/off-canvas-editor/branch.js +1 -0
- package/src/components/off-canvas-editor/index.js +8 -2
- package/src/components/off-canvas-editor/leaf-more-menu.js +52 -15
- package/src/components/off-canvas-editor/link-ui.js +2 -0
- package/src/components/responsive-block-control/index.js +1 -0
- package/src/components/rich-text/index.js +8 -46
- package/src/components/rich-text/use-delete.js +59 -0
- package/src/components/rich-text/use-input-rules.js +13 -5
- package/src/components/url-input/index.js +3 -2
- package/src/components/url-popover/stories/index.js +1 -0
- package/src/components/writing-flow/use-selection-observer.js +5 -1
- package/src/hooks/align.js +1 -1
- package/src/hooks/dimensions.js +97 -269
- package/src/hooks/duotone.js +100 -30
- package/src/hooks/font-family.js +0 -58
- package/src/hooks/font-size.js +1 -36
- package/src/hooks/gap.js +0 -201
- package/src/hooks/index.js +1 -0
- package/src/hooks/layout.js +19 -6
- package/src/hooks/line-height.js +0 -33
- package/src/hooks/margin.js +1 -164
- package/src/hooks/padding.js +1 -163
- package/src/hooks/test/__snapshots__/align.native.js.snap +24 -24
- package/src/hooks/test/duotone.js +102 -0
- package/src/hooks/typography.js +112 -213
- package/src/hooks/utils.js +90 -0
- package/src/layouts/flex.js +1 -0
- package/src/store/actions.js +12 -4
- package/src/store/reducer.js +68 -43
- package/src/store/selectors.js +20 -1
- package/src/store/test/actions.js +4 -2
- package/src/utils/parse-css-unit-to-px.js +35 -5
- package/src/utils/test/parse-css-unit-to-px.js +12 -0
- package/build/hooks/child-layout.js +0 -213
- package/build/hooks/child-layout.js.map +0 -1
- package/build/hooks/font-appearance.js +0 -188
- package/build/hooks/font-appearance.js.map +0 -1
- package/build/hooks/letter-spacing.js +0 -129
- package/build/hooks/letter-spacing.js.map +0 -1
- package/build/hooks/min-height.js +0 -139
- package/build/hooks/min-height.js.map +0 -1
- package/build/hooks/text-decoration.js +0 -130
- package/build/hooks/text-decoration.js.map +0 -1
- package/build/hooks/text-transform.js +0 -130
- package/build/hooks/text-transform.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/font-appearance.js +0 -161
- package/build-module/hooks/font-appearance.js.map +0 -1
- package/build-module/hooks/letter-spacing.js +0 -107
- package/build-module/hooks/letter-spacing.js.map +0 -1
- package/build-module/hooks/min-height.js +0 -116
- package/build-module/hooks/min-height.js.map +0 -1
- package/build-module/hooks/text-decoration.js +0 -108
- package/build-module/hooks/text-decoration.js.map +0 -1
- package/build-module/hooks/text-transform.js +0 -108
- package/build-module/hooks/text-transform.js.map +0 -1
- package/src/hooks/child-layout.js +0 -195
- package/src/hooks/font-appearance.js +0 -146
- package/src/hooks/letter-spacing.js +0 -101
- package/src/hooks/min-height.js +0 -104
- package/src/hooks/text-decoration.js +0 -102
- package/src/hooks/text-transform.js +0 -101
|
@@ -28,7 +28,7 @@ import BlockPatternList from '../block-patterns-list';
|
|
|
28
28
|
import PatternsExplorerModal from './block-patterns-explorer/explorer';
|
|
29
29
|
import MobileTabNavigation from './mobile-tab-navigation';
|
|
30
30
|
|
|
31
|
-
//
|
|
31
|
+
// Preferred order of pattern categories. Any other categories should
|
|
32
32
|
// be at the bottom without any re-ordering.
|
|
33
33
|
const patternCategoriesOrder = [
|
|
34
34
|
'featured',
|
|
@@ -68,28 +68,14 @@ function usePatternsCategories( rootClientId ) {
|
|
|
68
68
|
pattern.categories?.includes( category.name )
|
|
69
69
|
)
|
|
70
70
|
)
|
|
71
|
-
.sort( ( { name:
|
|
72
|
-
//
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
) {
|
|
80
|
-
return 0;
|
|
81
|
-
}
|
|
82
|
-
if (
|
|
83
|
-
[ currentName, nextName ].every( ( categoryName ) =>
|
|
84
|
-
patternCategoriesOrder.includes( categoryName )
|
|
85
|
-
)
|
|
86
|
-
) {
|
|
87
|
-
return (
|
|
88
|
-
patternCategoriesOrder.indexOf( currentName ) -
|
|
89
|
-
patternCategoriesOrder.indexOf( nextName )
|
|
90
|
-
);
|
|
91
|
-
}
|
|
92
|
-
return patternCategoriesOrder.includes( currentName ) ? -1 : 1;
|
|
71
|
+
.sort( ( { name: aName }, { name: bName } ) => {
|
|
72
|
+
// Sort categories according to `patternCategoriesOrder`.
|
|
73
|
+
let aIndex = patternCategoriesOrder.indexOf( aName );
|
|
74
|
+
let bIndex = patternCategoriesOrder.indexOf( bName );
|
|
75
|
+
// All other categories should come after that.
|
|
76
|
+
if ( aIndex < 0 ) aIndex = patternCategoriesOrder.length;
|
|
77
|
+
if ( bIndex < 0 ) bIndex = patternCategoriesOrder.length;
|
|
78
|
+
return aIndex - bIndex;
|
|
93
79
|
} );
|
|
94
80
|
|
|
95
81
|
if (
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
4
|
import { useMemo } from '@wordpress/element';
|
|
5
|
+
import { __ } from '@wordpress/i18n';
|
|
5
6
|
|
|
6
7
|
/**
|
|
7
8
|
* Internal dependencies
|
|
@@ -66,6 +67,7 @@ function BlockTypesTab( { onSelect, rootClientId, listProps } ) {
|
|
|
66
67
|
sections={ sections }
|
|
67
68
|
onSelect={ handleSelect }
|
|
68
69
|
listProps={ listProps }
|
|
70
|
+
label={ __( 'Blocks menu' ) }
|
|
69
71
|
/>
|
|
70
72
|
);
|
|
71
73
|
}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
4
|
import { useSelect } from '@wordpress/data';
|
|
5
|
+
import { __ } from '@wordpress/i18n';
|
|
5
6
|
|
|
6
7
|
/**
|
|
7
8
|
* Internal dependencies
|
|
@@ -31,6 +32,7 @@ function ReusableBlocksTab( { onSelect, rootClientId, listProps } ) {
|
|
|
31
32
|
sections={ sections }
|
|
32
33
|
onSelect={ onSelect }
|
|
33
34
|
listProps={ listProps }
|
|
35
|
+
label={ __( 'Reusable blocks' ) }
|
|
34
36
|
/>
|
|
35
37
|
);
|
|
36
38
|
}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
4
|
import { useSelect } from '@wordpress/data';
|
|
5
|
+
import { __ } from '@wordpress/i18n';
|
|
5
6
|
|
|
6
7
|
/**
|
|
7
8
|
* Internal dependencies
|
|
@@ -54,6 +55,7 @@ function InserterSearchResults( {
|
|
|
54
55
|
sections={ [ createInserterSection( { key: 'search', items } ) ] }
|
|
55
56
|
onSelect={ handleSelect }
|
|
56
57
|
listProps={ listProps }
|
|
58
|
+
label={ __( 'Blocks' ) }
|
|
57
59
|
/>
|
|
58
60
|
);
|
|
59
61
|
}
|
|
@@ -2,21 +2,21 @@
|
|
|
2
2
|
|
|
3
3
|
exports[`Inserter can add blocks adds new block at the end of post 1`] = `
|
|
4
4
|
"<!-- wp:spacer -->
|
|
5
|
-
<div style
|
|
5
|
+
<div style="height:100px" aria-hidden="true" class="wp-block-spacer"></div>
|
|
6
6
|
<!-- /wp:spacer -->
|
|
7
7
|
|
|
8
8
|
<!-- wp:heading -->
|
|
9
|
-
<h2 class
|
|
9
|
+
<h2 class="wp-block-heading"></h2>
|
|
10
10
|
<!-- /wp:heading -->"
|
|
11
11
|
`;
|
|
12
12
|
|
|
13
13
|
exports[`Inserter can add blocks after another block 1`] = `
|
|
14
14
|
"<!-- wp:spacer -->
|
|
15
|
-
<div style
|
|
15
|
+
<div style="height:100px" aria-hidden="true" class="wp-block-spacer"></div>
|
|
16
16
|
<!-- /wp:spacer -->
|
|
17
17
|
|
|
18
18
|
<!-- wp:heading -->
|
|
19
|
-
<h2 class
|
|
19
|
+
<h2 class="wp-block-heading"></h2>
|
|
20
20
|
<!-- /wp:heading -->
|
|
21
21
|
|
|
22
22
|
<!-- wp:more -->
|
|
@@ -30,7 +30,7 @@ exports[`Inserter can add blocks after another block 1`] = `
|
|
|
30
30
|
|
|
31
31
|
exports[`Inserter can add blocks before another block 1`] = `
|
|
32
32
|
"<!-- wp:heading -->
|
|
33
|
-
<h2 class
|
|
33
|
+
<h2 class="wp-block-heading"></h2>
|
|
34
34
|
<!-- /wp:heading -->
|
|
35
35
|
|
|
36
36
|
<!-- wp:paragraph -->
|
|
@@ -40,11 +40,11 @@ exports[`Inserter can add blocks before another block 1`] = `
|
|
|
40
40
|
|
|
41
41
|
exports[`Inserter can add blocks creates a new Paragraph block tapping on the empty area below the last block 1`] = `
|
|
42
42
|
"<!-- wp:spacer -->
|
|
43
|
-
<div style
|
|
43
|
+
<div style="height:100px" aria-hidden="true" class="wp-block-spacer"></div>
|
|
44
44
|
<!-- /wp:spacer -->
|
|
45
45
|
|
|
46
46
|
<!-- wp:heading -->
|
|
47
|
-
<h2 class
|
|
47
|
+
<h2 class="wp-block-heading"></h2>
|
|
48
48
|
<!-- /wp:heading -->
|
|
49
49
|
|
|
50
50
|
<!-- wp:paragraph -->
|
|
@@ -54,7 +54,7 @@ exports[`Inserter can add blocks creates a new Paragraph block tapping on the em
|
|
|
54
54
|
|
|
55
55
|
exports[`Inserter can add blocks inserts between 2 existing blocks 1`] = `
|
|
56
56
|
"<!-- wp:spacer -->
|
|
57
|
-
<div style
|
|
57
|
+
<div style="height:100px" aria-hidden="true" class="wp-block-spacer"></div>
|
|
58
58
|
<!-- /wp:spacer -->
|
|
59
59
|
|
|
60
60
|
<!-- wp:more -->
|
|
@@ -62,17 +62,17 @@ exports[`Inserter can add blocks inserts between 2 existing blocks 1`] = `
|
|
|
62
62
|
<!-- /wp:more -->
|
|
63
63
|
|
|
64
64
|
<!-- wp:heading -->
|
|
65
|
-
<h2 class
|
|
65
|
+
<h2 class="wp-block-heading"></h2>
|
|
66
66
|
<!-- /wp:heading -->"
|
|
67
67
|
`;
|
|
68
68
|
|
|
69
69
|
exports[`Inserter can add blocks inserts block at the end of post when no block is selected 1`] = `
|
|
70
70
|
"<!-- wp:spacer -->
|
|
71
|
-
<div style
|
|
71
|
+
<div style="height:100px" aria-hidden="true" class="wp-block-spacer"></div>
|
|
72
72
|
<!-- /wp:spacer -->
|
|
73
73
|
|
|
74
74
|
<!-- wp:heading -->
|
|
75
|
-
<h2 class
|
|
75
|
+
<h2 class="wp-block-heading"></h2>
|
|
76
76
|
<!-- /wp:heading -->
|
|
77
77
|
|
|
78
78
|
<!-- wp:more -->
|
|
@@ -86,11 +86,11 @@ exports[`Inserter can add blocks to the beginning 1`] = `
|
|
|
86
86
|
<!-- /wp:more -->
|
|
87
87
|
|
|
88
88
|
<!-- wp:spacer -->
|
|
89
|
-
<div style
|
|
89
|
+
<div style="height:100px" aria-hidden="true" class="wp-block-spacer"></div>
|
|
90
90
|
<!-- /wp:spacer -->
|
|
91
91
|
|
|
92
92
|
<!-- wp:heading -->
|
|
93
|
-
<h2 class
|
|
93
|
+
<h2 class="wp-block-heading"></h2>
|
|
94
94
|
<!-- /wp:heading -->
|
|
95
95
|
|
|
96
96
|
<!-- wp:paragraph -->
|
|
@@ -100,11 +100,11 @@ exports[`Inserter can add blocks to the beginning 1`] = `
|
|
|
100
100
|
|
|
101
101
|
exports[`Inserter can add blocks to the end 1`] = `
|
|
102
102
|
"<!-- wp:spacer -->
|
|
103
|
-
<div style
|
|
103
|
+
<div style="height:100px" aria-hidden="true" class="wp-block-spacer"></div>
|
|
104
104
|
<!-- /wp:spacer -->
|
|
105
105
|
|
|
106
106
|
<!-- wp:heading -->
|
|
107
|
-
<h2 class
|
|
107
|
+
<h2 class="wp-block-heading"></h2>
|
|
108
108
|
<!-- /wp:heading -->
|
|
109
109
|
|
|
110
110
|
<!-- wp:paragraph -->
|
|
@@ -12,6 +12,7 @@ import {
|
|
|
12
12
|
} from '@wordpress/components';
|
|
13
13
|
import warning from '@wordpress/warning';
|
|
14
14
|
import deprecated from '@wordpress/deprecated';
|
|
15
|
+
import { useEffect } from '@wordpress/element';
|
|
15
16
|
|
|
16
17
|
/**
|
|
17
18
|
* Internal dependencies
|
|
@@ -23,6 +24,7 @@ export default function InspectorControlsFill( {
|
|
|
23
24
|
children,
|
|
24
25
|
group = 'default',
|
|
25
26
|
__experimentalGroup,
|
|
27
|
+
resetAllFilter,
|
|
26
28
|
} ) {
|
|
27
29
|
if ( __experimentalGroup ) {
|
|
28
30
|
deprecated(
|
|
@@ -50,18 +52,40 @@ export default function InspectorControlsFill( {
|
|
|
50
52
|
<StyleProvider document={ document }>
|
|
51
53
|
<Fill>
|
|
52
54
|
{ ( fillProps ) => {
|
|
53
|
-
// Children passed to InspectorControlsFill will not have
|
|
54
|
-
// access to any React Context whose Provider is part of
|
|
55
|
-
// the InspectorControlsSlot tree. So we re-create the
|
|
56
|
-
// Provider in this subtree.
|
|
57
|
-
const value = ! isEmpty( fillProps ) ? fillProps : null;
|
|
58
55
|
return (
|
|
59
|
-
<
|
|
60
|
-
{
|
|
61
|
-
|
|
56
|
+
<ToolsPanelInspectorControl
|
|
57
|
+
fillProps={ fillProps }
|
|
58
|
+
children={ children }
|
|
59
|
+
resetAllFilter={ resetAllFilter }
|
|
60
|
+
/>
|
|
62
61
|
);
|
|
63
62
|
} }
|
|
64
63
|
</Fill>
|
|
65
64
|
</StyleProvider>
|
|
66
65
|
);
|
|
67
66
|
}
|
|
67
|
+
|
|
68
|
+
function ToolsPanelInspectorControl( { children, resetAllFilter, fillProps } ) {
|
|
69
|
+
const { registerResetAllFilter, deregisterResetAllFilter } = fillProps;
|
|
70
|
+
useEffect( () => {
|
|
71
|
+
if ( resetAllFilter && registerResetAllFilter ) {
|
|
72
|
+
registerResetAllFilter( resetAllFilter );
|
|
73
|
+
}
|
|
74
|
+
return () => {
|
|
75
|
+
if ( resetAllFilter && deregisterResetAllFilter ) {
|
|
76
|
+
deregisterResetAllFilter( resetAllFilter );
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
}, [ resetAllFilter, registerResetAllFilter, deregisterResetAllFilter ] );
|
|
80
|
+
|
|
81
|
+
// Children passed to InspectorControlsFill will not have
|
|
82
|
+
// access to any React Context whose Provider is part of
|
|
83
|
+
// the InspectorControlsSlot tree. So we re-create the
|
|
84
|
+
// Provider in this subtree.
|
|
85
|
+
const value = ! isEmpty( fillProps ) ? fillProps : null;
|
|
86
|
+
return (
|
|
87
|
+
<ToolsPanelContext.Provider value={ value }>
|
|
88
|
+
{ children }
|
|
89
|
+
</ToolsPanelContext.Provider>
|
|
90
|
+
);
|
|
91
|
+
}
|
|
@@ -6,8 +6,7 @@ import classnames from 'classnames';
|
|
|
6
6
|
/**
|
|
7
7
|
* WordPress dependencies
|
|
8
8
|
*/
|
|
9
|
-
import { Button, Spinner, Notice
|
|
10
|
-
import { keyboardReturn } from '@wordpress/icons';
|
|
9
|
+
import { Button, Spinner, Notice } from '@wordpress/components';
|
|
11
10
|
import { __ } from '@wordpress/i18n';
|
|
12
11
|
import { useRef, useState, useEffect } from '@wordpress/element';
|
|
13
12
|
import { focus } from '@wordpress/dom';
|
|
@@ -113,6 +112,7 @@ function LinkControl( {
|
|
|
113
112
|
settings = DEFAULT_LINK_SETTINGS,
|
|
114
113
|
onChange = noop,
|
|
115
114
|
onRemove,
|
|
115
|
+
onCancel,
|
|
116
116
|
noDirectEntry = false,
|
|
117
117
|
showSuggestions = true,
|
|
118
118
|
showInitialSuggestions,
|
|
@@ -136,6 +136,8 @@ function LinkControl( {
|
|
|
136
136
|
const textInputRef = useRef();
|
|
137
137
|
const isEndingEditWithFocus = useRef( false );
|
|
138
138
|
|
|
139
|
+
const [ settingsOpen, setSettingsOpen ] = useState( false );
|
|
140
|
+
|
|
139
141
|
const [ internalUrlInputValue, setInternalUrlInputValue ] =
|
|
140
142
|
useInternalInputValue( value?.url || '' );
|
|
141
143
|
|
|
@@ -190,6 +192,8 @@ function LinkControl( {
|
|
|
190
192
|
isEndingEditWithFocus.current = false;
|
|
191
193
|
}, [ isEditingLink, isCreatingPage ] );
|
|
192
194
|
|
|
195
|
+
const hasLinkValue = value?.url?.trim()?.length > 0;
|
|
196
|
+
|
|
193
197
|
/**
|
|
194
198
|
* Cancels editing state and marks that focus may need to be restored after
|
|
195
199
|
* the next render, if focus was within the wrapper when editing finished.
|
|
@@ -199,6 +203,7 @@ function LinkControl( {
|
|
|
199
203
|
wrapperNode.current.ownerDocument.activeElement
|
|
200
204
|
);
|
|
201
205
|
|
|
206
|
+
setSettingsOpen( false );
|
|
202
207
|
setIsEditingLink( false );
|
|
203
208
|
};
|
|
204
209
|
|
|
@@ -235,6 +240,29 @@ function LinkControl( {
|
|
|
235
240
|
}
|
|
236
241
|
};
|
|
237
242
|
|
|
243
|
+
const resetInternalValues = () => {
|
|
244
|
+
setInternalUrlInputValue( value?.url );
|
|
245
|
+
setInternalTextInputValue( value?.title );
|
|
246
|
+
};
|
|
247
|
+
|
|
248
|
+
const handleCancel = ( event ) => {
|
|
249
|
+
event.preventDefault();
|
|
250
|
+
event.stopPropagation();
|
|
251
|
+
|
|
252
|
+
// Ensure that any unsubmitted input changes are reset.
|
|
253
|
+
resetInternalValues();
|
|
254
|
+
|
|
255
|
+
if ( hasLinkValue ) {
|
|
256
|
+
// If there is a link then exist editing mode and show preview.
|
|
257
|
+
stopEditing();
|
|
258
|
+
} else {
|
|
259
|
+
// If there is no link value, then remove the link entirely.
|
|
260
|
+
onRemove?.();
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
onCancel?.();
|
|
264
|
+
};
|
|
265
|
+
|
|
238
266
|
const currentUrlInputValue = propInputValue || internalUrlInputValue;
|
|
239
267
|
|
|
240
268
|
const currentInputIsEmpty = ! currentUrlInputValue?.trim()?.length;
|
|
@@ -242,12 +270,14 @@ function LinkControl( {
|
|
|
242
270
|
const shownUnlinkControl =
|
|
243
271
|
onRemove && value && ! isEditingLink && ! isCreatingPage;
|
|
244
272
|
|
|
245
|
-
const
|
|
273
|
+
const showSettings = !! settings?.length;
|
|
246
274
|
|
|
247
275
|
// Only show text control once a URL value has been committed
|
|
248
276
|
// and it isn't just empty whitespace.
|
|
249
277
|
// See https://github.com/WordPress/gutenberg/pull/33849/#issuecomment-932194927.
|
|
250
|
-
const showTextControl =
|
|
278
|
+
const showTextControl = hasLinkValue && hasTextControl;
|
|
279
|
+
|
|
280
|
+
const isEditing = ( isEditingLink || ! value ) && ! isCreatingPage;
|
|
251
281
|
|
|
252
282
|
return (
|
|
253
283
|
<div
|
|
@@ -261,7 +291,7 @@ function LinkControl( {
|
|
|
261
291
|
</div>
|
|
262
292
|
) }
|
|
263
293
|
|
|
264
|
-
{
|
|
294
|
+
{ isEditing && (
|
|
265
295
|
<>
|
|
266
296
|
<div
|
|
267
297
|
className={ classnames( {
|
|
@@ -269,18 +299,6 @@ function LinkControl( {
|
|
|
269
299
|
'has-text-control': showTextControl,
|
|
270
300
|
} ) }
|
|
271
301
|
>
|
|
272
|
-
{ showTextControl && (
|
|
273
|
-
<TextControl
|
|
274
|
-
__nextHasNoMarginBottom
|
|
275
|
-
ref={ textInputRef }
|
|
276
|
-
className="block-editor-link-control__field block-editor-link-control__text-content"
|
|
277
|
-
label="Text"
|
|
278
|
-
value={ internalTextInputValue }
|
|
279
|
-
onChange={ setInternalTextInputValue }
|
|
280
|
-
onKeyDown={ handleSubmitWithEnter }
|
|
281
|
-
/>
|
|
282
|
-
) }
|
|
283
|
-
|
|
284
302
|
<LinkControlSearchInput
|
|
285
303
|
currentLink={ value }
|
|
286
304
|
className="block-editor-link-control__field block-editor-link-control__search-input"
|
|
@@ -299,17 +317,7 @@ function LinkControl( {
|
|
|
299
317
|
createSuggestionButtonText
|
|
300
318
|
}
|
|
301
319
|
useLabel={ showTextControl }
|
|
302
|
-
|
|
303
|
-
<div className="block-editor-link-control__search-actions">
|
|
304
|
-
<Button
|
|
305
|
-
onClick={ handleSubmit }
|
|
306
|
-
label={ __( 'Submit' ) }
|
|
307
|
-
icon={ keyboardReturn }
|
|
308
|
-
className="block-editor-link-control__search-submit"
|
|
309
|
-
disabled={ currentInputIsEmpty } // Disallow submitting empty values.
|
|
310
|
-
/>
|
|
311
|
-
</div>
|
|
312
|
-
</LinkControlSearchInput>
|
|
320
|
+
/>
|
|
313
321
|
</div>
|
|
314
322
|
{ errorMessage && (
|
|
315
323
|
<Notice
|
|
@@ -334,15 +342,42 @@ function LinkControl( {
|
|
|
334
342
|
/>
|
|
335
343
|
) }
|
|
336
344
|
|
|
337
|
-
{
|
|
345
|
+
{ isEditing && (
|
|
338
346
|
<div className="block-editor-link-control__tools">
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
347
|
+
{ ( showSettings || showTextControl ) && (
|
|
348
|
+
<LinkControlSettingsDrawer
|
|
349
|
+
settingsOpen={ settingsOpen }
|
|
350
|
+
setSettingsOpen={ setSettingsOpen }
|
|
351
|
+
showTextControl={ showTextControl }
|
|
352
|
+
showSettings={ showSettings }
|
|
353
|
+
textInputRef={ textInputRef }
|
|
354
|
+
internalTextInputValue={ internalTextInputValue }
|
|
355
|
+
setInternalTextInputValue={
|
|
356
|
+
setInternalTextInputValue
|
|
357
|
+
}
|
|
358
|
+
handleSubmitWithEnter={ handleSubmitWithEnter }
|
|
359
|
+
value={ value }
|
|
360
|
+
settings={ settings }
|
|
361
|
+
onChange={ onChange }
|
|
362
|
+
/>
|
|
363
|
+
) }
|
|
364
|
+
|
|
365
|
+
<div className="block-editor-link-control__search-actions">
|
|
366
|
+
<Button
|
|
367
|
+
variant="primary"
|
|
368
|
+
onClick={ handleSubmit }
|
|
369
|
+
className="xblock-editor-link-control__search-submit"
|
|
370
|
+
disabled={ currentInputIsEmpty } // Disallow submitting empty values.
|
|
371
|
+
>
|
|
372
|
+
{ __( 'Apply' ) }
|
|
373
|
+
</Button>
|
|
374
|
+
<Button variant="tertiary" onClick={ handleCancel }>
|
|
375
|
+
{ __( 'Cancel' ) }
|
|
376
|
+
</Button>
|
|
377
|
+
</div>
|
|
344
378
|
</div>
|
|
345
379
|
) }
|
|
380
|
+
|
|
346
381
|
{ renderControlBottom && renderControlBottom() }
|
|
347
382
|
</div>
|
|
348
383
|
);
|
|
@@ -1,41 +1,97 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
|
+
import {
|
|
5
|
+
Button,
|
|
6
|
+
TextControl,
|
|
7
|
+
__unstableMotion as motion,
|
|
8
|
+
__unstableAnimatePresence as AnimatePresence,
|
|
9
|
+
} from '@wordpress/components';
|
|
10
|
+
import { settings as settingsIcon } from '@wordpress/icons';
|
|
11
|
+
import { useReducedMotion, useInstanceId } from '@wordpress/compose';
|
|
4
12
|
import { __ } from '@wordpress/i18n';
|
|
5
|
-
import {
|
|
13
|
+
import { Fragment } from '@wordpress/element';
|
|
6
14
|
|
|
7
|
-
|
|
15
|
+
/**
|
|
16
|
+
* Internal dependencies
|
|
17
|
+
*/
|
|
18
|
+
import Settings from './settings';
|
|
8
19
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
20
|
+
function LinkSettingsDrawer( {
|
|
21
|
+
settingsOpen,
|
|
22
|
+
setSettingsOpen,
|
|
23
|
+
showTextControl,
|
|
24
|
+
showSettings,
|
|
25
|
+
textInputRef,
|
|
26
|
+
internalTextInputValue,
|
|
27
|
+
setInternalTextInputValue,
|
|
28
|
+
handleSubmitWithEnter,
|
|
29
|
+
value,
|
|
30
|
+
settings,
|
|
31
|
+
onChange,
|
|
32
|
+
} ) {
|
|
33
|
+
const prefersReducedMotion = useReducedMotion();
|
|
34
|
+
const MaybeAnimatePresence = prefersReducedMotion
|
|
35
|
+
? Fragment
|
|
36
|
+
: AnimatePresence;
|
|
37
|
+
const MaybeMotionDiv = prefersReducedMotion ? 'div' : motion.div;
|
|
13
38
|
|
|
14
|
-
const
|
|
15
|
-
onChange( {
|
|
16
|
-
...value,
|
|
17
|
-
[ setting.id ]: newValue,
|
|
18
|
-
} );
|
|
19
|
-
};
|
|
39
|
+
const id = useInstanceId( LinkSettingsDrawer );
|
|
20
40
|
|
|
21
|
-
const
|
|
22
|
-
<ToggleControl
|
|
23
|
-
className="block-editor-link-control__setting"
|
|
24
|
-
key={ setting.id }
|
|
25
|
-
label={ setting.title }
|
|
26
|
-
onChange={ handleSettingChange( setting ) }
|
|
27
|
-
checked={ value ? !! value[ setting.id ] : false }
|
|
28
|
-
/>
|
|
29
|
-
) );
|
|
41
|
+
const settingsDrawerId = `link-control-settings-drawer-${ id }`;
|
|
30
42
|
|
|
31
43
|
return (
|
|
32
|
-
|
|
33
|
-
<
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
44
|
+
<>
|
|
45
|
+
<Button
|
|
46
|
+
className="block-editor-link-control__drawer-toggle"
|
|
47
|
+
aria-expanded={ settingsOpen }
|
|
48
|
+
onClick={ () => setSettingsOpen( ! settingsOpen ) }
|
|
49
|
+
icon={ settingsIcon }
|
|
50
|
+
label={ __( 'Link Settings' ) }
|
|
51
|
+
aria-controls={ settingsDrawerId }
|
|
52
|
+
/>
|
|
53
|
+
<MaybeAnimatePresence>
|
|
54
|
+
{ settingsOpen && (
|
|
55
|
+
<MaybeMotionDiv
|
|
56
|
+
className="block-editor-link-control__drawer"
|
|
57
|
+
hidden={ ! settingsOpen }
|
|
58
|
+
id={ settingsDrawerId }
|
|
59
|
+
initial="collapsed"
|
|
60
|
+
animate="open"
|
|
61
|
+
exit="collapsed"
|
|
62
|
+
variants={ {
|
|
63
|
+
open: { opacity: 1, height: 'auto' },
|
|
64
|
+
collapsed: { opacity: 0, height: 0 },
|
|
65
|
+
} }
|
|
66
|
+
transition={ {
|
|
67
|
+
duration: 0.1,
|
|
68
|
+
} }
|
|
69
|
+
>
|
|
70
|
+
<div className="block-editor-link-control__drawer-inner">
|
|
71
|
+
{ showTextControl && (
|
|
72
|
+
<TextControl
|
|
73
|
+
__nextHasNoMarginBottom
|
|
74
|
+
ref={ textInputRef }
|
|
75
|
+
className="block-editor-link-control__setting block-editor-link-control__text-content"
|
|
76
|
+
label="Text"
|
|
77
|
+
value={ internalTextInputValue }
|
|
78
|
+
onChange={ setInternalTextInputValue }
|
|
79
|
+
onKeyDown={ handleSubmitWithEnter }
|
|
80
|
+
/>
|
|
81
|
+
) }
|
|
82
|
+
{ showSettings && (
|
|
83
|
+
<Settings
|
|
84
|
+
value={ value }
|
|
85
|
+
settings={ settings }
|
|
86
|
+
onChange={ onChange }
|
|
87
|
+
/>
|
|
88
|
+
) }
|
|
89
|
+
</div>
|
|
90
|
+
</MaybeMotionDiv>
|
|
91
|
+
) }
|
|
92
|
+
</MaybeAnimatePresence>
|
|
93
|
+
</>
|
|
38
94
|
);
|
|
39
|
-
}
|
|
95
|
+
}
|
|
40
96
|
|
|
41
|
-
export default
|
|
97
|
+
export default LinkSettingsDrawer;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { __ } from '@wordpress/i18n';
|
|
5
|
+
import { ToggleControl, VisuallyHidden } from '@wordpress/components';
|
|
6
|
+
|
|
7
|
+
const noop = () => {};
|
|
8
|
+
|
|
9
|
+
const LinkControlSettings = ( { value, onChange = noop, settings } ) => {
|
|
10
|
+
if ( ! settings || ! settings.length ) {
|
|
11
|
+
return null;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const handleSettingChange = ( setting ) => ( newValue ) => {
|
|
15
|
+
onChange( {
|
|
16
|
+
...value,
|
|
17
|
+
[ setting.id ]: newValue,
|
|
18
|
+
} );
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
const theSettings = settings.map( ( setting ) => (
|
|
22
|
+
<ToggleControl
|
|
23
|
+
__nextHasNoMarginBottom
|
|
24
|
+
className="block-editor-link-control__setting"
|
|
25
|
+
key={ setting.id }
|
|
26
|
+
label={ setting.title }
|
|
27
|
+
onChange={ handleSettingChange( setting ) }
|
|
28
|
+
checked={ value ? !! value[ setting.id ] : false }
|
|
29
|
+
/>
|
|
30
|
+
) );
|
|
31
|
+
|
|
32
|
+
return (
|
|
33
|
+
<fieldset className="block-editor-link-control__settings">
|
|
34
|
+
<VisuallyHidden as="legend">
|
|
35
|
+
{ __( 'Currently selected link settings' ) }
|
|
36
|
+
</VisuallyHidden>
|
|
37
|
+
{ theSettings }
|
|
38
|
+
</fieldset>
|
|
39
|
+
);
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
export default LinkControlSettings;
|