-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Inline Commenting: Added new sidebar as extension of the canvas #67347
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
Merged
Merged
Changes from 1 commit
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
35c9f23
Create new sidebar as extension of editor canvas for commenting
akasunil f1d7e1c
Cleanup and error fix
akasunil b1f0488
Merge branch 'trunk' of github.com:WordPress/gutenberg into try/inlin…
akasunil c60972c
Keep collab sidebar open when comments are available
akasunil 06c49ba
Merge branch 'trunk' of github.com:WordPress/gutenberg into try/inlin…
akasunil d096211
Remove fallback background color function
akasunil File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Keep collab sidebar open when comments are available
- Loading branch information
commit c60972c05820b8cca22a2dd919bb39827b1e5f4c
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,7 +2,12 @@ | |
| * WordPress dependencies | ||
| */ | ||
| import { __ } from '@wordpress/i18n'; | ||
| import { useSelect, useDispatch, resolveSelect } from '@wordpress/data'; | ||
| import { | ||
| useSelect, | ||
| useDispatch, | ||
| resolveSelect, | ||
| subscribe, | ||
| } from '@wordpress/data'; | ||
| import { useState, useMemo } from '@wordpress/element'; | ||
| import { comment as commentIcon } from '@wordpress/icons'; | ||
| import { addFilter } from '@wordpress/hooks'; | ||
|
|
@@ -22,6 +27,7 @@ import { store as editorStore } from '../../store'; | |
| import AddCommentButton from './comment-button'; | ||
| import AddCommentToolbarButton from './comment-button-toolbar'; | ||
| import { getEditorCanvasBackgroundColor } from './utils'; | ||
| import { useGlobalStylesContext } from '../global-styles-provider'; | ||
|
|
||
| const isBlockCommentExperimentEnabled = | ||
| window?.__experimentalEnableBlockComment; | ||
|
|
@@ -213,6 +219,7 @@ function CollabSidebarContent( { | |
| export default function CollabSidebar() { | ||
| const [ showCommentBoard, setShowCommentBoard ] = useState( false ); | ||
| const { enableComplementaryArea } = useDispatch( interfaceStore ); | ||
| const { getActiveComplementaryArea } = useSelect( interfaceStore ); | ||
|
|
||
| const { postStatus } = useSelect( ( select ) => { | ||
| return { | ||
|
|
@@ -285,6 +292,21 @@ export default function CollabSidebar() { | |
| return result; | ||
| }, [ threads ] ); | ||
|
|
||
| // Get the global styles to set the background color of the sidebar. | ||
| const { merged: GlobalStyles } = useGlobalStylesContext(); | ||
| const backgroundColor = GlobalStyles?.styles?.color?.background; | ||
|
|
||
| if ( 0 < resultComments.length ) { | ||
| const unsubscribe = subscribe( () => { | ||
| const activeSidebar = getActiveComplementaryArea( 'core' ); | ||
|
|
||
| if ( ! activeSidebar ) { | ||
| enableComplementaryArea( 'core', 'edit-post/collab-sidebar' ); | ||
| unsubscribe(); | ||
| } | ||
| } ); | ||
|
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. We could probably create an option for |
||
| } | ||
|
|
||
| // Check if the experimental flag is enabled. | ||
| if ( ! isBlockCommentExperimentEnabled || postStatus === 'publish' ) { | ||
| return null; // or maybe return some message indicating no threads are available. | ||
|
|
@@ -321,7 +343,8 @@ export default function CollabSidebar() { | |
| showCommentBoard={ showCommentBoard } | ||
| setShowCommentBoard={ setShowCommentBoard } | ||
| styles={ { | ||
| backgroundColor: getEditorCanvasBackgroundColor(), | ||
| backgroundColor: | ||
| backgroundColor ?? getEditorCanvasBackgroundColor(), | ||
| } } | ||
| /> | ||
| </PluginSidebar> | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Can you change this to an effect? We shouldn't subscribe on render.
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.
useEffectwon't work in this case, as the component doesn't re-render when another sidebar is toggled from outside the editor.