Skip to content
This repository has been archived by the owner on Nov 9, 2017. It is now read-only.

Commit

Permalink
Allow editting of hyperlinks. Hat tip to @CuriousAnimal
Browse files Browse the repository at this point in the history
  • Loading branch information
cheeaun committed Mar 1, 2010
1 parent a8744e8 commit 7ad9e62
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions Source/MooEditable/MooEditable.js
Expand Up @@ -1422,11 +1422,21 @@ MooEditable.Actions = new Hash({
}
},
command: function(){
if (this.selection.isCollapsed()){
this.dialogs.createlink.alert.open();
var selection = this.selection;
var dialogs = this.dialogs.createlink;
if (selection.isCollapsed()){
var node = selection.getNode();
if (node.get('tag') == 'a' && node.get('href')){
selection.selectNode(node);
var prompt = dialogs.prompt;
prompt.el.getElement('.dialog-input').set('value', node.get('href'));
prompt.open();
} else {
dialogs.alert.open();
}
} else {
var text = this.selection.getText();
var prompt = this.dialogs.createlink.prompt;
var text = selection.getText();
var prompt = dialogs.prompt;
if (urlRegex.test(text)) prompt.el.getElement('.dialog-input').set('value', text);
prompt.open();
}
Expand Down

1 comment on commit 7ad9e62

@nickolasgregory
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nicely done! Thanks.

Please sign in to comment.