@wordpress/edit-site 4.18.0 → 4.19.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 (85) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/build/components/add-new-template/add-custom-template-modal.js +3 -1
  3. package/build/components/add-new-template/add-custom-template-modal.js.map +1 -1
  4. package/build/components/block-editor/resizable-editor.js +9 -47
  5. package/build/components/block-editor/resizable-editor.js.map +1 -1
  6. package/build/components/global-styles/dimensions-panel.js +46 -2
  7. package/build/components/global-styles/dimensions-panel.js.map +1 -1
  8. package/build/components/global-styles/hooks.js +32 -0
  9. package/build/components/global-styles/hooks.js.map +1 -1
  10. package/build/components/global-styles/palette.js +8 -1
  11. package/build/components/global-styles/palette.js.map +1 -1
  12. package/build/components/global-styles/typography-panel.js +52 -16
  13. package/build/components/global-styles/typography-panel.js.map +1 -1
  14. package/build/components/global-styles/use-global-styles-output.js +43 -8
  15. package/build/components/global-styles/use-global-styles-output.js.map +1 -1
  16. package/build/components/header-edit-mode/document-actions/index.js +3 -1
  17. package/build/components/header-edit-mode/document-actions/index.js.map +1 -1
  18. package/build/components/header-edit-mode/index.js +14 -7
  19. package/build/components/header-edit-mode/index.js.map +1 -1
  20. package/build/components/keyboard-shortcuts/index.js +3 -0
  21. package/build/components/keyboard-shortcuts/index.js.map +1 -1
  22. package/build/components/list/table.js +1 -1
  23. package/build/components/list/table.js.map +1 -1
  24. package/build/components/list/use-register-shortcuts.js +3 -0
  25. package/build/components/list/use-register-shortcuts.js.map +1 -1
  26. package/build/components/save-button/index.js +20 -2
  27. package/build/components/save-button/index.js.map +1 -1
  28. package/build/components/sidebar-edit-mode/template-card/index.js +4 -2
  29. package/build/components/sidebar-edit-mode/template-card/index.js.map +1 -1
  30. package/build/components/template-details/index.js +4 -2
  31. package/build/components/template-details/index.js.map +1 -1
  32. package/build-module/components/add-new-template/add-custom-template-modal.js +2 -1
  33. package/build-module/components/add-new-template/add-custom-template-modal.js.map +1 -1
  34. package/build-module/components/block-editor/resizable-editor.js +11 -49
  35. package/build-module/components/block-editor/resizable-editor.js.map +1 -1
  36. package/build-module/components/global-styles/dimensions-panel.js +46 -2
  37. package/build-module/components/global-styles/dimensions-panel.js.map +1 -1
  38. package/build-module/components/global-styles/hooks.js +27 -1
  39. package/build-module/components/global-styles/hooks.js.map +1 -1
  40. package/build-module/components/global-styles/palette.js +9 -3
  41. package/build-module/components/global-styles/palette.js.map +1 -1
  42. package/build-module/components/global-styles/typography-panel.js +53 -16
  43. package/build-module/components/global-styles/typography-panel.js.map +1 -1
  44. package/build-module/components/global-styles/use-global-styles-output.js +44 -9
  45. package/build-module/components/global-styles/use-global-styles-output.js.map +1 -1
  46. package/build-module/components/header-edit-mode/document-actions/index.js +2 -1
  47. package/build-module/components/header-edit-mode/document-actions/index.js.map +1 -1
  48. package/build-module/components/header-edit-mode/index.js +13 -7
  49. package/build-module/components/header-edit-mode/index.js.map +1 -1
  50. package/build-module/components/keyboard-shortcuts/index.js +3 -0
  51. package/build-module/components/keyboard-shortcuts/index.js.map +1 -1
  52. package/build-module/components/list/table.js +1 -1
  53. package/build-module/components/list/table.js.map +1 -1
  54. package/build-module/components/list/use-register-shortcuts.js +3 -0
  55. package/build-module/components/list/use-register-shortcuts.js.map +1 -1
  56. package/build-module/components/save-button/index.js +21 -2
  57. package/build-module/components/save-button/index.js.map +1 -1
  58. package/build-module/components/sidebar-edit-mode/template-card/index.js +3 -2
  59. package/build-module/components/sidebar-edit-mode/template-card/index.js.map +1 -1
  60. package/build-module/components/template-details/index.js +3 -2
  61. package/build-module/components/template-details/index.js.map +1 -1
  62. package/build-style/style-rtl.css +15 -15
  63. package/build-style/style.css +15 -15
  64. package/package.json +30 -29
  65. package/src/components/add-new-template/add-custom-template-modal.js +5 -1
  66. package/src/components/block-editor/resizable-editor.js +10 -55
  67. package/src/components/editor/style.scss +1 -7
  68. package/src/components/global-styles/dimensions-panel.js +59 -1
  69. package/src/components/global-styles/hooks.js +36 -0
  70. package/src/components/global-styles/palette.js +15 -1
  71. package/src/components/global-styles/test/typography-utils.js +82 -98
  72. package/src/components/global-styles/test/use-global-styles-output.js +6 -6
  73. package/src/components/global-styles/typography-panel.js +57 -15
  74. package/src/components/global-styles/use-global-styles-output.js +47 -10
  75. package/src/components/header-edit-mode/document-actions/index.js +2 -1
  76. package/src/components/header-edit-mode/index.js +8 -4
  77. package/src/components/keyboard-shortcuts/index.js +4 -0
  78. package/src/components/list/table.js +1 -1
  79. package/src/components/list/use-register-shortcuts.js +4 -0
  80. package/src/components/navigation-sidebar/navigation-panel/style.scss +0 -7
  81. package/src/components/navigation-sidebar/navigation-toggle/test/index.js +20 -24
  82. package/src/components/save-button/index.js +17 -1
  83. package/src/components/sidebar-edit-mode/template-card/index.js +3 -2
  84. package/src/components/template-details/index.js +3 -2
  85. package/src/components/navigation-sidebar/navigation-toggle/test/__snapshots__/index.js.snap +0 -41
