[cvs] [Wiki] created: WysiwygProHowTo

Jan Schneider jan at horde.org
Tue Mar 25 10:49:29 UTC 2008


jan  Tue, 25 Mar 2008 06:49:29 -0400

Created page: http://wiki.horde.org/WysiwygProHowTo

+ Integrating the !WysiwygPro editor

>From the [http://www.wysiwygpro.com/ WysiwygPro homepage]: //"!WysiwygPro is
an advanced online HTML WYSIWYG editor that can be embedded in a web
page."//

To replace thew wysiwyg editor in IMP's compose screen when composing HTML
message, apply the patch attached to this wiki page. It's a patch against a
CVS HEAD checkout from March 8 2008. It only replaces the editor in the
compose screen, nowhere else. And it replaces it unconditionally, i.e. the
user has no choice between different editors. This is because that editor is
developed in a way that doesn't allow easy integration into existing
software because it makes too many assumptions.

For reference the patch is also pasted below, without the changes to
{{imp/js/compose.js}}. Patching this file probably fails because it usually
consists of a single line only, and only a small change causes a conflict
with the patch. You can either recreate that file by compressing the source
file {{imp/js/src/compose.js}}, or by simply copying that file over.

<code>
Index: compose.php
===================================================================
RCS file: /repository/imp/compose.php,v
retrieving revision 2.1083
diff -u -r2.1083 compose.php
--- compose.php	29 Feb 2008 13:07:51 -0000	2.1083
+++ compose.php	18 Mar 2008 14:49:46 -0000
@@ -755,6 +755,13 @@
     $js_code[] = 'var identities = ' .
IMP_Serialize_JSON::encode(String::convertCharset($js_ident,
NLS::getCharset()), 'utf-8');
 }

+if ($rtemode) {
+    require_once HORDE_BASE .
'/services/editor/wysiwygPro/wysiwygPro.class.php';
+    $editor = new wysiwygPro();
+    $editor->name = 'message';
+   
$editor->addCSSText('body{font-size:75%;}.imp-signature{background-color:
#eee;}');
+}
+
 Horde::addScriptFile('prototype.js', 'imp', true);
 Horde::addScriptFile('compose.js', 'imp', true);
 require IMP_TEMPLATES . '/common-header.inc';
@@ -1154,12 +1161,14 @@
         }
     }

-    echo $t->fetch(IMP_TEMPLATES . '/compose/compose.html');
-}
+    if ($rtemode) {
+        $editor->value = $msg;
+        $t->set('compose_body', $editor->fetch());
+    } else {
+        $t->set('compose_body', '<textarea class="composebody"
tabindex="<tag:message_tabindex />" name="message" id="message" rows="20"
cols="80">' . $t->get('message') . '</textarea>');
+    }

-/* Load RTE. */
-if ($rtemode && !$redirect) {
-    echo $imp_ui->initRTE();
+    echo $t->fetch(IMP_TEMPLATES . '/compose/compose.html');
 }

 require $registry->get('templates', 'horde') . '/common-footer.inc';
Index: js/src/compose.js
===================================================================
RCS file: /repository/imp/js/src/compose.js,v
retrieving revision 1.21
diff -u -r1.21 compose.js
--- js/src/compose.js	18 Mar 2008 13:15:17 -0000	1.21
+++ js/src/compose.js	18 Mar 2008 14:49:46 -0000
@@ -102,17 +102,8 @@
     // If the rich text editor is on, we'll use a regexp to find the
     // signature comment and replace its contents.
     if (rtemode) {
-        switch (ImpVar.js_editor) {
-        case 'xinha':
-            ed = _getXinha();
-            msg = ed.getHTML();
-            break;
-
-        case 'fckeditor':
-            ed = FCKeditorAPI.GetInstance('message');
-            msg = ed.GetHTML();
-            break;
-        }
+        ed = WPro.editors['message'];
+        msg = ed.getValue();

         msg = msg.replace(/\r\n/g, '\n');

@@ -148,15 +139,7 @@
     }

     if (rtemode) {
-        switch (ImpVar.js_editor) {
-        case 'xinha':
-            ed.setHTML(msg);
-            break;
-
-        case 'fckeditor':
-            ed.SetHTML(msg);
-            break;
-        }
+        ed.setValue(msg);
     } else {
         $('message').setValue(msg);
     }
@@ -288,31 +271,14 @@

     SpellCheckerObject.onBeforeSpellCheck = function() {
         SpellCheckerObject.htmlAreaParent = 'messageParent';
-        switch (ImpVar.js_editor) {
-        case 'xinha':
-            var ed = _getXinha();
-            SpellCheckerObject.htmlArea = ed._htmlArea;
-            ed._textArea.setValue(ed.outwardHtml(ed.getHTML()));
-            break;
-
-        case 'fckeditor':
-            SpellCheckerObject.htmlArea =
$('message').adjacent('iframe[id*=message]').first();
-           
$('message').setValue(FCKeditorAPI.GetInstance('message').GetHTML());
-            break;
-        }
+        SpellCheckerObject.htmlArea = $('message_border');
+        $('message').setValue(WPro.editors['message'].getValue());
+        $('message_container').select('div.wproEditor > div')[2].show();
     }
     SpellCheckerObject.onAfterSpellCheck = function() {
         SpellCheckerObject.htmlArea = SpellCheckerObject.htmlAreaParent =
null;
-        switch (ImpVar.js_editor) {
-        case 'xinha':
-            var ed = _getXinha();
-            ed.setHTML(ed.inwardHtml(ed._textArea.value));
-            break;
-
-        case 'fckeditor':
-           
FCKeditorAPI.GetInstance('message').SetHTML($('message').value);
-            break;
-        }
+        $('message_container').select('div.wproEditor > div')[2].hide();
+        WPro.editors['message'].setValue($('message').value);
     }
 }

Index: templates/common-header.inc
===================================================================
RCS file: /repository/imp/templates/common-header.inc,v
retrieving revision 2.94
diff -u -r2.94 common-header.inc
--- templates/common-header.inc	2 Jan 2008 12:51:02 -0000	2.94
+++ templates/common-header.inc	18 Mar 2008 14:49:47 -0000
@@ -45,6 +45,7 @@
 <link href="<?php echo Horde::applicationUrl('search.php') ?>"
rel="search" />
 <?php if (!empty($ie_clientcaps)): ?><style>IE\:clientcaps
{behavior:url(#default#clientcaps)}</style><?php endif; ?>
 <?php IMP::outputInlineScript(); ?>
+<?php if (isset($editor) && is_a($editor, 'wysiwygPro')) echo
$editor->displayHeadContent(); ?>
 </head>

 <body<?php if ($bc = Util::nonInputVar('bodyClass')) echo ' class="' . $bc
. '"' ?><?php if ($bi = Util::nonInputVar('bodyId')) echo ' id="' . $bi .
'"'; ?>>
Index: templates/compose/compose.html
===================================================================
RCS file: /repository/imp/templates/compose/compose.html,v
retrieving revision 2.40
diff -u -r2.40 compose.html
--- templates/compose/compose.html	18 Mar 2008 12:50:00 -0000	2.40
+++ templates/compose/compose.html	18 Mar 2008 14:49:47 -0000
@@ -194,7 +194,7 @@
  <tr>
   <td class="light rightAlign" valign="top"><strong><tag:message_label
/>&nbsp;</strong></td>
   <td class="item" colspan="2" id="messageParent">
-   <textarea class="composebody" tabindex="<tag:message_tabindex />"
name="message" id="message" rows="20" cols="80"><tag:message /></textarea>
+   <tag:compose_body />
   </td>
  </tr>

</code>

If the patch is not rendered correctly, copy it from the source view of
this page.


More information about the cvs mailing list