Dominus77 / yii2-tinymce-widget

TinyMCE 4 widget for Yii2.
MIT License
8 stars 0 forks source link

Do you plan to include the plugs for "code syntax highlighter" ? #5

Closed polinwei closed 6 years ago

polinwei commented 6 years ago

Hi Sir: Do you plan to include the plugs for "code syntax highlighter" ?

Ref: http://alexgorbatchev.com/SyntaxHighlighter/

Dominus77 commented 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',
    //...
],
polinwei commented 6 years ago

If I want show the line number? How to configure?

http://prismjs.com/plugins/line-numbers

Dominus77 commented 6 years ago

This already applies to the settings of the TinyMCE itself, you need to look at the documentation.

polinwei commented 6 years ago

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.

Dominus77 commented 6 years ago

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.

Dominus77 commented 6 years ago

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.

polinwei commented 6 years ago

Yes , It is more difficult. I just a normal user... ^^|||

Dominus77 commented 6 years ago

In general, then having studied the documentation for TinyMCE is not very difficult) https://www.tinymce.com/docs/advanced/creating-a-plugin/

polinwei commented 6 years ago

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.

Dominus77 commented 6 years ago

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.

Dominus77 commented 6 years ago

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.

polinwei commented 6 years ago

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.

polinwei commented 6 years ago

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'], ]) ?>

Dominus77 commented 6 years ago

https://github.com/Dominus77/SyntaxHighlighter

polinwei commented 6 years ago

Excellent !! I really want to learn how to write...