From 4dfe9dee7a4add1a852d3bc64ba02a3ee7db044e Mon Sep 17 00:00:00 2001 From: retrofox Date: Tue, 5 May 2020 10:40:53 -0300 Subject: [PATCH 01/19] inserter-menu: add contextual tips --- .../src/components/inserter/tips.js | 48 +++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/packages/block-editor/src/components/inserter/tips.js b/packages/block-editor/src/components/inserter/tips.js index d5d47b03dc24c9..19c656684681b9 100644 --- a/packages/block-editor/src/components/inserter/tips.js +++ b/packages/block-editor/src/components/inserter/tips.js @@ -4,6 +4,7 @@ import { __ } from '@wordpress/i18n'; import { createInterpolateElement, useState } from '@wordpress/element'; import { Tip } from '@wordpress/components'; +import {context} from "@actions/github/lib/github"; const globalTips = [ createInterpolateElement( @@ -28,6 +29,53 @@ const globalTips = [ __( "Change a block's type by pressing the block icon on the toolbar." ), ]; +const contextualTips = { + css: createInterpolateElement( + __( + 'CSS - You can visit the the Customizer to edit the CSS on your site.' + ), + { + a: + } + ), + + theme: createInterpolateElement( + __( + 'theme - You can visit the theme directory to select a different design for your site.' + ), + { + a: + } + ), + + plugin: createInterpolateElement( + __( + 'plugin - You can visit the plugin directory to install additional plugins.' + ), + { + a: + } + ), + + header: createInterpolateElement( + __( + 'header - You can visit the the Customizer to edit your logo and site title.' + ), + { + a: + } + ), + + colors: createInterpolateElement( + __( + 'colors - You can visit the the Customizer to edit your logo and site title.' + ), + { + a: + } + ), +}; + function Tips() { const [ randomIndex ] = useState( // Disable Reason: I'm not generating an HTML id. From 26dcd325220e7ffcb93ecb102effd207da66e98c Mon Sep 17 00:00:00 2001 From: retrofox Date: Tue, 5 May 2020 10:41:17 -0300 Subject: [PATCH 02/19] inserter-menu: return contextual tip if defined --- packages/block-editor/src/components/inserter/tips.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/block-editor/src/components/inserter/tips.js b/packages/block-editor/src/components/inserter/tips.js index 19c656684681b9..e2975494639ab6 100644 --- a/packages/block-editor/src/components/inserter/tips.js +++ b/packages/block-editor/src/components/inserter/tips.js @@ -76,7 +76,11 @@ const contextualTips = { ), }; -function Tips() { +function Tips( { tipContext } ) { + if ( contextualTips[ tipContext ] ) { + return { contextualTips[ tipContext ] }; + } + const [ randomIndex ] = useState( // Disable Reason: I'm not generating an HTML id. // eslint-disable-next-line no-restricted-syntax From 2861b118073b79445033ca0a30501ff64b6393d6 Mon Sep 17 00:00:00 2001 From: retrofox Date: Tue, 5 May 2020 10:42:00 -0300 Subject: [PATCH 03/19] inserter-menu: pass filter value as tip context --- packages/block-editor/src/components/inserter/menu.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/block-editor/src/components/inserter/menu.js b/packages/block-editor/src/components/inserter/menu.js index 3d9864fc14a3e3..fb04362c9505f0 100644 --- a/packages/block-editor/src/components/inserter/menu.js +++ b/packages/block-editor/src/components/inserter/menu.js @@ -154,7 +154,7 @@ function InserterMenu( { { showInserterHelpPanel && (
- +
) } From 66b9ea2a8dba4a9b722418e9bde494bf2f12e77a Mon Sep 17 00:00:00 2001 From: retrofox Date: Tue, 5 May 2020 12:01:13 -0300 Subject: [PATCH 04/19] inserter-menu: improve the way to pick up tips --- .../src/components/inserter/tips.js | 31 +++++++++++++++++-- 1 file changed, 28 insertions(+), 3 deletions(-) diff --git a/packages/block-editor/src/components/inserter/tips.js b/packages/block-editor/src/components/inserter/tips.js index e2975494639ab6..7f4461864e512b 100644 --- a/packages/block-editor/src/components/inserter/tips.js +++ b/packages/block-editor/src/components/inserter/tips.js @@ -1,10 +1,14 @@ +/** + * External dependencies + */ +import { lowerCase, includes, filter } from 'lodash'; + /** * WordPress dependencies */ import { __ } from '@wordpress/i18n'; import { createInterpolateElement, useState } from '@wordpress/element'; import { Tip } from '@wordpress/components'; -import {context} from "@actions/github/lib/github"; const globalTips = [ createInterpolateElement( @@ -76,9 +80,30 @@ const contextualTips = { ), }; +function getTipByContext( tipContext ) { + if ( ! tipContext ) { + return; + } + + const contextualKeys = filter( Object.keys( contextualTips ), ( key ) => + includes( lowerCase( tipContext ), key ) + ); + + if ( ! contextualKeys.length ) { + return; + } + + return contextualTips[ + // eslint-disable-next-line no-restricted-syntax + contextualKeys[ Math.floor( Math.random() * contextualKeys.length ) ] + ]; +} + function Tips( { tipContext } ) { - if ( contextualTips[ tipContext ] ) { - return { contextualTips[ tipContext ] }; + // Return a contextual tip when it's appropriate. + const contextualTip = getTipByContext( tipContext ); + if ( contextualTip ) { + return { contextualTip }; } const [ randomIndex ] = useState( From d7dd46e44849ed5f05de3d08d9afc596bb678c3d Mon Sep 17 00:00:00 2001 From: retrofox Date: Tue, 5 May 2020 13:17:44 -0300 Subject: [PATCH 05/19] inserter-menu: update colors tip --- packages/block-editor/src/components/inserter/tips.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/block-editor/src/components/inserter/tips.js b/packages/block-editor/src/components/inserter/tips.js index 7f4461864e512b..4ff771737b127d 100644 --- a/packages/block-editor/src/components/inserter/tips.js +++ b/packages/block-editor/src/components/inserter/tips.js @@ -72,7 +72,7 @@ const contextualTips = { colors: createInterpolateElement( __( - 'colors - You can visit the
the Customizer to edit your logo and site title.' + 'colors - You can visit the the Customizer to edit the colors on your site.' ), { a: From 21ebd69a2eab66639b5b9de2f0095f2cb5a448a8 Mon Sep 17 00:00:00 2001 From: retrofox Date: Wed, 6 May 2020 13:55:42 -0300 Subject: [PATCH 06/19] block-editor: add Tips actions to store --- packages/block-editor/src/store/actions.js | 32 ++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/packages/block-editor/src/store/actions.js b/packages/block-editor/src/store/actions.js index a4991797255b02..28a537030b5244 100644 --- a/packages/block-editor/src/store/actions.js +++ b/packages/block-editor/src/store/actions.js @@ -1010,3 +1010,35 @@ export function toggleBlockHighlight( clientId, isHighlighted ) { isHighlighted, }; } + +export function __experimentalRegisterTip( + scope, + context, + keywords, + description +) { + return { + type: 'REGISTER_TIP', + scope, + context, + keywords, + description, + }; +} + +export function __experimentalRegisterBlockInserterTip( + context, + keywords, + description +) { + return __experimentalRegisterTip( + 'blockInserter', + context, + keywords, + description + ); +} + +export function __experimentalRegisterBlockTip( type, description ) { + return __experimentalRegisterTip( type, null, null, description ); +} From 46f248c5c62acf4c5ba3612502ba896844d3c1db Mon Sep 17 00:00:00 2001 From: retrofox Date: Wed, 6 May 2020 13:57:16 -0300 Subject: [PATCH 07/19] block-editor: reduce Tips action --- packages/block-editor/src/store/reducer.js | 26 ++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/packages/block-editor/src/store/reducer.js b/packages/block-editor/src/store/reducer.js index 0b305a3a4f51f7..ebc22bb0f38abf 100644 --- a/packages/block-editor/src/store/reducer.js +++ b/packages/block-editor/src/store/reducer.js @@ -16,6 +16,7 @@ import { identity, difference, omitBy, + uniq, } from 'lodash'; /** @@ -23,6 +24,7 @@ import { */ import { combineReducers } from '@wordpress/data'; import { isReusableBlock } from '@wordpress/blocks'; + /** * Internal dependencies */ @@ -1479,6 +1481,29 @@ export function highlightedBlock( state, action ) { return state; } +export function tips( state, action ) { + const { scope, context, keywords, description } = action; + + switch ( action.type ) { + case 'REGISTER_TIP': + const tipsByScope = state && state[ scope ] ? state[ scope ] : []; + + return { + ...state, + [ scope ]: [ + ...tipsByScope, + { + context, + keywords: uniq( keywords ), + description, + }, + ], + }; + } + + return state; +} + export default combineReducers( { blocks, isTyping, @@ -1499,4 +1524,5 @@ export default combineReducers( { isNavigationMode, automaticChangeStatus, highlightedBlock, + tips, } ); From c399a4dbc1d2ada82b1f3f6898522c941d46414a Mon Sep 17 00:00:00 2001 From: retrofox Date: Wed, 6 May 2020 13:57:41 -0300 Subject: [PATCH 08/19] block-editor: add Tips selectors --- packages/block-editor/src/store/selectors.js | 53 ++++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/packages/block-editor/src/store/selectors.js b/packages/block-editor/src/store/selectors.js index fc9dd38979294b..694673875e5141 100644 --- a/packages/block-editor/src/store/selectors.js +++ b/packages/block-editor/src/store/selectors.js @@ -16,6 +16,9 @@ import { some, find, filter, + lowerCase, + uniq, + deburr, } from 'lodash'; import createSelector from 'rememo'; @@ -1633,3 +1636,53 @@ export function didAutomaticChange( state ) { export function isBlockHighlighted( state, clientId ) { return state.highlightedBlock === clientId; } + +function getArrayIndex( array, random = true ) { + // eslint-disable-next-line no-restricted-syntax + return random ? Math.floor( Math.random() * array.length ) : 0; +} + +export function __experimentalGetBlockInserterTipByContext( + state, + searchTerm, + random = false +) { + if ( ! searchTerm ) { + return; + } + + const tips = get( state, [ 'tips', 'blockInserter' ], EMPTY_ARRAY ); + if ( ! tips.length ) { + return; + } + + const normalizedSearchTerm = deburr( lowerCase( searchTerm ) ).replace( + /^\//, + '' + ); + + const foundTips = filter( + tips, + ( { keywords } ) => + filter( keywords, ( keyword ) => + includes( normalizedSearchTerm, keyword ) + ).length + ); + + if ( ! foundTips.length ) { + return; + } + + const index = getArrayIndex( foundTips, random ); + return get( foundTips, [ index, 'description' ] ); +} + +export function __experimentalGetBlockTipByType( state, type, random = false ) { + const tips = get( state, [ 'tips', type ], EMPTY_ARRAY ); + if ( ! tips.length ) { + return null; + } + + const index = getArrayIndex( tips, random ); + return get( tips, [ index, 'description' ] ); +} From d7d9633b947868b23f5d1343747a9bccb64f313b Mon Sep 17 00:00:00 2001 From: retrofox Date: Wed, 6 May 2020 13:59:09 -0300 Subject: [PATCH 09/19] inserter: pick up contextual tips from store --- .../src/components/inserter/menu.js | 2 +- .../src/components/inserter/tips.js | 75 +------------------ 2 files changed, 4 insertions(+), 73 deletions(-) diff --git a/packages/block-editor/src/components/inserter/menu.js b/packages/block-editor/src/components/inserter/menu.js index fb04362c9505f0..5b2e061c04d822 100644 --- a/packages/block-editor/src/components/inserter/menu.js +++ b/packages/block-editor/src/components/inserter/menu.js @@ -154,7 +154,7 @@ function InserterMenu( { { showInserterHelpPanel && (
- +
) } diff --git a/packages/block-editor/src/components/inserter/tips.js b/packages/block-editor/src/components/inserter/tips.js index 4ff771737b127d..30768382e83efb 100644 --- a/packages/block-editor/src/components/inserter/tips.js +++ b/packages/block-editor/src/components/inserter/tips.js @@ -1,7 +1,3 @@ -/** - * External dependencies - */ -import { lowerCase, includes, filter } from 'lodash'; /** * WordPress dependencies @@ -9,6 +5,7 @@ import { lowerCase, includes, filter } from 'lodash'; import { __ } from '@wordpress/i18n'; import { createInterpolateElement, useState } from '@wordpress/element'; import { Tip } from '@wordpress/components'; +import { select } from '@wordpress/data'; const globalTips = [ createInterpolateElement( @@ -33,75 +30,9 @@ const globalTips = [ __( "Change a block's type by pressing the block icon on the toolbar." ), ]; -const contextualTips = { - css: createInterpolateElement( - __( - 'CSS - You can visit the
the Customizer to edit the CSS on your site.' - ), - { - a: - } - ), - - theme: createInterpolateElement( - __( - 'theme - You can visit the theme directory to select a different design for your site.' - ), - { - a: - } - ), - - plugin: createInterpolateElement( - __( - 'plugin - You can visit the plugin directory to install additional plugins.' - ), - { - a: - } - ), - - header: createInterpolateElement( - __( - 'header - You can visit the the Customizer to edit your logo and site title.' - ), - { - a: - } - ), - - colors: createInterpolateElement( - __( - 'colors - You can visit the the Customizer to edit the colors on your site.' - ), - { - a: - } - ), -}; - -function getTipByContext( tipContext ) { - if ( ! tipContext ) { - return; - } - - const contextualKeys = filter( Object.keys( contextualTips ), ( key ) => - includes( lowerCase( tipContext ), key ) - ); - - if ( ! contextualKeys.length ) { - return; - } - - return contextualTips[ - // eslint-disable-next-line no-restricted-syntax - contextualKeys[ Math.floor( Math.random() * contextualKeys.length ) ] - ]; -} - -function Tips( { tipContext } ) { +function Tips( { context } ) { // Return a contextual tip when it's appropriate. - const contextualTip = getTipByContext( tipContext ); + const contextualTip = select( 'core/block-editor' ).__experimentalGetBlockInserterTipByContext( context, true ); if ( contextualTip ) { return { contextualTip }; } From f47fb0f8fa61864447f52a6a07e972bede053b44 Mon Sep 17 00:00:00 2001 From: retrofox Date: Wed, 6 May 2020 14:00:13 -0300 Subject: [PATCH 10/19] block-editor: pick and pass block tip from store --- .../src/components/inserter/preview-panel.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/packages/block-editor/src/components/inserter/preview-panel.js b/packages/block-editor/src/components/inserter/preview-panel.js index 763edbbd506377..b2c6252ba741b2 100644 --- a/packages/block-editor/src/components/inserter/preview-panel.js +++ b/packages/block-editor/src/components/inserter/preview-panel.js @@ -8,6 +8,7 @@ import { getBlockType, } from '@wordpress/blocks'; import { __ } from '@wordpress/i18n'; +import { select } from '@wordpress/data'; /** * Internal dependencies @@ -17,6 +18,8 @@ import BlockPreview from '../block-preview'; function InserterPreviewPanel( { item } ) { const hoveredItemBlockType = getBlockType( item.name ); + const { __experimentalGetBlockTipByType } = select( 'core/block-editor' ); + return (
@@ -50,7 +53,12 @@ function InserterPreviewPanel( { item } ) {
) }
- { ! isReusableBlock( item ) && } + { ! isReusableBlock( item ) && ( + + ) } ); } From cfdffc167c58b5804788f8478d258b5f7acf8b6f Mon Sep 17 00:00:00 2001 From: retrofox Date: Wed, 6 May 2020 14:01:46 -0300 Subject: [PATCH 11/19] edit-post: add block-inserter tips --- packages/edit-post/src/utils/tips.js | 71 ++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 packages/edit-post/src/utils/tips.js diff --git a/packages/edit-post/src/utils/tips.js b/packages/edit-post/src/utils/tips.js new file mode 100644 index 00000000000000..f8843fb80f7cfc --- /dev/null +++ b/packages/edit-post/src/utils/tips.js @@ -0,0 +1,71 @@ +/** + * WordPress dependencies + */ +import { __ } from '@wordpress/i18n'; +import { createInterpolateElement } from '@wordpress/element'; + +export default [ + [ + 'css', + [ 'css', __( 'css' ), 'style', __( 'style' ) ], + createInterpolateElement( + __( + 'CSS - You can visit the
the Customizer to edit the CSS on your site.' + ), + { + a: + } + ), + ], + + [ + 'theme', + [ 'theme', __( 'theme' ) ], + createInterpolateElement( + __( + 'theme - You can visit the theme directory to select a different design for your site.' + ), + { + a: + } + ), + ], + + [ + 'plugin', + [ 'plugin', __( 'plugin' ) ], + createInterpolateElement( + __( + 'plugin - You can visit the plugin directory to install additional plugins.' + ), + { + a: + } + ), + ], + + [ + 'header', + [ 'header', __( 'header' ) ], + createInterpolateElement( + __( + 'header - You can visit the the Customizer to edit your logo and site title.' + ), + { + a: + } + ), + ], + [ + 'colors', + [ 'colors', __( 'colors' ) ], + createInterpolateElement( + __( + 'colors - You can visit the the Customizer to edit the colors on your site.' + ), + { + a: + } + ), + ], +]; From 7bf43071f0e9d83b3c28b1755d5f56c881854b7b Mon Sep 17 00:00:00 2001 From: retrofox Date: Wed, 6 May 2020 14:02:16 -0300 Subject: [PATCH 12/19] edit-post: register block-inserter tips --- packages/edit-post/src/editor.js | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/packages/edit-post/src/editor.js b/packages/edit-post/src/editor.js index ba930a0e4b2f63..26925da5e857bd 100644 --- a/packages/edit-post/src/editor.js +++ b/packages/edit-post/src/editor.js @@ -2,7 +2,7 @@ * External dependencies */ import memize from 'memize'; -import { size, map, without } from 'lodash'; +import { size, map, without, each } from 'lodash'; /** * WordPress dependencies @@ -28,6 +28,7 @@ import preventEventDiscovery from './prevent-event-discovery'; import Layout from './components/layout'; import EditorInitialization from './components/editor-initialization'; import EditPostSettings from './components/edit-post-settings'; +import inserterContextualTips from './utils/tips'; class Editor extends Component { constructor() { @@ -36,6 +37,9 @@ class Editor extends Component { this.getEditorSettings = memize( this.getEditorSettings, { maxSize: 1, } ); + + // Register Block Inserter Tips. + each( inserterContextualTips, this.props.registerBlockInserterTip ); } getEditorSettings( @@ -167,8 +171,16 @@ export default compose( [ } ), withDispatch( ( dispatch ) => { const { updatePreferredStyleVariations } = dispatch( 'core/edit-post' ); + const { __experimentalRegisterBlockInserterTip } = dispatch( + 'core/block-editor' + ); + + const registerBlockInserterTip = ( args ) => + __experimentalRegisterBlockInserterTip( ...args ); + return { updatePreferredStyleVariations, + registerBlockInserterTip, }; } ), ] )( Editor ); From e1b03d34755f4a9e37c0c1da281247622f491d41 Mon Sep 17 00:00:00 2001 From: retrofox Date: Wed, 6 May 2020 14:02:48 -0300 Subject: [PATCH 13/19] block-card: rebder tip if it's defined --- .../src/components/block-card/index.js | 40 ++++++++++++++----- .../src/components/block-card/style.scss | 4 ++ 2 files changed, 33 insertions(+), 11 deletions(-) diff --git a/packages/block-editor/src/components/block-card/index.js b/packages/block-editor/src/components/block-card/index.js index aaff1af27e16dd..0ee033a8eedd08 100644 --- a/packages/block-editor/src/components/block-card/index.js +++ b/packages/block-editor/src/components/block-card/index.js @@ -1,21 +1,39 @@ +/** + * WordPress dependencies + */ +import { Tip } from '@wordpress/components'; + /** * Internal dependencies */ import BlockIcon from '../block-icon'; -function BlockCard( { blockType } ) { +// const contextualTip = select( 'core/block-editor' ).__experimentalGetBlockInserterTipByContext( context, true ); + +// console.log( { __experimentalGetBlockTipByType } ); + +function BlockCard( { blockType, tip } ) { return ( -
- -
-

- { blockType.title } -

- - { blockType.description } - + <> +
+ +
+

+ { blockType.title } +

+ + { blockType.description } + +
-
+ { tip && ( +
+
+ { tip } +
+
+ ) } + ); } diff --git a/packages/block-editor/src/components/block-card/style.scss b/packages/block-editor/src/components/block-card/style.scss index 993ac878d03c4c..d98b2791da4824 100644 --- a/packages/block-editor/src/components/block-card/style.scss +++ b/packages/block-editor/src/components/block-card/style.scss @@ -12,6 +12,10 @@ width: 36px; } +.block-editor-block-card__tip { + margin-top: -7px; +} + .block-editor-block-card__content { flex-grow: 1; } From caa99e85eb1383ecc32f390c52983ca108fce2f8 Mon Sep 17 00:00:00 2001 From: retrofox Date: Wed, 6 May 2020 14:03:14 -0300 Subject: [PATCH 14/19] core/image: register tips --- packages/block-library/src/image/index.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/packages/block-library/src/image/index.js b/packages/block-library/src/image/index.js index 6b0c1fcb0b9b97..cb97e2bb4b26fa 100644 --- a/packages/block-library/src/image/index.js +++ b/packages/block-library/src/image/index.js @@ -3,6 +3,7 @@ */ import { __, _x } from '@wordpress/i18n'; import { image as icon } from '@wordpress/icons'; +import { dispatch } from '@wordpress/data'; /** * Internal dependencies @@ -15,6 +16,16 @@ import transforms from './transforms'; const { name } = metadata; +// Register Tip. +const { __experimentalRegisterBlockTip } = dispatch( 'core/block-editor' ); +const tips = [ + __( 'Add alternative text to your images to make them more accessible.' ), + __( 'Use a Cover block to add text on top of your image.' ), + __( 'To place two images side by side, convert them to a Gallery.' ), +]; + +tips.forEach( ( desc ) => __experimentalRegisterBlockTip( name, desc ) ); + export { metadata, name }; export const settings = { From 14b711ffcc0f1af8b74afa52bc6666db8e17220e Mon Sep 17 00:00:00 2001 From: retrofox Date: Wed, 6 May 2020 14:03:32 -0300 Subject: [PATCH 15/19] core/video: register tip --- packages/block-library/src/video/index.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/packages/block-library/src/video/index.js b/packages/block-library/src/video/index.js index b3ec890ac4c63e..3dba9eb5d76781 100644 --- a/packages/block-library/src/video/index.js +++ b/packages/block-library/src/video/index.js @@ -3,6 +3,7 @@ */ import { __ } from '@wordpress/i18n'; import { video as icon } from '@wordpress/icons'; +import { dispatch } from '@wordpress/data'; /** * Internal dependencies @@ -14,6 +15,15 @@ import transforms from './transforms'; const { name } = metadata; +// Register Tip. +const { __experimentalRegisterBlockTip } = dispatch( 'core/block-editor' ); +__experimentalRegisterBlockTip( + name, + __( + 'The video block accepts uploads in the MP4, M4V, WebM, OGV, WMV, and FLV formats.' + ) +); + export { metadata, name }; export const settings = { From 6345fd50e74e85907820bcf6a0524d613cd25d08 Mon Sep 17 00:00:00 2001 From: retrofox Date: Wed, 6 May 2020 16:39:31 -0300 Subject: [PATCH 16/19] tips: rename selectors name --- packages/block-editor/src/components/block-card/index.js | 4 ++-- .../block-editor/src/components/inserter/preview-panel.js | 4 ++-- packages/block-editor/src/components/inserter/tips.js | 2 +- packages/block-editor/src/store/selectors.js | 4 ++-- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/packages/block-editor/src/components/block-card/index.js b/packages/block-editor/src/components/block-card/index.js index 0ee033a8eedd08..50c12f2cd3b4b4 100644 --- a/packages/block-editor/src/components/block-card/index.js +++ b/packages/block-editor/src/components/block-card/index.js @@ -8,9 +8,9 @@ import { Tip } from '@wordpress/components'; */ import BlockIcon from '../block-icon'; -// const contextualTip = select( 'core/block-editor' ).__experimentalGetBlockInserterTipByContext( context, true ); +// const contextualTip = select( 'core/block-editor' ).__experimentalGetBlockInserterTipsByContext( context, true ); -// console.log( { __experimentalGetBlockTipByType } ); +// console.log( { __experimentalGetBlockTipsByType } ); function BlockCard( { blockType, tip } ) { return ( diff --git a/packages/block-editor/src/components/inserter/preview-panel.js b/packages/block-editor/src/components/inserter/preview-panel.js index b2c6252ba741b2..0d22978f533288 100644 --- a/packages/block-editor/src/components/inserter/preview-panel.js +++ b/packages/block-editor/src/components/inserter/preview-panel.js @@ -18,7 +18,7 @@ import BlockPreview from '../block-preview'; function InserterPreviewPanel( { item } ) { const hoveredItemBlockType = getBlockType( item.name ); - const { __experimentalGetBlockTipByType } = select( 'core/block-editor' ); + const { __experimentalGetBlockTipsByType } = select( 'core/block-editor' ); return (
@@ -56,7 +56,7 @@ function InserterPreviewPanel( { item } ) { { ! isReusableBlock( item ) && ( ) }
diff --git a/packages/block-editor/src/components/inserter/tips.js b/packages/block-editor/src/components/inserter/tips.js index 30768382e83efb..288caa6debdc67 100644 --- a/packages/block-editor/src/components/inserter/tips.js +++ b/packages/block-editor/src/components/inserter/tips.js @@ -32,7 +32,7 @@ const globalTips = [ function Tips( { context } ) { // Return a contextual tip when it's appropriate. - const contextualTip = select( 'core/block-editor' ).__experimentalGetBlockInserterTipByContext( context, true ); + const contextualTip = select( 'core/block-editor' ).__experimentalGetBlockInserterTipsByContext( context, true ); if ( contextualTip ) { return { contextualTip }; } diff --git a/packages/block-editor/src/store/selectors.js b/packages/block-editor/src/store/selectors.js index 694673875e5141..9999ac22b15ba8 100644 --- a/packages/block-editor/src/store/selectors.js +++ b/packages/block-editor/src/store/selectors.js @@ -1642,7 +1642,7 @@ function getArrayIndex( array, random = true ) { return random ? Math.floor( Math.random() * array.length ) : 0; } -export function __experimentalGetBlockInserterTipByContext( +export function __experimentalGetBlockInserterTipsByContext( state, searchTerm, random = false @@ -1677,7 +1677,7 @@ export function __experimentalGetBlockInserterTipByContext( return get( foundTips, [ index, 'description' ] ); } -export function __experimentalGetBlockTipByType( state, type, random = false ) { +export function __experimentalGetBlockTipsByType( state, type, random = false ) { const tips = get( state, [ 'tips', type ], EMPTY_ARRAY ); if ( ! tips.length ) { return null; From 4d07311a550f676a0449323b6148a7e964197dcf Mon Sep 17 00:00:00 2001 From: retrofox Date: Wed, 6 May 2020 16:51:28 -0300 Subject: [PATCH 17/19] inserter: reame Tip filter value prop --- packages/block-editor/src/components/inserter/menu.js | 2 +- packages/block-editor/src/components/inserter/tips.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/block-editor/src/components/inserter/menu.js b/packages/block-editor/src/components/inserter/menu.js index 5b2e061c04d822..e532f3b9d5c835 100644 --- a/packages/block-editor/src/components/inserter/menu.js +++ b/packages/block-editor/src/components/inserter/menu.js @@ -154,7 +154,7 @@ function InserterMenu( {
{ showInserterHelpPanel && (
- +
) } diff --git a/packages/block-editor/src/components/inserter/tips.js b/packages/block-editor/src/components/inserter/tips.js index 288caa6debdc67..35188eeaabfe15 100644 --- a/packages/block-editor/src/components/inserter/tips.js +++ b/packages/block-editor/src/components/inserter/tips.js @@ -30,9 +30,9 @@ const globalTips = [ __( "Change a block's type by pressing the block icon on the toolbar." ), ]; -function Tips( { context } ) { +function Tips( { filterValue } ) { // Return a contextual tip when it's appropriate. - const contextualTip = select( 'core/block-editor' ).__experimentalGetBlockInserterTipsByContext( context, true ); + const contextualTip = select( 'core/block-editor' ).__experimentalGetBlockInserterTipsByContext( filterValue, true ); if ( contextualTip ) { return { contextualTip }; } From 55beff0ee2d3e44b04940d4b6e9528769b4721c2 Mon Sep 17 00:00:00 2001 From: retrofox Date: Thu, 7 May 2020 08:47:18 -0300 Subject: [PATCH 18/19] edit-post: fix block inserter tips links --- packages/edit-post/src/utils/tips.js | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/packages/edit-post/src/utils/tips.js b/packages/edit-post/src/utils/tips.js index f8843fb80f7cfc..f8530c94bc55cb 100644 --- a/packages/edit-post/src/utils/tips.js +++ b/packages/edit-post/src/utils/tips.js @@ -6,27 +6,27 @@ import { createInterpolateElement } from '@wordpress/element'; export default [ [ - 'css', - [ 'css', __( 'css' ), 'style', __( 'style' ) ], + 'theme', + [ 'theme', __( 'theme' ) ], createInterpolateElement( __( - 'CSS - You can visit the
the Customizer to edit the CSS on your site.' + 'theme - You can visit the theme directory to select a different design for your site.' ), { - a: + a: } ), ], [ - 'theme', - [ 'theme', __( 'theme' ) ], + 'css', + [ 'css', __( 'css' ), 'style', __( 'style' ) ], createInterpolateElement( __( - 'theme - You can visit the theme directory to select a different design for your site.' + 'CSS - You can visit the the Customizer to edit the CSS on your site.' ), { - a: + a: } ), ], @@ -39,7 +39,7 @@ export default [ 'plugin - You can visit the plugin directory to install additional plugins.' ), { - a: + a: } ), ], @@ -49,10 +49,10 @@ export default [ [ 'header', __( 'header' ) ], createInterpolateElement( __( - 'header - You can visit the the Customizer to edit your logo and site title.' + 'header - You can visit the the Customizer to edit your logo and site title.' ), { - a: + a: } ), ], @@ -61,10 +61,10 @@ export default [ [ 'colors', __( 'colors' ) ], createInterpolateElement( __( - 'colors - You can visit the the Customizer to edit the colors on your site.' + 'colors - You can visit the the Customizer to edit the colors on your site.' ), { - a: + a: } ), ], From 5fba8f5296309c6c26feac8cdc4cea132d15c0bf Mon Sep 17 00:00:00 2001 From: retrofox Date: Thu, 7 May 2020 10:19:03 -0300 Subject: [PATCH 19/19] block-card: remove commented code --- packages/block-editor/src/components/block-card/index.js | 4 ---- 1 file changed, 4 deletions(-) diff --git a/packages/block-editor/src/components/block-card/index.js b/packages/block-editor/src/components/block-card/index.js index 50c12f2cd3b4b4..1ecd04a66feafc 100644 --- a/packages/block-editor/src/components/block-card/index.js +++ b/packages/block-editor/src/components/block-card/index.js @@ -8,10 +8,6 @@ import { Tip } from '@wordpress/components'; */ import BlockIcon from '../block-icon'; -// const contextualTip = select( 'core/block-editor' ).__experimentalGetBlockInserterTipsByContext( context, true ); - -// console.log( { __experimentalGetBlockTipsByType } ); - function BlockCard( { blockType, tip } ) { return ( <>