User:Polygnotus/Scripts/VEbutton2.js: Difference between revisions

Content deleted Content added
Created page with '// Add a custom button to Wikipedia's Visual Editor // Add this code to your common.js page on Wikipedia // (e.g., https://en.wikipedia.org/wiki/User:YourUsername/common.js) // Wait for the VisualEditor to be ready mw.loader.using(['ext.visualEditor.desktopArticleTarget']).then(function() { mw.hook('ve.activationComplete').add(function() { console.log('VE activation hook fired'); // Wait a bit for the toolbar to fully initialize setTimeou...'
 
No edit summary
 
Line 76:
// Insert 'hello world' at the cursor position
var fragment = surface.getModel().getFragment();
fragment.insertContent('hello world at the cursor position', true);
});