]> git.proxmox.com Git - mirror_xterm.js.git/blobdiff - src/Linkifier.ts
Merge remote-tracking branch 'ups/master' into 591_element_on_validation
[mirror_xterm.js.git] / src / Linkifier.ts
index 6f93a897a0e1b8e4a06bb9c564255e524fa10b7c..f99cdaa43c0b485548f1ea1d0ce2fe08da420883 100644 (file)
@@ -88,10 +88,19 @@ export class Linkifier {
    * @param {LinkHandler} handler The handler to use, this can be cleared with
    * null.
    */
-  public attachHypertextLinkHandler(handler: LinkMatcherHandler): void {
+  public setHypertextLinkHandler(handler: LinkMatcherHandler): void {
     this._linkMatchers[HYPERTEXT_LINK_MATCHER_ID].handler = handler;
   }
 
+  /**
+   * Attaches a validation callback for hypertext links.
+   * @param {LinkMatcherValidationCallback} callback The callback to use, this
+   * can be cleared with null.
+   */
+  public setHypertextValidationCallback(callback: LinkMatcherValidationCallback): void {
+    this._linkMatchers[HYPERTEXT_LINK_MATCHER_ID].validationCallback = callback;
+  }
+
   /**
    * Registers a link matcher, allowing custom link patterns to be matched and
    * handled.
@@ -173,9 +182,10 @@ export class Linkifier {
         // Fire validation callback
         if (matcher.validationCallback) {
           for (let j = 0; j < linkElements.length; j++) {
-            matcher.validationCallback(linkElements[j].textContent, isValid => {
+            const element = linkElements[j];
+            matcher.validationCallback(element.textContent, element, isValid => {
               if (!isValid) {
-                linkElements[j].classList.add(INVALID_LINK_CLASS);
+                element.classList.add(INVALID_LINK_CLASS);
               }
             });
           }