DokuWiki

It's better when it's simple

User Tools

Site Tools


plugin:highlight

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
plugin:highlight [2013-10-24 00:55] 194.50.240.42plugin:highlight [2024-02-12 21:14] (current) louis-ouellet
Line 2: Line 2:
  
 ---- plugin ---- ---- plugin ----
-description: Enables a simple mark-up syntax for highlighting text in various colors. +description: Enables a simple mark-up syntax for highlighting text in various colors 
-author     : Joseph Nahmias +author     : Joseph Nahmias
 email      : joe@nahmias.net email      : joe@nahmias.net
 type       : syntax type       : syntax
 lastupdate : 2013-10-24 lastupdate : 2013-10-24
-compatible : Weatherwax+compatible : Ponder Stibbons, Binky, Weatherwax, Frusterick Manners, Greebo, !Hogfather
 depends    :  depends    : 
 conflicts  conflicts 
-similar    : changemarks, emphasis, fontcolor, wrap +similar    : changemarks, emphasis, fontcolor, wrap, color 
-tags       : marking, highlight+tags       : marking, highlight, !discontinued
  
 downloadurl: https://github.com/munduch/dokuwiki-highlight/archive/master.zip downloadurl: https://github.com/munduch/dokuwiki-highlight/archive/master.zip
 +bugtracker:  https://github.com/munduch/dokuwiki-highlight/issues
 +sourcerepo:  https://github.com/munduch/dokuwiki-highlight/
 +
 +screenshot_img: :plugin:highlight_plugin.png
 ---- ----
 +FIXME: REPOSITORY NO LONGER EXIST
  
-===== Recent changes ===== 
  
-I've made security fix in function  ''_isValid'' to prevent XSS vulnerability. All unrecognized as color input now is ignored.  If you want to fix your installation, just apply the patch.--- //[[kibizoid@gmail.com|Alexander Sorkin aka Kibi]] 2009/01/22 13:01//+===== Installation =====
  
