#6459: make it so control-shift-enter sends a blank line to tinymce
----------------------+-----------------------------------------------------
 Reporter:  was       |       Owner:  boothby   
     Type:  defect    |      Status:  new       
 Priority:  minor     |   Milestone:  sage-4.1.1
Component:  notebook  |    Keywords:            
 Reviewer:            |      Author:            
   Merged:            |  
----------------------+-----------------------------------------------------
 {{{
 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).
 }}}

-- 
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/6459>
Sage <http://sagemath.org/>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica, 
and MATLAB

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sage-trac" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/sage-trac?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to