Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
__experimentalToolsPanel as ToolsPanel,
__experimentalToolsPanelItem as ToolsPanelItem,
} from '@wordpress/components';
import { useCallback, Platform } from '@wordpress/element';
import { useCallback } from '@wordpress/element';
import { __ } from '@wordpress/i18n';
import { getValueFromVariable } from '@wordpress/global-styles-engine';

Expand All @@ -31,7 +31,7 @@ const DEFAULT_CONTROLS = {
* @return {boolean} Whether site settings has activated background panel.
*/
export function useHasBackgroundControl( settings, feature ) {
return Platform.OS === 'web' && settings?.background?.[ feature ];
return settings?.background?.[ feature ];
}

/**
Expand All @@ -44,7 +44,7 @@ export function useHasBackgroundControl( settings, feature ) {
*/
export function useHasBackgroundPanel( settings ) {
const { backgroundImage, gradient } = settings?.background || {};
return Platform.OS === 'web' && ( backgroundImage || gradient );
return backgroundImage || gradient;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {
__experimentalInputControlPrefixWrapper as InputControlPrefixWrapper,
} from '@wordpress/components';
import { Icon, alignNone, stretchWide } from '@wordpress/icons';
import { useCallback, useState, Platform } from '@wordpress/element';
import { useCallback, useState } from '@wordpress/element';
import { getValueFromVariable } from '@wordpress/global-styles-engine';

/**
Expand All @@ -43,18 +43,17 @@ export function useHasDimensionsPanel(
styleState = DEFAULT_BLOCK_STYLE_STATE
) {
return (
Platform.OS === 'web' &&
( hasContentSize( settings ) ||
hasWideSize( settings ) ||
hasPadding( settings ) ||
hasMargin( settings ) ||
hasGap( settings ) ||
hasHeight( settings ) ||
hasMinHeight( settings ) ||
hasMinWidth( settings ) ||
hasWidth( settings ) ||
hasAspectRatio( settings, styleState ) ||
hasChildLayout( settings, styleState ) )
hasContentSize( settings ) ||
hasWideSize( settings ) ||
hasPadding( settings ) ||
hasMargin( settings ) ||
hasGap( settings ) ||
hasHeight( settings ) ||
hasMinHeight( settings ) ||
hasMinWidth( settings ) ||
hasWidth( settings ) ||
hasAspectRatio( settings, styleState ) ||
hasChildLayout( settings, styleState )
);
}

Expand Down
26 changes: 9 additions & 17 deletions packages/block-editor/src/hooks/anchor.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { addFilter } from '@wordpress/hooks';
import { TextControl, ExternalLink } from '@wordpress/components';
import { __ } from '@wordpress/i18n';
import { hasBlockSupport } from '@wordpress/blocks';
import { Platform } from '@wordpress/element';

/**
* Internal dependencies
Expand Down Expand Up @@ -53,8 +52,6 @@ function BlockEditAnchorControlPure( { anchor, setAttributes } ) {
return null;
}

const isWeb = Platform.OS === 'web';

return (
<InspectorControls group="advanced">
<TextControl
Expand All @@ -65,23 +62,18 @@ function BlockEditAnchorControlPure( { anchor, setAttributes } ) {
<>
{ __(
'Enter a word or two—without spaces—to make a unique web address just for this block, called an “anchor”. Then, you’ll be able to link directly to this section of your page.'
) }
{ isWeb && (
<>
{ ' ' }
<ExternalLink
href={ __(
'https://wordpress.org/documentation/article/page-jumps/'
) }
>
{ __( 'Learn more about anchors' ) }
</ExternalLink>
</>
) }
) }{ ' ' }
<ExternalLink
href={ __(
'https://wordpress.org/documentation/article/page-jumps/'
) }
>
{ __( 'Learn more about anchors' ) }
</ExternalLink>
</>
}
value={ anchor || '' }
placeholder={ ! isWeb ? __( 'Add an anchor' ) : null }
placeholder={ null }
onChange={ ( nextValue ) => {
nextValue = nextValue.replace( ANCHOR_REGEX, '-' );
setAttributes( {
Expand Down
6 changes: 1 addition & 5 deletions packages/block-editor/src/hooks/border.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import clsx from 'clsx';
*/
import { hasBlockSupport, getBlockSupport } from '@wordpress/blocks';
import { __experimentalHasSplitBorders as hasSplitBorders } from '@wordpress/components';
import { Platform, useCallback, useMemo } from '@wordpress/element';
import { useCallback, useMemo } from '@wordpress/element';
import { addFilter } from '@wordpress/hooks';
import { useSelect } from '@wordpress/data';
import { __ } from '@wordpress/i18n';
Expand Down Expand Up @@ -217,10 +217,6 @@ export function BorderPanel( { clientId, name, setAttributes, settings } ) {
* @return {boolean} Whether there is support.
*/
export function hasBorderSupport( blockName, feature = 'any' ) {
if ( Platform.OS !== 'web' ) {
return false;
}

const support = getBlockSupport( blockName, BORDER_SUPPORT_KEY );

if ( support === true ) {
Expand Down
7 changes: 1 addition & 6 deletions packages/block-editor/src/hooks/color.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import clsx from 'clsx';
*/
import { addFilter } from '@wordpress/hooks';
import { getBlockSupport } from '@wordpress/blocks';
import { useMemo, Platform, useCallback } from '@wordpress/element';
import { useMemo, useCallback } from '@wordpress/element';
import { useSelect } from '@wordpress/data';

/**
Expand Down Expand Up @@ -55,10 +55,6 @@ const hasColorSupport = ( blockNameOrType ) => {
};

const hasLinkColorSupport = ( blockType ) => {
if ( Platform.OS !== 'web' ) {
return false;
}

const colorSupport = getBlockSupport( blockType, COLOR_SUPPORT_KEY );

return (
Expand Down Expand Up @@ -342,7 +338,6 @@ export function ColorEdit( {

const enableContrastChecking =
! isStateSelected &&
Platform.OS === 'web' &&
! value?.color?.gradient &&
( settings?.color?.text || settings?.color?.link ) &&
// Contrast checking is enabled by default.
Expand Down
6 changes: 1 addition & 5 deletions packages/block-editor/src/hooks/dimensions.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import clsx from 'clsx';
/**
* WordPress dependencies
*/
import { Platform, useState, useEffect, useCallback } from '@wordpress/element';
import { useState, useEffect, useCallback } from '@wordpress/element';
import { useDispatch, useSelect } from '@wordpress/data';
import { getBlockSupport } from '@wordpress/blocks';
import deprecated from '@wordpress/deprecated';
Expand Down Expand Up @@ -171,10 +171,6 @@ export function DimensionsPanel( { clientId, name, setAttributes, settings } ) {
* @return {boolean} Whether there is support.
*/
export function hasDimensionsSupport( blockName, feature = 'any' ) {
if ( Platform.OS !== 'web' ) {
return false;
}

const support = getBlockSupport( blockName, DIMENSIONS_SUPPORT_KEY );

if ( support === true ) {
Expand Down
50 changes: 23 additions & 27 deletions packages/block-editor/src/hooks/position.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { getBlockSupport, hasBlockSupport } from '@wordpress/blocks';
import { BaseControl, CustomSelectControl } from '@wordpress/components';
import { useInstanceId } from '@wordpress/compose';
import { useSelect } from '@wordpress/data';
import { useMemo, Platform } from '@wordpress/element';
import { useMemo } from '@wordpress/element';

/**
* Internal dependencies
Expand Down Expand Up @@ -264,32 +264,28 @@ export function PositionPanelPure( {
: DEFAULT_OPTION;

// Only display position controls if there is at least one option to choose from.
return Platform.select( {
web:
options.length > 1 ? (
<InspectorControls group="position">
<BaseControl help={ stickyHelpText }>
<CustomSelectControl
__next40pxDefaultSize
label={ __( 'Position' ) }
hideLabelFromVision
describedBy={ sprintf(
// translators: %s: Currently selected position.
__( 'Currently selected position: %s' ),
selectedOption.name
) }
options={ options }
value={ selectedOption }
onChange={ ( { selectedItem } ) => {
onChangeType( selectedItem.value );
} }
size="__unstable-large"
/>
</BaseControl>
</InspectorControls>
) : null,
native: null,
} );
return options.length > 1 ? (
<InspectorControls group="position">
<BaseControl help={ stickyHelpText }>
<CustomSelectControl
__next40pxDefaultSize
label={ __( 'Position' ) }
hideLabelFromVision
describedBy={ sprintf(
// translators: %s: Currently selected position.
__( 'Currently selected position: %s' ),
selectedOption.name
) }
options={ options }
value={ selectedOption }
onChange={ ( { selectedItem } ) => {
onChangeType( selectedItem.value );
} }
size="__unstable-large"
/>
</BaseControl>
</InspectorControls>
) : null;
}

export default {
Expand Down
9 changes: 0 additions & 9 deletions packages/block-editor/src/hooks/supports.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
* WordPress dependencies
*/
import { getBlockSupport, hasBlockSupport } from '@wordpress/blocks';
import { Platform } from '@wordpress/element';

const ALIGN_SUPPORT_KEY = 'align';
const ALIGN_WIDE_SUPPORT_KEY = 'alignWide';
Expand Down Expand Up @@ -120,10 +119,6 @@ export const getAlignWideSupport = ( nameOrType ) =>
* @return {boolean} Whether there is support.
*/
export function hasBorderSupport( nameOrType, feature = 'any' ) {
if ( Platform.OS !== 'web' ) {
return false;
}

const support = getBlockSupport( nameOrType, BORDER_SUPPORT_KEY );

if ( support === true ) {
Expand Down Expand Up @@ -177,10 +172,6 @@ export const hasColorSupport = ( nameOrType ) => {
* @return {boolean} Whether the block supports the feature.
*/
export const hasLinkColorSupport = ( nameOrType ) => {
if ( Platform.OS !== 'web' ) {
return false;
}

const colorSupport = getBlockSupport( nameOrType, COLOR_SUPPORT_KEY );

return (
Expand Down
5 changes: 1 addition & 4 deletions packages/block-editor/src/store/private-actions.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
/**
* WordPress dependencies
*/
import { Platform } from '@wordpress/element';
import deprecated from '@wordpress/deprecated';
import { speak } from '@wordpress/a11y';
import { __ } from '@wordpress/i18n';
Expand Down Expand Up @@ -56,9 +55,7 @@ export function __experimentalUpdateSettings(

let cleanSettings = incomingSettings;

// There are no plugins in the mobile apps, so there is no
// need to strip the experimental settings:
if ( stripExperimentalSettings && Platform.OS === 'web' ) {
if ( stripExperimentalSettings ) {
cleanSettings = {};
for ( const key in incomingSettings ) {
if ( ! privateSettings.includes( key ) ) {
Expand Down
9 changes: 0 additions & 9 deletions packages/block-editor/src/store/selectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import {
store as blocksStore,
privateApis as blocksPrivateApis,
} from '@wordpress/blocks';
import { Platform } from '@wordpress/element';
import { applyFilters } from '@wordpress/hooks';
import { symbol } from '@wordpress/icons';
import { create, remove, toHTMLString } from '@wordpress/rich-text';
Expand Down Expand Up @@ -109,14 +108,6 @@ const DEFAULT_INSERTER_OPTIONS = {
*/
export function getBlockName( state, clientId ) {
const block = state.blocks.byClientId.get( clientId );
const socialLinkName = 'core/social-link';

if ( Platform.OS !== 'web' && block?.name === socialLinkName ) {
const attributes = state.blocks.attributes.get( clientId );
const { service } = attributes ?? {};

return service ? `${ socialLinkName }-${ service }` : socialLinkName;
}
return block ? block.name : null;
}

Expand Down
Loading
Loading