페미위키:개선요청의 토론 주제

현재 시각 편집기에 {{주}}를 사용하는 별도 메뉴가 존재하지 않습니다.

그래서 시각편집기에 다음 동영상에서 보시는 것과 같은 메뉴가 추가되는 스크립트(붙임 1번)를 만들었습니다(동영상을 찍고 스크립트를 좀 더 수정해서 살짝 다르긴 합니다).

해당 스크립트를 미디어위키:common.js에 추가 요청드립니다.

붙임 1번
function addCommentTemplateTool() {
	//command name for registeration
	function commentTemplate() {}

	//Create and register command
	function CommentTemplate() {
		CommentTemplate.parent.call( this, 'commentTemplate' );
	}
	OO.inheritClass( CommentTemplate, ve.ui.Command );

	CommentTemplate.prototype.execute = function( surface ) {
		var surfaceModel = surface.getModel(),
			doc = surfaceModel.getDocument();
			
		var widget = surfaceModel.getFragment().collapseToEnd().insertContent(
		  [
		    {
		      type: 'mwTransclusionInline',
		      attributes: {
		        mw: {
		          parts: [
		            {
		              template: {
		                target: {
		                  href: '틀:주',
		                  wt: '주'
		                },
		                params: {
		                  1: { wt: '본문' },
		                }
		              }
		            }
		          ]
		        }
		      }
		    },
			{ type: '/mwTransclusionInline' }
		  ]
		);
		
		return true;
	};

	ve.ui.commandRegistry.register( new CommentTemplate() );

	//Create, register and insert tool
	function CommentTemplateTool() {
		CommentTemplateTool.parent.apply( this, arguments );
	}
	OO.inheritClass( CommentTemplateTool, ve.ui.Tool );

	CommentTemplateTool.static.name = 'commentTemplate';
	CommentTemplateTool.static.group = 'utility';
	CommentTemplateTool.static.title = '부연 설명';
	CommentTemplateTool.static.icon = 'reference';
	CommentTemplateTool.static.commandName = 'commentTemplate';
	CommentTemplateTool.static.autoAddToCatchall = false;
	CommentTemplateTool.static.deactivateOnSelect = false;

	CommentTemplateTool.prototype.onUpdateState = function() {
		CommentTemplateTool.parent.prototype.onUpdateState.apply( this, arguments );
		this.setActive( false );
	};

	ve.ui.toolFactory.register( CommentTemplateTool );
	
	var toolbarGroups = ve.init.mw.Target.static.toolbarGroups;
	toolbarGroups[ 4 ].include.push( 'commentTemplate' );
}

//Initialize
mw.loader.using( 'ext.visualEditor.desktopArticleTarget.init' ).done( function() {
	mw.libs.ve.addPlugin( function() {
		mw.loader.using( [ 'ext.visualEditor.core' ] )
			.done( function() {
				addCommentTemplateTool();
			} );
	} );
} );