Sub task of T102398, but not really a blocker.
Description
Details
Related Objects
- Mentioned In
- T138673: VisualEditor should retrieve content of all Page: pages wikitext editor field when switching from WikiEditor
T142137: While editing textarea gets empty - Mentioned Here
- T142137: While editing textarea gets empty
P3644 T135747 - public wikis with wikEd
T102398: Migrate wikis to use a single edit tab which has both visual and wikitext modes and allows on-the-fly switching between them
Event Timeline
I seem to recall the issue with mw.hook was that it ran hook functions asynchronously... Maybe we can trigger an event on wpTextbox1 like wikiEditor-toolbar-doneInitialSections, and have wikEd detect that and call wikEd.UpdateTextarea()?
Would have to cover all of these:
modules/ve-mw/init/targets/ve.init.mw.DesktopArticleTarget.init.js: var wikitext = $( '#wpTextbox1' ).val(), modules/ve-mw/init/targets/ve.init.mw.DesktopArticleTarget.init.js: initialWikitext = $( '#wpTextbox1' ).val(); modules/ve-mw/init/ve.init.mw.ArticleTargetLoader.js: $( '#wpTextbox1' ).val() && modules/ve-mw/init/ve.init.mw.ArticleTargetLoader.js: wikitext: $( '#wpTextbox1' ).val(),
Change 295444 had a related patch set uploaded (by Alex Monk):
Trigger a custom event on #wpTextbox1 when we need to get the latest wikitext out of it
Thanks to @Krinkle, PS2 replaces the original events-based idea with something that gadgets can handle without even having to implement anything VE-specific. For wikEd it could look something like this:
$( '#wpTextbox1' ).textSelection( 'register', { getContents: function () { wikEd.UpdateTextarea(); return $( this ).val(); } } )
Change 295444 merged by jenkins-bot:
Use .textSelection( 'getContents' ) instead of .val() to get the value of #wpTextbox1
So now the gadget needs updating on enwiki (and anywhere else?), and then we can declare this done?
It turns out there are rather a lot of wikis with this gadget or some variation thereof:
I went around several other wikis (jawiki, eswiki, itwiki, plwiki, metawiki, dewiki) and found they just import from enwiki... frwiki had an outdated (and very slightly modified) copy, which I updated in https://fr.wikipedia.org/w/index.php?title=MediaWiki:Gadget-WikEd.js/local&diff=128398597&oldid=120743896 and https://fr.wikipedia.org/w/index.php?title=MediaWiki:Gadgets-definition&diff=128398642&oldid=127364167
This has been marked for inclusion in Tech News. Just to be on the safe side, to make sure I understand the context, an item about it would look something like this (a bit simplified, but this would be the gist of the message)?
"If you use the wikEd gadget, changes you made were not saved when you switched from the wikitext editor to the visual editor when you edited. This has now been fixed."
That sounds about right, maybe "changes you made could not be kept when you switched ..."?
You probably have to wrap the call to wikEd.UpdateTextarea into a check whether wikEd is enabled or not, something like:
$( '#wpTextbox1' ).textSelection( 'register', { getContents: function () { if ( !wikEd.disabled ) { wikEd.UpdateTextarea(); } return $( this ).val(); } } );
Warning: This is not tested.
In other places the code checks for wikEd.useWikEd, no idea whether that or !wikEd.disabled is correct. @Cacycle?
You are right, at least that's what we use in https://de.wikipedia.org/wiki/MediaWiki:Onlyifuploading.js, and it works there.
Applied that fix, thanks: https://en.wikipedia.org/w/index.php?title=User:Cacycle/wikEd.js&diff=733556921&oldid=733181083
Seems okay to me?
Also in the French Wikipedia: https://fr.wikipedia.org/w/index.php?title=MediaWiki:Gadget-WikEd.js/local&diff=128490092&oldid=128423380
People that were having issues on T142137: While editing textarea gets empty before say it's fine with the new fix applied. Thanks @Schnark and @matmarex
And that's just on WMF wikis…; since I am usually just a Phabricator lurker and am not associated with the Foundation, I have no idea how widespread this is outside of it, though I do know of at least one other (rather obscure) wiki that uses it.
Yep. I imagine your overview of what non-Wikimedia wikis it is used on could be just as good as mine, I don't know much more by being associated with the Foundation. We don't really have a mechanism for knowing about these things outside of Wikimedia sites... I know there's been some talk of sending basic MW install details to Wikimedia so they can be used by MW developers, but I don't think gadgets was one of the details?
@AlexMonk-WMF: You wouldn't happen to remember where and when those discussions took place and if they're still ongoing, do you? If so, perhaps it might be a good idea for me to follow them since I'm interested in the work you're all doing here. Also, perhaps an issue could be opened to add gadget usage to the telemetry data gathered by whatever mechanism might be relevant here?
I managed to find it: https://gerrit.wikimedia.org/r/#/c/296699/ and https://lists.wikimedia.org/pipermail/wikitech-l/2016-July/086111.html
Unfortunately that is only part of the MW installer rather than something run on a regular basis - I don't think any pages/gadgets would be present when it is running
@AlexMonk-WMF: Thanks for the pointers! Are you sure, though, that telemetry will only be sent as part of the wiki installation process? The message on the mailing list seem to indicate otherwise, and that makes me suspect that the telemetry data could be extended to cover things like a list of installed extensions and gadgets and additional statistics like those shown on Special:Version.
It looks to me like it is only ever sent once per wiki (perhaps not from the installer itself, but still). You should ask them though.
@AlexMonk-WMF: Just on IRC or the relevant mailing list some time soon, right? (Hopefully I don't forget amidst the mess that is life; LOL.) Or would I have to open an issue up here in Phabricator since my question might get construed as a sort of feature request?
IRC, Mailing lists, Phabricator... Any of those are acceptable forms of communication