Closed polinwei closed 6 years ago
Look it up: https://www.tinymce.com/docs/plugins/codesample/ Not a bad plug-in and do not invent anything)
'clientOptions' => [
//...
'codesample_languages' => [
['text' => 'PHP', 'value' => 'php'],
//...
],
'codesample_content_css' => '/css/prism.css',
//...
],
If I want show the line number? How to configure?
This already applies to the settings of the TinyMCE itself, you need to look at the documentation.
I following the http://archive.tinymce.com/forum/viewtopic.php?id=33335 & http://lab.nomadonweb.com/en/sh4tinymce. I can using SH4TinyMCE - code Editor , after saved . I did not see the line numbers.
Yes, I saw this topic. Line numbers are formed using js. TinyMCE does not support running scripts inside its frame for security purposes. You can connect only CSS and numbers will be formed only on the finished page.
Or else as an option, write a plug-in that, before inserting the code, will run the text through itself and generate line numbers, then paste in the editor field. By the way, this solution is more suitable but also more difficult.
Yes , It is more difficult. I just a normal user... ^^|||
In general, then having studied the documentation for TinyMCE is not very difficult) https://www.tinymce.com/docs/advanced/creating-a-plugin/
I find the document : https://bar-data.com/blog/yii2/example-use-syntaxhighlighter-in-yii2 But I don't know what he say? It seems it will be workable.
https://lab.nomadonweb.com/en/sh4tinymce/demo Link to the demo. As you can see, there are no line numbers in the editor, only the code, and the result on the right. sh4tinymce only wraps the code in tags and puts the necessary brushes for SyntaxHighlighter.
In general, why do you need line numbers in the editor itself?) For an approximate viewing, you can connect css this is enough, and the full version with numbers is displayed on the finished page.
Sorry, This is my fault, I did not make it clear. I don't need line numbers in the editor itself. I can not see the line number in finished page.
It is my way to show content " 'content:html'" as below
<?= DetailView::widget([ 'model' => $model, 'attributes' => [ 'id', 'title', 'content:html', 'tags:ntext', ['label'=>'status', 'value'=>$model->status0->name, ], ['attribute' =>'create_time', 'value' => date('Y-m-d H:i:s',$model->create_time), ], ['attribute' =>'update_time', 'format' => ['datetime', 'php:Y-m-d H:i:s'] ], ['attribute' => 'author_id', 'value' => $model->author->nickname, ] ], 'template'=>'<tr><th style="width:120px;">{label}</th><td>{value}</td></tr>', 'options' => ['class' => 'table table-striped table-bordered detail-view'], ]) ?>
Excellent !! I really want to learn how to write...
Hi Sir: Do you plan to include the plugs for "code syntax highlighter" ?
Ref: http://alexgorbatchev.com/SyntaxHighlighter/