3 * requires installation into themes/default/htmlarea3/
4 * MSIE => 5.5, Mozilla >= 1.3
10 require_once("lib/WysiwygEdit.php");
12 class WysiwygEdit_htmlarea3 extends WysiwygEdit {
14 function Head($name='edit[content]') {
16 $WikiTheme->addMoreAttr('body'," onload='initEditor()'");
17 //Todo: language selection from available lang/*.js files
19 <script type="text/javascript" src="'.DATA_PATH.'/themes/default/htmlarea3/htmlarea.js"></script>
20 <script type="text/javascript" src="'.DATA_PATH.'/themes/default/htmlarea3/lang/en.js"></script>
21 <script type="text/javascript" src="'.DATA_PATH.'/themes/default/htmlarea3/dialog.js"></script>
22 <style type="text/css">
23 @import url('.DATA_PATH.'/themes/default/htmlarea3/htmlarea.css);
25 <script type="text/javascript">
26 _editor_url = "'.DATA_PATH.'/themes/default/htmlarea3/";
28 function initEditor() {
29 editor = new HTMLArea("'.$name.'");
31 // comment the following two lines to see how customization works
35 // BEGIN: code that adds custom buttons
36 var cfg = editor.config; // this is the default configuration
37 function clickHandler(editor, buttonId) {
40 editor.insertHTML("<?plugin CreateToc ?>");
43 editor.insertHTML((new Date()).toString());
46 editor.execCommand("bold");
47 editor.execCommand("italic");
50 editor.surroundHTML("<span class=\"hilite\">", "</span>");
54 cfg.registerButton("my-toc", "Insert TOC", _editor_url+"ed_custom.gif", false, clickHandler);
55 cfg.registerButton("my-date", "Insert date/time", _editor_url+"ed_custom.gif", false, clickHandler);
56 cfg.registerButton("my-bold-em", "Toggle bold/italic", _editor_url+"ed_custom.gif", false, clickHandler);
57 cfg.registerButton("my-hilite", "Hilite selection", _editor_url+"ed_custom.gif", false, clickHandler);
59 cfg.registerButton("my-sample", "Class: sample", _editor_url+"ed_custom.gif", false,
62 editor.insertHTML("<span class=\"sample\"> </span>");
63 var r = editor._doc.selection.createRange();
64 r.move("character", -2);
65 r.moveEnd("character", 2);
67 } else { // Gecko/W3C compliant
68 var n = editor._doc.createElement("span");
69 n.className = "sample";
70 editor.insertNodeAtSelection(n);
71 var sel = editor._iframe.contentWindow.getSelection();
72 sel.removeAllRanges();
73 var r = editor._doc.createRange();
81 //cfg.pageStyle = "body { background-color: #efd; } .hilite { background-color: yellow; } "+
82 // ".sample { color: green; font-family: monospace; }";
83 // add the new button to the toolbar
84 //cfg.toolbar.push(["linebreak", "my-toc", "my-date", "my-bold-em", "my-hilite", "my-sample"]);
85 // END: code that adds custom buttons
89 function insertHTML() {
90 var html = prompt("Enter some HTML code here");
92 editor.insertHTML(html);
95 function highlight() {
96 editor.surroundHTML(\'<span style="background-color: yellow">\', \'</span>\');
102 function Textarea($textarea,$wikitext,$name='edit[content]') {
103 $out = HTML($textarea,HTML::div(array("id"=>"editareawiki",'style'=>'display:none'),$wikitext),"\n");
104 //TODO: maybe some more custom links
109 // re-use these classes for the regexp's.
110 // just output strings instead of XmlObjects
111 class Markup_html_br extends Markup_linebreak {
112 function markup ($match) {
117 class Markup_html_simple_tag extends Markup_html_emphasis {
118 function markup ($match, $body) {
119 $tag = substr($match, 1, -1);
123 return "*".$body."*";
124 case 'big': return "<big>".$body."</big>";
127 return "_".$body."_";
132 //'<SPAN style="FONT-WEIGHT: bold">text</SPAN>' => '*text*'
133 class Markup_html_bold extends BalancedMarkup
135 var $_start_regexp = "<(?:span|SPAN) style=\"FONT-WEIGHT: bold\">";
137 function getEndRegexp ($match) {
138 return "<\\/" . substr($match, 1);
140 function markup ($match, $body) {
141 //Todo: convert style formatting to simplier nested <b><i> tags
142 return "*".$body."*";
146 class HtmlTransformer extends InlineTransformer
148 function HtmlTransformer () {
149 $this->InlineTransformer(array('escape',
150 'html_br','html_bold','html_simple_tag',
152 'html_a','html_span','html_div',
153 'html_table','html_hr','html_pre',
155 'html_indent','html_ol','html_li','html_ul','html_img',
161 $Log: not supported by cvs2svn $
169 // c-hanging-comment-ender-p: nil
170 // indent-tabs-mode: nil