aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/dumbyUtils.mjs
diff options
context:
space:
mode:
Diffstat (limited to 'src/dumbyUtils.mjs')
-rw-r--r--src/dumbyUtils.mjs13
1 files changed, 12 insertions, 1 deletions
diff --git a/src/dumbyUtils.mjs b/src/dumbyUtils.mjs
index 13c1142..46594bd 100644
--- a/src/dumbyUtils.mjs
+++ b/src/dumbyUtils.mjs
@@ -1,5 +1,5 @@
1import LeaderLine from 'leader-line' 1import LeaderLine from 'leader-line'
2import { insideWindow, insideParent } from './utils' 2import { insideWindow, insideParent, replaceTextNodes } from './utils'
3import proj4 from 'proj4' 3import proj4 from 'proj4'
4 4
5export const coordPattern = /^geo:([-]?[0-9.]+),([-]?[0-9.]+)/ 5export const coordPattern = /^geo:([-]?[0-9.]+),([-]?[0-9.]+)/
@@ -439,3 +439,14 @@ export const dragForAnchor = (container, range, endOfLeaderLine) => {
439 createGeoLink(geoLink) 439 createGeoLink(geoLink)
440 } 440 }
441} 441}
442
443export const addGeoSchemeByText = async (element) => {
444 const coordPatterns = /(-?\d+\.?\d*)([,\x2F\uFF0C])(-?\d+\.?\d*)/
445 const re = new RegExp(coordPatterns, 'g')
446 replaceTextNodes(element, re, match => {
447 const a = document.createElement('a')
448 a.href = `geo:0,0?xy=${match.at(1)},${match.at(3)}`
449 a.textContent = match.at(0)
450 return a
451 })
452}