How to Paste URL Annotation Hyperlink Dynamically in Angular Diagram?
In this article, you can learn about how to paste a URL annotation hyperlink dynamically in an Angular diagram. The Syncfusion® Angular Diagram component allows you to dynamically configure a URL as a hyperlink during editing. By using the textEdit event, you can capture the newly entered text and, if it matches a URL pattern, convert it into a clickable hyperlink.
Below is an example demonstrating how to dynamically paste a URL as an annotation hyperlink using the textEdit event:
<ejs-diagram #diagram id="diagram" width="100%" height="550px" (textEdit)="textEdit($event)> </ejs-diagram>
public textEdit(args:ITextEditEventArgs ): void {
const urlPattern = /^(http|https|www)/; // Regular expression to match links
if (urlPattern.test(args.newValue)) {
// Set hyperlink properties
(args.annotation as any).hyperlink = {
content: 'HyperLink content', // Set desired content for the hyperlink
link: args.newValue, // Use the new value as the link
hyperlinkOpenState: 'NewTab', // Open in new tab
textDecoration: 'Underline', // Add underline to the text
};
}
}
Sample: Click Here
Conclusion
We hope you enjoyed learning about how to paste URL annotation hyperlinks dynamically in Angular Diagram.
You can refer to our Angular Diagram feature tour page to learn about its other groundbreaking feature representations and documentation, and how to quickly get started with configuration specifications.
You can also explore our Angular Diagram example to understand how to create and manipulate data.
For current customers, you can check out our components from the License and Downloads page. If you are new to Syncfusion®, you can try our 30-day free trial to check out our other controls. If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forums, BoldDesk Support, or feedback portal. We are always happy to assist you!