Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[pull] trunk from WordPress:trunk #91

Merged
merged 6 commits into from
Dec 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 6 additions & 13 deletions packages/block-editor/src/components/date-format-picker/README.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,12 @@
# DateFormatPicker

The `DateFormatPicker` component renders controls that let the user choose a
_date format_. That is, how they want their dates to be formatted.
The `DateFormatPicker` component renders controls that let the user choose a _date format_. That is, how they want their dates to be formatted.

A user can pick _Default_ to use the default date format (usually set at the
site level).
A user can pick _Default_ to use the default date format (usually set at the site level).

Otherwise, a user may choose a suggested date format or type in their own date
format by selecting _Custom_.
Otherwise, a user may choose a suggested date format or type in their own date format by selecting _Custom_.

All date format strings should be in the format accepted by by the [`dateI18n`
function in
`@wordpress/date`](https://github.com/WordPress/gutenberg/tree/trunk/packages/date#datei18n).
All date format strings should be in the format accepted by by the [`dateI18n` function in `@wordpress/date`](https://github.com/WordPress/gutenberg/tree/trunk/packages/date#datei18n).

## Usage

Expand Down Expand Up @@ -43,16 +38,14 @@ The current date format selected by the user. If `null`, _Default_ is selected.

### `defaultFormat`

The default format string. Used to show to the user what the date will look like
if _Default_ is selected.
The default format string. Used to show to the user what the date will look like if _Default_ is selected.

- Type: `string`
- Required: Yes

### `onChange`

Called when the user makes a selection, or when the user types in a date format.
`null` indicates that _Default_ is selected.
Called when the user makes a selection, or when the user types in a date format. `null` indicates that _Default_ is selected.

- Type: `( format: string|null ) => void`
- Required: Yes
19 changes: 4 additions & 15 deletions packages/block-editor/src/components/date-format-picker/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,21 +29,10 @@ if ( exampleDate.getMonth() === 4 ) {
*
* @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/date-format-picker/README.md
*
* @param {Object} props
* @param {string|null} props.format The selected date
* format. If
* `null`,
* _Default_ is
* selected.
* @param {string} props.defaultFormat The date format that
* will be used if the
* user selects
* 'Default'.
* @param {( format: string|null ) => void} props.onChange Called when a
* selection is
* made. If `null`,
* _Default_ is
* selected.
* @param {Object} props
* @param {string|null} props.format The selected date format. If `null`, _Default_ is selected.
* @param {string} props.defaultFormat The date format that will be used if the user selects 'Default'.
* @param {Function} props.onChange Called when a selection is made. If `null`, _Default_ is selected.
*/
export default function DateFormatPicker( {
format,
Expand Down
8 changes: 8 additions & 0 deletions packages/block-library/src/archives/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,16 @@ import { __ } from '@wordpress/i18n';
import { InspectorControls, useBlockProps } from '@wordpress/block-editor';
import ServerSideRender from '@wordpress/server-side-render';

/**
* Internal dependencies
*/
import { useToolsPanelDropdownMenuProps } from '../utils/hooks';

export default function ArchivesEdit( { attributes, setAttributes } ) {
const { showLabel, showPostCounts, displayAsDropdown, type } = attributes;

const dropdownMenuProps = useToolsPanelDropdownMenuProps();

return (
<>
<InspectorControls>
Expand All @@ -28,6 +35,7 @@ export default function ArchivesEdit( { attributes, setAttributes } ) {
type: 'monthly',
} );
} }
dropdownMenuProps={ dropdownMenuProps }
>
<ToolsPanelItem
label={ __( 'Display as dropdown' ) }
Expand Down
2 changes: 1 addition & 1 deletion packages/block-library/src/image/transforms.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ const schema = ( { phrasingContentSchema } ) => ( {
...imageSchema,
a: {
attributes: [ 'href', 'rel', 'target' ],
classes: [ /[\w-]*/ ],
classes: [ '*' ],
children: imageSchema,
},
figcaption: {
Expand Down
6 changes: 6 additions & 0 deletions packages/block-library/src/loginout/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,14 @@ import {
__experimentalToolsPanelItem as ToolsPanelItem,
} from '@wordpress/components';
import { __ } from '@wordpress/i18n';
/**
* Internal dependencies
*/
import { useToolsPanelDropdownMenuProps } from '../utils/hooks';

export default function LoginOutEdit( { attributes, setAttributes } ) {
const { displayLoginAsForm, redirectToCurrent } = attributes;
const dropdownMenuProps = useToolsPanelDropdownMenuProps();

return (
<>
Expand All @@ -23,6 +28,7 @@ export default function LoginOutEdit( { attributes, setAttributes } ) {
redirectToCurrent: true,
} );
} }
dropdownMenuProps={ dropdownMenuProps }
>
<ToolsPanelItem
label={ __( 'Display login as form' ) }
Expand Down
3 changes: 3 additions & 0 deletions packages/block-library/src/page-list/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import {
convertDescription,
ConvertToLinksModal,
} from './convert-to-links-modal';
import { useToolsPanelDropdownMenuProps } from '../utils/hooks';

// We only show the edit option when page count is <= MAX_PAGE_COUNT
// Performance of Navigation Links is not good past this value.
Expand Down Expand Up @@ -124,6 +125,7 @@ export default function PageListEdit( {
const [ isOpen, setOpen ] = useState( false );
const openModal = useCallback( () => setOpen( true ), [] );
const closeModal = () => setOpen( false );
const dropdownMenuProps = useToolsPanelDropdownMenuProps();

const { records: pages, hasResolved: hasResolvedPages } = useEntityRecords(
'postType',
Expand Down Expand Up @@ -326,6 +328,7 @@ export default function PageListEdit( {
resetAll={ () => {
setAttributes( { parentPageID: 0 } );
} }
dropdownMenuProps={ dropdownMenuProps }
>
{ pagesTree.length > 0 && (
<ToolsPanelItem
Expand Down
5 changes: 4 additions & 1 deletion packages/dom/src/dom/clean-node-list.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,10 @@ export default function cleanNodeList( nodeList, doc, schema, inline ) {
// TODO: Explore patching this in jsdom-jscore.
if ( node.classList && node.classList.length ) {
const mattchers = classes.map( ( item ) => {
if ( typeof item === 'string' ) {
if ( item === '*' ) {
// Keep all classes.
return () => true;
} else if ( typeof item === 'string' ) {
return (
/** @type {string} */ className
) => className === item;
Expand Down
8 changes: 1 addition & 7 deletions packages/edit-site/src/components/editor/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import { privateApis as blockLibraryPrivateApis } from '@wordpress/block-library
import { useCallback, useMemo } from '@wordpress/element';
import { store as noticesStore } from '@wordpress/notices';
import { privateApis as routerPrivateApis } from '@wordpress/router';
import { store as preferencesStore } from '@wordpress/preferences';
import { decodeEntities } from '@wordpress/html-entities';
import { Icon, arrowUpLeft } from '@wordpress/icons';
import { store as blockEditorStore } from '@wordpress/block-editor';
Expand Down Expand Up @@ -130,21 +129,18 @@ export default function EditSiteEditor( { isPostsList = false } ) {
const { postType, postId, context } = entity;
const {
supportsGlobalStyles,
showIconLabels,
editorCanvasView,
currentPostIsTrashed,
hasSiteIcon,
} = useSelect( ( select ) => {
const { getEditorCanvasContainerView } = unlock(
select( editSiteStore )
);
const { get } = select( preferencesStore );
const { getCurrentTheme, getEntityRecord } = select( coreDataStore );
const siteData = getEntityRecord( 'root', '__unstableBase', undefined );

return {
supportsGlobalStyles: getCurrentTheme()?.is_block_theme,
showIconLabels: get( 'core', 'showIconLabels' ),
editorCanvasView: getEditorCanvasContainerView(),
currentPostIsTrashed:
select( editorStore ).getCurrentPostAttribute( 'status' ) ===
Expand Down Expand Up @@ -267,9 +263,7 @@ export default function EditSiteEditor( { isPostsList = false } ) {
postId={ postWithTemplate ? context.postId : postId }
templateId={ postWithTemplate ? postId : undefined }
settings={ settings }
className={ clsx( 'edit-site-editor__editor-interface', {
'show-icon-labels': showIconLabels,
} ) }
className="edit-site-editor__editor-interface"
styles={ styles }
customSaveButton={
_isPreviewingTheme && <SaveButton size="compact" />
Expand Down
13 changes: 12 additions & 1 deletion packages/edit-site/src/components/layout/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ import { privateApis as coreCommandsPrivateApis } from '@wordpress/core-commands
import { privateApis as routerPrivateApis } from '@wordpress/router';
import { PluginArea } from '@wordpress/plugins';
import { store as noticesStore } from '@wordpress/notices';
import { useDispatch } from '@wordpress/data';
import { useDispatch, useSelect } from '@wordpress/data';
import { store as preferencesStore } from '@wordpress/preferences';

/**
* Internal dependencies
Expand Down Expand Up @@ -70,6 +71,15 @@ function Layout() {
triggerAnimationOnChange: routeKey + '-' + canvas,
} );

const { showIconLabels } = useSelect( ( select ) => {
return {
showIconLabels: select( preferencesStore ).get(
'core',
'showIconLabels'
),
};
} );

const [ backgroundColor ] = useGlobalStyle( 'color.background' );
const [ gradientValue ] = useGlobalStyle( 'color.gradient' );
const previousCanvaMode = usePrevious( canvas );
Expand All @@ -93,6 +103,7 @@ function Layout() {
navigateRegionsProps.className,
{
'is-full-canvas': canvas === 'edit',
'show-icon-labels': showIconLabels,
}
) }
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,9 @@ import { __ } from '@wordpress/i18n';
import { useMemo, useState } from '@wordpress/element';
import { privateApis as routerPrivateApis } from '@wordpress/router';
import { useViewportMatch } from '@wordpress/compose';
import {
Button,
privateApis as componentsPrivateApis,
} from '@wordpress/components';
import { Button } from '@wordpress/components';
import { addQueryArgs } from '@wordpress/url';
import { seen } from '@wordpress/icons';

/**
* Internal dependencies
Expand All @@ -21,44 +19,21 @@ import StyleBook from '../style-book';
import { STYLE_BOOK_COLOR_GROUPS } from '../style-book/constants';

const { useLocation, useHistory } = unlock( routerPrivateApis );
const { Menu } = unlock( componentsPrivateApis );

const GlobalStylesPageActions = ( {
isStyleBookOpened,
setIsStyleBookOpened,
} ) => {
return (
<Menu
trigger={
<Button __next40pxDefaultSize variant="tertiary" size="compact">
{ __( 'Preview' ) }
</Button>
}
>
<Menu.RadioItem
value
checked={ isStyleBookOpened }
name="styles-preview-actions"
onChange={ () => setIsStyleBookOpened( true ) }
defaultChecked
>
<Menu.ItemLabel>{ __( 'Style book' ) }</Menu.ItemLabel>
<Menu.ItemHelpText>
{ __( 'Preview blocks and styles.' ) }
</Menu.ItemHelpText>
</Menu.RadioItem>
<Menu.RadioItem
value={ false }
checked={ ! isStyleBookOpened }
name="styles-preview-actions"
onChange={ () => setIsStyleBookOpened( false ) }
>
<Menu.ItemLabel>{ __( 'Site' ) }</Menu.ItemLabel>
<Menu.ItemHelpText>
{ __( 'Preview your site.' ) }
</Menu.ItemHelpText>
</Menu.RadioItem>
</Menu>
<Button
isPressed={ isStyleBookOpened }
icon={ seen }
label={ __( 'Style Book' ) }
onClick={ () => {
setIsStyleBookOpened( ! isStyleBookOpened );
} }
size="compact"
/>
);
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,25 @@
color: $gray-900;
}
}

.show-icon-labels {
.edit-site-styles .edit-site-page-content {
.edit-site-page-header__actions {
.components-button.has-icon {
width: auto;
padding: 0 $grid-unit-10;

// Hide the button icons when labels are set to display...
svg {
display: none;
}
// ... and display labels.
&::after {
content: attr(aria-label);
font-size: $helptext-font-size;
}
}

}
}
}
Loading