Skip to content
This repository has been archived by the owner on Oct 18, 2024. It is now read-only.

Commit

Permalink
fix(edusharing-embed): Make link embeds visible
Browse files Browse the repository at this point in the history
  • Loading branch information
LarsTheGlidingSquirrel committed Mar 18, 2024
1 parent a4eb45a commit ddedc1e
Showing 1 changed file with 28 additions and 2 deletions.
30 changes: 28 additions & 2 deletions src/frontend/plugins/edusharing-asset/renderer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ export function EdusharingAssetRenderer(props: {
ltik: string
contentWidth: string | null
}) {
// Use default value for widthInPercent so that old content can be load
// where this property was not set
const { nodeId, repositoryId, ltik, contentWidth } = props

let [embedHtml, setEmbedHtml] = useState<string | null>(null)
Expand Down Expand Up @@ -107,6 +105,34 @@ export function EdusharingAssetRenderer(props: {
const parser = new DOMParser()
const htmlDocument = parser.parseFromString(detailsSnippet, 'text/html')

// Sadly, LearningApps also have `mediatype: 'link'` so we need to check more stuff here than just `mediatype`
const isLink =
content.node.mediatype === 'link' &&
!content.node.mimetype &&
content.node.repositoryType === 'ALFRESCO'
if (isLink) {
const linkElement = htmlDocument.querySelector<HTMLLinkElement>(
'.edusharing_rendering_content_footer a',
)
if (!linkElement) {
return {
html: '<div>Fehler beim Einbinden des Inhalts</div>',
renderMethod: 'dangerously-set-inner-html',
defineContainerHeight: false,
}
}

return {
html: `<a class="serlo-link" target="_blank" rel="noopener noreferrer" href="${
linkElement.href
}">${
linkElement.innerText ? linkElement.innerText : linkElement.href
}</a>`,
renderMethod: 'dangerously-set-inner-html',
defineContainerHeight: false,
}
}

const image = getImageOrUndefined(htmlDocument)

const isPixabayImage =
Expand Down

0 comments on commit ddedc1e

Please sign in to comment.