+ if(children.length === 1 && s.element.isEmpty()) {
+ return;
+ }
+
+ s.canvas.wlxmlDocument.transaction(function() {
+ result = s.element.wlxmlNode.breakContent({offset: s.offset});
+ }, {
+ metadata: {
+ description: gettext('Splitting text'),
+ fragment: s.toDocumentFragment()
+ }
+ });
+
+ if(result.emptyText) {
+ goto = result.emptyText;
+ gotoOptions = {};
+ } else {
+ goto = result.second;
+ gotoOptions = {caretTo: 'start'};
+ }
+
+ s.canvas.setCurrentElement(utils.getElementForNode(goto), gotoOptions);
+ }
+ },
+ { // enter - new paragraph after image/video
+ applies: function (e, s) {
+ return s.type === 'nodeSelection' && e.key === KEYS.ENTER && !s.element.isRootElement();
+ },
+ run: function (e, s) {
+ var parent = s.element.parent(),
+ children = parent.children(),
+ result, goto, gotoOptions;
+ e.preventDefault();
+
+ s.canvas.wlxmlDocument.transaction(function() {
+ result = s.element.wlxmlNode.insertNewNode();
+ }, {
+ metadata: {
+ description: gettext('Inserting node'),
+ fragment: s.toDocumentFragment()
+ }
+ });
+
+ s.canvas.setCurrentElement(utils.getElementForNode(result), {caretTo: 'start'});
+ }