I've taken some time to implement the first steps towards having Drupal plugin support for jWYSIWYG.
I've tested it with the Teaser Break plugin in Firefox 3 so far and it looks good.
There's no support for Dialogs yet (allthough the Image Assist button shows up if enabled, it does nothing).
I've stared myself blind at this and need someone else to look at it to see if I'm heading in the right direction.
The attach method is huge because everything needs to be done before jwysiwyg is initialized, and almost every setting is passed as a parameter.
I hope the code comments will give some pointers to what happens but if those are not enough, just ask away here or on IRC.
Comment | File | Size | Author |
---|---|---|---|
#16 | wysiwyg-483452.patch | 14.96 KB | jonhattan |
#14 | wysiwyg-483452.patch | 11.87 KB | jonhattan |
#10 | wysiwyg_jwysiwyg092_jwysiwyg.inc_.patch | 6.51 KB | JohnnyX |
#10 | wysiwyg_jwysiwyg092_jwysiwyg.js_.patch | 7.7 KB | JohnnyX |
#8 | wysiwyg_jwysiwyg_drupal_plugins3.patch | 14.47 KB | TwoD |
Comments
Comment #1
TwoDHere's an update to fix buttons not being disabled properly along with a few more things.
I think the patch is almost done, considering what can be done at the moment.
I'd very much appreciate if anyone could help testing this, and perhaps review the code.
Comment #2
sunAwesome!
We need to get rid of "separator01" and "h2mozilla" buttons though. If those buttons are enabled by default, then we have to iterate over Wysiwyg.TOOLBAR to fetch all available buttons, and set their visibility to false (if not contained in our settings.buttons).
Comment #3
TwoDYes the separators and mozilla specific buttons are enabled by default, hence the big array defaulting to false in the code.
I'm not sure why they have mozilla specific buttons as I have not tested that yet, I just added things to that array until there were no visible objects left in the toolbar.
The separators are a nice visual addition IMHO, but they do clutter the Buttons and Plugins GUI...
Comment #4
sunNote that we'll tackle button groupings, separators, and all related stuff in #277954: Allow to sort editor buttons. Separators have been intentionally left out from plugin/button registries, because they do not make sense without a GUI to customize placement of buttons.
Comment #5
sunHrm. I tried to help here, but I'm a bit puzzled with how jWysiwyg registers itself into jQuery — I didn't manage it to access its default properties in that magic "Wysiwyg()" function, which seems to be declared within the scope of jQuery, but not in the window...
Anyway, attached patch contains some code clean-up, as well as a PHP notice fix (enabling E^ALL highly recommended).
Comment #6
sunuh oh - http://drupal.org/cvs?commit=222770 probably broke this patch. Sorry.
Comment #7
TwoDThe scope in which
Wysiwyg
is declared is exited and the only reference to that object is through the $.data function/method and the 'wysiwyg' key.The registration happens by extending the jQuery object through
$.fn.wysiwyg = function ....
. When called it in turn calls theWysiwyg
function to return a new instance keyed to the current jQuery object, or call a method on an existing instance. This makes it a bit hard to figure out how everything is connected at first, and especially whatthis
refers to all the time, but it's pretty efficient code.Yeah the code needed some cleanups, thanks. I'll reroll the patch against the new code.
Comment #8
TwoDI used sun's patch from #5 and added support for updating
Drupal.wysiwyg.activeId
when the editing area gets focus. (Clicking things in the toolbar does not count.)The separators no longer show up under "Buttons and plugins", commented out the code for future reference. They will thus not show up unless in default mode.
I also fixed an issue where buttons would not be deactivated when clicking a Drupal plugin button.
I don't think we can remove the Mozilla specific header buttons. It seems that if I disable the Mozilla buttons and try to use the corresponding other button in Firefox, nothing happens.
Maybe we could hard-code connections between those buttons though, so that if I enable H1 the H1 Mozilla button is also enabled.
Comment #9
abraham CreditAttribution: abraham commentedSubscribe.
Comment #10
JohnnyX CreditAttribution: JohnnyX commented@TwoD:
I testet your patch with
wysiwyg api 6.x-2.x-dev
jwysiwyg 0.92
I modified jwysiwyg (version line to match search expression of wysiwyg api module, version number at end of line) and the button set of jwysiwyg within wysiwyg api module (http://wiki.github.com/akzhan/jwysiwyg/default-parameter-settings-visibl...).
Editor works if I disable all buttons and plugins (with default toolbar) or all enabled (full toolbar). If I mix up enabled and disabled button and plugin settings jwysiwyg breaks sometimes and the toolbar disapears.
A short test with wysiwyg_imageupload module fails (maybe a problem with dependencies of wysiwyg_imageupload module). I see a (I think) jquery Dialog for insert image but without upload and the dialog view isn't correct. Also link promt (error message) doesn't open if no text is selected.
This patch is my starting point for the next steps...
I hope I created the patch well. It's my first time I do so :)
And sorry for my bad english... ;)
Comment #11
JohnnyX CreditAttribution: JohnnyX commentedjwysiwyg works fine and it is already active in development (plugin api) but at the moment it isn't useable with wysiwyg (buttons and plugin settings and wysiwyg_imageupload are not supported).
Sadly I can't implement it because I haven't enough experience with javascript/ drupal modules at the moment... Is there nobody who would also use jwysiwyg and could do it?
Comment #12
JohnnyX CreditAttribution: JohnnyX commentedOk, I tried to fix problems with wysiwyg plugins (wysiwyg_imageupload: edit an already inserted image is broken and button is invisible) but I have to give up... I don't understand where and what is to do and I haven't found a documentation how to integrate an editor to wysiwyg api :(
So maybe I have to remove wysiwyg editor/ api from my module list.
ckeditor -> generates strange source code and have no spoiler plugin I need
tinymce -> no spoiler plugin...
cleditor -> looks really good but isn't supported and only works with jquery 1.4
jwysiwyg -> doesn't support wysiwyg_imageupload/ imce and plugins
So - if nobody have a solution - I have to use bueditor instead? :(((
Or can somebody help to fix the imageupload support/problem with jwysiwyg?
Comment #13
Alan D. CreditAttribution: Alan D. commentedAny update / progress? This is a show stopper when trying to use this editor with Insert module, which is a shame as it is a nice little editor :(
Comment #14
jonhattanUpdated patch in #8 to drupal 7 & jwysiwyg 0.97.2.
I'll comment on the changes I've made in the next comment once I have dreditor available :)
Comment #15
jonhattanCommented out piece of code.
Drupal.settings.wysiwyg.plugins.drupal[buttonName] is not avasilable. I don't know how it works.
Ops. Not tested how css files area added in 0.97
OTOH initialContent needs to be reset.
Avoid repeating all the buttons here again.
Note:
Those buttons where added since 0.95:
Should we check button availability per version?
Comment #16
jonhattanSo I think I've learned a bit more about wysiwyg and javascript but I'm probably wrong.
Here's an updated version of the patch.
* Teaser break plugin works... more or less.
* Added a new section to the settings page for editor specific configuration. For now it provides a checkbox for the user to choose whether jwysiwyg should use jquery ui dialogs.
* Implemented the resizing option (it uses jquery ui.resizable).
* Reset editor default buttons so if you haven't configured the editor instance buttons, you get no buttons.
* Defined some buttons as plugins because they need a js file to be loaded and didn't found other way to include it.
It still needs work but merits a review to confirm it is going in the right direction.
Comment #17
JKey CreditAttribution: JKey commentedI`m apply patch in #16
and now i`m canno save text from jWysiwyg to site.
On save no changed send.
On click switch editor to siple text in console looked
[15:17:23.506] TypeError: pluginSettings[params.format] is undefined @ http://cluster.joxho.org/sites/all/modules/wysiwyg/editors/js/jwysiwyg.j...
in 83 line get error "pluginSettings[params.format] is undefined "
-------------------- -------------------- -------------------- -------------------- -------------------- --------------------
var oldGetContent = editor.getContent;
editor.getContent = function() {
var content = oldGetContent.call(this);
for (var plugin in pluginSettings[params.format].drupal) if (typeof pluginInstances[plugin].detach == 'function') { <= in this line error
content = pluginInstances[plugin].detach(content, pluginSettings[plugin], params.field);
}
return
-------------------- -------------------- -------------------- -------------------- -------------------- --------------------
use jWysiwyg - 0.98