Changeset 1271


Ignore:
Timestamp:
11/15/10 16:15:48 (4 years ago)
Author:
ejucovy
Message:

Fix editor._createLink confusion, closes ticket:1553

  • editor.execCommand("createlink") is now the standard way to trigger a link-creation action
  • under the hood, this calls an editor._createLink method
  • core itself doesn't define editor._createLink -- instead, modules/CreateLink or plugins/Linker defines that method
  • double-clicking on an existing link to edit that link now works

It is also possible to trigger a link-edit action independent of the cursor position/selection.
The way to do this is editor.execCommand("createlink", false, anchorEl)

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/XinhaCore.js

    r1270 r1271  
    11551155 
    11561156    inserthorizontalrule: [ "Horizontal Rule", ["ed_buttons_main.png",6,0], false, function(e) { e.execCommand("inserthorizontalrule"); } ], 
    1157     createlink: [ "Insert Web Link", ["ed_buttons_main.png",6,1], false, function(e) { e._createLink(); } ], 
     1157    createlink: [ "Insert Web Link", ["ed_buttons_main.png",6,1], false, function(e) { e.execCommand("createlink"); } ], 
    11581158    insertimage: [ "Insert/Modify Image", ["ed_buttons_main.png",6,3], false, function(e) { e.execCommand("insertimage"); } ], 
    11591159    inserttable: [ "Insert Table", ["ed_buttons_main.png",6,2], false, function(e) { e.execCommand("inserttable"); } ], 
     
    11841184  this.dblclickList =  
    11851185  { 
    1186     "a": [function(e, target) {e._createLink(target);}], 
     1186      "a": [function(e, target) {e.execCommand("createlink", false, target);}], 
    11871187    "img": [function(e, target) {e._insertImage(target);}] 
    11881188  }; 
  • trunk/modules/CreateLink/link.js

    r1084 r1271  
    2929        var self = this; 
    3030 
    31    editor.config.btnList.createlink[3] = function() { self.show(self._getSelectedAnchor()); } 
     31        if(typeof editor._createLink == 'undefined') { 
     32            editor._createLink = function(target) { 
     33                if(!target) target = self._getSelectedAnchor(); 
     34                self.show(target); 
     35            } 
     36        } 
    3237} 
    3338 
  • trunk/plugins/DoubleClick/DoubleClick.js

    r1067 r1271  
    3838  this.editor.dblClickList = { 
    3939    // Edit Link dialog 
    40     a: [ function(e) {e.config.btnList['createlink'][3](e); } ], 
     40    a: [ function(e, target) {e.execCommand("createlink", false, target);} ], 
    4141    // Follow link 
    4242    //a: [ function(editor, target) { window.location = target.href; properties(target); } ], 
  • trunk/plugins/Linker/Linker.js

    r1192 r1271  
    3232 
    3333  var linker = this; 
    34   if(editor.config.btnList.createlink) 
    35   { 
    36     editor.config.btnList.createlink[3] 
    37       =  function(e, objname, obj) { linker._createLink(linker._getSelectedAnchor()); }; 
     34  if(typeof editor._createLink == 'undefined') { 
     35      editor._createLink = function(target) { 
     36          if(!target) target = linker._getSelectedAnchor(); 
     37          linker._createLink(target); 
     38      } 
    3839  } 
    39   else 
     40  if(!editor.config.btnList.createlink) 
    4041  { 
    4142    editor.config.registerButton( 
    4243                                 'createlink', 'Insert/Modify Hyperlink', [_editor_url + "images/ed_buttons_main.gif",6,1], false, 
    43                                  function(e, objname, obj) { linker._createLink(linker._getSelectedAnchor()); } 
     44                                 function(e, objname, obj) { editor.execCommand("createlink"); } 
    4445                                 ); 
    4546  } 
Note: See TracChangeset for help on using the changeset viewer.