mirror of
https://github.com/wavetermdev/xterm.js.git
synced 2026-08-05 13:43:48 -07:00
Expose setHypertextValidationCallback
This commit is contained in:
+10
-1
@@ -75,10 +75,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.
|
||||
|
||||
+16
-1
@@ -1286,7 +1286,7 @@ Terminal.prototype.attachCustomKeydownHandler = function(customKeydownHandler) {
|
||||
* reconstructed. Calling this with null will remove the handler.
|
||||
* @param {LinkHandler} handler The handler callback function.
|
||||
*/
|
||||
Terminal.prototype.attachHypertextLinkHandler = function(handler) {
|
||||
Terminal.prototype.setHypertextLinkHandler = function(handler) {
|
||||
if (!this.linkifier) {
|
||||
throw new Error('Cannot attach a hypertext link handler before Terminal.open is called');
|
||||
}
|
||||
@@ -1295,6 +1295,21 @@ Terminal.prototype.attachHypertextLinkHandler = function(handler) {
|
||||
this.refresh(0, this.rows - 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Attaches a validation callback for hypertext links. This is useful to use
|
||||
* validation logic or to do something with the link's element and url.
|
||||
* @param {LinkMatcherValidationCallback} callback The callback to use, this can
|
||||
* be cleared with null.
|
||||
*/
|
||||
Terminal.prototype.setHypertextValidationCallback = function(handler) {
|
||||
if (!this.linkifier) {
|
||||
throw new Error('Cannot attach a hypertext validation callback before Terminal.open is called');
|
||||
}
|
||||
this.linkifier.setHypertextValidationCallback(handler);
|
||||
// Refresh to force links to refresh
|
||||
this.refresh(0, this.rows - 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers a link matcher, allowing custom link patterns to be matched and
|
||||
* handled.
|
||||
|
||||
Reference in New Issue
Block a user