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 Gutenberg to release 1.25.0 #21305

Merged
merged 3 commits into from
Apr 3, 2020
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
23 changes: 23 additions & 0 deletions packages/block-editor/src/components/block-list/block-elements.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
const ELEMENTS = [
'p',
'div',
'h1',
'h2',
'h3',
'h4',
'h5',
'h6',
'ol',
'ul',
'li',
'figure',
'nav',
'pre',
'header',
'section',
'aside',
'footer',
'main',
];

export default ELEMENTS;
25 changes: 2 additions & 23 deletions packages/block-editor/src/components/block-list/block-wrapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import { isInsideRootBlock } from '../../utils/dom';
import useMovingAnimation from './moving-animation';
import { Context, BlockNodes } from './root-container';
import { BlockContext } from './block';
import ELEMENTS from './block-elements';

const BlockComponent = forwardRef(
( { children, tagName = 'div', __unstableIsHtml, ...props }, wrapper ) => {
Expand Down Expand Up @@ -226,29 +227,7 @@ const BlockComponent = forwardRef(
}
);

const elements = [
'p',
'div',
'h1',
'h2',
'h3',
'h4',
'h5',
'h6',
'ol',
'ul',
'li',
'figure',
'nav',
'pre',
'header',
'section',
'aside',
'footer',
'main',
];

const ExtendedBlockComponent = elements.reduce( ( acc, element ) => {
const ExtendedBlockComponent = ELEMENTS.reduce( ( acc, element ) => {
acc[ element ] = forwardRef( ( props, ref ) => {
return <BlockComponent { ...props } ref={ ref } tagName={ element } />;
} );
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,9 @@
const elements = [
'p',
'div',
'h1',
'h2',
'h3',
'h4',
'h5',
'h6',
'ol',
'ul',
'li',
'figure',
'nav',
];
/**
* Internal dependencies
*/
import ELEMENTS from './block-elements';

const ExtendedBlockComponent = elements.reduce( ( acc, element ) => {
const ExtendedBlockComponent = ELEMENTS.reduce( ( acc, element ) => {
acc[ element ] = element;
return acc;
}, String );
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/**
* External dependencies
*/
import {
subscribePreferredColorScheme,
isInitialColorSchemeDark,
} from 'react-native-gutenberg-bridge';
/**
* WordPress dependencies
*/
import { useState, useEffect } from '@wordpress/element';

/**
* Returns the color scheme value when it changes. Possible values: [ 'light', 'dark' ]
*
* @return {string} return current color scheme.
*/
const usePreferredColorScheme = function() {
const [ currentColorScheme, setCurrentColorScheme ] = useState(
isInitialColorSchemeDark ? 'dark' : 'light'
);
useEffect( () => {
subscribePreferredColorScheme( ( { isPreferredColorSchemeDark } ) => {
const colorScheme = isPreferredColorSchemeDark ? 'dark' : 'light';
if ( colorScheme !== currentColorScheme ) {
setCurrentColorScheme( colorScheme );
}
} );
} );
return currentColorScheme;
};

export default usePreferredColorScheme;
1 change: 1 addition & 0 deletions test/native/setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ jest.mock( 'react-native-gutenberg-bridge', () => {
subscribeUpdateHtml: jest.fn(),
subscribeMediaAppend: jest.fn(),
subscribeAndroidModalClosed: jest.fn(),
subscribePreferredColorScheme: () => 'light',
editorDidMount: jest.fn(),
editorDidAutosave: jest.fn(),
subscribeMediaUpload: jest.fn(),
Expand Down
4 changes: 3 additions & 1 deletion tsconfig.base.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@

/* This needs to be false so our types are possible to consume without setting this */
"esModuleInterop": false,
"resolveJsonModule": true
"resolveJsonModule": true,

"typeRoots": [ "./node_modules/@types" ]
},
"exclude": [ "**/benchmark", "**/test/**", "**/build/**", "**/build-*/**" ]
}