Ticket #6459 (closed defect: fixed)
[with patch, positive review] make it so control-shift-enter sends a blank line to tinymce
| Reported by: | was | Owned by: | boothby |
|---|---|---|---|
| Priority: | minor | Milestone: | sage-4.2 |
| Component: | notebook | Keywords: | |
| Cc: | jason | Author(s): | Mitesh Patel |
| Report Upstream: | Reviewer(s): | Karl-Dieter Crisman, Jason Grout, William Stein | |
| Merged in: | Work issues: |
Description
From Pat LeSmithe:
Control-enter is bound to spliteval_cell. To make control-shift-enter, say, insert a line break, try augmenting notebook.py's tinyMCE.init()'s setup with some code ripped from the Safari plug-in:
// Around line 1840 of sage/server/notebook/notebook.py
setup : function(ed) {
ed.onKeyDown.add(function(ed, e) {
// Make ctrl-shift-enter insert a line break. Copied from
the Safari plug-in.
if (e.keyCode == 13 && e.shiftKey && e.ctrlKey) {
// Workaround for missing shift+enter support,
http://bugs.webkit.org/show_bug.cgi?id=16973
var dom = ed.dom, s = ed.selection, r = s.getRng(), br;
// Insert BR element
r.insertNode(br = dom.create('br'));
// Place caret after BR
r.setStartAfter(br);
r.setEndAfter(br);
s.setRng(r);
// Could not place caret after BR then insert an nbsp
entity and move the caret
if (s.getSel().focusNode == br.previousSibling) {
s.select(dom.insertAfter(dom.doc.createTextNode('\u00a0'), br));
s.collapse(1);
}
// Scroll to new position, scrollIntoView can't be
used due to bug: http://bugs.webkit.org/show_bug.cgi?id=16117
ed.getWin().scrollTo(0,
dom.getPos(s.getRng().startContainer).y);
tinymce.dom.Event.cancel(e);
}
});
// Make shift-enter quit editing. This is the "old" code.
ed.onKeyDown.add(function(ed, e) {
if (key_enter_shift(key_event(e))) {
$(ed.formElement).submit();
}
})
}
This seems to work on Linux in Firefox, Opera, and the Qt 4.5 WebKit
demo browser (e.g., /usr/lib64/qt4/demos/browser/browser).
Attachments
Change History
Note: See
TracTickets for help on using
tickets.

