Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/windrunnermax/flowcharteditor

流程图编辑器
https://github.com/windrunnermax/flowcharteditor

Last synced: 19 days ago
JSON representation

流程图编辑器

Awesome Lists containing this project

README

        

# FlowChartEditor


GitHub

Editor DEMO

BLOG

TODO

流程图编辑器,支持独立的流程图编辑器包以及`DrawIO`嵌入通信方案。

```bash
# Install
$ npm i embed-drawio

# Development
$ npm run build:dist
$ npm run dev
```
## 独立编辑器
支持独立的流程图编辑器编辑与渲染。

使用方法可参考`example/index.tsx`,由于包体积原因,强烈建议以懒加载方式引入。

```js
import type { DiagramEditor } from "embed-drawio/dist/es/core/editor";
import type { DiagramViewer } from "embed-drawio/dist/es/core/viewer";

let editor: typeof DiagramEditor | null = null;
export const loadEditor = async (): Promise => {
if (editor) return Promise.resolve(editor);
const res = await Promise.all([
import(/* webpackChunkName: "embed-drawio-editor" */ "embed-drawio/dist/es/core/editor"),
// @ts-expect-error css declaration
import(/* webpackChunkName: "embed-drawio-css" */ "embed-drawio/dist/es/index.css"),
]);
editor = res[0].DiagramEditor;
return editor;
};

let viewer: typeof DiagramViewer | null = null;
export const loadViewer = async (): Promise => {
if (viewer) return Promise.resolve(viewer);
const res = await Promise.all([
import(/* webpackChunkName: "embed-drawio-viewer" */ "embed-drawio/dist/es/core/viewer"),
]);
viewer = res[0].DiagramViewer;
return viewer;
};
```

## 嵌入DrawIO
支持`DrawIO`的嵌入通信方案。

使用方法可参考`example/index.tsx`,由于`sideEffects`原因,强烈建议以路径方式引入。

```js
import { EditorEvent } from "embed-drawio/dist/es/event/basic";
import { EditorBus } from "embed-drawio/dist/es/event/index";

// ...
```