npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

butlerov

v0.0.17

Published

Draw chemical structures with js and Konva

Downloads

563

Readme

Butlerov - a free and open source chemical structure editor written in Typescript and based on Konva.js.

For now, it is meant to be used to edit files in Mol format, because I need this badly. Other formats and SMILES might be supported later, as well as more advanced chemical drawing of multiple fragments and chemical artwork.

The package is named after Alexander M. Butlerov (1828-1886), a Russian chemist who proposed the idea that order of atom connection matters for organic compounds, so basically introduced chemical structures.


Demo and current features

A demo of the current version is available at Codepen: https://codepen.io/eizemazal/pen/ExQzmoJ

Use both your mouse and your keyboard for fast drawing. The context menu (inspired by Blender 3D editor software) is invoked by space bar when the mouse is over a bond or atom. The hot keys are specified in the menu.


Installation and use

Install into your project via npm

npm i butlerov

Or include it in your index.html file

<script src="https://unpkg.com/butlerov/dist/butlerov.js"></script>

Use it in your script files:


import { MoleculeEditor } from "butlerov";
// or use window.butlerov.MoleculeEditor global object

// bind editor to div element
const element = document.getElementById("div-element");
const editor = MoleculeEditor.from_html_element(element);

// load molfile format from string mol_string
editor.load_from_mol_string(mol_string);

// attach handler to 'onchange' event, and get the mol string from the editor
editor.onchange = function() { console.log(editor.get_mol_string()); }

Local build / contribs

Clone, build from source and test locally:

git clone [email protected]:eizemazal/butlerov.git
cd butlerov
npm i
npm run build
firefox demo/test.html

Open demo/test.html in browser, and see how it works.

Run tests:

npm run test

Automated tests require node-canvas package that is dependent on many graphic libs installed on your system. If it does not work out of the box, follow instructions for your platform here: https://github.com/Automattic/node-canvas. For example, for MacOS, the following dependencies are to be installed:

brew install pkg-config cairo pango libpng jpeg giflib librsvg

(For Mac M1, I had to switch to node v.14.19 to run tests, because node and libs must be built with the same architecture).

The project uses eslint. I am developing using VS code and eslint plugin. Contributions are highly welcome.

ToDo - smaller tasks

  • implement support for isotope specification
  • add support for radicals
  • sometimes cycles are created over existing atoms - fix it
  • when creating an edge by dragging between existing vertices, display it
  • when edge order is changed (e.g. from 1 to 3), move substituents to fit geometry
  • add support for abbreviations and superatoms
  • improve display of charges to show them top right when possible and not adjacent to a double edge
  • add support for coloring schemes for atoms
  • support for selection, copy and paste

ToDo - larger tasks

  • Add support for SMILES reading and writing. Structures after inserting SMILES should look well.
  • Write support for mobile platforms to use taps for drawing on Android and iOS devices
  • Implement scheme drawing tool based on Butlerov. It should retain its lightweight functionality to draw and display structures. Add support for drawing primitives (arrows, text etc), and support for multiple structures.
  • write support for cdx export and import, and svg export

License

Butlerov is developed for the use in cheminformatics projects by Lumiprobe Group. Brought to public domain under MIT license for the use in both commercial and non-commercial projects.