Skip to content

Commit

Permalink
fix bug where nothing new would be highlighted after saving a visual …
Browse files Browse the repository at this point in the history
…edit
  • Loading branch information
NovemLinguae committed Mar 20, 2024
1 parent cbb0584 commit e71718b
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions UserHighlighterSimple.js
Original file line number Diff line number Diff line change
Expand Up @@ -319,13 +319,22 @@ class UserHighlighterSimple {
}
}

// TODO: race condition with xtools gadget. sometimes it fails to highlight the xtools gadget's username link
// TODO: hook for after visual editor edit is saved?
// List of hooks: https://doc.wikimedia.org/mediawiki-core/master/js/Hooks.html#

// Fire after wiki content is added to the DOM, such as when first loading a page, or when a gadget such as the XTools gadget loads.
mw.hook('wikipage.content').add(async function() {
await mw.loader.using(['mediawiki.util', 'mediawiki.Uri', 'mediawiki.Title'], async function() {
let uhs = new UserHighlighterSimple($, mw, window);
await uhs.execute();
});
});

// Fire after an edit is successfully saved via JavaScript, such as edits by the Visual Editor and HotCat.
mw.hook('postEdit').add(async function() {
await mw.loader.using(['mediawiki.util', 'mediawiki.Uri', 'mediawiki.Title'], async function() {
let uhs = new UserHighlighterSimple($, mw, window);
await uhs.execute();
});
});

// </nowiki>

0 comments on commit e71718b

Please sign in to comment.