ckeditor/plugins/pbckcode/README.md
author indvd00m (gotoindvdum[at]gmail[dot]com)
Thu, 15 Dec 2016 18:10:20 +0300
changeset 0 44d330dccc59
permissions -rw-r--r--
Init sample
indvd00m@0
     1
# pbckcode
indvd00m@0
     2
indvd00m@0
     3
A CKEditor plugin to easily add code into your articles.
indvd00m@0
     4
The plugin will create a dialog where you will be able to format your code as your will. When you press the **OK** button, the plugin will create a *pre* tag with your code inside.
indvd00m@0
     5
indvd00m@0
     6
# Demo
indvd00m@0
     7
See it in action ! http://prbaron.github.com/pbckcode/
indvd00m@0
     8
indvd00m@0
     9
# Installation
indvd00m@0
    10
1. Download the plugin from the Github repository : [https://github.com/prbaron/pbckcode/tags](https://github.com/prbaron/pbckcode/tags)
indvd00m@0
    11
2. Rename it to **pbckcode** (it will be easier to call it into CKEditor)
indvd00m@0
    12
3. Place the folder into the plugins folder of CKEditor ( *{Path to CKEDitor}/plugins/* )
indvd00m@0
    13
4. Open the config.js file and add the following lines :
indvd00m@0
    14
indvd00m@0
    15
```
indvd00m@0
    16
 CKEDITOR.editorConfig = function( config ) {
indvd00m@0
    17
     // CKEDITOR TOOLBAR CUSTOMIZATION
indvd00m@0
    18
     // I only set the needed buttons, so feel frey to add those you want in the array
indvd00m@0
    19
     config.toolbarGroups = [
indvd00m@0
    20
         { name: 'pbckcode' } ,
indvd00m@0
    21
         // you other buttons here
indvd00m@0
    22
     ];
indvd00m@0
    23
indvd00m@0
    24
     // CKEDITOR PLUGINS LOADING
indvd00m@0
    25
     config.extraPlugins = 'pbckcode'; // add other plugins here (comma separated)
indvd00m@0
    26
indvd00m@0
    27
     // ADVANCED CONTENT FILTER (ACF)
indvd00m@0
    28
     // ACF protects your CKEditor instance of adding unofficial tags
indvd00m@0
    29
     // however it strips out the pre tag of pbckcode plugin
indvd00m@0
    30
     // add this rule to enable it, useful when you want to re edit a post
indvd00m@0
    31
     config.allowedContent= 'pre[*]{*}(*)'; // add other rules here
indvd00m@0
    32
indvd00m@0
    33
indvd00m@0
    34
     // PBCKCODE CUSTOMIZATION
indvd00m@0
    35
     config.pbckcode = {
indvd00m@0
    36
         // An optional class to your pre tag.
indvd00m@0
    37
         cls : '',
indvd00m@0
    38
indvd00m@0
    39
         // The syntax highlighter you will use in the output view
indvd00m@0
    40
         highlighter : 'PRETTIFY',
indvd00m@0
    41
indvd00m@0
    42
         // An array of the available modes for you plugin.
indvd00m@0
    43
         // The key corresponds to the string shown in the select tag.
indvd00m@0
    44
         // The value correspond to the loaded file for ACE Editor.
indvd00m@0
    45
         modes :  [ ['HTML', 'html'], ['CSS', 'css'], ['PHP', 'php'], ['JS', 'javascript'] ],
indvd00m@0
    46
indvd00m@0
    47
         // The theme of the ACE Editor of the plugin.
indvd00m@0
    48
         theme : 'textmate',
indvd00m@0
    49
indvd00m@0
    50
         // Tab indentation (in spaces)
indvd00m@0
    51
         tab_size : '4'
indvd00m@0
    52
     };
indvd00m@0
    53
 };
indvd00m@0
    54
```
indvd00m@0
    55
And you are good to go! You will have the same configuration than the demo.
indvd00m@0
    56
indvd00m@0
    57
# Options
indvd00m@0
    58
indvd00m@0
    59
## highlighter
indvd00m@0
    60
indvd00m@0
    61
Choose your synta highlighter output. Remove the option if you want to output a basic <pre> tag, otherwise, choose one of them.
indvd00m@0
    62
indvd00m@0
    63
```
indvd00m@0
    64
'HIGHLIGHT' // http://highlightjs.org/
indvd00m@0
    65
'PRETTIFY' // https://code.google.com/p/google-code-prettify/
indvd00m@0
    66
'PRISM' // http://prismjs.com/
indvd00m@0
    67
'SYNTAX_HIGHLIGHTER' // http://alexgorbatchev.com/SyntaxHighlighter/
indvd00m@0
    68
```
indvd00m@0
    69
indvd00m@0
    70
## modes
indvd00m@0
    71
```
indvd00m@0
    72
// Available modes
indvd00m@0
    73
['C/C++'        , 'c_pp']
indvd00m@0
    74
['C9Search'     , 'c9search']
indvd00m@0
    75
['Clojure'      , 'clojure']
indvd00m@0
    76
['CoffeeScript' , 'coffee']
indvd00m@0
    77
['ColdFusion'   , 'coldfusion']
indvd00m@0
    78
['C#'           , 'csharp']
indvd00m@0
    79
['CSS'          , 'css']
indvd00m@0
    80
['Diff'         , 'diff']
indvd00m@0
    81
['Glsl'         , 'glsl']
indvd00m@0
    82
['Go'           , 'golang']
indvd00m@0
    83
['Groovy'       , 'groovy']
indvd00m@0
    84
['haXe'         , 'haxe']
indvd00m@0
    85
['HTML'         , 'html']
indvd00m@0
    86
['Jade'         , 'jade']
indvd00m@0
    87
['Java'         , 'java']
indvd00m@0
    88
['JavaScript'   , 'javascript']
indvd00m@0
    89
['JSON'         , 'json']
indvd00m@0
    90
['JSP'          , 'jsp']
indvd00m@0
    91
['JSX'          , 'jsx']
indvd00m@0
    92
['LaTeX'        , 'latex']
indvd00m@0
    93
['LESS'         , 'less']
indvd00m@0
    94
['Liquid'       , 'liquid']
indvd00m@0
    95
['Lua'          , 'lua']
indvd00m@0
    96
['LuaPage'      , 'luapage']
indvd00m@0
    97
['Markdown'     , 'markdown']
indvd00m@0
    98
['OCaml'        , 'ocaml']
indvd00m@0
    99
['Perl'         , 'perl']
indvd00m@0
   100
['pgSQL'        , 'pgsql']
indvd00m@0
   101
['PHP'          , 'php']
indvd00m@0
   102
['Powershell'   , 'powershel1']
indvd00m@0
   103
['Python'       , 'python']
indvd00m@0
   104
['R'            , 'ruby']
indvd00m@0
   105
['OpenSCAD'     , 'scad']
indvd00m@0
   106
['Scala'        , 'scala']
indvd00m@0
   107
['SCSS/Sass'    , 'scss']
indvd00m@0
   108
['SH'           , 'sh']
indvd00m@0
   109
['SQL'          , 'sql']
indvd00m@0
   110
['SVG'          , 'svg']
indvd00m@0
   111
['Tcl'          , 'tcl']
indvd00m@0
   112
['Text'         , 'text']
indvd00m@0
   113
['Textile'      , 'textile']
indvd00m@0
   114
['XML'          , 'xml']
indvd00m@0
   115
['XQuery'       , 'xq']
indvd00m@0
   116
['YAML'         , 'yaml']
indvd00m@0
   117
```
indvd00m@0
   118
indvd00m@0
   119
## theme
indvd00m@0
   120
indvd00m@0
   121
```
indvd00m@0
   122
// Bright themes
indvd00m@0
   123
'chrome'
indvd00m@0
   124
'clouds'
indvd00m@0
   125
'crimson_editor'
indvd00m@0
   126
'dawn'
indvd00m@0
   127
'dreamweaver'
indvd00m@0
   128
'eclipse'
indvd00m@0
   129
'github'
indvd00m@0
   130
'solarized_light'
indvd00m@0
   131
'textmate' // default theme
indvd00m@0
   132
'tomorrow'
indvd00m@0
   133
'xcode'
indvd00m@0
   134
'kuroir'
indvd00m@0
   135
'katzenmilch'
indvd00m@0
   136
```
indvd00m@0
   137
indvd00m@0
   138
```
indvd00m@0
   139
// Dark themes
indvd00m@0
   140
'ambiance'
indvd00m@0
   141
'chaos'
indvd00m@0
   142
'clouds_midnight'
indvd00m@0
   143
'cobalt'
indvd00m@0
   144
'idle_fingers'
indvd00m@0
   145
'kr_theme'
indvd00m@0
   146
'merbivore'
indvd00m@0
   147
'merbivore_soft'
indvd00m@0
   148
'mono_industrial'
indvd00m@0
   149
'monokai'
indvd00m@0
   150
'pastel_on_dark'
indvd00m@0
   151
'solarized_dark'
indvd00m@0
   152
'terminal'
indvd00m@0
   153
'tomorrow_night'
indvd00m@0
   154
'tomorrow_night_blue'
indvd00m@0
   155
'tomorrow_night_bright'
indvd00m@0
   156
'tomorrow_night_eighties'
indvd00m@0
   157
'twilight'
indvd00m@0
   158
'vibrant_ink'
indvd00m@0
   159
```
indvd00m@0
   160
indvd00m@0
   161
# Special Thanks
indvd00m@0
   162
indvd00m@0
   163
  * CKEditor : [http://ckeditor.com/](http://ckeditor.com/)
indvd00m@0
   164
  * ACE : [http://ace.ajax.org/](http://ace.ajax.org/)
indvd00m@0
   165
  * Lea Verou : [http://prismjs.com/](http://prismjs.com/)
indvd00m@0
   166
  * Google : [https://code.google.com/p/google-code-prettify/](https://code.google.com/p/google-code-prettify/)
indvd00m@0
   167
  * Ivan Sagalaev : [http://highlightjs.org/](http://highlightjs.org/)
indvd00m@0
   168
  * Alex Gorbatchev : [http://alexgorbatchev.com/SyntaxHighlighter/](http://alexgorbatchev.com/SyntaxHighlighter/)
indvd00m@0
   169
indvd00m@0
   170
# Credits
indvd00m@0
   171
#### Pierre Baron
indvd00m@0
   172
Website : [http://www.pierrebaron.fr](http://www.pierrebaron.fr)
indvd00m@0
   173
Twitter : [@prbaron](https://twitter.com/prbaron)
indvd00m@0
   174
Contact : <prbaron22@gmail.com>