#2589: changing style when typing text works incorrectly
----------------------+-----------------------------------------------------
Reporter: Dina | Owner:
Type: Bug | Status: new
Priority: Normal | Milestone:
Component: General | Version: FCKeditor 2.5 Beta
Resolution: | Keywords: Confirmed
----------------------+-----------------------------------------------------
Comment(by Dina):
FYI. For myself I did some crude fixes. In my case I only have paragraph
and span css styles and bold/itaic and I want span styles not merged but
separated so for me works the following code (ff, ie):
_ApplyInlineStyle : function( range, selectIt, updateRange )
{
var doc = range.Window.document ;
if ( range.CheckIsCollapsed() )
{
// Create the element to be inserted in the DOM.
var collapsedElement = this.BuildElement( doc ) ;
///// by Irina D
//In case we are going to insert a span
//find out if the range is inside of another span and move it
outside if yes. We switch off possible
//bold/italic in this case but it is not so bad as inner spans
for me
if (range.StartContainer.parentNode) {
if (collapsedElement.tagName == "SPAN") {
//range.StartContainer.nodeName - points to #text node
in ff and to its parent element in ie
var parentEl;
if (range.StartContainer.nodeType == 3) { //text node
//probably mozilla
parentEl = range.StartContainer.parentNode;
} else {
//probably ie
parentEl = range.StartContainer;
}
if (parentEl.tagName != "P" && parentEl.tagName !=
"BODY") {
//probably we are inside of span
//alert(range.CheckEndOfBlock());
if (range.CheckEndOfBlock()) {
//cursor is not inside of text but we are just
typing in the end of line
for (;;) {
//we can be inside of bold/italic and that
can be inside of span
//so find that possible parent span.
if (!parentEl) break;
if (parentEl.tagName == "P" ||
parentEl.tagName == "SPAN"
|| parentEl.tagName == "BODY")
break;
parentEl = parentEl.parentNode;
}
if (parentEl) if (parentEl.tagName == "SPAN")
{
//if we found out that we are inside of
span and that new element is span too
//then we should start our new span
outside previous one
range.SetStart(parentEl, 4);
}
}
}
}
}
///// end by Irina D
range.InsertNode( collapsedElement ) ;
range.MoveToPosition( collapsedElement, 2 ) ;
range.Select() ;
return ;
}
--
Ticket URL: <http://dev.fckeditor.net/ticket/2589#comment:4>
FCKeditor <http://www.fckeditor.net/>
The text editor for Internet
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
FCKeditor-Trac mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/fckeditor-trac