enonic / lib-guillotine

Apache License 2.0
3 stars 0 forks source link

Support links metadata for rich text fields #217

Closed sigdestad closed 2 years ago

sigdestad commented 2 years ago

Currently, both macros and images have specific graphQL fields in addition to the markup value to support client post-processing of the rich text.

We need to offer similar support for links as well, since clients will often need to replace these.

Examples of output from processedHtml output:

This is what a regular content link might look like: <a href=\"/site/hmdb/draft/hmdb/persons/john-travolta\" title=\"Johnny boy\" data-link-ref="123123">internal links</a>

This is what a "download link" might look like <a href=\"/site/hmdb/draft/hmdb/api/_/attachment/download/09b3af0e-6da3-4bcf-88d9-11cbe9c41283:6be9f41d72ad1d0039aa3e691e5e2a939eede37e/Lea-Seydoux.jpg\" data-link-ref="12312qw3eq3">download links</a>

Proposed query:

 text {
   value(processHtml:{}) {
     processedHtml
      links{
         uri 
         ref
         media { # only for media, if content then `null`
            intent # `download` or `inline`
            content 
         }
         content # only for content, if media then `null`
      }
      images{}
      macros{}
      }
   }
}
sigdestad commented 2 years ago

Hi guys, can you have a look at this and improve it if needed?