Log in or register to post comments
Last post
joannelee's picture
Joined: 25/08/2006
Posts: 1
How to disable FCKEditor?
<<How to disable FCKEditor?>>
I found two relevant threads (Thanks for the authors):
(1) To turn editing off use "document.frames[0].objContent.DOM.designMode = 'Off'".
To turn it back on use "document.frames[0].objContent.DOM.designMode = 'On'"

(2) var oEditor = FCKeditorAPI.GetInstance('FCKeditor1');
oEditor.EditorDocument.body.disabled=true

I don't know where and how to implement (1) but I can implement (2) successfully. The editor is disabled with greyed out text and freezed scrollbar. However, this "disabled" effect is not what I expect. I want (i)the text remains its original colors, especially the background color is or close to grey, and (ii)the scrollbar is enabled for read-only. Please advise. Thanks a lot!
claudiu_cristea's picture
Joined: 31/08/2006
Posts: 7
RE: How to disable FCKEditor?
Right! I think that it must be a R/W property (named "disabled") of FCKeditor JavaScript API in the next releases. Something like:

oFCKInstance.disabled = true;

This should be an approach to the common form controls (remember that "textarea" have also this R/W property).

Claudiu
claudiu_cristea's picture
Joined: 31/08/2006
Posts: 7
RE: How to disable FCKEditor?
I had also posted a new Feature Request with ID #1549884 with this request.
saul11's picture
Joined: 19/06/2006
Posts: 633
RE: How to disable FCKEditor?
Independant of this thread I have written a toggleFCKeditor function. It disables and re-enables the FCKeditor. When disbaled, the whole toolbar is grayed out and the editorArea will not receive any input. Optionally the toolbar can be hidden or collapsed. In this manner, when re-enabled, the toolbar will show again or be expanded.
Note: When disabled, the editorArea is also grayed out in IE.

So no boolean, but a toggle function.

I have created a new page for things like this: http://fcksnippets.saulmade.nl/ (alias of http://www.saulmade.nl/FCKeditor/FCKSnippets.php)
Here you can read more about the function, see a demo and get your download.
kohila_kvp's picture
Joined: 05/04/2007
Posts: 3
How to disable FCKEditor?
I have used the same code in my asp.net web application

<script type="text/javascript">

function EditorReadOnly()
{

var oEditor = FCKeditorAPI.GetInstance('FCKeditor1');
oEditor.EditorDocument.body.disabled=true ;
}
</script>
<body id="body" onload="EditorReadOnly()">


but it shows the javascript error ( EditorDocument.body is null or not an object).

can plz help how to get the fckeditor with read only ...
( i have used the fckeditor 2.4.1)

Thanks in Advance

