@ecency/render-helper 2.3.15 → 2.3.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/methods/a.method.js +3 -3
- package/lib/methods/a.method.js.map +1 -1
- package/lib/methods/iframe.method.js +5 -1
- package/lib/methods/iframe.method.js.map +1 -1
- package/lib/render-helper.js +1 -1
- package/package.json +1 -1
- package/src/markdown-2-html.spec.ts +14 -2
- package/src/methods/a.method.ts +3 -3
- package/src/methods/iframe.method.ts +5 -1
package/package.json
CHANGED
|
@@ -424,7 +424,7 @@ describe('Markdown2Html', () => {
|
|
|
424
424
|
last_update: '2019-05-10T09:15:21',
|
|
425
425
|
body: '[](https://3speak.online/watch?v=wehmoen/xrhjxocx)'
|
|
426
426
|
}
|
|
427
|
-
const expected = '<p dir=\"auto\"><a class="markdown-video-link markdown-video-link-speak" data-embed-src="https://3speak.
|
|
427
|
+
const expected = '<p dir=\"auto\"><a class="markdown-video-link markdown-video-link-speak" data-embed-src="https://3speak.tv/embed?v=wehmoen/xrhjxocx"><img class="no-replace video-thumbnail" itemprop="image" src="https://images.ecency.com/p/2ufhwNgM3qHKBGVeU2TMMqPBjdB17MRuf4Q7vGrmGMtTn6yFtvW3Lt9t5v1c3so7UFhWDYh9B.png?format=match&mode=fit" loading="eager" fetchpriority="high" /><span class="markdown-video-play"></span></a></p>'
|
|
428
428
|
|
|
429
429
|
expect(markdown2Html(input)).toBe(expected)
|
|
430
430
|
})
|
|
@@ -436,7 +436,7 @@ describe('Markdown2Html', () => {
|
|
|
436
436
|
last_update: '2029-05-10T09:15:21',
|
|
437
437
|
body: '[](https://3speak.co/watch?v=theycallmedan/blnmdkjt) [Watch on 3Speak](https://3speak.co/watch?v=theycallmedan/blnmdkjt)'
|
|
438
438
|
}
|
|
439
|
-
const expected = '<p dir=\"auto\"><a class="markdown-video-link markdown-video-link-speak" data-embed-src="https://3speak.
|
|
439
|
+
const expected = '<p dir=\"auto\"><a class="markdown-video-link markdown-video-link-speak" data-embed-src="https://3speak.tv/embed?v=theycallmedan/blnmdkjt"><img class="no-replace video-thumbnail" itemprop="image" src="https://images.ecency.com/p/CQdwDW6BZfWWtctopKyTJuDRdBH4KXwm9ijE6sZXe5MveWF3nUu4zXXBFUau8NS.png?format=match&mode=fit" loading="eager" fetchpriority="high" /><span class="markdown-video-play"></span></a> <a class="markdown-external-link" data-href="https://3speak.co/watch?v=theycallmedan/blnmdkjt">Watch on 3Speak</a></p>'
|
|
440
440
|
|
|
441
441
|
expect(markdown2Html(input)).toBe(expected)
|
|
442
442
|
})
|
|
@@ -501,6 +501,18 @@ describe('Markdown2Html', () => {
|
|
|
501
501
|
expect(markdown2Html(input)).toBe(expected)
|
|
502
502
|
})
|
|
503
503
|
|
|
504
|
+
it('32b - Should treat titled Hive links as non-inline', () => {
|
|
505
|
+
const input = {
|
|
506
|
+
author: 'foo33436',
|
|
507
|
+
permlink: 'bar32436',
|
|
508
|
+
last_update: '2019-05-10T09:15:21',
|
|
509
|
+
body: '[Waves mobile app](https://ecency.com/hive-125125/@ecency/waves-mobile-app-update-explore "https://ecency.com/hive-125125/@ecency/waves-mobile-app-update-explore")'
|
|
510
|
+
}
|
|
511
|
+
const expected = '<p dir=\"auto\"><a title=\"https://ecency.com/hive-125125/@ecency/waves-mobile-app-update-explore\" class=\"markdown-post-link\" data-href=\"https://ecency.com/hive-125125/@ecency/waves-mobile-app-update-explore\" data-is-inline=\"false\" data-tag=\"hive-125125\" data-author=\"ecency\" data-permlink=\"waves-mobile-app-update-explore\">Waves mobile app</a></p>'
|
|
512
|
+
|
|
513
|
+
expect(markdown2Html(input)).toBe(expected)
|
|
514
|
+
})
|
|
515
|
+
|
|
504
516
|
it('33- Should handle whitelisted user links', () => {
|
|
505
517
|
const input = {
|
|
506
518
|
author: 'foo334352',
|
package/src/methods/a.method.ts
CHANGED
|
@@ -690,9 +690,9 @@ export function a(el: HTMLElement | null, forApp: boolean, webp: boolean): void
|
|
|
690
690
|
const imgEls = el.getElementsByTagName('img')
|
|
691
691
|
if (imgEls.length === 1 || el.textContent.trim() === href) {
|
|
692
692
|
const e = SPEAK_REGEX.exec(href)
|
|
693
|
-
// e[1] = tld , e[3] = embed address
|
|
694
|
-
if (e[1] && e[3]) {
|
|
695
|
-
const videoHref = `https://3speak
|
|
693
|
+
// e[1] / e[2] = tld , e[3] = embed address
|
|
694
|
+
if ((e[1] || e[2]) && e[3]) {
|
|
695
|
+
const videoHref = `https://3speak.tv/embed?v=${e[3]}`
|
|
696
696
|
el.setAttribute('class', 'markdown-video-link markdown-video-link-speak')
|
|
697
697
|
el.removeAttribute('href')
|
|
698
698
|
el.setAttribute('data-embed-src', videoHref)
|
|
@@ -40,7 +40,11 @@ export function iframe(el: HTMLElement | null): void {
|
|
|
40
40
|
|
|
41
41
|
// 3Speak
|
|
42
42
|
if (src.match(SPEAK_EMBED_REGEX)) {
|
|
43
|
-
const
|
|
43
|
+
const normalizedSrc = src.replace(/3speak\.[a-z]+/i, '3speak.tv');
|
|
44
|
+
const hasAutoplay = /[?&]autoplay=/.test(normalizedSrc);
|
|
45
|
+
const s = hasAutoplay
|
|
46
|
+
? normalizedSrc
|
|
47
|
+
: `${normalizedSrc}${normalizedSrc.includes('?') ? '&' : '?'}autoplay=true`;
|
|
44
48
|
el.setAttribute('src', s);
|
|
45
49
|
return;
|
|
46
50
|
}
|