Skip to content

Commit a9b0ca7

Browse files
authored
docs: documents upload node markdown placeholder (#16135)
- documents the upload node markdown placeholder format handled by `UploadMarkdownTransformer` - clarifies that standard image syntax is not automatically converted to upload nodes - adds migration guide for converting existing markdown image references
1 parent 71a6c60 commit a9b0ca7

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

docs/rich-text/converting-markdown.mdx

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,28 @@ const lexicalJSON = convertMarkdownToLexical({
109109
})
110110
```
111111

112+
## Converting Uploads
113+
114+
When converting Markdown to Lexical, standard image syntax `![alt] (url)` is **not** automatically converted to Upload nodes, because Payload has no way to look up a Media document from a URL alone.
115+
116+
The `UploadFeature` includes a built-in transformer that recognizes a special placeholder format:
117+
118+
```ts
119+
![media:6507f7b9a4d3c2e1f0ab1234]()
120+
```
121+
122+
Where `media` is your upload collection slug and the second part is the document ID. When `convertMarkdownToLexical` processes this, it creates a proper Upload node with the correct `relationTo` and `value`.
123+
124+
When converting **from** Lexical to Markdown, Upload nodes are serialized back into this same placeholder format (unless the document is populated, in which case the URL and alt text are used directly as a standard markdown image).
125+
126+
### Migrating existing Markdown content
127+
128+
If you're migrating content that contains standard `![alt] (url)` image references, the recommended approach is:
129+
130+
1. Upload your images to the Media collection first to get their document IDs
131+
2. Pre-process your Markdown to replace `![alt] (url)` with `![media:<id>]()`
132+
3. Then run `convertMarkdownToLexical`
133+
112134
## Converting MDX
113135

114136
Payload supports serializing and deserializing MDX content. While Markdown converters are stored on the features, MDX converters are stored on the blocks that you pass to the `BlocksFeature`.

0 commit comments

Comments
 (0)