How to use editor in plugins?

Discussions and requests related to new CMSimple features, plugins, templates etc. and how to develop.
Please don't ask for support at this forums!

Re: How to use editor in plugins?

Postby Holger » Fri Jan 06, 2012 1:01 pm

Hi folks,

the problem at the end seems to be the different ways how to include the different editors. For me it's much easier with (F)CK than with Tiny...

But that:
Code: Select all

    function editor_test_2
()
    {
           $html = '<form>
            <textarea id="my_teaser" name="my_teaser" class="my_teaser_class">Guten Tag!</textarea>
            <textarea id="my_content" name="my_content" class="my_content_class">I need a fullblown editor</textarea>
         </form>'
;

        init_editor(array('my_teaser_class'), 'minimal');
        init_editor(array('my_content_class'), 'full');
      
      return $html
;
    }  
 
is exactly what I meant (of course with full paths to config-files).

And that's why I thought that editor_replace() is complete useless, because everything is (or can be) done with a config(.js) - with CK.

The only thing is that CK needs IDs and Tiny needs classes. But if the plugin provides both, it should not be a problem.

But I have to think about how to provide a useful function editor_replace() for CK. At the end it'll be the same as init_editor()...

KR
Holger
Holger
Site Admin
 
Posts: 2582
Joined: Mon May 19, 2008 7:10 pm
Location: Hessen, Germany

Re: How to use editor in plugins?

Postby Holger » Fri Jan 06, 2012 1:05 pm

