1

I have a webpage with tinymce when a save my text into database tinymce save the text like this

[size= 14pt]Big text[b]big text blod[/b][/size]

but when i wantto display my text into the html the browser does not interpret the tinymce tags and show exactly the same code

I would like tinymce to save the text with the real html tags or valid tags

So that the text looks more like this

<p><span style="font-size:14px;">Big Text<b>Big text blod<b></span></p>

i have put this code into my tinymce inti

  formats: {
        bold: {inline : 'span', 'classes' : 'bold'},}

but when i write my text tinymce does not show me the changes and the text is plain no matter what i do

my tinymce inti like this

  tinymce.init({
                height: "300",
                width : "800",
                selector: 'textarea.editable',
                plugins : ['bbcode hr lists paste textcolor media'],
                toolbar: "bold italic underline forecolor backcolor image sizeselect fontsizeselect",
                fontsize_formats: "8pt 10pt 12pt 14pt 18pt 24pt 36pt",
                menubar: false,
                statusbar: false,
                toolbar_items_size: 'small',
                language: 'fr_FR',
                content_css: style_url,
                element_format: 'html',
                encoding: "UTF-8",
                entity_encoding : "raw",
                paste_retain_style_properties: "",
                oninit : "setPlainText",
                apply_source_formatting : true
            });
3
  • Why don't you use get HTML using plain javascript or jquery? Javascript code : var target = document.getElementById('texarea_id'); var wrap = document.createElement('div'); wrap.appendChild(target.cloneNode(true)); console.log(wrap.innerHTML); or Jquery :$('#textarea_id').html() to get the complete HTML. Commented Mar 16, 2017 at 18:09
  • tinymce change the textarea to iframe. The only method to catch de content is tinymce.activeEditor.getContent() but is not work Commented Mar 16, 2017 at 18:17
  • i find the solution . bbcode plugins change selector <> to [] i remove this in it work Commented Mar 16, 2017 at 18:49

3 Answers 3

2

For me, it works when I add this to my Laravel:

    {!! $php_var_here !!}
Sign up to request clarification or add additional context in comments.

Comments

1

There is a specific method to get html from TinyMCE

You can get HTML content from TinyMCE using below javascript

<script>
var content=tinymce.activeEditor.getContent();
console.log(content);
</script>

You can use content variable to save HTML to db or to send to server or you can add that HTML to some hidden field so that you can submit it to server side.

1 Comment

When I do this line of code. $content = The same code as inside with [b] tags
0

Note : This Is Only Applicable To Asp.net Core MVC

You Can Just Use @Html.Raw(@Model.textfile) To Display TinyMCE file text data in ASP.NET MVC EFcore

I Use Model To Pass My Data from controller To View. You can use ViewBag Or ViewData for the option Of @Model
Example : @Html.Raw(ViewBag.textfile)

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.