Page 1 of 1

Need an editor?

Posted: 22 May 2007, 16:20
by crash3903
Guys

Firstly i would like to express my utmost appreciation to the developers of this brilliant software that is going to save me hours of tracking issues for my new software product

As a small gesture I would like to give this simple change back to this community

I like to be able to have an editor when creating or updating issues. So i have installed the famous TinyMCE editor. the first thing you need to do is to download this file

Unpack it and upload to your mantis folder keeping the structure in place

Next open up html_api.php found in your core folder and find this function @ line 183

Code: Select all

    function html_head_begin() {
        echo '<head>', "\n";
    }
Change it to read

Code: Select all

function html_head_begin() {
        echo '<head><script language="javascript" type="text/javascript" src="jscripts/tiny_mce/tiny_mce.js"></script>
<script language="javascript" type="text/javascript">
tinyMCE.init({
	mode : "textareas",
	theme : "advanced",
	plugins : "table,save,autosave,autosave,cleanup,advhr,advimage,advlink,
emotions,iespell,insertdatetime,preview,zoom,searchreplace,print,
contextmenu,directionality,inlinepopups,media,nonbreaking,visualchars,
devkit,paste,noneditable,layer,fullpage,fullscreen,",
	theme_advanced_buttons1_add_before : "save,separator,",
	theme_advanced_buttons1_add : "fontselect,fontsizeselect",
	theme_advanced_buttons2_add : "separator,insertdate,inserttime,preview,zoom,separator,forecolor,
backcolor",
	theme_advanced_buttons2_add_before: "cut,copy,paste,separator,search,replace,separator",
	theme_advanced_buttons3_add_before : "tablecontrols,separator",
	theme_advanced_buttons3_add : "emotions,iespell,flash,advhr,separator,print,ltr,rtl",
	theme_advanced_buttons4_add_before : "visualchars,nonbreaking,devkit,separator,layer,fullpage,fullscreen",
	table_styles : "Header 1=header1;Header 2=header2;Header 3=header3",
	table_cell_styles : "Header 1=header1;Header 2=header2;Header 3=header3;Table Cell=tableCel1",
	table_row_styles : "Header 1=header1;Header 2=header2;Header 3=header3;Table Row=tableRow1",
	table_cell_limit : 100,
	table_row_limit : 5,
	table_col_limit : 5,
	theme_advanced_toolbar_location : "top",
	theme_advanced_toolbar_align : "left",
	theme_advanced_path_location : "bottom",
	plugin_insertdate_dateFormat : "%Y-%m-%d",
	plugin_insertdate_timeFormat : "%H:%M:%S",
	extended_valid_elements : "a[name|href|target|title|onclick],img[class|src|border=0|alt|title|
hspace|vspace|width|height|align|onmouseover|onmouseout|name],
hr[class|width|size|noshade],font[face|size|color|style],span[class|align|
style]",
	external_link_list_url : "example_data/example_link_list.js",
	external_image_list_url : "example_data/example_image_list.js",
	flash_external_list_url : "example_data/example_flash_list.js"
});
</script>
Now check any of your pages where you have a text box to add comments and you will see the change ;)

Hope this is of some use to someone

Regards

Mark

Brilliant idea, but ..

Posted: 06 Jun 2007, 08:20
by omeslo
.. even after adding

Code: Select all

';
}
at the end of your block of code, I still get a javascript error. Are you sure your instructions are correct?

using TinyMCE : sample not complete ?

Posted: 07 Jun 2007, 07:23
by davidf
Hello,

