@wordpress/block-editor 12.3.4 → 12.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.
Files changed (192) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/README.md +4 -0
  3. package/build/components/block-heading-level-dropdown/heading-level-icon.js +10 -2
  4. package/build/components/block-heading-level-dropdown/heading-level-icon.js.map +1 -1
  5. package/build/components/block-heading-level-dropdown/index.native.js +4 -3
  6. package/build/components/block-heading-level-dropdown/index.native.js.map +1 -1
  7. package/build/components/block-parent-selector/index.js +8 -5
  8. package/build/components/block-parent-selector/index.js.map +1 -1
  9. package/build/components/block-removal-warning-modal/index.js +18 -25
  10. package/build/components/block-removal-warning-modal/index.js.map +1 -1
  11. package/build/components/block-tools/block-contextual-toolbar.js +7 -11
  12. package/build/components/block-tools/block-contextual-toolbar.js.map +1 -1
  13. package/build/components/global-styles/color-panel.js +1 -1
  14. package/build/components/global-styles/color-panel.js.map +1 -1
  15. package/build/components/global-styles/hooks.js +2 -2
  16. package/build/components/global-styles/hooks.js.map +1 -1
  17. package/build/components/global-styles/typography-panel.js +34 -2
  18. package/build/components/global-styles/typography-panel.js.map +1 -1
  19. package/build/components/index.js +19 -1
  20. package/build/components/index.js.map +1 -1
  21. package/build/components/inserter/media-tab/hooks.js +2 -21
  22. package/build/components/inserter/media-tab/hooks.js.map +1 -1
  23. package/build/components/inserter/reusable-block-rename-hint.js +62 -0
  24. package/build/components/inserter/reusable-block-rename-hint.js.map +1 -0
  25. package/build/components/inserter/reusable-blocks-tab.js +5 -1
  26. package/build/components/inserter/reusable-blocks-tab.js.map +1 -1
  27. package/build/components/inserter/reusable-blocks-tab.native.js +2 -2
  28. package/build/components/inserter/reusable-blocks-tab.native.js.map +1 -1
  29. package/build/components/inserter/tabs.native.js +1 -1
  30. package/build/components/inserter/tabs.native.js.map +1 -1
  31. package/build/components/inserter-draggable-blocks/index.js +9 -1
  32. package/build/components/inserter-draggable-blocks/index.js.map +1 -1
  33. package/build/components/link-control/constants.js +1 -1
  34. package/build/components/link-control/constants.js.map +1 -1
  35. package/build/components/link-control/search-create-button.js +5 -21
  36. package/build/components/link-control/search-create-button.js.map +1 -1
  37. package/build/components/link-control/search-item.js +13 -30
  38. package/build/components/link-control/search-item.js.map +1 -1
  39. package/build/components/link-control/search-results.js +2 -2
  40. package/build/components/link-control/search-results.js.map +1 -1
  41. package/build/components/list-view/appender.js +2 -6
  42. package/build/components/list-view/appender.js.map +1 -1
  43. package/build/components/provider/index.js +5 -2
  44. package/build/components/provider/index.js.map +1 -1
  45. package/build/components/writing-flow/use-tab-nav.js +10 -27
  46. package/build/components/writing-flow/use-tab-nav.js.map +1 -1
  47. package/build/components/writing-mode-control/index.js +70 -0
  48. package/build/components/writing-mode-control/index.js.map +1 -0
  49. package/build/hooks/behaviors.js +25 -20
  50. package/build/hooks/behaviors.js.map +1 -1
  51. package/build/hooks/supports.js +7 -1
  52. package/build/hooks/supports.js.map +1 -1
  53. package/build/hooks/typography.js +2 -1
  54. package/build/hooks/typography.js.map +1 -1
  55. package/build/hooks/utils.js +4 -2
  56. package/build/hooks/utils.js.map +1 -1
  57. package/build/private-apis.js +3 -0
  58. package/build/private-apis.js.map +1 -1
  59. package/build/private-apis.native.js +3 -0
  60. package/build/private-apis.native.js.map +1 -1
  61. package/build/store/actions.js +195 -1
  62. package/build/store/actions.js.map +1 -1
  63. package/build/store/index.js +10 -1
  64. package/build/store/index.js.map +1 -1
  65. package/build/store/private-actions.js +46 -40
  66. package/build/store/private-actions.js.map +1 -1
  67. package/build/store/private-selectors.js +3 -3
  68. package/build/store/private-selectors.js.map +1 -1
  69. package/build/store/reducer.js +22 -8
  70. package/build/store/reducer.js.map +1 -1
  71. package/build/store/selectors.js +6 -4
  72. package/build/store/selectors.js.map +1 -1
  73. package/build-module/components/block-heading-level-dropdown/heading-level-icon.js +9 -2
  74. package/build-module/components/block-heading-level-dropdown/heading-level-icon.js.map +1 -1
  75. package/build-module/components/block-heading-level-dropdown/index.native.js +4 -3
  76. package/build-module/components/block-heading-level-dropdown/index.native.js.map +1 -1
  77. package/build-module/components/block-parent-selector/index.js +7 -5
  78. package/build-module/components/block-parent-selector/index.js.map +1 -1
  79. package/build-module/components/block-removal-warning-modal/index.js +19 -23
  80. package/build-module/components/block-removal-warning-modal/index.js.map +1 -1
  81. package/build-module/components/block-tools/block-contextual-toolbar.js +8 -11
  82. package/build-module/components/block-tools/block-contextual-toolbar.js.map +1 -1
  83. package/build-module/components/global-styles/color-panel.js +1 -1
  84. package/build-module/components/global-styles/color-panel.js.map +1 -1
  85. package/build-module/components/global-styles/hooks.js +2 -2
  86. package/build-module/components/global-styles/hooks.js.map +1 -1
  87. package/build-module/components/global-styles/typography-panel.js +33 -2
  88. package/build-module/components/global-styles/typography-panel.js.map +1 -1
  89. package/build-module/components/index.js +6 -0
  90. package/build-module/components/index.js.map +1 -1
  91. package/build-module/components/inserter/media-tab/hooks.js +2 -21
  92. package/build-module/components/inserter/media-tab/hooks.js.map +1 -1
  93. package/build-module/components/inserter/reusable-block-rename-hint.js +48 -0
  94. package/build-module/components/inserter/reusable-block-rename-hint.js.map +1 -0
  95. package/build-module/components/inserter/reusable-blocks-tab.js +4 -1
  96. package/build-module/components/inserter/reusable-blocks-tab.js.map +1 -1
  97. package/build-module/components/inserter/reusable-blocks-tab.native.js +2 -2
  98. package/build-module/components/inserter/reusable-blocks-tab.native.js.map +1 -1
  99. package/build-module/components/inserter/tabs.native.js +1 -1
  100. package/build-module/components/inserter/tabs.native.js.map +1 -1
  101. package/build-module/components/inserter-draggable-blocks/index.js +9 -2
  102. package/build-module/components/inserter-draggable-blocks/index.js.map +1 -1
  103. package/build-module/components/link-control/constants.js +1 -1
  104. package/build-module/components/link-control/constants.js.map +1 -1
  105. package/build-module/components/link-control/search-create-button.js +7 -20
  106. package/build-module/components/link-control/search-create-button.js.map +1 -1
  107. package/build-module/components/link-control/search-item.js +14 -28
  108. package/build-module/components/link-control/search-item.js.map +1 -1
  109. package/build-module/components/link-control/search-results.js +3 -3
  110. package/build-module/components/link-control/search-results.js.map +1 -1
  111. package/build-module/components/list-view/appender.js +2 -6
  112. package/build-module/components/list-view/appender.js.map +1 -1
  113. package/build-module/components/provider/index.js +5 -2
  114. package/build-module/components/provider/index.js.map +1 -1
  115. package/build-module/components/writing-flow/use-tab-nav.js +8 -26
  116. package/build-module/components/writing-flow/use-tab-nav.js.map +1 -1
  117. package/build-module/components/writing-mode-control/index.js +57 -0
  118. package/build-module/components/writing-mode-control/index.js.map +1 -0
  119. package/build-module/hooks/behaviors.js +26 -20
  120. package/build-module/hooks/behaviors.js.map +1 -1
  121. package/build-module/hooks/supports.js +7 -1
  122. package/build-module/hooks/supports.js.map +1 -1
  123. package/build-module/hooks/typography.js +2 -1
  124. package/build-module/hooks/typography.js.map +1 -1
  125. package/build-module/hooks/utils.js +4 -2
  126. package/build-module/hooks/utils.js.map +1 -1
  127. package/build-module/private-apis.js +2 -0
  128. package/build-module/private-apis.js.map +1 -1
  129. package/build-module/private-apis.native.js +2 -0
  130. package/build-module/private-apis.native.js.map +1 -1
  131. package/build-module/store/actions.js +191 -1
  132. package/build-module/store/actions.js.map +1 -1
  133. package/build-module/store/index.js +10 -1
  134. package/build-module/store/index.js.map +1 -1
  135. package/build-module/store/private-actions.js +45 -36
  136. package/build-module/store/private-actions.js.map +1 -1
  137. package/build-module/store/private-selectors.js +2 -2
  138. package/build-module/store/private-selectors.js.map +1 -1
  139. package/build-module/store/reducer.js +22 -8
  140. package/build-module/store/reducer.js.map +1 -1
  141. package/build-module/store/selectors.js +6 -4
  142. package/build-module/store/selectors.js.map +1 -1
  143. package/build-style/style-rtl.css +88 -81
  144. package/build-style/style.css +88 -81
  145. package/package.json +31 -31
  146. package/src/components/block-draggable/style.scss +1 -0
  147. package/src/components/block-heading-level-dropdown/heading-level-icon.js +6 -1
  148. package/src/components/block-heading-level-dropdown/index.native.js +8 -4
  149. package/src/components/block-inspector/style.scss +2 -1
  150. package/src/components/block-parent-selector/index.js +13 -8
  151. package/src/components/block-removal-warning-modal/index.js +16 -27
  152. package/src/components/block-tools/block-contextual-toolbar.js +5 -11
  153. package/src/components/block-tools/style.scss +69 -26
  154. package/src/components/font-family/README.md +71 -0
  155. package/src/components/global-styles/color-panel.js +1 -1
  156. package/src/components/global-styles/hooks.js +2 -0
  157. package/src/components/global-styles/typography-panel.js +40 -0
  158. package/src/components/index.js +6 -0
  159. package/src/components/inserter/media-tab/hooks.js +2 -22
  160. package/src/components/inserter/reusable-block-rename-hint.js +52 -0
  161. package/src/components/inserter/reusable-blocks-tab.js +4 -0
  162. package/src/components/inserter/reusable-blocks-tab.native.js +2 -2
  163. package/src/components/inserter/style.scss +28 -0
  164. package/src/components/inserter/tabs.native.js +5 -1
  165. package/src/components/inserter-draggable-blocks/index.js +13 -2
  166. package/src/components/link-control/constants.js +1 -1
  167. package/src/components/link-control/search-create-button.js +8 -26
  168. package/src/components/link-control/search-item.js +21 -43
  169. package/src/components/link-control/search-results.js +48 -46
  170. package/src/components/link-control/style.scss +18 -68
  171. package/src/components/link-control/test/index.js +6 -7
  172. package/src/components/list-view/appender.js +5 -6
  173. package/src/components/panel-color-settings/README.md +98 -0
  174. package/src/components/provider/index.js +9 -2
  175. package/src/components/recursion-provider/README.md +101 -0
  176. package/src/components/writing-flow/use-tab-nav.js +10 -33
  177. package/src/components/writing-mode-control/index.js +68 -0
  178. package/src/components/writing-mode-control/style.scss +18 -0
  179. package/src/hooks/behaviors.js +25 -16
  180. package/src/hooks/supports.js +7 -0
  181. package/src/hooks/typography.js +2 -0
  182. package/src/hooks/utils.js +3 -0
  183. package/src/private-apis.js +2 -0
  184. package/src/private-apis.native.js +2 -0
  185. package/src/store/actions.js +194 -1
  186. package/src/store/index.js +10 -0
  187. package/src/store/private-actions.js +39 -39
  188. package/src/store/private-selectors.js +2 -2
  189. package/src/store/reducer.js +22 -8
  190. package/src/store/selectors.js +9 -6
  191. package/src/store/test/actions.js +111 -0
  192. package/src/store/test/private-actions.js +56 -0
