selection = editor.getSelectionHelper().getSelectionPoints();
if (selection != null) {
point = selection.getFocus();
} else {
// Still no selection. Oh well, put it at the end.
point = doc.locate(doc.size() - 1);
}
}
XmlStringBuilder content = ImageThumbnail.constructXml(attachmentId, fileName);
ImageThumbnailWrapper thumbnail = ImageThumbnailWrapper.of(doc.insertXml(point, content));
thumbnail.setAttachmentId(attachmentId);