How to extend image or link dialogs to get values for other attributes of "img" and "a" tags from the user?
How to create a dialog for any tag just like image or link dialogs?

There is the E.tagDialog(tag, fields, options) method(introduced by default library) to create a dialog for
any tag.
tag -> tag name
fields -> an array of attributes that are eiter strings or objects.
options -> object containing optional parameters:

  title: dialog title. if not specified, "Tag editor - (tag)" is used.
 
stitle: label for submit button. if not specified, "OK" is used.
 
submit: custom submit handler. called with four parameters (tag, form, options, E)
 
validate: custom validator. called with four parameters (tag, form, options, E)
 
effect: jQuery effect ('slideDown' or 'fadeIn')

The simplest form, for example:
E.tagDialog('div', ['id''class''style''html']);//html is a special keyword that represents inner html
will create a DIV Tag Dialog requesting values of attributes id, class and style and also the inner html.
It will also detect if the current selection is a proper DIV tag, and if so, will put the values of attributes to the corresponding fields.
After submission, it will enclose/replace the selection in the textarea.

You might have noticed that fields in image/link dialogs are declared as objects not as strings. That's a
customized form of declaring attributes. It is ideal to use an object if you want
- a field type other than textfield (type: 'select', options: {'left': 'Left', 'right': 'Right'})
the default type is text and other supported types are select, textarea, hidden
- a custom label (title: 'Image URL')
- a default value (value: ' ')
- some prefix or suffix text or html (prefix: '[ ', suffix: ' ]')
- to join two fields in a single line like in image width & height fields (getnext: true)
- to set custom attributes for the field (attributes: {size: 10, style: 'width: 200px'})
- to force value entry (required: true)

Note:
- The field object must have a name property that specifies the attribute name. ex:{name: 'href'}
- If a field value has new a line character(\n) in it, then the field type automatically becomes "textarea"

