Skip to content

Commit

Permalink
Fix cross reference in text (#760)
Browse files Browse the repository at this point in the history
* Fix styling on xt links

In Native SAB, the href="some-value" so that the native app can process
the event.

In the PWA, we are handling the event and JavaScript and setting
href="#" which breaks a:link styling.  use href="javascript:void(0)"
instead.

* HACK: fix rendering of anonymous bars
  • Loading branch information
chrisvire authored Jan 3, 2025
1 parent 42af36a commit 3ed7064
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
9 changes: 9 additions & 0 deletions src/lib/components/ScriptureViewSofria.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,16 @@ LOGGING:
console.warn('%s ignored: %s', usfmType, text);
}
};
const fixText = (text) => {
if (text === '| default=""') {
// HACK: Proskomma adds default="" to anonymous bars in text
// See https://community.scripture.software.sil.org/t/issues-with-cross-references-in-pwa-modern/4476
text = '| ';
}
return text;
};
const addText = (workspace, text) => {
text = fixText(text);
if (scriptureLogs?.text) {
console.log('Adding text:', text);
}
Expand Down
3 changes: 2 additions & 1 deletion src/lib/scripts/scripture-reference-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ export function generateAnchor(refClass: string, start, end = undefined): HTMLEl
if (isNotBlank(refClass)) {
anchor.classList.add(refClass);
}
anchor.href = '#';
// use `javascript:void(0)` instead of `#` for anchor so that ref gets a:link styling
anchor.href = 'javascript:void(0)';
anchor.innerHTML = start.phrase;
anchor.setAttribute('data-start-ref', JSON.stringify(start));
anchor.setAttribute('data-end-ref', JSON.stringify(end));
Expand Down

0 comments on commit 3ed7064

Please sign in to comment.