@wordpress/editor 13.26.1-next.79a6196f.0 → 13.27.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 (132) hide show
  1. package/CHANGELOG.md +3 -1
  2. package/build/bindings/index.js +20 -0
  3. package/build/bindings/index.js.map +1 -0
  4. package/build/bindings/post-meta.js +52 -0
  5. package/build/bindings/post-meta.js.map +1 -0
  6. package/build/components/block-manager/category.js +106 -0
  7. package/build/components/block-manager/category.js.map +1 -0
  8. package/build/components/block-manager/checklist.js +35 -0
  9. package/build/components/block-manager/checklist.js.map +1 -0
  10. package/build/components/block-manager/index.js +130 -0
  11. package/build/components/block-manager/index.js.map +1 -0
  12. package/build/components/document-tools/index.js +58 -52
  13. package/build/components/document-tools/index.js.map +1 -1
  14. package/build/components/editor-canvas/index.js +4 -4
  15. package/build/components/editor-canvas/index.js.map +1 -1
  16. package/build/components/editor-notices/index.js +11 -11
  17. package/build/components/editor-notices/index.js.map +1 -1
  18. package/build/components/entities-saved-states/entity-type-list.js +38 -7
  19. package/build/components/entities-saved-states/entity-type-list.js.map +1 -1
  20. package/build/components/offline-status/index.native.js +1 -3
  21. package/build/components/offline-status/index.native.js.map +1 -1
  22. package/build/components/post-locked-modal/index.js +1 -1
  23. package/build/components/post-locked-modal/index.js.map +1 -1
  24. package/build/components/post-saved-state/index.js +10 -24
  25. package/build/components/post-saved-state/index.js.map +1 -1
  26. package/build/components/post-schedule/check.js +5 -16
  27. package/build/components/post-schedule/check.js.map +1 -1
  28. package/build/components/preferences-modal/enable-panel.js +42 -0
  29. package/build/components/preferences-modal/enable-panel.js.map +1 -0
  30. package/build/components/preferences-modal/enable-plugin-document-setting-panel.js +33 -0
  31. package/build/components/preferences-modal/enable-plugin-document-setting-panel.js.map +1 -0
  32. package/build/components/preferences-modal/index.js +186 -0
  33. package/build/components/preferences-modal/index.js.map +1 -0
  34. package/build/components/provider/disable-non-page-content-blocks.js +1 -4
  35. package/build/components/provider/disable-non-page-content-blocks.js.map +1 -1
  36. package/build/components/provider/use-block-editor-settings.js +34 -8
  37. package/build/components/provider/use-block-editor-settings.js.map +1 -1
  38. package/build/hooks/pattern-partial-syncing.js +12 -6
  39. package/build/hooks/pattern-partial-syncing.js.map +1 -1
  40. package/build/index.js +1 -0
  41. package/build/index.js.map +1 -1
  42. package/build/private-apis.js +6 -2
  43. package/build/private-apis.js.map +1 -1
  44. package/build/store/defaults.js +2 -0
  45. package/build/store/defaults.js.map +1 -1
  46. package/build/store/private-actions.js +33 -1
  47. package/build/store/private-actions.js.map +1 -1
  48. package/build/store/private-selectors.js +1 -1
  49. package/build/store/private-selectors.js.map +1 -1
  50. package/build-module/bindings/index.js +15 -0
  51. package/build-module/bindings/index.js.map +1 -0
  52. package/build-module/bindings/post-meta.js +45 -0
  53. package/build-module/bindings/post-meta.js.map +1 -0
  54. package/build-module/components/block-manager/category.js +97 -0
  55. package/build-module/components/block-manager/category.js.map +1 -0
  56. package/build-module/components/block-manager/checklist.js +27 -0
  57. package/build-module/components/block-manager/checklist.js.map +1 -0
  58. package/build-module/components/block-manager/index.js +121 -0
  59. package/build-module/components/block-manager/index.js.map +1 -0
  60. package/build-module/components/document-tools/index.js +58 -52
  61. package/build-module/components/document-tools/index.js.map +1 -1
  62. package/build-module/components/editor-canvas/index.js +4 -4
  63. package/build-module/components/editor-canvas/index.js.map +1 -1
  64. package/build-module/components/editor-notices/index.js +12 -12
  65. package/build-module/components/editor-notices/index.js.map +1 -1
  66. package/build-module/components/entities-saved-states/entity-type-list.js +39 -8
  67. package/build-module/components/entities-saved-states/entity-type-list.js.map +1 -1
  68. package/build-module/components/offline-status/index.native.js +1 -3
  69. package/build-module/components/offline-status/index.native.js.map +1 -1
  70. package/build-module/components/post-locked-modal/index.js +1 -1
  71. package/build-module/components/post-locked-modal/index.js.map +1 -1
  72. package/build-module/components/post-saved-state/index.js +11 -25
  73. package/build-module/components/post-saved-state/index.js.map +1 -1
  74. package/build-module/components/post-schedule/check.js +6 -15
  75. package/build-module/components/post-schedule/check.js.map +1 -1
  76. package/build-module/components/preferences-modal/enable-panel.js +34 -0
  77. package/build-module/components/preferences-modal/enable-panel.js.map +1 -0
  78. package/build-module/components/preferences-modal/enable-plugin-document-setting-panel.js +24 -0
  79. package/build-module/components/preferences-modal/enable-plugin-document-setting-panel.js.map +1 -0
  80. package/build-module/components/preferences-modal/index.js +179 -0
  81. package/build-module/components/preferences-modal/index.js.map +1 -0
  82. package/build-module/components/provider/disable-non-page-content-blocks.js +1 -4
  83. package/build-module/components/provider/disable-non-page-content-blocks.js.map +1 -1
  84. package/build-module/components/provider/use-block-editor-settings.js +35 -9
  85. package/build-module/components/provider/use-block-editor-settings.js.map +1 -1
  86. package/build-module/hooks/pattern-partial-syncing.js +12 -6
  87. package/build-module/hooks/pattern-partial-syncing.js.map +1 -1
  88. package/build-module/index.js +1 -0
  89. package/build-module/index.js.map +1 -1
  90. package/build-module/private-apis.js +6 -2
  91. package/build-module/private-apis.js.map +1 -1
  92. package/build-module/store/defaults.js +2 -0
  93. package/build-module/store/defaults.js.map +1 -1
  94. package/build-module/store/private-actions.js +29 -0
  95. package/build-module/store/private-actions.js.map +1 -1
  96. package/build-module/store/private-selectors.js +1 -1
  97. package/build-module/store/private-selectors.js.map +1 -1
  98. package/build-style/style-rtl.css +80 -12
  99. package/build-style/style.css +80 -12
  100. package/package.json +33 -33
  101. package/src/bindings/index.js +13 -0
  102. package/src/bindings/post-meta.js +42 -0
  103. package/src/components/block-manager/category.js +96 -0
  104. package/src/components/block-manager/checklist.js +30 -0
  105. package/src/components/block-manager/index.js +160 -0
  106. package/src/components/block-manager/style.scss +82 -0
  107. package/src/components/document-tools/index.js +9 -1
  108. package/src/components/editor-canvas/index.js +3 -2
  109. package/src/components/editor-notices/index.js +11 -12
  110. package/src/components/editor-notices/style.scss +0 -1
  111. package/src/components/entities-saved-states/entity-type-list.js +47 -5
  112. package/src/components/entities-saved-states/style.scss +4 -0
  113. package/src/components/offline-status/index.native.js +2 -4
  114. package/src/components/post-locked-modal/index.js +1 -1
  115. package/src/components/post-locked-modal/style.scss +0 -6
  116. package/src/components/post-saved-state/index.js +30 -47
  117. package/src/components/post-schedule/check.js +10 -14
  118. package/src/components/post-schedule/test/check.js +24 -9
  119. package/src/components/preferences-modal/enable-panel.js +30 -0
  120. package/src/components/preferences-modal/enable-plugin-document-setting-panel.js +23 -0
  121. package/src/components/preferences-modal/index.js +269 -0
  122. package/src/components/preferences-modal/test/index.js +28 -0
  123. package/src/components/provider/disable-non-page-content-blocks.js +3 -3
  124. package/src/components/provider/use-block-editor-settings.js +45 -17
  125. package/src/hooks/pattern-partial-syncing.js +26 -22
  126. package/src/index.js +1 -0
  127. package/src/private-apis.js +6 -2
  128. package/src/store/defaults.js +2 -0
  129. package/src/store/private-actions.js +49 -0
  130. package/src/store/private-selectors.js +1 -1
  131. package/src/style.scss +1 -1
  132. package/src/components/editor-canvas/style.scss +0 -5
