@wordpress/editor 14.40.1 → 14.40.2-next.v.202602241322.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 (47) hide show
  1. package/build/components/collaborators-overlay/use-block-highlighting.cjs +13 -4
  2. package/build/components/collaborators-overlay/use-block-highlighting.cjs.map +2 -2
  3. package/build/components/collaborators-overlay/use-render-cursors.cjs +23 -36
  4. package/build/components/collaborators-overlay/use-render-cursors.cjs.map +2 -2
  5. package/build/components/post-locked-modal/index.cjs +2 -4
  6. package/build/components/post-locked-modal/index.cjs.map +2 -2
  7. package/build/components/preferences-modal/index.cjs +1 -1
  8. package/build/components/preferences-modal/index.cjs.map +2 -2
  9. package/build/components/provider/use-upload-save-lock.cjs +5 -5
  10. package/build/components/provider/use-upload-save-lock.cjs.map +2 -2
  11. package/build/components/visual-editor/index.cjs +13 -4
  12. package/build/components/visual-editor/index.cjs.map +2 -2
  13. package/build/utils/media-upload/index.cjs +8 -2
  14. package/build/utils/media-upload/index.cjs.map +2 -2
  15. package/build-module/components/collaborators-overlay/use-block-highlighting.mjs +13 -4
  16. package/build-module/components/collaborators-overlay/use-block-highlighting.mjs.map +2 -2
  17. package/build-module/components/collaborators-overlay/use-render-cursors.mjs +23 -36
  18. package/build-module/components/collaborators-overlay/use-render-cursors.mjs.map +2 -2
  19. package/build-module/components/post-locked-modal/index.mjs +2 -4
  20. package/build-module/components/post-locked-modal/index.mjs.map +2 -2
  21. package/build-module/components/preferences-modal/index.mjs +1 -1
  22. package/build-module/components/preferences-modal/index.mjs.map +2 -2
  23. package/build-module/components/provider/use-upload-save-lock.mjs +5 -5
  24. package/build-module/components/provider/use-upload-save-lock.mjs.map +2 -2
  25. package/build-module/components/visual-editor/index.mjs +13 -4
  26. package/build-module/components/visual-editor/index.mjs.map +2 -2
  27. package/build-module/utils/media-upload/index.mjs +8 -2
  28. package/build-module/utils/media-upload/index.mjs.map +2 -2
  29. package/build-style/style-rtl.css +3 -3
  30. package/build-style/style.css +3 -3
  31. package/build-types/components/collaborators-overlay/use-block-highlighting.d.ts.map +1 -1
  32. package/build-types/components/collaborators-overlay/use-render-cursors.d.ts.map +1 -1
  33. package/build-types/components/post-locked-modal/index.d.ts.map +1 -1
  34. package/build-types/components/post-template/hooks.d.ts +1 -1
  35. package/build-types/components/post-template/hooks.d.ts.map +1 -1
  36. package/build-types/components/provider/use-upload-save-lock.d.ts +1 -1
  37. package/build-types/components/provider/use-upload-save-lock.d.ts.map +1 -1
  38. package/build-types/components/visual-editor/index.d.ts.map +1 -1
  39. package/build-types/utils/media-upload/index.d.ts.map +1 -1
  40. package/package.json +44 -44
  41. package/src/components/collaborators-overlay/use-block-highlighting.ts +15 -6
  42. package/src/components/collaborators-overlay/use-render-cursors.ts +24 -38
  43. package/src/components/post-locked-modal/index.js +2 -4
  44. package/src/components/preferences-modal/index.js +1 -1
  45. package/src/components/provider/use-upload-save-lock.js +7 -6
  46. package/src/components/visual-editor/index.js +21 -4
  47. package/src/utils/media-upload/index.js +8 -2
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wordpress/editor",
3
- "version": "14.40.1",
3
+ "version": "14.40.2-next.v.202602241322.0+bce7cff88",
4
4
  "description": "Enhanced block editor for WordPress posts.",
5
5
  "author": "The WordPress Contributors",
6
6
  "license": "GPL-2.0-or-later",
@@ -61,48 +61,48 @@
61
61
  ],
