Skip to content
Merged
Changes from all commits
Commits
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
Sync post title
  • Loading branch information
chriszarate committed Aug 21, 2025
commit 74ed47b71b9f921952fc2eae848b48d78b94e2e9
39 changes: 28 additions & 11 deletions packages/core-data/src/entities.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,7 @@ const POST_RAW_ATTRIBUTES = [ 'title', 'excerpt', 'content' ];
* @return {import('@wordpress/sync').ObjectData} The JSON representation of the document.
*/
const defaultFromCRDTDoc = ( ydoc ) => {
const json = ydoc.getMap( 'document' ).toJSON();
if ( json.title?.raw ) {
json.title = json.title.raw;
}
return json;
return ydoc.getMap( 'document' ).toJSON();
};

export const rootEntitiesConfig = [
Expand Down Expand Up @@ -268,6 +264,7 @@ async function loadPostTypeEntities() {
'sticky',
'tags',
'template',
'title',
] );

const postTypes = await apiFetch( {
Expand Down Expand Up @@ -324,6 +321,16 @@ async function loadPostTypeEntities() {
return ycontent.get( key );
}

// Set primitive a value (strings, numbers, booleans).
function setPrimitiveValue( primitiveValue ) {
mergePrimitiveValue(
currentValue ?? undefined,
primitiveValue ?? undefined,
setValue,
origin
);
}

switch ( key ) {
case 'blocks': {
let currentBlocks = currentValue;
Expand All @@ -340,15 +347,25 @@ async function loadPostTypeEntities() {
break;
}

case 'title': {
// Copy logic from prePersistPostType to ensure that the "Auto
// Draft" template title is not synced.
let rawNewValue = newValue?.raw ?? newValue;
if (
! currentValue &&
'Auto Draft' === rawNewValue
) {
rawNewValue = '';
}

setPrimitiveValue( rawNewValue );
break;
}

// Add support for additional data types here.

default: {
mergePrimitiveValue(
currentValue ?? undefined,
newValue ?? undefined,
setValue,
origin
);
setPrimitiveValue( newValue );
}
}
} );
Expand Down
Loading