TinyMCE:FAQ
From Moxiecode Documentation Wiki
Frequently Asked Questions
Here are some common answers to common questions. If you need more help you can always visit the TinyMCE Forum on the TinyMCE web site.
I have a question, what information should I provide so that somebody can help me with an answer?
Remember: People in the forum spend their spare time to help you. So make helping you as pleasant and easy for them as possible or you might get no help at all. Tell them as many useful (= relevant) details as you can think of right in your first posting. Include possible error messages which your browser tells you (you might need to search for them depending on which browser you use). It is especially tiresome if you ask a question that has been asked many times so make sure you use the forum's search functionality before you post your problem!!
For many questions (especially for beginners' questions) an answer can be found in the documentation on the configuration settings of TinyMCE. Often people just don't know (or simply don't realise) that the solution to their problems can be found there. They just need a hint on where to look for it. Therefore it is somehow mandatory that you provide the configuration code of your TinyMCE so that others can see how you have set up your editor and which changes can help solve your problem.
Now where is this code to be found? Have a look into the HTML source code of your editor's page and look for something like this:
<!-- tinyMCE -->
<script language="javascript" type="text/javascript">
tinyMCE.init({
mode : "textareas",
theme : "advanced"
});
</script>
<!-- /tinyMCE -->
When you have found your configuration then post this JavaScript code together with your question. It makes it much easier for people to help you, and sometimes it enables people to do so in the first place!
Don't write any excuses for your English language skills! The fewest people in the forum are English native speakers so you are in good company. Bad language skills might be a good reason to work on them though, because some people can hardly describe their problem in an understandable way which makes helping them nearly impossible.
How can I upload image files from my local computer?
Short answer: You can't!
Long answer: TinyMCE is just an editor to output (X)HTML code. It is by no means comparable to web editing desktop software such as Adobe Dreamweaver, Go Live! or Microsoft Web Expressions and the like. It runs on a user's browser (client-side) and not on a server. If you want to upload pictures to a server then you need a server-side component to process your image files. TinyMCE can't do that on its own since it doesn't run on the server but on the user's browser.
However there are two commercial plugins that enable you to upload files since they come with a server-side component. These are MCImageManager and MCFileManager.
In addition, there are two Open Source plugins which accomplish this same purpose. These include IMCE and Ibrowser. Note that these are both released under the GPL, which may not be acceptable for many commercial applications.
TinyMCE is a front-end for systems that need a client-side WYSIWYG editor (like many CMSes do). You can see it like an independent component that can be integrated into an existing system.
TinyMCE is broken, what should I do?
There are a few things you should check before posting questions about your problem at the forum or sourceforge.
- Does TinyMCE work on the TinyMCE website. Then you know that TinyMCE works with your browser.
- Try to disable any other JavaScripts on the page, some scripts interfere with internal functions that TinyMCE uses. Those scripts are probably poorly written.
- Check that you haven't missed removing the last , character in your initialization code and that all the other rows have a trailing , character.
- Verify that the path/URL to TinyMCE is correct, you can use the excellent tool Fiddler for this or Firebug.
- Do not cross domain load TinyMCE or any other script unless you really really must, since this will invoke various browser security features. In other words, try placing everything on the same server.
- Don't place textareas within paragraph elements since this is not valid HTML and it will break MSIE and TinyMCE.
Paths/URL's are incorrect, I want absolute/relative URLs?
These are the different configuration scenarios for URLs within TinyMCE. There is also an example page illustrating these different options:
Relative URLs
This will convert all URLs within the same domain to relative URLs. The URLs will be relative from the document_base_url.
relative_urls : true, document_base_url : "http://www.site.com/path1/"
Example: http://www.site.com/path1/path2/file.htm >> path2/file.htm
Absolute URLs
This will convert all relative URLs to absolute URLs. The URLs will be absolute based on the document_base_url.
relative_urls : false, remove_script_host : true, document_base_url : "http://www.site.com/path1/"
Example: path2/file.htm >> /path1/path2/file.htm
Domain Absolute URLs
This will convert all relative URLs to absolute URLs. The URLs will be absolute based on the document_base_url with domain.
relative_urls : false, remove_script_host : false, document_base_url : "http://www.site.com/path1/"
Example: path2/file.htm >> http://www.site.com/path1/path2/file.htm
No URL Conversion
This option will preserve the URLs as they are in a separate attribute while editing, since browsers tend to auto convert URLs.
convert_urls : false
Example: path2/file.htm or http://www.site.com/path1/path2/file.htm will not be converted at all.
TinyMCE strip away attributes or tags from my source?
You need to check out the valid_elements and extended_valid_elements option in the configuration. By default, TinyMCE only allows certain tags and attributes. TinyMCE also tries to follow the XHTML specification as much as possible, this can cause some unexpected source changes, there are however configuration options to battle this issue, study the configuration options in details.
How do I change the default font size/face color of the editor?
We recommend that you have a look at the content_css option, this enables you to switch the CSS file TinyMCE uses for its editing area with a file with your CSS rules for font size and so forth.
How do I remove/add buttons/controls to TinyMCE?
There are quite a few options for this but a reference of all available buttons/control names can be found in the button/control reference.
TinyMCE adds BR elements to my content
No it should not, if you are using PHP, check so that you are not using nl2br() function in PHP on the posted contents.
TinyMCE produce BR elements on enter/return instead of P elements?
Here are a few reasons why BR elements and the force_br_newlines aren't enabled by default and why forced_root_block is.
- Paragraphs were invented for a reason. Try modifying paragraph margins using CSS without using paragraph tags and you see what we mean.
- The IE WYSIWYG environment is built on handling paragraphs when it comes to alignment/list management and much more. TinyMCE and other editors will start producing lots of strange results if you enable force_br_newlines.
- The space between the Paragraphs can be removed using a simple CSS trick like this. p {margin:0; padding: 0;} the same can not be done for BR elements since the whole line is not wrapped in a container. So P elements gives you the flexibility to choose.
- If you really must have BR instead of Paragraph elements for some reason, an example would be to interface with Flash or send e-mail messages, simply post process away them by replacing <p> with nothing and </p> with <br />. The same process but from BR tags to P tags can not be done since you don't have a reference for the start element.
- Paragraphs make more semantically correct XHTML markup, and we are trying to make an XHTML editor not an old HTML editor.
- Paragraphs are mostly more valid containers for text in a W3C strict environment since plain text nodes are not allowed in all containers.
- BR elements might even be deprecated in the future and replace with a more suitable element. See the XHTML 2.0 draft for details.
- BR elements can still be produced if you really need one at a specific place for some reason using Shift+Enter/Return this is exactly the same behavior popular Word processors have.
- We have never seen one single valid reason why paragraphs must not be used unless it's for e-mail software or for integration with Flash, and both cases can and should be solved with post processing if you want the user to be able to modify the contents again with TinyMCE. If you have a good reason please drop us a e-mail describing it and I will put it on my exceptions list.
So if you really really must use BR elements for some odd reason then set this in your init code:
tinyMCE.init({
forced_root_block : false,
force_br_newlines : true,
force_p_newlines : false
});
HTML output include lots of \" like <a href=\"mylink.htm\">link</a>?
This is probably because you are using PHP and it has a feature that's called magic quotes that is enabled by default. You can read more about this at the PHP documentation.
A quick way to clean up magic quotes is to use this (taken from the PHP manual):
if (get_magic_quotes_gpc()) {
function stripslashes_deep($value)
{
$value = is_array($value) ?
array_map('stripslashes_deep', $value) :
stripslashes($value);
return $value;
}
$_POST = array_map('stripslashes_deep', $_POST);
$_GET = array_map('stripslashes_deep', $_GET);
$_COOKIE = array_map('stripslashes_deep', $_COOKIE);
$_REQUEST = array_map('stripslashes_deep', $_REQUEST);
}
TinyMCE encodes < and > characters in written text?
See the next question for details.
TinyMCE removes entities from my content?
No, TinyMCE doesn't remove them it's the browser that converts them before the textarea is converted into an editor instance. This is because the contents in your textarea isn't properly entity encoded.
This is wrong, paragraphs can not be placed inside textareas check the W3C specs and the nbsp will be parsed away by the browser:
<textarea><p>1 2</p></textarea>
This is right, notice that both the nbsp and the paragraphs are now encoded:
<textarea><p>1 &nbsp; 2</p></textarea>
To do this automatically use this line in PHP:
<textarea><?php echo htmlentities($data);?></textarea>.
Loading is slow, is there a way to make it load quicker?
There is a extra package for TinyMCE called TinyMCE compressor that reduces download and initialization time dramaticly by using GZip to compress the JavaScript files.
Change default text color/editor background in TinyMCE?
You need to specify a content css file with the content_css option in order to change the default text color or background of the editor. The specified CSS is loaded after the default CSS so you can use it to override. A good idea to check the CSS status of elements is to install Firebug addon to Firefox.
Edit a full page (with <html> and <head> tags) in TinyMCE?
By default TinyMCE is only interested in your page's content which is contained within the document's <body> part. If you want to have TinyMCE edit every part of your document, especially the <head> section, then you'll need the fullpage plugin.
Can I use TinyMCE in my commercial application?
Yes you can, the LGPL license is a Free Software License. You can read the whole license here or visit Free Software Foundation web site.
Are there any restrictions to using TinyMCE in my commercial application?
Yes, all copyright notices must be intact. Moxiecode Systems are still the copyright holders of the source code, so you can not use the code in other proprietary applications. Any modifications or add-ons you make to the source has to be released according to the provisions of the LGPL, for the communitys benefit. We recommend that you always contribute your changes back to the TinyMCE community, regardless of the situation.
If you start to make a lot of revenue from using TinyMCE, please remember the time and dedication that has been put into this by other developers, respect this and give credit to those who deserve it.
I don't like LGPL, is there a commercial license available for me?
Yes, we can draw up a license for you that enables you to remove copyright restrictions or anything else you would like to have in this license agreement. Contact us through email, sales (at) moxiecode (dot) com.
Do you provide support?
We do not provide any non-commercial support outside the forum on the TinyMCE web site. Read more about commercial support on our support page.
Who made this software?
The major author of TinyMCE is Moxiecode Systems AB. Portions of the code have also been contributed by others.
