onLinkClick method
Implementation
void onLinkClick(BuildContext context) {
LinkDialog.instance.show(
context: context,
complete: (LinkContent content) {
var index = controller.selection.start;
var length = controller.selection.end - index;
var linkValue = controller.getSelectionStyle().attributes[Attribute.link.key]?.value;
if (linkValue != null) {
final leaf = controller.document.querySegmentLeafNode(index).leaf;
if (leaf != null) {
final range = getLinkRange(leaf);
index = range.start;
length = range.end - range.start;
}
}
controller.replaceText(index, length, content.text, null);
controller.formatText(index, content.text.length, LinkAttribute(content.link));
controller.moveCursorToPosition(index + content.text.length);
});
}