plone / blocks-conversion-tool

A tool to convert HTML (as used in Plone Classic) to Blocks (as used on Volto)
7 stars 5 forks source link

title attributes on a hrefs are not migrated, where the code seems to be there and tested #45

Closed fredvd closed 3 months ago

fredvd commented 4 months ago

I found it in a recent migration that title attributes on links in richtextfields in a ClassicUI Plone 6 setup are not copied to the links in Slate texblocks when running @@migrate_to_volto .

https://github.com/plone/blocks-conversion-tool/blob/b0d2c9677f7e81d5f5bbaeea199549bcdd3b985d/src/converters/slate.js#L38-L54

here the links are created, but where I first thought this is creating the title attributes, this is the deserializer (from json?) to create the slate node, I'm not fully understanding the conversion code as there might be a missing serializer/the migration is done elsewhere?

creating the title and other anchor attributes is tested in the blocks conversion tool here: https://github.com/plone/blocks-conversion-tool/blob/b0d2c9677f7e81d5f5bbaeea199549bcdd3b985d/src/converters/slate.test.js#L553-L567

So what is missing where?

fredvd commented 4 months ago

Follow up on this issue, the blocks-conversion-tool is working fine. There was one thing I thought of but had forgotten to check. the blocks_layout json for the migrated blocks contains the title attribute just fine. For my test page with an internal link the attribute is migrated. But on instantiation in the browser frontend the attribute is not visible in the editor.

Even more interesting: when I edit an internal link in Slate with a 'hidden' title attribute, it IS preserved upon save, even though I can't see it in the frontend DOM. Magic.

"ac6ffec7-0c00-4ffd-a314-17f9bd0bba63": {
  "styles": {},
  "@type": "slate",
  "plaintext": "dit is een link naar nieuwe",
  "value": [
   {
    "children": [
     {
      "text": "dit is "
     },
     {
      "children": [
       {
        "text": "een link naar nieuwe"
       }
      ],
      "data": {
       "target": null,
       "title": "Extra tekst op het title attribuut voor de link naar nieuws",
       "url": "../resolveuid/0a6b842f856d4f1fa02df8fab7d63f3d"
      },
      "type": "link"
     }
    ],
    "type": "p"
   }
  ]
 },
davisagli commented 3 months ago

@fredvd It looks like support for it needs to be added in the slate component that renders the link: https://github.com/plone/volto/blob/main/packages/volto-slate/src/editor/plugins/Link/render.jsx#L7