@wordpress/edit-post 6.14.1 → 6.15.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.
@@ -1,7 +1,13 @@
1
1
  /**
2
2
  * External dependencies
3
3
  */
4
- import { shallow } from 'enzyme';
4
+ import { render, screen } from '@testing-library/react';
5
+
6
+ /**
7
+ * WordPress dependencies
8
+ */
9
+ import { EditorKeyboardShortcutsRegister } from '@wordpress/editor';
10
+ import { ShortcutProvider } from '@wordpress/keyboard-shortcuts';
5
11
 
6
12
  /**
7
13
  * Internal dependencies
@@ -12,24 +18,35 @@ const noop = () => {};
12
18
 
13
19
  describe( 'KeyboardShortcutHelpModal', () => {
14
20
  it( 'should match snapshot when the modal is active', () => {
15
- const wrapper = shallow(
16
- <KeyboardShortcutHelpModal
17
- isModalActive={ true }
18
- toggleModal={ noop }
19
- />
21
+ render(
22
+ <ShortcutProvider>
23
+ <EditorKeyboardShortcutsRegister />
24
+ <KeyboardShortcutHelpModal isModalActive toggleModal={ noop } />
25
+ </ShortcutProvider>
20
26
  );
21
27
 
22
- expect( wrapper ).toMatchSnapshot();
28
+ expect(
29
+ screen.getByRole( 'dialog', {
30
+ name: 'Keyboard shortcuts',
31
+ } )
32
+ ).toMatchSnapshot();
23
33
  } );
24
34
 
25
- it( 'should match snapshot when the modal is not active', () => {
26
- const wrapper = shallow(
27
- <KeyboardShortcutHelpModal
28
- isModalActive={ false }
29
- toggleModal={ noop }
30
- />
35
+ it( 'should not render the modal when inactive', () => {
36
+ render(
37
+ <ShortcutProvider>
38
+ <EditorKeyboardShortcutsRegister />
39
+ <KeyboardShortcutHelpModal
40
+ isModalActive={ false }
41
+ toggleModal={ noop }
42
+ />
43
+ </ShortcutProvider>
31
44
  );
32
45
 
33
- expect( wrapper ).toMatchSnapshot();
46
+ expect(
47
+ screen.queryByRole( 'dialog', {
48
+ name: 'Keyboard shortcuts',
49
+ } )
50
+ ).not.toBeInTheDocument();
34
51
  } );
35
52
  } );
@@ -118,15 +118,23 @@ export default function VisualEditor( { styles } ) {
118
118
  ( select ) => select( editPostStore ).hasMetaBoxes(),
119
119
  []
120
120
  );
121
- const { themeHasDisabledLayoutStyles, themeSupportsLayout, assets } =
122
- useSelect( ( select ) => {
123
- const _settings = select( blockEditorStore ).getSettings();
124
- return {
125
- themeHasDisabledLayoutStyles: _settings.disableLayoutStyles,
126
- themeSupportsLayout: _settings.supportsLayout,
127
- assets: _settings.__unstableResolvedAssets,
128
- };
129
- }, [] );
121
+ const {
122
+ themeHasDisabledLayoutStyles,
123
+ themeSupportsLayout,
124
+ assets,
125
+ useRootPaddingAwareAlignments,
126
+ isFocusMode,
127
+ } = useSelect( ( select ) => {
128
+ const _settings = select( blockEditorStore ).getSettings();
129
+ return {
130
+ themeHasDisabledLayoutStyles: _settings.disableLayoutStyles,
131
+ themeSupportsLayout: _settings.supportsLayout,
132
+ assets: _settings.__unstableResolvedAssets,
133
+ useRootPaddingAwareAlignments:
134
+ _settings.__experimentalFeatures?.useRootPaddingAwareAlignments,
135
+ isFocusMode: _settings.focusMode,
136
+ };
137
+ }, [] );
130
138
  const { clearSelectedBlock } = useDispatch( blockEditorStore );
131
139
  const { setIsEditingTemplate } = useDispatch( editPostStore );
132
140
  const desktopCanvasStyles = {
@@ -189,9 +197,11 @@ export default function VisualEditor( { styles } ) {
189
197
  return { type: 'default' };
190
198
  }, [ isTemplateMode, themeSupportsLayout, defaultLayout ] );
191
199
 
192
- const blockListLayoutClass = themeSupportsLayout
193
- ? 'is-layout-constrained'
194
- : 'is-layout-flow';
200
+ const blockListLayoutClass = classnames( {
201
+ 'is-layout-constrained': themeSupportsLayout,
202
+ 'is-layout-flow': ! themeSupportsLayout,
203
+ 'has-global-padding': useRootPaddingAwareAlignments,
204
+ } );
195
205
 
196
206
  const titleRef = useRef();
197
207
  useEffect( () => {
@@ -257,7 +267,12 @@ export default function VisualEditor( { styles } ) {
257
267
  ) }
258
268
  { ! isTemplateMode && (
259
269
  <div
260
- className="edit-post-visual-editor__post-title-wrapper"
270
+ className={ classnames(
271
+ 'edit-post-visual-editor__post-title-wrapper',
272
+ {
273
+ 'is-focus-mode': isFocusMode,
274
+ }
275
+ ) }
261
276
  contentEditable={ false }
262
277
  >
263
278
  <PostTitle ref={ titleRef } />