@@ -53,7 +53,7 @@ describe('Linkifier', () => {
|
|||||||
it('should enable link if true', done => {
|
it('should enable link if true', done => {
|
||||||
addRow('test');
|
addRow('test');
|
||||||
linkifier.registerLinkMatcher(/test/, () => done(), {
|
linkifier.registerLinkMatcher(/test/, () => done(), {
|
||||||
validationCallback: (url, cb) => {
|
validationCallback: (url, element, cb) => {
|
||||||
cb(true);
|
cb(true);
|
||||||
assert.equal((<HTMLElement>rows[0].firstChild).tagName, 'A');
|
assert.equal((<HTMLElement>rows[0].firstChild).tagName, 'A');
|
||||||
setTimeout(() => clickElement(rows[0].firstChild), 0);
|
setTimeout(() => clickElement(rows[0].firstChild), 0);
|
||||||
@@ -65,7 +65,7 @@ describe('Linkifier', () => {
|
|||||||
it('should disable link if false', done => {
|
it('should disable link if false', done => {
|
||||||
addRow('test');
|
addRow('test');
|
||||||
linkifier.registerLinkMatcher(/test/, () => assert.fail(), {
|
linkifier.registerLinkMatcher(/test/, () => assert.fail(), {
|
||||||
validationCallback: (url, cb) => {
|
validationCallback: (url, element, cb) => {
|
||||||
cb(false);
|
cb(false);
|
||||||
assert.equal((<HTMLElement>rows[0].firstChild).tagName, 'A');
|
assert.equal((<HTMLElement>rows[0].firstChild).tagName, 'A');
|
||||||
setTimeout(() => clickElement(rows[0].firstChild), 0);
|
setTimeout(() => clickElement(rows[0].firstChild), 0);
|
||||||
|
|||||||
+1
-1
@@ -160,7 +160,7 @@ export class Linkifier {
|
|||||||
const linkElement = this._doLinkifyRow(rowIndex, uri, matcher.handler, matcher.id === HYPERTEXT_LINK_MATCHER_ID);
|
const linkElement = this._doLinkifyRow(rowIndex, uri, matcher.handler, matcher.id === HYPERTEXT_LINK_MATCHER_ID);
|
||||||
// Fire validation callback
|
// Fire validation callback
|
||||||
if (linkElement && matcher.validationCallback) {
|
if (linkElement && matcher.validationCallback) {
|
||||||
matcher.validationCallback(uri, isValid => {
|
matcher.validationCallback(uri, linkElement, isValid => {
|
||||||
if (!isValid) {
|
if (!isValid) {
|
||||||
linkElement.classList.add(INVALID_LINK_CLASS);
|
linkElement.classList.add(INVALID_LINK_CLASS);
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -11,4 +11,4 @@ export type LinkMatcher = {
|
|||||||
priority?: number
|
priority?: number
|
||||||
};
|
};
|
||||||
export type LinkMatcherHandler = (event: MouseEvent, uri: string) => boolean | void;
|
export type LinkMatcherHandler = (event: MouseEvent, uri: string) => boolean | void;
|
||||||
export type LinkMatcherValidationCallback = (uri: string, callback: (isValid: boolean) => void) => void;
|
export type LinkMatcherValidationCallback = (uri: string, element: HTMLElement, callback: (isValid: boolean) => void) => void;
|
||||||
|
|||||||
Reference in New Issue
Block a user