@@ -331,70 +331,40 @@ describe('calculateInlineRunPropertiesPlugin', () => {
331331 expect ( paragraph . attrs . paragraphProperties ) . toBeNull ( ) ;
332332 } ) ;
333333
334- it ( ' does not sync paragraph runProperties for first runs inside inline wrappers' , ( ) => {
334+ it ( " does not update a paragraph's runProperties using the run's properties" , ( ) => {
335335 const schema = makeSchema ( ) ;
336+ const paragraphRunProperties = { italic : true , styleId : 'ParagraphDefault' } ;
336337 const doc = schema . node ( 'doc' , null , [
337- schema . node ( 'paragraph' , null , [
338- schema . node ( 'bookmarkStart' , null , [ schema . node ( 'run' , null , schema . text ( 'Wrapped' ) ) ] ) ,
339- ] ) ,
340- ] ) ;
341- const state = createState ( schema , doc ) ;
342- const [ wrappedRunPos ] = runPositions ( state . doc ) ;
343- const from = wrappedRunPos + 1 ;
344- const to = wrappedRunPos + 3 ;
345-
346- const tr = state . tr . addMark ( from , to , schema . marks . bold . create ( ) ) ;
347- const { state : nextState } = state . applyTransaction ( tr ) ;
348-
349- const paragraph = nextState . doc . firstChild ;
350- expect ( paragraph . attrs . paragraphProperties ) . toBeNull ( ) ;
351- } ) ;
352-
353- it ( 'does not update paragraph runProperties when a non-first run changes' , ( ) => {
354- const schema = makeSchema ( ) ;
355- const doc = schema . node ( 'doc' , null , [
356- schema . node ( 'paragraph' , null , [
357- schema . node ( 'run' , null , schema . text ( 'First' ) ) ,
358- schema . node ( 'run' , null , schema . text ( 'Second' ) ) ,
359- ] ) ,
338+ schema . node (
339+ 'paragraph' ,
340+ {
341+ paragraphProperties : {
342+ alignment : 'center' ,
343+ runProperties : paragraphRunProperties ,
344+ } ,
345+ } ,
346+ [ schema . node ( 'run' , null , schema . text ( 'Hello' ) ) , schema . node ( 'run' , null , schema . text ( 'World' ) ) ] ,
347+ ) ,
360348 ] ) ;
361349 const state = createState ( schema , doc ) ;
362- const [ firstRunPos , secondRunPos ] = runPositions ( state . doc ) ;
363- const from = secondRunPos + 1 ;
364- const to = secondRunPos + 3 ;
350+ const [ firstRunPos ] = runPositions ( state . doc ) ;
351+ const { from, to } = runTextRangeAtPos ( firstRunPos , 0 , 2 ) ;
365352
366353 const tr = state . tr . addMark ( from , to , schema . marks . bold . create ( ) ) ;
367354 const { state : nextState } = state . applyTransaction ( tr ) ;
368355
369356 const paragraph = nextState . doc . firstChild ;
370- expect ( paragraph . attrs . paragraphProperties ) . toBeNull ( ) ;
371- const firstRun = nextState . doc . nodeAt ( firstRunPos ) ;
372- expect ( firstRun ?. attrs . runProperties ) . toBeNull ( ) ;
373- } ) ;
374-
375- it ( 'does not update paragraph runProperties when first run is nested inside an inline container' , ( ) => {
376- const schema = makeSchema ( ) ;
377- const doc = schema . node ( 'doc' , null , [
378- schema . node ( 'paragraph' , null , [
379- schema . node ( 'pageReference' , { instruction : 'PAGEREF _Toc123456789 h' } , [
380- schema . node ( 'run' , null , schema . text ( 'Ref' ) ) ,
381- ] ) ,
382- schema . node ( 'run' , null , schema . text ( ' tail' ) ) ,
383- ] ) ,
384- ] ) ;
385- const state = createState ( schema , doc ) ;
386- const [ nestedRunPos ] = runPositions ( state . doc ) ;
387- const from = nestedRunPos + 1 ;
388- const to = nestedRunPos + 4 ;
389-
390- const tr = state . tr . addMark ( from , to , schema . marks . bold . create ( ) ) ;
391- const { state : nextState } = state . applyTransaction ( tr ) ;
357+ expect ( paragraph . attrs . paragraphProperties ) . toEqual ( {
358+ alignment : 'center' ,
359+ runProperties : paragraphRunProperties ,
360+ } ) ;
392361
393- const paragraph = nextState . doc . firstChild ;
394- expect ( paragraph . attrs . paragraphProperties ) . toBeNull ( ) ;
362+ const updatedRuns = runPositions ( nextState . doc ) ;
363+ const updatedRun = nextState . doc . nodeAt ( updatedRuns [ 0 ] ) ;
364+ expect ( updatedRun ?. attrs . runProperties ) . toEqual ( { bold : true } ) ;
395365 } ) ;
396366
397- it ( 'does not update paragraph runProperties when nested run is not first in paragraph ' , ( ) => {
367+ it ( 'does not update paragraph runProperties when a nested run changes ' , ( ) => {
398368 const schema = makeSchema ( ) ;
399369 const doc = schema . node ( 'doc' , null , [
400370 schema . node ( 'paragraph' , null , [
0 commit comments