本地logicflow依赖包
This commit is contained in:
1 parent
8ff82208ad
commit
30f225df00
290 files changed
+18624
-16276
No files matched your search
@@ -0,0 +1,173 @@
|
||||
<p align="center">
|
||||
<a href="http://logic-flow.org" target="_blank">
|
||||
<img
|
||||
src="http://logic-flow.org/new-logo.png"
|
||||
alt="LogicFlow logo"
|
||||
width="250"
|
||||
/>
|
||||
</a>
|
||||
</p>
|
||||
|
||||
<p align="center">
|
||||
<a href="https://www.npmjs.com/package/@logicflow/core">
|
||||
<img src="https://img.shields.io/npm/v/@logicflow/core" alt="Version">
|
||||
</a>
|
||||
<a href="https://www.npmjs.com/package/@logicflow/core">
|
||||
<img src="https://img.shields.io/npm/dm/@logicflow/core" alt="Download">
|
||||
</a>
|
||||
<a href="https://github.com/didi/LogicFlow/blob/master/LICENSE">
|
||||
<img src="https://img.shields.io/npm/l/@logicflow/core" alt="LICENSE">
|
||||
</a>
|
||||
</p>
|
||||
|
||||
LogicFlow 是一款流程图编辑框架,提供了一系列流程图交互、编辑所必需的功能和简单灵活的节点自定义、插件等拓展机制,方便我们快速在业务系统内满足类流程图的需求。
|
||||
|
||||
## 特性
|
||||
|
||||
|
||||
- 🛠 高拓展性
|
||||
|
||||
兼容各种产品自定义的流程编辑需求,绝大部分模块以插件的形式实现,支持各模块自由插拔。
|
||||
|
||||
- 🚀 重执行
|
||||
|
||||
流程图能完备的表达业务逻辑,不受流程引擎限制。
|
||||
|
||||
- 🎯 专业
|
||||
|
||||
专注于业务流程图编辑的框架
|
||||
|
||||
## 使用
|
||||
|
||||
### 安装
|
||||
|
||||
```sh
|
||||
# npm
|
||||
$ npm install @logicflow/core --save
|
||||
|
||||
|
||||
# yarn
|
||||
$ yarn add @logicflow/core
|
||||
```
|
||||
|
||||
### 代码示例
|
||||
|
||||
```js
|
||||
// 创建容器
|
||||
<div id="container"></div>;
|
||||
|
||||
// 准备数据
|
||||
const data = {
|
||||
// 节点
|
||||
nodes: [
|
||||
{
|
||||
id: 21,
|
||||
type: 'rect',
|
||||
x: 100,
|
||||
y: 200,
|
||||
text: {
|
||||
value: '矩形节点',
|
||||
x: 100,
|
||||
y: 200,
|
||||
},
|
||||
},
|
||||
{
|
||||
id: 50,
|
||||
type: 'circle',
|
||||
x: 300,
|
||||
y: 400,
|
||||
text: {
|
||||
value: '圆形节点',
|
||||
x: 300,
|
||||
y: 400,
|
||||
},
|
||||
},
|
||||
],
|
||||
// 边
|
||||
edges: [
|
||||
{
|
||||
type: 'polyline',
|
||||
sourceNodeId: 50,
|
||||
targetNodeId: 21,
|
||||
},
|
||||
],
|
||||
};
|
||||
// 渲染画布
|
||||
const lf = new LogicFlow({
|
||||
container: document.querySelector('#container'),
|
||||
width: 700,
|
||||
height: 600,
|
||||
});
|
||||
|
||||
lf.render(data);
|
||||
```
|
||||
|
||||
## 文档
|
||||
|
||||
[官方文档](http://logic-flow.org)
|
||||
|
||||
- [快速上手](http://logic-flow.org/guide/start.html#安装)
|
||||
- [基础教程](http://logic-flow.org/guide/basic/logic-flow.html)
|
||||
- [进阶指南](http://logic-flow.org/guide/advance/theme.html)
|
||||
- [拓展](http://logic-flow.org/guide/extension/extension-components.html)
|
||||
- [示例](http://logic-flow.org/usage/bpmn.html)
|
||||
|
||||
## 核心能力
|
||||
|
||||
### 流程图编辑器快速搭建
|
||||
|
||||
提供了一个流程图编辑所必需的各项能力,这也是 LogicFlow 的基础能力:
|
||||
|
||||
- 图的绘制能力。基于 SVG 来绘制形状各异的节点和线,并提供了基础的节点(矩形、圆形、多边形等)和线(直线、折线、曲线)
|
||||
- 各类交互能力,让图动起来。根据节点、线、图的各类鼠标事件(hover、点击、拖拽等)做出反应。比如节点拖拽、拖拽创建边、线的调整、双击节点编辑文本等
|
||||
- 提升编辑效率的能力。提供网格、对齐线,上一步、下一步,键盘快捷键,图放大缩小等配套能力,帮助用户提升编辑效率
|
||||
- 提供了丰富的 API ,宿主研发通过 API 传参调用和监听事件的方式,与 LogicFlow 完成交互
|
||||
|
||||
下面是通过 LogicFlow 内置的节点和配套能力,做的流程图示例
|
||||
:
|
||||
|
||||
<image src="https://dpubstatic.udache.com/static/dpubimg/eEMT14E7BR/lfexample1.gif" width="500"/>
|
||||
|
||||
### 基于业务场景拓展
|
||||
|
||||
当基础能力无法满足业务需求的时候,便需要基于业务场景拓展。
|
||||
|
||||
- 设置图上所有元素的样式,比如各种节点、线、锚点、箭头、对齐线的大小颜色等,满足对前端样式调整的需求
|
||||
- API 拓展。支持在 LogicFlow 上注册自定义的方法,比如通过 API 拓展提供图片下载的方法
|
||||
- 自定义节点、线。内置的矩形、圆形等图形类节点往往无法满足实际的业务需求,需要定义具有业务意义的节点。LogicFlow 提供了 的方式让用户定制具有自定义图形、业务数据的节点,比如流程审批场景中的 “审批” 节点
|
||||
- 拓展组件。LogicFlow 在 SVG 图层上提供了 HTML 层和一系列坐标转换逻辑,并支持在 HTML 层注册组件。宿主研发可以通过 LogicFlow 的 API,基于任何 View 框架开发组件,比如节点的右键菜单、控制面板等
|
||||
- 数据转换 adapter。LogicFlow 默认导出的图数据不一定适合所有业务,此时可以通过 adapter API,在图数据从 LogicFlow 输入、输出的时候做自定义转换,比如转换成 BPMN 规范的图数据
|
||||
- 内置部分拓展能力。基于上述拓展能力,我们还单独提供了 extension 的包,用来存放当前业务下沉淀出的具有通用性的节点、组件等,比如面向 BPMN 规范的节点和数据 adapter,默认菜单。注意 extension 可以单独安装,并支持按需引入
|
||||
|
||||
基于上述拓展的能力,前端研发能够根据实际业务场景的需求,灵活的开发出所需的节点、组件等。下面有两个基于 LogicFlow 拓展能力做出的流程图:
|
||||
|
||||
#### BPMN 规范
|
||||
|
||||

|
||||
|
||||
#### 审批流
|
||||
|
||||

|
||||
|
||||
#### vue 应用 demo
|
||||
|
||||
[代码地址](https://github.com/xinxin93/logicflow_vue_demo)
|
||||
|
||||

|
||||
|
||||
|
||||
#### vue3 node-red风格示例
|
||||
|
||||
[Logic-Flow/logicflow-node-red-vue3](https://github.com/Logic-Flow/logicflow-node-red-vue3)
|
||||
|
||||

|
||||
|
||||
## 联系我们
|
||||
|
||||
### 加入微信群
|
||||
|
||||
添加微信号:logic-flow 加入用户群
|
||||
|
||||
### 加入 QQ 群
|
||||
|
||||
<image src="https://dpubstatic.udache.com/static/dpubimg/VMBzV7jhh8/qq.png" width="300"/>
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
!function(t,e){if("object"==typeof exports&&"object"==typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var r=e();for(var n in r)("object"==typeof exports?exports:t)[n]=r[n]}}(window,(function(){return function(t){var e={};function r(n){if(e[n])return e[n].exports;var o=e[n]={i:n,l:!1,exports:{}};return t[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}return r.m=t,r.c=e,r.d=function(t,e,n){r.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.t=function(t,e){if(1&e&&(t=r(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var o in t)r.d(n,o,function(e){return t[e]}.bind(null,o));return n},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s=215)}([function(t,e,r){"use strict";(function(t,n){r.d(e,"a",(function(){return w})),r.d(e,"b",(function(){return er})),r.d(e,"c",(function(){return Ft})),r.d(e,"d",(function(){return jt})),r.d(e,"e",(function(){return yt})),r.d(e,"f",(function(){return dt})),r.d(e,"g",(function(){return _t})),r.d(e,"h",(function(){return yr})),r.d(e,"i",(function(){return at})),r.d(e,"j",(function(){return wt})),r.d(e,"k",(function(){return Qt})),r.d(e,"l",(function(){return ne})),r.d(e,"m",(function(){return rt})),r.d(e,"n",(function(){return se})),r.d(e,"o",(function(){return E})),r.d(e,"p",(function(){return Se})),r.d(e,"q",(function(){return le})),r.d(e,"r",(function(){return ge})),r.d(e,"s",(function(){return dr})),r.d(e,"t",(function(){return de})),r.d(e,"u",(function(){return ee})),r.d(e,"v",(function(){return Oe})),r.d(e,"w",(function(){return we})),r.d(e,"x",(function(){return je})),r.d(e,"y",(function(){return Je})),r.d(e,"z",(function(){return rr})),r.d(e,"A",(function(){return pr})),r.d(e,"B",(function(){return Ee})),r.d(e,"C",(function(){return Z})),r.d(e,"D",(function(){return Pe})),r.d(e,"E",(function(){return ue})),r.d(e,"F",(function(){return ae})),r.d(e,"G",(function(){return te})),r.d(e,"H",(function(){return $t})),r.d(e,"I",(function(){return De})),r.d(e,"J",(function(){return Me})),r.d(e,"K",(function(){return lt})),r.d(e,"L",(function(){return xe})),r.d(e,"M",(function(){return Ne}));var o=[];Object.freeze(o);var i={};function a(){return++Rt.mobxGuid}function u(t){throw c(!1,t),"X"}function c(t,e){if(!t)throw new Error("[mobx] "+(e||"An invariant failed, however the error is obfuscated because this is a production build."))}Object.freeze(i);function s(t){var e=!1;return function(){if(!e)return e=!0,t.apply(this,arguments)}}var l=function(){};function f(t){return null!==t&&"object"==typeof t}function p(t){if(null===t||"object"!=typeof t)return!1;var e=Object.getPrototypeOf(t);return e===Object.prototype||null===e}function d(t,e,r){Object.defineProperty(t,e,{enumerable:!1,writable:!0,configurable:!0,value:r})}function y(t,e){var r="isMobX"+t;return e.prototype[r]=!0,function(t){return f(t)&&!0===t[r]}}function h(t){return t instanceof Map}function v(t){return t instanceof Set}function g(t){var e=new Set;for(var r in t)e.add(r);return Object.getOwnPropertySymbols(t).forEach((function(r){Object.getOwnPropertyDescriptor(t,r).enumerable&&e.add(r)})),Array.from(e)}function b(t){return t&&t.toString?t.toString():new String(t).toString()}function m(t){return null===t?null:"object"==typeof t?""+t:t}var O="undefined"!=typeof Reflect&&Reflect.ownKeys?Reflect.ownKeys:Object.getOwnPropertySymbols?function(t){return Object.getOwnPropertyNames(t).concat(Object.getOwnPropertySymbols(t))}:Object.getOwnPropertyNames,w=Symbol("mobx administration"),_=function(){function t(t){void 0===t&&(t="Atom@"+a()),this.name=t,this.isPendingUnobservation=!1,this.isBeingObserved=!1,this.observers=new Set,this.diffValue=0,this.lastAccessedBy=0,this.lowestObserverState=J.NOT_TRACKING}return t.prototype.onBecomeObserved=function(){this.onBecomeObservedListeners&&this.onBecomeObservedListeners.forEach((function(t){return t()}))},t.prototype.onBecomeUnobserved=function(){this.onBecomeUnobservedListeners&&this.onBecomeUnobservedListeners.forEach((function(t){return t()}))},t.prototype.reportObserved=function(){return Xt(this)},t.prototype.reportChanged=function(){Bt(),function(t){if(t.lowestObserverState===J.STALE)return;t.lowestObserverState=J.STALE,t.observers.forEach((function(e){e.dependenciesState===J.UP_TO_DATE&&(e.isTracing!==Q.NONE&&Ut(e,t),e.onBecomeStale()),e.dependenciesState=J.STALE}))}(this),Ht()},t.prototype.toString=function(){return this.name},t}(),j=y("Atom",_);function E(t,e,r){void 0===e&&(e=l),void 0===r&&(r=l);var n,o=new _(t);return e!==l&&ce("onBecomeObserved",o,e,n),r!==l&&ue(Line truncated
|
||||
/*! *****************************************************************************
|
||||
Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|
||||
this file except in compliance with the License. You may obtain a copy of the
|
||||
License at http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
|
||||
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
|
||||
MERCHANTABLITY OR NON-INFRINGEMENT.
|
||||
|
||||
See the Apache Version 2.0 License for specific language governing permissions
|
||||
and limitations under the License.
|
||||
***************************************************************************** */var P=function(){return(P=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t}).apply(this,arguments)};function k(t){var e="function"==typeof Symbol&&t[Symbol.iterator],r=0;return e?e.call(t):{next:function(){return t&&r>=t.length&&(t=void 0),{value:t&&t[r++],done:!t}}}}function A(t,e){var r="function"==typeof Symbol&&t[Symbol.iterator];if(!r)return t;var n,o,i=r.call(t),a=[];try{for(;(void 0===e||e-- >0)&&!(n=i.next()).done;)a.push(n.value)}catch(t){o={error:t}}finally{try{n&&!n.done&&(r=i.return)&&r.call(i)}finally{if(o)throw o.error}}return a}function D(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(A(arguments[e]));return t}var T=Symbol("mobx did run lazy initializers"),M=Symbol("mobx pending decorators"),N={},C={};function R(t,e){var r=e?N:C;return r[t]||(r[t]={configurable:!0,enumerable:e,get:function(){return I(this),this[t]},set:function(e){I(this),this[t]=e}})}function I(t){var e,r;if(!0!==t[T]){var n=t[M];if(n){d(t,T,!0);var o=D(Object.getOwnPropertySymbols(n),Object.keys(n));try{for(var i=k(o),a=i.next();!a.done;a=i.next()){var u=n[a.value];u.propertyCreator(t,u.prop,u.descriptor,u.decoratorTarget,u.decoratorArguments)}}catch(t){e={error:t}}finally{try{a&&!a.done&&(r=i.return)&&r.call(i)}finally{if(e)throw e.error}}}}}function L(t,e){return function(){var r,n=function(n,o,i,a){if(!0===a)return e(n,o,i,n,r),null;if(!Object.prototype.hasOwnProperty.call(n,M)){var u=n[M];d(n,M,P({},u))}return n[M][o]={prop:o,propertyCreator:e,descriptor:i,decoratorTarget:n,decoratorArguments:r},R(o,t)};return z(arguments)?(r=o,n.apply(null,arguments)):(r=Array.prototype.slice.call(arguments),n)}}function z(t){return(2===t.length||3===t.length)&&("string"==typeof t[1]||"symbol"==typeof t[1])||4===t.length&&!0===t[3]}function B(t,e,r){return je(t)?t:Array.isArray(t)?Z.array(t,{name:r}):p(t)?Z.object(t,void 0,{name:r}):h(t)?Z.map(t,{name:r}):v(t)?Z.set(t,{name:r}):t}function H(t){return t}function X(e){c(e);var r=L(!0,(function(t,r,n,o,i){var a=n?n.initializer?n.initializer.call(t):n.value:void 0;ur(t).addObservableProp(r,a,e)})),n=(void 0!==t&&t.env,r);return n.enhancer=e,n}var U={deep:!0,name:void 0,defaultDecorator:void 0,proxy:!0};function F(t){return null==t?U:"string"==typeof t?{name:t,deep:!0,proxy:!0}:t}Object.freeze(U);var G=X(B),Y=X((function(t,e,r){return null==t||pr(t)||Je(t)||rr(t)||ir(t)?t:Array.isArray(t)?Z.array(t,{name:r,deep:!1}):p(t)?Z.object(t,void 0,{name:r,deep:!1}):h(t)?Z.map(t,{name:r,deep:!1}):v(t)?Z.set(t,{name:r,deep:!1}):u(!1)})),V=X(H),W=X((function(t,e,r){return vr(t,e)?e:t}));function K(t){return t.defaultDecorator?t.defaultDecorator.enhancer:!1===t.deep?H:B}var $={box:function(t,e){arguments.length>2&&q("box");var r=F(e);return new St(t,K(r),r.name,!0,r.equals)},array:function(t,e){arguments.length>2&&q("array");var r=F(e);return We(t,K(r),r.name)},map:function(t,e){arguments.length>2&&q("map");var r=F(e);return new er(t,K(r),r.name)},set:function(t,e){arguments.length>2&&q("set");var r=F(e);return new or(t,K(r),r.name)},object:function(t,e,r){"string"==typeof arguments[1]&&q("object");var n=F(r);if(!1===n.proxy)return le({},t,e,n);var o=fe(n),i=le({},void 0,void 0,n),a=Be(i);return pe(a,t,e,o),a},ref:V,shallow:Y,deep:G,struct:W},Z=function(t,e,r){if("string"==typeof arguments[1]||"symbol"==typeof arguments[1])return G.apply(null,arguments);if(je(t))return t;var n=p(t)?Z.object(t,e,r):Array.isArray(t)?Z.array(t,e):h(t)?Z.map(t,e):v(t)?Z.set(t,e):t;if(n!==t)return n;u(!1)};function q(t){u("Expected one or two arguments to observable."+t+". Did you accidentally try to use observable."+t+" as decorator?")}Object.keys($).forEach((function(t){return Z[t]=$[t]}));var J,Q,tt=L(!1,(function(t,e,r,n,o){var i=r.get,a=r.set,u=o[0]||{};ur(t).addComputedProp(t,e,P({get:i,set:a,context:t},u))})),et=tt({equals:x.structural}),rt=function(t,e,r){if("string"==typeof e)return tt.apply(null,arguments);if(null!==t&&"object"==typeof t&&1===arguments.length)return tt.apply(null,arguments);var n="object"==typeof e?e:{};return n.get=t,n.set="function"==typeof e?e:n.set,n.name=n.name||t.name||"",new kt(n)};rt.struct=et,function(t){t[t.NOT_TRACKING=-1]="NOT_TRACKING",t[t.UP_TO_DATE=0]="UP_TO_DATE",t[t.POSSIBLY_STALE=1]="POSSIBLY_STALE",t[t.STALE=2]="STALE"}(J||(J={})),function(t){t[t.NONE=0]="NONE",t[t.LOG=1]="LOG",t[t.BREAK=2]="BREAK"}(Q||(Q={}));var nt=function(t){this.cause=t};function ot(t){return t instanceof nt}function it(t){switch(t.dependenciesState){case J.UP_TO_DATE:return!1;case J.NOT_TRACKING:case J.STALE:return!0;case J.POSSIBLY_STALE:for(var e=dt(!0),r=ft(),n=t.observing,o=n.length,i=0;i<o;i++){var a=n[i];if(At(a)){if(Rt.disableErrorBoundaries)a.get();else try{a.get()}catch(t){return pt(r),yt(e),!0}if(t.dependenciesState===J.STALE)return pt(r),yt(e),!0}}return ht(t),pt(r),yt(e),!1}}function at(){return null!Line truncated
|
||||
+195
@@ -0,0 +1,195 @@
|
||||
.lf-graph {
|
||||
position: relative;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
z-index: 0;
|
||||
background: #ffffff;
|
||||
user-select: none;
|
||||
}
|
||||
.lf-element-text {
|
||||
cursor: text;
|
||||
}
|
||||
.lf-text-disabled {
|
||||
pointer-events: none;
|
||||
}
|
||||
.lf-text-draggable {
|
||||
cursor: move;
|
||||
}
|
||||
.lf-node-anchor {
|
||||
cursor: crosshair;
|
||||
}
|
||||
.lf-node-anchor-hover {
|
||||
visibility: hidden;
|
||||
}
|
||||
.lf-anchor:hover .lf-node-anchor-hover {
|
||||
visibility: visible;
|
||||
}
|
||||
.lf-edge.pointer-none {
|
||||
pointer-events: none;
|
||||
}
|
||||
.lf-edge-append {
|
||||
cursor: pointer;
|
||||
}
|
||||
.lf-edge-animation {
|
||||
stroke-dashoffset: 100%;
|
||||
animation: dash 5s linear infinite;
|
||||
}
|
||||
@keyframes dash {
|
||||
to {
|
||||
stroke-dashoffset: 0;
|
||||
}
|
||||
}
|
||||
/* node */
|
||||
.lf-node-not-allow {
|
||||
cursor: not-allowed;
|
||||
}
|
||||
|
||||
.lf-polyline-append-ns-resize {
|
||||
cursor: ns-resize;
|
||||
}
|
||||
.lf-polyline-append-ew-resize {
|
||||
cursor: ew-resize;
|
||||
}
|
||||
.lf-dragging {
|
||||
cursor: grabbing;
|
||||
}
|
||||
.lf-drag-able {
|
||||
cursor: default;
|
||||
}
|
||||
.lf-bezier-adjust-anchor {
|
||||
cursor: pointer;
|
||||
}
|
||||
/* background */
|
||||
.lf-background,
|
||||
.lf-grid {
|
||||
position: absolute;
|
||||
left: 0px;
|
||||
top: 0px;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
z-index: -1;
|
||||
}
|
||||
.lf-background-area {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
/* html-overlay */
|
||||
.lf-html-overlay {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
z-index: 1;
|
||||
pointer-events: none;
|
||||
overflow: hidden;
|
||||
user-select: none;
|
||||
}
|
||||
.lf-html-overlay__transform > * {
|
||||
pointer-events: all;
|
||||
}
|
||||
|
||||
.lf-text-editable {
|
||||
pointer-events: all;
|
||||
}
|
||||
.lf-text-input {
|
||||
text-align: center;
|
||||
outline: none;
|
||||
position: absolute;
|
||||
border: 1px solid #edefed;
|
||||
box-sizing: border-box;
|
||||
line-height: 1.2;
|
||||
border-radius: 3px;
|
||||
resize: none;
|
||||
padding: 5px;
|
||||
min-height: 20px;
|
||||
min-width: 100px;
|
||||
white-space: pre;
|
||||
background: #fff;
|
||||
transform: translate(-50%, -50%);
|
||||
}
|
||||
.lf-get-text-height {
|
||||
display: inline-block;
|
||||
word-break: break-all;
|
||||
/* 为了跟输入效果保持一致,设置透明边框占位 */
|
||||
border: 1px solid transparent;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
.lf-node-text-auto-wrap {
|
||||
box-sizing: border-box;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
/* border: 1px solid transparent; */
|
||||
}
|
||||
.lf-node-text-auto-wrap-content {
|
||||
line-height: 1.2;
|
||||
background: transparent;
|
||||
text-align: center;
|
||||
word-break: break-all;
|
||||
width: 100%;
|
||||
}
|
||||
.lf-node-text-ellipsis-content {
|
||||
line-height: 1.2;
|
||||
background: transparent;
|
||||
text-align: center;
|
||||
white-space: nowrap;
|
||||
/* overflow: hidden;
|
||||
text-overflow: ellipsis; */
|
||||
width: 100%;
|
||||
}
|
||||
.lf-node-text-ellipsis-content>div{
|
||||
text-overflow: ellipsis;
|
||||
overflow: hidden;
|
||||
}
|
||||
/* tool-overlay */
|
||||
.lf-tool-overlay {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
z-index: 2;
|
||||
pointer-events: none;
|
||||
overflow: hidden;
|
||||
}
|
||||
.lf-tool-overlay > * {
|
||||
pointer-events: all;
|
||||
}
|
||||
/* modification-overlay */
|
||||
|
||||
.modification-overlay {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
z-index: 1;
|
||||
pointer-events: none;
|
||||
overflow: hidden;
|
||||
}
|
||||
.modification-overlay > * {
|
||||
pointer-events: all;
|
||||
}
|
||||
.lf-outline,.lf-snapline {
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
.lf-keyboard-tips {
|
||||
float: right;
|
||||
}
|
||||
.lf-node-select-decorate {
|
||||
transform: translate(-50%, -50%);
|
||||
pointer-events: none;
|
||||
border: 1px dashed #343435;
|
||||
position: absolute;
|
||||
}
|
||||
.lf-multiple-select {
|
||||
position: absolute;
|
||||
border: 2px dashed rgba(24, 125, 255, 0.8);
|
||||
box-shadow: 0px 0px 3px 0px rgba(24, 125, 255, 0.5);
|
||||
cursor: move;
|
||||
}
|
||||
.lf-edge-adjust-point {
|
||||
cursor: move;
|
||||
}
|
||||
@@ -0,0 +1,99 @@
|
||||
{
|
||||
"name": "@logicflow/core",
|
||||
"version": "1.1.12",
|
||||
"description": "LogicFlow core, to quickly build flowchart editor",
|
||||
"main": "dist/logic-flow.js",
|
||||
"unpkg": "dist/logic-flow.js",
|
||||
"jsdelivr": "dist/logic-flow.js",
|
||||
"license": "Apache-2.0",
|
||||
"homepage": "http://logic-flow.org/",
|
||||
"types": "types/index.d.ts",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/didi/LogicFlow",
|
||||
"directory": "packages/core"
|
||||
},
|
||||
"scripts": {
|
||||
"dev": "cross-env NODE_ENV=development webpack-dev-server --client-log-level warning --config scripts/webpack.config.dev.js",
|
||||
"clean": "rimraf dist lib esm cjs",
|
||||
"build": "npm run build:umd",
|
||||
"build:umd": "cross-env NODE_ENV=production webpack --config scripts/webpack.config.build.js && cp -r src/style/ dist/style",
|
||||
"build-analyse": "cross-env analyse=true npm run build",
|
||||
"types": "tsc -d --declarationDir ./types --outDir temp && rimraf temp",
|
||||
"lint": "eslint . --ext .ts,.tsx",
|
||||
"publish-lib": "npm run types & npm run clean && npm run build && npm publish",
|
||||
"publish-next": "npm run types & npm run clean && npm run build && npm publish --tag next"
|
||||
},
|
||||
"files": [
|
||||
"dist",
|
||||
"es",
|
||||
"types",
|
||||
"README.md"
|
||||
],
|
||||
"dependencies": {
|
||||
"@types/mousetrap": "^1.6.4",
|
||||
"mousetrap": "^1.6.5",
|
||||
"preact": "^10.4.8"
|
||||
},
|
||||
"keywords": [
|
||||
"flowchart",
|
||||
"diagram"
|
||||
],
|
||||
"devDependencies": {
|
||||
"@babel/core": "^7.9.0",
|
||||
"@babel/plugin-proposal-class-properties": "^7.8.3",
|
||||
"@babel/plugin-proposal-decorators": "^7.10.5",
|
||||
"@babel/plugin-syntax-jsx": "^7.8.3",
|
||||
"@babel/plugin-transform-react-jsx": "^7.10.4",
|
||||
"@babel/preset-env": "^7.9.5",
|
||||
"@babel/preset-typescript": "^7.9.0",
|
||||
"@types/lodash-es": "^4.17.3",
|
||||
"@typescript-eslint/eslint-plugin": "^3.6.1",
|
||||
"@typescript-eslint/parser": "^3.2.0",
|
||||
"autoprefixer": "^9.7.6",
|
||||
"babel-core": "^7.0.0-bridge.0",
|
||||
"babel-loader": "^8.1.0",
|
||||
"babel-plugin-import": "^1.13.0",
|
||||
"case-sensitive-paths-webpack-plugin": "^2.3.0",
|
||||
"classnames": "^2.2.6",
|
||||
"core-js": "^3.6.5",
|
||||
"cross-env": "^7.0.2",
|
||||
"css-loader": "^4.2.1",
|
||||
"eslint": "^7.0.0",
|
||||
"eslint-config-airbnb-typescript": "^9.0.0",
|
||||
"eslint-loader": "^4.0.2",
|
||||
"eslint-plugin-import": "^2.22.0",
|
||||
"eslint-plugin-jsx-a11y": "^6.3.1",
|
||||
"eslint-plugin-react": "^7.20.6",
|
||||
"eslint-plugin-react-hooks": "^4.1.2",
|
||||
"eslint-plugin-standard": "^4.0.1",
|
||||
"eslint-webpack-plugin": "^2.1.0",
|
||||
"html-webpack-plugin": "^4.2.0",
|
||||
"husky": "^4.2.5",
|
||||
"ids": "^1.0.0",
|
||||
"less-loader": "^6.0.0",
|
||||
"lodash-es": "^4.17.15",
|
||||
"mobx": "^5.15.7",
|
||||
"mobx-react": "^6.3.0",
|
||||
"mobx-utils": "^5.6.1",
|
||||
"prettier": "^2.2.1",
|
||||
"rimraf": "^3.0.2",
|
||||
"standard-version": "^9.0.0",
|
||||
"style-loader": "^1.2.0",
|
||||
"style-resources-loader": "^1.3.3",
|
||||
"terser-webpack-plugin": "^4.2.3",
|
||||
"typescript": "^3.8.3",
|
||||
"url-loader": "^4.1.0",
|
||||
"uuid": "^8.2.0",
|
||||
"webpack": "^4.43.0",
|
||||
"webpack-bundle-analyzer": "^3.7.0",
|
||||
"webpack-cli": "^3.3.11",
|
||||
"webpack-dev-server": "^3.10.3"
|
||||
},
|
||||
"browserslist": [
|
||||
"> 3%",
|
||||
"last 2 versions",
|
||||
"not ie <= 11"
|
||||
],
|
||||
"gitHead": "ab8cc6126e9dfa5c4fb18037538a374d3a0b0521"
|
||||
}
|
||||
+553
@@ -0,0 +1,553 @@
|
||||
import GraphModel from './model/GraphModel';
|
||||
import Dnd from './view/behavior/DnD';
|
||||
import * as Options from './options';
|
||||
import * as _Model from './model';
|
||||
import History from './history/History';
|
||||
import Tool from './tool';
|
||||
import { CallbackType } from './event/eventEmitter';
|
||||
import Keyboard from './keyboard';
|
||||
import { EdgeConfig, EdgeFilter, NodeConfig, Extension, ComponentRender, FocusOnArgs, EdgeData, GraphConfigData, RegisterElementFn, RegisterConfig, ZoomParam, PointTuple } from './type';
|
||||
import SnaplineModel from './model/SnaplineModel';
|
||||
import { EditConfigInterface } from './model/EditConfigModel';
|
||||
import { Theme } from './constant/DefaultTheme';
|
||||
declare type GraphConfigModel = {
|
||||
nodes: _Model.BaseNodeModel[];
|
||||
edges: _Model.BaseEdgeModel[];
|
||||
};
|
||||
export default class LogicFlow {
|
||||
/**
|
||||
* 只读:logicflow实例挂载的容器。
|
||||
*/
|
||||
container: HTMLElement;
|
||||
/**
|
||||
* 只读:画布宽度
|
||||
*/
|
||||
width: number;
|
||||
/**
|
||||
* 只读:画布高度
|
||||
*/
|
||||
height: number;
|
||||
/**
|
||||
* 只读:控制整个logicflow画布的model
|
||||
*/
|
||||
graphModel: GraphModel;
|
||||
/**
|
||||
* 只读:控制上一步、下一步相关
|
||||
*/
|
||||
history: History;
|
||||
viewMap: Map<any, any>;
|
||||
tool: Tool;
|
||||
keyboard: Keyboard;
|
||||
dnd: Dnd;
|
||||
options: Options.Definition;
|
||||
snaplineModel: SnaplineModel;
|
||||
components: ComponentRender[];
|
||||
/**
|
||||
* 个性配置的插件,覆盖全局配置的插件
|
||||
*/
|
||||
plugins: Extension[];
|
||||
/**
|
||||
* 全局配置的插件,所有的LogicFlow示例都会使用
|
||||
*/
|
||||
static extensions: Map<string, Extension>;
|
||||
/**
|
||||
* 插件扩展方法
|
||||
* @example
|
||||
*/
|
||||
extension: Record<string, any>;
|
||||
/**
|
||||
* 自定义数据格式转换方法
|
||||
* 当接入系统格式和logicflow格式不一直的时候,可以自定义此方法来转换数据格式
|
||||
* 详情请参考adapter
|
||||
* @see todo
|
||||
*/
|
||||
adapterIn: (data: unknown) => GraphConfigData;
|
||||
/**
|
||||
* 自定义数据格式转换方法
|
||||
* 把logicflow输入的格式转换也接入系统需要的格式
|
||||
* 详情请参考adapter
|
||||
* @see todo
|
||||
*/
|
||||
adapterOut: (data: GraphConfigData) => unknown;
|
||||
/**
|
||||
* 支持插件在logicflow实例上增加自定义方法
|
||||
*/
|
||||
[propName: string]: any;
|
||||
constructor(options: Options.Definition);
|
||||
/**
|
||||
* 注册自定义节点和边
|
||||
* 支持两种方式
|
||||
* 方式一(推荐)
|
||||
* 详情见 todo: docs link
|
||||
* @example
|
||||
* import { RectNode, RectModel } from '@logicflow/core'
|
||||
* class CustomView extends RectNode {
|
||||
* }
|
||||
* class CustomModel extends RectModel {
|
||||
* }
|
||||
* lf.register({
|
||||
* type: 'custom',
|
||||
* view: CustomView,
|
||||
* model: CustomModel
|
||||
* })
|
||||
* 方式二
|
||||
* 不推荐,极个别在自定义的时候需要用到lf的情况下可以用这种方式。
|
||||
* 大多数情况下,我们可以直接在view中从this.props中获取graphModel
|
||||
* 或者model中直接this.graphModel获取model的方法。
|
||||
* @example
|
||||
* lf.register('custom', ({ RectNode, RectModel }) => {
|
||||
* class CustomView extends RectNode {}
|
||||
* class CustomModel extends RectModel {}
|
||||
* return {
|
||||
* view: CustomView,
|
||||
* model: CustomModel
|
||||
* }
|
||||
* })
|
||||
*/
|
||||
register(type: string | RegisterConfig, fn?: RegisterElementFn, isObserverView?: boolean): void;
|
||||
private registerElement;
|
||||
private defaultRegister;
|
||||
/**
|
||||
* 将图形选中
|
||||
* @param id 选择元素ID
|
||||
* @param multiple 是否允许多选,如果为true,不会将上一个选中的元素重置
|
||||
*/
|
||||
selectElementById(id: string, multiple?: boolean): void;
|
||||
/**
|
||||
* 定位到画布视口中心
|
||||
* 支持用户传入图形当前的坐标或id,可以通过type来区分是节点还是边的id,也可以不传(兜底)
|
||||
* @param focusOnArgs.id 如果传入的是id, 则画布视口中心移动到此id的元素中心点。
|
||||
* @param focusOnArgs.coordinate 如果传入的是坐标,则画布视口中心移动到此坐标。
|
||||
*/
|
||||
focusOn(focusOnArgs: FocusOnArgs): void;
|
||||
/**
|
||||
* 设置主题样式
|
||||
* @param { object } style 自定义主题样式
|
||||
* todo docs link
|
||||
*/
|
||||
setTheme(style: Theme): void;
|
||||
/**
|
||||
* 重新设置画布的宽高
|
||||
*/
|
||||
resize(width: number, height: number): void;
|
||||
/**
|
||||
* 设置默认的边类型。
|
||||
* 也就是设置在节点直接有用户手动绘制的连线类型。
|
||||
* @param type Options.EdgeType
|
||||
*/
|
||||
setDefaultEdgeType(type: Options.EdgeType): void;
|
||||
/**
|
||||
* 更新节点或边的文案
|
||||
* @param id 节点或者边id
|
||||
* @param value 文案内容
|
||||
*/
|
||||
updateText(id: string, value: string): void;
|
||||
/**
|
||||
* 删除元素,在不确定当前id是节点还是边时使用
|
||||
* @param id 元素id
|
||||
*/
|
||||
deleteElement(id: any): boolean;
|
||||
/**
|
||||
* 获取节点或边对象
|
||||
* @param id id
|
||||
*/
|
||||
getModelById(id: string): _Model.BaseNodeModel | _Model.BaseEdgeModel;
|
||||
/**
|
||||
* 获取节点或边的数据
|
||||
* @param id id
|
||||
*/
|
||||
getDataById(id: string): NodeConfig | EdgeConfig;
|
||||
/**
|
||||
* 修改指定节点类型
|
||||
* @param id 节点id
|
||||
* @param type 节点类型
|
||||
*/
|
||||
changeNodeType(id: string, type: string): void;
|
||||
/**
|
||||
* 切换边的类型
|
||||
* @param id 边Id
|
||||
* @param type 边类型
|
||||
*/
|
||||
changeEdgeType(id: string, type: string): void;
|
||||
/**
|
||||
* 获取节点连接的所有边的model
|
||||
* @param nodeId 节点ID
|
||||
* @returns model数组
|
||||
*/
|
||||
getNodeEdges(nodeId: any): _Model.BaseEdgeModel[];
|
||||
/**
|
||||
* 添加节点
|
||||
* @param nodeConfig 节点配置
|
||||
*/
|
||||
addNode(nodeConfig: NodeConfig): _Model.BaseNodeModel;
|
||||
/**
|
||||
* 删除节点
|
||||
* @param {string} nodeId 节点Id
|
||||
*/
|
||||
deleteNode(nodeId: string): boolean;
|
||||
/**
|
||||
* 克隆节点
|
||||
* @param nodeId 节点Id
|
||||
*/
|
||||
cloneNode(nodeId: string): _Model.BaseNodeModel;
|
||||
/**
|
||||
* 修改节点的id, 如果不传新的id,会内部自动创建一个。
|
||||
* @param { string } oldId 将要被修改的id
|
||||
* @param { string } newId 可选,修改后的id
|
||||
* @returns 修改后的节点id, 如果传入的oldId不存在,返回空字符串
|
||||
*/
|
||||
changeNodeId<T extends string>(oldId: string, newId?: T): T | string;
|
||||
/**
|
||||
* 获取节点对象
|
||||
* @param nodeId 节点Id
|
||||
*/
|
||||
getNodeModelById(nodeId: string): _Model.BaseNodeModel;
|
||||
/**
|
||||
* 获取节点数据
|
||||
* @param nodeId 节点
|
||||
*/
|
||||
getNodeDataById(nodeId: string): NodeConfig;
|
||||
/**
|
||||
* 给两个节点之间添加一条边
|
||||
* @example
|
||||
* lf.addEdge({
|
||||
* type: 'polygon'
|
||||
* sourceNodeId: 'node_id_1',
|
||||
* targetNodeId: 'node_id_2',
|
||||
* })
|
||||
* @param {object} edgeConfig
|
||||
*/
|
||||
addEdge(edgeConfig: EdgeConfig): _Model.BaseEdgeModel;
|
||||
/**
|
||||
* 删除边
|
||||
* @param {string} edgeId 边Id
|
||||
*/
|
||||
deleteEdge(edgeId: string): boolean;
|
||||
/**
|
||||
* 删除指定类型的边, 基于边起点和终点,可以只传其一。
|
||||
* @param config.sourceNodeId 边的起点节点ID
|
||||
* @param config.targetNodeId 边的终点节点ID
|
||||
*/
|
||||
deleteEdgeByNodeId(config: {
|
||||
sourceNodeId?: string;
|
||||
targetNodeId?: string;
|
||||
}): void;
|
||||
/**
|
||||
* 修改边的id, 如果不传新的id,会内部自动创建一个。
|
||||
* @param { string } oldId 将要被修改的id
|
||||
* @param { string } newId 可选,修改后的id
|
||||
* @returns 修改后的节点id, 如果传入的oldId不存在,返回空字符串
|
||||
*/
|
||||
changeEdgeId<T extends string>(oldId: string, newId?: T): T | string;
|
||||
/**
|
||||
* 基于边Id获取边的model
|
||||
* @param edgeId 边的Id
|
||||
* @return model
|
||||
*/
|
||||
getEdgeModelById(edgeId: string): _Model.BaseEdgeModel;
|
||||
/**
|
||||
* 获取满足条件边的model
|
||||
* @param edgeFilter 过滤条件
|
||||
* @example
|
||||
* 获取所有起点为节点A的边的model
|
||||
* lf.getEdgeModels({
|
||||
* sourceNodeId: 'nodeA_id'
|
||||
* })
|
||||
* 获取所有终点为节点B的边的model
|
||||
* lf.getEdgeModels({
|
||||
* targetNodeId: 'nodeB_id'
|
||||
* })
|
||||
* 获取起点为节点A,终点为节点B的边
|
||||
* lf.getEdgeModels({
|
||||
* sourceNodeId: 'nodeA_id',
|
||||
* targetNodeId: 'nodeB_id'
|
||||
* })
|
||||
* @return model数组
|
||||
*/
|
||||
getEdgeModels(edgeFilter: EdgeFilter): _Model.BaseEdgeModel[];
|
||||
/**
|
||||
* 基于id获取边数据
|
||||
* @param edgeId 边Id
|
||||
* @returns EdgeData
|
||||
*/
|
||||
getEdgeDataById(edgeId: string): EdgeData;
|
||||
/**
|
||||
* 获取所有以此节点为终点的边
|
||||
*/
|
||||
getNodeIncomingEdge(nodeId: any): any[];
|
||||
/**
|
||||
* 获取所有以此节点为起点的边
|
||||
*/
|
||||
getNodeOutgoingEdge(nodeId: any): any[];
|
||||
/**
|
||||
* 获取节点连接到的所有起始节点
|
||||
*/
|
||||
getNodeIncomingNode(nodeId: any): any[];
|
||||
/**
|
||||
* 获取节点连接到的所有目标节点
|
||||
*/
|
||||
getNodeOutgoingNode(nodeId: any): any[];
|
||||
/**
|
||||
* 显示节点、连线文本编辑框
|
||||
* @param id 元素id
|
||||
*/
|
||||
editText(id: string): void;
|
||||
/**
|
||||
* 设置元素的自定义属性
|
||||
* @see todo docs link
|
||||
* @param id 元素的id
|
||||
* @param properties 自定义属性
|
||||
*/
|
||||
setProperties(id: string, properties: Object): void;
|
||||
/**
|
||||
* 获取元素的自定义属性
|
||||
* @param id 元素的id
|
||||
* @returns 自定义属性
|
||||
*/
|
||||
getProperties(id: string): Object;
|
||||
/**
|
||||
* 将某个元素放置到顶部。
|
||||
* 如果堆叠模式为默认模式,则将原置顶元素重新恢复原有层级。
|
||||
* 如果堆叠模式为递增模式,则将需指定元素zIndex设置为当前最大zIndex + 1。
|
||||
* @see todo link 堆叠模式
|
||||
* @param id 元素Id
|
||||
*/
|
||||
toFront(id: any): void;
|
||||
/**
|
||||
* 设置元素的zIndex.
|
||||
* 注意:默认堆叠模式下,不建议使用此方法。
|
||||
* @see todo link 堆叠模式
|
||||
* @param id 元素id
|
||||
* @param zIndex zIndex的值,可以传数字,也支持传入'top' 和 'bottom'
|
||||
*/
|
||||
setElementZIndex(id: string, zIndex: number | 'top' | 'bottom'): void;
|
||||
/**
|
||||
* 添加多个元素, 包括边和节点。
|
||||
*/
|
||||
addElements({ nodes, edges }: GraphConfigData): GraphConfigModel;
|
||||
/**
|
||||
* 获取指定区域内的所有元素,此区域必须是DOM层。
|
||||
* 例如鼠标绘制选区后,获取选区内的所有元素。
|
||||
* @see todo 分层
|
||||
* @param leftTopPoint 区域左上角坐标, dom层坐标
|
||||
* @param rightBottomPoint 区域右下角坐标,dom层坐标
|
||||
*/
|
||||
getAreaElement(leftTopPoint: PointTuple, rightBottomPoint: PointTuple, wholeEdge?: boolean, wholeNode?: boolean): any[];
|
||||
/**
|
||||
* 获取选中的元素数据
|
||||
* @param isIgnoreCheck 是否包括sourceNode和targetNode没有被选中的边,默认包括。
|
||||
* 注意:复制的时候不能包括此类边, 因为复制的时候不允许悬空的边。
|
||||
*/
|
||||
getSelectElements(isIgnoreCheck?: boolean): GraphConfigData;
|
||||
/**
|
||||
* 将所有选中的元素设置为非选中
|
||||
*/
|
||||
clearSelectElements(): void;
|
||||
/**
|
||||
* 获取流程绘图数据
|
||||
* 注意: getGraphData返回的数据受到adapter影响,所以其数据格式不一定是logicflow内部图数据格式。
|
||||
* 如果实现通用插件,请使用getGraphRawData
|
||||
*/
|
||||
getGraphData(): GraphConfigData | any;
|
||||
/**
|
||||
* 获取流程绘图原始数据
|
||||
* 在存在adapter时,可以使用getGraphRawData获取图原始数据
|
||||
*/
|
||||
getGraphRawData(): GraphConfigData;
|
||||
/**
|
||||
* 清空画布
|
||||
*/
|
||||
clearData(): void;
|
||||
/**
|
||||
* 更新流程图编辑相关设置
|
||||
* @param {object} config 编辑配置
|
||||
* @see todo docs link
|
||||
*/
|
||||
updateEditConfig(config: EditConfigInterface): void;
|
||||
/**
|
||||
* 获取流程图当前编辑相关设置
|
||||
* @see todo docs link
|
||||
*/
|
||||
getEditConfig(): Partial<_Model.EditConfigModel>;
|
||||
/**
|
||||
* 获取事件位置相对于画布左上角的坐标
|
||||
* 画布所在的位置可以是页面任何地方,原生事件返回的坐标是相对于页面左上角的,该方法可以提供以画布左上角为原点的准确位置。
|
||||
* @see todo link
|
||||
* @param {number} x 事件x坐标
|
||||
* @param {number} y 事件y坐标
|
||||
* @returns {object} Point 事件位置的坐标
|
||||
* @returns {object} Point.domOverlayPosition HTML层上的坐标
|
||||
* @returns {object} Point.canvasOverlayPosition SVG层上的坐标
|
||||
*/
|
||||
getPointByClient(x: number, y: number): {
|
||||
domOverlayPosition: {
|
||||
x: number;
|
||||
y: number;
|
||||
};
|
||||
canvasOverlayPosition: {
|
||||
x: number;
|
||||
y: number;
|
||||
};
|
||||
};
|
||||
/**
|
||||
* 历史记录操作
|
||||
* 返回上一步
|
||||
*/
|
||||
undo(): void;
|
||||
/**
|
||||
* 历史记录操作
|
||||
* 恢复下一步
|
||||
*/
|
||||
redo(): void;
|
||||
/**
|
||||
* 放大缩小图形
|
||||
* @param zoomSize 放大缩小的值,支持传入0-n之间的数字。小于1表示缩小,大于1表示放大。也支持传入true和false按照内置的刻度放大缩小
|
||||
* @param point 缩放的原点
|
||||
* @returns {string} -放大缩小的比例
|
||||
*/
|
||||
zoom(zoomSize?: ZoomParam, point?: PointTuple): string;
|
||||
/**
|
||||
* 重置图形的放大缩写比例为默认
|
||||
*/
|
||||
resetZoom(): void;
|
||||
/**
|
||||
* 设置图形缩小时,能缩放到的最小倍数。参数为0-1自己。默认0.2
|
||||
* @param size 图形缩小的最小值
|
||||
*/
|
||||
setZoomMiniSize(size: number): void;
|
||||
/**
|
||||
* 设置图形放大时,能放大到的最大倍数,默认16
|
||||
* @param size 图形放大的最大值
|
||||
*/
|
||||
setZoomMaxSize(size: number): void;
|
||||
/**
|
||||
* 获取缩放的值和平移的值。
|
||||
*/
|
||||
getTransform(): {
|
||||
SCALE_X: number;
|
||||
SCALE_Y: number;
|
||||
TRANSLATE_X: number;
|
||||
TRANSLATE_Y: number;
|
||||
};
|
||||
/**
|
||||
* 平移图
|
||||
* @param x 向x轴移动距离
|
||||
* @param y 向y轴移动距离
|
||||
*/
|
||||
translate(x: number, y: number): void;
|
||||
/**
|
||||
* 还原图形为初始位置
|
||||
*/
|
||||
resetTranslate(): void;
|
||||
/**
|
||||
* 图形画布居中显示
|
||||
*/
|
||||
translateCenter(): void;
|
||||
/**
|
||||
* 图形适应屏幕大小
|
||||
* @param offset number 距离盒子四周的距离, 默认为20
|
||||
*/
|
||||
fitView(offset: number): void;
|
||||
/**
|
||||
* 监听事件
|
||||
* 事件详情见 @see todo
|
||||
* 支持同时监听多个事件
|
||||
* @example
|
||||
* lf.on('node:click,node:contextmenu', (data) => {
|
||||
* });
|
||||
*/
|
||||
on(evt: string, callback: CallbackType): void;
|
||||
/**
|
||||
* 撤销监听事件
|
||||
*/
|
||||
off(evt: string, callback: CallbackType): void;
|
||||
/**
|
||||
* 监听事件,只监听一次
|
||||
*/
|
||||
once(evt: string, callback: CallbackType): void;
|
||||
/**
|
||||
* 触发监听事件
|
||||
*/
|
||||
emit(evt: string, arg: any): void;
|
||||
/**
|
||||
* 添加扩展, 待讨论,这里是不是静态方法好一些?
|
||||
* 重复添加插件的时候,把上一次添加的插件的销毁。
|
||||
* @param plugin 插件
|
||||
*/
|
||||
static use(extension: Extension): void;
|
||||
private installPlugins;
|
||||
/**
|
||||
* 加载插件-内部方法
|
||||
*/
|
||||
private installPlugin;
|
||||
/**
|
||||
* 修改对应元素 model 中的属性
|
||||
* 注意:此方法慎用,除非您对logicflow内部有足够的了解。
|
||||
* 大多数情况下,请使用setProperties、updateText、changeNodeId等方法。
|
||||
* 例如直接使用此方法修改节点的id,那么就是会导致连接到此节点的边的sourceNodeId出现找不到的情况。
|
||||
* @param {string} id 元素id
|
||||
* @param {object} attributes 需要更新的属性
|
||||
*/
|
||||
updateAttributes(id: string, attributes: object): void;
|
||||
/**
|
||||
* 内部保留方法
|
||||
* 创建一个fakerNode,用于dnd插件拖动节点进画布的时候使用。
|
||||
*/
|
||||
createFakerNode(nodeConfig: any): any;
|
||||
/**
|
||||
* 内部保留方法
|
||||
* 移除fakerNode
|
||||
*/
|
||||
removeFakerNode(): void;
|
||||
/**
|
||||
* 内部保留方法
|
||||
* 用于fakerNode显示对齐线
|
||||
*/
|
||||
setNodeSnapLine(data: any): void;
|
||||
/**
|
||||
* 内部保留方法
|
||||
* 用于fakerNode移除对齐线
|
||||
*/
|
||||
removeNodeSnapLine(): void;
|
||||
/**
|
||||
* 内部保留方法
|
||||
* 用于fakerNode移除对齐线
|
||||
*/
|
||||
setView(type: string, component: any): void;
|
||||
renderRawData(graphRawData: any): void;
|
||||
/**
|
||||
* 渲染图
|
||||
* @example
|
||||
* lf.render({
|
||||
* nodes: [
|
||||
* {
|
||||
* id: 'node_1',
|
||||
* type: 'rect',
|
||||
* x: 100,
|
||||
* y: 100
|
||||
* },
|
||||
* {
|
||||
* id: 'node_2',
|
||||
* type: 'circel',
|
||||
* x: 300,
|
||||
* y: 200
|
||||
* }
|
||||
* ],
|
||||
* edges: [
|
||||
* {
|
||||
* sourceNodeId: 'node_1',
|
||||
* targetNodeId: 'node_2',
|
||||
* type: 'polyline'
|
||||
* }
|
||||
* ]
|
||||
* })
|
||||
* @param graphData 图数据
|
||||
*/
|
||||
render(graphData?: {}): void;
|
||||
/**
|
||||
* 内部保留方法
|
||||
* 获取指定类型的view
|
||||
*/
|
||||
getView: (type: string) => any;
|
||||
}
|
||||
export {};
|
||||
@@ -0,0 +1,6 @@
|
||||
import { Point } from '../type/index';
|
||||
export declare const getCorssPointOfLine: (a: Point, b: Point, c: Point, d: Point) => false | {
|
||||
x: number;
|
||||
y: number;
|
||||
};
|
||||
export declare const isInSegment: (point: any, start: any, end: any) => boolean;
|
||||
@@ -0,0 +1,6 @@
|
||||
export declare const getVerticalPointOfLine: (config: any) => {
|
||||
leftX: number;
|
||||
leftY: number;
|
||||
rightX: number;
|
||||
rightY: number;
|
||||
};
|
||||
@@ -0,0 +1,35 @@
|
||||
export declare const getNodeOutline: ({ x, y, width, height, }: {
|
||||
x: any;
|
||||
y: any;
|
||||
width: any;
|
||||
height: any;
|
||||
}) => {
|
||||
x: number;
|
||||
y: number;
|
||||
x1: any;
|
||||
y1: any;
|
||||
};
|
||||
export declare const getLineOutline: (edge: any) => {
|
||||
x: number;
|
||||
y: number;
|
||||
x1: number;
|
||||
y1: number;
|
||||
};
|
||||
export declare const getPolylineOutline: (edge: any) => {
|
||||
x: number;
|
||||
y: number;
|
||||
x1: number;
|
||||
y1: number;
|
||||
};
|
||||
export declare const getBezierOutline: (edge: any) => {
|
||||
x: number;
|
||||
y: number;
|
||||
x1: number;
|
||||
y1: number;
|
||||
};
|
||||
export declare const getEdgeOutline: (edge: any) => {
|
||||
x: number;
|
||||
y: number;
|
||||
x1: number;
|
||||
y1: number;
|
||||
};
|
||||
@@ -0,0 +1,12 @@
|
||||
export declare type AnimationConfig = {
|
||||
edge: boolean;
|
||||
node: boolean;
|
||||
};
|
||||
export declare type Animation = {
|
||||
stroke: string;
|
||||
strokeDasharray: string;
|
||||
className: string;
|
||||
};
|
||||
export declare const defaultAnimationCloseConfig: AnimationConfig;
|
||||
export declare const defaultAnimationOpenConfig: AnimationConfig;
|
||||
export declare const defaultAnimationData: Animation;
|
||||
@@ -0,0 +1,262 @@
|
||||
/**
|
||||
* 颜色
|
||||
* CSS属性用颜色
|
||||
* 如#000000,reg(0,0,0,0)
|
||||
* 如果是透明,可以传'none'
|
||||
*/
|
||||
export declare type Color = string;
|
||||
/**
|
||||
* svg虚线
|
||||
* 格式为逗号分割字符串,如
|
||||
* @see https://developer.mozilla.org/zh-CN/docs/Web/SVG/Attribute/stroke-dasharray
|
||||
*/
|
||||
export declare type DashArray = string;
|
||||
export declare type CommonTheme = {
|
||||
/**
|
||||
* 填充颜色
|
||||
*/
|
||||
fill?: Color;
|
||||
/**
|
||||
* 边框颜色
|
||||
*/
|
||||
stroke?: Color;
|
||||
/**
|
||||
* 边框宽度
|
||||
*/
|
||||
strokeWidth?: number;
|
||||
/**
|
||||
* 其他属性
|
||||
* 我们会把你定义的所有属性最终传递到DOM上
|
||||
* 详情请参考svg属性规范
|
||||
* https://developer.mozilla.org/zh-CN/docs/Web/SVG/Attribute
|
||||
*/
|
||||
[key: string]: any;
|
||||
};
|
||||
/**
|
||||
* rect主题样式
|
||||
* svg基础图形-矩形
|
||||
* https://developer.mozilla.org/zh-CN/docs/Web/SVG/Element/rect
|
||||
*/
|
||||
export declare type RectTheme = {
|
||||
/**
|
||||
* 矩形的默认宽度
|
||||
*/
|
||||
width?: number;
|
||||
/**
|
||||
* 矩形的默认高度
|
||||
*/
|
||||
height?: number;
|
||||
/**
|
||||
* 圆角
|
||||
* 注意,矩形圆角请使用radius
|
||||
* 不要使用rx和ry
|
||||
*/
|
||||
radius?: number;
|
||||
} & CommonTheme;
|
||||
/**
|
||||
* circle主题样式
|
||||
* svg基础图形-圆形
|
||||
* https://developer.mozilla.org/zh-CN/docs/Web/SVG/Element/circle
|
||||
*/
|
||||
export declare type CircleTheme = {
|
||||
/**
|
||||
* 默认半径
|
||||
*/
|
||||
r?: number;
|
||||
} & CommonTheme;
|
||||
/**
|
||||
* polygon主题样式
|
||||
* svg基础图形-多边形
|
||||
* https://developer.mozilla.org/zh-CN/docs/Web/SVG/Element/polygon
|
||||
*/
|
||||
export declare type PolygonTheme = CommonTheme;
|
||||
/**
|
||||
* ellipse主题样式
|
||||
* svg基础图形-椭圆
|
||||
* https://developer.mozilla.org/zh-CN/docs/Web/SVG/Element/ellipse
|
||||
*/
|
||||
export declare type EllipseTheme = CommonTheme;
|
||||
/**
|
||||
* 锚点样式
|
||||
* svg基础图形-圆
|
||||
*/
|
||||
export declare type AnchorTheme = {
|
||||
r?: number;
|
||||
hover?: {
|
||||
r: number;
|
||||
} & CommonTheme;
|
||||
} & CommonTheme;
|
||||
/**
|
||||
* 文本样式
|
||||
* svg文本
|
||||
* https://developer.mozilla.org/zh-CN/docs/Web/SVG/Element/text
|
||||
*/
|
||||
export declare type TextTheme = {
|
||||
/**
|
||||
* 文本颜色
|
||||
*/
|
||||
color?: Color;
|
||||
/**
|
||||
* 文本大小
|
||||
*/
|
||||
fontSize?: number;
|
||||
} & CommonTheme;
|
||||
/**
|
||||
* 文本节点样式
|
||||
*/
|
||||
export declare type TextNodeTheme = {
|
||||
background?: RectTheme;
|
||||
} & TextTheme;
|
||||
/**
|
||||
* 节点上文本样式
|
||||
*/
|
||||
export declare type NodeTextTheme = {
|
||||
/**
|
||||
* 文本超出指定宽度处理方式
|
||||
* default: 不特殊处理,允许超出
|
||||
* autoWrap: 超出自动换行
|
||||
* ellipsis: 超出省略
|
||||
*/
|
||||
overflowMode?: string;
|
||||
background?: RectTheme;
|
||||
} & TextTheme;
|
||||
/**
|
||||
* 边上文本样式
|
||||
*/
|
||||
export declare type EdgeTextTheme = {
|
||||
/**
|
||||
* 文本超出指定宽度处理方式
|
||||
* default: 不特殊处理,允许超出
|
||||
* autoWrap: 超出自动换行
|
||||
* ellipsis: 超出省略
|
||||
*/
|
||||
overflowMode?: string;
|
||||
/**
|
||||
* 文本一行最大宽度
|
||||
*/
|
||||
textWidth?: number;
|
||||
/**
|
||||
* 文本背景样式
|
||||
*/
|
||||
background?: {
|
||||
wrapPadding?: string;
|
||||
} & RectTheme;
|
||||
/**
|
||||
* hover状态下文本样式
|
||||
*/
|
||||
hover?: EdgeTextTheme;
|
||||
} & TextTheme;
|
||||
export declare type EdgeTheme = CommonTheme;
|
||||
export declare type EdgePolylineTheme = EdgeTheme;
|
||||
export declare type EdgeBezierTheme = {
|
||||
/**
|
||||
* 贝塞尔调整线主题
|
||||
*/
|
||||
adjustLine?: EdgeTheme;
|
||||
/**
|
||||
* 贝塞尔调整锚点主题
|
||||
*/
|
||||
adjustAnchor?: CircleTheme;
|
||||
} & EdgeTheme;
|
||||
/**
|
||||
* 箭头主题
|
||||
*/
|
||||
export declare type ArrowTheme = {
|
||||
/**
|
||||
* 箭头长度.
|
||||
* 以符号"->"为例, offset表示箭头大于号的宽度。
|
||||
*/
|
||||
offset?: number;
|
||||
/**
|
||||
* 箭头垂直于边的距离
|
||||
* 以符号"->"为例, verticalLength表示箭头大于号的高度
|
||||
*/
|
||||
verticalLength?: number;
|
||||
} & CommonTheme;
|
||||
export declare type OutlineTheme = {
|
||||
/**
|
||||
* hover状态下样式
|
||||
*/
|
||||
hover?: CommonTheme;
|
||||
} & CommonTheme;
|
||||
export declare type Theme = {
|
||||
/**
|
||||
* 所有节点的通用主题设置
|
||||
*/
|
||||
baseNode?: CommonTheme;
|
||||
/**
|
||||
* 基础图形-矩形样式
|
||||
*/
|
||||
rect?: RectTheme;
|
||||
/**
|
||||
* 基础图形-圆形样式
|
||||
*/
|
||||
circle?: CircleTheme;
|
||||
/**
|
||||
* 基础图形-菱形样式
|
||||
*/
|
||||
diamond?: PolygonTheme;
|
||||
/**
|
||||
* 基础图形-椭圆样式
|
||||
*/
|
||||
ellipse?: EllipseTheme;
|
||||
/**
|
||||
* 基础图形-多边形样式
|
||||
*/
|
||||
polygon?: PolygonTheme;
|
||||
/**
|
||||
* 所有边的通用主题设置
|
||||
*/
|
||||
baseEdge?: EdgeTheme;
|
||||
/**
|
||||
* 基础图形-直线样式
|
||||
*/
|
||||
line?: EdgeTheme;
|
||||
/**
|
||||
* 基础图形-折现样式
|
||||
*/
|
||||
polyline?: EdgePolylineTheme;
|
||||
/**
|
||||
* 基础图形-贝塞尔曲线样式
|
||||
*/
|
||||
bezier?: EdgeBezierTheme;
|
||||
/**
|
||||
* 锚点样式
|
||||
*/
|
||||
anchor?: AnchorTheme;
|
||||
/**
|
||||
* 文本节点样式
|
||||
*/
|
||||
text?: TextTheme;
|
||||
/**
|
||||
* 节点文本样式
|
||||
*/
|
||||
nodeText?: NodeTextTheme;
|
||||
/**
|
||||
* 边文本样式
|
||||
*/
|
||||
edgeText?: EdgeTextTheme;
|
||||
/**
|
||||
* 边上箭头的样式
|
||||
*/
|
||||
arrow?: ArrowTheme;
|
||||
/**
|
||||
* 从锚点拉出的边的样式
|
||||
*/
|
||||
anchorLine?: EdgeTheme;
|
||||
/**
|
||||
* 对齐线样式
|
||||
*/
|
||||
snapline?: EdgeTheme;
|
||||
/**
|
||||
* 当开启了跳转边的起点和终点(adjustEdgeStartAndEnd:true)后
|
||||
* 边的两端会出现调整按钮
|
||||
* 边连段的调整点样式
|
||||
*/
|
||||
edgeAdjust?: CircleTheme;
|
||||
/**
|
||||
* 节点选择状态下外侧的选框样式
|
||||
*/
|
||||
outline?: OutlineTheme;
|
||||
};
|
||||
export declare const defaultTheme: Theme;
|
||||
@@ -0,0 +1,91 @@
|
||||
export declare enum ElementState {
|
||||
DEFAULT = 1,
|
||||
TEXT_EDIT = 2,
|
||||
SHOW_MENU = 3,
|
||||
ALLOW_CONNECT = 4,
|
||||
NOT_ALLOW_CONNECT = 5
|
||||
}
|
||||
export declare enum ClipBoardInfo {
|
||||
KEY = "logic-flow",
|
||||
NODE_NAME = "lf-node",
|
||||
EDGE_NAME = "lf-edge"
|
||||
}
|
||||
export declare enum ModelType {
|
||||
NODE = "node",
|
||||
CIRCLE_NODE = "circle-node",
|
||||
POLYGON_NODE = "polygon-node",
|
||||
RECT_NODE = "rect-node",
|
||||
TEXT_NODE = "text-node",
|
||||
ELLIPSE_NODE = "ellipse-node",
|
||||
DIAMOND_NODE = "diamond-node",
|
||||
HTML_NODE = "html-node",
|
||||
EDGE = "edge",
|
||||
LINE_EDGE = "line-edge",
|
||||
POLYLINE_EDGE = "polyline-edge",
|
||||
BEZIER_EDGE = "bezier-edge",
|
||||
GRAPH = "graph"
|
||||
}
|
||||
export declare enum ElementType {
|
||||
NODE = "node",
|
||||
EDGE = "edge",
|
||||
GRAPH = "graph"
|
||||
}
|
||||
export declare enum EventType {
|
||||
ELEMENT_CLICK = "element:click",
|
||||
NODE_CLICK = "node:click",
|
||||
NODE_DBCLICK = "node:dbclick",
|
||||
NODE_DELETE = "node:delete",
|
||||
NODE_ADD = "node:add",
|
||||
NODE_DND_ADD = "node:dnd-add",
|
||||
NODE_DND_DRAG = "node:dnd-drag",
|
||||
NODE_MOUSEDOWN = "node:mousedown",
|
||||
NODE_DRAGSTART = "node:dragstart",
|
||||
NODE_DRAG = "node:drag",
|
||||
NODE_DROP = "node:drop",
|
||||
NODE_MOUSEUP = "node:mouseup",
|
||||
NODE_MOUSEMOVE = "node:mousemove",
|
||||
NODE_MOUSEENTER = "node:mouseenter",
|
||||
NODE_MOUSELEAVE = "node:mouseleave",
|
||||
NODE_CONTEXTMENU = "node:contextmenu",
|
||||
EDGE_DELETE = "edge:delete",
|
||||
EDGE_ADD = "edge:add",
|
||||
EDGE_CLICK = "edge:click",
|
||||
EDGE_DBCLICK = "edge:dbclick",
|
||||
EDGE_MOUSEENTER = "edge:mouseenter",
|
||||
EDGE_MOUSELEAVE = "edge:mouseleave",
|
||||
EDGE_CONTEXTMENU = "edge:contextmenu",
|
||||
EDGE_ADJUST = "edge:adjust",
|
||||
EDGE_EXCHANGE_NODE = "edge:exchange-node",
|
||||
ANCHOR_DRAGSTART = "anchor:dragstart",
|
||||
ANCHOR_DRAG = "anchor:drag",
|
||||
ANCHOR_DROP = "anchor:drop",
|
||||
BLANK_MOUSEDOWN = "blank:mousedown",
|
||||
BLANK_DRAGSTART = "blank:dragstart",
|
||||
BLANK_DRAG = "blank:drag",
|
||||
BLANK_DROP = "blank:drop",
|
||||
BLANK_MOUSEMOVE = "blank:mousemove",
|
||||
BLANK_MOUSEUP = "blank:mouseup",
|
||||
BLANK_CLICK = "blank:click",
|
||||
BLANK_CONTEXTMENU = "blank:contextmenu",
|
||||
SELECTION_MOUSEDOWN = "selection:mousedown",
|
||||
SELECTION_DRAGSTART = "selection:dragstart",
|
||||
SELECTION_DRAG = "selection:drag",
|
||||
SELECTION_DROP = "selection:drop",
|
||||
SELECTION_MOUSEMOVE = "selection:mousemove",
|
||||
SELECTION_MOUSEUP = "selection:mouseup",
|
||||
SELECTION_CONTEXTMENU = "selection:contextmenu",
|
||||
CONNECTION_NOT_ALLOWED = "connection:not-allowed",
|
||||
HISTORY_CHANGE = "history:change",
|
||||
TEXT_UPDATE = "text:update",
|
||||
GRAPH_TRANSFORM = "graph:transform",
|
||||
GRAPH_RENDERED = "graph:rendered"
|
||||
}
|
||||
export declare enum SegmentDirection {
|
||||
HORIZONTAL = "horizontal",
|
||||
VERTICAL = "vertical"
|
||||
}
|
||||
export declare const ElementMaxzIndex = 9999;
|
||||
export declare enum OverlapMode {
|
||||
DEFAULT = 0,
|
||||
INCREASE = 1
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
import { EventArgs } from '../type';
|
||||
export interface EventType {
|
||||
readonly callback: Function;
|
||||
readonly once: boolean;
|
||||
}
|
||||
export declare type CallbackType = (...args: any[]) => void;
|
||||
export { EventEmitter };
|
||||
export default class EventEmitter {
|
||||
private _events;
|
||||
/**
|
||||
* 监听一个事件
|
||||
* @param evt 事件名称
|
||||
* @param callback
|
||||
* @param once
|
||||
*/
|
||||
on(evt: string, callback: CallbackType, once?: boolean): this;
|
||||
/**
|
||||
* 监听一个事件一次
|
||||
* @param evt
|
||||
* @param callback
|
||||
*/
|
||||
once(evt: string, callback: CallbackType): void;
|
||||
/**
|
||||
* 触发一个事件
|
||||
* @param evt
|
||||
* @param args
|
||||
*/
|
||||
emit(evts: string, eventArgs: EventArgs): void;
|
||||
/**
|
||||
* 取消监听一个事件,或者一个channel
|
||||
* @param evt
|
||||
* @param callback
|
||||
*/
|
||||
off(evts?: string, callback?: CallbackType): this;
|
||||
getEvents(): Record<string, EventType[]>;
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
import EventEmitter from '../event/eventEmitter';
|
||||
declare class History {
|
||||
undos: any[];
|
||||
redos: any[];
|
||||
callbacks: any[];
|
||||
stopWatch: any;
|
||||
curData: any;
|
||||
maxSize: number;
|
||||
waitTime: number;
|
||||
eventCenter: EventEmitter;
|
||||
constructor(eventCenter: any);
|
||||
add(data: any): void;
|
||||
undoAble(): boolean;
|
||||
undo(): any;
|
||||
redoAble(): boolean;
|
||||
redo(): any;
|
||||
watch(model: any): void;
|
||||
}
|
||||
export { History };
|
||||
export default History;
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
import { h } from 'preact';
|
||||
import LogicFlow from './LogicFlow';
|
||||
import * as LogicFlowUtil from './util';
|
||||
export declare function observer<P>(props: P): any;
|
||||
export { LogicFlow, h };
|
||||
export { LogicFlowUtil };
|
||||
export * from './type/index';
|
||||
export * from './view';
|
||||
export * from './model';
|
||||
export * from './keyboard';
|
||||
export * from './options';
|
||||
export default LogicFlow;
|
||||
@@ -0,0 +1,32 @@
|
||||
import { MousetrapInstance } from 'mousetrap';
|
||||
import LogicFlow from '../LogicFlow';
|
||||
export declare type Action = 'keypress' | 'keydown' | 'keyup';
|
||||
export declare type Handler = (e: KeyboardEvent) => void;
|
||||
export interface KeyboardDef {
|
||||
enabled: boolean;
|
||||
shortcuts?: Array<{
|
||||
keys: string | string[];
|
||||
callback: Handler;
|
||||
action?: Action;
|
||||
}>;
|
||||
}
|
||||
export interface Options {
|
||||
lf: LogicFlow;
|
||||
keyboard?: KeyboardDef;
|
||||
}
|
||||
declare class Keyboard {
|
||||
readonly mousetrap: MousetrapInstance;
|
||||
options: Options;
|
||||
private target;
|
||||
constructor(options: Options);
|
||||
initShortcuts(): void;
|
||||
on(keys: string | string[], callback: Handler, action?: Action): void;
|
||||
get disabled(): boolean;
|
||||
off(keys: string | string[], action?: Action): void;
|
||||
enable(force: boolean): void;
|
||||
disable(): void;
|
||||
private getKeys;
|
||||
protected formatkey(key: string): string;
|
||||
}
|
||||
export { Keyboard };
|
||||
export default Keyboard;
|
||||
@@ -0,0 +1,3 @@
|
||||
import LogicFlow from '../LogicFlow';
|
||||
import GraphModel from '../model/GraphModel';
|
||||
export declare function initDefaultShortcut(lf: LogicFlow, graph: GraphModel): void;
|
||||
@@ -0,0 +1,86 @@
|
||||
import { ElementState } from '../constant/constant';
|
||||
import { TextConfig, AdditionData } from '../type';
|
||||
interface IBaseModel {
|
||||
/**
|
||||
* 节点或者边的id.
|
||||
* 默认情况下,使用uuidv4生成。
|
||||
* 如果想要自定义,可以重写createId生成。
|
||||
*/
|
||||
id: string;
|
||||
/**
|
||||
* 不可自定义
|
||||
* model对应的图形外观类型(eg: 圆形、矩形、多边形等)
|
||||
* 用于logicflow内部计算使用。
|
||||
*/
|
||||
modelType: string;
|
||||
/**
|
||||
* 请勿直接修改属性,如果想要将一个节点类型修改为另一个类型。请使用
|
||||
* `lf.graphModel.changeEdgeType`和`lf.graphModel.changeNodeType`
|
||||
*
|
||||
* 流程图元素类型,自定义元素时对应的标识。
|
||||
* 在logicflow/core中对应着rect、circle、polyline这种。
|
||||
* 在实际项目中,我们会基于业务类型进行自定义type.
|
||||
* 例如BPMN应用场景,我们会定义开始节点的类型为bpmn:start-event
|
||||
*
|
||||
* 和modelType的区别是,type更多的是业务上的类型,而modelType则是外观上的类型。
|
||||
* 例如bpmnjs的开始节点和结束节点type分别为'bpmn:start-event'和'bpmn:end-event'。
|
||||
* 但是他们的modelType都是circle-node, 因为他们外观都是基于圆形自定义而来。
|
||||
*/
|
||||
type: string;
|
||||
/**
|
||||
* 元素状态
|
||||
* 不同的状态对应着元素显示效果。
|
||||
* 请勿直接修改。
|
||||
* logicflow内部将元素状态分为5种:
|
||||
* DEFAULT = 1 默认显示
|
||||
* TEXT_EDIT = 2 此元素正在进行文本编辑
|
||||
* SHOW_MENU = 3, 显示菜单,废弃请使用菜单插件
|
||||
* ALLOW_CONNECT = 4, 此元素允许作为当前边的目标节点
|
||||
* NOT_ALLOW_CONNECT = 5, 此元素不允许作为当前边的目标节点
|
||||
*/
|
||||
state: ElementState;
|
||||
additionStateData: AdditionData;
|
||||
/**
|
||||
* 元素上的文本
|
||||
* logicflow中存在两种文本
|
||||
* 一种是脱离边和节点单独存在的文本
|
||||
* 一种是必须和边、节点关联的文本。
|
||||
* 此属性控制的是第二种。
|
||||
* 节点和边删除、调整的时候,其关联的文本也会对应删除、调整。
|
||||
*/
|
||||
text: TextConfig;
|
||||
/**
|
||||
* 元素是否被选中
|
||||
*/
|
||||
isSelected: boolean;
|
||||
visible: boolean;
|
||||
/**
|
||||
* 元素堆叠是层级,默认情况下节点zIndex值为1,边zIndex为0。
|
||||
* todo:写完善
|
||||
*/
|
||||
zIndex: number;
|
||||
/**
|
||||
* 创建节点ID
|
||||
* 默认情况下,logicflow内部使用uuidv4生成id。
|
||||
* 在自定义节点的时候,可以重写此方法基于自己的规则生成id。
|
||||
* 注意,此方法必须是同步的。
|
||||
* 如果想要异步修改Id,建议删除此节点后再同一位置创建一个新的节点。
|
||||
* @overridable 可以重写
|
||||
* @returns string
|
||||
*/
|
||||
createId(): string;
|
||||
moveText(deltaX: number, deltaY: number): void;
|
||||
updateText(value: string): void;
|
||||
setSelected(flag: boolean): void;
|
||||
setZIndex(zindex?: number): void;
|
||||
/**
|
||||
* 设置Node|Edge等model的状态
|
||||
* @param state 状态
|
||||
*/
|
||||
setElementState(state: ElementState, additionStateData?: AdditionData): void;
|
||||
getProperties(): Object;
|
||||
setProperties(properties: Object): void;
|
||||
updateAttributes(attributes: Object): void;
|
||||
getTextStyle(): Record<string, any>;
|
||||
}
|
||||
export { IBaseModel, };
|
||||
@@ -0,0 +1,99 @@
|
||||
export interface EditConfigInterface {
|
||||
/**
|
||||
* 是否为静默模式
|
||||
*/
|
||||
isSilentMode?: boolean;
|
||||
/**
|
||||
* 禁止缩放画布
|
||||
*/
|
||||
stopZoomGraph?: boolean;
|
||||
/**
|
||||
* 禁止鼠标滚动移动画布
|
||||
*/
|
||||
stopScrollGraph?: boolean;
|
||||
/**
|
||||
* 禁止拖动画布
|
||||
*/
|
||||
stopMoveGraph?: boolean;
|
||||
/**
|
||||
* 允许调整边
|
||||
*/
|
||||
adjustEdge?: boolean;
|
||||
/**
|
||||
* 允许调整边起点和终点
|
||||
*/
|
||||
adjustEdgeStartAndEnd?: boolean;
|
||||
/**
|
||||
* 允许拖动节点
|
||||
*/
|
||||
adjustNodePosition?: boolean;
|
||||
/**
|
||||
* 隐藏节点所有锚点
|
||||
*/
|
||||
hideAnchors?: boolean;
|
||||
/**
|
||||
* 显示节点悬浮时的外框
|
||||
*/
|
||||
hoverOutline?: boolean;
|
||||
/**
|
||||
* 节点被选中时是否显示outline
|
||||
*/
|
||||
nodeSelectedOutline?: boolean;
|
||||
/**
|
||||
* 边被选中时是否显示outline
|
||||
*/
|
||||
edgeSelectedOutline?: boolean;
|
||||
/**
|
||||
* 允许节点文本可以编辑
|
||||
*/
|
||||
nodeTextEdit?: boolean;
|
||||
/**
|
||||
* 允许边文本可以编辑
|
||||
*/
|
||||
edgeTextEdit?: boolean;
|
||||
/**
|
||||
* 允许文本编辑
|
||||
*/
|
||||
textEdit?: boolean;
|
||||
/**
|
||||
* 允许节点文本可以拖拽
|
||||
*/
|
||||
nodeTextDraggable?: boolean;
|
||||
/**
|
||||
* 允许边文本可以拖拽
|
||||
*/
|
||||
edgeTextDraggable?: boolean;
|
||||
/**
|
||||
* 多选按键, 支持meta(cmd)、shift、alt
|
||||
* 不支持ctrl,ctrl会触发contextmenu
|
||||
*/
|
||||
multipleSelectKey?: string;
|
||||
}
|
||||
/**
|
||||
* 页面编辑配置
|
||||
*/
|
||||
export default class EditConfigModel {
|
||||
isSilentMode: boolean;
|
||||
stopZoomGraph: boolean;
|
||||
stopScrollGraph: boolean;
|
||||
stopMoveGraph: boolean;
|
||||
adjustEdge: boolean;
|
||||
adjustEdgeMiddle: boolean;
|
||||
adjustEdgeStartAndEnd: boolean;
|
||||
adjustNodePosition: boolean;
|
||||
hideAnchors: boolean;
|
||||
hoverOutline: boolean;
|
||||
nodeSelectedOutline: boolean;
|
||||
edgeSelectedOutline: boolean;
|
||||
nodeTextEdit: boolean;
|
||||
edgeTextEdit: boolean;
|
||||
nodeTextDraggable: boolean;
|
||||
edgeTextDraggable: boolean;
|
||||
multipleSelectKey: string;
|
||||
defaultConfig: {};
|
||||
constructor(config: EditConfigInterface);
|
||||
updateEditConfig(config: any): void;
|
||||
getConfigDetail(config: any): Pick<any, string>;
|
||||
getConfig(): Partial<this>;
|
||||
}
|
||||
export { EditConfigModel };
|
||||
@@ -0,0 +1,441 @@
|
||||
import BaseNodeModel from './node/BaseNodeModel';
|
||||
import BaseEdgeModel from './edge/BaseEdgeModel';
|
||||
import EditConfigModel from './EditConfigModel';
|
||||
import TransfromModel from './TransformModel';
|
||||
import { OverlapMode } from '../constant/constant';
|
||||
import { AdditionData, Point, NodeConfig, EdgeConfig, PointTuple, NodeMoveRule, GraphConfigData, VirtualRectSize } from '../type';
|
||||
import EventEmitter from '../event/eventEmitter';
|
||||
import { Theme } from '../constant/DefaultTheme';
|
||||
import { Definition } from '../options';
|
||||
import { AnimationConfig } from '../constant/DefaultAnimation';
|
||||
declare type BaseNodeModelId = string;
|
||||
declare type ElementModeId = string;
|
||||
declare class GraphModel {
|
||||
/**
|
||||
* LogicFlow画布挂载元素
|
||||
* 也就是初始化LogicFlow实例时传入的container
|
||||
*/
|
||||
rootEl: HTMLElement;
|
||||
/**
|
||||
* LogicFlow画布宽度
|
||||
*/
|
||||
width: number;
|
||||
/**
|
||||
* LogicFlow画布高度
|
||||
*/
|
||||
height: number;
|
||||
/**
|
||||
* 主题配置
|
||||
* @see todo docs link
|
||||
*/
|
||||
theme: Theme;
|
||||
/**
|
||||
* 事件中心
|
||||
* @see todo docs link
|
||||
*/
|
||||
eventCenter: EventEmitter;
|
||||
/**
|
||||
* 维护所有节点和边类型对应的model
|
||||
*/
|
||||
modelMap: Map<any, any>;
|
||||
/**
|
||||
* 位于当前画布顶部的元素。
|
||||
* 此元素只在堆叠模式为默认模式下存在。
|
||||
* 用于在默认模式下将之前的顶部元素恢复初始高度。
|
||||
*/
|
||||
topElement: BaseNodeModel | BaseEdgeModel;
|
||||
/**
|
||||
* 控制是否开启动画
|
||||
*/
|
||||
animation: AnimationConfig;
|
||||
/**
|
||||
* 自定义全局id生成器
|
||||
* @see todo docs link
|
||||
*/
|
||||
idGenerator: (type?: string) => string;
|
||||
/**
|
||||
* 节点移动规则判断
|
||||
* 在节点移动的时候,会出发此数组中的所有规则判断
|
||||
*/
|
||||
nodeMoveRules: NodeMoveRule[];
|
||||
/**
|
||||
* 在图上操作创建边时,默认使用的边类型.
|
||||
*/
|
||||
edgeType: string;
|
||||
/**
|
||||
* 当前图上所有节点的model
|
||||
*/
|
||||
nodes: BaseNodeModel[];
|
||||
/**
|
||||
* 当前图上所有边的model
|
||||
*/
|
||||
edges: BaseEdgeModel[];
|
||||
/**
|
||||
* 元素重合时堆叠模式
|
||||
* 默认模式,节点和边被选中,会被显示在最上面。当取消选中后,元素会恢复之前的层级。
|
||||
* 递增模式,节点和边被选中,会被显示在最上面。当取消选中后,元素会保持层级。
|
||||
* @see todo link
|
||||
*/
|
||||
overlapMode: OverlapMode;
|
||||
/**
|
||||
* 背景配置
|
||||
* @see todo link
|
||||
*/
|
||||
background: any;
|
||||
/**
|
||||
* 控制画布的缩放、平移
|
||||
* @see todo link
|
||||
*/
|
||||
transformModel: TransfromModel;
|
||||
/**
|
||||
* 控制流程图编辑相关配置
|
||||
* @see todo link
|
||||
*/
|
||||
editConfigModel: EditConfigModel;
|
||||
/**
|
||||
* 网格大小
|
||||
* @see todo link
|
||||
*/
|
||||
gridSize: number;
|
||||
/**
|
||||
* 局部渲染
|
||||
* @see todo logicflow性能
|
||||
*/
|
||||
partial: boolean;
|
||||
/**
|
||||
* 外部拖动节点进入画布的过程中,用fakerNode来和画布上正是的节点区分开
|
||||
*/
|
||||
fakerNode: BaseNodeModel;
|
||||
[key: string]: any;
|
||||
constructor(options: Definition);
|
||||
get nodesMap(): {
|
||||
[key: string]: {
|
||||
index: number;
|
||||
model: BaseNodeModel;
|
||||
};
|
||||
};
|
||||
get edgesMap(): {
|
||||
[key: string]: {
|
||||
index: number;
|
||||
model: BaseEdgeModel;
|
||||
};
|
||||
};
|
||||
get modelsMap(): {
|
||||
[key: string]: BaseNodeModel | BaseEdgeModel;
|
||||
};
|
||||
/**
|
||||
* 基于zIndex对元素进行排序。
|
||||
* todo: 性能优化
|
||||
*/
|
||||
get sortElements(): any[];
|
||||
/**
|
||||
* 当前编辑的元素,低频操作,先循环找。
|
||||
*/
|
||||
get textEditElement(): BaseNodeModel | BaseEdgeModel;
|
||||
/**
|
||||
* 当前画布所有被选中的元素
|
||||
*/
|
||||
get selectElements(): Map<any, any>;
|
||||
/**
|
||||
* 获取指定区域内的所有元素
|
||||
* @param leftTopPoint 表示区域左上角的点
|
||||
* @param rightBottomPoint 表示区域右下角的点
|
||||
* @param wholeEdge 是否要整个边都在区域内部
|
||||
* @param wholeNode 是否要整个节点都在区域内部
|
||||
*/
|
||||
getAreaElement(leftTopPoint: PointTuple, rightBottomPoint: PointTuple, wholeEdge?: boolean, wholeNode?: boolean): any[];
|
||||
/**
|
||||
* 获取指定类型元素对应的Model
|
||||
*/
|
||||
getModel(type: string): any;
|
||||
/**
|
||||
* 基于Id获取节点的model
|
||||
*/
|
||||
getNodeModelById(nodeId: BaseNodeModelId): BaseNodeModel;
|
||||
/**
|
||||
* 因为流程图所在的位置可以是页面任何地方
|
||||
* 当内部事件需要获取触发事件时,其相对于画布左上角的位置
|
||||
* 需要事件触发位置减去画布相对于client的位置
|
||||
*/
|
||||
getPointByClient({ x: x1, y: y1 }: Point): {
|
||||
domOverlayPosition: {
|
||||
x: number;
|
||||
y: number;
|
||||
};
|
||||
canvasOverlayPosition: {
|
||||
x: number;
|
||||
y: number;
|
||||
};
|
||||
};
|
||||
/**
|
||||
* 判断一个元素是否在指定矩形区域内。
|
||||
* @param element 节点或者边
|
||||
* @param lt 左上角点
|
||||
* @param rb 右下角点
|
||||
* @param wholeEdge 边的起点和终点都在区域内才算
|
||||
* @param wholeNode 节点的box都在区域内才算
|
||||
*/
|
||||
isElementInArea(element: any, lt: PointTuple, rb: PointTuple, wholeEdge?: boolean, wholeNode?: boolean): boolean;
|
||||
/**
|
||||
* 使用新的数据重新设置整个画布的元素
|
||||
* 注意:将会清除画布上所有已有的节点和边
|
||||
* @param { object } graphData 图数据
|
||||
*/
|
||||
graphDataToModel(graphData: GraphConfigData): void;
|
||||
/**
|
||||
* 获取画布数据
|
||||
*/
|
||||
modelToGraphData(): GraphConfigData;
|
||||
modelToHistoryData(): false | {
|
||||
nodes: any[];
|
||||
edges: any[];
|
||||
};
|
||||
/**
|
||||
* 获取边的model
|
||||
*/
|
||||
getEdgeModelById(edgeId: string): BaseEdgeModel | undefined;
|
||||
/**
|
||||
* 获取节点或者边的model
|
||||
*/
|
||||
getElement(id: string): BaseNodeModel | BaseEdgeModel | undefined;
|
||||
/**
|
||||
* 所有节点上所有边的model
|
||||
*/
|
||||
getNodeEdges(nodeId: any): BaseEdgeModel[];
|
||||
/**
|
||||
* 获取选中的元素数据
|
||||
* @param isIgnoreCheck 是否包括sourceNode和targetNode没有被选中的边,默认包括。
|
||||
* 复制的时候不能包括此类边, 因为复制的时候不允许悬空的边
|
||||
*/
|
||||
getSelectElements(isIgnoreCheck?: boolean): GraphConfigData;
|
||||
/**
|
||||
* 修改对应元素 model 中的属性
|
||||
* 注意:此方法慎用,除非您对logicflow内部有足够的了解。
|
||||
* 大多数情况下,请使用setProperties、updateText、changeNodeId等方法。
|
||||
* 例如直接使用此方法修改节点的id,那么就是会导致连接到此节点的边的sourceNodeId出现找不到的情况。
|
||||
* @param {string} id 元素id
|
||||
* @param {object} attributes 需要更新的属性
|
||||
*/
|
||||
updateAttributes(id: string, attributes: object): void;
|
||||
/**
|
||||
* 修改节点的id, 如果不传新的id,会内部自动创建一个。
|
||||
* @param { string } oldId 将要被修改的id
|
||||
* @param { string } newId 可选,修改后的id
|
||||
* @returns 修改后的节点id, 如果传入的oldId不存在,返回空字符串
|
||||
*/
|
||||
changeNodeId<T extends string>(oldId: any, newId?: T | string): T | string;
|
||||
/**
|
||||
* 修改边的id, 如果不传新的id,会内部自动创建一个。
|
||||
* @param { string } oldId 将要被修改的id
|
||||
* @param { string } newId 可选,修改后的id
|
||||
* @returns 修改后的节点id, 如果传入的oldId不存在,返回空字符串
|
||||
*/
|
||||
changeEdgeId<T extends string>(oldId: string, newId?: string): T | string;
|
||||
/**
|
||||
* 内部保留方法,请勿直接使用
|
||||
*/
|
||||
setFakerNode(nodeModel: BaseNodeModel): void;
|
||||
/**
|
||||
* 内部保留方法,请勿直接使用
|
||||
*/
|
||||
removeFakerNode(): void;
|
||||
/**
|
||||
* 设置指定类型的Model,请勿直接使用
|
||||
*/
|
||||
setModel(type: string, ModelClass: any): Map<any, any>;
|
||||
/**
|
||||
* 将某个元素放置到顶部。
|
||||
* 如果堆叠模式为默认模式,则将原置顶元素重新恢复原有层级。
|
||||
* 如果堆叠模式为递增模式,则将需指定元素zIndex设置为当前最大zIndex + 1。
|
||||
* @see todo link 堆叠模式
|
||||
* @param id 元素Id
|
||||
*/
|
||||
toFront(id: any): void;
|
||||
/**
|
||||
* 设置元素的zIndex.
|
||||
* 注意:默认堆叠模式下,不建议使用此方法。
|
||||
* @see todo link 堆叠模式
|
||||
* @param id 元素id
|
||||
* @param zIndex zIndex的值,可以传数字,也支持传入'top' 和 'bottom'
|
||||
*/
|
||||
setElementZIndex(id: string, zIndex: number | 'top' | 'bottom'): void;
|
||||
/**
|
||||
* 删除节点
|
||||
* @param {string} nodeId 节点Id
|
||||
*/
|
||||
deleteNode(id: any): void;
|
||||
/**
|
||||
* 添加节点
|
||||
* @param nodeConfig 节点配置
|
||||
*/
|
||||
addNode(nodeConfig: NodeConfig): any;
|
||||
/**
|
||||
* 克隆节点
|
||||
* @param nodeId 节点Id
|
||||
*/
|
||||
cloneNode(nodeId: string): BaseNodeModel;
|
||||
/**
|
||||
* 移动节点-相对位置
|
||||
* @param nodeModel 节点Id
|
||||
* @param deltaX X轴移动距离
|
||||
* @param deltaY Y轴移动距离
|
||||
* @param isignoreRule 是否忽略移动规则限制
|
||||
*/
|
||||
moveNode(nodeId: BaseNodeModelId, deltaX: number, deltaY: number, isignoreRule?: boolean): void;
|
||||
/**
|
||||
* 移动节点-绝对位置
|
||||
* @param nodeModel 节点Id
|
||||
* @param x X轴目标位置
|
||||
* @param y Y轴目标位置
|
||||
*/
|
||||
moveNode2Coordinate(nodeId: BaseNodeModelId, x: number, y: number, isignoreRule?: boolean): void;
|
||||
/**
|
||||
* 显示节点、连线文本编辑框
|
||||
* @param elementId 节点id
|
||||
*/
|
||||
editText(id: ElementModeId): void;
|
||||
/**
|
||||
* 给两个节点之间添加一条边
|
||||
* @param {object} edgeConfig
|
||||
*/
|
||||
addEdge(edgeConfig: EdgeConfig): BaseEdgeModel;
|
||||
/**
|
||||
* 移动边,内部方法,请勿直接使用
|
||||
*/
|
||||
moveEdge(nodeId: BaseNodeModelId, deltaX: number, deltaY: number): void;
|
||||
/**
|
||||
* 删除两节点之间的边
|
||||
* @param sourceNodeId 边的起始节点
|
||||
* @param targetNodeId 边的目的节点
|
||||
*/
|
||||
deleteEdgeBySourceAndTarget(sourceNodeId: any, targetNodeId: any): void;
|
||||
/**
|
||||
* 基于边Id删除边
|
||||
*/
|
||||
deleteEdgeById(id: any): void;
|
||||
/**
|
||||
* 删除以节点Id为起点的所有边
|
||||
*/
|
||||
deleteEdgeBySource(sourceNodeId: any): void;
|
||||
/**
|
||||
* 删除以节点Id为终点的所有边
|
||||
*/
|
||||
deleteEdgeByTarget(targetNodeId: any): void;
|
||||
/**
|
||||
* 设置元素的状态,在需要保证整个画布上所有的元素只有一个元素拥有此状态时可以调用此方法。
|
||||
* 例如文本编辑、菜单显示等。
|
||||
* additionStateData: 传递的额外值,如菜单显示的时候,需要传递期望菜单显示的位置。
|
||||
*/
|
||||
setElementStateById(id: ElementModeId, state: number, additionStateData?: AdditionData): void;
|
||||
/**
|
||||
* 更新节点或边的文案
|
||||
* @param id 节点或者边id
|
||||
* @param value 文案内容
|
||||
*/
|
||||
updateText(id: ElementModeId, value: string): void;
|
||||
/**
|
||||
* 选中节点
|
||||
* @param id 节点Id
|
||||
* @param multiple 是否为多选,如果为多选,则不去掉原有已选择节点的选中状态
|
||||
*/
|
||||
selectNodeById(id: string, multiple?: boolean): void;
|
||||
/**
|
||||
* 选中边
|
||||
* @param id 边Id
|
||||
* @param multiple 是否为多选,如果为多选,则不去掉原已选中边的状态
|
||||
*/
|
||||
selectEdgeById(id: string, multiple?: boolean): void;
|
||||
/**
|
||||
* 将图形选中
|
||||
* @param id 选择元素ID
|
||||
* @param multiple 是否允许多选,如果为true,不会将上一个选中的元素重置
|
||||
*/
|
||||
selectElementById(id: string, multiple?: boolean): void;
|
||||
/**
|
||||
* 将所有选中的元素设置为非选中
|
||||
*/
|
||||
clearSelectElements(): void;
|
||||
/**
|
||||
* 批量移动节点,节点移动的时候,会动态计算所有节点与未移动节点的边位置
|
||||
* 移动的节点之间的边会保持相对位置
|
||||
*/
|
||||
moveNodes(nodeIds: string[], deltaX: number, deltaY: number, isignoreRule?: boolean): void;
|
||||
/**
|
||||
* 添加节点移动限制规则,在节点移动的时候触发。
|
||||
* 如果方法返回false, 则会阻止节点移动。
|
||||
* @param fn function
|
||||
* @example
|
||||
*
|
||||
* graphModel.addNodeMoveRules((nodeModel, x, y) => {
|
||||
* if (nodeModel.properties.disabled) {
|
||||
* return false
|
||||
* }
|
||||
* return true
|
||||
* })
|
||||
*
|
||||
*/
|
||||
addNodeMoveRules(fn: NodeMoveRule): void;
|
||||
/**
|
||||
* 设置默认的边类型
|
||||
* 也就是设置在节点直接有用户手动绘制的连线类型。
|
||||
* @param type Options.EdgeType
|
||||
*/
|
||||
setDefaultEdgeType(type: string): void;
|
||||
/**
|
||||
* 修改指定节点类型
|
||||
* @param id 节点id
|
||||
* @param type 节点类型
|
||||
*/
|
||||
changeNodeType(id: any, type: string): void;
|
||||
/**
|
||||
* 切换边的类型
|
||||
* @param id 边Id
|
||||
* @param type 边类型
|
||||
*/
|
||||
changeEdgeType(id: any, type: any): void;
|
||||
/**
|
||||
* 获取所有以此节点为终点的边
|
||||
*/
|
||||
getNodeIncomingEdge(nodeId: any): any[];
|
||||
/**
|
||||
* 获取所有以此节点为起点的边
|
||||
*/
|
||||
getNodeOutgoingEdge(nodeId: any): any[];
|
||||
/**
|
||||
* 获取节点连接到的所有起始节点
|
||||
*/
|
||||
getNodeIncomingNode(nodeId: any): any[];
|
||||
/**
|
||||
* 获取节点连接到的所有目标节点
|
||||
*/
|
||||
getNodeOutgoingNode(nodeId: any): any[];
|
||||
/**
|
||||
* 设置主题
|
||||
* todo docs link
|
||||
*/
|
||||
setTheme(style: Theme): void;
|
||||
/**
|
||||
* 重新设置画布的宽高
|
||||
*/
|
||||
resize(width: number, height: number): void;
|
||||
/**
|
||||
* 清空画布
|
||||
*/
|
||||
clearData(): void;
|
||||
/**
|
||||
* 获取图形区域虚拟矩型的尺寸和中心坐标
|
||||
* @returns
|
||||
*/
|
||||
getVirtualRectSize(): VirtualRectSize;
|
||||
/**
|
||||
* 将图形整体移动到画布中心
|
||||
*/
|
||||
translateCenter(): void;
|
||||
/**
|
||||
* 画布图形适应屏幕大小
|
||||
* @param offset number 距离盒子四周的距离, 默认为20
|
||||
*/
|
||||
fitView(offset?: number): void;
|
||||
}
|
||||
export { GraphModel };
|
||||
export default GraphModel;
|
||||
@@ -0,0 +1,33 @@
|
||||
import GraphModel from './GraphModel';
|
||||
import { NodeData } from '../type/index';
|
||||
import BaseNodeModel from './node/BaseNodeModel';
|
||||
export declare type SnaplineInfo = {
|
||||
isShowHorizontal?: boolean;
|
||||
isShowVertical?: boolean;
|
||||
position?: SnaplinePosition;
|
||||
};
|
||||
export declare type SnaplinePosition = {
|
||||
x?: number;
|
||||
y?: number;
|
||||
};
|
||||
export default class SnaplineModel {
|
||||
graphModel: GraphModel;
|
||||
isShowHorizontal: boolean;
|
||||
isShowVertical: boolean;
|
||||
position: SnaplinePosition;
|
||||
constructor(graphModel: any);
|
||||
getStyle(): {
|
||||
[x: string]: any;
|
||||
fill?: string;
|
||||
stroke?: string;
|
||||
strokeWidth?: number;
|
||||
};
|
||||
private getCenterSnapLine;
|
||||
private getHorizontalSnapline;
|
||||
private getVerticalSnapline;
|
||||
getSnapLinePosition(dragingNode: NodeData, nodes: BaseNodeModel[]): SnaplineInfo;
|
||||
private setSnaplineInfo;
|
||||
clearSnapline(): void;
|
||||
setNodeSnapLine(nodeData: NodeData): void;
|
||||
}
|
||||
export { SnaplineModel };
|
||||
@@ -0,0 +1,83 @@
|
||||
import EventEmitter from '../event/eventEmitter';
|
||||
import { PointTuple, ZoomParam } from '../type';
|
||||
export interface TransfromInterface {
|
||||
SCALE_X: number;
|
||||
SKEW_Y: number;
|
||||
SKEW_X: number;
|
||||
SCALE_Y: number;
|
||||
TRANSLATE_X: number;
|
||||
TRANSLATE_Y: number;
|
||||
ZOOM_SIZE: number;
|
||||
MINI_SCALE_SIZE: number;
|
||||
MAX_SCALE_SIZE: number;
|
||||
zoom: (isZoomout: ZoomParam) => string;
|
||||
HtmlPointToCanvasPoint: (point: PointTuple) => PointTuple;
|
||||
CanvasPointToHtmlPoint: (point: PointTuple) => PointTuple;
|
||||
moveCanvasPointByHtml: (point: PointTuple, x: number, y: number) => PointTuple;
|
||||
getTransformStyle: () => {
|
||||
transform: string;
|
||||
};
|
||||
}
|
||||
export default class TransfromModel implements TransfromInterface {
|
||||
MINI_SCALE_SIZE: number;
|
||||
MAX_SCALE_SIZE: number;
|
||||
SCALE_X: number;
|
||||
SKEW_Y: number;
|
||||
SKEW_X: number;
|
||||
SCALE_Y: number;
|
||||
TRANSLATE_X: number;
|
||||
TRANSLATE_Y: number;
|
||||
ZOOM_SIZE: number;
|
||||
eventCenter: EventEmitter;
|
||||
constructor(eventCenter: any);
|
||||
setZoomMiniSize(size: number): void;
|
||||
setZoomMaxSize(size: number): void;
|
||||
/**
|
||||
* 将最外层graph上的点基于缩放转换为canvasOverlay层上的点。
|
||||
* @param param0 HTML点
|
||||
*/
|
||||
HtmlPointToCanvasPoint([x, y]: PointTuple): PointTuple;
|
||||
/**
|
||||
* 将最外层canvasOverlay层上的点基于缩放转换为graph上的点。
|
||||
* @param param0 HTML点
|
||||
*/
|
||||
CanvasPointToHtmlPoint([x, y]: PointTuple): PointTuple;
|
||||
/**
|
||||
* 将一个在canvas上的点,向x轴方向移动directionX距离,向y轴方向移动dirctionY距离。
|
||||
* 因为canvas可能被缩小或者放大了,所以其在canvas层移动的距离需要计算上缩放的量。
|
||||
* @param point 点
|
||||
* @param directionX x轴距离
|
||||
* @param directionY y轴距离
|
||||
*/
|
||||
moveCanvasPointByHtml([x, y]: PointTuple, directionX: number, directionY: number): PointTuple;
|
||||
/**
|
||||
* 根据缩放情况,获取缩放后的delta距离
|
||||
* @param deltaX x轴距离变化
|
||||
* @param deltaY y轴距离变化
|
||||
*/
|
||||
fixDeltaXY(deltaX: number, deltaY: number): PointTuple;
|
||||
/**
|
||||
* 基于当前的缩放,获取画布渲染样式transform值
|
||||
*/
|
||||
getTransformStyle(): {
|
||||
transform: string;
|
||||
};
|
||||
/**
|
||||
* 放大缩小图形
|
||||
* @param zoomSize 放大缩小的值,支持传入0-n之间的数字。小于1表示缩小,大于1表示放大。也支持传入true和false按照内置的刻度放大缩小
|
||||
* @param point 缩放的原点
|
||||
* @returns {string} -放大缩小的比例
|
||||
*/
|
||||
zoom(zoomSize?: ZoomParam, point?: PointTuple): string;
|
||||
private emitGraphTransform;
|
||||
resetZoom(): void;
|
||||
translate(x: number, y: number): void;
|
||||
/**
|
||||
* 将图形定位到画布中心
|
||||
* @param targetX 图形当前x坐标
|
||||
* @param targetY 图形当前y坐标
|
||||
* @param width 画布宽
|
||||
* @param height 画布高
|
||||
*/
|
||||
focusOn(targetX: number, targetY: number, width: number, height: number): void;
|
||||
}
|
||||
@@ -0,0 +1,157 @@
|
||||
import { IBaseModel } from '../BaseModel';
|
||||
import GraphModel from '../GraphModel';
|
||||
import { Point, AdditionData, EdgeData, MenuConfig, EdgeConfig } from '../../type/index';
|
||||
import { ModelType, ElementType } from '../../constant/constant';
|
||||
import { OutlineTheme } from '../../constant/DefaultTheme';
|
||||
declare class BaseEdgeModel implements IBaseModel {
|
||||
id: string;
|
||||
type: string;
|
||||
sourceNodeId: string;
|
||||
targetNodeId: string;
|
||||
startPoint: any;
|
||||
endPoint: any;
|
||||
text: {
|
||||
value: string;
|
||||
x: number;
|
||||
y: number;
|
||||
draggable: boolean;
|
||||
editable: boolean;
|
||||
};
|
||||
properties: Record<string, any>;
|
||||
points: string;
|
||||
pointsList: any[];
|
||||
isSelected: boolean;
|
||||
isHovered: boolean;
|
||||
isHitable: boolean;
|
||||
draggable: boolean;
|
||||
visible: boolean;
|
||||
graphModel: GraphModel;
|
||||
zIndex: number;
|
||||
readonly BaseType = ElementType.EDGE;
|
||||
modelType: ModelType;
|
||||
state: number;
|
||||
additionStateData: AdditionData;
|
||||
sourceAnchorId: string;
|
||||
targetAnchorId: string;
|
||||
menu?: MenuConfig[];
|
||||
customTextPosition: boolean;
|
||||
animationData: import("../../constant/DefaultAnimation").Animation;
|
||||
[propName: string]: any;
|
||||
constructor(data: EdgeConfig, graphModel: GraphModel);
|
||||
/**
|
||||
* @overridable 支持重写
|
||||
* 初始化边数据
|
||||
* initNodeData和setAttributes的区别在于
|
||||
* initNodeData只在节点初始化的时候调用,用于初始化节点的所有属性。
|
||||
* setAttributes除了初始化调用外,还会在properties发生变化了调用。
|
||||
*/
|
||||
initEdgeData(data: any): void;
|
||||
/**
|
||||
* 设置model属性,每次properties发生变化会触发
|
||||
* @overridable 支持重写
|
||||
*/
|
||||
setAttributes(): void;
|
||||
/**
|
||||
* @overridable 支持重写,自定义此类型节点默认生成方式
|
||||
* @returns string
|
||||
*/
|
||||
createId(): any;
|
||||
/**
|
||||
* @overridable 支持重写
|
||||
* 获取当前节点样式
|
||||
* @returns 自定义边样式
|
||||
*/
|
||||
getEdgeStyle(): import("../../constant/DefaultTheme").CommonTheme;
|
||||
/**
|
||||
* @overridable 支持重写
|
||||
* 获取当前节点文本样式
|
||||
*/
|
||||
getTextStyle(): import("../../constant/DefaultTheme").EdgeTextTheme;
|
||||
/**
|
||||
* @overridable 支持重写
|
||||
* 获取当前边的动画样式
|
||||
* @returns 自定义边动画样式
|
||||
*/
|
||||
getAnimation(): import("../../constant/DefaultAnimation").Animation;
|
||||
/**
|
||||
* @overridable 支持重写
|
||||
* 获取outline样式,重写可以定义此类型边outline样式, 默认使用主题样式
|
||||
* @returns 自定义outline样式
|
||||
*/
|
||||
getOutlineStyle(): OutlineTheme;
|
||||
/**
|
||||
* @overridable 支持重新,重新自定义文本位置
|
||||
* @returns 文本位置
|
||||
*/
|
||||
getTextPosition(): Point;
|
||||
get sourceNode(): import("..").BaseNodeModel;
|
||||
get targetNode(): import("..").BaseNodeModel;
|
||||
get textPosition(): Point;
|
||||
/**
|
||||
* 内部方法,计算两个节点相连是起点位置
|
||||
*/
|
||||
getBeginAnchor(sourceNode: any, targetNode: any): Point;
|
||||
/**
|
||||
* 内部方法,计算两个节点相连是终点位置
|
||||
*/
|
||||
getEndAnchor(targetNode: any): Point;
|
||||
/**
|
||||
* 获取当前边的properties
|
||||
*/
|
||||
getProperties(): Record<string, any>;
|
||||
/**
|
||||
* 获取被保存时返回的数据
|
||||
*/
|
||||
getData(): EdgeData;
|
||||
/**
|
||||
* 用于在历史记录时获取节点数据,
|
||||
* 在某些情况下,如果希望某个属性变化不引起history的变化,
|
||||
* 可以重写此方法。
|
||||
*/
|
||||
getHistoryData(): EdgeData;
|
||||
setProperty(key: any, val: any): void;
|
||||
setProperties(properties: any): void;
|
||||
/**
|
||||
* 内部方法,处理初始化文本格式
|
||||
*/
|
||||
formatText(data: any): void;
|
||||
/**
|
||||
* 重置文本位置
|
||||
*/
|
||||
resetTextPosition(): void;
|
||||
/**
|
||||
* 移动边上的文本
|
||||
*/
|
||||
moveText(deltaX: number, deltaY: number): void;
|
||||
/**
|
||||
* 设置文本位置和值
|
||||
*/
|
||||
setText(textConfig: any): void;
|
||||
/**
|
||||
* 更新文本的值
|
||||
*/
|
||||
updateText(value: string): void;
|
||||
/**
|
||||
* 内部方法,计算边的起点和终点和其对于的锚点Id
|
||||
*/
|
||||
setAnchors(): void;
|
||||
setSelected(flag?: boolean): void;
|
||||
setHovered(flag?: boolean): void;
|
||||
setHitable(flag?: boolean): void;
|
||||
setElementState(state: number, additionStateData?: AdditionData): void;
|
||||
updateStartPoint(anchor: any): void;
|
||||
moveStartPoint(deltaX: any, deltaY: any): void;
|
||||
updateEndPoint(anchor: any): void;
|
||||
moveEndPoint(deltaX: any, deltaY: any): void;
|
||||
setZIndex(zindex?: number): void;
|
||||
initPoints(): void;
|
||||
updateAttributes(attributes: any): void;
|
||||
getAdjustStart(): any;
|
||||
getAdjustEnd(): any;
|
||||
updateAfterAdjustStartAndEnd({ startPoint, endPoint }: {
|
||||
startPoint: any;
|
||||
endPoint: any;
|
||||
}): void;
|
||||
}
|
||||
export { BaseEdgeModel };
|
||||
export default BaseEdgeModel;
|
||||
@@ -0,0 +1,51 @@
|
||||
import BaseEdgeModel from './BaseEdgeModel';
|
||||
import { Point } from '../../type';
|
||||
import { ModelType } from '../../constant/constant';
|
||||
export { BezierEdgeModel };
|
||||
export default class BezierEdgeModel extends BaseEdgeModel {
|
||||
modelType: ModelType;
|
||||
path: string;
|
||||
initEdgeData(data: any): void;
|
||||
getEdgeStyle(): {
|
||||
[x: string]: any;
|
||||
adjustLine?: import("../../constant/DefaultTheme").CommonTheme;
|
||||
adjustAnchor?: import("../../constant/DefaultTheme").CircleTheme;
|
||||
fill?: string;
|
||||
stroke?: string;
|
||||
strokeWidth?: number;
|
||||
};
|
||||
getTextPosition(): Point;
|
||||
getData(): {
|
||||
pointsList: {
|
||||
x: any;
|
||||
y: any;
|
||||
}[];
|
||||
id: string;
|
||||
type: string;
|
||||
sourceNodeId: string;
|
||||
startPoint: Point;
|
||||
targetNodeId: string;
|
||||
endPoint: Point;
|
||||
text?: import("../../type").TextConfig;
|
||||
properties: Record<string, unknown>;
|
||||
zIndex?: number;
|
||||
};
|
||||
private getControls;
|
||||
private getPath;
|
||||
initPoints(): void;
|
||||
updatePoints(): void;
|
||||
updatePath(sNext: any, ePre: any): void;
|
||||
updateStartPoint(anchor: any): void;
|
||||
updateEndPoint(anchor: any): void;
|
||||
moveStartPoint(deltaX: any, deltaY: any): void;
|
||||
moveEndPoint(deltaX: any, deltaY: any): void;
|
||||
updateAdjustAnchor(anchor: Point, type: string): void;
|
||||
getAdjustStart(): any;
|
||||
getAdjustEnd(): any;
|
||||
updateAfterAdjustStartAndEnd({ startPoint, endPoint, sourceNode, targetNode }: {
|
||||
startPoint: any;
|
||||
endPoint: any;
|
||||
sourceNode: any;
|
||||
targetNode: any;
|
||||
}): void;
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
import BaseEdgeModel from './BaseEdgeModel';
|
||||
import { Point } from '../../type';
|
||||
import { ModelType } from '../../constant/constant';
|
||||
export { LineEdgeModel };
|
||||
export default class LineEdgeModel extends BaseEdgeModel {
|
||||
modelType: ModelType;
|
||||
getEdgeStyle(): {
|
||||
[x: string]: any;
|
||||
fill?: string;
|
||||
stroke?: string;
|
||||
strokeWidth?: number;
|
||||
};
|
||||
getTextPosition(): Point;
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
import { ModelType } from '../../constant/constant';
|
||||
import { Point } from '../../type';
|
||||
import BaseEdgeModel from './BaseEdgeModel';
|
||||
export { PolylineEdgeModel };
|
||||
export default class PolylineEdgeModel extends BaseEdgeModel {
|
||||
modelType: ModelType;
|
||||
draginngPointList: any;
|
||||
dbClickPosition: Point;
|
||||
initEdgeData(data: any): void;
|
||||
getEdgeStyle(): {
|
||||
[x: string]: any;
|
||||
fill?: string;
|
||||
stroke?: string;
|
||||
strokeWidth?: number;
|
||||
};
|
||||
getTextPosition(): {
|
||||
x: number;
|
||||
y: number;
|
||||
};
|
||||
getAfterAnchor(direction: any, position: any, anchorList: any): any;
|
||||
getCorssPoint(direction: any, start: any, end: any): any;
|
||||
removeCrossPoints(startIndex: any, endIndex: any, pointList: any): any;
|
||||
getDragingPoints(direction: any, positioType: any, position: any, anchorList: any, draginngPointList: any): any;
|
||||
updateCrossPoints(pointList: any): any;
|
||||
getData(): import("../../type").EdgeData & {
|
||||
pointsList: {
|
||||
x: any;
|
||||
y: any;
|
||||
}[];
|
||||
};
|
||||
initPoints(): void;
|
||||
updatePoints(): void;
|
||||
updateStartPoint(anchor: any): void;
|
||||
moveStartPoint(deltaX: any, deltaY: any): void;
|
||||
updateEndPoint(anchor: any): void;
|
||||
moveEndPoint(deltaX: any, deltaY: any): void;
|
||||
dragAppendStart(): void;
|
||||
dragAppendSimple(appendInfo: any, dragInfo: any): {
|
||||
start: any;
|
||||
end: any;
|
||||
startIndex: any;
|
||||
endIndex: any;
|
||||
direction: any;
|
||||
};
|
||||
dragAppend(appendInfo: any, dragInfo: any): {
|
||||
start: any;
|
||||
end: any;
|
||||
startIndex: any;
|
||||
endIndex: any;
|
||||
direction: any;
|
||||
};
|
||||
dragAppendEnd(): void;
|
||||
updatePointsAfterDrage(pointsList: any): void;
|
||||
getAdjustStart(): any;
|
||||
getAdjustEnd(): any;
|
||||
updateAfterAdjustStartAndEnd({ startPoint, endPoint, sourceNode, targetNode }: {
|
||||
startPoint: any;
|
||||
endPoint: any;
|
||||
sourceNode: any;
|
||||
targetNode: any;
|
||||
}): void;
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
export * from './BaseEdgeModel';
|
||||
export * from './BezierEdgeModel';
|
||||
export * from './LineEdgeModel';
|
||||
export * from './PolylineEdgeModel';
|
||||
@@ -0,0 +1,7 @@
|
||||
export * from './edge';
|
||||
export * from './node';
|
||||
export * from './BaseModel';
|
||||
export * from './EditConfigModel';
|
||||
export * from './GraphModel';
|
||||
export * from './SnaplineModel';
|
||||
export * from './TransformModel';
|
||||
@@ -0,0 +1,197 @@
|
||||
import { OutlineTheme } from '../../constant/DefaultTheme';
|
||||
import { ModelType, ElementType } from '../../constant/constant';
|
||||
import { AdditionData, NodeData, NodeConfig, NodeMoveRule, Bounds, AnchorConfig, PointAnchor, AnchorsOffsetItem, ShapeStyleAttribute, IsAllowMove } from '../../type';
|
||||
import GraphModel from '../GraphModel';
|
||||
import { IBaseModel } from '../BaseModel';
|
||||
import { BaseEdgeModel } from '../edge';
|
||||
export declare type ConnectRule = {
|
||||
message: string;
|
||||
validate: (source?: BaseNodeModel, target?: BaseNodeModel, sourceAnchor?: AnchorConfig, targetAnchor?: AnchorConfig) => boolean;
|
||||
};
|
||||
export declare type ConnectRuleResult = {
|
||||
isAllPass: boolean;
|
||||
msg?: string;
|
||||
};
|
||||
interface IBaseNodeModel extends IBaseModel {
|
||||
/**
|
||||
* model基础类型,固定为node
|
||||
*/
|
||||
readonly BaseType: ElementType.NODE;
|
||||
}
|
||||
export { BaseNodeModel };
|
||||
export default class BaseNodeModel implements IBaseNodeModel {
|
||||
id: string;
|
||||
type: string;
|
||||
x: number;
|
||||
y: number;
|
||||
text: {
|
||||
value: string;
|
||||
x: number;
|
||||
y: number;
|
||||
draggable: boolean;
|
||||
editable: boolean;
|
||||
};
|
||||
properties: Record<string, any>;
|
||||
private _width;
|
||||
get width(): number;
|
||||
set width(value: number);
|
||||
private _height;
|
||||
get height(): number;
|
||||
set height(value: number);
|
||||
anchorsOffset: AnchorsOffsetItem[];
|
||||
isSelected: boolean;
|
||||
isHovered: boolean;
|
||||
isDragging: boolean;
|
||||
isHitable: boolean;
|
||||
draggable: boolean;
|
||||
visible: boolean;
|
||||
graphModel: GraphModel;
|
||||
zIndex: number;
|
||||
state: number;
|
||||
autoToFront: boolean;
|
||||
readonly BaseType = ElementType.NODE;
|
||||
modelType: ModelType;
|
||||
additionStateData: AdditionData;
|
||||
targetRules: ConnectRule[];
|
||||
sourceRules: ConnectRule[];
|
||||
moveRules: NodeMoveRule[];
|
||||
hasSetTargetRules: boolean;
|
||||
hasSetSourceRules: boolean;
|
||||
[propName: string]: any;
|
||||
constructor(data: NodeConfig, graphModel: GraphModel);
|
||||
/**
|
||||
* 获取进入当前节点的边和节点
|
||||
*/
|
||||
get incoming(): {
|
||||
nodes: BaseNodeModel[];
|
||||
edges: BaseEdgeModel[];
|
||||
};
|
||||
get outgoing(): {
|
||||
nodes: BaseNodeModel[];
|
||||
edges: BaseEdgeModel[];
|
||||
};
|
||||
/**
|
||||
* @overridable 可以重写
|
||||
* 初始化节点数据
|
||||
* initNodeData和setAttributes的区别在于
|
||||
* initNodeData只在节点初始化的时候调用,用于初始化节点的所有属性。
|
||||
* setAttributes除了初始化调用外,还会在properties发生变化了调用。
|
||||
*/
|
||||
initNodeData(data: any): void;
|
||||
/**
|
||||
* 设置model属性,每次properties发生变化会触发
|
||||
* 例如设置节点的宽度
|
||||
* @example
|
||||
*
|
||||
* setAttributes () {
|
||||
* this.width = 300
|
||||
* this.height = 200
|
||||
* }
|
||||
*
|
||||
* @overridable 支持重写
|
||||
*/
|
||||
setAttributes(): void;
|
||||
/**
|
||||
* @overridable 支持重写,自定义此类型节点默认生成方式
|
||||
* @returns string
|
||||
*/
|
||||
createId(): string;
|
||||
/**
|
||||
* 初始化文本属性
|
||||
*/
|
||||
private formatText;
|
||||
/**
|
||||
* 获取被保存时返回的数据
|
||||
* @overridable 支持重写
|
||||
*/
|
||||
getData(): NodeData;
|
||||
/**
|
||||
* 用于在历史记录时获取节点数据,
|
||||
* 在某些情况下,如果希望某个属性变化不引起history的变化,
|
||||
* 可以重写此方法。
|
||||
*/
|
||||
getHistoryData(): NodeData;
|
||||
/**
|
||||
* 获取当前节点的properties
|
||||
*/
|
||||
getProperties(): Record<string, any>;
|
||||
/**
|
||||
* @overridable 支持重写
|
||||
* 获取当前节点样式
|
||||
* @returns 自定义节点样式
|
||||
*/
|
||||
getNodeStyle(): ShapeStyleAttribute;
|
||||
/**
|
||||
* @overridable 支持重写
|
||||
* 获取当前节点文本样式
|
||||
*/
|
||||
getTextStyle(): import("../../constant/DefaultTheme").NodeTextTheme;
|
||||
/**
|
||||
* @overridable 支持重写
|
||||
* 获取当前节点锚点样式
|
||||
* @returns 自定义样式
|
||||
*/
|
||||
getAnchorStyle(anchorInfo: any): Record<string, any>;
|
||||
/**
|
||||
* @overridable 支持重写
|
||||
* 获取当前节点锚点拖出连线样式
|
||||
* @returns 自定义锚点拖出样式
|
||||
*/
|
||||
getAnchorLineStyle(): import("../../constant/DefaultTheme").CommonTheme;
|
||||
/**
|
||||
* @overridable 支持重写
|
||||
* 获取outline样式,重写可以定义此类型节点outline样式, 默认使用主题样式
|
||||
* @returns 自定义outline样式
|
||||
*/
|
||||
getOutlineStyle(): OutlineTheme;
|
||||
/**
|
||||
* @over
|
||||
* 在边的时候,是否允许这个节点为source节点,边到target节点。
|
||||
*/
|
||||
isAllowConnectedAsSource(target: BaseNodeModel, soureAnchor: AnchorConfig, targetAnchor: AnchorConfig): ConnectRuleResult | Boolean;
|
||||
/**
|
||||
* 获取当前节点作为连接的起始节点规则。
|
||||
*/
|
||||
getConnectedSourceRules(): ConnectRule[];
|
||||
/**
|
||||
* 在连线的时候,是否允许这个节点为target节点
|
||||
*/
|
||||
isAllowConnectedAsTarget(source: BaseNodeModel, soureAnchor: AnchorConfig, targetAnchor: AnchorConfig): ConnectRuleResult | Boolean;
|
||||
/**
|
||||
* 内部方法
|
||||
* 是否允许移动节点到新的位置
|
||||
*/
|
||||
isAllowMoveNode(deltaX: any, deltaY: any): boolean | IsAllowMove;
|
||||
/**
|
||||
* 获取作为连线终点时的所有规则。
|
||||
*/
|
||||
getConnectedTargetRules(): ConnectRule[];
|
||||
/**
|
||||
* @returns Point[] 锚点坐标构成的数组
|
||||
*/
|
||||
getAnchorsByOffset(): PointAnchor[];
|
||||
/**
|
||||
* @overridable 子类重写此方法设置默认锚点
|
||||
* 获取节点默认情况下的锚点
|
||||
*/
|
||||
getDefaultAnchor(): PointAnchor[];
|
||||
/**
|
||||
* 获取节点BBox
|
||||
*/
|
||||
getBounds(): Bounds;
|
||||
get anchors(): PointAnchor[];
|
||||
getAnchorInfo(anchorId: string): PointAnchor;
|
||||
addNodeMoveRules(fn: NodeMoveRule): void;
|
||||
move(deltaX: any, deltaY: any, isignoreRule?: boolean): boolean;
|
||||
moveTo(x: any, y: any, isignoreRule?: boolean): boolean;
|
||||
moveText(deltaX: any, deltaY: any): void;
|
||||
updateText(value: string): void;
|
||||
setSelected(flag?: boolean): void;
|
||||
setHovered(flag?: boolean): void;
|
||||
setHitable(flag?: boolean): void;
|
||||
setElementState(state: number, additionStateData?: AdditionData): void;
|
||||
setProperty(key: any, val: any): void;
|
||||
setProperties(properties: any): void;
|
||||
setZIndex(zindex?: number): void;
|
||||
updateAttributes(attributes: any): void;
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
import BaseNodeModel from './BaseNodeModel';
|
||||
import { ModelType } from '../../constant/constant';
|
||||
declare class CircleNodeModel extends BaseNodeModel {
|
||||
modelType: ModelType;
|
||||
r: number;
|
||||
get width(): number;
|
||||
get height(): number;
|
||||
getNodeStyle(): {
|
||||
[x: string]: any;
|
||||
r?: number;
|
||||
fill?: string;
|
||||
stroke?: string;
|
||||
strokeWidth?: number;
|
||||
};
|
||||
getDefaultAnchor(): {
|
||||
x: number;
|
||||
y: number;
|
||||
id: string;
|
||||
}[];
|
||||
}
|
||||
export { CircleNodeModel };
|
||||
export default CircleNodeModel;
|
||||
@@ -0,0 +1,25 @@
|
||||
import { Point, PointTuple } from '../../type';
|
||||
import BaseNodeModel from './BaseNodeModel';
|
||||
import { ModelType } from '../../constant/constant';
|
||||
declare class DiamondNodeModel extends BaseNodeModel {
|
||||
modelType: ModelType;
|
||||
rx: number;
|
||||
ry: number;
|
||||
getNodeStyle(): {
|
||||
[x: string]: any;
|
||||
fill?: string;
|
||||
stroke?: string;
|
||||
strokeWidth?: number;
|
||||
};
|
||||
get points(): PointTuple[];
|
||||
get pointsPosition(): Point[];
|
||||
get width(): number;
|
||||
get height(): number;
|
||||
getDefaultAnchor(): {
|
||||
x: number;
|
||||
y: number;
|
||||
id: string;
|
||||
}[];
|
||||
}
|
||||
export { DiamondNodeModel };
|
||||
export default DiamondNodeModel;
|
||||
@@ -0,0 +1,22 @@
|
||||
import BaseNodeModel from './BaseNodeModel';
|
||||
import { ModelType } from '../../constant/constant';
|
||||
declare class EllipseNodeModel extends BaseNodeModel {
|
||||
modelType: ModelType;
|
||||
rx: number;
|
||||
ry: number;
|
||||
getNodeStyle(): {
|
||||
[x: string]: any;
|
||||
fill?: string;
|
||||
stroke?: string;
|
||||
strokeWidth?: number;
|
||||
};
|
||||
get width(): number;
|
||||
get height(): number;
|
||||
getDefaultAnchor(): {
|
||||
x: number;
|
||||
y: number;
|
||||
id: string;
|
||||
}[];
|
||||
}
|
||||
export { EllipseNodeModel };
|
||||
export default EllipseNodeModel;
|
||||
@@ -0,0 +1,12 @@
|
||||
import BaseNodeModel from './BaseNodeModel';
|
||||
import { ModelType } from '../../constant/constant';
|
||||
declare class HtmlNodeModel extends BaseNodeModel {
|
||||
modelType: ModelType;
|
||||
getDefaultAnchor(): {
|
||||
x: number;
|
||||
y: number;
|
||||
id: string;
|
||||
}[];
|
||||
}
|
||||
export { HtmlNodeModel };
|
||||
export default HtmlNodeModel;
|
||||
@@ -0,0 +1,28 @@
|
||||
import { Point, PointTuple } from '../../type';
|
||||
import BaseNodeModel from './BaseNodeModel';
|
||||
import { ModelType } from '../../constant/constant';
|
||||
declare class PolygonNodeModel extends BaseNodeModel {
|
||||
modelType: ModelType;
|
||||
points: PointTuple[];
|
||||
getNodeStyle(): {
|
||||
[x: string]: any;
|
||||
fill?: string;
|
||||
stroke?: string;
|
||||
strokeWidth?: number;
|
||||
};
|
||||
/**
|
||||
* 由于大多数情况下,我们初始化拿到的多边形坐标都是基于原点的(例如绘图工具到处的svg)。
|
||||
* 在logicflow中对多边形进行移动,我们不需要去更新points,
|
||||
* 而是去更新多边形中心点即可。
|
||||
*/
|
||||
get pointsPosition(): Point[];
|
||||
get width(): number;
|
||||
get height(): number;
|
||||
getDefaultAnchor(): {
|
||||
x: number;
|
||||
y: number;
|
||||
id: string;
|
||||
}[];
|
||||
}
|
||||
export { PolygonNodeModel };
|
||||
export default PolygonNodeModel;
|
||||
@@ -0,0 +1,22 @@
|
||||
import BaseNodeModel from './BaseNodeModel';
|
||||
import { ModelType } from '../../constant/constant';
|
||||
declare class RectNodeModel extends BaseNodeModel {
|
||||
modelType: ModelType;
|
||||
radius: number;
|
||||
getDefaultAnchor(): {
|
||||
x: number;
|
||||
y: number;
|
||||
id: string;
|
||||
}[];
|
||||
getNodeStyle(): {
|
||||
[x: string]: any;
|
||||
width?: number;
|
||||
height?: number;
|
||||
radius?: number;
|
||||
fill?: string;
|
||||
stroke?: string;
|
||||
strokeWidth?: number;
|
||||
};
|
||||
}
|
||||
export { RectNodeModel };
|
||||
export default RectNodeModel;
|
||||
@@ -0,0 +1,19 @@
|
||||
import BaseNodeModel from './BaseNodeModel';
|
||||
import { ModelType } from '../../constant/constant';
|
||||
declare class TextNodeModel extends BaseNodeModel {
|
||||
modelType: ModelType;
|
||||
getTextStyle(): {
|
||||
[x: string]: any;
|
||||
color?: string;
|
||||
fontSize?: number;
|
||||
fill?: string;
|
||||
stroke?: string;
|
||||
strokeWidth?: number;
|
||||
overflowMode?: string;
|
||||
background?: import("../../constant/DefaultTheme").RectTheme;
|
||||
};
|
||||
get width(): number;
|
||||
get height(): number;
|
||||
}
|
||||
export { TextNodeModel };
|
||||
export default TextNodeModel;
|
||||
@@ -0,0 +1,8 @@
|
||||
export * from './BaseNodeModel';
|
||||
export * from './CircleNodeModel';
|
||||
export * from './DiamondNodeModel';
|
||||
export * from './EllipseNodeModel';
|
||||
export * from './PolygonNodeModel';
|
||||
export * from './RectNodeModel';
|
||||
export * from './TextNodeModel';
|
||||
export * from './HtmlNodeModel';
|
||||
+202
@@ -0,0 +1,202 @@
|
||||
import { GridOptions } from './view/overlay/Grid';
|
||||
import { BackgroundConfig } from './view/overlay/BackgroundOverlay';
|
||||
import { NodeData, EdgeData, Extension, GraphConfigData } from './type';
|
||||
import { KeyboardDef } from './keyboard';
|
||||
import { EditConfigInterface } from './model/EditConfigModel';
|
||||
import { Theme } from './constant/DefaultTheme';
|
||||
import { AnimationConfig } from './constant/DefaultAnimation';
|
||||
export declare type EdgeType = 'line' | 'polyline' | 'bezier' | any;
|
||||
declare type DefaultOverlapMode = 0;
|
||||
declare type IncreaseOverlapMode = 1;
|
||||
/**
|
||||
* 元素重叠处理方式
|
||||
* 0:表示节点在上,边在下,点击元素时选择元素显示在最顶部。
|
||||
* 1:表示安装元素创建顺序排序,点击元素也不会将其置顶。要置顶需要调用置顶API。
|
||||
*/
|
||||
export declare type OverlapMode = DefaultOverlapMode | IncreaseOverlapMode;
|
||||
export declare type Definition = {
|
||||
/**
|
||||
* 画布初始化容器
|
||||
* 注意,在不传入width和height的情况下,container元素本身应该存在高度和高度。
|
||||
*/
|
||||
container: HTMLElement;
|
||||
/**
|
||||
* 画布宽度,不传则默认100%
|
||||
*/
|
||||
width?: number;
|
||||
/**
|
||||
* 画布高度,不传则默认100%
|
||||
*/
|
||||
height?: number;
|
||||
/**
|
||||
* 背景图
|
||||
*/
|
||||
background?: false | BackgroundConfig;
|
||||
/**
|
||||
* 网格
|
||||
*/
|
||||
grid?: boolean | GridOptions;
|
||||
/**
|
||||
* 键盘快捷操作
|
||||
*/
|
||||
keyboard?: KeyboardDef;
|
||||
/**
|
||||
* 主题配置
|
||||
*/
|
||||
style?: Theme;
|
||||
/**
|
||||
* 禁止初始化的插件名称
|
||||
*/
|
||||
disabledPlugins?: string[];
|
||||
/**
|
||||
* 默认边类型
|
||||
*/
|
||||
edgeType?: EdgeType;
|
||||
/**
|
||||
* 是否开启对齐线,默认开启
|
||||
*/
|
||||
snapline?: boolean;
|
||||
/**
|
||||
* 是否开启历史记录功能,默认开启
|
||||
*/
|
||||
history?: boolean;
|
||||
/**
|
||||
* 是否开启局部渲染,默认不开启
|
||||
*/
|
||||
partial?: boolean;
|
||||
/**
|
||||
* 删除和克隆之前的判断函数
|
||||
* todo: 目前不完善,仅支持同步
|
||||
*/
|
||||
guards?: GuardsTypes;
|
||||
/**
|
||||
* 表示节点在上,边在下,点击元素时选择元素显示在最顶部。
|
||||
* 表示安装元素创建顺序排序,点击元素也不会将其置顶。要置顶需要调用置顶API。
|
||||
*/
|
||||
overlapMode?: OverlapMode;
|
||||
/**
|
||||
* 自定义创建节点、连线时生成id规则。
|
||||
* @param type 节点、连线类型
|
||||
*/
|
||||
idGenerator?: (type?: string) => string;
|
||||
/**
|
||||
* 禁止启用的内置工具
|
||||
* 有些场景下,需要自定义多选效果或者文本编辑效果,则需要禁用这些内置的工具
|
||||
* multipleSelect和textEdit
|
||||
* todo: 将multipleSelect放到插件中
|
||||
*/
|
||||
disabledTools?: string[];
|
||||
/**
|
||||
* 是否配置个性插件,覆盖全局配置的插件
|
||||
*/
|
||||
plugins?: Extension[];
|
||||
/**
|
||||
* 控制是否开启动画
|
||||
* false: 关闭所有动画
|
||||
* true: 开启所有动画
|
||||
* AnimationConfig: 配置部分动画开启
|
||||
*/
|
||||
animation?: boolean | Partial<AnimationConfig>;
|
||||
[key: string]: any;
|
||||
} & EditConfigInterface;
|
||||
export interface GuardsTypes {
|
||||
beforeClone?: (data: NodeData | GraphConfigData) => boolean;
|
||||
beforeDelete?: (data: NodeData | EdgeData) => boolean;
|
||||
}
|
||||
export declare function get(options: Definition): {
|
||||
background: boolean;
|
||||
grid: boolean;
|
||||
textEdit: boolean;
|
||||
disabledTools: any[];
|
||||
} & {
|
||||
[key: string]: any;
|
||||
/**
|
||||
* 画布初始化容器
|
||||
* 注意,在不传入width和height的情况下,container元素本身应该存在高度和高度。
|
||||
*/
|
||||
container: HTMLElement;
|
||||
/**
|
||||
* 画布宽度,不传则默认100%
|
||||
*/
|
||||
width?: number;
|
||||
/**
|
||||
* 画布高度,不传则默认100%
|
||||
*/
|
||||
height?: number;
|
||||
/**
|
||||
* 背景图
|
||||
*/
|
||||
background?: false | BackgroundConfig;
|
||||
/**
|
||||
* 网格
|
||||
*/
|
||||
grid?: boolean | GridOptions;
|
||||
/**
|
||||
* 键盘快捷操作
|
||||
*/
|
||||
keyboard?: KeyboardDef;
|
||||
/**
|
||||
* 主题配置
|
||||
*/
|
||||
style?: Theme;
|
||||
/**
|
||||
* 禁止初始化的插件名称
|
||||
*/
|
||||
disabledPlugins?: string[];
|
||||
/**
|
||||
* 默认边类型
|
||||
*/
|
||||
edgeType?: any;
|
||||
/**
|
||||
* 是否开启对齐线,默认开启
|
||||
*/
|
||||
snapline?: boolean;
|
||||
/**
|
||||
* 是否开启历史记录功能,默认开启
|
||||
*/
|
||||
history?: boolean;
|
||||
/**
|
||||
* 是否开启局部渲染,默认不开启
|
||||
*/
|
||||
partial?: boolean;
|
||||
/**
|
||||
* 删除和克隆之前的判断函数
|
||||
* todo: 目前不完善,仅支持同步
|
||||
*/
|
||||
guards?: GuardsTypes;
|
||||
/**
|
||||
* 表示节点在上,边在下,点击元素时选择元素显示在最顶部。
|
||||
* 表示安装元素创建顺序排序,点击元素也不会将其置顶。要置顶需要调用置顶API。
|
||||
*/
|
||||
overlapMode?: OverlapMode;
|
||||
/**
|
||||
* 自定义创建节点、连线时生成id规则。
|
||||
* @param type 节点、连线类型
|
||||
*/
|
||||
idGenerator?: (type?: string) => string;
|
||||
/**
|
||||
* 禁止启用的内置工具
|
||||
* 有些场景下,需要自定义多选效果或者文本编辑效果,则需要禁用这些内置的工具
|
||||
* multipleSelect和textEdit
|
||||
* todo: 将multipleSelect放到插件中
|
||||
*/
|
||||
disabledTools?: string[];
|
||||
/**
|
||||
* 是否配置个性插件,覆盖全局配置的插件
|
||||
*/
|
||||
plugins?: Extension[];
|
||||
/**
|
||||
* 控制是否开启动画
|
||||
* false: 关闭所有动画
|
||||
* true: 开启所有动画
|
||||
* AnimationConfig: 配置部分动画开启
|
||||
*/
|
||||
animation?: boolean | Partial<AnimationConfig>;
|
||||
} & EditConfigInterface;
|
||||
export declare const defaults: {
|
||||
background: boolean;
|
||||
grid: boolean;
|
||||
textEdit: boolean;
|
||||
disabledTools: any[];
|
||||
};
|
||||
export {};
|
||||
@@ -0,0 +1,20 @@
|
||||
import { h, Component } from 'preact';
|
||||
import LogicFlow from '../LogicFlow';
|
||||
import GraphModel from '../model/GraphModel';
|
||||
declare type IProps = {
|
||||
graphModel: GraphModel;
|
||||
logicFlow: LogicFlow;
|
||||
};
|
||||
export default class MultipleSelect extends Component<IProps> {
|
||||
static toolName: string;
|
||||
stepDrag: any;
|
||||
constructor(props: any);
|
||||
handleMouseDown: (ev: MouseEvent) => void;
|
||||
onDraging: ({ deltaX, deltaY }: {
|
||||
deltaX: any;
|
||||
deltaY: any;
|
||||
}) => void;
|
||||
handleContextMenu: (ev: MouseEvent) => void;
|
||||
render(): h.JSX.Element;
|
||||
}
|
||||
export {};
|
||||
@@ -0,0 +1,3 @@
|
||||
import EventEmitter from '../event/eventEmitter';
|
||||
import SnaplineModel from '../model/SnaplineModel';
|
||||
export declare function snaplineTool(eventCenter: EventEmitter, snaplineModel: SnaplineModel): void;
|
||||
@@ -0,0 +1,34 @@
|
||||
import { h, Component } from 'preact';
|
||||
import LogicFlow from '../LogicFlow';
|
||||
import GraphModel from '../model/GraphModel';
|
||||
declare type Style = {
|
||||
left: number;
|
||||
top: number;
|
||||
};
|
||||
declare type IProps = {
|
||||
graphModel: GraphModel;
|
||||
logicFlow: LogicFlow;
|
||||
};
|
||||
declare type IState = {
|
||||
style: Style;
|
||||
};
|
||||
export default class TextEdit extends Component<IProps, IState> {
|
||||
static toolName: string;
|
||||
ref: import("preact").RefObject<any>;
|
||||
__prevText: {
|
||||
type: string;
|
||||
text: string;
|
||||
id: string;
|
||||
};
|
||||
constructor();
|
||||
componentDidMount(): void;
|
||||
static getDerivedStateFromProps(props: any): {
|
||||
style: any;
|
||||
};
|
||||
componentDidUpdate(): void;
|
||||
keyupHandler: (ev: any) => void;
|
||||
inputHandler: (ev: any) => void;
|
||||
placeCaretAtEnd(el: any): void;
|
||||
render(): h.JSX.Element;
|
||||
}
|
||||
export {};
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
import { Component } from 'preact';
|
||||
import LogicFlow from '../LogicFlow';
|
||||
export default class Tool {
|
||||
tools: Component[];
|
||||
components: Component[];
|
||||
toolMap: Map<any, any>;
|
||||
instance: LogicFlow;
|
||||
constructor(instance: LogicFlow);
|
||||
private isDisabledTool;
|
||||
registerTool(name: any, component: any): void;
|
||||
getTools(): any[];
|
||||
getInstance(): LogicFlow;
|
||||
}
|
||||
+385
@@ -0,0 +1,385 @@
|
||||
import { h } from 'preact';
|
||||
import LogicFlow from '../LogicFlow';
|
||||
import BaseEdge from '../view/edge/BaseEdge';
|
||||
import BaseEdgeModel from '../model/edge/BaseEdgeModel';
|
||||
import BaseNode from '../view/node/BaseNode';
|
||||
import BaseNodeModel from '../model/node/BaseNodeModel';
|
||||
import RectNodeModel from '../model/node/RectNodeModel';
|
||||
import RectNode from '../view/node/RectNode';
|
||||
import CircleNode from '../view/node/CircleNode';
|
||||
import CircleNodeModel from '../model/node/CircleNodeModel';
|
||||
import DiamondNode from '../view/node/DiamondNode';
|
||||
import DiamondNodeModel from '../model/node/DiamondNodeModel';
|
||||
import PolygonNode from '../view/node/PolygonNode';
|
||||
import PolygonNodeModel from '../model/node/PolygonNodeModel';
|
||||
import TextNodeModel from '../model/node/TextNodeModel';
|
||||
import TextNode from '../view/node/TextNode';
|
||||
import LineEdge from '../view/edge/LineEdge';
|
||||
import LineEdgeModel from '../model/edge/LineEdgeModel';
|
||||
import PolylineEdge from '../view/edge/PolylineEdge';
|
||||
import PolylineEdgeModel from '../model/edge/PolylineEdgeModel';
|
||||
import EllipseNode from '../view/node/EllipseNode';
|
||||
import EllipseNodeModel from '../model/node/EllipseNodeModel';
|
||||
import HtmlNode from '../view/node/HtmlNode';
|
||||
import HtmlNodeModel from '../model/node/HtmlNodeModel';
|
||||
import * as Options from '../options';
|
||||
import { CommonTheme, EdgeTextTheme } from '../constant/DefaultTheme';
|
||||
export declare type PointTuple = [number, number];
|
||||
export declare type Point = {
|
||||
id?: string;
|
||||
x: number;
|
||||
y: number;
|
||||
[key: string]: unknown;
|
||||
};
|
||||
/**
|
||||
* 锚点坐标
|
||||
* 为了方便计算
|
||||
* 锚点的位置都是相对于节点中心点的偏移量。
|
||||
*/
|
||||
export declare type PointAnchor = {
|
||||
/**
|
||||
* 锚点x轴相对于中心点的偏移量
|
||||
*/
|
||||
x: number;
|
||||
/**
|
||||
* 锚点y轴相对于中心点的偏移量
|
||||
*/
|
||||
y: number;
|
||||
/**
|
||||
* 锚点Id
|
||||
*/
|
||||
id?: string;
|
||||
[key: string]: unknown;
|
||||
};
|
||||
export declare type AnchorsOffsetItem = PointTuple | PointAnchor;
|
||||
export declare type Size = {
|
||||
width: number;
|
||||
height: number;
|
||||
};
|
||||
export declare type TextConfig = {
|
||||
value: string;
|
||||
} & Point;
|
||||
export declare type GraphConfigData = {
|
||||
nodes: NodeConfig[];
|
||||
edges: EdgeConfig[];
|
||||
};
|
||||
export declare type NodeConfig = {
|
||||
id?: string;
|
||||
type: string;
|
||||
x: number;
|
||||
y: number;
|
||||
text?: TextConfig | string;
|
||||
zIndex?: number;
|
||||
properties?: Record<string, unknown>;
|
||||
};
|
||||
export declare type NodeData = {
|
||||
id: string;
|
||||
type: string;
|
||||
x: number;
|
||||
y: number;
|
||||
text?: TextConfig;
|
||||
properties: Record<string, unknown>;
|
||||
zIndex?: number;
|
||||
[key: string]: any;
|
||||
};
|
||||
export declare type NodeAttribute = {
|
||||
id: string;
|
||||
type?: string;
|
||||
x?: number;
|
||||
y?: number;
|
||||
text?: TextConfig;
|
||||
properties?: Record<string, unknown>;
|
||||
};
|
||||
export declare type MenuConfig = {
|
||||
text?: string;
|
||||
className?: string;
|
||||
icon?: boolean;
|
||||
callback: (id: any) => void;
|
||||
};
|
||||
export declare type AdditionData = Record<string, unknown>;
|
||||
export declare type EdgeData = {
|
||||
id: string;
|
||||
type: string;
|
||||
sourceNodeId: string;
|
||||
startPoint: Point;
|
||||
targetNodeId: string;
|
||||
endPoint: Point;
|
||||
text?: TextConfig;
|
||||
properties: Record<string, unknown>;
|
||||
zIndex?: number;
|
||||
pointsList?: Point[];
|
||||
};
|
||||
export declare type EdgeAttribute = {
|
||||
id: string;
|
||||
type?: string;
|
||||
sourceNodeId?: string;
|
||||
startPoint?: Point;
|
||||
targetNodeId?: string;
|
||||
endPoint?: Point;
|
||||
text?: TextConfig;
|
||||
properties?: Record<string, unknown>;
|
||||
};
|
||||
export declare type EdgeFilter = {
|
||||
id?: string;
|
||||
sourceNodeId?: string;
|
||||
targetNodeId?: string;
|
||||
};
|
||||
export declare type EdgeConfig = {
|
||||
id?: string;
|
||||
/**
|
||||
* 边的类型,不传默认为lf.setDefaultEdgeType(type)传入的类型。
|
||||
* LogicFlow内部默认为polyline
|
||||
*/
|
||||
type?: string;
|
||||
sourceNodeId: string;
|
||||
sourceAnchorId?: string;
|
||||
targetNodeId: string;
|
||||
targetAnchorId?: string;
|
||||
startPoint?: {
|
||||
x: number;
|
||||
y: number;
|
||||
};
|
||||
endPoint?: {
|
||||
x: number;
|
||||
y: number;
|
||||
};
|
||||
text?: {
|
||||
x: number;
|
||||
y: number;
|
||||
value: string;
|
||||
} | string;
|
||||
pointsList?: Point[];
|
||||
zIndex?: number;
|
||||
properties?: Record<string, unknown>;
|
||||
};
|
||||
declare type LeftTopX = number;
|
||||
declare type LeftTopY = number;
|
||||
declare type RightBottomX = number;
|
||||
declare type RightBottomY = number;
|
||||
export declare type Bounds = {
|
||||
x1: LeftTopX;
|
||||
y1: LeftTopY;
|
||||
x2: RightBottomX;
|
||||
y2: RightBottomY;
|
||||
};
|
||||
export declare type CommonStyle = {
|
||||
fill?: string;
|
||||
stroke?: string;
|
||||
strokeWidth?: number;
|
||||
fillOpacity?: number;
|
||||
strokeOpacity?: number;
|
||||
opacity?: number;
|
||||
outlineColor?: string;
|
||||
outlineStrokeDashArray?: string;
|
||||
};
|
||||
export declare type RectStyle = CommonStyle & {
|
||||
width?: number;
|
||||
height?: number;
|
||||
radius?: number;
|
||||
};
|
||||
export declare type CircleStyle = CommonStyle & {
|
||||
r?: number;
|
||||
};
|
||||
export declare type EllipseStyle = CommonStyle & {
|
||||
rx?: number;
|
||||
ry?: number;
|
||||
};
|
||||
export declare type DiamondStyle = CommonStyle;
|
||||
export declare type PolygonStyle = CommonStyle;
|
||||
export declare type AnchorStyle = CommonStyle & {
|
||||
stroke?: string;
|
||||
strokeWidth?: number;
|
||||
r?: number;
|
||||
};
|
||||
export declare type AnchorLineStyle = {
|
||||
stroke?: string;
|
||||
strokeWidth?: number;
|
||||
strokeDasharray?: string;
|
||||
};
|
||||
export declare type AnchorHoverStyle = {
|
||||
fill?: string;
|
||||
fillOpacity?: number;
|
||||
stroke?: string;
|
||||
strokeWidth?: number;
|
||||
r?: number;
|
||||
};
|
||||
export declare type EdgeStyle = {
|
||||
stroke?: string;
|
||||
strokeWidth?: number;
|
||||
strokeDashArray?: string;
|
||||
hoverStroke?: string;
|
||||
selectedStroke?: string;
|
||||
outlineColor?: string;
|
||||
outlineStrokeDashArray?: string;
|
||||
};
|
||||
export declare type LineStyle = EdgeStyle;
|
||||
export declare type PolylineStyle = EdgeStyle & {
|
||||
offset?: number;
|
||||
};
|
||||
export declare type BezierStyle = EdgeStyle & {
|
||||
offset?: number;
|
||||
adjustLineColor?: string;
|
||||
adjustAnchorStroke?: string;
|
||||
adjustAnchorFill?: string;
|
||||
adjustAnchorFillOpacity?: number;
|
||||
};
|
||||
export declare type TextStyle = {
|
||||
color?: string;
|
||||
fontSize?: number;
|
||||
fontWeight?: string;
|
||||
fontFamily?: string;
|
||||
};
|
||||
export declare type NodeTextStyle = TextStyle & {
|
||||
lineHeight?: number;
|
||||
wrapPadding?: string;
|
||||
};
|
||||
export declare type EdgeTextStyle = TextStyle & EdgeTextTheme;
|
||||
export declare type ArrowStyle = {
|
||||
offset?: number;
|
||||
verticalLength?: number;
|
||||
};
|
||||
export declare type EdgeAdjustStyle = {
|
||||
r: number;
|
||||
fill?: string;
|
||||
stroke?: string;
|
||||
};
|
||||
export declare type GraphTransform = {
|
||||
transform: string;
|
||||
transformOrigin: string;
|
||||
};
|
||||
export declare type EventArgs = Record<string, number | object | string>;
|
||||
export declare type FocusOnArgs = {
|
||||
id?: string;
|
||||
coordinate?: {
|
||||
x: number;
|
||||
y: number;
|
||||
};
|
||||
};
|
||||
export declare type ComponentRender = (lf: LogicFlow, container: HTMLElement) => void;
|
||||
export interface Extension {
|
||||
pluginName: string;
|
||||
install?: (lf: LogicFlow, LogicFlow: LogicFlowContractor) => void;
|
||||
render?: ComponentRender;
|
||||
destroy?: () => void;
|
||||
[props: string]: any;
|
||||
}
|
||||
export declare type Direction = 'vertical' | 'horizontal';
|
||||
export declare type AppendInfo = {
|
||||
start: Point;
|
||||
end: Point;
|
||||
startIndex?: number;
|
||||
endIndex?: number;
|
||||
direction?: string;
|
||||
dragAble?: boolean;
|
||||
};
|
||||
export declare type ArrowInfo = {
|
||||
start: Point;
|
||||
end: Point;
|
||||
hover: Boolean;
|
||||
isSelected: Boolean;
|
||||
};
|
||||
export declare type IEdgeState = {
|
||||
hover: boolean;
|
||||
};
|
||||
export interface ModelContractor {
|
||||
new (data: any, graphModel: any): unknown;
|
||||
}
|
||||
export interface LogicFlowContractor {
|
||||
new (option: Options.Definition): LogicFlow;
|
||||
}
|
||||
export interface ExtensionContractor {
|
||||
pluginName: string;
|
||||
new ({ lf: LogicFlow, LogicFlow: LogicFlowContractor, }: {
|
||||
lf: any;
|
||||
LogicFlow: any;
|
||||
}): any;
|
||||
render?: Function;
|
||||
}
|
||||
export declare type RegisterBack = {
|
||||
view: Function;
|
||||
model: Function;
|
||||
};
|
||||
export interface RegisterParam {
|
||||
h: typeof h;
|
||||
BaseEdge: typeof BaseEdge;
|
||||
BaseEdgeModel: typeof BaseEdgeModel;
|
||||
BaseNode: typeof BaseNode;
|
||||
BaseNodeModel: typeof BaseNodeModel;
|
||||
RectNode: typeof RectNode;
|
||||
RectNodeModel: typeof RectNodeModel;
|
||||
CircleNode: typeof CircleNode;
|
||||
CircleNodeModel: typeof CircleNodeModel;
|
||||
DiamondNode: typeof DiamondNode;
|
||||
DiamondNodeModel: typeof DiamondNodeModel;
|
||||
PolygonNode: typeof PolygonNode;
|
||||
PolygonNodeModel: typeof PolygonNodeModel;
|
||||
TextNode: typeof TextNode;
|
||||
TextNodeModel: typeof TextNodeModel;
|
||||
LineEdge: typeof LineEdge;
|
||||
LineEdgeModel: typeof LineEdgeModel;
|
||||
PolylineEdge: typeof PolylineEdge;
|
||||
PolylineEdgeModel: typeof PolylineEdgeModel;
|
||||
EllipseNode: typeof EllipseNode;
|
||||
EllipseNodeModel: typeof EllipseNodeModel;
|
||||
HtmlNode: typeof HtmlNode;
|
||||
HtmlNodeModel: typeof HtmlNodeModel;
|
||||
[key: string]: unknown;
|
||||
}
|
||||
export declare type RegisterElementFn = (params: RegisterParam) => RegisterBack;
|
||||
export declare type RegisterConfig = {
|
||||
type: string;
|
||||
view: any;
|
||||
model: any;
|
||||
isObserverView?: boolean;
|
||||
};
|
||||
export declare type AnchorConfig = {
|
||||
id?: string;
|
||||
x: number;
|
||||
y: number;
|
||||
[key: string]: any;
|
||||
};
|
||||
/**
|
||||
* 移动规则结果,可以支持允许水平移动,不允许垂直移动。
|
||||
* 在分组移动到边缘时有用到。
|
||||
*/
|
||||
export declare type IsAllowMove = {
|
||||
x: boolean;
|
||||
y: boolean;
|
||||
};
|
||||
/**
|
||||
* 限制节点移动规则
|
||||
* model: 移动节点的model
|
||||
* deltaX: 移动的x轴距离
|
||||
* deltaY: 移动的y轴距离
|
||||
*/
|
||||
export declare type NodeMoveRule = (model: BaseNodeModel, deltaX: number, deltaY: number) => Boolean | IsAllowMove;
|
||||
export declare type ZoomParam = boolean | number;
|
||||
export declare type NodeAttributes = {
|
||||
id: string;
|
||||
properties: Record<string, any>;
|
||||
type: string;
|
||||
x: number;
|
||||
y: number;
|
||||
isSelected: boolean;
|
||||
isHovered: boolean;
|
||||
width: number;
|
||||
height: number;
|
||||
text: {
|
||||
x: number;
|
||||
y: number;
|
||||
value: string;
|
||||
[key: string]: any;
|
||||
};
|
||||
[key: string]: any;
|
||||
};
|
||||
export declare type DiamondAttributes = {
|
||||
points: PointTuple[];
|
||||
} & NodeAttributes;
|
||||
export declare type ShapeStyleAttribute = CommonTheme;
|
||||
export declare type VirtualRectSize = {
|
||||
virtualRectWidth: number;
|
||||
virtualRectHeight: number;
|
||||
virtualRectCenterPositionX: number;
|
||||
virtualRectCenterPositionY: number;
|
||||
};
|
||||
export {};
|
||||
@@ -0,0 +1,2 @@
|
||||
import { AnimationConfig } from '../constant/DefaultAnimation';
|
||||
export declare const updateAnimation: (config: boolean | Partial<AnimationConfig>) => AnimationConfig;
|
||||
@@ -0,0 +1 @@
|
||||
export declare const isIe: boolean;
|
||||
@@ -0,0 +1 @@
|
||||
export declare const formatData: (data: any) => any;
|
||||
+44
@@ -0,0 +1,44 @@
|
||||
import EventEmitter from '../event/eventEmitter';
|
||||
import BaseEdgeModel from '../model/edge/BaseEdgeModel';
|
||||
import BaseNodeModel from '../model/node/BaseNodeModel';
|
||||
declare function createDrag({ onDragStart, onDraging, onDragEnd, step, isStopPropagation, }: {
|
||||
onDragStart?: (...args: any[]) => void;
|
||||
onDraging?: (...args: any[]) => void;
|
||||
onDragEnd?: (...args: any[]) => void;
|
||||
step?: number;
|
||||
isStopPropagation?: boolean;
|
||||
}): (e: MouseEvent) => void;
|
||||
declare class StepDrag {
|
||||
onDragStart: Function;
|
||||
onDraging: Function;
|
||||
onDragEnd: Function;
|
||||
step: number;
|
||||
isStopPropagation: boolean;
|
||||
isDraging: boolean;
|
||||
isStartDraging: boolean;
|
||||
startX: number;
|
||||
startY: number;
|
||||
sumDeltaX: number;
|
||||
sumDeltaY: number;
|
||||
eventType: string;
|
||||
eventCenter: EventEmitter | null;
|
||||
model?: BaseNodeModel | BaseEdgeModel;
|
||||
startTime?: number;
|
||||
isGrag: boolean;
|
||||
constructor({ onDragStart, onDraging, onDragEnd, eventType, eventCenter, step, isStopPropagation, model, }: {
|
||||
onDragStart?: (...args: any[]) => void;
|
||||
onDraging?: (...args: any[]) => void;
|
||||
onDragEnd?: (...args: any[]) => void;
|
||||
eventType?: string;
|
||||
eventCenter?: any;
|
||||
step?: number;
|
||||
isStopPropagation?: boolean;
|
||||
model?: any;
|
||||
});
|
||||
setStep(step: number): void;
|
||||
handleMouseDown: (e: MouseEvent) => void;
|
||||
handleMouseMove: (e: MouseEvent) => void;
|
||||
handleMouseUp: (e: MouseEvent) => void;
|
||||
cancelDrag: () => void;
|
||||
}
|
||||
export { createDrag, StepDrag, };
|
||||
+102
@@ -0,0 +1,102 @@
|
||||
import BaseNode from '../model/node/BaseNodeModel';
|
||||
import { Point, Direction, EdgeConfig } from '../type/index';
|
||||
export declare const setupEdgeModel: (edge: any, graphModel: any) => any;
|
||||
declare type PolyPoint = {
|
||||
x: number;
|
||||
y: number;
|
||||
id?: string;
|
||||
};
|
||||
declare type PolyPointMap = {
|
||||
[key: string]: PolyPoint;
|
||||
};
|
||||
declare type PolyPointLink = Record<PolyPoint['id'], PolyPoint['id']>;
|
||||
declare type PBBox = Partial<{
|
||||
x: number;
|
||||
y: number;
|
||||
minX: number;
|
||||
minY: number;
|
||||
maxX: number;
|
||||
maxY: number;
|
||||
height: number;
|
||||
width: number;
|
||||
centerX: number;
|
||||
centerY: number;
|
||||
}>;
|
||||
export declare const isBboxOverLapping: (b1: PBBox, b2: PBBox) => boolean;
|
||||
export declare const filterRepeatPoints: (points: PolyPoint[]) => PolyPoint[];
|
||||
export declare const getSimplePolyline: (sPoint: PolyPoint, tPoint: PolyPoint) => PolyPoint[];
|
||||
export declare const getExpandedBBox: (bbox: PBBox, offset: number) => PBBox;
|
||||
export declare const pointDirection: (point: PolyPoint, bbox: PBBox) => Direction;
|
||||
export declare const getExpandedBBoxPoint: (bbox: PBBox, point: PolyPoint) => PolyPoint;
|
||||
export declare const mergeBBox: (b1: PBBox, b2: PBBox) => PBBox;
|
||||
export declare const getBBoxOfPoints: (points?: PolyPoint[], offset?: number) => PBBox;
|
||||
export declare const getPointsFromBBox: (bbox: PBBox) => PolyPoint[];
|
||||
export declare const isPointOutsideBBox: (point: PolyPoint, bbox: PBBox) => boolean;
|
||||
export declare const getBBoxXCrossPoints: (bbox: PBBox, x: number) => PolyPoint[];
|
||||
export declare const getBBoxYCrossPoints: (bbox: PBBox, y: number) => PolyPoint[];
|
||||
export declare const getBBoxCrossPointsByPoint: (bbox: PBBox, point: PolyPoint) => PolyPoint[];
|
||||
export declare const estimateDistance: (p1: PolyPoint, p2: PolyPoint) => number;
|
||||
export declare const costByPoints: (p: PolyPoint, points: PolyPoint[]) => number;
|
||||
export declare const heuristicCostEstimate: (p: PolyPoint, ps: PolyPoint, pt: PolyPoint, source?: PolyPoint, target?: PolyPoint) => number;
|
||||
export declare const rebuildPath: (pathPoints: PolyPoint[], pointById: PolyPointMap, cameFrom: PolyPointLink, currentId: string, iterator?: number) => void;
|
||||
export declare const removeClosePointFromOpenList: (arr: PolyPoint[], item: PolyPoint) => void;
|
||||
export declare const isSegmentsIntersected: (p0: PolyPoint, p1: PolyPoint, p2: PolyPoint, p3: PolyPoint) => boolean;
|
||||
export declare const isSegmentCrossingBBox: (p1: PolyPoint, p2: PolyPoint, bbox: PBBox) => boolean;
|
||||
export declare const getNextNeighborPoints: (points: PolyPoint[], point: PolyPoint, bbox1: PBBox, bbox2: PBBox) => PolyPoint[];
|
||||
export declare const pathFinder: (points: PolyPoint[], start: PolyPoint, goal: PolyPoint, sBBox: PBBox, tBBox: PBBox, os: PolyPoint, ot: PolyPoint) => PolyPoint[];
|
||||
export declare const getBoxByOriginNode: (node: BaseNode) => PBBox;
|
||||
export declare const pointFilter: (points: PolyPoint[]) => PolyPoint[];
|
||||
export declare const getPolylinePoints: (start: PolyPoint, end: PolyPoint, sNode: BaseNode, tNode: BaseNode, offset: number) => PolyPoint[];
|
||||
/**
|
||||
* 获取折线中最长的一个线
|
||||
* @param pointsList 多个点组成的数组
|
||||
*/
|
||||
export declare const getLongestEdge: (pointsList: PolyPoint[]) => [PolyPoint, PolyPoint];
|
||||
export declare const isSegmentsInNode: (start: Point, end: Point, node: BaseNode) => boolean;
|
||||
export declare const isSegmentsCrossNode: (start: Point, end: Point, node: BaseNode) => boolean;
|
||||
export declare const getCrossPointInRect: (start: Point, end: Point, node: BaseNode) => Point;
|
||||
export declare const segmentDirection: (start: Point, end: Point) => Direction;
|
||||
export declare const points2PointsList: (points: string) => PolyPoint[];
|
||||
export declare const getSimplePoints: (start: any, end: any, sPoint: any, tPoint: any) => Point[];
|
||||
export declare const getBytesLength: (word: string) => number;
|
||||
export declare const getTextWidth: (text: any, font: any) => any;
|
||||
declare type AppendAttributesType = {
|
||||
d: string;
|
||||
fill: string;
|
||||
stroke: string;
|
||||
strokeWidth: number;
|
||||
strokeDasharray: string;
|
||||
};
|
||||
export declare const getAppendAttributes: (appendInfo: any) => AppendAttributesType;
|
||||
export declare type IBezierControls = {
|
||||
sNext: Point;
|
||||
ePre: Point;
|
||||
};
|
||||
export declare const getBezierControlPoints: ({ start, end, sourceNode, targetNode, offset, }: {
|
||||
start: any;
|
||||
end: any;
|
||||
sourceNode: any;
|
||||
targetNode: any;
|
||||
offset: any;
|
||||
}) => IBezierControls;
|
||||
export declare type IBezierPoints = {
|
||||
start: Point;
|
||||
sNext: Point;
|
||||
ePre: Point;
|
||||
end: Point;
|
||||
};
|
||||
export declare const getBezierPoints: (path: string) => Point[];
|
||||
export declare const getEndTangent: (path: string) => Point[];
|
||||
/**
|
||||
* 获取移动边后,文本位置距离边上的最近的一点
|
||||
* @param point 边上文本的位置
|
||||
* @param points 边的各个拐点
|
||||
*/
|
||||
export declare const getClosestPointOfPolyline: (point: Point, points: string) => Point;
|
||||
export declare const pickEdgeConfig: (data: any) => EdgeConfig;
|
||||
declare type Position = {
|
||||
x: number;
|
||||
y: number;
|
||||
};
|
||||
export declare const twoPointDistance: (source: Position, target: Position) => number;
|
||||
export {};
|
||||
@@ -0,0 +1,2 @@
|
||||
export declare function snapToGrid(distance: number, gridSize: number): number;
|
||||
export declare function getGridOffset(distance: number, gridSize: number): number;
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
export declare const getById: (id: any, data: any) => any;
|
||||
/**
|
||||
* 判断一个点是否在指定区域
|
||||
* @param point 当前点
|
||||
* @param leftTopPoint 区域左上角点
|
||||
* @param rightBottomPoint 区域的右下角点
|
||||
*/
|
||||
export declare const isPointInArea: ([x, y]: [any, any], [leftTopX, leftTopY]: [any, any], [rightBottomX, rightBottomY]: [any, any]) => boolean;
|
||||
/**
|
||||
* 判断鼠标点击选中元素的时候,是否为多选
|
||||
*/
|
||||
export declare const isMultipleSelect: (e: MouseEvent, editConfigModel: any) => boolean;
|
||||
@@ -0,0 +1,2 @@
|
||||
export * from './uuid';
|
||||
export * from './drag';
|
||||
+65
@@ -0,0 +1,65 @@
|
||||
import BaseNode from '../model/node/BaseNodeModel';
|
||||
import { Point, Direction, NodeConfig, AnchorConfig } from '../type';
|
||||
import { GraphModel } from '..';
|
||||
export declare const getAnchors: (data: any) => Point[];
|
||||
declare type NodeContaint = {
|
||||
node: BaseNode;
|
||||
anchorIndex: number;
|
||||
anchor: AnchorConfig;
|
||||
};
|
||||
export declare const targetNodeInfo: (position: Point, graphModel: GraphModel) => NodeContaint;
|
||||
export declare const distance: (x1: number, y1: number, x2: number, y2: number) => number;
|
||||
export declare const isInNode: (position: Point, node: BaseNode) => boolean;
|
||||
export declare const isInNodeBbox: (position: Point, node: any) => boolean;
|
||||
export declare type NodeBBox = {
|
||||
x: number;
|
||||
y: number;
|
||||
width: number;
|
||||
height: number;
|
||||
minX: number;
|
||||
minY: number;
|
||||
maxX: number;
|
||||
maxY: number;
|
||||
centerX: number;
|
||||
centerY: number;
|
||||
};
|
||||
export declare const getNodeBBox: (node: BaseNode) => NodeBBox;
|
||||
declare type RadiusCircle = {
|
||||
x: number;
|
||||
y: number;
|
||||
r: number;
|
||||
};
|
||||
export declare const getRectRadiusCircle: (node: BaseNode) => RadiusCircle[];
|
||||
export declare const getClosestRadiusCenter: (point: Point, direction: Direction, node: BaseNode) => Point;
|
||||
export declare const getCrossPointWithCircle: (point: Point, direction: Direction, node: BaseNode) => Point;
|
||||
export declare const pointEdgeDirection: (point: Point, node: BaseNode) => Direction;
|
||||
export declare const inStraightLineOfRect: (point: Point, node: BaseNode) => boolean;
|
||||
export declare const getCrossPointWithEllipse: (point: Point, direction: Direction, node: BaseNode) => any;
|
||||
export declare const getCrossPointWithPolyone: (point: Point, direction: Direction, node: BaseNode) => Point;
|
||||
export declare const pickNodeConfig: (data: any) => NodeConfig;
|
||||
/**
|
||||
* 基于节点的边,重新获取新的节点
|
||||
*/
|
||||
export declare const getNodeAnchorPosition: (center: any, point: any, width: any, height: any) => {
|
||||
x: any;
|
||||
y: any;
|
||||
};
|
||||
export declare const getHtmlTextHeight: ({ rows, style, rowsLength, className }: {
|
||||
rows: any;
|
||||
style: any;
|
||||
rowsLength: any;
|
||||
className: any;
|
||||
}) => number;
|
||||
export declare const getSvgTextWidthHeight: ({ rows, rowsLength, fontSize }: {
|
||||
rows: any;
|
||||
rowsLength: any;
|
||||
fontSize: any;
|
||||
}) => {
|
||||
width: number;
|
||||
height: number;
|
||||
};
|
||||
/**
|
||||
* @description 格式化边校验信息
|
||||
*/
|
||||
export declare const formateAnchorConnectValidateData: (data: any) => any;
|
||||
export {};
|
||||
@@ -0,0 +1,2 @@
|
||||
export declare const createRaf: (callback: any) => string;
|
||||
export declare const cancelRaf: (rafId: any) => void;
|
||||
@@ -0,0 +1,2 @@
|
||||
import { Theme } from '../constant/DefaultTheme';
|
||||
export declare const updateTheme: (style: Theme) => Theme;
|
||||
@@ -0,0 +1,6 @@
|
||||
import { GraphConfigData } from '..';
|
||||
export declare const createUuid: () => string;
|
||||
/**
|
||||
* 重新刷新流程图的所有id
|
||||
*/
|
||||
export declare const refreshGraphId: (graphData: GraphConfigData, prefix?: string) => GraphConfigData;
|
||||
@@ -0,0 +1,2 @@
|
||||
export declare const getZIndex: () => number;
|
||||
export declare const getMinIndex: () => number;
|
||||
@@ -0,0 +1,46 @@
|
||||
import { h, Component } from 'preact';
|
||||
import { StepDrag } from '../util/drag';
|
||||
import BaseNodeModel, { ConnectRuleResult } from '../model/node/BaseNodeModel';
|
||||
import GraphModel from '../model/GraphModel';
|
||||
import { AnchorConfig } from '../type';
|
||||
import { BaseNode } from './node';
|
||||
declare type TargetNodeId = string;
|
||||
interface IProps {
|
||||
anchorData: AnchorConfig;
|
||||
node: BaseNode;
|
||||
style?: Record<string, any>;
|
||||
hoverStyle?: Record<string, any>;
|
||||
edgeStyle?: Record<string, any>;
|
||||
anchorIndex: number;
|
||||
graphModel: GraphModel;
|
||||
nodeModel: BaseNodeModel;
|
||||
setHoverOFF: Function;
|
||||
}
|
||||
interface IState {
|
||||
startX: number;
|
||||
startY: number;
|
||||
endX: number;
|
||||
endY: number;
|
||||
draging: boolean;
|
||||
}
|
||||
declare class Anchor extends Component<IProps, IState> {
|
||||
preTargetNode: BaseNodeModel;
|
||||
sourceRuleResults: Map<TargetNodeId, ConnectRuleResult>;
|
||||
targetRuleResults: Map<TargetNodeId, ConnectRuleResult>;
|
||||
dragHandler: StepDrag;
|
||||
t: any;
|
||||
constructor();
|
||||
getAnchorShape(): h.JSX.Element;
|
||||
onDragStart: ({ event }: {
|
||||
event: any;
|
||||
}) => void;
|
||||
onDraging: ({ event }: {
|
||||
event: any;
|
||||
}) => void;
|
||||
onDragEnd: (event: any) => void;
|
||||
checkEnd: () => void;
|
||||
moveAnchorEnd(endX: number, endY: number): void;
|
||||
isShowLine(): boolean;
|
||||
render(): h.JSX.Element;
|
||||
}
|
||||
export default Anchor;
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
import { Component, h } from 'preact';
|
||||
import GraphModel from '../model/GraphModel';
|
||||
import Tool from '../tool';
|
||||
import * as Options from '../options';
|
||||
import DnD from './behavior/DnD';
|
||||
import BaseEdgeModel from '../model/edge/BaseEdgeModel';
|
||||
import BaseNodeModel from '../model/node/BaseNodeModel';
|
||||
import SnaplineModel from '../model/SnaplineModel';
|
||||
declare type IProps = {
|
||||
getView: (type: string) => typeof Component;
|
||||
tool: Tool;
|
||||
options: Options.Definition;
|
||||
dnd: DnD;
|
||||
snaplineModel: SnaplineModel;
|
||||
graphModel: GraphModel;
|
||||
};
|
||||
declare class Graph extends Component<IProps> {
|
||||
getComponent(model: BaseEdgeModel | BaseNodeModel, graphModel: GraphModel, overlay?: string): h.JSX.Element;
|
||||
render(): h.JSX.Element;
|
||||
}
|
||||
export default Graph;
|
||||
@@ -0,0 +1,2 @@
|
||||
import { h } from 'preact';
|
||||
export default function Circle(props: any): h.JSX.Element;
|
||||
@@ -0,0 +1,2 @@
|
||||
import { h } from 'preact';
|
||||
export default function Ellipse(props: any): h.JSX.Element;
|
||||
@@ -0,0 +1,3 @@
|
||||
import { h } from 'preact';
|
||||
declare function Line(props: any): h.JSX.Element;
|
||||
export default Line;
|
||||
@@ -0,0 +1 @@
|
||||
export default function Rect(props: any): void;
|
||||
@@ -0,0 +1,7 @@
|
||||
import { h } from 'preact';
|
||||
declare type IProps = {
|
||||
d: string;
|
||||
[key: string]: any;
|
||||
};
|
||||
declare function Path(props: IProps): h.JSX.Element;
|
||||
export default Path;
|
||||
@@ -0,0 +1,2 @@
|
||||
import { h } from 'preact';
|
||||
export default function Polygon(props: any): h.JSX.Element;
|
||||
@@ -0,0 +1,3 @@
|
||||
import { h } from 'preact';
|
||||
declare function Polyline(props: any): h.JSX.Element;
|
||||
export default Polyline;
|
||||
@@ -0,0 +1,14 @@
|
||||
import { h } from 'preact';
|
||||
import * as type from '../../type';
|
||||
declare type IProps = {
|
||||
className?: string;
|
||||
radius?: number;
|
||||
} & type.Point & type.Size;
|
||||
declare function Rect(props: IProps): h.JSX.Element;
|
||||
declare namespace Rect {
|
||||
var defaultProps: {
|
||||
className: string;
|
||||
radius: string;
|
||||
};
|
||||
}
|
||||
export default Rect;
|
||||
@@ -0,0 +1,2 @@
|
||||
import { h } from 'preact';
|
||||
export default function Text(props: any): h.JSX.Element;
|
||||
@@ -0,0 +1 @@
|
||||
export default function Rect(props: any): void;
|
||||
@@ -0,0 +1,35 @@
|
||||
import LogicFlow from '../../LogicFlow';
|
||||
import { BaseNodeModel } from '../../model';
|
||||
import { TextConfig } from '../../type';
|
||||
export declare type NewNodeConfig = {
|
||||
type: string;
|
||||
text?: TextConfig | string;
|
||||
properties?: Record<string, unknown>;
|
||||
[key: string]: any;
|
||||
};
|
||||
export default class Dnd {
|
||||
nodeConfig: NewNodeConfig;
|
||||
lf: LogicFlow;
|
||||
fakerNode: BaseNodeModel;
|
||||
constructor(params: any);
|
||||
clientToLocalPoint({ x, y }: {
|
||||
x: any;
|
||||
y: any;
|
||||
}): {
|
||||
x: number;
|
||||
y: number;
|
||||
};
|
||||
startDrag(nodeConfig: NewNodeConfig): void;
|
||||
stopDrag: () => void;
|
||||
dragEnter: (e: any) => void;
|
||||
onDragOver: (e: any) => boolean;
|
||||
onDragLeave: () => void;
|
||||
onDrop: (e: any) => void;
|
||||
eventMap(): {
|
||||
onMouseEnter: (e: any) => void;
|
||||
onMouseOver: (e: any) => void;
|
||||
onMouseMove: (e: any) => boolean;
|
||||
onMouseLeave: () => void;
|
||||
onMouseUp: (e: any) => void;
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
import { h, Component } from 'preact';
|
||||
export default class TransfromGraph extends Component {
|
||||
render(): h.JSX.Element;
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
import { h, Component } from 'preact';
|
||||
export default class TransfromGraph extends Component {
|
||||
render(): h.JSX.Element;
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
import { h, Component } from 'preact';
|
||||
import { BaseEdgeModel } from '../../model/edge';
|
||||
import GraphModel from '../../model/GraphModel';
|
||||
import { Point } from '../../type';
|
||||
interface IProps {
|
||||
x: number;
|
||||
y: number;
|
||||
type: AdjustType;
|
||||
id?: string;
|
||||
graphModel: GraphModel;
|
||||
edgeModel: BaseEdgeModel;
|
||||
}
|
||||
interface IState {
|
||||
draging: boolean;
|
||||
endX: number;
|
||||
endY: number;
|
||||
}
|
||||
interface OldEdge {
|
||||
startPoint: Point;
|
||||
endPoint: Point;
|
||||
pointsList: Point[];
|
||||
}
|
||||
declare enum AdjustType {
|
||||
SOURCE = "SOURCE",
|
||||
TARGET = "TARGET"
|
||||
}
|
||||
export default class AdjustPoint extends Component<IProps, IState> {
|
||||
dragHandler: Function;
|
||||
oldEdge: OldEdge;
|
||||
preTargetNode: any;
|
||||
targetRuleResults: Map<any, any>;
|
||||
sourceRuleResults: Map<any, any>;
|
||||
constructor();
|
||||
onDragStart: () => void;
|
||||
onDraging: ({ deltaX, deltaY }: {
|
||||
deltaX: any;
|
||||
deltaY: any;
|
||||
}) => void;
|
||||
onDragEnd: () => void;
|
||||
recoveryEdge: () => void;
|
||||
getAdjustPointStyle: () => import("../../constant/DefaultTheme").CircleTheme;
|
||||
isAllowAdjust(info: any): any;
|
||||
render(): h.JSX.Element;
|
||||
}
|
||||
export {};
|
||||
@@ -0,0 +1,22 @@
|
||||
import { h, Component } from 'preact';
|
||||
import { ArrowInfo } from '../../type/index';
|
||||
export declare type ArrowStyle = {
|
||||
stroke?: string;
|
||||
fill?: string;
|
||||
strokeWidth?: number;
|
||||
offset: number;
|
||||
verticalLength: number;
|
||||
};
|
||||
declare type ArrowAttributesType = {
|
||||
d: string;
|
||||
} & ArrowStyle;
|
||||
declare type IProps = {
|
||||
arrowInfo: ArrowInfo;
|
||||
style: ArrowStyle;
|
||||
};
|
||||
export default class Arrow extends Component<IProps> {
|
||||
getArrowAttributes(): ArrowAttributesType;
|
||||
getShape(): h.JSX.Element;
|
||||
render(): h.JSX.Element;
|
||||
}
|
||||
export {};
|
||||
@@ -0,0 +1,34 @@
|
||||
import { h, Component } from 'preact';
|
||||
import { ArrowStyle } from './Arrow';
|
||||
import BaseEdgeModel from '../../model/edge/BaseEdgeModel';
|
||||
import GraphModel from '../../model/GraphModel';
|
||||
import { ArrowInfo } from '../../type/index';
|
||||
declare type IProps = {
|
||||
model: BaseEdgeModel;
|
||||
graphModel: GraphModel;
|
||||
};
|
||||
export default class BaseEdge extends Component<IProps> {
|
||||
startTime: number;
|
||||
contextMenuTime: number;
|
||||
clickTimer: number;
|
||||
getShape(): void;
|
||||
getTextStyle(): void;
|
||||
getText(): "" | h.JSX.Element;
|
||||
getArrowInfo(): ArrowInfo;
|
||||
getArrowStyle(): ArrowStyle;
|
||||
getArrow(): h.JSX.Element;
|
||||
getAdjustPoints(): h.JSX.Element;
|
||||
getAnimation(): void;
|
||||
getAppendWidth(): h.JSX.Element;
|
||||
getAppend(): h.JSX.Element;
|
||||
handleHover: (hovered: any, ev: any) => void;
|
||||
setHoverON: (ev: any) => void;
|
||||
setHoverOFF: (ev: any) => void;
|
||||
handleContextMenu: (ev: MouseEvent) => void;
|
||||
handleMouseDown: (e: any) => void;
|
||||
handleMouseUp: (e: MouseEvent) => void;
|
||||
getIsDraging: () => boolean;
|
||||
toFront(): void;
|
||||
render(): h.JSX.Element;
|
||||
}
|
||||
export {};
|
||||
@@ -0,0 +1,10 @@
|
||||
import { h } from 'preact';
|
||||
import BaseEdge from './BaseEdge';
|
||||
import { ArrowInfo } from '../../type/index';
|
||||
export default class BezierEdge extends BaseEdge {
|
||||
getEdge(): h.JSX.Element;
|
||||
getShape(): h.JSX.Element;
|
||||
getAnimation(): h.JSX.Element;
|
||||
getAppendWidth(): h.JSX.Element;
|
||||
getArrowInfo(): ArrowInfo;
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
import { h } from 'preact';
|
||||
import BaseEdge from './BaseEdge';
|
||||
export default class LineEdge extends BaseEdge {
|
||||
getEdge(): h.JSX.Element;
|
||||
getShape(): h.JSX.Element;
|
||||
getAnimation(): h.JSX.Element;
|
||||
getAppendWidth(): h.JSX.Element;
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
import { h } from 'preact';
|
||||
import BaseEdge from './BaseEdge';
|
||||
import { AppendInfo, ArrowInfo } from '../../type/index';
|
||||
declare type AppendAttributesType = {
|
||||
d: string;
|
||||
fill: string;
|
||||
stroke: string;
|
||||
strokeWidth: number;
|
||||
strokeDasharray: string;
|
||||
};
|
||||
export default class PolylineEdge extends BaseEdge {
|
||||
drag: any;
|
||||
isDraging: boolean;
|
||||
appendInfo: AppendInfo;
|
||||
dragHandler: (ev: MouseEvent) => void;
|
||||
constructor();
|
||||
onDragStart: () => void;
|
||||
onDraging: ({ deltaX, deltaY }: {
|
||||
deltaX: any;
|
||||
deltaY: any;
|
||||
}) => void;
|
||||
onDragEnd: () => void;
|
||||
beforeDragStart: (e: any, appendInfo: any) => void;
|
||||
getIsDraging: () => boolean;
|
||||
getEdge(): h.JSX.Element;
|
||||
getShape(): h.JSX.Element;
|
||||
getAnimation(): h.JSX.Element;
|
||||
getArrowInfo(): ArrowInfo;
|
||||
getAppendAttributes(appendInfo: AppendInfo): AppendAttributesType;
|
||||
getAppendShape(appendInfo: AppendInfo): h.JSX.Element;
|
||||
getAppendWidth(): h.JSX.Element;
|
||||
}
|
||||
export {};
|
||||
@@ -0,0 +1,6 @@
|
||||
import BaseEdge from './BaseEdge';
|
||||
import LineEdge from './LineEdge';
|
||||
import PolylineEdge from './PolylineEdge';
|
||||
import BezierEdge from './BezierEdge';
|
||||
import Arrow from './Arrow';
|
||||
export { BaseEdge, LineEdge, PolylineEdge, BezierEdge, Arrow };
|
||||
@@ -0,0 +1,2 @@
|
||||
export * from './node';
|
||||
export * from './edge';
|
||||
@@ -0,0 +1,52 @@
|
||||
import { h, Component } from 'preact';
|
||||
import GraphModel from '../../model/GraphModel';
|
||||
import BaseNodeModel from '../../model/node/BaseNodeModel';
|
||||
import { StepDrag } from '../../util/drag';
|
||||
declare type IProps = {
|
||||
model: BaseNodeModel;
|
||||
graphModel: GraphModel;
|
||||
};
|
||||
declare type Istate = {
|
||||
isHovered: boolean;
|
||||
isDraging?: boolean;
|
||||
};
|
||||
export default abstract class BaseNode extends Component<IProps, Istate> {
|
||||
t: any;
|
||||
moveOffset: {
|
||||
x: number;
|
||||
y: number;
|
||||
};
|
||||
static getModel(defaultModel: any): any;
|
||||
stepDrag: StepDrag;
|
||||
contextMenuTime: number;
|
||||
startTime: number;
|
||||
clickTimer: number;
|
||||
constructor(props: any);
|
||||
abstract getShape(): any;
|
||||
getAnchorShape(anchorData: any): h.JSX.Element;
|
||||
getAnchors(): h.JSX.Element[];
|
||||
getText(): "" | h.JSX.Element;
|
||||
getStateClassName(): string;
|
||||
onDragStart: ({ event: { clientX, clientY } }: {
|
||||
event: {
|
||||
clientX: any;
|
||||
clientY: any;
|
||||
};
|
||||
}) => void;
|
||||
onDraging: ({ event }: {
|
||||
event: any;
|
||||
}) => void;
|
||||
onDragEnd: () => void;
|
||||
handleClick: (e: MouseEvent) => void;
|
||||
handleContextMenu: (ev: MouseEvent) => void;
|
||||
handleMouseDown: (ev: MouseEvent) => void;
|
||||
setHoverON: (ev: any) => void;
|
||||
setHoverOFF: (ev: any) => void;
|
||||
onMouseOut: (ev: any) => void;
|
||||
/**
|
||||
* 节点置顶,可以被某些不需要置顶的节点重写,如group节点。
|
||||
*/
|
||||
toFront(): void;
|
||||
render(): any;
|
||||
}
|
||||
export {};
|
||||
@@ -0,0 +1,5 @@
|
||||
import { h } from 'preact';
|
||||
import BaseNode from './BaseNode';
|
||||
export default class CircleNode extends BaseNode {
|
||||
getShape(): h.JSX.Element;
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
import { h } from 'preact';
|
||||
import BaseNode from './BaseNode';
|
||||
export default class DiamondNode extends BaseNode {
|
||||
getShape(): h.JSX.Element;
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
import { h } from 'preact';
|
||||
import BaseNode from './BaseNode';
|
||||
export default class EllipseNode extends BaseNode {
|
||||
getShape(): h.JSX.Element;
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
import { h } from 'preact';
|
||||
import BaseNode from './BaseNode';
|
||||
export default class HtmlNode extends BaseNode {
|
||||
ref: HTMLElement;
|
||||
currrentProperties: string;
|
||||
preProperties: string;
|
||||
setRef: (dom: any) => void;
|
||||
get rootEl(): HTMLElement;
|
||||
/**
|
||||
* @overridable 支持重写
|
||||
* 自定义HTML节点内容
|
||||
* @param {HTMLElement} rootEl 自定义HTML节点内容可以挂载的dom节点
|
||||
* @example
|
||||
* class CustomHtmlNode extends HtmlNode {
|
||||
* setHtml(rootEl) {
|
||||
* const input = document.createElement('input');
|
||||
* rootEl.appendChild(input)
|
||||
* }
|
||||
* }
|
||||
*/
|
||||
setHtml(rootEl: HTMLElement): void;
|
||||
/**
|
||||
* @overridable 支持重写
|
||||
* 和react的shouldComponentUpdate类似,都是为了避免出发不必要的render.
|
||||
* 但是这里不一样的地方在于,setHtml方法,我们只在properties发生变化了后再触发。
|
||||
* 而x,y等这些坐标相关的方法发生了变化,不会再重新触发setHtml.
|
||||
*/
|
||||
shouldUpdate(): boolean;
|
||||
componentDidMount(): void;
|
||||
componentDidUpdate(): void;
|
||||
getShape(): h.JSX.Element;
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
import { h } from 'preact';
|
||||
import BaseNode from './BaseNode';
|
||||
export default class PolygonNode extends BaseNode {
|
||||
getShape(): h.JSX.Element;
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
import { h } from 'preact';
|
||||
import BaseNode from './BaseNode';
|
||||
export default class RectNode extends BaseNode {
|
||||
getShape(): h.JSX.Element;
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
import { h } from 'preact';
|
||||
import BaseNode from './BaseNode';
|
||||
export default class TextNode extends BaseNode {
|
||||
getBackgroud(): h.JSX.Element;
|
||||
getShape(): h.JSX.Element;
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
import BaseNode from './BaseNode';
|
||||
import RectNode from './RectNode';
|
||||
import CircleNode from './CircleNode';
|
||||
import PolygonNode from './PolygonNode';
|
||||
import DiamondNode from './DiamondNode';
|
||||
import EllipseNode from './EllipseNode';
|
||||
import TextNode from './TextNode';
|
||||
import HtmlNode from './HtmlNode';
|
||||
export { BaseNode, RectNode, CircleNode, PolygonNode, DiamondNode, EllipseNode, TextNode, HtmlNode, };
|
||||
@@ -0,0 +1,28 @@
|
||||
import { h, Component } from 'preact';
|
||||
/**
|
||||
* 背景配置, 支持css属性配置
|
||||
* https://developer.mozilla.org/zh-CN/docs/Web/CSS/background
|
||||
* @example
|
||||
* {
|
||||
* backgroundImage: "url('./img/grid.svg')",
|
||||
backgroundRepeat: 'repeat',
|
||||
* }
|
||||
*/
|
||||
export declare type BackgroundConfig = {
|
||||
/**
|
||||
* 背景图片地址
|
||||
*/
|
||||
backgroundImage?: string;
|
||||
/**
|
||||
* 是否重复
|
||||
*/
|
||||
backgroundRepeat?: string;
|
||||
[key: string]: any;
|
||||
};
|
||||
declare type IProps = {
|
||||
background: BackgroundConfig;
|
||||
};
|
||||
export default class BackgroundOverlay extends Component<IProps> {
|
||||
render(): h.JSX.Element;
|
||||
}
|
||||
export {};
|
||||
@@ -0,0 +1,12 @@
|
||||
import { Component, h } from 'preact';
|
||||
import BezierEdgeModel from '../../model/edge/BezierEdgeModel';
|
||||
import GraphModel from '../../model/GraphModel';
|
||||
declare type IProps = {
|
||||
graphModel: GraphModel;
|
||||
};
|
||||
export default class BezierAdjustOverlay extends Component<IProps> {
|
||||
getBezierAdjust(bezier: BezierEdgeModel, graphModel: GraphModel): any[];
|
||||
selectedBezierEdge(): any[];
|
||||
render(): h.JSX.Element;
|
||||
}
|
||||
export {};
|
||||
@@ -0,0 +1,28 @@
|
||||
import { h, Component } from 'preact';
|
||||
import GraphModel from '../../model/GraphModel';
|
||||
import { StepDrag } from '../../util/drag';
|
||||
import Dnd from '../behavior/DnD';
|
||||
declare type IProps = {
|
||||
graphModel: GraphModel;
|
||||
dnd: Dnd;
|
||||
};
|
||||
declare type Istate = {
|
||||
isDraging: boolean;
|
||||
};
|
||||
declare class CanvasOverlay extends Component<IProps, Istate> {
|
||||
stepDrag: StepDrag;
|
||||
stepScrollX: number;
|
||||
stepScrollY: number;
|
||||
constructor(props: IProps);
|
||||
onDraging: ({ deltaX, deltaY }: {
|
||||
deltaX: any;
|
||||
deltaY: any;
|
||||
}) => void;
|
||||
onDragEnd: () => void;
|
||||
zoomHandler: (ev: WheelEvent) => void;
|
||||
clickHandler: (ev: MouseEvent) => void;
|
||||
handleContextMenu: (ev: MouseEvent) => void;
|
||||
mouseDownHandler: (ev: MouseEvent) => void;
|
||||
render(): h.JSX.Element;
|
||||
}
|
||||
export default CanvasOverlay;
|
||||
@@ -0,0 +1,30 @@
|
||||
import { h, Component } from 'preact';
|
||||
import GraphModel from '../../model/GraphModel';
|
||||
export declare type GridOptions = {
|
||||
/**
|
||||
* 网格格子间距
|
||||
*/
|
||||
size?: number;
|
||||
/**
|
||||
* 网格是否可见
|
||||
*/
|
||||
visible?: boolean;
|
||||
graphModel?: GraphModel;
|
||||
/**
|
||||
* 网格类型
|
||||
* 'dot' || 'mesh'
|
||||
*/
|
||||
type?: string;
|
||||
config?: {
|
||||
color: string;
|
||||
thickness?: number;
|
||||
};
|
||||
};
|
||||
declare type IProps = GridOptions;
|
||||
export default class Grid extends Component<IProps> {
|
||||
readonly id: string;
|
||||
renderDot(): h.JSX.Element;
|
||||
renderMesh(): h.JSX.Element;
|
||||
render(): h.JSX.Element;
|
||||
}
|
||||
export {};
|
||||
@@ -0,0 +1,15 @@
|
||||
/**
|
||||
* HtmlOverlay和CanvasOverlay放大,缩小,平移保持一致。
|
||||
* 但是这里是放的是HTML标签而不是SVG。
|
||||
* 目前这里可以放文本。
|
||||
* 之后可以考虑放图片,范围框等。
|
||||
*/
|
||||
import { h, Component } from 'preact';
|
||||
import GraphModel from '../../model/GraphModel';
|
||||
declare type IProps = {
|
||||
graphModel: GraphModel;
|
||||
};
|
||||
declare class HtmlOverlay extends Component<IProps> {
|
||||
render(): h.JSX.Element;
|
||||
}
|
||||
export default HtmlOverlay;
|
||||
@@ -0,0 +1,9 @@
|
||||
import { h, Component } from 'preact';
|
||||
import GraphModel from '../../model/GraphModel';
|
||||
declare type IProps = {
|
||||
graphModel: GraphModel;
|
||||
};
|
||||
export default class ModificationOverlay extends Component<IProps> {
|
||||
render(): h.JSX.Element;
|
||||
}
|
||||
export {};
|
||||
@@ -0,0 +1,17 @@
|
||||
import { Component, h } from 'preact';
|
||||
import { LineEdgeModel } from '../../model';
|
||||
import BezierEdgeModel from '../../model/edge/BezierEdgeModel';
|
||||
import PolylineEdgeModel from '../../model/edge/PolylineEdgeModel';
|
||||
import GraphModel from '../../model/GraphModel';
|
||||
declare type IProps = {
|
||||
graphModel: GraphModel;
|
||||
};
|
||||
export default class OutlineOverlay extends Component<IProps> {
|
||||
getNodesOutline(): any[];
|
||||
getEdgeOutline(): any[];
|
||||
getLineOutline(line: LineEdgeModel): h.JSX.Element;
|
||||
getPolylineOutline(polyline: PolylineEdgeModel): h.JSX.Element;
|
||||
getBezierOutline(bezier: BezierEdgeModel): h.JSX.Element;
|
||||
render(): h.JSX.Element;
|
||||
}
|
||||
export {};
|
||||
@@ -0,0 +1,9 @@
|
||||
import { h, Component } from 'preact';
|
||||
import SnaplineModel from '../../model/SnaplineModel';
|
||||
declare type IProps = {
|
||||
snaplineModel: SnaplineModel;
|
||||
};
|
||||
export default class SnaplineOverlay extends Component<IProps> {
|
||||
render(): h.JSX.Element;
|
||||
}
|
||||
export {};
|
||||
@@ -0,0 +1,15 @@
|
||||
import { h, Component } from 'preact';
|
||||
import GraphModel from '../../model/GraphModel';
|
||||
declare type IProps = {
|
||||
graphModel: GraphModel;
|
||||
tool: any;
|
||||
};
|
||||
export default class ToolOverlay extends Component<IProps> {
|
||||
setToolOverlayRef: (element: any) => void;
|
||||
/**
|
||||
* 外部传入的一般是HTMLElement
|
||||
*/
|
||||
getTools(): any;
|
||||
render(): h.JSX.Element;
|
||||
}
|
||||
export {};
|
||||
@@ -0,0 +1,34 @@
|
||||
import { h, ComponentType } from 'preact';
|
||||
import { GraphTransform } from '../../type';
|
||||
import GraphModel from '../../model/GraphModel';
|
||||
declare type IProps = {
|
||||
graphModel: GraphModel;
|
||||
};
|
||||
export default function getTransform<P>(WrappedComponent: ComponentType<P>): {
|
||||
new (props?: IProps & P, context?: any): {
|
||||
getMatrixString(): GraphTransform;
|
||||
render(): h.JSX.Element;
|
||||
componentWillMount?(): void;
|
||||
componentDidMount?(): void;
|
||||
componentWillUnmount?(): void;
|
||||
getChildContext?(): object;
|
||||
componentWillReceiveProps?(nextProps: Readonly<IProps & P>, nextContext: any): void;
|
||||
shouldComponentUpdate?(nextProps: Readonly<IProps & P>, nextState: Readonly<{}>, nextContext: any): boolean;
|
||||
componentWillUpdate?(nextProps: Readonly<IProps & P>, nextState: Readonly<{}>, nextContext: any): void;
|
||||
getSnapshotBeforeUpdate?(oldProps: Readonly<IProps & P>, oldState: Readonly<{}>): any;
|
||||
componentDidUpdate?(previousProps: Readonly<IProps & P>, previousState: Readonly<{}>, snapshot: any): void;
|
||||
componentDidCatch?(error: any, errorInfo: any): void;
|
||||
state: Readonly<{}>;
|
||||
props: import("preact").RenderableProps<IProps & P, any>;
|
||||
context: any;
|
||||
base?: Element | Text;
|
||||
setState<K extends never>(state: Partial<{}> | ((prevState: Readonly<{}>, props: Readonly<IProps & P>) => Partial<{}> | Pick<{}, K>) | Pick<{}, K>, callback?: () => void): void;
|
||||
forceUpdate(callback?: () => void): void;
|
||||
};
|
||||
displayName?: string;
|
||||
defaultProps?: any;
|
||||
contextType?: import("preact").Context<any>;
|
||||
getDerivedStateFromProps?(props: object, state: object): object;
|
||||
getDerivedStateFromError?(error: any): object;
|
||||
};
|
||||
export {};
|
||||
@@ -0,0 +1,29 @@
|
||||
import { h, Component } from 'preact';
|
||||
import GraphModel from '../../model/GraphModel';
|
||||
import { StepDrag } from '../../util/drag';
|
||||
import { IBaseModel } from '../../model/BaseModel';
|
||||
declare type IProps = {
|
||||
model: IBaseModel;
|
||||
graphModel: GraphModel;
|
||||
draggable: boolean;
|
||||
editable: boolean;
|
||||
};
|
||||
declare type IState = {
|
||||
isHoverd: boolean;
|
||||
};
|
||||
export default class BaseText extends Component<IProps, IState> {
|
||||
dragHandler: (ev: MouseEvent) => void;
|
||||
sumDeltaX: number;
|
||||
sumDeltaY: number;
|
||||
stepDrag: StepDrag;
|
||||
constructor(config: any);
|
||||
getShape(): h.JSX.Element;
|
||||
onDraging: ({ deltaX, deltaY }: {
|
||||
deltaX: any;
|
||||
deltaY: any;
|
||||
}) => void;
|
||||
dblClickHandler: () => void;
|
||||
mouseDownHandle: (ev: MouseEvent) => void;
|
||||
render(): h.JSX.Element;
|
||||
}
|
||||
export {};
|
||||
@@ -0,0 +1,9 @@
|
||||
import { h } from 'preact';
|
||||
import BaseText from './BaseText';
|
||||
export default class LineText extends BaseText {
|
||||
constructor(config: any);
|
||||
getBackgroud(): h.JSX.Element;
|
||||
setHoverON: () => void;
|
||||
setHoverOFF: () => void;
|
||||
getShape(): h.JSX.Element;
|
||||
}
|
||||
Reference in new issue
Block a user