Skip to content

Commit

Permalink
adds inline format toolbar in distraction free mode
Browse files Browse the repository at this point in the history
  • Loading branch information
draganescu committed Jul 6, 2022
1 parent ce7f7cc commit 63c3fbd
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
17 changes: 16 additions & 1 deletion packages/block-editor/src/components/rich-text/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ function RichTextWrapper(
isSelected,
};
};

// This selector must run on every render so the right selection state is
// retreived from the store on merge.
// To do: fix this somehow.
Expand Down Expand Up @@ -171,6 +172,16 @@ function RichTextWrapper(
);
}

// Check reduced UI to force the inline formatting toolbar
const distractionFreeSelector = ( select ) => {
const { getSettings } = select( blockEditorStore );
const settings = getSettings();
return {
hasReducedUI: settings.hasReducedUI,
};
};
const { hasReducedUI } = useSelect( distractionFreeSelector );

const onSelectionChange = useCallback(
( start, end ) => {
const selection = {};
Expand Down Expand Up @@ -342,7 +353,11 @@ function RichTextWrapper(
) }
{ isSelected && hasFormats && (
<FormatToolbarContainer
inline={ inlineToolbar }
inline={
! isCollapsed( value ) && hasReducedUI
? true
: inlineToolbar
}
anchorRef={ anchorRef }
/>
) }
Expand Down
5 changes: 4 additions & 1 deletion packages/edit-post/src/components/header/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,14 @@
& > .edit-post-header__settings > .block-editor-post-preview__dropdown,
& > .edit-post-header__settings > .editor-post-preview,
& > .edit-post-header__settings > .editor-post-switch-to-draft,
& > .edit-post-header__settings > .interface-pinned-items,
& > .edit-post-header__toolbar {
visibility: hidden;
}

& > .edit-post-header__settings > .interface-pinned-items {
display: none;
}

& > .edit-post-header__settings > .editor-post-publish-button,
& > .edit-post-header__settings > .editor-post-publish-panel__toggle,
& > .edit-post-header__settings .interface-more-menu-dropdown {
Expand Down

0 comments on commit 63c3fbd

Please sign in to comment.