Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

4.4.2 release #32

Merged
merged 1 commit into from
Dec 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions .github/workflows/github-pages.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Dashboard-Ent Release
name: VEditor GitHub Pages
on:
push:
branches:
Expand All @@ -15,10 +15,11 @@ jobs:
- name: Install dependencies
run: npm ci
- name: Build
run: npm run build:all
run: npm run build:all && npm run doc
- name: Delete node_modules
run: rm -rf node_modules
rm -rf demo
run: |
rm -rf node_modules && rm -rf demo && rm -rf src
rm .gitignore
- name: Deploy to GitHub Pages
uses: peaceiris/actions-gh-pages@v3
with:
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,5 @@ typings/

# next.js build output
.next
types/
types/
dist/
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@vesoft-inc/veditor",
"version": "4.4.1-beta.0",
"version": "4.4.2",
"description": "svg flow editor",
"main": "./dist/VEditor.js",
"types": "./types/index.d.ts",
Expand Down
3 changes: 2 additions & 1 deletion src/Model/Schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ class Schema {
node.data.x = nodeData.x;
node.data.y = nodeData.y;
});

// 触发format事件,保存历史
this.editor.graph.update();
/**
Expand Down Expand Up @@ -183,6 +183,7 @@ class Schema {

/**
* 获取当前最新的map
* TODO: 数据引用有点混乱,应该去除掉nodesMap和linesMap,改为实时获取
*/
makeNowDataMap() {
const nodes = this.editor.graph.node.nodes;
Expand Down
18 changes: 9 additions & 9 deletions src/Shape/Graph.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ class Graph extends Utils.Event {
node: Node;
line: Line;
anchorLine: AnchorLine;
mode: "edit" | "view";
linkStatus: string;
data: VEditorSchema;
constructor(editor: VEditor) {
Expand All @@ -22,9 +21,6 @@ class Graph extends Utils.Event {
this.line = new Line(this);
this.anchorLine = new AnchorLine(this);

// 模式:操作、查看模式
this.mode = editor.config.mode;

this.listenEvents();
if (this.editor.config.showBackGrid) {
this.addBack();
Expand Down Expand Up @@ -68,7 +64,7 @@ class Graph extends Utils.Event {
onKeyDown = (e: KeyboardEvent) => {

// 查看模式不能删除节点、线条;如果存在部分可操作则自己在业务中监听处理相关逻辑
if (this.mode === "view") {
if (this.editor.config.mode === "view") {
return
}
if (
Expand Down Expand Up @@ -98,16 +94,20 @@ class Graph extends Utils.Event {
/**
* @event Graph#copy
* @type {Object}
*/
this.fire("copy", { event: e });
*/
if (!this.editor.config.disableCopy) {
this.fire("copy", { event: e });
}
return;
}
if (e.keyCode === "V".charCodeAt(0) && (e.metaKey || e.ctrlKey)) {
/**
* @event Graph#paste
* @type {Object}
*/
this.fire("paste", { event: e });
*/
if (!this.editor.config.disableCopy) {
this.fire("paste", { event: e });
}
return;
}
if (
Expand Down
4 changes: 2 additions & 2 deletions src/Shape/Line.ts
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,7 @@ class Line {
*/
this.graph.fire("line:click", { line: g, event: e });
});
if (this.graph.mode === "view") return;
if (this.graph.editor.config.mode === "view") return;
let startX: number;
let startY: number;
// 箭头拖拽
Expand Down Expand Up @@ -505,7 +505,7 @@ class Line {
* 节点的新增线逻辑
*/
addLinkPointEvent = (point: InstanceNodePoint) => {
if (this.graph.mode === "view") return;
if (this.graph.editor.config.mode === "view") return;
const { nodes } = this.graph.node;
const node = nodes[point.nodeId];
let startX: number;
Expand Down
2 changes: 1 addition & 1 deletion src/Shape/Lines/Line.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ const DefaultLine: LineRender = {
}

} else {
const offsetLength = Math.sqrt(Math.pow(start.x - end.y, 2) + Math.pow(start.x - end.y, 2)) / this.arcRatio; // 连接点的距离的一半作为控制点的长度
const offsetLength = Math.sqrt(Math.pow(start.x - end.x, 2) + Math.pow(start.y - end.y, 2)) / this.arcRatio; // 连接点的距离的一半作为控制点的长度
startControlPoint.x += Math.cos(startAngle) * offsetLength;
startControlPoint.y += Math.sin(startAngle) * offsetLength; // svg坐标系倒置需要给y坐标加负号
endControlPoint.x += Math.cos(endAngle) * offsetLength;
Expand Down
8 changes: 5 additions & 3 deletions src/Shape/Node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ class Node {
* 删除节点
* @param {object} data
*/
deleteNode = (input: VEditorNode | string) => {
deleteNode = (input: VEditorNode | string, noEvent: boolean = false) => {
const uuid = typeof input === "string" ? input : input.uuid;
const deleteNode = this.nodes[uuid] as InstanceNode;
const nodeRender = this.shapes[deleteNode.data.type || "default"];
Expand All @@ -185,7 +185,9 @@ class Node {
/**
* @event Graph#node:remove - 移除节点事件
*/
this.graph.fire("node:remove", { node: deleteNode, uuid });
if (!noEvent) {
this.graph.fire("node:remove", { node: deleteNode, uuid });
}
deleteNode.linkPoints?.forEach((point) => {
point.dom.remove();
point = null;
Expand Down Expand Up @@ -489,7 +491,7 @@ class Node {
const { nodes } = this;
clearTimeout(this.timeout);
for (let key in nodes) {
this.deleteNode(nodes[key].data);
this.deleteNode(nodes[key].data, true);
}
}
}
Expand Down
1 change: 1 addition & 0 deletions src/VEditor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export interface VEditorOptions {
hideAchor?: boolean;
hideAchorLine?: boolean;
anchorDistance?: number;
disableCopy?: boolean;
showBackGrid?: boolean;
showMiniMap?: boolean;
mode?: "edit" | "view";
Expand Down
12 changes: 7 additions & 5 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
{
"include": ["src/**/*"],
"include": [
"src/**/*"
],
"compileOnSave": true,
"compilerOptions": {
"pretty": true,
Expand All @@ -9,11 +11,11 @@
"importHelpers": true,
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
"jsx":"react",
"jsx": "react",
"outDir": "dist",
"module": "es6",
"target": "es5",
"module": "esnext",
"target": "ES2015",
"resolveJsonModule": true,
"moduleResolution": "node"
"moduleResolution": "NodeNext"
}
}