?? fckxhtml.js
字號:
break ;
// Text Node.
case 3 :
if ( htmlNode.parentNode && htmlNode.parentNode.nodeName.IEquals( 'pre' ) )
return this._AppendTextNode( xmlNode, htmlNode.nodeValue ) ;
return this._AppendTextNode( xmlNode, htmlNode.nodeValue.ReplaceNewLineChars(' ') ) ;
// Comment
case 8 :
// IE catches the <!DOTYPE ... > as a comment, but it has no
// innerHTML, so we can catch it, and ignore it.
if ( FCKBrowserInfo.IsIE && !htmlNode.innerHTML )
break ;
try { xmlNode.appendChild( this.XML.createComment( htmlNode.nodeValue ) ) ; }
catch (e) { /* Do nothing... probably this is a wrong format comment. */ }
break ;
// Unknown Node type.
default :
xmlNode.appendChild( this.XML.createComment( "Element not supported - Type: " + htmlNode.nodeType + " Name: " + htmlNode.nodeName ) ) ;
break ;
}
return true ;
}
// Append an item to the SpecialBlocks array and returns the tag to be used.
FCKXHtml._AppendSpecialItem = function( item )
{
return '___FCKsi___' + FCKXHtml.SpecialBlocks.AddItem( item ) ;
}
FCKXHtml._AppendEntity = function( xmlNode, entity )
{
xmlNode.appendChild( this.XML.createTextNode( '#?-:' + entity + ';' ) ) ;
}
FCKXHtml._AppendTextNode = function( targetNode, textValue )
{
var bHadText = textValue.length > 0 ;
if ( bHadText )
targetNode.appendChild( this.XML.createTextNode( textValue.replace( FCKXHtmlEntities.EntitiesRegex, FCKXHtml_GetEntity ) ) ) ;
return bHadText ;
}
// Retrieves a entity (internal format) for a given character.
function FCKXHtml_GetEntity( character )
{
// We cannot simply place the entities in the text, because the XML parser
// will translate & to &. So we use a temporary marker which is replaced
// in the end of the processing.
var sEntity = FCKXHtmlEntities.Entities[ character ] || ( '#' + character.charCodeAt(0) ) ;
return '#?-:' + sEntity + ';' ;
}
// An object that hold tag specific operations.
FCKXHtml.TagProcessors =
{
a : function( node, htmlNode )
{
// Firefox may create empty tags when deleting the selection in some special cases (SF-BUG 1556878).
if ( htmlNode.innerHTML.Trim().length == 0 && !htmlNode.name )
return false ;
var sSavedUrl = htmlNode.getAttribute( '_fcksavedurl' ) ;
if ( sSavedUrl != null )
FCKXHtml._AppendAttribute( node, 'href', sSavedUrl ) ;
// Anchors with content has been marked with an additional class, now we must remove it.
if ( FCKBrowserInfo.IsIE )
{
// Buggy IE, doesn't copy the name of changed anchors.
if ( htmlNode.name )
FCKXHtml._AppendAttribute( node, 'name', htmlNode.name ) ;
}
node = FCKXHtml._AppendChildNodes( node, htmlNode, false ) ;
return node ;
},
area : function( node, htmlNode )
{
var sSavedUrl = htmlNode.getAttribute( '_fcksavedurl' ) ;
if ( sSavedUrl != null )
FCKXHtml._AppendAttribute( node, 'href', sSavedUrl ) ;
// IE ignores the "COORDS" and "SHAPE" attribute so we must add it manually.
if ( FCKBrowserInfo.IsIE )
{
if ( ! node.attributes.getNamedItem( 'coords' ) )
{
var sCoords = htmlNode.getAttribute( 'coords', 2 ) ;
if ( sCoords && sCoords != '0,0,0' )
FCKXHtml._AppendAttribute( node, 'coords', sCoords ) ;
}
if ( ! node.attributes.getNamedItem( 'shape' ) )
{
var sShape = htmlNode.getAttribute( 'shape', 2 ) ;
if ( sShape && sShape.length > 0 )
FCKXHtml._AppendAttribute( node, 'shape', sShape.toLowerCase() ) ;
}
}
return node ;
},
body : function( node, htmlNode )
{
node = FCKXHtml._AppendChildNodes( node, htmlNode, false ) ;
// Remove spellchecker attributes added for Firefox when converting to HTML code (Bug #1351).
node.removeAttribute( 'spellcheck' ) ;
return node ;
},
// IE loses contents of iframes, and Gecko does give it back HtmlEncoded
// Note: Opera does lose the content and doesn't provide it in the innerHTML string
iframe : function( node, htmlNode )
{
var sHtml = htmlNode.innerHTML ;
// Gecko does give back the encoded html
if ( FCKBrowserInfo.IsGecko )
sHtml = FCKTools.HTMLDecode( sHtml );
// Remove the saved urls here as the data won't be processed as nodes
sHtml = sHtml.replace( /\s_fcksavedurl="[^"]*"/g, '' ) ;
node.appendChild( FCKXHtml.XML.createTextNode( FCKXHtml._AppendSpecialItem( sHtml ) ) ) ;
return node ;
},
img : function( node, htmlNode )
{
// The "ALT" attribute is required in XHTML.
if ( ! node.attributes.getNamedItem( 'alt' ) )
FCKXHtml._AppendAttribute( node, 'alt', '' ) ;
var sSavedUrl = htmlNode.getAttribute( '_fcksavedurl' ) ;
if ( sSavedUrl != null )
FCKXHtml._AppendAttribute( node, 'src', sSavedUrl ) ;
// Bug #768 : If the width and height are defined inline CSS,
// don't define it again in the HTML attributes.
if ( htmlNode.style.width )
node.removeAttribute( 'width' ) ;
if ( htmlNode.style.height )
node.removeAttribute( 'height' ) ;
return node ;
},
// Fix orphaned <li> nodes (Bug #503).
li : function( node, htmlNode, targetNode )
{
// If the XML parent node is already a <ul> or <ol>, then add the <li> as usual.
if ( targetNode.nodeName.IEquals( ['ul', 'ol'] ) )
return FCKXHtml._AppendChildNodes( node, htmlNode, true ) ;
var newTarget = FCKXHtml.XML.createElement( 'ul' ) ;
// Reset the _fckxhtmljob so the HTML node is processed again.
htmlNode._fckxhtmljob = null ;
// Loop through all sibling LIs, adding them to the <ul>.
do
{
FCKXHtml._AppendNode( newTarget, htmlNode ) ;
// Look for the next element following this <li>.
do
{
htmlNode = FCKDomTools.GetNextSibling( htmlNode ) ;
} while ( htmlNode && htmlNode.nodeType == 3 && htmlNode.nodeValue.Trim().length == 0 )
} while ( htmlNode && htmlNode.nodeName.toLowerCase() == 'li' )
return newTarget ;
},
// Fix nested <ul> and <ol>.
ol : function( node, htmlNode, targetNode )
{
if ( htmlNode.innerHTML.Trim().length == 0 )
return false ;
var ePSibling = targetNode.lastChild ;
if ( ePSibling && ePSibling.nodeType == 3 )
ePSibling = ePSibling.previousSibling ;
if ( ePSibling && ePSibling.nodeName.toUpperCase() == 'LI' )
{
htmlNode._fckxhtmljob = null ;
FCKXHtml._AppendNode( ePSibling, htmlNode ) ;
return false ;
}
node = FCKXHtml._AppendChildNodes( node, htmlNode ) ;
return node ;
},
pre : function ( node, htmlNode )
{
var firstChild = htmlNode.firstChild ;
if ( firstChild && firstChild.nodeType == 3 )
node.appendChild( FCKXHtml.XML.createTextNode( FCKXHtml._AppendSpecialItem( '\r\n' ) ) ) ;
FCKXHtml._AppendChildNodes( node, htmlNode, true ) ;
return node ;
},
script : function( node, htmlNode )
{
// The "TYPE" attribute is required in XHTML.
if ( ! node.attributes.getNamedItem( 'type' ) )
FCKXHtml._AppendAttribute( node, 'type', 'text/javascript' ) ;
node.appendChild( FCKXHtml.XML.createTextNode( FCKXHtml._AppendSpecialItem( htmlNode.text ) ) ) ;
return node ;
},
span : function( node, htmlNode )
{
// Firefox may create empty tags when deleting the selection in some special cases (SF-BUG 1084404).
if ( htmlNode.innerHTML.length == 0 )
return false ;
node = FCKXHtml._AppendChildNodes( node, htmlNode, false ) ;
return node ;
},
style : function( node, htmlNode )
{
// The "TYPE" attribute is required in XHTML.
if ( ! node.attributes.getNamedItem( 'type' ) )
FCKXHtml._AppendAttribute( node, 'type', 'text/css' ) ;
var cssText = htmlNode.innerHTML ;
if ( FCKBrowserInfo.IsIE ) // Bug #403 : IE always appends a \r\n to the beginning of StyleNode.innerHTML
cssText = cssText.replace( /^(\r\n|\n|\r)/, '' ) ;
node.appendChild( FCKXHtml.XML.createTextNode( FCKXHtml._AppendSpecialItem( cssText ) ) ) ;
return node ;
},
title : function( node, htmlNode )
{
node.appendChild( FCKXHtml.XML.createTextNode( FCK.EditorDocument.title ) ) ;
return node ;
}
} ;
FCKXHtml.TagProcessors.ul = FCKXHtml.TagProcessors.ol ;
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -