Early Bird Registration for DrupalCon Portland 2024 is open! Register by 23:59 PST on 31 March 2024, to get $100 off your ticket.
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.
Comment | File | Size | Author |
---|---|---|---|
#11 | wysiwyg-listbox-439258-11.patch | 6.96 KB | douggreen |
#10 | wysiwyg-listbox-439258-10.patch | 6.91 KB | douggreen |
wysiwyg_listbox_test-6.x-2.x-dev.tar_.gz | 1.07 KB | Anonymous (not verified) | |
wysiwyg_listbox.patch.gz | 2.72 KB | Anonymous (not verified) |
Comments
Comment #1
sun1) 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?
Comment #2
Anonymous (not verified) CreditAttribution: Anonymous commented1) 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:
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.
Comment #3
sunThanks for the detailed explanation. The last proposal for passing a selection object would definitely make sense. The rest I have to think about.
Comment #4
hasan.raihan CreditAttribution: hasan.raihan commentedg.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.
Comment #5
TwoD@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.
Comment #6
hasan.raihan CreditAttribution: hasan.raihan commentedTwoD,
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.
Comment #7
cindylai CreditAttribution: cindylai commentedhasan.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!
Comment #8
extremist99 CreditAttribution: extremist99 commentedxzcxc
sd
Comment #9
TwoD?
Comment #10
douggreen CreditAttribution: douggreen commentedThis 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.
Comment #11
douggreen CreditAttribution: douggreen commentedminor update to patch removes PHP warning... setting default controlType