MediaWiki:Common.js: Unterschied zwischen den Versionen
Aus RI Wiki
				
				
				Zur Navigation springenZur Suche springen
				
				
| Keine Bearbeitungszusammenfassung | Keine Bearbeitungszusammenfassung | ||
| Zeile 24: | Zeile 24: | ||
|              ); |              ); | ||
|          } |          } | ||
|          // --- Define the tool --- |          // --- Define the tool --- | ||
| Zeile 33: | Zeile 32: | ||
|          OO.inheritClass(HighlightTool, ve.ui.Tool); |          OO.inheritClass(HighlightTool, ve.ui.Tool); | ||
|          HighlightTool.static.name = 'highlight'; |          HighlightTool.static.name = 'highlight'; | ||
|          HighlightTool.static.group = ' |          HighlightTool.static.group = 'format'; // Try 'format' group | ||
|          HighlightTool.static.icon = 'highlight'; |          HighlightTool.static.icon = 'highlight'; | ||
|          HighlightTool.static.title = 'Highlight text'; |          HighlightTool.static.title = 'Highlight text'; | ||
| Zeile 41: | Zeile 40: | ||
|              ve.ui.toolFactory.register(HighlightTool); |              ve.ui.toolFactory.register(HighlightTool); | ||
|          } |          } | ||
|         // Debug: Check if tool is registered | |||
|         console.log('Highlight tool registered:', ve.ui.toolFactory.lookup('highlight')); | |||
|      }); |      }); | ||
| }); | }); | ||
Version vom 3. September 2025, 20:31 Uhr
mw.loader.using('ext.visualEditor.desktopArticleTarget.init').then(function () {
    mw.hook('ve.activationComplete').add(function () {
        // --- Define the command ---
        function doHighlight(surface) {
            var fragment = surface.getModel().getFragment();
            var selectedText = fragment.getText();
            if (!selectedText) {
                return;
            }
            fragment.insertContent('{{Highlight|' + selectedText + '|yellow}}');
        }
        
        var commandName = 'insertHighlight';
        
        // Register command
        if (!ve.ui.commandRegistry.lookup(commandName)) {
            ve.ui.commandRegistry.register(
                new ve.ui.Command(
                    commandName,
                    'content',
                    'exec',
                    { args: [doHighlight] }
                )
            );
        }
        
        // --- Define the tool ---
        function HighlightTool(toolGroup, config) {
            ve.ui.Tool.call(this, toolGroup, config);
        }
        
        OO.inheritClass(HighlightTool, ve.ui.Tool);
        HighlightTool.static.name = 'highlight';
        HighlightTool.static.group = 'format'; // Try 'format' group
        HighlightTool.static.icon = 'highlight';
        HighlightTool.static.title = 'Highlight text';
        HighlightTool.static.commandName = commandName;
        
        if (!ve.ui.toolFactory.lookup('highlight')) {
            ve.ui.toolFactory.register(HighlightTool);
        }
        // Debug: Check if tool is registered
        console.log('Highlight tool registered:', ve.ui.toolFactory.lookup('highlight'));
    });
});