@@ -10,6 +10,7 @@ import {
10
10
  headingLevel6,
11
11
  paragraph,
12
12
  } from '@wordpress/icons';
13
+ import { Icon } from '@wordpress/components';
13
14
 
14
15
  /** @typedef {import('@wordpress/element').WPComponent} WPComponent */
15
16
 
@@ -39,5 +40,9 @@ const LEVEL_TO_PATH = {
39
40
  * @return {?WPComponent} The icon.
40
41
  */
41
42
  export default function HeadingLevelIcon( { level } ) {
42
- return LEVEL_TO_PATH[ level ] ?? null;
43
+ if ( LEVEL_TO_PATH[ level ] ) {
44
+ return <Icon icon={ LEVEL_TO_PATH[ level ] } />;
45
+ }
46
+
47
+ return null;
43
48
  }
@@ -30,7 +30,11 @@ const HEADING_LEVELS = [ 1, 2, 3, 4, 5, 6 ];
30
30
  *
31
31
  * @return {WPComponent} The toolbar.
32
32
  */
33
- export default function HeadingLevelDropdown( { selectedLevel, onChange } ) {
33
+ export default function HeadingLevelDropdown( {
34
+ options = HEADING_LEVELS,
35
+ value,
36
+ onChange,
37
+ } ) {
34
38
  const createLevelControl = (
35
39
  targetLevel,
36
40
  currentLevel,
@@ -53,9 +57,9 @@ export default function HeadingLevelDropdown( { selectedLevel, onChange } ) {
53
57
 
54
58
  return (
55
59
  <DropdownMenu
56
- icon={ <HeadingLevelIcon level={ selectedLevel } /> }
57
- controls={ HEADING_LEVELS.map( ( index ) =>
58
- createLevelControl( index, selectedLevel, onChange )
60
+ icon={ <HeadingLevelIcon level={ value } /> }
61
+ controls={ options.map( ( index ) =>
62
+ createLevelControl( index, value, onChange )
59
63
  ) }
60
64
  label={ __( 'Change level' ) }
61
65
  />
@@ -20,7 +20,8 @@
20
20
 
21
21
  // Reset unwanted margin-bottom from being applied to BaseControls within certain components.
22
22
  .components-focal-point-picker-control,
23
- .components-query-controls {
23
+ .components-query-controls,
24
+ .components-range-control {
24
25
  .components-base-control {
25
26
  margin-bottom: 0;
26
27
  }
@@ -14,6 +14,7 @@ import useBlockDisplayInformation from '../use-block-display-information';
14
14
  import BlockIcon from '../block-icon';
15
15
  import { useShowMoversGestures } from '../block-toolbar/utils';
16
16
  import { store as blockEditorStore } from '../../store';
17
+ import { unlock } from '../../lock-unlock';
17
18
 
18
19
  /**
19
20
  * Block parent selector component, displaying the hierarchy of the
@@ -24,14 +25,15 @@ import { store as blockEditorStore } from '../../store';
24
25
  export default function BlockParentSelector() {
25
26
  const { selectBlock, toggleBlockHighlight } =
26
27
  useDispatch( blockEditorStore );
27
- const { firstParentClientId, shouldHide, isDistractionFree } = useSelect(
28
+ const { firstParentClientId, isVisible, isDistractionFree } = useSelect(
28
29
  ( select ) => {
29
30
  const {
30
31
  getBlockName,
31
32
  getBlockParents,
32
33
  getSelectedBlockClientId,
33
34
  getSettings,
34
- } = select( blockEditorStore );
35
+ getBlockEditingMode,
36
+ } = unlock( select( blockEditorStore ) );
35
37
  const { hasBlockSupport } = select( blocksStore );
36
38
  const selectedBlockClientId = getSelectedBlockClientId();
37
39
  const parents = getBlockParents( selectedBlockClientId );
@@ -41,11 +43,14 @@ export default function BlockParentSelector() {
41
43
  const settings = getSettings();
42
44
  return {
43
45
  firstParentClientId: _firstParentClientId,
44
- shouldHide: ! hasBlockSupport(
45
- _parentBlockType,
46
- '__experimentalParentSelector',
47
- true
48
- ),
46
+ isVisible:
47
+ _firstParentClientId &&
48
+ getBlockEditingMode( _firstParentClientId ) === 'default' &&
49
+ hasBlockSupport(
50
+ _parentBlockType,
51
+ '__experimentalParentSelector',
52
+ true
53
+ ),
49
54
  isDistractionFree: settings.isDistractionFree,
50
55
  };
51
56
  },
@@ -66,7 +71,7 @@ export default function BlockParentSelector() {
66
71
  },
67
72
  } );
68
73
 
69
- if ( shouldHide || firstParentClientId === undefined ) {
74
+ if ( ! isVisible ) {
70
75
  return null;
71
76
  }
72
77
 
@@ -16,38 +16,26 @@ import { __ } from '@wordpress/i18n';
16
16
  import { store as blockEditorStore } from '../../store';
17
17
  import { unlock } from '../../lock-unlock';
18
18
 
19
- // In certain editing contexts, we'd like to prevent accidental removal of
20
- // important blocks. For example, in the site editor, the Query Loop block is
21
- // deemed important. In such cases, we'll ask the user for confirmation that
22
- // they intended to remove such block(s).
23
- //
24
- // @see https://github.com/WordPress/gutenberg/pull/51145
25
- export const blockTypePromptMessages = {
26
- 'core/query': __( 'Query Loop displays a list of posts or pages.' ),
27
- 'core/post-content': __(
28
- 'Post Content displays the content of a post or page.'
29
- ),
30
- };
31
-
32
- export function BlockRemovalWarningModal() {
19
+ export function BlockRemovalWarningModal( { rules } ) {
33
20
  const { clientIds, selectPrevious, blockNamesForPrompt } = useSelect(
34
21
  ( select ) =>
35
22
  unlock( select( blockEditorStore ) ).getRemovalPromptData()
36
23
  );
37
24
 
38
25
  const {
39
- clearRemovalPrompt,
40
- toggleRemovalPromptSupport,
26
+ clearBlockRemovalPrompt,
27
+ setBlockRemovalRules,
41
28
  privateRemoveBlocks,
42
29
  } = unlock( useDispatch( blockEditorStore ) );
43
30
 
44
- // Signalling the removal prompt is in place.
31
+ // Load block removal rules, simultaneously signalling that the block
32
+ // removal prompt is in place.
45
33
  useEffect( () => {
46
- toggleRemovalPromptSupport( true );
34
+ setBlockRemovalRules( rules );
47
35
  return () => {
48
- toggleRemovalPromptSupport( false );
36
+ setBlockRemovalRules();
49
37
  };
50
- }, [ toggleRemovalPromptSupport ] );
38
+ }, [ rules, setBlockRemovalRules ] );
51
39
 
52
40
  if ( ! blockNamesForPrompt ) {
53
41
  return;
@@ -55,22 +43,23 @@ export function BlockRemovalWarningModal() {
55
43
 
56
44
  const onConfirmRemoval = () => {
57
45
  privateRemoveBlocks( clientIds, selectPrevious, /* force */ true );
58
- clearRemovalPrompt();
46
+ clearBlockRemovalPrompt();
59
47
  };
60
48
 
61
49
  return (
62
50
  <Modal
63
51
  title={ __( 'Are you sure?' ) }
64
- onRequestClose={ clearRemovalPrompt }
52
+ onRequestClose={ clearBlockRemovalPrompt }
53
+ style={ {
54
+ maxWidth: '40rem',
55
+ } }
65
56
  >
66
57
  { blockNamesForPrompt.length === 1 ? (
67
- <p>{ blockTypePromptMessages[ blockNamesForPrompt[ 0 ] ] }</p>
58
+ <p>{ rules[ blockNamesForPrompt[ 0 ] ] }</p>
68
59
  ) : (
69
60
  <ul style={ { listStyleType: 'disc', paddingLeft: '1rem' } }>
70
61
  { blockNamesForPrompt.map( ( name ) => (
71
- <li key={ name }>
72
- { blockTypePromptMessages[ name ] }
73
- </li>
62
+ <li key={ name }>{ rules[ name ] }</li>
74
63
  ) ) }
75
64
  </ul>
76
65
  ) }
@@ -80,7 +69,7 @@ export function BlockRemovalWarningModal() {
80
69
  : __( 'Removing this block is not advised.' ) }
81
70
  </p>
82
71
  <HStack justify="right">
83
- <Button variant="tertiary" onClick={ clearRemovalPrompt }>
72
+ <Button variant="tertiary" onClick={ clearBlockRemovalPrompt }>
84
73
  { __( 'Cancel' ) }
85
74
  </Button>
86
75
  <Button variant="primary" onClick={ onConfirmRemoval }>
@@ -15,7 +15,7 @@ import {
15
15
  ToolbarButton,
16
16
  ToolbarGroup,
17
17
  } from '@wordpress/components';
18
- import { levelUp } from '@wordpress/icons';
18
+ import { next, previous } from '@wordpress/icons';
19
19
  import { useViewportMatch } from '@wordpress/compose';
20
20
 
21
21
  /**
@@ -24,7 +24,6 @@ import { useViewportMatch } from '@wordpress/compose';
24
24
  import NavigableToolbar from '../navigable-toolbar';
25
25
  import BlockToolbar from '../block-toolbar';
26
26
  import { store as blockEditorStore } from '../../store';
27
- import BlockIcon from '../block-icon';
28
27
  import { unlock } from '../../lock-unlock';
29
28
 
30
29
  function BlockContextualToolbar( { focusOnMount, isFixed, ...props } ) {
@@ -57,6 +56,7 @@ function BlockContextualToolbar( { focusOnMount, isFixed, ...props } ) {
57
56
  hasParents: parents.length,
58
57
  showParentSelector:
59
58
  parentBlockType &&
59
+ getBlockEditingMode( firstParentClientId ) === 'default' &&
60
60
  hasBlockSupport(
61
61
  parentBlockType,
62
62
  '__experimentalParentSelector',
@@ -93,6 +93,7 @@ function BlockContextualToolbar( { focusOnMount, isFixed, ...props } ) {
93
93
  aria-label={ __( 'Block tools' ) }
94
94
  { ...props }
95
95
  >
96
+ { ! isCollapsed && <BlockToolbar hideDragHandle={ isFixed } /> }
96
97
  { isFixed && isLargeViewport && blockType && (
97
98
  <ToolbarGroup
98
99
  className={
@@ -104,13 +105,7 @@ function BlockContextualToolbar( { focusOnMount, isFixed, ...props } ) {
104
105
  <ToolbarItem
105
106
  as={ ToolbarButton }
106
107
  ref={ toolbarButtonRef }
107
- icon={
108
- isCollapsed ? (
109
- <BlockIcon icon={ blockType.icon } />
110
- ) : (
111
- levelUp
112
- )
113
- }
108
+ icon={ isCollapsed ? next : previous }
114
109
  onClick={ () => {
115
110
  setIsCollapsed( ( collapsed ) => ! collapsed );
116
111
  toolbarButtonRef.current.focus();
@@ -118,12 +113,11 @@ function BlockContextualToolbar( { focusOnMount, isFixed, ...props } ) {
118
113
  label={
119
114
  isCollapsed
120
115
  ? __( 'Show block tools' )
121
- : __( 'Show document tools' )
116
+ : __( 'Hide block tools' )
122
117
  }
123
118
  />
124
119
  </ToolbarGroup>
125
120
  ) }
126
- { ! isCollapsed && <BlockToolbar hideDragHandle={ isFixed } /> }
127
121
  </NavigableToolbar>
128
122
  );
129
123
  }
@@ -131,11 +131,11 @@
131
131
  @include break-medium() {
132
132
  &.is-fixed {
133
133
 
134
- // leave room for block inserter
135
- margin-left: $grid-unit-80;
134
+ // leave room for block inserter, undo and redo, list view
135
+ margin-left: $grid-unit-80 * 3 - 2 * $grid-unit + $grid-unit-05;
136
136
  // position on top of interface header
137
137
  position: fixed;
138
- top: $admin-bar-height + $grid-unit;
138
+ top: $admin-bar-height + $grid-unit - $border-width;
139
139
  // Don't fill up when empty
140
140
  min-height: initial;
141
141
  // remove the border
@@ -145,32 +145,63 @@
145
145
 
146
146
  &.is-collapsed {
147
147
  width: initial;
148
- margin-left: $grid-unit-80 * 3 + $grid-unit-30;
149
148
  }
150
149
 
151
150
  .is-fullscreen-mode & {
152
- // leave room for block inserter
153
- margin-left: $grid-unit-80 + $grid-unit-70;
154
- top: $grid-unit;
151
+ // leave room for block inserter, undo and redo, list view
152
+ // and some margin left
153
+ margin-left: $grid-unit-80 * 4 - 2 * $grid-unit;
154
+ top: $grid-unit - $border-width;
155
155
  &.is-collapsed {
156
156
  width: initial;
157
- margin-left: $grid-unit-80 * 4 + $grid-unit-30;
157
+ }
158
+ }
159
+
160
+ & > .block-editor-block-toolbar.is-showing-movers {
161
+ flex-grow: initial;
162
+ width: initial;
163
+
164
+ // Add a border as separator in the block toolbar.
165
+ &::before {
166
+ content: "";
167
+ width: $border-width;
168
+ height: 3 * $grid-unit;
169
+ margin-top: $grid-unit + $grid-unit-05;
170
+ margin-right: 0;
171
+ background-color: $gray-300;
172
+ position: relative;
173
+ left: math.div(-$grid-unit-05, 2);
174
+ top: -1px;
158
175
  }
159
176
  }
160
177
 
161
178
  & > .block-editor-block-toolbar__group-collapse-fixed-toolbar {
162
179
  border: none;
163
180
 
181
+ .show-icon-labels & {
182
+ .components-button.has-icon {
183
+ // Hide the button icons when labels are set to display...
184
+ svg {
185
+ display: none;
186
+ }
187
+ // ... and display labels.
188
+ &::after {
189
+ content: attr(aria-label);
190
+ font-size: $helptext-font-size;
191
+ }
192
+ }
193
+ }
194
+
164
195
  // Add a border as separator in the block toolbar.
165
- &::after {
196
+ &::before {
166
197
  content: "";
167
198
  width: $border-width;
168
- height: 24px;
199
+ height: 3 * $grid-unit;
169
200
  margin-top: $grid-unit + $grid-unit-05;
170
- margin-bottom: $grid-unit + $grid-unit-05;
201
+ margin-right: $grid-unit-10;
171
202
  background-color: $gray-300;
172
- position: absolute;
173
- left: 44px;
203
+ position: relative;
204
+ left: 0;
174
205
  top: -1px;
175
206
  }
176
207
  }
@@ -178,6 +209,21 @@
178
209
  & > .block-editor-block-toolbar__group-expand-fixed-toolbar {
179
210
  border: none;
180
211
 
212
+ .show-icon-labels & {
213
+ width: $grid-unit-80 * 4;
214
+ .components-button.has-icon {
215
+ // Hide the button icons when labels are set to display...
216
+ svg {
217
+ display: none;
218
+ }
219
+ // ... and display labels.
220
+ &::after {
221
+ content: attr(aria-label);
222
+ font-size: $helptext-font-size;
223
+ }
224
+ }
225
+ }
226
+
181
227
  // Add a border as separator in the block toolbar.
182
228
  &::before {
183
229
  content: "";
@@ -186,27 +232,20 @@
186
232
  margin-bottom: $grid-unit + $grid-unit-05;
187
233
  background-color: $gray-300;
188
234
  position: relative;
189
- left: -12px; //the padding of buttons
190
- height: 24px;
235
+ left: -8px;
236
+ height: 3 * $grid-unit;
237
+ top: -1px;
191
238
  }
192
239
  }
193
240
 
194
241
  .show-icon-labels & {
195
242
 
196
- margin-left: $grid-unit-80;
197
-
198
- &.is-collapsed {
199
- margin-left: $grid-unit-80 * 6;
200
- }
243
+ margin-left: $grid-unit-80 + 2 * $grid-unit; // inserter and margin ;
201
244
 
202
245
  .is-fullscreen-mode & {
203
- margin-left: $grid-unit-80 + $grid-unit-80;
204
- &.is-collapsed {
205
- margin-left: $grid-unit-80 * 7;
206
- }
246
+ margin-left: $grid-unit * 18; // site hub, inserter and margin
207
247
  }
208
248
 
209
-
210
249
  .block-editor-block-parent-selector .block-editor-block-parent-selector__button::after {
211
250
  left: 0;
212
251
  }
@@ -234,12 +273,14 @@
234
273
  }
235
274
 
236
275
  &.is-fixed .block-editor-block-parent-selector {
276
+
237
277
  .block-editor-block-parent-selector__button {
238
278
  position: relative;
239
279
  top: -1px;
240
280
  border: 0;
241
281
  padding-right: 6px;
242
282
  padding-left: 6px;
283
+
243
284
  &::after {
244
285
  content: "\00B7";
245
286
  font-size: 16px;
@@ -281,7 +322,9 @@
281
322
  // for the block inserter the publish button
282
323
  @include break-large() {
283
324
  &.is-fixed {
284
- width: initial;
325
+ // the combined with of the tools at the right of the header and the margin left
326
+ // of the toolbar which includes four buttons
327
+ width: calc(100% - 240px - #{4 * $grid-unit-80});
285
328
  }
286
329
  }
287
330
 
@@ -0,0 +1,71 @@
1
+ # FontFamilyControl
2
+
3
+ FontFamilyControl is a React component that renders a UI that allows users to select a font family.
4
+ The component renders a user interface that allows the user to select from a set of predefined font families as defined by the `typography.fontFamilies` presets.
5
+ Optionally, you can provide a `fontFamilies` prop that overrides the predefined font families.
6
+
7
+ ![FontFamilyControl component preview](https://i.imgur.com/blS5iA3.png)
8
+
9
+ ## Usage
10
+
11
+ ```jsx
12
+ import { FontFamilyControl } from '@wordpress/block-editor';
13
+ import { useState } from '@wordpress/element';
14
+ import { __ } from '@wordpress/i18n';
15
+
16
+ // ...
17
+
18
+ const MyFontFamilyControl = () => {
19
+ const [ fontFamily, setFontFamily ] = useState( '' );
20
+
21
+ return (
22
+ <FontFamilyControl
23
+ value={ fontFamily }
24
+ onChange={ ( newFontFamily ) => {
25
+ setFontFamily( newFontFamily );
26
+ } }
27
+ />
28
+ );
29
+ };
30
+
31
+ /// ...
32
+
33
+ <MyFontFamilyControl />
34
+ ```
35
+
36
+ ## Props
37
+
38
+ The component accepts the following props:
39
+
40
+ ### onChange
41
+
42
+ A function that receives the new font family value.
43
+ If onChange is called without any parameter, it should reset the value, attending to what reset means in that context, e.g., set the font family to undefined or set the font family a starting value.
44
+
45
+ - Type: `function`
46
+ - Required: Yes
47
+
48
+ ### fontFamilies
49
+
50
+ A user-provided set of font families.
51
+ Optional, used in case we want to override the predefined ones coming from presets.
52
+
53
+ - Type: `Array`
54
+ - Required: No
55
+
56
+ The font families are provided as an array of objects with the following schema:
57
+
58
+ | Property | Description | Type |
59
+ | ---------- | ----------------------------------------- | ------ |
60
+ | fontFamily | Font family, as used in CSS. | string |
61
+ | name | Optional display name of the font family. | string |
62
+
63
+ ### value
64
+
65
+ The current font family value.
66
+
67
+ - Type: `String`
68
+ - Required: No
69
+ - Default: ''
70
+
71
+ The rest of the props are passed down to the underlying `<SelectControl />` instance.
@@ -35,7 +35,7 @@ export function useHasColorPanel( settings ) {
35
35
  const hasBackgroundPanel = useHasBackgroundPanel( settings );
36
36
  const hasLinkPanel = useHasLinkPanel( settings );
37
37
  const hasHeadingPanel = useHasHeadingPanel( settings );
38
- const hasButtonPanel = useHasHeadingPanel( settings );
38
+ const hasButtonPanel = useHasButtonPanel( settings );
39
39
  const hasCaptionPanel = useHasCaptionPanel( settings );
40
40
 
41
41
  return (
@@ -71,6 +71,7 @@ const VALID_SETTINGS = [
71
71
  'typography.textColumns',
72
72
  'typography.textDecoration',
73
73
  'typography.textTransform',
74
+ 'typography.writingMode',
74
75
  ];
75
76
 
76
77
  export const useGlobalStylesReset = () => {
@@ -292,6 +293,7 @@ export function useSettingsForBlockElement(
292
293
  'letterSpacing',
293
294
  'textTransform',
294
295
  'textDecoration',
296
+ 'writingMode',
295
297
  ].forEach( ( key ) => {
296
298
  if ( ! supportedStyles.includes( key ) ) {
297
299
  updatedSettings.typography = {
@@ -19,6 +19,7 @@ import LineHeightControl from '../line-height-control';
19
19
  import LetterSpacingControl from '../letter-spacing-control';
20
20
  import TextTransformControl from '../text-transform-control';
21
21
  import TextDecorationControl from '../text-decoration-control';
22
+ import WritingModeControl from '../writing-mode-control';
22
23
  import { getValueFromVariable } from './utils';
23
24
  import { setImmutably } from '../../utils/object';
24
25
 
@@ -32,6 +33,7 @@ export function useHasTypographyPanel( settings ) {
32
33
  const hasLetterSpacing = useHasLetterSpacingControl( settings );
33
34
  const hasTextTransform = useHasTextTransformControl( settings );
34
35
  const hasTextDecoration = useHasTextDecorationControl( settings );
36
+ const hasWritingMode = useHasWritingModeControl( settings );
35
37
  const hasTextColumns = useHasTextColumnsControl( settings );
36
38
  const hasFontSize = useHasFontSizeControl( settings );
37
39
 
@@ -43,6 +45,7 @@ export function useHasTypographyPanel( settings ) {
43
45
  hasTextTransform ||
44
46
  hasFontSize ||
45
47
  hasTextDecoration ||
48
+ hasWritingMode ||
46
49
  hasTextColumns
47
50
  );
48
51
  }
@@ -103,6 +106,10 @@ function useHasTextDecorationControl( settings ) {
103
106
  return settings?.typography?.textDecoration;
104
107
  }
105
108
 
109
+ function useHasWritingModeControl( settings ) {
110
+ return settings?.typography?.writingMode;
111
+ }
112
+
106
113
  function useHasTextColumnsControl( settings ) {
107
114
  return settings?.typography?.textColumns;
108
115
  }
@@ -138,6 +145,7 @@ const DEFAULT_CONTROLS = {
138
145
  letterSpacing: true,
139
146
  textTransform: true,
140
147
  textDecoration: true,
148
+ writingMode: true,
141
149
  textColumns: true,
142
150
  };
143
151
 
@@ -310,6 +318,21 @@ export default function TypographyPanel( {
310
318
  const hasTextDecoration = () => !! value?.typography?.textDecoration;
311
319
  const resetTextDecoration = () => setTextDecoration( undefined );
312
320
 
321
+ // Text Orientation
322
+ const hasWritingModeControl = useHasWritingModeControl( settings );
323
+ const writingMode = decodeValue( inheritedValue?.typography?.writingMode );
324
+ const setWritingMode = ( newValue ) => {
325
+ onChange(
326
+ setImmutably(
327
+ value,
328
+ [ 'typography', 'writingMode' ],
329
+ newValue || undefined
330
+ )
331
+ );
332
+ };
333
+ const hasWritingMode = () => !! value?.typography?.writingMode;
334
+ const resetWritingMode = () => setWritingMode( undefined );
335
+
313
336
  const resetAllFilter = useCallback( ( previousValue ) => {
314
337
  return {
315
338
  ...previousValue,
@@ -456,6 +479,23 @@ export default function TypographyPanel( {
456
479
  />
457
480
  </ToolsPanelItem>
458
481
  ) }
482
+ { hasWritingModeControl && (
483
+ <ToolsPanelItem
484
+ className="single-column"
485
+ label={ __( 'Text orientation' ) }
486
+ hasValue={ hasWritingMode }
487
+ onDeselect={ resetWritingMode }
488
+ isShownByDefault={ defaultControls.writingMode }
489
+ panelId={ panelId }
490
+ >
491
+ <WritingModeControl
492
+ value={ writingMode }
493
+ onChange={ setWritingMode }
494
+ size="__unstable-large"
495
+ __nextHasNoMarginBottom
496
+ />
497
+ </ToolsPanelItem>
498
+ ) }
459
499
  { hasTextTransformControl && (
460
500
  <ToolsPanelItem
461
501
  label={ __( 'Letter case' ) }
@@ -50,6 +50,7 @@ export { default as __experimentalFontFamilyControl } from './font-family';
50
50
  export { default as __experimentalLetterSpacingControl } from './letter-spacing-control';
51
51
  export { default as __experimentalTextDecorationControl } from './text-decoration-control';
52
52
  export { default as __experimentalTextTransformControl } from './text-transform-control';
53
+ export { default as __experimentalWritingModeControl } from './writing-mode-control';
53
54
  export { default as __experimentalColorGradientControl } from './colors-gradients/control';
54
55
  export { default as __experimentalColorGradientSettingsDropdown } from './colors-gradients/dropdown';
55
56
  export { default as __experimentalPanelColorGradientSettings } from './colors-gradients/panel-color-gradient-settings';
@@ -164,3 +165,8 @@ export { default as __experimentalInspectorPopoverHeader } from './inspector-pop
164
165
 
165
166
  export { default as BlockEditorProvider } from './provider';
166
167
  export { default as useSetting } from './use-setting';
168
+
169
+ /*
170
+ * The following rename hint component can be removed in 6.4.
171
+ */
172
+ export { default as ReusableBlocksRenameHint } from './inserter/reusable-block-rename-hint';
@@ -9,28 +9,8 @@ import { useSelect } from '@wordpress/data';
9
9
  */
10
10
  import { store as blockEditorStore } from '../../../store';
11
11
 
12
- /**
13
- * Interface for inserter media requests.
14
- *
15
- * @typedef {Object} InserterMediaRequest
16
- * @property {number} per_page How many items to fetch per page.
17
- * @property {string} search The search term to use for filtering the results.
18
- */
19
-
20
- /**
21
- * Interface for inserter media responses. Any media resource should
22
- * map their response to this interface, in order to create the core
23
- * WordPress media blocks (image, video, audio).
24
- *
25
- * @typedef {Object} InserterMediaItem
26
- * @property {string} title The title of the media item.
27
- * @property {string} url The source url of the media item.
28
- * @property {string} [previewUrl] The preview source url of the media item to display in the media list.
29
- * @property {number} [id] The WordPress id of the media item.
30
- * @property {number|string} [sourceId] The id of the media item from external source.
31
- * @property {string} [alt] The alt text of the media item.
32
- * @property {string} [caption] The caption of the media item.
33
- */
12
+ /** @typedef {import('./api').InserterMediaRequest} InserterMediaRequest */
13
+ /** @typedef {import('./api').InserterMediaItem} InserterMediaItem */
34
14
 
35
15
  /**
36
16
  * Fetches media items based on the provided category.