Skip to content

Conversation

@shekharnwagh
Copy link

@shekharnwagh shekharnwagh commented Nov 12, 2025

Add CollaborationMode SlotFill for editor toolbar

What?

Adds a new CollaborationMode SlotFill that lets plugins display collaboration mode indicators (like view/edit state) in the editor toolbar.

Why?

For real-time collaboration, we need to show users their current mode - whether they can edit or are in view-only mode. This follows the same pattern as EditorPresence.

How?

  • Created CollaborationMode SlotFill component
  • Added slot as first element in the left toolbar section
  • Exported as a private API

Testing Instructions

  1. Open the editor and verify it loads without errors
  2. Check that toolbar functions normally (no visual changes without a plugin using the slot)

To test with a plugin:

const { CollaborationMode } = unlock( editorStore.privateApis );

<CollaborationMode>
    <div>Edit Mode</div>
</CollaborationMode>

The indicator should appear as the first item in the left toolbar.

Screenshots or screencast

N/A - Infrastructure only, no visual changes without a Fill.

Creates a new SlotFill component similar to EditorPresence that allows
plugins to inject collaboration mode indicators (like view/edit state)
into the editor toolbar.

The slot renders as the first element in editor-document-tools__left,
making collaboration status immediately visible to users. This follows
the same pattern as EditorPresence and is exported as a private API
for use by collaboration plugins.
@github-actions
Copy link

github-actions bot commented Nov 12, 2025

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: shekharnwagh <shekharnwagh@git.wordpress.org>
Co-authored-by: Mamaduka <mamaduka@git.wordpress.org>
Co-authored-by: ingeniumed <ingeniumed@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@github-actions github-actions bot added the First-time Contributor Pull request opened by a first-time contributor to Gutenberg repository label Nov 12, 2025
@github-actions
Copy link

👋 Thanks for your first Pull Request and for helping build the future of Gutenberg and WordPress, @shekharnwagh! In case you missed it, we'd love to have you join us in our Slack community.

If you want to learn more about WordPress development in general, check out the Core Handbook full of helpful information.

Copy link
Member

@Mamaduka Mamaduka left a comment

Choose a reason for hiding this comment

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

The editor-document-tools__left area is getting crowded with recent iterations.

It would be nice to get design feedback here, before we move forward.

P.S. Is there an associated issue for this task?

Screenshot

CleanShot 2025-11-12 at 16 23 05

*/
import { createSlotFill } from '@wordpress/components';

const { Fill, Slot } = createSlotFill( 'CollaborationMode' );
Copy link
Member

Choose a reason for hiding this comment

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

This SlotFill is still public; when the name is a string, anyone who knows it can use it. Please take a look at #67238 for better examples.

Comment on lines +8 to +13
/**
* Renders the SlotFill for collaboration mode.
*/
export const CollaborationMode = Fill;

export { Slot };
Copy link
Member

Choose a reason for hiding this comment

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

This exmport can be simplified.

const CollaborationModeSlotFill = createSlotFill( 'CollaborationMode' );

export CollaborationModeSlotFill;

// Somewhere else in the app.

<CollaborationModeSlotFill.Slot></CollaborationModeSlotFill.Slot>

<CollaborationModeSlotFill.Fill></CollaborationModeSlotFill.Fill>

@Mamaduka Mamaduka added [Feature] Real-time Collaboration Phase 3 of the Gutenberg roadmap around real-time collaboration [Type] Experimental Experimental feature or API. labels Nov 12, 2025
@ingeniumed
Copy link
Contributor

ingeniumed commented Nov 12, 2025

@Mamaduka - Thanks for the quick review on this PR! This is actually not going into trunk, but into our experimental branch - wpvip/rtc-plugin where we are building out real-time collaboration. Once it goes into that branch, we cherry pick changes and turn them into formal PRs into trunk. It'd be that point that it'd be ready for formal review.

We'll def take your comments into consideration, but not all of them may be solved in this PR. They will be before the formal PR 🙏🏾

The corresponding issue is #52593.

Changes the CollaborationMode SlotFill to use a Symbol instead of a
string for the slot name. This makes the slot truly private by ensuring
only code with a reference to the exported Fill/Slot components can
access it.

String-based slot names can be accessed by anyone who knows the name.
Using Symbol() prevents unauthorized usage and follows the pattern
established in PR WordPress#67238.
Copy link
Contributor

@ingeniumed ingeniumed left a comment

Choose a reason for hiding this comment

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

This is good for our wpvip branch. We can work on it a bit more before our PR into trunk.

@ingeniumed ingeniumed merged commit 513d4cc into WordPress:wpvip/rtc-plugin Nov 14, 2025
34 checks passed
@ingeniumed ingeniumed changed the title Add CollaborationMode SlotFill for editor toolbar Real-time collaboration: Add CollaborationMode SlotFill for editor toolbar Nov 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Feature] Real-time Collaboration Phase 3 of the Gutenberg roadmap around real-time collaboration First-time Contributor Pull request opened by a first-time contributor to Gutenberg repository [Type] Experimental Experimental feature or API.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants