Skip to content

Commit

Permalink
Resolve conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
t-hamano committed Dec 30, 2024
2 parents 32fd9f7 + 37a06bd commit 8c0bc3d
Show file tree
Hide file tree
Showing 19 changed files with 138 additions and 46 deletions.
30 changes: 30 additions & 0 deletions bin/api-docs/gen-components-docs/get-tags-from-storybook.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/**
* External dependencies
*/
import fs from 'node:fs/promises';
import babel from '@babel/core';

/**
* Returns `meta.tags` from a Storybook file.
*
* @param {string} filePath
* @return {Promise<string[]>} Array of tags.
*/
export async function getTagsFromStorybook( filePath ) {
const fileContent = await fs.readFile( filePath, 'utf8' );
const parsedFile = babel.parse( fileContent, {
filename: filePath,
} );

const meta = parsedFile.program.body.find(
( node ) =>
node.type === 'VariableDeclaration' &&
node.declarations[ 0 ].id.name === 'meta'
);

return (
meta.declarations[ 0 ].init.properties
.find( ( node ) => node.key.name === 'tags' )
?.value.elements.map( ( node ) => node.value ) ?? []
);
}
9 changes: 9 additions & 0 deletions bin/api-docs/gen-components-docs/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import path from 'path';
*/
import { generateMarkdownDocs } from './markdown/index.mjs';
import { getDescriptionsForSubcomponents } from './get-subcomponent-descriptions.mjs';
import { getTagsFromStorybook } from './get-tags-from-storybook.mjs';

const MANIFEST_GLOB = 'packages/components/src/**/docs-manifest.json';

Expand Down Expand Up @@ -113,9 +114,17 @@ await Promise.all(
} ) ?? []
);

const tags = await getTagsFromStorybook(
path.resolve(
path.dirname( manifestPath ),
'stories/index.story.tsx'
)
);

