-
Notifications
You must be signed in to change notification settings - Fork 73
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Showcase: Use standalone Smiles Drawer in a typescript project #172
Comments
Thanks! Can you please post a minimal example that shows how to use this in React.js? |
I did try combining React with my project, https://github.com/Acylation/obsidian-chem-indev, in which it successfully identify the package while no actual rendering example had I implemented. Maybe you can try this #157 (comment) The quoted example calls declare module 'smiles-drawer' {
class SmiDrawer {
constructor(moleculeOptions?: object, reactionOptions?: object);
static apply(
moleculeOptions?: object,
reactionOptions?: object,
attribute?: string | undefined,
theme?: string,
successCallback?: CallableFunction,
errorCallback?: CallableFunction
): void;
apply(
attribute?: string,
theme?: string,
successCallback?: CallableFunction,
errorCallback?: CallableFunction
): void;
draw(
smiles: string,
target:
| HTMLElement
| SVGElement
| HTMLImageElement
| string
| 'svg'
| 'canvas'
| 'img'
| null,
theme?: string,
successCallback?: CallableFunction,
errorCallback?: CallableFunction,
weights?: number[] | object
): void;
drawMolecule(
smiles: string,
target:
| HTMLElement
| SVGElement
| HTMLImageElement
| string
| 'svg'
| 'canvas'
| 'img'
| null,
theme: string,
weights: number[] | object,
callback: CallableFunction
): void;
drawReaction(
smiles: string,
target:
| HTMLElement
| SVGElement
| HTMLImageElement
| string
| 'svg'
| 'canvas'
| 'img'
| null,
theme: string,
settings: object, // reaction settings
weights: number[] | object,
callback: CallableFunction
): void;
svgToCanvas(
svg: SVGElement,
canvas?: HTMLCanvasElement
): HTMLCanvasElement;
svgToImg(svg: SVGElement, img?: HTMLImageElement): HTMLImageElement;
getDimensions(
element: HTMLImageElement | HTMLCanvasElement | SVGElement,
svg: SVGElement
): { w: number; h: number };
}
} |
https://github.com/Acylation/obsidian-chem
Run
npm install smiles-drawer
, and then declare it in theglobal.d.ts
using the linedeclare module 'smiles-drawer';
, then you'll have the smiles-drawer included in your project.To call the module, you can use this to import
import SmilesDrawer from 'smiles-drawer';
The text was updated successfully, but these errors were encountered: