Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Greyhound 102 posts 124 karma points
    Apr 01, 2011 @ 12:46
    Greyhound
    0

    Embedding code in TinyMCE

    Hi,

    I'm running 4.6 and just starting to post a few blogs. Some of them contain code examples and I'd like to embed these into the rich text editor in TinyMCE.

    Thus far I am unable to find a walk through on this. Can anyone point me in the direction of an example?

    This is pretty standard functionality so I'm surprised I am unable to find anything concrete.

    Thanks.

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    Apr 01, 2011 @ 15:27
    Jan Skovgaard
    0

    Hi Greyhound

    You can't do this with the default configuration of TinyMce. I guess you could try to disable tidy in the umbracoSetting.config file.

    There are some downsides to this though. For instance all kind of bad markup is allowed in there without being stripped.

    Something in the back of my mind tells me that there has been made some clever workaround for this but must admit I can't remember right now.

    Another approach could be to make a Codesnippet repository where you create a folder in the content tree at the root level and then create a document type called "Codesnippet" and add a textfield multiple property to it where you can paste the code as you like.

    Then you can create a macro based on XSLT for instance and then give it a parameter of contentPicker, which makes it possible for you to select the codesnippet you wish to place in your text through a macro.

    Does this make sense?

    /Jan

  • Greyhound 102 posts 124 karma points
    Apr 06, 2011 @ 16:12
    Greyhound
    0

    Hi Jan,

    Thank you kindly for the information.

    The approach you suggest does make sense, its not ideal from an end user perspective but as its for my own site I can cope with that!

    Thanks again.

  • Tom Fulton 2030 posts 4998 karma points c-trib
    Apr 06, 2011 @ 19:03
    Tom Fulton
    0

    Hi,

    I thought I saw a post on this recently but I can't seem to find it.

    Another alternative might be to find a TinyMCE plugin that's already created for this and add it to Umbraco.  There's a wiki article on how to Add YouTube Button to TinyMCE - the same steps can be used to add any plugin.

    I did see one Insert Code plugin that looks promising, RJ_InsertCode.  The only thing is it requires PHP which I don't have on my dev machine so I'm not able to fully test at the moment, but it looks like it would work.  If you do end up trying, one thing I ran into is you need to copy/rename editor_plugin.js to editor_plugin_src.js

    Hope this might help,
    Tom

Please Sign in or register to post replies

Write your reply to:

Draft