Ignore:
Timestamp:
02/06/18 11:47:27 (6 months ago)
Author:
gogo
Message:

Add improved and standardised tab handling support for Gecko and WebKit?, configurable by the tabSpanClass and tabSpanContents options.

Hitting tab will insert a span with the given class and contents, hitting more than once will insert nested tab spans, hitting shift-tab will remove the current tab span if you are in one, do nothing otherwise.

tested in FF and Chrome, it seems to work well.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/modules/WebKit/WebKit.js

    r1336 r1378  
    187187    break; 
    188188     
     189    case 9: // KEY tab 
     190    { 
     191      // Note that the ListOperations plugin will handle tabs in list items and indent/outdent those 
     192      // at some point TableOperations might do also 
     193      // so this only has to handle a tab/untab in text 
     194      if(editor.config.tabSpanClass) 
     195      { 
     196        if(!ev.shiftKey) 
     197        { 
     198          editor.insertHTML('<span class="'+editor.config.tabSpanClass+'">'+editor.config.tabSpanContents+'</span>'); 
     199          var s = editor.getSelection().collapseToEnd(); 
     200        } 
     201        else 
     202        { 
     203          var existingTab = editor.getParentElement(); 
     204          if(existingTab && existingTab.className.match(editor.config.tabSpanClass)) 
     205          { 
     206            var s = editor.getSelection(); 
     207            s.removeAllRanges(); 
     208            var r = editor.createRange(); 
     209            r.selectNode(existingTab); 
     210            s.addRange(r); 
     211            s.deleteFromDocument(); 
     212          } 
     213        } 
     214      } 
     215       
     216      Xinha._stopEvent(ev); 
     217       
     218    } 
     219    break; 
     220     
    189221    case 8: // KEY backspace 
    190222    case 46: // KEY delete 
Note: See TracChangeset for help on using the changeset viewer.