i'm trying to add a wysiwyg kind of javascript formatting buttons onto the top of textarea fields in page, story, blog and comment entry... but nary a clue do i have...

i'm wishing there was a document that explained the underlying structure of one of the most important parts of drupal: the node.module. [ like this document on the way MT tags are structured ] ... is this the comparable document for drupal? 'Drupal 4 node system' http://drupal.org/node.php?id=189...

tell me if i am right: if you are adding in a story, you go to node.module which pulls in story.module, which pulls in which information you need (e.g., what fields can be entered, and the 'explainer' information at the top...)

i'd like to add the javscript WYSIWYG buttons as an include so i can maintain is seperatly... where would be the best place to add this?

Comments

moshe weitzman’s picture

i would think that the best place to do this is in form_textare() function located in cincludes/common.inc file. please do share anything interesting that you come up with.

heather’s picture

NOW- i can see in the common inc where it should go, BUT, in order for this to work, functions need to be in the header of the HTML...

...for sharing purposes, what is the best way to submit this 2 part code?

VIEW: http://artists.nearlythere.com/outgoing/example-add-html.php

DOWNLOAD : http://artists.nearlythere.com/outgoing/example-add-html.php.txt

USAGE: These buttons appear over the text area. User selects text written in field, then clicks on the formatting buttons; the code is inserted around selected text. The examples provided are bold, italics, or ordered and unordered lists. Insert URL prompts user to type in an http:// reference.

HOW IT WORKS: It uses document.write after checking if javascript is working. That way, the buttons won't show up in browsers that don't support javascript. (tested in IE 6 and Opera 6.) ...

DESIGN: This uses input buttons. (i think in the end i am going to use a stylesheet to format the input buttons and make them pretty, but this here is a simple version for anyone to customize. I could also rewrite it to use text links or images, if you like)

moshe weitzman’s picture

looking good.

i contributed a week ago a patch which allows modules to add HTML to the HEAD section. see my sandbox - contrib/sandbox/moshe/theme_head

doesn't work in mozilla. this would be a nice enhancement.

also, i suggest that the best way to get this incorporated into drupal is to remove all form_* functions from common.inc into orm.inc or form.module then admins can choose to use the plain form file or enhanced ones like javascript buttons or WYSIWYG. this also enables admins to choose form_ functions which don't add markup like br between elements.

heather’s picture

1. i see now that i don't have to include the functions in the 'head' they can simply be in the texbuttons include file...

2. you mention it doesn't work in mozilla. no it wouldn't... but at least the buttons should not be showing up so mozilla or opera users won't know what they're missing. Only local images are allowed. (it's not showing up in mozilla is it?)

3. as for making the change to the moving form functions to a form module... do you want to do this to the CVS version? how do you push a change like that through?

moshe weitzman’s picture

mozilla supprts javascript. i think this should work for all javascript enabled browsers. i have not examined why it is not working, but hopefully someone will.

the process for pushing through a change is to submit a patch to the development mailing list. if you read the list for a few days, you'll get a taste for how the whole community works. there is also lots of good info in the drupal handbook - developer guide. someone will review your patch and commit it or give reasons why it isn't ready, or isn't desirable.

joe lombardo’s picture

This is a great hook. Can you document it in http://www.drupal.org/node.php?id=329 ?

Cheers,
- joe

Joe Lombardo | joe@familytimes.com | My Blog

moshe weitzman’s picture

joe lombardo’s picture

Forgive my ignorance, but does it need to return an array? Can it just return any old html markup?
Joe Lombardo | joe@familytimes.com | My Blog

moshe weitzman’s picture

just like the link hook

ax’s picture

for drupal v3: http://voidstar.com/node.php?title=Javascript+helper+buttons+for+TextAreas. may be helpful to implement it for v4; guess it won't require many changes (i converted julians v3 Blog it Bookmarklet to v4 - wasn't that hard ...)

heather’s picture

yeah they did it basically with the same idea, as an include. and *duh* i didn't think of putting the script just inside the include. sillly me! it doesn't have to be in the header.

the one advantage i can offer with my version is that it only displays in browsers that support javascript by using document.write...

but that script is more functional with its function simpleinsert (for horizontal rules or line breaks) and function addimage (if people have an image link to add)...

i could adapt that example with the javascript document.write so it works the same as my example...

what kinds of change would it need to work w/ version 4?