Skip to content

Commit a8687d7

Browse files
authored
Merge branch 'main' into multi-char-suggestions
2 parents 0c29680 + 3d084e3 commit a8687d7

File tree

8 files changed

+122
-6
lines changed

8 files changed

+122
-6
lines changed

packages/core/src/api/nodeConversions/blockToNode.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff 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
}

tests/src/end-to-end/images/images.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ test.describe("Check Image Block and Toolbar functionality", () => {
2727
await compareDocToSnapshot(page, "createImage");
2828
expect(await page.screenshot()).toMatchSnapshot("create-image.png");
2929
});
30-
test("Should be able to upload image", async ({ page }) => {
30+
test.skip("Should be able to upload image", async ({ page }) => {
3131
await focusOnEditor(page);
3232
await executeSlashCommand(page, "image");
3333

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
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>
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<p>
2+
Text1
3+
<br />
4+
Text2
5+
<br />
6+
Text3
7+
<br />
8+
</p>
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Text1\
2+
Text2\
3+
Text3
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
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+
]

tests/src/unit/core/formatConversion/export/exportTestInstances.ts

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff 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

15971634
export const exportTestInstancesHTML: TestInstance<

tests/src/unit/shared/formatConversion/exportParseEquality/exportParseEqualityTestExecutors.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff 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

3744
export const testExportParseEqualityNodes = async <

0 commit comments

Comments
 (0)