File tree Expand file tree Collapse file tree 7 files changed +121
-5
lines changed
packages/core/src/api/nodeConversions
core/formatConversion/export
shared/formatConversion/exportParseEquality Expand file tree Collapse file tree 7 files changed +121
-5
lines changed Original file line number Diff line number Diff line change @@ -40,9 +40,13 @@ function styledTextToNodes<T extends StyleSchema>(
4040 }
4141
4242 if ( config . propSchema === "boolean" ) {
43- marks . push ( schema . mark ( style ) ) ;
43+ if ( value ) {
44+ marks . push ( schema . mark ( style ) ) ;
45+ }
4446 } else if ( config . propSchema === "string" ) {
45- marks . push ( schema . mark ( style , { stringValue : value } ) ) ;
47+ if ( value ) {
48+ marks . push ( schema . mark ( style , { stringValue : value } ) ) ;
49+ }
4650 } else {
4751 throw new UnreachableCaseError ( config . propSchema ) ;
4852 }
Original file line number Diff line number Diff line change 1+ < div class ="bn-block-group " data-node-type ="blockGroup ">
2+ < div class ="bn-block-outer " data-node-type ="blockOuter " data-id ="1 ">
3+ < div class ="bn-block " data-node-type ="blockContainer " data-id ="1 ">
4+ < div class ="bn-block-content " data-content-type ="paragraph ">
5+ < p class ="bn-inline-content ">
6+ Text1
7+ < br />
8+ Text2
9+ < br />
10+ Text3
11+ < br />
12+ </ p >
13+ </ div >
14+ </ div >
15+ </ div >
16+ </ div >
Original file line number Diff line number Diff line change 1+ < p >
2+ Text1
3+ < br />
4+ Text2
5+ < br />
6+ Text3
7+ < br />
8+ </ p >
Original file line number Diff line number Diff line change 1+ Text1\
2+ Text2\
3+ Text3
Original file line number Diff line number Diff line change 1+ [
2+ {
3+ "attrs" : {
4+ "backgroundColor" : " default" ,
5+ "id" : " 1" ,
6+ "textColor" : " default" ,
7+ },
8+ "content" : [
9+ {
10+ "attrs" : {
11+ "textAlignment" : " left" ,
12+ },
13+ "content" : [
14+ {
15+ "text" : " Text1" ,
16+ "type" : " text" ,
17+ },
18+ {
19+ "type" : " hardBreak" ,
20+ },
21+ {
22+ "text" : " Text2" ,
23+ "type" : " text" ,
24+ },
25+ {
26+ "type" : " hardBreak" ,
27+ },
28+ {
29+ "text" : " Text3" ,
30+ "type" : " text" ,
31+ },
32+ {
33+ "type" : " hardBreak" ,
34+ },
35+ ],
36+ "type" : " paragraph" ,
37+ },
38+ ],
39+ "type" : " blockContainer" ,
40+ },
41+ ]
Original file line number Diff line number Diff line change @@ -1592,6 +1592,43 @@ export const exportTestInstancesBlockNoteHTML: TestInstance<
15921592 } ,
15931593 executeTest : testExportBlockNoteHTML ,
15941594 } ,
1595+ {
1596+ testCase : {
1597+ name : "malformed/JSON" ,
1598+ content : [
1599+ {
1600+ // id: UniqueID.options.generateID(),
1601+ type : "paragraph" ,
1602+ content : [
1603+ {
1604+ type : "text" ,
1605+ text : "Text1\n" ,
1606+ styles : {
1607+ bold : false ,
1608+ } ,
1609+ } ,
1610+ {
1611+ type : "text" ,
1612+ text : "Text2\n" ,
1613+ styles : {
1614+ italic : false ,
1615+ fontSize : "" ,
1616+ } ,
1617+ } ,
1618+ {
1619+ type : "text" ,
1620+ text : "Text3\n" ,
1621+ styles : {
1622+ italic : false ,
1623+ code : false ,
1624+ } ,
1625+ } ,
1626+ ] ,
1627+ } ,
1628+ ] ,
1629+ } ,
1630+ executeTest : testExportBlockNoteHTML ,
1631+ } ,
15951632] ;
15961633
15971634export const exportTestInstancesHTML : TestInstance <
Original file line number Diff line number Diff line change @@ -29,9 +29,16 @@ export const testExportParseEqualityBlockNoteHTML = async <
2929
3030 const exported = await editor . blocksToFullHTML ( testCase . content ) ;
3131
32- expect ( await editor . tryParseHTMLToBlocks ( exported ) ) . toStrictEqual (
33- partialBlocksToBlocksForTesting ( editor . schema , testCase . content ) ,
34- ) ;
32+ if ( testCase . name . startsWith ( "malformed/" ) ) {
33+ // We purposefully are okay with malformed response, we know they won't match
34+ expect ( await editor . tryParseHTMLToBlocks ( exported ) ) . not . toStrictEqual (
35+ partialBlocksToBlocksForTesting ( editor . schema , testCase . content ) ,
36+ ) ;
37+ } else {
38+ expect ( await editor . tryParseHTMLToBlocks ( exported ) ) . toStrictEqual (
39+ partialBlocksToBlocksForTesting ( editor . schema , testCase . content ) ,
40+ ) ;
41+ }
3542} ;
3643
3744export const testExportParseEqualityNodes = async <
You can’t perform that action at this time.
0 commit comments