Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue with Image node #44

Open
vnugent opened this issue Nov 1, 2021 · 1 comment
Open

Issue with Image node #44

vnugent opened this issue Nov 1, 2021 · 1 comment

Comments

@vnugent
Copy link

vnugent commented Nov 1, 2021

I'm using remark-slate with Plate. Plate can load most markdown except for image (see differences below). I can pass an option to the deserialize function to change type=image to type=img. I don't think I can change how caption field is created. Any tips on how to fix this issue?

Plate image node: (working)

  {
    "type": "img",
    "url": "path to image",
    "children": [
      {
        "text": ""
      }
    ],
    "caption": [
      {
        "text": "foos"
      }
    ]
  }

remark-slate -> Plate: (not working)

      {
        "type": "image",  <-- expecting 'img'
        "children": [
          {
            "text": ""
          }
        ],
        "url": "path to image",
        "caption": "foos" <-- expecting an array 
      }
@janaka
Copy link

janaka commented Jun 5, 2022

I'm hitting an issue which is caused by this as far as I can tell. Plate is throwing the error here. Expecting an array.

Error Cannot read properties of undefined (reading 'map') in ImageElement.tsx 108:1

I've had to set imageCaptionKey to something other than caption as a workaround.

.use(slate, { nodeTypes: plateNodeTypes, imageCaptionKey:'cap', imageSourceKey:'src'})

Being able to configure the caption deserialisation would be ideal IMO.

fwiw I've had to configure type from image to img along with a bunch of other elements using InputNodeTypes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants