@wordpress/editor 14.0.3 → 14.0.4

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 (35) hide show
  1. package/build/bindings/pattern-overrides.js +8 -5
  2. package/build/bindings/pattern-overrides.js.map +1 -1
  3. package/build/components/editor/index.js +5 -0
  4. package/build/components/editor/index.js.map +1 -1
  5. package/build/components/editor-interface/index.js +2 -1
  6. package/build/components/editor-interface/index.js.map +1 -1
  7. package/build/components/post-actions/actions.js +1 -1
  8. package/build/components/post-actions/actions.js.map +1 -1
  9. package/build/components/save-publish-panels/index.js +30 -16
  10. package/build/components/save-publish-panels/index.js.map +1 -1
  11. package/build/hooks/pattern-overrides.js +2 -2
  12. package/build/hooks/pattern-overrides.js.map +1 -1
  13. package/build-module/bindings/pattern-overrides.js +8 -5
  14. package/build-module/bindings/pattern-overrides.js.map +1 -1
  15. package/build-module/components/editor/index.js +5 -0
  16. package/build-module/components/editor/index.js.map +1 -1
  17. package/build-module/components/editor-interface/index.js +2 -1
  18. package/build-module/components/editor-interface/index.js.map +1 -1
  19. package/build-module/components/post-actions/actions.js +1 -1
  20. package/build-module/components/post-actions/actions.js.map +1 -1
  21. package/build-module/components/save-publish-panels/index.js +30 -16
  22. package/build-module/components/save-publish-panels/index.js.map +1 -1
  23. package/build-module/hooks/pattern-overrides.js +3 -1
  24. package/build-module/hooks/pattern-overrides.js.map +1 -1
  25. package/build-style/style-rtl.css +12 -1
  26. package/build-style/style.css +12 -1
  27. package/package.json +6 -6
  28. package/src/bindings/pattern-overrides.js +9 -10
  29. package/src/components/editor/index.js +6 -0
  30. package/src/components/editor-interface/index.js +17 -12
  31. package/src/components/post-actions/actions.js +5 -1
  32. package/src/components/post-featured-image/style.scss +15 -0
  33. package/src/components/save-publish-panels/index.js +33 -23
  34. package/src/components/visual-editor/style.scss +1 -1
  35. package/src/hooks/pattern-overrides.js +4 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wordpress/editor",
3
- "version": "14.0.3",
3
+ "version": "14.0.4",
4
4
  "description": "Enhanced block editor for WordPress posts.",
5
5
  "author": "The WordPress Contributors",
6
6
  "license": "GPL-2.0-or-later",
@@ -35,12 +35,12 @@
35
35
  "@wordpress/a11y": "^4.0.1",
36
36
  "@wordpress/api-fetch": "^7.0.1",
37
37
  "@wordpress/blob": "^4.0.1",
38
- "@wordpress/block-editor": "^13.0.3",
38
+ "@wordpress/block-editor": "^13.0.4",
39
39
  "@wordpress/blocks": "^13.0.3",
40
40
  "@wordpress/commands": "^1.0.3",
41
41
  "@wordpress/components": "^28.0.3",
42
42
  "@wordpress/compose": "^7.0.1",
43
- "@wordpress/core-data": "^7.0.3",
43
+ "@wordpress/core-data": "^7.0.4",
44
44
  "@wordpress/data": "^10.0.2",
45
45
  "@wordpress/date": "^5.0.1",
46
46
  "@wordpress/deprecated": "^4.0.1",
@@ -55,11 +55,11 @@
55
55
  "@wordpress/keycodes": "^4.0.1",
56
56
  "@wordpress/media-utils": "^5.0.1",
57
57
  "@wordpress/notices": "^5.0.2",
58
- "@wordpress/patterns": "^2.0.3",
58
+ "@wordpress/patterns": "^2.0.4",
59
59
  "@wordpress/plugins": "^7.0.3",
60
60
  "@wordpress/preferences": "^4.0.3",
61
61
  "@wordpress/private-apis": "^1.0.2",
62
- "@wordpress/reusable-blocks": "^5.0.3",
62
+ "@wordpress/reusable-blocks": "^5.0.4",
63
63
  "@wordpress/rich-text": "^7.0.2",
64
64
  "@wordpress/server-side-render": "^5.0.3",
65
65
  "@wordpress/url": "^4.0.1",
@@ -83,5 +83,5 @@
83
83
  "publishConfig": {
84
84
  "access": "public"
85
85
  },
86
- "gitHead": "9dd5f8dcfa4fc7242e5d48be20ee789ad087b432"
86
+ "gitHead": "85486692a3e48b7d863226cf895a21d787434921"
87
87
  }
