Product
Introducing License Enforcement in Socket
Ensure open-source compliance with Socket’s License Enforcement Beta. Set up your License Policy and secure your software!
@realrisman/typed-mxgraph
Advanced tools
mxGraph Typescript Declarations For Official mxGraph NPM Package.
Add mxgraph
and @typed-mxgraph/typed-mxgraph
dependencies to your project:
npm:
npm install --save mxgraph
npm install --save-dev @typed-mxgraph/typed-mxgraph
yarn:
yarn add mxgraph
yarn add --dev @typed-mxgraph/typed-mxgraph
Update tsconfig.json
append node_modules/@typed-mxgraph
to typeRoots
:
{
"compilerOptions": {
"target": "es5",
"module": "commonjs",
"esModuleInterop": true,
"typeRoots": [
"node_modules/@types",
"node_modules/@typed-mxgraph"
]
}
}
Import mxGraph factory:
import factory from '@realrisman/mxgraph';
const mx = factory({
mxBasePath: '',
});
console.log(mx.mxClient.VERSION);
(optional) Create a helper to import mxgraph
// src/mxgraph.ts
import factory from '@realrisman/mxgraph';
(window as any)['mxBasePath'] = 'assets/mxgraph';
export default factory({
// not working see https://github.com/jgraph/mxgraph/issues/479
mxBasePath: 'assets/mxgraph',
});
// src/application.ts
import mx from './mxgraph'; // <- import values from factory()
import { mxGraph, mxGraphModel } from '@realrisman/mxgraph'; // <- import types only
export class Application {
constructor(container: HTMLElement) {
if(mx.mxClient.isBrowserSupported()) {
console.log('Yes! Yes!');
}
const graph: mxGraph = new mx.mxGraph(container);
const model: mxGraphModel = graph.getModel();
model.beginUpdate();
try {
graph.insertVertex(graph.getDefaultParent(), '', 'TEST', 0, 0, 100, 100);
} finally {
model.endUpdate();
}
}
}
Demos:
Types have been initially created from mxGraph 4.1.0
by hand (1st hosting repository was mxgraph-type-definitions) and progressively updated when new mxgraph
versions have been released.
The mxgraph lib is almost fully covered by types in this project. The issues you may encounter are
any
and use optional when we don't know.The definitions target mxGraph 4.2.2
. See the implementation status in the following table.
Module | Progress | Checked |
---|---|---|
editor | partial | no |
handler | completed | no |
io | completed | no |
layout | completed | no |
model | completed | no |
shape | completed | no |
util | partial | no |
view | partial | no |
mxClient.d.ts | completed | no |
We are actively developing, if you want to be a contributor, please refer to the following links
FAQs
mxGraph typescript declarations
The npm package @realrisman/typed-mxgraph receives a total of 0 weekly downloads. As such, @realrisman/typed-mxgraph popularity was classified as not popular.
We found that @realrisman/typed-mxgraph demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Ensure open-source compliance with Socket’s License Enforcement Beta. Set up your License Policy and secure your software!
Product
We're launching a new set of license analysis and compliance features for analyzing, managing, and complying with licenses across a range of supported languages and ecosystems.
Product
We're excited to introduce Socket Optimize, a powerful CLI command to secure open source dependencies with tested, optimized package overrides.