-
-
Save jdlrobson/d555904f1739561a7e614d882acc0712 to your computer and use it in GitHub Desktop.
Example code of how a Math preview could be registered
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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