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
38 changes: 38 additions & 0 deletions lib/compat/wordpress-5.9/default-editor-styles.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?php
/**
* Loads the default editor styles.
*
* @package gutenberg
*/

/**
* Load the default editor styles.
* These styles are used if the "no theme styles" options is triggered
* or on themes without their own editor styles.
*
* @param array $settings Default editor settings.
*
* @return array Filtered editor settings.
*/
function gutenberg_extend_block_editor_settings_with_default_editor_styles( $settings ) {
$default_editor_styles_file = gutenberg_dir_path() . 'build/block-editor/default-editor-styles.css';
$settings['defaultEditorStyles'] = array(
array(
'css' => file_get_contents( $default_editor_styles_file ),
),
);

// Remove the default font addition from Core Code.
$styles_without_core_styles = array();
if ( isset( $settings['styles'] ) ) {
foreach ( $settings['styles'] as $style ) {
if ( 'core' !== $style['__unstableType'] ) {
$styles_without_core_styles[] = $style;
}
}
}
$settings['styles'] = $styles_without_core_styles;

return $settings;
}
add_filter( 'block_editor_settings_all', 'gutenberg_extend_block_editor_settings_with_default_editor_styles' );
12 changes: 7 additions & 5 deletions lib/global-styles.php
Original file line number Diff line number Diff line change
Expand Up @@ -139,15 +139,17 @@ function_exists( 'gutenberg_is_edit_site_page' ) &&
}

// Reset existing global styles.
foreach ( $settings['styles'] as $key => $style ) {
if ( isset( $style['__unstableType'] ) && 'globalStyles' === $style['__unstableType'] ) {
unset( $settings['styles'][ $key ] );
$styles_without_existing_global_styles = array();
foreach ( $settings['styles'] as $style ) {
if ( ! isset( $style['__unstableType'] ) || 'globalStyles' !== $style['__unstableType'] ) {
$styles_without_existing_global_styles[] = $style;
}
}

// Add the new ones.
$settings['styles'][] = $css_variables;
$settings['styles'][] = $block_styles;
$styles_without_existing_global_styles[] = $css_variables;
$styles_without_existing_global_styles[] = $block_styles;
$settings['styles'] = $styles_without_existing_global_styles;
}

// Copied from get_block_editor_settings() at wordpress-develop/block-editor.php.
Expand Down
1 change: 1 addition & 0 deletions lib/load.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ function gutenberg_is_experiment_enabled( $name ) {
require __DIR__ . '/compat.php';
require __DIR__ . '/compat/wordpress-5.8/index.php';
require __DIR__ . '/compat/wordpress-5.8.1/index.php';
require __DIR__ . '/compat/wordpress-5.9/default-editor-styles.php';
require __DIR__ . '/utils.php';
require __DIR__ . '/editor-settings.php';

Expand Down
4 changes: 4 additions & 0 deletions packages/base-styles/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## Unreleased

### Breaking Change

- Remove the background-colors, foreground-colors, and gradient-colors mixins.

## 2.0.0 (2020-07-07)

### Breaking Changes
Expand Down
158 changes: 10 additions & 148 deletions packages/base-styles/_mixins.scss
Original file line number Diff line number Diff line change
Expand Up @@ -479,186 +479,48 @@
}
}

