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!
svasti
Posts: 1660
Joined: Wed Dec 17, 2008 5:08 pm

Re: How to use editor in plugins?

Post by svasti » Sat Feb 04, 2012 5:53 pm

Hello experts,

ckeditor is finally working in calendar, but one problem remains: when I save, this notice comes:
Diese Seite bittet Sie zu bestätigen, dass Sie die Seite verlassen möchten – Daten, die Sie eingegeben haben, werden unter Umständen nicht gespeichert.
Although this is a good notice in other places, here it is completely out of place. How can I get rid of it?????

Strange thing is, this problem doesn't occur with tinymce.

svasti

cmb
Posts: 14225
Joined: Tue Jun 21, 2011 11:04 am
Location: Bingen, RLP, DE
Contact:

Re: How to use editor in plugins?

Post by cmb » Sat Feb 04, 2012 6:01 pm

Hi Frank,
svasti wrote:when I save, this notice comes:
That's fixed with the CMSimpleSave plugin, that Holger had coded. Did you specify it as one of the extraPlugins in the config? And you must not use the save button -- instead use CMSimpleSave.

Christoph
Christoph M. Becker – Plugins for CMSimple_XH

svasti
Posts: 1660
Joined: Wed Dec 17, 2008 5:08 pm

Re: How to use editor in plugins?

Post by svasti » Sat Feb 04, 2012 6:37 pm

Hi Christoph,

sorry this time your advice doesn't seem to work... may be you can have a look for yourself: http://frankziesing.de/cmsimple/downloa ... .php?id=18
Unfortunately the way I did it, CKEditor can only be used when it is the standard editor. May be not so good? But why would anybody want CKEditor in Calendar otherwise?
I fixed many small bugs, now Calendar validates and soft hyphens (\-) also work Hope to release a stable version soon.
svasti

edit: Ok I got it working now. Took me some time to understand your advice.
Last edited by svasti on Mon Feb 06, 2012 9:00 am, edited 1 time in total.

cmb
Posts: 14225
Joined: Tue Jun 21, 2011 11:04 am
Location: Bingen, RLP, DE
Contact:

Re: How to use editor in plugins?

Post by cmb » Sat Feb 04, 2012 6:52 pm

Hi Holger,

I've somehow overlooked you're latest post in this thread. :oops:
Holger wrote:At the moment (XH 1.5.1) TinyMCE is usable in the frontend. The filebrowser is disabled but the internal-link list is usable.
That's quite inconsitent, and should be changed IMO.
Holger wrote:editor_replace() gives us one (1) full configured and working editor and does not write to hjs / onload etc.
I want to suggest again, that editor_replace() should return only the JS without any surrounding <script>. This way it's possible for the plugin author to delay the actual instantiation. And I want to suggest explicitely to use array('xh-editor') as default value of $element_classes for init_editor() instead of array().

I've made the appropriate changes to my suggestion above.

Christoph
Christoph M. Becker – Plugins for CMSimple_XH

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

Re: How to use editor in plugins?

Post by Holger » Mon Feb 06, 2012 12:12 am

Hi Christoph,
cmb wrote: I want to suggest again, that editor_replace() should return only the JS without any surrounding <script>.
Hmm, seems I've overseen that... ;)
But that should not be a problem to change that for CKEditor with the next release.
cmb wrote:And I want to suggest explicitely to use array('xh-editor') as default value of $element_classes for init_editor() instead of array().
I've used that code for CKEditor:

Code: Select all

function init_ckeditor($classes = array(), $config = false) {
    ...
    ...
    $initClasses = 'xh-editor';
    if (is_array($classes) && (bool) $classes) {
        $initClasses = implode('|', $classes);
    }
 
$classes is assigned to $initClasses, which is 'xh-editor' by default. Maybe that way it's bit wired, but is it not the same at the end :? ?

KR
Holger

cmb
Posts: 14225
Joined: Tue Jun 21, 2011 11:04 am
Location: Bingen, RLP, DE
Contact:

Re: How to use editor in plugins?

Post by cmb » Mon Feb 06, 2012 12:35 am

Hi Holger,
Holger wrote:
cmb wrote: I want to suggest again, that editor_replace() should return only the JS without any surrounding <script>.
Hmm, seems I've overseen that... ;)
But that should not be a problem to change that for CKEditor with the next release.
It's just a suggestion. But if everybody agrees (although silently ;)), I guess we should change it this way.
Holger wrote:but is it not the same at the end
Yes, it's the same in the end. But I would prefer to have it in the function's declaration. This way it's clear , what is the default. If we change this now, it's only a small problem, as this could be changed in CMSimple_XH's core accordingly. Only the incompatibility of XH 1.5.1 and newer editors will remain, but this could be solved easily by updating to XH 1.5.2 (an update package will be available). If we postpone the change, the incompatibilities might be harder to resolve.

But this is not really important. It's just, that we have to agree on a standard.

Christoph
Christoph M. Becker – Plugins for CMSimple_XH

Tata
Posts: 3588
Joined: Tue May 20, 2008 5:34 am
Location: Slovakia
Contact:

Re: How to use editor in plugins?

Post by Tata » Mon Feb 06, 2012 7:29 am

Hi, all!
Could you show me at this placea practical way how to call TinyMCE in Wellrad Plugin? In it's version 1.2, there is the tinymce.js available, but there are no hints how to activate it in the prpoduct-details section.
THX in advance.
CMSimple.sk
It's no shame to ask for an answer if all efforts failed.
But it's awful to ask without any effort to find the answer yourself.

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

Re: How to use editor in plugins?

Post by Martin » Mon Feb 06, 2012 10:20 am

Hallo Tata,

o, sorry! The editor call of the shop is not yet changed to the new interface. I'll have a look at it tomorrow and change the download next weekend.

But you can probably change it yourself: Have a look at plugins/wellrad/WRS_CMSBridge.php. There you will find the function initProductDescriptionEditor(). As a quick and dirty solution: just changing the paths to the editor js-file should probably work. But using the new interace is the cleaner - and perhaps even easier - way.

KR

Martin

Tata
Posts: 3588
Joined: Tue May 20, 2008 5:34 am
Location: Slovakia
Contact:

Re: How to use editor in plugins?

Post by Tata » Mon Feb 06, 2012 10:46 am

Super!!! The dirties use to work. This works fine:
Lines:

Code: Select all

            if(!key_exists('tinymce', $cf) ||$cf['tinymce']['folder'] == '') {
                $cf['tinymce']['folder']='tiny_mce';
            }
            if(is_dir($pth['folder']['base'].$cf['tinymce']['folder'])){
                $description_editor = "TinyMCE";
                $hjs .= '<script language="javascript" type="text/javascript" src="'.$pth['folder']['base'].$cf['tinymce']['folder'].'/tiny_mce.js"></script>
changed to:

Code: Select all

    if($cf['editor']['external']=="tinymce")
        {
            if(!key_exists('tinymce', $cf) ||$cf['tinymce']['folder'] == '') {
                $cf['tinymce']['folder']='plugins/tinymce';
            }
            if(is_dir($pth['folder']['base'].$cf['tinymce']['folder'])){
                $description_editor = "TinyMCE";
                $hjs .= '<script language="javascript" type="text/javascript" src="'.$pth['folder']['base'].$cf['tinymce']['folder'].'/tiny_mce/tiny_mce.js"></script>
CMSimple.sk
It's no shame to ask for an answer if all efforts failed.
But it's awful to ask without any effort to find the answer yourself.

Post Reply