@@ -376,6 +376,41 @@ describe( 'Schema', () => {
376376 } ) ;
377377 } ) ;
378378
379+ describe ( 'isInline()' , ( ) => {
380+ it ( 'returns true if an item was registered as inline' , ( ) => {
381+ schema . register ( 'foo' , {
382+ isInline : true
383+ } ) ;
384+
385+ expect ( schema . isInline ( 'foo' ) ) . to . be . true ;
386+ } ) ;
387+
388+ it ( 'returns false if an item was registered as a limit (because not all limits are objects)' , ( ) => {
389+ schema . register ( 'foo' , {
390+ isLimit : true
391+ } ) ;
392+
393+ expect ( schema . isInline ( 'foo' ) ) . to . be . false ;
394+ } ) ;
395+
396+ it ( 'returns false if an item was not registered as an object' , ( ) => {
397+ schema . register ( 'foo' ) ;
398+
399+ expect ( schema . isInline ( 'foo' ) ) . to . be . false ;
400+ } ) ;
401+
402+ it ( 'returns false if an item was not registered at all' , ( ) => {
403+ expect ( schema . isInline ( 'foo' ) ) . to . be . false ;
404+ } ) ;
405+
406+ it ( 'uses getDefinition()\'s item to definition normalization' , ( ) => {
407+ const stub = sinon . stub ( schema , 'getDefinition' ) . returns ( { isInline : true } ) ;
408+
409+ expect ( schema . isInline ( 'foo' ) ) . to . be . true ;
410+ expect ( stub . calledOnce ) . to . be . true ;
411+ } ) ;
412+ } ) ;
413+
379414 describe ( 'checkChild()' , ( ) => {
380415 beforeEach ( ( ) => {
381416 schema . register ( '$root' ) ;
@@ -2468,7 +2503,8 @@ describe( 'Schema', () => {
24682503 } ,
24692504 ( ) => {
24702505 schema . extend ( '$text' , {
2471- allowAttributes : [ 'bold' , 'italic' ]
2506+ allowAttributes : [ 'bold' , 'italic' ] ,
2507+ isInline : true
24722508 } ) ;
24732509
24742510 // Disallow bold in heading1.
@@ -2494,7 +2530,8 @@ describe( 'Schema', () => {
24942530 isBlock : true
24952531 } ) ;
24962532 schema . register ( '$text' , {
2497- allowIn : '$block'
2533+ allowIn : '$block' ,
2534+ isInline : true
24982535 } ) ;
24992536
25002537 for ( const definition of definitions ) {
@@ -2738,40 +2775,53 @@ describe( 'Schema', () => {
27382775 expect ( schema . checkAttribute ( r1i , 'alignment' ) ) . to . be . false ;
27392776 } ) ;
27402777
2778+ it ( '$text is inline' , ( ) => {
2779+ expect ( schema . isLimit ( '$text' ) ) . to . be . false ;
2780+ expect ( schema . isBlock ( '$text' ) ) . to . be . false ;
2781+ expect ( schema . isObject ( '$text' ) ) . to . be . false ;
2782+ expect ( schema . isInline ( '$text' ) ) . to . be . true ;
2783+ } ) ;
2784+
27412785 it ( '$root is limit' , ( ) => {
27422786 expect ( schema . isLimit ( '$root' ) ) . to . be . true ;
27432787 expect ( schema . isBlock ( '$root' ) ) . to . be . false ;
27442788 expect ( schema . isObject ( '$root' ) ) . to . be . false ;
2789+ expect ( schema . isInline ( '$root' ) ) . to . be . false ;
27452790 } ) ;
27462791
27472792 it ( 'paragraph is block' , ( ) => {
27482793 expect ( schema . isLimit ( 'paragraph' ) ) . to . be . false ;
27492794 expect ( schema . isBlock ( 'paragraph' ) ) . to . be . true ;
27502795 expect ( schema . isObject ( 'paragraph' ) ) . to . be . false ;
2796+ expect ( schema . isInline ( 'paragraph' ) ) . to . be . false ;
27512797 } ) ;
27522798
27532799 it ( 'heading1 is block' , ( ) => {
27542800 expect ( schema . isLimit ( 'heading1' ) ) . to . be . false ;
27552801 expect ( schema . isBlock ( 'heading1' ) ) . to . be . true ;
27562802 expect ( schema . isObject ( 'heading1' ) ) . to . be . false ;
2803+ expect ( schema . isInline ( 'heading1' ) ) . to . be . false ;
27572804 } ) ;
27582805
27592806 it ( 'listItem is block' , ( ) => {
27602807 expect ( schema . isLimit ( 'listItem' ) ) . to . be . false ;
27612808 expect ( schema . isBlock ( 'listItem' ) ) . to . be . true ;
27622809 expect ( schema . isObject ( 'listItem' ) ) . to . be . false ;
2810+ expect ( schema . isInline ( 'lisItem' ) ) . to . be . false ;
27632811 } ) ;
27642812
27652813 it ( 'image is block object' , ( ) => {
27662814 expect ( schema . isLimit ( 'image' ) ) . to . be . true ;
27672815 expect ( schema . isBlock ( 'image' ) ) . to . be . true ;
27682816 expect ( schema . isObject ( 'image' ) ) . to . be . true ;
2817+ expect ( schema . isInline ( 'image' ) ) . to . be . false ;
27692818 } ) ;
27702819
27712820 it ( 'caption is limit' , ( ) => {
27722821 expect ( schema . isLimit ( 'caption' ) ) . to . be . true ;
27732822 expect ( schema . isBlock ( 'caption' ) ) . to . be . false ;
27742823 expect ( schema . isObject ( 'caption' ) ) . to . be . false ;
2824+ expect ( schema . isInline ( 'caption' ) ) . to . be . false ;
27752825 } ) ;
27762826 } ) ;
27772827
0 commit comments