Skip to content

Commit

Permalink
Decode HTML entities in cartouche labels (#5930)
Browse files Browse the repository at this point in the history
**Problem:**

HTML entities are displayed raw in the cartouche labels.

**Fix:**

Parse the entities when building the content to display.

<img width="547" alt="Screenshot 2024-06-13 at 5 29 45 PM"
src="https://github.com/concrete-utopia/utopia/assets/1081051/8b4caeca-72d2-48d3-97c7-2e5ef5df3953">


**Manual Tests:**
I hereby swear that:

- [x] I opened a hydrogen project and it loaded
- [x] I could navigate to various routes in Preview mode

Fixes #5916
  • Loading branch information
ruggi authored Jun 13, 2024
1 parent 04a5b5b commit 26c219a
Showing 1 changed file with 11 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ import { useAtom } from 'jotai'
import type { CartoucheDataType, CartoucheHighlight, CartoucheUIProps } from './cartouche-ui'
import { CartoucheUI } from './cartouche-ui'
import * as PP from '../../../../core/shared/property-path'
import { AllHtmlEntities } from 'html-entities'

const htmlEntities = new AllHtmlEntities()

interface DataReferenceCartoucheControlProps {
elementPath: ElementPath
Expand All @@ -44,11 +47,16 @@ export const DataReferenceCartoucheControl = React.memo(

const contentsToDisplay = useEditorState(
Substores.metadata,
(store) =>
getTextContentOfElement(
(store) => {
const content = getTextContentOfElement(
childOrAttribute,
MetadataUtils.findElementByElementPath(store.editor.jsxMetadata, elementPath),
),
)
if (content.label != null) {
return { ...content, label: htmlEntities.decode(content.label) }
}
return content
},
'DataReferenceCartoucheControl contentsToDisplay',
)

Expand Down

0 comments on commit 26c219a

Please sign in to comment.