mwstake/mediawiki-component-generictaghandler 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

mwstake/mediawiki-component-generictaghandler

最新稳定版本:1.0.3

Composer 安装命令:

composer require mwstake/mediawiki-component-generictaghandler

包简介

Provides a generic tag handler interface for MediaWiki

README 文档

README

Register tags

Tag definition

Implement an instance of MWStake\MediaWiki\Component\GenericTagHandler\ITag interface and register it:

// By global $GLOBALS['mwsgGenericTagRegistry'] = [ 'class' => 'MyClass', 'services' => [ '...' ] ]; // By hook $wgHooks['MWStakeGenericTagHandlerInitTags'][] = function ( &$tags ) { $tags[] = new MyTag(...); }; // By registry $registry = \MediaWiki\MediaWikiServices::getInstance()->getService( 'MWStake.GenericTagHandler.TagFactory' ); $registry->register( new MyTag( ... ) );

VisualEditor integration (over VisualEditorPlus)

You can return a MWStake\MediaWiki\Component\GenericTagHandler\ClientTagSpecification from your tag implementation to automatically register a tag in VisualEditor.

Without a custom form

Pass null to $formSpecification param to let the default form be used.

With server-side-defined form

Pass a MWStake\MediaWiki\Component\FormEngine\StandaloneFormSpecification object to $formSpecification param to use a custom form.

$formSpec = new StandaloneFormSpecification(); $formSpec->setItems( [ [ 'type' => 'text', 'name' => 'field', 'label' => 'My field', ], [ 'type' => 'checkbox', 'name' => 'framed', 'label' => 'Is framed' ], ] ); 

With client-side defined form

You can implement an instance of mw.ext.forms.standalone.Form client-side and use it in the ClientTagSpecification

For that you would pass a MWStake\MediaWiki\Component\FormEngine\FormLoaderSpecification as $formSpecification param.

$formSpec = new FormLoaderSpecification( 'my.form.class', [ 'modules.loading.the.form.class' ] );

Register custom VisualEditor definition classes

In very specific cases you may want to override the default VisualEditor tag definition class

Load a JS file using getResourceLoaderModules method, that will override the tag class

mw.hook( 'ext.visualEditorPlus.tags.getTagDefinition' ).add( ( definitionData, tagDefinition ) => { if ( definitionData.tagname !== 'myfancytag' ) { return; } // definition data contains the info from `ClientTagSpecification` tagDefinition = new my.class.inheriting.from.ext.visualEditorPlus.ui.tags.Definition( { ... data } ); };

In this case, you would likely pass null to $formSpecification param in the PHP class.

统计信息

  • 总下载量: 3.68k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 2
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 4
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: GPL-3.0-only
  • 更新时间: 2026-01-04

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固