Project

General

Profile

Feature #17813 » rtehtmlarea_feature_6769_2.patch

Administrator Admin, 2007-11-20 23:51

View differences:

typo3/sysext/rtehtmlarea/htmlarea/htmlarea-gecko.js (working copy)
};
/*
* Empty the selection object
*/
HTMLArea.prototype.emptySelection = function(sel) {
if (HTMLArea.is_safari) {
sel.empty();
} else {
sel.removeAllRanges();
}
};
/*
* Add a range to the selection
*/
HTMLArea.prototype.addRangeToSelection = function(sel, range) {
if (HTMLArea.is_safari) {
sel.setBaseAndExtent(range.startContainer, range.startOffset, range.endContainer, range.endOffset);
} else {
sel.addRange(range);
}
};
/*
* Create a range for the current selection
*/
HTMLArea.prototype._createRange = function(sel) {
......
if (node.nodeType == 1 && node.tagName.toLowerCase() == "body") range.selectNodeContents(node);
else range.selectNode(node);
if ((typeof(pos) != "undefined")) range.collapse(pos);
if (HTMLArea.is_safari) {
sel.empty();
sel.setBaseAndExtent(range.startContainer,range.startOffset,range.endContainer,range.endOffset);
} else {
sel.removeAllRanges();
sel.addRange(range);
}
this.emptySelection(sel);
this.addRangeToSelection(sel, range);
};
/*
......
var range = this._doc.createRange();
range.selectNodeContents(node);
if ((typeof(pos) != "undefined")) range.collapse(pos);
if (HTMLArea.is_safari) {
sel.empty();
sel.setBaseAndExtent(range.startContainer,range.startOffset,range.endContainer,range.endOffset);
} else {
sel.removeAllRanges();
sel.addRange(range);
}
this.emptySelection(sel);
this.addRangeToSelection(sel, range);
};
/*
......
if (typeof(range) === "undefined") {
var range = this._createRange(sel);
}
try {
var p = range.commonAncestorContainer;
if (!range.collapsed && range.startContainer == range.endContainer &&
range.startOffset - range.endOffset <= 1 && range.startContainer.hasChildNodes()) {
p = range.startContainer.childNodes[range.startOffset];
}
while (p.nodeType == 3) {
p = p.parentNode;
}
return p;
} catch (e) {
return this._doc.body;
var p = range.commonAncestorContainer;
while (p.nodeType == 3) {
p = p.parentNode;
}
return p;
};
/*
......
node = range.startContainer,
pos = range.startOffset,
selnode = toBeInserted;
if (HTMLArea.is_safari) sel.empty();
else sel.removeAllRanges();
this.emptySelection(sel);
range.deleteContents();
switch (node.nodeType) {
case 3: // Node.TEXT_NODE: we have to split it at the caret position.
......
range = this._createRange();
range.setEnd(node, pos + toBeInserted.length);
range.setStart(node, pos + toBeInserted.length);
if (HTMLArea.is_safari) sel.setBaseAndExtent(range.startContainer, range.startOffset, range.endContainer, range.endOffset);
else sel.addRange(range);
this.addRangeToSelection(sel, range);
} else {
node = node.splitText(pos);
if (toBeInserted.nodeType == 11) selnode = selnode.lastChild;
......
var editor = target.editor;
target.blur();
editor.selectNode(target.el);
editor._statusBarTree.selected = target.el;
editor.updateToolbar(true);
switch (ev.type) {
case "click" :
......
r.setStartBefore(newr);
r.setEndAfter(newr);
r.extractContents();
if(HTMLArea.is_safari) {
sel.empty();
sel.setBaseAndExtent(r.startContainer,r.startOffset,r.endContainer,r.endOffset);
} else {
sel.removeAllRanges();
sel.addRange(r);
}
this.emptySelection(sel);
this.addRangeToSelection(sel, r);
return true;
}
},10);
......
/*
* Enter event handler
*/
HTMLArea.prototype._checkInsertP = function(ev) {
HTMLArea.prototype._checkInsertP = function() {
var editor = this;
this.focusEditor();
var i, left, right, rangeClone,
......
break;
}
}
if (!range.collapsed) range.deleteContents();
if (HTMLArea.is_safari) sel.empty();
else sel.removeAllRanges();
if (!range.collapsed) {
range.deleteContents();
}
this.emptySelection(sel);
if (!block || /^(td|div)$/i.test(block.tagName)) {
if (!block) var block = doc.body;
if (/\S/.test(HTMLArea.getInnerText(block))) {
......
left.appendChild(doc.createElement('br'));
}
left.normalize();
range.setStartAfter(left);
range.setEndAfter(block.lastChild);
range.surroundContents(right = doc.createElement('p'));
// Working around Safari issue: The following gives a range exception
// range.surroundContents(right = doc.createElement('p'));
right = doc.createElement('p');
right.appendChild(range.extractContents());
block.appendChild(right);
// Remove any element created empty
a = right.previousSibling;
if (a && !/\S/.test(HTMLArea.getInnerText(a))) HTMLArea.removeFromParent(a);
......
} else {
range = doc.createRange();
var first = block.firstChild;
block.removeChild(first);
if (first) block.removeChild(first);
block.appendChild(right = doc.createElement('p'));
right.appendChild(first);
if (first) right.appendChild(first);
}
range.selectNodeContents(right);
} else {
......
}
}
range.collapse(true);
if (HTMLArea.is_safari) sel.setBaseAndExtent(r.startContainer,r.startOffset,r.endContainer,r.endOffset);
else sel.addRange(range);
this.emptySelection(sel);
this.addRangeToSelection(sel, range);
this.scrollToCaret();
return true;
};
/*
typo3/sysext/rtehtmlarea/htmlarea/htmlarea.js (working copy)
sel = this._getSelection();
var r = this._createRange(sel).cloneRange();
r.collapse(false);
if(HTMLArea.is_safari) {
sel.empty();
sel.setBaseAndExtent(r.startContainer,r.startOffset,r.endContainer,r.endOffset);
} else {
sel.removeAllRanges();
sel.addRange(r);
}
this.emptySelection(sel);
this.addRangeToSelection(sel, r);
}
}
break;
......
while (owner.parentElement) { owner = owner.parentElement; }
}
var editor = RTEarea[owner._editorNo]["editor"];
var keyEvent = ((HTMLArea.is_ie || HTMLArea.is_safari) && ev.type == "keydown") || (!HTMLArea.is_ie && ev.type == "keypress");
var keyEvent = (HTMLArea.is_ie && ev.type == "keydown") || (HTMLArea.is_gecko && ev.type == "keypress");
editor.focusEditor();
if(keyEvent) {
......
switch (ev.keyCode) {
case 13 : // KEY enter
if (HTMLArea.is_gecko && !ev.shiftKey && !editor.config.disableEnterParagraphs) {
if (editor._checkInsertP(ev)) HTMLArea._stopEvent(ev);
editor._checkInsertP();
HTMLArea._stopEvent(ev);
// update the toolbar state after some time
if (editor._timerToolbar) window.clearTimeout(editor._timerToolbar);
editor._timerToolbar = window.setTimeout("HTMLArea.updateToolbar(" + editor._editorNumber + ");", 50);
return false;
}
break;
case 8 : // KEY backspace
typo3/sysext/rtehtmlarea/pi2/class.tx_rtehtmlarea_pi2.php (working copy)
// Preloading the pageStyle
$filename = trim($this->thisConfig['contentCSS']) ? trim($this->thisConfig['contentCSS']) : 'EXT:' . $this->ID . '/htmlarea/plugins/DynamicCSS/dynamiccss.css';
$additionalCode_loadCSS = '
<link rel="alternate stylesheet" type="text/css" href="' . $this->getFullFileName($filename) . '" />';
<link rel="alternate stylesheet" type="text/css" href="' . $this->getFullFileName($filename) . '" title="HTMLArea RTE Content CSS" />';
// Loading the editor skin
$skinFilename = trim($this->thisConfig['skin']) ? trim($this->thisConfig['skin']) : 'EXT:' . $this->ID . '/htmlarea/skins/default/htmlarea.css';
(2-2/2)