@@ -261,7 +261,7 @@ exports[`EditPostPreferencesModal should match snapshot when the modal is active
class="components-base-control__help emotion-6 emotion-7"
id="inspector-toggle-control-1__help"
>
- Highlights the current block and fades other content.
+ Reduce visual distractions by hiding the toolbar and other elements to focus on writing.
@@ -299,7 +299,7 @@ exports[`EditPostPreferencesModal should match snapshot when the modal is active
class="components-toggle-control__label"
for="inspector-toggle-control-2"
>
- Show button text labels
+ Spotlight mode
@@ -307,7 +307,7 @@ exports[`EditPostPreferencesModal should match snapshot when the modal is active
class="components-base-control__help emotion-6 emotion-7"
id="inspector-toggle-control-2__help"
>
- Show text instead of icons on buttons.
+ Highlights the current block and fades other content.
@@ -345,7 +345,7 @@ exports[`EditPostPreferencesModal should match snapshot when the modal is active
class="components-toggle-control__label"
for="inspector-toggle-control-3"
>
- Always open list view
+ Show button text labels
@@ -353,7 +353,7 @@ exports[`EditPostPreferencesModal should match snapshot when the modal is active
class="components-base-control__help emotion-6 emotion-7"
id="inspector-toggle-control-3__help"
>
- Opens the block list view sidebar by default.
+ Show text instead of icons on buttons.
@@ -391,7 +391,7 @@ exports[`EditPostPreferencesModal should match snapshot when the modal is active
class="components-toggle-control__label"
for="inspector-toggle-control-4"
>
- Reduce the interface
+ Always open list view
@@ -399,7 +399,7 @@ exports[`EditPostPreferencesModal should match snapshot when the modal is active
class="components-base-control__help emotion-6 emotion-7"
id="inspector-toggle-control-4__help"
>
- Compacts options and outlines in the toolbar.
+ Opens the block list view sidebar by default.
@@ -437,7 +437,7 @@ exports[`EditPostPreferencesModal should match snapshot when the modal is active
class="components-toggle-control__label"
for="inspector-toggle-control-5"
>
- Use theme styles
+ Reduce the interface
@@ -445,7 +445,7 @@ exports[`EditPostPreferencesModal should match snapshot when the modal is active
class="components-base-control__help emotion-6 emotion-7"
id="inspector-toggle-control-5__help"
>
- Make the editor look like your theme.
+ Compacts options and outlines in the toolbar.
@@ -483,13 +483,59 @@ exports[`EditPostPreferencesModal should match snapshot when the modal is active
class="components-toggle-control__label"
for="inspector-toggle-control-6"
>
- Display block breadcrumbs
+ Use theme styles
+ Make the editor look like your theme.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Shows block breadcrumbs at the bottom of the editor.
+
+
{ ! isPublishSidebarOpened && (
// This button isn't completely hidden by the publish sidebar.
// We can't hide the whole toolbar when the publish sidebar is open because
@@ -88,7 +112,7 @@ function Header( { setEntitiesSavedStatesCallback } ) {
{ showIconLabels && ! isLargeViewport && (
) }
-
From cb4abb16d311b417efeb44cdd93eff78f61a8193 Mon Sep 17 00:00:00 2001
From: Andrei Draganescu
Date: Tue, 13 Sep 2022 19:49:49 +0300
Subject: [PATCH 11/29] Fixes the page jump in distraction free mode. Part of
this bug but with a different cause exists in trunk as well.
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Co-authored-by: Ella van Durpe <4710635+ellatrix@users.noreply.github.com>
---
.../src/components/block-tools/selected-block-popover.js | 8 +++-----
1 file changed, 3 insertions(+), 5 deletions(-)
diff --git a/packages/block-editor/src/components/block-tools/selected-block-popover.js b/packages/block-editor/src/components/block-tools/selected-block-popover.js
index cd2b5d8deed33..44dd9b04b3135 100644
--- a/packages/block-editor/src/components/block-tools/selected-block-popover.js
+++ b/packages/block-editor/src/components/block-tools/selected-block-popover.js
@@ -47,6 +47,7 @@ function SelectedBlockPopover( {
clientId,
rootClientId,
isEmptyDefaultBlock,
+ showContents, // we may need to mount an empty popover because we reuse
capturingClientId,
__unstablePopoverSlot,
__unstableContentRef,
@@ -139,7 +140,7 @@ function SelectedBlockPopover( {
resize={ false }
{ ...popoverProps }
>
- { shouldShowContextualToolbar && (
+ { shouldShowContextualToolbar && showContents && (
Date: Tue, 13 Sep 2022 23:25:51 +0300
Subject: [PATCH 12/29] Bulk adds the same distraction free mode toggle effects
to:
- toggle in the writing menu
- the keyboard shortcut
- the preference toggle
Adds a new action to set a feature to a desired value.
Some duplication, not sure how to DRY.
---
.../data/data-core-edit-post.md | 9 +++++
.../components/header/writing-menu/index.js | 12 ++++---
.../components/keyboard-shortcuts/index.js | 16 +++++++++
.../src/components/preferences-modal/index.js | 35 ++++++++++++++-----
.../options/enable-feature.js | 7 ++--
packages/edit-post/src/store/actions.js | 13 +++++++
6 files changed, 78 insertions(+), 14 deletions(-)
diff --git a/docs/reference-guides/data/data-core-edit-post.md b/docs/reference-guides/data/data-core-edit-post.md
index 26337e973bd34..60013e7779b35 100644
--- a/docs/reference-guides/data/data-core-edit-post.md
+++ b/docs/reference-guides/data/data-core-edit-post.md
@@ -440,6 +440,15 @@ _Parameters_
- _metaBoxesPerLocation_ `Object`: Meta boxes per location.
+### setFeature
+
+Triggers an action used to set a feature flag to a desired state.
+
+_Parameters_
+
+- _feature_ `string`: Feature name.
+- _value_ `boolean`: Feature value
+
### setIsEditingTemplate
Returns an action object used to switch to template editing.
diff --git a/packages/edit-post/src/components/header/writing-menu/index.js b/packages/edit-post/src/components/header/writing-menu/index.js
index 4262d48f07a24..c465e246376d9 100644
--- a/packages/edit-post/src/components/header/writing-menu/index.js
+++ b/packages/edit-post/src/components/header/writing-menu/index.js
@@ -21,10 +21,16 @@ function WritingMenu( { onClose } ) {
[]
);
- const { setIsInserterOpened, setIsListViewOpened, closeGeneralSidebar } =
- useDispatch( postEditorStore );
+ const {
+ setIsInserterOpened,
+ setIsListViewOpened,
+ closeGeneralSidebar,
+ setFeature,
+ } = useDispatch( postEditorStore );
const toggleDistractionFree = () => {
+ setFeature( 'inlineToolbar', ! isDistractionFree );
+ setFeature( 'fixedToolbar', false );
setIsInserterOpened( false );
setIsListViewOpened( false );
closeGeneralSidebar();
@@ -51,7 +57,6 @@ function WritingMenu( { onClose } ) {
/>
+ select( blockEditorStore ).getSettings().isDistractionFree,
+ []
+ );
const {
getEditorMode,
isEditorSidebarOpened,
@@ -39,9 +44,19 @@ function KeyboardShortcuts() {
closeGeneralSidebar,
toggleFeature,
setIsListViewOpened,
+ setIsInserterOpened,
+ setFeature,
} = useDispatch( editPostStore );
const { registerShortcut } = useDispatch( keyboardShortcutsStore );
+ const toggleDistractionFree = () => {
+ setFeature( 'inlineToolbar', ! isDistractionFree );
+ setFeature( 'fixedToolbar', false );
+ setIsInserterOpened( false );
+ setIsListViewOpened( false );
+ closeGeneralSidebar();
+ };
+
useEffect( () => {
registerShortcut( {
name: 'core/edit-post/toggle-mode',
@@ -155,6 +170,7 @@ function KeyboardShortcuts() {
useShortcut( 'core/edit-post/toggle-distraction-free', () => {
closeGeneralSidebar();
setIsListViewOpened( false );
+ toggleDistractionFree();
toggleFeature( 'distractionFree' );
const modeState = isFeatureActive( 'distractionFree' )
? __( 'on' )
diff --git a/packages/edit-post/src/components/preferences-modal/index.js b/packages/edit-post/src/components/preferences-modal/index.js
index 5fbb93c8376dd..5e521f9d460b7 100644
--- a/packages/edit-post/src/components/preferences-modal/index.js
+++ b/packages/edit-post/src/components/preferences-modal/index.js
@@ -48,22 +48,40 @@ export default function EditPostPreferencesModal() {
( select ) => select( editPostStore ).isModalActive( MODAL_NAME ),
[]
);
- const showBlockBreadcrumbsOption = useSelect(
+ const [ showBlockBreadcrumbsOption, isDistractionFree ] = useSelect(
( select ) => {
const { getEditorSettings } = select( editorStore );
const { getEditorMode, isFeatureActive } = select( editPostStore );
const mode = getEditorMode();
const isRichEditingEnabled = getEditorSettings().richEditingEnabled;
- const isDistractionFree = isFeatureActive( 'distractionFree' );
- return (
- ! isDistractionFree &&
- isLargeViewport &&
- isRichEditingEnabled &&
- mode === 'visual'
- );
+ const isDistractionFreeEnabled =
+ isFeatureActive( 'distractionFree' );
+ return [
+ ! isDistractionFreeEnabled &&
+ isLargeViewport &&
+ isRichEditingEnabled &&
+ mode === 'visual',
+ isDistractionFreeEnabled,
+ ];
},
[ isLargeViewport ]
);
+
+ const {
+ closeGeneralSidebar,
+ setIsListViewOpened,
+ setIsInserterOpened,
+ setFeature,
+ } = useDispatch( editPostStore );
+
+ const toggleDistractionFree = () => {
+ setFeature( 'inlineToolbar', ! isDistractionFree );
+ setFeature( 'fixedToolbar', false );
+ setIsInserterOpened( false );
+ setIsListViewOpened( false );
+ closeGeneralSidebar();
+ };
+
const sections = useMemo(
() => [
{
@@ -97,6 +115,7 @@ export default function EditPostPreferencesModal() {
>
( {
- onChange: () => dispatch( editPostStore ).toggleFeature( featureName ),
+ withDispatch( ( dispatch, { featureName, onToggle = () => {} } ) => ( {
+ onChange: () => {
+ onToggle();
+ dispatch( editPostStore ).toggleFeature( featureName );
+ },
} ) )
)( BaseOption );
diff --git a/packages/edit-post/src/store/actions.js b/packages/edit-post/src/store/actions.js
index 5fb074f171aae..c58fc47f2cb4a 100644
--- a/packages/edit-post/src/store/actions.js
+++ b/packages/edit-post/src/store/actions.js
@@ -194,6 +194,19 @@ export const toggleFeature =
.dispatch( preferencesStore )
.toggle( 'core/edit-post', feature );
+/**
+ * Triggers an action used to set a feature flag to a desired state.
+ *
+ * @param {string} feature Feature name.
+ * @param {boolean} value Feature value
+ */
+export const setFeature =
+ ( feature, value ) =>
+ ( { registry } ) =>
+ registry
+ .dispatch( preferencesStore )
+ .set( 'core/edit-post', feature, value );
+
/**
* Triggers an action used to switch editor mode.
*
From 0eba2b6c9b6d960d3c57892e4cb1ffd87ab8e56f Mon Sep 17 00:00:00 2001
From: Andrei Draganescu
Date: Wed, 14 Sep 2022 14:52:46 +0300
Subject: [PATCH 13/29] Removes "reduce UI" from the prefferences modal.
Co-authored-by: Matias Ventura <548849+mtias@users.noreply.github.com>
---
.../edit-post/src/components/preferences-modal/index.js | 7 -------
1 file changed, 7 deletions(-)
diff --git a/packages/edit-post/src/components/preferences-modal/index.js b/packages/edit-post/src/components/preferences-modal/index.js
index 5e521f9d460b7..25b525adf89b3 100644
--- a/packages/edit-post/src/components/preferences-modal/index.js
+++ b/packages/edit-post/src/components/preferences-modal/index.js
@@ -142,13 +142,6 @@ export default function EditPostPreferencesModal() {
) }
label={ __( 'Always open list view' ) }
/>
-
Date: Thu, 15 Sep 2022 17:35:18 +0300
Subject: [PATCH 14/29] adds back slash to allowed chars in shortcuts visual
expression
---
packages/keycodes/src/index.js | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/packages/keycodes/src/index.js b/packages/keycodes/src/index.js
index 12ba73acdbf7a..abfcb0ad31993 100644
--- a/packages/keycodes/src/index.js
+++ b/packages/keycodes/src/index.js
@@ -237,7 +237,7 @@ export const displayShortcutList = mapValues( modifiers, ( modifier ) => {
// so override the rule to allow symbols used for shortcuts.
// see: https://github.com/blakeembrey/change-case#options
const capitalizedCharacter = capitalCase( character, {
- stripRegexp: /[^A-Z0-9`,\.]/gi,
+ stripRegexp: /[^A-Z0-9`,\.\\]/gi,
} );
return [ ...modifierKeys, capitalizedCharacter ];
From 8bb362de4a8165726b30e07821b466ae5d83a5e7 Mon Sep 17 00:00:00 2001
From: Andrei Draganescu
Date: Tue, 20 Sep 2022 17:08:35 +0300
Subject: [PATCH 15/29] fix snapshot and pref modal test
---
.../test/__snapshots__/index.js.snap | 52 ++-----------------
.../preferences-modal/test/index.js | 6 +--
2 files changed, 6 insertions(+), 52 deletions(-)
diff --git a/packages/edit-post/src/components/preferences-modal/test/__snapshots__/index.js.snap b/packages/edit-post/src/components/preferences-modal/test/__snapshots__/index.js.snap
index aa0914a5e7bb8..95812a2828ea9 100644
--- a/packages/edit-post/src/components/preferences-modal/test/__snapshots__/index.js.snap
+++ b/packages/edit-post/src/components/preferences-modal/test/__snapshots__/index.js.snap
@@ -437,7 +437,7 @@ exports[`EditPostPreferencesModal should match snapshot when the modal is active
class="components-toggle-control__label"
for="inspector-toggle-control-5"
>
- Reduce the interface
+ Use theme styles
@@ -445,7 +445,7 @@ exports[`EditPostPreferencesModal should match snapshot when the modal is active
class="components-base-control__help emotion-6 emotion-7"
id="inspector-toggle-control-5__help"
>
- Compacts options and outlines in the toolbar.
+ Make the editor look like your theme.
@@ -482,52 +482,6 @@ exports[`EditPostPreferencesModal should match snapshot when the modal is active
-
-
-
- Make the editor look like your theme.
-
-
-
-
-
-
-
-
-
-
-
-
-
@@ -535,7 +489,7 @@ exports[`EditPostPreferencesModal should match snapshot when the modal is active
Shows block breadcrumbs at the bottom of the editor.