From 861399bc5d36aa7a53d93ac63743d9f3e819851a Mon Sep 17 00:00:00 2001 From: David Ryan Date: Thu, 23 Aug 2018 15:07:42 -0700 Subject: [PATCH 1/2] allow filtering of modes in editor mode switcher --- .../components/header/mode-switcher/index.js | 21 ++++++++++--------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/edit-post/components/header/mode-switcher/index.js b/edit-post/components/header/mode-switcher/index.js index 9b1e9198821f64..6d6fb73b24f5a8 100644 --- a/edit-post/components/header/mode-switcher/index.js +++ b/edit-post/components/header/mode-switcher/index.js @@ -4,6 +4,7 @@ import { __ } from '@wordpress/i18n'; import { MenuItemsChoice, MenuGroup } from '@wordpress/components'; import { compose } from '@wordpress/compose'; +import { applyFilters } from '@wordpress/hooks'; import { withSelect, withDispatch } from '@wordpress/data'; /** @@ -15,16 +16,16 @@ import shortcuts from '../../../keyboard-shortcuts'; * * @type {Array} */ -const MODES = [ - { - value: 'visual', - label: __( 'Visual Editor' ), - }, - { - value: 'text', - label: __( 'Code Editor' ), - }, -]; +const MODES = applyFilters( 'editor.modeSwitcher', [ + { + value: 'visual', + label: __( 'Visual Editor' ), + }, + { + value: 'text', + label: __( 'Code Editor' ), + }, +] ); function ModeSwitcher( { onSwitch, mode } ) { const choices = MODES.map( ( choice ) => { From 4e21706da9d9798ed635d6a45e71c888925e5978 Mon Sep 17 00:00:00 2001 From: David Ryan Date: Thu, 23 Aug 2018 15:08:08 -0700 Subject: [PATCH 2/2] formatting --- .../components/header/mode-switcher/index.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/edit-post/components/header/mode-switcher/index.js b/edit-post/components/header/mode-switcher/index.js index 6d6fb73b24f5a8..043ad2ded0841b 100644 --- a/edit-post/components/header/mode-switcher/index.js +++ b/edit-post/components/header/mode-switcher/index.js @@ -17,14 +17,14 @@ import shortcuts from '../../../keyboard-shortcuts'; * @type {Array} */ const MODES = applyFilters( 'editor.modeSwitcher', [ - { - value: 'visual', - label: __( 'Visual Editor' ), - }, - { - value: 'text', - label: __( 'Code Editor' ), - }, + { + value: 'visual', + label: __( 'Visual Editor' ), + }, + { + value: 'text', + label: __( 'Code Editor' ), + }, ] ); function ModeSwitcher( { onSwitch, mode } ) {