@wordpress/block-editor 12.3.6 → 12.3.7

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.
Files changed (56) hide show
  1. package/build/components/block-draggable/index.js +6 -3
  2. package/build/components/block-draggable/index.js.map +1 -1
  3. package/build/components/inserter/reusable-block-rename-hint.js +1 -1
  4. package/build/components/inserter/reusable-block-rename-hint.js.map +1 -1
  5. package/build/components/link-control/constants.js +1 -1
  6. package/build/components/link-control/constants.js.map +1 -1
  7. package/build/components/link-control/search-create-button.js +5 -21
  8. package/build/components/link-control/search-create-button.js.map +1 -1
  9. package/build/components/link-control/search-item.js +13 -30
  10. package/build/components/link-control/search-item.js.map +1 -1
  11. package/build/components/link-control/search-results.js +2 -2
  12. package/build/components/link-control/search-results.js.map +1 -1
  13. package/build/components/use-block-display-information/index.js +7 -3
  14. package/build/components/use-block-display-information/index.js.map +1 -1
  15. package/build/hooks/margin.js +1 -1
  16. package/build/hooks/margin.js.map +1 -1
  17. package/build/hooks/padding.js +1 -1
  18. package/build/hooks/padding.js.map +1 -1
  19. package/build/store/selectors.js +1 -1
  20. package/build/store/selectors.js.map +1 -1
  21. package/build-module/components/block-draggable/index.js +6 -3
  22. package/build-module/components/block-draggable/index.js.map +1 -1
  23. package/build-module/components/inserter/reusable-block-rename-hint.js +1 -1
  24. package/build-module/components/inserter/reusable-block-rename-hint.js.map +1 -1
  25. package/build-module/components/link-control/constants.js +1 -1
  26. package/build-module/components/link-control/constants.js.map +1 -1
  27. package/build-module/components/link-control/search-create-button.js +7 -20
  28. package/build-module/components/link-control/search-create-button.js.map +1 -1
  29. package/build-module/components/link-control/search-item.js +14 -28
  30. package/build-module/components/link-control/search-item.js.map +1 -1
  31. package/build-module/components/link-control/search-results.js +3 -3
  32. package/build-module/components/link-control/search-results.js.map +1 -1
  33. package/build-module/components/use-block-display-information/index.js +7 -3
  34. package/build-module/components/use-block-display-information/index.js.map +1 -1
  35. package/build-module/hooks/margin.js +1 -1
  36. package/build-module/hooks/margin.js.map +1 -1
  37. package/build-module/hooks/padding.js +1 -1
  38. package/build-module/hooks/padding.js.map +1 -1
  39. package/build-module/store/selectors.js +1 -1
  40. package/build-module/store/selectors.js.map +1 -1
  41. package/build-style/style-rtl.css +20 -83
  42. package/build-style/style.css +20 -83
  43. package/package.json +4 -4
  44. package/src/components/block-draggable/index.js +13 -4
  45. package/src/components/inserter/reusable-block-rename-hint.js +1 -1
  46. package/src/components/link-control/constants.js +1 -1
  47. package/src/components/link-control/search-create-button.js +8 -26
  48. package/src/components/link-control/search-item.js +21 -43
  49. package/src/components/link-control/search-results.js +48 -46
  50. package/src/components/link-control/style.scss +25 -95
  51. package/src/components/link-control/test/index.js +6 -7
  52. package/src/components/use-block-display-information/index.js +12 -5
  53. package/src/hooks/margin.js +4 -1
  54. package/src/hooks/padding.js +4 -1
  55. package/src/store/selectors.js +1 -1
  56. package/src/store/test/selectors.js +1 -1
@@ -1897,6 +1897,7 @@ body.is-fullscreen-mode .block-editor-block-contextual-toolbar.is-fixed {
1897
1897
  }
1898
1898
 
1899
1899
  .block-editor-link-control__search-input-wrapper {
1900
+ margin-bottom: 8px;
1900
1901
  position: relative;
1901
1902
  }
1902
1903
 
