@wordpress/edit-post 8.8.8 → 8.10.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 (76) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/build/components/back-button/fullscreen-mode-close.js +2 -4
  3. package/build/components/back-button/fullscreen-mode-close.js.map +1 -1
  4. package/build/components/init-pattern-modal/index.js +3 -12
  5. package/build/components/init-pattern-modal/index.js.map +1 -1
  6. package/build/components/layout/index.js +24 -30
  7. package/build/components/layout/index.js.map +1 -1
  8. package/build/components/layout/use-padding-appender.js +19 -16
  9. package/build/components/layout/use-padding-appender.js.map +1 -1
  10. package/build/components/meta-boxes/meta-box-visibility.js.map +1 -1
  11. package/build/components/meta-boxes/meta-boxes-area/index.js.map +1 -1
  12. package/build/components/preferences-modal/enable-custom-fields.js +2 -5
  13. package/build/components/preferences-modal/enable-custom-fields.js.map +1 -1
  14. package/build/components/preferences-modal/meta-boxes-section.js.map +1 -1
  15. package/build/deprecated.js.map +1 -1
  16. package/build/index.js +2 -4
  17. package/build/index.js.map +1 -1
  18. package/build/store/actions.js +1 -1
  19. package/build/store/actions.js.map +1 -1
  20. package/build/store/private-selectors.js.map +1 -1
  21. package/build/store/selectors.js +1 -1
  22. package/build/store/selectors.js.map +1 -1
  23. package/build/utils/meta-boxes.js.map +1 -1
  24. package/build-module/components/back-button/fullscreen-mode-close.js +2 -4
  25. package/build-module/components/back-button/fullscreen-mode-close.js.map +1 -1
  26. package/build-module/components/header/header-toolbar/index.native.js +1 -2
  27. package/build-module/components/header/header-toolbar/index.native.js.map +1 -1
  28. package/build-module/components/init-pattern-modal/index.js +5 -16
  29. package/build-module/components/init-pattern-modal/index.js.map +1 -1
  30. package/build-module/components/layout/index.js +25 -33
  31. package/build-module/components/layout/index.js.map +1 -1
  32. package/build-module/components/layout/index.native.js +1 -3
  33. package/build-module/components/layout/index.native.js.map +1 -1
  34. package/build-module/components/layout/use-padding-appender.js +20 -16
  35. package/build-module/components/layout/use-padding-appender.js.map +1 -1
  36. package/build-module/components/meta-boxes/index.js +1 -3
  37. package/build-module/components/meta-boxes/index.js.map +1 -1
  38. package/build-module/components/meta-boxes/meta-box-visibility.js.map +1 -1
  39. package/build-module/components/meta-boxes/meta-boxes-area/index.js +1 -2
  40. package/build-module/components/meta-boxes/meta-boxes-area/index.js.map +1 -1
  41. package/build-module/components/more-menu/index.js +1 -3
  42. package/build-module/components/more-menu/index.js.map +1 -1
  43. package/build-module/components/preferences-modal/enable-custom-fields.js +3 -8
  44. package/build-module/components/preferences-modal/enable-custom-fields.js.map +1 -1
  45. package/build-module/components/preferences-modal/meta-boxes-section.js +1 -2
  46. package/build-module/components/preferences-modal/meta-boxes-section.js.map +1 -1
  47. package/build-module/components/welcome-guide/default.js +1 -3
  48. package/build-module/components/welcome-guide/default.js.map +1 -1
  49. package/build-module/components/welcome-guide/image.js +1 -2
  50. package/build-module/components/welcome-guide/image.js.map +1 -1
  51. package/build-module/components/welcome-guide/template.js +1 -3
  52. package/build-module/components/welcome-guide/template.js.map +1 -1
  53. package/build-module/deprecated.js.map +1 -1
  54. package/build-module/index.js +2 -4
  55. package/build-module/index.js.map +1 -1
  56. package/build-module/store/actions.js +1 -1
  57. package/build-module/store/actions.js.map +1 -1
  58. package/build-module/store/private-selectors.js.map +1 -1
  59. package/build-module/store/selectors.js +1 -1
  60. package/build-module/store/selectors.js.map +1 -1
  61. package/build-module/utils/meta-boxes.js.map +1 -1
  62. package/build-style/classic-rtl.css +10 -1
  63. package/build-style/classic.css +10 -1
  64. package/build-style/style-rtl.css +10 -1
  65. package/build-style/style.css +10 -1
  66. package/package.json +32 -32
  67. package/src/components/back-button/fullscreen-mode-close.js +1 -2
  68. package/src/components/back-button/test/__snapshots__/fullscreen-mode-close.js.snap +1 -1
  69. package/src/components/init-pattern-modal/index.js +5 -12
  70. package/src/components/layout/index.js +21 -32
  71. package/src/components/layout/use-padding-appender.js +21 -18
  72. package/src/components/preferences-modal/enable-custom-fields.js +1 -3
  73. package/src/components/preferences-modal/test/__snapshots__/enable-custom-fields.js.snap +2 -2
  74. package/src/index.js +0 -2
  75. package/src/store/actions.js +1 -1
  76. package/src/store/selectors.js +1 -1
