@wordpress/block-editor 7.0.4 → 8.0.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 +11 -0
- package/README.md +31 -0
- package/build/components/alignment-control/ui.js +1 -2
- package/build/components/alignment-control/ui.js.map +1 -1
- package/build/components/block-icon/index.js +5 -1
- package/build/components/block-icon/index.js.map +1 -1
- package/build/components/block-inspector/index.js +4 -0
- package/build/components/block-inspector/index.js.map +1 -1
- package/build/components/block-list/index.native.js +1 -1
- package/build/components/block-list/index.native.js.map +1 -1
- package/build/components/block-list/use-block-props/use-multi-selection.js +21 -8
- package/build/components/block-list/use-block-props/use-multi-selection.js.map +1 -1
- package/build/components/block-navigation/dropdown.js +0 -1
- package/build/components/block-navigation/dropdown.js.map +1 -1
- package/build/components/block-patterns-list/index.js +1 -8
- package/build/components/block-patterns-list/index.js.map +1 -1
- package/build/components/block-settings/container.native.js +5 -2
- package/build/components/block-settings/container.native.js.map +1 -1
- package/build/components/block-settings-menu/block-settings-dropdown.js +22 -2
- package/build/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
- package/build/components/block-styles/preview.native.js +2 -2
- package/build/components/block-styles/preview.native.js.map +1 -1
- package/build/components/colors-gradients/control.js +8 -47
- package/build/components/colors-gradients/control.js.map +1 -1
- package/build/components/colors-gradients/panel-color-gradient-settings.js +81 -6
- package/build/components/colors-gradients/panel-color-gradient-settings.js.map +1 -1
- package/build/components/duotone-control/index.js +5 -2
- package/build/components/duotone-control/index.js.map +1 -1
- package/build/components/font-appearance-control/index.js +27 -15
- package/build/components/font-appearance-control/index.js.map +1 -1
- package/build/components/iframe/index.js +1 -1
- package/build/components/iframe/index.js.map +1 -1
- package/build/components/index.js +20 -2
- package/build/components/index.js.map +1 -1
- package/build/components/index.native.js +2 -2
- package/build/components/index.native.js.map +1 -1
- package/build/components/inner-blocks/index.js +5 -4
- package/build/components/inner-blocks/index.js.map +1 -1
- package/build/components/inner-blocks/index.native.js +4 -3
- package/build/components/inner-blocks/index.native.js.map +1 -1
- package/build/components/inserter/block-patterns-explorer/explorer.js +62 -0
- package/build/components/inserter/block-patterns-explorer/explorer.js.map +1 -0
- package/build/components/inserter/block-patterns-explorer/patterns-list.js +111 -0
- package/build/components/inserter/block-patterns-explorer/patterns-list.js.map +1 -0
- package/build/components/inserter/block-patterns-explorer/sidebar.js +78 -0
- package/build/components/inserter/block-patterns-explorer/sidebar.js.map +1 -0
- package/build/components/inserter/block-patterns-tab.js +74 -45
- package/build/components/inserter/block-patterns-tab.js.map +1 -1
- package/build/components/inserter/hooks/use-block-type-impressions.native.js +4 -7
- package/build/components/inserter/hooks/use-block-type-impressions.native.js.map +1 -1
- package/build/components/inserter/pattern-panel.js +19 -10
- package/build/components/inserter/pattern-panel.js.map +1 -1
- package/build/components/inspector-controls/groups.js +3 -1
- package/build/components/inspector-controls/groups.js.map +1 -1
- package/build/components/letter-spacing-control/index.js +9 -6
- package/build/components/letter-spacing-control/index.js.map +1 -1
- package/build/components/link-control/index.js +88 -35
- package/build/components/link-control/index.js.map +1 -1
- package/build/components/link-control/link-preview.js +19 -6
- package/build/components/link-control/link-preview.js.map +1 -1
- package/build/components/link-control/search-input.js +12 -3
- package/build/components/link-control/search-input.js.map +1 -1
- package/build/components/list-view/block.js +49 -23
- package/build/components/list-view/block.js.map +1 -1
- package/build/components/list-view/branch.js +92 -73
- package/build/components/list-view/branch.js.map +1 -1
- package/build/components/list-view/index.js +39 -16
- package/build/components/list-view/index.js.map +1 -1
- package/build/components/list-view/leaf.js +1 -1
- package/build/components/list-view/leaf.js.map +1 -1
- package/build/components/list-view/use-list-view-client-ids.js +8 -58
- package/build/components/list-view/use-list-view-client-ids.js.map +1 -1
- package/build/components/rich-text/embed-handler-picker.native.js +1 -0
- package/build/components/rich-text/embed-handler-picker.native.js.map +1 -1
- package/build/components/rich-text/format-edit.js +28 -2
- package/build/components/rich-text/format-edit.js.map +1 -1
- package/build/components/rich-text/format-toolbar/index.js +2 -1
- package/build/components/rich-text/format-toolbar/index.js.map +1 -1
- package/build/components/url-input/index.js +11 -4
- package/build/components/url-input/index.js.map +1 -1
- package/build/components/use-setting/index.js +48 -9
- package/build/components/use-setting/index.js.map +1 -1
- package/build/hooks/border.js +5 -5
- package/build/hooks/border.js.map +1 -1
- package/build/hooks/color-panel.js +2 -1
- package/build/hooks/color-panel.js.map +1 -1
- package/build/hooks/duotone.js +16 -5
- package/build/hooks/duotone.js.map +1 -1
- package/build/hooks/font-appearance.js +49 -6
- package/build/hooks/font-appearance.js.map +1 -1
- package/build/hooks/font-family.js +37 -16
- package/build/hooks/font-family.js.map +1 -1
- package/build/hooks/font-size.js +51 -9
- package/build/hooks/font-size.js.map +1 -1
- package/build/hooks/index.js +8 -0
- package/build/hooks/index.js.map +1 -1
- package/build/hooks/index.native.js +8 -0
- package/build/hooks/index.native.js.map +1 -1
- package/build/hooks/letter-spacing.js +44 -7
- package/build/hooks/letter-spacing.js.map +1 -1
- package/build/hooks/line-height.js +45 -8
- package/build/hooks/line-height.js.map +1 -1
- package/build/hooks/margin.js +1 -1
- package/build/hooks/margin.js.map +1 -1
- package/build/hooks/padding.js +1 -1
- package/build/hooks/padding.js.map +1 -1
- package/build/hooks/text-decoration.js +42 -6
- package/build/hooks/text-decoration.js.map +1 -1
- package/build/hooks/text-transform.js +42 -6
- package/build/hooks/text-transform.js.map +1 -1
- package/build/hooks/typography.js +108 -8
- package/build/hooks/typography.js.map +1 -1
- package/build/hooks/use-cached-truthy.js +29 -0
- package/build/hooks/use-cached-truthy.js.map +1 -0
- package/build/index.js +7 -0
- package/build/index.js.map +1 -1
- package/build/layouts/flex.js +120 -28
- package/build/layouts/flex.js.map +1 -1
- package/build/store/actions.js +303 -265
- package/build/store/actions.js.map +1 -1
- package/build/store/index.js +1 -3
- package/build/store/index.js.map +1 -1
- package/build/store/reducer.js +23 -22
- package/build/store/reducer.js.map +1 -1
- package/build/store/selectors.js +44 -35
- package/build/store/selectors.js.map +1 -1
- package/build-module/components/alignment-control/ui.js +1 -2
- package/build-module/components/alignment-control/ui.js.map +1 -1
- package/build-module/components/block-icon/index.js +5 -1
- package/build-module/components/block-icon/index.js.map +1 -1
- package/build-module/components/block-inspector/index.js +4 -0
- package/build-module/components/block-inspector/index.js.map +1 -1
- package/build-module/components/block-list/index.native.js +1 -1
- package/build-module/components/block-list/index.native.js.map +1 -1
- package/build-module/components/block-list/use-block-props/use-multi-selection.js +21 -8
- package/build-module/components/block-list/use-block-props/use-multi-selection.js.map +1 -1
- package/build-module/components/block-navigation/dropdown.js +0 -1
- package/build-module/components/block-navigation/dropdown.js.map +1 -1
- package/build-module/components/block-patterns-list/index.js +1 -6
- package/build-module/components/block-patterns-list/index.js.map +1 -1
- package/build-module/components/block-settings/container.native.js +6 -3
- package/build-module/components/block-settings/container.native.js.map +1 -1
- package/build-module/components/block-settings-menu/block-settings-dropdown.js +24 -4
- package/build-module/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
- package/build-module/components/block-styles/preview.native.js +2 -2
- package/build-module/components/block-styles/preview.native.js.map +1 -1
- package/build-module/components/colors-gradients/control.js +12 -53
- package/build-module/components/colors-gradients/control.js.map +1 -1
- package/build-module/components/colors-gradients/panel-color-gradient-settings.js +82 -6
- package/build-module/components/colors-gradients/panel-color-gradient-settings.js.map +1 -1
- package/build-module/components/duotone-control/index.js +5 -2
- package/build-module/components/duotone-control/index.js.map +1 -1
- package/build-module/components/font-appearance-control/index.js +23 -15
- package/build-module/components/font-appearance-control/index.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/index.js +3 -1
- package/build-module/components/index.js.map +1 -1
- package/build-module/components/index.native.js +1 -1
- package/build-module/components/index.native.js.map +1 -1
- package/build-module/components/inner-blocks/index.js +6 -5
- package/build-module/components/inner-blocks/index.js.map +1 -1
- package/build-module/components/inner-blocks/index.native.js +5 -4
- package/build-module/components/inner-blocks/index.native.js.map +1 -1
- package/build-module/components/inserter/block-patterns-explorer/explorer.js +50 -0
- package/build-module/components/inserter/block-patterns-explorer/explorer.js.map +1 -0
- package/build-module/components/inserter/block-patterns-explorer/patterns-list.js +92 -0
- package/build-module/components/inserter/block-patterns-explorer/patterns-list.js.map +1 -0
- package/build-module/components/inserter/block-patterns-explorer/sidebar.js +69 -0
- package/build-module/components/inserter/block-patterns-explorer/sidebar.js.map +1 -0
- package/build-module/components/inserter/block-patterns-tab.js +75 -46
- package/build-module/components/inserter/block-patterns-tab.js.map +1 -1
- package/build-module/components/inserter/hooks/use-block-type-impressions.native.js +4 -7
- package/build-module/components/inserter/hooks/use-block-type-impressions.native.js.map +1 -1
- package/build-module/components/inserter/pattern-panel.js +21 -13
- package/build-module/components/inserter/pattern-panel.js.map +1 -1
- package/build-module/components/inspector-controls/groups.js +3 -1
- package/build-module/components/inspector-controls/groups.js.map +1 -1
- package/build-module/components/letter-spacing-control/index.js +9 -6
- package/build-module/components/letter-spacing-control/index.js.map +1 -1
- package/build-module/components/link-control/index.js +88 -36
- package/build-module/components/link-control/index.js.map +1 -1
- package/build-module/components/link-control/link-preview.js +19 -7
- package/build-module/components/link-control/link-preview.js.map +1 -1
- package/build-module/components/link-control/search-input.js +11 -3
- package/build-module/components/link-control/search-input.js.map +1 -1
- package/build-module/components/list-view/block.js +49 -24
- package/build-module/components/list-view/block.js.map +1 -1
- package/build-module/components/list-view/branch.js +92 -73
- package/build-module/components/list-view/branch.js.map +1 -1
- package/build-module/components/list-view/index.js +41 -18
- package/build-module/components/list-view/index.js.map +1 -1
- package/build-module/components/list-view/leaf.js +1 -1
- package/build-module/components/list-view/leaf.js.map +1 -1
- package/build-module/components/list-view/use-list-view-client-ids.js +8 -58
- package/build-module/components/list-view/use-list-view-client-ids.js.map +1 -1
- package/build-module/components/rich-text/embed-handler-picker.native.js +1 -0
- package/build-module/components/rich-text/embed-handler-picker.native.js.map +1 -1
- package/build-module/components/rich-text/format-edit.js +28 -3
- package/build-module/components/rich-text/format-edit.js.map +1 -1
- package/build-module/components/rich-text/format-toolbar/index.js +2 -1
- package/build-module/components/rich-text/format-toolbar/index.js.map +1 -1
- package/build-module/components/url-input/index.js +11 -4
- package/build-module/components/url-input/index.js.map +1 -1
- package/build-module/components/use-setting/index.js +48 -9
- package/build-module/components/use-setting/index.js.map +1 -1
- package/build-module/hooks/border.js +5 -5
- package/build-module/hooks/border.js.map +1 -1
- package/build-module/hooks/color-panel.js +2 -1
- package/build-module/hooks/color-panel.js.map +1 -1
- package/build-module/hooks/duotone.js +16 -5
- package/build-module/hooks/duotone.js.map +1 -1
- package/build-module/hooks/font-appearance.js +45 -6
- package/build-module/hooks/font-appearance.js.map +1 -1
- package/build-module/hooks/font-family.js +33 -16
- package/build-module/hooks/font-family.js.map +1 -1
- package/build-module/hooks/font-size.js +47 -9
- package/build-module/hooks/font-size.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/index.native.js +1 -0
- package/build-module/hooks/index.native.js.map +1 -1
- package/build-module/hooks/letter-spacing.js +40 -7
- package/build-module/hooks/letter-spacing.js.map +1 -1
- package/build-module/hooks/line-height.js +41 -8
- package/build-module/hooks/line-height.js.map +1 -1
- package/build-module/hooks/margin.js +1 -1
- package/build-module/hooks/margin.js.map +1 -1
- package/build-module/hooks/padding.js +1 -1
- package/build-module/hooks/padding.js.map +1 -1
- package/build-module/hooks/text-decoration.js +38 -6
- package/build-module/hooks/text-decoration.js.map +1 -1
- package/build-module/hooks/text-transform.js +38 -6
- package/build-module/hooks/text-transform.js.map +1 -1
- package/build-module/hooks/typography.js +117 -17
- package/build-module/hooks/typography.js.map +1 -1
- package/build-module/hooks/use-cached-truthy.js +21 -0
- package/build-module/hooks/use-cached-truthy.js.map +1 -0
- package/build-module/index.js +1 -1
- package/build-module/index.js.map +1 -1
- package/build-module/layouts/flex.js +124 -32
- package/build-module/layouts/flex.js.map +1 -1
- package/build-module/store/actions.js +266 -241
- package/build-module/store/actions.js.map +1 -1
- package/build-module/store/index.js +1 -2
- package/build-module/store/index.js.map +1 -1
- package/build-module/store/reducer.js +23 -22
- package/build-module/store/reducer.js.map +1 -1
- package/build-module/store/selectors.js +42 -30
- package/build-module/store/selectors.js.map +1 -1
- package/build-style/style-rtl.css +160 -57
- package/build-style/style.css +160 -57
- package/package.json +13 -14
- package/src/components/alignment-control/test/__snapshots__/index.js.snap +0 -2
- package/src/components/alignment-control/ui.js +1 -4
- package/src/components/block-draggable/style.scss +19 -4
- package/src/components/block-icon/index.js +4 -1
- package/src/components/block-inspector/index.js +5 -0
- package/src/components/block-list/index.native.js +1 -1
- package/src/components/block-list/use-block-props/use-multi-selection.js +27 -7
- package/src/components/block-navigation/dropdown.js +0 -1
- package/src/components/block-patterns-list/index.js +1 -8
- package/src/components/block-patterns-list/style.scss +22 -12
- package/src/components/block-settings/container.native.js +7 -0
- package/src/components/block-settings-menu/block-settings-dropdown.js +19 -7
- package/src/components/block-styles/preview.native.js +2 -2
- package/src/components/block-switcher/test/__snapshots__/index.js.snap +1 -1
- package/src/components/color-palette/test/__snapshots__/control.js.snap +88 -63
- package/src/components/colors-gradients/control.js +19 -62
- package/src/components/colors-gradients/panel-color-gradient-settings.js +76 -6
- package/src/components/colors-gradients/style.scss +3 -14
- package/src/components/colors-gradients/test/control.js +0 -16
- package/src/components/duotone-control/index.js +6 -0
- package/src/components/duotone-control/style.scss +27 -12
- package/src/components/font-appearance-control/index.js +22 -14
- package/src/components/iframe/index.js +1 -1
- package/src/components/index.js +3 -4
- package/src/components/index.native.js +1 -4
- package/src/components/inner-blocks/index.js +4 -4
- package/src/components/inner-blocks/index.native.js +7 -4
- package/src/components/inserter/block-patterns-explorer/explorer.js +50 -0
- package/src/components/inserter/block-patterns-explorer/patterns-list.js +122 -0
- package/src/components/inserter/block-patterns-explorer/sidebar.js +73 -0
- package/src/components/inserter/block-patterns-tab.js +107 -80
- package/src/components/inserter/hooks/use-block-type-impressions.native.js +14 -21
- package/src/components/inserter/pattern-panel.js +33 -16
- package/src/components/inserter/style.scss +64 -1
- package/src/components/inserter/test/block-types-tab.native.js +1 -1
- package/src/components/inserter/test/fixtures/index.native.js +12 -0
- package/src/components/inspector-controls/groups.js +4 -0
- package/src/components/letter-spacing-control/index.js +12 -6
- package/src/components/link-control/README.md +7 -0
- package/src/components/link-control/index.js +99 -34
- package/src/components/link-control/link-preview.js +21 -9
- package/src/components/link-control/search-input.js +9 -3
- package/src/components/link-control/style.scss +32 -16
- package/src/components/link-control/test/index.js +179 -4
- package/src/components/list-view/block.js +67 -23
- package/src/components/list-view/branch.js +113 -91
- package/src/components/list-view/index.js +58 -19
- package/src/components/list-view/leaf.js +1 -1
- package/src/components/list-view/style.scss +14 -3
- package/src/components/list-view/use-list-view-client-ids.js +7 -66
- package/src/components/rich-text/embed-handler-picker.native.js +1 -0
- package/src/components/rich-text/format-edit.js +36 -2
- package/src/components/rich-text/format-toolbar/index.js +3 -0
- package/src/components/url-input/index.js +14 -4
- package/src/components/use-setting/index.js +49 -11
- package/src/hooks/border.js +8 -11
- package/src/hooks/color-panel.js +1 -0
- package/src/hooks/duotone.js +21 -7
- package/src/hooks/font-appearance.js +38 -7
- package/src/hooks/font-family.js +29 -13
- package/src/hooks/font-size.js +42 -6
- package/src/hooks/index.js +1 -0
- package/src/hooks/index.native.js +1 -0
- package/src/hooks/layout.scss +3 -1
- package/src/hooks/letter-spacing.js +35 -7
- package/src/hooks/line-height.js +37 -9
- package/src/hooks/margin.js +1 -1
- package/src/hooks/padding.js +1 -1
- package/src/hooks/text-decoration.js +34 -6
- package/src/hooks/text-transform.js +34 -6
- package/src/hooks/typography.js +165 -15
- package/src/hooks/typography.scss +16 -0
- package/src/hooks/use-cached-truthy.js +20 -0
- package/src/index.js +1 -0
- package/src/layouts/flex.js +137 -41
- package/src/store/actions.js +223 -391
- package/src/store/index.js +1 -2
- package/src/store/reducer.js +36 -18
- package/src/store/selectors.js +52 -47
- package/src/store/test/actions.js +395 -694
- package/src/store/test/selectors.js +79 -21
- package/src/style.scss +1 -1
- package/src/utils/test/parse-css-unit-to-px.js +127 -167
- package/build/components/text-decoration-and-transform/index.js +0 -39
- package/build/components/text-decoration-and-transform/index.js.map +0 -1
- package/build/store/controls.js +0 -44
- package/build/store/controls.js.map +0 -1
- package/build-module/components/text-decoration-and-transform/index.js +0 -30
- package/build-module/components/text-decoration-and-transform/index.js.map +0 -1
- package/build-module/store/controls.js +0 -32
- package/build-module/store/controls.js.map +0 -1
- package/src/components/text-decoration-and-transform/index.js +0 -36
- package/src/components/text-decoration-and-transform/style.scss +0 -3
- package/src/store/controls.js +0 -39
|
@@ -10,29 +10,22 @@ import { setBlockTypeImpressions } from '@wordpress/react-native-bridge';
|
|
|
10
10
|
import { store as blockEditorStore } from '../../../store';
|
|
11
11
|
|
|
12
12
|
function useBlockTypeImpressions( blockTypes ) {
|
|
13
|
-
const { blockTypeImpressions
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
};
|
|
24
|
-
},
|
|
25
|
-
[]
|
|
26
|
-
);
|
|
13
|
+
const { blockTypeImpressions } = useSelect( ( select ) => {
|
|
14
|
+
const { getSettings: getBlockEditorSettings } = select(
|
|
15
|
+
blockEditorStore
|
|
16
|
+
);
|
|
17
|
+
const { impressions } = getBlockEditorSettings();
|
|
18
|
+
|
|
19
|
+
return {
|
|
20
|
+
blockTypeImpressions: impressions,
|
|
21
|
+
};
|
|
22
|
+
}, [] );
|
|
27
23
|
const { updateSettings } = useDispatch( blockEditorStore );
|
|
28
24
|
|
|
29
|
-
const items =
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
} ) )
|
|
34
|
-
: blockTypes;
|
|
35
|
-
|
|
25
|
+
const items = blockTypes.map( ( blockType ) => ( {
|
|
26
|
+
...blockType,
|
|
27
|
+
isNew: blockTypeImpressions[ blockType.name ] > 0,
|
|
28
|
+
} ) );
|
|
36
29
|
const trackBlockTypeSelected = ( { name } ) => {
|
|
37
30
|
if ( blockTypeImpressions[ name ] > 0 ) {
|
|
38
31
|
const updatedBlockTypeImpressions = {
|
|
@@ -6,15 +6,17 @@ import classnames from 'classnames';
|
|
|
6
6
|
/**
|
|
7
7
|
* WordPress dependencies
|
|
8
8
|
*/
|
|
9
|
-
import { SelectControl } from '@wordpress/components';
|
|
10
|
-
import { __ } from '@wordpress/i18n';
|
|
9
|
+
import { Flex, FlexItem, SelectControl, Button } from '@wordpress/components';
|
|
10
|
+
import { __, _x } from '@wordpress/i18n';
|
|
11
|
+
import { useViewportMatch } from '@wordpress/compose';
|
|
11
12
|
|
|
12
13
|
function PatternInserterPanel( {
|
|
13
14
|
selectedCategory,
|
|
14
15
|
patternCategories,
|
|
15
16
|
onClickCategory,
|
|
16
|
-
|
|
17
|
+
openPatternExplorer,
|
|
17
18
|
} ) {
|
|
19
|
+
const isMobile = useViewportMatch( 'medium', '<' );
|
|
18
20
|
const categoryOptions = () => {
|
|
19
21
|
const options = [];
|
|
20
22
|
|
|
@@ -36,12 +38,10 @@ function PatternInserterPanel( {
|
|
|
36
38
|
);
|
|
37
39
|
};
|
|
38
40
|
|
|
39
|
-
const
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
);
|
|
44
|
-
};
|
|
41
|
+
const className = classnames(
|
|
42
|
+
'block-editor-inserter__panel-header',
|
|
43
|
+
'block-editor-inserter__panel-header-patterns'
|
|
44
|
+
);
|
|
45
45
|
|
|
46
46
|
// In iOS-based mobile devices, the onBlur will fire when selecting an option
|
|
47
47
|
// from a Select element. To prevent closing the useDialog on iOS devices, we
|
|
@@ -54,8 +54,13 @@ function PatternInserterPanel( {
|
|
|
54
54
|
};
|
|
55
55
|
|
|
56
56
|
return (
|
|
57
|
-
|
|
58
|
-
|
|
57
|
+
<Flex
|
|
58
|
+
justify="space-between"
|
|
59
|
+
align="start"
|
|
60
|
+
gap="4"
|
|
61
|
+
className={ className }
|
|
62
|
+
>
|
|
63
|
+
<FlexItem isBlock>
|
|
59
64
|
<SelectControl
|
|
60
65
|
className="block-editor-inserter__panel-dropdown"
|
|
61
66
|
label={ __( 'Filter patterns' ) }
|
|
@@ -65,11 +70,23 @@ function PatternInserterPanel( {
|
|
|
65
70
|
onBlur={ onBlur }
|
|
66
71
|
options={ categoryOptions() }
|
|
67
72
|
/>
|
|
68
|
-
</
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
+
</FlexItem>
|
|
74
|
+
{ ! isMobile && (
|
|
75
|
+
<FlexItem>
|
|
76
|
+
<Button
|
|
77
|
+
variant="secondary"
|
|
78
|
+
className="block-editor-inserter__patterns-explorer-expand"
|
|
79
|
+
label={ __( 'Explore all patterns' ) }
|
|
80
|
+
onClick={ () => openPatternExplorer() }
|
|
81
|
+
>
|
|
82
|
+
{ _x(
|
|
83
|
+
'Explore',
|
|
84
|
+
'Label for showing all block patterns'
|
|
85
|
+
) }
|
|
86
|
+
</Button>
|
|
87
|
+
</FlexItem>
|
|
88
|
+
) }
|
|
89
|
+
</Flex>
|
|
73
90
|
);
|
|
74
91
|
}
|
|
75
92
|
|
|
@@ -166,7 +166,8 @@ $block-inserter-tabs-height: 44px;
|
|
|
166
166
|
}
|
|
167
167
|
|
|
168
168
|
.block-editor-inserter__panel-dropdown select.components-select-control__input.components-select-control__input.components-select-control__input {
|
|
169
|
-
|
|
169
|
+
height: 36px;
|
|
170
|
+
line-height: 36px;
|
|
170
171
|
}
|
|
171
172
|
|
|
172
173
|
.block-editor-inserter__panel-dropdown select {
|
|
@@ -296,6 +297,12 @@ $block-inserter-tabs-height: 44px;
|
|
|
296
297
|
display: grid;
|
|
297
298
|
grid-template-columns: 1fr 1fr;
|
|
298
299
|
grid-gap: $grid-unit-10;
|
|
300
|
+
.block-editor-block-patterns-list__list-item {
|
|
301
|
+
margin-bottom: 0;
|
|
302
|
+
}
|
|
303
|
+
.block-editor-block-preview__container {
|
|
304
|
+
min-height: 100px;
|
|
305
|
+
}
|
|
299
306
|
}
|
|
300
307
|
}
|
|
301
308
|
|
|
@@ -330,3 +337,59 @@ $block-inserter-tabs-height: 44px;
|
|
|
330
337
|
border-color: var(--wp-admin-theme-color);
|
|
331
338
|
}
|
|
332
339
|
}
|
|
340
|
+
|
|
341
|
+
.block-editor-block-patterns-explorer {
|
|
342
|
+
&__sidebar {
|
|
343
|
+
position: absolute;
|
|
344
|
+
top: $header-height;
|
|
345
|
+
left: 0;
|
|
346
|
+
bottom: 0;
|
|
347
|
+
width: $sidebar-width;
|
|
348
|
+
padding: $grid-unit-30 $grid-unit-40 $grid-unit-40;
|
|
349
|
+
overflow-x: visible;
|
|
350
|
+
overflow-y: scroll;
|
|
351
|
+
|
|
352
|
+
&__categories-list__item {
|
|
353
|
+
display: block;
|
|
354
|
+
width: 100%;
|
|
355
|
+
height: 48px;
|
|
356
|
+
text-align: left;
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
&__search {
|
|
361
|
+
margin-bottom: $grid-unit-40;
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
&__search-results-count {
|
|
365
|
+
padding-bottom: $grid-unit-40;
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
&__list {
|
|
369
|
+
margin-left: $sidebar-width - $grid-unit-40;
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
.block-editor-block-patterns-list {
|
|
373
|
+
display: grid;
|
|
374
|
+
grid-gap: $grid-unit-40;
|
|
375
|
+
grid-template-columns: repeat(1, 1fr);
|
|
376
|
+
|
|
377
|
+
@include break-xlarge() {
|
|
378
|
+
grid-template-columns: repeat(2, 1fr);
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
@include break-huge() {
|
|
382
|
+
grid-template-columns: repeat(3, 1fr);
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
.block-editor-block-patterns-list__list-item {
|
|
386
|
+
min-height: 240px;
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
.block-editor-block-preview__container {
|
|
390
|
+
height: inherit;
|
|
391
|
+
min-height: 100px;
|
|
392
|
+
max-height: 800px;
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
}
|
|
@@ -24,7 +24,7 @@ const selectMock = {
|
|
|
24
24
|
canInsertBlockType: jest.fn(),
|
|
25
25
|
getBlockType: jest.fn(),
|
|
26
26
|
getClipboard: jest.fn(),
|
|
27
|
-
getSettings: jest.fn( () => ( {} ) ),
|
|
27
|
+
getSettings: jest.fn( () => ( { impressions: {} } ) ),
|
|
28
28
|
};
|
|
29
29
|
|
|
30
30
|
describe( 'BlockTypesTab component', () => {
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Internal dependencies
|
|
3
|
+
*/
|
|
4
|
+
import fixtures from './index.js';
|
|
5
|
+
|
|
6
|
+
export * from './index';
|
|
7
|
+
|
|
8
|
+
export default fixtures.map( ( filteredItems ) => ( {
|
|
9
|
+
...filteredItems,
|
|
10
|
+
// Set `isNew` property expected from block type impressions
|
|
11
|
+
isNew: false,
|
|
12
|
+
} ) );
|
|
@@ -8,11 +8,15 @@ const InspectorControlsAdvanced = createSlotFill( 'InspectorAdvancedControls' );
|
|
|
8
8
|
const InspectorControlsDimensions = createSlotFill(
|
|
9
9
|
'InspectorControlsDimensions'
|
|
10
10
|
);
|
|
11
|
+
const InspectorControlsTypography = createSlotFill(
|
|
12
|
+
'InspectorControlsTypography'
|
|
13
|
+
);
|
|
11
14
|
|
|
12
15
|
const groups = {
|
|
13
16
|
default: InspectorControlsDefault,
|
|
14
17
|
advanced: InspectorControlsAdvanced,
|
|
15
18
|
dimensions: InspectorControlsDimensions,
|
|
19
|
+
typography: InspectorControlsTypography,
|
|
16
20
|
};
|
|
17
21
|
|
|
18
22
|
export default groups;
|
|
@@ -15,12 +15,18 @@ import useSetting from '../../components/use-setting';
|
|
|
15
15
|
/**
|
|
16
16
|
* Control for letter-spacing.
|
|
17
17
|
*
|
|
18
|
-
* @param {Object} props
|
|
19
|
-
* @param {string} props.value
|
|
20
|
-
* @param {Function} props.onChange
|
|
21
|
-
* @
|
|
18
|
+
* @param {Object} props Component props.
|
|
19
|
+
* @param {string} props.value Currently selected letter-spacing.
|
|
20
|
+
* @param {Function} props.onChange Handles change in letter-spacing selection.
|
|
21
|
+
* @param {boolean} props.__unstableInputWidth Input width to pass through to inner UnitControl.
|
|
22
|
+
*
|
|
23
|
+
* @return {WPElement} Letter-spacing control.
|
|
22
24
|
*/
|
|
23
|
-
export default function LetterSpacingControl( {
|
|
25
|
+
export default function LetterSpacingControl( {
|
|
26
|
+
value,
|
|
27
|
+
onChange,
|
|
28
|
+
__unstableInputWidth = '60px',
|
|
29
|
+
} ) {
|
|
24
30
|
const units = useCustomUnits( {
|
|
25
31
|
availableUnits: useSetting( 'spacing.units' ) || [ 'px', 'em', 'rem' ],
|
|
26
32
|
defaultValues: { px: '2', em: '.2', rem: '.2' },
|
|
@@ -29,7 +35,7 @@ export default function LetterSpacingControl( { value, onChange } ) {
|
|
|
29
35
|
<UnitControl
|
|
30
36
|
label={ __( 'Letter-spacing' ) }
|
|
31
37
|
value={ value }
|
|
32
|
-
__unstableInputWidth=
|
|
38
|
+
__unstableInputWidth={ __unstableInputWidth }
|
|
33
39
|
units={ units }
|
|
34
40
|
onChange={ onChange }
|
|
35
41
|
/>
|
|
@@ -192,6 +192,13 @@ A `suggestion` should have the following shape:
|
|
|
192
192
|
)}
|
|
193
193
|
/>
|
|
194
194
|
```
|
|
195
|
+
### renderControlBottom
|
|
196
|
+
|
|
197
|
+
- Type: `Function`
|
|
198
|
+
- Required: No
|
|
199
|
+
- Default: null
|
|
200
|
+
|
|
201
|
+
A render prop that can be used to pass optional controls to be rendered at the bottom of the component.
|
|
195
202
|
|
|
196
203
|
# LinkControlSearchInput
|
|
197
204
|
|
|
@@ -2,11 +2,12 @@
|
|
|
2
2
|
* External dependencies
|
|
3
3
|
*/
|
|
4
4
|
import { noop } from 'lodash';
|
|
5
|
+
import classnames from 'classnames';
|
|
5
6
|
|
|
6
7
|
/**
|
|
7
8
|
* WordPress dependencies
|
|
8
9
|
*/
|
|
9
|
-
import { Button, Spinner, Notice } from '@wordpress/components';
|
|
10
|
+
import { Button, Spinner, Notice, TextControl } from '@wordpress/components';
|
|
10
11
|
import { keyboardReturn } from '@wordpress/icons';
|
|
11
12
|
import { __ } from '@wordpress/i18n';
|
|
12
13
|
import { useRef, useState, useEffect } from '@wordpress/element';
|
|
@@ -93,6 +94,7 @@ import { DEFAULT_LINK_SETTINGS } from './constants';
|
|
|
93
94
|
* @property {Object=} suggestionsQuery Query parameters to pass along to wp.blockEditor.__experimentalFetchLinkSuggestions.
|
|
94
95
|
* @property {boolean=} noURLSuggestion Whether to add a fallback suggestion which treats the search query as a URL.
|
|
95
96
|
* @property {string|Function|undefined} createSuggestionButtonText The text to use in the button that calls createSuggestion.
|
|
97
|
+
* @property {Function} renderControlBottom Optional controls to be rendered at the bottom of the component.
|
|
96
98
|
*/
|
|
97
99
|
|
|
98
100
|
/**
|
|
@@ -119,6 +121,8 @@ function LinkControl( {
|
|
|
119
121
|
noURLSuggestion = false,
|
|
120
122
|
createSuggestionButtonText,
|
|
121
123
|
hasRichPreviews = false,
|
|
124
|
+
hasTextControl = false,
|
|
125
|
+
renderControlBottom = null,
|
|
122
126
|
} ) {
|
|
123
127
|
if ( withCreateSuggestion === undefined && createSuggestion ) {
|
|
124
128
|
withCreateSuggestion = true;
|
|
@@ -126,8 +130,13 @@ function LinkControl( {
|
|
|
126
130
|
|
|
127
131
|
const isMounting = useRef( true );
|
|
128
132
|
const wrapperNode = useRef();
|
|
133
|
+
const textInputRef = useRef();
|
|
134
|
+
|
|
129
135
|
const [ internalInputValue, setInternalInputValue ] = useState(
|
|
130
|
-
|
|
136
|
+
value?.url || ''
|
|
137
|
+
);
|
|
138
|
+
const [ internalTextValue, setInternalTextValue ] = useState(
|
|
139
|
+
value?.title || ''
|
|
131
140
|
);
|
|
132
141
|
const currentInputValue = propInputValue || internalInputValue;
|
|
133
142
|
const [ isEditingLink, setIsEditingLink ] = useState(
|
|
@@ -149,22 +158,53 @@ function LinkControl( {
|
|
|
149
158
|
}, [ forceIsEditingLink ] );
|
|
150
159
|
|
|
151
160
|
useEffect( () => {
|
|
161
|
+
// We don't auto focus into the Link UI on mount
|
|
162
|
+
// because otherwise using the keyboard to select text
|
|
163
|
+
// *within* the link format is not possible.
|
|
152
164
|
if ( isMounting.current ) {
|
|
153
165
|
isMounting.current = false;
|
|
154
166
|
return;
|
|
155
167
|
}
|
|
168
|
+
// Unless we are mounting, we always want to focus either:
|
|
169
|
+
// - the URL input
|
|
170
|
+
// - the first focusable element in the Link UI.
|
|
171
|
+
// But in editing mode if there is a text input present then
|
|
172
|
+
// the URL input is at index 1. If not then it is at index 0.
|
|
173
|
+
const whichFocusTargetIndex = textInputRef?.current ? 1 : 0;
|
|
156
174
|
|
|
157
|
-
//
|
|
158
|
-
//
|
|
175
|
+
// Scenario - when:
|
|
176
|
+
// - switching between editable and non editable LinkControl
|
|
177
|
+
// - clicking on a link
|
|
178
|
+
// ...then move focus to the *first* element to avoid focus loss
|
|
179
|
+
// and to ensure focus is *within* the Link UI.
|
|
159
180
|
const nextFocusTarget =
|
|
160
|
-
focus.focusable.find( wrapperNode.current )[
|
|
161
|
-
|
|
181
|
+
focus.focusable.find( wrapperNode.current )[
|
|
182
|
+
whichFocusTargetIndex
|
|
183
|
+
] || wrapperNode.current;
|
|
162
184
|
|
|
163
185
|
nextFocusTarget.focus();
|
|
164
186
|
|
|
165
187
|
isEndingEditWithFocus.current = false;
|
|
166
188
|
}, [ isEditingLink ] );
|
|
167
189
|
|
|
190
|
+
useEffect( () => {
|
|
191
|
+
/**
|
|
192
|
+
* If the value's `text` property changes then sync this
|
|
193
|
+
* back up with state.
|
|
194
|
+
*/
|
|
195
|
+
if ( value?.title && value.title !== internalTextValue ) {
|
|
196
|
+
setInternalTextValue( value.title );
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
/**
|
|
200
|
+
* Update the state value internalInputValue if the url value changes
|
|
201
|
+
* for example when clicking on another anchor
|
|
202
|
+
*/
|
|
203
|
+
if ( value?.url ) {
|
|
204
|
+
setInternalInputValue( value.url );
|
|
205
|
+
}
|
|
206
|
+
}, [ value ] );
|
|
207
|
+
|
|
168
208
|
/**
|
|
169
209
|
* Cancels editing state and marks that focus may need to be restored after
|
|
170
210
|
* the next render, if focus was within the wrapper when editing finished.
|
|
@@ -182,22 +222,47 @@ function LinkControl( {
|
|
|
182
222
|
);
|
|
183
223
|
|
|
184
224
|
const handleSelectSuggestion = ( updatedValue ) => {
|
|
185
|
-
onChange(
|
|
225
|
+
onChange( {
|
|
226
|
+
...updatedValue,
|
|
227
|
+
title: internalTextValue || updatedValue?.title,
|
|
228
|
+
} );
|
|
186
229
|
stopEditing();
|
|
187
230
|
};
|
|
188
231
|
|
|
189
|
-
const
|
|
190
|
-
if (
|
|
191
|
-
|
|
232
|
+
const handleSubmit = () => {
|
|
233
|
+
if (
|
|
234
|
+
currentInputValue !== value?.url ||
|
|
235
|
+
internalTextValue !== value?.title
|
|
236
|
+
) {
|
|
237
|
+
onChange( {
|
|
238
|
+
url: currentInputValue,
|
|
239
|
+
title: internalTextValue,
|
|
240
|
+
} );
|
|
192
241
|
}
|
|
193
242
|
stopEditing();
|
|
194
243
|
};
|
|
195
244
|
|
|
245
|
+
const handleSubmitWithEnter = ( event ) => {
|
|
246
|
+
const { keyCode } = event;
|
|
247
|
+
if (
|
|
248
|
+
keyCode === ENTER &&
|
|
249
|
+
! currentInputIsEmpty // disallow submitting empty values.
|
|
250
|
+
) {
|
|
251
|
+
event.preventDefault();
|
|
252
|
+
handleSubmit();
|
|
253
|
+
}
|
|
254
|
+
};
|
|
255
|
+
|
|
196
256
|
const shownUnlinkControl =
|
|
197
257
|
onRemove && value && ! isEditingLink && ! isCreatingPage;
|
|
198
258
|
|
|
199
259
|
const showSettingsDrawer = !! settings?.length;
|
|
200
260
|
|
|
261
|
+
// Only show text control once a URL value has been committed
|
|
262
|
+
// and it isn't just empty whitespace.
|
|
263
|
+
// See https://github.com/WordPress/gutenberg/pull/33849/#issuecomment-932194927.
|
|
264
|
+
const showTextControl = value?.url?.trim()?.length > 0 && hasTextControl;
|
|
265
|
+
|
|
201
266
|
return (
|
|
202
267
|
<div
|
|
203
268
|
tabIndex={ -1 }
|
|
@@ -212,10 +277,26 @@ function LinkControl( {
|
|
|
212
277
|
|
|
213
278
|
{ ( isEditingLink || ! value ) && ! isCreatingPage && (
|
|
214
279
|
<>
|
|
215
|
-
<div
|
|
280
|
+
<div
|
|
281
|
+
className={ classnames( {
|
|
282
|
+
'block-editor-link-control__search-input-wrapper': true,
|
|
283
|
+
'has-text-control': showTextControl,
|
|
284
|
+
} ) }
|
|
285
|
+
>
|
|
286
|
+
{ showTextControl && (
|
|
287
|
+
<TextControl
|
|
288
|
+
ref={ textInputRef }
|
|
289
|
+
className="block-editor-link-control__field block-editor-link-control__text-content"
|
|
290
|
+
label="Text"
|
|
291
|
+
value={ internalTextValue }
|
|
292
|
+
onChange={ setInternalTextValue }
|
|
293
|
+
onKeyDown={ handleSubmitWithEnter }
|
|
294
|
+
/>
|
|
295
|
+
) }
|
|
296
|
+
|
|
216
297
|
<LinkControlSearchInput
|
|
217
298
|
currentLink={ value }
|
|
218
|
-
className="block-editor-link-control__search-input"
|
|
299
|
+
className="block-editor-link-control__field block-editor-link-control__search-input"
|
|
219
300
|
placeholder={ searchInputPlaceholder }
|
|
220
301
|
value={ currentInputValue }
|
|
221
302
|
withCreateSuggestion={ withCreateSuggestion }
|
|
@@ -230,20 +311,11 @@ function LinkControl( {
|
|
|
230
311
|
createSuggestionButtonText={
|
|
231
312
|
createSuggestionButtonText
|
|
232
313
|
}
|
|
314
|
+
useLabel={ showTextControl }
|
|
233
315
|
>
|
|
234
316
|
<div className="block-editor-link-control__search-actions">
|
|
235
317
|
<Button
|
|
236
|
-
onClick={
|
|
237
|
-
onKeyDown={ ( event ) => {
|
|
238
|
-
const { keyCode } = event;
|
|
239
|
-
if (
|
|
240
|
-
keyCode === ENTER &&
|
|
241
|
-
! currentInputIsEmpty // disallow submitting empty values.
|
|
242
|
-
) {
|
|
243
|
-
event.preventDefault();
|
|
244
|
-
handleSubmitButton();
|
|
245
|
-
}
|
|
246
|
-
} }
|
|
318
|
+
onClick={ handleSubmit }
|
|
247
319
|
label={ __( 'Submit' ) }
|
|
248
320
|
icon={ keyboardReturn }
|
|
249
321
|
className="block-editor-link-control__search-submit"
|
|
@@ -270,28 +342,21 @@ function LinkControl( {
|
|
|
270
342
|
value={ value }
|
|
271
343
|
onEditClick={ () => setIsEditingLink( true ) }
|
|
272
344
|
hasRichPreviews={ hasRichPreviews }
|
|
345
|
+
hasUnlinkControl={ shownUnlinkControl }
|
|
346
|
+
onRemove={ onRemove }
|
|
273
347
|
/>
|
|
274
348
|
) }
|
|
275
349
|
|
|
276
|
-
{
|
|
350
|
+
{ showSettingsDrawer && (
|
|
277
351
|
<div className="block-editor-link-control__tools">
|
|
278
352
|
<LinkControlSettingsDrawer
|
|
279
353
|
value={ value }
|
|
280
354
|
settings={ settings }
|
|
281
355
|
onChange={ onChange }
|
|
282
356
|
/>
|
|
283
|
-
{ shownUnlinkControl && (
|
|
284
|
-
<Button
|
|
285
|
-
className="block-editor-link-control__unlink"
|
|
286
|
-
isDestructive
|
|
287
|
-
variant="link"
|
|
288
|
-
onClick={ onRemove }
|
|
289
|
-
>
|
|
290
|
-
{ __( 'Unlink' ) }
|
|
291
|
-
</Button>
|
|
292
|
-
) }
|
|
293
357
|
</div>
|
|
294
358
|
) }
|
|
359
|
+
{ renderControlBottom && renderControlBottom() }
|
|
295
360
|
</div>
|
|
296
361
|
);
|
|
297
362
|
}
|
|
@@ -13,7 +13,8 @@ import {
|
|
|
13
13
|
__experimentalText as Text,
|
|
14
14
|
} from '@wordpress/components';
|
|
15
15
|
import { filterURLForDisplay, safeDecodeURI } from '@wordpress/url';
|
|
16
|
-
import { Icon, globe, info } from '@wordpress/icons';
|
|
16
|
+
import { Icon, globe, info, linkOff, edit } from '@wordpress/icons';
|
|
17
|
+
import { __unstableStripHTML as stripHTML } from '@wordpress/dom';
|
|
17
18
|
|
|
18
19
|
/**
|
|
19
20
|
* Internal dependencies
|
|
@@ -26,6 +27,8 @@ export default function LinkPreview( {
|
|
|
26
27
|
value,
|
|
27
28
|
onEditClick,
|
|
28
29
|
hasRichPreviews = false,
|
|
30
|
+
hasUnlinkControl = false,
|
|
31
|
+
onRemove,
|
|
29
32
|
} ) {
|
|
30
33
|
// Avoid fetching if rich previews are not desired.
|
|
31
34
|
const showRichPreviews = hasRichPreviews ? value?.url : null;
|
|
@@ -39,6 +42,8 @@ export default function LinkPreview( {
|
|
|
39
42
|
( value && filterURLForDisplay( safeDecodeURI( value.url ), 16 ) ) ||
|
|
40
43
|
'';
|
|
41
44
|
|
|
45
|
+
const displayTitle = richData?.title || value?.title || displayURL;
|
|
46
|
+
|
|
42
47
|
const isEmptyURL = ! value.url.length;
|
|
43
48
|
|
|
44
49
|
let icon;
|
|
@@ -82,9 +87,7 @@ export default function LinkPreview( {
|
|
|
82
87
|
className="block-editor-link-control__search-item-title"
|
|
83
88
|
href={ value.url }
|
|
84
89
|
>
|
|
85
|
-
{
|
|
86
|
-
value?.title ||
|
|
87
|
-
displayURL }
|
|
90
|
+
{ stripHTML( displayTitle ) }
|
|
88
91
|
</ExternalLink>
|
|
89
92
|
|
|
90
93
|
{ value?.url && (
|
|
@@ -102,12 +105,21 @@ export default function LinkPreview( {
|
|
|
102
105
|
</span>
|
|
103
106
|
|
|
104
107
|
<Button
|
|
105
|
-
|
|
106
|
-
|
|
108
|
+
icon={ edit }
|
|
109
|
+
label={ __( 'Edit' ) }
|
|
107
110
|
className="block-editor-link-control__search-item-action"
|
|
108
|
-
|
|
109
|
-
{
|
|
110
|
-
|
|
111
|
+
onClick={ onEditClick }
|
|
112
|
+
iconSize={ 24 }
|
|
113
|
+
/>
|
|
114
|
+
{ hasUnlinkControl && (
|
|
115
|
+
<Button
|
|
116
|
+
icon={ linkOff }
|
|
117
|
+
label={ __( 'Unlink' ) }
|
|
118
|
+
className="block-editor-link-control__search-item-action block-editor-link-control__unlink"
|
|
119
|
+
onClick={ onRemove }
|
|
120
|
+
iconSize={ 24 }
|
|
121
|
+
/>
|
|
122
|
+
) }
|
|
111
123
|
<ViewerSlot fillProps={ value } />
|
|
112
124
|
</div>
|
|
113
125
|
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* External dependencies
|
|
3
3
|
*/
|
|
4
4
|
import { noop, omit } from 'lodash';
|
|
5
|
-
|
|
5
|
+
import classnames from 'classnames';
|
|
6
6
|
/**
|
|
7
7
|
* WordPress dependencies
|
|
8
8
|
*/
|
|
@@ -45,6 +45,7 @@ const LinkControlSearchInput = forwardRef(
|
|
|
45
45
|
suggestionsQuery = {},
|
|
46
46
|
withURLSuggestion = true,
|
|
47
47
|
createSuggestionButtonText,
|
|
48
|
+
useLabel = false,
|
|
48
49
|
},
|
|
49
50
|
ref
|
|
50
51
|
) => {
|
|
@@ -117,10 +118,15 @@ const LinkControlSearchInput = forwardRef(
|
|
|
117
118
|
}
|
|
118
119
|
};
|
|
119
120
|
|
|
121
|
+
const inputClasses = classnames( className, {
|
|
122
|
+
'has-no-label': ! useLabel,
|
|
123
|
+
} );
|
|
124
|
+
|
|
120
125
|
return (
|
|
121
|
-
<div>
|
|
126
|
+
<div className="block-editor-link-control__search-input-container">
|
|
122
127
|
<URLInput
|
|
123
|
-
|
|
128
|
+
label={ useLabel ? 'URL' : undefined }
|
|
129
|
+
className={ inputClasses }
|
|
124
130
|
value={ value }
|
|
125
131
|
onChange={ onInputChange }
|
|
126
132
|
placeholder={ placeholder ?? __( 'Search or type url' ) }
|