2
0
Files
bot/packages/lib/markdown/remark-slate/remarkPlugin.ts
Baptiste Arnaud ff9c4726cc 🚸 Rewrite the markdown deserializer to improve br… (#1198)
<!-- 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 -->
2024-01-31 08:03:13 +01:00

19 lines
606 B
TypeScript

import { Value } from '@udecode/plate-common'
import { remarkTransformNode } from './remarkTransformNode'
import { MdastNode, RemarkPluginOptions } from './types'
export function remarkPlugin<V extends Value>(options: RemarkPluginOptions<V>) {
let lastLineNumber = 1
const compiler = (node: { children: Array<MdastNode> }) => {
return node.children.flatMap((child) => {
const parsedChild = remarkTransformNode(child, lastLineNumber, options)
lastLineNumber = child.position?.end.line || lastLineNumber
return parsedChild
})
}
// @ts-ignore
this.Compiler = compiler
}