mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-17 00:32:21 +00:00
Credits keep their linked words: only the words a source linked are the link
A credit read from markup keeps the first link's own words as linkText, and the Cesium credit display and the credit line link just those words, as the source wrote them (Street Level's "© Mapillary contributors" links Mapillary only). The Street Level gate reads a drawn item's pick id from its draw-set id.
This commit is contained in:
1 parent
74673f3c85
commit
a7fe3eebc6
9 files changed
+123
-8
No files matched your search
+20
-1
@@ -9,7 +9,12 @@
|
||||
* or logo is kept only for a safe scheme.
|
||||
*/
|
||||
import { findCredits } from '../render/rendererOf.js';
|
||||
import { LINK_SCHEMES, LOGO_SCHEMES, safeUrl } from '../render/creditMarkup.js';
|
||||
import {
|
||||
LINK_SCHEMES,
|
||||
LOGO_SCHEMES,
|
||||
safeUrl,
|
||||
splitLink,
|
||||
} from '../render/creditMarkup.js';
|
||||
import { onLocaleChange, t } from '../i18n/index.js';
|
||||
|
||||
const PANEL_ID = 'gev-credits-panel';
|
||||
@@ -28,6 +33,20 @@ function distinct(list) {
|
||||
/** One credit as DOM: its logo or its text, linked when it has a link. */
|
||||
function creditElement(doc, credit) {
|
||||
const href = credit.href ? safeUrl(credit.href, LINK_SCHEMES) : null;
|
||||
const logoUrl = credit.logoUrl ? safeUrl(credit.logoUrl, LOGO_SCHEMES) : null;
|
||||
// Only the credit's linked words are the link, as the source wrote it.
|
||||
if (href && !logoUrl && credit.linkText) {
|
||||
const [before, words, after] = splitLink(credit);
|
||||
const element = doc.createElement('span');
|
||||
element.className = 'gev-credit';
|
||||
const link = doc.createElement('a');
|
||||
link.href = href;
|
||||
link.target = '_blank';
|
||||
link.rel = 'noopener noreferrer';
|
||||
link.textContent = words;
|
||||
element.append(before, link, after);
|
||||
return element;
|
||||
}
|
||||
const element = doc.createElement(href ? 'a' : 'span');
|
||||
element.className = 'gev-credit';
|
||||
if (href) {
|
||||
|
||||
@@ -132,3 +132,23 @@ test('focus in the list stays in it as it redraws, and goes to the line as it em
|
||||
);
|
||||
off();
|
||||
});
|
||||
|
||||
test('a credit with linked words links only those words', () => {
|
||||
const { viewer, renderer } = scene();
|
||||
renderer.credits.addStatic({
|
||||
text: 'Street Level: imagery © Mapillary contributors, CC BY-SA 4.0',
|
||||
href: 'https://www.mapillary.com/',
|
||||
linkText: 'Mapillary',
|
||||
inline: true,
|
||||
});
|
||||
const off = mountCreditsView(viewer);
|
||||
const credit = document.querySelector('#gev-credits .gev-credit');
|
||||
const link = credit.querySelector('a');
|
||||
assert.equal(link.textContent, 'Mapillary');
|
||||
assert.equal(link.href, 'https://www.mapillary.com/');
|
||||
assert.equal(
|
||||
credit.textContent,
|
||||
'Street Level: imagery © Mapillary contributors, CC BY-SA 4.0',
|
||||
);
|
||||
off();
|
||||
});
|
||||
Reference in new issue
Block a user