|
| 1 | +TinyMCE WYSIWYG Editor Tutorial |
| 2 | +===================================== |
| 3 | + |
| 4 | +Insert Code-Snippets |
| 5 | +---------------------------------------- |
| 6 | + |
| 7 | +EnlighterJS provides a full TinyMCE editor integration via [EnlighterJS/Plugin.TinyMCE](https://github.com/EnlighterJS/Plugin.TinyMCE). This allows you to add/edit code to your content seemlessly. |
| 8 | + |
| 9 | +The examples on this page are showing the editor plugin added to WordPress via [Enlighter Plugin](https://wordpress.org/plugins/enlighter/) - it also works standalone! |
| 10 | + |
| 11 | +### Example ### |
| 12 | + |
| 13 | + |
| 14 | + |
| 15 | +[EnlighterJS TinyMCE Live-Demo](https://tinymce.enlighterjs.org/) |
| 16 | + |
| 17 | +### Steps ### |
| 18 | + |
| 19 | +1. Move the Cursor to the position you want to insert the code snippet |
| 20 | +2. Click on the `Enlighter Code Insert` Button on the upper right of the toolbar |
| 21 | +3. Paste your snippet into the text-area |
| 22 | +4. Select the language of your snippet (javascript in this example) |
| 23 | +5. Select "Left-Align-Indentation" - this will strip the unnecessary code indentation (marked in the example) |
| 24 | +6. Click **OK** |
| 25 | +7. You can edit the snippet directly in the Visual Editor at any time |
| 26 | +8. Publish your post! |
| 27 | + |
| 28 | +Use Editor-Formats to highlight existing code |
| 29 | +------------------------------------------------------ |
| 30 | + |
| 31 | +Sometime you already have some code within your posts you want to highlight. In this case Enlighter comes with its own **Formats** which allows you to highlight a selected text in the Visual Editor. |
| 32 | + |
| 33 | +### Example ### |
| 34 | + |
| 35 | + |
| 36 | + |
| 37 | +### Steps ### |
| 38 | + |
| 39 | +1. Expand the Editor Toolbar |
| 40 | +2. Select the content you want to highlight |
| 41 | +3. Goto `Formats -> Enlighter Codeblocks` and select the language |
| 42 | +4. Publish your post! |
| 43 | + |
| 44 | + |
| 45 | +Align your code with <kbd>tab</kbd> key |
| 46 | +------------------------------------------------------ |
| 47 | + |
| 48 | +Enlighter 3.5 comes with its own tab-alignment addon which allows you to align your code directly within the editor (optional feature). |
| 49 | + |
| 50 | +**Requirement**: Set `Enlighter -> Editing -> Visual Editor -> Tweaks -> Enable Tab Indentation` |
| 51 | + |
| 52 | +* Move Right: Select code + press <kbd>tab</kbd> key |
| 53 | +* Move Left: Select code + press <kbd>shift</kbd>+<kbd>tab</kbd> key |
| 54 | + |
| 55 | + |
| 56 | + |
| 57 | + |
| 58 | + |
| 59 | +Use Inline Code Highlighting |
| 60 | +------------------------------------------------------ |
| 61 | + |
| 62 | +Enlighter allows you to highlight codeblocks as well as **inline snippets** out-of-the-box. Inline-Code is often used to highlight small pieces of code diretly within a larger textblock. |
| 63 | + |
| 64 | +### Example ### |
| 65 | + |
| 66 | + |
| 67 | + |
| 68 | +### Steps ### |
| 69 | + |
| 70 | +1. Expand the Editor Toolbar |
| 71 | +2. Select the content you want to highlight |
| 72 | +3. Goto `Formats -> Enlighter Inline` and select the language |
| 73 | +4. Publish your post! |
| 74 | + |
| 75 | + |
| 76 | +Change Code Settings / Advanced Code Settings |
| 77 | +------------------------------------------------------ |
| 78 | + |
| 79 | +Sometime you may need some advanced features like |
| 80 | + |
| 81 | +* Disable Linenumbers |
| 82 | +* Change Theme of a individual codeblock |
| 83 | +* Set a linenumber offset |
| 84 | +* Highlight special lins |
| 85 | +* Create Codegroups |
| 86 | + |
| 87 | +this settings are available after the code-snippet has been added to the editor by using the `Enlighter Code Settings` Button |
| 88 | + |
| 89 | +### Example ### |
| 90 | + |
| 91 | + |
| 92 | + |
| 93 | +### Steps ### |
| 94 | + |
| 95 | +1. Move the Cursor into an existing Enlighter Codeblock (or inline) |
| 96 | +2. The `Enlighter Code Settings` Button will appear on the upper right side of the codeblock **and** on the upper right of the toolbar |
| 97 | +3. Click on the `Enlighter Code Settings` Button |
| 98 | +4. An advanced settings dialog will be opened |
| 99 | +5. Change the Theme |
| 100 | +6. Set a linenumber-offset |
| 101 | +7. Highlight a special line |
| 102 | +8. Click **OK** |
| 103 | +9. Publish your post! |
| 104 | + |
| 105 | +Codegroups |
| 106 | +------------------------------------------------------ |
| 107 | + |
| 108 | +In some cases, your code example rely on a several different languages. For example **HTML**, **CSS** and **Javascript**. It can be helpful to group this snippets together. |
| 109 | + |
| 110 | +### Example ### |
| 111 | + |
| 112 | + |
| 113 | + |
| 114 | +### Steps ### |
| 115 | + |
| 116 | +1. Add some code snippets to your post |
| 117 | +2. Click on the `Enlighter Code Settings` Button to edit a codeblock |
| 118 | +3. Add a `Codegroup Identifier` to each codeblock you want to group together (has to be **unique** for each group) |
| 119 | +4. Add an optional `Codegroup Title` to each codeblock - its used as the tabname |
0 commit comments