Topic on Talk:Structured Discussions

Scripting in Flow editor - mw.libs.ve.addPlugin not fully available

6
Summary last edited by Clump 03:33, 31 July 2018 5 years ago
185.162.92.7 (talkcontribs)

Hi! Since MediaWiki 1.31 update something in Flow editor changed and I need to update my code. I used to be able to have my own input method (for writing some letters and symbols for users without a special keyboard) working in Flow editor, is there a way to implement this in new one? Some events or hooks to use, maybe. There is no documentation for this at the moment and the only script for Flow makes only stylistic changes.

Trizek (WMF) (talkcontribs)

Hey

You mean the wikitext editor? It has been changed to use the 2017 wikitext editor (for Wikimedia supported wikis only), on which gadgets are coded the same way as on visual editor. That way, you can have gadgets working on both editors. I'm not aware of a gadget I can show, so I would be curious to see if you change yours to try it.

185.162.92.7 (talkcontribs)

Yeah, I mean wikitext editor. It seems to be enabled now for all wikis with visual editor available. I am already supporting visual editor in my code, but it seems like initialization for Flow editor does not work the same way as for standard visual editor.

Trizek (WMF) (talkcontribs)

What is your gadget so I can have a look at it?

185.162.92.7 (talkcontribs)

I have since then found a way to overcome all problems. Bug with Flow editors for me seemed to be in that Flow editors don't support mw.libs.ve.addPlugin at all but support sequenceRegistry and other stuff, so I had to duplicate the code to make it work either in visual editor or wikitext editor.

	mw.loader.using( 'ext.visualEditor.desktopArticleTarget.init', function () {
		mw.libs.ve.addPlugin( function () {
			return mw.loader.using( [ 'ext.visualEditor.core', 'ext.visualEditor.mwwikitext' ] ).done( function () {
				// This does nothing in Flow boards
			} );
		} );
	} );
	if ( mw.config.get( 'wgPageContentModel' ) === 'flow-board' ) {
		mw.loader.using( 'ext.visualEditor.desktopArticleTarget.init', function () {
			mw.loader.using( [ 'ext.visualEditor.core', 'ext.visualEditor.mwwikitext' ] ).done( function () {
				// This seems to work in Flow boards
			} );
		} );
	}

Hope this helps someone if they had to write plugins for Flow editors.

Trizek (WMF) (talkcontribs)

I've documented your case. This is something we need to fix so that it would simplify your life.

Reply to "Scripting in Flow editor - mw.libs.ve.addPlugin not fully available"