Tinymce wrongly rewriting HTML - tinymce

I have a custom button that insert some HTML in the editor
First block of code is the button action and the second one is how the HTML is inserted
Any idea why it is rewriting it that way and how to stop it?

I just managed to fix it, in the init function:
valid_children : 'pre[code]'

TinyMCE includes the ability to insert code samples into the editor via its Code Sample plugin:
https://www.tinymce.com/docs/plugins/codesample/
If you want to try to do this yourself you need to do a few things like using the protect configuration option to tell TinyMCE to allow your PHP tags. See this TinyMCE Fiddle for a basic example:
http://fiddle.tinymce.com/Qdgaab

Related

TinyMCE - Setting up for EE tags

I've got a TinyMCE plugin that I'm using in Expression Engine. Problem is though I'm going from a textarea with code that uses EE tags to this and when saving it's breaking code.
For example, for an image I'll use src="{site_url}/image/logo.png", TinyMCE then rips out or corrupts the {site_url} part and try to and replace it with a relative path which (as site_url isn't at the root) is wrong.
I know you can add new tags for TinyMCE to respect in the config but this only assumes those wrapped in <> and not {}.
Anyone know if I can adapt this? Or have a better solution of something that will respect it?
Since TineMCE is a wysiwyg you need the full image path in order for the TinyMCE to render the image. I would recommend backing up the database and then running a find replace and replace on the old paths via sql: http://www.mediacollege.com/computer/database/mysql/find-replace.html

Tinymce initizlising textarea with <> tags

Tinymce editor is not rendering editor properly when the content is something like
<textarea><p><sample data></p></textarea>
i.e. <sample data>.
When I initialize a TinyMCE editor here, I dont see anything as it looks like it assumes <sample data> is an HTML tag.
Please assume I have tinymce.js loaded and I initilize using tinymce.init.
Is there a fix for this? Please let me know if it is a server side fix, or is there a tinymce.init option I could give to fix this problem.
PS: It does look like this is an HTML Entity encoding related issue but I am hardly an expert in this area.
Have a look at the tinymce config parameter entity_encoding.
If this does not work you may use this workaround
// save content
var saved_content = document.getElementById('id_of_my_textarea').innerHTML;
// init the editor
tinyMCE.execCommand('mceAddControl', false, 'id_of_my_textarea');
// after tinymce is fully initialized do
// you should use the tinymce configuration parameter "setup" rather than this code here
tinymce.get('id_of_my_textarea').setContent(saved_content);

How do I implement <pre> with tinymce

Glad to see a lot of posts about tinymce but there's nothing here that helps me with my current problem.
What I am trying to do is work out how to add "code" to my text with tinymce.
Something like this
Does anyone know how I can do this.
Help would be appreciated.
Mandy
You will need to add pre to the tinymce init setting valid_elements
You need to add to the editor the Code Sample plugin to your editor.
This is the example code to include the plugin from the TinyMCE website.
tinymce.init({
selector: "textarea", // change this value according to your HTML
plugins: "codesample",
toolbar: "codesample"
});
The codesample plugin uses http://prismjs.com/ to embed the code samples within the editor and works out of the box. That is, when a user copies valid code syntax into the editable area the code will be automatically formatted according to Prism default CSS rules.
You need to add prism.js and prism.css to your page for syntax highlighting to work.
Then you will get the code sample button in your editor interface.
Here you can find the Documentation about.

TinyMCE: Contenteditable - Paste plugin not working

I have a block of text with some of its regions editable via contentEditable property. I am using Paste plugin's paste_preprocess to cleanup the text before pasting it. But when I try it get the o.centent (the clipboard data) it returns empty.
But when I try to do the same with a completely editable section, it works fine.
Any clue?
Thanks,
Imran
Although, it has been fixed. I invite seniors to please comment on the workaround I used to make it running. Please follow the link below:
http://tinymce.moxiecode.com/forum/viewtopic.php?pid=84335#p84335

TinyMCE Removes site base url

im using TinyMCE Wysiwyg editor, and when i enter a link, or an image from the same website, it removes the base url
for example, if i enter: http://www.domain.com/somelink.php - i'll get - somelink.php
any ideas how to solve it?
thanks!
Add this few lines in your tinyMCE.init function :
convert_urls:true,
relative_urls:false,
remove_script_host:false,
(Old thread I know but in case anyone else is googling this:)
I had to set convert_urls to false as well.
I am using TinyMCE within Umbraco, so I needed to make the changes in /config/tinyMceConfig.config and then restart the website.
It's very easy to solve.
Instead of Epharion said, simply put this line in your tinyMCE.init function:
tinyMCE.init({
...
document_base_url : "http://www.site.com/path1/"
});