I've written an extension to the plugin API which makes it possible to use a listbox control in a plugin. I implemented the functionality for TinyMCE 3 and FCKEditor 2.6. Furthermore I wrote a simple test plugin to be able to test the functionality.
I've tested on Firefox 3 and IE7. Both seem to work ok.

I attached a patch against 6.x-2.0-HEAD and the module with the test plugin.

CommentFileSizeAuthor
#11 wysiwyg-listbox-439258-11.patch6.96 KBdouggreen
#10 wysiwyg-listbox-439258-10.patch6.91 KBdouggreen
wysiwyg_listbox_test-6.x-2.x-dev.tar_.gz1.07 KBAnonymous (not verified)
wysiwyg_listbox.patch.gz2.72 KBAnonymous (not verified)
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

sun’s picture

Status: Needs review » Needs work

1) Please do not attach compressed files or archives to issues. Plain patches only. Can you re-attach?

2) I don't see how dropdowns would be useful? Why did you implement this? I.e., which module will use this?

Anonymous’s picture

1) I wasn't sure how to post the wysiwyg_listbox_test. It is a demo module which doesn't contain anything but a wysiwyg to demonstrate/test the listbox functionality I added in the patch. I didn't want to put it inside the wysiwyg module as it doesn't have the same status as the break plugin. Now I think it would be a better idea to have a separate examples folder in the root of the wysiwyg module. This would then be the right place for this module.
Please let me know if you agree an I'll build a new (uncompressed) patch which reflects this.

2) The main reason I want a listbox control, comes from the way tinyMCE handles the 'HTML block format' control. I mentioned this already in #407326, but decided not to make it more complex than necessary and not bother about css classes for now.
TinyMCE just shows a list of P, H1, H2 etc. which is quite meaningless to my users. FCKEditor does a much better job by showing Normal, Heading 1 etc. and even formatting them.
Having the possibility to create a listbox control from a plugin (either external or internal) would make it possible to write a plugin that gives this functionality (Custom block labels) for any underlying wysiwyg editor. It could be configurable through the administration menu. I think that once it works, it could be improved to support css classes as well and might even be linked to a filter.
Right now, I'm working on a plugin that provides this functionality.

Other possible future uses of the listbox:

  • A list of predefined snippets like frequently use legal sentences. Especially useful if editor profiles could be associated with content types.
  • A list of predefined images to insert. (Like emoticons, but editor independent and configurable from within the module). For example taxonomy images
  • I'm sure there will be many more uses for this functionality

There's another extension that would really be great to have in the wysiwyg plugin API:
In the current API, the invoke() function passes a DOM node and a content string to represent the selected text. Replacing this (or adding it for backwards compatibility) with a browser and editor independent wysiwygSelection object would make it much easier to implement plugins. This object should have methods like replaceSelection(html), surroundWith(element), getParentNode(), isCollapsed() and getContent(). I know it's not going to be easy, but I'll have a go at it to see if this helps me to implement my plugin.

sun’s picture

Thanks for the detailed explanation. The last proposal for passing a selection object would definitely make sense. The rest I have to think about.

hasan.raihan’s picture

g.idema ,
I'm getting some pain by making a list box in tinyMCE for drupal6.2. I follow the tinyMCE documentation and forum, but I just failed to show a listbox in the tinyMCE editor. Seems your plugin will solve my problem. Could you please tell me little bit details how to use it.

Thanks.

TwoD’s picture

Version: 6.x-2.x-dev » 7.x-2.x-dev
Status: Needs work » Postponed

@hasan.raihan, if you're building a 'native' TinyMCE plugin (that is, a 'normal' one which would work without Wysiwyg module) you have to follow the TinyMCE documentation and preferably test it on a TinyMCE installation which does not go via Wysiwyg module. After that, you create a small module and implement hook_wysiwyg_plugin(), in the same way IMCE Wysiwyg bridge does, but replace 'extensions' with 'buttons'. Wysiwyg module does not need to know if a native plugin's control is actually a button or not (even though we use the key 'buttons'), it just needs to know its name.

If you're building a 'Drupal plugin', like the included Teaser Break plugin or the one in Image Assist, you can only use buttons for now. It is very unlikely that the patch here will still apply as the module has changed a bit lately.

In any case, I'm with sun here. This is a feature we would have to add to Wysiwyg module 3.x first, and then maybe backport to 2.x branches. It's a fairly complex change though as all editors implement selectboxes differently and some don't support them at all. We want all Drupal plugins to work in all editors, so we're not sure what to do about this yet.

hasan.raihan’s picture

TwoD,
Sorry for let replying. Thank you for attention. Actually I needed a list box in the tinyMCE, where users would select language (Bangla/English) for writing in the editor. tinyMCE has the option to create listbox control. I created the listbox and worked fine. But works elsewhere other than inside drupal. After spending some time I found the tinyMCE module for drupal is for version 2.x . Therefore the list control doesnot work in drupal.

Using version 2, which create control with html my problem is solved.

cindylai’s picture

hasan.raihan,

Do you mind sharing your code? I am trying to create a custom listbox for tinyMCE in Drupal (7.x) and I have been working on this for a couple of days with no success. Thanks in advance!

extremist99’s picture

Version: 7.x-2.x-dev » 7.x-2.0
Component: Plugins » Editor - TinyMCE
Status: Postponed » Active

xzcxc

sdss<?php
sds
?>

sd

  1. sd

sds

TwoD’s picture

Version: 7.x-2.0 » 7.x-2.x-dev
Assigned: » Unassigned
Status: Active » Postponed

?

douggreen’s picture

This issue appears dead, but I had a client using this patch. So attached is an updated patch to the latest 7.x-2.2 version.

douggreen’s picture

minor update to patch removes PHP warning... setting default controlType