const docs = generateMarkdownDocs( {
typeDocs,
subcomponentTypeDocs,
tags,
} );
const outputFile = path.resolve(
path.dirname( manifestPath ),
Expand Down
11 changes: 10 additions & 1 deletion bin/api-docs/gen-components-docs/markdown/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,19 @@ json2md.converters.md = ( input ) => {
return input?.trim() || '';
};

export function generateMarkdownDocs( { typeDocs, subcomponentTypeDocs } ) {
export function generateMarkdownDocs( {
typeDocs,
subcomponentTypeDocs,
tags,
} ) {
const mainDocsJson = [
{ h1: typeDocs.displayName },
'<!-- This file is generated automatically and cannot be edited directly. Make edits via TypeScript types and TSDocs. -->',
tags.includes( 'status-private' ) && [
{
p: '🔒 This component is locked as a [private API](https://developer.wordpress.org/block-editor/reference-guides/packages/packages-private-apis/). We do not yet recommend using this outside of the Gutenberg project.',
},
],
{
p: `<p class="callout callout-info">See the <a href="https://wordpress.github.io/gutenberg/?path=/docs/components-${ typeDocs.displayName.toLowerCase() }--docs">WordPress Storybook</a> for more detailed, interactive documentation.</p>`,
},
Expand Down
2 changes: 1 addition & 1 deletion docs/getting-started/faq.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ What follows is a set of questions that have come up from the last few years of

“Gutenberg” is the name of the project to create a new editor experience for WordPress — contributors have been working on it since January 2017 and it’s one of the most significant changes to WordPress in years. It’s built on the idea of using “blocks” to write and design posts and pages. This will serve as the foundation for future improvements to WordPress, including blocks as a way not just to design posts and pages, but also entire sites. The overall goal is to simplify the first-time user experience of WordPress — for those who are writing, editing, publishing, and designing web pages. The editing experience is intended to give users a better visual representation of what their post or page will look like when they hit publish. Originally, this was the kickoff goal:

> The editor will endeavour to create a new page and post building experience that makes writing rich posts effortless, and has “blocks” to make it easy what today might take shortcodes, custom HTML, or “mystery meat” embed discovery.
> The editor will endeavor to create a new page and post building experience that makes writing rich posts effortless, and has “blocks” to make it easy what today might take shortcodes, custom HTML, or “mystery meat” embed discovery.
Key takeaways include the following points:

Expand Down
10 changes: 5 additions & 5 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@
"resize-observer-polyfill": "1.5.1",
"rimraf": "5.0.10",
"rtlcss": "4.3.0",
"sass": "1.50.1",
"sass": "1.54.0",
"sass-loader": "16.0.3",
"semver": "7.5.4",
"simple-git": "3.24.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import fastDeepEqual from 'fast-deep-equal/es6';
* WordPress dependencies
*/
import { useRef, useLayoutEffect } from '@wordpress/element';
import { useSelect, useDispatch } from '@wordpress/data';
import { useRegistry } from '@wordpress/data';
import { synchronizeBlocksWithTemplate } from '@wordpress/blocks';

/**
Expand Down Expand Up @@ -42,21 +42,22 @@ export default function useInnerBlockTemplateSync(
) {
// Instead of adding a useSelect mapping here, please add to the useSelect
// mapping in InnerBlocks! Every subscription impacts performance.

const {
getBlocks,
getSelectedBlocksInitialCaretPosition,
isBlockSelected,
} = useSelect( blockEditorStore );
const { replaceInnerBlocks, __unstableMarkNextChangeAsNotPersistent } =
useDispatch( blockEditorStore );
const registry = useRegistry();

// Maintain a reference to the previous value so we can do a deep equality check.
const existingTemplateRef = useRef( null );

useLayoutEffect( () => {
let isCancelled = false;

const {
getBlocks,
getSelectedBlocksInitialCaretPosition,
isBlockSelected,
} = registry.select( blockEditorStore );
const { replaceInnerBlocks, __unstableMarkNextChangeAsNotPersistent } =
registry.dispatch( blockEditorStore );

// There's an implicit dependency between useInnerBlockTemplateSync and useNestedSettingsUpdate
// The former needs to happen after the latter and since the latter is using microtasks to batch updates (performance optimization),
// we need to schedule this one in a microtask as well.
Expand Down Expand Up @@ -110,5 +111,11 @@ export default function useInnerBlockTemplateSync(
return () => {
isCancelled = true;
};
}, [ template, templateLock, clientId ] );
}, [
template,
templateLock,
clientId,
registry,
templateInsertUpdatesSelection,
] );
}
6 changes: 6 additions & 0 deletions packages/block-library/src/read-more/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/**
* WordPress dependencies
*/
import { __ } from '@wordpress/i18n';
import { link as icon } from '@wordpress/icons';

/**
Expand All @@ -16,6 +17,11 @@ export { metadata, name };
export const settings = {
icon,
edit,
example: {
attributes: {
content: __( 'Read more' ),
},
},
};

export const init = () => initBlock( { name, metadata, settings } );
1 change: 1 addition & 0 deletions packages/components/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
### Bug Fixes

- `BoxControl`: Better respect for the `min` prop in the Range Slider ([#67819](https://github.com/WordPress/gutenberg/pull/67819)).
- `FontSizePicker`: Add `display:contents` rule to fix overflowing text in the custom size select. ([#68280](https://github.com/WordPress/gutenberg/pull/68280)).
- `BoxControl`: Fix aria-valuetext value ([#68362](https://github.com/WordPress/gutenberg/pull/68362)).

### Experimental
Expand Down
2 changes: 2 additions & 0 deletions packages/components/src/badge/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

<!-- This file is generated automatically and cannot be edited directly. Make edits via TypeScript types and TSDocs. -->

🔒 This component is locked as a [private API](https://developer.wordpress.org/block-editor/reference-guides/packages/packages-private-apis/). We do not yet recommend using this outside of the Gutenberg project.

<p class="callout callout-info">See the <a href="https://wordpress.github.io/gutenberg/?path=/docs/components-badge--docs">WordPress Storybook</a> for more detailed, interactive documentation.</p>

## Props
Expand Down
4 changes: 2 additions & 2 deletions packages/components/src/badge/stories/index.story.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ import type { Meta, StoryObj } from '@storybook/react';
*/
import Badge from '..';

const meta = {
const meta: Meta< typeof Badge > = {
component: Badge,
title: 'Components/Containers/Badge',
id: 'components-badge',
tags: [ 'status-private' ],
} satisfies Meta< typeof Badge >;
};

export default meta;

Expand Down
1 change: 1 addition & 0 deletions packages/components/src/font-size-picker/styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export const Container = styled.fieldset`
border: 0;
margin: 0;
padding: 0;
display: contents;
`;

export const Header = styled( HStack )`
Expand Down
26 changes: 24 additions & 2 deletions packages/core-data/src/private-selectors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,12 @@ import { createSelector, createRegistrySelector } from '@wordpress/data';
/**
* Internal dependencies
*/
import { getDefaultTemplateId, getEntityRecord, type State } from './selectors';
import {
canUser,
getDefaultTemplateId,
getEntityRecord,
type State,
} from './selectors';
import { STORE_NAME } from './name';
import { unlock } from './lock-unlock';

Expand Down Expand Up @@ -134,6 +139,13 @@ interface SiteData {
export const getHomePage = createRegistrySelector( ( select ) =>
createSelector(
() => {
const canReadSiteData = select( STORE_NAME ).canUser( 'read', {
kind: 'root',
name: 'site',
} );
if ( ! canReadSiteData ) {
return null;
}
const siteData = select( STORE_NAME ).getEntityRecord(
'root',
'site'
Expand All @@ -156,7 +168,10 @@ export const getHomePage = createRegistrySelector( ( select ) =>
return { postType: 'wp_template', postId: frontPageTemplateId };
},
( state ) => [
getEntityRecord( state, 'root', 'site' ),
canUser( state, 'read', {
kind: 'root',
name: 'site',
} ) && getEntityRecord( state, 'root', 'site' ),
getDefaultTemplateId( state, {
slug: 'front-page',
} ),
Expand All @@ -165,6 +180,13 @@ export const getHomePage = createRegistrySelector( ( select ) =>
);

export const getPostsPageId = createRegistrySelector( ( select ) => () => {
const canReadSiteData = select( STORE_NAME ).canUser( 'read', {
kind: 'root',
name: 'site',
} );
if ( ! canReadSiteData ) {
return null;
}
const siteData = select( STORE_NAME ).getEntityRecord( 'root', 'site' ) as
| SiteData
| undefined;
Expand Down
3 changes: 2 additions & 1 deletion packages/editor/src/components/document-bar/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import { store as commandsStore } from '@wordpress/commands';
import { useRef, useEffect } from '@wordpress/element';
import { useReducedMotion } from '@wordpress/compose';
import { decodeEntities } from '@wordpress/html-entities';
import { __unstableStripHTML as stripHTML } from '@wordpress/dom';

/**
* Internal dependencies
Expand Down Expand Up @@ -200,7 +201,7 @@ export default function DocumentBar( props ) {
<Text size="body" as="h1">
<span className="editor-document-bar__post-title">
{ title
? decodeEntities( title )
? stripHTML( title )
: __( 'No title' ) }
</span>
{ pageTypeBadge && (
Expand Down
4 changes: 2 additions & 2 deletions packages/editor/src/components/post-card-panel/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { store as coreStore } from '@wordpress/core-data';
import { useSelect } from '@wordpress/data';
import { useMemo } from '@wordpress/element';
import { __, sprintf } from '@wordpress/i18n';
import { decodeEntities } from '@wordpress/html-entities';
import { __unstableStripHTML as stripHTML } from '@wordpress/dom';

/**
* Internal dependencies
Expand Down Expand Up @@ -94,7 +94,7 @@ export default function PostCardPanel( {
labels?.name
);
} else if ( postTitle ) {
title = decodeEntities( postTitle );
title = stripHTML( postTitle );
}

return (
Expand Down
7 changes: 5 additions & 2 deletions packages/editor/src/components/provider/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ export const ExperimentalEditorProvider = withRegistryProvider(
BlockEditorProviderComponent = ExperimentalBlockEditorProvider,
__unstableTemplate: template,
} ) => {
const hasTemplate = !! template;
const {
editorSettings,
selection,
Expand Down Expand Up @@ -195,15 +196,17 @@ export const ExperimentalEditorProvider = withRegistryProvider(
isReady: __unstableIsEditorReady(),
mode: getRenderingMode(),
defaultMode:
postTypeObject?.default_rendering_mode ?? 'post-only',
hasTemplate && postTypeObject?.default_rendering_mode
? postTypeObject?.default_rendering_mode
: 'post-only',
selection: getEditorSelection(),
postTypeEntities:
post.type === 'wp_template'
? getEntitiesConfig( 'postType' )
: null,
};
},
[ post.type ]
[ post.type, hasTemplate ]
);

const shouldRenderTemplate = !! template && mode !== 'post-only';
Expand Down
1 change: 1 addition & 0 deletions packages/scripts/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
### Internal

- The bundled `rtlcss-webpack-plugin` dependency has been replaced with a modified fork of the plugin to fix issues with the original package ([#68201](https://github.com/WordPress/gutenberg/pull/68201)).
- The bundled `sass` dependency has been updated from `^1.50.0` to `^1.54.0` ([#68380](https://github.com/WordPress/gutenberg/pull/68380)).

## 30.7.0 (2024-12-11)

Expand Down
2 changes: 1 addition & 1 deletion packages/scripts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@
"read-pkg-up": "^7.0.1",
"resolve-bin": "^0.4.0",
"rtlcss": "^4.3.0",
"sass": "^1.50.1",
"sass": "^1.54.0",
"sass-loader": "^16.0.3",
"schema-utils": "^4.2.0",
"source-map-loader": "^3.0.0",
Expand Down
Loading

0 comments on commit 8c0bc3d

Please sign in to comment.