Skip to content

Commit

Permalink
fix: Preserve node and asset URIs in Editable for link editor
Browse files Browse the repository at this point in the history
  • Loading branch information
hlubek committed Mar 21, 2024
1 parent fd13ac5 commit 649513c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
7 changes: 5 additions & 2 deletions src/lib/components/Editable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ type EditableProps = {
};

export default function Editable({ as = 'div', property, ...rest }: EditableProps) {
const { properties, nodeType, contextPath } = useNode();
const { properties, nodeType, contextPath, backend } = useNode();
const inBackend = useInBackend();
const editPreviewMode = useEditPreviewMode();
const { className, ...restAttributes } = rest;
Expand All @@ -26,7 +26,10 @@ export default function Editable({ as = 'div', property, ...rest }: EditableProp
property={'typo3:' + property}
data-neos-node-type={nodeType}
contentEditable
dangerouslySetInnerHTML={{ __html: properties[property] }}
dangerouslySetInnerHTML={{
// Use the actual content from the backend metadata if available to preserve original node and asset URIs
__html: backend?.serializedNode?.properties[property] || properties[property] || '',
}}
{...restAttributes}
/>
);
Expand Down
7 changes: 5 additions & 2 deletions src/server/components/Editable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const Editable = async ({ ctx, as = 'div', property, ...rest }: EditableProps) =
return null;
}

const { contextPath, nodeType, properties } = node;
const { contextPath, nodeType, properties, backend } = node;
const { className, ...restAttributes } = rest;
const Component = as;

Expand All @@ -35,7 +35,10 @@ const Editable = async ({ ctx, as = 'div', property, ...rest }: EditableProps) =
property={'typo3:' + property}
data-neos-node-type={nodeType}
contentEditable
dangerouslySetInnerHTML={{ __html: properties[property] || '' }}
dangerouslySetInnerHTML={{
// Use the actual content from the backend metadata if available to preserve original node and asset URIs
__html: backend?.serializedNode?.properties[property] || properties[property] || '',
}}
{...restAttributes}
/>
);
Expand Down

0 comments on commit 649513c

Please sign in to comment.