umbraco / Umbraco-CMS

Umbraco is a free and open source .NET content management system helping you deliver delightful digital experiences.
https://umbraco.com
MIT License
4.42k stars 2.67k forks source link

`RichTextOutputAsJson` skips space between inline elements #17037

Open thebuilder opened 1 week ago

thebuilder commented 1 week ago

Which Umbraco version are you using? (Please write the exact version, example: 10.1.0)

13.4.1

Bug summary

We can get a different HTML output if using RichText as JSON using the content delivery API. Specially, if we have multiple adjacent inline elements. View the HTML in the backoffice, and it's shown correctly. image

However, if we consume JSON output, we can see that it doesn't include a " " between the adjacent inline elements. It should do this, since we cannot infer the intent of the editor. image

Specifics

No response

Steps to reproduce

  1. Set the RichTextOutputAsJson on the Content Delivery API
  2. Add the following HTML to a Rich Text Field
    <p>What follows from <strong>here</strong> <em>is</em> <a  href="#">just</a> a bunch of absolute nonsense I've written to dogfood the plugin itself. It includes every sensible typographic element I could think of, like <strong>bold text</strong>, unordered lists, ordered lists, code blocks, block quotes, <em>and even italics</em>.</p>
  3. Inspect the API output, and see how the space is not included.
{
  "tag": "#root",
  "attributes": {},
  "elements": [
    {
      "tag": "p",
      "attributes": {},
      "elements": [
        {
          "text": "What follows from ",
          "tag": "#text"
        },
        {
          "tag": "strong",
          "attributes": {},
          "elements": [
            {
              "text": "here",
              "tag": "#text"
            }
          ]
        },
        {
          "tag": "em",
          "attributes": {},
          "elements": [
            {
              "text": "is",
              "tag": "#text"
            }
          ]
        },
        {
          "tag": "a",
          "attributes": {
            "rel": "noopener",
            "href": "##",
            "target": "_blank",
            "anchor": "#"
          },
          "elements": [
            {
              "text": "just",
              "tag": "#text"
            }
          ]
        },
        {
          "text": " a bunch of absolute nonsense I've written to dogfood the plugin itself. It includes every sensible typographic element I could think of.",
          "tag": "#text"
        }
      ]
    },
  "blocks": []
}

Expected result / actual result

The resulting API output should include a " " between the inline elements. It would be a simple object like:

{
  "text": " ",
  "tag": "#text"
}

Put into context:


{
  "tag": "#root",
  "attributes": {},
  "elements": [
    {
      "tag": "p",
      "attributes": {},
      "elements": [
        {
          "text": "What follows from ",
          "tag": "#text"
        },
        {
          "tag": "strong",
          "attributes": {},
          "elements": [
            {
              "text": "here",
              "tag": "#text"
            }
          ]
        },
       {
          "text": " ",
          "tag": "#text"
        },
        {
          "tag": "em",
          "attributes": {},
          "elements": [
            {
              "text": "is",
              "tag": "#text"
            }
          ]
        },
        {
          "text": " ",
          "tag": "#text"
        },
        {
          "tag": "a",
          "attributes": {
            "rel": "noopener",
            "href": "##",
            "target": "_blank",
            "anchor": "#"
          },
          "elements": [
            {
              "text": "just",
              "tag": "#text"
            }
          ]
        },
        {
          "text": " a bunch of absolute nonsense I've written to dogfood the plugin itself. It includes every sensible typographic element I could think of.",
          "tag": "#text"
        }
      ]
    },
  "blocks": []
}
github-actions[bot] commented 1 week ago

Hi there @thebuilder!

Firstly, a big thank you for raising this issue. Every piece of feedback we receive helps us to make Umbraco better.

We really appreciate your patience while we wait for our team to have a look at this but we wanted to let you know that we see this and share with you the plan for what comes next.

We wish we could work with everyone directly and assess your issue immediately but we're in the fortunate position of having lots of contributions to work with and only a few humans who are able to do it. We are making progress though and in the meantime, we will keep you in the loop and let you know when we have any questions.

Thanks, from your friendly Umbraco GitHub bot :robot: :slightly_smiling_face: