pgerd-to-drawio-diagram-converter
TypeScript icon, indicating that this package has built-in type declarations

1.0.2 • Public • Published

pgerd-to-drawio-diagram-converter

https://github.com/bertyhell/pgerd-to-drawio-diagram-converter/blob/main/images/hero.jpg

Try it out on: https://bertyhell.github.io/pgerd-to-drawio-diagram-converter

https://github.com/bertyhell/pgerd-to-drawio-diagram-converter/blob/main/images/manual.jpg

Programmatic interface

Installation:

npm install pgerd-to-drawio-diagram-converter

Use inside node:

import {convertPgerdToDrawIo} from 'pgerd-to-drawio-diagram-converter';
import * as fs from "fs";

// Read the pgerd file as a string
const pgerdJsonString = fs.readFileSync('./diagram.pgerd').toString('utf-8');

// Interpret the string as json
const pgerdJson = JSON.parse(pgerdJsonString);

// Convert the json diagram info to a draw io xml format
const drawIoXmlString = convertPgerdToDrawIo(pgerdJson);

// Write the xml string to an xml file
fs.writeFileSync('./diagram.drawio.xml', drawIoXmlString);

Use inside a browser:

import { saveAs } from 'file-saver';

const pgerdDiagramJson: PgErdDiagramInfo = JSON.parse(pgerdJsonString);
const drawIoXml = convertPgerdToDrawIo(pgerdDiagramJson);

const blob = new Blob([drawIoXml], { type: 'text/xml;charset=utf-8' });
saveAs(blob, 'diagram.drawio.xml');

React example:

App.tsx

Package Sidebar

Install

npm i pgerd-to-drawio-diagram-converter

Weekly Downloads

7

Version

1.0.2

License

MIT

Unpacked Size

24.4 kB

Total Files

15

Last publish

Collaborators

  • bertyhell