Embed php js html code in tinymce, posible?

倾然丶 夕夏残阳落幕 提交于 2019-12-06 11:27:58

问题


I have been looking a lot for it but haven't found anithing...

(i want just some editor -i know the same it's hard to get done- like the one i'm using now, where i can share my code in my blog)(My own CMS)

So,

I guess some went through this one before, can i embed code using tinyMce?

any conclusion?

thanks a lot

PD: i've seen that stackoverflow uses a fork from WMD wich is not online but in github, anyone has an example of use? (only .js files there)

PD2: thanks a lot, again!

EDIT

Well, after some replies got to prettyprint -> here

wich only need to be loaded on $(document).ready() And will prettify (lol) any of those:

<pre class="prettyprint"> code here  </pre>

So i'm trying to add this format to tinimce with:

style_formats : [
                {title : 'Bold text', inline : 'b'},
                {title : 'Blue text', inline : 'span', styles : {color : '#006'}},
                {title : 'Blue header', block : 'h1', styles : {color : '#006'}},
          -->   {title : 'Codigo fuente', inline : 'pre', classes : 'prettyprint'},    
                {title : 'Example 2', inline : 'span', classes : 'example2'},
                {title : 'Table styles'},
                {title : 'Table row 1', selector : 'tr', classes : 'tablerow1'}
        ],

But if i use it turns into a <p> on $_POST, why?

Edit two

this one works: {title : 'Codigo fuente', block : 'pre', classes : 'prettyprint'},

The problem it's that i get

<pre ..>line 1</pre>
<pre ..>line 2</pre> 

..

and i would like to apply:

<pre..>
line1 
line2
</pre>

how can i solve this? if i change block by inline, simply the style it's not even applied :?

Gracias!


回答1:


EDIT: sorry for the improper placement, Still kind of new here. As far as I know you can past code straight into tinymce and it won't interpret it. When it stores it it should add all the necessary escapes so when it's displayed on your blog or whatever it will look liek code. What it won't do it automatically format it in a nice read friendly fashion and add coloring and such. I imagine there must be a plugin or some alternative for that... bbiam :P

EDIT2: this -> http://www.maclovin.de/syntaxhl-editor/ seems like a good option.

download - > https://github.com/RichGuk/syntaxhl

EDIT3: also this might be nice as well -> http://code.google.com/p/google-code-prettify/ Makes the code all nice and pretty, hence the name.

ORIGINAL:I'm a bit confused, do you want code you put into tiny MCE to be active code or do you want it to be code samples?

<A href="www.google.com">google</a>

or http://www.google.com




回答2:


Maybe, you can use this one: SyntaxHighlighter or some other syntax highlighter...

And use the forum/website of tinymce, because your question is related to tinymce. Read the manual. Look for plugins and the implementation of them.

Hint: Search first in the Resources of the developers or use google... Google Results



来源:https://stackoverflow.com/questions/5501270/embed-php-js-html-code-in-tinymce-posible

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!