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

The recommended method of customizing your AppGini-generated application is through hooks. But sometimes you might need to add functionality not accessible through hooks. You can discuss this here.
Post Reply
User avatar
jsetzer
Veteran Member
Posts: 53
Joined: 2018-07-06 06:03
Location: Kiel, Germany
Contact:

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

Post by jsetzer » 2018-07-14 11:11

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 312 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

pböttcher
AppGini Super Hero
AppGini Super Hero
Posts: 282
Joined: 2018-04-01 10:12

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

Post by pböttcher » 2018-07-14 13:01

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.


User avatar
jsetzer
Veteran Member
Posts: 53
Joined: 2018-07-06 06:03
Location: Kiel, Germany
Contact:

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

Post by jsetzer » 2018-07-14 13:51

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

pböttcher
AppGini Super Hero
AppGini Super Hero
Posts: 282
Joined: 2018-04-01 10:12

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

Post by pböttcher » 2018-07-14 14:57

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)

ronwill
Veteran Member
Posts: 73
Joined: 2015-08-08 10:12
Location: Cheltenham UK +Weatherford USA

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

Post by ronwill » 2018-08-05 01:16

As an alternative, have you tried to use ckeditor instead of Nicedit. I use it on most my client text areas now.
Ron - AppGini Pro V 5.72 Rev 1036

Post Reply