Hi, a make some progress with subj. but i have very small experience with coding for FCKeditor. I need some examples for 'fake image' insert and remove in to FCKeditor text area...

Now i have this (working) plugin for FCKeditor, but this insert only invisible <--break--> and <--pagebreak--> tags... Plugin need install (unpack) into modules/fckeditor/fckeditor/editor/plugins.

(file fckplugin.js)

// Define the command.

var FCKDrupal = function( name )
{
  this.Name = name ;
  this.EditMode = FCK.EditMode;
}

FCKDrupal.prototype.Execute = function()
{
  switch ( this.Name )
  {
    case 'Break' :
      var oBreak = FCK.InsertHtml('<!--break-->') ;
      break;
    case 'PageBreak' :
      var oPageBreak = FCK.InsertHtml('<!--pagebreak-->') ;
      break;
    default :
  }
}

FCKDrupal.prototype.GetState = function()
{
  return FCK_TRISTATE_OFF ;
}

// Register the Drupal tag commands.
FCKCommands.RegisterCommand( 'DrupalBreak', new FCKDrupal( 'Break' ) ) ;
FCKCommands.RegisterCommand( 'DrupalPageBreak', new FCKDrupal( 'PageBreak' ) ) ;

// Create the Drupal tag buttons.
var oDrupalItem = new FCKToolbarButton( 'DrupalBreak', 'Break', null, FCK_TOOLBARITEM_ICONTEXT, true, true ) ;
oDrupalItem.IconPath = FCKConfig.PluginsPath + 'drupalbreak/drupalbreak.gif';
FCKToolbarItems.RegisterItem( 'DrupalBreak', oDrupalItem ) ;

var oDrupalItem = new FCKToolbarButton( 'DrupalPageBreak', 'PageBreak', null, FCK_TOOLBARITEM_ICONTEXT, true, true ) ;
oDrupalItem.IconPath = FCKConfig.PluginsPath + 'drupalbreak/drupalbreak.gif';
FCKToolbarItems.RegisterItem( 'DrupalPageBreak', oDrupalItem ) ;

Into modules/fckeditor/fckeditor.config.js needed (on the begining for me):

FCKConfig.Plugins.Add( 'drupalbreak' ) ;

and somewhere into toolbarset definition (for example):

FCKConfig.ToolbarSets["DrupalFull"] = [
	['Source','DrupalBreak','DrupalPageBreak'],
...
CommentFileSizeAuthor
#2 drupalbreak_1.zip1.48 KBhavran
drupalbreak_0.zip1.45 KBhavran

Comments

ontwerpwerk’s picture

I love this plugin, it's a lot better than the one I tried in http://drupal.org/node/16137 ..

but I'm not really sure how I should handle it, is there a way to have those plugins live outside of the default FCKeditor plugins directory? that would make installation easier.

havran’s picture

StatusFileSize
new1.48 KB

Hmm, plugins path is configurable.

I have created directory modules/fckeditor/plugins
Move drupalbreak plugin (directory) from modules/fckeditor/fckeditor/editor/plugins in to modules/fckeditor/plugins
And set

FCKConfig.PluginsPath = '../../plugins/' ;
FCKConfig.Plugins.Add( 'drupalbreak' ) ;

In file modules/fckeditor/fckedito.config.js

(PS: I attach version with new icons...)

ontwerpwerk’s picture

Status: Active » Needs review

will existing plugins still work, or do you have to copy them to your new plugins directory too?

ontwerpwerk’s picture

By the way, I like the multiple pages icon :)

but I remember that that also requires an extra filter module http://drupal.org/project/paging .. please include that information in the readme.

havran’s picture

I make some progress, but...

// Define the command.
var FCKDrupal = function( name )
{
  this.Name = name ;
  this.EditMode = FCK.EditMode;
}

FCKDrupal.prototype.Execute = function()
{
  switch ( this.Name )
  {
    case 'Break' :
     	var e = FCK.InsertHtml('<!--break-->') ;
     	var oFakeImage = FCKDocumentProcessor_CreateFakeImage( 'FCK__PageBreak', e );
	    oFakeImage = FCK.InsertElement( oFakeImage ) ;
      break;
    /*
    case 'PageBreak' :
      var oPageBreak = FCK.InsertHtml('<!--pagebreak-->') ;
    	var oFakeImage = FCKDocumentProcessor_CreateFakeImage( 'FCK__PageBreak', e ) ;
	    oFakeImage = FCK.InsertElement( oFakeImage ) ;
      break; // */
    default :
  }
}

