Skip to content

Commit

Permalink
Merge pull request #457 from towersxu/master
Browse files Browse the repository at this point in the history
release 1.0.4
  • Loading branch information
xinxin93 authored Jan 12, 2022
2 parents d104534 + be2e695 commit 1740fda
Show file tree
Hide file tree
Showing 21 changed files with 79 additions and 31 deletions.
4 changes: 2 additions & 2 deletions docs/api/nodeModelApi.md
Original file line number Diff line number Diff line change
Expand Up @@ -223,14 +223,14 @@ const nodeModel = lf.getNodeModelById('node_1');
const properties = nodeModel.getProperties();
```

## getDetaultAnchor
## getDefaultAnchor

重新设置默认锚点, 可以给锚点加上id等自定义属性,用于对锚点的验证。

```ts
class cNode extend RectNodeModel {
// 定义节点只有左右两个锚点. 锚点位置通过中心点和宽度算出来。
getDetaultAnchor() {
getDefaultAnchor() {
const { width, height, x, y, id } = this;
return [
{
Expand Down
2 changes: 1 addition & 1 deletion docs/guide/basic/node.md
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,7 @@ class SquareModel extends RectNodeModel {
};
this.sourceRules.push(rule);
}
getDetaultAnchor() {
getDefaultAnchor() {
const { width, height, x, y, id } = this;
return [
{
Expand Down
11 changes: 11 additions & 0 deletions examples/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.0.4](https://github.com/didi/LogicFlow/compare/[email protected]@1.0.4) (2022-01-12)


### Features

* release 1.0.0🎉🎉 ([670fed7](https://github.com/didi/LogicFlow/commit/670fed7fa3e0cb0ee39501251d177c693694ef59))





## [1.0.1-alpha.0](https://github.com/didi/LogicFlow/compare/[email protected]@1.0.1) (2022-01-07)


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.0.3",
"version": "1.0.4",
"private": true,
"dependencies": {
"@ant-design/icons": "^4.3.0",
"@babel/core": "7.12.3",
"@logicflow/core": "^1.0.2",
"@logicflow/extension": "^1.0.2",
"@logicflow/core": "^1.0.4",
"@logicflow/extension": "^1.0.4",
"@pmmmwh/react-refresh-webpack-plugin": "0.4.2",
"@svgr/webpack": "5.4.0",
"@testing-library/jest-dom": "^5.11.4",
Expand Down
2 changes: 1 addition & 1 deletion examples/src/pages/advance/custom-node/anchor/circle.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { CircleNode, CircleNodeModel } from '@logicflow/core';

class Model extends CircleNodeModel {
getDetaultAnchor() {
getDefaultAnchor() {
return []
}
}
Expand Down
22 changes: 22 additions & 0 deletions packages/core/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,28 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

## [1.0.4](https://github.com/didi/LogicFlow/compare/@logicflow/[email protected]...@logicflow/[email protected]) (2022-01-12)


### Bug Fixes

* change edge type remove pointsList ([433c8e8](https://github.com/didi/LogicFlow/commit/433c8e805da226e37550c7abd770748f8c8a8bdc))
* focus on ([2301c09](https://github.com/didi/LogicFlow/commit/2301c094f2853591741101623da879ea7e0d22de))
* mini map viewport ([38c2408](https://github.com/didi/LogicFlow/commit/38c2408e0f8a76dd0b49b9271dd259fd8b6fa684))
* move edge not keep controls ([b8f28f3](https://github.com/didi/LogicFlow/commit/b8f28f38d943ab2881a2f375603025e01573c0d8))
* node updateText observable ([b04f96a](https://github.com/didi/LogicFlow/commit/b04f96abf639befeaa5cf22be9407955926a5118))
* rewrite text node getTextStyle ([2717203](https://github.com/didi/LogicFlow/commit/27172038a282404c02697986736bf10955117d16))
* typo EditConfigMode ([fed381b](https://github.com/didi/LogicFlow/commit/fed381b47ec3786f43d043c07c33f01458239840))


### Features

* release 1.0.0🎉🎉 ([670fed7](https://github.com/didi/LogicFlow/commit/670fed7fa3e0cb0ee39501251d177c693694ef59))





## [1.0.1](https://github.com/didi/LogicFlow/compare/@logicflow/[email protected]...@logicflow/[email protected]) (2022-01-07)


Expand Down
3 changes: 3 additions & 0 deletions packages/core/examples/api/api.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,7 @@ document.querySelector('#js_change_edge_type').addEventListener('change', (e) =>
if (edges.length) {
lf.changeEdgeType(edges[0].id, e.target.value)
}
})
document.querySelector('#js_updateText').addEventListener('click', (e) => {
lf.updateText('11', '4444')
})
1 change: 1 addition & 0 deletions packages/core/examples/api/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
<option value="bezier">bezier</option>
<option value="line">line</option>
</select>
<button id="js_updateText">updateText</button>
<div id="container"></div>
<script src="/logic-flow.js"></script>
<script type="module" src="./api.mjs">
Expand Down
2 changes: 1 addition & 1 deletion packages/core/examples/customNode/userTask.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class UserTaskModel extends RectNodeModel {
};
this.sourceRules.push(circleOnlyAsTarget);
}
getDetaultAnchor() {
getDefaultAnchor() {
const { width, height, x, y } = this;
return [
{
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.0.3",
"version": "1.0.5",
"description": "LogicFlow core, to quickly build flowchart editor",
"main": "dist/logic-flow.js",
"unpkg": "dist/logic-flow.js",
Expand Down
11 changes: 1 addition & 10 deletions packages/core/src/model/edge/BaseEdgeModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -310,17 +310,8 @@ class BaseEdgeModel implements IBaseModel {
* 更新文本的值
*/
@action updateText(value: string): void {
const {
x,
y,
draggable,
editable,
} = this.text;
this.text = {
x,
y,
draggable,
editable,
...this.text,
value,
};
}
Expand Down
9 changes: 6 additions & 3 deletions packages/core/src/model/node/BaseNodeModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -369,13 +369,13 @@ export default class BaseNodeModel implements IBaseNodeModel {
};
});
}
return this.getDetaultAnchor();
return this.getDefaultAnchor();
}
/**
* @overridable 子类重写此方法设置默认锚点
* 获取节点默认情况下的锚点
*/
public getDetaultAnchor(): PointAnchor[] {
public getDefaultAnchor(): PointAnchor[] {
return [];
}
/**
Expand Down Expand Up @@ -442,7 +442,10 @@ export default class BaseNodeModel implements IBaseNodeModel {

@action
updateText(value: string): void {
this.text.value = value;
this.text = {
...this.text,
value,
};
}

@action
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/model/node/CircleNodeModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class CircleNodeModel extends BaseNodeModel {
...cloneDeep(circle),
};
}
getDetaultAnchor() {
getDefaultAnchor() {
const { x, y, r } = this;
return [
{ x, y: y - r, id: `${this.id}_0` },
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/model/node/DiamondNodeModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ class DiamondNodeModel extends BaseNodeModel {
return max - min;
}

getDetaultAnchor() {
getDefaultAnchor() {
return this.points.map(([x1, y1], idx) => ({ x: x1, y: y1, id: `${this.id}_${idx}` }));
}
}
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/model/node/EllipseNodeModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class EllipseNodeModel extends BaseNodeModel {
return this.ry * 2;
}

getDetaultAnchor() {
getDefaultAnchor() {
const {
x, y, rx, ry,
} = this;
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/model/node/HtmlNodeModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { ModelType } from '../../constant/constant';

class HtmlNodeModel extends BaseNodeModel {
modelType = ModelType.HTML_NODE;
getDetaultAnchor() {
getDefaultAnchor() {
const {
x, y, width, height,
} = this;
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/model/node/PolygonNodeModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ class PolygonNodeModel extends BaseNodeModel {
return max - min;
}

getDetaultAnchor() {
getDefaultAnchor() {
const {
x, y, width, height, points,
} = this;
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/model/node/RectNodeModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { ModelType } from '../../constant/constant';
class RectNodeModel extends BaseNodeModel {
modelType = ModelType.RECT_NODE;
@observable radius = 0;
getDetaultAnchor() {
getDefaultAnchor() {
const { x, y, width, height } = this;
return [
{ x, y: y - height / 2, id: `${this.id}_0` },
Expand Down
17 changes: 17 additions & 0 deletions packages/extension/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,23 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

## [1.0.4](https://github.com/didi/LogicFlow/compare/@logicflow/[email protected]...@logicflow/[email protected]) (2022-01-12)


### Bug Fixes

* mini map viewport ([38c2408](https://github.com/didi/LogicFlow/commit/38c2408e0f8a76dd0b49b9271dd259fd8b6fa684))


### Features

* release 1.0.0🎉🎉 ([670fed7](https://github.com/didi/LogicFlow/commit/670fed7fa3e0cb0ee39501251d177c693694ef59))
* remove node selection ([92d4b7a](https://github.com/didi/LogicFlow/commit/92d4b7a88727b8dd213487f09e1117afa5c48310))





## [1.0.1-alpha.0](https://github.com/didi/LogicFlow/compare/@logicflow/[email protected]...@logicflow/[email protected]) (2022-01-07)


Expand Down
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.0.3",
"version": "1.0.5",
"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.0.1-alpha.0",
"@logicflow/core": "^1.0.4",
"ids": "^1.0.0",
"preact": "^10.4.8"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/extension/src/materials/node-selection/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ class NodeSelectionModel extends PolygonNodeModel {
}
}

getDetaultAnchor() {
getDefaultAnchor() {
return [];
}

Expand Down

0 comments on commit 1740fda

Please sign in to comment.