Created a CodeInjector class which handles all the notebook code injection related functions. This allows for improved separation of concerns and makes code injection functionality modular so that the functions can be called from any components that have access to the code injection object. The CodeInjector is instantiated when the sidebar is first initialized and then it can be passed as a prop to any components that need to perform code injection functions. The widgets file is significantly reduced in size and complexity, and the error handling is standardized within the code injector class. Also code injector functions provide more information if an error occurs, including the code used in the command and variables values that were passed to the function. From now on, any new injection functions can be implemented in this one place and can then be run from various other components.
Created a CodeInjector class which handles all the notebook code injection related functions. This allows for improved separation of concerns and makes code injection functionality modular so that the functions can be called from any components that have access to the code injection object. The CodeInjector is instantiated when the sidebar is first initialized and then it can be passed as a prop to any components that need to perform code injection functions. The widgets file is significantly reduced in size and complexity, and the error handling is standardized within the code injector class. Also code injector functions provide more information if an error occurs, including the code used in the command and variables values that were passed to the function. From now on, any new injection functions can be implemented in this one place and can then be run from various other components.