MediaWiki:Common.js: Unterschied zwischen den Versionen
Aus RI Wiki
Zur Navigation springenZur Suche springen
Keine Bearbeitungszusammenfassung |
Keine Bearbeitungszusammenfassung |
||
Zeile 1: | Zeile 1: | ||
mw. | mw.hook('ve.loadModules').add(function (addPlugin) { | ||
addPlugin(function () { | |||
// Register command | |||
ve.ui.commandRegistry.register( | |||
new ve.ui.Command('insertHighlight', 'content', 'insert', { | |||
args: [ | |||
[ | |||
{ | |||
type: 'mwTransclusionInline', | |||
attributes: { | |||
mw: { | |||
parts: [{ | |||
template: { | |||
target: { | |||
href: 'Template:Highlight', | |||
wt: 'Highlight' | |||
}, | |||
params: { | |||
1: { wt: 'selected text' }, // Placeholder, replaced dynamically | |||
2: { wt: 'yellow' } | |||
} | |||
} | |||
}] | |||
} | |||
} | |||
}, | |||
{ type: '/mwTransclusionInline' } | |||
], | |||
false, // Annotate | |||
true // Collapse selection | |||
], | |||
supportedSelections: ['linear'] | |||
}) | |||
); | |||
// Register tool | |||
function HighlightTool() { | |||
HighlightTool.super.apply(this, arguments); | |||
} | } | ||
OO.inheritClass(HighlightTool, ve.ui.Tool); | OO.inheritClass(HighlightTool, ve.ui.Tool); | ||
HighlightTool.static.name = 'highlight'; | HighlightTool.static.name = 'highlight'; | ||
HighlightTool.static.group = 'insert'; | HighlightTool.static.group = 'insert'; | ||
HighlightTool.static.icon = 'highlight'; | HighlightTool.static.icon = 'highlight'; | ||
HighlightTool.static.title = 'Highlight text'; | HighlightTool.static.title = 'Highlight text'; | ||
HighlightTool.static.commandName = | HighlightTool.static.commandName = 'insertHighlight'; | ||
ve.ui.toolFactory.register(HighlightTool); | |||
console.log('Highlight tool and command registered.'); | |||
}); | }); | ||
}); | }); |
Version vom 3. September 2025, 21:52 Uhr
mw.hook('ve.loadModules').add(function (addPlugin) {
addPlugin(function () {
// Register command
ve.ui.commandRegistry.register(
new ve.ui.Command('insertHighlight', 'content', 'insert', {
args: [
[
{
type: 'mwTransclusionInline',
attributes: {
mw: {
parts: [{
template: {
target: {
href: 'Template:Highlight',
wt: 'Highlight'
},
params: {
1: { wt: 'selected text' }, // Placeholder, replaced dynamically
2: { wt: 'yellow' }
}
}
}]
}
}
},
{ type: '/mwTransclusionInline' }
],
false, // Annotate
true // Collapse selection
],
supportedSelections: ['linear']
})
);
// Register tool
function HighlightTool() {
HighlightTool.super.apply(this, arguments);
}
OO.inheritClass(HighlightTool, ve.ui.Tool);
HighlightTool.static.name = 'highlight';
HighlightTool.static.group = 'insert';
HighlightTool.static.icon = 'highlight';
HighlightTool.static.title = 'Highlight text';
HighlightTool.static.commandName = 'insertHighlight';
ve.ui.toolFactory.register(HighlightTool);
console.log('Highlight tool and command registered.');
});
});