webiny-js icon indicating copy to clipboard operation
webiny-js copied to clipboard

Copied text into PB paragraph element not visible

Open plsalvado opened this issue 3 years ago • 0 comments

Version

5.29.0

Operating System

macOS

Browser

Chrome

What are the steps to reproduce this bug?

  1. Create a page with a paragraph element
  2. Go to this page - as an example - and copy the text at the top "Our mission is to organise the world’s information and make it universally accessible and useful." You need to copy it from the website itself.
  3. Paste that text into the paragraph element.

What is the expected behavior?

When the page is published the text should be rendered.

What do you see instead?

A few important things to note:

  1. The page renders OK in preview mode,
  2. The paragraph is not rendered when the page is published. Reasons why below.

The copied text contains some HTML encoded tags which are not being sanitised at the time of pasting the content into PB. See in the Additional Information section how the text attribute contains an HTML encoded p tag, which breaks the rendering of the published page.

Additional information

"elements": [{
    "id": "WCKfnhSUCi",
    "type": "paragraph",
    "data": {
        "text": {
            "desktop": {
                "type": "paragraph",
                "typography": "webiny-pb-typography-body",
                "alignment": "left",
                "tag": "p"
            },
            "data": {
                "text": "\u003cp>Our mission is to organise the world’s information and make it universally accessible and useful.\u003c/p>"
            }
        },
        "settings": {
            "margin": {
                "desktop": {
                    "all": "0px"
                }
            },
            "padding": {
                "desktop": {
                    "all": "0px"
                }
            }
        }
    },
    "elements": [],
    "path": ["aoOvCNMuES", "lHbpgj5NuK",
        "sneNOpuOCI"
    ]
}],
"path": ["aoOvCNMuES", "lHbpgj5NuK", "sneNOpuOCI"]

Possible solution

Sanitise the text at the time of pasting into the element.

Another important note, this is not happening with the Heading element.

plsalvado avatar Aug 02 '22 09:08 plsalvado