govuk_publishing_components 56.3.1 → 56.3.2

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: f0fcdb89ba039de9b8a67c84076554f0c682edada146c84f81cb22bc8fec2a62
4
- data.tar.gz: a7a294bc45bdafd3d9b638c7dbf3a1f6a44d563d0666a49b43f75287441bdf44
3
+ metadata.gz: 7d76c938f0964afb347980522c6baca92610afaf0d035ffde0f3d8b6bb8fcb03
4
+ data.tar.gz: d8da458559e80bde908f7d80abcf435df61b0c495bcd2d4348e2c39b49553978
5
5
  SHA512:
6
- metadata.gz: a93248b11908e91cdabf061cd9171ecaae6ce0a7fb38020518f103e0477841c7e6a8ddca861499e3846c74e7e3c0407fb1a6170483d7d8c0a3adf07835386858
7
- data.tar.gz: 97bcab90207d352eaf2602d3604a79f441a993179be1999b482fb86b7ee0fd056c1efb5f72b2ea919531b9ea21e7dd9271223503488b201c5787f95372d9fb6b
6
+ metadata.gz: fab8b889f851e16fa0bc0d0dfe3e79ca3140d26d10479bc9ebb99ed1395e6d65833ba4c224e85ad751352538731050b9d7408fc27b5265797a0a271b4ddae155
7
+ data.tar.gz: 5d07560bb97b95bcba67ae3b5fa4744b60994e5dae7c27f80175171df124eee3dab5b9534ce1d1c06b311b641f6b781688124f7e69d8622b84a3d2a5a32d73ae
@@ -86,7 +86,7 @@ window.GOVUK.Modules = window.GOVUK.Modules || {};
86
86
 
87
87
  if (inputType === 'checkbox' && elem.checked) {
88
88
  input.answer = labelText
89
- } else if (inputNodename === 'SELECT' && elem.options[elem.selectedIndex].value) {
89
+ } else if (inputNodename === 'SELECT' && elem.options[elem.selectedIndex] && elem.options[elem.selectedIndex].value) {
90
90
  input.answer = elem.options[elem.selectedIndex].text
91
91
  } else if (inputTypes.indexOf(inputType) !== -1 && elem.value) {
92
92
  if (this.includeTextInputValues || elem.hasAttribute('data-ga4-form-include-input')) {
@@ -67,7 +67,11 @@ window.GOVUK.analyticsGa4.analyticsModules = window.GOVUK.analyticsGa4.analytics
67
67
  tool_name: this.getToolName(),
68
68
  spelling_suggestion: this.getMetaContent('spelling-suggestion'),
69
69
  discovery_engine_attribution_token: this.getMetaContent('discovery-engine-attribution-token'),
70
- canonical_url: this.getCanonicalHref()
70
+ canonical_url: this.getCanonicalHref(),
71
+
72
+ user_created_at: this.getMetaContent('user-created-at'),
73
+ user_organisation_name: this.getMetaContent('user-organisation-name'),
74
+ user_role: this.getMetaContent('user-role')
71
75
  }
72
76
  }
73
77
  window.GOVUK.analyticsGa4.core.sendData(data)
@@ -6,6 +6,7 @@
6
6
  var YoutubeLinkEnhancement = function ($element, $classOverride) {
7
7
  this.$element = $element
8
8
  this.$classOverride = typeof $classOverride !== 'undefined' ? $classOverride : 'gem-c-govspeak__youtube-video'
9
+ this.punctuationRegex = /[\.!\?"']/g // eslint-disable-line no-useless-escape
9
10
  }
10
11
 
11
12
  YoutubeLinkEnhancement.prototype.init = function () {
@@ -18,12 +19,15 @@
18
19
  this.startModule()
19
20
  }
20
21
 
22
+ YoutubeLinkEnhancement.prototype.paragraphHasOtherContent = function (paragraph, link) {
23
+ return paragraph.innerHTML.replaceAll(this.punctuationRegex, '') !== link.outerHTML.replaceAll(this.punctuationRegex, '')
24
+ }
25
+
21
26
  YoutubeLinkEnhancement.prototype.decorateLink = function () {
22
27
  var $youtubeLinks = this.$element.querySelectorAll('a[href*="youtube.com"], a[href*="youtu.be"]')
23
28
  for (var i = 0; i < $youtubeLinks.length; ++i) {
24
29
  var $link = $youtubeLinks[i]
25
-
26
- if (this.hasDisabledEmbed($link)) {
30
+ if (this.hasDisabledEmbed($link) || $link.getAttribute('href').includes('/playlist')) {
27
31
  continue
28
32
  }
29
33
 
@@ -31,7 +35,8 @@
31
35
 
32
36
  // Only replace the <p> with a YT embed if the YT link is the only thing in the <p>.
33
37
  // This prevents other content in the <p> being lost.
34
- if ($linkParent.innerHTML !== $link.outerHTML) {
38
+ // However, if a <p> exists with only a YT link and punctuation, we do allow the punctuation characters to be lost to the YT embed.
39
+ if (this.paragraphHasOtherContent($linkParent, $link)) {
35
40
  continue
36
41
  }
37
42
  var href = $link.getAttribute('href')
@@ -102,7 +107,8 @@
102
107
 
103
108
  // Only replace the <p> with a YT embed if the YT link is the only thing in the <p>.
104
109
  // This prevents other content in the <p> being lost.
105
- if (parentPara.innerHTML !== $link.outerHTML) {
110
+ // However, if a <p> exists with only a YT link and punctuation, we do allow the punctuation characters to be lost to the YT embed.
111
+ if (this.paragraphHasOtherContent(parentPara, $link)) {
106
112
  return
107
113
  }
108
114
 
@@ -1027,6 +1027,11 @@ examples:
1027
1027
  block: |
1028
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_with_punctuation:
1031
+ description: YouTube links should still be enhanced if punctuation is in the same paragraph but outside the YT <a> tag.
1032
+ data:
1033
+ block: |
1034
+ <p>"<a href="https://www.youtube.com/watch?v=y6hbrS3DheU">Operations: a developer's guide, by Anna Shipman</a>."</p>
1030
1035
  youtube_embed_disabled_by_component:
1031
1036
  data:
1032
1037
  disable_youtube_expansions: true
@@ -1,3 +1,3 @@
1
1
  module GovukPublishingComponents
2
- VERSION = "56.3.1".freeze
2
+ VERSION = "56.3.2".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.1
4
+ version: 56.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - GOV.UK Dev
@@ -2039,7 +2039,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
2039
2039
  - !ruby/object:Gem::Version
2040
2040
  version: '0'
2041
2041
  requirements: []
2042
- rubygems_version: 3.6.8
2042
+ rubygems_version: 3.6.9
2043
2043
  specification_version: 4
2044
2044
  summary: A gem to document components in GOV.UK frontend applications
2045
2045
  test_files: []