@mkljczk/lexical-remark
Version:
This package contains Markdown helpers and functionality for Lexical using remark-parse.
22 lines (21 loc) • 530 B
JavaScript
import { $isTextNode, $isLineBreakNode } from 'lexical';
export const code = (node) => {
const remarkNode = {
type: 'code',
value: node
.getChildren()
.map((child) => {
if ($isTextNode(child)) {
return child.getTextContent();
}
else if ($isLineBreakNode(child)) {
return '\n';
}
else {
return '';
}
})
.join(''),
};
return remarkNode;
};