GrapesJS / grapesjs

Free and Open source Web Builder Framework. Next generation tool for building templates without coding
https://grapesjs.com
BSD 3-Clause "New" or "Revised" License
20.6k stars 3.89k forks source link

[Editor UI]: Replace the current View for the core editor UI components #2282

Open pouyamiralayi opened 4 years ago

pouyamiralayi commented 4 years ago

Hi there! the currently used structure of grapesjs is based on leveraging backbonejs model-view concept for implementing the Virtual Dom inside the ecosystem of grapesjs. Virtual Dom is a great practice which has a vast area of applications and benefits; but the downside of virtual dom is the actual gap between virtual and actual dom itself, what this means is that the usage of virtual dom is some sort of performance sacrifice in order to achieve the model-view concept which is the already established architecture of grapesjs, react, vue & etc. based on the real-time nature of grapesjs and its ability to manage thousands of model objects based on each user interaction, there are cases that performance is poorly appreciated on model updates that as it's result there would be no real-time experience for the end user. as an example of this scenario think about calling addAttributes for property changes on a complex component type that will be invoked every time the end user provides us with new inputs in the associated trait section; each time that user presses a key, there would be a noticeable delay for the model to updates the attributes of the target component according to the user input. my proposal on this matter is to get rid of virtual dom in the sack of hyperhtml that benefits from actual dom that are bounded to a context object that acts as our current model. the way hyperhtml is achieving the model-view concept for actual dom is leveraging js native template literals and it's associated chunks and interpolations. i know this is a very scary taboo for the current implementation :) but i think if grapesjs architecture has been started up with backbone, the sub parts of the ecosystem should not follow the same lead although this is a common implication in the development path of a complex project like grapesjs; backbone can be really tempting to push developers mind to go with it until the end, but i am suggesting more flexibility by separating grapesjs into a solid core with backbone and all the other parts leveraging hyperhtml to introduce a more lightweight, performance friendly ecosystem that embraces the future with no fear of performance breakdowns. i am a very naive developer and please forgive me if i am going wrong with this. hyperhtml cheers.

lexoyo commented 7 months ago

Nice idea I use lit-html quite lot, it's the same approach but also adds web components when/if needed But i don't get where would backbone stop? And what would be without it. I guess it is a question that is broader about what @artf announced in the roadmap (taking things out of the core)

artf commented 7 months ago

Yes @lexoyo the final goal here would be to stop relying on Backbone's View and migrate all editor UI elements to web components. In the end, there will be @grapesjs/core (no UI) and @grapesjs/core-ui with a set of reusable and extendable web components for the editor UI

lexoyo commented 7 months ago

Ok that's interesting :) I can't wait to see that and i will contribute as much as i can