Support for link target selection
This commit is contained in:
parent
eb87f6e6f7
commit
fff79f97b4
1 changed files with 57 additions and 4 deletions
|
|
@ -372,10 +372,63 @@ function editor_action(button_id) {
|
||||||
if (cmdID.toLowerCase() == 'subscript' && editdoc.queryCommandState('superscript')) { editdoc.execCommand('superscript'); }
|
if (cmdID.toLowerCase() == 'subscript' && editdoc.queryCommandState('superscript')) { editdoc.execCommand('superscript'); }
|
||||||
if (cmdID.toLowerCase() == 'superscript' && editdoc.queryCommandState('subscript')) { editdoc.execCommand('subscript'); }
|
if (cmdID.toLowerCase() == 'superscript' && editdoc.queryCommandState('subscript')) { editdoc.execCommand('subscript'); }
|
||||||
|
|
||||||
// insert link
|
// insert link (modified)
|
||||||
if (cmdID.toLowerCase() == 'createlink'){
|
if (cmdID.toLowerCase() == 'createlink') {
|
||||||
editdoc.execCommand(cmdID,1);
|
if (editdoc.selection.createRange().text != "") {
|
||||||
}
|
var highlightedText = editdoc.selection.createRange().text;
|
||||||
|
}
|
||||||
|
else { var highlightedText = ""; }
|
||||||
|
|
||||||
|
var href_attribute = '';
|
||||||
|
var tar_attribute = '';
|
||||||
|
var linkText = '';
|
||||||
|
|
||||||
|
if (editdoc.selection.createRange().parentElement().outerHTML.search(/^\<[A|a]/) != -1) {
|
||||||
|
|
||||||
|
var fullElement = editdoc.selection.createRange().parentElement().outerHTML;
|
||||||
|
fullElement = fullElement.replace(/\"/g, "");
|
||||||
|
fullElement = fullElement.replace(/\'/g, "");
|
||||||
|
|
||||||
|
// here, we have an <a> tag. Now let's extract...
|
||||||
|
// 1. the href attribute
|
||||||
|
var href_value = fullElement.split(/href=/);
|
||||||
|
href_value2 = href_value[1].split(/\s|>/);
|
||||||
|
href_attribute = href_value2[0];
|
||||||
|
|
||||||
|
// 2. the target attribute
|
||||||
|
if (fullElement.search(/target=/) != -1) {
|
||||||
|
var tar = fullElement.split(/target=/);
|
||||||
|
tar2 = tar[1].split(/\s|>/);
|
||||||
|
tar_attribute = tar2[0];
|
||||||
|
}
|
||||||
|
else { tar_attribute = ''; }
|
||||||
|
|
||||||
|
// 3. the link text
|
||||||
|
var linkText2 = fullElement.split(/>/);
|
||||||
|
var lt = linkText2[1].split(/</);
|
||||||
|
linkText = lt[0];
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
var myValues = new Object();
|
||||||
|
myValues.highlightedText = highlightedText;
|
||||||
|
myValues.tar_attribute = tar_attribute;
|
||||||
|
myValues.href_attribute = href_attribute;
|
||||||
|
myValues.linkText = linkText;
|
||||||
|
|
||||||
|
var myText = showModalDialog(_editor_url + "popups/insert_link.html", myValues, "status=no; scroll=no");
|
||||||
|
|
||||||
|
if (linkText != '') {
|
||||||
|
if (myText) {
|
||||||
|
editdoc.selection.createRange().parentElement().outerHTML = '';
|
||||||
|
editor_insertHTML(objname, unescape( myText) );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (myText) { editor_insertHTML(objname, unescape(myText) ); } // this function ALWAYS puts in an absolute link
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
// insert image
|
// insert image
|
||||||
else if (cmdID.toLowerCase() == 'insertimage'){
|
else if (cmdID.toLowerCase() == 'insertimage'){
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue