Project

General

Profile

Bug #23837 » rtehtmlarea_bugfix_16124_trunk.patch

Administrator Admin, 2010-11-25 04:30

View differences:

typo3/sysext/rtehtmlarea/htmlarea/plugins/TYPO3Link/typo3link.js (copie de travail)
this.editor.focus();
this.restoreSelection();
var node = this.editor.getParentElement();
var el = HTMLArea.getElementObject(node, "a");
if (el != null && /^a$/i.test(el.nodeName)) node = el;
if (node != null && /^a$/i.test(node.nodeName)) this.editor.selectNode(node);
// Clean images from existing anchors otherwise Mozilla may create nested anchors
if (HTMLArea.classesAnchorSetup) {
var el = HTMLArea.getElementObject(node, 'a');
if (el != null && /^a$/i.test(el.nodeName)) {
node = el;
}
if (HTMLArea.classesAnchorSetup && cur_class) {
for (var i = HTMLArea.classesAnchorSetup.length; --i >= 0;) {
anchorClass = HTMLArea.classesAnchorSetup[i];
if (anchorClass.name == cur_class && anchorClass.image) {
imageNode = this.editor.document.createElement('img');
imageNode.src = anchorClass.image;
imageNode.alt = anchorClass.altText;
addIconAfterLink = anchorClass.addIconAfterLink;
break;
}
}
}
if (node != null && /^a$/i.test(node.nodeName)) {
// Update existing link
this.editor.selectNode(node);
selection = this.editor._getSelection();
range = this.editor._createRange(selection);
this.cleanAllLinks(node, range, true);
}
// In FF, if the url is the same except for upper/lower case of a file name, the link is not updated.
// Therefore, we remove the link before creating a new one.
if (!Ext.isIE && node != null && /^a$/i.test(node.nodeName)) {
// If the class attribute is not removed, UnLink folowed by CreateLink will create a span element inside the new link
node.removeAttribute("class");
// Moreover, the selection is sometimes lost after the unlink operation
// Clean images
if (HTMLArea.classesAnchorSetup) {
this.cleanAllLinks(node, range, true);
}
// Update link href
node.href = Ext.isGecko ? encodeURI(theLink) : theLink;
// Update link attributes
this.setLinkAttributes(node, range, cur_target, cur_class, cur_title, imageNode, addIconAfterLink, additionalValues);
} else {
// Create new link
// Clean existing anchors otherwise Mozilla may create nested anchors
selection = this.editor._getSelection();
range = this.editor._createRange(selection);
// Selection may be lost when cleaning links
var bookmark = this.editor.getBookmark(range);
this.editor._doc.execCommand("UnLink", false, null);
this.cleanAllLinks(node, range);
this.editor.selectRange(this.editor.moveToBookmark(bookmark));
}
if (Ext.isGecko) {
this.editor._doc.execCommand("CreateLink", false, encodeURI(theLink));
} else {
this.editor._doc.execCommand("CreateLink", false, theLink);
}
selection = this.editor._getSelection();
range = this.editor._createRange(selection);
node = this.editor.getParentElement();
el = HTMLArea.getElementObject(node, "a");
if (el != null && /^a$/i.test(el.nodeName)) node = el;
if (node) {
// Export trailing br that IE may include in the link
if (Ext.isIE) {
if (node.lastChild && /^br$/i.test(node.lastChild.nodeName)) {
HTMLArea.removeFromParent(node.lastChild);
node.parentNode.insertBefore(this.editor.document.createElement('br'), node.nextSibling);
}
if (Ext.isGecko) {
this.editor.document.execCommand('CreateLink', false, encodeURI(theLink));
} else {
this.editor.document.execCommand('CreateLink', false, theLink);
}
if (HTMLArea.classesAnchorSetup && cur_class) {
for (var i = HTMLArea.classesAnchorSetup.length; --i >= 0;) {
anchorClass = HTMLArea.classesAnchorSetup[i];
if (anchorClass.name == cur_class && anchorClass.image) {
imageNode = this.editor._doc.createElement("img");
imageNode.src = anchorClass.image;
imageNode.alt = anchorClass.altText;
addIconAfterLink = anchorClass.addIconAfterLink;
break;
// Get the created link
selection = this.editor._getSelection();
range = this.editor._createRange(selection);
node = this.editor.getParentElement();
el = HTMLArea.getElementObject(node, 'a');
if (el != null && /^a$/i.test(el.nodeName)) {
node = el;
}
if (node) {
// Export trailing br that IE may include in the link
if (Ext.isIE) {
if (node.lastChild && /^br$/i.test(node.lastChild.nodeName)) {
HTMLArea.removeFromParent(node.lastChild);
node.parentNode.insertBefore(this.editor.document.createElement('br'), node.nextSibling);
}
}
// We may have created multiple links in as many blocks
this.setLinkAttributes(node, range, cur_target, cur_class, cur_title, imageNode, addIconAfterLink, additionalValues);
}
// We may have created multiple links in as many blocks
this.setLinkAttributes(node, range, cur_target, cur_class, cur_title, imageNode, addIconAfterLink, additionalValues);
}
this.close();
},
(2-2/2)