@@ -5,6 +5,7 @@ import { createListLevel } from '../../../lib/modelApi/creators/createListLevel'
55import { createModelToDomContext } from '../../../lib/modelToDom/context/createModelToDomContext' ;
66import { expectHtml } from '../../testUtils' ;
77import { handleList } from '../../../lib/modelToDom/handlers/handleList' ;
8+ import { listLevelMetadataApplier } from 'roosterjs-content-model-core/lib/override/listMetadataApplier' ;
89import { NumberingListType } from '../../../lib/constants/NumberingListType' ;
910
1011describe ( 'handleList without format handlers' , ( ) => {
@@ -510,4 +511,66 @@ describe('handleList handles metadata', () => {
510511 expect ( onNodeCreated . calls . argsFor ( 1 ) [ 0 ] ) . toBe ( listLevel1 ) ;
511512 expect ( onNodeCreated . calls . argsFor ( 1 ) [ 1 ] ) . toBe ( parent . querySelector ( 'ul' ) ) ;
512513 } ) ;
514+
515+ it ( 'List style type is changed by metadata, node stack should not be changed' , ( ) => {
516+ const listItem : ContentModelListItem = {
517+ blockType : 'BlockGroup' ,
518+ blockGroupType : 'ListItem' ,
519+ blocks : [
520+ {
521+ blockType : 'Paragraph' ,
522+ segments : [
523+ {
524+ segmentType : 'Br' ,
525+ format : { } ,
526+ } ,
527+ ] ,
528+ format : { } ,
529+ } ,
530+ ] ,
531+ levels : [
532+ {
533+ listType : 'UL' ,
534+ format : { } ,
535+ dataset : {
536+ editingInfo : '{"applyListStyleFromLevel":true}' ,
537+ } ,
538+ } ,
539+ ] ,
540+ formatHolder : {
541+ segmentType : 'SelectionMarker' ,
542+ isSelected : false ,
543+ format : { } ,
544+ } ,
545+ format : { } ,
546+ } ;
547+
548+ context = createModelToDomContext ( undefined , {
549+ metadataAppliers : {
550+ listLevel : listLevelMetadataApplier ,
551+ } ,
552+ } ) ;
553+
554+ handleList ( document , parent , listItem , context , null ) ;
555+
556+ expectHtml ( parent . outerHTML , [
557+ '<div><ul data-editing-info="{"applyListStyleFromLevel":true}" style="list-style-type: disc;"></ul></div>' ,
558+ '<div><ul style="list-style-type: disc;" data-editing-info="{"applyListStyleFromLevel":true}"></ul></div>' ,
559+ ] ) ;
560+ expect ( context . listFormat ) . toEqual ( {
561+ threadItemCounts : [ ] ,
562+ nodeStack : [
563+ {
564+ node : parent ,
565+ } ,
566+ {
567+ node : parent . firstChild as HTMLElement ,
568+ listType : 'UL' ,
569+ dataset : { editingInfo : '{"applyListStyleFromLevel":true}' } ,
570+ format : { } ,
571+ } ,
572+ ] ,
573+ } ) ;
574+ expect ( listItem . levels [ 0 ] . format . listStyleType ) . toBe ( 'disc' ) ;
575+ } ) ;
513576} ) ;
0 commit comments