@mixin background-colors() {
.has-pale-pink-background-color {
background-color: #f78da7;
}

.has-vivid-red-background-color {
background-color: #cf2e2e;
}

.has-luminous-vivid-orange-background-color {
background-color: #ff6900;
}

.has-luminous-vivid-amber-background-color {
background-color: #fcb900;
}

.has-light-green-cyan-background-color {
background-color: #7bdcb5;
}

.has-vivid-green-cyan-background-color {
background-color: #00d084;
}

.has-pale-cyan-blue-background-color {
background-color: #8ed1fc;
}

.has-vivid-cyan-blue-background-color {
background-color: #0693e3;
}

.has-vivid-purple-background-color {
background-color: #9b51e0;
}

.has-white-background-color {
background-color: #fff;
}

// Deprecated from UI, kept for back-compat.
// Deprecated from UI, kept for back-compat.
@mixin background-colors-deprecated() {
.has-very-light-gray-background-color {
background-color: #eee;
}

.has-cyan-bluish-gray-background-color {
background-color: #abb8c3;
}

// Deprecated from UI, kept for back-compat.
.has-very-dark-gray-background-color {
background-color: #313131;
}

.has-black-background-color {
background-color: #000;
}
}

@mixin foreground-colors() {
.has-pale-pink-color {
color: #f78da7;
}

.has-vivid-red-color {
color: #cf2e2e;
}

.has-luminous-vivid-orange-color {
color: #ff6900;
}

.has-luminous-vivid-amber-color {
color: #fcb900;
}

.has-light-green-cyan-color {
color: #7bdcb5;
}

.has-vivid-green-cyan-color {
color: #00d084;
}

.has-pale-cyan-blue-color {
color: #8ed1fc;
}

.has-vivid-cyan-blue-color {
color: #0693e3;
}

.has-vivid-purple-color {
color: #9b51e0;
}

.has-white-color {
color: #fff;
}

// Deprecated from UI, kept for back-compat.
// Deprecated from UI, kept for back-compat.
@mixin foreground-colors-deprecated() {
.has-very-light-gray-color {
color: #eee;
}

.has-cyan-bluish-gray-color {
color: #abb8c3;
}

// Deprecated from UI, kept for back-compat.
.has-very-dark-gray-color {
color: #313131;
}

.has-black-color {
color: #000;
}
}

@mixin gradient-colors() {
// Our classes uses the same values we set for gradient value attributes, and we can not use spacing because of WP multi site kses rule.
// Deprecated from UI, kept for back-compat.
@mixin gradient-colors-deprecated() {
/*
* Our classes uses the same values we set for gradient value attributes,
* and we can not use spacing because of WP multi site kses rule.
*/

/* stylelint-disable function-comma-space-after */
.has-vivid-cyan-blue-to-vivid-purple-gradient-background {
background: linear-gradient(135deg,rgba(6,147,227,1) 0%,rgb(155,81,224) 100%);
}

.has-vivid-green-cyan-to-vivid-cyan-blue-gradient-background {
background: linear-gradient(135deg,rgba(0,208,132,1) 0%,rgba(6,147,227,1) 100%);
}

.has-light-green-cyan-to-vivid-green-cyan-gradient-background {
background: linear-gradient(135deg,rgb(122,220,180) 0%,rgb(0,208,130) 100%);
}

.has-luminous-vivid-amber-to-luminous-vivid-orange-gradient-background {
background: linear-gradient(135deg,rgba(252,185,0,1) 0%,rgba(255,105,0,1) 100%);
}

.has-luminous-vivid-orange-to-vivid-red-gradient-background {
background: linear-gradient(135deg,rgba(255,105,0,1) 0%,rgb(207,46,46) 100%);
}

.has-very-light-gray-to-cyan-bluish-gray-gradient-background {
background: linear-gradient(135deg,rgb(238,238,238) 0%,rgb(169,184,195) 100%);
}

.has-cool-to-warm-spectrum-gradient-background {
background: linear-gradient(135deg,rgb(74,234,220) 0%,rgb(151,120,209) 20%,rgb(207,42,186) 40%,rgb(238,44,130) 60%,rgb(251,105,98) 80%,rgb(254,248,76) 100%);
}

.has-blush-light-purple-gradient-background {
background: linear-gradient(135deg,rgb(255,206,236) 0%,rgb(152,150,240) 100%);
}

.has-blush-bordeaux-gradient-background {
background: linear-gradient(135deg,rgb(254,205,165) 0%,rgb(254,45,45) 50%,rgb(107,0,62) 100%);
}

.has-purple-crush-gradient-background {
background: linear-gradient(135deg,rgb(52,226,228) 0%,rgb(71,33,251) 50%,rgb(171,29,254) 100%);
}

.has-luminous-dusk-gradient-background {
background: linear-gradient(135deg,rgb(255,203,112) 0%,rgb(199,81,192) 50%,rgb(65,88,208) 100%);
}

.has-hazy-dawn-gradient-background {
background: linear-gradient(135deg,rgb(250,172,168) 0%,rgb(218,208,236) 100%);
}

.has-pale-ocean-gradient-background {
background: linear-gradient(135deg,rgb(255,245,203) 0%,rgb(182,227,212) 50%,rgb(51,167,181) 100%);
}

.has-electric-grass-gradient-background {
background: linear-gradient(135deg,rgb(202,248,128) 0%,rgb(113,206,126) 100%);
}

.has-subdued-olive-gradient-background {
background: linear-gradient(135deg,rgb(250,250,225) 0%,rgb(103,166,113) 100%);
}
Expand Down
5 changes: 1 addition & 4 deletions packages/block-editor/src/components/block-edit/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,7 @@ export const Edit = ( props ) => {
// them preferentially as the render value for the block.
const Component = blockType.edit || blockType.save;

if (
blockType.apiVersion > 1 ||
hasBlockSupport( blockType, 'lightBlockWrapper', false )
) {
if ( blockType.apiVersion > 1 ) {
return <Component { ...props } context={ context } />;
}

Expand Down
6 changes: 1 addition & 5 deletions packages/block-editor/src/components/block-list/block.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import {
getBlockType,
getSaveContent,
isUnmodifiedDefaultBlock,
hasBlockSupport,
} from '@wordpress/blocks';
import { withFilters } from '@wordpress/components';
import { withDispatch, withSelect, useDispatch } from '@wordpress/data';
Expand Down Expand Up @@ -110,9 +109,6 @@ function BlockListBlock( {
);

const blockType = getBlockType( name );
const lightBlockWrapper =
blockType?.apiVersion > 1 ||
hasBlockSupport( blockType, 'lightBlockWrapper', false );

// Determine whether the block has props to apply to the wrapper.
if ( blockType?.getEditWrapperProps ) {
Expand Down Expand Up @@ -159,7 +155,7 @@ function BlockListBlock( {
</Block>
</>
);
} else if ( lightBlockWrapper ) {
} else if ( blockType?.apiVersion > 1 ) {
block = blockEdit;
} else {
block = <Block { ...wrapperProps }>{ blockEdit }</Block>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import { __, sprintf } from '@wordpress/i18n';
import {
__unstableGetBlockProps as getBlockProps,
getBlockType,
hasBlockSupport,
} from '@wordpress/blocks';
import { useMergeRefs } from '@wordpress/compose';
import { useSelect } from '@wordpress/data';
Expand Down Expand Up @@ -68,11 +67,11 @@ export function useBlockProps( props = {}, { __unstableIsHtml } = {} ) {
index,
mode,
name,
blockApiVersion,
blockTitle,
isPartOfSelection,
adjustScrolling,
enableAnimation,
lightBlockWrapper,
} = useSelect(
( select ) => {
const {
Expand All @@ -99,16 +98,14 @@ export function useBlockProps( props = {}, { __unstableIsHtml } = {} ) {
index: getBlockIndex( clientId, rootClientId ),
mode: getBlockMode( clientId ),
name: blockName,
blockApiVersion: blockType?.apiVersion || 1,
blockTitle: blockType?.title,
isPartOfSelection: isSelected || isPartOfMultiSelection,
adjustScrolling:
isSelected || isFirstMultiSelectedBlock( clientId ),
enableAnimation:
! isTyping() &&
getGlobalBlockCount() <= BLOCK_ANIMATION_THRESHOLD,
lightBlockWrapper:
blockType?.apiVersion > 1 ||
hasBlockSupport( blockType, 'lightBlockWrapper', false ),
};
},
[ clientId ]
Expand Down Expand Up @@ -139,7 +136,7 @@ export function useBlockProps( props = {}, { __unstableIsHtml } = {} ) {

const blockEditContext = useBlockEditContext();
// Ensures it warns only inside the `edit` implementation for the block.
if ( ! lightBlockWrapper && clientId === blockEditContext.clientId ) {
if ( blockApiVersion < 2 && clientId === blockEditContext.clientId ) {
warning(
`Block type "${ name }" must support API version 2 or higher to work correctly with "useBlockProps" method.`
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* WordPress dependencies
*/
import { useSelect } from '@wordpress/data';
import { hasBlockSupport, getBlockType } from '@wordpress/blocks';
import { getBlockType } from '@wordpress/blocks';

/**
* Internal dependencies
Expand Down Expand Up @@ -32,9 +32,7 @@ export function useBlockCustomClassName( clientId ) {
}

const blockType = getBlockType( getBlockName( clientId ) );
const hasLightBlockWrapper =
blockType?.apiVersion > 1 ||
hasBlockSupport( blockType, 'lightBlockWrapper', false );
const hasLightBlockWrapper = blockType?.apiVersion > 1;

if ( ! hasLightBlockWrapper ) {
return;
Expand Down
Loading