Welcome to Software Development on Codidact!
Will you help us build our independent community of developers helping developers? We're small and trying to grow. We welcome questions about all aspects of software development, from design to code to QA and more. Got questions? Got answers? Got code you'd like someone to review? Please join us.
Comments on How to access the visual editor from JavaScript in MediaWiki?
Post
How to access the visual editor from JavaScript in MediaWiki?
In MediaWiki 1.36.1 with Skin:Timeless, the following JavaScript code doesn't work. I get in browser console:
Your skin is incompatible with VisualEditor.
See https://www.mediawiki.org/wiki/Extension:VisualEditor/Skin_requirements for the requirements.
That's strange because right after installing Visual Editor, when I first came to edit, I was asked if I want to use the source code editor OR the visual editor and when I chose the Visual Editor, it worked fine.
let domain = window.location.host;
let protocol = window.location.protocol;
let h1 = document.querySelector("h1");
window.addEventListener('keydown', function(event) {
if (event.altKey && event.shiftKey && event.key === 'E') {
window.location.href = `${protocol}//${domain}/index.php?title=${h1.innerText}&veaction=edit`;
}
});
Why do I get the above error in console and how to solve it?
Notes
- I emphasize the
veaction=edit
instead justaction=edit
in this code - Credit for user:hkotsubo†who wrote most of that code
1 comment thread