<!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **Refactor** - Updated markdown handling and serialization libraries for improved performance and accuracy in text formatting. - **New Features** - Enhanced rich text and markdown conversion capabilities, providing users with more reliable and seamless text formatting options. - **Documentation** - Added detailed documentation for markdown to rich text conversion and vice versa, ensuring easier understanding and implementation for developers. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
21 lines
647 B
TypeScript
21 lines
647 B
TypeScript
import { TDescendant, Value } from '@udecode/plate-common'
|
|
|
|
import { remarkTextTypes } from './remarkTextTypes'
|
|
import { remarkTransformElement } from './remarkTransformElement'
|
|
import { remarkTransformText } from './remarkTransformText'
|
|
import { MdastNode, RemarkPluginOptions } from './types'
|
|
|
|
export const remarkTransformNode = <V extends Value>(
|
|
node: MdastNode,
|
|
lastLineNumber: number,
|
|
options: RemarkPluginOptions<V>
|
|
): TDescendant | TDescendant[] => {
|
|
const { type } = node
|
|
|
|
if (remarkTextTypes.includes(type!)) {
|
|
return remarkTransformText(node, options)
|
|
}
|
|
|
|
return remarkTransformElement(node, lastLineNumber, options)
|
|
}
|