이 게시물의 하나의 판에 대한 영구 링크 입니다.
이 판은 2017년 6월 13일 (화) 것이며 그 이전 판과의 차이를 볼 수 있고 게시물 역사 문서에서는 다른 판들도 볼 수 있습니다.
현재 시각 편집기에 {{주}}를 사용하는 별도 메뉴가 존재하지 않습니다.
그래서 시각편집기에 다음 동영상에서 보시는 것과 같은 메뉴가 추가되는 스크립트(붙임 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: '주' } } } ] } } }, { 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 = 'object'; CommentTemplateTool.static.title = '부연 설명'; CommentTemplateTool.static.icon = 'reference'; CommentTemplateTool.static.commandName = 'commentTemplate'; CommentTemplateTool.static.modelClasses = ve.ui.toolFactory.lookup('reference').static.modelClasses; CommentTemplateTool.static.autoAddToCatchall = 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 ].label='각주'; toolbarGroups[ 4 ].include.push( 'commentTemplate' ); ve.ui.toolFactory.lookup('reference').static.title='출처'; ve.ui.toolFactory.lookup('reference/existing').static.title='출처 재사용'; } //Initialize mw.loader.using( 'ext.visualEditor.desktopArticleTarget.init' ).done( function() { mw.libs.ve.addPlugin( function() { mw.loader.using( [ 'ext.visualEditor.core' ] ).done( function() { addCommentTemplateTool(); } ); } ); } ); var customizeToolbar = function () { /* 왠지 작동 안함 $( '#wpTextbox1' ).on( 'wikiEditor-toolbar-buildSection-main', function( event, section ) { delete section.groups.insert.tools.reference["labelMsg"]; section.groups.insert.tools.reference.label = '출처'; } );*/ $( '#wpTextbox1' ).wikiEditor( 'addToToolbar', { 'section': 'main', 'group': 'insert', 'tools': { 'comment': { label: '부연 설명', type: 'button', icon: { sv: 'insert-reference.png' }, offset:{ sv: [2, -1798] }, action: { type: 'encapsulate', options: { pre: "{{주|", post: "}}" } } } } } ); }; if ( $.inArray( mw.config.get( 'wgAction' ), [ 'edit', 'submit' ] ) !== -1 ) { mw.loader.using( 'user.options' ).then( function () { if ( mw.user.options.get( 'usebetatoolbar' ) == 1 ) { $.when( mw.loader.using( 'ext.wikiEditor.toolbar' ), $.ready ).then( customizeToolbar ); } } ); } |
(6/13 추가)원본편집기 편집 도구 모음에도 추가했습니다.