@@ -8,6 +8,7 @@ import classnames from 'classnames';
8
8
  */
9
9
  import { useCallback, useRef } from '@wordpress/element';
10
10
  import { useViewportMatch } from '@wordpress/compose';
11
+ import { store as coreStore } from '@wordpress/core-data';
11
12
  import {
12
13
  ToolSelector,
13
14
  __experimentalPreviewOptions as PreviewOptions,
@@ -50,8 +51,8 @@ export default function Header( { showIconLabels } ) {
50
51
  isListViewOpen,
51
52
  listViewShortcut,
52
53
  isVisualMode,
53
- settings,
54
54
  blockEditorMode,
55
+ homeUrl,
55
56
  } = useSelect( ( select ) => {
56
57
  const {
57
58
  __experimentalGetPreviewDeviceType,
@@ -59,13 +60,16 @@ export default function Header( { showIconLabels } ) {
59
60
  isInserterOpened,
60
61
  isListViewOpened,
61
62
  getEditorMode,
62
- getSettings,
63
63
  } = select( editSiteStore );
64
64
  const { getShortcutRepresentation } = select( keyboardShortcutsStore );
65
65
  const { __unstableGetEditorMode } = select( blockEditorStore );
66
66
 
67
67
  const postType = getEditedPostType();
68
68
 
69
+ const {
70
+ getUnstableBase, // Site index.
71
+ } = select( coreStore );
72
+
69
73
  return {
70
74
  deviceType: __experimentalGetPreviewDeviceType(),
71
75
  templateType: postType,
@@ -75,8 +79,8 @@ export default function Header( { showIconLabels } ) {
75
79
  'core/edit-site/toggle-list-view'
76
80
  ),
77
81
  isVisualMode: getEditorMode() === 'visual',
78
- settings: getSettings(),
79
82
  blockEditorMode: __unstableGetEditorMode(),
83
+ homeUrl: getUnstableBase()?.home,
80
84
  };
81
85
  }, [] );
82
86
 
@@ -218,7 +222,7 @@ export default function Header( { showIconLabels } ) {
218
222
  >
219
223
  <MenuGroup>
220
224
  <MenuItem
221
- href={ settings?.siteUrl }
225
+ href={ homeUrl }
222
226
  target="_blank"
223
227
  icon={ external }
224
228
  >
@@ -180,6 +180,10 @@ function KeyboardShortcutsRegister() {
180
180
  modifier: 'access',
181
181
  character: 'p',
182
182
  },
183
+ {
184
+ modifier: 'ctrlShift',
185
+ character: '~',
186
+ },
183
187
  ],
184
188
  } );
