提供: defeatedcrow mod wiki
移動先: 案内検索
8行目: 8行目:
 
         tools: {
 
         tools: {
 
             buttonId: {
 
             buttonId: {
                 label: 'Comment visible only for editors',
+
                 label: 'Comment',
 
                 type: 'button',
 
                 type: 'button',
                 icon: '//defeatedcrow.jp/modwiki/extensions/WikiEditor/modules/images/toolbar/aformat-italic-C.png',
+
                 icon: '//defeatedcrow.jp/modwiki/extensions/WikiEditor/modules/images/toolbar/format-italic-C.png',
 
                 action: {
 
                 action: {
 
                     type: 'encapsulate',
 
                     type: 'encapsulate',
36行目: 36行目:
 
                         peri: 'Insert sode here',
 
                         peri: 'Insert sode here',
 
                         post: '<source>'
 
                         post: '<source>'
 +
                    }
 +
                }
 +
            }
 +
        }
 +
    } );
 +
    $( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
 +
        section: 'advanced',
 +
        group: 'format',
 +
        tools: {
 +
            buttonId: {
 +
                label: 'red',
 +
                type: 'button',
 +
                icon: '//defeatedcrow.jp/modwiki/extensions/WikiEditor/modules/images/toolbar/color-red.png',
 +
                action: {
 +
                    type: 'encapsulate',
 +
                    options: {
 +
                        pre: '<pre style="color: red">',
 +
                        peri: 'Insert text',
 +
                        post: '</pre>'
 +
                    }
 +
                }
 +
            }
 +
        }
 +
    } );
 +
    $( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
 +
        section: 'advanced',
 +
        group: 'format',
 +
        tools: {
 +
            buttonId: {
 +
                label: 'blue',
 +
                type: 'button',
 +
                icon: '//defeatedcrow.jp/modwiki/extensions/WikiEditor/modules/images/toolbar/color-blue.png',
 +
                action: {
 +
                    type: 'encapsulate',
 +
                    options: {
 +
                        pre: '<pre style="color: blue">',
 +
                        peri: 'Insert text',
 +
                        post: '</pre>'
 
                     }
 
                     }
 
                 }
 
                 }

2016年3月8日 (火) 13:17時点における版

jQuery( document ).ready( function ( $ ) {
$( 'div#edittoolbar' ).wikiEditor();

var customizeToolbar = function() {
	   $( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
        section: 'advanced',
        group: 'format',
        tools: {
            buttonId: {
                label: 'Comment',
                type: 'button',
                icon: '//defeatedcrow.jp/modwiki/extensions/WikiEditor/modules/images/toolbar/format-italic-C.png',
                action: {
                    type: 'encapsulate',
                    options: {
                        pre: '<!-- ',
                        peri: 'Insert comment here',
                        post: ' -->'
                    }
                }
            }
        }
    } );
    $( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
        section: 'advanced',
        group: 'format',
        tools: {
            buttonId: {
                label: 'source code',
                type: 'button',
                icon: '//defeatedcrow.jp/modwiki/extensions/WikiEditor/modules/images/toolbar/add-code.png',
                action: {
                    type: 'encapsulate',
                    options: {
                        pre: '<source lang="java">',
                        peri: 'Insert sode here',
                        post: '<source>'
                    }
                }
            }
        }
    } );
    $( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
        section: 'advanced',
        group: 'format',
        tools: {
            buttonId: {
                label: 'red',
                type: 'button',
                icon: '//defeatedcrow.jp/modwiki/extensions/WikiEditor/modules/images/toolbar/color-red.png',
                action: {
                    type: 'encapsulate',
                    options: {
                        pre: '<pre style="color: red">',
                        peri: 'Insert text',
                        post: '</pre>'
                    }
                }
            }
        }
    } );
    $( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
        section: 'advanced',
        group: 'format',
        tools: {
            buttonId: {
                label: 'blue',
                type: 'button',
                icon: '//defeatedcrow.jp/modwiki/extensions/WikiEditor/modules/images/toolbar/color-blue.png',
                action: {
                    type: 'encapsulate',
                    options: {
                        pre: '<pre style="color: blue">',
                        peri: 'Insert text',
                        post: '</pre>'
                    }
                }
            }
        }
    } );
};

/* Check if view is in edit mode and that the required modules are available. Then, customize the toolbar … */
if ( $.inArray( mw.config.get( 'wgAction' ), [ 'edit', 'submit' ] ) !== -1 ) {
	mw.loader.using( 'user.options', function () {
		// This can be the string "0" if the user disabled the preference ([[phab:T54542#555387]])
		if ( mw.user.options.get( 'usebetatoolbar' ) == 1 ) {
			$.when(
				mw.loader.using( 'ext.wikiEditor.toolbar' ), $.ready
			).then( customizeToolbar );
		}
	} );
}
// Add the customizations to LiquidThreads' edit toolbar, if available
mw.hook( 'ext.lqt.textareaCreated' ).add( customizeToolbar );
} );