gnomek
1
The author of
Edit Field During Review (Cloze)
added option to add custom shortcut to execute any script in review window
Is there a JavaSript coder who can share such script, please.
Maybe it is possible to use some code from
editor.js from Remove Cloze Button and Hotkey, which has been updated recently.
gnomek
2
Here is the solution. Thank you very much to the author of this add-on @BlueGreenMagick and also to @jcznk for his contribution.
<script>
EFDRC.registerShortcut("Ctrl+Shift+Alt+R", (event, elem) => {
let selectedHTML = elem.innerHTML
if (!selectedHTML) {
return;
}
selectedHTML = selectedHTML.replace(
/\{\{c(\d+)::(.*?)(::(.*?))?\}\}/gm,
"$2"
);
// workaround for duplicate list items:
selectedHTML = selectedHTML.replace(/^(<li>)/, "");
elem.innerHTML = selectedHTML
})
</script>
1 Like