Bläddra i källkod

chore(entry) move <a> handling code from q-app (#21)

Lucas Fernandes Nogueira 6 år sedan
förälder
incheckning
88f01efbe5
1 ändrade filer med 12 tillägg och 0 borttagningar
  1. 12 0
      lib/tauri.js

+ 12 - 0
lib/tauri.js

@@ -11,6 +11,18 @@
  *
  *
  **/
  **/
 
 
+// open <a href="..."> links with the Tauri API
+document.querySelector('body').addEventListener('click', e => {
+  let target = e.target
+  while (target != null) {
+    if (target.matches ? target.matches('a') : target.msMatchesSelector('a')) {
+      tauri.open(target.href)
+      break
+    }
+    target = target.parentElement
+  }
+}, true)
+
 /**
 /**
  * @module tauri
  * @module tauri
  * @description This API interface makes powerful interactions available
  * @description This API interface makes powerful interactions available