Replies: 4 comments 1 reply
-
|
Please add a reproduction in order for us to be able to investigate. Depending on the quality of reproduction steps, this issue may be closed if no reproduction is provided. Why was this issue marked with the
|
Beta Was this translation helpful? Give feedback.
-
|
I believe I've just hit the same issue ... with the following editor state: {
"root": {
"type": "root",
"format": "",
"indent": 0,
"version": 1,
"children": [
{
"tag": "h1",
"type": "heading",
"format": "",
"indent": 0,
"version": 1,
"children": [
{
"mode": "normal",
"text": "Hello from team!",
"type": "text",
"style": "",
"detail": 0,
"format": 1,
"version": 1
}
],
"direction": null,
"textFormat": 1
},
{
"type": "paragraph",
"format": "",
"indent": 0,
"version": 1,
"children": [
{
"mode": "normal",
"text": "Nice to see you",
"type": "text",
"style": "",
"detail": 0,
"format": 0,
"version": 1
}
],
"direction": null,
"textStyle": "",
"textFormat": 0
},
{
"type": "paragraph",
"format": "",
"indent": 0,
"version": 1,
"children": [
{
"mode": "normal",
"text": "Here are the reasons:",
"type": "text",
"style": "",
"detail": 0,
"format": 0,
"version": 1
}
],
"direction": null,
"textStyle": "",
"textFormat": 0
},
{
"tag": "ol",
"type": "list",
"start": 1,
"format": "",
"indent": 0,
"version": 1,
"children": [
{
"type": "listitem",
"value": 1,
"format": "",
"indent": 0,
"version": 1,
"children": [
{
"mode": "normal",
"text": "Blah blah.",
"type": "text",
"style": "",
"detail": 0,
"format": 0,
"version": 1
}
],
"direction": null
},
{
"type": "listitem",
"value": 2,
"format": "",
"indent": 0,
"version": 1,
"children": [
{
"mode": "normal",
"text": "Sun station",
"type": "text",
"style": "",
"detail": 0,
"format": 0,
"version": 1
}
],
"direction": null
}
],
"listType": "number",
"direction": null
},
{
"id": "68f5dcd3fa95823a6989a5c6",
"type": "upload",
"value": "9e085dc7-db63-4e32-86ef-74c7bb1df81d",
"fields": null,
"format": "",
"version": 3,
"relationTo": "media"
},
{
"type": "quote",
"format": "",
"indent": 0,
"version": 1,
"children": [
{
"mode": "normal",
"text": "The past is past, now, but that’s… you know, that’s okay! It’s never really gone completely. The future is always built on the past, even if we won’t get to see it.",
"type": "text",
"style": "",
"detail": 0,
"format": 0,
"version": 1
}
],
"direction": null
}
],
"direction": null
}
}... using the officially recommended way of conversion: const payload = await getPayload({ config: payloadConfig })
const html = await convertLexicalToHTMLAsync({
data,
populate: await getPayloadPopulateFn({
payload,
depth,
currentDepth: 0,
}),
}) |
Beta Was this translation helpful? Give feedback.
-
|
I've spent some time reading the codebase and from what I understand, the relationship field stored in Lexical editor state gets populated with partial data when editor state gets selected prior, so the actual state stored in the database... {
"id": "68f5dcd3fa95823a6989a5c6",
"type": "upload",
"value": "9e085dc7-db63-4e32-86ef-74c7bb1df81d", // <--- Only ID here.
"fields": null,
"format": "",
"version": 3,
"relationTo": "media"
},... somehow turns into {
id: '68f5dcd3fa95823a6989a5c6',
type: 'upload',
value: { // <--- Partially populated data.
id: '9e085dc7-db63-4e32-86ef-74c7bb1df81d',
alt: null,
url: '/api/media/file/Sun_station-1.webp',
filename: 'Sun_station-1.webp'
},
fields: null,
format: '',
version: 3,
relationTo: 'media'
}... so the converter assumes all the necessary data is present and fails to call I assume this can be worked around by not populating the relationship field which is suboptimal. It's quite unexpected to me that Payload somehow inspects the Lexical editor state for relationships and populates them beforehand. |
Beta Was this translation helpful? Give feedback.
-
|
I converted this into a discussion, as this is expected behavior - check out this section of the docs.
Lexical upload/relationship/internal link nodes behave the exact same way as payload upload/relationship fields - when you fetch the data with a depth > 0, the related document value will automatically be populated. The synchronous html converter requires you to pass this populated data, as the populated document contains data required to output the complete HTML (e.g. If you want the converter to fetch the document for you, you can use the asynchronous version of the HTML converter and pass a |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Describe the Bug
Lexical default sync HTML converter for Upload Node not working.
Here is content for field
contentin MongoDB:Simple code for collection
return formatted text without upload node content
<div class="payload-richtext"><p>Hello!</p><p>bye</p></div>Debuging show that converter wait for node as Object
if (typeof uploadNode.value !== 'object') { return '' }inpayload/packages/richtext-lexical/src/features/converters/lexicalToHtml/sync/converters/upload.ts
Line 14 in 13a1d90
but
uploadNode.value = "68f0b665d86c759e1d14247a"andtypeof uploadNode.value = 'string'Link to the code that reproduces this issue
pnpx create-payload-app@latest -t blank
Reproduction Steps
Which area(s) are affected? (Select all that apply)
plugin: richtext-lexical
Environment Info
Beta Was this translation helpful? Give feedback.
All reactions