I have created a plugin called Frappe Better Attach Control which extends several attachment related javascript libraries but it doesn’t get loaded for Web Forms…
Useing the hooks webform_include_js and webform_include_css is meant to inject files to specific standard web forms so I can’t use it to make the plugin work in all web forms…
I have also tried injecting the plugin files directly to the context using the hook update_website_context but it seems that the hook gets ececuted before the web form code so the hook can’t determine if the current context is for a web page or a web form…
Even if I don’t check the context for what does it belong to and directly load the files into the context, the code for standard web forms override the scripts and styles instead of appending if previous value exists so all scripts and styles I load will be removed from the context…
Finally, my question is does anyone of you know how I can load my plugin for web forms?
I have checked everywhere but I couldn’t find a solution. You guys are my last resort, so any help will be appreciated…
I have managed to make it work. It’s funny how talking to yourself can be helpful sometimes
So let me share the what must be done with you…
If you want to manually inject JavaScript and/or CSS files to Web Form, you need to do the following…
For JavaScript, the code must not include import and export but if it does, then the file must be compiled using esbuild. It’s better to use a separate compiled file for Web Form and the original is kept for Desk
In the hooks.py file, add a custom hook key to store the list of paths for the JavaScript and/or CSS files