], function(documentElement, utils) {
'use strict';
-
+/* globals gettext */
var KEYS = {
ENTER: 13,
if(Object.keys(cursor.getPosition()).length === 0) {
var currentElement = canvas.getCurrentNodeElement();
if(currentElement) {
- canvas.wlxmlDocument.startTransaction();
+ canvas.wlxmlDocument.startTransaction(gettext('Splitting text'));
added = currentElement.wlxmlNode.after({
tagName: currentElement.getWlxmlTag() || 'div',
attrs: {'class': currentElement.getWlxmlClass() || 'p'}
element = element.parent();
}
- canvas.wlxmlDocument.startTransaction();
+ canvas.wlxmlDocument.startTransaction(gettext('Splitting text'));
added = element.wlxmlNode.after(
{tagName: element.getWlxmlTag() || 'div', attrs: {'class': element.getWlxmlClass() || 'p'}}
);
// goto = nodes.second;
// gotoOptions = {caretTo: 'start'};
// }
+ var node = position.element.wlxmlNode,
+ result, goto, gotoOptions;
+
+ node.document.transaction(function() {
+ result = position.element.wlxmlNode.breakContent({offset: position.offset});
+ }, this, gettext('Splitting text'));
- var result = position.element.wlxmlNode.breakContent({offset: position.offset}),
- goto, gotoOptions;
if(result.emptyText) {
goto = result.emptyText;
gotoOptions = {};
var cursor = canvas.getCursor(),
position = canvas.getCursor().getPosition(),
element = position.element,
- node = element.wlxmlNode,
+ node = element ? element.wlxmlNode : null,
direction = 'above',
caretTo = 'end',
goto;
+ if(!element || !node) {
+ return;
+ }
if(event.which === KEYS.DELETE) {
direction = 'below';