{"id":20045623,"url":"https://github.com/marcveens/react-drawio","last_synced_at":"2025-10-06T01:11:50.770Z","repository":{"id":191132313,"uuid":"683468069","full_name":"marcveens/react-drawio","owner":"marcveens","description":"React component for integrating the Diagrams (draw.io) embed iframe","archived":false,"fork":false,"pushed_at":"2025-07-22T07:11:44.000Z","size":1206,"stargazers_count":82,"open_issues_count":8,"forks_count":13,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-10-03T19:46:57.870Z","etag":null,"topics":["diagramsnet","drawio","react","typescript"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/marcveens.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null},"funding":{"github":"marcveens","buy_me_a_coffee":"marcveens"}},"created_at":"2023-08-26T17:05:58.000Z","updated_at":"2025-09-22T08:53:24.000Z","dependencies_parsed_at":"2025-02-03T18:47:19.793Z","dependency_job_id":"c46029a1-4ea8-416a-a78a-32ad02448d7d","html_url":"https://github.com/marcveens/react-drawio","commit_stats":null,"previous_names":["marcveens/react-drawio"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/marcveens/react-drawio","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marcveens%2Freact-drawio","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marcveens%2Freact-drawio/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marcveens%2Freact-drawio/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marcveens%2Freact-drawio/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/marcveens","download_url":"https://codeload.github.com/marcveens/react-drawio/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marcveens%2Freact-drawio/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278544075,"owners_count":26004254,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-05T02:00:06.059Z","response_time":54,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["diagramsnet","drawio","react","typescript"],"created_at":"2024-11-13T11:18:16.473Z","updated_at":"2025-10-06T01:11:50.734Z","avatar_url":"https://github.com/marcveens.png","language":"TypeScript","funding_links":["https://github.com/sponsors/marcveens","https://buymeacoffee.com/marcveens"],"categories":[],"sub_categories":[],"readme":"# react-drawio\n\n[![npm](https://img.shields.io/npm/v/react-drawio.svg?style=flat)](https://www.npmjs.com/package/react-drawio)\n[![Build](https://github.com/marcveens/react-drawio/actions/workflows/build.yml/badge.svg)](https://github.com/marcveens/react-drawio/actions/workflows/build.yml)\n[![Storybook demo](https://img.shields.io/badge/-Demo-FF4785?style=flat\u0026logo=storybook\u0026logoColor=white)](https://marcveens.github.io/react-drawio)\n\n\nReact component for integrating the \u003ca href=\"https://app.diagrams.net\"\u003eDiagrams\u003c/a\u003e (\u003ca href=\"https://www.drawio.com/\"\u003edraw.io\u003c/a\u003e) embed iframe.\n\nThis is an unofficial best-effort package based on the embedding documentation that can be found at https://www.drawio.com/doc/faq/embed-mode. \n\n## Table of Contents\n\n* [Demo](https://marcveens.github.io/react-drawio)\n* [Installation](#installation)\n* [Examples](#examples)\n* [API documentation](#api-documentation)\n\n## Installation\n\nInstall this library:\n\n```bash\npnpm add react-drawio\n# or\nyarn add react-drawio\n# or\nnpm i react-drawio\n```\n\n## Examples \n### Simple rendering\n```tsx\nimport { DrawIoEmbed } from 'react-drawio';\n\nfunction App() {\n  return (\n    \u003cDrawIoEmbed /\u003e\n  );\n}\n```\n\n### Start with a few settings enabled\n```tsx\nimport { DrawIoEmbed } from 'react-drawio';\n\nfunction App() {\n  return (\n    \u003cDrawIoEmbed urlParameters={{\n      ui: 'kennedy',\n      spin: true,\n      libraries: true,\n      saveAndExit: true\n    }} /\u003e\n  );\n}\n```\n\n### Start with existing diagram\n```tsx\nimport { DrawIoEmbed } from 'react-drawio';\n\nfunction App() {\n  return (\n    \u003cDrawIoEmbed xml=\"...\" /\u003e\n  );\n}\n```\n\n### Export diagram programmatically\n```tsx\nimport { DrawIoEmbed, DrawIoEmbedRef } from 'react-drawio';\nimport { useRef, useState } from 'react';\n\nfunction App() {\n  const [imgData, setImgData] = useState\u003cstring | null\u003e(null);\n  const drawioRef = useRef\u003cDrawIoEmbedRef\u003e(null);\n\n  const export = () =\u003e {\n    if (drawioRef.current) {\n      drawioRef.current.exportDiagram({\n        format: 'xmlsvg'\n      });\n    }\n  };\n\n  return (\n    \u003c\u003e\n      \u003cbutton onClick={export}\u003eExport\u003c/button\u003e\n\n      \u003cDrawIoEmbed \n        ref={drawioRef}\n        onExport={(data) =\u003e  setImgData(data.data)} \n      /\u003e\n      \n      {imgData \u0026\u0026 \u003cimg src={imgData} /\u003e}\n    \u003c/\u003e\n  );\n}\n```\n\n## API Documentation\nAll options are based on the documentation at \u003ca href=\"https://www.drawio.com/doc/faq/embed-mode\"\u003edraw.io/doc/faq/embed-mode\u003c/a\u003e. If something is off, please let me know by creating an \u003ca href=\"https://github.com/marcveens/react-drawio/issues/new\"\u003eissue\u003c/a\u003e.\n\n### `props`\n- `autosave` (`boolean`, default: `false`)\\\n  When enabled, it will call `onAutoSave` for all changes made\n- `urlParameters` (`UrlParameters`, default: `undefined`)\\\n  Parameters documented at https://www.drawio.com/doc/faq/embed-mode\n- `xml` (`string`, default: `undefined`)\\\n  XML structure for prefilling the editor\n- `csv` (`string`, default: `undefined`)\\\n  CSV structure for prefilling the editor\n- `configuration` (`Object`, default: `undefined`)\\\n  For configuration options, see https://www.drawio.com/doc/faq/configure-diagram-editor\n- `exportFormat` (`'html' | 'html2' | 'svg' | 'xmlsvg' | 'png' | 'xmlpng'`, default: `xmlsvg`)\\\n  Set export format\n- `baseUrl` (`string`, default: `https://embed.diagrams.net`)\\\n  For self hosted instances of draw.io, insert your URL here\n\n- `onLoad` (`(data: EventLoad) =\u003e void`, optional)\n- `onAutoSave` (`(data: EventAutoSave) =\u003e void`, optional)\\\n  This will only trigger when the `autosave` property is `true`\n- `onSave` (`(data: EventSave) =\u003e void`, optional)\n- `onClose` (`(data: EventExit) =\u003e void`, optional)\n- `onConfigure` (`(data: EventConfigure) =\u003e void`, optional)\n- `onMerge` (`(data: EventMerge) =\u003e void`, optional)\n- `onPrompt` (`(data: EventPrompt) =\u003e void`, optional)\n- `onTemplate` (`(data: EventTemplate) =\u003e void`, optional)\n- `onDraft` (`(data: EventDraft) =\u003e void`, optional)\n- `onExport` (`(data: EventExport) =\u003e void`, optional)\n\n### Actions\nIt is possible to send actions to the Diagrams iframe. These actions are available as functions bound to the `ref` of the component, see [examples](#examples).\n\n- `load` (`(obj: ActionLoad) =\u003e void`)\\\n  Load the contents of a diagram\n- `configure` (`(obj: ActionConfigure) =\u003e void`)\\\nSend configuration option to the iframe. Read more about it at https://www.drawio.com/doc/faq/configure-diagram-editor\n- `merge` (`(obj: ActionMerge) =\u003e void`)\\\nMerge the contents of the given XML into the current file\n- `dialog` (`(obj: ActionDialog) =\u003e void`)\\\nDisplay a dialog in the editor window\n- `prompt` (`(obj: ActionPrompt) =\u003e void`)\\\nDisplay a prompt in the editor window\n- `template` (`(obj: ActionTemplate) =\u003e void`)\\\nShow the template dialog\n- `layout` (`(obj: ActionLayout) =\u003e void`)\\\nRuns an array of layouts using the same format as Arrange \u003e Layout \u003e Apply.\n- `draft` (`(obj: ActionDraft) =\u003e void`)\\\nShow a draft dialog\n- `status` (`(obj: ActionStatus) =\u003e void`)\\\nDisplay a message in the status bar\n- `spinner` (`(obj: ActionSpinner) =\u003e void`)\\\nDisplay a spinner with a message or hide the current spinner if show is set to false\n- `exportDiagram` (`(obj: ActionExport) =\u003e void`)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarcveens%2Freact-drawio","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmarcveens%2Freact-drawio","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarcveens%2Freact-drawio/lists"}