Skip to content

Commit 29381bb

Browse files
committed
Link Download and display text and alt text update
1 parent f10ab07 commit 29381bb

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

src/helper/find-embeded-object.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { AssetModel } from '../Models/asset-model';
33
import { RenderOption, RenderObject, RenderContentType } from '../options/index';
44
import { EmbeddedAsset, EmbeddedEntry, EmbedTagModel } from '../Models/embeddec-object-model';
55
import { defaultOptions } from '../options/default-options';
6+
import ASSET from '../embedded-types/asset';
67

78
// This function will find Embedded object present in string
89
export function findEmbeddedEntry(
@@ -51,10 +52,10 @@ export function findRenderString(
5152
return '';
5253
}
5354
let text = null
54-
if ((object as EmbeddedEntry).a && (object as EmbeddedEntry).a["#text"]) {
55-
text = (object as EmbeddedEntry).a["#text"]
56-
} else if ((object as EmbeddedEntry).img && (object as EmbeddedEntry).img.alt) {
57-
text = (object as EmbeddedEntry).img.alt
55+
if (object["sys-style-type"] !== ASSET.DISPLAYABLE && (object as EmbeddedEntry)["#text"]) {
56+
text = (object as EmbeddedEntry)["#text"]
57+
} else if ((object as EmbeddedEntry).alt) {
58+
text = (object as EmbeddedEntry).alt
5859
}
5960
if (renderOptions && renderOptions[object['sys-style-type']] !== undefined) {
6061
const renderFunction = renderOptions[object['sys-style-type']] as RenderObject;

src/options/default-options.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,8 @@ export const defaultOptions: RenderOption = {
88
[ENTRY.INLINE]: (entry) => `<span>${entry.title || entry.uid}</span>`,
99
[ENTRY.LINK]: (entry, text) => `<a href="${entry.url}">${text || entry.title || entry.uid}</a>`, // Todo Check for link with Manish
1010
[ASSET.DOWNLOADABLE]: (asset, text) => `<a href="${asset.url}">${text || asset.title || asset.filename || asset.uid}</a>`,
11-
[ASSET.DISPLAYABLE]: (asset, text) => `<img src="${asset.url}" alt="${text || asset.title || asset.filename || asset.uid}" />`,
11+
[ASSET.DISPLAYABLE]: (asset, text) => {
12+
const displaycontent = `<img src="${asset.url}" alt="${text || asset.title || asset.filename || asset.uid}" />`
13+
return displaycontent
14+
},
1215
};

0 commit comments

Comments
 (0)