diff --git a/src/leaflet/marker/GenericMarker.ts b/src/leaflet/marker/GenericMarker.ts index a745932..7c57a42 100644 --- a/src/leaflet/marker/GenericMarker.ts +++ b/src/leaflet/marker/GenericMarker.ts @@ -34,7 +34,7 @@ export class GenericMarker extends Marker { icon: options.icon, label: options.tooltip, iconSize: options.dimensions, - isHtml: options.isTooltipHTML, + isHtml: !!options.tooltipHTML, }); this.options.maxZoom = options.maxZoom; diff --git a/src/providers/Pl3xmapMapProvider.ts b/src/providers/Pl3xmapMapProvider.ts index b884882..5ab53e8 100644 --- a/src/providers/Pl3xmapMapProvider.ts +++ b/src/providers/Pl3xmapMapProvider.ts @@ -34,7 +34,7 @@ import LiveAtlasMapDefinition from "@/model/LiveAtlasMapDefinition"; import {MutationTypes} from "@/store/mutation-types"; import MapProvider from "@/providers/MapProvider"; import {ActionTypes} from "@/store/action-types"; -import {titleColoursRegex} from "@/util"; +import {stripHTML, titleColoursRegex} from "@/util"; export default class Pl3xmapMapProvider extends MapProvider { private configurationAbort?: AbortController = undefined; @@ -300,8 +300,8 @@ export default class Pl3xmapMapProvider extends MapProvider { dimensions: marker.size ? [marker.size.x || 16, marker.size.z || 16] : [16, 16], icon: marker.icon || "default", - tooltip: (marker.tooltip || '').trim(), - isTooltipHTML: true, + tooltip: stripHTML(marker.tooltip), + tooltipHTML: marker.tooltip, popup: marker.popup, isPopupHTML: true, }; @@ -327,8 +327,8 @@ export default class Pl3xmapMapProvider extends MapProvider { ], outline: false, - tooltip: area.tooltip, - isTooltipHTML: true, + tooltip: stripHTML(area.tooltip), + tooltipHTML: area.tooltip, popup: area.popup, isPopupHTML: true, }; @@ -349,8 +349,8 @@ export default class Pl3xmapMapProvider extends MapProvider { points: area.points, outline: false, - tooltip: area.tooltip, - isTooltipHTML: true, + tooltip: stripHTML(area.tooltip), + tooltipHTML: area.tooltip, popup: area.popup, isPopupHTML: true, }; @@ -366,8 +366,8 @@ export default class Pl3xmapMapProvider extends MapProvider { }, points: line.points, - tooltip: line.tooltip, - isTooltipHTML: true, + tooltip: stripHTML(line.tooltip), + tooltipHTML: line.tooltip, popup: line.popup, isPopupHTML: true, }; @@ -392,10 +392,10 @@ export default class Pl3xmapMapProvider extends MapProvider { fillRule: circle.fillRule, }, - tooltip: circle.tooltip, - isTooltipHTML: true, + tooltip: stripHTML(circle.tooltip), + tooltipHTML: circle.tooltip, popup: circle.popup, - isPopupHTML: true + isPopupHTML: true, }; } diff --git a/src/util/dynmap.ts b/src/util/dynmap.ts index 3f20971..5bb77a9 100644 --- a/src/util/dynmap.ts +++ b/src/util/dynmap.ts @@ -28,7 +28,7 @@ import { LiveAtlasWorldDefinition } from "@/index"; import {getPoints} from "@/util/areas"; -import {decodeHTMLEntities, endWorldNameRegex, netherWorldNameRegex, titleColoursRegex} from "@/util"; +import {decodeHTMLEntities, endWorldNameRegex, netherWorldNameRegex, stripHTML, titleColoursRegex} from "@/util"; import {getLinePoints} from "@/util/lines"; import LiveAtlasMapDefinition from "@/model/LiveAtlasMapDefinition"; import { @@ -302,14 +302,14 @@ export function buildMarker(data: Marker): LiveAtlasPointMarker { icon: data.icon || "default", minZoom: typeof data.minzoom !== 'undefined' && data.minzoom > -1 ? data.minzoom : undefined, maxZoom: typeof data.maxzoom !== 'undefined' && data.maxzoom > -1 ? data.maxzoom : undefined, - tooltip: data.label || '', - isTooltipHTML: data.markup || false, + tooltip: data.markup ? stripHTML(data.label) : data.label, + tooltipHTML: data.markup ? data.label : undefined, popup: data.desc || undefined, isPopupHTML: true, }; //Fix double escaping on non-HTML labels - if(!marker.isTooltipHTML) { + if(!marker.tooltipHTML) { marker.tooltip = decodeHTMLEntities(marker.tooltip); } @@ -348,8 +348,8 @@ export function buildArea(area: MarkerArea): LiveAtlasAreaMarker { minZoom: typeof area.minzoom !== 'undefined' && area.minzoom > -1 ? area.minzoom : undefined, maxZoom: typeof area.maxzoom !== 'undefined' && area.maxzoom > -1 ? area.maxzoom : undefined, - tooltip: area.label, - isTooltipHTML: area.markup || false, + tooltip: area.markup ? stripHTML(area.label) : area.label, + tooltipHTML: area.markup ? area.label : undefined, popup: area.desc || area.label || undefined, isPopupHTML: area.desc ? true : area.markup || false, }; @@ -380,8 +380,8 @@ export function buildLine(line: MarkerLine): LiveAtlasLineMarker { minZoom: typeof line.minzoom !== 'undefined' && line.minzoom > -1 ? line.minzoom : undefined, maxZoom: typeof line.maxzoom !== 'undefined' && line.maxzoom > -1 ? line.maxzoom : undefined, - tooltip: line.label, - isTooltipHTML: line.markup || false, + tooltip: line.markup ? stripHTML(line.label) : line.label, + tooltipHTML: line.markup ? line.label : undefined, popup: line.desc || line.label || undefined, isPopupHTML: line.desc ? true : line.markup || false, }; @@ -419,8 +419,8 @@ export function buildCircle(circle: MarkerCircle): LiveAtlasCircleMarker { minZoom: typeof circle.minzoom !== 'undefined' && circle.minzoom > -1 ? circle.minzoom : undefined, maxZoom: typeof circle.maxzoom !== 'undefined' && circle.maxzoom > -1 ? circle.maxzoom : undefined, - tooltip: circle.label, - isTooltipHTML: circle.markup || false, + tooltip: circle.markup ? stripHTML(circle.label) : circle.label, + tooltipHTML: circle.markup ? circle.label : undefined, popup: circle.desc || circle.label || undefined, isPopupHTML: circle.desc ? true : circle.markup || false, }; diff --git a/src/util/markers.ts b/src/util/markers.ts index 1f442d5..048b477 100644 --- a/src/util/markers.ts +++ b/src/util/markers.ts @@ -58,7 +58,7 @@ export const updateMarker = (marker: Marker | undefined, options: LiveAtlasPoint icon: options.icon, label: options.tooltip, iconSize: options.dimensions, - isHtml: options.isTooltipHTML, + isHtml: !!options.tooltipHTML, }); } }