FCKDrupal.prototype.GetState = function()
{
  return FCK_TRISTATE_OFF ;
}

// Register the Drupal tag commands.
FCKCommands.RegisterCommand( 'DrupalBreak', new FCKDrupal( 'Break' ) ) ;
// Create the Drupal tag buttons.
var oDrupalItem = new FCKToolbarButton( 'DrupalBreak', 'Break', null, FCK_TOOLBARITEM_ICONTEXT, true, true ) ;
oDrupalItem.IconPath = FCKConfig.PluginsPath + 'drupalbreak/drupalbreak.gif';
FCKToolbarItems.RegisterItem( 'DrupalBreak', oDrupalItem ) ;

/*
// Register the Drupal tag commands.
FCKCommands.RegisterCommand( 'DrupalPageBreak', new FCKDrupal( 'PageBreak' ) ) ;
// Create the Drupal tag buttons.
var oDrupalItem = new FCKToolbarButton( 'DrupalPageBreak', 'PageBreak', null, FCK_TOOLBARITEM_ICONTEXT, true, true ) ;
oDrupalItem.IconPath = FCKConfig.PluginsPath + 'drupalbreak/drupalpagebreak.gif';
FCKToolbarItems.RegisterItem( 'DrupalPageBreak', oDrupalItem ) ;
// */


// after switch in to source mode and back proccess page and insert fake
// image for break again
// Drupal Page Breaks Processor
var FCKDrupalPageBreaksProcessor = FCKDocumentProcessor.AppendNew() ;
FCKDrupalPageBreaksProcessor.ProcessDocument = function( document )
{
  // get all elements in FCK document
	var elements = document.getElementsByTagName( '*' ) ;

  // check every element for childNodes
  var i = 0;
  while (element = elements[i++]) {
    var nodes = element.childNodes;

    var j = 0;
    while (node = nodes[j++]) {
  		if (node.nodeName == '#comment') {
        // alert(node.nodeType + ' ' + node.nodeName + ' ' + node.nodeValue);
        if (node.nodeValue == 'break') { // <- ??? nodeValue is for every switch to source mode changed and is value is something like {PS..2}, maybe internal name for FCKeditor?  
    			var oFakeImage = FCKDocumentProcessor_CreateFakeImage( 'FCK__PageBreak', node.cloneNode(true) ) ;
      		node.parentNode.insertBefore( oFakeImage, node ) ;
      		node.parentNode.removeChild( node ) ;
        }
      }
    }
  }
} // */

I need check nodeValue == 'break' but (i think) FCKeditor replace nodeValue with his internal value (or something like that)...

Btw. i have 'stole' some original code from FCKeditor :)

ontwerpwerk’s picture

Status: Needs review » Needs work

This is helpful info for making plugins in second location than the default pluginspath
http://wiki.fckeditor.net/Developer%27s_Guide/Customization/Plug-ins

ontwerpwerk’s picture

Assigned: havran » ontwerpwerk
Status: Needs work » Active

I'll include a teaser button in the next version.

ray007’s picture

Subscribing

igdrasil’s picture

this code work this FCKEditor internal value:

FCKDrupalPageBreaksProcessor.ProcessDocument = function( document )
{
  // get all elements in FCK document
var elements = document.getElementsByTagName( '*' ) ;

  // check every element for childNodes
  var i = 0;
  while (element = elements[i++]) {
    var nodes = element.childNodes;

    var j = 0;
    while (node = nodes[j++]) {
  if (node.nodeName == '#comment') {
        // alert(node.nodeType + ' ' + node.nodeName + ' ' + node.nodeValue);
	var PContent;
	if (node.nodeValue.match('PS..')) 
	  PContent = FCKTempBin.Elements[parseInt(node.nodeValue.substring(5,node.nodeValue.length - 1))];
        if (node.nodeValue == 'break' || PContent == '<!--break-->') { 
    var oFakeImage = FCKDocumentProcessor_CreateFakeImage( 'FCK__PageBreak', node.cloneNode(true) ) ;
      node.parentNode.insertBefore( oFakeImage, node ) ;
      node.parentNode.removeChild( node ) ;
        }
      }
    }
  }
}
ontwerpwerk’s picture

