Update for MW 1.42.0

master
落雨楓 1 month ago
parent 5125723c79
commit 18ea2c327e

@ -1,6 +1,7 @@
<?php
namespace Isekai;
use Wikimedia\Parsoid\DOM\Element;
use Wikimedia\Parsoid\Ext\ExtensionTagHandler;
use Wikimedia\Parsoid\Ext\ParsoidExtensionAPI;
@ -8,18 +9,17 @@ class BlockQuoteTagHandler extends ExtensionTagHandler {
public function sourceToDom(ParsoidExtensionAPI $extApi, string $src, array $extArgs) {
return $extApi->extTagToDOM(
$extArgs,
'',
$src,
[
'wrapperTag' => 'span',
'parseOpts' => [
'extTag' => 'blockquote',
],
],
]
);
}
public function getInnerWikitext(ParsoidExtensionAPI $extApi, \DOMElement $dom) {
public function getInnerWikitext(ParsoidExtensionAPI $extApi, Element $dom) {
$wikiText = '';
foreach($dom->childNodes as $child){
if($child instanceof \DOMText){
@ -31,7 +31,7 @@ class BlockQuoteTagHandler extends ExtensionTagHandler {
return $wikiText;
}
public function domToWikitext(ParsoidExtensionAPI $extApi, \DOMElement $node, bool $wrapperUnmodified): string {
public function domToWikitext(ParsoidExtensionAPI $extApi, Element $node, bool $wrapperUnmodified): string {
$innerCode = $this->getInnerWikitext($extApi, $node);
return "<span>\n{$innerCode}\n</span>";
}

@ -3,14 +3,15 @@
namespace Isekai;
use MediaWiki\MediaWikiServices;
use Config;
use OutputPage;
use Html;
use Title;
use MediaWiki\Config\Config;
use MediaWiki\Output\OutputPage;
use MediaWiki\Html\Html;
use MediaWiki\Title\Title;
use MediaWiki\User\User;
use MediaWiki\EditPage\EditPage;
use MediaWiki\Linker\LinkRenderer;
use MediaWiki\Linker\LinkTarget;
use User;
use EditPage;
use MediaWiki\Parser\Parser;
use Isekai\Job\CheckActivatedEditorJob;
class Isekai {
@ -265,10 +266,10 @@ HTML
}
}
public static function onParserBeforeInternalParse(\Parser $parser, &$text, $strip_state) {
public static function onParserBeforeInternalParse(Parser $parser, &$text, $strip_state) {
$title = $parser->getPage();
if ($title !== null && $title instanceof \Title && $title->isSubpage()) {
if ($title !== null && $title instanceof Title && $title->isSubpage()) {
//更改显示的标题
$titleText = $title->getPrefixedText();
if ($titleText) {

@ -1,7 +1,7 @@
<?php
namespace Isekai;
use Html;
use MediaWiki\Html\Html;
class IsekaiChart {
/**

@ -1,11 +1,10 @@
<?php
namespace Isekai\Job;
use Exception;
use Isekai\MiscUtils;
use Job;
use MediaWiki\MediaWikiServices;
use Title;
use MediaWiki\Title\Title;
class CheckActivatedEditorJob extends Job {
public function __construct(Title $title, array $params){

@ -2,8 +2,8 @@
namespace Isekai;
use ApiMain;
use FauxRequest;
use User;
use MediaWiki\Request\FauxRequest;
use MediaWiki\User\User;
use MediaWiki\MediaWikiServices;
class MiscUtils {

@ -2,13 +2,9 @@
namespace Isekai\Maintenance;
use Maintenance;
use Config;
use ApiMain;
use FauxRequest;
use Isekai\MiscUtills;
use MediaWiki\Config\Config;
use Isekai\MiscUtils;
use MediaWiki\MediaWikiServices;
use Title;
use Wikimedia\Rdbms\IDatabase;
$IP = getenv( 'MW_INSTALL_PATH' );

@ -30,6 +30,63 @@ function updateVisualEditorConfig() {
} else {
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();
Loading…
Cancel
Save