185
189
  registerShortcut( {
@@ -94,7 +94,7 @@ export default function Table( { templateType } ) {
94
94
  ) }
95
95
  </Link>
96
96
  </Heading>
97
- { template.description }
97
+ { decodeEntities( template.description ) }
98
98
  </td>
99
99
 
100
100
  <td className="edit-site-list-table-column" role="cell">
@@ -39,6 +39,10 @@ export default function useRegisterShortcuts() {
39
39
  modifier: 'access',
40
40
  character: 'p',
41
41
  },
42
+ {
43
+ modifier: 'ctrlShift',
44
+ character: '~',
45
+ },
42
46
  ],
43
47
  } );
44
48
  }, [] );
@@ -7,13 +7,6 @@
7
7
  color: $white;
8
8
  transition: width 100ms linear;
9
9
  @include reduce-motion("transition");
10
-
11
- // Footer is visible from medium so we subtract footer's height
12
- .interface-interface-skeleton.has-footer & {
13
- @include break-medium() {
14
- height: calc(100% - #{$button-size-small + $border-width});
15
- }
16
- }
17
10
  }
18
11
 
19
12
  .edit-site-navigation-panel__inner {
@@ -15,55 +15,51 @@ import NavigationToggle from '..';
15
15
 
16
16
  jest.mock( '@wordpress/data/src/components/use-select', () => {
17
17
  // This allows us to tweak the returned value on each test.
18
- const mock = jest.fn();
19
- return mock;
18
+ return jest.fn();
20
19
  } );
21
- jest.mock( '@wordpress/data/src/components/use-dispatch', () => ( {
22
- useDispatch: () => ( { setNavigationPanelActiveMenu: jest.fn() } ),
23
- } ) );
24
-
25
- jest.mock( '@wordpress/core-data' );
26
20
 
27
21
  describe( 'NavigationToggle', () => {
28
22
  describe( 'when in full screen mode', () => {
29
23
  it( 'should display a user uploaded site icon if it exists', () => {
30
- useSelect.mockImplementation( ( cb ) => {
31
- return cb( () => ( {
32
- getCurrentTemplateNavigationPanelSubMenu: () => 'root',
24
+ useSelect.mockImplementation( ( cb ) =>
25
+ cb( () => ( {
33
26
  getEntityRecord: () => ( {
34
27
  site_icon_url: 'https://fakeUrl.com',
35
28
  } ),
36
29
  isResolving: () => false,
37
30
  isNavigationOpened: () => false,
38
- } ) );
39
- } );
31
+ } ) )
32
+ );
40
33
 
41
- render( <NavigationToggle /> );
34
+ const { unmount } = render( <NavigationToggle /> );
42
35
 
43
36
  const siteIcon = screen.getByAltText( 'Site Icon' );
44
-
45
37
  expect( siteIcon ).toBeVisible();
38
+
39
+ // Unmount the UI synchronously so that any async effects, like the on-mount focus
40
+ // that shows and positions a tooltip, are cancelled right away and never run.
41
+ unmount();
46
42
  } );
47
43
 
48
44
  it( 'should display a default site icon if no user uploaded site icon exists', () => {
49
- useSelect.mockImplementation( ( cb ) => {
50
- return cb( () => ( {
51
- getCurrentTemplateNavigationPanelSubMenu: () => 'root',
45
+ useSelect.mockImplementation( ( cb ) =>
46
+ cb( () => ( {
52
47
  getEntityRecord: () => ( {
53
48
  site_icon_url: '',
54
49
  } ),
55
50
  isResolving: () => false,
56
51
  isNavigationOpened: () => false,
57
- } ) );
58
- } );
52
+ } ) )
53
+ );
59
54
 
60
- const { container } = render( <NavigationToggle /> );
55
+ const { unmount } = render( <NavigationToggle /> );
61
56
 
62
- expect(
63
- screen.queryByAltText( 'Site Icon' )
64
- ).not.toBeInTheDocument();
57
+ const siteIcon = screen.queryByAltText( 'Site Icon' );
58
+ expect( siteIcon ).not.toBeInTheDocument();
65
59
 
66
- expect( container ).toMatchSnapshot();
60
+ // Unmount the UI synchronously so that any async effects, like the on-mount focus
61
+ // that shows and positions a tooltip, are cancelled right away and never run.
62
+ unmount();
67
63
  } );
68
64
  } );
69
65
  } );
@@ -5,6 +5,7 @@ import { useSelect, useDispatch } from '@wordpress/data';
5
5
  import { Button } from '@wordpress/components';
6
6
  import { __ } from '@wordpress/i18n';
7
7
  import { store as coreStore } from '@wordpress/core-data';
8
+ import { displayShortcut } from '@wordpress/keycodes';
8
9
 
9
10
  /**
10
11
  * Internal dependencies
@@ -29,6 +30,8 @@ export default function SaveButton() {
29
30
 
30
31
  const disabled = ! isDirty || isSaving;
31
32
 
33
+ const label = __( 'Save' );
34
+
32
35
  return (
33
36
  <Button
34
37
  variant="primary"
@@ -37,8 +40,21 @@ export default function SaveButton() {
37
40
  aria-expanded={ isSaveViewOpen }
38
41
  isBusy={ isSaving }
39
42
  onClick={ disabled ? undefined : () => setIsSaveViewOpened( true ) }
43
+ label={ label }
44
+ /*
45
+ * We want the tooltip to show the keyboard shortcut only when the
46
+ * button does something, i.e. when it's not disabled.
47
+ */
48
+ shortcut={ disabled ? undefined : displayShortcut.primary( 's' ) }
49
+ /*
50
+ * Displaying the keyboard shortcut conditionally makes the tooltip
51
+ * itself show conditionally. This would trigger a full-rerendering
52
+ * of the button that we want to avoid. By setting `showTooltip`,
53
+ & the tooltip is always rendered even when there's no keyboard shortcut.
54
+ */
55
+ showTooltip
40
56
  >
41
- { __( 'Save' ) }
57
+ { label }
42
58
  </Button>
43
59
  );
