-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Dark Theme Support: Allow for theme modifications #28233
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
Changes from all commits
59ed2e7
094ae5b
a37043f
28e851a
e037fcd
abe459d
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.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,8 @@ | ||
| /** | ||
| * External dependencies | ||
| */ | ||
| import mergeRefs from 'react-merge-refs'; | ||
|
|
||
| /** | ||
| * WordPress dependencies | ||
| */ | ||
|
|
@@ -16,9 +21,10 @@ import { | |
| __experimentalBlockSettingsMenuFirstItem, | ||
| __experimentalUseResizeCanvas as useResizeCanvas, | ||
| __unstableUseCanvasClickRedirect as useCanvasClickRedirect, | ||
| __unstableUseEditorStyles as useEditorStyles, | ||
| } from '@wordpress/block-editor'; | ||
| import { Popover } from '@wordpress/components'; | ||
| import { useRef } from '@wordpress/element'; | ||
| import { useRef, useCallback } from '@wordpress/element'; | ||
|
|
||
| /** | ||
| * Internal dependencies | ||
|
|
@@ -27,7 +33,7 @@ import BlockInspectorButton from './block-inspector-button'; | |
| import { useSelect } from '@wordpress/data'; | ||
| import { store as editPostStore } from '../../store'; | ||
|
|
||
| export default function VisualEditor() { | ||
| export default function VisualEditor( { styles } ) { | ||
| const ref = useRef(); | ||
| const { deviceType, isTemplateMode } = useSelect( ( select ) => { | ||
| const { | ||
|
|
@@ -57,13 +63,18 @@ export default function VisualEditor() { | |
| useClipboardHandler( ref ); | ||
| useTypingObserver( ref ); | ||
| useCanvasClickRedirect( ref ); | ||
|
Contributor
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. It seems like there's a number of hooks above that can be reworked as hooks that return "refs" instead of receiving refs (outside the scope of this PR) |
||
| const editorStylesRef = useEditorStyles( styles ); | ||
| const mergedRefs = useCallback( mergeRefs( [ ref, editorStylesRef ] ), [ | ||
| ref, | ||
| editorStylesRef, | ||
| ] ); | ||
|
Member
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. When does @youknowriad We discussed this a few times that adding dependencies here will give problems when passing new functions as a callback ref.
Member
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. Ah I see your comment now #28233 (comment) |
||
|
|
||
| return ( | ||
| <div className="edit-post-visual-editor"> | ||
| <VisualEditorGlobalKeyboardShortcuts /> | ||
| <Popover.Slot name="block-toolbar" /> | ||
| <div | ||
| ref={ ref } | ||
| ref={ mergedRefs } | ||
| className="editor-styles-wrapper" | ||
| style={ resizedCanvasStyles || desktopCanvasStyles } | ||
| > | ||
|
|
||
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.
Love that we don't use this phrase :) It can be dark mode, or it can just be a dark background! 👌