-
Notifications
You must be signed in to change notification settings - Fork 29
Description
If I've notified you, or you've just come across this, I'd love ❤️ it if you could give feedback (here or via email to [email protected]). However, feel free to take your time and don't feel you have to; I know you may be busy.
I'm thinking of rewriting most of the core of code-input and its architecture. The reasons are: architectural flaws, better modularity, and performance, all of which desire breaking changes:
Features
The current architecture that has existed since the start, where a code-input custom element that in reality contains a textarea is interacted with as if it were a textarea itself, requires quite a lot of glue code which can contain bugs, causes CSS problems, and isn't as easy to combine with other textarea-modifying code as it could be. Following code-input's existing focus on both using and mirroring the API of the native textarea for the majority of its functionality, a breaking-change architecture could lead to less core code being needed, and even better textarea support, by exposing a real textarea element to JavaScript and HTML then generating highlighted elements etc. based on interactions with it (e.g. a textarea class="code-input"
element for usage, instead of code-input
element). Plugin architecture is also problematic; more flexibility to add and remove plugins real-time would be useful (as suggested in #122).
Better modularity likely includes writing the library as ES modules (but other than that vanilla JavaScript) by default, separating the Plugin definition into another file so it doesn't need to be imported, separating templates, and bundling only the necessary features for a setup to a CDN. Encapsulation should be implemented and a public API exposed more strictly than just TypeScript definitions, for better classification of breaking changes. It also involves deleting deprecated, little-used functionality that is present for back-compatibility but is now largely causing bloat.
Performance involves only partially highlighting on input to reduce time complexity, as in #70. This isn't a breaking change but is quite a large change and to avoid bloat should be loaded as a separate module, suggesting better modularity which does require a breaking change.
I will also try to standardise the dialect of JavaScript being used for more portability across browsers, and not just use any JS/CSS feature.
I'm also considering releasing the new version under the MPL-2.0
license which allows plugins under any license, and use of the code in a project under any license (both like MIT) but preserves the availability of the library itself as open source by requiring edited versions of existing plugins and the core library (only those files) to be distributed with source code under an open source license. Do you have feedback on this?
The result should be a lighter, faster, and more flexible code-input.js library.
Maintenance
Security fixes should still be backported to version 2, but for other updates it shouldn't be too difficult to upgrade plugins to the new API, and usage in HTML is only one element so not much code to change. JavaScript usage shouldn't change much since the textarea interface is still a focus.
As always, before version 3, solving people's immediate problems in version 2 will be prioritised wherever practical.
Feedback
What do you all think? I'm unlikely to have time to implement this in code very soon, but feedback and/or patches to begin this are very much welcome, and in a future holiday I will have time. I'm working on a project right now that both wants this update at some point and is teaching me about concepts that would be helpful in the update.
Notifying those who have contributed code/docs and thus interacted with the architecture: @vanowm, @MattiasBuelens, @paulrosen, @andrelsm, @mitchcapper, @eyaler, @keithjgrant, @RobertBlackhart
Notifying some people relevant to: architecture @nikita51bot (from #122); modularity @paulrouget, @Bowrna; performance @andrelsm (yes, I know you said it probably isn't worth it but with a more modular architecture it will be possible and is quite a large hurdle to adoption; and with e.g. line-based highlighting could likely be quite versatile across all (regex-based) highlighters), @KaiWilke
Everyone else is also welcome to comment.