Dies ist eine alte Version des Dokuments!
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:
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.