Skip to content
Open
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
13 changes: 13 additions & 0 deletions packages/lexical-table/src/LexicalTableSelectionHelpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -691,10 +691,23 @@ export function applyTableHandlers(
selection,
tableNode,
);
const lastChild = tableCellNode.getLastChild();
const isLastChildPageBreak =
lastChild && lastChild.getType() === 'page-break'; // Adjust 'page-break' to the actual node type for page breaks
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

page-break is currently a playground-only node that is not distributed with lexical so it doesn't really make sense to encode specific behavior for it in the @lexical/table package. This method of type checking is also not compatible with subclasses which would have a different type (this is important for node replacement).

if (edgePosition) {
$insertParagraphAtTableEdge(edgePosition, tableNode, [
$createTextNode(payload),
]);
return true;
} else if (isLastChildPageBreak && edgePosition === undefined) {
// Create a new paragraph node with the payload text
const newParagraph = $createParagraphNode();
newParagraph.append($createTextNode(payload));
// Insert the new paragraph after the last child (page-break)
lastChild.insertAfter(newParagraph);
// Optionally, move the selection to the new paragraph
newParagraph.selectEnd();
Comment on lines +708 to +709
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

optional isn't a very accurate description since this always happens and there's no way to control it


return true;
}
}
Expand Down