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 | /*
|
---|
23 | if ( FCKConfig.UseBROnCarriageReturn )
|
---|
24 | {
|
---|
25 | // Named commands to be handled by this browsers specific implementation.
|
---|
26 | FCK.RedirectNamedCommands =
|
---|
27 | {
|
---|
28 | InsertOrderedList : true,
|
---|
29 | InsertUnorderedList : true
|
---|
30 | }
|
---|
31 |
|
---|
32 | FCK.ExecuteRedirectedNamedCommand = function( commandName, commandParameter )
|
---|
33 | {
|
---|
34 | if ( commandName == 'InsertOrderedList' || commandName == 'InsertUnorderedList' )
|
---|
35 | {
|
---|
36 | if ( !(FCK.EditorDocument.queryCommandState( 'InsertOrderedList' ) || FCK.EditorDocument.queryCommandState( 'InsertUnorderedList' )) )
|
---|
37 | {
|
---|
38 | }
|
---|
39 | }
|
---|
40 |
|
---|
41 | FCK.ExecuteNamedCommand( commandName, commandParameter ) ;
|
---|
42 | }
|
---|
43 | }
|
---|
44 | */
|
---|
45 |
|
---|
46 | FCK.Paste = function()
|
---|
47 | {
|
---|
48 | if ( FCKConfig.ForcePasteAsPlainText )
|
---|
49 | {
|
---|
50 | FCK.PasteAsPlainText() ;
|
---|
51 | return ;
|
---|
52 | }
|
---|
53 |
|
---|
54 | var sHTML = FCK.GetClipboardHTML() ;
|
---|
55 |
|
---|
56 | if ( FCKConfig.AutoDetectPasteFromWord )
|
---|
57 | {
|
---|
58 | var re = /<\w[^>]*(( class="?MsoNormal"?)|(="mso-))/gi ;
|
---|
59 | if ( re.test( sHTML ) )
|
---|
60 | {
|
---|
61 | if ( confirm( FCKLang["PasteWordConfirm"] ) )
|
---|
62 | {
|
---|
63 | FCK.PasteFromWord() ;
|
---|
64 | return ;
|
---|
65 | }
|
---|
66 | }
|
---|
67 | }
|
---|
68 |
|
---|
69 | FCK.InsertHtml( sHTML ) ;
|
---|
70 | }
|
---|
71 |
|
---|
72 | FCK.PasteAsPlainText = function()
|
---|
73 | {
|
---|
74 | // Get the data available in the clipboard and encodes it in HTML.
|
---|
75 | var sText = FCKTools.HTMLEncode( clipboardData.getData("Text") ) ;
|
---|
76 |
|
---|
77 | // Replace the carriage returns with <BR>
|
---|
78 | sText = sText.replace( /\n/g, '<BR>' ) ;
|
---|
79 |
|
---|
80 | // Insert the resulting data in the editor.
|
---|
81 | this.InsertHtml( sText ) ;
|
---|
82 | }
|
---|
83 | /*
|
---|
84 | FCK.PasteFromWord = function()
|
---|
85 | {
|
---|
86 | FCK.CleanAndPaste( FCK.GetClipboardHTML() ) ;
|
---|
87 | }
|
---|
88 | */
|
---|
89 | FCK.InsertElement = function( element )
|
---|
90 | {
|
---|
91 | FCK.InsertHtml( element.outerHTML ) ;
|
---|
92 | }
|
---|
93 |
|
---|
94 | FCK.GetClipboardHTML = function()
|
---|
95 | {
|
---|
96 | var oDiv = document.getElementById( '___FCKHiddenDiv' ) ;
|
---|
97 |
|
---|
98 | if ( !oDiv )
|
---|
99 | {
|
---|
100 | var oDiv = document.createElement( 'DIV' ) ;
|
---|
101 | oDiv.id = '___FCKHiddenDiv' ;
|
---|
102 | oDiv.style.visibility = 'hidden' ;
|
---|
103 | oDiv.style.overflow = 'hidden' ;
|
---|
104 | oDiv.style.position = 'absolute' ;
|
---|
105 | oDiv.style.width = 1 ;
|
---|
106 | oDiv.style.height = 1 ;
|
---|
107 |
|
---|
108 | document.body.appendChild( oDiv ) ;
|
---|
109 | }
|
---|
110 |
|
---|
111 | oDiv.innerHTML = '' ;
|
---|
112 |
|
---|
113 | var oTextRange = document.body.createTextRange() ;
|
---|
114 | oTextRange.moveToElementText( oDiv ) ;
|
---|
115 | oTextRange.execCommand( 'Paste' ) ;
|
---|
116 |
|
---|
117 | var sData = oDiv.innerHTML ;
|
---|
118 | oDiv.innerHTML = '' ;
|
---|
119 |
|
---|
120 | return sData ;
|
---|
121 | }
|
---|
122 |
|
---|
123 | FCK.AttachToOnSelectionChange = function( functionPointer )
|
---|
124 | {
|
---|
125 | this.Events.AttachEvent( 'OnSelectionChange', functionPointer ) ;
|
---|
126 | }
|
---|
127 |
|
---|
128 | /*
|
---|
129 | FCK.AttachToOnSelectionChange = function( functionPointer )
|
---|
130 | {
|
---|
131 | FCK.EditorDocument.attachEvent( 'onselectionchange', functionPointer ) ;
|
---|
132 | }
|
---|
133 | */
|
---|
134 |
|
---|
135 | FCK.CreateLink = function( url )
|
---|
136 | {
|
---|
137 | // Remove any existing link in the selection.
|
---|
138 | FCK.ExecuteNamedCommand( 'Unlink' ) ;
|
---|
139 |
|
---|
140 | if ( url.length > 0 )
|
---|
141 | {
|
---|
142 | // Generate a temporary name for the link.
|
---|
143 | var sTempUrl = 'javascript:void(0);/*' + ( new Date().getTime() ) + '*/' ;
|
---|
144 |
|
---|
145 | // Use the internal "CreateLink" command to create the link.
|
---|
146 | FCK.ExecuteNamedCommand( 'CreateLink', sTempUrl ) ;
|
---|
147 |
|
---|
148 | // Look for the just create link.
|
---|
149 | var oLinks = this.EditorDocument.links ;
|
---|
150 |
|
---|
151 | for ( i = 0 ; i < oLinks.length ; i++ )
|
---|
152 | {
|
---|
153 | var oLink = oLinks[i] ;
|
---|
154 |
|
---|
155 | if ( oLink.href == sTempUrl )
|
---|
156 | {
|
---|
157 | var sInnerHtml = oLink.innerHTML ; // Save the innerHTML (IE changes it if it is like an URL).
|
---|
158 | oLink.href = url ;
|
---|
159 | oLink.innerHTML = sInnerHtml ; // Restore the innerHTML.
|
---|
160 | return oLink ;
|
---|
161 | }
|
---|
162 | }
|
---|
163 | }
|
---|
164 | }
|
---|