Skip to content

Commit

Permalink
Merge pull request didi#1037 from towersxu/master
Browse files Browse the repository at this point in the history
release 1.2.0
  • Loading branch information
xinxin93 authored Mar 13, 2023
2 parents 2182830 + 9d60ada commit 6035ba3
Show file tree
Hide file tree
Showing 12 changed files with 187 additions and 14 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/docs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,10 @@ jobs:
- name: generate static file
run: |
npm run build:types
npm run docs:build
npm run build
rm -rf ./deploy
mkdir -p deploy/examples
cp -rf ./docs/.vuepress/dist/* ./deploy
cp -rf ./docs/.vuepress/index.html ./deploy
cp -rf ./examples/build/* ./deploy/examples
- name: generate mvp
Expand Down
3 changes: 3 additions & 0 deletions docs/.vuepress/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<script>
window.location.href="https://docs.logic-flow.cn"
</script>
8 changes: 8 additions & 0 deletions examples/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

# [1.2.0](https://github.com/didi/LogicFlow/compare/examples@1.2.0-next.5...examples@1.2.0) (2023-03-13)

**Note:** Version bump only for package examples





# [1.2.0-next.5](https://github.com/didi/LogicFlow/compare/examples@1.2.0-next.4...examples@1.2.0-next.5) (2023-03-10)

**Note:** Version bump only for package examples
Expand Down
6 changes: 3 additions & 3 deletions examples/package.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{
"name": "examples",
"version": "1.2.0-next.5",
"version": "1.2.0",
"private": true,
"dependencies": {
"@ant-design/icons": "^4.3.0",
"@babel/core": "7.12.3",
"@logicflow/core": "^1.2.0-next.5",
"@logicflow/extension": "^1.2.0-next.5",
"@logicflow/core": "^1.2.0",
"@logicflow/extension": "^1.2.0",
"@pmmmwh/react-refresh-webpack-plugin": "0.4.2",
"@svgr/webpack": "5.4.0",
"@testing-library/jest-dom": "^5.11.4",
Expand Down
11 changes: 11 additions & 0 deletions packages/core/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,17 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

# [1.2.0](https://github.com/didi/LogicFlow/compare/@logicflow/core@1.2.0-next.5...@logicflow/core@1.2.0) (2023-03-13)


### Bug Fixes

* trigger extension render in difference env ([9be1f58](https://github.com/didi/LogicFlow/commit/9be1f58a3768fd48117e1143939c8a92f61191dc))





# [1.2.0-next.5](https://github.com/didi/LogicFlow/compare/@logicflow/core@1.2.0-next.4...@logicflow/core@1.2.0-next.5) (2023-03-10)


Expand Down
2 changes: 1 addition & 1 deletion packages/core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@logicflow/core",
"version": "1.2.0-next.5",
"version": "1.2.0",
"description": "LogicFlow core, to quickly build flowchart editor",
"main": "dist/entry.js",
"module": "dist/logic-flow.js",
Expand Down
20 changes: 15 additions & 5 deletions packages/core/src/view/overlay/ToolOverlay.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,15 @@ type IProps = {

@observer
export default class ToolOverlay extends Component<IProps> {
// 在react严格模式下,useEffect会执行两次,但是在LogicFlow内部,则只会触发一次componentDidMount和componentDidUpdate。
// 其中第一次componentDidMount对应的graphModel为被丢弃的graphModel, 所以不应该生效。
// 在非react环境下,只会触发一次componentDidMount,不会触发componentDidUpdate。
// 所以这里采用componentDidUpdate和componentDidMount都去触发插件的render方法。
componentDidMount(): void {
this.triggerToolRender();
}
componentDidUpdate(): void {
const { tool, graphModel } = this.props;
const ToolOverlayElement = document.querySelector(`#ToolOverlay_${graphModel.flowId}`) as HTMLElement;
const lf: LogicFlow = tool.getInstance();
lf.components.forEach(render => render(lf, ToolOverlayElement));
lf.components = []; // 保证extension组件的render只执行一次
this.triggerToolRender();
}
/**
* 外部传入的一般是HTMLElement
Expand All @@ -30,6 +33,13 @@ export default class ToolOverlay extends Component<IProps> {
tool.components = components;
return components;
}
triggerToolRender() {
const { tool, graphModel } = this.props;
const ToolOverlayElement = document.querySelector(`#ToolOverlay_${graphModel.flowId}`) as HTMLElement;
const lf: LogicFlow = tool.getInstance();
lf.components.forEach(render => render(lf, ToolOverlayElement));
lf.components = []; // 保证extension组件的render只执行一次
}
render() {
const { graphModel } = this.props;
return (
Expand Down
11 changes: 11 additions & 0 deletions packages/extension/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,17 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

# [1.2.0](https://github.com/didi/LogicFlow/compare/@logicflow/extension@1.2.0-next.5...@logicflow/extension@1.2.0) (2023-03-13)


### Bug Fixes

* trigger extension render in difference env ([9be1f58](https://github.com/didi/LogicFlow/commit/9be1f58a3768fd48117e1143939c8a92f61191dc))





# [1.2.0-next.5](https://github.com/didi/LogicFlow/compare/@logicflow/extension@1.2.0-next.4...@logicflow/extension@1.2.0-next.5) (2023-03-10)

**Note:** Version bump only for package @logicflow/extension
Expand Down
36 changes: 36 additions & 0 deletions packages/extension/examples/components/menu/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="format-detection" content="telephone=no, email=no">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>LOGIC FLOW</title>
<link rel="stylesheet" href="/core/dist/style/index.css">
<!-- <link rel="stylesheet" href="http://0.0.0.0:9099/src/style/index.css"> -->
<link rel="stylesheet" href="/extension/src/style/index.css">
<style>
html,body {
padding: 0;
margin: 0;
}
body {
background-color: #FFF;
}
#app {
width: 1000px;
height: 1000px;
border: 1px solid #efefef;
}
</style>
</head>
<body>
<div class="rules-graph">
<div id="app"></div>
</div>
<!-- <script src="/core/dist/logic-flow.js"></script> -->
<script src="http://localhost:9093/logic-flow.js"></script>
<script src="/Menu.js"></script>
<script src="./index.js"></script>

</body>
</html>
95 changes: 95 additions & 0 deletions packages/extension/examples/components/menu/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
window.addEventListener('DOMContentLoaded', () => {
const lf = new LogicFlow({
container: document.querySelector('#app'),
edgeTextDraggable: true,
nodeTextDraggable: true,
grid: {
type: 'dot',
size: 20,
},
keyboard: {
enabled: true,
},
plugins: [Menu],
pluginsOptions: {
MiniMap: {
width: 200,
height: 170,
headerTitle: '缩略图',
topPosition: 20,
rightPosition: 20,
bottomPosition: 100,
}
},
snapline: true,
});
lf.register({
type: 'x-node',
view: RectNode,
model: RectNodeModel,
})
lf.extension.menu.addMenuConfig({
nodeMenu: [
{
text: "分享",
callback() {
alert("分享成功!");
}
},
{
text: "属性",
callback(node) {
alert(`
节点id:${node.id}
节点类型:${node.type}
节点坐标:(x: ${node.x}, y: ${node.y})`);
}
}
],
edgeMenu: [
{
text: "属性",
callback(edge) {
alert(`
边id:${edge.id}
边类型:${edge.type}
边坐标:(x: ${edge.x}, y: ${edge.y})
源节点id:${edge.sourceNodeId}
目标节点id:${edge.targetNodeId}`);
}
}
],
graphMenu: [
{
text: "分享",
callback() {
alert("分享成功!");
}
}
]
});

lf.render({
nodes: [
{
id: '1',
x: 100,
y: 100,
type: 'rect',
},
{
id: '2',
x: 300,
y: 200,
type: 'rect',
},
],
edges: [
{
sourceNodeId: '1',
targetNodeId: '2',
type: 'polyline',
}
]
});
})
2 changes: 1 addition & 1 deletion packages/extension/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions packages/extension/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@logicflow/extension",
"version": "1.2.0-next.5",
"version": "1.2.0",
"description": "LogicFlow extension",
"main": "cjs/index.js",
"module": "es/index.js",
Expand Down Expand Up @@ -32,7 +32,7 @@
"readme.md"
],
"dependencies": {
"@logicflow/core": "^1.2.0-next.5",
"@logicflow/core": "^1.2.0",
"ids": "^1.0.0",
"lodash-es": "^4.17.21",
"preact": "^10.4.8"
Expand Down

0 comments on commit 6035ba3

Please sign in to comment.