Re: EditChapterPlugin WYSIWYG enhancement

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view

Re: EditChapterPlugin WYSIWYG enhancement

Paul.W Harvey
Apart from changing the JS (from $('#button_save_new').click() to $('#save_new').click()).

This modification does the job... It still seems more kludgy than I'd like. It's running in my test/staging environment, but I will think more about whether to take this over to the live site or not.

Thank you very much for your assistance, it's saved me a lot of time. I am supposed to keep our installation as close to mainstream as possible, which means this gives me a good starting point to perhaps make a patch that could be rolled into the next version of EditChapter. At a minimum I don't want to rely on Timeout events.

Thanks again

- Paul

From: Thomas Zobel [[hidden email]]
Sent: Thursday, 26 March 2009 9:07 PM
To: [hidden email]
Cc: Heiko Ihrig
Subject: Re: [Foswiki-discuss] EditChapterPlugin WYSIWYG enhancement

To be true: This 'solution' is a bit clumsy but it worked in TWiki! I think it is better than nothing.

I changed the edit.chapter.tmpl a bit:

A new save button was added and the old one was set to display:none;

%TMPL:DEF{"button_save_new"}%<input type="button"
class="twikiSubmit" id="save_new" %MAKETEXT{"value='Save' accesskey='s'"}% />%TMPL:END%

%TMPL:DEF{"button_save"}%<input style="display:none;" type="submit" class="twikiSubmit" name="action_save" id="save" %MAKETEXT{"value='Save' accesskey='s'"}% />%TMPL:END%

%TMPL:DEF{"action_buttons"}%%TMPL:P{"button_save_new"}%&nbsp;%TMPL:P{"button_save"}%&nbsp;%TMPL:P{"button_quietsave"}% %MAKETEXT{"or"}% %TMPL:P{"button_cancel"}%%TMPL:END%

A small piece JS (requires JQuery) follows:


        $('#button_save_new').click(function() {
                //Checking if raw or WYSIWYG
                var topicDisplay = $('textarea#topic').css('display');

                if (topicDisplay == 'none') {
                    // If WYSIWYG then switch to raw
                    tinyMCE.execCommand("mceToggleEditor", null, 'mce_editor_0');
                    // The click on the 'original' save button is triggered, 2 sec of waiting is enough to get the content
                    window.setTimeout("$('#save').trigger('click')", '2000');
                } else {
                    window.setTimeout("$('#save').trigger('click')", '10');


Viele Grüße

----- Ursprüngliche Mail -----
Von: "Martin Seibert" <[hidden email]>
An: [hidden email]
CC: "Thomas Zobel" <[hidden email]>
Gesendet: Donnerstag, 26. März 2009 10:25:33 GMT +01:00 Amsterdam/Berlin/Bern/Rom/Stockholm/Wien
Betreff: Re: [Foswiki-discuss] EditChapterPlugin WYSIWYG enhancement

I do not know how, but I know that Thomas Zobel created a solution for
sectional editing with the WYSIWYG-editor.

Thomas: Can you explain, how you did that?

Viele Grüße

Martin Seibert

//SEIBERT/MEDIA GmbH / Rheingau Palais
   Söhnleinstraße 8 / 65201 Wiesbaden
   GF: J.Seibert und M.Seibert / AG Wiesbaden: HRB11502

   T.+49-611-20570-20 / F.+49-611-20570-70
   [hidden email] /

Am 26.03.2009 um 10:07 schrieb Michael Daum:

> Hi Paul,
> On Thursday 26 March 2009, [hidden email] wrote:
>> Among a number of things including looking at migrating to Foswiki,
>> we would really like to enable EditChapter for our users but a
>> requirement is that they should be able to continue using the
>> WYSIWYG editor.
>> As I'm learning TWiki internals and how EditChapter does its thing,
>> any pointers, hints or suggestions on where to start working on
>> this (or whether I should start at all) would be greatly
>> appreciated. I'm hoping the author Michael Daum is reading.
> Bad news: this is not doable that easily. That's because the wysiwyg
> editor is loading
> the editable content using a secondary ajax request from the backend.
> Further more, there is no formal concept of section or chapter in
> general. That's only
> solved as good as possible within EditChapterPlugin but not used by
> any other
> plugins so far.
> During edit the EditChapterPlugin separates the content into three
> parts:
> text before, current and text after the section to be edited and
> fills the edit template
> appropriately. Only the current section is put into an editable
> textarea the other two
> are hidden. Before submit these three  parts are reassembled to
> create the full topic text
> which is then saved the normal way. So far the tech background of
> the EditChapterPlugin.
> So what I would expect is that the wysiwyg editor will hijack the
> textarea containing
> the current section, but then request the full topic text using a
> subsequent ajax call
> and the replaces the content of the  current textarea ... which is
> not what you want.
> You wanted the specific section EditChapterPlugin already loaded
> into the textarea.
> Likewise, save done via the wysiwyg editor will fail as it doesn't
> know anything about
> the other two parts that have been loaded into the template and that
> these need
> to be recombined before saving the topic.
>       Michael.
> --
> -- Michael Daum Consulting
> -- Your Wiki Software Partner
> -- WikiRing Consultant
> --
> -- Tel: +49 (0)40 21 99 27 51
> ------------------------------------------------------------------------------
> _______________________________________________
> Foswiki-discuss mailing list
> [hidden email]


Viele Grüße

Thomas Zobel


//SEIBERT/MEDIA GMBH / Rheingau Palais
  Söhnleinstraße 8 / D-65201 Wiesbaden
  GF: J.Seibert und M.Seibert / AG Wiesbaden: HRB11502

  T.+49-611-20570-14 / F.+49-611-20570-70
  [hidden email] /


Consulting / Technologies / Design

Foswiki-discuss mailing list
[hidden email]

Foswiki-discuss mailing list
[hidden email]
Reply | Threaded
Open this post in threaded view

Re: EditChapterPlugin WYSIWYG enhancement

Crawford Currie
[hidden email] wrote:
> At a minimum I don't want to rely on Timeout events.
Absolutely, and there's no reason you should have to. The timeout is
waiting for the completion of the toggle editor command, which is being
called to force the conversion of the DOM tree that represents the
edited text back to the plain text in the textarea. This can be achieved
much more easily, by directly calling the JS function that handles this
conversion. See the function "switchToRaw" in foswiki_tiny_src.js (and
the "transform" method in the same class)



Crawford Currie
- C-Dot Consultants
- A WikiRing Partner
- landline: +44-1606-330-242
- mobile: +44-7837-877-956
- public key

Foswiki-discuss mailing list
[hidden email]