To make the sample working, you have to put all the text between echo '<head> and <script> in one line, and add '; at this end of line, and it will work better.
After doing that, this work better. With Tiny MCE, you can customize the number of buttons proposed ( tinyMCE.init({ mode : "textareas",...).

The problem I have now, is that the field is not displayed correctly, I see
"<?xml version="1.0" encoding="utf-8"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> [^] <html xmlns="http://www.w3.org/1999/xhtml" [^] lang="en" xml:lang="en"> <head> <title>Untitled document</title> ..."
instead of the text I hope to see.

corrected version using 'simple' syle

Posted: 07 Jun 2007, 07:34
by omeslo
Well, I got it working anyway, only to find that all html tags that require a parameter (like <img> etc) are not supported. The tags are simply printed to the screen and not rendered.
So here's a version using only the 'simple' style (bold, underline etc.)

code:

Code: Select all

# (2) Begin the <head> section
	function html_head_begin() {
		echo '<head>', "\n";
	echo "<script language=\"javascript\" type=\"text/javascript\" src=\"insert_your_path_to/tiny_mce.js\"></script>
	<script language=\"javascript\" type=\"text/javascript\">
		tinyMCE.init({
		theme : \"simple\",
		mode : \"textareas\"
		});
	</script>";
	}
And don't forget to specify which tags should be rendered in config_inc.php. I am using:

Code: Select all

$g_html_valid_tags		= 'p, li, ul, ol, br, pre, i, b, u, strong, em, strike, blockquote, h1, h2, h3, sub, sup, a, hr';

Re: Need an editor?

Posted: 27 Dec 2010, 08:05
by thomasbrooks
Hello!
Since Mantis can't cope with tags that have parameters (eg. <font face="arial">) in textareas (see $g_html_valid_tags section in the config_defaults_inc.php file), hence even the basic theme of TintMCE causes problems after submitting the text, if, for example, underline has selected.
I've played a bit with TinyMCE, and below are instruction on how to make it work in mantis.

1) Download TinyMCE from http://tinymce.moxiecode.com/download/download.php (currently the last stable version is: 3.3.9.3), unzip it and paste the folder called "tinymce" (in which there are the "examples" and "jscripts" folders and changelog text file) into the mantis/javascript folder.

2) Open the mantis/core/html_api.php file. Search for: function html_head_begin(). Replace the existing function (- you may just mark it as a comment using /* and */), with:

Code: Select all

    function html_head_begin() {
      echo '<head>', "\n";
   echo "<script language=\"javascript\" type=\"text/javascript\" src=\"./javascript/tinymce/jscripts/tiny_mce/tiny_mce.js\"></script>
   <script language=\"javascript\" type=\"text/javascript\">
      tinyMCE.init({
      mode : \"textareas\",
      theme : \"advanced\",
      plugins : \"searchreplace\",      
      theme_advanced_buttons1 : \"bold,italic,underline,strikethrough,bullist,numlist,hr,formatselect,undo,redo,search,replace,link,unlink\",
      theme_advanced_blockformats : \"h1,h2,h3,h4,h5,blockquote,code,div,p\",
      preformatted : false,
      theme_advanced_buttons2 : \"\",
      theme_advanced_buttons3 : \"\",
      theme_advanced_toolbar_location : \"top\",
      theme_advanced_toolbar_align : \"left\",
      theme_advanced_statusbar_location : \"bottom\",
      theme_advanced_resizing : true,
      convert_fonts_to_spans : false,
      convert_newlines_to_brs : false,
      force_br_newlines : false,
      force_p_newlines : true,
      forced_root_block : '',
      remove_redundant_brs : true,
      inline_styles : false,
      formats : { strikethrough : {block : 'strike'},
                  underline : {block : 'u'},
                  h1 : {block : 'h1'},
                  h2 : {block : 'h2'},
                  h3 : {block : 'h3'},
                  h4 : {block : 'h4'},
                  h5 : {block : 'h5'},
                  h6 : {block : 'h6'}
      }
      
      });
   </script>";
   }
and save the file.
Note: some of the configurations here may be obsolete since they are the default, but it doesn't hurt.

3) Open the mantis/config_inc.php file. Add the following line:

Code: Select all

  $g_html_valid_tags = 'p, div, center, table, tr, td, li, ul, ol, br, big, small, tt, pre, i, b, u, strong, em, strike, blockquote, h1, h2, h3, h4, h5, sub, sup, a, hr';
and save the file.

4) Open the mantis/css/defalut.css file. Change the line that begins with "p" (about the 9th line) to be:

Code: Select all

p 					{ font-family: Verdana, Arial, Helvetica, sans-serif; margin: 0; padding: 0;}
and save the file.

Now open your Mantis and you'll notice the editor appears on each textarea.

Re: Need an editor?

Posted: 13 Jan 2011, 13:39
by cas
I have released a plugin for this, see:
http://www.mantisbt.org/bugs/view.php?id=12325

And provided a new version 1.01 with support for RSS

Re: Need an editor?

Posted: 24 Feb 2011, 19:13
by YomaBV
Thanks for the plugin! I recently had to reinstall everything, and the plugin simplified this part a great deal .

Re: Need an editor?

Posted: 25 Feb 2011, 07:33
by cas
Be warned that adding wysiwyg functionality (via plugin or manually) will impact your mail, graphics and RSS functions. These have not been fully solved.

Re: Need an editor?

Posted: 02 Mar 2011, 15:00
by brianoliveruk
Thanks for the plug in,
testing it now

Re: Need an editor?

Posted: 03 Jun 2013, 21:11
by Yuhd
Hello All,
Thanks for the plugin.
I'd like to know whether it's still impacting the Email Notification or it was fixed?

Re: Need an editor?

Posted: 04 Jun 2013, 06:30
by cas
Noop, never fixed it :roll: