From 49d79cf40a7786bee93af3594a95bb9ebfbc3094 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9rgio=20Est=C3=AAv=C3=A3o?= Date: Tue, 31 Mar 2020 22:44:34 +0100 Subject: [PATCH 1/3] Add pre to list of block wrappers (#21255) * Add pre to list of block wrappers * Share the elements definition between web and native. * Make constant name all uppercase. * Rename constant name to be all uppercase * Rename elements constant to all uppercase --- .../components/block-list/block-elements.js | 23 +++++++++++++++++ .../components/block-list/block-wrapper.js | 25 ++----------------- .../block-list/block-wrapper.native.js | 21 ++++------------ 3 files changed, 30 insertions(+), 39 deletions(-) create mode 100644 packages/block-editor/src/components/block-list/block-elements.js diff --git a/packages/block-editor/src/components/block-list/block-elements.js b/packages/block-editor/src/components/block-list/block-elements.js new file mode 100644 index 00000000000000..1d71649a1cc479 --- /dev/null +++ b/packages/block-editor/src/components/block-list/block-elements.js @@ -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; diff --git a/packages/block-editor/src/components/block-list/block-wrapper.js b/packages/block-editor/src/components/block-list/block-wrapper.js index cfcbfccb9a99f9..80a63a15df6ceb 100644 --- a/packages/block-editor/src/components/block-list/block-wrapper.js +++ b/packages/block-editor/src/components/block-list/block-wrapper.js @@ -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 ) => { @@ -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 ; } ); diff --git a/packages/block-editor/src/components/block-list/block-wrapper.native.js b/packages/block-editor/src/components/block-list/block-wrapper.native.js index 69cbf52723125a..c97dae59059f54 100644 --- a/packages/block-editor/src/components/block-list/block-wrapper.native.js +++ b/packages/block-editor/src/components/block-list/block-wrapper.native.js @@ -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 ); From 43dfb9163349cf1ab328bbe73e46d26f04b3309c Mon Sep 17 00:00:00 2001 From: Sergio Estevao Date: Thu, 2 Apr 2020 15:31:06 +0100 Subject: [PATCH 2/3] Fix the TS used for the GB-Mobile project. (#21324) * Fix the TS used for the GB-Mobile project. Make sure only types inside node_modules/@types are used. This avoids TS to find the ../node_modules/@types inside the gb-mobile repo that lives one path level up of gutenberg root. * Framework: Fix configuration spacing * Change to types node. * Revert "Change to types node." This reverts commit bfb8b7b3efb74c82bbdb8445d3afce3b8c2a3062. Co-authored-by: Andrew Duthie --- tsconfig.base.json | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tsconfig.base.json b/tsconfig.base.json index 8ee1f8b3d415ba..e17cd0ff564d80 100644 --- a/tsconfig.base.json +++ b/tsconfig.base.json @@ -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-*/**" ] } From dc0ee70b30882c4980263033bb3108e26726d6c5 Mon Sep 17 00:00:00 2001 From: Stefanos Togoulidis Date: Fri, 3 Apr 2020 16:23:21 +0300 Subject: [PATCH 3/3] [RNMobile] Dark mode on Android put on the v1.25.0 native release (#21352) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Revert revert of dark mode impl * Add pre to list of block wrappers (#21255) * Add pre to list of block wrappers * Share the elements definition between web and native. * Make constant name all uppercase. * Rename constant name to be all uppercase * Rename elements constant to all uppercase Co-authored-by: Marko Savic Co-authored-by: Sérgio Estêvão --- .../index.android.js | 33 +++++++++++++++++++ .../{index.native.js => index.ios.js} | 0 test/native/setup.js | 1 + 3 files changed, 34 insertions(+) create mode 100644 packages/compose/src/hooks/use-preferred-color-scheme/index.android.js rename packages/compose/src/hooks/use-preferred-color-scheme/{index.native.js => index.ios.js} (100%) diff --git a/packages/compose/src/hooks/use-preferred-color-scheme/index.android.js b/packages/compose/src/hooks/use-preferred-color-scheme/index.android.js new file mode 100644 index 00000000000000..6d81eeca5a0852 --- /dev/null +++ b/packages/compose/src/hooks/use-preferred-color-scheme/index.android.js @@ -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; diff --git a/packages/compose/src/hooks/use-preferred-color-scheme/index.native.js b/packages/compose/src/hooks/use-preferred-color-scheme/index.ios.js similarity index 100% rename from packages/compose/src/hooks/use-preferred-color-scheme/index.native.js rename to packages/compose/src/hooks/use-preferred-color-scheme/index.ios.js diff --git a/test/native/setup.js b/test/native/setup.js index fe55851be4827a..7d656b41eafb42 100644 --- a/test/native/setup.js +++ b/test/native/setup.js @@ -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(),