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

redraw-drawio

v0.0.2

Published

react component for drawio

Downloads

8

Readme

Redraw Drawio

npm version Build Status Coverage Status License: MIT

Table of Contents

Overview

The DrawIOEmbed component is a React component that integrates diagrams.net (formerly draw.io) as an embeddable interface within React applications. This component facilitates the creation, editing, and saving of diagrams directly in the user interface of your web application.

Features

Embedding diagrams.net: Seamlessly embed the diagrams.net editor using an iframe.

  • Event Handling: Custom event handlers for various diagram events such as save, load, and export.
  • Custom Configuration: Ability to configure the embedded editor with custom parameters.
  • Ref Forwarding: Utilizes forwardRef to pass a ref down to the DOM iframe for parent component control.
  • Action Hooks: A custom hook, useActions, to interact with the embedded editor through postMessage API.
  • Life-cycle Integration: React lifecycle methods are used to handle the initialization and event listener cleanup.

Installation

Before you can use the DrawIOEmbed component, ensure you have React and the required dependencies installed in your project:

npm install react
yarn add react
pnpm add react

Usage

Here is a basic example of how to use the DrawIOEmbed component within a React application:

import React from 'react';
import { DrawIOEmbed } from './DrawIOEmbed';

const App = () => {
  const handleSave = (data) => {
    // Handle the save event with the diagram data
  };

  return (
    <div style={{ width: '100%', height: '100vh' }}>
      <DrawIOEmbed onSave={handleSave} />
    </div>
  );
};

export default App;

Props

The component accepts the following props:

urlParameters: Optional parameters to customize the diagrams.net editor. configuration: Optional configuration settings for the editor. xml: The initial XML of the diagram to be loaded. onSave: Function that will be called when the diagram is saved. onClose: Function that will be called when the editor is closed. onLoad: Function that will be called when the diagram is loaded. onConfigure: Function that will be called to configure the editor. onDraft: Function that will be called when there is a draft event. onExport: Function that will be called when the diagram is exported. onMerge: Function that will be called for merge events. onPrompt: Function that will be called for prompt events. onTemplate: Function that will be called when a template is selected. Ref Methods The component exposes the following methods through the forwarded ref:

load: Loads a diagram XML into the editor. configure: Sends configuration settings to the diagrams.net editor. exportDiagram: Exports the current diagram in the specified format. Event Handling The component utilizes a message handler to communicate with the diagrams.net editor. It listens for messages from the iframe and triggers appropriate callbacks.

Styling The iframe is styled to occupy the full width and height of its container, with a minimum size set to ensure usability. You can override these styles by passing a style prop to the component.

Contributing

If you would like to contribute to the development of the DrawIOEmbed component, please follow the contributing guidelines in the project's repository.

License

The DrawIOEmbed component is open-sourced software licensed under the MIT license.

API

| Interfaces | | ---------------- | | DrawIoEmbedProps | | UrlParameters | | ActionConfigure |


| Type Aliases | | --------------------- | | ActionDialog | | ActionDraft | | ActionExit | | ActionExport | | ActionLayout | | ActionLoad | | ActionMerge | | ActionPromptv | | ActionSpinner | | ActionStatus | | ActionTemplate | | DrawIoEmbedRef | | EmbedActions | | EmbedActionsWithDraft | | EmbedEvents | | EventConfigure | | EventDraft | | EventExit | | EventExport | | EventHandler | | EventHandlerMap | | EventInit | | EventKey | | EventLoad | | EventMap | | EventMerge | | EventPrompt | | EventSave | | EventTemplate | | EventUnion | | ExportFormat | | UiTheme |


| Functions | | --------- | | default |