Open pavelvasev opened 1 year ago
Hi, perhaps something like this would work:
index.html:
...
<link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/npm/pdbe-molstar@3.3.0/build/pdbe-molstar.css">
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/pdbe-molstar@3.3.0/build/pdbe-molstar-plugin.js"></script>
<script type="text/javascript" src="hack.js"></script>
...
const viewerContainer = document.getElementById('myViewer');
viewerInstance.render(viewerContainer, options).then(() => {
registerCustomColorTheme(viewerInstance.plugin);
});
...
Your hack.ts (or hack.js):
import { type PluginContext } from 'molstar/lib/mol-plugin/context';
import { type RepresentationProvider } from 'molstar/lib/mol-repr/representation';
const provider = { /* ... */ } as RepresentationProvider;
function registerCustomColorTheme(plugin: PluginContext) {
plugin.representation.structure.registry.add(provider);
}
(window as any).registerCustomColorTheme = registerCustomColorTheme;
As we only import types, they shouldn't end up in the hack.js bundle (or you can just forget types and write in plain Javascript if you prefer).
Another option is creating your custom build.
But instead of forking the pdbe-molstar
repo I would recommend including pdbe-molstar
as dependency of your project.
Then you can just import { PDBeMolstarPlugin } from 'pdbe-molstar/lib/viewer'
and extend PDBeMolstarPlugin
class (registering your provider in the overridden render
method, I think).
Hi there!
I want to use PDBeMolstarPlugin in my project. And I want to configure it to use my custom ColorTheme component.
representation.structure.themes.colorThemeRegistry.add
call and activate usingplugin.managers.structure.component.updateRepresentationsTheme
. Seems this will work.Now I try to understand, how ColorerX may use webpacked Molstar modules which are located in pdbe-molstar-plugin-3.1.0.js file?
Please give me an advice, how my ColorerX component might use Molstar modules from pdbe-molstar-plugin? While keeping pdbe-molstar and ColorerX as separate projects. I am new to webpack and tryied to resolve that, but still failed to find a solution.
Many thanks in advance!