User:Artoria2e5/ve-editor-button.js

注意:保存之后,你必须清除浏览器缓存才能看到做出的更改。Google ChromeFirefoxMicrosoft EdgeSafari:按住⇧ Shift键并单击工具栏的“刷新”按钮。参阅Help:绕过浏览器缓存以获取更多帮助。

function addVEButton(button) {
    button.iconUrlVis ||= button.iconUrl
	mw.loader.using('mediawiki.util').done(function () {
		mw.util.addCSS(
			'.oo-ui-icon-ATB' + button.id + ' {' +
				'background-image: url(' + button.iconUrlVis + ');' +
			'}'
		);
	} );
    
    function ATBButton {
        ATBButton.super.apply(this, arguments);
    }
    OO.inheritClass(ATBButton, OO.ui.Tool);
    
    ATBButton.static.name = 'ATB' + button.id;
    ATBButton.static.icon = 'ATB' + button.id;
    ATBButton.static.title = 'ATB' + button.id;

    /** 
    ATBButton.static.commandName = 'ATB' + button.id;
    // button.tooltip 
    
    ve.ui.commandRegistry.register(
        new ve.ui.Command(
            // Command name
            'ATB' + button.id,
            // Type and name of the action to execute
            'content', 'insert', // Calls the ve.ui.ContentAction#insert method
            {
                // Extra arguments for the action
                args: [
                    // Content to insert
                    [
                        { type: 'break' },
                        { type: '/break' }
                    ],
                    // Annotate content to match surrounding annotations?
                    true,
                    // Move cursor to after the new content? (otherwise - select it)
                    true
                ],
                supportedSelections: [ 'linear' ]
            }
        )
    );
    */
    
    ATBButton.prototype.onSelect = function () {
        
    }
    
    ve.ui.toolFactory.register(ATBButton);