Ticket #300 (closed defect: fixed)
creation of span-tags for selected text when selecting a style does not work with firefox
| Reported by: | Michael Hosse <michael.hosse@…> | Owned by: | gogo |
|---|---|---|---|
| Priority: | high | Milestone: | 2.0 |
| Component: | Plugin_DynamicCSS | Version: | trunk |
| Severity: | normal | Keywords: | |
| Cc: |
Description
If you are using IE you can select some text and assign a style to this selection. This is done by adding a span-Tag. But this does not work with Firefox. If you try to assign a style to some selected text the style will be assigned to the whole paragraph. IMO the problem is the HTMLArea.prototype._activeElement. This method should return null if you select some text, but it always returns the parent Node. I added some code to this method, but i am not sure if this is the best solution:
// For Mozilla we just see if the selection is not collapsed (something is selected) // and that the anchor (start of selection) is an element. This might not be totally // correct, we possibly should do a simlar check to IE? if(! sel.isCollapsed) {
if(sel.anchorNode.childNodes.length > sel.anchorOffset && sel.anchorNode.childNodes[sel.anchorOffset].nodeType == 1) {
return sel.anchorNode.childNodes[sel.anchorOffset];
} else if(sel.anchorNode.nodeType == 1) {
return sel.anchorNode;
} else {
// Check if the whole tag is selected or only a part of it. var range = sel.getRangeAt(0);
if (range.startContainer == range.endContainer && (range.startOffset != 0
range.endOffset != range.startContainer.length)) return null;
else
return sel.anchorNode.parentNode;
}
} return null;
Change History
Note: See TracTickets for help on using tickets.Download in other formats:
