Index: typo3/sysext/rtehtmlarea/htmlarea/plugins/CopyPaste/copy-paste.js
===================================================================
--- typo3/sysext/rtehtmlarea/htmlarea/plugins/CopyPaste/copy-paste.js (révision 6285)
+++ typo3/sysext/rtehtmlarea/htmlarea/plugins/CopyPaste/copy-paste.js (copie de travail)
@@ -117,6 +117,10 @@
if (buttonId == id) {
// If we are handling a button, not a hotkey
this.applyBrowserCommand(buttonId);
+ } else if (buttonId == "Cut") {
+ // If we are handling the cut hotkey
+ var removeEmpyLinkLaterFunctRef = this.makeFunctionReference("removeEmptyLinkLater");
+ window.setTimeout(removeEmpyLinkLaterFunctRef, 50);
}
break;
case "Paste":
@@ -151,9 +155,49 @@
this.mozillaClipboardAccessException();
}
}
+ if (buttonId == "Cut") {
+ this.removeEmptyLink();
+ }
},
/*
+ * This function removes any link left over by the cut operation
+ */
+ removeEmptyLink : function() {
+ var selection = this.editor._getSelection();
+ var range = this.editor._createRange(selection);
+ var parent = this.editor.getParentElement(selection, range);
+ if (parent.firstChild && /^(a)$/i.test(parent.firstChild.nodeName)) {
+ parent = parent.firstChild;
+ }
+ if (/^(a)$/i.test(parent.nodeName)) {
+ parent.normalize();
+ if (!parent.innerHTML || (parent.childNodes.length == 1 && /^(br)$/i.test(parent.firstChild.nodeName))) {
+ HTMLArea.removeFromParent(parent);
+ }
+ }
+ // Safari may leave font and span elements behind!
+ if (HTMLArea.is_safari) {
+ var selection = this.editor._getSelection();
+ var range = this.editor._createRange(selection);
+ var parent = this.editor.getParentElement(selection, range);
+ while (/^(font|span)$/i.test(parent.nodeName) && HTMLArea._hasClass(parent, "Apple-style-span")) {
+ var container = parent.parentNode;
+ HTMLArea.removeFromParent(parent);
+ parent = container;
+ }
+ }
+ },
+
+ /*
+ * This function removes any link left over by the cut operation triggered by hotkey
+ */
+ removeEmptyLinkLater : function() {
+ this.removeEmptyLink();
+ this.editor.updateToolbar();
+ },
+
+ /*
* This function gets called by the main editor when a copy/cut/paste operation is to be performed
*/
applyToTable : function (buttonId, target) {