@@ -481,6 +481,27 @@ test(`简单 mark <p><strong>加粗</strong></p>`, () => {
481481 } )
482482} )
483483
484+ test ( `简单 mark JSON.stringify <p><strong>加粗</strong></p>` , ( ) => {
485+ expect ( JSON . stringify ( parseHTML ( '<p><strong>加粗</strong></p>' , {
486+ markRule : [ {
487+ type : 'strong' ,
488+ mark : { type : 'bold' }
489+ } ]
490+ } ) . doc ) ) . toEqual ( JSON . stringify ( {
491+ type : 'doc' ,
492+ content : [ {
493+ type : 'p' ,
494+ content : [ {
495+ type : 'text' ,
496+ marks : [
497+ { type : 'bold' }
498+ ] ,
499+ text : '加粗' ,
500+ } ]
501+ } ]
502+ } ) )
503+ } )
504+
484505test ( `不同种类的 mark <i>aa</i> <b>bb</b>cc` , ( ) => {
485506 expect ( parseHTML ( `<i>aa</i> <b>bb</b>cc` , {
486507 markRule : [ {
@@ -494,15 +515,15 @@ test(`不同种类的 mark <i>aa</i> <b>bb</b>cc`, () => {
494515 type : 'doc' ,
495516 content : [ {
496517 type : 'text' ,
497- text : 'aa' ,
498- marks : [ { type : 'italic' } ]
518+ marks : [ { type : 'italic' } ] ,
519+ text : 'aa'
499520 } , {
500521 type : 'text' ,
501522 text : ' ' ,
502523 } , {
503524 type : 'text' ,
504- text : 'bb' ,
505- marks : [ { type : 'bold' } ]
525+ marks : [ { type : 'bold' } ] ,
526+ text : 'bb'
506527 } , {
507528 type : 'text' ,
508529 text : 'cc'
@@ -523,11 +544,11 @@ test(`嵌套的 mark <i><b>斜体加粗</b></i>`, () => {
523544 type : 'doc' ,
524545 content : [ {
525546 type : 'text' ,
526- text : '斜体加粗' ,
527547 marks : [
528548 { type : 'italic' } ,
529549 { type : 'bold' }
530- ]
550+ ] ,
551+ text : '斜体加粗'
531552 } ]
532553 } )
533554} )
@@ -543,10 +564,10 @@ test(`带属性的 mark <span type="highlight">高亮</span>`, () => {
543564 type : 'doc' ,
544565 content : [ {
545566 type : 'text' ,
546- text : '高亮' ,
547567 marks : [ {
548568 type : 'highlight'
549- } ]
569+ } ] ,
570+ text : '高亮'
550571 } ]
551572 } )
552573} )
@@ -562,14 +583,14 @@ test(`带属性的 mark <span type="highlight" color="pink" foo="11">高亮</spa
562583 type : 'doc' ,
563584 content : [ {
564585 type : 'text' ,
565- text : '高亮' ,
566586 marks : [ {
567587 type : 'highlight' ,
568588 attrs : {
569589 color : 'pink' ,
570590 foo : 11
571591 }
572- } ]
592+ } ] ,
593+ text : '高亮'
573594 } ]
574595 } )
575596} )
@@ -591,10 +612,10 @@ test(`标签包裹的 mark <p>文字<span type="highlight">高亮</span></p>`, (
591612 text : '文字' ,
592613 } , {
593614 type : 'text' ,
594- text : '高亮' ,
595615 marks : [ {
596616 type : 'highlight'
597- } ]
617+ } ] ,
618+ text : '高亮'
598619 } ]
599620 } ]
600621 } )
@@ -613,8 +634,8 @@ test(`多种规则对应用一个 mark <strong>aa</strong><b>bb</b>`, () => {
613634 type : 'doc' ,
614635 content : [ {
615636 type : 'text' ,
616- text : 'aabb' ,
617- marks : [ { type : 'bold' } ]
637+ marks : [ { type : 'bold' } ] ,
638+ text : 'aabb'
618639 } ]
619640 } )
620641} )
0 commit comments