[drupal-devel] Textarea editor hooks
I've just launched a new drupal site at http://www.bikeweb.com using 4.5 As part of this I wanted to include my minimalist html editor. It's all worked but I had to hack common.inc slightly. So here's a couple of suggestions for making extending form_textarea() easier. 1. Textarea, pre really needs to be between the title and textarea of the form_item. textarea extensions are very likely to add a toolbar and this really ought to be hard against the top of the textarea rather than floating above the title. 2. I need a way of adding extra $attributes as part of the module code and can't see an easy way of doing this without making $attributes global. Suggestions? -- Julian Bond Email&MSM: julian.bond at voidstar.com Webmaster: http://www.ecademy.com/ Personal WebLog: http://www.voidstar.com/ M: +44 (0)77 5907 2173 T: +44 (0)192 0412 433 S: callto://julian.bond/
Julian Bond wrote:
I've just launched a new drupal site at http://www.bikeweb.com using 4.5 As part of this I wanted to include my minimalist html editor. It's all worked but I had to hack common.inc slightly. So here's a couple of suggestions for making extending form_textarea() easier.
1. Textarea, pre really needs to be between the title and textarea of the form_item. textarea extensions are very likely to add a toolbar and this really ought to be hard against the top of the textarea rather than floating above the title.
2. I need a way of adding extra $attributes as part of the module code and can't see an easy way of doing this without making $attributes global. Suggestions?
As you need Javascript for your HTML editor anyway, why not use Javascript to add the attributes in the first place? Mark the textarea with a class, then use simple DOM manipulations (getElementsByTagName, element.className) to do what you need to do. Steven Wittens
Op maandag 17 januari 2005 16:45, schreef Steven Wittens:
1. Textarea, pre really needs to be between the title and textarea of the form_item. textarea extensions are very likely to add a toolbar and this really ought to be hard against the top of the textarea rather than floating above the title.
This gets a +1 from me. IT makes no sense to have it called befire the title. Quicktags needs it after the title too.
2. I need a way of adding extra $attributes as part of the module code and can't see an easy way of doing this without making $attributes global. Suggestions?
I think a small patch that takes $arguments from hook_texarea()-returns and merges these into the (optional) existing $arguments will make sense. Regards, Bèr -- [ Bèr Kessels | Drupal services www.webschuur.com ]
1. Textarea, pre really needs to be between the title and textarea of the form_item. textarea extensions are very likely to add a toolbar and this really ought to be hard against the top of the textarea rather than floating above the title.
This gets a +1 from me. IT makes no sense to have it called befire the title. Quicktags needs it after the title too.
Why? It is javascript, isn't it? Do you still use document.write()? It should not be used in XHTML, it is actually not possible to document.write() anything into a real XHTML document! If the answer is no, and you use DOM, then it does not matter, where is that hook...
2. I need a way of adding extra $attributes as part of the module code and can't see an easy way of doing this without making $attributes global. Suggestions?
I think a small patch that takes $arguments from hook_texarea()-returns and merges these into the (optional) existing $arguments will make sense.
All form elements in Drupal already have ID attributes, which makes then extremely easy to get from JavaScript (and add attributes). Goba
Op maandag 17 januari 2005 17:13, schreef Gabor Hojtsy:
Why? It is javascript, isn't it? Yes. Do you still use document.write()? It NO. should not be used in XHTML, it is actually not possible to document.write() anything into a real XHTML document! If the answer is no, and you use DOM, then it does not matter, where is that hook... I use $output = form_something() etc.
Off course I can use a bloated javascript to place it somewhere else. Hell, i can probaly even include a HUGE javascript to move my whole DOM around. But who needs the info /before/ the title? No-one, i guess. So why not move it /after/ ? Regards, Bèr -- [ Bèr Kessels | Drupal services www.webschuur.com ]
should not be used in XHTML, it is actually not possible to document.write() anything into a real XHTML document! If the answer is no, and you use DOM, then it does not matter, where is that hook...
I use $output = form_something() etc.
Off course I can use a bloated javascript to place it somewhere else. Hell, i can probaly even include a HUGE javascript to move my whole DOM around. But who needs the info /before/ the title? No-one, i guess. So why not move it /after/ ?
Huge javascript: ta = document.getElementById('edit-body'); ta.setAttribute('...', '...'); toolbar = document.createElement('div'); ta.insertBefore(toolbar); What is the purpose? You are about to add quicktags editors above all textareas, right? Are you about to add the HTML tags for those toolbars above all textareas literally into the HTML code, to avoid 'bloated HUGE javascript'? If you add it once, and are not doing to bloat the HTML code, you still need to move and/or copy around as needed with JavaScript, which still need the same procedure as above. If you add one instance, then the createElement will be replaced with getElementById, right. Goba
participants (4)
-
Bèr Kessels -
Gabor Hojtsy -
Julian Bond -
Steven Wittens