govuk_publishing_components 56.3.0 → 56.3.1
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.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f0fcdb89ba039de9b8a67c84076554f0c682edada146c84f81cb22bc8fec2a62
|
4
|
+
data.tar.gz: a7a294bc45bdafd3d9b638c7dbf3a1f6a44d563d0666a49b43f75287441bdf44
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a93248b11908e91cdabf061cd9171ecaae6ce0a7fb38020518f103e0477841c7e6a8ddca861499e3846c74e7e3c0407fb1a6170483d7d8c0a3adf07835386858
|
7
|
+
data.tar.gz: 97bcab90207d352eaf2602d3604a79f441a993179be1999b482fb86b7ee0fd056c1efb5f72b2ea919531b9ea21e7dd9271223503488b201c5787f95372d9fb6b
|
data/app/assets/javascripts/govuk_publishing_components/lib/govspeak/youtube-link-enhancement.js
CHANGED
@@ -22,7 +22,18 @@
|
|
22
22
|
var $youtubeLinks = this.$element.querySelectorAll('a[href*="youtube.com"], a[href*="youtu.be"]')
|
23
23
|
for (var i = 0; i < $youtubeLinks.length; ++i) {
|
24
24
|
var $link = $youtubeLinks[i]
|
25
|
+
|
26
|
+
if (this.hasDisabledEmbed($link)) {
|
27
|
+
continue
|
28
|
+
}
|
29
|
+
|
25
30
|
var $linkParent = $link.closest('p')
|
31
|
+
|
32
|
+
// Only replace the <p> with a YT embed if the YT link is the only thing in the <p>.
|
33
|
+
// This prevents other content in the <p> being lost.
|
34
|
+
if ($linkParent.innerHTML !== $link.outerHTML) {
|
35
|
+
continue
|
36
|
+
}
|
26
37
|
var href = $link.getAttribute('href')
|
27
38
|
var text = $link.textContent
|
28
39
|
var placeholder = document.createElement('p')
|
@@ -89,6 +100,12 @@
|
|
89
100
|
var parentPara = $link.parentNode
|
90
101
|
var parentContainer = parentPara.parentNode
|
91
102
|
|
103
|
+
// Only replace the <p> with a YT embed if the YT link is the only thing in the <p>.
|
104
|
+
// This prevents other content in the <p> being lost.
|
105
|
+
if (parentPara.innerHTML !== $link.outerHTML) {
|
106
|
+
return
|
107
|
+
}
|
108
|
+
|
92
109
|
var youtubeVideoContainer = document.createElement('div')
|
93
110
|
youtubeVideoContainer.className += this.$classOverride
|
94
111
|
youtubeVideoContainer.innerHTML = '<span id="' + elementId + '" data-video-id="' + id + '"></span>'
|
@@ -1025,16 +1025,26 @@ examples:
|
|
1025
1025
|
youtube_embed:
|
1026
1026
|
data:
|
1027
1027
|
block: |
|
1028
|
-
<p>This content has a YouTube video link, converted to an accessible embedded player by component JavaScript.</p>
|
1028
|
+
<p>This content has a YouTube video link, converted to an accessible embedded player by component JavaScript. Bear in mind that the link will not convert if the paragraph it is in contains other content.</p>
|
1029
1029
|
<p><a href="https://www.youtube.com/watch?v=y6hbrS3DheU">Operations: a developer's guide, by Anna Shipman</a></p>
|
1030
|
-
|
1030
|
+
youtube_embed_disabled_by_component:
|
1031
1031
|
data:
|
1032
1032
|
disable_youtube_expansions: true
|
1033
1033
|
block: |
|
1034
|
-
<p>This content has a YouTube video link, where the govspeak expansion has been disabled
|
1034
|
+
<p>This content has a YouTube video link, where the govspeak expansion has been disabled by the render statement for the component.</p>
|
1035
1035
|
<p><a href="https://www.youtube.com/watch?v=y6hbrS3DheU">Operations: a developer's guide, by Anna Shipman</a></p>
|
1036
|
+
youtube_embed_disabled_by_content:
|
1037
|
+
description: YouTube links should not become an embed if the YouTube link is in a paragraph with other content.
|
1038
|
+
data:
|
1039
|
+
block: |
|
1040
|
+
<p>This youtube video titled <a href="https://www.youtube.com/watch?v=y6hbrS3DheU">Operations: a developer's guide, by Anna Shipman</a> should stay as a link due to this non-link text existing in the paragraph.</p>
|
1041
|
+
youtube_embed_disabled_by_editors:
|
1042
|
+
description: Editors can disable YouTube link enhancement by using the `data-youtube-player="off"` HTML attribute.
|
1043
|
+
data:
|
1044
|
+
block: |
|
1045
|
+
<p><a href="https://www.youtube.com/watch?v=y6hbrS3DheU" data-youtube-player="off">Operations: a developer's guide, by Anna Shipman</a></p>
|
1036
1046
|
youtube_livestream:
|
1037
1047
|
data:
|
1038
1048
|
block: |
|
1039
|
-
<p>This content has a YouTube livestream link, converted to an accessible embedded player by component JavaScript.</p>
|
1049
|
+
<p>This content has a YouTube livestream link, converted to an accessible embedded player by component JavaScript. Bear in mind that the link will not convert if the paragraph it is in contains other content.</p>
|
1040
1050
|
<p><a href="https://www.youtube.com/embed/live_stream?channel=UCoMdktPbSTixAyNGwb-UYkQ">Livestream video</a></p>
|