<!DOCTYPE html><html><body><!--For convenience, this demo uses files from JSDelivr CDN; for more privacy and security download and host them yourself.--><scriptsrc="https://cdn.jsdelivr.net/gh/WebCoder49/code-input@2.8/code-input.min.js"></script><linkrel="stylesheet" href="https://cdn.jsdelivr.net/gh/WebCoder49/code-input@2.8/code-input.min.css"><!--Import--><scriptsrc="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 interfacefunctiongoToLine(){goToLinePlugin.showPrompt(document.querySelector("code-input"));}codeInput.registerTemplate("no-indent",newcodeInput.Template((elem)=>{elem.style.background='lightblue';},false,false,false,[]));codeInput.registerTemplate("indent",newcodeInput.Template((elem)=>{elem.style.background='pink';},false,false,false,[newcodeInput.plugins.Indent()]));</script><buttononclick="document.querySelector('code-input').setAttribute('template', 'no-indent');">Switch to 'no-indent'</button><code-inputstyle="outline: 2px solid grey;" template="indent"><textareadata-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.