本文整理汇总了TypeScript中autolinker.link函数的典型用法代码示例。如果您正苦于以下问题:TypeScript link函数的具体用法?TypeScript link怎么用?TypeScript link使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了link函数的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: linkify
function linkify(text: string, options: LinkifyOptions): string {
const autolinker = new Autolinker({
urls: {
schemeMatches: true,
wwwMatches: true,
tldMatches: true
},
email: true,
phone: true,
hashtag: false,
stripPrefix: true,
newWindow: true,
truncate: {
length: 60,
location: "end"
},
className: ""
});
const res = autolinker.link(text);
if (options && options.skipMediaLinks) {
return res;
}
try {
return links.processMediaLinks(res);
} catch (err) {
log.error(err);
return res;
}
}
示例2: it
it( `Autolinker should be the default export of 'autolinker'`, () => {
expect( Autolinker ).toEqual( jasmine.any( Function ) ); // constructor function
expect( Autolinker.link ).toEqual( jasmine.any( Function ) );
expect( Autolinker.link( 'Hello google.com', { newWindow: false } ) )
.toBe( 'Hello <a href="http://google.com">google.com</a>' );
} );
示例3:
document.addEventListener( 'DOMContentLoaded', () => {
var resultEl = document.getElementById( 'result' )!;
var options: AutolinkerConfig = { newWindow: false }; // Note: Testing that the AutolinkerConfig interface can be imported
var linkedStr = Autolinker.link( 'Go to google.com', options );
resultEl.innerHTML = linkedStr;
} );
示例4: transform
transform(html: string): string {
return Autolinker.link(html, {
replaceFn(autolinker, match) {
const tag = match.buildTag();
tag.setAttr('target', '_system');
return tag;
}
});
}
示例5: transform
transform(value:string, args?: any[]): string {
let options = args !== undefined ? args[0] : null;
return Autolinker.link(value, options);
}
示例6: it
it( 'should run using the AutolinkerConfig interface import', () => {
var options: AutolinkerConfig = { newWindow: false }; // Note: Testing that the AutolinkerConfig interface can be imported
var linkedStr = Autolinker.link( 'Go to google.com', options );
expect( linkedStr ).toBe( `Go to <a href="http://google.com">google.com</a>` );
} );
示例7: transform
transform(value: string, options?: any): string {
return Autolinker.link(value, options);
}
示例8: transform
transform(value: any, args?: any): any {
return Autolinker.link(value, args);
}