@wordpress/editor 14.36.1-next.8b30e05b0.0 → 14.37.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.
- package/CHANGELOG.md +2 -0
- package/README.md +2 -3
- package/build/components/autocompleters/user.js.map +2 -2
- package/build/components/collab-sidebar/comments.js +4 -12
- package/build/components/collab-sidebar/comments.js.map +2 -2
- package/build/components/collab-sidebar/hooks.js +7 -19
- package/build/components/collab-sidebar/hooks.js.map +2 -2
- package/build/components/document-bar/index.js +19 -8
- package/build/components/document-bar/index.js.map +3 -3
- package/build/components/document-bar/useEditedSectionDetails.js +95 -0
- package/build/components/document-bar/useEditedSectionDetails.js.map +7 -0
- package/build/components/page-attributes/parent.js +1 -0
- package/build/components/page-attributes/parent.js.map +2 -2
- package/build/components/post-card-panel/index.js +1 -1
- package/build/components/post-card-panel/index.js.map +2 -2
- package/build/components/post-publish-panel/maybe-tags-panel.js +1 -1
- package/build/components/post-publish-panel/maybe-tags-panel.js.map +2 -2
- package/build/components/post-taxonomies/flat-term-selector.js +3 -16
- package/build/components/post-taxonomies/flat-term-selector.js.map +3 -3
- package/build/components/post-taxonomies/index.js +1 -5
- package/build/components/post-taxonomies/index.js.map +2 -2
- package/build/components/provider/use-block-editor-settings.js +10 -2
- package/build/components/provider/use-block-editor-settings.js.map +2 -2
- package/build/components/style-book/index.js +3 -5
- package/build/components/style-book/index.js.map +2 -2
- package/build/dataviews/store/private-actions.js +9 -1
- package/build/dataviews/store/private-actions.js.map +2 -2
- package/build/store/utils/notice-builder.js +12 -4
- package/build/store/utils/notice-builder.js.map +2 -2
- package/build/utils/get-template-part-icon.js +9 -4
- package/build/utils/get-template-part-icon.js.map +3 -3
- package/build-module/components/autocompleters/user.js.map +2 -2
- package/build-module/components/collab-sidebar/comments.js +4 -12
- package/build-module/components/collab-sidebar/comments.js.map +2 -2
- package/build-module/components/collab-sidebar/hooks.js +7 -20
- package/build-module/components/collab-sidebar/hooks.js.map +2 -2
- package/build-module/components/document-bar/index.js +20 -9
- package/build-module/components/document-bar/index.js.map +2 -2
- package/build-module/components/document-bar/useEditedSectionDetails.js +74 -0
- package/build-module/components/document-bar/useEditedSectionDetails.js.map +7 -0
- package/build-module/components/page-attributes/parent.js +1 -0
- package/build-module/components/page-attributes/parent.js.map +2 -2
- package/build-module/components/post-card-panel/index.js +1 -1
- package/build-module/components/post-card-panel/index.js.map +2 -2
- package/build-module/components/post-publish-panel/maybe-tags-panel.js +1 -1
- package/build-module/components/post-publish-panel/maybe-tags-panel.js.map +2 -2
- package/build-module/components/post-taxonomies/flat-term-selector.js +4 -17
- package/build-module/components/post-taxonomies/flat-term-selector.js.map +2 -2
- package/build-module/components/post-taxonomies/index.js +1 -5
- package/build-module/components/post-taxonomies/index.js.map +2 -2
- package/build-module/components/provider/use-block-editor-settings.js +10 -2
- package/build-module/components/provider/use-block-editor-settings.js.map +2 -2
- package/build-module/components/style-book/index.js +3 -5
- package/build-module/components/style-book/index.js.map +2 -2
- package/build-module/dataviews/store/private-actions.js +11 -2
- package/build-module/dataviews/store/private-actions.js.map +2 -2
- package/build-module/store/utils/notice-builder.js +12 -4
- package/build-module/store/utils/notice-builder.js.map +2 -2
- package/build-module/utils/get-template-part-icon.js +10 -4
- package/build-module/utils/get-template-part-icon.js.map +2 -2
- package/build-style/style-rtl.css +76 -161
- package/build-style/style.css +76 -161
- package/build-types/components/autocompleters/user.d.ts +8 -2
- package/build-types/components/autocompleters/user.d.ts.map +1 -1
- package/build-types/components/collab-sidebar/comments.d.ts.map +1 -1
- package/build-types/components/collab-sidebar/hooks.d.ts +0 -1
- package/build-types/components/collab-sidebar/hooks.d.ts.map +1 -1
- package/build-types/components/document-bar/index.d.ts.map +1 -1
- package/build-types/components/document-bar/useEditedSectionDetails.d.ts +8 -0
- package/build-types/components/document-bar/useEditedSectionDetails.d.ts.map +1 -0
- package/build-types/components/page-attributes/parent.d.ts.map +1 -1
- package/build-types/components/post-taxonomies/flat-term-selector.d.ts +3 -5
- package/build-types/components/post-taxonomies/flat-term-selector.d.ts.map +1 -1
- package/build-types/components/post-taxonomies/index.d.ts.map +1 -1
- package/build-types/components/post-template/hooks.d.ts +1 -1
- package/build-types/components/post-template/hooks.d.ts.map +1 -1
- package/build-types/components/provider/use-block-editor-settings.d.ts.map +1 -1
- package/build-types/components/style-book/index.d.ts.map +1 -1
- package/build-types/dataviews/store/private-actions.d.ts.map +1 -1
- package/build-types/store/utils/notice-builder.d.ts.map +1 -1
- package/build-types/utils/get-template-part-icon.d.ts +3 -3
- package/build-types/utils/get-template-part-icon.d.ts.map +1 -1
- package/package.json +40 -40
- package/src/components/autocompleters/user.js +6 -0
- package/src/components/collab-sidebar/comments.js +16 -23
- package/src/components/collab-sidebar/hooks.js +7 -24
- package/src/components/document-bar/index.js +41 -9
- package/src/components/document-bar/useEditedSectionDetails.js +103 -0
- package/src/components/global-styles-sidebar/style.scss +0 -4
- package/src/components/page-attributes/parent.js +2 -1
- package/src/components/post-card-panel/index.js +1 -1
- package/src/components/post-publish-panel/maybe-tags-panel.js +1 -1
- package/src/components/post-taxonomies/flat-term-selector.js +6 -27
- package/src/components/post-taxonomies/index.js +1 -7
- package/src/components/provider/use-block-editor-settings.js +8 -0
- package/src/components/style-book/index.js +3 -5
- package/src/dataviews/store/private-actions.ts +16 -0
- package/src/store/utils/notice-builder.js +12 -4
- package/src/utils/get-template-part-icon.js +19 -6
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"private-actions.d.ts","sourceRoot":"","sources":["../../../src/dataviews/store/private-actions.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"private-actions.d.ts","sourceRoot":"","sources":["../../../src/dataviews/store/private-actions.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AA2C1D,OAAO,CAAC,MAAM,CAAC;IACd,UAAU,MAAM;QACf,8BAA8B,CAAC,EAAE,OAAO,CAAC;KACzC;CACD;AAgBD,wBAAgB,oBAAoB,CAAE,IAAI,EACzC,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM,CAAE,IAAI,CAAE;;;;;EAQtB;AAED,wBAAgB,sBAAsB,CACrC,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,MAAM;;;;;EAQhB;AAED,wBAAgB,mBAAmB,CAAE,IAAI,EACxC,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,KAAK,CAAE,IAAI,CAAE;;;;;EAQrB;AAED,wBAAgB,qBAAqB,CACpC,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,MAAM;;;;;EAQf;AAED,wBAAgB,UAAU,CAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM;;;;EAMrD;AAED,eAAO,MAAM,sBAAsB,GAChC,UAAU,MAAM,MACV,cAAc;IAAE,QAAQ,EAAE,GAAG,CAAA;CAAE,kBAoItC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"notice-builder.d.ts","sourceRoot":"","sources":["../../../src/store/utils/notice-builder.js"],"names":[],"mappings":"AAKA;;;;;;;GAOG;AACH,6DALW,MAAM,SA+DhB;AAED;;;;;;;GAOG;AACH,0DALW,MAAM,
|
|
1
|
+
{"version":3,"file":"notice-builder.d.ts","sourceRoot":"","sources":["../../../src/store/utils/notice-builder.js"],"names":[],"mappings":"AAKA;;;;;;;GAOG;AACH,6DALW,MAAM,SA+DhB;AAED;;;;;;;GAOG;AACH,0DALW,MAAM,SA+DhB;AAED;;;;;;GAMG;AACH,2DAJW,MAAM,SAahB"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Helper function to retrieve the corresponding icon by name.
|
|
2
|
+
* Helper function to retrieve the corresponding icon by area name or icon name.
|
|
3
3
|
*
|
|
4
|
-
* @param {string}
|
|
4
|
+
* @param {string} areaOrIconName The area name (e.g., 'header', 'overlay') or icon name (e.g., 'menu').
|
|
5
5
|
*
|
|
6
6
|
* @return {Object} The corresponding icon.
|
|
7
7
|
*/
|
|
8
|
-
export function getTemplatePartIcon(
|
|
8
|
+
export function getTemplatePartIcon(areaOrIconName: string): Object;
|
|
9
9
|
//# sourceMappingURL=get-template-part-icon.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-template-part-icon.d.ts","sourceRoot":"","sources":["../../src/utils/get-template-part-icon.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"get-template-part-icon.d.ts","sourceRoot":"","sources":["../../src/utils/get-template-part-icon.js"],"names":[],"mappings":"AAWA;;;;;;GAMG;AACH,oDAJW,MAAM,GAEL,MAAM,CAsBjB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wordpress/editor",
|
|
3
|
-
"version": "14.
|
|
3
|
+
"version": "14.37.0",
|
|
4
4
|
"description": "Enhanced block editor for WordPress posts.",
|
|
5
5
|
"author": "The WordPress Contributors",
|
|
6
6
|
"license": "GPL-2.0-or-later",
|
|
@@ -53,44 +53,44 @@
|
|
|
53
53
|
],
|
|
54
54
|
"dependencies": {
|
|
55
55
|
"@floating-ui/react-dom": "2.0.8",
|
|
56
|
-
"@wordpress/a11y": "^4.
|
|
57
|
-
"@wordpress/api-fetch": "^7.
|
|
58
|
-
"@wordpress/base-styles": "^6.
|
|
59
|
-
"@wordpress/blob": "^4.
|
|
60
|
-
"@wordpress/block-editor": "^15.
|
|
61
|
-
"@wordpress/blocks": "^15.
|
|
62
|
-
"@wordpress/commands": "^1.
|
|
63
|
-
"@wordpress/components": "^
|
|
64
|
-
"@wordpress/compose": "^7.
|
|
65
|
-
"@wordpress/core-data": "^7.
|
|
66
|
-
"@wordpress/data": "^10.
|
|
67
|
-
"@wordpress/dataviews": "^11.
|
|
68
|
-
"@wordpress/date": "^5.
|
|
69
|
-
"@wordpress/deprecated": "^4.
|
|
70
|
-
"@wordpress/dom": "^4.
|
|
71
|
-
"@wordpress/element": "^6.
|
|
72
|
-
"@wordpress/fields": "^0.
|
|
73
|
-
"@wordpress/global-styles-engine": "^1.
|
|
74
|
-
"@wordpress/global-styles-ui": "^1.
|
|
75
|
-
"@wordpress/hooks": "^4.
|
|
76
|
-
"@wordpress/html-entities": "^4.
|
|
77
|
-
"@wordpress/i18n": "^6.
|
|
78
|
-
"@wordpress/icons": "^11.
|
|
79
|
-
"@wordpress/interface": "^9.
|
|
80
|
-
"@wordpress/keyboard-shortcuts": "^5.
|
|
81
|
-
"@wordpress/keycodes": "^4.
|
|
82
|
-
"@wordpress/media-utils": "^5.
|
|
83
|
-
"@wordpress/notices": "^5.
|
|
84
|
-
"@wordpress/patterns": "^2.
|
|
85
|
-
"@wordpress/plugins": "^7.
|
|
86
|
-
"@wordpress/preferences": "^4.
|
|
87
|
-
"@wordpress/private-apis": "^1.
|
|
88
|
-
"@wordpress/reusable-blocks": "^5.
|
|
89
|
-
"@wordpress/rich-text": "^7.
|
|
90
|
-
"@wordpress/server-side-render": "^6.
|
|
91
|
-
"@wordpress/url": "^4.
|
|
92
|
-
"@wordpress/warning": "^3.
|
|
93
|
-
"@wordpress/wordcount": "^4.
|
|
56
|
+
"@wordpress/a11y": "^4.37.0",
|
|
57
|
+
"@wordpress/api-fetch": "^7.37.0",
|
|
58
|
+
"@wordpress/base-styles": "^6.13.0",
|
|
59
|
+
"@wordpress/blob": "^4.37.0",
|
|
60
|
+
"@wordpress/block-editor": "^15.10.0",
|
|
61
|
+
"@wordpress/blocks": "^15.10.0",
|
|
62
|
+
"@wordpress/commands": "^1.37.0",
|
|
63
|
+
"@wordpress/components": "^31.0.0",
|
|
64
|
+
"@wordpress/compose": "^7.37.0",
|
|
65
|
+
"@wordpress/core-data": "^7.37.0",
|
|
66
|
+
"@wordpress/data": "^10.37.0",
|
|
67
|
+
"@wordpress/dataviews": "^11.1.0",
|
|
68
|
+
"@wordpress/date": "^5.37.0",
|
|
69
|
+
"@wordpress/deprecated": "^4.37.0",
|
|
70
|
+
"@wordpress/dom": "^4.37.0",
|
|
71
|
+
"@wordpress/element": "^6.37.0",
|
|
72
|
+
"@wordpress/fields": "^0.29.0",
|
|
73
|
+
"@wordpress/global-styles-engine": "^1.4.0",
|
|
74
|
+
"@wordpress/global-styles-ui": "^1.4.0",
|
|
75
|
+
"@wordpress/hooks": "^4.37.0",
|
|
76
|
+
"@wordpress/html-entities": "^4.37.0",
|
|
77
|
+
"@wordpress/i18n": "^6.10.0",
|
|
78
|
+
"@wordpress/icons": "^11.4.0",
|
|
79
|
+
"@wordpress/interface": "^9.22.0",
|
|
80
|
+
"@wordpress/keyboard-shortcuts": "^5.37.0",
|
|
81
|
+
"@wordpress/keycodes": "^4.37.0",
|
|
82
|
+
"@wordpress/media-utils": "^5.37.0",
|
|
83
|
+
"@wordpress/notices": "^5.37.0",
|
|
84
|
+
"@wordpress/patterns": "^2.37.0",
|
|
85
|
+
"@wordpress/plugins": "^7.37.0",
|
|
86
|
+
"@wordpress/preferences": "^4.37.0",
|
|
87
|
+
"@wordpress/private-apis": "^1.37.0",
|
|
88
|
+
"@wordpress/reusable-blocks": "^5.37.0",
|
|
89
|
+
"@wordpress/rich-text": "^7.37.0",
|
|
90
|
+
"@wordpress/server-side-render": "^6.13.0",
|
|
91
|
+
"@wordpress/url": "^4.37.0",
|
|
92
|
+
"@wordpress/warning": "^3.37.0",
|
|
93
|
+
"@wordpress/wordcount": "^4.37.0",
|
|
94
94
|
"change-case": "^4.1.2",
|
|
95
95
|
"client-zip": "^2.4.5",
|
|
96
96
|
"clsx": "^2.1.1",
|
|
@@ -108,5 +108,5 @@
|
|
|
108
108
|
"publishConfig": {
|
|
109
109
|
"access": "public"
|
|
110
110
|
},
|
|
111
|
-
"gitHead": "
|
|
111
|
+
"gitHead": "2cf13ec6cf86153c9b3cf369bf5c59046f5cd950"
|
|
112
112
|
}
|
|
@@ -5,6 +5,12 @@ import { useMemo } from '@wordpress/element';
|
|
|
5
5
|
import { useSelect } from '@wordpress/data';
|
|
6
6
|
import { store as coreStore } from '@wordpress/core-data';
|
|
7
7
|
|
|
8
|
+
/**
|
|
9
|
+
* Renders a user label for the autocompleter.
|
|
10
|
+
*
|
|
11
|
+
* @param {Object} user User object.
|
|
12
|
+
* @return {JSX.Element} User label component.
|
|
13
|
+
*/
|
|
8
14
|
export function getUserLabel( user ) {
|
|
9
15
|
const avatar =
|
|
10
16
|
user.avatar_urls && user.avatar_urls[ 24 ] ? (
|
|
@@ -70,28 +70,22 @@ export function Comments( {
|
|
|
70
70
|
useDispatch( blockEditorStore )
|
|
71
71
|
);
|
|
72
72
|
|
|
73
|
-
const {
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
: null,
|
|
90
|
-
selectedBlockClientId: clientId,
|
|
91
|
-
orderedBlockIds: getClientIdsWithDescendants(),
|
|
92
|
-
blockMode: clientId ? getBlockMode( clientId ) : null,
|
|
93
|
-
};
|
|
94
|
-
}, [] );
|
|
73
|
+
const { blockCommentId, selectedBlockClientId, orderedBlockIds } =
|
|
74
|
+
useSelect( ( select ) => {
|
|
75
|
+
const {
|
|
76
|
+
getBlockAttributes,
|
|
77
|
+
getSelectedBlockClientId,
|
|
78
|
+
getClientIdsWithDescendants,
|
|
79
|
+
} = select( blockEditorStore );
|
|
80
|
+
const clientId = getSelectedBlockClientId();
|
|
81
|
+
return {
|
|
82
|
+
blockCommentId: clientId
|
|
83
|
+
? getBlockAttributes( clientId )?.metadata?.noteId
|
|
84
|
+
: null,
|
|
85
|
+
selectedBlockClientId: clientId,
|
|
86
|
+
orderedBlockIds: getClientIdsWithDescendants(),
|
|
87
|
+
};
|
|
88
|
+
}, [] );
|
|
95
89
|
|
|
96
90
|
const relatedBlockElement = useBlockElement( selectedBlockClientId );
|
|
97
91
|
|
|
@@ -318,7 +312,6 @@ export function Comments( {
|
|
|
318
312
|
threads,
|
|
319
313
|
selectedThread,
|
|
320
314
|
setCanvasMinHeight,
|
|
321
|
-
blockMode,
|
|
322
315
|
] );
|
|
323
316
|
|
|
324
317
|
const handleThreadNavigation = ( event, thread, isSelected ) => {
|
|
@@ -14,7 +14,6 @@ import { __ } from '@wordpress/i18n';
|
|
|
14
14
|
import {
|
|
15
15
|
useEffect,
|
|
16
16
|
useMemo,
|
|
17
|
-
useRef,
|
|
18
17
|
useCallback,
|
|
19
18
|
useReducer,
|
|
20
19
|
} from '@wordpress/element';
|
|
@@ -36,9 +35,7 @@ import { collabSidebarName } from './constants';
|
|
|
36
35
|
import { unlock } from '../../lock-unlock';
|
|
37
36
|
import { noop } from './utils';
|
|
38
37
|
|
|
39
|
-
const {
|
|
40
|
-
blockEditorPrivateApis
|
|
41
|
-
);
|
|
38
|
+
const { useBlockElement, cleanEmptyObject } = unlock( blockEditorPrivateApis );
|
|
42
39
|
|
|
43
40
|
export function useBlockComments( postId ) {
|
|
44
41
|
const [ commentLastUpdated, reflowComments ] = useReducer(
|
|
@@ -369,20 +366,7 @@ export function useFloatingThread( {
|
|
|
369
366
|
setBlockRef,
|
|
370
367
|
commentLastUpdated,
|
|
371
368
|
} ) {
|
|
372
|
-
const
|
|
373
|
-
useBlockElementRef( thread.blockClientId, blockRef );
|
|
374
|
-
|
|
375
|
-
const blockMode = useSelect(
|
|
376
|
-
( select ) => {
|
|
377
|
-
return thread.blockClientId
|
|
378
|
-
? select( blockEditorStore ).getBlockMode(
|
|
379
|
-
thread.blockClientId
|
|
380
|
-
)
|
|
381
|
-
: null;
|
|
382
|
-
},
|
|
383
|
-
[ thread.blockClientId ]
|
|
384
|
-
);
|
|
385
|
-
|
|
369
|
+
const blockElement = useBlockElement( thread.blockClientId );
|
|
386
370
|
const updateHeight = useCallback(
|
|
387
371
|
( id, newHeight ) => {
|
|
388
372
|
setHeights( ( prev ) => {
|
|
@@ -408,17 +392,17 @@ export function useFloatingThread( {
|
|
|
408
392
|
|
|
409
393
|
// Store the block reference for each thread.
|
|
410
394
|
useEffect( () => {
|
|
411
|
-
if (
|
|
412
|
-
refs.setReference(
|
|
395
|
+
if ( blockElement ) {
|
|
396
|
+
refs.setReference( blockElement );
|
|
413
397
|
}
|
|
414
|
-
}, [
|
|
398
|
+
}, [ blockElement, refs, commentLastUpdated ] );
|
|
415
399
|
|
|
416
400
|
// Track thread heights.
|
|
417
401
|
useEffect( () => {
|
|
418
402
|
if ( refs.floating?.current ) {
|
|
419
|
-
setBlockRef( thread.id,
|
|
403
|
+
setBlockRef( thread.id, blockElement );
|
|
420
404
|
}
|
|
421
|
-
}, [ thread.id, refs.floating, setBlockRef ] );
|
|
405
|
+
}, [ blockElement, thread.id, refs.floating, setBlockRef ] );
|
|
422
406
|
|
|
423
407
|
// When the selected thread changes, update heights, triggering offset recalculation.
|
|
424
408
|
useEffect( () => {
|
|
@@ -435,7 +419,6 @@ export function useFloatingThread( {
|
|
|
435
419
|
] );
|
|
436
420
|
|
|
437
421
|
return {
|
|
438
|
-
blockRef,
|
|
439
422
|
y,
|
|
440
423
|
refs,
|
|
441
424
|
};
|
|
@@ -14,7 +14,7 @@ import {
|
|
|
14
14
|
__unstableMotion as motion,
|
|
15
15
|
__unstableAnimatePresence as AnimatePresence,
|
|
16
16
|
} from '@wordpress/components';
|
|
17
|
-
import { BlockIcon } from '@wordpress/block-editor';
|
|
17
|
+
import { BlockIcon, store as blockEditorStore } from '@wordpress/block-editor';
|
|
18
18
|
import { chevronLeftSmall, chevronRightSmall, layout } from '@wordpress/icons';
|
|
19
19
|
import { displayShortcut } from '@wordpress/keycodes';
|
|
20
20
|
import { store as coreStore } from '@wordpress/core-data';
|
|
@@ -33,6 +33,7 @@ import usePageTypeBadge from '../../utils/pageTypeBadge';
|
|
|
33
33
|
import { getTemplateInfo } from '../../utils/get-template-info';
|
|
34
34
|
import { getStylesCanvasTitle } from '../styles-canvas';
|
|
35
35
|
import { unlock } from '../../lock-unlock';
|
|
36
|
+
import useEditedSectionDetails from './useEditedSectionDetails';
|
|
36
37
|
|
|
37
38
|
/** @typedef {import("@wordpress/components").IconType} IconType */
|
|
38
39
|
|
|
@@ -56,6 +57,14 @@ const MotionButton = motion.create( Button );
|
|
|
56
57
|
* @return {React.ReactNode} The rendered DocumentBar component.
|
|
57
58
|
*/
|
|
58
59
|
export default function DocumentBar( props ) {
|
|
60
|
+
// Get action to lock the pattern design
|
|
61
|
+
const { stopEditingContentOnlySection } = unlock(
|
|
62
|
+
useDispatch( blockEditorStore )
|
|
63
|
+
);
|
|
64
|
+
|
|
65
|
+
// Get details about the currently edited content-only section
|
|
66
|
+
const unlockedPatternInfo = useEditedSectionDetails();
|
|
67
|
+
|
|
59
68
|
const {
|
|
60
69
|
postId,
|
|
61
70
|
postType,
|
|
@@ -133,11 +142,28 @@ export default function DocumentBar( props ) {
|
|
|
133
142
|
const isReducedMotion = useReducedMotion();
|
|
134
143
|
|
|
135
144
|
const isTemplate = TEMPLATE_POST_TYPES.includes( postType );
|
|
136
|
-
const hasBackButton =
|
|
145
|
+
const hasBackButton =
|
|
146
|
+
!! onNavigateToPreviousEntityRecord || !! unlockedPatternInfo;
|
|
137
147
|
const entityTitle = isTemplate ? templateTitle : documentTitle;
|
|
138
|
-
|
|
148
|
+
|
|
149
|
+
// Use pattern info if a pattern block is unlocked, otherwise use document/entity info
|
|
150
|
+
const title =
|
|
151
|
+
unlockedPatternInfo?.patternTitle ||
|
|
152
|
+
props.title ||
|
|
153
|
+
stylesCanvasTitle ||
|
|
154
|
+
entityTitle;
|
|
139
155
|
const icon = props.icon;
|
|
140
156
|
|
|
157
|
+
// Determine the back button action
|
|
158
|
+
const handleBackClick = ( event ) => {
|
|
159
|
+
event.stopPropagation();
|
|
160
|
+
if ( unlockedPatternInfo ) {
|
|
161
|
+
stopEditingContentOnlySection();
|
|
162
|
+
} else if ( onNavigateToPreviousEntityRecord ) {
|
|
163
|
+
onNavigateToPreviousEntityRecord();
|
|
164
|
+
}
|
|
165
|
+
};
|
|
166
|
+
|
|
141
167
|
const pageTypeBadge = usePageTypeBadge( postId );
|
|
142
168
|
|
|
143
169
|
const mountedRef = useRef( false );
|
|
@@ -156,10 +182,7 @@ export default function DocumentBar( props ) {
|
|
|
156
182
|
<MotionButton
|
|
157
183
|
className="editor-document-bar__back"
|
|
158
184
|
icon={ isRTL() ? chevronRightSmall : chevronLeftSmall }
|
|
159
|
-
onClick={
|
|
160
|
-
event.stopPropagation();
|
|
161
|
-
onNavigateToPreviousEntityRecord();
|
|
162
|
-
} }
|
|
185
|
+
onClick={ handleBackClick }
|
|
163
186
|
size="compact"
|
|
164
187
|
initial={
|
|
165
188
|
mountedRef.current
|
|
@@ -219,12 +242,21 @@ export default function DocumentBar( props ) {
|
|
|
219
242
|
? stripHTML( title )
|
|
220
243
|
: __( 'No title' ) }
|
|
221
244
|
</span>
|
|
222
|
-
{
|
|
245
|
+
{ unlockedPatternInfo && (
|
|
246
|
+
<span className="editor-document-bar__post-type-label">
|
|
247
|
+
{ unlockedPatternInfo.type ===
|
|
248
|
+
'template-part'
|
|
249
|
+
? `· ${ __( 'Template Part' ) }`
|
|
250
|
+
: `· ${ __( 'Pattern' ) }` }
|
|
251
|
+
</span>
|
|
252
|
+
) }
|
|
253
|
+
{ ! unlockedPatternInfo && pageTypeBadge && (
|
|
223
254
|
<span className="editor-document-bar__post-type-label">
|
|
224
255
|
{ `· ${ pageTypeBadge }` }
|
|
225
256
|
</span>
|
|
226
257
|
) }
|
|
227
|
-
{
|
|
258
|
+
{ ! unlockedPatternInfo &&
|
|
259
|
+
postTypeLabel &&
|
|
228
260
|
! props.title &&
|
|
229
261
|
! pageTypeBadge && (
|
|
230
262
|
<span className="editor-document-bar__post-type-label">
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { useSelect } from '@wordpress/data';
|
|
5
|
+
import { decodeEntities } from '@wordpress/html-entities';
|
|
6
|
+
import { store as blockEditorStore } from '@wordpress/block-editor';
|
|
7
|
+
import { store as coreStore } from '@wordpress/core-data';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Internal dependencies
|
|
11
|
+
*/
|
|
12
|
+
import { unlock } from '../../lock-unlock';
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Hook to get details about the currently edited content-only section.
|
|
16
|
+
* Only returns information when the content only pattern insertion experiment is enabled.
|
|
17
|
+
*
|
|
18
|
+
* @return {Object|null} Object with patternName, patternTitle, and type, or null if no section is being edited or experiment is disabled.
|
|
19
|
+
*/
|
|
20
|
+
export default function useEditedSectionDetails() {
|
|
21
|
+
return useSelect( ( select ) => {
|
|
22
|
+
// Only run when the content only pattern insertion experiment is enabled
|
|
23
|
+
if ( ! window?.__experimentalContentOnlyPatternInsertion ) {
|
|
24
|
+
return null;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const {
|
|
28
|
+
getBlockAttributes,
|
|
29
|
+
getBlockName,
|
|
30
|
+
__experimentalGetParsedPattern,
|
|
31
|
+
} = select( blockEditorStore );
|
|
32
|
+
const { getEditedEntityRecord, getCurrentTheme } = select( coreStore );
|
|
33
|
+
const { getEditedContentOnlySection } = unlock(
|
|
34
|
+
select( blockEditorStore )
|
|
35
|
+
);
|
|
36
|
+
|
|
37
|
+
// Get the clientId of the unlocked pattern/section
|
|
38
|
+
const editedSectionId = getEditedContentOnlySection();
|
|
39
|
+
if ( ! editedSectionId ) {
|
|
40
|
+
return null;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const attributes = getBlockAttributes( editedSectionId );
|
|
44
|
+
|
|
45
|
+
// Handle unsynced patterns (contentOnly patterns with patternName)
|
|
46
|
+
const patternName = attributes?.metadata?.patternName;
|
|
47
|
+
if ( patternName ) {
|
|
48
|
+
// Get pattern details if available
|
|
49
|
+
const pattern =
|
|
50
|
+
typeof __experimentalGetParsedPattern === 'function'
|
|
51
|
+
? __experimentalGetParsedPattern( patternName )
|
|
52
|
+
: null;
|
|
53
|
+
|
|
54
|
+
return {
|
|
55
|
+
patternName,
|
|
56
|
+
patternTitle: pattern?.title || attributes?.metadata?.name,
|
|
57
|
+
type: 'pattern',
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
const blockName = getBlockName( editedSectionId );
|
|
62
|
+
|
|
63
|
+
// Handle synced patterns (core/block)
|
|
64
|
+
if ( blockName === 'core/block' && !! attributes?.ref ) {
|
|
65
|
+
const entity = getEditedEntityRecord(
|
|
66
|
+
'postType',
|
|
67
|
+
'wp_block',
|
|
68
|
+
attributes.ref
|
|
69
|
+
);
|
|
70
|
+
if ( entity?.title ) {
|
|
71
|
+
return {
|
|
72
|
+
patternName: attributes.ref,
|
|
73
|
+
patternTitle: decodeEntities( entity.title ),
|
|
74
|
+
type: 'synced-pattern',
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
// Handle template parts (core/template-part)
|
|
80
|
+
if ( blockName === 'core/template-part' && !! attributes?.slug ) {
|
|
81
|
+
const theme = attributes.theme || getCurrentTheme()?.stylesheet;
|
|
82
|
+
const templatePartId = theme
|
|
83
|
+
? `${ theme }//${ attributes.slug }`
|
|
84
|
+
: null;
|
|
85
|
+
if ( templatePartId ) {
|
|
86
|
+
const entity = getEditedEntityRecord(
|
|
87
|
+
'postType',
|
|
88
|
+
'wp_template_part',
|
|
89
|
+
templatePartId
|
|
90
|
+
);
|
|
91
|
+
if ( entity?.title ) {
|
|
92
|
+
return {
|
|
93
|
+
patternName: attributes.slug,
|
|
94
|
+
patternTitle: decodeEntities( entity.title ),
|
|
95
|
+
type: 'template-part',
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
return null;
|
|
102
|
+
}, [] );
|
|
103
|
+
}
|
|
@@ -91,9 +91,10 @@ export function PageAttributesParent() {
|
|
|
91
91
|
_fields: 'id,title,parent',
|
|
92
92
|
};
|
|
93
93
|
|
|
94
|
-
// Perform a search when the field is changed.
|
|
94
|
+
// Perform a search by relevance when the field is changed.
|
|
95
95
|
if ( !! fieldValue ) {
|
|
96
96
|
query.search = fieldValue;
|
|
97
|
+
query.orderby = 'relevance';
|
|
97
98
|
}
|
|
98
99
|
|
|
99
100
|
const parentPost = pageId
|
|
@@ -2,14 +2,13 @@
|
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
4
|
import { __, _x, sprintf } from '@wordpress/i18n';
|
|
5
|
-
import {
|
|
5
|
+
import { useEffect, useMemo, useState } from '@wordpress/element';
|
|
6
6
|
import {
|
|
7
7
|
FormTokenField,
|
|
8
8
|
withFilters,
|
|
9
9
|
__experimentalVStack as VStack,
|
|
10
10
|
} from '@wordpress/components';
|
|
11
11
|
import { useSelect, useDispatch } from '@wordpress/data';
|
|
12
|
-
import deprecated from '@wordpress/deprecated';
|
|
13
12
|
import { store as coreStore } from '@wordpress/core-data';
|
|
14
13
|
import { useDebounce } from '@wordpress/compose';
|
|
15
14
|
import { speak } from '@wordpress/a11y';
|
|
@@ -57,38 +56,19 @@ const termNamesToIds = ( names, terms ) => {
|
|
|
57
56
|
.filter( ( id ) => id !== undefined );
|
|
58
57
|
};
|
|
59
58
|
|
|
60
|
-
const Wrapper = ( { children, __nextHasNoMarginBottom } ) =>
|
|
61
|
-
__nextHasNoMarginBottom ? (
|
|
62
|
-
<VStack spacing={ 4 }>{ children }</VStack>
|
|
63
|
-
) : (
|
|
64
|
-
<Fragment>{ children }</Fragment>
|
|
65
|
-
);
|
|
66
|
-
|
|
67
59
|
/**
|
|
68
60
|
* Renders a flat term selector component.
|
|
69
61
|
*
|
|
70
|
-
* @param {Object}
|
|
71
|
-
* @param {string}
|
|
72
|
-
* @param {boolean} props.__nextHasNoMarginBottom Start opting into the new margin-free styles that will become the default in a future version, currently scheduled to be WordPress 7.0. (The prop can be safely removed once this happens.)
|
|
62
|
+
* @param {Object} props The component props.
|
|
63
|
+
* @param {string} props.slug The slug of the taxonomy.
|
|
73
64
|
*
|
|
74
65
|
* @return {React.ReactNode} The rendered flat term selector component.
|
|
75
66
|
*/
|
|
76
|
-
export function FlatTermSelector( { slug
|
|
67
|
+
export function FlatTermSelector( { slug } ) {
|
|
77
68
|
const [ values, setValues ] = useState( [] );
|
|
78
69
|
const [ search, setSearch ] = useState( '' );
|
|
79
70
|
const debouncedSearch = useDebounce( setSearch, 500 );
|
|
80
71
|
|
|
81
|
-
if ( ! __nextHasNoMarginBottom ) {
|
|
82
|
-
deprecated(
|
|
83
|
-
'Bottom margin styles for wp.editor.PostTaxonomiesFlatTermSelector',
|
|
84
|
-
{
|
|
85
|
-
since: '6.7',
|
|
86
|
-
version: '7.0',
|
|
87
|
-
hint: 'Set the `__nextHasNoMarginBottom` prop to true to start opting into the new styles, which will become the default in a future version.',
|
|
88
|
-
}
|
|
89
|
-
);
|
|
90
|
-
}
|
|
91
|
-
|
|
92
72
|
const {
|
|
93
73
|
terms,
|
|
94
74
|
termIds,
|
|
@@ -300,7 +280,7 @@ export function FlatTermSelector( { slug, __nextHasNoMarginBottom } ) {
|
|
|
300
280
|
);
|
|
301
281
|
|
|
302
282
|
return (
|
|
303
|
-
<
|
|
283
|
+
<VStack spacing={ 4 }>
|
|
304
284
|
<FormTokenField
|
|
305
285
|
__next40pxDefaultSize
|
|
306
286
|
value={ values }
|
|
@@ -314,10 +294,9 @@ export function FlatTermSelector( { slug, __nextHasNoMarginBottom } ) {
|
|
|
314
294
|
removed: termRemovedLabel,
|
|
315
295
|
remove: removeTermLabel,
|
|
316
296
|
} }
|
|
317
|
-
__nextHasNoMarginBottom={ __nextHasNoMarginBottom }
|
|
318
297
|
/>
|
|
319
298
|
<MostUsedTerms taxonomy={ taxonomy } onSelect={ appendTerm } />
|
|
320
|
-
</
|
|
299
|
+
</VStack>
|
|
321
300
|
);
|
|
322
301
|
}
|
|
323
302
|
|
|
@@ -36,17 +36,11 @@ export function PostTaxonomies( { taxonomyWrapper = identity } ) {
|
|
|
36
36
|
const TaxonomyComponent = taxonomy.hierarchical
|
|
37
37
|
? HierarchicalTermSelector
|
|
38
38
|
: FlatTermSelector;
|
|
39
|
-
const taxonomyComponentProps = {
|
|
40
|
-
slug: taxonomy.slug,
|
|
41
|
-
...( taxonomy.hierarchical
|
|
42
|
-
? {}
|
|
43
|
-
: { __nextHasNoMarginBottom: true } ),
|
|
44
|
-
};
|
|
45
39
|
|
|
46
40
|
return (
|
|
47
41
|
<Fragment key={ `taxonomy-${ taxonomy.slug }` }>
|
|
48
42
|
{ taxonomyWrapper(
|
|
49
|
-
<TaxonomyComponent {
|
|
43
|
+
<TaxonomyComponent slug={ taxonomy.slug } />,
|
|
50
44
|
taxonomy
|
|
51
45
|
) }
|
|
52
46
|
</Fragment>
|
|
@@ -97,6 +97,7 @@ const {
|
|
|
97
97
|
sectionRootClientIdKey,
|
|
98
98
|
mediaEditKey,
|
|
99
99
|
getMediaSelectKey,
|
|
100
|
+
isIsolatedEditorKey,
|
|
100
101
|
} = unlock( privateApis );
|
|
101
102
|
|
|
102
103
|
/**
|
|
@@ -348,6 +349,13 @@ function useBlockEditorSettings( settings, postType, postId, renderingMode ) {
|
|
|
348
349
|
renderingMode === 'post-only' && postType !== 'wp_template'
|
|
349
350
|
? 'edit'
|
|
350
351
|
: undefined,
|
|
352
|
+
// When editing template parts, patterns, or navigation directly,
|
|
353
|
+
// we're in an isolated editing context (focused on that entity alone).
|
|
354
|
+
[ isIsolatedEditorKey ]: [
|
|
355
|
+
'wp_template_part',
|
|
356
|
+
'wp_block',
|
|
357
|
+
'wp_navigation',
|
|
358
|
+
].includes( postType ),
|
|
351
359
|
};
|
|
352
360
|
|
|
353
361
|
return blockEditorSettings;
|
|
@@ -597,12 +597,10 @@ export const StyleBookBody = ( {
|
|
|
597
597
|
|
|
598
598
|
const handleLoad = () => setHasIframeLoaded( true );
|
|
599
599
|
useLayoutEffect( () => {
|
|
600
|
-
if ( hasIframeLoaded && iframeRef
|
|
601
|
-
|
|
602
|
-
scrollToSection( 'top', iframeRef?.current );
|
|
603
|
-
}
|
|
600
|
+
if ( hasIframeLoaded && iframeRef.current && goTo?.top ) {
|
|
601
|
+
scrollToSection( 'top', iframeRef.current );
|
|
604
602
|
}
|
|
605
|
-
}, [
|
|
603
|
+
}, [ goTo?.top, hasIframeLoaded ] );
|
|
606
604
|
|
|
607
605
|
return (
|
|
608
606
|
<Iframe
|