// })
this.dom.css('display', what);
this._container().css('display', what);
+ },
+ children: function() {
+ return [];
}
});
return s.type === 'caret' && e.key === KEYS.ENTER && !s.element.parent().isRootElement();
},
run: function(e, s) {
- var result, goto, gotoOptions;
+ var parent = s.element.parent(),
+ children = parent.children(),
+ result, goto, gotoOptions;
void(e);
e.preventDefault();
+
+ if(children.length === 1 && s.element.isEmpty()) {
+ return;
+ }
+
s.canvas.wlxmlDocument.transaction(function() {
result = s.element.wlxmlNode.breakContent({offset: s.offset});
}, {
expect(selection.offset).to.equal(0);
});
+ it('does nothing on an empty paragraph', function() {
+ var c = getCanvasFromXML('<section><div class="p">a</div></section>'),
+ k = new Keyboard(c),
+ spy = sinon.spy();
+
+ k.withCaret('a|').press(K.BACKSPACE);
+ c.wlxmlDocument.on('change', spy);
+ k.press(K.ENTER);
+ expect(spy.callCount).to.equal(0);
+ });
+
it('splits its parent box if inside a span', function() {
var c = getCanvasFromXML('<section><div class="p">this <span>is</span> a paragraph</div></section>'),
k = new Keyboard(c);