TinyMCE: Difference between revisions

From Meta, a Wikimedia project coordination wiki
Content deleted Content added
No edit summary
No edit summary
Line 1: Line 1:
Please read the article on [[WYSIWYM]] for more information on WYSIWYG editors in WikiMedia.
Please read the article on [[WYSIWYM]] for more information on WYSIWYG editors in WikiMedia.


You can also download the following patch: [http://www.logicsupply.com/pub/wysiwyg.patch.zip http://www.logicsupply.com/pub/wysiwyg.patch.zip]. This patch integrates [http://tinymce.moxiecode.com/ TinyMCE] into MediaWiki version 1.5.2. The TinyMCE source is included in the patch. I've added an option to the user preferences to enable or disable the editor on a per user basis. All HTML is converted to appropriate wiki markup before previewing/saving.
You can also download the following patch: [http://www.logicsupply.com/pub/wysiwyg.patch.zip http://www.logicsupply.com/pub/wysiwyg.patch.zip]. This patch integrates [http://tinymce.moxiecode.com/ TinyMCE] into MediaWiki version 1.5.7 (used to be 1.5.2). The TinyMCE source is included in the patch. I've added an option to the user preferences to enable or disable the editor on a per user basis. All HTML is converted to appropriate wiki markup before previewing/saving.


Limitations include:
Limitations include:
Line 8: Line 8:
* Preformatted text (lines starting with whitespace) doesn't survive the trip to and from HTML
* Preformatted text (lines starting with whitespace) doesn't survive the trip to and from HTML
* Some features, like underline and strikethrough, have no effect.
* Some features, like underline and strikethrough, have no effect.
* Editing pages using templates will break the template usage.


If someone wants to hack TinyMCE to make these features work, they're more than welcome.
If someone wants to hack TinyMCE to make these features work, they're more than welcome.
Line 46: Line 47:


Test the preview and save features as well as basic editing commands. If everything looks good, you may want to remove the backup files created by patch.
Test the preview and save features as well as basic editing commands. If everything looks good, you may want to remove the backup files created by patch.

'''Manually fetching images should no longer be necessary:'''


After patching you will need to install the images used for toolbar buttons from the latest TinyMCE editor download ([http://tinymce.moxiecode.com/download.php download here]). From the archive's <code>jscripts</code> subdirectory, copy the contents of the <code>tiny_mce/themes/advanced/images</code> and <code>tiny_mce/plugins/table/images</code> directories into the <code>javascript</code> subdirectory of your MediaWiki install. (Nothing else from the TinyMCE download is needed, so the rest can be discarded).
After patching you will need to install the images used for toolbar buttons from the latest TinyMCE editor download ([http://tinymce.moxiecode.com/download.php download here]). From the archive's <code>jscripts</code> subdirectory, copy the contents of the <code>tiny_mce/themes/advanced/images</code> and <code>tiny_mce/plugins/table/images</code> directories into the <code>javascript</code> subdirectory of your MediaWiki install. (Nothing else from the TinyMCE download is needed, so the rest can be discarded).

Revision as of 13:19, 20 July 2006

Please read the article on WYSIWYM for more information on WYSIWYG editors in WikiMedia.

You can also download the following patch: http://www.logicsupply.com/pub/wysiwyg.patch.zip. This patch integrates TinyMCE into MediaWiki version 1.5.7 (used to be 1.5.2). The TinyMCE source is included in the patch. I've added an option to the user preferences to enable or disable the editor on a per user basis. All HTML is converted to appropriate wiki markup before previewing/saving.

Limitations include:

  • Links and images must still be specified using wiki markup
  • Preformatted text (lines starting with whitespace) doesn't survive the trip to and from HTML
  • Some features, like underline and strikethrough, have no effect.
  • Editing pages using templates will break the template usage.

If someone wants to hack TinyMCE to make these features work, they're more than welcome.

This implementation makes use of html2wiki, a trivial utility written in perl. Download the script, and put it in the $PATH somewhere (probably /usr/local/bin):

$ wget http://www.logicsupply.com/pub/html2wiki
$ sudo mv html2wiki /usr/local/bin

To use html2wiki, you will need the perl module HTML::WikiConverter. If you have CPAN installed, you can type:

# cpan
cpan> install HTML::WikiConverter
cpan> install HTML::WikiConverter::MediaWiki

Otherwise, you will need to download this module (as well as any dependencies) from the CPAN website. Please note that if you get no output on when previewing or saving you may need to specify the MediaWiki dialect. Find file includes/EditPage.php and edit the process description at the begining to be:

$html2wiki = 'html2wiki --dialect MediaWiki';

If you are using HTML::Converter v.0.52, you will need to pass an encoding type to html2wiki. Find file includes/EditPage.php and edit the process description at the begining to be:

$html2wiki = 'html2wiki --dialect MediaWiki --encoding=utf-8';

To use the patch, type at a command prompt:

$ wget http://www.logicsupply.com/pub/wysiwyg.patch.zip
$ unzip wysiwyg.patch.zip
$  mv wysiwyg.patch [WIKIROOT]
$ cd [WIKIROOT]
$ patch --backup -p0 < wysiwyg.patch

Watch the output of the patch command carefully, and make sure everything went smoothly.

Test the preview and save features as well as basic editing commands. If everything looks good, you may want to remove the backup files created by patch.

Manually fetching images should no longer be necessary:

After patching you will need to install the images used for toolbar buttons from the latest TinyMCE editor download (download here). From the archive's jscripts subdirectory, copy the contents of the tiny_mce/themes/advanced/images and tiny_mce/plugins/table/images directories into the javascript subdirectory of your MediaWiki install. (Nothing else from the TinyMCE download is needed, so the rest can be discarded).

If you see blank main page after patching, then it can be problem with permisions. Setting permisions to 777 will not help and is insecure. I recomend changing owner recursively for the whole wiki folder. You can do that by command chown. If it doesn't help then try to figure out what's wrong by adding these lines to the begining of file index.php(placed in main wiki folder)
error_reporting( E_ALL );
@ini_set( "display_errors", true );

This patch is courtesy of Logic Supply. Please direct all emails regarding the patch to Forest Bond <forest@logicsupply.com>. Patch last modified 12/6/2005.

Please note, this patch is certainly not perfect. I suggest you use the option "Use wiki-style links in WYSIWYG." Please note, to create internal links using the TinyMCE interface, you should just set the URL to the page title you are trying to link to. This will only work, however, if the link text matches the link URL.

Note: This patch requires PHP 4.3.0 or later. You can make it work with 4.2.2 by changing the html2wiki function in EditPage.php to something like this:

function html2wiki($html)
{
  $html = "<html>\n<body>\n" . wysiwyg_preproc($html) . "</body>\n</html>\n";
  $tempfname = tempnam( '/tmp', 'mce' );
  $tempfile = fopen( $tempfname, 'w' );
  fwrite( $tempfile, $html );
  fclose( $tempfile );
  $pipe = popen( "html2wiki --dialect MediaWiki $tempfname", 'r' );
  while( ! feof( $pipe ) ) {
    $output .= fgets($pipe);
  }
  pclose( $pipe );
  unlink( $tempfname );
  return wysiwyg_postproc($output);
}


Using MediaWiki 1.5.3 on Linux I had to remove an empty line at the end of EditPage.php because I got error messages in the html user interface. Edit does work but after saving an empty page is stored.



Hi, I'm trying to integrate TinyMCE into MediaWiki 1.5.6. The editor works, however I also have the problem of saving an empty page.

Is there a fix for this yet? I tried:

  • removing the empty line at the end of EditPage.php
  • adding the dialect: "$html2wiki = 'html2wiki --dialect MediaWiki';" in EditPage.php.

Any ideas to solve the problem? It's quite urgent.


UPDATE: I was able to fix the problem. Here's my solution. I hope it helps others having the same problem. The saved text disappeared because html2wiki didn't run correctly.

  • Although the installation went fine, the MediaWiki dialect was not installed. If it is installed you should have a file MediaWiki.pm somewhere in your Perl directory. I fixed this by running:
perl -MCPAN -e 'install HTML::WikiConverter::MediaWiki'
  • To test if html2wiki worked I created a simple html file and ran:
html2wiki --dialect=MediaWiki test.html 

It complained about an encoding parameter (undef).

  • I tried running:
html2wiki --dialect=MediaWiki --encoding=utf-8 test.html 

and it worked fine.

  • So to make it work in the MediaWiki, I changed EditPage.php:
$html2wiki = 'html2wiki'

to

$html2wiki = 'html2wiki --dialect=MediaWiki --encoding=utf-8';