Need an editor?

Post about your customizations to share with others.

Moderators: Developer, Contributor

Post Reply
crash3903
Posts: 1
Joined: 20 May 2007, 16:37
Location: united Kingdom
Contact:

Need an editor?

Post 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
Mark A Reynolds
LSM Loaded Online Stores
omeslo
Posts: 16
Joined: 23 Apr 2007, 14:42

Brilliant idea, but ..

Post 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?
davidf
Posts: 2
Joined: 13 Apr 2007, 07:36

using TinyMCE : sample not complete ?

Post 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.
David F
Senior Project Manager
omeslo
Posts: 16
Joined: 23 Apr 2007, 14:42

corrected version using 'simple' syle

Post 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';
thomasbrooks
Posts: 5
Joined: 27 Dec 2010, 07:37

Re: Need an editor?

Post 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.
Attachments
tinymce_in_mantis.jpg
tinymce_in_mantis.jpg (14.02 KiB) Viewed 23203 times
Thomas Brooks

Mantis: 1.2.4
PHP: 5.3.1
SQL: MySQL 5.1.41
OS: Windows Server 2003 R2, Standard Edition, SP2
cas
Posts: 1586
Joined: 11 Mar 2006, 16:08
Contact:

Re: Need an editor?

Post 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
YomaBV
Posts: 1
Joined: 24 Feb 2011, 19:08

Re: Need an editor?

Post by YomaBV »

Thanks for the plugin! I recently had to reinstall everything, and the plugin simplified this part a great deal .
cas
Posts: 1586
Joined: 11 Mar 2006, 16:08
Contact:

Re: Need an editor?

Post 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.
brianoliveruk
Posts: 1
Joined: 02 Mar 2011, 14:53

Re: Need an editor?

Post by brianoliveruk »

Thanks for the plug in,
testing it now
Yuhd
Posts: 27
Joined: 20 Nov 2012, 22:01

Re: Need an editor?

Post 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?
cas
Posts: 1586
Joined: 11 Mar 2006, 16:08
Contact:

Re: Need an editor?

Post by cas »

Noop, never fixed it :roll:
Post Reply