UNPKG

1.02 kBJavaScriptView Raw
1import Parse from '../parse';
2import { computedImageSize } from '../helpers';
3
4class WebRich extends Parse {
5 constructor(option) {
6 super(option);
7 this.platform = option.platform;
8 this.containerWidth = option.width;
9 }
10
11 renderImage(props) {
12 const { width, height } = computedImageSize(
13 +props.width,
14 +props.height,
15 this.containerWidth
16 );
17 return `<p><img style="width:${width}px;" src="${
18 props.url
19 }">${
20 props.desc && props.desc !== '' ? `<span>${props.desc}</span>` : ''
21 }</p>`;
22 }
23
24 renderLink(props) {
25 return `<a href="${props.route.webUrl || props.route.webURL}" target="_blank">${props.content}</a>`;
26 }
27
28 renderVideo(props) {
29 return `<video width="600" height="400" controls="controls">
30 <source src="${props.url}">
31 </video>`
32 // return `<video url="${props.url}" controls="${props.controls}" width="600" height="400" webkit-playsinline="true" playsinline="true" x5-playsinline="true"></video>`;
33 }
34}
35
36export default WebRich;