Simplify marker regex + link CSS
This commit is contained in:
parent
ebea10059e
commit
b0915d0973
@ -4,7 +4,6 @@ import { GisState } from "../state.js";
|
||||
*/
|
||||
const Utils = {};
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {string} galleryId The image gallery's id
|
||||
@ -145,13 +144,12 @@ Utils.buildBibliography = async function(recordUri, recordId) {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {String} text - The content text from database
|
||||
* Parse marker strings (pseudo-shortcodes) and convert them
|
||||
* to Stimulus links
|
||||
* @param {String} text - The content text from database
|
||||
*/
|
||||
Utils.parseMarkers = function(text) {
|
||||
const regex = /(?<marker>\[marker coords=\"(?<coords>[\d\s\.]+)\"\ ?(group=\"(?<group>\w+)\")?](?<content>[\w\d\s\.;,:\-\(\)\"\']+)\[\/marker\])/mig;
|
||||
const regex = /(?<marker>\[marker coords=\"(?<coords>[\d\s\.]+)\"\ ?(group=\"(?<group>\w+)\")?](?<content>[\s\S]+?)\[\/marker\])/mig;
|
||||
|
||||
if (!text) return text;
|
||||
|
||||
@ -159,9 +157,9 @@ Utils.parseMarkers = function(text) {
|
||||
|
||||
if (matches.length) {
|
||||
matches.forEach(match => {
|
||||
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>`;
|
||||
const replacement = `<a class="has-text-link" 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.trim()}</a>`;
|
||||
text = text.replace(match.groups.marker, replacement.trim());
|
||||
});
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user