BTW: is it ok to use 1.5.1 for development, or are there some planned changes / bugfixes available?
(I can't find some new code on SF ;) ).

Holger
Holger
Site Admin
 
Posts: 2582
Joined: Mon May 19, 2008 7:10 pm
Location: Hessen, Germany

Re: How to use editor in plugins?

Postby cmb » Fri Jan 06, 2012 1:18 pm

Hi Martin, hi Holger,

Martin wrote:That's a good idea!

Shall we add it to the roadmap?

Holger wrote:The only thing is that CK needs IDs and Tiny needs classes.

No! To allow differently configured editor instances on the same page, even tinyMCE needs IDs. And Whizzywig too, BTW. But as I've written, it's not hard to map that either way.

Holger wrote:But I have to think about how to provide a useful function editor_replace() for CK. At the end it'll be the same as init_editor()...

Have a look as it's currently implemented for tinyMCE. tinymce_replace() doesn't do anything besides passing the $config to the instantiation of the editor. init_tinymce() does a lot more (reading the config file, calling tinymce_filebrowser() and replacing the %PLACEHOLDER%s).

Holger wrote:BTW: is it ok to use 1.5.1 for development, or are there some planned changes / bugfixes available?

There were some changes (minor improvements) suggested (see the Roadmap), but not finally discussed or decided upon.

The most important changes would be changes to the editor interface IMO, as they have to be made, before it's reasonable to procede with the editor integration or updating plugins that need an editor.

Christoph
Christoph M. Becker---Plugins for CMSimple_XH
cmb
 
Posts: 5484
Joined: Tue Jun 21, 2011 11:04 am
Location: Germany

Re: How to use editor in plugins?

Postby Martin » Fri Jan 06, 2012 1:57 pm

Hallo Holger,

tinymce_replace($elementID, $config = '') inserts a small javascript snippet. This snippet will convert the textarea (or div) with the given id to an editor. The second parameter can be used to configure it the way you need it. If you do not use $config, a most basic instance of TinyMCE editor will be produced. (Not even the "init_minimal.js", just a TinyMCE out of the box). The only thing the plugin author really has to care about is to insert this snippet to the output after the targeted textarea/div has been written.

CKEditor offers the same possibility. Just have a look at http://nightly.ckeditor.com/7350/_samples/replacebycode.html

Martin
Martin
 
Posts: 741
Joined: Thu Oct 23, 2008 11:57 am

Re: How to use editor in plugins?

Postby Holger » Fri Jan 06, 2012 3:08 pm

Hi Christoph & Martin

@Christoph: ok, I got it now...

@Martin:
I know about CKEDITOR.replace( 'textarea_id' ); - but I can't imagine when this blank editor might be useful.
And when I give some some minimal configuration (basePath etc.) to function editor_replace(), there might be only a small difference to init_editor().

Anyway, I'll stop to discuss that at this point and use the time to build some compatible code for CK now ;) .
About FCK: IMO it's a waste of time. My quick&dirty installation is running and that might be enough.

KR
Holger
Holger
Site Admin
 
Posts: 2582
Joined: Mon May 19, 2008 7:10 pm
Location: Hessen, Germany

Re: How to use editor in plugins?

Postby cmb » Fri Jan 06, 2012 3:25 pm

Hello Holger,

it was not my intention to suppress the discussion about improving the editor interface. But if we discuss that, a decision should be made quickly.

Holger wrote:there might be only a small difference to init_editor().

Yes, you're right. But it doesn't hurt to implement the EDITOR_replace(), and perhaps some plugin authors prefer to use it this way.

Christoph
Christoph M. Becker---Plugins for CMSimple_XH
cmb
 
Posts: 5484
Joined: Tue Jun 21, 2011 11:04 am
Location: Germany

Re: How to use editor in plugins?

Postby Holger » Fri Jan 06, 2012 5:53 pm

Hi Christoph,

no problem. I wont suppress that discussion too. I meant what I wrote: I have now understand why things were made this way.
So IMO it's the best now to finish a barebone of a CKeditor - plugin with all the same functions like tinymce.
I'll drop FCK, because that is not really possible with the old one (from my knowledge).

So if my barebone is available, we can discuss if there are things to change at the interface.

Ok?

Holger
Holger
Site Admin
 
Posts: 2582
Joined: Mon May 19, 2008 7:10 pm
Location: Hessen, Germany

Re: How to use editor in plugins?

Postby cmb » Fri Jan 06, 2012 6:02 pm

Hi Holger,

Holger wrote:So if my barebone is available, we can discuss if there are things to change at the interface.

Ok?

Yes -- that might be the best thing to do. IMO the two most important editors are tinyMCE and CKeditor, and so the interface should mainly be useful for this editors. Other editor integrators will probably manage to find a way to conform to the specification somehow.

So I'm looking forward to the CKeditor barebone.

Christoph
Christoph M. Becker---Plugins for CMSimple_XH
cmb
 
Posts: 5484
Joined: Tue Jun 21, 2011 11:04 am
Location: Germany

Re: How to use editor in plugins?

Postby svasti » Fri Jan 06, 2012 8:05 pm

Hi folks,
today I tried to put tiny into calendar and half way succeeded and now going to the forum and I see the big discussion here. Difficult to follow.

Fckeditor works calendar and has got textfields with IDs, but having 50 events with lots of text the page build up is slooow. So I made the user click a buttom to activate the editor in specific text areas. With Tiny + classes there is no problem with page build up.

However the configuration init_calendar.js is now in the plugin/editor/inits folder as I haven't understood how to call the editor with config, css etc. in the calendar folder.
svasti
svasti
 
Posts: 687
Joined: Wed Dec 17, 2008 5:08 pm
Location: Bielefeld, Germany

Re: How to use editor in plugins?

Postby Holger » Fri Jan 06, 2012 10:13 pm

Hi Frank,

svasti wrote:Fckeditor works calendar and has got textfields with IDs
Don't waste time for FCK at the moment.
If you really want to build a calendar version for the older XH, we can look for a solution later. It's possible to create editors on the fly with FCK too.
But now we should first concentrate on the interface with new editors.

svasti wrote:So I made the user click a buttom to activate the editor in specific text areas. With Tiny + classes there is no problem with page build up.
Good to hear! Than it should work with CK too - hope so ;) .

KR
Holger
Holger
Site Admin
 
Posts: 2582
Joined: Mon May 19, 2008 7:10 pm
Location: Hessen, Germany

PreviousNext

Return to Open Development

Who is online

Users browsing this forum: No registered users and 0 guests