Skip to content

Commit 23d4cfd

Browse files
fix(markdown): keep custom inline elements inside table cell paragraphs (udecode#5068)
1 parent 45116fd commit 23d4cfd

2 files changed

Lines changed: 10 additions & 1 deletion

File tree

.changeset/tidy-pugs-punch.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@platejs/markdown': patch
3+
---
4+
5+
Keep custom inline elements inside a table cell's paragraph when deserializing markdown. The cell deserializer recognised only `inlineEquation` as inline, so any other custom inline element was hoisted out of the paragraph and became its sibling. The cell serializer then separated those siblings with `<br/>`, and a second round trip turned that into a newline — silently destroying the element. The check now asks the editor whether the node is inline, which is the same answer the plugin configuration already holds.

packages/markdown/src/lib/rules/defaultRules.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -964,7 +964,11 @@ export const defaultRules: MdRules = {
964964

965965
for (const child of cellChildren) {
966966
// Text nodes or inline elements should be grouped into paragraphs
967-
if (!child.type || child.type === KEYS.inlineEquation) {
967+
if (
968+
!child.type ||
969+
child.type === KEYS.inlineEquation ||
970+
options.editor!.api.isInline(child)
971+
) {
968972
currentParagraphChildren.push(child);
969973
} else {
970974
// Block-level elements should end the current paragraph and be added directly

0 commit comments

Comments
 (0)