마지막 의견: 2017년 5월 6일 (토) (렌즈님) - 주제: 추가 요청:시각편집기 "주" 틀 입력 도구 추가 스크립트
위와 같은 스크립트입니다.
이 글을 보려면 오른쪽 '펼치기' 버튼 클릭 |
---|
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(); surfaceModel.getFragment().collapseToEnd().insertContent( [ { type: 'mwTransclusionInline', attributes: { mw: { parts: [ { template: { target: { href: '틀:주', wt: '주' }, params: { 1: { wt: '본문' }, } } } ] } } } ] ).collapseToEnd().select(); 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(); } ); } ); } ); |
감사합니다. --렌즈 (토론) 2017년 5월 6일 (토) 20:31 (KST)답변[답변]