that looks promising... but where does it fit in?

igdrasil’s picture

This is only a small fix to the previous code fragment

lias’s picture

I've just experienced the fckeditor teaser problem but I'm not sure how to implement this plugin. Will this be rolled into a future version of fckeditor or as an addition? In the meantime, which part of the code should I use and how should it be installed?
Thanks for the clarification.
Lsabug

ontwerpwerk’s picture

there is some experimental code in the current 5x dev release, but that really needs more testing, check the source if you are interested.

tangent’s picture

The pagebreak button should not be included in this plugin. That would only be useful if the related drupal module is available and that's not a commonly used module. The related button should be in another plugin for that specific module.

tangent’s picture

The break button should ensure that the

comment is never placed inside an html element. Allowing it to be placed inside a paragraph element, for example, will result in broken output in the teaser.

wwalc’s picture

Assigned: ontwerpwerk » wwalc
Status: Active » Fixed

Plugins for <!--break--> and <!--pagebreak--> tags have been rewritten. As of fckeditor 5.x-2.x, we have now two separate plugins for that tags.
Also, from now on, break tags should automatically move outside HTML elements.
Let me know if you have any problems with using it.

emackn’s picture

where are these plugins you speak of? :)

In the latest dev release of FCKEditor, http://drupal.org/node/16118/release

wwalc’s picture

In fckeditor-5.x-2.x-dev.tar.gz package, plugins are placed inside fckeditor/plugins directory.

In fckeditor.config.js uncomment three lines to enable those two plugins:
[code]
//FCKConfig.PluginsPath = '../../plugins/' ;
//FCKConfig.Plugins.Add( 'drupalbreak' ) ;
//FCKConfig.Plugins.Add( 'drupalpagebreak' ) ;
[/code]
and remember to add 'DrupalBreak' and 'DrupalPageBreak' buttons to the toolbar

Note that the first line (FCKConfig.PluginsPath = '../../plugins/') sets the plugins path outside the default (fckeditor/fckeditor/editor/plugins) directory.

This is intended to avoid problems with FCKeditor upgrades (for example someone may delete FCKeditor directory, then upload newer version of FCKeditor and this way accidentically delete drupalbreak plugins)

So since 5.x-2.x, plugins path may (and should) be set to '../../plugins/' (which means "modules/fckeditor/plugins").

ayshe’s picture

--deleted--

Anonymous’s picture

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.

emanhossny’s picture

Category: feature » bug
Status: Closed (fixed) » Active

Hello All,
actually, want to use this plugin, so i downloaded it & put it in the plugins folder of FCKeditor,
& i added to the fckcnfig.js an item in the default toolbar,
currently,i can see the break button in the toolbar of FCKeditor, but when i click on this button, it told me "Unknown command name "teaserbreak"",
can anyone help me in solving this problem?

wwalc’s picture

Status: Active » Fixed

This issue is about creating teasebreak plugins, please create new support request or bug report.
You have probably put the plugins into the wrong folder. The easiest way is to simply follow the README.txt. There is no need to move plugins at all, simply download the latest versions of FCKeditor module and FCKeditor and follow the instructions:

1. Open /drupal5/modules/fckeditor/fckeditor.config.js and uncomment these three lines:

FCKConfig.PluginsPath = '../../plugins/' ;
FCKConfig.Plugins.Add( 'drupalbreak' ) ;
FCKConfig.Plugins.Add( 'drupalpagebreak' ) ;

2. The second step is to add buttons to the toolbar (in the same file).
The button names are: DrupalBreak, DrupalPageBreak.
For example if you have a toolbar with an array of buttons defined as follows:

['Image','Flash','Table','Rule','SpecialChar']

simply add those two buttons at the end of array:

['Image','Flash','Table','Rule','SpecialChar', 'DrupalBreak', 'DrupalPageBreak']

Note that there is nothing about moving plugins.

Anonymous’s picture

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.