62
62
  "dependencies": {
63
63
  "@floating-ui/react-dom": "2.0.8",
64
- "@wordpress/a11y": "^4.40.0",
65
- "@wordpress/api-fetch": "^7.40.0",
66
- "@wordpress/base-styles": "^6.16.0",
67
- "@wordpress/blob": "^4.40.0",
68
- "@wordpress/block-editor": "^15.13.1",
69
- "@wordpress/block-serialization-default-parser": "^5.40.0",
70
- "@wordpress/blocks": "^15.13.0",
71
- "@wordpress/commands": "^1.40.0",
72
- "@wordpress/components": "^32.2.0",
73
- "@wordpress/compose": "^7.40.0",
74
- "@wordpress/core-data": "^7.40.1",
75
- "@wordpress/data": "^10.40.0",
76
- "@wordpress/dataviews": "^12.0.0",
77
- "@wordpress/date": "^5.40.0",
78
- "@wordpress/deprecated": "^4.40.0",
79
- "@wordpress/dom": "^4.40.0",
80
- "@wordpress/element": "^6.40.0",
81
- "@wordpress/fields": "^0.32.1",
82
- "@wordpress/global-styles-engine": "^1.7.0",
83
- "@wordpress/global-styles-ui": "^1.7.1",
84
- "@wordpress/hooks": "^4.40.0",
85
- "@wordpress/html-entities": "^4.40.0",
86
- "@wordpress/i18n": "^6.13.0",
87
- "@wordpress/icons": "^11.7.0",
88
- "@wordpress/interface": "^9.25.0",
89
- "@wordpress/keyboard-shortcuts": "^5.40.0",
90
- "@wordpress/keycodes": "^4.40.0",
91
- "@wordpress/media-editor": "^0.3.0",
92
- "@wordpress/media-fields": "^0.5.1",
93
- "@wordpress/media-utils": "^5.40.1",
94
- "@wordpress/notices": "^5.40.0",
95
- "@wordpress/patterns": "^2.40.1",
96
- "@wordpress/plugins": "^7.40.0",
97
- "@wordpress/preferences": "^4.40.0",
98
- "@wordpress/private-apis": "^1.40.0",
99
- "@wordpress/reusable-blocks": "^5.40.1",
100
- "@wordpress/rich-text": "^7.40.0",
101
- "@wordpress/server-side-render": "^6.16.0",
102
- "@wordpress/upload-media": "^0.25.1",
103
- "@wordpress/url": "^4.40.0",
104
- "@wordpress/warning": "^3.40.0",
105
- "@wordpress/wordcount": "^4.40.0",
64
+ "@wordpress/a11y": "^4.40.1-next.v.202602241322.0+bce7cff88",
65
+ "@wordpress/api-fetch": "^7.40.1-next.v.202602241322.0+bce7cff88",
66
+ "@wordpress/base-styles": "^6.16.1-next.v.202602241322.0+bce7cff88",
67
+ "@wordpress/blob": "^4.40.1-next.v.202602241322.0+bce7cff88",
68
+ "@wordpress/block-editor": "^15.13.2-next.v.202602241322.0+bce7cff88",
69
+ "@wordpress/block-serialization-default-parser": "^5.40.1-next.v.202602241322.0+bce7cff88",
70
+ "@wordpress/blocks": "^15.13.1-next.v.202602241322.0+bce7cff88",
71
+ "@wordpress/commands": "^1.40.1-next.v.202602241322.0+bce7cff88",
72
+ "@wordpress/components": "^32.3.1-next.v.202602241322.0+bce7cff88",
73
+ "@wordpress/compose": "^7.40.1-next.v.202602241322.0+bce7cff88",
74
+ "@wordpress/core-data": "^7.40.2-next.v.202602241322.0+bce7cff88",
75
+ "@wordpress/data": "^10.40.1-next.v.202602241322.0+bce7cff88",
76
+ "@wordpress/dataviews": "^12.1.1-next.v.202602241322.0+bce7cff88",
77
+ "@wordpress/date": "^5.40.1-next.v.202602241322.0+bce7cff88",
78
+ "@wordpress/deprecated": "^4.40.1-next.v.202602241322.0+bce7cff88",
79
+ "@wordpress/dom": "^4.40.1-next.v.202602241322.0+bce7cff88",
80
+ "@wordpress/element": "^6.40.1-next.v.202602241322.0+bce7cff88",
81
+ "@wordpress/fields": "^0.32.2-next.v.202602241322.0+bce7cff88",
82
+ "@wordpress/global-styles-engine": "^1.7.1-next.v.202602241322.0+bce7cff88",
83
+ "@wordpress/global-styles-ui": "^1.7.2-next.v.202602241322.0+bce7cff88",
84
+ "@wordpress/hooks": "^4.40.1-next.v.202602241322.0+bce7cff88",
85
+ "@wordpress/html-entities": "^4.40.1-next.v.202602241322.0+bce7cff88",
86
+ "@wordpress/i18n": "^6.13.1-next.v.202602241322.0+bce7cff88",
87
+ "@wordpress/icons": "^11.7.1-next.v.202602241322.0+bce7cff88",
88
+ "@wordpress/interface": "^9.25.1-next.v.202602241322.0+bce7cff88",
89
+ "@wordpress/keyboard-shortcuts": "^5.40.1-next.v.202602241322.0+bce7cff88",
90
+ "@wordpress/keycodes": "^4.40.1-next.v.202602241322.0+bce7cff88",
91
+ "@wordpress/media-editor": "^0.3.1-next.v.202602241322.0+bce7cff88",
92
+ "@wordpress/media-fields": "^0.5.2-next.v.202602241322.0+bce7cff88",
93
+ "@wordpress/media-utils": "^5.40.2-next.v.202602241322.0+bce7cff88",
94
+ "@wordpress/notices": "^5.40.1-next.v.202602241322.0+bce7cff88",
95
+ "@wordpress/patterns": "^2.40.2-next.v.202602241322.0+bce7cff88",
96
+ "@wordpress/plugins": "^7.40.1-next.v.202602241322.0+bce7cff88",
97
+ "@wordpress/preferences": "^4.40.1-next.v.202602241322.0+bce7cff88",
98
+ "@wordpress/private-apis": "^1.40.1-next.v.202602241322.0+bce7cff88",
99
+ "@wordpress/reusable-blocks": "^5.40.2-next.v.202602241322.0+bce7cff88",
100
+ "@wordpress/rich-text": "^7.40.1-next.v.202602241322.0+bce7cff88",
101
+ "@wordpress/server-side-render": "^6.16.1-next.v.202602241322.0+bce7cff88",
102
+ "@wordpress/upload-media": "^0.25.2-next.v.202602241322.0+bce7cff88",
103
+ "@wordpress/url": "^4.40.1-next.v.202602241322.0+bce7cff88",
104
+ "@wordpress/warning": "^3.40.1-next.v.202602241322.0+bce7cff88",
105
+ "@wordpress/wordcount": "^4.40.1-next.v.202602241322.0+bce7cff88",
106
106
  "change-case": "^4.1.2",
107
107
  "client-zip": "^2.4.5",
108
108
  "clsx": "^2.1.1",
@@ -124,5 +124,5 @@
124
124
  "publishConfig": {
125
125
  "access": "public"
126
126
  },
127
- "gitHead": "398c509dbbdcdb525d17e968edd83da33a0a7bde"
127
+ "gitHead": "943dde7f0b600ce238726c36284bc9f70ce0ffa4"
128
128
  }
