Page 1 of 1

tinyMCE p tag wrappers

Posted: Mon Jun 13, 2022 3:28 pm
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

Re: tinyMCE p tag wrappers

Posted: Mon Jun 13, 2022 4:11 pm
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.

Re: tinyMCE p tag wrappers

Posted: Mon Jun 13, 2022 5:04 pm
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.

Re: tinyMCE p tag wrappers

Posted: Tue Jun 14, 2022 6:46 am
by kev1n
I'm not quite sure what the behaviour will be like then. If you have the chance, please try it out.

Re: tinyMCE p tag wrappers

Posted: Wed Jun 15, 2022 8:04 am
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);

	});
}

Re: tinyMCE p tag wrappers

Posted: Wed Jun 15, 2022 2:57 pm
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.

Re: tinyMCE p tag wrappers

Posted: Wed Jun 15, 2022 4:51 pm
by kev1n
Please try again with this patched file:

[Attachment removed, patch incorporated]

Re: tinyMCE p tag wrappers

Posted: Wed Jun 15, 2022 5:11 pm
by chpwebmaster
that works

thank you