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

More/backports for beta 2 #59208

Merged
merged 22 commits into from
Feb 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
3c9d2cd
Font Library: Replace infinite scroll by pagination (#58794)
pbking Feb 13, 2024
d50c836
Revert "Block Hooks: Set ignoredHookedBlocks metada attr upon inserti…
ockham Feb 13, 2024
16f7948
DataViews: Fix patterns, templates and template parts pagination `z-i…
ntsekouras Feb 13, 2024
50244c6
Block Bindings: Fix disable bindings editing when source is undefined…
SantosGuillamot Feb 13, 2024
942cc3e
Patterns: Fix pattern categories on import (#58926)
ntsekouras Feb 13, 2024
0ef370b
Shadows: Don't assume that core provides defaults (#58973)
scruffian Feb 13, 2024
0f3e9fb
Inserter: Don't select the closest block with editing mode set as dis…
Mamaduka Feb 14, 2024
79dffd9
Make the custom CSS validation error message accessible. (#56690)
afercia Feb 14, 2024
a01f6a7
Inserter: Fix title condition for media tab previews (#58993)
Mamaduka Feb 14, 2024
1e70298
DataViews: Add loading/no results message in grid view (#59002)
ntsekouras Feb 14, 2024
4b25a88
Block editor: pass patterns selector as setting (#58661)
ellatrix Feb 14, 2024
00f7e12
Font Libary: Add missing translation functions (#58104)
t-hamano Feb 15, 2024
9b48e86
Background image support: Fix issue with background position if keybo…
andrewserong Feb 15, 2024
e53ba3b
Editor: Do not open list view by default on mobile (#59016)
youknowriad Feb 15, 2024
18c62df
Refactor to use string instead of an object (#59030)
cbravobernal Feb 15, 2024
81115e7
Fix DFM ui toggling bugs (#59061)
draganescu Feb 15, 2024
2958043
Rich text: fix link paste for internal paste (#59063)
ellatrix Feb 15, 2024
974f545
Image: Mark connected controls as 'readyonly' (#59059)
Mamaduka Feb 15, 2024
ea8ea99
Global Styles: fix console error in block preview (#59112)
t-hamano Feb 16, 2024
1236a04
Site Editor: Fix navigation on mobile web (#59014)
youknowriad Feb 15, 2024
2181591
Revert footer in pages list with DataViews (#59151)
ntsekouras Feb 19, 2024
dfe3d0d
Fix build
youknowriad Feb 20, 2024
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
48 changes: 0 additions & 48 deletions docs/reference-guides/data/data-core-blocks.md
Original file line number Diff line number Diff line change
Expand Up @@ -504,54 +504,6 @@ _Returns_

- `string?`: Name of the block for handling the grouping of blocks.

### getHookedBlocks

Returns the hooked blocks for a given anchor block.

Given an anchor block name, returns an object whose keys are relative positions, and whose values are arrays of block names that are hooked to the anchor block at that relative position.

_Usage_

```js
import { store as blocksStore } from '@wordpress/blocks';
import { useSelect } from '@wordpress/data';

const ExampleComponent = () => {
const hookedBlockNames = useSelect(
( select ) =>
select( blocksStore ).getHookedBlocks( 'core/navigation' ),
[]
);

return (
<ul>
{ Object.keys( hookedBlockNames ).length &&
Object.keys( hookedBlockNames ).map( ( relativePosition ) => (
<li key={ relativePosition }>
{ relativePosition }>
<ul>
{ hookedBlockNames[ relativePosition ].map(
( hookedBlock ) => (
<li key={ hookedBlock }>{ hookedBlock }</li>
)
) }
</ul>
</li>
) ) }
</ul>
);
};
```

_Parameters_

- _state_ `Object`: Data state.
- _blockName_ `string`: Anchor block type name.

_Returns_

- `Object`: Lists of hooked block names for each relative position.

### getUnregisteredFallbackBlockName

Returns the name of the block for handling unregistered blocks.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -800,14 +800,14 @@ public function print_router_loading_and_screen_reader_markup() {
echo <<<HTML
<div
class="wp-interactivity-router-loading-bar"
data-wp-interactive='{"namespace":"core/router"}'
data-wp-interactive="core/router"
data-wp-class--start-animation="state.navigation.hasStarted"
data-wp-class--finish-animation="state.navigation.hasFinished"
></div>
<div
class="screen-reader-text"
aria-live="polite"
data-wp-interactive='{"namespace":"core/router"}'
data-wp-interactive="core/router"
data-wp-text="state.navigation.message"
></div>
HTML;
Expand Down
2 changes: 2 additions & 0 deletions packages/base-styles/_z-index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,8 @@ $z-layers: (
".edit-site-page-content": 1,
".edit-site-patterns__header": 2,
".edit-site-patterns__grid-pagination": 2,
".edit-site-patterns__dataviews-list-pagination": 2,
".edit-site-templates__dataviews-list-pagination": 2,
".edit-site-layout__canvas-container": 2,
".edit-site-layout__sidebar": 1,
".edit-site-layout__canvas-container.is-resizing::after": 100,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,16 @@ function InbetweenInsertionPointPopover( {
isInserterShown: insertionPoint?.__unstableWithInserter,
};
}, [] );
const { getBlockEditingMode } = useSelect( blockEditorStore );

const disableMotion = useReducedMotion();

function onClick( event ) {
if ( event.target === ref.current && nextClientId ) {
if (
event.target === ref.current &&
nextClientId &&
getBlockEditingMode( nextClientId ) !== 'disabled'
) {
selectBlock( nextClientId, -1 );
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,11 @@
*/
import {
TextareaControl,
Tooltip,
Notice,
__experimentalVStack as VStack,
} from '@wordpress/components';
import { useState } from '@wordpress/element';
import { __ } from '@wordpress/i18n';
import { Icon, info } from '@wordpress/icons';

/**
* Internal dependencies
Expand Down Expand Up @@ -58,6 +57,11 @@ export default function AdvancedPanel( {

return (
<VStack spacing={ 3 }>
{ cssError && (
<Notice status="error" onRemove={ () => setCSSError( null ) }>
{ cssError }
</Notice>
) }
<TextareaControl
label={ __( 'Additional CSS' ) }
__nextHasNoMarginBottom
Expand All @@ -67,16 +71,6 @@ export default function AdvancedPanel( {
className="block-editor-global-styles-advanced-panel__custom-css-input"
spellCheck={ false }
/>
{ cssError && (
<Tooltip text={ cssError }>
<div className="block-editor-global-styles-advanced-panel__custom-css-validation-wrapper">
<Icon
icon={ info }
className="block-editor-global-styles-advanced-panel__custom-css-validation-icon"
/>
</div>
</Tooltip>
) }
</VStack>
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ import { shadow as shadowIcon, Icon, check } from '@wordpress/icons';
import classNames from 'classnames';

export function ShadowPopoverContainer( { shadow, onShadowChange, settings } ) {
const defaultShadows = settings?.shadow?.presets?.default;
const themeShadows = settings?.shadow?.presets?.theme;
const defaultShadows = settings?.shadow?.presets?.default || [];
const themeShadows = settings?.shadow?.presets?.theme || [];
const defaultPresetsEnabled = settings?.shadow?.defaultPresets;

const shadows = [
...( defaultPresetsEnabled ? defaultShadows : [] ),
...( themeShadows || [] ),
...themeShadows,
];

return (
Expand Down
10 changes: 0 additions & 10 deletions packages/block-editor/src/components/global-styles/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,3 @@
/*rtl:ignore*/
direction: ltr;
}

.block-editor-global-styles-advanced-panel__custom-css-validation-wrapper {
position: absolute;
bottom: $grid-unit-20;
right: $grid-unit * 3;
}

.block-editor-global-styles-advanced-panel__custom-css-validation-icon {
fill: $alert-red;
}
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,12 @@ export function MediaPreview( { media, onClick, category } ) {
createSuccessNotice,
]
);
const title = media.title?.rendered || media.title;

const title =
typeof media.title === 'string'
? media.title
: media.title?.rendered || __( 'no title' );

let truncatedTitle;
if ( title.length > MAXIMUM_TITLE_LENGTH ) {
const omission = '...';
Expand Down
17 changes: 12 additions & 5 deletions packages/block-editor/src/components/rich-text/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -156,12 +156,19 @@ export function RichTextWrapper(
for ( const [ attribute, args ] of Object.entries(
blockBindings
) ) {
// If any of the attributes with source "rich-text" is part of the bindings,
// has a source with `lockAttributesEditing`, disable it.
if (
blockTypeAttributes?.[ attribute ]?.source ===
'rich-text' &&
getBlockBindingsSource( args.source )?.lockAttributesEditing
blockTypeAttributes?.[ attribute ]?.source !== 'rich-text'
) {
break;
}

// If the source is not defined, or if its value of `lockAttributesEditing` is `true`, disable it.
const blockBindingsSource = getBlockBindingsSource(
args.source
);
if (
! blockBindingsSource ||
blockBindingsSource.lockAttributesEditing
) {
shouldDisableEditing = true;
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,35 @@ export function usePasteHandler( props ) {
const isInternal =
event.clipboardData.getData( 'rich-text' ) === 'true';

function pasteInline( content ) {
const transformed = formatTypes.reduce(
( accumulator, { __unstablePasteRule } ) => {
// Only allow one transform.
if ( __unstablePasteRule && accumulator === value ) {
accumulator = __unstablePasteRule( value, {
html,
plainText,
} );
}

return accumulator;
},
value
);
if ( transformed !== value ) {
onChange( transformed );
} else {
const valueToInsert = create( { html: content } );
addActiveFormats( valueToInsert, value.activeFormats );
onChange( insert( value, valueToInsert ) );
}
}

// If the data comes from a rich text instance, we can directly use it
// without filtering the data. The filters are only meant for externally
// pasted content and remove inline styles.
if ( isInternal ) {
const pastedValue = create( { html } );
addActiveFormats( pastedValue, value.activeFormats );
onChange( insert( value, pastedValue ) );
pasteInline( html );
return;
}

Expand Down Expand Up @@ -135,28 +157,7 @@ export function usePasteHandler( props ) {
} );

if ( typeof content === 'string' ) {
const transformed = formatTypes.reduce(
( accumlator, { __unstablePasteRule } ) => {
// Only allow one transform.
if ( __unstablePasteRule && accumlator === value ) {
accumlator = __unstablePasteRule( value, {
html,
plainText,
} );
}

return accumlator;
},
value
);

if ( transformed !== value ) {
onChange( transformed );
} else {
const valueToInsert = create( { html: content } );
addActiveFormats( valueToInsert, value.activeFormats );
onChange( insert( value, valueToInsert ) );
}
pasteInline( content );
} else if ( content.length > 0 ) {
if ( onReplace && isEmpty( value ) ) {
onReplace( content, content.length - 1, -1 );
Expand Down
7 changes: 5 additions & 2 deletions packages/block-editor/src/hooks/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -374,11 +374,14 @@ function backgroundSizeHelpText( value ) {
}

export const coordsToBackgroundPosition = ( value ) => {
if ( ! value || isNaN( value.x ) || isNaN( value.y ) ) {
if ( ! value || ( isNaN( value.x ) && isNaN( value.y ) ) ) {
return undefined;
}

return `${ value.x * 100 }% ${ value.y * 100 }%`;
const x = isNaN( value.x ) ? 0.5 : value.x;
const y = isNaN( value.y ) ? 0.5 : value.y;

return `${ x * 100 }% ${ y * 100 }%`;
};

export const backgroundPositionToCoords = ( value ) => {
Expand Down
2 changes: 2 additions & 0 deletions packages/block-editor/src/private-apis.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import { usesContextKey } from './components/rich-text/format-edit';
import { ExperimentalBlockCanvas } from './components/block-canvas';
import { getDuotoneFilter } from './components/duotone/utils';
import { useFlashEditableBlocks } from './components/use-flash-editable-blocks';
import { selectBlockPatternsKey } from './store/private-keys';

/**
* Private @wordpress/block-editor APIs.
Expand Down Expand Up @@ -56,4 +57,5 @@ lock( privateApis, {
useReusableBlocksRenameHint,
usesContextKey,
useFlashEditableBlocks,
selectBlockPatternsKey,
} );
2 changes: 0 additions & 2 deletions packages/block-editor/src/store/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import reducer from './reducer';
import * as selectors from './selectors';
import * as privateActions from './private-actions';
import * as privateSelectors from './private-selectors';
import * as resolvers from './resolvers';
import * as actions from './actions';
import { STORE_NAME } from './constants';
import { unlock } from '../lock-unlock';
Expand All @@ -23,7 +22,6 @@ import { unlock } from '../lock-unlock';
export const storeConfig = {
reducer,
selectors,
resolvers,
actions,
};

Expand Down
1 change: 1 addition & 0 deletions packages/block-editor/src/store/private-keys.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const selectBlockPatternsKey = Symbol( 'selectBlockPatternsKey' );
11 changes: 4 additions & 7 deletions packages/block-editor/src/store/private-selectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import { checkAllowListRecursive, getAllPatternsDependants } from './utils';
import { INSERTER_PATTERN_TYPES } from '../components/inserter/block-patterns-tab/utils';
import { STORE_NAME } from './constants';
import { unlock } from '../lock-unlock';
import { selectBlockPatternsKey } from './private-keys';

export { getBlockSettings } from './get-block-settings';

Expand Down Expand Up @@ -250,10 +251,6 @@ export const getInserterMediaCategories = createSelector(
]
);

export function getFetchedPatterns( state ) {
return state.blockPatterns;
}

/**
* Returns whether there is at least one allowed pattern for inner blocks children.
* This is useful for deferring the parsing of all patterns until needed.
Expand Down Expand Up @@ -285,7 +282,7 @@ export const hasAllowedPatterns = createRegistrySelector( ( select ) =>
} );
},
( state, rootClientId ) => [
getAllPatternsDependants( state ),
getAllPatternsDependants( select )( state ),
state.settings.allowedBlockTypes,
state.settings.templateLock,
state.blockListSettings[ rootClientId ],
Expand Down Expand Up @@ -325,12 +322,12 @@ export const getAllPatterns = createRegistrySelector( ( select ) =>
return [
...userPatterns,
...__experimentalBlockPatterns,
...unlock( select( STORE_NAME ) ).getFetchedPatterns(),
...( state.settings[ selectBlockPatternsKey ]?.( select ) ?? [] ),
].filter(
( x, index, arr ) =>
index === arr.findIndex( ( y ) => x.name === y.name )
);
}, getAllPatternsDependants )
}, getAllPatternsDependants( select ) )
);

/**
Expand Down
10 changes: 0 additions & 10 deletions packages/block-editor/src/store/reducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -2064,15 +2064,6 @@ function blockBindingsSources( state = {}, action ) {
return state;
}

function blockPatterns( state = [], action ) {
switch ( action.type ) {
case 'RECEIVE_BLOCK_PATTERNS':
return action.patterns;
}

return state;
}

const combinedReducers = combineReducers( {
blocks,
isDragging,
Expand Down Expand Up @@ -2105,7 +2096,6 @@ const combinedReducers = combineReducers( {
openedBlockSettingsMenu,
registeredInserterMediaCategories,
blockBindingsSources,
blockPatterns,
} );

function withAutomaticChangeReset( reducer ) {
Expand Down
Loading
Loading