44
60
  }
@@ -5,6 +5,7 @@ import { useSelect } from '@wordpress/data';
5
5
  import { Icon } from '@wordpress/components';
6
6
  import { store as editorStore } from '@wordpress/editor';
7
7
  import { store as coreStore } from '@wordpress/core-data';
8
+ import { decodeEntities } from '@wordpress/html-entities';
8
9
 
9
10
  /**
10
11
  * Internal dependencies
@@ -42,12 +43,12 @@ export default function TemplateCard() {
42
43
  <div className="edit-site-template-card__content">
43
44
  <div className="edit-site-template-card__header">
44
45
  <h2 className="edit-site-template-card__title">
45
- { title }
46
+ { decodeEntities( title ) }
46
47
  </h2>
47
48
  <TemplateActions template={ template } />
48
49
  </div>
49
50
  <div className="edit-site-template-card__description">
50
- { description }
51
+ { decodeEntities( description ) }
51
52
  </div>
52
53
  <TemplateAreas />
53
54
  </div>
@@ -11,6 +11,7 @@ import {
11
11
  } from '@wordpress/components';
12
12
  import { useDispatch, useSelect } from '@wordpress/data';
13
13
  import { store as editorStore } from '@wordpress/editor';
14
+ import { decodeEntities } from '@wordpress/html-entities';
14
15
 
15
16
  /**
16
17
  * Internal dependencies
@@ -65,7 +66,7 @@ export default function TemplateDetails( { template, onClose } ) {
65
66
  className="edit-site-template-details__title"
66
67
  as="p"
67
68
  >
68
- { title }
69
+ { decodeEntities( title ) }
69
70
  </Text>
70
71
  ) }
71
72
 
@@ -75,7 +76,7 @@ export default function TemplateDetails( { template, onClose } ) {
75
76
  className="edit-site-template-details__description"
76
77
  as="p"
77
78
  >
78
- { description }
79
+ { decodeEntities( description ) }
79
80
  </Text>
80
81
  ) }
81
82
  </VStack>
@@ -1,41 +0,0 @@
1
- // Jest Snapshot v1, https://goo.gl/fbAQLP
2
-
3
- exports[`NavigationToggle when in full screen mode should display a default site icon if no user uploaded site icon exists 1`] = `
4
- <div>
5
- <div
6
- class="edit-site-navigation-toggle"
7
- >
8
- <button
9
- aria-label="Toggle navigation"
10
- aria-pressed="false"
11
- class="components-button edit-site-navigation-toggle__button"
12
- type="button"
13
- >
14
- <svg
15
- aria-hidden="true"
16
- focusable="false"
17
- height="36px"
18
- viewBox="-2 -2 24 24"
19
- width="36px"
20
- xmlns="http://www.w3.org/2000/svg"
21
- >
22
- <path
23
- d="M20 10c0-5.51-4.49-10-10-10C4.48 0 0 4.49 0 10c0 5.52 4.48 10 10 10 5.51 0 10-4.48 10-10zM7.78 15.37L4.37 6.22c.55-.02 1.17-.08 1.17-.08.5-.06.44-1.13-.06-1.11 0 0-1.45.11-2.37.11-.18 0-.37 0-.58-.01C4.12 2.69 6.87 1.11 10 1.11c2.33 0 4.45.87 6.05 2.34-.68-.11-1.65.39-1.65 1.58 0 .74.45 1.36.9 2.1.35.61.55 1.36.55 2.46 0 1.49-1.4 5-1.4 5l-3.03-8.37c.54-.02.82-.17.82-.17.5-.05.44-1.25-.06-1.22 0 0-1.44.12-2.38.12-.87 0-2.33-.12-2.33-.12-.5-.03-.56 1.2-.06 1.22l.92.08 1.26 3.41zM17.41 10c.24-.64.74-1.87.43-4.25.7 1.29 1.05 2.71 1.05 4.25 0 3.29-1.73 6.24-4.4 7.78.97-2.59 1.94-5.2 2.92-7.78zM6.1 18.09C3.12 16.65 1.11 13.53 1.11 10c0-1.3.23-2.48.72-3.59C3.25 10.3 4.67 14.2 6.1 18.09zm4.03-6.63l2.58 6.98c-.86.29-1.76.45-2.71.45-.79 0-1.57-.11-2.29-.33.81-2.38 1.62-4.74 2.42-7.1z"
24
- />
25
- </svg>
26
- <div
27
- aria-hidden="true"
28
- class="components-popover components-tooltip"
29
- style="position: absolute;"
30
- tabindex="-1"
31
- >
32
- <div
33
- class="components-popover__content"
34
- >
35
- Toggle navigation
36
- </div>
37
- </div>
38
- </button>
39
- </div>
40
- </div>
41
- `;