@@ -87,27 +87,17 @@ const DESIGN_POST_TYPES = [
87
87
  'wp_navigation',
88
88
  ];
89
89
 
90
- function useEditorStyles() {
91
- const {
92
- hasThemeStyleSupport,
93
- editorSettings,
94
- isZoomedOutView,
95
- renderingMode,
96
- postType,
97
- } = useSelect( ( select ) => {
98
- const { __unstableGetEditorMode } = select( blockEditorStore );
99
- const { getCurrentPostType, getRenderingMode } = select( editorStore );
100
- const _postType = getCurrentPostType();
90
+ function useEditorStyles( ...additionalStyles ) {
91
+ const { hasThemeStyleSupport, editorSettings } = useSelect( ( select ) => {
101
92
  return {
102
93
  hasThemeStyleSupport:
103
94
  select( editPostStore ).isFeatureActive( 'themeStyles' ),
104
95
  editorSettings: select( editorStore ).getEditorSettings(),
105
- isZoomedOutView: __unstableGetEditorMode() === 'zoom-out',
106
- renderingMode: getRenderingMode(),
107
- postType: _postType,
108
96
  };
109
97
  }, [] );
110
98
 
99
+ const addedStyles = additionalStyles.join( '\n' );
100
+
111
101
  // Compute the default styles.
112
102
  return useMemo( () => {
113
103
  const presetStyles =
@@ -144,19 +134,8 @@ function useEditorStyles() {
144
134
  ? editorSettings.styles ?? []
145
135
  : defaultEditorStyles;
146
136
 
147
- // Add a space for the typewriter effect. When typing in the last block,
148
- // there needs to be room to scroll up.
149
- if (
150
- ! isZoomedOutView &&
151
- renderingMode === 'post-only' &&
152
- ! DESIGN_POST_TYPES.includes( postType )
153
- ) {
154
- return [
155
- ...baseStyles,
156
- {
157
- css: ':root :where(.editor-styles-wrapper)::after {content: ""; display: block; height: 40vh;}',
158
- },
159
- ];
137
+ if ( addedStyles ) {
138
+ return [ ...baseStyles, { css: addedStyles } ];
160
139
  }
161
140
 
162
141
  return baseStyles;
@@ -165,7 +144,7 @@ function useEditorStyles() {
165
144
  editorSettings.disableLayoutStyles,
166
145
  editorSettings.styles,
167
146
  hasThemeStyleSupport,
168
- postType,
147
+ addedStyles,
169
148
  ] );
170
149
  }
171
150
 
@@ -393,7 +372,6 @@ function Layout( {
393
372
  } ) {
394
373
  useCommands();
395
374
  useEditPostCommands();
396
- const paddingAppenderRef = usePaddingAppender();
397
375
  const shouldIframe = useShouldIframe();
398
376
  const { createErrorNotice } = useDispatch( noticesStore );
399
377
  const {
@@ -417,6 +395,7 @@ function Layout( {
417
395
  hasHistory,
418
396
  isWelcomeGuideVisible,
419
397
  templateId,
398
+ enablePaddingAppender,
420
399
  } = useSelect(
421
400
  ( select ) => {
422
401
  const { get } = select( preferencesStore );
@@ -432,9 +411,12 @@ function Layout( {
432
411
  kind: 'postType',
433
412
  name: 'wp_template',
434
413
  } );
414
+ const { __unstableGetEditorMode } = select( blockEditorStore );
415
+ const { getEditorMode, getRenderingMode } = select( editorStore );
416
+ const isRenderingPostOnly = getRenderingMode() === 'post-only';
435
417
 
436
418
  return {
437
- mode: select( editorStore ).getEditorMode(),
419
+ mode: getEditorMode(),
438
420
  isFullscreenActive:
439
421
  select( editPostStore ).isFeatureActive( 'fullscreenMode' ),
440
422
  hasActiveMetaboxes: select( editPostStore ).hasMetaBoxes(),
@@ -444,7 +426,7 @@ function Layout( {
444
426
  isDistractionFree: get( 'core', 'distractionFree' ),
445
427
  showMetaBoxes:
446
428
  ! DESIGN_POST_TYPES.includes( currentPostType ) &&
447
- select( editorStore ).getRenderingMode() === 'post-only',
429
+ isRenderingPostOnly,
448
430
  isWelcomeGuideVisible: isFeatureActive( 'welcomeGuide' ),
449
431
  templateId:
450
432
  supportsTemplateMode &&
@@ -453,10 +435,17 @@ function Layout( {
453
435
  ! isEditingTemplate
454
436
  ? getEditedPostTemplateId()
455
437
  : null,
438
+ enablePaddingAppender:
439
+ __unstableGetEditorMode() !== 'zoom-out' &&
440
+ isRenderingPostOnly &&
441
+ ! DESIGN_POST_TYPES.includes( currentPostType ),
456
442
  };
457
443
  },
458
444
  [ currentPostType, isEditingTemplate, settings.supportsTemplateMode ]
459
445
  );
446
+ const [ paddingAppenderRef, paddingStyle ] = usePaddingAppender(
447
+ enablePaddingAppender
448
+ );
460
449
 
461
450
  // Set the right context for the command palette
462
451
  const commandContext = hasBlockSelected
@@ -472,7 +461,7 @@ function Layout( {
472
461
  } ),
473
462
  [ settings, onNavigateToEntityRecord, onNavigateToPreviousEntityRecord ]
474
463
  );
475
- const styles = useEditorStyles();
464
+ const styles = useEditorStyles( paddingStyle );
476
465
 
477
466
  // We need to add the show-icon-labels class to the body element so it is applied to modals.
478
467
  if ( showIconLabels ) {
@@ -6,24 +6,23 @@ import { useRefEffect } from '@wordpress/compose';
6
6
  import { store as blockEditorStore } from '@wordpress/block-editor';
7
7
  import { isUnmodifiedDefaultBlock } from '@wordpress/blocks';
8
8
 
9
- export function usePaddingAppender() {
9
+ // Ruleset to add space for the typewriter effect. When typing in the last
10
+ // block, there needs to be room to scroll up.
11
+ const CSS =
12
+ ':root :where(.editor-styles-wrapper)::after {content: ""; display: block; height: 40vh;}';
13
+
14
+ export function usePaddingAppender( enabled ) {
10
15
  const registry = useRegistry();
11
- return useRefEffect(
16
+ const effect = useRefEffect(
12
17
  ( node ) => {
13
18
  function onMouseDown( event ) {
14
- if ( event.target !== node ) {
15
- return;
16
- }
17
-
18
- const { ownerDocument } = node;
19
- const { defaultView } = ownerDocument;
20
-
21
- const pseudoHeight = defaultView.parseInt(
22
- defaultView.getComputedStyle( node, ':after' ).height,
23
- 10
24
- );
25
-
26
- if ( ! pseudoHeight ) {
19
+ if (
20
+ event.target !== node &&
21
+ // Tests for the parent element because in the iframed editor if the click is
22
+ // below the padding the target will be the parent element (html) and should
23
+ // still be treated as intent to append.
24
+ event.target !== node.parentElement
25
+ ) {
27
26
  return;
28
27
  }
29
28
 
@@ -38,7 +37,7 @@ export function usePaddingAppender() {
38
37
  return;
39
38
  }
40
39
 
41
- event.stopPropagation();
40
+ event.preventDefault();
42
41
 
43
42
  const blockOrder = registry
44
43
  .select( blockEditorStore )
@@ -57,11 +56,15 @@ export function usePaddingAppender() {
57
56
  insertDefaultBlock();
58
57
  }
59
58
  }
60
- node.addEventListener( 'mousedown', onMouseDown );
59
+ const { ownerDocument } = node;
60
+ // Adds the listener on the document so that in the iframed editor clicks below the
61
+ // padding can be handled as they too should be treated as intent to append.
62
+ ownerDocument.addEventListener( 'mousedown', onMouseDown );
61
63
  return () => {
62
- node.removeEventListener( 'mousedown', onMouseDown );
64
+ ownerDocument.removeEventListener( 'mousedown', onMouseDown );
63
65
  };
64
66
  },
65
67
  [ registry ]
66
68
  );
69
+ return enabled ? [ effect, CSS ] : [];
67
70
  }
@@ -39,9 +39,7 @@ export function CustomFieldsConfirmation( { willEnable } ) {
39
39
  ) }
40
40
  </p>
41
41
  <Button
42
- // TODO: Switch to `true` (40px size) if possible
43
- __next40pxDefaultSize={ false }
44
- className="edit-post-preferences-modal__custom-fields-confirmation-button"
42
+ __next40pxDefaultSize
45
43
  variant="secondary"
46
44
  isBusy={ isReloading }
47
45
  accessibleWhenDisabled
@@ -97,7 +97,7 @@ exports[`EnableCustomFieldsOption renders a checked checkbox and a confirmation
97
97
  A page reload is required for this change. Make sure your content is saved before reloading.
98
98
  </p>
99
99
  <button
100
- class="components-button edit-post-preferences-modal__custom-fields-confirmation-button is-secondary"
100
+ class="components-button is-next-40px-default-size is-secondary"
101
101
  type="button"
102
102
  >
103
103
  Show & Reload Page
@@ -300,7 +300,7 @@ exports[`EnableCustomFieldsOption renders an unchecked checkbox and a confirmati
300
300
  A page reload is required for this change. Make sure your content is saved before reloading.
301
301
  </p>
302
302
  <button
303
- class="components-button edit-post-preferences-modal__custom-fields-confirmation-button is-secondary"
303
+ class="components-button is-next-40px-default-size is-secondary"
304
304
  type="button"
305
305
  >
306
306
  Hide & Reload Page
package/src/index.js CHANGED
@@ -28,7 +28,6 @@ import { unlock } from './lock-unlock';
28
28
  const {
29
29
  BackButton: __experimentalMainDashboardButton,
30
30
  registerCoreBlockBindingsSources,
31
- bootstrapBlockBindingsSourcesFromServer,
32
31
  } = unlock( editorPrivateApis );
33
32
 
34
33
  /**
@@ -95,7 +94,6 @@ export function initializeEditor(
95
94
  }
96
95
 
97
96
  registerCoreBlocks();
98
- bootstrapBlockBindingsSourcesFromServer( settings?.blockBindingsSources );
99
97
  registerCoreBlockBindingsSources();
100
98
  registerLegacyWidgetBlock( { inserter: false } );
101
99
  registerWidgetGroupBlock( { inserter: false } );
@@ -481,7 +481,7 @@ export const initializeMetaBoxes =
481
481
  addAction(
482
482
  'editor.savePost',
483
483
  'core/edit-post/save-metaboxes',
484
- async ( options ) => {
484
+ async ( post, options ) => {
485
485
  if ( ! options.isAutosave && select.hasMetaBoxes() ) {
486
486
  await dispatch.requestMetaBoxUpdates();
487
487
  }
@@ -506,7 +506,7 @@ export const __experimentalGetInsertionPoint = createRegistrySelector(
506
506
  version: '6.7',
507
507
  }
508
508
  );
509
- return unlock( select( editorStore ) ).getInsertionPoint();
509
+ return unlock( select( editorStore ) ).getInserter();
510
510
  }
511
511
  );
512
512