fck_2_ie.js
上传用户:li2971742
上传日期:2021-11-18
资源大小:39096k
文件大小:4k
源码类别:

OA系统

开发平台:

C#

  1. /*
  2.  * FCKeditor - The text editor for internet
  3.  * Copyright (C) 2003-2006 Frederico Caldeira Knabben
  4.  * 
  5.  * Licensed under the terms of the GNU Lesser General Public License:
  6.  *  http://www.opensource.org/licenses/lgpl-license.php
  7.  * 
  8.  * For further information visit:
  9.  *  http://www.fckeditor.net/
  10.  * 
  11.  * "Support Open Source software. What about a donation today?"
  12.  * 
  13.  * File Name: fck_2_ie.js
  14.  *  This is the second part of the "FCK" object creation. This is the main
  15.  *  object that represents an editor instance.
  16.  *  (IE specific implementations)
  17.  * 
  18.  * File Authors:
  19.  *  Frederico Caldeira Knabben (fredck@fckeditor.net)
  20.  */
  21. /*
  22. if ( FCKConfig.UseBROnCarriageReturn ) 
  23. {
  24. // Named commands to be handled by this browsers specific implementation.
  25. FCK.RedirectNamedCommands = 
  26. {
  27. InsertOrderedList : true,
  28. InsertUnorderedList : true
  29. }
  30. FCK.ExecuteRedirectedNamedCommand = function( commandName, commandParameter )
  31. {
  32. if ( commandName == 'InsertOrderedList' || commandName == 'InsertUnorderedList' )
  33. {
  34. if ( !(FCK.EditorDocument.queryCommandState( 'InsertOrderedList' ) || FCK.EditorDocument.queryCommandState( 'InsertUnorderedList' )) )
  35. {
  36. }
  37. }
  38. FCK.ExecuteNamedCommand( commandName, commandParameter ) ;
  39. }
  40. }
  41. */
  42. FCK.Paste = function()
  43. {
  44. if ( FCKConfig.ForcePasteAsPlainText )
  45. {
  46. FCK.PasteAsPlainText() ;
  47. return ;
  48. }
  49. var sHTML = FCK.GetClipboardHTML() ;
  50. if ( FCKConfig.AutoDetectPasteFromWord )
  51. {
  52. var re = /<w[^>]*(( class="?MsoNormal"?)|(="mso-))/gi ;
  53. if ( re.test( sHTML ) )
  54. {
  55. if ( confirm( FCKLang["PasteWordConfirm"] ) )
  56. {
  57. FCK.PasteFromWord() ;
  58. return ;
  59. }
  60. }
  61. }
  62. FCK.InsertHtml( sHTML ) ;
  63. }
  64. FCK.PasteAsPlainText = function()
  65. {
  66. // Get the data available in the clipboard and encodes it in HTML.
  67. var sText = FCKTools.HTMLEncode( clipboardData.getData("Text") ) ;
  68. // Replace the carriage returns with <BR>
  69. sText = sText.replace( /n/g, '<BR>' ) ;
  70. // Insert the resulting data in the editor.
  71. this.InsertHtml( sText ) ;
  72. }
  73. /*
  74. FCK.PasteFromWord = function()
  75. {
  76. FCK.CleanAndPaste( FCK.GetClipboardHTML() ) ;
  77. }
  78. */
  79. FCK.InsertElement = function( element )
  80. {
  81. FCK.InsertHtml( element.outerHTML ) ;
  82. }
  83. FCK.GetClipboardHTML = function()
  84. {
  85. var oDiv = document.getElementById( '___FCKHiddenDiv' ) ;
  86. if ( !oDiv )
  87. {
  88. var oDiv = document.createElement( 'DIV' ) ;
  89. oDiv.id = '___FCKHiddenDiv' ;
  90. oDiv.style.visibility = 'hidden' ;
  91. oDiv.style.overflow = 'hidden' ;
  92. oDiv.style.position = 'absolute' ;
  93. oDiv.style.width = 1 ;
  94. oDiv.style.height = 1 ;
  95. document.body.appendChild( oDiv ) ;
  96. }
  97. oDiv.innerHTML = '' ;
  98. var oTextRange = document.body.createTextRange() ;
  99. oTextRange.moveToElementText( oDiv ) ;
  100. oTextRange.execCommand( 'Paste' ) ;
  101. var sData = oDiv.innerHTML ;
  102. oDiv.innerHTML = '' ;
  103. return sData ;
  104. }
  105. FCK.AttachToOnSelectionChange = function( functionPointer )
  106. {
  107. this.Events.AttachEvent( 'OnSelectionChange', functionPointer ) ;
  108. }
  109. /*
  110. FCK.AttachToOnSelectionChange = function( functionPointer )
  111. {
  112. FCK.EditorDocument.attachEvent( 'onselectionchange', functionPointer ) ;
  113. }
  114. */
  115. FCK.CreateLink = function( url )
  116. {
  117. // Remove any existing link in the selection.
  118. FCK.ExecuteNamedCommand( 'Unlink' ) ;
  119. if ( url.length > 0 )
  120. {
  121. // Generate a temporary name for the link.
  122. var sTempUrl = 'javascript:void(0);/*' + ( new Date().getTime() ) + '*/' ;
  123. // Use the internal "CreateLink" command to create the link.
  124. FCK.ExecuteNamedCommand( 'CreateLink', sTempUrl ) ;
  125. // Look for the just create link.
  126. var oLinks = this.EditorDocument.links ;
  127. for ( i = 0 ; i < oLinks.length ; i++ )
  128. {
  129. var oLink = oLinks[i] ;
  130. if ( oLink.href == sTempUrl )
  131. {
  132. var sInnerHtml = oLink.innerHTML ; // Save the innerHTML (IE changes it if it is like an URL).
  133. oLink.href = url ;
  134. oLink.innerHTML = sInnerHtml ; // Restore the innerHTML.
  135. return oLink ;
  136. }
  137. }
  138. }
  139. }