From 636b7bf072a4365d5c41fec07872a81fe0247516 Mon Sep 17 00:00:00 2001 From: andrei draganescu Date: Fri, 24 May 2019 15:31:47 +0300 Subject: [PATCH] proxied getEditorSettings in block-editor (#15807) * proxied getEditorSettings in block-editor * just do what Riad says * correct getSettings * added to the readme the new property in code editor default settings * docs auto generated --- packages/block-editor/README.md | 1 + .../src/components/block-settings-menu/block-mode-toggle.js | 4 ++-- packages/block-editor/src/store/defaults.js | 1 + packages/editor/src/components/provider/index.js | 1 + 4 files changed, 5 insertions(+), 2 deletions(-) diff --git a/packages/block-editor/README.md b/packages/block-editor/README.md index e2dcd26cd5095..072bec27f51b9 100644 --- a/packages/block-editor/README.md +++ b/packages/block-editor/README.md @@ -369,6 +369,7 @@ The default editor settings isRTL boolean Whether the editor is in RTL mode bodyPlaceholder string Empty post placeholder titlePlaceholder string Empty title placeholder + codeEditingEnabled string Whether or not the user can switch to the code editor # **SkipToSelectedBlock** diff --git a/packages/block-editor/src/components/block-settings-menu/block-mode-toggle.js b/packages/block-editor/src/components/block-settings-menu/block-mode-toggle.js index 99de4ddf40e44..d36ab6974e276 100644 --- a/packages/block-editor/src/components/block-settings-menu/block-mode-toggle.js +++ b/packages/block-editor/src/components/block-settings-menu/block-mode-toggle.js @@ -34,9 +34,9 @@ export function BlockModeToggle( { blockType, mode, onToggleMode, small = false, export default compose( [ withSelect( ( select, { clientId } ) => { - const { getBlock, getBlockMode } = select( 'core/block-editor' ); + const { getBlock, getBlockMode, getSettings } = select( 'core/block-editor' ); const block = getBlock( clientId ); - const isCodeEditingEnabled = select( 'core/editor' ).getEditorSettings().codeEditingEnabled; + const isCodeEditingEnabled = getSettings().codeEditingEnabled; return { mode: getBlockMode( clientId ), diff --git a/packages/block-editor/src/store/defaults.js b/packages/block-editor/src/store/defaults.js index 14c114216f12a..49cf289b58e0d 100644 --- a/packages/block-editor/src/store/defaults.js +++ b/packages/block-editor/src/store/defaults.js @@ -26,6 +26,7 @@ export const PREFERENCES_DEFAULTS = { * isRTL boolean Whether the editor is in RTL mode * bodyPlaceholder string Empty post placeholder * titlePlaceholder string Empty title placeholder + * codeEditingEnabled string Whether or not the user can switch to the code editor */ export const SETTINGS_DEFAULTS = { alignWide: false, diff --git a/packages/editor/src/components/provider/index.js b/packages/editor/src/components/provider/index.js index 31dbc721bf822..2a4dd5ccbf26f 100644 --- a/packages/editor/src/components/provider/index.js +++ b/packages/editor/src/components/provider/index.js @@ -78,6 +78,7 @@ class EditorProvider extends Component { 'allowedBlockTypes', 'availableLegacyWidgets', 'bodyPlaceholder', + 'codeEditingEnabled', 'colors', 'disableCustomColors', 'disableCustomFontSizes',