JSPM

@butlerov-chemistry/core

0.1.1
    • ESM via JSPM
    • ES Module Entrypoint
    • Export Map
    • Keywords
    • License
    • Repository URL
    • TypeScript Types
    • README
    • Created
    • Published
    • Downloads 1
    • Score
      100M100P100Q22420F
    • License MIT

    Draw chemical structures with js and Konva

    Package Exports

    • @butlerov-chemistry/core
    • @butlerov-chemistry/core/dist/butlerov.umd.cjs

    This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@butlerov-chemistry/core) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

    Readme

    Butlerov core web component - a control to edit and display chemical structures.

    Use in frontend projects

    When using in projects built by js package managers like npm / yarn, just install into your project:

    npm i butlerov

    Then, import

    import { MoleculeEditor, MW } from "butlerov";
    const editor = MoleculeEditor({stage: document.getElementById("div-chemical")});
    editor.onchange = () => {
        const mw = new MW(editor.graph).compute();
        console.log(`Molecular weight: ${MW} Da`);
    }

    Use in browser

    You need to put butlerov.umd.js universal module definition (UMD) file somewhere in your project tree.

    <html>
        <head>
            <script type="text/javascript" src="/js/butlerov.umd.js"></script>
            <!-- alternative option: -->
            <!-- <script src="https://unpkg.com/butlerov/dist/butlerov.umd.js"></script> -->
            <script type="text/javascript">
                const editor = window.butlerov.MoleculeEditor({stage: document.getElementById("div-chemical")});
                editor.onchange = () => {
                    const mw = new window.butlerov.MW(editor.graph).compute();
                    console.log(`Molecular weight: ${MW} Da`);
                }
            </script>
        </head>
        <body>
            <p>Now draw some chemistry</p>
            <div style="width: 1000px; height: 600px" id="div-chemical"></div>
        </body>
    </html>