Page 1 of 1

Richtext-Editor nicEdit.js - remove tools from button list

Posted: 2018-07-14 11:11
by jsetzer
Hi there,

I need to remove a couple of tools from the button list of the nicEdit richtext editor. I am using AppGini 5.72.1036.
chrome_2018-07-14_13-07-01.png
chrome_2018-07-14_13-07-01.png (11.77 KiB) Viewed 4470 times
I have to remove fontSize, fontFamily, fontFormat, image, upload, link, unlink, forecolor and bgcolor.

According to the nicEdit documentation (http://wiki.nicedit.com/w/page/515/Conf ... %20Options) I have found the buttonList-configuration in nicEdit.js, line 30:

Code: Select all

buttonList : ['save','bold','italic','underline','left','center','right','justify','ol','ul','fontSize','fontFamily','fontFormat','indent','outdent','image','upload','link','unlink','forecolor','bgcolor'],
My configuration after removing those buttons:

Code: Select all

buttonList : ['save','bold','italic','underline','left','center','right','justify','ol','ul', 'indent','outdent'],

Unfortunately the buttons still appear :| .

Does anyone know how to remove them?

Kind Regards,
Jan

Re: Richtext-Editor nicEdit.js - remove tools from button list

Posted: 2018-07-14 13:01
by pbottcher
Hi,

you need to modify the template/<TABLENAME>_templateDV.html file. search for the

new nicEditor and either replace

Code: Select all

new nicEditor({ fullPanel : true })

by

Code: Select all

 new nicEditor({ buttonList : ['bold','italic','underline','left','center','right','justify','ol','ul', 'indent','outdent'] })   //  this will change only this single nicEdit box

or by

Code: Select all

new nicEditor({ fullPanel : false })  // this will affect this nicEdit box and apply the settings from the nicEdit.js defintion.


Re: Richtext-Editor nicEdit.js - remove tools from button list

Posted: 2018-07-14 13:51
by jsetzer
Thanks a lot, pböttcher, your solution works as expected! ;)

Unfortunately both files (nicEdit.js AND template/<TABLENAME>_templateDV.htm) will be overwritten on generation if I'm not careful enough.

Is there any solution using jQuery like...

Code: Select all

$j(function() {

	$j('#myEditor').nicEdit( /* ... configure or call some method ... */ );

});
... or something similar? I know we can adjust SELECT2 this way. So I'm wondering if we can do the same with nicEdit?!

Kind Regards,
Jan

Re: Richtext-Editor nicEdit.js - remove tools from button list

Posted: 2018-07-14 14:57
by pbottcher
Hi, you can try in the hooks/<TABLENAME>.php

Code: Select all

	function <TABLENAME>_footer($contentType, $memberInfo, &$args){
		$footer='';

		switch($contentType){
			case 'tableview':
				$footer='';
				break;

			case 'detailview':
				$footer='<script>
							bkLib.onDomLoaded(function() {
								setTimeout(function() {
									$j(\'div.nicEdit-panel\').children().slice(<AMOUNT OF BUTTON YOU WANT>).hide();
								},100);
							});
						 </script><%%FOOTER%%>
						';
				break;
replace <AMOUNT OF BUTTON YOU WANT> with the correct number you are looking for (e.g. 9)

Re: Richtext-Editor nicEdit.js - remove tools from button list

Posted: 2018-08-05 01:16
by ronwill
As an alternative, have you tried to use ckeditor instead of Nicedit. I use it on most my client text areas now.