diff --git a/packages/lexical-playground/__tests__/e2e/Tables.spec.mjs b/packages/lexical-playground/__tests__/e2e/Tables.spec.mjs
index 69dcad56dbe..e5a89fe1178 100644
--- a/packages/lexical-playground/__tests__/e2e/Tables.spec.mjs
+++ b/packages/lexical-playground/__tests__/e2e/Tables.spec.mjs
@@ -49,6 +49,7 @@ import {
LEGACY_EVENTS,
mergeTableCells,
pasteFromClipboard,
+ resizeTableCell,
selectCellFromTableCoord,
selectCellsFromTableCords,
selectFromAdditionalStylesDropdown,
@@ -5948,6 +5949,185 @@ test.describe.parallel('Tables', () => {
);
});
+ test(`Can paste tables inside table cells (with hasNestedTables)`, async ({
+ page,
+ isPlainText,
+ isCollab,
+ }) => {
+ test.skip(isPlainText);
+ await initialize({hasNestedTables: true, isCollab, page});
+ await focusEditor(page);
+
+ // Create and copy a table
+ await insertTable(page, 2, 2);
+ await page.keyboard.type('test inner table');
+ await selectAll(page);
+ await withExclusiveClipboardAccess(async () => {
+ const clipboard = await copyToClipboard(page);
+ await page.keyboard.press('Backspace');
+ await moveToEditorBeginning(page);
+
+ // Create another table and try to paste the first table into a cell
+ await insertTable(page, 2, 2);
+ await click(page, '.PlaygroundEditorTheme__tableCell:first-child');
+ await pasteFromClipboard(page, clipboard);
+ });
+
+ // Verify that a nested table was pasted into the cell
+ await assertHTML(
+ page,
+ html`
+
+
+
+
+
+
+
+ |
+
+
+
+
+
+
+
+ |
+
+ test inner table
+
+ |
+
+
+ |
+
+
+ |
+
+ |
+
+
+ |
+
+
+
+ |
+
+
+ |
+
+
+ |
+
+ |
+
+
+ |
+
+
+
+ `,
+ undefined,
+ {ignoreClasses: true, ignoreDir: true},
+ );
+ });
+
+ test(`Can paste and autofit tables inside table cells (with hasNestedTables, hasFitNestedTables)`, async ({
+ page,
+ isPlainText,
+ isCollab,
+ }) => {
+ test.skip(isPlainText);
+ await initialize({
+ hasFitNestedTables: true,
+ hasNestedTables: true,
+ isCollab,
+ page,
+ });
+ await focusEditor(page);
+
+ // Create and copy a table
+ await insertTable(page, 2, 2);
+
+ await page.keyboard.type('test inner table');
+
+ await selectAll(page);
+ await withExclusiveClipboardAccess(async () => {
+ const clipboard = await copyToClipboard(page);
+ await page.keyboard.press('Backspace');
+ await moveToEditorBeginning(page);
+
+ // Create another table and try to paste the first table into a cell
+ await insertTable(page, 2, 2);
+ // Resize outer table cell (92px default + 50px = 142px)
+ await resizeTableCell(page, 'tr:nth-child(2) > th:nth-child(1)', 50);
+ await click(
+ page,
+ 'tr:nth-child(2) > th:nth-child(1) > .PlaygroundEditorTheme__paragraph',
+ );
+
+ await pasteFromClipboard(page, clipboard);
+ });
+
+ // Verify that a nested table was pasted into the cell
+ await assertHTML(
+ page,
+ html`
+
+
+
+
+
+
+
+ |
+
+
+
+
+
+
+
+ |
+
+ test inner table
+
+ |
+
+
+ |
+
+
+ |
+
+ |
+
+
+ |
+
+
+
+ |
+
+
+ |
+
+
+ |
+
+ |
+
+
+ |
+
+
+
+ `,
+ undefined,
+ {ignoreClasses: true, ignoreDir: true},
+ );
+ });
+
test(`Click and drag to create selection in Firefox #7245`, async ({
page,
isPlainText,
diff --git a/packages/lexical-playground/__tests__/utils/index.mjs b/packages/lexical-playground/__tests__/utils/index.mjs
index 91aaa341cb7..ef08aa00960 100644
--- a/packages/lexical-playground/__tests__/utils/index.mjs
+++ b/packages/lexical-playground/__tests__/utils/index.mjs
@@ -58,17 +58,31 @@ function wrapAndSlowDown(method, delay) {
};
}
-export function wrapTableHtml(expected, {ignoreClasses = false} = {}) {
+export function wrapTableHtml(
+ expected,
+ {ignoreClasses = false, ignoreDir = false} = {},
+) {
return html`
${expected
- .replace(
- /]*)(dir="\w+")([^>]*)>/g,
- `