-<code php> +Please use the [[plugin:extension|extension manager]] to install the plugin.
-    // old code +
-    function _isValid($c) { +
-        $c = trim($c); +
-  +
-        $pattern = "/ +
-            ([a-zA-z]+)|                                #colorname - not verified +
-            (\#([0-9a-fA-F]{3}|[0-9a-fA-F]{6}))|        #colorvalue +
-            (rgb\(([0-9]{1,3}%?,){2}[0-9]{1,3}%?\))     #rgb triplet +
-            /x"; +
-  +
-        if (preg_match($pattern, $c)) return true; +
-  +
-        return false; +
-    }+
  
-    // new code +//Optional//  Add additional colors to your [[devel:javascript|conf/userscript.js]] file (see [[#additional_colors|below]] for more details)
-   function _isValid($c{+
  
-        $c trim($c); +===== Usage =====
-         +
-        $pattern "/ +
-            (^[a-zA-Z]+$)|                                #colorname - not verified +
-            (^\#([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$)|        #colorvalue +
-            (^rgb\(([0-9]{1,3}%?,){2}[0-9]{1,3}%?\)$)     #rgb triplet +
-            /x"; +
-         +
-        return (preg_match($pattern, $c)); +
-         +
-    }+
  
-</code> +You could type or input via the toolbar button {{https://raw.githubusercontent.com/munduch/dokuwiki-highlight/master/images/toolbar_icon.png|Color picker}} the following highlights
  
 +<code>
 +<hi cyan>named cyan highlight</hi>
  
 +<hi>default highlight with **some bold** text</hi>
  
 +<hi #e0e>3-hex magenta highlight</hi> <hi #f30>or red</hi>
 +</code>
 +which looks as
  
 +{{:plugin:highlight_plugin.png?nolink|Highlight plugin in action}}
  
 +In a highlight you cannot apply a second highlight:
 +<code>
 +<hi cyan>cyan with <hi pink>pink in the middle</hi> of the highlight</hi>
 + --- doesn't work
  
 +you <hi cyan>need to </hi><hi pink>do it</hi><hi cyan> this</hi> way
 +</code>
  
 +{{:plugin:highlight_plugin_explain.png?nolink|No nested syntax}}
  
-===== Background ===== +==== Syntax Details====
- +
-Although [[wikidesign@gmail.com|Esther Brunner]] already created a highlight +
-plugin, [[joe@nahmias.net|I]] felt it was limiting since it didn't allow the user to define +
-the color of the highlighting.  This plugin addresses that shortcoming and adds a nice +
-toolbar menu to choose from various predefined colors.  You can also customize the toolbar +
-to add additional colors if you wish. +
- +
-You can try out this plugin on [[ncc@staddle.net|Neal]]'s wiki at [[http://www.staddle.net/wiki/plugins/highlight]].  He has also packaged a version for installation via the plugin manager. FIXED :-P Version for download includes all the corrections on this page - //[[ncc@staddle.net|Neal]] 2009-11-30// +
- +
- +
- +
-===== Installation ===== +
- +
-  - Install via [[plugin:Plugin]] Manager +
-    - Visit [[http://www.staddle.net/wiki/plugins/highlight|Neal's site]] for the [[plugin:Plugin]] Manager packaged version \\ FIXME **This link doesn't work**. +
-  - Manual Installation +
-    - Create a directory ''lib/plugins/highlight'' +
-    - Place the PHP code below in a file called ''syntax.php'' in that directory +
-    - Place the JavaScript code below in a file called ''script.js'' in that directory +
-    - Create a file called ''toolbar_icon.png'' size 16x16. You can use this [[http://www.staddle.net/dokuwiki/_media/plugins/toolbar_icon.png|image]] (//not found// April 2008) -- make sure to save it as ''toolbar_icon.png'' +
-  - //Optional//  Add additional colors to your [[tips:javascript|conf/userscript.js]] file (see [[#additional_colors|below]] for more details) +
-  - Enjoy! :-) +
- +
- +
- +
-===== Syntax =====+
  
 You surround the text that you would like to highlight with the tags ''<hi //color//>'' and ''</hi>''. You surround the text that you would like to highlight with the tags ''<hi //color//>'' and ''</hi>''.
Line 99: Line 66:
  
  
-===== Example =====+===== Development =====
  
-<code> +Although [[wikidesign@gmail.com|Esther Brunner]] already created a highlight 
-<hi cyan>named cyan highlight</hi> +plugin, [[joe@nahmias.net|I]] felt it was limiting since it didn't allow the user to define 
- \\ +the color of the highlighting.  This plugin addresses that shortcoming and adds a nice 
-<hi>default highlight with **some bold** text</hi> +toolbar menu to choose from various predefined colors.  You can also customize the toolbar 
- \\ +to add additional colors if you wish.
-<hi #e0e>3-hex magenta highlight</hi> +
- \\ +
-<hi cyan>cyan with <hi pink>pink in the middle</hi> of the highlight</hi> --- doesn't work :-( +
- \\ +
- \\ +
-you <hi cyan>need to </hi><hi pink>do it</hi><hi cyan> this</hi> way +
-</code>+
  
-you <hi cyan>need to </hi><hi pink>do it</hi><hi cyan> this</hi> way+You can try out this plugin on [[ncc@staddle.net|Neal]]'s wiki at [[http://www.staddle.net/wiki/plugins/highlight]].  He has also packaged a version for installation via the plugin manager. FIXED :-P Version for download includes all the corrections on this page - //[[ncc@staddle.net|Neal]] 2009-11-30//
  
-===== Plugin ===== 
  
- +==== Changelog ====
-==== PHP ==== +
- +
-Put this code into ''lib/plugins/highlight/syntax.php'': +
- +
-<code php syntax.php> +
-<?php +
-/** +
- * Highlight Plugin: Allows user-defined colored highlighting +
- * +
- * @license    GPL 2 (http://www.gnu.org/licenses/gpl.html) +
- * @author     Joseph Nahmias <joe@nahmias.net> +
- * @link       http://www.dokuwiki.org/plugin:highlight +
- * @version    3.1 +
- */ +
- +
-if(!defined('DOKU_INC')) define('DOKU_INC',realpath(dirname(__FILE__).'/../../').'/'); +
-if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/'); +
-require_once(DOKU_PLUGIN.'syntax.php'); +
- +
-/** +
- * All DokuWiki plugins to extend the parser/rendering mechanism +
- * need to inherit from this class +
- */ +
-class syntax_plugin_highlight extends DokuWiki_Syntax_Plugin { +
- +
-    function getInfo(){  // return some info +
-        return array( +
-            'author' => 'Joseph Nahmias', +
-            'email'  => 'joe@nahmias.net', +
-            'date'   => '2006-09-06', +
-            'name'   => 'Color Highlight Plugin', +
-            'desc'   => 'Highlight text with a specific color +
-                         Syntax: <hi color>highlighted content</hi>', +
-            'url'    => 'http://www.dokuwiki.org/plugin:highlight', +
-        ); +
-    } +
- +
-     // What kind of syntax are we? +
-    function getType(){ return 'formatting';+
- +
-    // What kind of syntax do we allow (optional) +
-    function getAllowedTypes() { +
-        return array('formatting', 'substition', 'disabled'); +
-    } +
- +
-   // What about paragraphs? (optional) +
-   function getPType(){ return 'normal';+
- +
-    // Where to sort in? +
-    function getSort(){ return 90; } +
- +
- +
-    // Connect pattern to lexer +
-    function connectTo($mode) { +
-      $this->Lexer->addEntryPattern('(?i)<hi(?: .+?)?>(?=.+</hi>)',$mode,'plugin_highlight'); +
-    } +
-    function postConnect() { +
-      $this->Lexer->addExitPattern('(?i)</hi>','plugin_highlight'); +
-    } +
- +
- +
-    // Handle the match +
-    function handle($match, $state, $pos, &$handler){ +
-        switch ($state) { +
-          case DOKU_LEXER_ENTER : +
-            preg_match("/(?i)<hi (.+?)>/", $match, $color); // get the color +
-            if ( $this->_isValid($color[1]) ) return array($state, $color[1]); +
-            break; +
-          case DOKU_LEXER_MATCHED : +
-            break; +
-          case DOKU_LEXER_UNMATCHED : +
-            return array($state, $match); +
-            break; +
-          case DOKU_LEXER_EXIT : +
-            break; +
-          case DOKU_LEXER_SPECIAL : +
-            break; +
-        } +
-        return array($state, "#ff0"); +
-    } +
- +
-    // Create output +
-    function render($mode, &$renderer, $data) { +
-        if($mode == 'xhtml'){ +
-          list($state, $color) = $data; +
-          switch ($state) { +
-            case DOKU_LEXER_ENTER : +
-              $renderer->doc .= "<span style=\"background-color: $color\">"; +
-              break; +
-            case DOKU_LEXER_MATCHED : +
-              break; +
-            case DOKU_LEXER_UNMATCHED : +
-              $renderer->doc .= $renderer->_xmlEntities($color); +
-              break; +
-            case DOKU_LEXER_EXIT : +
-              $renderer->doc .= "</span>"; +
-              break; +
-            case DOKU_LEXER_SPECIAL : +
-              break; +
-          } +
-          return true; +
-        } +
-        return false; +
-    } +
- +
-    // validate color value $c +
-    // this is cut price validation - only to ensure the basic format is +
-    // correct and there is nothing harmful +
-    // three basic formats  "colorname", "#fff[fff]", "rgb(255[%],255[%],255[%])" +
-    function _isValid($c) { +
- +
-        $c = trim($c); +
-         +
-        $pattern = "/ +
-            (^[a-zA-Z]+$)|                                #colorname - not verified +
-            (^\#([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$)|        #colorvalue +
-            (^rgb\(([0-9]{1,3}%?,){2}[0-9]{1,3}%?\)$)     #rgb triplet +
-            /x"; +
-         +
-        return (preg_match($pattern, $c)); +
-         +
-    } +
-+
- +
-//Setup VIM: ex: et ts=4 sw=4 enc=utf-8 : +
-</code> +
- +
-==== JavaScript ==== +
- +
-Put this code into ''lib/plugins/highlight/script.js'': +
- +
-<code javascript script.js> +
-/* JavaScript function to create highlight toolbar in DokuwKki */ +
-/* see http://www.dokuwiki.org/plugin:highlight for more info */ +
- +
-var plugin_highlight_colors = { +
- +
-  "Yellow":      "#ffff00", +
-  "Red":         "#ff0000", +
-  "Orange":      "#ffa500", +
-  "Salmon":      "#fa8072", +
-  "Pink":        "#ffc0cb", +
-  "Plum":        "#dda0dd", +
-  "Purple":      "#800080", +
-  "Fuchsia":     "#ff00ff", +
-  "Silver":      "#c0c0c0", +
-  "Aqua":        "#00ffff", +
-  "Teal":        "#008080", +
-  "Cornflower":  "#6495ed", +
-  "Sky Blue":    "#87ceeb", +
-  "Aquamarine":  "#7fffd4", +
-  "Pale Green":  "#98fb98", +
-  "Lime":        "#00ff00", +
-  "Green":       "#008000", +
-  "Olive":       "#808000" +
- +
-}; +
- +
-function plugin_highlight_make_color_button(name, value) { +
- +
-  var btn = document.createElement('button'); +
- +
-  btn.className = 'pickerbutton'; +
-  btn.value = ' '; +
-  btn.title = name; +
-  btn.style.height = '2em'; +
-  btn.style.padding = '1em'; +
-  btn.style.backgroundColor = value; +
- +
-  var open = "<hi " + value + ">"; +
-  var close ="<\/hi>"; +
-  var sample = name + " Highlighted Text"; +
-  btn.onclick = function(){ +
-    insertTags('wiki__text',open,close,sample); +
-    return false; }; +
- +
-  return(btn); +
- +
-+
- +
-function plugin_highlight_toolbar_picker() { +
- +
-  var toolbar = document.getElementById('tool__bar'); +
-  if (!toolbar) return; +
- +
-  // Create the picker button +
-  var p_id = 'picker_plugin_highlight'; // picker id that we're creating +
-  var p_ico = document.createElement('img'); +
-  p_ico.src = DOKU_BASE + 'lib/plugins/highlight/toolbar_icon.png'; +
-  var p_btn = document.createElement('button'); +
-  p_btn.className = 'toolbutton'; +
-  p_btn.title = 'Highlight Text'; +
-  p_btn.appendChild(p_ico); +
-  p_btn.onclick = function() { +
-    showPicker(p_id,this); return false; }; +
- +
-  // Create the picker <div> +
-  var picker = document.createElement('div'); +
-  picker.className = 'picker'; +
-  picker.id = p_id; +
-  picker.style.position = 'absolute'; +
-  picker.style.display = 'none'; +
- +
-  // Add a button to the picker <div> for each of the colors +
-  for( var color in plugin_highlight_colors ) { +
-    var btn = plugin_highlight_make_color_button(color, +
-        plugin_highlight_colors[color]); +
-    picker.appendChild(btn); +
-  } +
-  if (typeof user_highlight_colors != 'undefined') { +
-    for( var color in user_highlight_colors ) { +
-      var btn = plugin_highlight_make_color_button(color, +
-          user_highlight_colors[color]); +
-      picker.appendChild(btn); +
-    } +
-  } +
- +
-  var body = document.getElementsByTagName('body')[0]; +
-  body.appendChild(picker);     // attach the picker <div> to the page body +
-  toolbar.appendChild(p_btn);   // attach the picker button to the toolbar +
-+
-addInitEvent(plugin_highlight_toolbar_picker); +
- +
-//Setup VIM: ex: et ts=2 sw=2 enc=utf-8 : +
-</code> +
- +
-==== Additional Colors  ==== +
- +
-To add more colors to the toolbar picker, add the following code to the +
-''conf/userscript.js'' file (create it if it doesn't exist already): +
- +
-<code javascript> +
-// Additional user-defined highlighting colors +
-var user_highlight_colors = { +
-  "Indian Red":  "#cd5c5c", +
-  "Khaki":       "#f0e68c", +
-  "Powder Blue": "#b0e0e6", +
-  "Sandy Brown": "#f4a460", +
-  "Steel Blue":  "#4682b4", +
-  "Thistle":     "#d8bfd8", +
-  "Yellow Green":"#9acd32", +
-  "Dark Violet": "#9400d3", +
-  "Maroon":      "#800000" +
-}; +
-</code> +
- +
-For additional colors (with names) check out the page at: [[http://www.w3schools.com/css/css_colornames.asp|W3Schools]]. +
- +
- +
-===== Changelog =====+
  
   * Version 3.1: Fix bug in IE when no user-defined colors exists; thanks [[ncc@staddle.net|Neal]]!   --- //[[joe+dokuwiki@nahmias.net|Joseph Nahmias]] 2006-09-06 15:39//   * Version 3.1: Fix bug in IE when no user-defined colors exists; thanks [[ncc@staddle.net|Neal]]!   --- //[[joe+dokuwiki@nahmias.net|Joseph Nahmias]] 2006-09-06 15:39//
Line 378: Line 87:
  
  
-===== TODO ===== +===== Additional Colors  =====
- +
-  * <del>Figure out how users can add colors to the toolbar in ''conf/userscript.js''</del> +
-  * Done?! :-) +
- +
- +
-===== Bugs ===== +
- +
-  * You can't nest highlights (anyone know how to fix this? --- I thought making the second glob greedy would help, but it doesn't :-() FIXME. +
- +
- +
- +
- +
-===== Discussion ===== +
- +
-  * __NOTE__: Please [[joe+dokuwiki@nahmias.net|email me]] if you change the page; for some reason I can't subscribe to changes... +
-  * I have modified your plugin to change only the colour of the font (not the background). I didn't want to use inline HTML because it conflicts with many other plugins (notes, styler, draw, etc.). +
-    * Here's the modified **plugins/colour/syntax.php** +
-<code php> +
-<?php +
-/** +
- * Highlight Plugin: Allows user-defined colored highlighting +
- * +
- * @license    GPL 2 (http://www.gnu.org/licenses/gpl.html) +
- * @author     Joseph Nahmias <joe@nahmias.net> +
- */ +
-  +
-if(!defined('DOKU_INC')) define('DOKU_INC',realpath(dirname(__FILE__).'/../../').'/'); +
-if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/'); +
-require_once(DOKU_PLUGIN.'syntax.php'); +
-  +
-/** +
- * All DokuWiki plugins to extend the parser/rendering mechanism +
- * need to inherit from this class +
- */ +
-class syntax_plugin_colour extends DokuWiki_Syntax_Plugin { +
-  +
-    /** +
-     * return some info +
-     */ +
-    function getInfo(){ +
-        return array( +
-            'author' => 'Joseph Nahmias', +
-            'email'  => 'joe@nahmias.net', +
-            'date'   => '2006-07-27', +
-            'name'   => 'Colour Plugin', +
-            'desc'   => 'Colour text with a specific color. Modified by alex@seidlitz.ca', +
-            'url'    => 'http://www.dokuwiki.org/plugin:highlight', +
-        ); +
-    } +
-  +
-    /** +
-     * What kind of syntax are we? +
-     */ +
-    function getType(){ +
-        return 'formatting'; +
-    } +
-  +
-    /** +
-     * What kind of syntax do we allow (optional) +
-     */ +
-    function getAllowedTypes() { +
-        return array('formatting', 'substition', 'disabled'); +
-    } +
-  +
-    /** +
-     * What about paragraphs? (optional) +
-     */ +
-   function getPType(){ +
-       return 'normal'; +
-   } +
-  +
-    /** +
-     * Where to sort in? +
-     */ +
-    function getSort(){ +
-        return 90; +
-    } +
-  +
-  +
-    /** +
-     * Connect pattern to lexer +
-     */ +
-    function connectTo($mode) { +
-      $this->Lexer->addEntryPattern('(?i)<col(?: .+?)?>(?=.+</col>)',$mode,'plugin_colour'); +
-    } +
-  +
-    function postConnect() { +
-      $this->Lexer->addExitPattern('(?i)</col>','plugin_colour'); +
-    } +
-  +
-  +
-    /** +
-     * Handle the match +
-     */ +
-    function handle($match, $state, $pos, &$handler){ +
-        switch ($state) { +
-          case DOKU_LEXER_ENTER : +
-            preg_match("/(?i)<col (.+?)>/", $match, $color); // get the color +
-            if ( $this->_isValid($color[1]) ) return array($state, $color[1]); +
-            break; +
-          case DOKU_LEXER_MATCHED : +
-            break; +
-          case DOKU_LEXER_UNMATCHED : +
-            return array($state, $match); +
-            break; +
-          case DOKU_LEXER_EXIT : +
-            break; +
-          case DOKU_LEXER_SPECIAL : +
-            break; +
-        } +
-        return array($state, "#ff0"); +
-    } +
-  +
-    /** +
-     * Create output +
-     */ +
-    function render($mode, &$renderer, $data) { +
-        if($mode == 'xhtml'){ +
-          list($state, $color) = $data; +
-          switch ($state) { +
-            case DOKU_LEXER_ENTER : +
-              $renderer->doc .= "<font color=\"$color\">"; +
-              break; +
-            case DOKU_LEXER_MATCHED : +
-              break; +
-            case DOKU_LEXER_UNMATCHED : +
-              $renderer->doc .= $renderer->_xmlEntities($color); +
-              break; +
-            case DOKU_LEXER_EXIT : +
-              $renderer->doc .= "</font>"; +
-              break; +
-            case DOKU_LEXER_SPECIAL : +
-              break; +
-          } +
-          return true; +
-        } +
-        return false; +
-    } +
-  +
-    // validate color value $c +
-    // this is cut price validation - only to ensure the basic format is +
-    // correct and there is nothing harmful +
-    // three basic formats  "colorname", "#fff[fff]", "rgb(255[%],255[%],255[%])" +
-    function _isValid($c) { +
-        $c = trim($c); +
-  +
-        $pattern = "/ +
-            ([a-zA-z]+)|                                #colorname - not verified +
-            (\#([0-9a-fA-F]{3}|[0-9a-fA-F]{6}))|        #colorvalue +
-            (rgb\(([0-9]{1,3}%?,){2}[0-9]{1,3}%?\))     #rgb triplet +
-            /x"; +
-  +
-        if (preg_match($pattern, $c)) return true; +
-  +
-        return false; +
-    } +
-+
-  +
-//Setup VIM: ex: et ts=4 enc=utf-8 : +
-</code> +
- +
- +
- +
-...and I have updated the script.js file to correspond +
-    * Here's the modified **plugins/colour/script.js** +
-<code php> +
- +
-/* javascript function to create colour toolbar in dokuwiki */ +
-/* see http://www.dokuwiki.org/plugin:colour for more info */ +
- +
-var plugin_colour_colors = { +
- +
-  "Yellow":      "#ffff00", +
-  "Red":         "#ff0000", +
-  "Orange":      "#ffa500", +
-  "Salmon":      "#fa8072", +
-  "Pink":        "#ffc0cb", +
-  "Plum":        "#dda0dd", +
-  "Purple":      "#800080", +
-  "Fuchsia":     "#ff00ff", +
-  "Silver":      "#c0c0c0", +
-  "Aqua":        "#00ffff", +
-  "Teal":        "#008080", +
-  "Cornflower":  "#6495ed", +
-  "Sky Blue":    "#87ceeb", +
-  "Aquamarine":  "#7fffd4", +
-  "Pale Green":  "#98fb98", +
-  "Lime":        "#00ff00", +
-  "Green":       "#008000", +
-  "Olive":       "#808000" +
- +
-}; +
- +
-function plugin_colour_make_color_button(name, value) { +
- +
-  var btn = document.createElement('button'); +
- +
-  btn.className = 'pickerbutton'; +
-  btn.value = ' '; +
-  btn.title = name; +
-  btn.style.height = '2em'; +
-  btn.style.padding = '1em'; +
-  btn.style.backgroundColor = value; +
- +
-  var open = "<col " + value + ">"; +
-  var close ="<\/col>"; +
-  var sample = name + " Colour Text"; +
-  btn.onclick = function(){ +
-    insertTags('wiki__text',open,close,sample); +
-    return false; }; +
- +
-  return(btn); +
- +
-+
- +
-function plugin_colour_toolbar_picker() { +
- +
-  // Check that we are editing the page - is there a better way to do this? +
-  var edbtn = document.getElementById('edbtn__save'); +
-  if (!edbtn) return; +
- +
-  var toolbar = document.getElementById('tool__bar'); +
-  if (!toolbar) return; +
- +
-  // Create the picker button +
-  var p_id = 'picker_plugin_colour';    // picker id that we're creating +
-  var p_ico = document.createElement('img'); +
-  p_ico.src = DOKU_BASE + 'lib/plugins/colour/colour_toolbar_icon.png'; +
-  var p_btn = document.createElement('button'); +
-  p_btn.className = 'toolbutton'; +
-  p_btn.title = 'Colour Text'; +
-  p_btn.appendChild(p_ico); +
-  p_btn.onclick = function() { +
-    showPicker(p_id,this); return false; }; +
- +
-  // Create the picker <div> +
-  var picker = document.createElement('div'); +
-  picker.className = 'picker'; +
-  picker.id = p_id; +
-  picker.style.position = 'absolute'; +
-  picker.style.display = 'none'; +
- +
-  // Add a button to the picker <div> for each of the colors +
-  for( var color in plugin_colour_colors ) { +
-    var btn = plugin_colour_make_color_button(color, +
-        plugin_colour_colors[color]); +
-    picker.appendChild(btn); +
-  } +
-  if (typeof user_colour_colors != 'undefined') { +
-    for( var color in user_colour_colors ) { +
-      var btn = plugin_colour_make_color_button(color, +
-          user_colour_colors[color]); +
-      picker.appendChild(btn); +
-    } +
-  } +
- +
-  var body = document.getElementsByTagName('body')[0]; +
-  body.appendChild(picker);     // attach the picker <div> to the page body +
-  toolbar.appendChild(p_btn);   // attach the picker button to the toolbar +
-+
-addInitEvent(plugin_colour_toolbar_picker); +
- +
-//Setup VIM: ex: et ts=2 sw=2 enc=utf-8 : +
- +
-</code> +
- +
-...and, finally the colour_toolbar_icon.png : (oops, can't upload the file) +
- +
- +
-=== Toolbar button missing === +
- +
-Any tips on making the toolbar button show up? Everything works, except the button isn't there. Thanks. -Richard +
-Jupp, I'm having the same problem here ... any help welcome! +
-- Kristine +
- +
-Changing script.js line 60 +
-**from:**   p_ico.src = DOKU_BASE + 'lib/plugins/highlight/toolbar_icon.png'; +
-**to:**   p_ico.src = DOKU_BASE + 'lib/plugins/highlight/images/toolbar_icon.png'; +
- +
-And placing the image inside the images folder solved the problem. +
- +
-The icon for highlighting shows in the page source when not logged in to the wiki.  +
-ADD \\  if (!document.getElementById('spell__action')) return; +
-\\ below  +
-function plugin_highlight_toolbar_picker() { +
- +
- +
-**Toolbar button isn't added to the toolbar.... ** +
- +
-==== Adding button to toolbar ==== +
- +
-Does anybody know which changes need to be made in order to have the button displayed in the toolbar? +
- +
-===Adding button to toolbar ==== +
- +
-button image is accessible but the button is not added at all at the toolbar.+
  
-==== Toolbar button still missing ====+To add more colors to the toolbar picker, add a duplicate of some blocks of ''[[https://github.com/munduch/dokuwiki-highlight/blob/master/script.js|script.js]]'' to your ''conf/userscript.js'' file (create it if it doesn't exist already):
  
-Bump! Has anybody out there been able to fix the missing toolbar button? Since I've updated to DokuWiki 2009-12-25c the button is gone (the generated HTML isn't even showing the JavaScript to insert the buttonso that's not a browser problem).+Some examples of additional user-defined highlighting colors 
 +  * "Indian Red":  "#cd5c5c", 
 +  * "Khaki":       "#f0e68c", 
 +  * "Powder Blue": "#b0e0e6", 
 +  * "Sandy Brown": "#f4a460", 
 +  * "Steel Blue":  "#4682b4", 
 +  * "Thistle":     "#d8bfd8", 
 +  * "Yellow Green":"#9acd32", 
 +  * "Dark Violet": "#9400d3", 
 +  * "Maroon":      "#800000"
  
-=== Bugfix for missing toolbar icon ===+For more additional colors (with names) check out the page at: [[http://www.w3schools.com/css/css_colornames.asp|W3Schools]].
  
-Yup, after quite a lot of debugging and finally digging into the code, it's obvious that the toolbar has changed quite a bit in recent versions. After rewriting the init function like below, everything works fine in DokuWiki 2010-11-07 ("Anteater"): 
  
-(code removed, as it breaks rendering you can find a copy in the page history, if you need a fix now.) 
  
-==== Adding button to toolbar ==== 
  
-I've added support for Weatherwax toolbar and made some new icons. The JavaScript code isn't very "DRY", but works well. Jan 
  
plugin/highlight.1382568933.txt.gz · Last modified: 2013-10-24 00:55 by 194.50.240.42

Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Share Alike 4.0 International
CC Attribution-Share Alike 4.0 International Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki