@@ -1124,6 +1124,47 @@ describe('internal helper functions', () => {
11241124 expect ( payload ?. deletedText ) . toBe ( 'original' ) ;
11251125 } ) ;
11261126
1127+ it ( 'preserves deletedText on replacement update when transaction meta only carries insertion mark' , ( ) => {
1128+ const schema = createCommentSchema ( ) ;
1129+ const insertMark = schema . marks [ TrackInsertMarkName ] . create ( {
1130+ id : 'replace-update-1' ,
1131+ author : 'Author' ,
1132+ authorEmail : 'author@example.com' ,
1133+ date : 'today' ,
1134+ } ) ;
1135+ const deleteMark = schema . marks [ TrackDeleteMarkName ] . create ( {
1136+ id : 'replace-update-1' ,
1137+ author : 'Author' ,
1138+ authorEmail : 'author@example.com' ,
1139+ date : 'today' ,
1140+ } ) ;
1141+
1142+ const docInsertNode = schema . text ( 'replacement' , [ insertMark ] ) ;
1143+ const docDeleteNode = schema . text ( 'original' , [ deleteMark ] ) ;
1144+ const doc = schema . node ( 'doc' , null , [ schema . node ( 'paragraph' , null , [ docInsertNode , docDeleteNode ] ) ] ) ;
1145+ const state = EditorState . create ( { schema, doc } ) ;
1146+
1147+ // Simulate an update transaction where meta has only insertedMark, but the
1148+ // document still has both insert+delete marks under the same tracked-change id.
1149+ const payload = createOrUpdateTrackedChangeComment ( {
1150+ event : 'update' ,
1151+ marks : { insertedMark : insertMark , deletionMark : null , formatMark : null } ,
1152+ deletionNodes : [ ] ,
1153+ nodes : [ schema . text ( 'replacement' , [ insertMark ] ) ] ,
1154+ newEditorState : state ,
1155+ documentId : 'doc-1' ,
1156+ trackedChangesForId : [
1157+ { mark : insertMark , from : 1 , to : doc . content . size } ,
1158+ { mark : deleteMark , from : 1 , to : doc . content . size } ,
1159+ ] ,
1160+ } ) ;
1161+
1162+ expect ( payload ?. event ) . toBe ( comments_module_events . UPDATE ) ;
1163+ expect ( payload ?. trackedChangeType ) . toBe ( 'both' ) ;
1164+ expect ( payload ?. trackedChangeText ) . toBe ( 'replacement' ) ;
1165+ expect ( payload ?. deletedText ) . toBe ( 'original' ) ;
1166+ } ) ;
1167+
11271168 it ( 'createOrUpdateTrackedChangeComment builds add and update payloads' , ( ) => {
11281169 const schema = createCommentSchema ( ) ;
11291170 const insertMark = schema . marks [ TrackInsertMarkName ] . create ( {
0 commit comments