@@ -2,8 +2,7 @@
2
2
  * WordPress dependencies
3
3
  */
4
4
  import { NoticeList } from '@wordpress/components';
5
- import { withSelect, withDispatch } from '@wordpress/data';
6
- import { compose } from '@wordpress/compose';
5
+ import { useDispatch, useSelect } from '@wordpress/data';
7
6
  import { store as noticesStore } from '@wordpress/notices';
8
7
 
9
8
  /**
@@ -11,7 +10,14 @@ import { store as noticesStore } from '@wordpress/notices';
11
10
  */
12
11
  import TemplateValidationNotice from '../template-validation-notice';
13
12
 
14
- export function EditorNotices( { notices, onRemove } ) {
13
+ export function EditorNotices() {
14
+ const { notices } = useSelect(
15
+ ( select ) => ( {
16
+ notices: select( noticesStore ).getNotices(),
17
+ } ),
18
+ []
19
+ );
20
+ const { removeNotice } = useDispatch( noticesStore );
15
21
  const dismissibleNotices = notices.filter(
16
22
  ( { isDismissible, type } ) => isDismissible && type === 'default'
17
23
  );
@@ -28,7 +34,7 @@ export function EditorNotices( { notices, onRemove } ) {
28
34
  <NoticeList
29
35
  notices={ dismissibleNotices }
30
36
  className="components-editor-notices__dismissible"
31
- onRemove={ onRemove }
37
+ onRemove={ removeNotice }
32
38
  >
33
39
  <TemplateValidationNotice />
34
40
  </NoticeList>
@@ -36,11 +42,4 @@ export function EditorNotices( { notices, onRemove } ) {
36
42
  );
37
43
  }
38
44
 
39
- export default compose( [
40
- withSelect( ( select ) => ( {
41
- notices: select( noticesStore ).getNotices(),
42
- } ) ),
43
- withDispatch( ( dispatch ) => ( {
44
- onRemove: dispatch( noticesStore ).removeNotice,
45
- } ) ),
46
- ] )( EditorNotices );
45
+ export default EditorNotices;
@@ -9,7 +9,6 @@
9
9
 
10
10
  .components-notice {
11
11
  box-sizing: border-box;
12
- margin: 0;
13
12
  border-bottom: $border-width solid rgba(0, 0, 0, 0.2);
14
13
  padding: 0 $grid-unit-15;
15
14
 
@@ -5,11 +5,18 @@ import { __ } from '@wordpress/i18n';
5
5
  import { useSelect } from '@wordpress/data';
6
6
  import { PanelBody, PanelRow } from '@wordpress/components';
7
7
  import { store as coreStore } from '@wordpress/core-data';
8
+ import { privateApis as blockEditorPrivateApis } from '@wordpress/block-editor';
9
+ import { useContext } from '@wordpress/element';
8
10
 
9
11
  /**
10
12
  * Internal dependencies
11
13
  */
12
14
  import EntityRecordItem from './entity-record-item';
15
+ import { unlock } from '../../lock-unlock';
16
+
17
+ const { getGlobalStylesChanges, GlobalStylesContext } = unlock(
18
+ blockEditorPrivateApis
19
+ );
13
20
 
14
21
  function getEntityDescription( entity, count ) {
15
22
  switch ( entity ) {
@@ -27,6 +34,44 @@ function getEntityDescription( entity, count ) {
27
34
  }
28
35
  }
29
36
 
37
+ function GlobalStylesDescription( { record } ) {
38
+ const { user: currentEditorGlobalStyles } =
39
+ useContext( GlobalStylesContext );
40
+ const savedRecord = useSelect(
41
+ ( select ) =>
42
+ select( coreStore ).getEntityRecord(
43
+ record.kind,
44
+ record.name,
45
+ record.key
46
+ ),
47
+ [ record.kind, record.name, record.key ]
48
+ );
49
+
50
+ const globalStylesChanges = getGlobalStylesChanges(
51
+ currentEditorGlobalStyles,
52
+ savedRecord,
53
+ {
54
+ maxResults: 10,
55
+ }
56
+ );
57
+ return globalStylesChanges.length ? (
58
+ <>
59
+ <h3 className="entities-saved-states__description-heading">
60
+ { __( 'Changes made to:' ) }
61
+ </h3>
62
+ <PanelRow>{ globalStylesChanges.join( ', ' ) }</PanelRow>
63
+ </>
64
+ ) : null;
65
+ }
66
+
67
+ function EntityDescription( { record, count } ) {
68
+ if ( 'globalStyles' === record?.name ) {
69
+ return <GlobalStylesDescription record={ record } />;
70
+ }
71
+ const description = getEntityDescription( record?.name, count );
72
+ return description ? <PanelRow>{ description }</PanelRow> : null;
73
+ }
74
+
30
75
  export default function EntityTypeList( {
31
76
  list,
32
77
  unselectedEntities,
@@ -42,19 +87,16 @@ export default function EntityTypeList( {
42
87
  ),
43
88
  [ firstRecord.kind, firstRecord.name ]
44
89
  );
45
- const { name } = firstRecord;
46
90
 
47
91
  let entityLabel = entityConfig.label;
48
- if ( name === 'wp_template_part' ) {
92
+ if ( firstRecord?.name === 'wp_template_part' ) {
49
93
  entityLabel =
50
94
  1 === count ? __( 'Template Part' ) : __( 'Template Parts' );
51
95
  }
52
- // Set description based on type of entity.
53
- const description = getEntityDescription( name, count );
54
96
 
55
97
  return (
56
98
  <PanelBody title={ entityLabel } initialOpen={ true }>
57
- { description && <PanelRow>{ description }</PanelRow> }
99
+ <EntityDescription record={ firstRecord } count={ count } />
58
100
  { list.map( ( record ) => {
59
101
  return (
60
102
  <EntityRecordItem
@@ -15,3 +15,7 @@
15
15
  margin-bottom: $grid-unit-15;
16
16
  }
17
17
  }
18
+
19
+ .entities-saved-states__description-heading {
20
+ font-size: $default-font-size;
21
+ }
@@ -90,10 +90,8 @@ const OfflineStatus = () => {
90
90
  ) }
91
91
  style={ containerStyle }
92
92
  >
93
- <View style={ containerStyle }>
94
- <Icon fill={ iconStyle.fill } icon={ offlineIcon } />
95
- <Text style={ textStyle }>{ __( 'Working Offline' ) }</Text>
96
- </View>
93
+ <Icon fill={ iconStyle.fill } icon={ offlineIcon } />
94
+ <Text style={ textStyle }>{ __( 'Working Offline' ) } </Text>
97
95
  </View>
98
96
  ) : null;
99
97
  };
@@ -172,7 +172,7 @@ export default function PostLockedModal() {
172
172
  shouldCloseOnClickOutside={ false }
173
173
  shouldCloseOnEsc={ false }
174
174
  isDismissible={ false }
175
- className="editor-post-locked-modal"
175
+ size="medium"
176
176
  >
177
177
  <HStack alignment="top" spacing={ 6 }>
178
178
  { !! userAvatar && (
@@ -1,9 +1,3 @@
1
- .editor-post-locked-modal {
2
- @include break-small() {
3
- max-width: $break-mobile;
4
- }
5
- }
6
-
7
1
  .editor-post-locked-modal__buttons {
8
2
  margin-top: $grid-unit-30;
9
3
  }
@@ -9,7 +9,6 @@ import classnames from 'classnames';
9
9
  import {
10
10
  __unstableGetAnimateClassName as getAnimateClassName,
11
11
  Button,
12
- Tooltip,
13
12
  } from '@wordpress/components';
14
13
  import { usePrevious, useViewportMatch } from '@wordpress/compose';
15
14
  import { useDispatch, useSelect } from '@wordpress/data';
@@ -129,54 +128,38 @@ export default function PostSavedState( { forceIsDirty } ) {
129
128
  text = shortLabel;
130
129
  }
131
130
 
132
- const buttonAccessibleLabel = text || label;
133
-
134
- /**
135
- * The tooltip needs to be enabled only if the button is not disabled. When
136
- * relying on the internal Button tooltip functionality, this causes the
137
- * resulting `button` element to be always removed and re-added to the DOM,
138
- * causing focus loss. An alternative approach to circumvent the issue
139
- * is not to use the `label` and `shortcut` props on `Button` (which would
140
- * trigger the tooltip), and instead manually wrap the `Button` in a separate
141
- * `Tooltip` component.
142
- */
143
- const tooltipProps = isDisabled
144
- ? undefined
145
- : {
146
- text: buttonAccessibleLabel,
147
- shortcut: displayShortcut.primary( 's' ),
148
- };
149
-
150
131
  // Use common Button instance for all saved states so that focus is not
151
132
  // lost.
152
133
  return (
153
- <Tooltip { ...tooltipProps }>
154
- <Button
155
- className={
156
- isSaveable || isSaving
157
- ? classnames( {
158
- 'editor-post-save-draft': ! isSavedState,
159
- 'editor-post-saved-state': isSavedState,
160
- 'is-saving': isSaving,
161
- 'is-autosaving': isAutosaving,
162
- 'is-saved': isSaved,
163
- [ getAnimateClassName( {
164
- type: 'loading',
165
- } ) ]: isSaving,
166
- } )
167
- : undefined
168
- }
169
- onClick={ isDisabled ? undefined : () => savePost() }
170
- variant="tertiary"
171
- size="compact"
172
- icon={ isLargeViewport ? undefined : cloudUpload }
173
- // Make sure the aria-label has always a value, as the default `text` is undefined on small screens.
174
- aria-label={ buttonAccessibleLabel }
175
- aria-disabled={ isDisabled }
176
- >
177
- { isSavedState && <Icon icon={ isSaved ? check : cloud } /> }
178
- { text }
179
- </Button>
180
- </Tooltip>
134
+ <Button
135
+ className={
136
+ isSaveable || isSaving
137
+ ? classnames( {
138
+ 'editor-post-save-draft': ! isSavedState,
139
+ 'editor-post-saved-state': isSavedState,
140
+ 'is-saving': isSaving,
141
+ 'is-autosaving': isAutosaving,
142
+ 'is-saved': isSaved,
143
+ [ getAnimateClassName( {
144
+ type: 'loading',
145
+ } ) ]: isSaving,
146
+ } )
147
+ : undefined
148
+ }
149
+ onClick={ isDisabled ? undefined : () => savePost() }
150
+ /*
151
+ * We want the tooltip to show the keyboard shortcut only when the
152
+ * button does something, i.e. when it's not disabled.
153
+ */
154
+ shortcut={ isDisabled ? undefined : displayShortcut.primary( 's' ) }
155
+ variant="tertiary"
156
+ size="compact"
157
+ icon={ isLargeViewport ? undefined : cloudUpload }
158
+ label={ text || label }
159
+ aria-disabled={ isDisabled }
160
+ >
161
+ { isSavedState && <Icon icon={ isSaved ? check : cloud } /> }
162
+ { text }
163
+ </Button>
181
164
  );
182
165
  }
@@ -1,29 +1,25 @@
1
1
  /**
2
2
  * WordPress dependencies
3
3
  */
4
- import { compose } from '@wordpress/compose';
5
- import { withSelect } from '@wordpress/data';
4
+ import { useSelect } from '@wordpress/data';
6
5
 
7
6
  /**
8
7
  * Internal dependencies
9
8
  */
10
9
  import { store as editorStore } from '../../store';
11
10
 
12
- export function PostScheduleCheck( { hasPublishAction, children } ) {
11
+ export default function PostScheduleCheck( { children } ) {
12
+ const hasPublishAction = useSelect( ( select ) => {
13
+ return (
14
+ select( editorStore ).getCurrentPost()._links?.[
15
+ 'wp:action-publish'
16
+ ] ?? false
17
+ );
18
+ }, [] );
19
+
13
20
  if ( ! hasPublishAction ) {
14
21
  return null;
15
22
  }
16
23
 
17
24
  return children;
18
25
  }
19
-
20
- export default compose( [
21
- withSelect( ( select ) => {
22
- const { getCurrentPost, getCurrentPostType } = select( editorStore );
23
- return {
24
- hasPublishAction:
25
- getCurrentPost()._links?.[ 'wp:action-publish' ] ?? false,
26
- postType: getCurrentPostType(),
27
- };
28
- } ),
29
- ] )( PostScheduleCheck );
@@ -3,25 +3,40 @@
3
3
  */
4
4
  import { render, screen } from '@testing-library/react';
5
5
 
6
+ /**
7
+ * WordPress dependencies
8
+ */
9
+ import { useSelect } from '@wordpress/data';
10
+
6
11
  /**
7
12
  * Internal dependencies
8
13
  */
9
- import { PostScheduleCheck } from '../check';
14
+ import PostScheduleCheck from '../check';
15
+
16
+ jest.mock( '@wordpress/data/src/components/use-select', () => jest.fn() );
17
+
18
+ function setupMockSelect( hasPublishAction ) {
19
+ useSelect.mockImplementation( ( mapSelect ) => {
20
+ return mapSelect( () => ( {
21
+ getCurrentPost: () => ( {
22
+ _links: {
23
+ 'wp:action-publish': hasPublishAction,
24
+ },
25
+ } ),
26
+ } ) );
27
+ } );
28
+ }
10
29
 
11
30
  describe( 'PostScheduleCheck', () => {
12
31
  it( "should not render anything if the user doesn't have the right capabilities", () => {
13
- render(
14
- <PostScheduleCheck hasPublishAction={ false }>
15
- yes
16
- </PostScheduleCheck>
17
- );
32
+ setupMockSelect( false );
33
+ render( <PostScheduleCheck>yes</PostScheduleCheck> );
18
34
  expect( screen.queryByText( 'yes' ) ).not.toBeInTheDocument();
19
35
  } );
20
36
 
21
37
  it( 'should render if the user has the correct capability', () => {
22
- render(
23
- <PostScheduleCheck hasPublishAction={ true }>yes</PostScheduleCheck>
24
- );
38
+ setupMockSelect( true );
39
+ render( <PostScheduleCheck>yes</PostScheduleCheck> );
25
40
  expect( screen.getByText( 'yes' ) ).toBeVisible();
26
41
  } );
27
42
  } );
@@ -0,0 +1,30 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import { compose, ifCondition } from '@wordpress/compose';
5
+ import { withSelect, withDispatch } from '@wordpress/data';
6
+ import { privateApis as preferencesPrivateApis } from '@wordpress/preferences';
7
+
8
+ /**
9
+ * Internal dependencies
10
+ */
11
+ import { unlock } from '../../lock-unlock';
12
+ import { store as editorStore } from '../../store';
13
+
14
+ const { PreferenceBaseOption } = unlock( preferencesPrivateApis );
15
+
16
+ export default compose(
17
+ withSelect( ( select, { panelName } ) => {
18
+ const { isEditorPanelEnabled, isEditorPanelRemoved } =
19
+ select( editorStore );
20
+ return {
21
+ isRemoved: isEditorPanelRemoved( panelName ),
22
+ isChecked: isEditorPanelEnabled( panelName ),
23
+ };
24
+ } ),
25
+ ifCondition( ( { isRemoved } ) => ! isRemoved ),
26
+ withDispatch( ( dispatch, { panelName } ) => ( {
27
+ onChange: () =>
28
+ dispatch( editorStore ).toggleEditorPanelEnabled( panelName ),
29
+ } ) )
30
+ )( PreferenceBaseOption );
@@ -0,0 +1,23 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import { createSlotFill } from '@wordpress/components';
5
+
6
+ /**
7
+ * Internal dependencies
8
+ */
9
+ import EnablePanelOption from './enable-panel';
10
+
11
+ const { Fill, Slot } = createSlotFill(
12
+ 'EnablePluginDocumentSettingPanelOption'
13
+ );
14
+
15
+ const EnablePluginDocumentSettingPanelOption = ( { label, panelName } ) => (
16
+ <Fill>
17
+ <EnablePanelOption label={ label } panelName={ panelName } />
18
+ </Fill>
19
+ );
20
+
21
+ EnablePluginDocumentSettingPanelOption.Slot = Slot;
22
+
23
+ export default EnablePluginDocumentSettingPanelOption;