Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ function WritingMenu() {
shortcut={ displayShortcut.primaryShift( '\\' ) }
/>
<PreferenceToggleMenuItem
scope="core/edit-post"
scope="core"
name="focusMode"
label={ __( 'Spotlight mode' ) }
info={ __( 'Focus on one block at a time' ) }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ export default function EditPostPreferencesModal() {
label={ __( 'Distraction free' ) }
/>
<EnableFeature
scope="core"
featureName="focusMode"
help={ __(
'Highlights the current block and fades other content.'
Expand Down
4 changes: 0 additions & 4 deletions packages/edit-post/src/editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ function Editor( {

const {
hasFixedToolbar,
focusMode,
isDistractionFree,
hasInlineToolbar,
post,
Expand Down Expand Up @@ -91,7 +90,6 @@ function Editor( {
return {
hasFixedToolbar:
isFeatureActive( 'fixedToolbar' ) || ! isLargeViewport,
focusMode: isFeatureActive( 'focusMode' ),
isDistractionFree: isFeatureActive( 'distractionFree' ),
hasInlineToolbar: isFeatureActive( 'inlineToolbar' ),
preferredStyleVariations: select( preferencesStore ).get(
Expand Down Expand Up @@ -122,7 +120,6 @@ function Editor( {
onChange: updatePreferredStyleVariations,
},
hasFixedToolbar,
focusMode,
isDistractionFree,
hasInlineToolbar,

Expand Down Expand Up @@ -151,7 +148,6 @@ function Editor( {
settings,
hasFixedToolbar,
hasInlineToolbar,
focusMode,
isDistractionFree,
hiddenBlockTypes,
blockTypes,
Expand Down
5 changes: 0 additions & 5 deletions packages/edit-post/src/editor.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,13 @@ class Editor extends Component {
getEditorSettings(
settings,
hasFixedToolbar,
focusMode,
hiddenBlockTypes,
blockTypes
) {
settings = {
...settings,
isRTL: I18nManager.isRTL,
hasFixedToolbar,
focusMode,
};

// Omit hidden block types if exists and non-empty.
Expand Down Expand Up @@ -135,7 +133,6 @@ class Editor extends Component {
const {
settings,
hasFixedToolbar,
focusMode,
initialEdits,
hiddenBlockTypes,
blockTypes,
Expand All @@ -150,7 +147,6 @@ class Editor extends Component {
const editorSettings = this.getEditorSettings(
settings,
hasFixedToolbar,
focusMode,
hiddenBlockTypes,
blockTypes
);
Expand Down Expand Up @@ -198,7 +194,6 @@ export default compose( [

return {
hasFixedToolbar: isFeatureActive( 'fixedToolbar' ),
focusMode: isFeatureActive( 'focusMode' ),
mode: getEditorMode(),
hiddenBlockTypes: getHiddenBlockTypes(),
blockTypes: getBlockTypes(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ export default function useCommonCommands() {
name: 'core/toggle-spotlight-mode',
label: __( 'Toggle spotlight mode' ),
callback: ( { close } ) => {
toggle( 'core/edit-post', 'focusMode' );
toggle( 'core', 'focusMode' );
close();
},
} );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@ export function useSpecificEditorSettings() {
const getPostLinkProps = usePostLinkProps();
const {
templateSlug,
focusMode,
isDistractionFree,
hasFixedToolbar,
canvasMode,
Expand All @@ -121,7 +120,6 @@ export function useSpecificEditorSettings() {
const _context = getEditedPostContext();
return {
templateSlug: _record.slug,
focusMode: !! getPreference( 'core/edit-site', 'focusMode' ),
isDistractionFree: !! getPreference(
'core/edit-site',
'distractionFree'
Expand All @@ -144,7 +142,7 @@ export function useSpecificEditorSettings() {

richEditingEnabled: true,
supportsTemplateMode: true,
focusMode: canvasMode === 'view' && focusMode ? false : focusMode,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a breaking change; the spotlight mode will now apply in view mode.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can restore it but I don't like that part :P

@Mamaduka Mamaduka Jan 4, 2024 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the current behavior creates bad UX when exploring theme styles.

Update: Actually, the behavior is the same on the trunk when browsing styles from the sidebar; this might be something we'll need to fix separately.

The 2da2fd6 fixed regression for view mode.

Screenshot

CleanShot.2024-01-04.at.12.03.50.mp4

focusMode: canvasMode !== 'view',
Comment thread
ntsekouras marked this conversation as resolved.
Resolved
isDistractionFree,
hasFixedToolbar,
defaultRenderingMode,
Expand All @@ -156,7 +154,6 @@ export function useSpecificEditorSettings() {
}, [
settings,
canvasMode,
focusMode,
isDistractionFree,
hasFixedToolbar,
defaultRenderingMode,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ export default function MoreMenu( { showIconLabels } ) {
) }
/>
<PreferenceToggleMenuItem
scope="core/edit-site"
scope="core"
name="focusMode"
label={ __( 'Spotlight mode' ) }
info={ __( 'Focus on one block at a time' ) }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ export default function EditSitePreferencesModal() {
label={ __( 'Distraction free' ) }
/>
<EnableFeature
scope="core"
featureName="focusMode"
help={ __(
'Highlights the current block and fades other content.'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ function useEditUICommands() {
name: 'core/toggle-spotlight-mode',
label: __( 'Toggle spotlight mode' ),
callback: ( { close } ) => {
toggle( 'core/edit-site', 'focusMode' );
toggle( 'core', 'focusMode' );
close();
},
} );
Expand Down
2 changes: 1 addition & 1 deletion packages/edit-site/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ export function initializeEditor( id, settings ) {
dispatch( preferencesStore ).setDefaults( 'core/edit-site', {
editorMode: 'visual',
fixedToolbar: false,
focusMode: false,
distractionFree: false,
welcomeGuide: true,
welcomeGuideStyles: true,
Expand All @@ -64,6 +63,7 @@ export function initializeEditor( id, settings ) {

dispatch( preferencesStore ).setDefaults( 'core', {
allowRightClickOverrides: true,
focusMode: false,
keepCaretInsideBlock: false,
showBlockBreadcrumbs: true,
showListViewByDefault: false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ const BLOCK_EDITOR_SETTINGS = [
'enableCustomSpacing',
'enableCustomUnits',
'enableOpenverseMediaCategory',
'focusMode',
'distractionFree',
'fontSizes',
'gradients',
Expand Down Expand Up @@ -90,6 +89,7 @@ const BLOCK_EDITOR_SETTINGS = [
function useBlockEditorSettings( settings, postType, postId ) {
const {
allowRightClickOverrides,
focusMode,
keepCaretInsideBlock,
reusableBlocks,
hasUploadPermissions,
Expand Down Expand Up @@ -131,6 +131,7 @@ function useBlockEditorSettings( settings, postType, postId ) {
postType,
postId
)?._links?.hasOwnProperty( 'wp:action-unfiltered-html' ),
focusMode: get( 'core', 'focusMode' ),
keepCaretInsideBlock: get( 'core', 'keepCaretInsideBlock' ),
reusableBlocks: isWeb
? getEntityRecords( 'postType', 'wp_block', {
Expand Down Expand Up @@ -214,6 +215,8 @@ function useBlockEditorSettings( settings, postType, postId ) {
[ saveEntityRecord, userCanCreatePages ]
);

const forceDisableFocusMode = settings.focusMode === false;

return useMemo(
() => ( {
...Object.fromEntries(
Expand All @@ -222,6 +225,7 @@ function useBlockEditorSettings( settings, postType, postId ) {
)
),
allowRightClickOverrides,
focusMode: focusMode && ! forceDisableFocusMode,
keepCaretInsideBlock,
mediaUpload: hasUploadPermissions ? mediaUpload : undefined,
__experimentalReusableBlocks: reusableBlocks,
Expand Down Expand Up @@ -257,6 +261,8 @@ function useBlockEditorSettings( settings, postType, postId ) {
} ),
[
allowRightClickOverrides,
focusMode,
forceDisableFocusMode,
keepCaretInsideBlock,
settings,
hasUploadPermissions,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export default function convertEditorSettings( data ) {
let newData = data;
const settingsToMoveToCore = [
'allowRightClickOverrides',
'focusMode',
'keepCaretInsideBlock',
'showBlockBreadcrumbs',
'showIconLabels',
Expand Down