@@ -4,7 +4,6 @@
4
4
  import {
5
5
  privateApis as coreDataPrivateApis,
6
6
  SelectionType,
7
- type SelectionWholeBlock,
8
7
  } from '@wordpress/core-data';
9
8
  import { useEffect, useRef } from '@wordpress/element';
10
9
 
@@ -14,7 +13,8 @@ import { useEffect, useRef } from '@wordpress/element';
14
13
  import { unlock } from '../../lock-unlock';
15
14
  import { getAvatarBorderColor } from '../collab-sidebar/utils';
16
15
 
17
- const { useActiveCollaborators } = unlock( coreDataPrivateApis );
16
+ const { useActiveCollaborators, useResolvedSelection } =
17
+ unlock( coreDataPrivateApis );
18
18
 
19
19
  /**
20
20
  * Custom hook for highlighting selected blocks in the editor
@@ -32,6 +32,10 @@ export function useBlockHighlighting(
32
32
  postId ?? null,
33
33
  postType ?? null
34
34
  );
35
+ const resolveSelection = useResolvedSelection(
36
+ postId ?? null,
37
+ postType ?? null
38
+ );
35
39
 
36
40
  // Draw block highlights
37
41
  useEffect( () => {
@@ -66,11 +70,16 @@ export function useBlockHighlighting(
66
70
  const shouldDrawUser = ! userState.isMe;
67
71
 
68
72
  if ( isWholeBlockSelected && shouldDrawUser ) {
69
- const selection = userState.editorState
70
- ?.selection as unknown as SelectionWholeBlock;
73
+ const { localClientId } = resolveSelection(
74
+ userState.editorState?.selection
75
+ );
76
+
77
+ if ( ! localClientId ) {
78
+ return null;
79
+ }
71
80
 
72
81
  return {
73
- blockId: selection.blockId,
82
+ blockId: localClientId,
74
83
  color: getAvatarBorderColor(
75
84
  userState.collaboratorInfo.id
76
85
  ),
@@ -112,7 +121,7 @@ export function useBlockHighlighting(
112
121
  highlightedBlockIds.current.add( blockId );
113
122
  }
114
123
  } );
115
- }, [ userStates, blockEditorDocument ] );
124
+ }, [ userStates, blockEditorDocument, resolveSelection ] );
116
125
  }
117
126
 
118
127
  const getBlockElementById = (
@@ -1,6 +1,5 @@
1
1
  import {
2
2
  privateApis as coreDataPrivateApis,
3
- type SelectionCursor,
4
3
  SelectionType,
5
4
  } from '@wordpress/core-data';
6
5
  import { useEffect, useMemo, useState } from '@wordpress/element';
@@ -9,7 +8,7 @@ import { unlock } from '../../lock-unlock';
9
8
  import { getAvatarUrl } from './get-avatar-url';
10
9
  import { getAvatarBorderColor } from '../collab-sidebar/utils';
11
10
 
12
- const { useActiveCollaborators, useGetAbsolutePositionIndex } =
11
+ const { useActiveCollaborators, useResolvedSelection } =
13
12
  unlock( coreDataPrivateApis );
14
13
 
15
14
  export interface CursorData {
@@ -41,7 +40,7 @@ export function useRenderCursors(
41
40
  postId ?? null,
42
41
  postType ?? null
43
42
  );
44
- const getAbsolutePositionIndex = useGetAbsolutePositionIndex(
43
+ const resolveSelection = useResolvedSelection(
45
44
  postId ?? null,
46
45
  postType ?? null
47
46
  );
@@ -85,40 +84,32 @@ export function useRenderCursors(
85
84
  } else if ( selection.type === SelectionType.WholeBlock ) {
86
85
  // Don't draw a cursor for a whole block selection.
87
86
  } else if ( selection.type === SelectionType.Cursor ) {
88
- coords = getCursorPosition(
89
- getAbsolutePositionIndex( selection ),
90
- selection.blockId,
91
- blockEditorDocument,
92
- overlayElement
93
- );
94
- } else if (
95
- selection.type === SelectionType.SelectionInOneBlock
96
- ) {
97
- const selectionAsCursor: SelectionCursor = {
98
- type: SelectionType.Cursor,
99
- blockId: selection.blockId,
100
- cursorPosition: selection.cursorStartPosition,
101
- };
102
- coords = getCursorPosition(
103
- getAbsolutePositionIndex( selectionAsCursor ),
104
- selectionAsCursor.blockId,
105
- blockEditorDocument,
106
- overlayElement
107
- );
87
+ const { textIndex, localClientId } =
88
+ resolveSelection( selection );
89
+ if ( localClientId ) {
90
+ coords = getCursorPosition(
91
+ textIndex,
92
+ localClientId,
93
+ blockEditorDocument,
94
+ overlayElement
95
+ );
96
+ }
108
97
  } else if (
98
+ selection.type === SelectionType.SelectionInOneBlock ||
109
99
  selection.type === SelectionType.SelectionInMultipleBlocks
110
100
  ) {
111
- const selectionAsCursor: SelectionCursor = {
101
+ const { textIndex, localClientId } = resolveSelection( {
112
102
  type: SelectionType.Cursor,
113
- blockId: selection.blockStartId,
114
103
  cursorPosition: selection.cursorStartPosition,
115
- };
116
- coords = getCursorPosition(
117
- getAbsolutePositionIndex( selectionAsCursor ),
118
- selectionAsCursor.blockId,
119
- blockEditorDocument,
120
- overlayElement
121
- );
104
+ } );
105
+ if ( localClientId ) {
106
+ coords = getCursorPosition(
107
+ textIndex,
108
+ localClientId,
109
+ blockEditorDocument,
110
+ overlayElement
111
+ );
112
+ }
122
113
  }
123
114
 
124
115
  if ( coords ) {
@@ -134,12 +125,7 @@ export function useRenderCursors(
134
125
 
135
126
  setCursorPositions( results );
136
127
  },
137
- [
138
- blockEditorDocument,
139
- getAbsolutePositionIndex,
140
- overlayElement,
141
- sortedUsers,
142
- ]
128
+ [ blockEditorDocument, resolveSelection, overlayElement, sortedUsers ]
143
129
  );
144
130
 
145
131
  useEffect( computeCursors, [ computeCursors ] );
@@ -152,10 +152,8 @@ function PostLockedModal() {
152
152
  }
153
153
 
154
154
  // Avoid sending the modal if sync is supported, but retain functionality around locks etc.
155
- if ( globalThis.IS_GUTENBERG_PLUGIN ) {
156
- if ( isCollaborationEnabled ) {
157
- return null;
158
- }
155
+ if ( isCollaborationEnabled ) {
156
+ return null;
159
157
  }
160
158
 
161
159
  const userDisplayName = user.name;
@@ -298,7 +298,7 @@ function PreferencesModalContents( { extraSections = {} } ) {
298
298
  </>
299
299
  ),
300
300
  },
301
- window.__experimentalMediaProcessing && {
301
+ window.__clientSideMediaProcessing && {
302
302
  name: 'media',
303
303
  tabLabel: __( 'Media' ),
304
304
  content: (
@@ -16,19 +16,20 @@ const LOCK_NAME = 'upload-in-progress';
16
16
  * A hook that locks post saving and autosaving while media uploads are in progress.
17
17
  * This prevents users from publishing or saving while files are still uploading.
18
18
  *
19
- * Only active when the experimental media processing feature is enabled.
19
+ * Only active when client-side media processing is enabled.
20
20
  */