@@ -9,23 +9,22 @@ const CONTENT = 'content';
9
9
  export default {
10
10
  name: 'core/pattern-overrides',
11
11
  label: _x( 'Pattern Overrides', 'block bindings source' ),
12
- getValue( { registry, clientId, attributeName } ) {
13
- const { getBlockAttributes, getBlockParentsByBlockName } =
14
- registry.select( blockEditorStore );
12
+ getValue( { registry, clientId, context, attributeName } ) {
13
+ const patternOverridesContent = context[ 'pattern/overrides' ];
14
+ const { getBlockAttributes } = registry.select( blockEditorStore );
15
15
  const currentBlockAttributes = getBlockAttributes( clientId );
16
- const [ patternClientId ] = getBlockParentsByBlockName(
17
- clientId,
18
- 'core/block',
19
- true
20
- );
16
+
17
+ if ( ! patternOverridesContent ) {
18
+ return currentBlockAttributes[ attributeName ];
19
+ }
21
20
 
22
21
  const overridableValue =
23
- getBlockAttributes( patternClientId )?.[ CONTENT ]?.[
22
+ patternOverridesContent?.[
24
23
  currentBlockAttributes?.metadata?.name
25
24
  ]?.[ attributeName ];
26
25
 
27
26
  // If there is no pattern client ID, or it is not overwritten, return the default value.
28
- if ( ! patternClientId || overridableValue === undefined ) {
27
+ if ( overridableValue === undefined ) {
29
28
  return currentBlockAttributes[ attributeName ];
30
29
  }
31
30
 
@@ -29,6 +29,7 @@ function Editor( {
29
29
  className,
30
30
  styles,
31
31
  customSaveButton,
32
+ customSavePanel,
32
33
  forceDisableBlockTools,
33
34
  title,
34
35
  iframeProps,
@@ -58,6 +59,10 @@ function Editor( {
58
59
  [ postType, postId, templateId ]
59
60
  );
60
61
 
62
+ if ( ! post ) {
63
+ return null;
64
+ }
65
+
61
66
  return (
62
67
  <ExperimentalEditorProvider
63
68
  post={ post }
@@ -77,6 +82,7 @@ function Editor( {
77
82
  styles={ styles }
78
83
  enableRegionNavigation={ enableRegionNavigation }
79
84
  customSaveButton={ customSaveButton }
85
+ customSavePanel={ customSavePanel }
80
86
  forceDisableBlockTools={ forceDisableBlockTools }
81
87
  title={ title }
82
88
  iframeProps={ iframeProps }
@@ -55,6 +55,7 @@ export default function EditorInterface( {
55
55
  disableIframe,
56
56
  autoFocus,
57
57
  customSaveButton,
58
+ customSavePanel,
58
59
  forceDisableBlockTools,
59
60
  title,
60
61
  iframeProps,
@@ -212,18 +213,22 @@ export default function EditorInterface( {
212
213
  )
213
214
  }
214
215
  actions={
215
- ! isPreviewMode ? (
216
- <SavePublishPanels
217
- closeEntitiesSavedStates={ closeEntitiesSavedStates }
218
- isEntitiesSavedStatesOpen={
219
- entitiesSavedStatesCallback
220
- }
221
- setEntitiesSavedStatesCallback={
222
- setEntitiesSavedStatesCallback
223
- }
224
- forceIsDirtyPublishPanel={ forceIsDirty }
225
- />
226
- ) : undefined
216
+ ! isPreviewMode
217
+ ? customSavePanel || (
218
+ <SavePublishPanels
219
+ closeEntitiesSavedStates={
220
+ closeEntitiesSavedStates
221
+ }
222
+ isEntitiesSavedStatesOpen={
223
+ entitiesSavedStatesCallback
224
+ }
225
+ setEntitiesSavedStatesCallback={
226
+ setEntitiesSavedStatesCallback
227
+ }
228
+ forceIsDirtyPublishPanel={ forceIsDirty }
229
+ />
230
+ )
231
+ : undefined
227
232
  }
228
233
  shortcuts={ {
229
234
  previous: previousShortcut,
@@ -257,7 +257,11 @@ const trashPostAction = {
257
257
  } else if ( items[ 0 ].type === 'page' ) {
258
258
  successMessage = sprintf(
259
259
  /* translators: The number of items. */
260
- __( '%s items moved to trash.' ),
260
+ _n(
261
+ '%s item moved to trash.',
262
+ '%s items moved to trash.',
263
+ items.length
264
+ ),
261
265
  items.length
262
266
  );
263
267
  } else {
@@ -20,6 +20,21 @@
20
20
  opacity: 1;
21
21
  }
22
22
  }
23
+
24
+ .components-drop-zone__content {
25
+ border-radius: $radius-block-ui;
26
+ }
27
+
28
+ // Align text and icons horizontally to avoid clipping when the featured image is not set.
29
+ &:has(.editor-post-featured-image__toggle) .components-drop-zone .components-drop-zone__content-inner {
30
+ display: flex;
31
+ align-items: center;
32
+ gap: $grid-unit-10;
33
+
34
+ .components-drop-zone__content-icon {
35
+ margin: 0;
36
+ }
37
+ }
23
38
  }
24
39
 
25
40
  .editor-post-featured-image__toggle,
@@ -30,20 +30,28 @@ export default function SavePublishPanels( {
30
30
  useDispatch( editorStore );
31
31
  const {
32
32
  publishSidebarOpened,
33
- hasNonPostEntityChanges,
34
- hasPostMetaChanges,
35
- } = useSelect(
36
- ( select ) => ( {
37
- publishSidebarOpened:
38
- select( editorStore ).isPublishSidebarOpened(),
39
- hasNonPostEntityChanges:
40
- select( editorStore ).hasNonPostEntityChanges(),
41
- hasPostMetaChanges: unlock(
42
- select( editorStore )
43
- ).hasPostMetaChanges(),
44
- } ),
45
- []
46
- );
33
+ isPublishable,
34
+ isDirty,
35
+ hasOtherEntitiesChanges,
36
+ } = useSelect( ( select ) => {
37
+ const {
38
+ isPublishSidebarOpened,
39
+ isEditedPostPublishable,
40
+ isCurrentPostPublished,
41
+ isEditedPostDirty,
42
+ hasNonPostEntityChanges,
43
+ } = select( editorStore );
44
+ const _hasOtherEntitiesChanges =
45
+ hasNonPostEntityChanges() ||
46
+ unlock( select( editorStore ) ).hasPostMetaChanges();
47
+ return {
48
+ publishSidebarOpened: isPublishSidebarOpened(),
49
+ isPublishable:
50
+ ! isCurrentPostPublished() && isEditedPostPublishable(),
51
+ isDirty: _hasOtherEntitiesChanges || isEditedPostDirty(),
52
+ hasOtherEntitiesChanges: _hasOtherEntitiesChanges,
53
+ };
54
+ }, [] );
47
55
 
48
56
  const openEntitiesSavedStates = useCallback(
49
57
  () => setEntitiesSavedStatesCallback( true ),
@@ -62,29 +70,31 @@ export default function SavePublishPanels( {
62
70
  PostPublishExtension={ PluginPostPublishPanel.Slot }
63
71
  />
64
72
  );
65
- } else if ( hasNonPostEntityChanges || hasPostMetaChanges ) {
73
+ } else if ( isPublishable && ! hasOtherEntitiesChanges ) {
66
74
  unmountableContent = (
67
- <div className="editor-layout__toggle-entities-saved-states-panel">
75
+ <div className="editor-layout__toggle-publish-panel">
68
76
  <Button
69
77
  variant="secondary"
70
- className="editor-layout__toggle-entities-saved-states-panel-button"
71
- onClick={ openEntitiesSavedStates }
78
+ className="editor-layout__toggle-publish-panel-button"
79
+ onClick={ togglePublishSidebar }
72
80
  aria-expanded={ false }
73
81
  >
74
- { __( 'Open save panel' ) }
82
+ { __( 'Open publish panel' ) }
75
83
  </Button>
76
84
  </div>
77
85
  );
78
86
  } else {
79
87
  unmountableContent = (
80
- <div className="editor-layout__toggle-publish-panel">
88
+ <div className="editor-layout__toggle-entities-saved-states-panel">
81
89
  <Button
82
90
  variant="secondary"
83
- className="editor-layout__toggle-publish-panel-button"
84
- onClick={ togglePublishSidebar }
91
+ className="editor-layout__toggle-entities-saved-states-panel-button"
92
+ onClick={ openEntitiesSavedStates }
85
93
  aria-expanded={ false }
94
+ disabled={ ! isDirty }
95
+ __experimentalIsFocusable
86
96
  >
87
- { __( 'Open publish panel' ) }
97
+ { __( 'Open save panel' ) }
88
98
  </Button>
89
99
  </div>
90
100
  );
@@ -19,7 +19,7 @@
19
19
 
20
20
  // In the iframed canvas this keeps extra scrollbars from appearing (when block toolbars overflow). In the
21
21
  // legacy (non-iframed) canvas, overflow must not be hidden in order to maintain support for sticky positioning.
22
- .is-iframed {
22
+ &.is-iframed {
23
23
  overflow: hidden;
24
24
  }
25
25
 
@@ -14,6 +14,8 @@ import { store as blocksStore } from '@wordpress/blocks';
14
14
  import { store as editorStore } from '../store';
15
15
  import { unlock } from '../lock-unlock';
16
16
 
17
+ /** @typedef {import('@wordpress/blocks').WPBlockSettings} WPBlockSettings */
18
+
17
19
  const {
18
20
  PatternOverridesControls,
19
21
  ResetOverridesControl,
@@ -46,7 +48,8 @@ const withPatternOverrideControls = createHigherOrderComponent(
46
48
  { isSupportedBlock && <PatternOverridesBlockControls /> }
47
49
  </>
48
50
  );
49
- }
51
+ },
52
+ 'withPatternOverrideControls'
50
53
  );
51
54
 
52
55
  // Split into a separate component to avoid a store subscription