There is 1 comment.
 
 
XWiki Platform / cid:jira-generated-image-avatar-1f39884b-f02f-4cad-a863-1035ecb28928 XWIKI-24548 Open

Toggle heading with content is saved as a regular heading and paragraph

 
View issue   ยท   Add comment
 

1 comment

 
cid:jira-generated-image-avatar-cd1ba468-dd62-41c3-b7ff-c4a9f2e4db33 Marius Dumitru Florea on 20/Jul/26 14:14
 

Example BlockNote JSON with toggle heading:

[
   {
      "type":"heading",
      "props":{
         "level":2,
         "isToggleable":true
      },
      "content":[
         {
            "type":"text",
            "text":"My toggle heading",
            "styles":{}
         }
      ],
      "children":[
         {
            "type":"paragraph",
            "props":{},
            "content":[
               {
                  "type":"text",
                  "text":"Content that can be hidden",
                  "styles":{}
               }
            ],
            "children":[]
         }
      ]
   }
]

The behavior after XWIKI-24157 is different:

  • The isToggleable flag / information is lost on save. We can easily modify the BlockNote parser to read isToggleable and set a custom parameter on the XDOM heading block. Then modify the BlockNote renderer to check this custom parameter and restore the isToggleable property
  • the heading children (the paragraph in the example above) is lost because currently the BlockNote parser doesn't parse the children of a heading. Basically we assume headings don't have nested blocks. We could modify the BlockNote parser to treat heading children as siblings of the heading, in order to avoid losing that content. But this won't preserve the toggle heading content when editing back. In order to achieve that we need to group the heading children in an XDOM group block, with some marker, and then when rendering back we have to check if the heading is followed by such a group and if it does then consider that group as children of the heading.