Articles in this section

How to Add Annotation Constraints in React Diagram?

In this article, learn how to add annotation constraints for dynamically added annotations during the TextEdit event in the React Diagram component.

When you double-click on a node or connector annotation, the edit box will open. After editing the annotation content, the TextEdit event will be triggered. In this event, you can access the edited node or connector object. Using this object, you can add annotation constraints for the corresponding node or connector.

Please refer to the code below to handle changes inside the TextEdit event:

const textEdit = (args) => {
     let element = args.element;
     if (element.annotations.length > 0) {
       element.annotations[0].constraints =
         AnnotationConstraints.Interaction | AnnotationConstraints.Drag;
     }
   
 }; 

In this code:

  • After editing, we access the edited node or connector through args.element.
  • If the element has annotations, we apply the interaction and drag constraints to the first annotation.

Refer to the working sample for additional details and implementation: Sample

Conclusion

We hope you enjoyed learning how to add annotation constraints in React Diagram.

You can refer to our React Diagram feature tour page to know about its other groundbreaking feature representations and documentation, and how to quickly get started for configuration specifications. You can also explore our React 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!

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Access denied
Access denied