<!DOCTYPE html>
<html>
<body>
<!--For convenience, this demo uses files from JSDelivr CDN; for more privacy and security download and host them yourself.-->
<script src="https://cdn.jsdelivr.net/gh/WebCoder49/code-input@2.8/code-input.min.js"></script>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/WebCoder49/code-input@2.8/code-input.min.css">
<!--Import-->
<script src="https://cdn.jsdelivr.net/gh/WebCoder49/code-input@2.8/plugins/indent.min.js"></script>
<script>
// Programatically opening the dialogs, to integrate with your user interface
function goToLine() {
goToLinePlugin.showPrompt(document.querySelector("code-input"));
}
codeInput.registerTemplate("no-indent", new codeInput.Template((elem) => { elem.style.background='lightblue'; }, false, false, false, []));
codeInput.registerTemplate("indent", new codeInput.Template((elem) => { elem.style.background='pink'; }, false, false, false, [new codeInput.plugins.Indent()]));
</script>
<button onclick="document.querySelector('code-input').setAttribute('template', 'no-indent');">Switch to 'no-indent'</button>
<code-input style="outline: 2px solid grey;" template="indent"><textarea data-code-input-fallback></textarea></code-input>
</body>
</html>
Steps to reproduce:
code-inputelement and press theTabkey.This changes the
code-inputelement from theindenttemplate which sets a pink background and tab-for-indent using the Indent plugin, to theno-indenttemplate which sets a blue background and has no Indent plugin.Expected outcome:
no-indenttemplate has been loaded.code-inputelement, because the currentno-indenttemplate does not have theIndentplugin.Actual outcome:
no-indenttemplate has been loaded.Indentplugin was not unloaded, and in fact plugins cannot ever be unloaded: they cannot define what to do on unload (i.e. unregister event handlers they previously registered). Check thecodeInput.PluginAPI - there is no "unload" function.