]> git.proxmox.com Git - mirror_xterm.js.git/blobdiff - src/Linkifier.ts
Merge remote-tracking branch 'upstream/master' into 578_ctrl_click_links
[mirror_xterm.js.git] / src / Linkifier.ts
index 7aab1ef3c850e6dda8ec7190de5727830bd009e3..1218bdb6742fdf9107c155b4b73631afc779a45c 100644 (file)
@@ -233,9 +233,13 @@ export class Linkifier {
     const element = this._document.createElement('a');
     element.textContent = uri;
     if (handler) {
-      element.addEventListener('click', () => {
-        // Only execute the handler if the link is not flagged as invalid
-        if (!element.classList.contains(INVALID_LINK_CLASS)) {
+      element.addEventListener('click', (event: KeyboardEvent) => {
+        // Don't execute the handler if the link is flagged as invalid
+        if (element.classList.contains(INVALID_LINK_CLASS)) {
+          return;
+        }
+        // Require ctrl on click
+        if (event.ctrlKey) {
           handler(uri);
         }
       });
@@ -243,6 +247,13 @@ export class Linkifier {
       element.href = uri;
       // Force link on another tab so work is not lost
       element.target = '_blank';
+      element.addEventListener('click', (event: KeyboardEvent) => {
+        // Require ctrl on click
+        if (!event.ctrlKey) {
+          event.preventDefault();
+          return false;
+        }
+      });
     }
     return element;
   }