Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -170,11 +170,8 @@ const TableParagraph = createStronglyTypedTiptapNode({
];
},

renderHTML({ node, HTMLAttributes }) {
// Insert a line break if there is no content, in order to preserve the
// correct cell height. Otherwise, the cell will have a height of zero +
// padding.
return ["p", HTMLAttributes, node.childCount ? 0 : ["br"]];
renderHTML({ HTMLAttributes }) {
return ["p", HTMLAttributes, 0];
},
});

Expand Down
5 changes: 5 additions & 0 deletions packages/core/src/editor/editor.css
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,11 @@ Tippy popups that are appended to document.body directly
text-align: left;
}

.bn-editor [data-content-type="table"] th > p,
.bn-editor [data-content-type="table"] td > p {
min-height: 1.5rem;
}

/* tiptap uses colwidth instead of data-colwidth, se we need to adjust this style from prosemirror-tables */
.ProseMirror td,
.ProseMirror th {
Expand Down
52 changes: 52 additions & 0 deletions tests/src/end-to-end/tables/tables.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import { test } from "../../setup/setupScript.js";
import { BASE_URL } from "../../utils/const.js";
import { compareDocToSnapshot, focusOnEditor } from "../../utils/editor.js";
import { executeSlashCommand } from "../../utils/slashmenu.js";

test.beforeEach(async ({ page }) => {
await page.goto(BASE_URL);
});

test.describe("Check Table interactions", () => {
test("Should be able to type in cell", async ({ page }) => {
await focusOnEditor(page);
await executeSlashCommand(page, "table");
await page.keyboard.type("Table Cell");

await compareDocToSnapshot(page, "cellTyping.json");
});
test("Tab should cycle cells", async ({ page }) => {
await focusOnEditor(page);
await executeSlashCommand(page, "table");
// Cycle to sixth (last) cell.
for (let i = 0; i < 5; i++) {
await page.keyboard.press("Tab");
}
await page.keyboard.type("Table Cell");
// Cycle back to first cell.
for (let i = 0; i < 5; i++) {
await page.keyboard.press("Shift+Tab");
}
await page.keyboard.type("Table Cell");

await compareDocToSnapshot(page, "tabCells.json");
});
test("Arrow keys should move cells", async ({ page }) => {
await focusOnEditor(page);
await executeSlashCommand(page, "table");
// Move down to second (last) cell in column and third (last) cell in row.
page.keyboard.press("ArrowDown");
for (let i = 0; i < 2; i++) {
await page.keyboard.press("ArrowRight");
}
await page.keyboard.type("Table Cell");
// Cycle back to first cell.
page.keyboard.press("ArrowUp");
for (let i = 0; i < 2; i++) {
await page.keyboard.press("ArrowLeft");
}
await page.keyboard.type("Table Cell");

await compareDocToSnapshot(page, "arrowKeyCells.json");
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,159 @@
{
"type": "doc",
"content": [
{
"type": "blockGroup",
"content": [
{
"type": "blockContainer",
"attrs": {
"id": "0",
"textColor": "default",
"backgroundColor": "default"
},
"content": [
{
"type": "table",
"content": [
{
"type": "tableRow",
"content": [
{
"type": "tableCell",
"attrs": {
"textColor": "default",
"backgroundColor": "default",
"textAlignment": "left",
"colspan": 1,
"rowspan": 1,
"colwidth": null
},
"content": [
{
"type": "tableParagraph",
"content": [
{
"type": "text",
"text": "Table Cell"
}
]
}
]
},
{
"type": "tableCell",
"attrs": {
"textColor": "default",
"backgroundColor": "default",
"textAlignment": "left",
"colspan": 1,
"rowspan": 1,
"colwidth": null
},
"content": [
{
"type": "tableParagraph"
}
]
},
{
"type": "tableCell",
"attrs": {
"textColor": "default",
"backgroundColor": "default",
"textAlignment": "left",
"colspan": 1,
"rowspan": 1,
"colwidth": null
},
"content": [
{
"type": "tableParagraph"
}
]
}
]
},
{
"type": "tableRow",
"content": [
{
"type": "tableCell",
"attrs": {
"textColor": "default",
"backgroundColor": "default",
"textAlignment": "left",
"colspan": 1,
"rowspan": 1,
"colwidth": null
},
"content": [
{
"type": "tableParagraph"
}
]
},
{
"type": "tableCell",
"attrs": {
"textColor": "default",
"backgroundColor": "default",
"textAlignment": "left",
"colspan": 1,
"rowspan": 1,
"colwidth": null
},
"content": [
{
"type": "tableParagraph"
}
]
},
{
"type": "tableCell",
"attrs": {
"textColor": "default",
"backgroundColor": "default",
"textAlignment": "left",
"colspan": 1,
"rowspan": 1,
"colwidth": null
},
"content": [
{
"type": "tableParagraph",
"content": [
{
"type": "text",
"text": "Table Cell"
}
]
}
]
}
]
}
]
}
]
},
{
"type": "blockContainer",
"attrs": {
"id": "1",
"textColor": "default",
"backgroundColor": "default"
},
"content": [
{
"type": "paragraph",
"attrs": {
"textAlignment": "left"
}
}
]
}
]
}
]
}
Loading
Loading