@@ -2,28 +2,62 @@ import {builders} from 'prosemirror-test-builder';
22
33import { createMarkupChecker } from '../../../../tests/sameMarkup' ;
44import { ExtensionsManager } from '../../../core' ;
5+ import { BlockquoteSpecs , blockquoteNodeName } from '../../markdown/Blockquote/BlockquoteSpecs' ;
56
67import { BaseNode , BaseSchemaSpecs } from './BaseSchemaSpecs' ;
78
8- const {
9- schema,
10- markupParser : parser ,
11- serializer,
12- } = new ExtensionsManager ( {
13- extensions : ( builder ) => builder . use ( BaseSchemaSpecs , { } ) ,
14- } ) . buildDeps ( ) ;
15-
16- const { doc, p} = builders < 'doc' | 'p' > ( schema , {
17- doc : { nodeType : BaseNode . Doc } ,
18- p : { nodeType : BaseNode . Paragraph } ,
19- } ) ;
9+ describe ( 'BaseSchema extension' , ( ) => {
10+ describe ( 'common' , ( ) => {
11+ const {
12+ schema,
13+ markupParser : parser ,
14+ serializer,
15+ } = new ExtensionsManager ( {
16+ extensions : ( builder ) => builder . use ( BaseSchemaSpecs , { } ) ,
17+ } ) . buildDeps ( ) ;
2018
21- const { same} = createMarkupChecker ( { parser, serializer} ) ;
19+ const { doc, p} = builders < 'doc' | 'p' > ( schema , {
20+ doc : { nodeType : BaseNode . Doc } ,
21+ p : { nodeType : BaseNode . Paragraph } ,
22+ } ) ;
2223
23- describe ( 'BaseSchema extension' , ( ) => {
24- it ( 'should parse a paragraph' , ( ) => same ( 'hello!' , doc ( p ( 'hello!' ) ) ) ) ;
24+ const { same} = createMarkupChecker ( { parser, serializer} ) ;
25+
26+ it ( 'should parse a paragraph' , ( ) => same ( 'hello!' , doc ( p ( 'hello!' ) ) ) ) ;
27+
28+ it ( 'should parse a few paragraphs' , ( ) => {
29+ same ( [ 'hello' , '' , 'world!' ] . join ( '\n' ) , doc ( p ( 'hello' ) , p ( 'world!' ) ) ) ;
30+ } ) ;
31+ } ) ;
32+
33+ describe ( 'preserveEmptyRows=true' , ( ) => {
34+ const {
35+ schema,
36+ markupParser : parser ,
37+ serializer,
38+ } = new ExtensionsManager ( {
39+ extensions : ( builder ) =>
40+ builder . use ( BaseSchemaSpecs , { preserveEmptyRows : true } ) . use ( BlockquoteSpecs ) ,
41+ } ) . buildDeps ( ) ;
42+
43+ const { doc, p, bq} = builders < 'doc' | 'p' | 'bq' > ( schema , {
44+ doc : { nodeType : BaseNode . Doc } ,
45+ p : { nodeType : BaseNode . Paragraph } ,
46+ bq : { nodeType : blockquoteNodeName } ,
47+ } ) ;
48+
49+ const { same} = createMarkupChecker ( { parser, serializer} ) ;
50+
51+ it ( 'should serialize empty paragraph as ' , ( ) =>
52+ same (
53+ 'hello!\n\n \n\nworld!' ,
54+ doc ( p ( 'hello!' ) , p ( String . fromCharCode ( 160 /* */ ) ) , p ( 'world!' ) ) ,
55+ ) ) ;
2556
26- it ( 'should parse a few paragraphs' , ( ) => {
27- same ( [ 'hello' , '' , 'world!' ] . join ( '\n' ) , doc ( p ( 'hello' ) , p ( 'world!' ) ) ) ;
57+ it ( 'should correct insert inside other nodes' , ( ) =>
58+ same (
59+ '> hello!\n>\n> \n> \n> world!' ,
60+ doc ( bq ( p ( 'hello!' ) , p ( String . fromCharCode ( 160 /* */ ) ) , p ( 'world!' ) ) ) ,
61+ ) ) ;
2862 } ) ;
2963} ) ;
0 commit comments