Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
bdc9719
Real-time collaboration: [pr-72407] Add UndoManager support for colla…
chriszarate Oct 16, 2025
68cb64d
Real-time collaboration: [pr-72437] Add Yjs awareness
chriszarate Oct 16, 2025
d32aaee
Real-time collaboration: [no-pr] Add <EditorsPresence> SlotFill
chriszarate Oct 17, 2025
2f5b6e9
Real-time collaboration: [no-pr] Add <BlockCanvasCover> and <VisualEd…
chriszarate Oct 17, 2025
e85a436
Real-time collaboration: [no-pr] Only render presence UI container on…
maxschmeling Oct 23, 2025
637dc0f
Real-time collaboration: [no-pr] Refetch entity when it is saved by a…
chriszarate Oct 31, 2025
11b3bb3
Real-time collaboration: [pr-72450] Add typings in core-data for @wor…
chriszarate Oct 17, 2025
17b5bdd
Real-time collaboration: [no-pr] Replace fast-diff in quill-delta (wi…
alecgeatches Oct 23, 2025
221db30
Block all saves for user id 4 as a test for viewing
ingeniumed Nov 20, 2025
3dd7f70
Port the mode picker to GB
ingeniumed Nov 20, 2025
61acfac
Get the selector dropdown to work
ingeniumed Nov 20, 2025
34fb804
Use the new mode from within GB
ingeniumed Nov 20, 2025
9c5db94
Actually export the reducer
ingeniumed Nov 21, 2025
4d11c79
Restrict view mode to only when the experiment is enabled
ingeniumed Nov 21, 2025
8b5e5f0
Prettify the code
ingeniumed Nov 21, 2025
8a386f5
Restrict the post title, and code-editor
ingeniumed Nov 21, 2025
a631f28
Add a guard in place
ingeniumed Nov 21, 2025
d50b53e
Real-time collaboration: [pr-72407] Add UndoManager support for colla…
chriszarate Oct 16, 2025
ee756b9
Real-time collaboration: [pr-72437] Add Yjs awareness
chriszarate Oct 16, 2025
c66cb1f
Real-time collaboration: [no-pr] Add <EditorsPresence> SlotFill
chriszarate Oct 17, 2025
368b3f9
Real-time collaboration: [no-pr] Add <BlockCanvasCover> and <VisualEd…
chriszarate Oct 17, 2025
666fb90
Real-time collaboration: [no-pr] Only render presence UI container on…
maxschmeling Oct 23, 2025
1644fb1
Real-time collaboration: [no-pr] Refetch entity when it is saved by a…
chriszarate Oct 31, 2025
4f9211b
Real-time collaboration: [no-pr] Sync collections
chriszarate Nov 7, 2025
095481d
Real-time collaboration: [no-pr] Do not call saveRecord when persiste…
chriszarate Nov 20, 2025
ea75cdb
Remove the unnecessary support changes
ingeniumed Dec 1, 2025
46fa121
remove tsconfig changes
ingeniumed Dec 1, 2025
2a2d1d6
Remove extra typings field
ingeniumed Dec 1, 2025
5168654
revert unnecessary change
ingeniumed Dec 2, 2025
17b2c06
Combine the selectors as per CR
ingeniumed Dec 3, 2025
0a733b8
Fix the linting
ingeniumed Dec 3, 2025
8e0c8cd
Revert some unnecessary changes
ingeniumed Dec 4, 2025
7374c1e
Move collaborator mode to editor store, and remove the temporary bloc…
ingeniumed Dec 5, 2025
560d2ee
Fix the linting issues
ingeniumed Dec 5, 2025
495827d
Tweak the changes
ingeniumed Dec 5, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions docs/reference-guides/data/data-core-editor.md
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,18 @@ _Related_

- getClientIdsWithDescendants in core/block-editor store.

### getCollaboratorMode

Returns the current collaborator mode.

_Parameters_

- _state_ `Object`: Editor state.

_Returns_

- `'view' | 'edit'`: Collaborator mode.

### getCurrentPost

Returns the post currently being edited in its last known saved state, not including unsaved edits. Returns an object containing relevant default post values if the post has not yet been saved.
Expand Down Expand Up @@ -1470,6 +1482,18 @@ _Related_

- selectBlock in core/block-editor store.

### setCollaboratorMode

Returns an action object used in signalling that the collaborator mode has been set.

_Parameters_

- _collaboratorMode_ `'view' | 'edit'`: The collaborator mode.

_Returns_

- `Object`: Action object.

### setDeviceType

Action that changes the width of the editing canvas.
Expand Down
40 changes: 27 additions & 13 deletions packages/editor/src/components/post-text-editor/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,20 +26,32 @@ import { store as editorStore } from '../../store';
*/
export default function PostTextEditor() {
const instanceId = useInstanceId( PostTextEditor );
const { content, blocks, type, id } = useSelect( ( select ) => {
const { getEditedEntityRecord } = select( coreStore );
const { getCurrentPostType, getCurrentPostId } = select( editorStore );
const _type = getCurrentPostType();
const _id = getCurrentPostId();
const editedRecord = getEditedEntityRecord( 'postType', _type, _id );
const { content, blocks, type, id, collaboratorMode } = useSelect(
( select ) => {
const { getEditedEntityRecord } = select( coreStore );
const {
getCurrentPostType,
getCurrentPostId,
getCollaboratorMode,
} = select( editorStore );
const _type = getCurrentPostType();
const _id = getCurrentPostId();
const editedRecord = getEditedEntityRecord(
'postType',
_type,
_id
);

return {
content: editedRecord?.content,
blocks: editedRecord?.blocks,
type: _type,
id: _id,
};
}, [] );
return {
content: editedRecord?.content,
blocks: editedRecord?.blocks,
type: _type,
id: _id,
collaboratorMode: getCollaboratorMode(),
};
},
[]
);
const { editEntityRecord } = useDispatch( coreStore );
// Replicates the logic found in getEditedPostContent().
const value = useMemo( () => {
Expand All @@ -63,6 +75,8 @@ export default function PostTextEditor() {
{ __( 'Type text or HTML' ) }
</VisuallyHidden>
<Textarea
readOnly={ collaboratorMode === 'view' }
contentEditable={ collaboratorMode === 'edit' }
autoComplete="off"
dir="auto"
value={ value }
Expand Down
9 changes: 7 additions & 2 deletions packages/editor/src/components/post-title/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,18 @@ import { DEFAULT_CLASSNAMES, REGEXP_NEWLINES } from './constants';
import usePostTitleFocus from './use-post-title-focus';
import usePostTitle from './use-post-title';
import PostTypeSupportCheck from '../post-type-support-check';
import { store as editorStore } from '../../store';

const PostTitle = forwardRef( ( _, forwardedRef ) => {
const { placeholder } = useSelect( ( select ) => {
const { placeholder, collaboratorMode } = useSelect( ( select ) => {
const { getSettings } = select( blockEditorStore );
const { titlePlaceholder } = getSettings();

const { getCollaboratorMode } = select( editorStore );

return {
placeholder: titlePlaceholder,
collaboratorMode: getCollaboratorMode(),
};
}, [] );

Expand Down Expand Up @@ -173,11 +177,12 @@ const PostTitle = forwardRef( ( _, forwardedRef ) => {
/* eslint-disable jsx-a11y/heading-has-content, jsx-a11y/no-noninteractive-element-to-interactive-role */
<h1
ref={ useMergeRefs( [ richTextRef, focusRef ] ) }
contentEditable
contentEditable={ collaboratorMode === 'edit' }
className={ className }
aria-label={ decodedPlaceholder }
role="textbox"
aria-multiline="true"
readOnly={ collaboratorMode === 'view' }
onFocus={ onSelect }
onBlur={ onUnselect }
onKeyDown={ onKeyDown }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import { useState, forwardRef } from '@wordpress/element';
import { DEFAULT_CLASSNAMES, REGEXP_NEWLINES } from './constants';
import usePostTitleFocus from './use-post-title-focus';
import usePostTitle from './use-post-title';
import { store as editorStore } from '../../store';

/**
* Renders a raw post title input field.
Expand All @@ -29,12 +30,15 @@ import usePostTitle from './use-post-title';
* @return {React.ReactNode} The rendered component.
*/
function PostTitleRaw( _, forwardedRef ) {
const { placeholder } = useSelect( ( select ) => {
const { placeholder, collaboratorMode } = useSelect( ( select ) => {
const { getSettings } = select( blockEditorStore );
const { titlePlaceholder } = getSettings();

const { getCollaboratorMode } = select( editorStore );

return {
placeholder: titlePlaceholder,
collaboratorMode: getCollaboratorMode(),
};
}, [] );

Expand Down Expand Up @@ -67,6 +71,8 @@ function PostTitleRaw( _, forwardedRef ) {

return (
<TextareaControl
readOnly={ collaboratorMode === 'view' }
contentEditable={ collaboratorMode === 'edit' }
ref={ focusRef }
value={ title }
onChange={ onChange }
Expand Down
14 changes: 14 additions & 0 deletions packages/editor/src/store/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -666,6 +666,20 @@ export function setDeviceType( deviceType ) {
};
}

/**
* Returns an action object used in signalling that the collaborator mode has been set.
*
* @param {'view' | 'edit'} collaboratorMode The collaborator mode.
*
* @return {Object} Action object.
*/
export function setCollaboratorMode( collaboratorMode ) {
return {
type: 'SET_COLLABORATOR_MODE',
collaboratorMode,
};
}

/**
* Returns an action object used to enable or disable a panel in the editor.
*
Expand Down
18 changes: 18 additions & 0 deletions packages/editor/src/store/reducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,23 @@ export function deviceType( state = 'Desktop', action ) {
return state;
}

/**
* Reducer managing the current collaborator mode.
*
* @param {Object} state Current state.
* @param {Object} action Dispatched action.
*
* @return {Object} Updated state.
*/
export function collaboratorMode( state = 'edit', action ) {
switch ( action.type ) {
case 'SET_COLLABORATOR_MODE':
return action.collaboratorMode;
}

return state;
}

/**
* Reducer storing the list of all programmatically removed panels.
*
Expand Down Expand Up @@ -412,6 +429,7 @@ export default combineReducers( {
postAutosavingLock,
renderingMode,
deviceType,
collaboratorMode,
removedPanels,
blockInserterPanel,
inserterSidebarToggleRef,
Expand Down
19 changes: 19 additions & 0 deletions packages/editor/src/store/selectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -1357,6 +1357,25 @@ export const getDeviceType = createRegistrySelector(
}
);

/**
* Returns the current collaborator mode.
*
* @param {Object} state Editor state.
*
* @return {'view' | 'edit'} Collaborator mode.
*/
export function getCollaboratorMode( state ) {
if ( window.__experimentalEnableSync ) {
if ( globalThis.IS_GUTENBERG_PLUGIN ) {
return state.collaboratorMode;
}
}

// Default to edit mode if the collaboration experiment is not enabled, or
// if the Gutenberg plugin is not being used.
return 'edit';
}

/**
* Returns true if the list view is opened.
*
Expand Down
Loading