|
|
@ -30,6 +30,63 @@ function updateVisualEditorConfig() {
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
console.warn('Cannot find ve lib');
|
|
|
|
console.warn('Cannot find ve lib');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (mw.libs && mw.libs.ve && mw.libs.ve.targetLoader) {
|
|
|
|
|
|
|
|
var _oldRequestParsoidData = mw.libs.ve.targetLoader.requestParsoidData;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* Request the page data and various metadata from the MediaWiki API (which will use
|
|
|
|
|
|
|
|
* Parsoid or RESTBase).
|
|
|
|
|
|
|
|
*
|
|
|
|
|
|
|
|
* @param {string} mode Target mode: 'visual' or 'source'
|
|
|
|
|
|
|
|
* @param {string} pageName Page name to request, in prefixed DB key form (underscores instead of spaces)
|
|
|
|
|
|
|
|
* @param {Object} [options]
|
|
|
|
|
|
|
|
* @param {boolean} [options.sessionStore] Store result in session storage (by page+mode+section) for auto-save
|
|
|
|
|
|
|
|
* @param {null|string} [options.section] Section to edit; number, 'T-'-prefixed, null or 'new' (currently just source mode)
|
|
|
|
|
|
|
|
* @param {number} [options.oldId] Old revision ID. Current if omitted.
|
|
|
|
|
|
|
|
* @param {string} [options.targetName] Optional target name for tracking
|
|
|
|
|
|
|
|
* @param {boolean} [options.modified] The page was been modified before loading (e.g. in source mode)
|
|
|
|
|
|
|
|
* @param {string} [options.wikitext] Wikitext to convert to HTML. The original document is fetched if undefined.
|
|
|
|
|
|
|
|
* @param {string} [options.editintro] Name of a page to use as edit intro message
|
|
|
|
|
|
|
|
* @param {string} [options.preload] Name of a page to use as preloaded content if pageName is empty
|
|
|
|
|
|
|
|
* @param {Array} [options.preloadparams] Parameters to substitute into preload if it's used
|
|
|
|
|
|
|
|
* @return {jQuery.Promise} Abortable promise resolved with a JSON object
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
mw.libs.ve.targetLoader.requestParsoidData = function ( mode, pageName, options ) {
|
|
|
|
|
|
|
|
console.log('loading page data: ', pageName);
|
|
|
|
|
|
|
|
if (window.URL) {
|
|
|
|
|
|
|
|
var urlInfo = new URL(location.href);
|
|
|
|
|
|
|
|
let tplPageName = urlInfo.searchParams.get('tplPageName');
|
|
|
|
|
|
|
|
if (tplPageName) {
|
|
|
|
|
|
|
|
// 使用模板页面名替代页面名
|
|
|
|
|
|
|
|
pageName = tplPageName;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return _oldRequestParsoidData(mode, pageName, options);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
console.log('mw.libs.ve.targetLoader not defined');
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 重写参数输入框
|
|
|
|
|
|
|
|
// 1. 添加下拉框类型
|
|
|
|
|
|
|
|
if (ve.ui && ve.ui.MWParameterPage) {
|
|
|
|
|
|
|
|
var _oldCreateValueInput = ve.ui.MWParameterPage.prototype.createValueInput;
|
|
|
|
|
|
|
|
ve.ui.MWParameterPage.prototype.createValueInput = function () {
|
|
|
|
|
|
|
|
var type = this.parameter.getType(),
|
|
|
|
|
|
|
|
value = this.parameter.getValue(),
|
|
|
|
|
|
|
|
valueInputConfig = this.getDefaultInputConfig();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ( type === 'dropdown' ) {
|
|
|
|
|
|
|
|
return new ve.ui.MWParameterDropdownInputWidget( valueInputConfig, this.parameter.getDefaultValue() );
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return _oldCreateValueInput.call(this);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
console.log('ve.ui.MWParameterPage not defined');
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
updateVisualEditorConfig();
|
|
|
|
updateVisualEditorConfig();
|