Getting output to just what's in the textarea - html

how do i get the output to just what's in the textarea instead of tinymce adding a whole html page wrapped aound my content.

plugins : "fullpage",
theme_advanced_buttons3_add : "fullpage"
remove these options from plugin settings
actually the question should have been the other way around

tinyMCE.get("elm1").getContent();

Related

Using AngularJS, How Can I Choose Not to Render a HTML Element if a Variable is Not Defined?

I'm trying to resolve an issue whereby a HTML element uses a Javascript variable to define the image it should display, but errors on load. Have a look at this line:
<img src="../../Images/{{variableData.data.canEdit}}.png" />
This currently works great, except under the browser's console, it is displaying an error to say that it cannot find the literal string "{{variableData.data.canEdit}}.png". I assume this is because AngularJS is loaded after the HTML elements are rendered by the browser.
How can I work around this?
I did try using the following Angular statement on the element like so:
ng-if="typeof(variableData.data)!=='undefined'"
But I imagine this makes no difference and the browser will still display a not found error message for the .png image.
The page all functions correctly, I just don't want those error messages in the browser's console.
Any ideas?
Many thanks
ng-if="variableData.data"
this should work fine
Change
src="<img src="../../Images/{{variableData.data.canEdit}}.png" />"
to
ng-src="<img src="../../Images/{{variableData.data.canEdit}}.png" />"
This makes sure it doesn't attempt to load until runtime of the javascript.
Changing the ng-if to just the variable (ng-if="variableData.data.canEdit") will make sure the element is loaded after the variable.
You have to put just variable like this
ng-if="variableData.data.canEdit"
Thanks to #PierreEmmanuelLallemant for answering this one in the comments.
The solution was to use ng-src within the img element, and then wrap the img element within a div and use an ng-if. Like so:
<div ng-if="variableData.data.canEdit"><img ng-src="../../Images/{{variableData.data.canEdit}}.png" /></div>
Using ng-src ensures that when Angular loads it sets the source attribute. Wrapping the img inside a div with ng-if makes sure that anything inside the div is not rendered until variableData.data.canEdit is defined.
Many thanks

Remove inline styles from django-tinymce html content

When I save content through django-tinymce it adds its own inline styles. However I'd like to remove this behaviour and just save the content in plain html. Can you please help me on this issue?
You can use any of tinyMCE configs like this:
Put this to your Django settings.py
(this will tell tinyMCE which elements are allowed`)
DJANGO settings.py
TINYMCE_DEFAULT_CONFIG = {
'theme': "advanced",
'valid_elements' : 'a[href|target=_blank],strong/b,div[align],br,p'
}
And push Clean Button in TinyMCE.
All TinyMCE configs is here:
Try also look at invalid_elements and invalid_styles
P.S. It would have more sense to set:
'invalid_elements': 'p[styles], span'
to remove all styles But It didn't work.
Hope it helps.
You could try writing your own implementation of a save function using
getContent({format: 'text'})
I'm no Djanjo expert but it sounds like the problem is being caused by them, and not TinyMCE itself.

Insert text surrounded by angular brackets inside contenteditable div?

I have a content editable div which is my search box. I need to add stack trace in C which has memory addresses surrounded by angular braces. When I insert this text inside the search box, it is being considered as html tags. How should I avoid that ?
An example of the content I am pasting inside the div:
[<ffffffff810733ff>] do_exit+0x15f/0x870
[<ffffffff8109dc25>] ? sched_clock_local+0x25/0x90
[<ffffffff81088792>] ? __dequeue_signal+0x102/0x200
[<ffffffff81073b68>] do_group_exit+0x58/0xd0
The div element after pasting.
<div id="searchBox"
contenteditable="true">do_exit+0x15f/0x870[<ffffffff8109dc25>] ?
sched_clock_local+0x25/0x90[<ffffffff81088792>] ?
__dequeue_signal+0x102/0x200[<ffffffff81073b68>] do_group_exit+0x58/0xd0
</div>
attribute contenteditable + unofficial value "plaintext-only" already answered.
Beside if you copy/paste these, brackets are turned into html entities.
If this is already in your code, then you should treat this on server side.
Anyway here is an extra option, if you still want to use html tag around this bits of code, you may give a try to an old tag <xmp>:
What says W3C about it : https://www.w3.org/wiki/HTML/Elements/xmp ... use at your own appreciation.
<div id="searchBox"
contenteditable="true"><xmp>do_exit+0x15f/0x870[<ffffffff8109dc25>] ?
sched_clock_local+0x25/0x90[<ffffffff81088792>] ?
__dequeue_signal+0x102/0x200[<ffffffff81073b68>] do_group_exit+0x58/0xd0
</xmp></div>
the proper way would be : (use htmlentities() or similar to treat brackets before being send to browser or when saved ).
[contenteditable] {
white-space:pre;
}
<div contenteditable="true">do_exit+0x15f/0x870[<ffffffff8109dc25>] ?
sched_clock_local+0x25/0x90[<ffffffff81088792>] ?
__dequeue_signal+0x102/0x200[ffffffff81073b68>] do_group_exit+0x58/0xd0</div>
Some browsers support contenteditable="plaintext-only", which solves your problem. However, the browsers that don’t support this may not even make the div contenteditable.
Example:
<div contenteditable="plaintext-only"></div>
A better solution to this problem would probably to use a native <input> or <textarea> — those should handle this for you.

HTML inside TextArea?

So I have this textarea in my website. By default, it has something like this as its contents:
Name : Sample Value
Age : Sample Value
Location : Sample Value
It is editable before the user hits the button and inserts it into the database, although I am not using a rich text editor since it's nothing but a simple text.
Since basic HTML codes are not browser readable inside the textarea tag, I used
to separate lines.
Now my problem is that I am not able to include the HTML code when I'm reading the value of the textarea tag in the server side.
Thus, the value inserted to the database is not HTML formatted as well, and when it is once again fetched into a web browser, it has no format at all.
What alternatives do I have? Thanks.
Not possible using textarea, use contenteditable DIV instead.
<div contenteditable="true"></div>
You can use getters and setter as shown below:
//Get content
var contents = document.getElementById("divId").innerHTML;
//Set content
document.getElementById("divId").innerHTML = contents
Here is the browser support for this approach.
Why don't you use JQuery and do this $(textarea).val() to get the value of the textarea as a string and use it server side. you might have to consider using Ajax to make a call to the server side method you want to pass the Html data.
The answer is very simple.
Use contenteditable DIVs instead of TextBox and TextArea.
But remember to add contenteditable="false" to all your inner HTML tags.
This worked for me.

How to prevent ░ or ▀ changing to &#9617,etc?

i am trying to add this in source code of my page inside a comment.
However,when i save,the characters change from this http://img.ctrlv.in/5134b28e330fa.jpg
to
http://img.ctrlv.in/5134b28e7a5b0.jpg
i tried encoding the characters,but in vain.They still change.
Is there any trick to prevent them from changing?thanks a lot
No.
You are at the mercy of Blogger's template processor.