contentful / rich-text

Libraries for handling and rendering Rich Text 📄
MIT License
549 stars 109 forks source link

Contentful API does not work with richTextFromMarkdown when inserting a node of type INLINES.EMBEDDED_ENTRY (embedded-entry-inline) #337

Closed labago closed 2 years ago

labago commented 2 years ago
let richText = await richTextFromMarkdown(markdown,
    node => ({
    nodeType: INLINES.EMBEDDED_ENTRY,
    content: [],
    data: {
        target: {
            sys: {
                type: 'Link',
                linkType: 'Entry',
                id: entryId
            }
        }
    }
} );

When trying to submit this rich text data (which is generated correctly) to the Contentufl Entry POST api, i get back the following error:

"errors": [ { "name": "in", "details": "Value must be one of expected values", "path": [ "fields", "content", "en-US", "content", 8, "nodeType" ], "value": "embedded-entry-inline", "expected": [ "blockquote", "embedded-asset-block", "embedded-entry-block", "heading-1", "heading-2", "heading-3", "heading-4", "heading-5", "heading-6", "hr", "ordered-list", "paragraph", "table", "unordered-list" ] } ]

This indicates that the API does not accept embedded-entry-inline nodes even though it is a valid node type, how can I create an inline entry inside the rich text field with the API?

labago commented 2 years ago

In case anyone stumbles upon the same or similar issue, I talked to Contentful support and you have to nest these inline-entrys within a paragraph node like this:

"nodeType": "paragraph",
 "data": {},
 "content": [
     {
          "nodeType": "text",
          "value": "",
          "marks": [],
          "data": {}
     },
     {
          "nodeType": "embedded-entry-inline",
           "data": {