plugin:fontfamily
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
plugin:fontfamily [2010-03-20 16:07] – partly reverted compatibility info ach | plugin:fontfamily [2023-12-16 18:49] (current) – Aleksandr | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== | + | ====== |
---- plugin ---- | ---- plugin ---- | ||
Line 6: | Line 6: | ||
email : thorsten.stratmann@web.de | email : thorsten.stratmann@web.de | ||
type : syntax | type : syntax | ||
- | lastupdate : 2009-02-04 | + | lastupdate : 2019-03-19 |
- | compatible : 2005-07-01 - 2009-12-25 | + | compatible : Anteater, Rincewind, Angua, Adora Belle, Weatherwax, Binky, Ponder Stibbons, Greebo |
depends | depends | ||
conflicts | conflicts | ||
- | similar | + | similar |
tags : typography | tags : typography | ||
+ | |||
+ | downloadurl: | ||
+ | bugtracker : # https:// | ||
+ | sourcerepo : # https:// | ||
---- | ---- | ||
===== Download and Installation ===== | ===== Download and Installation ===== | ||
- | Download | + | Search |
- | + | ||
- | * [[http:// | + | |
- | + | ||
- | + | ||
- | + | ||
- | ===== Examples ===== | + | |
- | + | ||
- | [[http:// | + | |
+ | * ver. 2019: [[https:// | ||
+ | * ver. 2012 (0.3): [[https:// | ||
===== Description ===== | ===== Description ===== | ||
- | Change | + | Select |
- | To change the fontfamily , mark the text that you would like to change. | + | The result is: |
- | Then click on the button fontfamily and choose one of the predefined styles. | + | |
- | The result is: <ff fontfamily> | + | |
- | + | Code based on the [[plugin: | |
- | ===== Code ===== | + | |
- | code based on the plugin highlight http:// | + | |
- | + | ||
- | + | ||
- | ==== syntax.php==== | + | |
- | + | ||
- | Put this code into '' | + | |
- | + | ||
- | + | ||
- | <code php> | + | |
- | <?php | + | |
- | <?php | + | |
- | /** | + | |
- | * fontfamily Plugin: control the font-family of your text | + | |
- | * | + | |
- | * @license | + | |
- | * @author | + | |
- | * @link http:// | + | |
- | * @version | + | |
- | */ | + | |
- | + | ||
- | if(!defined(' | + | |
- | if(!defined(' | + | |
- | require_once(DOKU_PLUGIN.' | + | |
- | + | ||
- | /** | + | |
- | * All DokuWiki plugins to extend the parser/ | + | |
- | * need to inherit from this class | + | |
- | */ | + | |
- | class syntax_plugin_fontfamily extends DokuWiki_Syntax_Plugin { | + | |
- | + | ||
- | function getInfo(){ | + | |
- | return array( | + | |
- | ' | + | |
- | ' | + | |
- | ' | + | |
- | ' | + | |
- | ' | + | |
- | | + | |
- | ' | + | |
- | ); | + | |
- | } | + | |
- | + | ||
- | // What kind of syntax are we? | + | |
- | function getType(){ return ' | + | |
- | + | ||
- | // What kind of syntax do we allow (optional) | + | |
- | function getAllowedTypes() { | + | |
- | return array(' | + | |
- | } | + | |
- | + | ||
- | // What about paragraphs? (optional) | + | |
- | | + | |
- | + | ||
- | // Where to sort in? | + | |
- | function getSort(){ return 92; } | + | |
- | + | ||
- | + | ||
- | // Connect pattern to lexer | + | |
- | function connectTo($mode) { | + | |
- | $this-> | + | |
- | } | + | |
- | function postConnect() { | + | |
- | $this-> | + | |
- | } | + | |
- | + | ||
- | + | ||
- | // Handle the match | + | |
- | function handle($match, | + | |
- | { | + | |
- | switch ($state) | + | |
- | { | + | |
- | case DOKU_LEXER_ENTER : | + | |
- | preg_match("/ | + | |
- | if ( $this-> | + | |
- | break; | + | |
- | case DOKU_LEXER_MATCHED : | + | |
- | break; | + | |
- | case DOKU_LEXER_UNMATCHED : | + | |
- | return array($state, | + | |
- | break; | + | |
- | case DOKU_LEXER_EXIT : | + | |
- | break; | + | |
- | case DOKU_LEXER_SPECIAL : | + | |
- | break; | + | |
- | } | + | |
- | return array($state, | + | |
- | } | + | |
- | + | ||
- | // Create output | + | |
- | function render($mode, | + | |
- | if($mode == ' | + | |
- | list($state, | + | |
- | switch ($state) { | + | |
- | case DOKU_LEXER_ENTER : | + | |
- | $renderer-> | + | |
- | break; | + | |
- | case DOKU_LEXER_MATCHED : | + | |
- | break; | + | |
- | case DOKU_LEXER_UNMATCHED : | + | |
- | $renderer-> | + | |
- | break; | + | |
- | case DOKU_LEXER_EXIT : | + | |
- | $renderer-> | + | |
- | break; | + | |
- | case DOKU_LEXER_SPECIAL : | + | |
- | break; | + | |
- | } | + | |
- | return true; | + | |
- | } | + | |
- | return false; | + | |
- | } | + | |
- | function _isValid($c) { | + | |
- | + | ||
- | $c = trim($c); | + | |
- | + | ||
- | $pattern = "/ | + | |
- | + | ||
- | // if (preg_match($pattern, | + | |
- | return true; | + | |
- | } | + | |
- | } | + | |
- | </ | + | |
- | + | ||
- | ==== script.js==== | + | |
- | + | ||
- | Put this code into '' | + | |
- | + | ||
- | <code javascript> | + | |
- | /* javascript function to create fontfamily toolbar in dokuwiki */ | + | |
- | /* see http:// | + | |
- | + | ||
- | var plugin_fontfamily = { | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | }; | + | |
- | + | ||
- | if (isUndefined(user_fontfamily)) { | + | |
- | var user_fontfamily = { }; | + | |
- | } | + | |
- | + | ||
- | function plugin_fontfamily_make_fontfamily_button(name, | + | |
- | + | ||
- | var b_id = name; // picker id that we're creating | + | |
- | var b_ico = document.createElement(' | + | |
- | b_ico.src = DOKU_BASE + ' | + | |
- | var btn = document.createElement(' | + | |
- | + | ||
- | btn.className = ' | + | |
- | btn.value = value; | + | |
- | btn.title = name; | + | |
- | btn.style.height = ' | + | |
- | btn.style.padding = ' | + | |
- | btn.name = value; | + | |
- | btn.appendChild(b_ico); | + | |
- | + | ||
- | var open = "< | + | |
- | var close ="< | + | |
- | var sample = name + " Fontfamily"; | + | |
- | + | ||
- | eval(" | + | |
- | + jsEscape(' | + | |
- | + jsEscape(open) + "','" | + | |
- | + jsEscape(close) + "','" | + | |
- | + jsEscape(sample) + "' | + | |
- | ); | + | |
- | + | ||
- | return(btn); | + | |
- | + | ||
- | } | + | |
- | + | ||
- | function plugin_fontfamily_toolbar_picker() { | + | |
- | + | ||
- | // Check that we are editing the page - is there a better way to do this? | + | |
- | var edbtn = document.getElementById(' | + | |
- | if (!edbtn) return; | + | |
- | + | ||
- | var toolbar = document.getElementById(' | + | |
- | if (!toolbar) return; | + | |
- | + | ||
- | // Create the picker button | + | |
- | var p_id = ' | + | |
- | var p_ico = document.createElement(' | + | |
- | p_ico.src = DOKU_BASE + ' | + | |
- | var p_btn = document.createElement(' | + | |
- | p_btn.className = ' | + | |
- | p_btn.title = ' | + | |
- | p_btn.appendChild(p_ico); | + | |
- | eval(" | + | |
- | + p_id + "', | + | |
- | + | ||
- | // Create the picker < | + | |
- | var picker = document.createElement(' | + | |
- | picker.className = ' | + | |
- | picker.id = p_id; | + | |
- | picker.style.position = ' | + | |
- | picker.style.display = ' | + | |
- | + | ||
- | /// Add a button to the picker <div> for each of the colors | + | |
- | for( var ff in plugin_fontfamily ) { | + | |
- | if (!isFunction(plugin_fontfamily[ff])) { | + | |
- | var btn = plugin_fontfamily_make_fontfamily_button(ff, | + | |
- | plugin_fontfamily[ff]); | + | |
- | picker.appendChild(btn); | + | |
- | } | + | |
- | } | + | |
- | + | ||
- | + | ||
- | + | ||
- | var body = document.getElementsByTagName(' | + | |
- | body.appendChild(picker); | + | |
- | toolbar.appendChild(p_btn); | + | |
- | } | + | |
- | + | ||
- | addInitEvent(plugin_fontfamily_toolbar_picker); | + | |
- | + | ||
- | //Setup VIM: ex: et ts=2 sw=2 enc=utf-8 : | + | |
- | + | ||
- | </ | + | |
- | + | ||
- | + | ||
- | + | ||
- | ===== Images ===== | + | |
- | + | ||
- | Additionally you need the images, displayed by clicking the fontfamily Button. | + | |
- | Please obtain this images from the installation packet. | + | |
===== Changelog ===== | ===== Changelog ===== | ||
- | * Version 0.1: Created | + | |
- | + | | |
- | ===== Wishlist ===== | + | * Version 0.1: Created |
- | + | ||
- | * | + | |
- | + | ||
===== Bugs ===== | ===== Bugs ===== | ||
- | * | + | * Click on icon make automatic saving comment in Discussion |
- | + | * Don't use toolbar in Discussion... | |
- | ===== Discussion | + | |
- | + | ||
- | | + | |
plugin/fontfamily.1269097642.txt.gz · Last modified: 2010-03-20 16:07 by ach