@@ -1973,32 +1974,9 @@ body.is-fullscreen-mode .block-editor-block-contextual-toolbar.is-fixed {
1973
1974
  order: 20;
1974
1975
  }
1975
1976
 
1976
- .block-editor-link-control__search-results-wrapper {
1977
- position: relative;
1978
- }
1979
- .block-editor-link-control__search-results-wrapper::before, .block-editor-link-control__search-results-wrapper::after {
1980
- content: "";
1981
- position: absolute;
1982
- right: -1px;
1983
- left: 16px;
1984
- display: block;
1985
- pointer-events: none;
1986
- z-index: 100;
1987
- }
1988
- .block-editor-link-control__search-results-wrapper::before {
1989
- height: 8px;
1990
- top: 0;
1991
- bottom: auto;
1992
- }
1993
- .block-editor-link-control__search-results-wrapper::after {
1994
- height: 16px;
1995
- bottom: 0;
1996
- top: auto;
1997
- }
1998
-
1999
1977
  .block-editor-link-control__search-results {
2000
- margin: 0;
2001
- padding: 8px 16px 8px;
1978
+ margin-top: -16px;
1979
+ padding: 8px;
2002
1980
  max-height: 200px;
2003
1981
  overflow-y: auto;
2004
1982
  }
@@ -2006,35 +1984,29 @@ body.is-fullscreen-mode .block-editor-block-contextual-toolbar.is-fixed {
2006
1984
  opacity: 0.2;
2007
1985
  }
2008
1986
 
