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

Heading with anchor in it will create a broken block #15

Open pbauer opened 1 year ago

pbauer commented 1 year ago

This html : <h2><a name="fairuse"></a>Examples of Fair Use of the Plone Trademark</h2> will result in the following broken block:

 "e1dfcb82-7463-4db4-885b-1057e63b60ca": {
  "@type": "slate",
  "value": [
   {
    "type": "h2",
    "children": [
     {
      "type": "link",
      "data": {
       "url": null,
       "title": null,
       "target": null
      },
      "children": [
       {
        "text": ""
       }
      ]
     },
     {
      "text": "Examples of Fair Use of the Plone Trademark"
     }
    ]
   }
  ],
  "plaintext": "Examples of Fair Use of the Plone Trademark"
 },
davisagli commented 1 year ago

@tiberiuichim Is there a way to represent an anchor in slate?

tiberiuichim commented 1 year ago

@davisagli No, here's the code that renders the above data:

https://github.com/plone/volto/blob/6cb3cfab77e9ddc9e32dc29dd45652881db91542/packages/volto-slate/src/editor/plugins/Link/render.jsx#L4-L14

In principle it's a simple matter of stashing some data in the link element and rendering it in the ViewLink component.

davisagli commented 1 year ago

@tiberiuichim Thanks. Though, semantically here maybe it makes more sense as a property of the heading. So maybe it has some relation to https://github.com/plone/volto/pull/3540 then...

tiberiuichim commented 1 year ago

@davisagli oh, right, I forgot about that PR :( I should finish it maybe

pbauer commented 1 year ago

I'm working around that issue for the plone.org migration by dropping the anchors here: https://github.com/plone/plone.org/commit/dedc1d039023c5143b8ac4bf27c9068f66e53efa#diff-80a050ecf679f4bda74b9fa99abf9b8ab3211a301b62a5b826430d52194e4839R211