Module @js-draw/material-icons - v1.25.0

@js-draw/material-icons

Provides a material icon theme for js-draw.

import { Editor, makeEdgeToolbar } from 'js-draw';
import { MaterialIconProvider } from '@js-draw/material-icons';

// Apply js-draw CSS
import 'js-draw/styles';

const editor = new Editor(document.body, {
  iconProvider: new MaterialIconProvider(),
});

// Ensure that there is enough room for the toolbar
editor.getRootElement().style.minHeight = '500px';

// Add a toolbar
const toolbar = makeEdgeToolbar(editor);

// ...with the default elements
toolbar.addDefaults();

@js-draw/material-icons

A material icon pack for js-draw.

The icons in this pack are licensed under the Apache 2.0 License. See the icon pack's GitHub repository.

If using a bundler (e.g. webpack), it should be possible to add @js-draw/material-icons as a dependency and import it directly.

For example,

import Editor from 'js-draw';
import { MaterialIconProvider } from '@js-draw/material-icons';
import 'js-draw/bundledStyles';

const editor = new Editor(document.body, {
iconProvider: new MaterialIconProvider(),
});

// Add a toolbar that uses the icons
editor.addToolbar();

It's also possible to include js-draw and @js-draw/material-icons from a CDN.

For example, with JSDelivr,

<script src="https://cdn.jsdelivr.net/npm/js-draw@1.23.1/dist/bundle.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@js-draw/material-icons@1.23.1/dist/bundle.js"></script>

Then, in a script,

// makeMaterialIconProviderClass provides @js-draw/material-icons with an instance of the js-draw library.
const MaterialIcons = jsdrawMaterialIcons.makeMaterialIconProviderClass(jsdraw);

const editor = new jsdraw.Editor(document.body, {
iconProvider: new MaterialIcons(),
});
editor.addToolbar();

Notes:

Variables

MaterialIconProvider

Functions

makeMaterialIconProviderClass

References

default → MaterialIconProvider
OpenSource licenses