Topic on Extension talk:VisualEditor

Skipping the save confirmation dialog

7
MyWikis-JeffreyWang (talkcontribs)

One of our clients does not want the save confirmation dialog to appear; they would like for the save to happen immediately.

They proposed using this code on their wiki:

ve.init.mw.ArticleTarget.prototype.showSaveDialog = function ( action, checkboxName ) {
    this.save(this.getDocToSave(), this.getSaveOptions());
    this.tryTeardown(true);
    return;
}

However, it only executes in the browser's console. When adding it to MediaWiki:Common.js, it doesn't do anything.

How can this snippet of code be modified to execute such that it can be stored in MediaWiki:Common.js?

Krabina (talkcontribs)
MyWikis-JeffreyWang (talkcontribs)

It seems like that extension is for uploads of files only, whereas here we are trying to save pages without the summary/confirmation appearing. Am I mistaken?

Krabina (talkcontribs)

ah, yes. I was not reading this properly. Yes, EnhanceUpload does onyl fix several options when uploading files with VE

This post was hidden by Thomas-topway-it (history)
Thomas-topway-it (talkcontribs)

hello @MyWikis-JeffreyWang could you try the following ?

(function () {

    // @see https://www.mediawiki.org/w/index.php?title=Topic%3AY42xiwa26cl6d1zl&topic_showPostId=y4cmacnoqiruyy2x&fromnotif=1#flow-post-y4cmacnoqiruyy2x
	mw.loader.using('ext.visualEditor.targetLoader', function () {
		// Register plugins to VE. will be loaded once the user opens VE
		mw.libs.ve.targetLoader.addPlugin(function () {

			ve.init.mw.ArticleTarget.prototype.showSaveDialog = function (
				action,
				checkboxName
			) {
				// @see ve.ui.MWSaveDialog.js -> getActionProcess
				var saveDeferred = ve.createDeferred();
				this.emit('save', saveDeferred);
				var saveOptions = this.getSaveOptions();

				// @see ve.init.mw.ArticleTarget.js -> onSaveDialogSave
				this.emit('saveInitiated');
				this.startSave(saveOptions);
				this.saveDeferred = saveDeferred;
			};
		});
	});
})();

MyWikis-JeffreyWang (talkcontribs)

That works well for me, I've passed it on to the client. Let's hope it works for them!

Thanks a bunch @Thomas-topway-it!

Reply to "Skipping the save confirmation dialog"