Skip to content

Instantly share code, notes, and snippets.

@jdlrobson
Created July 13, 2022 00:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jdlrobson/d555904f1739561a7e614d882acc0712 to your computer and use it in GitHub Desktop.
Save jdlrobson/d555904f1739561a7e614d882acc0712 to your computer and use it in GitHub Desktop.
Example code of how a Math preview could be registered
// do this on the server
document.querySelectorAll('.mwe-math-element img').forEach((node) => {
node.dataset.title = 'math-unique-identifier';
});
const previewType = 'math'
mw.popups.register(previewType, '.mwe-math-element img', {
fetchPreviewForTitle: function ( title, el ) {
console.log('fetch', title, el);
const model = {
title: 'Math',
url: `#infoboxLink-${encodeURIComponent(title)}`,
extract: 'Hello world',
type: previewType,
thumbnail: undefined,
pageId: -1
};
return $.Deferred().resolve( model )
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment