@wordpress/edit-post 7.5.0 → 7.6.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/build/components/header/header-toolbar/index.native.js +5 -0
- package/build/components/header/header-toolbar/index.native.js.map +1 -1
- package/build/components/header/post-publish-button-or-toggle.js +13 -15
- package/build/components/header/post-publish-button-or-toggle.js.map +1 -1
- package/build/components/header/template-title/edit-template-title.js +6 -8
- package/build/components/header/template-title/edit-template-title.js.map +1 -1
- package/build/components/header/tools-more-menu-group/index.js +1 -7
- package/build/components/header/tools-more-menu-group/index.js.map +1 -1
- package/build/components/layout/index.js +6 -7
- package/build/components/layout/index.js.map +1 -1
- package/build/components/preferences-modal/index.js +1 -7
- package/build/components/preferences-modal/index.js.map +1 -1
- package/build/components/sidebar/post-taxonomies/taxonomy-panel.js +6 -8
- package/build/components/sidebar/post-taxonomies/taxonomy-panel.js.map +1 -1
- package/build/components/sidebar/post-template/create-modal.js +1 -1
- package/build/components/sidebar/post-template/create-modal.js.map +1 -1
- package/build/components/visual-editor/index.js +26 -23
- package/build/components/visual-editor/index.js.map +1 -1
- package/build/components/welcome-guide/default.js +1 -1
- package/build/components/welcome-guide/default.js.map +1 -1
- package/build/index.js +3 -0
- package/build/index.js.map +1 -1
- package/build-module/components/header/header-toolbar/index.native.js +6 -0
- package/build-module/components/header/header-toolbar/index.native.js.map +1 -1
- package/build-module/components/header/post-publish-button-or-toggle.js +13 -14
- package/build-module/components/header/post-publish-button-or-toggle.js.map +1 -1
- package/build-module/components/header/template-title/edit-template-title.js +6 -7
- package/build-module/components/header/template-title/edit-template-title.js.map +1 -1
- package/build-module/components/header/tools-more-menu-group/index.js +1 -6
- package/build-module/components/header/tools-more-menu-group/index.js.map +1 -1
- package/build-module/components/layout/index.js +6 -7
- package/build-module/components/layout/index.js.map +1 -1
- package/build-module/components/preferences-modal/index.js +1 -6
- package/build-module/components/preferences-modal/index.js.map +1 -1
- package/build-module/components/sidebar/post-taxonomies/taxonomy-panel.js +6 -7
- package/build-module/components/sidebar/post-taxonomies/taxonomy-panel.js.map +1 -1
- package/build-module/components/sidebar/post-template/create-modal.js +1 -1
- package/build-module/components/sidebar/post-template/create-modal.js.map +1 -1
- package/build-module/components/visual-editor/index.js +26 -23
- package/build-module/components/visual-editor/index.js.map +1 -1
- package/build-module/components/welcome-guide/default.js +1 -1
- package/build-module/components/welcome-guide/default.js.map +1 -1
- package/build-module/index.js +4 -1
- package/build-module/index.js.map +1 -1
- package/build-style/style-rtl.css +4 -0
- package/build-style/style.css +4 -0
- package/package.json +30 -31
- package/src/components/header/header-toolbar/index.native.js +5 -0
- package/src/components/header/post-publish-button-or-toggle.js +4 -10
- package/src/components/header/template-title/edit-template-title.js +8 -12
- package/src/components/header/tools-more-menu-group/index.js +1 -6
- package/src/components/layout/index.js +6 -8
- package/src/components/preferences-modal/index.js +1 -9
- package/src/components/preferences-modal/test/__snapshots__/index.js.snap +1 -1
- package/src/components/sidebar/post-taxonomies/taxonomy-panel.js +2 -7
- package/src/components/sidebar/post-template/create-modal.js +1 -1
- package/src/components/visual-editor/index.js +31 -21
- package/src/components/welcome-guide/default.js +1 -1
- package/src/index.js +5 -1
- package/src/test/editor.native.js +1 -1
|
@@ -80,19 +80,20 @@ function MaybeIframe( { children, contentRef, shouldIframe, styles, style } ) {
|
|
|
80
80
|
|
|
81
81
|
/**
|
|
82
82
|
* Given an array of nested blocks, find the first Post Content
|
|
83
|
-
* block inside it, recursing through any nesting levels
|
|
83
|
+
* block inside it, recursing through any nesting levels,
|
|
84
|
+
* and return its attributes.
|
|
84
85
|
*
|
|
85
86
|
* @param {Array} blocks A list of blocks.
|
|
86
87
|
*
|
|
87
88
|
* @return {Object | undefined} The Post Content block.
|
|
88
89
|
*/
|
|
89
|
-
function
|
|
90
|
+
function getPostContentAttributes( blocks ) {
|
|
90
91
|
for ( let i = 0; i < blocks.length; i++ ) {
|
|
91
92
|
if ( blocks[ i ].name === 'core/post-content' ) {
|
|
92
|
-
return blocks[ i ];
|
|
93
|
+
return blocks[ i ].attributes;
|
|
93
94
|
}
|
|
94
95
|
if ( blocks[ i ].innerBlocks.length ) {
|
|
95
|
-
const nestedPostContent =
|
|
96
|
+
const nestedPostContent = getPostContentAttributes(
|
|
96
97
|
blocks[ i ].innerBlocks
|
|
97
98
|
);
|
|
98
99
|
|
|
@@ -108,6 +109,7 @@ export default function VisualEditor( { styles } ) {
|
|
|
108
109
|
deviceType,
|
|
109
110
|
isWelcomeGuideVisible,
|
|
110
111
|
isTemplateMode,
|
|
112
|
+
postContentAttributes,
|
|
111
113
|
editedPostTemplate = {},
|
|
112
114
|
wrapperBlockName,
|
|
113
115
|
wrapperUniqueId,
|
|
@@ -116,8 +118,8 @@ export default function VisualEditor( { styles } ) {
|
|
|
116
118
|
const {
|
|
117
119
|
isFeatureActive,
|
|
118
120
|
isEditingTemplate,
|
|
119
|
-
__experimentalGetPreviewDeviceType,
|
|
120
121
|
getEditedPostTemplate,
|
|
122
|
+
__experimentalGetPreviewDeviceType,
|
|
121
123
|
} = select( editPostStore );
|
|
122
124
|
const { getCurrentPostId, getCurrentPostType, getEditorSettings } =
|
|
123
125
|
select( editorStore );
|
|
@@ -141,8 +143,9 @@ export default function VisualEditor( { styles } ) {
|
|
|
141
143
|
deviceType: __experimentalGetPreviewDeviceType(),
|
|
142
144
|
isWelcomeGuideVisible: isFeatureActive( 'welcomeGuide' ),
|
|
143
145
|
isTemplateMode: _isTemplateMode,
|
|
146
|
+
postContentAttributes: getEditorSettings().postContentAttributes,
|
|
144
147
|
// Post template fetch returns a 404 on classic themes, which
|
|
145
|
-
// messes with e2e tests, so
|
|
148
|
+
// messes with e2e tests, so check it's a block theme first.
|
|
146
149
|
editedPostTemplate:
|
|
147
150
|
supportsTemplateMode && canEditTemplate
|
|
148
151
|
? getEditedPostTemplate()
|
|
@@ -230,10 +233,13 @@ export default function VisualEditor( { styles } ) {
|
|
|
230
233
|
return { type: 'default' };
|
|
231
234
|
}, [ isTemplateMode, themeSupportsLayout, globalLayoutSettings ] );
|
|
232
235
|
|
|
233
|
-
const
|
|
236
|
+
const newestPostContentAttributes = useMemo( () => {
|
|
237
|
+
if ( ! editedPostTemplate?.content && ! editedPostTemplate?.blocks ) {
|
|
238
|
+
return postContentAttributes;
|
|
239
|
+
}
|
|
234
240
|
// When in template editing mode, we can access the blocks directly.
|
|
235
241
|
if ( editedPostTemplate?.blocks ) {
|
|
236
|
-
return
|
|
242
|
+
return getPostContentAttributes( editedPostTemplate?.blocks );
|
|
237
243
|
}
|
|
238
244
|
// If there are no blocks, we have to parse the content string.
|
|
239
245
|
// Best double-check it's a string otherwise the parse function gets unhappy.
|
|
@@ -242,10 +248,19 @@ export default function VisualEditor( { styles } ) {
|
|
|
242
248
|
? editedPostTemplate?.content
|
|
243
249
|
: '';
|
|
244
250
|
|
|
245
|
-
return
|
|
246
|
-
}, [
|
|
251
|
+
return getPostContentAttributes( parse( parseableContent ) ) || {};
|
|
252
|
+
}, [
|
|
253
|
+
editedPostTemplate?.content,
|
|
254
|
+
editedPostTemplate?.blocks,
|
|
255
|
+
postContentAttributes,
|
|
256
|
+
] );
|
|
257
|
+
|
|
258
|
+
const layout = newestPostContentAttributes?.layout || {};
|
|
247
259
|
|
|
248
|
-
const postContentLayoutClasses = useLayoutClasses(
|
|
260
|
+
const postContentLayoutClasses = useLayoutClasses(
|
|
261
|
+
newestPostContentAttributes,
|
|
262
|
+
'core/post-content'
|
|
263
|
+
);
|
|
249
264
|
|
|
250
265
|
const blockListLayoutClass = classnames(
|
|
251
266
|
{
|
|
@@ -255,12 +270,11 @@ export default function VisualEditor( { styles } ) {
|
|
|
255
270
|
);
|
|
256
271
|
|
|
257
272
|
const postContentLayoutStyles = useLayoutStyles(
|
|
258
|
-
|
|
273
|
+
newestPostContentAttributes,
|
|
274
|
+
'core/post-content',
|
|
259
275
|
'.block-editor-block-list__layout.is-root-container'
|
|
260
276
|
);
|
|
261
277
|
|
|
262
|
-
const layout = postContentBlock?.attributes?.layout || {};
|
|
263
|
-
|
|
264
278
|
// Update type for blocks using legacy layouts.
|
|
265
279
|
const postContentLayout = useMemo( () => {
|
|
266
280
|
return layout &&
|
|
@@ -280,7 +294,7 @@ export default function VisualEditor( { styles } ) {
|
|
|
280
294
|
|
|
281
295
|
// If there is a Post Content block we use its layout for the block list;
|
|
282
296
|
// if not, this must be a classic theme, in which case we use the fallback layout.
|
|
283
|
-
const blockListLayout =
|
|
297
|
+
const blockListLayout = postContentAttributes
|
|
284
298
|
? postContentLayout
|
|
285
299
|
: fallbackLayout;
|
|
286
300
|
|
|
@@ -318,7 +332,7 @@ export default function VisualEditor( { styles } ) {
|
|
|
318
332
|
<motion.div
|
|
319
333
|
className="edit-post-visual-editor__content-area"
|
|
320
334
|
animate={ {
|
|
321
|
-
padding: isTemplateMode ? '48px 48px 0' :
|
|
335
|
+
padding: isTemplateMode ? '48px 48px 0' : 0,
|
|
322
336
|
} }
|
|
323
337
|
ref={ blockSelectionClearerRef }
|
|
324
338
|
>
|
|
@@ -376,15 +390,11 @@ export default function VisualEditor( { styles } ) {
|
|
|
376
390
|
{ ! isTemplateMode && (
|
|
377
391
|
<div
|
|
378
392
|
className={ classnames(
|
|
379
|
-
// This wrapper div should have the same
|
|
380
|
-
// classes as the block list beneath.
|
|
381
|
-
'is-root-container',
|
|
382
|
-
'block-editor-block-list__layout',
|
|
383
393
|
'edit-post-visual-editor__post-title-wrapper',
|
|
384
394
|
{
|
|
385
395
|
'is-focus-mode': isFocusMode,
|
|
386
396
|
},
|
|
387
|
-
|
|
397
|
+
'is-layout-flow'
|
|
388
398
|
) }
|
|
389
399
|
contentEditable={ false }
|
|
390
400
|
>
|
|
@@ -110,7 +110,7 @@ export default function WelcomeGuideDefault() {
|
|
|
110
110
|
) }
|
|
111
111
|
<ExternalLink
|
|
112
112
|
href={ __(
|
|
113
|
-
'https://wordpress.org/
|
|
113
|
+
'https://wordpress.org/documentation/article/wordpress-block-editor/'
|
|
114
114
|
) }
|
|
115
115
|
>
|
|
116
116
|
{ __( "Here's a detailed guide." ) }
|
package/src/index.js
CHANGED
|
@@ -11,7 +11,10 @@ import { createRoot } from '@wordpress/element';
|
|
|
11
11
|
import { dispatch, select } from '@wordpress/data';
|
|
12
12
|
import { addFilter } from '@wordpress/hooks';
|
|
13
13
|
import { store as preferencesStore } from '@wordpress/preferences';
|
|
14
|
-
import {
|
|
14
|
+
import {
|
|
15
|
+
registerLegacyWidgetBlock,
|
|
16
|
+
registerWidgetGroupBlock,
|
|
17
|
+
} from '@wordpress/widgets';
|
|
15
18
|
|
|
16
19
|
/**
|
|
17
20
|
* Internal dependencies
|
|
@@ -68,6 +71,7 @@ export function initializeEditor(
|
|
|
68
71
|
|
|
69
72
|
registerCoreBlocks();
|
|
70
73
|
registerLegacyWidgetBlock( { inserter: false } );
|
|
74
|
+
registerWidgetGroupBlock( { inserter: false } );
|
|
71
75
|
if ( process.env.IS_GUTENBERG_PLUGIN ) {
|
|
72
76
|
__experimentalRegisterExperimentalCoreBlocks( {
|
|
73
77
|
enableFSEBlocks: settings.__unstableEnableFullSiteEditingBlocks,
|