Skip to content

Commit

Permalink
Merge branch 'trunk' into add/link-color-theme-support
Browse files Browse the repository at this point in the history
  • Loading branch information
carolinan committed Jun 23, 2023
2 parents 4d94d76 + b2a7941 commit e5f10e0
Show file tree
Hide file tree
Showing 87 changed files with 2,041 additions and 419 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/end2end-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ jobs:
strategy:
fail-fast: false
matrix:
part: [1, 2, 3, 4]
totalParts: [4]
part: [1, 2, 3]
totalParts: [3]

steps:
- uses: actions/checkout@8f4b7f84864484a7bf31766abe9204da3cbe65b3 # v3.5.0
Expand Down Expand Up @@ -67,8 +67,8 @@ jobs:
strategy:
fail-fast: false
matrix:
part: [1, 2]
totalParts: [2]
part: [1, 2, 3, 4]
totalParts: [4]

steps:
- uses: actions/checkout@8f4b7f84864484a7bf31766abe9204da3cbe65b3 # v3.5.0
Expand Down
9 changes: 9 additions & 0 deletions docs/reference-guides/core-blocks.md
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,15 @@ Add a link to a downloadable file. ([Source](https://github.com/WordPress/gutenb
- **Supports:** align, anchor, color (background, gradients, link, ~~text~~)
- **Attributes:** displayPreview, downloadButtonText, fileId, fileName, href, id, previewHeight, showDownloadButton, textLinkHref, textLinkTarget

## Footnotes

([Source](https://github.com/WordPress/gutenberg/tree/trunk/packages/block-library/src/footnotes))

- **Name:** core/footnotes
- **Category:** text
- **Supports:** ~~html~~, ~~inserter~~, ~~multiple~~, ~~reusable~~
- **Attributes:**

## Classic

Use the classic WordPress editor. ([Source](https://github.com/WordPress/gutenberg/tree/trunk/packages/block-library/src/freeform))
Expand Down
2 changes: 2 additions & 0 deletions lib/blocks.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ function gutenberg_reregister_core_block_types() {
'comments',
'details',
'group',
'footnotes',
'html',
'list',
'list-item',
Expand Down Expand Up @@ -65,6 +66,7 @@ function gutenberg_reregister_core_block_types() {
'comments-pagination-previous.php' => 'core/comments-pagination-previous',
'comments-title.php' => 'core/comments-title',
'comments.php' => 'core/comments',
'footnotes.php' => 'core/footnotes',
'file.php' => 'core/file',
'home-link.php' => 'core/home-link',
'image.php' => 'core/image',
Expand Down
5 changes: 4 additions & 1 deletion package-lock.json

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

Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
/**
* WordPress dependencies
*/
import { useEffect } from '@wordpress/element';
import { useDispatch, useSelect } from '@wordpress/data';
import {
Modal,
Button,
__experimentalHStack as HStack,
} from '@wordpress/components';
import { __, _n } from '@wordpress/i18n';

/**
* Internal dependencies
*/
import { store as blockEditorStore } from '../../store';
import { unlock } from '../../lock-unlock';

// In certain editing contexts, we'd like to prevent accidental removal of
// important blocks. For example, in the site editor, the Query Loop block is
// deemed important. In such cases, we'll ask the user for confirmation that
// they intended to remove such block(s).
//
// @see https://github.com/WordPress/gutenberg/pull/51145
export const blockTypePromptMessages = {
'core/query': __( 'Query Loop displays a list of posts or pages.' ),
'core/post-content': __(
'Post Content displays the content of a post or page.'
),
};

export function BlockRemovalWarningModal() {
const { clientIds, selectPrevious, blockNamesForPrompt } = useSelect(
( select ) =>
unlock( select( blockEditorStore ) ).getRemovalPromptData()
);

const {
clearRemovalPrompt,
toggleRemovalPromptSupport,
privateRemoveBlocks,
} = unlock( useDispatch( blockEditorStore ) );

// Signalling the removal prompt is in place.
useEffect( () => {
toggleRemovalPromptSupport( true );
return () => {
toggleRemovalPromptSupport( false );
};
}, [ toggleRemovalPromptSupport ] );

if ( ! blockNamesForPrompt ) {
return;
}

const onConfirmRemoval = () => {
privateRemoveBlocks( clientIds, selectPrevious, /* force */ true );
clearRemovalPrompt();
};

return (
<Modal
title={ __( 'Are you sure?' ) }
onRequestClose={ clearRemovalPrompt }
>
{ blockNamesForPrompt.length === 1 ? (
<p>{ blockTypePromptMessages[ blockNamesForPrompt[ 0 ] ] }</p>
) : (
<ul style={ { listStyleType: 'disc', paddingLeft: '1rem' } }>
{ blockNamesForPrompt.map( ( name ) => (
<li key={ name }>
{ blockTypePromptMessages[ name ] }
</li>
) ) }
</ul>
) }
<p>
{ _n(
'Removing this block is not advised.',
'Removing these blocks is not advised.',
blockNamesForPrompt.length
) }
</p>
<HStack justify="right">
<Button variant="tertiary" onClick={ clearRemovalPrompt }>
{ __( 'Cancel' ) }
</Button>
<Button variant="primary" onClick={ onConfirmRemoval }>
{ __( 'Delete' ) }
</Button>
</HStack>
</Modal>
);
}
10 changes: 5 additions & 5 deletions packages/block-editor/src/components/copy-handler/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,11 @@ export function useClipboardHandler() {

return useRefEffect( ( node ) => {
function handler( event ) {
if ( event.defaultPrevented ) {
// This was likely already handled in rich-text/use-paste-handler.js.
return;
}

const selectedBlockClientIds = getSelectedBlockClientIds();

if ( selectedBlockClientIds.length === 0 ) {
Expand Down Expand Up @@ -127,7 +132,6 @@ export function useClipboardHandler() {
return;
}

const eventDefaultPrevented = event.defaultPrevented;
event.preventDefault();

const isSelectionMergeable = __unstableIsSelectionMergeable();
Expand Down Expand Up @@ -197,10 +201,6 @@ export function useClipboardHandler() {
__unstableDeleteSelection();
}
} else if ( event.type === 'paste' ) {
if ( eventDefaultPrevented ) {
// This was likely already handled in rich-text/use-paste-handler.js.
return;
}
const {
__experimentalCanUserUseUnfilteredHTML:
canUserUseUnfilteredHTML,
Expand Down
3 changes: 2 additions & 1 deletion packages/block-editor/src/components/inserter/library.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ function InserterLibrary(
return {
destinationRootClientId: _rootClientId,
prioritizePatterns:
getSettings().__experimentalPreferPatternsOnRoot,
getSettings().__experimentalPreferPatternsOnRoot &&
! _rootClientId,
};
},
[ clientId, rootClientId ]
Expand Down
9 changes: 6 additions & 3 deletions packages/block-editor/src/components/list-view/branch.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ function ListViewBranch( props ) {
selectedClientIds,
level = 1,
path = '',
isBranchDragged = false,
isBranchSelected = false,
listPosition = 0,
fixedListWindow,
Expand Down Expand Up @@ -167,7 +168,8 @@ function ListViewBranch( props ) {
);
const isSelectedBranch =
isBranchSelected || ( isSelected && hasNestedBlocks );
const showBlock = isDragged || blockInView || isSelected;
const showBlock =
isDragged || blockInView || isSelected || isBranchDragged;
return (
<AsyncModeProvider key={ clientId } value={ ! isSelected }>
{ showBlock && (
Expand All @@ -176,7 +178,7 @@ function ListViewBranch( props ) {
selectBlock={ selectBlock }
isSelected={ isSelected }
isBranchSelected={ isSelectedBranch }
isDragged={ isDragged }
isDragged={ isDragged || isBranchDragged }
level={ level }
position={ position }
rowCount={ rowCount }
Expand All @@ -194,7 +196,7 @@ function ListViewBranch( props ) {
<td className="block-editor-list-view-placeholder" />
</tr>
) }
{ hasNestedBlocks && shouldExpand && ! isDragged && (
{ hasNestedBlocks && shouldExpand && (
<ListViewBranch
parentId={ clientId }
blocks={ innerBlocks }
Expand All @@ -205,6 +207,7 @@ function ListViewBranch( props ) {
listPosition={ nextPosition + 1 }
fixedListWindow={ fixedListWindow }
isBranchSelected={ isSelectedBranch }
isBranchDragged={ isDragged || isBranchDragged }
selectedClientIds={ selectedClientIds }
isExpanded={ isExpanded }
isSyncedBranch={ syncedBranch }
Expand Down
22 changes: 11 additions & 11 deletions packages/block-editor/src/components/list-view/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,17 @@
}
}

&:not(.is-selected) .block-editor-list-view-block-select-button {
// While components are being dragged, ensure that hover styles are not applied.
// This resolves a bug where while dragging, the hover styles would be applied to
// the wrong list item while scrolling long lists, particularly in Chrome.
.is-dragging-components-draggable & {
&:hover {
color: inherit;
}
}
}

// The background has to be applied to the td, not tr, or border-radius won't work.
&.is-selected td {
background: var(--wp-admin-theme-color);
Expand All @@ -51,13 +62,6 @@
&.is-selected .components-button.has-icon {
color: $white;
}
&.is-selected .block-editor-list-view-block-contents {
// Hide selection styles while a user is dragging blocks/files etc.
.is-dragging-components-draggable & {
background: none;
color: $gray-900;
}
}
&.is-selected .block-editor-list-view-block-contents:focus {
&::after {
box-shadow:
Expand All @@ -76,10 +80,6 @@
box-shadow: inset 0 0 0 var(--wp-admin-border-width-focus) $white;
}

&.is-dragging {
display: none;
}

// Border radius for corners of the selected item.
&.is-first-selected td:first-child {
border-top-left-radius: $radius-block-ui;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -434,6 +434,8 @@ export default function useListViewDropZone( { dropZoneElement } ) {
const blocksData = blockElements.map( ( blockElement ) => {
const clientId = blockElement.dataset.block;
const isExpanded = blockElement.dataset.expanded === 'true';
const isDraggedBlock =
blockElement.classList.contains( 'is-dragging' );

// Get nesting level from `aria-level` attribute because Firefox does not support `element.ariaLevel`.
const nestingLevel = parseInt(
Expand All @@ -449,9 +451,7 @@ export default function useListViewDropZone( { dropZoneElement } ) {
blockIndex: getBlockIndex( clientId ),
element: blockElement,
nestingLevel: nestingLevel || undefined,
isDraggedBlock: isBlockDrag
? draggedBlockClientIds.includes( clientId )
: false,
isDraggedBlock: isBlockDrag ? isDraggedBlock : false,
innerBlockCount: getBlockCount( clientId ),
canInsertDraggedBlocksAsSibling: isBlockDrag
? canInsertBlocks(
Expand Down
Loading

0 comments on commit e5f10e0

Please sign in to comment.