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: 67d7750a4af75be256720a227401885c736d2af67113acfa16889fc5dc599a5d
4
- data.tar.gz: a312eca2e3699de90c89bf5e256a09bca8eedffeb3e00657738ec21fb8fa3059
3
+ metadata.gz: f0fcdb89ba039de9b8a67c84076554f0c682edada146c84f81cb22bc8fec2a62
4
+ data.tar.gz: a7a294bc45bdafd3d9b638c7dbf3a1f6a44d563d0666a49b43f75287441bdf44
5
5
  SHA512:
6
- metadata.gz: 1ae3113f4320e8ce93b70ec08a9b9581101d59c3eddff0444ec1ec42b551cf14f593e085fb919c7a70d634e47aeb49ec7f463c50195c40e56fe9a42636c864db
7
- data.tar.gz: ebc820fe837ad54b2539fbe6c9baed82438c4ad254b9680d1c7716b2d34c6ffcbcfac49f516b5da883f74084116d72c70621b689af5a8adff314d4a9f63f2e04
6
+ metadata.gz: a93248b11908e91cdabf061cd9171ecaae6ce0a7fb38020518f103e0477841c7e6a8ddca861499e3846c74e7e3c0407fb1a6170483d7d8c0a3adf07835386858
7
+ data.tar.gz: 97bcab90207d352eaf2602d3604a79f441a993179be1999b482fb86b7ee0fd056c1efb5f72b2ea919531b9ea21e7dd9271223503488b201c5787f95372d9fb6b
@@ -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
- youtube_embed_disabled:
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</p>
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>
@@ -1,3 +1,3 @@
1
1
  module GovukPublishingComponents
2
- VERSION = "56.3.0".freeze
2
+ VERSION = "56.3.1".freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: govuk_publishing_components
3
3
  version: !ruby/object:Gem::Version
4
- version: 56.3.0
4
+ version: 56.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - GOV.UK Dev