21
21
  export default function useUploadSaveLock() {
22
- const isExperimentEnabled = window.__experimentalMediaProcessing;
22
+ const isClientSideMediaProcessingEnabled =
23
+ window.__clientSideMediaProcessing;
23
24
 
24
25
  const isUploading = useSelect(
25
26
  ( select ) => {
26
- if ( ! isExperimentEnabled ) {
27
+ if ( ! isClientSideMediaProcessingEnabled ) {
27
28
  return false;
28
29
  }
29
30
  return select( uploadStore ).isUploading();
30
31
  },
31
- [ isExperimentEnabled ]
32
+ [ isClientSideMediaProcessingEnabled ]
32
33
  );
33
34
 
34
35
  const {
@@ -39,7 +40,7 @@ export default function useUploadSaveLock() {
39
40
  } = useDispatch( editorStore );
40
41
 
41
42
  useEffect( () => {
42
- if ( ! isExperimentEnabled ) {
43
+ if ( ! isClientSideMediaProcessingEnabled ) {
43
44
  return;
44
45
  }
45
46
 
@@ -56,7 +57,7 @@ export default function useUploadSaveLock() {
56
57
  unlockPostAutosaving( LOCK_NAME );
57
58
  };
58
59
  }, [
59
- isExperimentEnabled,
60
+ isClientSideMediaProcessingEnabled,
60
61
  isUploading,
61
62
  lockPostSaving,
62
63
  unlockPostSaving,
@@ -334,6 +334,8 @@ function VisualEditor( {
334
334
  // Disable resizing in zoomed-out mode.
335
335
  ! isZoomedOut;
336
336
 
337
+ const isNavigationPreview = postType === NAVIGATION_POST_TYPE && isPreview;
338
+
337
339
  // Calculate the minimum height including scroll offset to fit all notes.
338
340
  const calculatedMinHeight = useMemo( () => {
339
341
  if ( ! localRef.current ) {
@@ -352,6 +354,8 @@ function VisualEditor( {
352
354
  ! isPreview && renderingMode === 'post-only' && ! isDesignPostType
353
355
  );
354
356
 
357
+ const centerContentCSS = `display:flex;align-items:center;justify-content:center;`;
358
+
355
359
  const iframeStyles = useMemo( () => {
356
360
  return [
357
361
  ...( styles ?? [] ),
@@ -366,19 +370,32 @@ function VisualEditor( {
366
370
  }}.is-root-container{display:flow-root;${
367
371
  // Some themes will have `min-height: 100vh` for the root container,
368
372
  // which isn't a requirement in auto resize mode.
369
- enableResizing ? 'min-height:0!important;' : ''
373
+ enableResizing || isNavigationPreview
374
+ ? 'min-height:0!important;'
375
+ : ''
370
376
  }}
371
377
  ${ paddingStyle ? paddingStyle : '' }
372
378
  ${
373
379
  enableResizing
374
- ? `.block-editor-iframe__html{background:var(--wp-editor-canvas-background);display:flex;align-items:center;justify-content:center;min-height:100vh;}.block-editor-iframe__body{width:100%;}`
380
+ ? `.block-editor-iframe__html{background:var(--wp-editor-canvas-background);min-height:100vh;${ centerContentCSS }}.block-editor-iframe__body{width:100%;}`
381
+ : ''
382
+ }${
383
+ isNavigationPreview
384
+ ? `.block-editor-iframe__body{${ centerContentCSS }}`
375
385
  : ''
376
386
  }`,
377
- // The CSS above centers the body content vertically when resizing is enabled and applies a background
387
+ // The CSS for enableResizing centers the body content vertically when resizing is enabled and applies a background
378
388
  // color to the iframe HTML element to match the background color of the editor canvas.
389
+ // The CSS for isNavigationPreview centers the body content vertically and horizontally when the navigation is in preview mode.
379
390
  },
380
391
  ];
381
- }, [ styles, enableResizing, calculatedMinHeight, paddingStyle ] );
392
+ }, [
393
+ styles,
394
+ enableResizing,
395
+ isNavigationPreview,
396
+ calculatedMinHeight,
397
+ paddingStyle,
398
+ ] );
382
399
 
383
400
  const typewriterRef = useTypewriter();
384
401
  contentRef = useMergeRefs( [
@@ -62,6 +62,9 @@ export default function mediaUpload( {
62
62
  ? currentPost.id
63
63
  : currentPost?.wp_id;
64
64
  const setSaveLock = () => {
65
+ if ( window.__clientSideMediaProcessing ) {
66
+ return; // Skip - handled by useUploadSaveLock in editor provider
67
+ }
65
68
  lockPostSaving( lockKey );
66
69
  lockPostAutosaving( lockKey );
67
70
  imageIsUploading = true;
@@ -69,6 +72,9 @@ export default function mediaUpload( {
69
72
 
70
73
  const postData = currentPostId ? { post: currentPostId } : {};
71
74
  const clearSaveLock = () => {
75
+ if ( window.__clientSideMediaProcessing ) {
76
+ return; // Skip - handled by useUploadSaveLock in editor provider
77
+ }
72
78
  unlockPostSaving( lockKey );
73
79
  unlockPostAutosaving( lockKey );
74
80
  imageIsUploading = false;
@@ -80,7 +86,7 @@ export default function mediaUpload( {
80
86
  onFileChange: ( file ) => {
81
87
  // When client-side media processing is enabled, save locking
82
88
  // is handled by useUploadSaveLock in the editor provider.
83
- if ( ! window.__experimentalMediaProcessing ) {
89
+ if ( ! window.__clientSideMediaProcessing ) {
84
90
  if ( ! imageIsUploading ) {
85
91
  setSaveLock();
86
92
  } else {
@@ -111,7 +117,7 @@ export default function mediaUpload( {
111
117
  },
112
118
  maxUploadFileSize,
113
119
  onError: ( { message } ) => {
114
- if ( ! window.__experimentalMediaProcessing ) {
120
+ if ( ! window.__clientSideMediaProcessing ) {
115
121
  clearSaveLock();
116
122
  }
117
123
  onError( message );