이 게시물의 하나의 판에 대한 영구 링크 입니다.
이 판은 2017년 6월 13일 (화) 것이며 그 이전 판과의 차이를 볼 수 있고 게시물 역사 문서에서는 다른 판들도 볼 수 있습니다.
현재 시각 편집기에 {{주}}를 사용하는 별도 메뉴가 존재하지 않습니다.
그래서 시각편집기에 다음 동영상에서 보시는 것과 같은 메뉴가 추가되는 스크립트(붙임 1번)를 만들었습니다(동영상을 찍고 스크립트를 좀 더 수정해서 살짝 다르긴 합니다).
해당 스크립트를 미디어위키:common.js에 추가 요청드립니다.
붙임 1번 |
---|
//시각편집기에 {{주}} 입력 툴 넣기 function addCommentTemplateToolToVisualEditor() { //'주'틀을 입력해 주는 커맨드 만들기 function commentTemplate() {} function CommentTemplate() { CommentTemplate.parent.call( this, 'commentTemplate' ); } OO.inheritClass( CommentTemplate, ve.ui.Command ); CommentTemplate.prototype.execute = function( surface ) { var surfaceModel = surface.getModel(), //선택된 것이 있으면 뒤로 이동하고 틀을 추가 widget = surfaceModel.getFragment().collapseToEnd().insertContent( [ { type: 'mwTransclusionInline', attributes: { mw: { parts: [ { template: { target: { href: '틀:주', wt: '주' } } } ] } } }, { type: '/mwTransclusionInline' } ] ); return true; }; //만든 커맨드 등록 ve.ui.commandRegistry.register( new CommentTemplate() ); //등록된 커맨드를 실행하는 툴 (메뉴) 만들기 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 ].include.push( 'commentTemplate' ); //기존 툴 레이블 변경 toolbarGroups[ 4 ].label='각주'; ve.ui.toolFactory.lookup('reference').static.title='출처'; ve.ui.toolFactory.lookup('reference/existing').static.title='출처 재사용'; } mw.loader.using( 'ext.visualEditor.desktopArticleTarget.init' ).done( function() { mw.libs.ve.addPlugin( function() { mw.loader.using( [ 'ext.visualEditor.core' ] ).done( function() { addCommentTemplateToolToVisualEditor(); } ); } ); } ); //위키편집기에 {{주}} 입력 툴 넣기 var addCommentTemplateToolToWikiEditor = function () { //툴바에 {{주|}}로 감싸주는 툴 추가 $( '#wpTextbox1' ).wikiEditor( 'addToToolbar', { 'section': 'main', 'group': 'insert', 'tools': { 'comment': { label: '부연 설명', type: 'button', icon: {}, offset: [2, -1798], action: { type: 'encapsulate', options: { pre: "{{주|", peri: "여기에 각주 내용을 적어 주세요", 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( addCommentTemplateToolToWikiEditor ); } } ); } //위키편집기 기존 메뉴 이름 바꾸기(왠지 작동 안함) //https://www.mediawiki.org/wiki/Extension:WikiEditor/Toolbar_customization#Modifying_things // $( '#wpTextbox1' ).on( 'wikiEditor-toolbar-buildSection-main', function( event, section ) { // console.log('on wikiEditor-toolbar-buildSection-main'); // delete section.groups.insert.tools.reference.labelMsg; // section.groups.insert.tools.reference.label = '출처'; // //배열 내용은 확인해보면 바뀌어 있는데 정작 메뉴는 바뀌지 않습니다. // } ); |
(6/13 추가)원본편집기 편집 도구 모음에도 추가했습니다.