2009
- .block-editor-link-control__search-item {
2010
- position: relative;
2011
- display: flex;
2012
- align-items: flex-start;
2013
- font-size: 13px;
2014
- cursor: pointer;
2015
- background: #fff;
2016
- width: 100%;
2017
- border: none;
2018
- text-align: right;
2019
- padding: 12px 16px;
2020
- border-radius: 2px;
1987
+ .block-editor-link-control__search-item.components-button.components-menu-item__button {
2021
1988
  height: auto;
1989
+ text-align: right;
2022
1990
  }
2023
- .block-editor-link-control__search-item:hover, .block-editor-link-control__search-item:focus {
2024
- background-color: #f0f0f0;
1991
+ .block-editor-link-control__search-item .components-menu-item__item {
1992
+ overflow: hidden;
1993
+ text-overflow: ellipsis;
1994
+ display: inline-block;
1995
+ width: 100%;
2025
1996
  }
2026
- .block-editor-link-control__search-item:hover .block-editor-link-control__search-item-type, .block-editor-link-control__search-item:focus .block-editor-link-control__search-item-type {
2027
- background: #fff;
1997
+ .block-editor-link-control__search-item .components-menu-item__item mark {
1998
+ font-weight: 600;
1999
+ color: inherit;
2000
+ background-color: transparent;
2028
2001
  }
2029
- .block-editor-link-control__search-item:focus:not(:disabled) {
2030
- box-shadow: 0 0 0 var(--wp-admin-border-width-focus) var(--wp-admin-theme-color) inset;
2002
+ .block-editor-link-control__search-item .components-menu-item__shortcut {
2003
+ color: #757575;
2004
+ text-transform: capitalize;
2005
+ white-space: nowrap;
2031
2006
  }
2032
- .block-editor-link-control__search-item.is-selected {
2007
+ .block-editor-link-control__search-item[aria-selected] {
2033
2008
  background: #f0f0f0;
2034
2009
  }
2035
- .block-editor-link-control__search-item.is-selected .block-editor-link-control__search-item-type {
2036
- background: #fff;
2037
- }
2038
2010
  .block-editor-link-control__search-item.is-current {
2039
2011
  flex-direction: column;
2040
2012
  background: transparent;
@@ -2063,7 +2035,6 @@ body.is-fullscreen-mode .block-editor-block-contextual-toolbar.is-fixed {
2063
2035
  }
2064
2036
  .block-editor-link-control__search-item .block-editor-link-control__search-item-icon {
2065
2037
  position: relative;
2066
- top: 0.2em;
2067
2038
  margin-left: 8px;
2068
2039
  max-height: 24px;
2069
2040
  flex-shrink: 0;
@@ -2079,17 +2050,6 @@ body.is-fullscreen-mode .block-editor-block-contextual-toolbar.is-fixed {
2079
2050
  width: 32px;
2080
2051
  max-height: 32px;
2081
2052
  }
2082
- .block-editor-link-control__search-item .block-editor-link-control__search-item-info,
2083
- .block-editor-link-control__search-item .block-editor-link-control__search-item-title {
2084
- overflow: hidden;
2085
- text-overflow: ellipsis;
2086
- }
2087
- .block-editor-link-control__search-item .block-editor-link-control__search-item-info .components-external-link__icon,
2088
- .block-editor-link-control__search-item .block-editor-link-control__search-item-title .components-external-link__icon {
2089
- position: absolute;
2090
- left: 0;
2091
- margin-top: 0;
2092
- }
2093
2053
  .block-editor-link-control__search-item .block-editor-link-control__search-item-title {
2094
2054
  display: block;
2095
2055
  margin-bottom: 0.2em;
@@ -2097,7 +2057,7 @@ body.is-fullscreen-mode .block-editor-block-contextual-toolbar.is-fixed {
2097
2057
  position: relative;
2098
2058
  }
2099
2059
  .block-editor-link-control__search-item .block-editor-link-control__search-item-title mark {
2100
- font-weight: 700;
2060
+ font-weight: 600;
2101
2061
  color: inherit;
2102
2062
  background-color: transparent;
2103
2063
  }
@@ -2107,25 +2067,6 @@ body.is-fullscreen-mode .block-editor-block-contextual-toolbar.is-fixed {
2107
2067
  .block-editor-link-control__search-item .block-editor-link-control__search-item-title svg {
2108
2068
  display: none;
2109
2069
  }
2110
- .block-editor-link-control__search-item .block-editor-link-control__search-item-info {
2111
- display: block;
2112
- color: #757575;
2113
- font-size: 0.9em;
2114
- line-height: 1.3;
2115
- }
2116
- .block-editor-link-control__search-item .block-editor-link-control__search-item-error-notice {
2117
- font-style: italic;
2118
- font-size: 1.1em;
2119
- }
2120
- .block-editor-link-control__search-item .block-editor-link-control__search-item-type {
2121
- display: block;
2122
- padding: 3px 6px;
2123
- margin-right: auto;
2124
- font-size: 0.9em;
2125
- background-color: #f0f0f0;
2126
- border-radius: 2px;
2127
- white-space: nowrap;
2128
- }
2129
2070
  .block-editor-link-control__search-item .block-editor-link-control__search-item-description {
2130
2071
  padding-top: 12px;
2131
2072
  margin: 0;
@@ -2240,10 +2181,6 @@ body.is-fullscreen-mode .block-editor-block-contextual-toolbar.is-fixed {
2240
2181
  top: 0;
2241
2182
  }
2242
2183
 
2243
- .block-editor-link-control__search-results div[role=menu] > .block-editor-link-control__search-item.block-editor-link-control__search-item {
2244
- padding: 10px;
2245
- }
2246
-
2247
2184
  .block-editor-link-control__drawer {
2248
2185
  display: flex;
2249
2186
  order: 30;
@@ -1898,6 +1898,7 @@ body.is-fullscreen-mode .block-editor-block-contextual-toolbar.is-fixed {
1898
1898
  }
1899
1899
 
1900
1900
  .block-editor-link-control__search-input-wrapper {
1901
+ margin-bottom: 8px;
1901
1902
  position: relative;
1902
1903
  }
1903
1904
 
@@ -1974,32 +1975,9 @@ body.is-fullscreen-mode .block-editor-block-contextual-toolbar.is-fixed {
1974
1975
  order: 20;
1975
1976
  }
1976
1977
 
1977
- .block-editor-link-control__search-results-wrapper {
1978
- position: relative;
1979
- }
1980
- .block-editor-link-control__search-results-wrapper::before, .block-editor-link-control__search-results-wrapper::after {
1981
- content: "";
1982
- position: absolute;
1983
- left: -1px;
1984
- right: 16px;
1985
- display: block;
1986
- pointer-events: none;
1987
- z-index: 100;
1988
- }
1989
- .block-editor-link-control__search-results-wrapper::before {
1990
- height: 8px;
1991
- top: 0;
1992
- bottom: auto;
1993
- }
1994
- .block-editor-link-control__search-results-wrapper::after {
1995
- height: 16px;
1996
- bottom: 0;
1997
- top: auto;
1998
- }
1999
-
2000
1978
  .block-editor-link-control__search-results {
2001
- margin: 0;
2002
- padding: 8px 16px 8px;
1979
+ margin-top: -16px;
1980
+ padding: 8px;
2003
1981
  max-height: 200px;
2004
1982
  overflow-y: auto;
2005
1983
  }
@@ -2007,35 +1985,29 @@ body.is-fullscreen-mode .block-editor-block-contextual-toolbar.is-fixed {
2007
1985
  opacity: 0.2;
2008
1986
  }
2009
1987
 
2010
- .block-editor-link-control__search-item {
2011
- position: relative;
2012
- display: flex;
2013
- align-items: flex-start;
2014
- font-size: 13px;
2015
- cursor: pointer;
2016
- background: #fff;
2017
- width: 100%;
2018
- border: none;
2019
- text-align: left;
2020
- padding: 12px 16px;
2021
- border-radius: 2px;
1988
+ .block-editor-link-control__search-item.components-button.components-menu-item__button {
2022
1989
  height: auto;
1990
+ text-align: left;
2023
1991
  }
2024
- .block-editor-link-control__search-item:hover, .block-editor-link-control__search-item:focus {
2025
- background-color: #f0f0f0;
1992
+ .block-editor-link-control__search-item .components-menu-item__item {
1993
+ overflow: hidden;
1994
+ text-overflow: ellipsis;
1995
+ display: inline-block;
1996
+ width: 100%;
2026
1997
  }
2027
- .block-editor-link-control__search-item:hover .block-editor-link-control__search-item-type, .block-editor-link-control__search-item:focus .block-editor-link-control__search-item-type {
2028
- background: #fff;
1998
+ .block-editor-link-control__search-item .components-menu-item__item mark {
1999
+ font-weight: 600;
2000
+ color: inherit;
2001
+ background-color: transparent;
2029
2002
  }
2030
- .block-editor-link-control__search-item:focus:not(:disabled) {
2031
- box-shadow: 0 0 0 var(--wp-admin-border-width-focus) var(--wp-admin-theme-color) inset;
2003
+ .block-editor-link-control__search-item .components-menu-item__shortcut {
2004
+ color: #757575;
2005
+ text-transform: capitalize;
2006
+ white-space: nowrap;
2032
2007
  }
2033
- .block-editor-link-control__search-item.is-selected {
2008
+ .block-editor-link-control__search-item[aria-selected] {
2034
2009
  background: #f0f0f0;
2035
2010
  }
2036
- .block-editor-link-control__search-item.is-selected .block-editor-link-control__search-item-type {
2037
- background: #fff;
2038
- }
2039
2011
  .block-editor-link-control__search-item.is-current {
2040
2012
  flex-direction: column;
2041
2013
  background: transparent;
@@ -2064,7 +2036,6 @@ body.is-fullscreen-mode .block-editor-block-contextual-toolbar.is-fixed {
2064
2036
  }
2065
2037
  .block-editor-link-control__search-item .block-editor-link-control__search-item-icon {
2066
2038
  position: relative;
2067
- top: 0.2em;
2068
2039
  margin-right: 8px;
2069
2040
  max-height: 24px;
2070
2041
  flex-shrink: 0;
@@ -2080,17 +2051,6 @@ body.is-fullscreen-mode .block-editor-block-contextual-toolbar.is-fixed {
2080
2051
  width: 32px;
2081
2052
  max-height: 32px;
2082
2053
  }
2083
- .block-editor-link-control__search-item .block-editor-link-control__search-item-info,
2084
- .block-editor-link-control__search-item .block-editor-link-control__search-item-title {
2085
- overflow: hidden;
2086
- text-overflow: ellipsis;
2087
- }
2088
- .block-editor-link-control__search-item .block-editor-link-control__search-item-info .components-external-link__icon,
2089
- .block-editor-link-control__search-item .block-editor-link-control__search-item-title .components-external-link__icon {
2090
- position: absolute;
2091
- right: 0;
2092
- margin-top: 0;
2093
- }
2094
2054
  .block-editor-link-control__search-item .block-editor-link-control__search-item-title {
2095
2055
  display: block;
2096
2056
  margin-bottom: 0.2em;
@@ -2098,7 +2058,7 @@ body.is-fullscreen-mode .block-editor-block-contextual-toolbar.is-fixed {
2098
2058
  position: relative;
2099
2059
  }
2100
2060
  .block-editor-link-control__search-item .block-editor-link-control__search-item-title mark {
2101
- font-weight: 700;
2061
+ font-weight: 600;
2102
2062
  color: inherit;
2103
2063
  background-color: transparent;
2104
2064
  }
@@ -2108,25 +2068,6 @@ body.is-fullscreen-mode .block-editor-block-contextual-toolbar.is-fixed {
2108
2068
  .block-editor-link-control__search-item .block-editor-link-control__search-item-title svg {
2109
2069
  display: none;
2110
2070
  }
2111
- .block-editor-link-control__search-item .block-editor-link-control__search-item-info {
2112
- display: block;
2113
- color: #757575;
2114
- font-size: 0.9em;
2115
- line-height: 1.3;
2116
- }
2117
- .block-editor-link-control__search-item .block-editor-link-control__search-item-error-notice {
2118
- font-style: italic;
2119
- font-size: 1.1em;
2120
- }
2121
- .block-editor-link-control__search-item .block-editor-link-control__search-item-type {
2122
- display: block;
2123
- padding: 3px 6px;
2124
- margin-left: auto;
2125
- font-size: 0.9em;
2126
- background-color: #f0f0f0;
2127
- border-radius: 2px;
2128
- white-space: nowrap;
2129
- }
2130
2071
  .block-editor-link-control__search-item .block-editor-link-control__search-item-description {
2131
2072
  padding-top: 12px;
2132
2073
  margin: 0;
@@ -2241,10 +2182,6 @@ body.is-fullscreen-mode .block-editor-block-contextual-toolbar.is-fixed {
2241
2182
  top: 0;
2242
2183
  }
2243
2184
 
2244
- .block-editor-link-control__search-results div[role=menu] > .block-editor-link-control__search-item.block-editor-link-control__search-item {
2245
- padding: 10px;
2246
- }
2247
-
2248
2185
  .block-editor-link-control__drawer {
2249
2186
  display: flex;
2250
2187
  order: 30;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wordpress/block-editor",
3
- "version": "12.3.6",
3
+ "version": "12.3.7",
4
4
  "description": "Generic block editor.",
5
5
  "author": "The WordPress Contributors",
6
6
  "license": "GPL-2.0-or-later",
@@ -38,7 +38,7 @@
38
38
  "@wordpress/api-fetch": "^6.32.1",
39
39
  "@wordpress/blob": "^3.35.1",
40
40
  "@wordpress/blocks": "^12.12.3",
41
- "@wordpress/components": "^25.1.6",
41
+ "@wordpress/components": "^25.1.7",
42
42
  "@wordpress/compose": "^6.12.1",
43
43
  "@wordpress/data": "^9.5.3",
44
44
  "@wordpress/date": "^4.35.1",
@@ -54,7 +54,7 @@
54
54
  "@wordpress/keyboard-shortcuts": "^4.12.3",
55
55
  "@wordpress/keycodes": "^3.35.1",
56
56
  "@wordpress/notices": "^4.3.3",
57
- "@wordpress/preferences": "^3.12.6",
57
+ "@wordpress/preferences": "^3.12.7",
58
58
  "@wordpress/private-apis": "^0.17.1",
59
59
  "@wordpress/rich-text": "^6.12.4",
60
60
  "@wordpress/shortcode": "^3.35.1",
@@ -85,5 +85,5 @@
85
85
  "publishConfig": {
86
86
  "access": "public"
87
87
  },
88
- "gitHead": "86ecd96b3bcada6b4cc35bb2455b3029cebb0ff3"
88
+ "gitHead": "5a52ea1ed29bbf8f3ead96f83b17d2c1cf84c880"
89
89
  }
@@ -22,16 +22,25 @@ const BlockDraggable = ( {
22
22
  } ) => {
23
23
  const { srcRootClientId, isDraggable, icon } = useSelect(
24
24
  ( select ) => {
25
- const { canMoveBlocks, getBlockRootClientId, getBlockName } =
26
- select( blockEditorStore );
27
- const { getBlockType } = select( blocksStore );
25
+ const {
26
+ canMoveBlocks,
27
+ getBlockRootClientId,
28
+ getBlockName,
29
+ getBlockAttributes,
30
+ } = select( blockEditorStore );
31
+ const { getBlockType, getActiveBlockVariation } =
32
+ select( blocksStore );
28
33
  const rootClientId = getBlockRootClientId( clientIds[ 0 ] );
29
34
  const blockName = getBlockName( clientIds[ 0 ] );
35
+ const variation = getActiveBlockVariation(
36
+ blockName,
37
+ getBlockAttributes( clientIds[ 0 ] )
38
+ );
30
39
 
31
40
  return {
32
41
  srcRootClientId: rootClientId,
33
42
  isDraggable: canMoveBlocks( clientIds, rootClientId ),
34
- icon: getBlockType( blockName )?.icon,
43
+ icon: variation?.icon || getBlockType( blockName )?.icon,
35
44
  };
36
45
  },
37
46
  [ clientIds ]
@@ -29,7 +29,7 @@ export default function ReusableBlocksRenameHint() {
29
29
  <div ref={ ref } className="reusable-blocks-menu-items__rename-hint">
30
30
  <div className="reusable-blocks-menu-items__rename-hint-content">
31
31
  { __(
32
- 'Reusable blocks are now called patterns. A synced pattern will behave in exactly the same way as a reusable block.'
32
+ 'Reusable blocks are now synced patterns. A synced pattern will behave in exactly the same way as a reusable block.'
33
33
  ) }
34
34
  </div>
35
35
  <Button
@@ -8,7 +8,7 @@ import { __ } from '@wordpress/i18n';
8
8
  // order to handle it as a unique case.
9
9
  export const CREATE_TYPE = '__CREATE__';
10
10
  export const TEL_TYPE = 'tel';
11
- export const URL_TYPE = 'URL';
11
+ export const URL_TYPE = 'link';
12
12
  export const MAILTO_TYPE = 'mailto';
13
13
  export const INTERNAL_TYPE = 'internal';
14
14
 
@@ -1,21 +1,15 @@
1
- /**
2
- * External dependencies
3
- */
4
- import classnames from 'classnames';
5
-
6
1
  /**
7
2
  * WordPress dependencies
8
3
  */
9
4
  import { __, sprintf } from '@wordpress/i18n';
10
- import { Button } from '@wordpress/components';
5
+ import { MenuItem } from '@wordpress/components';
11
6
  import { createInterpolateElement } from '@wordpress/element';
12
- import { Icon, plus } from '@wordpress/icons';
7
+ import { plus } from '@wordpress/icons';
13
8
 
14
9
  export const LinkControlSearchCreate = ( {
15
10
  searchTerm,
16
11
  onClick,
17
12
  itemProps,
18
- isSelected,
19
13
  buttonText,
20
14
  } ) => {
21
15
  if ( ! searchTerm ) {
@@ -40,27 +34,15 @@ export const LinkControlSearchCreate = ( {
40
34
  }
41
35
 
42
36
  return (
43
- <Button
37
+ <MenuItem
44
38
  { ...itemProps }
45
- className={ classnames(
46
- 'block-editor-link-control__search-create block-editor-link-control__search-item',
47
- {
48
- 'is-selected': isSelected,
49
- }
50
- ) }
39
+ iconPosition="left"
40
+ icon={ plus }
41
+ className="block-editor-link-control__search-item"
51
42
  onClick={ onClick }
52
43
  >
53
- <Icon
54
- className="block-editor-link-control__search-item-icon"
55
- icon={ plus }
56
- />
57
-
58
- <span className="block-editor-link-control__search-item-header">
59
- <span className="block-editor-link-control__search-item-title">
60
- { text }
61
- </span>
62
- </span>
63
- </Button>
44
+ { text }
45
+ </MenuItem>
64
46
  );
65
47
  };
66
48
 
@@ -1,14 +1,8 @@
1
- /**
2
- * External dependencies
3
- */
4
- import classnames from 'classnames';
5
-
6
1
  /**
7
2
  * WordPress dependencies
8
3
  */
9
- import { safeDecodeURI, filterURLForDisplay } from '@wordpress/url';
10
4
  import { __ } from '@wordpress/i18n';
11
- import { Button, TextHighlight } from '@wordpress/components';
5
+ import { MenuItem, TextHighlight } from '@wordpress/components';
12
6
  import {
13
7
  Icon,
14
8
  globe,
@@ -19,6 +13,7 @@ import {
19
13
  file,
20
14
  } from '@wordpress/icons';
21
15
  import { __unstableStripHTML as stripHTML } from '@wordpress/dom';
16
+ import { safeDecodeURI, filterURLForDisplay } from '@wordpress/url';
22
17
 
23
18
  const ICONS_MAP = {
24
19
  post: postList,
@@ -52,50 +47,33 @@ function SearchItemIcon( { isURL, suggestion } ) {
52
47
  export const LinkControlSearchItem = ( {
53
48
  itemProps,
54
49
  suggestion,
55
- isSelected = false,
50
+ searchTerm,
56
51
  onClick,
57
52
  isURL = false,
58
- searchTerm = '',
59
53
  shouldShowType = false,
60
54
  } ) => {
55
+ const info = isURL
56
+ ? __( 'Press ENTER to add this link' )
57
+ : filterURLForDisplay( safeDecodeURI( suggestion?.url ) );
58
+
61
59
  return (
62
- <Button
60
+ <MenuItem
63
61
  { ...itemProps }
62
+ info={ info }
63
+ iconPosition="left"
64
+ icon={
65
+ <SearchItemIcon suggestion={ suggestion } isURL={ isURL } />
66
+ }
64
67
  onClick={ onClick }
65
- className={ classnames( 'block-editor-link-control__search-item', {
66
- 'is-selected': isSelected,
67
- 'is-url': isURL,
68
- 'is-entity': ! isURL,
69
- } ) }
68
+ shortcut={ shouldShowType && getVisualTypeName( suggestion ) }
69
+ className="block-editor-link-control__search-item"
70
70
  >
71
- <SearchItemIcon suggestion={ suggestion } isURL={ isURL } />
72
-
73
- <span className="block-editor-link-control__search-item-header">
74
- <span className="block-editor-link-control__search-item-title">
75
- <TextHighlight
76
- // The component expects a plain text string.
77
- text={ stripHTML( suggestion.title ) }
78
- highlight={ searchTerm }
79
- />
80
- </span>
81
- <span
82
- aria-hidden={ ! isURL }
83
- className="block-editor-link-control__search-item-info"
84
- >
85
- { ! isURL &&
86
- ( filterURLForDisplay(
87
- safeDecodeURI( suggestion.url )
88
- ) ||
89
- '' ) }
90
- { isURL && __( 'Press ENTER to add this link' ) }
91
- </span>
92
- </span>
93
- { shouldShowType && suggestion.type && (
94
- <span className="block-editor-link-control__search-item-type">
95
- { getVisualTypeName( suggestion ) }
96
- </span>
97
- ) }
98
- </Button>
71
+ <TextHighlight
72
+ // The component expects a plain text string.
73
+ text={ stripHTML( suggestion.title ) }
74
+ highlight={ searchTerm }
75
+ />
76
+ </MenuItem>
99
77
  );
100
78
  };
101
79
 
@@ -2,7 +2,7 @@
2
2
  * WordPress dependencies
3
3
  */
4
4
  import { __, sprintf } from '@wordpress/i18n';
5
- import { VisuallyHidden } from '@wordpress/components';
5
+ import { VisuallyHidden, MenuGroup } from '@wordpress/components';
6
6
 
7
7
  /**
8
8
  * External dependencies
@@ -72,59 +72,61 @@ export default function LinkControlSearchResults( {
72
72
  className={ resultsListClasses }
73
73
  aria-labelledby={ searchResultsLabelId }
74
74
  >
75
- { suggestions.map( ( suggestion, index ) => {
76
- if (
77
- shouldShowCreateSuggestion &&
78
- CREATE_TYPE === suggestion.type
79
- ) {
75
+ <MenuGroup>
76
+ { suggestions.map( ( suggestion, index ) => {
77
+ if (
78
+ shouldShowCreateSuggestion &&
79
+ CREATE_TYPE === suggestion.type
80
+ ) {
81
+ return (
82
+ <LinkControlSearchCreate
83
+ searchTerm={ currentInputValue }
84
+ buttonText={ createSuggestionButtonText }
85
+ onClick={ () =>
86
+ handleSuggestionClick( suggestion )
87
+ }
88
+ // Intentionally only using `type` here as
89
+ // the constant is enough to uniquely
90
+ // identify the single "CREATE" suggestion.
91
+ key={ suggestion.type }
92
+ itemProps={ buildSuggestionItemProps(
93
+ suggestion,
94
+ index
95
+ ) }
96
+ isSelected={ index === selectedSuggestion }
97
+ />
98
+ );
99
+ }
100
+
101
+ // If we're not handling "Create" suggestions above then
102
+ // we don't want them in the main results so exit early.
103
+ if ( CREATE_TYPE === suggestion.type ) {
104
+ return null;
105
+ }
106
+
80
107
  return (
81
- <LinkControlSearchCreate
82
- searchTerm={ currentInputValue }
83
- buttonText={ createSuggestionButtonText }
84
- onClick={ () =>
85
- handleSuggestionClick( suggestion )
86
- }
87
- // Intentionally only using `type` here as
88
- // the constant is enough to uniquely
89
- // identify the single "CREATE" suggestion.
90
- key={ suggestion.type }
108
+ <LinkControlSearchItem
109
+ key={ `${ suggestion.id }-${ suggestion.type }` }
91
110
  itemProps={ buildSuggestionItemProps(
92
111
  suggestion,
93
112
  index
94
113
  ) }
114
+ suggestion={ suggestion }
115
+ index={ index }
116
+ onClick={ () => {
117
+ handleSuggestionClick( suggestion );
118
+ } }
95
119
  isSelected={ index === selectedSuggestion }
120
+ isURL={ LINK_ENTRY_TYPES.includes(
121
+ suggestion.type
122
+ ) }
123
+ searchTerm={ currentInputValue }
124
+ shouldShowType={ shouldShowSuggestionsTypes }
125
+ isFrontPage={ suggestion?.isFrontPage }
96
126
  />
97
127
  );
98
- }
99
-
100
- // If we're not handling "Create" suggestions above then
101
- // we don't want them in the main results so exit early.
102
- if ( CREATE_TYPE === suggestion.type ) {
103
- return null;
104
- }
105
-
106
- return (
107
- <LinkControlSearchItem
108
- key={ `${ suggestion.id }-${ suggestion.type }` }
109
- itemProps={ buildSuggestionItemProps(
110
- suggestion,
111
- index
112
- ) }
113
- suggestion={ suggestion }
114
- index={ index }
115
- onClick={ () => {
116
- handleSuggestionClick( suggestion );
117
- } }
118
- isSelected={ index === selectedSuggestion }
119
- isURL={ LINK_ENTRY_TYPES.includes(
120
- suggestion.type
121
- ) }
122
- searchTerm={ currentInputValue }
123
- shouldShowType={ shouldShowSuggestionsTypes }
124
- isFrontPage={ suggestion?.isFrontPage }
125
- />
126
- );
127
- } ) }
128
+ } ) }
129
+ </MenuGroup>
128
130
  </div>
129
131
  </div>
130
132
  );