Welcome to the nuBuilder Forums!

Register and log in to access exclusive forums and content available only to registered users.

tinyMCE p tag wrappers Topic is solved

Questions related to using nuBuilder Forte.
Post Reply
chpwebmaster
Posts: 72
Joined: Mon Jun 10, 2019 5:00 pm
Has thanked: 6 times
Been thanked: 4 times

tinyMCE p tag wrappers

Unread post by chpwebmaster »

We have a couple of forms that have boxes for notes I changed them to tinyMCE. The problem is that it wraps them with a p tag causing:
Screen Shot 2022-06-13 at 9.07.46 AM.png
Is there a way we could get the tinyMCE option in the nuconfig file to either disable (forced_root_block = '' in the init will do it) or change it to a div at least so it won't affect the browse form.

tested forced_root_block = '' in nuwysiwyg.js tinyMCE init fixes the problem

Thank You
You do not have the required permissions to view the files attached to this post.
kev1n
nuBuilder Team
Posts: 4297
Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 71 times
Been thanked: 444 times
Contact:

Re: tinyMCE p tag wrappers

Unread post by kev1n »

Hi,

I found this in the docs
Setting forced_root_block to false or an empty string has been deprecated in TinyMCE 5.10. For TinyMCE 6.0, this option will only accept valid block elements.
That means as soon as TinyMCE is bumped to v6, forced_root_block will no longer work.

There is going to be a new option newline_behavior (dev channel) according to this discussion.
chpwebmaster
Posts: 72
Joined: Mon Jun 10, 2019 5:00 pm
Has thanked: 6 times
Been thanked: 4 times

Re: tinyMCE p tag wrappers

Unread post by chpwebmaster »

If i'm reading that correctly they are not getting rid of forced_root_block it can just no longer be set to false and must have a block element. So there could just be an option to change it to a div which should fix my particular problem. However I will go ahead and add a patch file in my updater to make the change on my local nuwysiwyg.js file for the time being.
kev1n
nuBuilder Team
Posts: 4297
Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 71 times
Been thanked: 444 times
Contact:

Re: tinyMCE p tag wrappers

Unread post by kev1n »

I'm not quite sure what the behaviour will be like then. If you have the chance, please try it out.
kev1n
nuBuilder Team
Posts: 4297
Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 71 times
Been thanked: 444 times
Contact:

Re: tinyMCE p tag wrappers

Unread post by kev1n »

I updated nuwysiwyg.js so you can use custom options. Could you try it?

[Attachment removed, incorporated update]

JS in the form's Custom Code:

Code: Select all

function nuOnEditorLoad() {

	$('.nuEditor').each((index, element) => { 

		let options = {
			forced_root_block = ''
		};

		nuInitTinyMCE(element.id, options);

	});
}
chpwebmaster
Posts: 72
Joined: Mon Jun 10, 2019 5:00 pm
Has thanked: 6 times
Been thanked: 4 times

Re: tinyMCE p tag wrappers

Unread post by chpwebmaster »

With either your code or mine if it is set to an empty string you get an error in the console about V6. when set to div with my patch:

Code: Select all

--- nuwysiwyg.js.master	2022-06-13 11:10:05.098250842 -0400
+++ nuwysiwyg.js	2022-06-13 09:22:20.776065213 -0400
@@ -71,6 +71,7 @@
 
 	tinymce.init({
 		selector: "#" + idContainer,
+		forced_root_block : 'div',
 		plugins: _plugins,
 		mobile: _mobile, 
 		menu: {
I get both old and new lines in the editor with yours it changes it on the browse form when I make an edit but is not loading existing content into the editor. I did try changing

Code: Select all

let options = {
			forced_root_block = ''
		};
to

Code: Select all

let options = {
			forced_root_block : '',
		};
as well. the ACE editor was complaining about the =.

I do know that yours is at least loading it into the options because of the warning about V6.
kev1n
nuBuilder Team
Posts: 4297
Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 71 times
Been thanked: 444 times
Contact:

Re: tinyMCE p tag wrappers

Unread post by kev1n »

Please try again with this patched file:

[Attachment removed, patch incorporated]
chpwebmaster
Posts: 72
Joined: Mon Jun 10, 2019 5:00 pm
Has thanked: 6 times
Been thanked: 4 times

Re: tinyMCE p tag wrappers

Unread post by chpwebmaster »

that works

thank you
Post Reply