+ selectionEnd = cursor.getSelectionEnd(),
+ wlxmlNode, caretTo, wrapper, wrapperCanvasElement;
+
+ var insertNode = function(insertion) {
+ var doc = canvas.wlxmlDocument,
+ node, metadata, creator;
+
+ doc.startTransaction();
+ node = insertion();
+ if(node.getTagName() === 'aside' && node.getClass() === 'comment') {
+ if(user) {
+ creator = user.name;
+ if(user.email) {
+ creator += ' (' + user.email + ')';
+ }
+ } else {
+ creator = 'anonymous';
+ }
+
+ metadata = node.getMetadata();
+ metadata.add({key: 'creator', value: creator});
+ metadata.add({key: 'date', value: datetime.currentStrfmt()});
+ }
+ doc.endTransaction();
+ return node;
+ };
+