Opened 14 years ago

Closed 13 years ago

#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 (3)

comment:1 Changed 14 years ago by gogo

  • Milestone set to Version 1.0

comment:2 Changed 14 years ago by Sam

  • Component changed from Plugin - Stylist to Plugin_DynamicCSS
  • Milestone changed from Version 1.0 to 2.0
  • Priority changed from normal to high

The proposition from Michael Hosse doesn't work (when using pageStyle classes).
Moreover, this problem arises with IE 6.0 as badly as with FF.

comment:3 Changed 13 years ago by gogo

  • Resolution set to fixed
  • Status changed from new to closed

I think this is corrected by a change yesterday (attributed to another ticket).

Note: See TracTickets for help on using tickets.