Open modal for internal links (WIP)

This commit is contained in:
2025-10-29 18:23:34 +01:00
parent 262540e735
commit 13550078cb
3 changed files with 39 additions and 6 deletions

View File

@@ -151,12 +151,13 @@ Utils.buildBibliography = async function(recordUri, recordId) {
* to Stimulus links
*/
Utils.parseMarkers = function(text) {
const regex = /(?<marker>\[marker coords=\"(?<coords>[\d\s\.]+)\"\](?<content>[\w\s\.;:\-]+)\[\/marker\])/mig;
const regex = /(?<marker>\[marker coords=\"(?<coords>[\d\s\.]+)\"\ ?(group=\"(?<group>\w+)\")?](?<content>[\w\s\.;:\-]+)\[\/marker\])/mig;
let matches = [...text.matchAll(regex)];
if (matches.length) {
matches.forEach(match => {
const replacement = `<a data-action="marker#go modal#close" data-controller="marker" data-marker-coords-value="${match.groups.coords}">
const replacement = `<a data-action="marker#go modal#close tabs#reset marker#goAndOpen" data-controller="marker"
data-marker-coords-value="${match.groups.coords}" data-marker-group-value="${match.groups.group}">
${match.groups.content}</a>`;
text = text.replace(match.groups.marker, replacement.trim());
});