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

Update/second round rc1 #52677

Merged
merged 23 commits into from
Jul 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
d733cc5
Try restoring the site editor animation (#51956)
talldan Jul 4, 2023
e38cc2f
Change password input to type text so contents are visible. (#52622)
tellthemachines Jul 14, 2023
a93b06c
Iframe: Silence style compat warnings when in a BlockPreview (#52627)
noisysocks Jul 14, 2023
735463a
Do not autofocus page title field in the Create new page modal dialog…
afercia Jul 14, 2023
ba4100f
Use lowercase p in "Manage Patterns" (#52617)
richtabor Jul 14, 2023
184448b
Remove theme patterns title (#52570)
jameskoster Jul 14, 2023
4de66d2
Block editor store: also attach private APIs to old store descriptor …
mcsf Jun 29, 2023
cea9557
Block removal prompt: let consumers pass their own rules (#51841)
mcsf Jun 30, 2023
da41195
Fix Shift+Tab to Block Toolbar (#52613)
diegohaz Jul 14, 2023
cbe67e3
Show warning on removal of Post Template block in the site editor. (#…
tellthemachines Jul 17, 2023
c13d613
Avoid copying global style presets via the styles compatibility hook …
Mamaduka Jul 17, 2023
889213e
i18n: Make the tab labels of `ColorGradientSettingsDropdown` componen…
t-hamano Jul 17, 2023
83aa024
Rich Text/Footnotes: fix getRichTextValues for useInnerBlocksProps.sa…
ellatrix Jul 17, 2023
d186ada
Patterns: Remove `reusable` text from menu once rename hint has been …
glendaviesnz Jul 17, 2023
530cd9e
Show uncategorized patterns on the Editor > Patterns page (#52633)
carolinan Jul 17, 2023
9f6ca9c
Patterns: fix bug with Create Patterns menu not showing in site edito…
glendaviesnz Jul 18, 2023
c9a1617
Search block: Enqueue view script through block.json (#52552)
Jul 18, 2023
9c123c4
Use `_get_block_template_file` function and set $area variable. (#52708)
spacedmonkey Jul 18, 2023
53757c7
Site Editor: Don't allow creating template part on the Patterns page …
t-hamano Jul 17, 2023
ffca214
Change Delete page menu item to Move to trash. (#52641)
afercia Jul 18, 2023
c9978c8
Use relative path internally to include packages in dependencies (#52…
ramonjd Jul 18, 2023
c79aa94
Spacing Sizes: Fix zero size (#52711)
andrewserong Jul 18, 2023
77f25c0
DimensionsPanel: Fix unexpected value decoding/encoding (#52661)
t-hamano Jul 18, 2023
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
49 changes: 25 additions & 24 deletions package-lock.json

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

4 changes: 0 additions & 4 deletions packages/block-editor/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -680,10 +680,6 @@ _Related_

Private @wordpress/block-editor APIs.

### ReusableBlocksRenameHint

Undocumented declaration.

### RichText

_Related_
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,64 +16,50 @@ import { __ } from '@wordpress/i18n';
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() {
export function BlockRemovalWarningModal( { rules } ) {
const { clientIds, selectPrevious, blockNamesForPrompt } = useSelect(
( select ) =>
unlock( select( blockEditorStore ) ).getRemovalPromptData()
);

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

// Signalling the removal prompt is in place.
// Load block removal rules, simultaneously signalling that the block
// removal prompt is in place.
useEffect( () => {
toggleRemovalPromptSupport( true );
setBlockRemovalRules( rules );
return () => {
toggleRemovalPromptSupport( false );
setBlockRemovalRules();
};
}, [ toggleRemovalPromptSupport ] );
}, [ rules, setBlockRemovalRules ] );

if ( ! blockNamesForPrompt ) {
return;
}

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

return (
<Modal
title={ __( 'Are you sure?' ) }
onRequestClose={ clearRemovalPrompt }
onRequestClose={ clearBlockRemovalPrompt }
style={ {
maxWidth: '40rem',
} }
>
{ blockNamesForPrompt.length === 1 ? (
<p>{ blockTypePromptMessages[ blockNamesForPrompt[ 0 ] ] }</p>
<p>{ rules[ blockNamesForPrompt[ 0 ] ] }</p>
) : (
<ul style={ { listStyleType: 'disc', paddingLeft: '1rem' } }>
{ blockNamesForPrompt.map( ( name ) => (
<li key={ name }>
{ blockTypePromptMessages[ name ] }
</li>
<li key={ name }>{ rules[ name ] }</li>
) ) }
</ul>
) }
Expand All @@ -83,7 +69,7 @@ export function BlockRemovalWarningModal() {
: __( 'Removing this block is not advised.' ) }
</p>
<HStack justify="right">
<Button variant="tertiary" onClick={ clearRemovalPrompt }>
<Button variant="tertiary" onClick={ clearBlockRemovalPrompt }>
{ __( 'Cancel' ) }
</Button>
<Button variant="primary" onClick={ onConfirmRemoval }>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import classnames from 'classnames';
/**
* WordPress dependencies
*/
import { __ } from '@wordpress/i18n';
import {
BaseControl,
__experimentalVStack as VStack,
Expand All @@ -28,12 +29,12 @@ const colorsAndGradientKeys = [

const TAB_COLOR = {
name: 'color',
title: 'Solid',
title: __( 'Solid' ),
value: 'color',
};
const TAB_GRADIENT = {
name: 'gradient',
title: 'Gradient',
title: __( 'Gradient' ),
value: 'gradient',
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -207,18 +207,24 @@ export default function DimensionsPanel( {
// in global styles but not in block inspector.
includeLayoutControls = false,
} ) {
const { dimensions, spacing } = settings;

const decodeValue = ( rawValue ) => {
if ( rawValue && typeof rawValue === 'object' ) {
return Object.keys( rawValue ).reduce( ( acc, key ) => {
acc[ key ] = getValueFromVariable(
{ settings },
{ settings: { dimensions, spacing } },
'',
rawValue[ key ]
);
return acc;
}, {} );
}
return getValueFromVariable( { settings }, '', rawValue );
return getValueFromVariable(
{ settings: { dimensions, spacing } },
'',
rawValue
);
};

const showSpacingPresetsControl = useHasSpacingPresets( settings );
Expand Down
25 changes: 15 additions & 10 deletions packages/block-editor/src/components/iframe/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,14 @@ function Iframe( {
forwardedRef: ref,
...props
} ) {
const { styles = '', scripts = '' } = useSelect(
( select ) =>
select( blockEditorStore ).getSettings().__unstableResolvedAssets,
[]
);
const { resolvedAssets, isPreviewMode } = useSelect( ( select ) => {
const settings = select( blockEditorStore ).getSettings();
return {
resolvedAssets: settings.__unstableResolvedAssets,
isPreviewMode: settings.__unstableIsPreviewMode,
};
}, [] );
const { styles = '', scripts = '' } = resolvedAssets;
const [ iframeDocument, setIframeDocument ] = useState();
const [ bodyClasses, setBodyClasses ] = useState( [] );
const compatStyles = useCompatibilityStyles();
Expand Down Expand Up @@ -140,11 +143,13 @@ function Iframe( {
compatStyle.cloneNode( true )
);

// eslint-disable-next-line no-console
console.warn(
`${ compatStyle.id } was added to the iframe incorrectly. Please use block.json or enqueue_block_assets to add styles to the iframe.`,
compatStyle
);
if ( ! isPreviewMode ) {
// eslint-disable-next-line no-console
console.warn(
`${ compatStyle.id } was added to the iframe incorrectly. Please use block.json or enqueue_block_assets to add styles to the iframe.`,
compatStyle
);
}
}

iFrameDocument.addEventListener(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@ export function useCompatibilityStyles() {
return accumulator;
}

// Don't try to add styles without ID. Styles enqueued via the WP dependency system will always have IDs.
if ( ! ownerNode.id ) {
return accumulator;
}

function matchFromRules( _cssRules ) {
return Array.from( _cssRules ).find(
( {
Expand Down
5 changes: 0 additions & 5 deletions packages/block-editor/src/components/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,3 @@ export { default as __experimentalInspectorPopoverHeader } from './inspector-pop

export { default as BlockEditorProvider } from './provider';
export { default as useSetting } from './use-setting';

/*
* The following rename hint component can be removed in 6.4.
*/
export { default as ReusableBlocksRenameHint } from './inserter/reusable-block-rename-hint';
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,24 @@ import { close } from '@wordpress/icons';
import { store as preferencesStore } from '@wordpress/preferences';

const PREFERENCE_NAME = 'isResuableBlocksrRenameHintVisible';
/*
* This hook was added in 6.3 to help users with the transition from Reusable blocks to Patterns.
* It is only exported for use in the reusable-blocks package as well as block-editor.
* It will be removed in 6.4. and should not be used in any new code.
*/
export function useReusableBlocksRenameHint() {
return useSelect(
( select ) =>
select( preferencesStore ).get( 'core', PREFERENCE_NAME ) ?? true,
[]
);
}

/*
* This component was added in 6.3 to help users with the transition from Reusable blocks to Patterns.
* It is only exported for use in the reusable-blocks package as well as block-editor.
* It will be removed in 6.4. and should not be used in any new code.
*/
export default function ReusableBlocksRenameHint() {
const isReusableBlocksRenameHint = useSelect(
( select ) =>
Expand Down
Loading
Loading