-
Notifications
You must be signed in to change notification settings - Fork 4.6k
Add Inline comment experimental flag #60622
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 35 commits
10c9ed0
271895a
f2b7114
5e0890c
031e8d5
6b0c3b3
d2d6215
cbee86f
b36c2ab
b7b1ba4
6c0862d
77ee009
a8ea60e
ec302ff
f002607
fdc44a3
bb2c0bd
e6ac0b4
9447911
bf84cc4
57ed39a
b9668fd
6628689
1d81922
87fe4f9
139135d
20f2bd3
2df0bdb
515a592
08fd837
251ae5f
e747430
b7a5bd7
16d2186
877f090
1ce0191
1a677d8
d67d2b1
e0cb8b5
9004004
d23a0a6
cf605d5
f115c3b
f748ad9
59e96c4
18e5081
c9f4964
1ed6d54
84733c5
2d5d162
e68cdcc
8042e22
ceb188c
575361c
8c45982
a2345e8
2004c04
8ac8328
868c095
ab73559
d5df8cc
533c5d4
c0a5dcd
56e475b
9de8c69
4104869
b8b0292
6996e5f
0321430
3bf3c4c
c66fbcd
751d727
9a42d64
68d5e1c
1f5a2c2
6477102
66832a7
5c70d90
cc28c6a
951d8b4
b0ad9d5
a5e12e1
cf59158
6cfdb29
465b438
c9d50d8
fd6f327
15c85e0
c7be827
bd1a7ce
19dfab8
48ee928
8fa3f85
5f0ae80
69d1878
d6e01f3
668671b
ee6fe75
de2cd8f
8e6da19
90ba459
e2fd75a
aad19d0
6f03c48
2b057cc
59caf1c
efa41ac
4ee210d
38bea58
609cad6
8a54986
2fd78b0
f236a42
b3c879d
bc308e9
11cf1f1
22c189a
33cd398
211944c
a4abbec
5c99dcc
50e8101
ce7f7bc
b0c5960
f768b4a
92870c4
37fa922
4d6841a
71f7a39
6f73a0b
edab788
6e528a1
b129367
8d17f22
fd4c045
4d3eeb1
f06340a
6b8027a
06c8526
e1d4396
c78f981
da72b79
d7bca6e
68d203e
b296d2d
bddceeb
c5094a0
a23241a
9548565
06e840f
3883a11
334daf2
b028876
cd63f6a
9b12661
f287eff
16ebd4c
7aa5508
e55109f
f66d825
7ff9a79
d01c693
2caf2d1
6bda66d
64b1b31
31ea3b5
bdf982f
c5a53a2
c0aee07
1a251ba
452181d
898a924
11d6693
0326444
bf20345
c419ce4
667163e
25364d8
5a53245
f4dd385
83a5955
ec1a8b3
2a4a427
ffc7f51
0d36a58
ed6e2e6
9a6556f
ebc28ca
02bd950
f5be6ac
973f559
e3c49b7
ab1395c
f9f24d9
63f915f
fc43c1e
68c5272
3d14991
6b32fcf
9db107b
c92de93
97a6d6e
0136fae
13f53d8
4d0ca6e
c5b76e8
02aabd9
65e1eb4
e3bc354
c8ff644
8cd46c3
45f9553
27ab929
b9017a4
e3cb45b
c4d4b1d
345c227
7a6c085
aa2d47b
7ce91e9
4cd5835
00076ff
7bf2c78
514853c
4b59a86
1cfd88e
45f6ac9
42a4eb2
e42e647
8744c83
127228b
5781530
ca54345
2e212c1
4b8986b
b42cd97
30ddf61
e446297
1955469
22893f8
b89ce85
3f9d745
90b038b
b7c0c46
48c3351
7c00570
047e07f
a342e27
ae50d7a
2ca51c3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| <?php | ||
| /** | ||
| * Functions to support collaboration. | ||
| * | ||
| * @package gutenberg | ||
| */ | ||
|
|
||
| if ( ! function_exists( 'register_post_meta_for_collab_comment' ) ) { | ||
| /** | ||
| * Registers the collab meta field required for comments to work. | ||
| * | ||
| * @since // TODO: Add version number. | ||
| */ | ||
| function register_post_meta_for_collab_comment() { | ||
| $post_types = get_post_types( array( 'show_in_rest' => true ) ); | ||
|
|
||
| foreach ( $post_types as $post_type ) { | ||
| // Only register the meta field if the post type supports the editor, custom fields, and revisions. | ||
| if ( | ||
| post_type_supports( $post_type, 'editor' ) && | ||
| post_type_supports( $post_type, 'custom-fields' ) && | ||
| post_type_supports( $post_type, 'revisions' ) | ||
| ) { | ||
| register_post_meta( | ||
| $post_type, | ||
| 'collab', | ||
| array( | ||
| 'show_in_rest' => true, | ||
| 'single' => true, | ||
| 'type' => 'string', | ||
| 'revisions_enabled' => true, | ||
| ) | ||
| ); | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| /* | ||
| * Most post types are registered at priority 10, so use priority 20 here in | ||
| * order to catch them. | ||
| */ | ||
| add_action( 'init', 'register_post_meta_for_collab_comment', 20 ); | ||
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 |
|---|---|---|
|
|
@@ -232,6 +232,10 @@ _Returns_ | |
|
|
||
| - `string`: Processed string | ||
|
|
||
| ### CollabSidebar | ||
|
|
||
| Renders the Collab sidebar. | ||
|
||
|
|
||
| ### ColorPalette | ||
|
|
||
| > **Deprecated** since 5.3, use `wp.blockEditor.ColorPalette` instead. | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,184 @@ | ||
| /** | ||
| * WordPress dependencies | ||
| */ | ||
| import { __ } from '@wordpress/i18n'; | ||
| import { | ||
| comment as commentIcon, | ||
| commentAuthorAvatar as userIcon, | ||
| Icon, | ||
| check as resolvedIcon, | ||
| } from '@wordpress/icons'; | ||
| import { useSelect } from '@wordpress/data'; | ||
| import { | ||
| __experimentalHStack as HStack, | ||
| __experimentalVStack as VStack, | ||
| __experimentalText as Text, | ||
| } from '@wordpress/components'; | ||
| import { dateI18n, format, getSettings } from '@wordpress/date'; | ||
|
|
||
| /** | ||
| * Internal dependencies | ||
| */ | ||
| import PluginSidebar from '../plugin-sidebar'; | ||
| import { store as editorStore } from '../../store'; | ||
|
|
||
| const isBlockCommentExperimentEnabled = | ||
| window?.__experimentalEnableBlockComment; | ||
|
|
||
| /** | ||
| * Renders the Collab sidebar. | ||
| */ | ||
| export default function CollabSidebar() { | ||
| const { threads } = useSelect( ( select ) => { | ||
| const post = select( editorStore ).getCurrentPost(); | ||
|
|
||
| return { | ||
| threads: post?.meta?.collab ? JSON.parse( post.meta.collab ) : [], | ||
|
||
| }; | ||
| }, [] ); | ||
|
|
||
| // Check if the experimental flag is enabled and thread count is greater than zero. | ||
ellatrix marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| if ( | ||
| ! isBlockCommentExperimentEnabled || | ||
| Object.keys( threads ).length === 0 | ||
| ) { | ||
| return null; // or maybe return some message indicating no threads are available. | ||
| } | ||
|
|
||
| // Get the date time format from WordPress settings. | ||
| const dateTimeFormat = getSettings().formats.datetime; | ||
|
|
||
| return ( | ||
| <PluginSidebar | ||
| name="collab-activities" | ||
| title={ __( 'Collab Activities' ) } | ||
| icon={ commentIcon } | ||
| > | ||
| <div className="editor-collab-sidebar__activities"> | ||
| { Object.values( threads ) | ||
| .reverse() | ||
| .map( ( thread, index ) => ( | ||
| <VStack | ||
| key={ index } | ||
| className="editor-collab-sidebar__thread" | ||
| spacing="3" | ||
| > | ||
| <HStack | ||
| alignment="left" | ||
| spacing="3" | ||
| justify="flex-start" | ||
| > | ||
| <Icon | ||
| icon={ userIcon } | ||
| className="editor-collab-sidebar__userIcon" | ||
| size={ 35 } | ||
| /> | ||
| <VStack spacing="1"> | ||
| <span className="editor-collab-sidebar__userName"> | ||
| { thread.createdBy } | ||
| </span> | ||
| <time | ||
| dateTime={ format( | ||
| 'c', | ||
| thread.createdAt | ||
| ) } | ||
| > | ||
| { dateI18n( | ||
| dateTimeFormat, | ||
| thread.createdAt | ||
| ) } | ||
| </time> | ||
| </VStack> | ||
| </HStack> | ||
| { thread.comments.map( ( comment ) => ( | ||
| <VStack | ||
| key={ comment.commentId } | ||
| className="editor-collab-sidebar__comment" | ||
| > | ||
| <HStack | ||
| alignment="center" | ||
| spacing="3" | ||
| justify="flex-start" | ||
| > | ||
| <Icon | ||
| icon={ userIcon } | ||
| className="editor-collab-sidebar__userIcon" | ||
| size={ 35 } | ||
| /> | ||
| <VStack spacing="1"> | ||
| <span className="editor-collab-sidebar__userName"> | ||
| { comment.createdBy } | ||
| </span> | ||
| <time | ||
| dateTime={ format( | ||
| 'c', | ||
| comment.createdAt | ||
| ) } | ||
| > | ||
| { dateI18n( | ||
| dateTimeFormat, | ||
| comment.createdAt | ||
| ) } | ||
| </time> | ||
| </VStack> | ||
| </HStack> | ||
| <HStack | ||
| alignment="center" | ||
| spacing="1" | ||
| justify="flex-start" | ||
| > | ||
| { comment.comment } | ||
| </HStack> | ||
| </VStack> | ||
| ) ) } | ||
| { thread.isResolved && ( | ||
| <VStack className="editor-collab-sidebar__resolved"> | ||
| <HStack | ||
| alignment="center" | ||
| spacing="3" | ||
| justify="flex-start" | ||
| > | ||
| <Icon | ||
| icon={ userIcon } | ||
| className="editor-collab-sidebar__userIcon" | ||
| size={ 35 } | ||
| /> | ||
| <VStack spacing="1"> | ||
| <span className="editor-collab-sidebar__userName"> | ||
| { thread.resolvedBy } | ||
| </span> | ||
| <time | ||
| dateTime={ format( | ||
| 'c', | ||
| thread.resolvedAt | ||
| ) } | ||
| > | ||
| { dateI18n( | ||
| dateTimeFormat, | ||
| thread.resolvedAt | ||
| ) } | ||
| </time> | ||
| </VStack> | ||
| </HStack> | ||
| <HStack | ||
| alignment="center" | ||
| spacing="1" | ||
| justify="flex-start" | ||
| > | ||
| <Icon | ||
| icon={ resolvedIcon } | ||
| size={ 20 } | ||
| className="editor-collab-sidebar__resolvedIcon" | ||
| /> | ||
| <Text className="editor-collab-sidebar__resolvedText"> | ||
| { __( 'Marked as resolved' ) } | ||
| </Text> | ||
| </HStack> | ||
| </VStack> | ||
| ) } | ||
| </VStack> | ||
| ) ) } | ||
| </div> | ||
| </PluginSidebar> | ||
| ); | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| .editor-collab-sidebar { | ||
| &__activities { | ||
| background-color: #f3f5f6; | ||
| } | ||
|
|
||
| &__thread { | ||
| padding: 20px; | ||
| &:not(:last-child) { | ||
| border-bottom: 1px solid $gray-300; | ||
| } | ||
| } | ||
|
|
||
| &__comment, | ||
| &__resolved { | ||
| border: 1px solid $gray-300; | ||
| border-radius: 5px; | ||
| padding: 10px 15px; | ||
| background-color: #fff; | ||
| } | ||
|
|
||
| &__userName { | ||
| font-size: 14px; | ||
| text-transform: capitalize; | ||
| } | ||
|
|
||
| &__userIcon { | ||
| border: 1px solid #c5c5c5; | ||
| } | ||
|
|
||
| &__resolvedIcon { | ||
| fill: #008000; | ||
|
||
| border-radius: 50%; | ||
|
||
| width: 18px; | ||
| height: 18px; | ||
| border: 1px solid #008000; | ||
| margin-right: 2px; | ||
| margin-top: 5px; | ||
| } | ||
|
|
||
| &__resolvedText { | ||
| font-style: italic; | ||
| font-weight: 500 !important; | ||
| color: #808080 !important; | ||
| margin-top: 5px !important; | ||
|
||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -100,6 +100,7 @@ export { default as UnsavedChangesWarning } from './unsaved-changes-warning'; | |
| export { default as WordCount } from './word-count'; | ||
| export { default as TimeToRead } from './time-to-read'; | ||
| export { default as CharacterCount } from './character-count'; | ||
| export { default as CollabSidebar } from './collab-sidebar'; | ||
|
||
|
|
||
| // State Related Components. | ||
| export { default as EditorProvider } from './provider'; | ||
|
|
||
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.
This file should move within the experimental folder, otherwise it will be backported to core.
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.
Moved within Experimental folder