Last modified: 2009-08-14 07:58:47 UTC

Wikimedia Bugzilla is closed!

Wikimedia migrated from Bugzilla to Phabricator. Bug reports are handled in Wikimedia Phabricator.
This static website is read-only and for historical purposes. It is not possible to log in and except for displaying bug reports and their history, links might be broken. See T22134, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 20134 - New toolbar breaks wikEd
New toolbar breaks wikEd
Status: CLOSED FIXED
Product: MediaWiki extensions
Classification: Unclassified
UsabilityInitiative (Other open bugs)
unspecified
All All
: Normal major (vote)
: ---
Assigned To: Trevor Parscal
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2009-08-08 19:18 UTC by Cacycle
Modified: 2009-08-14 07:58 UTC (History)
2 users (show)

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---


Attachments

Description Cacycle 2009-08-08 19:18:29 UTC
The new toolbar is not compatible with the rich text editor wikEd (http://en.wikipedia.org/wiki/User_talk:Cacycle/wikEd). wikEd is used as a gadget on many MediaWikis as well as a Greasemonkey script. wikEd uses an iFrame in designmode as the edit area instead of the classical html textarea.

The old toolbar has been made compatible with wikEd by redirecting the insertTags() function in edit.js to wikEd's own function WikEdInsertTags().

In order to make the new toolbar compatible with wikEd I need a "hook", anything that could be used to provide wikEd with the three insert strings (before, inside, after). I have checked the toolbar code, but was not able to come up with a mechanism to hook wikEd into the new toolbar.

Trevor: please could you check the new toolbar code and point me to a solution or could you otherwise create such a hook (e.g. a function call that wikEd can redirect to its own function). Thanks, Cacycle
Comment 1 Roan Kattouw 2009-08-09 19:24:11 UTC
Done in r54680. The hook works as follows:

// Do this in an onload hook or inside a jQuery(document).ready(function() { here });
jQuery('#wpTextbox1').bind('encapsulateSelection', function(e, before, inside, after) {
        // Do something with before, inside, after, e.g.
        WikEdInsertTags(before, inside, after);
        // or however this is done
});
Comment 2 Cacycle 2009-08-10 03:04:27 UTC
Thanks for this change. Unfortunately, this does not work yet.

The problem is that the original button handler is still executed and tries to change / access the hidden (style.display = 'none') original textarea. And because the textarea is not displayed, accessing e.selectionStart (encapsulateSelection in plugin.combined.js, line 315 in rv 54680) terminates with an error message before throwing the encapsulateSelection event.

There should be a way to prohibit the default event handling. Also, because one can switch between textarea and rich text frame, it must be possible to switch back and forth between both handlers.

I hope this explains the situation a bit better than my original request :-)

Comment 3 Roan Kattouw 2009-08-10 09:50:43 UTC
JS error fixed in r54704
Comment 4 Cacycle 2009-08-10 13:12:14 UTC
Thanks again. Maybe you could move the "(e.style.display != 'none')" test up so that no code but the event thrower will be executed under any browser when the textarea is not available. That might be a cleaner solution (even if it currently works under IE without errors).
Comment 5 Roan Kattouw 2009-08-10 13:26:52 UTC
(In reply to comment #4)
> Thanks again. Maybe you could move the "(e.style.display != 'none')" test up so
> that no code but the event thrower will be executed under any browser when the
> textarea is not available. That might be a cleaner solution (even if it
> currently works under IE without errors).
> 

Good point. Done in r54716.
Comment 6 Trevor Parscal 2009-08-13 21:47:34 UTC
This is a good example of the API in use. (it's our tests to make sure it's working)

http://svn.wikimedia.org/viewvc/mediawiki/trunk/extensions/UsabilityInitiative/js/tests/wikiEditor.toolbar.js?view=markup
Comment 7 Roan Kattouw 2009-08-13 21:48:56 UTC
(In reply to comment #6)
> This is a good example of the API in use. (it's our tests to make sure it's
> working)
> 
> http://svn.wikimedia.org/viewvc/mediawiki/trunk/extensions/UsabilityInitiative/js/tests/wikiEditor.toolbar.js?view=markup
> 

Please note that this means that the hook I added earlier has been removed in favor of this new API.
Comment 8 Cacycle 2009-08-13 22:44:49 UTC
So what do I have to do to to temporarily redirect all new toolbar button push events to a different editor (i.e. wikEd). I have checked the code but couldn't quite figure that out.
Comment 9 Roan Kattouw 2009-08-14 07:58:47 UTC
(In reply to comment #8)
> So what do I have to do to to temporarily redirect all new toolbar button push
> events to a different editor (i.e. wikEd). I have checked the code but couldn't
> quite figure that out.
> 

Gah, my apologies. The API for adding and removing buttons changed, the one for catching the insert event and passing it to wikiEd is the same.

*Slams head into wall*

Note You need to log in before you can comment on or make changes to this bug.


Navigation
Links