
Security News
Vite Releases Technical Preview of Rolldown-Vite, a Rust-Based Bundler
Vite releases Rolldown-Vite, a Rust-based bundler preview offering faster builds and lower memory usage as a drop-in replacement for Vite.
react-drawio
Advanced tools
React component for integrating the Diagrams (draw.io) embed iframe.
This is an unofficial best-effort package based on the embedding documentation that can be found at https://www.drawio.com/doc/faq/embed-mode.
Install this library:
pnpm add react-drawio
# or
yarn add react-drawio
# or
npm i react-drawio
import { DrawIoEmbed } from 'react-drawio';
function App() {
return (
<DrawIoEmbed />
);
}
import { DrawIoEmbed } from 'react-drawio';
function App() {
return (
<DrawIoEmbed urlParameters={{
ui: 'kennedy',
spin: true,
libraries: true,
saveAndExit: true
}} />
);
}
import { DrawIoEmbed } from 'react-drawio';
function App() {
return (
<DrawIoEmbed xml="..." />
);
}
import { DrawIoEmbed, DrawIoEmbedRef } from 'react-drawio';
import { useRef, useState } from 'react';
function App() {
const [imgData, setImgData] = useState<string | null>(null);
const drawioRef = useRef<DrawIoEmbedRef>(null);
const export = () => {
if (drawioRef.current) {
drawioRef.current.exportDiagram({
format: 'xmlsvg'
});
}
};
return (
<>
<button onClick={export}>Export</button>
<DrawIoEmbed
ref={drawioRef}
onExport={(data) => setImgData(data.data)}
/>
{imgData && <img src={imgData} />}
</>
);
}
All options are based on the documentation at draw.io/doc/faq/embed-mode. If something is off, please let me know by creating an issue.
props
autosave
(boolean
, default: false
)
When enabled, it will call onAutoSave
for all changes made
urlParameters
(UrlParameters
, default: undefined
)
Parameters documented at https://www.drawio.com/doc/faq/embed-mode
xml
(string
, default: undefined
)
XML structure for prefilling the editor
csv
(string
, default: undefined
)
CSV structure for prefilling the editor
configuration
(Object
, default: undefined
)
For configuration options, see https://www.drawio.com/doc/faq/configure-diagram-editor
exportFormat
('html' | 'html2' | 'svg' | 'xmlsvg' | 'png' | 'xmlpng'
, default: xmlsvg
)
Set export format
baseUrl
(string
, default: https://embed.diagrams.net
)
For self hosted instances of draw.io, insert your URL here
onLoad
((data: EventLoad) => void
, optional)
onAutoSave
((data: EventAutoSave) => void
, optional)
This will only trigger when the autosave
property is true
onSave
((data: EventSave) => void
, optional)
onClose
((data: EventExit) => void
, optional)
onConfigure
((data: EventConfigure) => void
, optional)
onMerge
((data: EventMerge) => void
, optional)
onPrompt
((data: EventPrompt) => void
, optional)
onTemplate
((data: EventTemplate) => void
, optional)
onDraft
((data: EventDraft) => void
, optional)
onExport
((data: EventExport) => void
, optional)
It is possible to send actions to the Diagrams iframe. These actions are available as functions bound to the ref
of the component, see examples.
load
((obj: ActionLoad) => void
)configure
((obj: ActionConfigure) => void
)merge
((obj: ActionMerge) => void
)dialog
((obj: ActionDialog) => void
)prompt
((obj: ActionPrompt) => void
)template
((obj: ActionTemplate) => void
)layout
((obj: ActionLayout) => void
)draft
((obj: ActionDraft) => void
)status
((obj: ActionStatus) => void
)spinner
((obj: ActionSpinner) => void
)exportDiagram
((obj: ActionExport) => void
)1.0.1
FAQs
React component for integrating the Diagrams (draw.io) embed iframe
The npm package react-drawio receives a total of 2,072 weekly downloads. As such, react-drawio popularity was classified as popular.
We found that react-drawio demonstrated a healthy version release cadence and project activity because the last version was released less than 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.
Security News
Vite releases Rolldown-Vite, a Rust-based bundler preview offering faster builds and lower memory usage as a drop-in replacement for Vite.
Research
Security News
A malicious npm typosquat uses remote commands to silently delete entire project directories after a single mistyped install.
Research
Security News
Malicious PyPI package semantic-types steals Solana private keys via transitive dependency installs using monkey patching and blockchain exfiltration.