-
Notifications
You must be signed in to change notification settings - Fork 4.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Site and Post Editor: Unify the DocumentBar component #56778
Changes from 4 commits
52fffad
d65db30
593b841
4f69987
f7653d6
4257daf
a9b300f
d1eb313
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
This file was deleted.
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -97,10 +97,12 @@ export function useSpecificEditorSettings() { | |
keepCaretInsideBlock, | ||
canvasMode, | ||
settings, | ||
postWithTemplate, | ||
} = useSelect( ( select ) => { | ||
const { | ||
getEditedPostType, | ||
getEditedPostId, | ||
getEditedPostContext, | ||
getCanvasMode, | ||
getSettings, | ||
} = unlock( select( editSiteStore ) ); | ||
|
@@ -113,6 +115,7 @@ export function useSpecificEditorSettings() { | |
usedPostType, | ||
usedPostId | ||
); | ||
const _context = getEditedPostContext(); | ||
return { | ||
templateSlug: _record.slug, | ||
focusMode: !! getPreference( 'core/edit-site', 'focusMode' ), | ||
|
@@ -130,9 +133,13 @@ export function useSpecificEditorSettings() { | |
), | ||
canvasMode: getCanvasMode(), | ||
settings: getSettings(), | ||
postWithTemplate: _context?.postId, | ||
}; | ||
}, [] ); | ||
const archiveLabels = useArchiveLabel( templateSlug ); | ||
const defaultRenderingMode = useMemo( () => { | ||
return postWithTemplate ? 'template-locked' : 'all'; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why memo? It's just a string? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Bad habit. Thanks for noticing |
||
}, [ postWithTemplate ] ); | ||
|
||
const defaultEditorSettings = useMemo( () => { | ||
return { | ||
|
@@ -144,6 +151,7 @@ export function useSpecificEditorSettings() { | |
isDistractionFree, | ||
hasFixedToolbar, | ||
keepCaretInsideBlock, | ||
defaultRenderingMode, | ||
|
||
// I wonder if they should be set in the post editor too | ||
__experimentalArchiveTitleTypeLabel: archiveLabels.archiveTypeLabel, | ||
|
@@ -159,6 +167,7 @@ export function useSpecificEditorSettings() { | |
canvasMode, | ||
archiveLabels.archiveTypeLabel, | ||
archiveLabels.archiveNameLabel, | ||
defaultRenderingMode, | ||
] ); | ||
|
||
return defaultEditorSettings; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed this because it gets out of sync very quickly as the code evolves.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could replace the reference to specific instances with a search query like https://github.com/search?q=repo%3AWordPress%2Fgutenberg+commandsStore+language%3AJavaScript&type=code&l=JavaScript which should always return relevant results.