So lets add an "align" attribute field to the image dialog(note that it's not XHTML compliant):

The field object to pass to E.tagDialog is;

{
 
name: 'align',//required
 
title: 'Image align', // if we don't set it, it will be set as 'Align' automatically.(the name with the first letter uppercase)
 
type: 'select', // we use a select box instead of a plain text field.
 
options: {'': '', left: 'Left', right: 'Right', center: 'Center'} //structure is {attribute-value: 'Visible value'}
}

Lets add it to the form in the image button's content:

var form = [
{
name: 'src', title: 'Image URL', required: true},
{
name: 'width', title: 'Width x Height', suffix: ' x ', getnext: true, attributes: {size: 3}},
{
name: 'height', attributes: {size: 3}},
{
name: 'alt', title: 'Alternative text', required: true},
{
name: 'align', title: 'Image align', type: 'select', options: {'': '', left: 'Left', right: 'Right', center: 'Center'}} //align
];
E.tagDialog('img', form, {title: 'Insert/edit image'});

That's it. We now have an image dialog which can also get/set the "align" attribute of an image tag.

How to create a button that gets user input and adds it to the textarea?

If you want to use a complete form for user input, then use the E.tagDialog method with a custom submit handler.
If you want to get just a single input you may consider using javascript prompt().
Here is an example that gets image URL as a user input

js:
var
url = prompt('URL', '');//prompt for URL
var code = '<img src="'+ url +'" />';//put the url into the code.
E.replaceSelection(code);//replace the selection with the code.

How to extend the functionality of Headings button to create a specialized tag chooser?
How to create an image chooser(ie. smiley chooser) using E.tagChooser?

Firstly, we should understand what E.tagChooser does.
E.tagChooser(tags, options)

Parameter "tags": an array of tag info, each having the format:
[tag, title, attributes]
tag: the tag that will enclose the selected text in the textarea
title: the text or html to help the user choose this tag
attributes: attributes that will be inserted inside the tag. ex:{'id': 'site-name', 'class': 'dark'}

ex tags: [ ['span', 'Red', {'style': 'color: red'}], ['span', 'Blue', {'class': 'blue-text'}] ]
this will create two options:
Red (inserting <span style="color: red"></span>)
Blue (inserting <span class="blue-text"></span>)

Parameter "options": an object containing the optional parameters.
It defaults to {wrapEach'li'wrapAll'ul'applyTagtrueeffect'slideDown'}

wrapEach: the html tag that will enclose each option.
wrapAll: the html tag that will enclose the whole block of options.
applyTag: boolean allowing the user to preview the effect of the tag.
effect: jQuery effect ('slideDown' or 'fadeIn')

Knowing the details we can create our customized tag chooser.
Let's, for example, add styled headings to the default header chooser.

js: E.tagChooser([
[
'h1', 'Header1'],
[
'h1', 'Header1-title', {'class': 'title'}],// this will insert <h1 class="title"></h1>
['h2', 'Header2'],
[
'h2', 'Header2-title', {'class': 'title'}],
[
'h3', 'Header3'],
[
'h4', 'Header4']
]);

Now, let's create an image chooser
There will be no title for our tags since we will use applyTag to preview the image that will be inserted. However we will be using a line break for every N(=4 in our example) image in order to create rows of options. Otherwise,
all of them will be placed in a single row.

js: E.tagChooser([
[
'img', '', {'src': '/path-to-images/img1.png'}],//better to set also the width & height & alt attributes
['img', '', {'src': '/path-to-images/img2.png'}],
[
'img', '', {'src': '/path-to-images/img3.png'}],
[
'img', '<br />', {'src': '/path-to-images/img4.png'}],//line break added after 4th
['img', '', {'src': '/path-to-images/img5.png'}],
[
'img', '', {'src': '/path-to-images/img6.png'}],
[
'img', '', {'src': '/path-to-images/img7.png'}],
[
'img', '<br />', {'src': '/path-to-images/img8.png'}],//br after 8th
['img', '', {'src': '/path-to-images/img9.png'}],
[
'img', '', {'src': '/path-to-images/img10.png'}]
], {
wrapEach: '', wrapAll: 'div'});

While inserting a single tag should we use the classic <tag>%TEXT%</tag> pattern or the E.toggleTag('tag') ?
What is the difference between <tag>%TEXT%</tag> and js:E.toggleTag('tag') ?

First of all, the classic tag insertion method does not require any additional library, whereas E.toggleTag is a part of the bue.misc.js library.

- Classic method preserves the selected text after tag insertion, whereas E.toggleTag selects the whole insertion.
Classic method: converts the selection "foo" to "<tag>foo</tag>", ("foo" still being selected)
E.toggleTag('tag'): converts the selection "foo" to "<tag>foo</tag>" (<tag>foo</tag> is selected)

- Classic method doesn't parse the selection to check if it is an instance of the tag, whereas E.toggleTag does and toggles it.
Classic method: converts the selection "<tag>foo</tag>" to "<tag><tag>foo</tag></tag>"
E.toggleTag('tag'): converts the selection "<tag>foo</tag>" to "foo"

- In classic method you define the attributes of the tag in the usual way, whereas in E.toggleTag you pass them as an object
<tag class="foo" id="bar">%TEXT%</tag> <=> E.toggleTag('tag', {'class''foo''id''bar'})

- In classic method It's possible to use the selected text for any purpose, whereas in E.toggleTag the only goal is to html.
Classic method can use the selection multiple times and do anything with it: [bbcode]%TEXT%[/bbcode]: (%TEXT%)

hi! thanks for

hi! thanks for bueditor!

please, help me: how i can add blockqoute button to qoute any selected text on a page?

thanks!

i try to add

i try to add this:
<blockqoute>%TEXT%</blockqoute>
but it's can work with text only typed in textarea, but i need to qoute text on a full page (qoute node content in comments)

What you request requires

What you request requires javascript. And it's not an esy one regarding browser compatibility, since browsers have different methods for handling the selected text in a page.

if i have JS function that

if i have JS function that return selected text (and its work fine on my browser) how i can add it to BUeditor ??????

you can create javascript

you can create javascript buttons by prefixing the content with the text js:. The remaining part should be the code inside your functon. You can use editor instance methods to change the selected text inside the textarea.

Hi, Thanks for the great

Hi,

Thanks for the great module. I'm trying to create a button that does something more complex but am having trouble getting right. The button, once pressed, will pop up a form that asks for a link, img url, title and alt text, then format the entered values to the following:

<div class="center">
<
div class="spacer">&nbsp;</div>
<
div class="image"><a href=""><img src="" alt="" title="" /></a>
  <
div class="caption"></div>
<
div class="spacer">&nbsp;</div>
</
div>
</
div>

Any help would be appreciated!

Hi to all... I need an

Hi to all...

I need an information to customize the Insert/Edit link button of BUE editor under Drupal 6.x.

I need to make appear the string "http://" from the beginnig, in the URL input field... when the pop-up windows appear...

It's possible to make it with e simple "button editing" operation?

Thaks a lot!

Bye!

Just a quick thanks for

Just a quick thanks for making Bueditor as good as it is today.
The documentation really helps explore all the options!

Using it extensively with bbcode on a few sites, and if you ask me, this is the best editor available in drupal

Under supervision of Drupal :)