[pmwiki-users] Pre-alpha rich text WYSIWTF editor

Eemeli Aro eemeli at gmail.com
Wed Mar 30 08:45:38 CDT 2011


On 30 March 2011 15:41, Petko Yotov <5ko at 5ko.fr> wrote:
> It is so hard to edit without a recent JavaScript-enabled browser, that I
> contemplate writing a JavaScript wiki2html2wiki parser that would read and
> save the wikitext. That's technically complex and will not be a perfect clone
> of the PHP version. And in this case You Don't Always Get Exactly What You
> See.

In case you're interested, I once played around with a live HTML
preview for PmWiki action=edit. This was about two years ago, and I
never followed through with it, but a few minor fixes got the code to
mostly work again.

My approach was to reveal the MarkupRules table using a special
action, so you could add <script
src='{$PageUrl}?action=js-markuprules'> to the edit form. Note that
rules with the /e flag set aren't included and some other filtering is
done as well. Then I've re-implemented the necessary Markup* PHP
functions in javascript (included as a static .js file), so that I can
add onkeyup and onmouseup event handlers to the text edit box that
call the Javascript MarkupToHTML() function which updates the contents
of the #preview div with the generated HTML.

Right now, I can't remember why I gave up on this, probably lack of time again.

In any case, the two necessary files I've now uploaded to
<http://www.pmwiki.org/pmwiki/uploads/Cookbook/js-preview.php> and
<http://www.pmwiki.org/pmwiki/uploads/Cookbook/edit-markup.js.txt>.
You'll need to rename the latter and adjust its hardcoded location in
js-preview.php to whatever you're using, and then just include_once()
the PHP file. And in case it's not clear, I'm releasing that code
under GPLv2 as it's pretty much entirely derived from PmWiki code.

As for the WYGIWYG component, I strongly suggest generating PmWiki
markup directly and using something like the above to turn that to
HTML for the live edit display.

eemeli



More information about the pmwiki-users mailing list