Toolbar

To add a button on the edit-toolbar: — Gerald Nasenbrecher 2016/01/19 11:44 (newer versions of DokuWiki)

To add a buttom for < code> edit /inc/tooblbar.php Add to the array (eg. after the last one with the signature sig.png)

           array(
                'type'   => 'format',
                'title'  => 'Code',
                'icon'   => 'eek.png',
                'open'   => '\n<code>\n',
                'close'  => '\n<//code>\n'
                ),

( < slash code> SHOULD BE A SINGE / !!!)

Save. Nothing happens. This is because of the caches of the javascript. To clean cache, call: https://gerwiki.de/lib/exe/js.php?purge=true

Clean the browser-cache too (by shift-reload to force reload).

Done.

Alt:

Um einen Button bei der Editpage oben hinzuzufügen:

Quelle1)

zh-tw Table of Contents Adding your own button to the toolbar userscript.js examples Discussion Icons Adding your own button to the toolbar The toolbar is completely built through JavaScript. Which buttons the toolbar contains, is read from an array called toolbar which is created from the defines in the inc/toolbar.php. To add your own button, you can simply enhance the toolbar array in your conf/userscript.js file(you need to create this file). Eg. if you want a button for the subscript syntax, just place a button image into the lib/images/toolbar folder and add the following code to conf/userscript.js:

if(toolbar){
  toolbar[toolbar.length] = {"type":"format",
                             "title":"Subscripted Text",
                             "icon":"subscript.png",
                             "key":"",
                             "open":"<sub>",
                             "close":"</sub>"};
}

Button types:

  • format - If there is a selection this wraps it with the open and close strings, else it inserts the title.
  • insert - Simple string insertion. insert.
  • picker - Displays the picker with mutiple insertion selections. Populated by array or assosiative array(iconified) list and optional icobase.
  • mediapopup - opens the media manager. Probably not useful for you
  • signature - inserts the signature. Probably not useful for you
if(window.toolbar!=undefined){
 
  /* format: subscript */
  toolbar[toolbar.length] = {"type":"format",
                             "title":"Subscript Text",
                             "icon":"text_subscript.png",
                             "key":"",
                             "open":"<sub>",
                             "close":"</sub>"};
 
  /* insert: footnote */
  toolbar[toolbar.length] = {"type":"format",
                             "title":"Footnote",
                             "icon":"asterisk_yellow.png",
                             "key":"",
                             "insert":"((footnote))",   
 
  /* picker: notes plugin ICONIFIED*/
  var notes_arr = new Array(); /* array[key]= insertion string , value = icon filename. */
  notes_arr['<note></note>\\n']='note.png';
  notes_arr['<note tip></note>\\n']='tip.png';
  notes_arr['<note important></note>\\n']='important.png';
  notes_arr['<note warning></note>\\n']='warning.png';
 
  toolbar[toolbar.length] = {"type":"picker",
                             "title":"Notes",
                             "icon":"note.png",
                             "key":"",
                             "list": notes_arr,
                             "icobase":"notes"}; /* subdir of lib/images/ where images found.*/
 
 
  /* picker: sample TEXT ONLY (like special chars) */
 
  toolbar[toolbar.length] = {"type":"picker",
                             "title":"Bunch o strings",
                             "icon":"stuff.png",
                             "key":"",
                             "list": Array('A','B','C'),
                             };
}

If anyone knows a way to insert a button instead of adding it at the end would be great…

This can be done by editing the inc/toolbar.php file directly. Around line 27, you will find the following code:

    $menu = array(
       array(
            'type'   => 'format',
            'title'  => $lang['qb_bold'],
            'icon'   => 'bold.png',
            'key'    => 'b',
            'open'   => '**',
            'close'  => '**',
            ),
       array(
            'type'   => 'format',
            'title'  => $lang['qb_italic'],
            'icon'   => 'italic.png',
       ...

To add a button which inserts the text “Hi there”, add a new array element like so:

    $menu = array(
       array(
            'type'   => 'insert',
            'title'  => "Insert 'hello there'",
            'icon'   => 'helloThere.png',
            'insert' => 'Hello there!\n',
            ),
       array(
            'type'   => 'format',
            'title'  => $lang['qb_bold'],
            'icon'   => 'bold.png',
            'key'    => 'b',
            'open'   => '**',
            'close'  => '**',
            ),
       array(
            'type'   => 'format',
            'title'  => $lang['qb_italic'],
            'icon'   => 'italic.png',
       ...

Note that you can use \n for a new line…

Also note that when playing around with it, cacheing was tricky. I had to keep manually deleting the cached version of the file.

 
Nach oben
dokuwiki/button.txt · Zuletzt geändert: 2016/01/19 11:52 von gerald
chimeric.de = chi`s home Creative Commons License Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0
DFmW2CEce3htPL1uNQuHUVu4Tk6WXigFQp   Dogecoin Donations Accepted Here    DFmW2CEce3htPL1uNQuHUVu4Tk6WXigFQp  DFmW2CEce3htPL1uNQuHUVu4Tk6WXigFQp