fckIsRunning[fckLaunchedJsId] always returns true, whether it's in rich text mode or plain text. Does the code from line 9 to 18 ever run, in fckeditor.utils.js?

My need is, if there is a way to detect if the rich text mode is active or not, for a textarea? fckIsRunning[fckLaunchedJsId] seemed to be what I need but vain, maybe it's a bug; if not, then a feature request.

Also, is there a way to get Instance Name using textarea's ID attribute e.g. edit-body, edit-comment, etc. ? fckIsRunning[fckLaunchedJsId] is good in my case only when there's one instance on FCKeditor on single page.

if (typeof FCKeditorAPI !== 'undefined' && fckIsRunning[fckLaunchedJsId]) {
  FCKeditorAPI.GetInstance(fckLaunchedJsId).InsertHtml(smiley);
}

Integrating FCKeditor with Smileys module :)

Comments

wwalc’s picture

Category: bug » support

fckIsRunning[fckLaunchedJsId] is set to true when FCKeditor is loaded for the first time.
It doesn't matter in what state FCKeditor is later, it's always set to true.
This variable is used only to detect whether ReplaceTextarea() method should be called.

fckLaunchedJsId is an array and it stores all the id's of FCKeditor instances that may be accessed with FCKeditorAPI.GetInstance.
Example (line 88-90):

for( var i = 0 ; i < fckLaunchedJsId.length ; i++ ) {
   if ( document.getElementById( fckLaunchedTextareaId[i] ).style.display == 'none' ) 
      document.getElementById( fckLaunchedTextareaId[i] ).value = FCKeditorAPI.GetInstance( fckLaunchedJsId[i] ).GetXHTML() ; 
}

Determining whether FCKeditor is visible or not and whether it is in WYSIWYG mode or in text mode is a bit more complicated unfortunately.
For example FCKeditor may be in WYSIWYG mode, but still not visible because it is hidden with display:none hack.

The following values may also interest you:
eTextarea.style.display (used in line 30; eTextarea.style.display == '' if FCKeditor is not visible)
oEditor.EditMode (set to FCK_EDITMODE_WYSIWYG if FCKeditor is in WYSIWYG mode)

Add this code at the end of Toggle function, it might help you in understanding how it works:

	if (eTextarea.style.display == 'none' && oEditor.EditMode == FCK_EDITMODE_WYSIWYG ) {
	  alert("FCKeditor is visible and running in WYSIWYG mode");
	}

FCKeditor wiki: http://wiki.fckeditor.net/Developer's_Guide/Javascript_API

Let me know if you have any more questions.

Jorrit’s picture

Status: Active » Postponed (maintainer needs more info)
asxnot’s picture

I had the same problem in integration of Smiley and FCKEditor and finally I chosed the following code for smiley.js:

else if (typeof FCKeditorAPI !== 'undefined' && document.getElementById(fckLaunchedTextareaId[0]).style.display=='none'){
	      // FCKeditor support
	      FCKeditorAPI.GetInstance(fckLaunchedJsId).InsertHtml(smiley);
	      } 

I don't know if it is the best way, but it works :)

wwalc’s picture

Title: fckIsRunning stores disabled editor instances » FCKeditor and Smileys module compatibility
Category: support » feature
Status: Postponed (maintainer needs more info) » Needs work

Marking as a feature request, we have some initial code posted by @asxnot, so perhaps there is a chance to make both modules compatible.

tassoman’s picture

Smiley insertion works only by clicking smileys into [more] box.

Clicking on img.smiley-class has been promoted seems isn't catched by JQ trigger $('img.smiley-class', this).click(function() ...

edit: I've added an alert(); into the function ... And seems that trigger isn't triggered outside more smiley popup

Edit2: Clicks are triggered on document ready. So into the Drupal.smileysAutoAttach function. I've added at line 10 into smileys.js:

Drupal.smileysAutoAttach = function() {
	$('img.smiley-class', this).click(function() {
  	console.log(this);
	});

...and it's logging into firebug. But i dunno wich js code writes into FCK textarea :(

Jorrit’s picture

Component: Code » Compatibility with other modules
Jorrit’s picture

Status: Needs work » Closed (fixed)

Feature requests are no longer considered for this version.