govuk_publishing_components 57.3.0 → 57.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 +4 -4
- data/app/assets/javascripts/govuk_publishing_components/components/reorderable-list.js +2 -1
- data/app/assets/javascripts/govuk_publishing_components/lib/govspeak/youtube-link-enhancement.js +15 -3
- data/app/views/govuk_publishing_components/components/docs/organisation_logo.yml +1 -1
- data/lib/govuk_publishing_components/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 41a446b912bf0ceb75ba5700eeff0f6d91b976039d175fe9262e44ed75fbd420
|
4
|
+
data.tar.gz: 18c75d217261b9b6793f251cc2020fa785da20f31aa47ada9721dbb642a4ccb8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d3ee818d7df8773727db46921ba33a905de236ed76b4a3c00d5aad2394cf26513fbc6a1039926e7ac29466ec98d1e25b98701d49cfcd10e7c663abb1f23aaaf9
|
7
|
+
data.tar.gz: 46bb83df7af008ed114877f485b4888789c1e72b7876692c10a025e631df2391a99ee4c631e5d5ec3325c3a517d8cda520e20fd4c2832d6dc0d900e75577afcd
|
@@ -25,8 +25,9 @@ window.GOVUK.Modules = window.GOVUK.Modules || {};
|
|
25
25
|
|
26
26
|
if (eventData) {
|
27
27
|
item.dataset.ga4Event = eventData.dataset.ga4Event
|
28
|
+
item.dataset.indexSection = event.oldIndex
|
28
29
|
item.dataset.action = 'drag and drop'
|
29
|
-
item.dataset.text = event.newIndex > event.oldIndex ? '
|
30
|
+
item.dataset.text = event.newIndex > event.oldIndex ? 'Down' : 'Up'
|
30
31
|
this.triggerEvent(item, 'click')
|
31
32
|
delete item.dataset.ga4Event
|
32
33
|
}
|
data/app/assets/javascripts/govuk_publishing_components/lib/govspeak/youtube-link-enhancement.js
CHANGED
@@ -20,7 +20,7 @@
|
|
20
20
|
}
|
21
21
|
|
22
22
|
YoutubeLinkEnhancement.prototype.paragraphHasOtherContent = function (paragraph, link) {
|
23
|
-
return paragraph.innerHTML.replaceAll(this.punctuationRegex, '') !== link.outerHTML.replaceAll(this.punctuationRegex, '')
|
23
|
+
return paragraph.innerHTML.replaceAll(this.punctuationRegex, '').trim() !== link.outerHTML.replaceAll(this.punctuationRegex, '').trim()
|
24
24
|
}
|
25
25
|
|
26
26
|
YoutubeLinkEnhancement.prototype.decorateLink = function () {
|
@@ -222,6 +222,17 @@
|
|
222
222
|
}
|
223
223
|
}
|
224
224
|
|
225
|
+
YoutubeLinkEnhancement.sanitiseVideoId = function (pathname) {
|
226
|
+
// YouTube links can now contain an ?si= param in the URL.
|
227
|
+
// This usually only appears on youtu.be links but it's appearing for us on youtube.com URLs due to some Whitehall regex being outdated.
|
228
|
+
// Therefore we need to use regex to remove it from the path.
|
229
|
+
// E.g. youtube.com/watch?v=[video-id]?si=ABCzJtVWBAZ2o_l3
|
230
|
+
// ?=si in this case isn't a valid query parameter as it isn't using an &, so we can't use JS' native URL API to filter it out.
|
231
|
+
if (pathname) {
|
232
|
+
return pathname.replace(/(\?|&)(.+)=.+/g, '')
|
233
|
+
}
|
234
|
+
}
|
235
|
+
|
225
236
|
// This is a public class method so it can be used outside of this embed to
|
226
237
|
// check that user input for videos will be supported in govspeak
|
227
238
|
YoutubeLinkEnhancement.parseVideoId = function (url) {
|
@@ -232,9 +243,10 @@
|
|
232
243
|
} catch (e) { return undefined }
|
233
244
|
|
234
245
|
if (u.host === 'www.youtube.com' || u.host === 'youtube.com') {
|
235
|
-
return u.searchParams.get('v') || undefined
|
246
|
+
return this.sanitiseVideoId(u.searchParams.get('v')) || undefined
|
236
247
|
} else if (u.host === 'youtu.be') {
|
237
|
-
|
248
|
+
var pathName = u.pathname.slice(1) // Trim the leading /
|
249
|
+
return this.sanitiseVideoId(pathName)
|
238
250
|
}
|
239
251
|
}
|
240
252
|
|
@@ -150,7 +150,7 @@ examples:
|
|
150
150
|
url: '/government/organisations/hm-prison-service'
|
151
151
|
brand: 'ministry-of-justice'
|
152
152
|
image:
|
153
|
-
url: 'https://assets.publishing.service.gov.uk/
|
153
|
+
url: 'https://assets.publishing.service.gov.uk/media/6850134301d3b0e7b62da740/hmps_25_gov_240x188.png'
|
154
154
|
alt_text: 'HM Prison Service'
|
155
155
|
without_a_link:
|
156
156
|
data:
|