Jump to content

Tiny MCE minifying code


Recommended Posts

Hi All,

I hope this is in the right place.

I am using tinymce on a textarea.  When populating this text area, tiny mce seems to be minifying the code.

If i put this in and save

 

<div class="row">
    <div class="col">This is some info</div>
    <div class="col">This is some more info</div>
</div>

This is what i get back when it is returned

 

<div class="row"> <div class="col">This is some info</div> <div class="col">This is some more info</div> </div>

This makes editing really challenging.

 

Here is my init

 

	function initializeTinyMCE() {

		
		tinymce.remove(".tmce");

		
		setTimeout(function() {
			if ($("textarea.tmce").length > 0) {

				tinymce.init({
					selector: "textarea.tmce",
					apply_source_formatting: true,
					highlight_on_focus: true,
					skin: "bootstrap",
					plugins: "lists, link, image, media, code",
					toolbar: "h1 h2 bold italic strikethrough blockquote bullist numlist backcolor | link image media | removeformat code",
					menubar: false,
					forced_root_block: 'false'
					
				});
			} else {

			}
		}, 100); 
	}

This is how it is being saved into json in maria DB

 

"Content": "&lt;div class=\"row\"&gt;\n&lt;div class=\"col\"&gt;This is some info&lt;\/div&gt;\n&lt;div class=\"col\"&gt;This is some more info&lt;\/div&gt;\n&lt;\/div&gt;"

I guess my question is - can i make tinymce pretty the code when it is displayed, indenting tags and putting blocks on new lines?

Link to comment
Share on other sites

1 hour ago, Adamhumbug said:

Hi All,

I hope this is in the right place.

I am using tinymce on a textarea.  When populating this text area, tiny mce seems to be minifying the code.

If i put this in and save

 

<div class="row">
    <div class="col">This is some info</div>
    <div class="col">This is some more info</div>
</div>

This is what i get back when it is returned

 

<div class="row"> <div class="col">This is some info</div> <div class="col">This is some more info</div> </div>

This makes editing really challenging.

 

Here is my init

 

	function initializeTinyMCE() {

		
		tinymce.remove(".tmce");

		
		setTimeout(function() {
			if ($("textarea.tmce").length > 0) {

				tinymce.init({
					selector: "textarea.tmce",
					apply_source_formatting: true,
					highlight_on_focus: true,
					skin: "bootstrap",
					plugins: "lists, link, image, media, code",
					toolbar: "h1 h2 bold italic strikethrough blockquote bullist numlist backcolor | link image media | removeformat code",
					menubar: false,
					forced_root_block: 'false'
					
				});
			} else {

			}
		}, 100); 
	}

This is how it is being saved into json in maria DB

 

"Content": "&lt;div class=\"row\"&gt;\n&lt;div class=\"col\"&gt;This is some info&lt;\/div&gt;\n&lt;div class=\"col\"&gt;This is some more info&lt;\/div&gt;\n&lt;\/div&gt;"

I guess my question is - can i make tinymce pretty the code when it is displayed, indenting tags and putting blocks on new lines?

This is happening when pasting code into the rich text view, not the code view.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.