Kohi
saul11's picture
Joined: 19/06/2006
Posts: 633
RE: How to disable FCKEditor?
As I wrote on my FCKSnippets page (http://www.saulmade.nl/FCKeditor/FCKSnippets.php):

When you want the FCKeditor to disable onload, use the FCKeditor_OnComplete API method:
function FCKeditor_OnComplete(editorInstance){toggleFCKeditor(editorInstance);}

See the wiki docs for more inforamtion: http://wiki.fckeditor.net/Developer%27s ... b159762430
guvenck's picture
Joined: 25/07/2007
Posts: 8
Re: How to disable FCKEditor?
Hi Saul,

I installed the toggleFCKeditor snippet found on your homepage.

I am using the snippet function like this:

I have two radio buttons.

<p>Install a block:</p>
<input type="radio" name="type" value="0" onClick="toggleBlockType(this.value);">From File&nbsp;
<select name="blockfile" disabled>
<option value="">Select...</option>
<option value="box_blogarchive.php">box_blogarchive.php</option>
<option value="box_news.php">box_news.php</option>
<option value="box_news_scroll.php">box_news_scroll.php</option>
<option value="box_user.php">box_user.php</option>
</select>
<br>   

<input type="radio" name="type" value="1" onClick="toggleBlockType(this.value);" checked>HTML&nbsp;<br>
<div>
<input type="hidden" id="ta1" name="ta1" value="" style="display:none" /><input type="hidden" id="ta1___Config" value="CustomConfigurationsPath=../4kconfig.js" style="display:none" /><iframe id="ta1___Frame" src="editors/fckeditor/editor/fckeditor.html?InstanceName=ta1&amp;Toolbar=Block" width="100%" height="240" frameborder="0" scrolling="no"></iframe>
</div>


and my function:

function toggleBlockType(value) {
   var oEditor = FCKeditorAPI.GetInstance('ta1');
   if(value == 0) {
      document.forms.AddBlock.blockfile.disabled = false;
      toggleFCKeditor(FCKeditorAPI.GetInstance('ta1'));
   }
   if(value == 1) {
      document.forms.AddBlock.blockfile.disabled = true;
      toggleFCKeditor(FCKeditorAPI.GetInstance('ta1'));
   }
}


When the From File radio button is clicked, the FCKeditor should be disabled and when the HTML radio button is clicked, the select element "blockfile" should be disabled.

As long as you click the right buttons in order, it is OK. But when clicked on an already-clicked radio button, it toggles the editor instance and for me the toggle part does not work as expected.

How can I make it work?
shahbazkiani's picture
Joined: 09/04/2009
Posts: 2
Re: How to disable FCKEditor?
this function hide the toolbar and also make contect non-editable.

you can use these lines any where not only in FCKeditor_OnComplete but you need get an instance of editor using javascript API for getting an instance of FCKeditor.

function FCKeditor_OnComplete( editorInstance )
{
// Just hiding the toolbar:
editorInstance.EditorWindow.parent.document.getElementById("xExpanded").style.display = "none";
// And hiding the small bar showing when the toolbar is collapsed is this:
editorInstance.EditorWindow.parent.document.getElementById("xCollapsed").style.display = "none";

// when you want to hide the collapse handle do:
editorInstance.EditorWindow.parent.document.getElementById("xCollapseHandle").style.display = "none";
// or hiding the expand handle. This seems to be the same as hiding the object with id 'xCollapsed' mentioned above:
editorInstance.EditorWindow.parent.document.getElementById("xExpandHandle").style.display = "none";

editorInstance.EditorDocument.body.contentEditable='false';
editorInstance.EditorDocument.designMode='off';
}
shahbazkiani's picture
Joined: 09/04/2009
Posts: 2
Re: How to disable FCKEditor?
Same above procedure is used for making it readonly instead disabled.
andrewmaisey's picture
Joined: 13/05/2009
Posts: 1
Re: How to disable FCKEditor?
Here is a variation for disabling the control and hiding the menu items...

<%@ Register assembly="FredCK.FCKeditorV2" namespace="FredCK.FCKeditorV2" tagprefix="FCKeditorV2" %>

<script type="text/javascript">
{
    // Special FCK Editor disable & control script.
    function FCKeditor_OnComplete(editorInstance) {
        // editorInstance.BasePath = "/UserControls/fckeditor/"; - Note the path is now supplied in the HTML. - alert(editorInstance.Name);
        if ((editorInstance.Name == "ReferralForm_ReferralFormReferral_ViewReferral_FCKEditorManagerNotesItem") || (editorInstance.Name == "ReferralForm_ReferralFormReferral_ViewReferral_FCKEditorNotesItem"))
        {
            // Diable toolbar.
            editorInstance.EditorDocument.body.disabled = true;
            // Diable buttons.
            editorInstance.EditorWindow.parent.FCK.ToolbarSet.Disable();
            editorInstance.EditorWindow.parent.document.getElementById("xExpanded").style.display = "none";
        }
    }
}
</script>


And here is one of the buttons which have IDs above...

<FCKeditorV2:FCKeditor ID="FCKEditorNotesItem" runat="server" BasePath="~/UserControls/fckeditor/" ToolbarSet="MySet" Width="90%" Value='<%# Bind("Notes") %>' ></FCKeditorV2:FCKeditor>


Andrew Maisey