parent2 = selectionEnd.element.parent() || undefined;
if(canvas.list.areItemsOfTheSameList({element1: parent1, element2: parent2})) {
parent2 = selectionEnd.element.parent() || undefined;
if(canvas.list.areItemsOfTheSameList({element1: parent1, element2: parent2})) {
} else if(!cursor.isSelecting()) {
var toUnwrap = cursor.getPosition().element,
parent = toUnwrap.unwrap();
} else if(!cursor.isSelecting()) {
var toUnwrap = cursor.getPosition().element,
parent = toUnwrap.unwrap();
parent1 = selectionStart.element.parent() || undefined,
parent2 = selectionEnd.element.parent() || undefined;
parent1 = selectionStart.element.parent() || undefined,
parent2 = selectionEnd.element.parent() || undefined;
- selectionStart.element.wrapWithNodeElement({tag: params.wlxmlTag, klass: params.wlxmlClass, start: selectionStart.offset, end: selectionEnd.offset});
+ var newElement = selectionStart.element.wrapWithNodeElement({tag: params.wlxmlTag, klass: params.wlxmlClass, start: selectionStart.offset, end: selectionEnd.offset}),
+ caretTo = selectionStart.offset < selectionEnd.offset ? 'start' : 'end';
+ canvas.setCurrentElement(newElement.children()[0], {caretTo: caretTo});
- var parent = selectionStart.element.parent();
- canvas.wrapText({
+ var parent = selectionStart.element.parent(),
+ caretTo = selectionStart.element.sameNode(cursor.getSelectionAnchor().element) ? 'end' : 'start';
+
+ var wrapper = canvas.wrapText({
inside: parent,
_with: {tag: params.wlxmlTag, klass: params.wlxmlClass},
offsetStart: selectionStart.offset,
offsetEnd: selectionEnd.offset,
textNodeIdx: [parent.childIndex(selectionStart.element), parent.childIndex(selectionEnd.element)]
});
inside: parent,
_with: {tag: params.wlxmlTag, klass: params.wlxmlClass},
offsetStart: selectionStart.offset,
offsetEnd: selectionEnd.offset,
textNodeIdx: [parent.childIndex(selectionStart.element), parent.childIndex(selectionEnd.element)]
});